tangxu
2023-04-12 ac2a648ea67669eab6de9a1864c07f6475511dd2
Merge branch 'master' of http://47.103.154.90:83/r/IStation/Service.V4.1
已修改1个文件
83 ■■■■■ 文件已修改
Application/IStation.Application.OpenApi/shys/dispatch/DispatchAna_ShysController.cs 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.OpenApi/shys/dispatch/DispatchAna_ShysController.cs
@@ -17,7 +17,7 @@
    /// </summary>
    [Route("OpenApi/DispatchAna/SHYS")]
    [ApiDescriptionSettings("OpenApi", Name = "上海原水调度分析", Order = 1000)]
    public class DispatchAna_ShysController : IDynamicApiController
    public class DispatchAna_ShysController : IDynamicApiController
    {
        /// <summary>
        /// 计算保持的方案
@@ -30,10 +30,20 @@
        {
            if (input == null)
                return default;
            LogHelper.Debug(JsonHelper.Object2Json(input));
            //众毅连续两次调用解决方案
            if (!string.IsNullOrEmpty(_lastFlowId))
            {
                if (_lastFlowId == input.flowId)
                {
                    LogHelper.Debug($"众毅重复入参:{JsonHelper.Object2Json(input)}");
                    return default;
                }
            }
            _lastFlowId = input.flowId;
            LogHelper.Debug($"众毅入参:{JsonHelper.Object2Json(input)}");
            var url_sg = Settings.WebApi.OpenApi.SanGaoDispatchUrl;
            var responseText = HttpRequestHelper.Post(url_sg,JsonHelper.Object2Json(input));
            LogHelper.Debug(responseText);
            var responseText = HttpRequestHelper.Post(url_sg, JsonHelper.Object2Json(input));
            LogHelper.Debug($"三高出参:{responseText}");
            var result_sg = JsonHelper.Json2Object<DispatchFactoryDto>(responseText);
            if (result_sg == null)
                return default;
@@ -42,13 +52,14 @@
            {
                case 1://长兴泵站
                    {
                        var result= shys_cxd(input, result_sg,out error_info);
                        //LogHelper.Debug(JsonHelper.Object2Json(result));
                        var result = shys_cxd(input, result_sg, out error_info);
                        LogHelper.Debug($"义维出参:{JsonHelper.Object2Json(result)}");
                        return result;
                    }
                default:return default;
                default: return default;
            }
        }
        private static string _lastFlowId = null;
        /// <summary>
        /// 计算保持的方案
@@ -117,16 +128,16 @@
            var input = new StationDispatchExInput();
            input.flowId = "测试";
            input.type = 1;
            input.factory = new List<FactoryDispatchInput>() { new FactoryDispatchInput() { id=1,value=200} };
            input.factory = new List<FactoryDispatchInput>() { new FactoryDispatchInput() { id = 1, value = 200 } };
            var result_sg = new DispatchFactoryDto();
            result_sg.result = new List<DispatchBranchDto>();
            result_sg.result.Add(new DispatchBranchDto() { key= "stationCX_1#_flow",value= flow1 });
            result_sg.result.Add(new DispatchBranchDto() { key = "stationCX_1#_flow", value = flow1 });
            result_sg.result.Add(new DispatchBranchDto() { key = "stationCX_1#_pressure", value = press1 });
            result_sg.result.Add(new DispatchBranchDto() { key = "stationCX_2#_flow", value = flow2 });
            result_sg.result.Add(new DispatchBranchDto() { key = "stationCX_2#_pressure", value = press2 });
            result_sg.scada = new List<DispatchScadaDto>();
            result_sg.scada.Add(new DispatchScadaDto() {tagname= "_0402010404030103001",value=waterLevel });
            result_sg.scada.Add(new DispatchScadaDto() { tagname = "_0402010404030103001", value = waterLevel });
            result_sg.scada.Add(new DispatchScadaDto() { tagname = "_0402010403150103003", value = middleValveStatus });
            result_sg.scada.Add(new DispatchScadaDto() { tagname = "_0402010403010101003", value = runStatus1 });
            result_sg.scada.Add(new DispatchScadaDto() { tagname = "_0402010403010201003", value = runStatus2 });
@@ -176,11 +187,13 @@
            {
                water_level = scada_water.value;
            }
            complex_request_paras.InletPipePara = new List<IStation.Calculation.DispatchAna.Model.InletPipePara>();
            complex_request_paras.InletPipePara.Add(new IStation.Calculation.DispatchAna.Model.InletPipePara() {
                Name = "吸水井液位",
                Value = water_level });
            complex_request_paras.InletPipePara.Add(new IStation.Calculation.DispatchAna.Model.InletPipePara()
            {
                Name = "吸水井液位",
                Value = water_level
            });
@@ -191,7 +204,7 @@
                middleValveStatus = (int)scada_middle_vavle.value;
            complex_request_paras.ValvePara = new List<IStation.Calculation.DispatchAna.Model.ValvePara>();
            complex_request_paras.ValvePara.Add(new IStation.Calculation.DispatchAna.Model.ValvePara() { Name = "中间阀门", OpenStatus = middleValveStatus });
            //机泵 开停机状态
            List<long> machine_id_array = new List<long> { 19, 22, 25, 28 };
@@ -200,7 +213,7 @@
            var scada_runstatus1 = result_sg.scada.Find(t => t.tagname == "_0402010403010101003");
            if (scada_runstatus1 != null && (int)scada_runstatus1.value == 1)
                machine_run_status.Add(machine_id_array[0]);
            //2号泵开机状态
            var scada_runstatus2 = result_sg.scada.Find(t => t.tagname == "_0402010403010201003");
            if (scada_runstatus2 != null && (int)scada_runstatus2.value == 1)
@@ -226,7 +239,7 @@
            IStation.Calculation.DispatchAna.Model.OutletPipePara pipe1 = new Calculation.DispatchAna.Model.OutletPipePara();
            pipe1.Name = "一号管";
            var flow1 = result_sg.result.Find(x => x.key == "stationCX_1#_flow");
            if(flow1 == null)
            if (flow1 == null)
            {
                error_info = "一号管流量无法获取";
                return null;
@@ -234,7 +247,7 @@
            else
            {
                pipe1.TargetFlow = flow1.value;
            }
            }
            var press1 = result_sg.result.Find(x => x.key == "stationCX_1#_pressure");
            if (press1 == null)
            {
@@ -244,14 +257,14 @@
            else
            {
                pipe1.TargetPress = press1.value;
            }
            }
            var pipe1_val = result_sg.scada.Find(t => t.tagname == "_0402010403150101003");
            if (pipe1_val != null)
            {
                pipe1.ValveStatus =  (int)pipe1_val.value;
                pipe1.ValveStatus = (int)pipe1_val.value;
            }
            //2号管
            IStation.Calculation.DispatchAna.Model.OutletPipePara pipe2 = new Calculation.DispatchAna.Model.OutletPipePara();
@@ -266,7 +279,7 @@
            {
                pipe2.TargetFlow = flow2.value;
            }
            var press2 = result_sg.result.Find(x => x.key == "stationCX_2#_pressure");
            if (press2 == null)
            {
@@ -276,13 +289,13 @@
            else
            {
                pipe2.TargetPress = press2.value;
            }
            }
            var pipe2_val = result_sg.scada.Find(t => t.tagname == "_0402010403150102003");
            if (pipe2_val != null)
            {
                pipe2.ValveStatus = (int)pipe2_val.value;
            }
            complex_request_paras.OutletPipePara = new List<IStation.Calculation.DispatchAna.Model.OutletPipePara>(2);
            complex_request_paras.OutletPipePara.Add(pipe1);
@@ -293,7 +306,7 @@
            //构造计算器
            var calulator = IStation.Calculation.DispatchAnalyCalculatorFactory.CreateKeepStatusCalculator(4,
                IStation.ObjectType.Station, 2,null);
                IStation.ObjectType.Station, 2, null);
            calulator.IntialRequest(complex_request_paras,
                    null,
                    machine_run_status);
