tangxu
2022-10-26 8bf45c89968cd202558f06f180eee4f4a51d5d49
计划分析 增加 GetMonitorNameByTag函数
已修改6个文件
114 ■■■■ 文件已修改
Application/IStation.Application.OpenApi/shys/plan/PlanAna_ShysController.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.OpenApi/shys/plan/dto/PlanAnaDto.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.OpenApi/shys/plan/helper/PlanAnaBaseCalculator.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.OpenApi/shys/plan/shys/ShysHelper.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.OpenApi/shys/plan/shys/shys陈行一输.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.OpenApi/shys/plan/shys/shys陈行二输.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.OpenApi/shys/plan/PlanAna_ShysController.cs
@@ -10,6 +10,7 @@
using IStation.Calculation;
using IStation.Dto;
using System.Collections.Generic;
using Mapster;
namespace IStation.Application
{
@@ -63,7 +64,10 @@
            var responseText = System.IO.File.ReadAllText(path);//(测试用的)   
            var planDataList = JsonHelper.Json2Object<List<PlanAnaData>>(responseText);
            return CalculateCore(planDataList);
            var ret = CalculateCore(planDataList );
            return ret;
        }
        /// <summary>
@@ -71,37 +75,46 @@
        /// </summary>
        /// <param name="planDataList"></param>
        /// <returns></returns>
        private List<PlanAnaDto> CalculateCore(List<PlanAnaData> planDataList)
        private List<PlanAnaDto> CalculateCore(List<PlanAnaData> planDataList )
        {
            if (planDataList == null || planDataList.Count < 1)
            {
            {
                LogHelper.Error("上海原水能耗计划分析计算三高返回接口出参为空");
                return default;
            }
            if (planDataList.Exists(x => x.datas == null || x.datas.Count < 1))
            {
            {
                LogHelper.Error("上海原水能耗计划分析计算三高返回接口出参格式错误");
                return default;
            }
            var sg_factoryIds = planDataList.SelectMany(x => x.datas).Select(x => x.factory).Distinct().ToList();
            var vmList = new List<PlanAnaDto>();
            foreach (var sg_factoryId in sg_factoryIds)
            {
                var vmItem = Ana(planDataList, sg_factoryId);
                string error_info;
                var vmItem = Ana(planDataList, sg_factoryId,out error_info);
                if (vmItem != null)
                {
                    vmList.Add(vmItem);
                }
                else
                {
                    vmList.Add(new PlanAnaDto() { factory=sg_factoryId, name="", Error = error_info });
                }
            }
            return vmList;
        }
        private PlanAnaDto Ana(List<PlanAnaData> planDataList, int sg_factoryId)
        private PlanAnaDto Ana(List<PlanAnaData> planDataList, int sg_factoryId, out string error_info)
        {
            //找到相关泵站,并进行计算
            var stationInfo = ShysPlanHelper.GetStationInfo(sg_factoryId);
            if (stationInfo == null)
            {
                // LogHelper.Error("未找到id:{factoryId},对应的泵站");
                error_info = "未找到id:{factoryId},对应的泵站" ;
                return null;
            }
@@ -109,13 +122,13 @@
            var station = new Service.Station().GetByID(_corpId, stationId);
            if (station == null)
            {
                LogHelper.Error($"上海原水能耗计划分析计算中, æ³µç«™id:{stationId}, æ•°æ®åº“中未找到此泵站");
                error_info = $"泵站id:{stationId}, æ•°æ®åº“中未找到此泵站" ;
                return null;
            }
            var calculator = stationInfo.Calculator;
            if (calculator == null)
            {
                LogHelper.Error($"上海原水能耗计划分析计算中, æ³µç«™id:{stationId}, æœªæž„建计算器");
                error_info =  $"泵站id:{stationId}, æœªæž„建计算器" ;
                return null;
            }
            calculator.SetStationID(_corpId, stationInfo.ID);//设置ID
@@ -146,13 +159,13 @@
                                {
                                    scadaRecord.RecordValue = 0;
                                }
                                else if (calculator.Is液位Monitor(scadaItem.tagname))
                                {
                                    scadaRecord.RecordValue = 0;
                                }
                                //else if (calculator.Is液位Monitor(scadaItem.tagname))
                                //{
                                //    scadaRecord.RecordValue = 0;
                                //}
                                else
                                {
                                    LogHelper.Error($"上海原水能耗计划分析计算中, æ³µç«™id:{stationId}, {scadaItem.tagname} æ—¶é—´ç‚¹{i}, æœªæ‰¾åˆ°æ•°æ®");
                                    error_info = $"factoryId:{sg_factoryId}, æ³µç«™id:{stationId}, æµ‹è¯•tag:{scadaItem.tagname} ,测点名称{calculator.GetMonitorNameByTag(scadaItem.tagname)},时间点{i}, æœªæ‰¾åˆ°å¯¹åº”数据" ;
                                    return null;
                                }
                            }
@@ -169,11 +182,12 @@
                sumRecordList.Add(sumRecord);
            }
            string error_info = "";
            var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out error_info);
            string  ana_error_info = "";
            var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out ana_error_info);
            if (resultList == null || resultList.Count() < 1)
            {
                LogHelper.Error($"上海原水能耗计划分析计算中,泵站名称:{station.Name} æ³µç«™id:{stationId},计算错误,原因是:{error_info}");
                error_info = $"factoryId:{sg_factoryId},泵站名称:{station.Name} æ³µç«™id:{stationId},分析错误,原因是:{ana_error_info}";
                LogHelper.Error("上海原水能耗计划分析计算中,"+error_info);
                return null;
            }
