From 39d468b76e60c05ffcdf749f7ed1d3c443d542f8 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期四, 30 四月 2026 17:13:05 +0800
Subject: [PATCH] 一堆需要求新增及更改

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs |  197 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 158 insertions(+), 39 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
index 1b3794c..68f84b1 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
@@ -43,54 +43,105 @@
         /// <param name="stationCode"></param>
         /// <param name="palletCode"></param>
         /// <returns></returns>
-        public WebResponseContent DeviceRequestInboundTaskSimple(string stationCode)
+        public WebResponseContent DeviceRequestInboundTaskSimple(string stationCode, string startPoint = "")
         {
+            WebResponseContent content = new WebResponseContent();
             try
             {
                 Dt_Task task = Repository.QueryFirst(x => x.PalletCode == stationCode);
                 if (task != null)
                 {
                     PushTasksToWCS(new List<Dt_Task> { task });
-                    return WebResponseContent.Instance.OK($"璇ユ墭鐩樺凡鐢熸垚浠诲姟", _mapper.Map<WMSTaskDTO>(task));
+                    return content.OK($"璇ユ墭鐩樺凡鐢熸垚浠诲姟", _mapper.Map<WMSTaskDTO>(task));
                 }
                 Dt_ProStockInfo stockInfo = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == stationCode).Includes(x => x.proStockInfoDetails).First(); ;
                 if (stockInfo == null)
                 {
-                    return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
+                    return content.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
                 }
                 if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
                 {
-                    return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
+                    return content.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
                 }
-
-                Dt_Task newTask = new Dt_Task()
-                {
-                    CurrentAddress = stationCode,
-                    Grade = 0,
-                    NextAddress = "",
-                    PalletCode = stationCode,
-                    Roadway = "",
-                    SourceAddress = stationCode,
-                    TargetAddress = "",
-                    TaskType = TaskTypeEnum.InProduct.ObjToInt(),
-                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
-                    WarehouseId = stockInfo.WarehouseId,
-                    PalletType = stockInfo.PalletType,
-                };
                 stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
                 stockInfo.proStockInfoDetails.ForEach(x =>
                 {
                     x.ProStockDetailStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
                 });
-                _unitOfWorkManage.BeginTran();
-                int taskId = BaseDal.AddData(newTask);
-                newTask.TaskId = taskId;
-                _stockRepository.ProStockInfoRepository.UpdateData(stockInfo);
-                _stockRepository.ProStockInfoDetailRepository.UpdateData(stockInfo.proStockInfoDetails);
-                _unitOfWorkManage.CommitTran();
-                WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
+                if (startPoint.IsNullOrEmpty())
+                {
+                    Dt_Task newTask = new Dt_Task()
+                    {
+                        CurrentAddress = stationCode,
+                        Grade = 0,
+                        NextAddress = "",
+                        PalletCode = stationCode,
+                        Roadway = "",
+                        SourceAddress = stationCode,
+                        TargetAddress = "",
+                        TaskType = TaskTypeEnum.InProduct.ObjToInt(),
+                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
+                        WarehouseId = stockInfo.WarehouseId,
+                        PalletType = stockInfo.PalletType,
+                    };
+                    _unitOfWorkManage.BeginTran();
+                    int taskId = BaseDal.AddData(newTask);
+                    newTask.TaskId = taskId;
+                    _stockRepository.ProStockInfoRepository.UpdateData(stockInfo);
+                    _stockRepository.ProStockInfoDetailRepository.UpdateData(stockInfo.proStockInfoDetails);
+                    _unitOfWorkManage.CommitTran();
+                    WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
 
-                return WebResponseContent.Instance.OK(data: wMSTaskDTO);
+                    return content.OK(data: wMSTaskDTO);
+                }
+                else
+                {
+                    Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
+                    if (agvstation == null)
+                    {
+                        return content.Error($"璧风偣閿欒{startPoint}");
+                    }
+                    if (agvstation.StationArea != StationAreaEnum.浜屾ゼ鎴愬搧搴撶紦瀛樺尯.ToString())
+                    {
+                        return content.Error($"璧风偣绔欑偣鍖哄煙閿欒{agvstation.StationArea}");
+                    }
+                    //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅
+                    Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Executing.ObjToInt()));
+                    if (taskOldPoint != null)
+                    {
+                        return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�");
+                    }
+                    //鍒嗛厤宸烽亾
+                    string roadWay = AssignCPRoadwayNo();
+                    Dt_ProStockInfoDetail? proStockInfoDetail = stockInfo.proStockInfoDetails.FirstOrDefault();
+                    //鐢熸垚浠诲姟
+                    Dt_Task newTask = new Dt_Task()
+                    {
+                        CurrentAddress = startPoint,
+                        Grade = 0,
+                        NextAddress = "",
+                        PalletCode = stockInfo.PalletCode,
+                        Roadway = roadWay,
+                        SourceAddress = startPoint,
+                        TargetAddress = "",
+                        TaskType = TaskTypeEnum.Inbound2ndFloor.ObjToInt(),
+                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
+                        WarehouseId = stockInfo.WarehouseId,
+                        PalletType = stockInfo.PalletType,
+                        MaterielCode = proStockInfoDetail.ProductCode,
+                        OrderNo = stockInfo.ProInOrderNo,
+                        Quantity = stockInfo.proStockInfoDetails.Sum(x=>x.StockQty),
+                    };
+                    _unitOfWorkManage.BeginTran();
+                    int taskId = BaseDal.AddData(newTask);
+                    newTask.TaskId = taskId;
+                    _stockRepository.ProStockInfoRepository.UpdateData(stockInfo);
+                    _stockRepository.ProStockInfoDetailRepository.UpdateData(stockInfo.proStockInfoDetails);
+                    _unitOfWorkManage.CommitTran();
+                    //鎺ㄩ�佷换鍔�
+                    PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV");
+                    return content.OK("鍒涘缓鍏ュ簱鎴愬姛");
+                }
             }
             catch (Exception ex)
             {
@@ -888,7 +939,8 @@
                     //闄愬埗
                     if (stockInfo.CheckThickness >= 800 && stockInfo.CheckThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
                     {
-                        bool LayerLimit = stockInfo.CheckThickness > 1300;
+                        bool LayerLimit1 = stockInfo.CheckThickness >= 1200;
+                        bool LayerLimit2 = stockInfo.CheckThickness > 1300;
                         bool RoadwayLimit = stockInfo.MaterielWide > 2200;
                         bool RoadwayType = stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt();
                         var query = Db.Queryable<Dt_LocationInfo>()
@@ -899,7 +951,11 @@
                             .Select(x => new { x.RoadwayNo, x.Columns });
 
                         // 鏍规嵁鏉′欢杩囨护
-                        if (LayerLimit)
+                        if (LayerLimit1)
+                        {
+                            query = query.Where(x => x.RoadwayNo != "SC03_YLDual");
+                        }
+                        if (LayerLimit2)
                         {
                             query = query.Where(x => x.Columns >= 56 && !x.RoadwayNo.Contains("YLDual"));
                         }
@@ -975,7 +1031,7 @@
                 {
                     item.Count -= count.Count;
                 }
-                if (item.Count >= 50 && count?.Count<=2)
+                if (item.Count >= 50 && count?.Count<=1)
                 {
                     return item.RoadwayNo;
                 }
@@ -1073,7 +1129,7 @@
                             }
                             proInUpModel.PB_INV_PRODUCT_IN= pRODUCT_INItems;
                             string request = _invokeERPService.ERPProInUp(proInUpModel) ?? throw new Exception("鎴愬搧鍏ュ簱鎺ュ彛璇锋眰澶辫触");
-                            if (!request.Contains("Success"))
+                            if (!request.Contains("success"))
                             {
                                 throw new Exception($"鎴愬搧鍏ュ簱澶辫触");
                             }
@@ -1225,12 +1281,17 @@
                     return WebResponseContent.Instance.OK(data: task.TargetAddress);
                 }
                 Dt_StockInfo? stockInfo = null;
+                Dt_ProStockInfo? proStockInfo = null;
                 if (roadwayNo.Contains("YL"))
                 {
                     stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x=>x.PalletCode==task.PalletCode);
                 }
