From dc06f58d8ed537555fd529551180f43a0586ec3f Mon Sep 17 00:00:00 2001
From: helongyang <647556386@qq.com>
Date: 星期日, 22 六月 2025 11:44:43 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs |   57 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 41 insertions(+), 16 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs"
index a702bf8..1fad87f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs"
@@ -30,6 +30,7 @@
 using WIDESEA_DTO.Stock;
 using SqlSugar;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
 
 namespace WIDESEA_TaskInfoService
 {
@@ -97,6 +98,13 @@
                         PalletType = stockInfo.PalletType,
                         WarehouseId = stockInfo.WarehouseId,
                     };
+                    string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+                    float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+                    if (MaterielCode != null && Quantity != null)
+                    {
+                        taskOut.MaterielCode = MaterielCode;
+                        taskOut.Quantity = Quantity;
+                    }
                     stockInfo.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾;
                     LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                     locationInfo.LocationStatus = (int)LocationStatusEnum.Lock;
@@ -130,11 +138,6 @@
                 MesResponseContent responseContent = new MesResponseContent();
                 try
                 {
-                    Dt_Task exsit = Repository.QueryFirst(x => x.TargetAddress == model.TargetAddressCode);
-                    if (exsit != null)
-                    {
-                        return responseContent.Error($"鐩爣鍦板潃閲嶅");
-                    }
 
                     Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString());
                     //鑾峰彇搴撳瓨璁板綍
@@ -176,6 +179,13 @@
                         PalletType = stockInfo.PalletType,
                         WarehouseId = stockInfo.WarehouseId,
                     };
+                    string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+                    float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+                    if (MaterielCode != null && Quantity != null)
+                    {
+                        taskOut.MaterielCode = MaterielCode;
+                        taskOut.Quantity = Quantity;
+                    }
                     stockInfo.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾;
                     LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                     locationInfo.LocationStatus = (int)LocationStatusEnum.Lock;
@@ -210,11 +220,7 @@
                 MesResponseContent responseContent = new MesResponseContent();
                 try
                 {
-                    Dt_Task exsit = Repository.QueryFirst(x => x.TargetAddress == model.TargetAddressCode);
-                    if (exsit != null)
-                    {
-                        return responseContent.Error($"鐩爣鍦板潃閲嶅");
-                    }
+                    
 
                     Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString());
                     //鑾峰彇搴撳瓨璁板綍
@@ -251,11 +257,18 @@
                         SourceAddress = stockInfo.LocationCode,
                         TargetAddress = model.TargetAddressCode,
                         TaskStatus = (int)TaskStatusEnum.New,
-                        TaskType = stockInfo.PalletType < 2 ? (int)TaskTypeEnum.MaskOutSmall : (int)TaskTypeEnum.m,
+                        TaskType = stockInfo.PalletType < 2 ? (int)TaskTypeEnum.MaskOutSmall : (int)TaskTypeEnum.MaskOutLarge,
                         TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                         PalletType = stockInfo.PalletType,
                         WarehouseId = stockInfo.WarehouseId,
                     };
+                    string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+                    float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+                    if (MaterielCode != null && Quantity != null)
+                    {
+                        taskOut.MaterielCode = MaterielCode;
+                        taskOut.Quantity = Quantity;
+                    }
                     stockInfo.StockStatus = (int)StockStatusEmun.鍑哄簱閿佸畾;
                     LocationStatusEnum locationStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                     locationInfo.LocationStatus = (int)LocationStatusEnum.Lock;
@@ -318,6 +331,13 @@
                     PalletType = stockInfo.PalletType,
                     WarehouseId = stockInfo.WarehouseId,
                 };
+                string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+                float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+                if (MaterielCode != null && Quantity != null)
+                {
+                    taskIn.MaterielCode = MaterielCode;
+                    taskIn.Quantity = Quantity;
+                }
                 //鏇存敼搴撳瓨鐘舵��
                 stockInfo.StockStatus = StockStatusEmun.閫�搴�.ObjToInt();
                 BaseDal.AddData(taskIn);
@@ -613,10 +633,10 @@
 
                 Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == palletTypeInfo.WarehouseId);
                 //鍒ゆ柇鏄惁鎵樼洏搴撳瓨鏄惁宸插瓨鍦�
-                Dt_StockInfo stockInfoOld = _stockRepository.StockInfo_HtyRepository.QueryData(x => x.PalletCode == model.CarrierCode).First();
-                if (stockInfoOld!=null)
+                Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == model.CarrierCode);
+                if (stockInfoOld != null)
                 {
-                    return MesResponseContent.Instance.Error($"鎵樼洏鍙穥model.CarrierCode}宸插瓨鍦�");
+                    return MesResponseContent.Instance.Error($"鎵樼洏鍙峰簱瀛榹model.CarrierCode}宸插瓨鍦�");
                 }
 
                 Dt_StockInfo_Hty stockInfo_Hty = _stockRepository.StockInfo_HtyRepository.QueryData(x => x.PalletCode == model.CarrierCode).OrderByDescending(x => x.SourceId).First();
@@ -1034,9 +1054,14 @@
                     TaskStatus = TaskStatusEnum.New.ObjToInt(),
                     WarehouseId = stockInfo.WarehouseId,
                     PalletType = stockInfo.PalletType,
-                    MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode,
-                    Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity,
                 };
+                string MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode;
+                float Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+                if (MaterielCode != null && Quantity != null)
+                {
+                    newTask.MaterielCode = MaterielCode;
+                    newTask.Quantity = Quantity;
+                }
                 LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                 _unitOfWorkManage.BeginTran();
                 _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation);

--
Gitblit v1.9.3