From c1eac732fc3ef407d51b76d288f311d2fa43e618 Mon Sep 17 00:00:00 2001
From: xby-y <2251528873@qq.com>
Date: 星期一, 12 一月 2026 15:18:41 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 162 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 127 insertions(+), 35 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 17eab30..74a61e7 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"
@@ -546,7 +546,7 @@
ApiResponse<object> apiResponse = new ApiResponse<object>();
apiResponse.Message = Message;
apiResponse.Success = Success;
- apiResponse.Code = 1;
+ apiResponse.Code = Code;
return apiResponse;
}
@@ -880,7 +880,7 @@
/// <param name="taskNum"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
- public WebResponseContent ManualTaskCompleted(string palletTaskDTO)
+ public ApiResponse<object> ManualTaskCompleted(string palletTaskDTO)
{
WebResponseContent webResponse = new WebResponseContent();
try
@@ -889,7 +889,7 @@
Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletTaskDTO);
if (task == null)
{
- return webResponse.Error($"鏈壘鍒版墭鐩樼紪鐮佷负銆恵palletTaskDTO}銆戠殑浠诲姟淇℃伅");
+ return MESresponse($"鏈壘鍒版墭鐩樼紪鐮佷负銆恵palletTaskDTO}銆戠殑浠诲姟淇℃伅", false, 0);
}
@@ -910,14 +910,15 @@
if (task.TaskType == TaskInboundTypeEnum.Inbound.ObjToInt() || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
{
stockmsseg = _stockRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
- if (stockmsseg == null) { return webResponse.Error("鏈壘鍒板簱瀛樹俊鎭�"); };
+ if (stockmsseg == null) { return MESresponse($"鏈壘鍒板簱瀛樹俊鎭�", false, 0); }
+ ;
stockmsseg.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
resstock = _stockRepository.UpdateData(stockmsseg);
if (task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
{
locationmsseg1 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
locationmsseg2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.CurrentAddress);
- if (locationmsseg1 == null || locationmsseg2 == null) { webResponse.Error("鏈壘鍒拌揣浣嶄俊鎭�"); }
+ if (locationmsseg1 == null || locationmsseg2 == null) { return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�", false, 0); }
locationmsseg1.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
locationmsseg2.LocationStatus = LocationStatusEnum.Free.ObjToInt();
location1 = _locationInfoRepository.UpdateData(locationmsseg1);
@@ -926,7 +927,7 @@
else
{
locationmsseg1 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
- if (locationmsseg1 == null) { webResponse.Error("鏈壘鍒拌揣浣嶄俊鎭�"); }
+ if (locationmsseg1 == null) { return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�", false, 0); }
locationmsseg1.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
location1 = _locationInfoRepository.UpdateData(locationmsseg1);
@@ -935,10 +936,10 @@
else
{
stockmsseg = _stockRepository.QueryFirst(x => x.LocationCode == task.CurrentAddress);
- if (stockmsseg == null) { return webResponse.Error("鏈壘鍒板簱瀛樹俊鎭�"); }
+ if (stockmsseg == null) { return MESresponse($"鏈壘鍒板簱瀛樹俊鎭�", false, 0); }
resstock = _stockRepository.DeleteData(stockmsseg);
locationmsseg1 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.CurrentAddress);
- if (locationmsseg1 == null) { webResponse.Error("鏈壘鍒拌揣浣嶄俊鎭�"); }
+ if (locationmsseg1 == null) { return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�", false, 0); }
locationmsseg1.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
location1 = _locationInfoRepository.UpdateData(locationmsseg1);
}
@@ -952,7 +953,7 @@
if (WCSReceiveTaskAPI == null)
{
_unitOfWorkManage.RollbackTran();
- return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
+ return MESresponse($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛", false, 0);
}
string apiUrl = $"{WCSReceiveTaskAPI}?taskNum={task.TaskNum}";
@@ -961,53 +962,144 @@
if (respon == null)
{
_unitOfWorkManage.RollbackTran();
- return webResponse.Error($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+ return MESresponse($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�", false, 0);
}
var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
if (!response.status)
{
_unitOfWorkManage.RollbackTran();
- return webResponse.Error($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+ return MESresponse($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}", false, 0);
+
}
if (!(resstock && task_htymsseg && taskmsseg && task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt() ? (location1 && location2) : location1))
{
_unitOfWorkManage.RollbackTran();
- return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触");
+ return MESresponse($"浠诲姟鎵嬪姩瀹屾垚澶辫触", false, 0);
}
- //鑾峰彇鎺ュ彛杩涜璋冨彇
- var MESConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESmockComplete); //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
- string MESmockComplete = MESConfigsAPIInfo.ApiAddress + MESConfigsAPIInfo.ApiName;
- if (MESConfigsAPIInfo == null)
+ ////鑾峰彇鎺ュ彛杩涜璋冨彇
+ //var MESConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESmockComplete); //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
+ //string MESmockComplete = MESConfigsAPIInfo.ApiAddress + MESConfigsAPIInfo.ApiName;
+ //if (MESConfigsAPIInfo == null)
+ //{
+ // _unitOfWorkManage.RollbackTran();
+ // return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆MES浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
+ //}
+ //var MES = new
+ //{
+ // businessId = task.MESbusinessId,
+ // taskId = task.MEStaskId,
+ // palletCode = task.PalletCode
+ //};
+ //var MESrespon = HttpHelper.Post(MESmockComplete, JsonConvert.SerializeObject(MES));
+ //if (respon == null)
+ //{
+ // _unitOfWorkManage.RollbackTran();
+ // return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+ //}
+ //var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(MESrespon);
+ //if (!MESresponse.Success)
+ //{
+ // _unitOfWorkManage.RollbackTran();
+ // return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+ //}
+
+ WebResponseContent content;
+ switch (task.TaskType)
{
- _unitOfWorkManage.RollbackTran();
- return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆MES浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
+ case (int)TaskRelocationTypeEnum.Relocation:
+ content = MES_TransferCompletionFeedback(task);
+ break;
+ case (int)TaskInboundTypeEnum.Inbound:
+ content = TaskCompletionFeedback(task);
+ break;
+ case (int)TaskOutboundTypeEnum.Outbound:
+ content = TaskCompletionFeedback(task);
+ break;
+ default: return MESresponse($"浠诲姟绫诲瀷閿欒锛屼换鍔″彿锛歿task.TaskNum}", false, 0);
}
- var MES = new
- {
- businessId = task.MESbusinessId,
- taskId = task.MEStaskId,
- palletCode = task.PalletCode
- };
- var MESrespon = HttpHelper.Post(MESmockComplete, JsonConvert.SerializeObject(MES));
- if (respon == null)
+ if (!content.Status)
{
_unitOfWorkManage.RollbackTran();
- return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
- }
- var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(MESrespon);
- if (!MESresponse.Success)
- {
- _unitOfWorkManage.RollbackTran();
- return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+ return MESresponse($"鎵嬪姩鍚慚ES鎺ュ彛鎶ュ畬鎴愬け璐task.TaskNum}", false, 0);
}
_unitOfWorkManage.CommitTran();
- return webResponse.OK("浠诲姟鎵嬪姩瀹屾垚鎴愬姛");
+ return MESresponse($"浠诲姟鎵嬪姩瀹屾垚鎴愬姛{task.TaskNum}", true, 1);
+
}
catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
- return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屽師鍥狅細{ex.Message}");
+ return MESresponse($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屽師鍥狅細{ex.Message}", false, 0);
+
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇瀹炴椂浠诲姟鍒楄〃
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent GetRealTimeTasks()
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ // 鏌ヨ鏈�鏂扮殑10鏉′换鍔¤褰�
+ var tasks = Repository.Db.Queryable<Dt_Task>()
+ .OrderByDescending(x => x.CreateDate)
+ .Take(10)
+ .ToList();
+
+ // 杞崲浠诲姟鏁版嵁涓哄墠绔渶瑕佺殑鏍煎紡
+ var result = tasks.Select(task => {
+ // 杞崲浠诲姟绫诲瀷
+ string taskTypeText = "鏈煡";
+ switch ((TaskInboundTypeEnum)task.TaskType)
+ {
+ case TaskInboundTypeEnum.Inbound:
+ taskTypeText = "鍏ュ簱";
+ break;
+ case (TaskInboundTypeEnum)TaskOutboundTypeEnum.Outbound:
+ taskTypeText = "鍑哄簱";
+ break;
+ case (TaskInboundTypeEnum)TaskRelocationTypeEnum.Relocation:
+ taskTypeText = "绉诲簱";
+ break;
+ }
+
+ // 杞崲浠诲姟鐘舵��
+ string taskStatusText = "鏈煡";
+ if ((TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.OutNew) {
+ taskStatusText = "寰呭鐞�";
+ } else if (
+ (TaskInStatusEnum)task.TaskStatus == TaskInStatusEnum.Line_InExecuting ||
+ (TaskInStatusEnum)task.TaskStatus == TaskInStatusEnum.SC_InExecuting ||
+ (TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.SC_OutExecuting ||
+ (TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.Line_OutExecuting
+ ) {
+ taskStatusText = "杩愯涓�";
+ } else if (
+ (TaskInStatusEnum)task.TaskStatus == TaskInStatusEnum.InFinish ||
+ (TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.OutFinish
+ ) {
+ taskStatusText = "宸插畬鎴�";
+ }
+
+ return new {
+ id = task.TaskId,
+ taskNum = task.TaskNum,
+ taskType = taskTypeText,
+ sourceAddress = task.SourceAddress,
+ targetAddress = task.TargetAddress,
+ taskStatus = taskStatusText
+ };
+ }).ToList();
+
+ return content.OK(data: result);
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
}
}
}
--
Gitblit v1.9.3