From 84da5576a7cc88a7cffaea5cfe14eeff8b999e02 Mon Sep 17 00:00:00 2001
From: tangxu <76880903@qq.com>
Date: 星期一, 24 十月 2022 20:30:45 +0800
Subject: [PATCH] youhua

---
 Application/IStation.Application.OpenApi/shys/plan/PlanAna_ShysController.cs   |  194 +++++++++++++++++++++++++-----------------------
 Calculation/IStation.Calculation.Dispatch/helper/DispatchAnaGeneralHelper压力.cs |    2 
 2 files changed, 102 insertions(+), 94 deletions(-)

diff --git a/Application/IStation.Application.OpenApi/shys/plan/PlanAna_ShysController.cs b/Application/IStation.Application.OpenApi/shys/plan/PlanAna_ShysController.cs
index 6822e92..7616b7a 100644
--- a/Application/IStation.Application.OpenApi/shys/plan/PlanAna_ShysController.cs
+++ b/Application/IStation.Application.OpenApi/shys/plan/PlanAna_ShysController.cs
@@ -87,106 +87,112 @@
             var vmList = new List<PlanAnaDto>();
             foreach (var sg_factoryId in sg_factoryIds)
             {
-                //鎵惧埌鐩稿叧娉电珯锛屽苟杩涜璁$畻
-                var stationInfo = ShysPlanHelper.GetStationInfo(sg_factoryId);
-                if (stationInfo == null)
-                {
-                   // LogHelper.Error("鏈壘鍒癷d:{factoryId},瀵瑰簲鐨勬车绔�");
-                    continue;
-                }
- 
-                var stationId = stationInfo.ID;
-                var station = new Service.Station().GetByID(_corpId, stationId);
-                if (station == null)
-                {
-                    LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛� 娉电珯id:{stationId}, 鏁版嵁搴撲腑鏈壘鍒版娉电珯");
-                    continue;
-                }
-                var calculator = stationInfo.Calculator;
-                if (calculator == null)
-                {
-                    LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛� 娉电珯id:{stationId}, 鏈瀯寤鸿绠楀櫒");
-                    continue;
-                }
-                calculator.SetStationID(4, stationInfo.ID);//璁剧疆ID
-
-                //鏋勯�犺绠楀叆鍙�
-                var sumRecordList = new List<MonthSumRecord>();
-                foreach (var planData in planDataList)
-                {
-                    var sumRecord = new MonthSumRecord();
-                    sumRecord.Month = planData.timeflag;
-                    sumRecord.HourRecords = new List<HourSumRecord>();
-                    var factoryData = planData.datas.Find(t => t.factory == sg_factoryId);
-                    for (int i = 0; i <= 23; i++)
-                    {
-                        var hourSumRecord = new HourSumRecord();
-                        hourSumRecord.Hour = i;
-                        hourSumRecord.Records = new List<Dto.MonitorRecord4SG>();
-                        if (factoryData.scada != null && factoryData.scada.Count > 0)
-                        {
-                            foreach (var scadaItem in factoryData.scada)
-                            {
-                                var scadaRecord = new Dto.MonitorRecord4SG();
-                                scadaRecord.MonitorTag =  scadaItem.tagname ;
-                                var ff = scadaItem.values.Find(t => t.GetHour() ==  i );
-                                if(ff == null)
-                                {
-                                    if (calculator.Is娑蹭綅Monitor(scadaItem.tagname))
-                                    {
-                                        scadaRecord.RecordValue = 0;
-                                    }
-                                    else
-                                    {
-                                        LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛� 娉电珯id:{stationId}, {scadaItem.tagname} 鏃堕棿鐐箋i}, 鏈壘鍒版暟鎹�");
-                                        return default;
-                                    }
-
-                                }
-                                else
-                                {
-                                    scadaRecord.RecordValue = ff.value;
-                                }
-                              
-                                hourSumRecord.Records.Add(scadaRecord);
-                            }
-                        }
-                        sumRecord.HourRecords.Add(hourSumRecord);
-                    }
-                    sumRecordList.Add(sumRecord);
-                }
-
-                string error_info="";
-                var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out error_info);
-                if (resultList == null || resultList.Count() < 1)
-                {
-                    LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛屾车绔欏悕绉�:{station.Name} 娉电珯id:{stationId},璁$畻閿欒,鍘熷洜鏄�:{error_info}"  );
-                    continue;
-                }
-
-                //鐢熸垚杩斿洖缁撴灉
-                var vmItem = new PlanAnaDto();
-                vmItem.factory = sg_factoryId;
-                vmItem.name = station.Name;
-                vmItem.values = new List<List<double>>();
-                for (int i = 1; i <= 12; i++)
-                {
-                    var result = resultList.Find(t => t.Month == i);
-                    if (result == null)
-                    {
-                        vmItem.values.Add(new List<double>() { 0, 0, 0 });
-                    }
-                    else
-                    {
-                        vmItem.values.Add(new List<double>() { result.Qt, result.Dt, result.WP });
-                    }
-                }
+                var vmItem = Ana(planDataList, sg_factoryId);
+                if(vmItem != null)
                 vmList.Add(vmItem);
             }
             return vmList;
         }
 
