From ea9bdf217e8202a5fa475262dba1792decb05bcb Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期五, 13 九月 2024 15:36:00 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 291 +++------------------------------------------------------- 1 files changed, 15 insertions(+), 276 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index 469485b..4e92639 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -25,6 +25,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; +using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; using WIDESEA_Core; @@ -36,9 +37,11 @@ using WIDESEA_DTO.Stock; using WIDESEA_IBasicRepository; using WIDESEA_IBasicService; +using WIDESEA_IOutboundRepository; using WIDESEA_IOutboundService; using WIDESEA_IRecordService; using WIDESEA_IStockRepository; +using WIDESEA_IStockService; using WIDESEA_ITaskInfoRepository; using WIDESEA_ITaskInfoService; using WIDESEA_Model.Models; @@ -46,257 +49,46 @@ namespace WIDESEA_TaskInfoService { - public class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService + public partial class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService { private readonly IMapper _mapper; private readonly IUnitOfWorkManage _unitOfWorkManage; private readonly ILocationInfoService _locationInfoService; - private readonly ILocationInfoRepository _locationInfoRepository; - private readonly IStockInfoRepository _stockInfoRepository; + private readonly IStockInfoService _stockInfoService; private readonly ILocationStatusChangeRecordSetvice _locationStatusChangeRecordSetvice; private readonly IOutboundOrderDetailService _outboundOrderDetailService; private readonly IRoadwayInfoRepository _roadwayInfoRepository; + private readonly IOutStockLockInfoService _outStockLockInfoService; - public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService, ILocationInfoRepository locationInfoRepository, IStockInfoRepository stockInfoRepository, ILocationStatusChangeRecordSetvice locationStatusChangeRecordSetvice, IOutboundOrderDetailService outboundOrderDetailService, IRoadwayInfoRepository roadwayInfoRepository) : base(BaseDal) + public ITaskRepository Repository => BaseDal; + + public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService, IStockInfoRepository stockInfoRepository, ILocationStatusChangeRecordSetvice locationStatusChangeRecordSetvice, IOutboundOrderDetailService outboundOrderDetailService, IRoadwayInfoRepository roadwayInfoRepository, IOutStockLockInfoService outStockLockInfoService, IStockInfoService stockInfoService) : base(BaseDal) { _mapper = mapper; _locationInfoService = locationInfoService; - _locationInfoRepository = locationInfoRepository; - _stockInfoRepository = stockInfoRepository; + _stockInfoService = stockInfoService; _locationStatusChangeRecordSetvice = locationStatusChangeRecordSetvice; _outboundOrderDetailService = outboundOrderDetailService; _roadwayInfoRepository = roadwayInfoRepository; _unitOfWorkManage = unitOfWorkManage; - } - - /// <summary> - /// PDA鐢宠鍏ュ簱--鍫嗗灈鏈虹珛搴撳叆搴� - /// </summary> - /// <param name="stationCode">璧峰鍦板潃</param> - /// <param name="taskType">浠诲姟绫诲瀷--鍏ョ┖锛屽叆鏂�</param> - /// <param name="palletCode">鎵樼洏缂栧彿</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - public WebResponseContent GenerateInboundTask(string stationCode, int taskType, string palletCode) - { - string? name = Enum.GetName(typeof(TaskTypeEnum), taskType); - MethodInfo? methodInfo = GetType().GetMethod(name + "Request"); - if (methodInfo != null) - { - WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { stationCode, palletCode }); - if (responseContent != null) - { - return responseContent; - } - } - else - { - return WebResponseContent.Instance.Error("鏈壘鍒拌浠诲姟绫诲瀷涓氬姟"); - } - return WebResponseContent.Instance.Error("閿欒"); - } - - /// <summary> - /// 绌烘墭鐩樺叆搴� - /// </summary> - /// <param name="stationCode">璧峰鍦板潃</param> - /// <param name="palletCode">鎵樼洏缂栧彿</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - public WebResponseContent PalletInboundRequest(string stationCode, string palletCode) - { - WebResponseContent content = new WebResponseContent(); - try - { - (bool, string) result = CheckRequestInbound(stationCode, palletCode, false); - if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); - content = AssignLocUpdateData(stationCode, TaskTypeEnum.PalletInbound.ObjToInt(), palletCode, false); - } - catch (Exception ex) - { - content = WebResponseContent.Instance.Error(ex.Message); - } - return content; - } - - /// <summary> - /// 鐗╂枡鍏ュ簱 - /// </summary> - /// <param name="stationCode">璧峰鍦板潃</param> - /// <param name="palletCode">鎵樼洏缂栧彿</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - public WebResponseContent InboundRequest(string stationCode, string palletCode) - { - WebResponseContent content = new WebResponseContent(); - try - { - Dt_StockInfo stockInfo = _stockInfoRepository.GetStockInfo(palletCode); - (bool, string) result = CheckRequestInbound(stationCode, palletCode, true, stockInfo); - if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); - content = AssignLocUpdateData(stationCode, TaskTypeEnum.Inbound.ObjToInt(), palletCode, true, stockInfo); - } - catch (Exception ex) - { - content = WebResponseContent.Instance.Error(ex.Message); - } - return content; - } - - /// <summary> - /// 鍏ュ簱鍒嗛厤璐т綅鍙婂鐞嗘暟鎹� - /// </summary> - /// <param name="stationCode">璧峰鍦板潃</param> - /// <param name="taskType">浠诲姟绫诲瀷</param> - /// <param name="palletCode">鎵樼洏缂栧彿</param> - /// <param name="isUpdateStock">鏄惁鏇存柊缁勭洏淇℃伅--鍖哄垎鐗╂枡鍏ュ簱鍜岀┖鎵樺叆搴�</param> - /// <param name="stockInfo">缁勭洏淇℃伅--鍙┖</param> - /// <param name="orderNo">璁㈠崟鍙�--鍙┖</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - private WebResponseContent AssignLocUpdateData(string stationCode, int taskType, string palletCode, bool isUpdateStock = true, Dt_StockInfo? stockInfo = null, string orderNo = "") - { - WebResponseContent content = new WebResponseContent(); - try - { - Dt_LocationInfo? locationInfo = _locationInfoService.AssignLocation(stationCode, taskType); - if (locationInfo != null) - { - Dt_Task task = new() - { - CurrentAddress = stationCode, - Grade = 0, - PalletCode = palletCode, - NextAddress = locationInfo.LocationCode, - Roadway = locationInfo.RoadwayNo, - SourceAddress = stationCode, - TargetAddress = locationInfo.LocationCode, - TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), - TaskType = taskType, - }; - BaseDal.AddData(task); - int beforeStatus = locationInfo.LocationStatus; - - locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); - if (isUpdateStock) - { - locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); - if (stockInfo != null && stockInfo.Details != null && stockInfo.Details.Count > 0) - { - orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; - - stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); - _stockInfoRepository.UpdateData(stockInfo); - } - else - { - return content = WebResponseContent.Instance.Error("鏈壘鍒板簱瀛樹俊鎭�"); - } - } - _locationInfoRepository.UpdateData(locationInfo); - _locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), orderNo, task.TaskNum); - - return content = WebResponseContent.Instance.OK(); - } - return content = WebResponseContent.Instance.Error("鏈壘鍒板彲鍒嗛厤璐т綅"); - } - catch (Exception ex) - { - content = WebResponseContent.Instance.Error(ex.Message); - } - return content; - } - - /// <summary> - /// 楠岃瘉鏁版嵁 - /// </summary> - /// <param name="stationCode">璧峰鍦板潃</param> - /// <param name="palletCode">鎵樼洏缂栧彿</param> - /// <param name="isCheckStock">鏄惁妫�鏌ョ粍鐩樹俊鎭�--鍖哄垎鐗╂枡鍏ュ簱鍜岀┖鎵樺叆搴�</param> - /// <param name="stockInfo">缁勭洏淇℃伅--鍙┖</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - private (bool, string) CheckRequestInbound(string stationCode, string palletCode, bool isCheckStock = true, Dt_StockInfo? stockInfo = null) - { - if (BaseDal.QueryFirst(x => x.PalletCode == palletCode) != null) - { - return (false, "璇ユ墭鐩樺彿宸叉湁浠诲姟"); - } - if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null) - { - return (false, "褰撳墠鍏ュ簱绔欏彴宸叉湁涓�鏉℃柊寤轰换鍔�"); - } - if (isCheckStock) - { - if (stockInfo == null) - { - return (false, "鏈壘鍒扮粍鐩樹俊鎭�"); - } - if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt()) - { - return (false, "璇ョ粍鐩樼姸鎬佷笉鍙叆搴�"); - } - if (!string.IsNullOrEmpty(stockInfo.LocationCode)) - { - return (false, "璇ユ墭鐩樺凡缁戝畾璐т綅"); - } - if (stockInfo.Details == null || stockInfo.Details.Count == 0) - { - return (false, "娌℃湁搴撳瓨鏄庣粏淇℃伅"); - } - } - else - { - if (_stockInfoRepository.QueryFirst(x => x.PalletCode == palletCode) != null) - { - return (false, "璇ユ墭鐩樺凡瀛樺湪搴撳唴"); - } - } - - return (true, "鎴愬姛"); - } - - /// <summary> - /// 绌烘墭鐩樺叆搴撳畬鎴愬鐞� - /// </summary> - /// <param name="task">浠诲姟瀹炰綋瀵硅薄</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - public WebResponseContent PalletInboundTaskCompleted(Dt_Task task) - { - Dt_StockInfo stockInfo = new Dt_StockInfo() - { - PalletCode = task.PalletCode, - LocationCode = task.TargetAddress, - StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt() - }; - Dt_LocationInfo locationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress); - - CheckInboundCompleted(stockInfo, locationInfo); - - _stockInfoRepository.AddData(stockInfo); - - int beforeStatus = locationInfo.LocationStatus; - locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); - _locationInfoRepository.UpdateData(locationInfo); - - - BaseDal.DeleteData(task); - - _locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); - - return WebResponseContent.Instance.OK(); + _outStockLockInfoService = outStockLockInfoService; } public WebResponseContent InboundTaskCompleted(Dt_Task task) { - Dt_StockInfo stockInfo = _stockInfoRepository.GetStockInfo(task.PalletCode); + Dt_StockInfo stockInfo = _stockInfoService.Repository.GetStockInfo(task.PalletCode); - Dt_LocationInfo locationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress); + Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); CheckInboundCompleted(stockInfo, locationInfo); stockInfo.LocationCode = locationInfo.LocationCode; stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); - _stockInfoRepository.UpdateData(stockInfo); + _stockInfoService.Repository.UpdateData(stockInfo); int beforeStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); - _locationInfoRepository.UpdateData(locationInfo); + _locationInfoService.Repository.UpdateData(locationInfo); BaseDal.DeleteData(task); @@ -355,58 +147,5 @@ return WebResponseContent.Instance.Error(); } - public WebResponseContent GenerateOutboundTask(int orderDetailId, List<StockSelectViewDTO> stockSelectViews) - { - try - { - List<Dt_Task> tasks = new List<Dt_Task>(); - (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundOrderDetailService.AssignStockOutbound(orderDetailId, stockSelectViews); - for (int i = 0; i < result.Item1.Count; i++) - { - Dt_StockInfo stockInfo = result.Item1[i]; - - if (stockInfo != null) - { - Dt_LocationInfo locationInfo = _locationInfoRepository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode); - Dt_RoadwayInfo roadwayInfo = _roadwayInfoRepository.QueryFirst(x => x.RoadwayNo == locationInfo.RoadwayNo); - if (roadwayInfo != null) - { - Dt_Task task = new() - { - CurrentAddress = stockInfo.LocationCode, - Grade = 0, - PalletCode = stockInfo.PalletCode, - NextAddress = roadwayInfo.OutSCStationCode, - Roadway = locationInfo.RoadwayNo, - SourceAddress = stockInfo.LocationCode, - TargetAddress = roadwayInfo.OutStationCode, - TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), - TaskType = TaskTypeEnum.Outbound.ObjToInt(), - }; - tasks.Add(task); - } - } - } - result.Item2.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); - result.Item3.ForEach(x => - { - x.Status = OutStockStatus.鍑哄簱涓�.ObjToInt(); - }); - List<Dt_LocationInfo> locationInfos = _locationInfoRepository.GetLocationInfos(result.Item3.Select(x => x.LocationCode).ToList()); - - _unitOfWorkManage.BeginTran(); - - BaseDal.AddData(tasks); - _outboundOrderDetailService.LockOutboundStockDataUpdate(result.Item1, result.Item2, result.Item3, locationInfos); - _locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, LocationStatusEnum.Lock.ObjToInt(), StockChangeType.Outbound.ObjToInt(), "", tasks.Select(x => x.TaskNum).ToList()); - _unitOfWorkManage.CommitTran(); - return WebResponseContent.Instance.OK(); - } - catch (Exception ex) - { - _unitOfWorkManage.RollbackTran(); - return WebResponseContent.Instance.Error(ex.Message); - } - } } } -- Gitblit v1.9.3