From 9d2e93a197a0babf0761d7517f43d9d83143218b Mon Sep 17 00:00:00 2001 From: tangxu <tangxu76880903> Date: 星期四, 30 五月 2024 14:12:47 +0800 Subject: [PATCH] 众毅 添加 OptSortType 校核 --- WebApi/Controllers/ZyPrjController.cs | 100 ++++++++++++++++++++++++++++++++++++------------- 1 files changed, 73 insertions(+), 27 deletions(-) diff --git a/WebApi/Controllers/ZyPrjController.cs b/WebApi/Controllers/ZyPrjController.cs index 23f445e..bb7de69 100644 --- a/WebApi/Controllers/ZyPrjController.cs +++ b/WebApi/Controllers/ZyPrjController.cs @@ -91,40 +91,88 @@ IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} 鏃堕棿鑼冨洿閿欒,涓嶈兘瓒呰繃24灏忔椂", start_timme, end_timme)); return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "鏃堕棿鑼冨洿閿欒,涓嶈兘瓒呰繃24灏忔椂" }; } - if (request.TotalFlowIn == null) - { - if (string.IsNullOrEmpty(request.MaxReservoirLevel )) - { - return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璇疯緭鍏ュ彇姘存�婚噺鎴栨按浣嶈姹�" }; - } - } + - IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} ,StartOpenCount:{2} ", - start_timme, end_timme, request.StartOpenCount )); + IStation.CalcModel.AnaRequest anaRequest = new AnaRequest(); anaRequest.CalcOptType = (eCalcOptType)IStation.AnaGlobalParas.Setting.OptSortType; anaRequest.StartTime = start_timme; anaRequest.EndTime = end_timme; anaRequest.WaterLevels闀挎睙 = GetTide3Day(start_timme); - if(!string.IsNullOrEmpty(request.TotalFlowIn)) + + + if (string.IsNullOrEmpty(request.TotalFlowIn)) + { + if (string.IsNullOrEmpty(request.MaxReservoirLevel)) + { + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 璇疯緭鍏ュ彇姘存�婚噺鎴栨按浣嶈姹�", + start_timme, end_timme )); + return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璇疯緭鍏ュ彇姘存�婚噺鎴栨按浣嶈姹�" }; + } + } + else { double TotalFlowIn = 0; if(!double.TryParse( request.TotalFlowIn,out TotalFlowIn)) - { + { + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 娉ㄦ剰鍙栨按鎬婚噺鍗曚綅鏄惃,褰撳墠鍙傛暟鍙傛暟杩囧皬", + start_timme, end_timme)); return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "娉ㄦ剰鍙栨按鎬婚噺鍗曚綅鏄惃,褰撳墠鍙傛暟鍙傛暟杩囧皬" }; } if (TotalFlowIn < 10000) { + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 娉ㄦ剰鍙栨按鎬婚噺鍗曚綅鏄惃,褰撳墠鍙傛暟鍙傛暟杩囧皬", + start_timme, end_timme)); return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "娉ㄦ剰鍙栨按鎬婚噺鍗曚綅鏄惃,褰撳墠鍙傛暟鍙傛暟杩囧皬" }; } anaRequest.TotalFlowIn = TotalFlowIn; } - + if (!string.IsNullOrEmpty(request.MaxReservoirLevel)) + { + anaRequest.MaxLimitWaterBoxLevel = Convert.ToDouble(request.MaxReservoirLevel); + IStation.DAL.WaterPredictRecord dal = new DAL.WaterPredictRecord(); + var water_records = dal.GetByHourRangle( start_timme , end_timme ); + if (water_records == null) + { + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 姘翠綅棰勬祴鏁版嵁涓虹┖,璇峰厛淇濇寔姘翠綅棰勬祴鏈嶅姟姝e父杩愯", + start_timme, end_timme)); + return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = "姘翠綅棰勬祴鏁版嵁涓虹┖,璇峰厛淇濇寔姘翠綅棰勬祴鏈嶅姟姝e父杩愯" }; + } + var count = (end_timme - start_timme).TotalHours; + if (water_records.Count != count) + { + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 棰勬祴鏁版嵁鑾峰彇澶辫触,鏁版嵁鏉℃棤娉曞尮閰�, 妫�鏌ユ槸鍚﹂娴嬫湇鍔′腑鏂�", + start_timme, end_timme)); + return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = "棰勬祴鏁版嵁鑾峰彇澶辫触,鏁版嵁鏉℃棤娉曞尮閰�, 妫�鏌ユ槸鍚﹂娴嬫湇鍔′腑鏂�" }; + } + + anaRequest.SpaceFlowOut = new List<double>(); + foreach(var r in water_records) + { + if(r.States == 0) + { + var error_info11 = string.Format("棰勬祴鏁版嵁寮傚父,鏃犳硶杩涜姘翠綅璁$畻:{0} {1},{2}", r.DayHour, r.LastPredictValue, r.Description); + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , {2}}", + start_timme, end_timme, error_info11)); + return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = error_info11 + }; + } + anaRequest.SpaceFlowOut.Add(r.LastPredictValue/10000); + } + } + + if (!string.IsNullOrEmpty(request.MaxReservoirLevelTime)) + anaRequest.MaxLimitWaterBoxTime = request.MaxReservoirLevelTime; + + + + + // if (request.StartOpenCount == null) { anaRequest.StartOpenCount = -1; @@ -134,38 +182,32 @@ anaRequest.StartOpenCount = request.StartOpenCount.Value; } - #region 闄堣姘村簱姘翠綅 - + //闄堣姘村簱姘翠綅 if (!string.IsNullOrEmpty(request.StartReservoirLevel)) { anaRequest.CurrentWaterBoxLevel = Convert.ToDouble(request.StartReservoirLevel); } else { - /* var tagDict = new Dictionary<string, string> { { "_0402010201030103006", "闄堣姘村簱姘翠綅" } }; - var input = new { search = "real", tablename = "闄堣鏅鸿兘璋冨害" }; - var tags = tagDict.Keys.ToList(); - var realScadaRecordList = ZyConnectHelper.GetRealScadaResultAsync(tags, input).GetAwaiter().GetResult(); - if (realScadaRecordList != null && realScadaRecordList.Count() > 0) - { - anaRequest.CurrentWaterBoxLevel = realScadaRecordList.Last().Value; - }*/ anaRequest.CurrentWaterBoxLevel = ZyConnectHelper.GetRealReservoirWaterLevel(); } - #endregion 闄堣姘村簱姘翠綅 + - if (!string.IsNullOrEmpty(request.MaxReservoirLevel)) - anaRequest.MaxLimitWaterBoxLevel = Convert.ToDouble(request.MaxReservoirLevel); - if (!string.IsNullOrEmpty(request.MaxReservoirLevelTime)) - anaRequest.MaxLimitWaterBoxTime = request.MaxReservoirLevelTime; + var calcHelper = new IStation.CalcPrjHelper(); AnaPrj defaultPrj = null; string error_info = calcHelper.Calc(anaRequest, out defaultPrj); if (!string.IsNullOrEmpty(error_info) || defaultPrj == null) { + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 璁$畻閿欒, 鍘熷洜鏄�:{2} ,Request::: ", + start_timme, end_timme, error_info)+ JsonHelper.Object2Json( anaRequest)); return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璁$畻閿欒, 鍘熷洜鏄�:" + error_info }; + } + else + { + IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 璁$畻鎴愬姛", start_timme, end_timme )); } //淇濆瓨鏂规 @@ -386,7 +428,11 @@ return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "鏈�澶у垏娉垫鏁� 璁剧疆杩囬暱" }; } model_setting.MaxPumpSwitchCountQ = dto.MaxPumpSwitchCount; + if(dto.OptSortType>=2) + { + return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "OptSortType 鍙兘璁剧疆 0 鎴栬�� 1, 0浠h〃 鐢ㄧ數閲忔渶灏� 1浠h〃 鐢佃垂鏈�灏�" }; + } model_setting.OptSortType = dto.OptSortType; if (dto.SwitchPumpIgnoreTimes != null) { -- Gitblit v1.9.3