From 06e0e3b7d61e95902a6129de2490461cd0693e1d Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 15 十月 2025 15:06:40 +0800
Subject: [PATCH] 新增异步方法并优化服务调用逻辑在多个数据库文件中进行了二进制文件的修改、删除和新增操作,可能涉及数据库内容的更新或重建。在 HttpsClient.cs文件中新增了 PostNotLimitAsync方法,用于发送支持 JSON 格式的异步 HTTP POST 请求,并记录请求和响应参数。在 AgingInOrOutInputService.cs文件中,将 HttpsClient.PostAsync替换为PostNotLimitAsync,以利用新方法的功能特性。同时删除了不再需要的注释代码。
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 117 ++++++++++++++++++++++++++++++++--------------------------
1 files changed, 65 insertions(+), 52 deletions(-)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index 8cfd6d0..7662b61 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,5 +1,6 @@
锘縰sing Mapster;
using Masuit.Tools;
+using SixLabors.Fonts.Tables.AdvancedTypographic;
using SqlSugar;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -85,30 +86,30 @@
{
if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
{
- if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+ //if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+ //{
+ if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB")
{
- if (!task.Roadway.Contains("FR") && stock.ProcessCode != "OCVB")
+ var agingOutputDto = MapToAgingOutputDto(stock);
+ content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
+
+ if (content.Status)
{
- var agingOutputDto = MapToAgingOutputDto(stock);
- content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto);
+ var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
- if (content.Status)
+ if (!result.Success && result.MessageCode == "E10001")
{
- var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString());
-
- if (!result.Success && result.MessageCode == "E10001")
- {
- await HandleOutBoundError(stock, task);
- }
- }
- else
- {
- task.Remark = "NG";
- ConsoleHelper.WriteErrorLine("MOM閫氭姤鐐硅姱NG");
- return content.Error("MOM閫氭姤鐐硅姱NG");
+ await HandleOutBoundError(stock, task);
}
}
+ else
+ {
+ task.Remark = "NG";
+ ConsoleHelper.WriteErrorLine("MOM閫氭姤鐐硅姱NG");
+ return content.Error("MOM閫氭姤鐐硅姱NG");
+ }
}
+ //}
}
if (task.Remark == "NG")
@@ -428,8 +429,8 @@
Console.WriteLine(err.Message.ToString());
LogFactory.GetLog("浠诲姟瀹屾垚").Error(true, err);
content.Error(err.Message);
- task.ErrorMessage= err.Message;
- task.TaskState=(int)TaskInStatusEnum.SC_InExecuting;
+ task.ErrorMessage = err.Message;
+ task.TaskState = (int)TaskInStatusEnum.SC_InExecuting;
await BaseDal.Update(task);
}
return content;
@@ -616,13 +617,13 @@
}
LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "楠岃瘉浠诲姟鏄惁瀛樺湪", JsonConvert.SerializeObject(task));
- if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
- {
- return await CompleteInToOutTaskAsync(task);
- }
+
// 楠岃瘉搴撳瓨鏄惁瀛樺湪
var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
-
+ if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
+ {
+ return await CompleteInToOutTaskAsync(task, stock);
+ }
// 鏍规嵁浠诲姟绫诲瀷璋冪敤鐩稿簲鐨勫畬鎴愪换鍔℃柟娉�
switch (task.TaskType)
{
@@ -636,7 +637,7 @@
case (int)TaskOutboundTypeEnum.OutTray:
case (int)TaskOutboundTypeEnum.Outbound:
case (int)TaskOutboundTypeEnum.OutNG:
-
+
LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍑哄簱浠诲姟", "");
return await CompleteStackTaskAsync(task, stock);
@@ -647,7 +648,6 @@
case (int)TaskRelocationTypeEnum.Relocation:
return await CompleteTransferTaskAsync(task, stock);
-
default:
return content.Error("浠诲姟绫诲瀷涓嶅瓨鍦�");
}
@@ -674,6 +674,11 @@
var stock = await QueryStockInfo(input.PalletCode);
if (stock != null)
{
+ List<string> strings = new List<string>() { "GW", "CW", "FR" };
+ if (stock.AreaCode.Contains(strings))
+ {
+ return content.Error($"鎵樼洏銆恵stock.PalletCode}銆戝瓨鍦ㄥ簱瀛樹笉鍏佽鍏ュ簱");
+ }
Dt_Task taskNew = new Dt_Task
{
Grade = 1,
@@ -764,6 +769,7 @@
// return await HandleErrorCells(input, area, serialNosError);
//}
#endregion
+
var boxing = CreateBoxingInfo(result, input.PalletCode);
if (boxing == null) return content.Error("缁勭洏澶辫触");
@@ -776,6 +782,7 @@
// 鏇磋缁嗙殑寮傚父澶勭悊锛屽彲浠ユ牴鎹紓甯哥被鍨嬭褰曚笉鍚岀殑閿欒鏃ュ織绛�
content.Error(err.Message);
Console.WriteLine(err.Message);
+ LogFactory.GetLog($"璇锋眰鍏ュ簱寮傚父").Info(true, $"寮傚父淇℃伅銆恵err.Message}銆戝紓甯歌銆恵err.StackTrace}銆�");
}
return content;
@@ -859,8 +866,8 @@
var configOne = _configService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStacker, SysConfigConst.CHInboundEmptyProductLineOne);
var configTwo = _configService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStacker, SysConfigConst.CHInboundEmptyProductLineTwo);
- List<string> productLineconfigOne = configOne.ConfigValue.Split(',').ToList();
- List<string> productLineconfigTwo = configTwo.ConfigValue.Split(',').ToList();
+ List<string> productLineconfigOne = configOne.ConfigValue.Split(',').ToList();
+ List<string> productLineconfigTwo = configTwo.ConfigValue.Split(',').ToList();
if (productLineconfigOne.Count == 0 && productLineconfigTwo.Count() == 0)
{
@@ -879,13 +886,13 @@
{
ConsoleHelper.WriteErrorLine($"鏈壘鍒皗result.ProductionLine}瀵瑰簲閰嶇疆宸烽亾");
return content.Error($"鏈壘鍒皗result.ProductionLine}瀵瑰簲閰嶇疆宸烽亾");
- }
+ }
}
else
{
strings = stationManagers.Roadway.Split(',').ToList();
}
-
+
return await CreateNewTask(input, result.ProductionLine, result.ProcessCode, strings, 1);
}
@@ -904,8 +911,8 @@
// 鑾峰彇缁勭洏淇℃伅
private DtBoxingInfo CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
- {
- var boxing=_boxingInfoRepository.QueryFirst(x=>x.PalletCode == palletCode);
+ {
+ var boxing = _boxingInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
if (boxing == null)
{
return new DtBoxingInfo
@@ -924,8 +931,11 @@
}).ToList()
};
}
- else {
- _boxingInfoRepository.DeleteData(boxing);
+ else
+ {
+ _boxingInfoRepository.Db.DeleteNav<DtBoxingInfo>(x => x.Id == boxing.Id)
+ .Include(x => x.BoxingInfoDetails)
+ .ExecuteCommandAsync();
return new DtBoxingInfo
{
PalletCode = palletCode,
@@ -942,7 +952,7 @@
}).ToList()
};
}
-
+
}
// 鑾峰彇宸ヨ壓鐢宠
@@ -976,6 +986,8 @@
WebResponseContent content = new WebResponseContent();
try
{
+ // 璁板綍寮傚父淇℃伅骞舵姏鍑�
+ LogFactory.GetLog($"{position}璇锋眰{productionLine}浠诲姟").Info(true, $"{position}-{tag}-{areaCode}-{JsonConvert.SerializeObject(areaCodes)}-{productionLine}");
// 鏍规嵁鎵樼洏绫诲瀷鏌ヨ搴撳瓨淇℃伅
DtStockInfo stockInfo = tag == (int)TaskOutboundTypeEnum.Outbound
? areaCode != "CWSC1" ? await QueryStockInfoForRealTrayAsync(areaCode, areaCodes, productionLine) : await QueryStockInfoForRealTrayCWAsync(areaCodes, productionLine)
@@ -1306,7 +1318,7 @@
if (stockInfo.AreaCode.Contains("CH"))
{
// 鍒涘缓骞舵坊鍔犱换鍔″埌鏁版嵁搴�
- if(stockInfo.LocationInfo.RoadwayNo=="CHSC1"|| stockInfo.LocationInfo.RoadwayNo == "CHSC2"|| stockInfo.LocationInfo.RoadwayNo == "CHSC3")
+ if (stockInfo.LocationInfo.RoadwayNo == "CHSC1" || stockInfo.LocationInfo.RoadwayNo == "CHSC2" || stockInfo.LocationInfo.RoadwayNo == "CHSC3")
{
task = CreateTask(stockInfo, "1020-1", taskType);
}
@@ -1314,7 +1326,7 @@
{
task = CreateTask(stockInfo, "1049-8", taskType);
}
-
+
}
else
{
@@ -1738,21 +1750,20 @@
// 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷
try
{
- Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key[0]));
- if (task == null)
+ foreach (var item in key)
{
- return content.Error("鏈壘鍒颁换鍔′俊鎭�!");
+ Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key));
+ if (task == null)
+ {
+ return content.Error("鏈壘鍒颁换鍔′俊鎭�!");
+ }
+ var taskHtyNG = CreateHistoricalTask(task, true);
+ // 娣诲姞鍘嗗彶浠诲姟
+ var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
+
+ // 鍒犻櫎浠诲姟鏁版嵁
+ var isTaskDelete = BaseDal.Delete(task.TaskId);
}
- var taskHtyNG = CreateHistoricalTask(task, true);
-
- // 鎵ц鏁版嵁搴撲簨鍔�
-
- // 娣诲姞鍘嗗彶浠诲姟
- var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
-
- // 鍒犻櫎浠诲姟鏁版嵁
- var isTaskDelete = BaseDal.Delete(task.TaskId);
-
return content.OK("鍒犻櫎鎴愬姛!");
}
catch (Exception ex)
@@ -1886,7 +1897,6 @@
{
taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System";
}
- taskHty.TaskState = task.TaskType > 199 ? (int)TaskInStatusEnum.InFinish : (int)TaskOutStatusEnum.OutFinish;
return taskHty;
}
@@ -2143,7 +2153,10 @@
ToAddress = await GetRoadWayAsync(process);
else
ToAddress = process[0];
-
+ if (string.IsNullOrEmpty(ToAddress))
+ {
+ return content.Error("鏃犳硶鑾峰彇鐩爣鍦板潃");
+ }
// 鍒涘缓鏂颁换鍔″疄渚�
var task = new Dt_Task
{
--
Gitblit v1.9.3