| | |
| | | [Route("Calc")] |
| | | [HttpPost] |
| | | public IStation.Dto.ApiResult Calc([FromBody] ZyPrjRequest request) |
| | | { |
| | | { |
| | | if (request == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "request is null" }; |
| | |
| | | // |
| | | IStation.LogHelper.Info("--------------------------START-----------------------------------------"); |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Calc Request: {0}", JsonHelper.Object2Json(request))); |
| | | |
| | | |
| | | |
| | | DateTime start_timme = DateTime.Now; |
| | | DateTime end_timme = DateTime.Now; |
| | |
| | | { |
| | | double TotalFlowIn = 0; |
| | | if (!double.TryParse(request.TotalFlowIn, out TotalFlowIn)) |
| | | { |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入数字型取水总量,接受到的输入值是:" + request.TotalFlowIn }; |
| | | } |
| | | if (TotalFlowIn < 10000) |
| | |
| | | double TotalFlowIn = 0; |
| | | if (!double.TryParse(request.TotalFlowIn, out TotalFlowIn)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入数字型取水总量,接受到的输入值是:"+ request.TotalFlowIn }; |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入数字型取水总量,接受到的输入值是:" + request.TotalFlowIn }; |
| | | } |
| | | } |
| | | |
| | |
| | | TotalFlowOutPrecid += r.LastPredictValue; |
| | | anaRequest.PerHourFlowOut.Add(r.LastPredictValue);//计算中用吨 |
| | | } |
| | | IStation.LogHelper.Info(string.Format(" 获取水量预测值: {0} ", string.Join(",",anaRequest.PerHourFlowOut))); |
| | | IStation.LogHelper.Info(string.Format(" 获取水量预测值: {0} ", string.Join(",", anaRequest.PerHourFlowOut))); |
| | | |
| | | #endregion 用预测值 |
| | | } |
| | | else |
| | | { |
| | | if (!double.TryParse(request.TotalFlowOut, out TotalFlowOut)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意供水总量输入参数无法识别,参数是:"+ request.TotalFlowOut }; |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意供水总量输入参数无法识别,参数是:" + request.TotalFlowOut }; |
| | | } |
| | | if (TotalFlowOut < 10000) |
| | | { |
| | |
| | | #endregion 供水量 |
| | | |
| | | //开始时的开机状态 |
| | | List<int> StartOpenPumpIndexArray = new List<int>(); |
| | | if (!string.IsNullOrEmpty(request.StartOpenPumpIndexArray )) |
| | | List<int> StartOpenPumpIndexArray = new List<int>(); |
| | | if (!string.IsNullOrEmpty(request.StartOpenPumpIndexArray)) |
| | | { |
| | | var sss = request.StartOpenPumpIndexArray.Split(','); |
| | | var sss = request.StartOpenPumpIndexArray.Split(','); |
| | | foreach (var item in sss) |
| | | { |
| | | if (int.TryParse(item, out int index)) |
| | |
| | | string error_info = calcHelper.Calc(anaRequest, out defaultPrj); |
| | | |
| | | if (!string.IsNullOrEmpty(error_info) || defaultPrj == null) |
| | | { |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj 计算错误: \r\n {0} ", error_info)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "计算错误, 原因是:" + error_info }; |
| | | } |
| | | else |
| | | { |
| | | // IStation.LogHelper.Info(string.Format("Zy Prj 计算成功: \r\n {0} ", JsonHelper.Object2Json(defaultPrj))); |
| | | { |
| | | // IStation.LogHelper.Info(string.Format("Zy Prj 计算成功: \r\n {0} ", JsonHelper.Object2Json(defaultPrj))); |
| | | } |
| | | IStation.LogHelper.Info("-----------------------------END--------------------------------------"); |
| | | |
| | | //保存方案 |
| | | //保存方案 |
| | | var ret = Common.HistoryAnaPrjFileHelper.SavePrj(IStation.AnaGlobalParas.Setting, anaRequest, defaultPrj); |
| | | |
| | | // |
| | |
| | | foreach (var bt in defaultPrj.PumpSwitchs) |
| | | { |
| | | ZyDto.SubmitPrjSwitchInfo dto_item = new ZyDto.SubmitPrjSwitchInfo(); |
| | | dto_item.Index = bt.Index; |
| | | dto_item.GroupID = bt.GroupID;//分组ID |
| | | dto_item.PumpIndex = bt.PumpIndex;//泵角标 |
| | | dto_item.Time = bt.Time.ToString("yyyy-MM-dd HH:mm:ss");//时间 |
| | |
| | | dto_setting.OptSortType = model_setting.OptSortType; |
| | | dto_setting.SwitchPumpMinuteSpace = model_setting.SwitchPumpMinuteSpace; |
| | | |
| | | dto_setting.OpenPumpIndexSequence = IStation.Dto.ZyPrjAnaSetting.ListToString( model_setting.OpenPumpIndexSequence); |
| | | dto_setting.OpenPumpIndexSequence = IStation.Dto.ZyPrjAnaSetting.ListToString(model_setting.OpenPumpIndexSequence); |
| | | dto_setting.ClosePumpIndexSequence = IStation.Dto.ZyPrjAnaSetting.ListToString(model_setting.ClosePumpIndexSequence); |
| | | dto_setting.OptimalPumpIndexSequence = IStation.Dto.ZyPrjAnaSetting.ListToString(model_setting.OptimalPumpIndexSequence); |
| | | |
| | |
| | | model_setting.UnablePumpIndexArray = overhallStatus.ToArray(); |
| | | dto_setting.UnablePumpIndexArray = string.Join(",", overhallStatus); |
| | | IStation.Common.AnaSetting.SaveSetting(model_setting); |
| | | } |
| | | } |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "无法链接工控服务器,错误原因:" + ex.Message}; |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "无法链接工控服务器,错误原因:" + ex.Message }; |
| | | } |
| | | |
| | | |
| | | |
| | | if (model_setting.SwitchPumpIgnoreTimes != null) |
| | | { |
| | |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "最少切泵时间 设置过长" }; |
| | | } |
| | | model_setting.MinSwitchTimeMinute = dto.MinSwitchTimeMinute; |
| | | if (dto.SwitchPumpMinuteSpace < 2 || dto.SwitchPumpMinuteSpace > 30) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "切换泵时间间隔 设置不合理" }; |
| | | } |
| | | model_setting.SwitchPumpMinuteSpace = dto.SwitchPumpMinuteSpace; |
| | | |
| | | if (dto.MaxPumpSwitchCount < 1) |
| | | { |
| | |
| | | |
| | | return new IStation.Dto.ApiResult<List<int>>(overhallStatus); |
| | | } |
| | | private string BuildSequenceFromDto(string sequenceDto, out int[] sequenceDs) |
| | | |
| | | private string BuildSequenceFromDto(string sequenceDto, out int[] sequenceDs) |
| | | { |
| | | sequenceDs = null; |
| | | if (string.IsNullOrEmpty(sequenceDto)) |
| | | return null; |
| | | |
| | | |
| | | List<int> list = new List<int>(); |
| | | if (!string.IsNullOrEmpty(sequenceDto)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return BuildSequenceFromDto(list,out sequenceDs); |
| | | return BuildSequenceFromDto(list, out sequenceDs); |
| | | } |
| | | |
| | | private string BuildSequenceFromDto(List<int> sequenceDto, out int[] sequenceDs) |
| | | |
| | | private string BuildSequenceFromDto(List<int> sequenceDto, out int[] sequenceDs) |
| | | { |
| | | sequenceDs = null; |
| | | if (sequenceDto == null || sequenceDto.Count() == 0) |