From d58196721475e968769d708d9c14f60dd8d5671f Mon Sep 17 00:00:00 2001
From: HuBingJie <3146306518@qq.com>
Date: 星期四, 13 十一月 2025 22:20:14 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 226 ++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 186 insertions(+), 40 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 09a2a21..cd6f546 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -1,4 +1,4 @@
-锘�#region << 鐗� 鏈� 娉� 閲� >>
+#region << 鐗� 鏈� 娉� 閲� >>
/*----------------------------------------------------------------
* 鍛藉悕绌洪棿锛歐IDESEA_TaskInfoService
* 鍒涘缓鑰咃細鑳$搴�
@@ -193,11 +193,11 @@
NextAddress = Nextlocation.LocationCode,
Grade = 1,
Creater = "WMS",
- Depth = ShallowLocation.Depth,
+ Depth = Nextlocation.Depth,
CreateDate = DateTime.Now,
};
- _locationInfoRepository.AddData(loca);
+ _locationInfoRepository.UpdateData(loca);
BaseDal.AddData(dt_Task); //鏂板浠诲姟
_unitOfWorkManage.CommitTran();
@@ -267,6 +267,8 @@
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
WebResponseContent content=MES_TransferCompletionFeedback(task);
+ //content.Status = true;
+
if (!content.Status)
{
_unitOfWorkManage.RollbackTran();
@@ -321,12 +323,15 @@
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
- /*WebResponseContent content = TaskCompletionFeedback(task);
+ WebResponseContent content = TaskCompletionFeedback(task);
+ //content.Status = true;
if (!content.Status)
{
_unitOfWorkManage.RollbackTran();
return content;
- }*/
+ }
+
+ //Thread.Sleep(5000);
_unitOfWorkManage.CommitTran();
}
@@ -367,13 +372,15 @@
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
_locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(), "1", task.TaskNum);
- /*WebResponseContent content = TaskCompletionFeedback(task);
+ WebResponseContent content = TaskCompletionFeedback(task);
+ //content.Status = true;
+
if (!content.Status)
{
_unitOfWorkManage.RollbackTran();
return content;
- }*/
-
+ }
+ //Thread.Sleep(5000);
_unitOfWorkManage.CommitTran();
return webResponse.OK();
}
@@ -404,17 +411,26 @@
try
{
+ string locationCode = null;
+ if (dt_Task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+ {
+ locationCode = dt_Task.SourceAddress;
+ }
+ else
+ {
+ locationCode = dt_Task.TargetAddress;
+ }
TransferRequest transferRequest = new TransferRequest()
{
//涓氬姟id锛屼换鍔d鍚庣画杩涜鏇存敼
- businessId = "1",
- TaskId = "1",
- SourceLocationCode = dt_Task.SourceAddress,
- LocationCode = dt_Task.TargetAddress,
- PalletCode = dt_Task.PalletCode,
- Status = "FINISH",
- ErrorStatus = "NORMAL",
- ErrorInfo = "",
+ taskId = dt_Task.MEStaskId, //浠诲姟id
+ businessId = dt_Task.MESbusinessId, //涓氬姟id
+ sourceLocationCode = dt_Task.SourceAddress,
+ locationCode = locationCode,
+ palletCode = dt_Task.PalletCode,
+ status = "FINISH",
+ errorStatus = "NORMAL",
+ errorInfo = "",
};
//鑾峰彇鎺ュ彛杩涜璋冨彇
@@ -422,25 +438,27 @@
string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
if (WCSReceiveTaskAPI == null)
{
- return webResponse.Error($"鍑哄簱澶辫触锛屾湭閰嶇疆MES绉诲簱瀹屾垚鍙嶉鎺ュ彛");
+ return webResponse.Error($"鍑哄簱澶辫触锛屾湭閰嶇疆MES绉诲簱瀹屾垚鍙嶉鎺ュ彛");
}
var respon = HttpHelper.Post(WCSReceiveTaskAPI, JsonConvert.SerializeObject(transferRequest));
if (respon != null)
{
- var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
- if (response.Success)
- {
- return webResponse.OK();
- }
- else
- {
- return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
- }
+ var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
+ if (response.Success)
+ {
+ return webResponse.OK();
+ }
+ else
+ {
+ return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+ }
}
else
{
- return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+ return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
}
+
+ return webResponse.OK();
}
catch (Exception ex)
{
@@ -461,17 +479,26 @@
try
{
- TaskNotification transferRequest = new TaskNotification()
+ string locationCode = null;
+ if (dt_Task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
{
- //涓氬姟id锛屼换鍔d鍚庣画杩涜鏇存敼
- TaskId = "1", //浠诲姟id
- BusinessId = "1", //涓氬姟id
- PalletCode = dt_Task.PalletCode,
- SubPalletCode = "",//瀛愭墭鐩樼紪鐮�
- LocationCode = dt_Task.SourceAddress,
- ErrorStatus = "NORMAL",
- ErrorInfo = "",
- };
+ locationCode = dt_Task.SourceAddress;
+ }
+ else
+ {
+ locationCode = dt_Task.TargetAddress;
+ }
+ TaskNotification transferRequest = new TaskNotification()
+ {
+ //涓氬姟id锛屼换鍔d鍚庣画杩涜鏇存敼
+ taskId = dt_Task.MEStaskId, //浠诲姟id
+ businessId = dt_Task.MESbusinessId, //涓氬姟id
+ palletCode = dt_Task.PalletCode,
+ subPalletCode = dt_Task.MESsubPalletCode,//瀛愭墭鐩樼紪鐮�
+ locationCode = locationCode,
+ errorStatus = "NORMAL",
+ errorInfo = "",
+ };
//鑾峰彇鎺ュ彛杩涜璋冨彇
var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESTaskFeedback); //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
@@ -480,7 +507,14 @@
{
return webResponse.Error($"浠诲姟鍙嶉MES澶辫触锛屾湭閰嶇疆MES浠诲姟瀹屾垚鍙嶉鎺ュ彛");
}
- var respon = HttpHelper.Post(WCSReceiveTaskAPI, JsonConvert.SerializeObject(transferRequest));
+
+ // 娣诲姞璋冭瘯淇℃伅
+ string requestJson = JsonConvert.SerializeObject(transferRequest);
+ //Console.WriteLine($"MES鍙嶉鎺ュ彛URL: {WCSReceiveTaskAPI}");
+ //Console.WriteLine($"MES鍙嶉璇锋眰鏁版嵁: {requestJson}");
+
+ // 浣跨敤淇鍚庣殑PostSync鏂规硶锛堝凡鍦≒ostSync涓缃粯璁よ姹傚ご锛�
+ var respon = HttpHelper.Post(WCSReceiveTaskAPI, requestJson);
if (respon != null)
{
var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
@@ -505,7 +539,7 @@
}
}
- public ApiResponse<object> MESresponse(string Message, bool Success)
+ public ApiResponse<object> MESresponse(string Message, bool Success,int Code)
{
ApiResponse<object> apiResponse = new ApiResponse<object>();
apiResponse.Message = Message;
@@ -514,8 +548,33 @@
return apiResponse;
}
+ /// <summary>
+ /// 鍙栨秷浠诲姟鎺ュ彛
+ /// </summary>
+ /// <param name="taskNum">浠诲姟鍙�</param>
+ /// <returns></returns>
+ public WebResponseContent Cancelinventory(int taskNum)
+ {
+ WebResponseContent webResponse = new WebResponseContent();
+ try
+ {
+ // 鏌ユ壘浠诲姟
+ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.TaskStatus == TaskOutStatusEnum.OutFinish.ObjToInt());
+ if (task == null)
+ {
+ return webResponse.Error($"鏈壘鍒颁换鍔″彿涓恒�恵taskNum}銆戠殑浠诲姟淇℃伅");
+ }
-
+ // TODO: 杩欓噷鍚庣画闇�瑕佹坊鍔犲叿浣撶殑鍙栨秷浠诲姟涓氬姟閫昏緫
+ // 渚嬪锛氭洿鏂颁换鍔$姸鎬併�侀噴鏀捐揣浣嶃�侀�氱煡WCS绛�
+
+ return webResponse.OK("浠诲姟鍙栨秷鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ return webResponse.Error($"鍙栨秷浠诲姟澶辫触锛屽師鍥狅細{ex.Message}");
+ }
+ }
/// <summary>
/// 鍒涘缓璐т綅
@@ -603,5 +662,92 @@
}
return MESresponse($"", true);
}
+
+
+ public static string GetLastPart(string locationCode)
+ {
+ string[] parts = locationCode.Split('-');
+ return parts[parts.Length - 1];
+ }
+
+
+ /// <summary>
+ /// 鍑哄簱
+ /// </summary>
+ /// <param name="locationCode"></param>
+ /// <returns></returns>
+ /// <exception cref="NotImplementedException"></exception>
+ public WebResponseContent chuku(string locationCode)
+ {
+
+ try
+ {
+ int result = GetLastPart(locationCode).ObjToInt(); // 杩斿洖 "C03"
+ List<Dt_Task> dt_s = new List<Dt_Task>();
+ //鐢熸垚绉诲姩浠诲姟
+ Dt_Task dt_Task = new()
+ {
+ PalletCode = "1111",
+ TaskNum = 111,
+ Roadway = "SC01",
+ TaskType = TaskOutboundTypeEnum.Outbound.ObjToInt(),
+ TaskStatus = TaskOutStatusEnum.OutNew.ObjToInt(),
+ SourceAddress = locationCode,
+ TargetAddress = "1002",
+ CurrentAddress = locationCode,
+ NextAddress = "1002",
+ Grade = 1,
+ Creater = "MES",
+ Depth = result,
+ CreateDate = DateTime.Now,
+ MEStaskId = "111",
+ MESbusinessId = "123456",
+ MESsubPalletCode = "",
+ OutboundPlatform = "1001"
+ };
+
+ //鍒涘缓缁勭洏淇℃伅
+ var dt_Stock = new Dt_StockInfo
+ {
+ PalletCode = dt_Task.PalletCode,
+ PalletType = 1,
+ LocationCode = locationCode,
+ StockStatus = 6,
+ Creater = "WMS",
+ CreateDate = DateTime.Now,
+ MESsubPalletCode = dt_Task.MESsubPalletCode,
+ };
+
+ Dt_LocationInfo dt_LocationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == locationCode);
+ dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.InStockLock;
+
+ bool l = _locationInfoRepository.UpdateData(dt_LocationInfo);
+ int s = _stockRepository.AddData(dt_Stock);
+ int t = BaseDal.AddData(dt_Task);
+ bool ss = s.ObjToBool();
+ bool tt = t.ObjToBool();
+
+
+ if (!l && !ss && tt)
+ {
+ _unitOfWorkManage.RollbackTran();
+ }
+
+ dt_s.Add(dt_Task);
+ var respon = PushTasksToWCS(dt_s, "");
+ if (respon.Status)
+ {
+ _unitOfWorkManage.CommitTran(); //鎻愪氦浜嬪姟
+ return WebResponseContent.Instance.OK();
+ }
+ return WebResponseContent.Instance.Error();
+ }
+ catch
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error();
+
+ }
+ }
}
}
--
Gitblit v1.9.3