From 1924bdeca6414b6fec314c37260b44f20865d593 Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期四, 22 一月 2026 20:49:05 +0800
Subject: [PATCH] 代码同步,接口更新

---
 项目代码/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/pullLock.cs |   72 +++++++++++++++++++++++++++++++++--
 1 files changed, 67 insertions(+), 5 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/pullLock.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/pullLock.cs"
index 88b4e86..b9af1b0 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/pullLock.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/pullLock.cs"
@@ -11,7 +11,10 @@
 using WIDESEA_Common.MES.Request;
 using WIDESEA_Core;
 using WIDESEA_Core.Const;
+using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
+using WIDESEA_DTO.WMS;
+using WIDESEA_Model.Models;
 using WIDESEAWCS_BasicInfoService;
 using WIDESEAWCS_Model.Models;
 
@@ -28,22 +31,80 @@
             try
             {
                 if (string.IsNullOrEmpty(jsondata.ToString())) throw new Exception("璇锋眰鍙傛暟涓虹┖");
-
+                Console.WriteLine(jsondata);
                 var result = JsonConvert.DeserializeObject<pullLockInfo>(jsondata.ToString());
 
                 foreach (var item in result.data)
                 {
+                    Dt_PalletStockInfo carinfo = null;
                     if (!string.IsNullOrEmpty(item.pvi))
                     {
-                        var carInfo = _palletStockInfoRepository.QueryFirst(x => x.PVI == item.pvi && x.pbMaterial == item.pbMaterial);
-                        if (carInfo == null)
+                        carinfo = _palletStockInfoRepository.QueryFirst(x => x.PVI == item.pvi && x.pbMaterial == item.pbMaterial);
+                        if (carinfo == null)
                         {
-                            throw new Exception("鏈煡杞﹁韩");
+                            throw new Exception($"鏈壘鍒版寚瀹歅VI杞﹁韩淇℃伅{item.pvi}");
                         }
                     }
+                    else
+                    {
+                        carinfo = _palletStockInfoRepository.QueryData(x => x.pbMaterial == item.pbMaterial).OrderBy(x => x.CreateDate).FirstOrDefault();
+                    }
 
-                    var carinfo = _palletStockInfoRepository.QueryData(x => x.pbMaterial == item.pbMaterial).OrderBy(x => x.CreateDate);
+                    if (carinfo == null)
+                    {
+                        throw new Exception("鏃犳硶鍖归厤杞﹁韩,鎷夊姩閿佸畾澶辫触");
+                    }
 
+                    Dt_Task task = new Dt_Task()
+                    {
+                        CreateDate = DateTime.Now,
+                        Creater = "System",
+                        CurrentAddress = carinfo.LocationCode,
+                        Grade = 5,
+                        PalletCode = carinfo.PalletCode,
+                        PVI = item.pvi,
+                        Roadway = carinfo.RoadwayNo,
+                        SourceAddress = carinfo.LocationCode,
+                        TaskNum = _taskRepository.GetTaskNo().Result,
+                        TaskType = (int)TaskOutboundTypeEnum.Outbound,
+                        TaskState = (int)TaskOutStatusEnum.OutNew,
+                        TargetAddress = ""
+                    };
+
+                    WMSTaskDTO taskDTO = new WMSTaskDTO()
+                    {
+                        Grade = task.Grade.Value,
+                        PalletCode = task.PalletCode,
+                        SourceAddress = task.SourceAddress,
+                        TargetAddress = task.TargetAddress,
+                        RoadWay = task.Roadway,
+                        TaskState = task.TaskState.Value,
+                        TaskType = task.TaskType,
+                        TaskNum = task.TaskNum.Value
+                    };
+
+                    var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+                    var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue;
+                    var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveTask)?.ConfigValue;
+                    if (wmsBase == null || ipAddress == null)
+                    {
+                        throw new InvalidOperationException("WMS IP 鏈厤缃�");
+                    }
+                    var wmsIpAddress = wmsBase + ipAddress;
+
+                    _unitOfWorkManage.BeginTran();
+                    var WCSresult = HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
+                    content = JsonConvert.DeserializeObject<WebResponseContent>(WCSresult);
+                    if (content != null && content.Status)
+                    {
+                        carinfo.StockStatus = 1;
+                        carinfo.LockOrder = 1;
+
+                        _taskRepository.AddData(task);
+                        _palletStockInfoRepository.UpdateData(carinfo);
+
+                        _unitOfWorkManage.CommitTran();
+                    }
                 }
 
                 LogFactory.GetLog("MES鎷夊姩閿佽溅").Info(true, $"\r\r--------------------------------------");
@@ -53,6 +114,7 @@
             }
             catch (Exception ex)
             {
+                _unitOfWorkManage.RollbackTran();
                 return content.Error(ex.Message);
             }
         }

--
Gitblit v1.9.3