+                else
+                {
+                    proStockInfo = Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x=>x.proStockInfoDetails).First();
+                }
                 //鍒嗛厤璐т綅
-                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, stockInfo);
+                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, stockInfo, proStockInfo);
                 if (locationInfo == null)
                 {
                     return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
@@ -1884,6 +1945,16 @@
                 {
                     return content.Error("浼犲叆淇℃伅涓虹┖");
                 }
+                // 鍙繑鍥為噸澶嶇殑 BarCode 鍒楄〃
+                var repeatBarCodeList = proInDTOs
+                    .GroupBy(x => x.BarCode)
+                    .Where(g => g.Count() > 1)
+                    .Select(g => g.Key)
+                    .ToList();
+                if (repeatBarCodeList.Count>0)
+                {
+                    return content.Error($"浼犲叆{repeatBarCodeList.FirstOrDefault()}绠辩爜鏁版嵁閲嶅锛岃妫�鏌ヤ紶鍏ユ暟鎹�");
+                }
                 //鑾峰彇鎵�鏈夋垚鍝侊紝鍗婃垚鍝佷俊鎭�
                 List<Dt_MESProInOrderInfo> proInOrderInfosOld = _inboundRepository.MESProInOrderInfoRepository.QueryData();
                 //鑾峰彇鎵�鏈夌墿鏂欎俊鎭�
@@ -1960,7 +2031,7 @@
                     string request = _invokeERPService.ERPSemiProInUp(
                             new ERPProInUpModel()
                             {
-                                PB_INV_PRODUCT_IN= pRODUCT_INItems
+                                PB_INV_PRODUCT_IN = pRODUCT_INItems
                             }) ?? throw new Exception("鍗婃垚鍝佸叆搴撴帴鍙h姹傚け璐�");
                     //鐢熸垚鍗婃垚鍝佸叆搴�
                     List<Dt_MESProInOrderInfo> semiProInOrderInfos = mESProInOrderInfos.Where(x => x.MESProInStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt() && x.WarehouseId==WarehouseEnum.LLDYL.ObjToInt()).ToList();
@@ -2012,7 +2083,6 @@
                 {
                     return content.Error("浼犲叆淇℃伅涓虹┖");
                 }
-                
                 List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData();
                 List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
                 List<Dt_Task> tasks = new List<Dt_Task>();
@@ -2089,10 +2159,11 @@
                         nameof(StationAreaEnum.涓�妤煎嵃鍒�) => TaskTypeEnum.PrintYLInbound,
                         nameof(StationAreaEnum.涓�妤煎垎鍒�) => TaskTypeEnum.PartOffInbound,
                         nameof(StationAreaEnum.涓�妤肩焊寮犳穻鑶�) => TaskTypeEnum.PaperFilmInbound,
-                        nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�) => TaskTypeEnum.WFBYLInbound,
+                        nameof(StationAreaEnum.涓�妤兼棤绾虹粐甯�) => TaskTypeEnum.WFBYLInbound,
+                        nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�) => TaskTypeEnum.WFBLMYLInbound,
                         _ => throw new Exception("鏈壘鍒板搴斾换鍔�")
                     };
