From c020f31a67fc5aa5644511bddff075f7ecc85234 Mon Sep 17 00:00:00 2001 From: qinchulong <qinchulong@hnkhzn.com> Date: 星期二, 27 五月 2025 15:35:27 +0800 Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/ZhongHeLiTiKu --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 231 insertions(+), 0 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" new file mode 100644 index 0000000..dfb74fb --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" @@ -0,0 +1,231 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using WIDESEA_Core.Enums; +using WIDESEA_Core; +using WIDESEA_Model.Models; +using WIDESEA_Core.Helper; +using Microsoft.Extensions.Logging; +using System.Net.Http.Headers; +using System.Security.Policy; +using Newtonsoft.Json; + +namespace WIDESEA_TaskInfoService +{ + public partial class TaskService + { + public string url = AppSettings.Configuration["WCS"]; + /// <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 = _stockService.StockInfoService.Repository.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 + { + _unitOfWorkManage.BeginTran(); + Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(stationCode, taskType); + if (locationInfo != null) + { + List<Dt_Task> tasks = new List<Dt_Task>(); + Dt_Task task = new() + { + CurrentAddress = stationCode, + Grade = 2, + PalletCode = palletCode, + NextAddress = locationInfo.LocationCode, + Roadway = locationInfo.RoadwayNo, + SourceAddress = stationCode, + TargetAddress = locationInfo.LocationCode, + TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), + TaskType = taskType, + Depth= locationInfo.Depth, + }; + BaseDal.AddData(task); + int beforeStatus = locationInfo.LocationStatus; + + if (isUpdateStock) + { + locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); + if (locationInfo.Depth == 2) + { + _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); + } + + if (stockInfo != null && stockInfo.Details != null && stockInfo.Details.Count > 0) + { + orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; + + stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + } + else + { + return content = WebResponseContent.Instance.Error("鏈壘鍒板簱瀛樹俊鎭�"); + } + } + else + { + locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); + if (locationInfo.Depth == 2) + { + _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); + } + task.Grade = 1; + } + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + + tasks.Add(task); + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), orderNo, task.TaskNum); + + var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", tasks, "鍏ュ簱浠诲姟涓嬪彂"); + if (!response.Status) + { + _unitOfWorkManage.RollbackTran(); + return content = WebResponseContent.Instance.Error($"{response.Message}"); + } + _unitOfWorkManage.CommitTran(); + return content = WebResponseContent.Instance.OK(); + } + return content = WebResponseContent.Instance.Error("鏈壘鍒板彲鍒嗛厤璐т綅"); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + 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 (_stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == palletCode) != null) + { + return (false, "璇ユ墭鐩樺凡瀛樺湪搴撳唴!"); + } + } + + return (true, "鎴愬姛!"); + } + + + } +} -- Gitblit v1.9.3