From daea1a90c2fa1b5cc2f52e62be15bd95cc4155f6 Mon Sep 17 00:00:00 2001
From: Tiandele <tiandele@hnkhzn.com>
Date: 星期五, 20 三月 2026 17:16:04 +0800
Subject: [PATCH] 优化手动锁车逻辑
---
项目代码/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/pullLock.cs | 130 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 117 insertions(+), 13 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 8e62761..3ae3103 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,29 +31,130 @@
try
{
if (string.IsNullOrEmpty(jsondata.ToString())) throw new Exception("璇锋眰鍙傛暟涓虹┖");
+ Console.WriteLine(jsondata);
+ var result = JsonConvert.DeserializeObject<List<pullLockInfo>>(jsondata.ToString());
- var result = JsonConvert.DeserializeObject<pullLockInfo>(jsondata.ToString());
-
- foreach (var item in result.data)
+ foreach (var item in result)
{
- var carInfo = _palletStockInfoRepository.QueryFirst(x => x.PVI == item.pvi);
- if (carInfo == null)
+ var assemblyOrderInfo = _assemblyOrderInfoRepository.QueryFirst(x => x.workOrderNo == item.workOrderNo && x.orderType == item.workOrderType);
+ if (assemblyOrderInfo == null) throw new Exception($"鎷夊姩閿佽溅澶辫触:鏈煡鎬昏宸ュ崟鍙穥item.workOrderNo}");
+
+ //Dt_PalletStockInfo carinfo = null;
+ VV_StockInfo OutStock = new VV_StockInfo();
+ //Dt_CarBodyInfo carbodyinfo = null;
+ if (!string.IsNullOrEmpty(item.pvi))
{
- throw new Exception("鏈煡杞﹁韩");
+ // carinfo = _palletStockInfoRepository.QueryFirst(x => x.PVI == item.pvi && x.pbMaterial == item.pbMaterial);
+ //carbodyinfo = _carBodyRepository.QueryFirst(x => x.pbMaterial == item.pbMaterial && x.PVI == item.pvi);
+ OutStock = _VVStockInfoRepository.QueryFirst(x => x.PVI == item.pvi && x.pbMaterial == item.pbMaterial && x.StockStatus == 0 && x.LockOrder == 0 && x.StayStatus == 0);
+ if (OutStock == null)
+ {
+ throw new Exception($"鏈壘鍒版寚瀹歅VI杞﹁韩淇℃伅{item.pvi}");
+ }
+ }
+ else
+ {
+ //carinfo = _palletStockInfoRepository.QueryData(x => x.pbMaterial == item.pbMaterial).OrderBy(x => x.biwInPassTime).FirstOrDefault();
+ //carbodyinfo = _carBodyRepository.QueryData(x => x.pbMaterial == item.pbMaterial && x.BodyStatus == 0).OrderBy(x => x.biwInPassTime).FirstOrDefault();
+ OutStock = _VVStockInfoRepository.QueryData(x => x.pbMaterial == item.pbMaterial && x.StockStatus == 0 && x.LockOrder == 0 && x.StayStatus == 0 && x.workOrderType == item.workOrderType).OrderBy(x => x.biwInPassTime).FirstOrDefault();
}
- content.lockpvi = carInfo.PVI;
+ if (OutStock == null)
+ {
+ throw new Exception("鏈尮閰嶅埌杞﹁韩,鎷夊姩閿佸畾澶辫触");
+ }
+ var stockInfo = _palletStockInfoRepository.QueryFirst(x => x.CarBodyInfo.PVI == OutStock.PVI);
+
+ var carBody = _carBodyRepository.QueryFirst(x => x.PVI == OutStock.PVI);
+
+ var lockInfo = _MESLockInfoRepository.QueryData().OrderByDescending(x => x.sequenceNo).FirstOrDefault();
+ int serial = 1;
+ if (lockInfo != null)
+ {
+ serial = lockInfo.sequenceNo + 1;
+ }
+
+ Dt_MESLockInfo mESLockInfo = new Dt_MESLockInfo
+ {
+ carBodyID = stockInfo.carBodyID,
+ CarBodyInfo = carBody,
+ CreateDate = DateTime.Now,
+ Creater = "System",
+ LockStatue = 0,
+ sequenceNo = serial,
+ TCLine = OutStock.RoadwayNo
+ };
+
+ #region 浠诲姟涓嬪彂
+ //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;
+ #endregion
+
+ _unitOfWorkManage.BeginTran();
+ //var WCSresult = HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
+ //content = JsonConvert.DeserializeObject<WebResponseContent>(WCSresult);
+ //if (content != null && content.Status)
+ //{
+ stockInfo.StockStatus = 0;
+ stockInfo.LockOrder = 1;
+ carBody.BodyStatus = 1;
+
+ _MESLockInfoRepository.AddData(mESLockInfo);
+ //_taskRepository.AddData(task);
+ _palletStockInfoRepository.UpdateData(stockInfo);
+ //_carBodyRepository.UpdateData(carbodyinfo);
+ _unitOfWorkManage.CommitTran();
+ //}
+
+ LogFactory.GetLog("MES鎷夊姩閿佽溅").Info(true, $"\r\r--------------------------------------");
+ LogFactory.GetLog("MES鎷夊姩閿佽溅").Info(true, jsondata.ToJsonString());
+ LockResult lockResult = new LockResult { result = "1", lockPvi = carBody.PVI };
+ content.OK(data: lockResult);
}
-
- LogFactory.GetLog("MES鎷夊姩閿佽溅").Info(true, $"\r\r--------------------------------------");
- LogFactory.GetLog("MES鎷夊姩閿佽溅").Info(true, jsondata.ToJsonString());
-
- return content;
}
catch (Exception ex)
{
- return content.Error(ex.Message);
+ LogFactory.GetLog("MES鎷夊姩閿佽溅").Info(true, $"閿佽溅澶辫触:{ex.Message};璇锋眰鍙傛暟{jsondata.ToJsonString()}锛� ");
+ _unitOfWorkManage.RollbackTran();
+ content.result = "2";
+ LockResult result = new LockResult { result = "2", lockPvi = "" };
+ content.Error(ex.Message, result);
}
+ return content;
}
}
}
--
Gitblit v1.9.3