From a23f4d86c588a3fa0bc23e5252bc1ddd1f5a1787 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 08 一月 2025 23:19:36 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs |   78 ++++++++++++++++++++++++--------------
 1 files changed, 49 insertions(+), 29 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
index 4bb32e3..664fc0a 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
@@ -7,8 +7,10 @@
 using WIDESEA_Common.LocationEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
+using WIDESEA_Common.WareHouseEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Task;
 using WIDESEA_Model.Models;
 
 namespace WIDESEA_TaskInfoService
@@ -28,6 +30,11 @@
                 var palletCode = saveModel.MainData["barcode"].ToString();
                 var warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
                 var stationCode = saveModel.MainData["startPoint"].ToString();
+                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == warehouseId);
+                if (warehouse == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒板簱鍖�");
+                }
                 Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode && x.WarehouseId == warehouseId);
                 if (task != null)
                 {
@@ -56,37 +63,45 @@
                 {
                     return WebResponseContent.Instance.Error($"浠撳簱涓嶆纭�");
                 }
-
-                Dt_Task newTask = new Dt_Task()
+                if (warehouse.WarehouseCode == WarehouseEnum.HA60.ToString())
                 {
-                    CurrentAddress = stationCode,
-                    Grade = 0,
-                    NextAddress = "",
-                    PalletCode = palletCode,
-                    Roadway = "",
-                    SourceAddress = stationCode,
-                    TargetAddress = "",
-                    TaskType = TaskTypeEnum.Inbound.ObjToInt(),
-                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
-                    WarehouseId = stockInfo.WarehouseId,
-                    PalletType = stockInfo.PalletType
-                };
-
-                if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
-                {
-                    stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt();
+                    Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseId);
+                    if (locationInfo == null) return WebResponseContent.Instance.Error($"鏈壘鍒板綋鍓嶅簱鍖鸿揣浣嶄俊鎭�");
+                    return DeviceRequestInboundTask(stationCode, locationInfo.RoadwayNo, palletCode);
                 }
                 else
                 {
-                    stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+                    Dt_Task newTask = new Dt_Task()
+                    {
+                        CurrentAddress = stationCode,
+                        Grade = 0,
+                        NextAddress = "",
+                        PalletCode = palletCode,
+                        Roadway = "",
+                        SourceAddress = stationCode,
+                        TargetAddress = "",
+                        TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
+                        WarehouseId = stockInfo.WarehouseId,
+                        PalletType = stockInfo.PalletType
+                    };
+
+                    if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
+                    {
+                        stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt();
+                    }
+                    else
+                    {
+                        stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+                    }
+                    _unitOfWorkManage.BeginTran();
+                    int taskId = BaseDal.AddData(newTask);
+                    newTask.TaskId = taskId;
+                    _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+                    _unitOfWorkManage.CommitTran();
+                    PushTasksToWCS(new List<Dt_Task> { newTask });
+                    return WebResponseContent.Instance.OK(data: newTask);
                 }
-                _unitOfWorkManage.BeginTran();
-                int taskId = BaseDal.AddData(newTask);
-                newTask.TaskId = taskId;
-                _stockRepository.StockInfoRepository.UpdateData(stockInfo);
-                _unitOfWorkManage.CommitTran();
-                PushTasksToWCS(new List<Dt_Task> { newTask });
-                return WebResponseContent.Instance.OK(data: newTask);
             }
             catch (Exception ex)
             {
@@ -102,7 +117,7 @@
                 Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
                 if (task != null)
                 {
-                    return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡鐢熸垚浠诲姟");
+                    return WebResponseContent.Instance.OK($"璇ユ墭鐩樺凡鐢熸垚浠诲姟", _mapper.Map<WMSTaskDTO>(task));
                 }
 
                 if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null)
@@ -153,13 +168,18 @@
                 {
                     stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
                 }
+                LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                 _unitOfWorkManage.BeginTran();
+                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation);
+                _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)newTask.PalletType, LocationStatusEnum.Lock, newTask.WarehouseId);
                 int taskId = BaseDal.AddData(newTask);
                 newTask.TaskId = taskId;
                 _stockRepository.StockInfoRepository.UpdateData(stockInfo);
                 _unitOfWorkManage.CommitTran();
+                WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
+
                 PushTasksToWCS(new List<Dt_Task> { newTask });
-                return WebResponseContent.Instance.OK(data: newTask);
+                return WebResponseContent.Instance.OK(data: wMSTaskDTO);
             }
             catch (Exception ex)
             {
@@ -202,7 +222,7 @@
                 LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
 
                 _unitOfWorkManage.BeginTran();
-                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundAssignLocation);
+                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation);
                 _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)task.PalletType, LocationStatusEnum.Lock, task.WarehouseId);
                 BaseDal.UpdateData(task);
                 _unitOfWorkManage.CommitTran();

--
Gitblit v1.9.3