From 03214febb52b6e0f6f03248d3ef3cbe08967a116 Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期五, 27 三月 2026 10:17:42 +0800
Subject: [PATCH]  1

---
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs |  100 +++++++++++++++++++++++++++++---------------------
 1 files changed, 58 insertions(+), 42 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
index ba47fd4..02accf4 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
@@ -1,30 +1,33 @@
-锘縰sing System;
+锘縰sing MailKit.Search;
+using Microsoft.Extensions.Logging;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
+using System.Reflection.Metadata;
 using System.Text;
 using System.Threading.Tasks;
-using WIDESEA_Core.Enums;
-using WIDESEA_Core;
-using WIDESEA_Model.Models;
-using WIDESEA_Core.Helper;
-using Microsoft.Extensions.Logging;
-using MailKit.Search;
-using System.Reflection.Metadata;
-using static WIDESEA_ITaskInfoService.ITaskService;
-using static WIDESEA_Common.HouseInventoryIn;
 using WIDESEA_Common;
-using Parameter = WIDESEA_Common.Parameter;
-using WIDESEA_Core.LogHelper;
-using WIDESEA_DTO.Task;
-using WIDESEA_Core.TaskEnum;
-using WIDESEA_Model.Models.Inbound;
 using WIDESEA_Common.OrderEnum;
+using WIDESEA_Common.TaskEnum;
+using WIDESEA_Core;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.Log;
+using WIDESEA_Core.LogHelper;
+using WIDESEA_Core.TaskEnum;
+using WIDESEA_DTO.Task;
+using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Inbound;
+using static WIDESEA_Common.HouseInventoryIn;
+using static WIDESEA_ITaskInfoService.ITaskService;
+using Parameter = WIDESEA_Common.Parameter;
 
 namespace WIDESEA_TaskInfoService
 {
     public partial class TaskService
     {
+
 
         /// <summary>
         /// 浠呯敵璇蜂换鍔★紝璁¦CS鏍规嵁璺敱纭畾涓嬩竴鍦板潃
@@ -39,6 +42,7 @@
                 Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
                 if (task != null)
                 {
+                    //PushTasksToWCS(new List<Dt_Task> { task });
                     return WebResponseContent.Instance.Error($"璇ユ墭鐩榹palletCode}宸茬敓鎴愪换鍔�");
                 }
                 Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
@@ -46,6 +50,10 @@
                 if (stockInfo == null)
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
+                }
+                if (stockInfo.StockStatus == StockStatusEmun.鍚堟墭鍑哄簱瀹屾垚.ObjToInt())
+                {
+
                 }
                 ///鍒ゆ柇鏄惁瀛樺湪鍥炲簱鍗�,杩涜鍥炲師搴撲綅閫昏緫
                 string returnOrderNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.OrderNo;
@@ -207,10 +215,20 @@
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
                 }
+
+                Dt_RoadwayInfo returnRoadwayInfo = new Dt_RoadwayInfo();
+                if (stockInfo.StockStatus == StockStatusEmun.鍚堟墭鍑哄簱瀹屾垚.ObjToInt())
+                {
+                    Dt_LocationInfo locationInfo1 = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
+                    if (locationInfo1 == null)
+                    {
+                        return WebResponseContent.Instance.Error($"鍥炲簱鍗曚腑璇ュ簱浣峽stockInfo.LocationCode}鏈壘鍒�");
+                    }
+                    returnRoadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.RoadwayNo == locationInfo1.RoadwayNo && x.InStationCode == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode));
+                }
                 ///鍒ゆ柇鏄惁瀛樺湪鍥炲簱鍗�,杩涜鍥炲師搴撲綅閫昏緫
                 string returnOrderNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.OrderNo;
-                Dt_ReturnOrder returnOrder = _returnOrderRepository.QueryFirst(x => x.OrderNo == returnOrderNo && x.OrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt());
-                Dt_RoadwayInfo returnRoadwayInfo = new Dt_RoadwayInfo();
+                Dt_ReturnOrder returnOrder = _returnOrderRepository.QueryFirst(x => (x.OrderNo == returnOrderNo || x.LPNNo == palletCode) && x.OrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt());
                 if (returnOrder != null && !string.IsNullOrEmpty(returnOrder.LocationCode))
                 {
                     Dt_LocationInfo locationInfo1 = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == returnOrder.LocationCode);