+        private PlanAnaDto Ana(List<PlanAnaData> planDataList, int sg_factoryId)
+        {
+            //鎵惧埌鐩稿叧娉电珯锛屽苟杩涜璁$畻
+            var stationInfo = ShysPlanHelper.GetStationInfo(sg_factoryId);
+            if (stationInfo == null)
+            {
+                // LogHelper.Error("鏈壘鍒癷d:{factoryId},瀵瑰簲鐨勬车绔�");
+                return null ;
+            }
 
+            var stationId = stationInfo.ID;
+            var station = new Service.Station().GetByID(_corpId, stationId);
+            if (station == null)
+            {
+                LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛� 娉电珯id:{stationId}, 鏁版嵁搴撲腑鏈壘鍒版娉电珯");
+                return null;
+            }
+            var calculator = stationInfo.Calculator;
+            if (calculator == null)
+            {
+                LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛� 娉电珯id:{stationId}, 鏈瀯寤鸿绠楀櫒");
+                return null;
+            }
+            calculator.SetStationID(4, stationInfo.ID);//璁剧疆ID
+
+            //鏋勯�犺绠楀叆鍙�
+            var sumRecordList = new List<MonthSumRecord>();
+            foreach (var planData in planDataList)
+            {
+                var sumRecord = new MonthSumRecord();
+                sumRecord.Month = planData.timeflag;
+                sumRecord.HourRecords = new List<HourSumRecord>();
+                var factoryData = planData.datas.Find(t => t.factory == sg_factoryId);
+                for (int i = 0; i <= 23; i++)
+                {
+                    var hourSumRecord = new HourSumRecord();
+                    hourSumRecord.Hour = i;
+                    hourSumRecord.Records = new List<Dto.MonitorRecord4SG>();
+                    if (factoryData.scada != null && factoryData.scada.Count > 0)
+                    {
+                        foreach (var scadaItem in factoryData.scada)
+                        {
+                            var scadaRecord = new Dto.MonitorRecord4SG();
+                            scadaRecord.MonitorTag = scadaItem.tagname;
+                            var ff = scadaItem.values.Find(t => t.GetHour() == i);
+                            if (ff == null)
+                            {
+                                if (calculator.Is娑蹭綅Monitor(scadaItem.tagname))
+                                {
+                                    scadaRecord.RecordValue = 0;
+                                }
+                                else
+                                {
+                                    LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛� 娉电珯id:{stationId}, {scadaItem.tagname} 鏃堕棿鐐箋i}, 鏈壘鍒版暟鎹�");
+                                    return null;
+                                }
+
+                            }
+                            else
+                            {
+                                scadaRecord.RecordValue = ff.value;
+                            }
+
+                            hourSumRecord.Records.Add(scadaRecord);
+                        }
+                    }
+                    sumRecord.HourRecords.Add(hourSumRecord);
+                }
+                sumRecordList.Add(sumRecord);
+            }
+
+            string error_info = "";
+            var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out error_info);
+            if (resultList == null || resultList.Count() < 1)
+            {
+                LogHelper.Error($"涓婃捣鍘熸按鑳借�楄鍒掑垎鏋愯绠椾腑锛屾车绔欏悕绉�:{station.Name} 娉电珯id:{stationId},璁$畻閿欒,鍘熷洜鏄�:{error_info}");
+                return null;
+            }
+
+            //鐢熸垚杩斿洖缁撴灉
+            var vmItem = new PlanAnaDto();
+            vmItem.factory = sg_factoryId;
+            vmItem.name = station.Name;
+            vmItem.values = new List<List<double>>();
+            for (int i = 1; i <= 12; i++)
+            {
+                var result = resultList.Find(t => t.Month == i);
+                if (result == null)
+                {
+                    vmItem.values.Add(new List<double>() { 0, 0, 0 });
+                }
+                else
+                {
+                    vmItem.values.Add(new List<double>() { result.Qt, result.Dt, result.WP });
+                }
+            }
+
+            return vmItem;
+        }
 
 
 
diff --git "a/Calculation/IStation.Calculation.Dispatch/helper/DispatchAnaGeneralHelper\345\216\213\345\212\233.cs" "b/Calculation/IStation.Calculation.Dispatch/helper/DispatchAnaGeneralHelper\345\216\213\345\212\233.cs"
index a3d5ad0..818e030 100644
--- "a/Calculation/IStation.Calculation.Dispatch/helper/DispatchAnaGeneralHelper\345\216\213\345\212\233.cs"
+++ "b/Calculation/IStation.Calculation.Dispatch/helper/DispatchAnaGeneralHelper\345\216\213\345\212\233.cs"
@@ -1203,6 +1203,8 @@
             //    AddMultiFreqPumpPrj6(null, freqPumpAnaList, 0);
             //}
         }
+
+    
         #endregion
 
 

--
Gitblit v1.9.3