From f7ec7a32e8cddcb976093c826e3a0d1ed61fb335 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 13:09:43 +0800
Subject: [PATCH] feat(任务服务): 扩展任务更新接口以支持地址信息

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs |   86 ++++++++++++++++++++----------------------
 1 files changed, 41 insertions(+), 45 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
index 9c14375..3ff0a10 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
@@ -1,27 +1,15 @@
 using Mapster;
-using MapsterMapper;
 using Microsoft.Extensions.Configuration;
 using SqlSugar;
-using System.DirectoryServices.Protocols;
-using System.Text.Json;
 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_Core.BaseRepository;
-using WIDESEA_Core.BaseServices;
-using WIDESEA_Core.Core;
-using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
-using WIDESEA_DTO.GradingMachine;
-using WIDESEA_DTO.MES;
 using WIDESEA_DTO.Stock;
 using WIDESEA_DTO.Task;
-using WIDESEA_IBasicService;
-using WIDESEA_IStockService;
-using WIDESEA_ITaskInfoService;
 using WIDESEA_Model.Models;
 
 namespace WIDESEA_TaskInfoService
@@ -185,7 +173,6 @@
                 // 鍒ゆ柇鏄笉鏄瀬鍗峰簱浠诲姟
                 if (taskDto.WarehouseId == (int)WarehouseEnum.FJ1 || taskDto.WarehouseId == (int)WarehouseEnum.ZJ1)
                 {
-
                     return await CompleteAgvInboundTaskAsync(taskDto);
                 }
 
@@ -580,18 +567,20 @@
         /// <param name="taskId"></param>
         /// <param name="newStatus"></param>
         /// <returns></returns>
-        public async Task<WebResponseContent> UpdateTaskByStatusAsync(int taskId, int newStatus)
+        public async Task<WebResponseContent> UpdateTaskByStatusAsync(UpdateTaskDto taskDto)
         {
             try
             {
-                var tasks = await BaseDal.QueryFirstAsync(s => s.TaskNum == taskId);
-                if (tasks == null)
+                var taskInfo = await BaseDal.QueryFirstAsync(s => s.TaskNum == taskDto.Id);
+                if (taskInfo == null)
                     return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
 
-                tasks.TaskStatus = newStatus;
-                await BaseDal.UpdateDataAsync(tasks);
+                taskInfo.TaskStatus = taskDto.NewStatus;
+                taskInfo.NextAddress = taskDto.NextAddress;
+                taskInfo.CurrentAddress = taskDto.CurrentAddress;
+                await BaseDal.UpdateDataAsync(taskInfo);
 
-                return WebResponseContent.Instance.OK("淇敼鎴愬姛", tasks);
+                return WebResponseContent.Instance.OK("淇敼鎴愬姛", taskInfo);
             }
             catch (Exception ex)
             {
@@ -885,31 +874,31 @@
         {
             try
             {
-                // 1. 鏍规嵁浠诲姟绫诲瀷瀛楃涓茬‘瀹� TaskType 鍜� TaskStatus
                 int taskType;
                 int taskStatus;
                 switch (dto.TaskType)
                 {
                     case "鍏ュ簱":
-                        taskType = TaskTypeEnum.Inbound.GetHashCode();
+                        taskType = TaskInboundTypeEnum.Inbound.GetHashCode();
                         taskStatus = TaskInStatusEnum.InNew.GetHashCode();
                         break;
+
                     case "鍑哄簱":
-                        taskType = TaskTypeEnum.Outbound.GetHashCode();
+                        taskType = TaskOutboundTypeEnum.Outbound.GetHashCode();
                         taskStatus = TaskOutStatusEnum.OutNew.GetHashCode();
                         break;
+
                     case "绉诲簱":
-                        taskType = TaskTypeEnum.Relocation.GetHashCode();
+                        taskType = TaskRelocationTypeEnum.Relocation.GetHashCode();
                         taskStatus = TaskRelocationStatusEnum.RelocationNew.GetHashCode();
                         break;
+
                     default:
                         return WebResponseContent.Instance.Error($"涓嶆敮鎸佺殑浠诲姟绫诲瀷: {dto.TaskType}");
                 }
 
-                // 2. 鐢熸垚浠诲姟鍙�
                 int taskNum = await BaseDal.GetTaskNo();
 
-                // 3. 鏋勫缓浠诲姟瀹炰綋
                 var task = new Dt_Task
                 {
                     TaskNum = taskNum,
@@ -919,6 +908,7 @@
                     TaskType = taskType,
                     TaskStatus = taskStatus,
                     Grade = dto.Grade,
+                    Roadway = dto.TargetAddress,
                     WarehouseId = dto.WarehouseId,
                     CurrentAddress = dto.SourceAddress,
                     NextAddress = dto.TargetAddress,
@@ -927,31 +917,37 @@
                     ModifyDate = DateTime.Now
                 };
 
-                // 4. 淇濆瓨鍒版暟鎹簱
-                var result = await BaseDal.AddDataAsync(task) > 0;
-                if (!result)
-                    return WebResponseContent.Instance.Error("鍒涘缓浠诲姟澶辫触");
-
-                // 5. 鍙戦�佸埌 WCS
-                var wmsTaskDto = new WMSTaskDTO
+                var wmsTaskDtos = new List<WMSTaskDTO>()
                 {
-                    TaskNum = task.TaskNum,
-                    PalletCode = task.PalletCode,
-                    SourceAddress = task.SourceAddress,
-                    TargetAddress = task.TargetAddress,
-                    TaskType = task.TaskType,
-                    TaskStatus = task.TaskStatus,
-                    WarehouseId = task.WarehouseId
+                    new()
+                    {
+                        TaskNum = task.TaskNum,
+                        PalletCode = task.PalletCode,
+                        SourceAddress = task.SourceAddress,
+                        TargetAddress = task.TargetAddress,
+                        TaskType = task.TaskType,
+                        Roadway = task.Roadway,
+                        TaskStatus = task.TaskStatus,
+                        WarehouseId = task.WarehouseId
+                    }
                 };
 
-                var wcsResult = _httpClientHelper.Post<WebResponseContent>(
-                    "http://localhost:9292/api/Task/ReceiveManualTask",
-                    wmsTaskDto.ToJson());
+               return await _unitOfWorkManage.BeginTranAsync(async () =>
+                {
+                    // 4. 淇濆瓨鍒版暟鎹簱
+                    var result = await BaseDal.AddDataAsync(task) > 0;
+                    if (!result)
+                        return WebResponseContent.Instance.Error("鍒涘缓浠诲姟澶辫触");
 
-                if (!wcsResult.IsSuccess || !wcsResult.Data.Status)
-                    return WebResponseContent.Instance.Error($"浠诲姟宸插垱寤轰絾鍙戦�佺粰WCS澶辫触: {wcsResult.Data?.Message}");
+                    var wcsResult = _httpClientHelper.Post<WebResponseContent>(
+                        "http://localhost:9292/api/Task/ReceiveManualTask",
+                        wmsTaskDtos.ToJson());
 
-                return WebResponseContent.Instance.OK($"鎵嬪姩鍒涘缓浠诲姟鎴愬姛锛屼换鍔″彿: {taskNum}");
+                    if (!wcsResult.IsSuccess || !wcsResult.Data.Status)
+                        return WebResponseContent.Instance.Error($"浠诲姟宸插垱寤轰絾鍙戦�佺粰WCS澶辫触: {wcsResult.Data?.Message}");
+
+                    return WebResponseContent.Instance.OK($"鎵嬪姩鍒涘缓浠诲姟鎴愬姛锛屼换鍔″彿: {taskNum}");
+                });
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3