From d41acebbd89f171b0eeb205fca4f68043ca85f95 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期三, 03 十二月 2025 19:47:24 +0800
Subject: [PATCH] 选配与暂存
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 155 insertions(+), 3 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
index a7b5f4a..18299f0 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
@@ -5,6 +5,7 @@
using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using SqlSugar;
using System.Diagnostics;
using System.Reflection.Emit;
using System.Text.RegularExpressions;
@@ -47,6 +48,7 @@
private readonly IDt_ZdpStockRepository _ZdpStockRepository;
private readonly IDt_ZdpStock_htyRepository _ZdpStock_HtyRepository;
private readonly IDt_PreOutboundRepository _PreOutboundRepository;
+ private readonly ILocationInfoRepository _locationInfoRepository;
public Dt_TaskService(IDt_TaskRepository BaseDal,
@@ -72,7 +74,8 @@
IDt_ZdpStockRepository zdpStockRepository,
IDt_ZdpStock_htyRepository dt_ZdpStock_HtyRepository,
IDt_OutZdp_htyRepository dt_OutZdp_HtyRepository,
- IDt_PreOutboundRepository dt_PreOutboundRepository) : base(BaseDal)
+ IDt_PreOutboundRepository dt_PreOutboundRepository,
+ ILocationInfoRepository locationInfoRepository) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
@@ -95,6 +98,7 @@
_ZdpStock_HtyRepository = dt_ZdpStock_HtyRepository;
_Dt_OutZdp_htyRepository = dt_OutZdp_HtyRepository;
_PreOutboundRepository = dt_PreOutboundRepository;
+ _locationInfoRepository = locationInfoRepository;
}
#region 澶栭儴鎺ュ彛鏂规硶
@@ -776,7 +780,7 @@
IsCheck = true,
Standards = stockInfo.Wheels_NewOrOld
};
-
+
task = new Dt_Task
{
@@ -816,7 +820,7 @@
}
- // 鑾峰彇WMS IP鍦板潃鐢ㄤ簬鍙戦�佷换鍔¤姹�
+ //鑾峰彇WMS IP鍦板潃鐢ㄤ簬鍙戦�佷换鍔¤姹�
var wmsIpAddress = GetWCSIpReceiveTask();
if (wmsIpAddress == null)
{
@@ -840,6 +844,8 @@
_WheelsStockRepository.UpdateData(WheelList);
}
}
+
+
}
catch (Exception ex)
@@ -909,6 +915,8 @@
return await BaseDal.Delete(ids);
}
+
+ #region 鍒犻櫎浠诲姟鍥炴粴
public override WebResponseContent DeleteData(object[] key)
{
WebResponseContent content = new WebResponseContent();
@@ -924,6 +932,59 @@
if (task.TaskState != (int)TaskInStatusEnum.InNew && task.TaskState != (int)TaskOutStatusEnum.OutNew && task.TaskState != (int)TaskStatus.Created)
{
return content.Error("浠诲姟涓嶅浜庢柊寤虹姸鎬�,绂佹鍒犻櫎!");
+ }
+
+ ////鍏ュ簱鏋氫妇
+ //List<int> TaskInboundTypeEnums = Enum.GetValues(typeof(TaskInboundTypeEnum)).Cast<int>().ToList();
+ ////鍑哄簱鏋氫妇
+ //List<int> TaskOutboundTypeEnums = Enum.GetValues(typeof(TaskOutboundTypeEnum)).Cast<int>().ToList();
+ ////绉诲簱鏋氫妇
+ //List<int> TaskMoveTypeEnums = Enum.GetValues(typeof(TaskRelocationTypeEnum)).Cast<int>().ToList();
+ //鍒ゆ柇浠诲姟绫诲瀷
+ // 鏍规嵁浠诲姟绫诲瀷璋冪敤鐩稿簲鐨勫畬鎴愪换鍔℃柟娉�
+
+ // 楠岃瘉搴撳瓨鏄惁瀛樺湪
+ var stock = _WheelsStockRepository.QueryFirstNavAsync(x => x.Wheels_Num.Contains(task.PalletCode) && x.Wheels_Location == task.SourceAddress);
+ var ZdpStock = _ZdpStockRepository.QueryFirstNavAsync(x => x.Zdp_code == task.PalletCode && x.Zdp_Location == task.SourceAddress);
+ bool res = false;
+ switch (task.TaskType)
+ {
+ case (int)TaskInboundTypeEnum.Inbound:
+ case (int)TaskInboundTypeEnum.InWheels:
+ case (int)TaskInboundTypeEnum.InBrake:
+ LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍏ュ簱浠诲姟", "");
+ res = SellectLocationInfo(task,1);
+ break;
+
+ case (int)TaskOutboundTypeEnum.Outbound:
+ case (int)TaskOutboundTypeEnum.OutWheels:
+ LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍑哄簱浠诲姟", "");
+ res = SellectLocationInfo(task,2);
+ break;
+
+ case (int)TaskOutboundTypeEnum.OutBrake:
+ LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍒跺姩鐩樺嚭搴撲换鍔�", "");
+ res = SellectLocationInfo(task,3);
+ break;
+
+ case (int)TaskRelocationTypeEnum.Relocation:
+ if (stock != null)
+ {
+ res = SellectLocationInfo(task,4);
+ }
+ else
+ {
+ res = SellectLocationInfo(task,5);
+ }
+ break;
+
+ default:
+ return content.Error("浠诲姟绫诲瀷涓嶅瓨鍦�");
+ }
+
+ if (!res)
+ {
+ return content.Error("鍦ㄦ墽琛屼换鍔″垎绫荤殑鏃跺�欏嚭鐜伴敊璇紒");
}
var taskHtyNG = CreateHistoricalTask(task, true);
@@ -948,6 +1009,97 @@
}
/// <summary>
+ /// 鑾峰彇搴撲綅淇℃伅
+ /// </summary>
+ /// <param name="targetAddress"></param>
+ /// <returns></returns>
+ /// <exception cref="NotImplementedException"></exception>
+ private bool SellectLocationInfo(Dt_Task task,int taskType)
+ {
+ // 鑾峰彇搴撲綅淇℃伅
+ DtLocationInfo locationInfoT = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
+ DtLocationInfo locationInfoS = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
+
+
+ Dt_WheelsStock stock = _WheelsStockRepository.QueryFirst(x => x.Wheels_Num.Contains(task.PalletCode) && x.Wheels_Location == task.SourceAddress);
+ Dt_ZdpStock ZdpStock = _ZdpStockRepository.QueryFirst(x => x.Zdp_code == task.PalletCode && x.Zdp_Location == task.SourceAddress);
+
+ //if (locationInfoT == null) return false;
+
+ //if (locationInfoS == null) return false;
+ //1-鍏ュ簱 2-鍑哄簱 3-鍒跺姩鐩樺嚭搴� 4-绉诲簱
+ var db = _locationInfoRepository.Db as SqlSugarClient;
+ try
+ {
+ db.Ado.BeginTran();
+ if (taskType == 1)
+ {
+ locationInfoT.LocationStatus = (int)LocationEnum.Free;
+ bool res = _locationInfoRepository.UpdateData(locationInfoT);
+ if (res)
+ {
+ db.Ado.CommitTran();
+ return true;
+ }
+ }
+ else if (taskType == 2)
+ {
+ locationInfoS.LocationStatus = (int)LocationEnum.InStock;
+ bool res = _locationInfoRepository.UpdateData(locationInfoS);
+ stock.Wheels_CurrentStatue = 1;
+ bool ress = _WheelsStockRepository.UpdateData(stock);
+ if (res && ress)
+ {
+ db.Ado.CommitTran();
+ return true;
+ }
+ }
+ else if (taskType == 3)
+ {
+ locationInfoS.LocationStatus = (int)LocationEnum.InStock;
+ bool res = _locationInfoRepository.UpdateData(locationInfoS);
+ ZdpStock.Zdp_CurrentStatue = 1;
+ bool ress = _ZdpStockRepository.UpdateData(ZdpStock);
+ if (res && ress)
+ {
+ db.Ado.CommitTran();
+ return true;
+ }
+ }
+ //绉诲簱
+ else
+ {
+ locationInfoT.LocationStatus = (int)LocationEnum.Free;
+ locationInfoS.LocationStatus = (int)LocationEnum.InStock;
+ bool res = _locationInfoRepository.UpdateData(locationInfoT);
+ bool res1 = _locationInfoRepository.UpdateData(locationInfoS);
+ if(taskType == 4)
+ {
+ stock.Wheels_CurrentStatue = 1;
+ }
+ else
+ {
+ ZdpStock.Zdp_CurrentStatue = 1;
+ }
+ bool ress = taskType == 4 ? _WheelsStockRepository.UpdateData(stock) : _ZdpStockRepository.UpdateData(ZdpStock);
+ if (res && res1 && ress)
+ {
+ db.Ado.CommitTran();
+ return true;
+ }
+ }
+ return false;
+ }
+ catch (Exception ex)
+ {
+ db.Ado.RollbackTran();
+ return false;
+ }
+ }
+
+ #endregion
+
+ /// <summary>
/// 閫氳繃ID鑾峰彇浠诲姟
/// </summary>
/// <param name="id">浠诲姟ID</param>
--
Gitblit v1.9.3