From 0e57c17412761fc2f46566a8f32fd5c62e636366 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期二, 11 二月 2025 14:12:54 +0800 Subject: [PATCH] 修改供水量只取24条 --- WebApi/Controllers/ZyPrjController.cs | 59 +++++++++++++++++++++++++++-------------------------------- 1 files changed, 27 insertions(+), 32 deletions(-) diff --git a/WebApi/Controllers/ZyPrjController.cs b/WebApi/Controllers/ZyPrjController.cs index bf39aa0..e4f85e5 100644 --- a/WebApi/Controllers/ZyPrjController.cs +++ b/WebApi/Controllers/ZyPrjController.cs @@ -94,21 +94,22 @@ 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 }; @@ -124,7 +125,7 @@ } #endregion 鍙栨按鎬婚噺 - + #region 姘翠綅瑕佹眰 if (!string.IsNullOrEmpty(request.MaxReservoirLevelTime)) @@ -151,7 +152,7 @@ { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璇疯緭鍏ュ彇姘存�婚噺鎴栨按浣嶈姹�" }; } - + if (TotalFlowIn < 1000) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璇疯緭鍏ュ彇姘存�婚噺,鎺ュ彈鍒扮殑杈撳叆鍊兼槸:" + request.TotalFlowIn }; @@ -169,6 +170,7 @@ 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); @@ -204,10 +206,11 @@ 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 @@ -232,7 +235,7 @@ anaRequest.PerHourFlowOut = list; FlowTotalOut闇�姹� = TotalFlowOut鎵嬪姩杈撳叆闇�姹�; - isPredictRecord = false ; + isPredictRecord = false; } #endregion 渚涙按閲� @@ -297,13 +300,12 @@ } IStation.LogHelper.Info("-----------------------------END--------------------------------------"); - //淇濆瓨鏂规 + //淇濆瓨鏂规 var ret = Common.HistoryAnaPrjFileHelper.SavePrj(IStation.AnaGlobalParas.Setting, isPredictRecord, anaRequest, defaultPrj); // var dto_prj = ToPrjDto(defaultPrj); dto_prj.FlowTotalOut = FlowTotalOut闇�姹�; - //鎺ㄩ��:浠g爜淇濈暀 //if (!string.IsNullOrEmpty(request.IsSubmit) && Convert.ToBoolean(request.IsSubmit)) @@ -314,10 +316,8 @@ // }); //} - //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 }; } @@ -417,8 +417,6 @@ } } - - /// <summary> /// 鑾峰彇鏌愪竴澶�,鏈�杩戜竴鏉� /// </summary> @@ -437,7 +435,6 @@ { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 鏍煎紡涓嶆纭�" }; } - IStation.CalcModel.AnaRequestBase requestBase = null; var prj = Common.HistoryAnaPrjFileHelper.GetByCreateDay(d, out requestBase); @@ -450,7 +447,7 @@ 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; @@ -487,15 +484,15 @@ 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) @@ -514,8 +511,8 @@ 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 = "鏈壘鍒伴」鐩�" }; } @@ -541,9 +538,9 @@ 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; @@ -570,7 +567,6 @@ return new IStation.Dto.ApiResult() { Code = ApiResultCode.Alert, Message = "鏈壘鍒伴」鐩�" }; } } - /// <summary> /// @@ -1069,8 +1065,8 @@ } } if (defaultPrj.MaxWaterLevelH <= 0) - { - double maxHeight = 0; + { + double maxHeight = 0; DateTime maxHeightTime = defaultPrj.StartTime; if (defaultPrj.BlockTimes != null) { @@ -1096,10 +1092,10 @@ 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)); @@ -1129,6 +1125,5 @@ } #endregion 鎹㈢畻鎴怐TO - } } \ No newline at end of file -- Gitblit v1.9.3