tangxu
2022-10-09 055084a369abc0d03a41b495c955d95a64852fb5
Application/IStation.Application.OpenApi/shys/plan/shys/shys³¤Ð˱ÃÕ¾.cs
@@ -6,119 +6,106 @@
namespace IStation.Calculation
{
    internal class shys长兴泵站: PlanAnaCalculator
    internal class shys长兴泵站: PlanAnaBaseCalculator
    { 
        public shys长兴泵站( )
        {
            this._dispatchAnaCalc = new IStation.Calculation.DispatchAna.Calculator_OptAna_SHYS_长兴岛();
        }
        protected override List<IStation.Calculation.DispatchAna.Model.HourRequest> BuildHourRequest(
            List<IStation.Dto.HourSumRecord> HourSumRecords,
            out string error_info)
        {
            List<IStation.Calculation.DispatchAna.Model.HourRequest> HourRequests = new List<DispatchAna.Model.HourRequest>();
            for (int i = 0; i <= 23; i++)
            {
                var hourSumRecord = new IStation.Calculation.DispatchAna.Model.HourRequest();
                hourSumRecord.Hour = i;
                hourSumRecord.Request = new DispatchAna.Model.RequestParasComplex();
                var Records = HourSumRecords[i].Records;
                var water_level = Records.Find(x => x.MonitorTag == monitor泵站前池液位.Item1);
                if(water_level  == null)
                {
                    water_level = Records.Find(x => x.MonitorTag == monitor青草沙水库液位.Item1);
                    if (water_level == null)
                    {
                        error_info = "青草沙水库液位测点未找到";
                        return HourRequests;
                    }
                }
                var pipe1_flow = Records.Find(x => x.MonitorTag == monitor水管道1流量.Item1);
                if (pipe1_flow == null)
                {
                    error_info = "青草沙水管道1流量测点未找到";
                    return HourRequests;
                }
                var pipe1_press = Records.Find(x => x.MonitorTag == monitor水管道1压力.Item1);
                if (pipe1_press == null)
                {
                    error_info = "青草沙水管道1压力测点未找到";
                    return HourRequests;
                }
                var pipe2_flow = Records.Find(x => x.MonitorTag == monitor水管道2流量.Item1);
                if (pipe2_flow == null)
                {
                    error_info = "青草沙水管道2流量测点未找到";
                    return HourRequests;
                }
                var pipe2_press = Records.Find(x => x.MonitorTag == monitor水管道2压力.Item1);
                if (pipe2_press == null)
                {
                    error_info = "青草沙水管道2压力测点未找到";
                    return HourRequests;
                }
                hourSumRecord.Request.CorpID = 4;
                hourSumRecord.Request.StationID = 2;
                hourSumRecord.Request.SchemeNumber = 1;
                hourSumRecord.Request.PressValueType = DispatchAna.Model.RequestParasComplex.ePressValueType.压力;
                hourSumRecord.Request.WaterLevelPara = new List<DispatchAna.Model.WaterLevelPara>()
                        {
                            new DispatchAna.Model.WaterLevelPara(){ Name="æ°´æ± ", Value = water_level.RecordValue}
                        };
                hourSumRecord.Request.OutletPipePara = new List<DispatchAna.Model.OutletPipePara>();
                hourSumRecord.Request.OutletPipePara.Add(new DispatchAna.Model.OutletPipePara()
                {
                    Name = "一号管路",
                    TargetFlow = pipe1_flow.RecordValue,
                    TargetPress = pipe1_press.RecordValue,
                });
                hourSumRecord.Request.OutletPipePara.Add(new DispatchAna.Model.OutletPipePara()
                {
                    Name = "二号管路",
                    TargetFlow = pipe2_flow.RecordValue,
                    TargetPress = pipe2_press.RecordValue,
                });
                hourSumRecord.Request.ValvePara = new List<DispatchAna.Model.ValvePara>();
                hourSumRecord.Request.ValvePara.Add(new DispatchAna.Model.ValvePara() { Name = "中间阀门", OpenStatus = 0 });
                //if (factoryData.result != null && factoryData.result.Count > 0)
                //{
                //    foreach (var resultItem in factoryData.result)
                //    {
                //        var resultRecord = new Calculation.PlanAna.MonitorRecord();
                //        resultRecord.MonitorId = PlanAnaConstant.MonitorDict[resultItem.tagname];
                //        resultRecord.RecordValue = resultItem.values.Find(t => t.datetime.Trim() == PlanAnaConstant.HourDict[i]).value;
                //        hourSumRecord.Records.Add(resultRecord);
                //    }
                HourRequests.Add(hourSumRecord);
            }
            error_info = null;
            return HourRequests;
        }
        /// <summary>
        /// æµ‹ç‚¹å­—å…¸
        /// æµ‹ç‚¹å­—å…¸(这个每个泵站都不一样)
        /// </summary>
        private Tuple<string, long> monitor青草沙水库液位 = new Tuple<string, long>("_0402010403030103001", 69);
        private Tuple<string, long> monitor水库液位 = new Tuple<string, long>("_0402010403030103001", 69);
        private Tuple<string, long> monitor泵站前池液位 = new Tuple<string, long>("_0402010404030103001", 70);
        private Tuple<string, long> monitor水管道1流量 = new Tuple<string, long>("_0402010403030002001", 73);
        private Tuple<string, long> monitor水管道1压力 = new Tuple<string, long>("_0402010403030002005", 72);
        private Tuple<string, long> monitor水管道2流量 = new Tuple<string, long>("_0402010403030002002", 77);
        private Tuple<string, long> monitor水管道2压力 = new Tuple<string, long>("_0402010403030002006", 76);
        //{"_0402010403030103001",69},//青草沙水库液位
        //    {"_0402010404030103001",70},//青草沙水库吸水井液位-长兴泵站前池液位
        //    {"_0402010403030002001",73},//长兴泵站输水泵出水管道1流量
        //    {"_0402010403030002005",72},//长兴泵站输水管道1#压力
        //    {"_0402010403030002002",77},//长兴泵站输水泵出水管道2流量
        //    {"_0402010403030002006",76},//长兴泵站输水管道2#压力
        //};
        /// <summary>
        /// æ ¹æ®ä¸‰é«˜æä¾›çš„参数,构建调度分析所需的参数, (这个每个泵站都不一样)
        /// </summary>
        /// <param name="allRecords_hour"></param>
        /// <param name="error_info"></param>
        /// <returns></returns>
        protected override DispatchAna.Model.RequestParasComplex BuildDispatchAnaRequest(
            List<IStation.Dto.MonitorRecord4SG> allRecords_hour,
            out string error_info)
        {
            if(allRecords_hour == null || allRecords_hour.Count == 0)
            {
                error_info = "青草沙测点数据为空";
                return null;
            }
            var complex_dispatch_request = new DispatchAna.Model.RequestParasComplex();
            var water_level = allRecords_hour.Find(x => x.MonitorTag == monitor泵站前池液位.Item1);
            if (water_level == null)
            {
                water_level = allRecords_hour.Find(x => x.MonitorTag == monitor水库液位.Item1);
                if (water_level == null)
                {
                    error_info = "青草沙水库液位测点未找到";
                    return null;
                }
            }
            var pipe1_flow = allRecords_hour.Find(x => x.MonitorTag == monitor水管道1流量.Item1);
            if (pipe1_flow == null)
            {
                error_info = "青草沙水管道1流量测点未找到";
                return null;
            }
            var pipe1_press = allRecords_hour.Find(x => x.MonitorTag == monitor水管道1压力.Item1);
            if (pipe1_press == null)
            {
                error_info = "青草沙水管道1压力测点未找到";
                return null;
            }
            var pipe2_flow = allRecords_hour.Find(x => x.MonitorTag == monitor水管道2流量.Item1);
            if (pipe2_flow == null)
            {
                error_info = "青草沙水管道2流量测点未找到";
                return null;
            }
            var pipe2_press = allRecords_hour.Find(x => x.MonitorTag == monitor水管道2压力.Item1);
            if (pipe2_press == null)
            {
                error_info = "青草沙水管道2压力测点未找到";
                return null;
            }
            complex_dispatch_request.CorpID = this._corpID;
            complex_dispatch_request.StationID = this._stationID;
            complex_dispatch_request.SchemeNumber = 1;
            complex_dispatch_request.PressValueType = DispatchAna.Model.RequestParasComplex.ePressValueType.压力;
            complex_dispatch_request.WaterLevelPara = new List<DispatchAna.Model.WaterLevelPara>()
                        {
                            new DispatchAna.Model.WaterLevelPara(){ Name="æ°´æ± ", Value = water_level.RecordValue}
                        };
            complex_dispatch_request.OutletPipePara = new List<DispatchAna.Model.OutletPipePara>();
            complex_dispatch_request.OutletPipePara.Add(new DispatchAna.Model.OutletPipePara()
            {
                Name = "一号管路",
                TargetFlow = pipe1_flow.RecordValue,
                TargetPress = pipe1_press.RecordValue,
            });
            complex_dispatch_request.OutletPipePara.Add(new DispatchAna.Model.OutletPipePara()
            {
                Name = "二号管路",
                TargetFlow = pipe2_flow.RecordValue,
                TargetPress = pipe2_press.RecordValue,
            });
            complex_dispatch_request.ValvePara = new List<DispatchAna.Model.ValvePara>();
            complex_dispatch_request.ValvePara.Add(new DispatchAna.Model.ValvePara() { Name = "中间阀门", OpenStatus = 0 });
            error_info = null;
            return complex_dispatch_request;
        }
    }
}