tangxu
2022-10-08 6b437da7145139fda9cbff0acaa5b8e2295d11cd
Application/IStation.Application.Eta/dispatch_analy/DispatchAnaly_StdController.cs
@@ -24,7 +24,7 @@
        /// </summary>
        [Route("GetCurrentInfo@V1.0")]
        [HttpGet]
        public  IStation.Dto.ApiResult GetCurrentInfo([FromQuery][Required] StationIDUnderCorpInput input)
        public IStation.Dto.ApiResult GetCurrentInfo([FromQuery][Required] StationIDUnderCorpInput input)
        {
            var pipeLineList = new Service.PipeLine().GetByBelongTypeAndBelongID(input.CorpID, IStation.ObjectType.Station, input.StationID);
            if (pipeLineList == null || pipeLineList.Count < 1)
@@ -77,27 +77,31 @@
            vm_ana_result.Name = string.Join(",", name_list);
            IStation.Calculation.IDispatchAnalyCalculator calc_helper =
                IStation.Calculation.DispatchAnalyCalculatorFactory.CreateCalculator(input.CorpID,
                IStation.ObjectType.Station,
                input.StationID, null);
            IStation.Calculation.DispatchAna.IGetCurrentRecord calc_helper =
                IStation.Calculation.DispatchAnalyCalculatorFactory.CreateGetCurrentRecord(
                    input.CorpID, IStation.ObjectType.Station,
                    input.StationID);
            if (calc_helper == null)
            {
                return new Dto.ApiResult<IStation.Dto.DispatchAna.StationCurrentInfo>( new IStation.Dto.DispatchAna.StationCurrentInfo(vm_ana_result));
                return new Dto.ApiResult<IStation.Dto.DispatchAna.StationCurrentInfo>(new IStation.Dto.DispatchAna.StationCurrentInfo(vm_ana_result));
            }
            string error_info = null;
            var current_dispatch_info = calc_helper.GetCurrentRecord(input.CorpID, input.StationID, out error_info);
            if (current_dispatch_info == null)
            {
                return new Dto.ApiResult<IStation.Dto.DispatchAna.StationCurrentInfo>(
                    new IStation.Dto.DispatchAna.StationCurrentInfo(vm_ana_result));
            }
            else
            {
                string error_info = null;
                var current_dispatch_info = calc_helper.GetCurrentRecord(input.CorpID, input.StationID, out error_info);
                if(current_dispatch_info == null)
                {
                    return new Dto.ApiResult<IStation.Dto.DispatchAna.StationCurrentInfo>(new IStation.Dto.DispatchAna.StationCurrentInfo(vm_ana_result));
                }
                else
                {
                    return new Dto.ApiResult<IStation.Dto.DispatchAna.StationCurrentInfo>(new IStation.Dto.DispatchAna.StationCurrentInfo(vm_ana_result, current_dispatch_info));
                }
                return new Dto.ApiResult<IStation.Dto.DispatchAna.StationCurrentInfo>(
                    new IStation.Dto.DispatchAna.StationCurrentInfo(
                        vm_ana_result,
                        current_dispatch_info)
                    );
            }
        }
