From 41a59b8098446c595ce42d78a279123a4bfa6795 Mon Sep 17 00:00:00 2001 From: ningshuxia <ningshuxia0927@outlook.com> Date: 星期五, 12 八月 2022 14:38:20 +0800 Subject: [PATCH] 增加 泵曲线映射批量操作接口 --- Service/IStation.Service4Product/pump_curve/pump_curve_mapping/PumpCurveMapping.cs | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Service/IStation.Service4Product/pump_curve/pump_curve_mapping/PumpCurveMapping.cs b/Service/IStation.Service4Product/pump_curve/pump_curve_mapping/PumpCurveMapping.cs index 422e9c6..7ac1d77 100644 --- a/Service/IStation.Service4Product/pump_curve/pump_curve_mapping/PumpCurveMapping.cs +++ b/Service/IStation.Service4Product/pump_curve/pump_curve_mapping/PumpCurveMapping.cs @@ -114,6 +114,20 @@ } } + //閫氳繃 CurveID 鏇存柊缂撳瓨 + internal void UpdateCorpCacheByCurveID(long CorpID, long CurveID) + { + var dal = new DAL.PumpCurveMapping(); + var entity_list = dal.GetByCurveID(CorpID, CurveID); + var model_list = Entity2Models(entity_list); + var all = GetCorpCache(CorpID); + all.RemoveAll(x => x.CurveID == CurveID); + if (model_list != null && model_list.Count > 0) + { + all.AddRange(model_list); + } + } + //閫氳繃 CurveID 绉婚櫎缂撳瓨 internal void RemoveCorpCacheByCurveID(long CorpID, long CurveID) { @@ -453,5 +467,46 @@ #endregion + + #region Set + + /// <summary> + /// 璁剧疆 CurveID 娴嬬偣鏄犲皠 + /// </summary> + public bool SetOfObject(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) + { + foreach (var working_curve in update_working_list) + { + var relevant_pump_curve_list = GetByPumpID(CorpID, working_curve.PumpID); + if (relevant_pump_curve_list == null || relevant_pump_curve_list.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) + continue; + exist_working_curve_list.ForEach(x => x.IsWorking = false); + list.AddRange(exist_working_curve_list); + } + } + } + var entity_list = Model2Entities(list.ToList()); + var bol = dal.SetOfObject(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()); + } + } + return bol; + } + #endregion } } -- Gitblit v1.9.3