-                    if (taskTypeEnum == TaskTypeEnum.WFBYLInbound)
+                    if (taskTypeEnum == TaskTypeEnum.WFBYLInbound || taskTypeEnum == TaskTypeEnum.WFBLMYLInbound)
                     {
                         Dt_AGVStationInfo? stationInfo = AssignWFBStation(_AGVStationInfos?.Select(x => x.AGVStationCode).ToList()) ?? throw new Exception("鏈壘鍒板彲鐢ㄦ棤绾哄竷鏆傚瓨鏋�");
                         newTask.NextAddress = stationInfo.AGVStationCode;
@@ -2158,16 +2229,28 @@
                 throw new Exception(ex.Message);
             }
         }
-        public WebResponseContent BoxingInBound(string stationCode,List<string> barCodes)
+        /// <summary>
+        /// 鎴愬搧缁勭洏
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent BoxingInBound(string stationCode, int heightNum, List<string> barCodes, int type = 0)
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
+                if (stationCode.IsNullOrEmpty())
+                {
+                    return content.Error($"鎵樼洏鏉$爜涓嶈兘涓虹┖");
+                }
+                if (barCodes==null || barCodes.Count<=0)
+                {
+                    return content.Error($"绠辩爜涓嶈兘涓虹┖");
+                }
                 //鑾峰彇鎴愬搧搴撳瓨
                 Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == stationCode);
                 if (proStockInfoOld != null)
                 {
-                    return content.Error($"鎵樼洏{stationCode}宸插瓨鍦�");
+                    return content.Error($"鎵樼洏鏉$爜{stationCode}宸插瓨鍦�");
                 }
                 //鑾峰彇鏉$爜淇℃伅
                 List<Dt_MESProInOrderInfo> proInOrderInfos = _inboundRepository.MESProInOrderInfoRepository.QueryData(x=> barCodes.Contains(x.BarCode));
