| | |
| | | } |
| | | } |
| | | |
| | | //通过 CurveIds 更新缓存 |
| | | internal void UpdateCorpCacheByCurveID(long CorpID, List<long> CurveIds) |
| | | { |
| | | if (CurveIds == null || CurveIds.Count < 1) |
| | | return; |
| | | var dal = new DAL.PumpCurveMapping(); |
| | | var entity_list = dal.GetByCurveIds(CorpID, CurveIds); |
| | | var model_list = Entity2Models(entity_list); |
| | | var all = GetCorpCache(CorpID); |
| | | all.RemoveAll(x => CurveIds.Contains(x.CurveID)); |
| | | if (model_list != null && model_list.Count > 0) |
| | | { |
| | | all.AddRange(model_list); |
| | | } |
| | | } |
| | | |
| | | //通过 CurveID 移除缓存 |
| | | internal void RemoveCorpCacheByCurveID(long CorpID, long CurveID) |
| | | { |
| | |
| | | var all = GetByCorpID(CorpID); |
| | | return all?.Where(x => x.CurveID == CurveID).OrderBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 通过 CurveIds 获取 |
| | |
| | | /// <summary> |
| | | /// 设置 CurveID 泵曲线映射 |
| | | /// </summary> |
| | | public bool SetOfCurveID(long CorpID, long CurveID, List<Model.PumpCurveMapping> list) |
| | | public bool SetByCurveID(long CorpID, long CurveID, List<Model.PumpCurveMapping> list) |
| | | { |
| | | var dal = new DAL.PumpCurveMapping(); |
| | | if (list != null && list.Count > 0) |
| | | { |
| | | var update_working_list = list.FindAll(x => x.IsWorking).ToList(); |
| | | if (update_working_list != null && update_working_list.Count > 0) |
| | | if (list.GroupBy(x => x.PumpID).Count() > 0) |
| | | return false; |
| | | var allCurveMappingList = GetCorpCache(CorpID); |
| | | var updateWorkingList = list.FindAll(x => x.IsWorking).ToList(); |
| | | if (updateWorkingList != null && updateWorkingList.Count > 0) |
| | | { |
| | | foreach (var working_curve in update_working_list) |
| | | foreach (var workingMapping in updateWorkingList) |
| | | { |
| | | var relevant_pump_curve_list = GetByPumpID(CorpID, working_curve.PumpID); |
| | | if (relevant_pump_curve_list == null || relevant_pump_curve_list.Count < 1) |
| | | var relevantPumpCurveMappingList = allCurveMappingList.Where(x => x.PumpID == workingMapping.PumpID).ToList(); |
| | | if (relevantPumpCurveMappingList == null || relevantPumpCurveMappingList.Count < 1) |
| | | continue; |
| | | var exist_working_curve_list = relevant_pump_curve_list.FindAll(x => x.IsWorking); |
| | | if (exist_working_curve_list == null || exist_working_curve_list.Count < 1) |
| | | var existWorkingMappingList = relevantPumpCurveMappingList.Where(x => x.IsWorking && x.ID != workingMapping.ID).ToList(); |
| | | if (existWorkingMappingList == null || existWorkingMappingList.Count < 1) |
| | | continue; |
| | | exist_working_curve_list.ForEach(x => x.IsWorking = false); |
| | | list.AddRange(exist_working_curve_list); |
| | | existWorkingMappingList.ForEach(x => x.IsWorking = false); |
| | | list.AddRange(existWorkingMappingList); |
| | | } |
| | | } |
| | | } |
| | | var entity_list = Model2Entities(list.ToList()); |
| | | var bol = dal.SetOfCurveID(CorpID, CurveID, entity_list); |
| | | var bol = dal.SetByCurveID(CorpID, CurveID, entity_list); |
| | | if (bol) |
| | | { |
| | | UpdateCorpCacheByCurveID(CorpID, CurveID); |
| | | var other_pump_curve_list = entity_list.Where(x => x.CurveID != CurveID).ToList(); |
| | | if (other_pump_curve_list != null && other_pump_curve_list.Count > 0) |
| | | { |
| | | UpdateCorpCache(CorpID, other_pump_curve_list.Select(x => x.ID).ToList()); |
| | | } |
| | | var curveIds = list.Select(x => x.CurveID).Distinct().ToList(); |
| | | UpdateCorpCacheByCurveID(CorpID, curveIds); |
| | | } |
| | | return bol; |
| | | } |