From 5b2265e68c0a493c52ea336f77f8dbcd7655d34a Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期五, 22 十一月 2024 10:20:59 +0800 Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/BaiBuLiKu --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 249 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 177 insertions(+), 72 deletions(-) diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs index ed4d3ef..0fb68e6 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -13,7 +13,7 @@ namespace WIDESEA_StorageOutTaskServices; -public class Dt_TaskService : ServiceBase<Dt_Task, IDt_TaskRepository>, IDt_TaskService +public partial class Dt_TaskService : ServiceBase<Dt_Task, IDt_TaskRepository>, IDt_TaskService { private readonly LogFactory LogFactory = new LogFactory(); private readonly IUnitOfWorkManage _unitOfWorkManage; @@ -93,11 +93,11 @@ { if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) { - var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>() - .FirstAsync(x => x.EquipmentName == task.Roadway); - var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue); + //var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>() + // .FirstAsync(x => x.EquipmentName == task.Roadway); + //var info = JsonConvert.DeserializeObject<ResponseEqptRunDto>(process.ProcessValue); - var agingOutputDto = MapToAgingOutputDto(stock, info); + var agingOutputDto = MapToAgingOutputDto(stock); content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); ValidateResponse(content); } @@ -123,31 +123,37 @@ } } - private AgingOutputDto MapToAgingOutputDto(DtStockInfo stock, ResponseEqptRunDto info) + private AgingOutputDto MapToAgingOutputDto(DtStockInfo stock, ResponseEqptRunDto info = null) { // TODO Value鍊兼牴鎹甅OM涓嬪彂鐨勯潤缃椂闂村埌褰撳墠鏃堕棿鐨勫垎閽熸暟 + var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == stock.AreaCode); + if (area == null) + { + throw new Exception("鏈壘鍒板搴旂殑搴撳尯淇℃伅"); + } return new AgingOutputDto { OpFlag = 1, - Software = "WMS", - EquipmentCode = "24MEJQ08-1091", + Software = area.Spare3, + EquipmentCode = area.Spare2, TrayBarcode = stock.PalletCode, SerialNos = stock.StockInfoDetails.Select(x => new SerialNoOutDto { SlotNo = x.OrderNo.ToInt32(), SerialNo = x.SerialNumber, SerialNoResult = true, - ParameterInfo = info.ParameterInfo.Select(y => new ParameterInfo() - { - LowerLomit = y.LowerControlLimit, - UpperLimit = y.UpperControlLimit, - ParameterResult = y.EquipmentAvailabilityFlag, - ParameterCode = y.ParameterCode, - ParameterDesc = y.Description, - TargetValue = y.TargetValue, - Value = (DateTime.Parse(stock.LinedProcessFeedbackTime, null, System.Globalization.DateTimeStyles.RoundtripKind).ToLocalTime() - stock.CreateDate).TotalMinutes.ToString(), - DefectCode = y.UOMCode - }).ToList() + ParameterInfo = new List<ParameterInfo> { new ParameterInfo() { Value = (DateTime.Now - stock.CreateDate).TotalMinutes.ToString() } } + //ParameterInfo = info.ParameterInfo.Select(y => new ParameterInfo() + //{ + // LowerLomit = y.LowerControlLimit, + // UpperLimit = y.UpperControlLimit, + // ParameterResult = y.EquipmentAvailabilityFlag, + // ParameterCode = y.ParameterCode, + // ParameterDesc = y.Description, + // TargetValue = y.TargetValue, + // Value = (DateTime.Parse(stock.LinedProcessFeedbackTime, null, System.Globalization.DateTimeStyles.RoundtripKind).ToLocalTime() - stock.CreateDate).TotalMinutes.ToString(), + // DefectCode = y.UOMCode + //}).ToList() }).ToList() }; } @@ -164,7 +170,7 @@ private (DtLocationInfo, Dt_Task) UpdateStockAndTaskStatus(DtStockInfo stock, Dt_Task task) { var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); - var details = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id); + //var details = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id); location.LocationStatus = (int)LocationEnum.Free; task.TaskState = (int)TaskOutStatusEnum.OutFinish; @@ -289,6 +295,7 @@ // 璁板綍寮傚父淇℃伅鍒版帶鍒跺彴鍜屾棩蹇� Console.WriteLine(err.Message.ToString()); LogFactory.GetLog("浠诲姟瀹屾垚").Error(true, err); + content.Error(err.Message); } return content; } @@ -327,7 +334,11 @@ private DtStockInfo CreateFullPalletStock(Dt_Task task, DtLocationInfo locationInf, DtBoxingInfo boxing) { var loation = _locationRepository.QueryFirst(x => x.RoadwayNo == task.Roadway && x.LocationCode == task.TargetAddress); + if (loation == null) + throw new Exception("鏈壘鍒板搴斾綅缃俊鎭�"); var area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId); + if (area == null) + throw new Exception("鏈壘鍒板搴斿尯鍩熶俊鎭�"); var boxDetail = boxing.BoxingInfoDetails.Adapt<List<DtStockInfoDetail>>(); boxDetail.ForEach(x => { x.Status = (int)StockStateEmun.宸插叆搴�; }); var stock = new DtStockInfo() @@ -350,8 +361,8 @@ .ToList(), TrayBarcode = task.PalletCode, OpFlag = 1, - EquipmentCode = "24MEJQ08-1091", - Software = "WMS" + EquipmentCode = area.Spare2, + Software = area.Spare3 }; var result = _agingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result; var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.Data.ToString()); @@ -452,13 +463,17 @@ } } + var area = await _areaInfoRepository.QueryFirstAsync(x => x.Spare1.Contains(input.Position)); + if (area == null) + return content.Error("鏀圭偣浣嶄笉鍦ㄥ尯鍩熷垪琛ㄤ腑瀛樺湪"); + // 鍒涘缓涓�涓猅rayCellsStatusDto瀵硅薄锛屽苟璧嬪�� TrayCellsStatusDto trayCells = new TrayCellsStatusDto() { - Software = "WMS", + Software = area.Spare3, TrayBarcode = input.PalletCode, //EquipmentCode = "EQ_CWJZ01" - EquipmentCode = "24MEJQ08-1091" + EquipmentCode = area.Spare2 }; // 璋冪敤GetTrayCellStatusAsync鏂规硶锛岃幏鍙栨暣鐩樼數鑺� @@ -487,6 +502,12 @@ // 濡傛灉process涓簄ull锛屽垯杩斿洖content if (process == null) return content; + + // 骞惰祴鍊间笂浣嶈蒋浠跺悕绉板拰璁惧缂栫爜 + process.Software = area.Spare3; + process.EquipmentCode = area.Spare2; + + // 璋冪敤GetProcessApplyAsync鏂规硶锛岃幏鍙栧伐鑹虹敵璇� // 璋冪敤_processApplyService.GetProcessApplyAsync鏂规硶锛岃幏鍙栧伐鑹虹敵璇� content = await _processApplyService.GetProcessApplyAsync(process); @@ -615,8 +636,6 @@ // 鍒涘缓涓�涓狿rocessApplyDto瀵硅薄锛屽苟璧嬪�� return new ProcessApplyDto() { - EquipmentCode = "24MEJQ08-1091", - Software = "WMS", //WipOrderNo = result.BindCode, SerialNos = content.SerialNos.Select(item => new SerialNos { @@ -825,7 +844,7 @@ if (task == null) return content.Error("鏈壘鍒颁换鍔�"); - if (taskState == (int)TaskOutStatusEnum.Line_OutFinish || taskState == (int)TaskOutStatusEnum.SC_OutFinish) + if (taskState == (int)TaskOutStatusEnum.Line_OutFinish || taskState == (int)TaskInStatusEnum.SC_InFinish) { var taskHty = CreateHistoricalTask(task); await _unitOfWorkManage.UseTranAsync(async () => @@ -1116,12 +1135,13 @@ /// <param name="taskHty">鍘嗗彶浠诲姟瀵硅薄</param> /// <param name="taskId">浠诲姟ID</param> /// <returns></returns> - private async Task<bool> ExecuteTransaction(DtStockInfo stock, Dt_Task_Hty taskHty, DtLocationInfo locationInfo, int taskId) + private async Task<bool> ExecuteTransaction(DtStockInfo stock, Dt_Task_Hty taskHty, DtLocationInfo locationInfo, int taskId, DtBoxingInfo boxingInfo = null) { _unitOfWorkManage.BeginTran(); try { var isUpdateStock = true; + var isDeleteBoxing = true; if (taskHty.TaskType == (int)TaskTypeEnum.Outbound) { // 鏇存柊搴撳瓨 @@ -1131,6 +1151,9 @@ { // 娣诲姞搴撳瓨 isUpdateStock = await _stockInfoRepository.AddDataNavAsync(stock); + isDeleteBoxing = await _boxingInfoRepository.Db.DeleteNav<DtBoxingInfo>(x => x.Id == boxingInfo.Id) + .Include(x => x.BoxingInfoDetails) + .ExecuteCommandAsync(); } @@ -1145,7 +1168,7 @@ var isTaskDelete = await Delete(taskId); // 鎻愪氦鎴栧洖婊氫簨鍔� - if (isUpdateStock && isTaskHtyAdd && isTaskDelete && isUpdateLoc) + if (isUpdateStock && isTaskHtyAdd && isTaskDelete && isUpdateLoc && isDeleteBoxing) { LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "浠诲姟瀹屾垚", $"浜嬪姟澶勭悊瀹屾垚,鎻愪氦浜嬪姟銆傛坊鍔犲巻鍙蹭换鍔★細{isTaskHtyAdd},鍒犻櫎浠诲姟鏁版嵁锛歿isTaskDelete},鏇存柊鎴栨坊鍔犲簱瀛橈細{isUpdateStock},淇敼绉诲簱鍓嶈揣浣嶇姸鎬侊細{isUpdateLoc}"); _unitOfWorkManage.CommitTran(); @@ -1160,7 +1183,7 @@ } catch (Exception err) { - LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, $"绉诲簱浠诲姟瀹屾垚,绯荤粺寮傚父锛屽紓甯镐俊鎭細{err.Message}", "鏃犲弬鏁�"); + LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, $"浠诲姟瀹屾垚,绯荤粺寮傚父锛屽紓甯镐俊鎭細{err.Message}", "鏃犲弬鏁�"); _unitOfWorkManage.RollbackTran(); throw; // 鎶涘嚭寮傚父浠ヤ究澶栭儴鎹曡幏 } @@ -1176,46 +1199,140 @@ /// <param name="task">浠诲姟瀹炰緥</param> /// <param name="content">鍝嶅簲鍐呭</param> /// <returns></returns> + //private async Task<WebResponseContent> UpdateExistingTask(RequestTaskDto input, Dt_Task task) + //{ + // // 鍒涘缓WebResponseContent瀵硅薄 + // WebResponseContent content = new WebResponseContent(); + // // 瀹氫箟鍙橀噺 + // string toAddress; + // int taskState; + // string original = task.CurrentAddress; + // DtLocationInfo location = new DtLocationInfo(); + // int beforeStatus = 0; + + // // 澶勭悊鍏ュ簱浠诲姟 + // location = await GetLocationDistributeAsync(task.Roadway); + // toAddress = location.LocationCode; + // taskState = (int)TaskInStatusEnum.Line_InFinish; + // beforeStatus = location.LocationStatus; + + // // 鏇存柊璐т綅淇℃伅 + // location.LocationStatus = (int)LocationEnum.Lock; + + // // 鏇存柊浠诲姟淇℃伅 + // task.CurrentAddress = input.Position; + // task.TargetAddress = toAddress; + // task.NextAddress = toAddress; + // task.TaskState = taskState; + + // // 寮�濮嬩簨鍔� + // _unitOfWorkManage.BeginTran(); + // // 瀹氫箟鍙橀噺 + // bool isUpdateLo = true; + // bool isUpdateChange = true; + + // // 灏濊瘯鏇存柊浠诲姟 + // bool isResult = await BaseDal.UpdateDataAsync(task); + // bool isTaskDetail = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(task.PalletCode, original, input.Position, TaskInStatusEnum.Line_InFinish.GetIntegralRuleTypeEnumDesc())); + + // // 鍒涘缓LocationChangeRecordDto瀵硅薄 + // LocationChangeRecordDto changeRecordDto = new LocationChangeRecordDto() + // { + // // 璁剧疆鍙橀噺 + // AfterStatus = location.LocationStatus, + // BeforeStatus = beforeStatus, + // TaskNum = task.TaskNum.Value, + // LocationId = location.Id, + // LocationCode = location.LocationCode, + // ChangeType = (int)StatusChangeTypeEnum.AutomaticStorage, + // }; + // // 鏇存柊浣嶇疆鐘舵�� + // isUpdateChange = _locationStatusChangeRecordRepository.AddStatusChangeRecord(changeRecordDto); + // isUpdateLo = await _locationRepository.UpdateDataAsync(location); + + // if (isResult && isUpdateLo && isTaskDetail) + // { + // // 鎻愪氦浜嬪姟 + // _unitOfWorkManage.CommitTran(); + // content.OK(data: task); + // } + // else + // { + // // 鍥炴粴浜嬪姟 + // _unitOfWorkManage.RollbackTran(); + // content.Error("鏇存柊浠诲姟澶辫触"); + // } + // return content; + //} + + // 鏇存柊浠诲姟璐т綅 + private async Task<WebResponseContent> UpdateExistingTask(RequestTaskDto input, Dt_Task task) { - // 鍒涘缓WebResponseContent瀵硅薄 - WebResponseContent content = new WebResponseContent(); - // 瀹氫箟鍙橀噺 - string toAddress; - int taskState; - string original = task.CurrentAddress; - DtLocationInfo location = new DtLocationInfo(); - int beforeStatus = 0; + if (task == null) + { + return new WebResponseContent().Error("浠诲姟瀵硅薄涓虹┖"); + } - // 澶勭悊鍏ュ簱浠诲姟 - location = await GetLocationDistributeAsync(task.Roadway); - toAddress = location.LocationCode; - taskState = (int)TaskInStatusEnum.Line_InFinish; - beforeStatus = location.LocationStatus; + try + { + // 鍒涘缓WebResponseContent瀵硅薄 + var content = new WebResponseContent(); - // 鏇存柊璐т綅淇℃伅 - location.LocationStatus = (int)LocationEnum.Lock; + // 鑾峰彇鐩爣鍦板潃鍜屾洿鏂颁换鍔$姸鎬� + var location = await GetLocationDistributeAsync(task.Roadway); + if (location == null) + { + return content.Error("鏃犳硶鑾峰彇璐т綅淇℃伅"); + } - // 鏇存柊浠诲姟淇℃伅 + string toAddress = location.LocationCode; + int taskState = (int)TaskInStatusEnum.Line_InFinish; + int beforeStatus = location.LocationStatus; + + // 鏇存柊璐т綅淇℃伅 + location.LocationStatus = (int)LocationEnum.Lock; + + // 鏇存柊浠诲姟淇℃伅 + MapTaskProperties(task, input, toAddress, taskState); + + // 寮�濮嬩簨鍔� + var isResult = await UpdateTaskAsync(task, location, beforeStatus); + if (!isResult) + { + _unitOfWorkManage.RollbackTran(); + return content.Error("鏇存柊浠诲姟澶辫触"); + } + + // 鎻愪氦浜嬪姟 + _unitOfWorkManage.CommitTran(); + return content.OK(data: task); + } + catch (Exception ex) + { + // 鍥炴粴浜嬪姟 + _unitOfWorkManage.RollbackTran(); + // 杩欓噷鍙互娣诲姞鏃ュ織璁板綍 + return new WebResponseContent().Error($"鏇存柊浠诲姟鏃跺彂鐢熼敊璇�: {ex.Message}"); + } + } + + private void MapTaskProperties(Dt_Task task, RequestTaskDto input, string toAddress, int taskState) + { task.CurrentAddress = input.Position; task.TargetAddress = toAddress; task.NextAddress = toAddress; task.TaskState = taskState; + } - // 寮�濮嬩簨鍔� - _unitOfWorkManage.BeginTran(); - // 瀹氫箟鍙橀噺 - bool isUpdateLo = true; - bool isUpdateChange = true; - - // 灏濊瘯鏇存柊浠诲姟 + // 淇敼浠诲姟 + private async Task<bool> UpdateTaskAsync(Dt_Task task, DtLocationInfo location, int beforeStatus) + { bool isResult = await BaseDal.UpdateDataAsync(task); - bool isTaskDetail = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(task.PalletCode, original, input.Position, TaskInStatusEnum.Line_InFinish.GetIntegralRuleTypeEnumDesc())); + bool isTaskDetail = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(task.PalletCode, task.CurrentAddress, task.TargetAddress, TaskInStatusEnum.Line_InFinish.GetIntegralRuleTypeEnumDesc())); - // 鍒涘缓LocationChangeRecordDto瀵硅薄 LocationChangeRecordDto changeRecordDto = new LocationChangeRecordDto() { - // 璁剧疆鍙橀噺 AfterStatus = location.LocationStatus, BeforeStatus = beforeStatus, TaskNum = task.TaskNum.Value, @@ -1223,23 +1340,11 @@ LocationCode = location.LocationCode, ChangeType = (int)StatusChangeTypeEnum.AutomaticStorage, }; - // 鏇存柊浣嶇疆鐘舵�� - isUpdateChange = _locationStatusChangeRecordRepository.AddStatusChangeRecord(changeRecordDto); - isUpdateLo = await _locationRepository.UpdateDataAsync(location); - if (isResult && isUpdateLo && isTaskDetail) - { - // 鎻愪氦浜嬪姟 - _unitOfWorkManage.CommitTran(); - content.OK(data: task); - } - else - { - // 鍥炴粴浜嬪姟 - _unitOfWorkManage.RollbackTran(); - content.Error("鏇存柊浠诲姟澶辫触"); - } - return content; + bool isUpdateChange = _locationStatusChangeRecordRepository.AddStatusChangeRecord(changeRecordDto); + bool isUpdateLo = await _locationRepository.UpdateDataAsync(location); + + return isResult && isUpdateLo && isTaskDetail; } /// <summary> -- Gitblit v1.9.3