@@ -125,51 +129,29 @@
                return IStation.Dto.ApiResult.Error("StationID为空");
            }
            string error_info = null;
            var complex = request.BuildRequestComplex(out error_info);
            complex.SchemeSortType = (Calculation.DispatchAna.Model.eAnaSchemeSortType)request.SortType;
            List<IStation.Calculation.DispatchAna.Model.MachineRunFilter> machine_run_filter_list = null;
            if (request.RunStatusList == null)
            {
                // IStation.LogHelper.Info("RunStatusList none");
            }
            else if (request.RunStatusList.Count() == 0)
            {
                // IStation.LogHelper.Info("RunStatusList Count==0");
            }
            else //if (request.Setting.OpenStatus != null && request.Setting.OpenStatus.Count > 0)
            {
                machine_run_filter_list = new List<IStation.Calculation.DispatchAna.Model.MachineRunFilter>();
                foreach (var d in request.RunStatusList)
                {
                    var binding_list = new Service.PipeLineBinding().GetByPipeLineID(request.CorpID, d.MachineID);
                    machine_run_filter_list.Add(new IStation.Calculation.DispatchAna.Model.MachineRunFilter()
                    {
                        MachineID = binding_list.First().ID,
                        RunStatus = d.Status,
                        MaxFlow = -1
                    });
                }
            }
            IStation.Calculation.IDispatchAnalyCalculator calc_helper =
                IStation.Calculation.DispatchAnalyCalculatorFactory.CreateCalculator(request.CorpID,
                IStation.ObjectType.Station,
                request.StationID, null);
            //获取辅助类
            IStation.Calculation.DispatchAna.IOptAnaCalc calc_helper =
                IStation.Calculation.DispatchAnalyCalculatorFactory.CreateOptAnaCalculator(
                    request.CorpID, IStation.ObjectType.Station,
                    request.StationID,null);
            if (calc_helper == null)
            {
                return IStation.Dto.ApiResult.Error("Calculator 还未构建");
            }
            var machine_run_status = new IStation.Calculation.DispatchAna.Model.MachineRunPara() { MachineRunFilter = machine_run_filter_list };
            //调用CalcOptListByPre 因为可能部分参数还需获取实时数据
            var items = calc_helper.CalcOptListByPre(complex, machine_run_status, out error_info);
            //构建参数
            string error_info = null;
            var complex_request_paras = request.BuildRequestComplex(out error_info);
            var machine_run_status = request.BuildMachineRunPara(out error_info);
            var eta_ana_records = request.BuildEtaAnaRecord(out error_info);
            //计算
            var items = calc_helper.CalcSchemes(
                complex_request_paras,
                eta_ana_records,
                machine_run_status,
                out error_info);
            if (items == null || items.Count() == 0)
            {
                return IStation.Dto.ApiResult.Alert(error_info);
@@ -252,7 +234,7 @@
                    continue;
                IStation.Calculation.DispatchAna.Model.AnaCurveItem anaData = new IStation.Calculation.DispatchAna.Model.AnaCurveItem();
                int ret = IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.CalcAnaCurve(
                int ret = IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper压力.CalcAnaCurve(
                    pump_curve.CurveInfo.CurveQH,
                    pump_curve.CurveInfo.CurveQP,
                    0, TargetH / 102, 0, 0, frequence, ref anaData);
@@ -275,8 +257,8 @@
            }
            project.TotalWrkQ = (from x in project.Items where x.WorkPointQ > 0 select x.WorkPointQ).Sum();
            project.TotalWrkP = (from x in project.Items where x.WorkPointP > 0 select x.WorkPointP).Sum();
            project.UWP = Math.Round(IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.Calcu_UWP(project.TotalWrkP, project.TotalWrkQ, TargetH), 3);
            project.WP = Math.Round(IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.Calcu_UWP(project.TotalWrkP, project.TotalWrkQ, TargetH), 3);
            project.UWP = Math.Round(IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper压力.Calcu_UWP(project.TotalWrkP, project.TotalWrkQ, TargetH), 3);
            project.WP = Math.Round(IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper压力.Calcu_UWP(project.TotalWrkP, project.TotalWrkQ, TargetH), 3);
            project.SpanQ = Math.Round(project.TotalWrkQ - TargetQ, 0);
@@ -340,11 +322,11 @@
                if (frequence > 49.5)
                {
                    var curve_qh = curve_default.CurveInfo.CurveQH;
                    curve_qh.Max = curve_qh.Max * IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio;
                    curve_qh.Max = curve_qh.Max * IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper压力.ExtendMaxRatio;
                    curveListQH.Add(curve_qh);
                    var curve_qp = curve_default.CurveInfo.CurveQP;
                    curve_qp.Max = curve_qp.Max * IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio;
                    curve_qp.Max = curve_qp.Max * IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper压力.ExtendMaxRatio;
                    curveListQP.Add(curve_qp);
                }
                else
@@ -352,9 +334,9 @@
                    var ration = frequence / 50.0;
                    var maxCurveQH = IStation.Model.FitCurveHelper.GetFitPointsByExtend(curve_default.CurveInfo.CurveQH,
                        IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio, 20);
                        IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper压力.ExtendMaxRatio, 20);
                    var maxCurveQP = IStation.Model.FitCurveHelper.GetFitPointsByExtend(curve_default.CurveInfo.CurveQP,
                        IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio, 20);
                        IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper压力.ExtendMaxRatio, 20);
                    List<IStation.Model.CurvePoint> simuPointsQH = new List<IStation.Model.CurvePoint>();
                    foreach (var pt in maxCurveQH)