@@ -218,7 +236,7 @@
                     {
                         return WebResponseContent.Instance.Error($"鍥炲簱鍗曚腑璇ュ簱浣峽returnOrder.LocationCode}鏈壘鍒�");
                     }
-                    returnRoadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.RoadwayNo == locationInfo1.RoadwayNo);
+                    returnRoadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.RoadwayNo == locationInfo1.RoadwayNo && x.InStationCode == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode));
                 }
 
                 if (Repository.QueryFirst(x => x.SourceAddress == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode) && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null)
@@ -260,12 +278,11 @@
                         return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
                     }
                 }
-
                 Dt_Task newTask = new Dt_Task()
                 {
                     CurrentAddress = courceAddress,
                     Grade = 0,
-                    NextAddress = "",
+                    NextAddress = returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode,
                     PalletCode = palletCode,
                     OrderNo = details.OrderNo,
                     Roadway = roadwayInfo.RoadwayNo,
@@ -297,6 +314,10 @@
                 {
                     newTask.TaskType = TaskTypeEnum.InInventory.ObjToInt();
                 }
+                if (stockInfo.StockStatus == StockStatusEmun.鍚堟墭鍑哄簱瀹屾垚.ObjToInt())
+                {
+                    newTask.TaskType = TaskTypeEnum.InSyncretism.ObjToInt();
+                }
                 //if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
                 //{
                 //    stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt();
@@ -320,7 +341,10 @@
                 //}
                 //else
                 //{
-                stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+                else
+                {
+                    stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+                }
                 locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                 //}
 
@@ -623,9 +647,8 @@
         //鏌ヨ浠撳簱鎵樼洏璐х墿绫诲瀷
         public int GetPalletType(Dt_Warehouse warehouse, string palletCode)
         {
-            if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ObjToString() || warehouse.WarehouseCode == WarehouseEnum.SC02_BC.ObjToString())
+            if (warehouse.WarehouseCode.Contains("BC"))
             {
-
                 Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 3));
                 if (palletTypeInfo == null)
                 {
@@ -633,25 +656,16 @@
                 }
                 return palletTypeInfo.PalletType;
             }
-            //else if (warehouse.WarehouseCode == WarehouseEnum.HA152.ObjToString())
-            //{
-            //    Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2));
-            //    if (palletTypeInfo == null)
-            //    {
-            //        throw new Exception($"鎵樼洏鍙烽敊璇�");
-            //    }
-            //    return palletTypeInfo.PalletType;
-            //}
-            //else if (warehouse.WarehouseCode == WarehouseEnum.HA57.ObjToString())
-            //{
-            //    Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 3));
-            //    if (palletTypeInfo == null)
-            //    {
-            //        throw new Exception($"鎵樼洏鍙烽敊璇�");
-            //    }
-            //    return palletTypeInfo.PalletType;
-            //}
-            return -1;
+            else 
+            {
+                Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2));
+                if (palletTypeInfo == null)
+                {
+                    throw new Exception($"鎵樼洏鍙烽敊璇�");
+                }
+                return palletTypeInfo.PalletType;
+            }
+            return 0;
         }
 
 
@@ -781,6 +795,8 @@
                     houseInboundPassBack.Context.Add("Ticket", Ticket);
                     houseInboundPassBack.Context.Add("InvOrgId", InvOrgId);
                     var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSInventoryIn, houseInboundPassBack, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
+                    WriteLog.Write_Log("API", "鐩樼偣宸紓鏁伴噺鍥炰紶", "璇锋眰", new { 璇锋眰鎶ユ枃 = houseInboundPassBack, 鎺ユ敹鎶ユ枃 = responses });
+
                 }
                 content = WebResponseContent.Instance.OK();
             }

--
Gitblit v1.9.3