From 9fe74fc1c8dfb27733888160fd2d63908e26acd4 Mon Sep 17 00:00:00 2001 From: tangxu <tangxu76880903> Date: 星期四, 01 八月 2024 16:12:05 +0800 Subject: [PATCH] 对接修改 --- WebApi/Controllers/ZyPrjController.cs | 81 ++++++++++++++++++++++------------------ 1 files changed, 45 insertions(+), 36 deletions(-) diff --git a/WebApi/Controllers/ZyPrjController.cs b/WebApi/Controllers/ZyPrjController.cs index 4a7446e..2edbe73 100644 --- a/WebApi/Controllers/ZyPrjController.cs +++ b/WebApi/Controllers/ZyPrjController.cs @@ -29,7 +29,7 @@ //public int? StartOpenCount { get; set; } = -1;//宸蹭綔搴� public string StartReservoirLevel { get; set; }//寮�濮嬫按搴撴按浣�(鍙┖):鍗曚綅m - public List<int> StartOpenPumpIndexArray { get; set; }//寮�濮嬫満娉靛紑鏈虹姸鎬�(鏂�) + public int[] StartOpenPumpIndexArray { get; set; }//寮�濮嬫満娉靛紑鏈虹姸鎬�(涓嶅彲绌�) public string TotalFlowIn { get; set; }//鍙栨按鎬婚噺 (鍗曚綅 鍚�) public string TotalFlowOut { get; set; }//渚涙按鎬婚噺 (鍗曚綅 鍚�) 涓嶈緭鍏ュ氨鐢ㄩ娴嬪�� @@ -56,7 +56,8 @@ [HttpPost] public IStation.Dto.ApiResult Calc([FromBody] ZyPrjRequest request) { - LogHelper.Info(JsonHelper.Object2Json(request)); + + if (request == null) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "request is null" }; @@ -69,6 +70,11 @@ { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "EndTime 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; @@ -101,14 +107,12 @@ #region 鍙栨按鎬婚噺 - if (!string.IsNullOrEmpty(request.TotalFlowIn)) + if (!string.IsNullOrEmpty(request.TotalFlowIn) && !string.IsNullOrWhiteSpace(request.TotalFlowIn)) { 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 = "娉ㄦ剰鍙栨按鎬婚噺鍗曚綅鏄惃,褰撳墠鍙傛暟鍙傛暟杩囧皬" }; + { + return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璇疯緭鍏ユ暟瀛楀瀷鍙栨按鎬婚噺,鎺ュ彈鍒扮殑杈撳叆鍊兼槸:" + request.TotalFlowIn }; } if (TotalFlowIn < 10000) { @@ -129,7 +133,7 @@ anaRequest.MaxReservoirLevelTime = request.MaxReservoirLevelTime; } - if (!string.IsNullOrEmpty(request.MaxReservoirLevel)) + if (!string.IsNullOrEmpty(request.MaxReservoirLevel) && !string.IsNullOrWhiteSpace(request.MaxReservoirLevel)) { double MaxReservoirLevel = 0; if (!double.TryParse(request.MaxReservoirLevel, out MaxReservoirLevel)) @@ -144,11 +148,14 @@ } else { - if (string.IsNullOrEmpty(request.TotalFlowIn)) + if (string.IsNullOrEmpty(request.TotalFlowIn) || string.IsNullOrWhiteSpace(request.TotalFlowIn)) { - IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 璇疯緭鍏ュ彇姘存�婚噺鎴栨按浣嶈姹�", - start_timme, end_timme)); return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璇疯緭鍏ュ彇姘存�婚噺鎴栨按浣嶈姹�" }; + } + double TotalFlowIn = 0; + if (!double.TryParse(request.TotalFlowIn, out TotalFlowIn)) + { + return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "璇疯緭鍏ユ暟瀛楀瀷鍙栨按鎬婚噺,鎺ュ彈鍒扮殑杈撳叆鍊兼槸:"+ request.TotalFlowIn }; } } @@ -159,7 +166,7 @@ double TotalFlowOut = 0; double TotalFlowOutPrecid = 0;//棰勬祴鍊肩殑渚涙按鎬婚噺 - if (string.IsNullOrEmpty(request.TotalFlowOut)) + if (string.IsNullOrEmpty(request.TotalFlowOut) || string.IsNullOrWhiteSpace(request.TotalFlowOut)) {//鐢ㄩ娴嬪�� #region 鐢ㄩ娴嬪�� @@ -197,16 +204,14 @@ TotalFlowOutPrecid += r.LastPredictValue; anaRequest.PerHourFlowOut.Add(r.LastPredictValue);//璁$畻涓敤鍚� } - + IStation.LogHelper.Info(string.Format(" 鑾峰彇姘撮噺棰勬祴鍊�: {0} ", string.Join(",",anaRequest.PerHourFlowOut))); #endregion 鐢ㄩ娴嬪�� } else { if (!double.TryParse(request.TotalFlowOut, out TotalFlowOut)) - { - IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 娉ㄦ剰鍙栨按鎬婚噺鍗曚綅鏄惃,褰撳墠鍙傛暟鍙傛暟杩囧皬", - start_timme, end_timme)); - return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "娉ㄦ剰渚涙按鎬婚噺鍗曚綅鏄惃,褰撳墠鍙傛暟鍙傛暟杩囧皬" }; + { + return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "娉ㄦ剰渚涙按鎬婚噺杈撳叆鍙傛暟鏃犳硶璇嗗埆,鍙傛暟鏄�:"+ request.TotalFlowOut }; } if (TotalFlowOut < 10000) { @@ -233,7 +238,7 @@ return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = "鏈缃紑濮嬫椂鏈烘车寮�鍋滅姸鎬� (Error: StartOpenPumpIndexArray is null)" }; } anaRequest.IsKnownStartOpenPump = true; - anaRequest.StartOpenPumpIndexArray = request.StartOpenPumpIndexArray; + anaRequest.StartOpenPumpIndexArray = request.StartOpenPumpIndexArray.ToList(); //闄堣姘村簱姘翠綅 if (string.IsNullOrEmpty(request.StartReservoirLevel)) @@ -264,20 +269,17 @@ string error_info = calcHelper.Calc(anaRequest, out defaultPrj); if (!string.IsNullOrEmpty(error_info) || defaultPrj == null) - { - var er = string.Format("Zy Prj Time:{0}-{1} , 璁$畻閿欒, 鍘熷洜鏄�:{2} ,Request::: {3}", - start_timme, end_timme, error_info, JsonHelper.Object2Json(anaRequest)); - - IStation.LogHelper.Info(er); + { + 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 Time:{0}-{1} , 璁$畻鎴愬姛", start_timme, end_timme)); + { + IStation.LogHelper.Info(string.Format("Zy Prj 璁$畻鎴愬姛: \r\n {0} ", JsonHelper.Object2Json(defaultPrj))); } + IStation.LogHelper.Info("-----------------------------END--------------------------------------"); - //淇濆瓨鏂规 - //defaultPrj.Name + //淇濆瓨鏂规 var ret = Common.HistoryAnaPrjFileHelper.SavePrj(IStation.AnaGlobalParas.Setting, anaRequest, defaultPrj); // @@ -559,21 +561,28 @@ //dto_setting.OptimalPumpIndexSequence = BuildSequenceToDto(model_setting.OptimalPumpIndexSequence); //妫�淇车鐨勮鏍�, 0 琛ㄧず1鍙锋车 1 琛ㄧず浜屽彿娉� 涓虹┖,琛ㄧず娌℃湁妫�淇� - var overhallStatus = ZyConnectHelper.GetOverhaulStatus(); - if(overhallStatus == null || overhallStatus.Count == 0) + try { - if(model_setting.UnablePumpIndexArray != null) + var overhallStatus = ZyConnectHelper.GetOverhaulStatus(); + if (overhallStatus == null || overhallStatus.Count == 0) { - model_setting.UnablePumpIndexArray = null; + if (model_setting.UnablePumpIndexArray != null) + { + model_setting.UnablePumpIndexArray = null; + IStation.Common.AnaSetting.SaveSetting(model_setting); + } + } + else + { + model_setting.UnablePumpIndexArray = overhallStatus.ToArray(); IStation.Common.AnaSetting.SaveSetting(model_setting); - } + } + dto_setting.UnablePumpIndexArray = model_setting.UnablePumpIndexArray; } - else + catch(Exception ex) { - model_setting.UnablePumpIndexArray = overhallStatus.ToArray(); - IStation.Common.AnaSetting.SaveSetting(model_setting); + return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "鏃犳硶閾炬帴宸ユ帶鏈嶅姟鍣�,閿欒鍘熷洜:" + ex.Message}; } - dto_setting.UnablePumpIndexArray = model_setting.UnablePumpIndexArray; -- Gitblit v1.9.3