@@ -2188,7 +2271,7 @@
                     };
                     proStockInfoDetails.Add(proStockInfoDetail);
                 }
-                
+
                 Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
                 {
                     PalletCode = stationCode,
@@ -2198,13 +2281,25 @@
                     LocationCode = "",
                     WarehouseId = materielInfo.WarehouseId,
                     StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+                    ProHeight = heightNum,
                     proStockInfoDetails = proStockInfoDetails
                 };
+                _unitOfWorkManage.BeginTran();
                 BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
+                if (type != 0)
+                {
+                    proInOrderInfos.ForEach(x =>
+                    {
+                        x.MESProInStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+                    });
+                    _inboundRepository.MESProInOrderInfoRepository.UpdateData(proInOrderInfos);
+                }
+                _unitOfWorkManage.CommitTran();
                 content.OK();
             }
             catch (Exception ex)
             {
+                _unitOfWorkManage.RollbackTran();
                 content.Error(ex.Message);
             }
             return content;
@@ -2325,5 +2420,29 @@
             }
             return content;
         }
+        /// <summary>
+        /// 浜屾ゼ鎴愬搧PDA鎵爜鏍¢獙
+        /// </summary>
+        /// <param name="barcode"></param>
+        /// <returns></returns>
+        public WebResponseContent CodeAnalysis(string barcode)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                if (barcode.IsNullOrEmpty())
+                    return content.Error("浼犲叆绠辩爜涓嶈兘涓虹┖");
+                //鑾峰彇鏉$爜鐘舵��
+                Dt_MESProInOrderInfo proInOrderInfo = Db.Queryable<Dt_MESProInOrderInfo>().Where(x => x.BarCode == barcode && x.MESProInStatus == (int)InOrderStatusEnum.鏈紑濮�).OrderByDescending(x => x.CreateDate).First();
+                if (proInOrderInfo==null)
+                    return content.Error($"绠辩爜{barcode}鐘舵�佷笉鍙叆搴擄紝璇锋鏌ョ鐮佹暟鎹�");
+                return content.OK("鎴愬姛", new { proInOrderInfo.BarCode, proInOrderInfo.ProductOrderNo, proInOrderInfo.MaterialCode, proInOrderInfo.ProQuantity });
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
+        }
     }
 }

--
Gitblit v1.9.3