From ce1292c9cf37195b6abd2699dfc5d6cb3e143c9b Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 23:38:19 +0800
Subject: [PATCH] feat(MES): 添加MES接口相关实体和DTO JS扩展文件至JSX格式并更新配置
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Inbound.cs | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 210 insertions(+), 0 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Inbound.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Inbound.cs
new file mode 100644
index 0000000..0a1f053
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/WCS/TaskService_Inbound.cs
@@ -0,0 +1,210 @@
+using WIDESEA_Common.Constants;
+using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.StockEnum;
+using WIDESEA_Common.TaskEnum;
+using WIDESEA_Common.WareHouseEnum;
+using WIDESEA_Core;
+using WIDESEA_DTO.Task;
+using WIDESEA_Model.Models;
+
+namespace WIDESEA_TaskInfoService
+{
+ public partial class TaskService
+ {
+ #region 鍏ュ簱浠诲姟
+
+ /// <summary>
+ /// 鍒涘缓浠诲姟锛堢粍鐩樺叆搴撲换鍔°�佺┖鎵樼洏鍥炲簱浠诲姟锛�
+ /// </summary>
+ public async Task<WebResponseContent> CreateTaskInboundAsync(CreateTaskDto taskDto)
+ {
+ try
+ {
+ WebResponseContent content = await GetTaskByPalletCodeAsync(taskDto.PalletCode);
+ if (content.Status)
+ {
+ return content;
+ }
+
+ if (string.IsNullOrWhiteSpace(taskDto.PalletCode) ||
+ string.IsNullOrWhiteSpace(taskDto.Roadway))
+ {
+ return WebResponseContent.Instance.Error("鏃犳晥鐨勪换鍔¤鎯�");
+ }
+
+ if (taskDto.TaskType != TaskTypeEnum.Inbound && taskDto.TaskType != TaskTypeEnum.InEmpty)
+ {
+ return WebResponseContent.Instance.Error("鏃犳晥鐨勪换鍔¤鎯�");
+ }
+
+ // 浣跨敤 switch 琛ㄨ揪寮忔槧灏勪换鍔$被鍨�
+ int taskInboundType = taskDto.TaskType switch
+ {
+ TaskTypeEnum.Inbound => TaskInboundTypeEnum.Inbound.GetHashCode(),
+ TaskTypeEnum.InEmpty => TaskInboundTypeEnum.InEmpty.GetHashCode(),
+ _ => 0 // 鐞嗚涓婁笉浼氳蛋鍒拌繖閲岋紝鍥犱负宸茬粡楠岃瘉杩囦簡
+ };
+
+ var task = new Dt_Task
+ {
+ TaskNum = await BaseDal.GetTaskNo(),
+ PalletCode = taskDto.PalletCode,
+ PalletType = taskDto.PalletType,
+ Roadway = taskDto.Roadway,
+ TaskType = taskInboundType,
+ TaskStatus = TaskInStatusEnum.InNew.GetHashCode(),
+ SourceAddress = taskDto.SourceAddress,
+ TargetAddress = taskDto.TargetAddress,
+ CurrentAddress = taskDto.SourceAddress,
+ NextAddress = taskDto.TargetAddress,
+ WarehouseId = taskDto.WarehouseId,
+ Grade = 1,
+ Creater = "system"
+ };
+
+ var result = await Repository.AddDataAsync(task) > 0;
+ if (!result) return WebResponseContent.Instance.Error("浠诲姟鍒涘缓澶辫触");
+
+ var wmstaskDto = _mapper.Map<WMSTaskDTO>(task);
+ return WebResponseContent.Instance.OK("浠诲姟鍒涘缓鎴愬姛", wmstaskDto);
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"浠诲姟鍒涘缓澶辫触: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇鍙叆搴撹揣浣�
+ /// </summary>
+ public async Task<WebResponseContent> GetTasksLocationAsync(CreateTaskDto taskDto)
+ {
+ try
+ {
+ var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode);
+ if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
+
+ var locationInfo = await _locationInfoService.GetLocationInfo(task.Roadway);
+ if (locationInfo == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑璐т綅");
+
+ return await _unitOfWorkManage.BeginTranAsync(async () =>
+ {
+ locationInfo.LocationStatus = LocationStatusEnum.FreeLock.GetHashCode();
+ task.CurrentAddress = task.SourceAddress;
+ task.NextAddress = locationInfo.LocationCode;
+ task.TargetAddress = locationInfo.LocationCode;
+ task.TaskStatus = TaskInStatusEnum.Line_InFinish.GetHashCode();
+
+ var updateTaskResult = await BaseDal.UpdateDataAsync(task);
+ var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(locationInfo);
+ if (!updateTaskResult || !updateLocationResult)
+ {
+ return WebResponseContent.Instance.Error("浠诲姟鏇存柊澶辫触");
+ }
+
+ return WebResponseContent.Instance.OK("浠诲姟鏇存柊鎴愬姛", locationInfo.LocationCode);
+ });
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鑾峰彇浠诲姟澶辫触: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 鍏ュ簱浠诲姟瀹屾垚锛氭坊鍔犲簱瀛橈紝淇敼璐т綅鐘舵�侊紝鍒犻櫎浠诲姟鏁版嵁锛屾坊鍔犲巻鍙蹭换鍔℃暟鎹�
+ /// </summary>
+ public async Task<WebResponseContent> InboundFinishTaskAsync(CreateTaskDto taskDto)
+ {
+ try
+ {
+ var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode);
+ if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
+
+ var location = await _locationInfoService.GetLocationInfo(task.Roadway, task.TargetAddress);
+ if (location == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑璐т綅");
+
+ var stockInfo = await _stockInfoService.GetStockInfoAsync(taskDto.PalletCode);
+ if (stockInfo == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴斿簱瀛樹俊鎭�");
+
+ // 鍒ゆ柇鏄笉鏄瀬鍗峰簱浠诲姟
+ if (taskDto.WarehouseId == (int)WarehouseEnum.FJ1 || taskDto.WarehouseId == (int)WarehouseEnum.ZJ1)
+ {
+ return await CompleteAgvInboundTaskAsync(taskDto);
+ }
+
+ return await _unitOfWorkManage.BeginTranAsync(async () =>
+ {
+ WebResponseContent content = new WebResponseContent();
+ stockInfo.LocationCode = location.LocationCode;
+ stockInfo.LocationId = location.Id;
+
+ SetOutboundDateByRoadway(task, stockInfo);
+
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.GetHashCode();
+
+ location.LocationStatus = LocationStatusEnum.InStock.GetHashCode();
+
+ var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(location);
+ var updateStockResult = await _stockInfoService.UpdateStockAsync(stockInfo);
+ if (!updateLocationResult || !updateStockResult)
+ return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
+ // 璋冪敤MES鎵樼洏杩涚珯
+ //var inboundRequest = new InboundInContainerRequest
+ //{
+ // EquipmentCode = "STK-GROUP-001",
+ // ResourceCode = "STK-GROUP-001",
+ // LocalTime = DateTime.Now,
+ // ContainerCode = taskDto.PalletCode
+ //};
+ //var inboundResult = _mesService.InboundInContainer(inboundRequest);
+ //if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess)
+ //{
+ // return content.Error($"浠诲姟瀹屾垚澶辫触锛歁ES杩涚珯澶辫触: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
+ //}
+ return await CompleteTaskAsync(task, "鍏ュ簱瀹屾垚");
+ });
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"瀹屾垚浠诲姟澶辫触: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁宸烽亾绫诲瀷璁剧疆搴撳瓨鐨勫嚭搴撴椂闂村拰澶囨敞
+ /// </summary>
+ /// <param name="task">浠诲姟淇℃伅</param>
+ /// <param name="stockInfo">搴撳瓨淇℃伅</param>
+ private void SetOutboundDateByRoadway(Dt_Task task, Dt_StockInfo stockInfo)
+ {
+ var now = DateTime.Now;
+ if (task.Roadway.Contains("GW"))
+ {
+ stockInfo.OutboundDate = string.IsNullOrEmpty(stockInfo.Remark)
+ ? now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST)
+ : stockInfo.Remark == StockRemarkConstants.GW1
+ ? now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_SECOND)
+ : now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST);
+
+ stockInfo.Remark = string.IsNullOrEmpty(stockInfo.Remark)
+ ? StockRemarkConstants.GW1
+ : stockInfo.Remark == StockRemarkConstants.GW1
+ ? StockRemarkConstants.GW2
+ : stockInfo.Remark;
+ }
+ else if (task.Roadway.Contains("CW"))
+ {
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1);
+ if (stockInfo.Remark == StockRemarkConstants.GW2)
+ stockInfo.Remark = StockRemarkConstants.CW1;
+ }
+ else
+ {
+ stockInfo.OutboundDate = now;
+ }
+ }
+
+ #endregion 鍏ュ簱浠诲姟
+ }
+}
--
Gitblit v1.9.3