@@ -305,7 +318,7 @@
            {//实时量,  stationCX_2#_flow" 三高给的目标量
                real_total_flow_pipe1 = pipe1_val_flow_real.value;
            }
            double real_oulet_press_pipe1 = 0;
            var pipe1_val_press_real = result_sg.scada.Find(t => t.tagname == "_0402010403030002005");
            if (pipe1_val_press_real != null)
@@ -423,13 +436,13 @@
                    pump_item.Name = machine_names[pump_item.Index];
                }
                result.Pumps.Add(pump_item);
                result.Pumps.Add(pump_item);
            }
            if (machine_run_status.Count == 1)
            {//保证开一台泵时, 流量大 频率也大, 流量小 , 频率也小
                if(pipe1.TargetFlow + pipe2.TargetFlow > 100)
                if (pipe1.TargetFlow + pipe2.TargetFlow > 100)
                {
                    double current_total_flow = 0;
                    if (pipe1.TargetFlow > 100)
@@ -437,7 +450,7 @@
                    else
                        current_total_flow = pipe2.TargetFlow;
                    var open_pump = result.Pumps.First();
                    var fr_hz_tag_name = machine_frq_hz_target_name[open_pump.Index];
                    var current_val_fr_hz = result_sg.scada.Find(t => t.tagname == fr_hz_tag_name);
@@ -459,7 +472,7 @@
                                //    (open_pump.Speed * (open_pump.Frequency + 0.5) / (open_pump.Frequency),0);
                                open_pump.Frequency = open_pump.Frequency + 0.5;
                                open_pump.Speed = Math.Round(740 * open_pump.Frequency / 50, 1);
                            }
                            }
                        }
                    }
                }
@@ -476,8 +489,8 @@
                            //    (x.Speed * (x.Frequency + 0.5) / (x.Frequency), 0);
                            x.Frequency = x.Frequency + 0.5;
                            x.Speed = Math.Round(740 * x.Frequency / 50, 1);
                        }
                    }
                        }
                    }
                });
            }
@@ -496,7 +509,7 @@
            });
            return result;
        }
    }
}