From 2929a5bd618ed09a11ee88309da5b9af9d2011c0 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 10 一月 2025 20:53:54 +0800
Subject: [PATCH] 辅料仓逻辑优化

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   62 ++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 6 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 108f974..cc787f0 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -16,6 +16,7 @@
 #endregion << 鐗� 鏈� 娉� 閲� >>
 
 using AutoMapper;
+using Microsoft.AspNetCore.Mvc.ApiExplorer;
 using Newtonsoft.Json;
 using SqlSugar;
 using System.Reflection.Emit;
@@ -111,7 +112,35 @@
                 {
                     x.AGVArea = agvDescription;
                 });
-                string response = HttpHelper.Post("http://127.0.0.1:9281/api/Task/ReceiveTask", taskDTOs.Serialize());
+                string address = AppSettings.Get("WCSApiAddress");
+                if (string.IsNullOrEmpty(address))
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃");
+                }
+                string response = HttpHelper.Post($"{address}/api/Task/ReceiveTask", taskDTOs.Serialize());
+
+                return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        /// <summary>
+        /// 鏀捐揣瀹屾垚
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
+        public WebResponseContent PutFinish(string code)
+        {
+            try
+            {
+                string address = AppSettings.Get("WCSApiAddress");
+                if (string.IsNullOrEmpty(address))
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃");
+                }
+                string response = HttpHelper.Post($"{address}/api/CTU_AGV/PutFinish", code);
 
                 return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
             }
@@ -147,7 +176,7 @@
                     return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅");
                 }
 
-                if (stockInfo.Details.Count == 0)
+                if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt())
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
                 }
@@ -168,6 +197,22 @@
                 Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId);
 
                 stockInfo.LocationCode = locationInfo.LocationCode;
+
+                #region 绌虹鍏ュ簱
+                if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
+                {
+                    stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+                    task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+                    _unitOfWorkManage.BeginTran();
+                    BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
+                    _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
+                    _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+                    _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted);
+                    _unitOfWorkManage.CommitTran();
+                    return WebResponseContent.Instance.OK();
+                }
+                #endregion
+
                 Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First();
                 List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>();
                 if (stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt())
@@ -226,7 +271,7 @@
                 {
                     foreach (var model in stockInfo.Details)
                     {
-                        TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, Life = int.TryParse(model.Remark, out int val) ? val : 1000 });
+                        TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, /*MaterialName = model.MaterielName,*/ Life = int.TryParse(model.Remark, out int val) ? val : 1000 });
                     }
                 }
 
@@ -299,7 +344,7 @@
                 List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
                 List<Dt_MesOutboundOrder> mesOutboundOrders = new List<Dt_MesOutboundOrder>();
 
-                if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString())
+                if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType != TaskTypeEnum.OutEmpty.ObjToInt())
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒板嚭搴撹鎯呬俊鎭�");
                 }
@@ -337,6 +382,7 @@
                     }
                 }
 
+                task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
                 _unitOfWorkManage.BeginTran();
 
                 if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
@@ -349,6 +395,11 @@
                     stockInfo.LocationCode = "";
                     stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
                     _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+                }
+                else if (task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt())
+                {
+                    _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
+                    _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
                 }
                 else if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt())
                 {
@@ -369,12 +420,11 @@
 
                 if (warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                 {
-                    _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().Id, outStockLockInfos);
+                    _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().OrderId, outStockLockInfos);
                 }
                 if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt())
                 {
                     MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, mesOutboundOrders.FirstOrDefault().OrderQuantity);
-
                     UploadMesMaterialLotaAcept(model);
                 }
                 return WebResponseContent.Instance.OK();

--
Gitblit v1.9.3