@@ -194,7 +208,7 @@
                    vmItem.values.Add(new List<double>() { result.Qt, result.Dt, result.WP });
                }
            }
            error_info = null;
            return vmItem;
        }
Application/IStation.Application.OpenApi/shys/plan/dto/PlanAnaDto.cs
@@ -25,6 +25,11 @@
        /// 12个月数据数组[供水量,耗电量,千吨水能耗]
        /// </summary>
        public List<List<double>> values { get; set; }
        /// <summary>
        /// é”™è¯¯ä¿¡æ¯
        /// </summary>
        public  string Error { get; set; }
    }
  
}
Application/IStation.Application.OpenApi/shys/plan/helper/PlanAnaBaseCalculator.cs
@@ -51,6 +51,15 @@
        /// </summary>
        /// <param name="tagname"></param>
        /// <returns></returns>
        public virtual string GetMonitorNameByTag(string tagname)
        {
            return "未知测点";
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="tagname"></param>
        /// <returns></returns>
        public virtual bool IsIgnoreAble(string tagname)
        {
            return false;
@@ -93,7 +102,7 @@
                var daySum = this._dispatchAnaCalc.CalcSumData(allHourRequests,true, out error_info);
                if (daySum == null || daySum.Qt <= 0)
                {
                    error_info = "青草沙,调度分析失败,原因:" + error_info;
                    error_info = "调度分析失败,原因:" + error_info;
                    return null;
                }
                //计算每月的汇总
Application/IStation.Application.OpenApi/shys/plan/shys/ShysHelper.cs
@@ -32,11 +32,17 @@
        private static void Inital()
        {
            _dict = new Dictionary<int, StationInfo>();
            _dict.Add(1, new StationInfo(2, new IStation.Calculation.shys长兴泵站()));//OK
            _dict.Add(2, new StationInfo(12, new IStation.Calculation.shys五号沟凌桥方向()));//ok
            //_dict.Add(3, new StationInfo(9, new IStation.Calculation.shys五号沟金海方向()));
            _dict.Add(4, new StationInfo(3, new IStation.Calculation.shys五号沟严桥方向1()));//OK
            _dict.Add(5, new StationInfo(5, new IStation.Calculation.shys五号沟严桥方向2()));//OK
            // å‡ºæ°´æ€»ç®¡åŽ‹åŠ›, æ²¡æœ‰æ•°æ®
            _dict.Add(15, new StationInfo(19, new IStation.Calculation.shys金泽泵站()));
            //_dict.Add(1, new StationInfo(2, new IStation.Calculation.shys长兴泵站()));//OK
            //_dict.Add(2, new StationInfo(12, new IStation.Calculation.shys五号沟凌桥方向()));//ok
            //_dict.Add(4, new StationInfo(3, new IStation.Calculation.shys五号沟严桥方向1()));//OK
            //_dict.Add(5, new StationInfo(5, new IStation.Calculation.shys五号沟严桥方向2()));//OK
            ////_dict.Add(3, new StationInfo(9, new IStation.Calculation.shys五号沟金海方向()));
            //_dict.Add(6, new StationInfo(4, new IStation.Calculation.shys严桥泵站())); 
            //_dict.Add(7, new StationInfo(6, new IStation.Calculation.shys临江1号泵房())); 
            //_dict.Add(8, new StationInfo(7, new IStation.Calculation.shys临江2号泵房())); 
@@ -46,10 +52,10 @@
            //_dict.Add(12, new StationInfo(15, new IStation.Calculation.shys陈行一输())); 
            //_dict.Add(13, new StationInfo(16, new IStation.Calculation.shys陈行二输())); 
            //_dict.Add(14, new StationInfo(17, new IStation.Calculation.shys泰和泵站())); 
            //_dict.Add(15, new StationInfo(19, new IStation.Calculation.shys金泽泵站()));
            //
            //_dict.Add(16, new StationInfo(20, new IStation.Calculation.shys松江泵站())); 
            //_dict.Add(17, new StationInfo(21, new IStation.Calculation.shys大桥泵站())); 
            //    {1,2},//长兴泵站
            //    {2,12},//五号沟凌桥方向
@@ -68,7 +74,7 @@
            //    {15,19},//金泽泵站
            //    {16,20},//松江泵站
            //    {17,21},//大桥泵站
        }
        /// <summary>
Application/IStation.Application.OpenApi/shys/plan/shys/shys³ÂÐÐÒ»Êä.cs
@@ -17,8 +17,6 @@
        /// <summary>
        /// æµ‹ç‚¹å­—å…¸(这个每个泵站都不一样)
        /// </summary>
        private Tuple<string, long> monitor出水总管1压力 = new Tuple<string, long>("_0402010201090105001", 859);
        private Tuple<string, long> monitor出水总管1瞬时流量 = new Tuple<string, long>("_0402060601010103000", 860);
        private Tuple<string, long> monitor出水总管2压力 = new Tuple<string, long>("_0402010201090105002", 862);
@@ -28,6 +26,7 @@
        private Tuple<string, long> monitor进水前池液位1 = new Tuple<string, long>("_0402010201090104011", 856);
        private Tuple<string, long> monitor进水前池液位2 = new Tuple<string, long>("_0402010201091104123", 857);
        private Tuple<string, long> monitor进水前池液位3 = new Tuple<string, long>("_0402010201091104122", 858);
        /// <summary>
        /// æ ¹æ®ä¸‰é«˜æä¾›çš„参数,构建调度分析所需的参数, (这个每个泵站都不一样)
        /// </summary>
Application/IStation.Application.OpenApi/shys/plan/shys/shys³ÂÐжþÊä.cs
@@ -17,13 +17,32 @@
        /// <summary>
        /// æµ‹ç‚¹å­—å…¸(这个每个泵站都不一样)
        /// </summary>
        private Tuple<string, long> monitor出水总管1压力 = new Tuple<string, long>("_0402010201090105004", 917);
        private Tuple<string, long> monitor出水总管1瞬时流量 = new Tuple<string, long>("_0402010201090103020", 918);
        private Tuple<string, long> monitor出水总管2压力 = new Tuple<string, long>("_0402010201090105003", 920);
        private Tuple<string, long> monitor出水总管2瞬时流量 = new Tuple<string, long>("_0402010201090103017", 921);
        private Tuple<string, long> monitor进水前池液位 = new Tuple<string, long>("_0402010201080204002", 916);
        public override bool Is液位Monitor(string tagname)
        {
            if (monitor进水前池液位.Item1 == tagname)
                return true;
            return false ;
        }
        public override string GetMonitorNameByTag(string tagname)
        {
            if (monitor出水总管1压力.Item1 == tagname)
                return "出水总管1压力";
            if (monitor出水总管1瞬时流量.Item1 == tagname)
                return "出水总管1瞬时流量";
            if (monitor出水总管2压力.Item1 == tagname)
                return "出水总管2压力";
            if (monitor出水总管2瞬时流量.Item1 == tagname)
                return "出水总管2瞬时流量";
            return "未知测点";
        }
        /// <summary>
        /// æ ¹æ®ä¸‰é«˜æä¾›çš„参数,构建调度分析所需的参数, (这个每个泵站都不一样)
        /// </summary>