| | |
| | | IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} 时间范围错误,不能超过24小时", start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "时间范围错误,不能超过24小时" }; |
| | | } |
| | | |
| | | |
| | | IStation.CalcModel.AnaRequest anaRequest = new AnaRequest(); |
| | | anaRequest.CalcOptType = (eCalcOptType)IStation.AnaGlobalParas.Setting.OptSortType; |
| | | anaRequest.StartTime = start_timme; |
| | | anaRequest.EndTime = end_timme; |
| | | anaRequest.WaterLevels长江 = GetTide3Day(_tideSouce, start_timme); |
| | | if(anaRequest.WaterLevels长江 ==null || anaRequest.WaterLevels长江.Count()==0) |
| | | { |
| | | if (anaRequest.WaterLevels长江 == null || anaRequest.WaterLevels长江.Count() == 0) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "无法获取长江水位数据" }; |
| | | } |
| | | |
| | | #region 取水总量 |
| | | |
| | | double TotalFlowIn = 0; |
| | | if (!string.IsNullOrEmpty(request.TotalFlowIn) && !string.IsNullOrWhiteSpace(request.TotalFlowIn)) |
| | | { |
| | | { |
| | | if (!double.TryParse(request.TotalFlowIn, out TotalFlowIn)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入数字型取水总量,接受到的输入值是:" + request.TotalFlowIn }; |
| | |
| | | } |
| | | |
| | | #endregion 取水总量 |
| | | |
| | | |
| | | #region 水位要求 |
| | | |
| | | if (!string.IsNullOrEmpty(request.MaxReservoirLevelTime)) |
| | |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入取水总量或水位要求" }; |
| | | } |
| | | |
| | | |
| | | if (TotalFlowIn < 1000) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入取水总量,接受到的输入值是:" + request.TotalFlowIn }; |
| | |
| | | if (string.IsNullOrEmpty(request.TotalFlowOut) || string.IsNullOrWhiteSpace(request.TotalFlowOut)) |
| | | {//用预测值 |
| | | #region 用预测值 |
| | | |
| | | anaRequest.PerHourFlowOut = new List<double>(); |
| | | IStation.DAL.WaterPredictRecord dal = new DAL.WaterPredictRecord(); |
| | | var water_records = dal.GetByHourRangle(start_timme, end_timme); |
| | |
| | | anaRequest.PerHourFlowOut.Add(r.LastPredictValue);//计算中用吨 |
| | | } |
| | | IStation.LogHelper.Info( |
| | | string.Format("获取水量预测值: {0} , 预测值总供水总量:{1} ", |
| | | string.Format("获取水量预测值: {0} , 预测值总供水总量:{1} ", |
| | | string.Join(",", anaRequest.PerHourFlowOut), TotalFlowOut预测值的供水总量)); |
| | | FlowTotalOut需求 = TotalFlowOut预测值的供水总量; |
| | | isPredictRecord = true ; |
| | | isPredictRecord = true; |
| | | |
| | | #endregion 用预测值 |
| | | } |
| | | else |
| | |
| | | anaRequest.PerHourFlowOut = list; |
| | | |
| | | FlowTotalOut需求 = TotalFlowOut手动输入需求; |
| | | isPredictRecord = false ; |
| | | isPredictRecord = false; |
| | | } |
| | | |
| | | #endregion 供水量 |
| | |
| | | } |
| | | IStation.LogHelper.Info("-----------------------------END--------------------------------------"); |
| | | |
| | | //保存方案 |
| | | //保存方案 |
| | | var ret = Common.HistoryAnaPrjFileHelper.SavePrj(IStation.AnaGlobalParas.Setting, isPredictRecord, anaRequest, defaultPrj); |
| | | |
| | | // |
| | | var dto_prj = ToPrjDto(defaultPrj); |
| | | dto_prj.FlowTotalOut = FlowTotalOut需求; |
| | | |
| | | |
| | | //推送:代码保留 |
| | | //if (!string.IsNullOrEmpty(request.IsSubmit) && Convert.ToBoolean(request.IsSubmit)) |
| | |
| | | // }); |
| | | //} |
| | | |
| | | |
| | | //IStation.LogHelper.Info(string.Format(" 产生计算方案:{0}", dto_prj.schemeID)); |
| | | //IStation.LogHelper.Info(string.Format("Zy Prj 计算成功: \r\n {0} ", JsonHelper.Object2Json(dto_prj))); |
| | | |
| | | |
| | | return new IStation.Dto.ApiResult<IStation.ZyDto.SubmitPrj>(dto_prj) { Code = ApiResultCode.Success }; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取某一天,最近一条 |
| | | /// </summary> |
| | |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; |
| | | } |
| | | |
| | | |
| | | IStation.CalcModel.AnaRequestBase requestBase = null; |
| | | var prj = Common.HistoryAnaPrjFileHelper.GetByCreateDay(d, out requestBase); |
| | |
| | | var sumFlow = (from x in requestBase.PerHourFlowOut select x).Sum(); |
| | | dto_prj.FlowTotalOut = sumFlow; |
| | | } |
| | | if(dto_prj.Switchs != null) |
| | | if (dto_prj.Switchs != null) |
| | | { |
| | | var switch2 = from x in dto_prj.Switchs orderby x.Time select x; |
| | | int index = 1; |
| | |
| | | IStation.LogHelper.Info(" api GetLastHistoryRecord is null "); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | IStation.CalcModel.AnaRequestBase requestBase = null; |
| | | var prj = Common.HistoryAnaPrjFileHelper.GetByStartTime(record.StartTime, out requestBase); |
| | | if (prj != null) |
| | | { |
| | | { |
| | | var dto_prj = ToPrjDto(prj); |
| | | if (requestBase != null && requestBase.PerHourFlowOut != null) |
| | | { |
| | | var sumFlow = (from x in requestBase.PerHourFlowOut select x).Sum(); |
| | | var sumFlow = (from x in requestBase.PerHourFlowOut.Take(24) select x).Sum(); |
| | | dto_prj.FlowTotalOut = sumFlow; |
| | | } |
| | | if (dto_prj.Switchs != null) |
| | |
| | | else |
| | | { |
| | | IStation.LogHelper.Info(string.Format( |
| | | " api GetLastHistoryRecord is null (未找到项目) LastRecord 信息: ID:{0}, StartTime:{1}, EndTime:{2}", |
| | | record.ID, |
| | | " api GetLastHistoryRecord is null (未找到项目) LastRecord 信息: ID:{0}, StartTime:{1}, EndTime:{2}", |
| | | record.ID, |
| | | record.StartTime, record.EndTime)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Alert, Message = "未找到项目" }; |
| | | } |
| | |
| | | IStation.CalcModel.AnaRequestBase requestBase = null; |
| | | var prj = Common.HistoryAnaPrjFileHelper.GetByStartTime(record.StartTime, out requestBase); |
| | | if (prj != null) |
| | | { |
| | | { |
| | | var dto_prj = ToPrjDto(prj); |
| | | if (requestBase != null && requestBase.PerHourFlowOut != null ) |
| | | if (requestBase != null && requestBase.PerHourFlowOut != null) |
| | | { |
| | | var sumFlow = (from x in requestBase.PerHourFlowOut select x).Sum(); |
| | | dto_prj.FlowTotalOut = sumFlow; |
| | |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Alert, Message = "未找到项目" }; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | } |
| | | } |
| | | if (defaultPrj.MaxWaterLevelH <= 0) |
| | | { |
| | | double maxHeight = 0; |
| | | { |
| | | double maxHeight = 0; |
| | | DateTime maxHeightTime = defaultPrj.StartTime; |
| | | if (defaultPrj.BlockTimes != null) |
| | | { |
| | |
| | | defaultPrj.MaxWaterLevelH = maxHeight; |
| | | defaultPrj.MaxWaterLevelTime = maxHeightTime; |
| | | } |
| | | |
| | | if(defaultPrj.MaxWaterLevelTime> defaultPrj.StartTime) |
| | | dto_prj.MaxWaterLevelH = string.Format("{0:N2} ({1})", Math.Round( defaultPrj.MaxWaterLevelH,2) , |
| | | defaultPrj.MaxWaterLevelTime.ToString("HH:mm")); |
| | | |
| | | if (defaultPrj.MaxWaterLevelTime > defaultPrj.StartTime) |
| | | dto_prj.MaxWaterLevelH = string.Format("{0:N2} ({1})", Math.Round(defaultPrj.MaxWaterLevelH, 2), |
| | | defaultPrj.MaxWaterLevelTime.ToString("HH:mm")); |
| | | else |
| | | dto_prj.MaxWaterLevelH = string.Format("{0:N2} ", Math.Round(defaultPrj.MaxWaterLevelH, 2)); |
| | | |
| | |
| | | } |
| | | |
| | | #endregion 换算成DTO |
| | | |
| | | } |
| | | } |