From d5fe80c5cb7dc0b209d8fea9faa84c7ca5b20324 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期五, 16 一月 2026 16:07:18 +0800
Subject: [PATCH] 出入库移库完成
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 236 ++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 163 insertions(+), 73 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index c48f46f..2e16a0f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -16,9 +16,14 @@
#endregion << 鐗� 鏈� 娉� 閲� >>
using AutoMapper;
+using Microsoft.Extensions.Logging;
+using Org.BouncyCastle.Math.EC;
using SqlSugar;
+using System.ComponentModel;
using System.Net;
using System.Reflection;
+using System.Reflection.Emit;
+using System.Threading.Tasks;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OtherEnum;
using WIDESEA_Common.StockEnum;
@@ -26,6 +31,7 @@
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
+using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Task;
@@ -41,13 +47,14 @@
{
public partial class TaskService : ServiceBase<Dt_Task, IRepository<Dt_Task>>, ITaskService
{
+ private readonly ILogger<TaskService> _logger;
private readonly IMapper _mapper;
private readonly IUnitOfWorkManage _unitOfWorkManage;
private readonly IStockInfoService _stockInfoService;
private readonly ILocationInfoService _locationInfoService;
private readonly IWarehouseService _warehouseService;
private readonly IRoadWayinfoService _roadWayinfoService;
-
+ private Timer _timer;
public IRepository<Dt_Task> Repository => BaseDal;
private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -60,9 +67,10 @@
public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
- public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, ILocationInfoService locationInfoService,
+ public TaskService(ILogger<TaskService> logger, IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, ILocationInfoService locationInfoService,
IWarehouseService warehouseService, IRoadWayinfoService roadWayinfoService) : base(BaseDal)
{
+ _logger = logger;
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -118,99 +126,181 @@
private WebResponseContent HandleInboundTask(Dt_Task task, int wcsTaskType)
{
WebResponseContent content = new WebResponseContent();
- switch (wcsTaskType)
+ try
{
- case 1:
- task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
- int loctype = 0;
- if (task.Roadway == "1" || task.Roadway == "2")
- {
- if(task.PalletType=="1") loctype = (int)LocationTypeEnum.SmallPallet;
- else if(task.PalletType=="2") loctype = (int)LocationTypeEnum.MediumPallet;
- }
- else
- {
- loctype = (int)LocationTypeEnum.LargePallet;
- }
- //鏌ユ壘璐т綅锛屾洿鏂颁换鍔�
- Dt_LocationInfo dt_Location=_locationInfoService.GetLocation(task.Roadway, loctype);
- Dt_LocationInfo ShallowCargoHold = _locationInfoService.ShallowGetLocation(dt_Location.RoadwayNo, dt_Location.LocationType, dt_Location.Row, dt_Location.Layer, dt_Location.Column);
- if(ShallowCargoHold==null) return content.Error($"鏈壘鍒拌璐т綅淇℃伅,璐т綅缂栧彿:{dt_Location.LocationCode}鐨勬祬璐т綅");
- if(ShallowCargoHold.LocationStatus != (int)LocationStatusEnum.Free) return content.Error($"浠诲姟鍙凤細{task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode},鏌ユ壘鐨勮揣浣嶆祬璐т綅鏈夎揣锛岃揣浣嶇紪鍙凤細{ShallowCargoHold.LocationCode}");
+ switch (wcsTaskType)
+ {
+ case 1:
+
+ if(task.TargetAddress == "")
+ {
+ int loctype = 0;
+ if (task.Roadway == "1" || task.Roadway == "2")
+ {
+ if (task.PalletType == "1") loctype = (int)LocationTypeEnum.SmallPallet;
+ else if (task.PalletType == "2") loctype = (int)LocationTypeEnum.MediumPallet;
+ }
+ else
+ {
+ loctype = (int)LocationTypeEnum.LargePallet;
+ }
- task.TargetAddress = dt_Location.LocationCode;
- task.CurrentAddress = task.NextAddress;
- task.NextAddress= dt_Location.LocationCode;
- task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
- dt_Location.LocationStatus = (int)LocationStatusEnum.Lock;
+ //鏌ユ壘璐т綅锛屾洿鏂颁换鍔�
+ Dt_LocationInfo dt_Location = _locationInfoService.GetLocation(task.Roadway, loctype);
+ Dt_LocationInfo ShallowCargoHold = _locationInfoService.ShallowGetLocation(dt_Location.RoadwayNo, dt_Location.LocationType, dt_Location.Row, dt_Location.Layer, dt_Location.Column);
+ if (ShallowCargoHold == null) return content.Error($"鏈壘鍒拌璐т綅淇℃伅,璐т綅缂栧彿:{dt_Location.LocationCode}鐨勬祬璐т綅");
+ if (ShallowCargoHold.LocationStatus != (int)LocationStatusEnum.Free) return content.Error($"浠诲姟鍙凤細{task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode},鏌ユ壘鐨勮揣浣嶆祬璐т綅鏈夎揣锛岃揣浣嶇紪鍙凤細{ShallowCargoHold.LocationCode}");
- _locationInfoService.UpdateData(dt_Location);
- BaseDal.UpdateData(task);
- return content.OK($"宸叉帴鏀跺叆搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
-
-
- case 2:
- //涓婃姤MES浠诲姟瀹屾垚
- MES_parameter mES_Parameter = InStoreDocCallback(task.TaskNum, "Finish", "鎿嶄綔鎴愬姛", task.PalletCode, task.TargetAddress);
- if (mES_Parameter.Result == "Y")
- {
+ task.TargetAddress = dt_Location.LocationCode;
+ task.CurrentAddress = task.NextAddress;
+ task.NextAddress = dt_Location.LocationCode;
+ task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
- task.TaskStatus = (int)InTaskStatusEnum.SC_OutFinish;
- BaseDal.DeleteData(task);
- return content.OK($"宸叉帴鏀跺叆搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
- }
- else
- {
- return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
- }
- default:
- return WebResponseContent.Instance.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
+ dt_Location.LocationStatus = (int)LocationStatusEnum.Lock;
+
+ Dt_StockInfo dt_StockInfo = new Dt_StockInfo();
+ dt_StockInfo.PalletCode = task.PalletCode;
+ dt_StockInfo.PalletType = task.PalletType;
+ dt_StockInfo.WarehouseId = task.WarehouseId;
+ dt_StockInfo.LocationCode = dt_Location.LocationCode;
+ dt_StockInfo.StockStatus = (int)StockStatusEmun.鍏ュ簱涓�;
+ dt_StockInfo.Creater = "MWS";
+ dt_StockInfo.CreateDate = DateTime.Now;
+
+ _unitOfWorkManage.BeginTran();
+ _stockInfoService.AddData(dt_StockInfo);
+ _locationInfoService.UpdateData(dt_Location);
+ BaseDal.UpdateData(task);
+ _unitOfWorkManage.CommitTran();
+ return content.OK($"宸叉帴鏀跺叆搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ }
+ else
+ {
+ string Resultplc = MesInTaskStatusEnum.鍏ュ簱瀹屾垚.GetDescription();
+ MES_parameter mES_PCLParameter = InStoreDocCallback(task.TaskNum, Resultplc, "鎿嶄綔鎴愬姛", task.PalletCode, task.TargetAddress);
+ if (mES_PCLParameter.Result == "Y")
+ {
+ task.TaskStatus = (int)InTaskStatusEnum.PLC_InFinish;
+ _unitOfWorkManage.BeginTran();
+ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ _unitOfWorkManage.CommitTran();
+ return content.OK($"杈撻�佺嚎浠诲姟宸插弽棣堣嚦涓婃父锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ }
+ else
+ {
+ return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_PCLParameter.ResultMsg);
+ }
+ }
+ case 2:
+ string Resultsc = MesInTaskStatusEnum.鍏ュ簱瀹屾垚.GetDescription();
+ //涓婃姤MES浠诲姟瀹屾垚
+ MES_parameter mES_Parameter = InStoreDocCallback(task.TaskNum, Resultsc, "鎿嶄綔鎴愬姛", task.PalletCode, task.TargetAddress);
+ if (mES_Parameter.Result == "Y")
+ {
+ Dt_StockInfo dt_Stockowc = _stockInfoService.Repository.QueryData(x => x.PalletCode == task.PalletCode).FirstOrDefault();
+ Dt_LocationInfo dt_LocationInfo=_locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stockowc.LocationCode).FirstOrDefault();
+
+ dt_Stockowc.StockStatus = (int)StockStatusEmun.宸插叆搴�;
+ dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.InStock;
+ task.TaskStatus = (int)InTaskStatusEnum.InFinish;
+
+ _unitOfWorkManage.BeginTran();
+ _stockInfoService.UpdateData(dt_Stockowc);
+ _locationInfoService.UpdateData(dt_LocationInfo);
+ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ _unitOfWorkManage.CommitTran();
+ return content.OK($"宸叉帴鏀跺叆搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ }
+ else
+ {
+ return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
+ }
+ default:
+ return content.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
+ }
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return content.Error($"WCS浠诲姟瀹屾垚鎺ュ彛鏁呴殰锛屽師鍥狅細{ex.Message}");
}
}
private WebResponseContent HandleOutboundTask(Dt_Task task, int wcsTaskType)
{
WebResponseContent content = new WebResponseContent();
- switch (wcsTaskType)
+ try
{
- case 1:
- //涓婃姤MES浠诲姟瀹屾垚
- MES_parameter mES_Parameter = OutStoreDocCallback(task.TaskNum, "Finish", "鎿嶄綔鎴愬姛");
- if (mES_Parameter.Result == "Y")
- {
- task.TaskStatus = (int)OutTaskStatusEnum.PLC_OutFinish;
- BaseDal.DeleteData(task);
- return content.OK($"宸叉帴鏀跺嚭搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
- }
- else
- {
- return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
- }
- case 2:
- //鑾峰彇瀵瑰簲PLC绔欏彴淇℃伅
- Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(task.Roadway);
- task.CurrentAddress = _Roadwayinfo.OutStationCode;
- task.NextAddress = task.TargetAddress;
- task.TaskStatus = (int)OutTaskStatusEnum.SC_OutFinish;
- BaseDal.UpdateData(task);
- return content.OK($"宸叉帴鏀跺嚭搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
- default:
- return content.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
+ switch (wcsTaskType)
+ {
+ case 1:
+ string Resultplc = MesOutTaskStatusEnum.鍒拌揪鐩殑鍦�.GetDescription();
+ //涓婃姤MES浠诲姟瀹屾垚
+ MES_parameter mES_Parameter = OutStoreDocCallback(task.TaskNum, Resultplc, "鎿嶄綔鎴愬姛");
+ if (mES_Parameter.Result == "Y")
+ {
+ task.TaskStatus = (int)OutTaskStatusEnum.PLC_OutFinish;
+ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ return content.OK($"宸叉帴鏀跺嚭搴撹緭閫佺嚎瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ }
+ else
+ {
+ return content.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
+ }
+ case 2:
+ //鑾峰彇瀵瑰簲PLC绔欏彴淇℃伅
+ Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(task.Roadway);
+ task.CurrentAddress = _Roadwayinfo.OutStationCode;
+ task.NextAddress = task.TargetAddress;
+ task.TaskStatus = (int)OutTaskStatusEnum.SC_OutFinish;
+
+ Dt_StockInfo dt_Stockowc = _stockInfoService.Repository.QueryData(x => x.PalletCode == task.PalletCode).FirstOrDefault();
+ Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stockowc.LocationCode).FirstOrDefault();
+
+ _unitOfWorkManage.BeginTran();
+ _stockInfoService.DeleteData(dt_Stockowc);
+ _locationInfoService.DeleteData(dt_LocationInfo);
+ BaseDal.UpdateData(task);
+ _unitOfWorkManage.CommitTran();
+
+
+ return content.OK($"宸叉帴鏀跺嚭搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ default:
+ return content.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
+ }
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return content.Error($"WCS浠诲姟瀹屾垚鎺ュ彛鏁呴殰锛屽師鍥狅細{ex.Message}");
}
}
private WebResponseContent HandleRelocationTask(Dt_Task task, int wcsTaskType)
{
+ WebResponseContent responseContent = new WebResponseContent();
if (wcsTaskType == 2)
{
- task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish;
- BaseDal.UpdateData(task);
- return WebResponseContent.Instance.OK($"宸叉帴鏀剁Щ搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ //涓婃姤MES鍫嗗灈鏈虹Щ搴撲换鍔�
+ string Resultplc = MesOutTaskStatusEnum.鍒拌揪鐩殑鍦�.GetDescription();
+ //涓婃姤MES浠诲姟瀹屾垚
+ MES_parameter mES_Parameter = AbnormalStorageLocation(task.PalletCode, task.SourceAddress, task.TargetAddress);
+ if (mES_Parameter.Result == "Y")
+ {
+ task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationFinish;
+ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ return WebResponseContent.Instance.OK($"宸叉帴鏀剁Щ搴撳爢鍨涙満瀹屾垚淇℃伅锛屼换鍔″彿锛歿task.TaskId},鎵樼洏缂栧彿锛歿task.PalletCode}");
+ }
+ else
+ {
+ return responseContent.Error("涓婁紶MES澶辫触锛屽師鍥狅細" + mES_Parameter.ResultMsg);
+ }
}
return WebResponseContent.Instance.Error($"WCS涓婃姤绫诲瀷閿欒锛歿wcsTaskType}");
}
-
+
+
}
}
--
Gitblit v1.9.3