From eae9077f3978f695f4e3af5301e8a08bdd8bf23c Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期一, 09 十二月 2024 09:24:46 +0800 Subject: [PATCH] 最新程序 --- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 192 ++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 170 insertions(+), 22 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 d6fe226..19379e7 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 @@ -1,11 +1,16 @@ 锘� +using AngleSharp.Io; +using log4net.Core; using Mapster; using Masuit.Tools; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; +using SixLabors.Fonts.Tables.AdvancedTypographic; using WIDESEA_Core.Const; using WIDESEA_DTO.MOM; using WIDESEA_DTO.WMS; using WIDESEA_IServices; using WIDESEA_IStoragIntegrationServices; +using WIDESEA_Model.Models; using WIDESEA_Services; using WIDESEA_StorageBasicRepository; using WIDESEAWCS_BasicInfoRepository; @@ -88,7 +93,7 @@ content = await _agingInOrOutInputService.GetOCVOutputAsync(agingOutputDto); //ValidateResponse(content); var result = JsonConvert.DeserializeObject<BasicResult>(content.Data.ToString()); - if (!result.Success) + if (!result.Success || !agingOutputDto.SerialNos[0].SerialNoResult) { task.Remark = "NG"; } @@ -101,11 +106,14 @@ // 浜嬪姟澶勭悊 await _unitOfWorkManage.UseTranAsync(async () => { + if (task.TaskType != (int)TaskOutboundTypeEnum.OutQuality) + { + await DeleteStockInfoAsync(stock.Id); + await DeleteStockInfoDetailsAsync(stock.StockInfoDetails); + } await UpdateLocationAsync(loc); - await DeleteStockInfoAsync(stock.Id); - await DeleteStockInfoDetailsAsync(stock.StockInfoDetails); - if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW")) //濡傛灉鏄垎瀹规垨楂樻俯鍑哄簱 灏嗕换鍔″垹闄� - await DeleteTaskAsync(task.TaskId); + //if (task.Roadway.Contains("FR") || task.Roadway.Contains("GW") || task.TaskType == (int)TaskOutboundTypeEnum.OutTray) //濡傛灉鏄垎瀹规垨楂樻俯鍑哄簱 灏嗕换鍔″垹闄� + await DeleteTaskAsync(task.TaskId); }); return content.OK("浠诲姟瀹屾垚鎴愬姛", task.Remark); @@ -154,7 +162,7 @@ { SlotNo = x.OrderNo.ToInt32(), SerialNo = x.SerialNumber, - SerialNoResult = true, + SerialNoResult = isNG, ParameterInfo = new List<ParameterInfoOutput> { new ParameterInfoOutput() { Value = outHours.ToString(), @@ -164,7 +172,8 @@ TargetValue = parameterInfo.TargetValue, LowerLomit = parameterInfo.LowerSpecificationsLimit, UpperLimit = parameterInfo.UpperSpecificationsLimit, - DefectCode = defectCode + DefectCode = defectCode, + UOMCode = parameterInfo.UOMCode, } } }).ToList() @@ -397,13 +406,22 @@ throw new Exception("鏈壘鍒板搴斾綅缃俊鎭�"); var area = new Dt_AreaInfo(); - var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress); - if (station.stationPLC == "1017") - area = _areaInfoRepository.QueryFirst(x => x.AreaID == Convert.ToInt32(station.stationNGLocation)); - else + if (task.Roadway.Contains("FR")) + { area = _areaInfoRepository.QueryFirst(x => x.AreaID == loation.AreaId); - if (area == null) - throw new Exception("鏈壘鍒板搴斿尯鍩熶俊鎭�"); + } + else + { + var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress); + if (station.stationPLC == "1017") + area = _areaInfoRepository.QueryFirst(x => x.AreaID == Convert.ToInt32(station.stationNGLocation)); + else + 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() @@ -429,6 +447,7 @@ EquipmentCode = area.Spare2, Software = area.Spare3 }; + var result = _agingInOrOutInputService.GetOCVInputAsync(agingInputDto).Result; var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.Data.ToString()); stock.LinedProcessFeedbackTime = respone.LinedProcessFeedbackTime; @@ -482,11 +501,13 @@ { case (int)TaskInboundTypeEnum.Inbound: case (int)TaskInboundTypeEnum.InTray: + case (int)TaskInboundTypeEnum.InNG: LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍏ュ簱浠诲姟", ""); return await CompleteInboundTaskAsync(task); case (int)TaskOutboundTypeEnum.OutTray: case (int)TaskOutboundTypeEnum.Outbound: + case (int)TaskOutboundTypeEnum.OutNG: LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "鍑哄簱浠诲姟", ""); return await CompleteStackTaskAsync(task, stock); @@ -749,11 +770,32 @@ var stock = await QueryStockInfo(input.PalletCode); if (stock != null) { + Dt_Task taskNew = new Dt_Task + { + Grade = 1, + Roadway = stock.LocationInfo.RoadwayNo, + TargetAddress = stock.LocationInfo.RoadwayNo, + Dispatchertime = DateTime.Now, + MaterialNo = "", + NextAddress = stock.LocationInfo.RoadwayNo, + OrderNo = null, + PalletCode = stock.PalletCode, + SourceAddress = input.Position, + CurrentAddress = input.Position, + TaskState = (int)TaskInStatusEnum.InNew, + TaskType = (int)TaskInboundTypeEnum.InQuality, + TaskNum = BaseDal.GetTaskNo().Result, + Creater = "System", // 淇鎷煎啓閿欒 + CreateDate = DateTime.Now, + TaskId = 0, + }; + + var taskDTO = CreateTaskDTO(task); // TODO璐ㄦ鍥炲簱 } // 鏍规嵁浣嶇疆鏌ヨ鍖哄煙淇℃伅 - var area = await QueryAreaInfoByPosition(input.Position); + var area = await QueryAreaInfoByPosition(input.Position.Replace("-1", "")); if (area == null) { return content.Error("璇ョ偣浣嶄笉鍦ㄥ尯鍩熷垪琛ㄤ腑瀛樺湪"); @@ -767,7 +809,13 @@ var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); if (!result.Success) { - return content.Error(result.MOMMessage); + if (result.SerialNos.Count <= 0) + { + // 绌烘墭鐩樺叆搴撻�昏緫 + return await RequestTrayInTaskAsync(input); + } + else + return content.Error(result.MOMMessage); } // 澶勭悊寮傚父鐢佃姱鎯呭喌 @@ -777,11 +825,6 @@ return await HandleErrorCells(input, area, serialNosError); } - if (result.SerialNos.Count <= 0) - { - // 绌烘墭鐩樺叆搴撻�昏緫 - return await RequestTrayInTaskAsync(input); - } var boxing = CreateBoxingInfo(result, input.PalletCode); if (boxing == null) return content.Error("缁勭洏澶辫触"); @@ -1036,7 +1079,7 @@ SourceAddress = stockInfo.LocationCode, CurrentAddress = stockInfo.LocationCode, TaskState = (int)TaskOutStatusEnum.OutNew, - TaskType = tag == (int)TaskOutboundTypeEnum.Outbound ? (int)TaskOutboundTypeEnum.Outbound : (int)TaskOutboundTypeEnum.OutTray, + TaskType = tag, TaskNum = BaseDal.GetTaskNo().Result, Creater = "System", // 淇鎷煎啓閿欒 CreateDate = DateTime.Now, @@ -1138,6 +1181,84 @@ content.Error(ex.Message); } return content; + } + + #endregion + + #region 鎸囧畾浠诲姟鍑哄簱 + + public async Task<WebResponseContent> CreateAndSendOutboundTask(string locationCode, string palletCode) + { + WebResponseContent content = new WebResponseContent(); + try + { + // 鏌ヨ搴撳瓨淇℃伅 + var stockInfo = await _stockInfoRepository.QueryFirstNavAsync(x => x.LocationCode == locationCode && x.PalletCode == palletCode); + if (stockInfo == null) + { + return content.Error("鏈煡璇㈠埌瀵瑰簲鐨勫簱瀛樹俊鎭�"); + } + + var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode); + if (task != null) + { + return content.Error($"銆恵palletCode}銆戝凡瀛樺湪浠诲姟"); + } + + int taskType = 0; + if (stockInfo.IsFull) + taskType = (int)TaskOutboundTypeEnum.OutQuality; + else + taskType = (int)TaskOutboundTypeEnum.OutTray; + // 鍒涘缓骞舵坊鍔犱换鍔″埌鏁版嵁搴� + task = CreateTask(stockInfo, "1020-1", taskType); + //var taskId = await BaseDal.AddDataAsync(task); + //if (taskId <= 0) + //{ + // return content.Error("浠诲姟鍒涘缓澶辫触"); + //} + + // 鍒涘缓浠诲姟浼犺緭鐢ㄧ殑DTO瀵硅薄 + var taskDTO = CreateTaskDTO(task); + + // 鑾峰彇WMS IP鍦板潃鐢ㄤ簬鍙戦�佷换鍔¤姹� + var wmsIpAddress = GetWCSIpReceiveTask(); + if (wmsIpAddress == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + + var tasks = new List<WMSTaskDTO>() { taskDTO }; + // 鍙戦�佷换鍔¤姹傚埌WMS + var result = await HttpHelper.PostAsync(wmsIpAddress, tasks.ToJsonString()); + content = JsonConvert.DeserializeObject<WebResponseContent>(result); + if (content.Status) + { + // 娣诲姞浠诲姟鍒版暟鎹簱 + await BaseDal.AddDataAsync(task); + // 鏇存柊搴撳瓨浣嶇疆鐘舵�佷负涓嶅彲鐢� + stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; + await _locationRepository.UpdateDataAsync(stockInfo.LocationInfo); + } + } + catch (Exception ex) + { + Console.WriteLine($"鍙戠敓寮傚父: {ex.Message}"); + content.Error(ex.Message); + } + + return content; + } + private string GetWCSIpReceiveTask() + { + var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); + var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue; + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveTask)?.ConfigValue; + if (wmsBase == null || ipAddress == null) + { + return null; + } + return wmsBase + ipAddress; } #endregion @@ -1365,6 +1486,18 @@ } + var stocks = _stockInfoRepository.QueryData(x => x.AreaCode == stock.AreaCode && x.ProductionLine == stock.ProductionLine && x.SpecialParameterDuration != stock.SpecialParameterDuration); + if (stocks != null && stocks.Count > 0) + { + foreach (var item in stocks) + { + item.SpecialParameterDuration = stock.SpecialParameterDuration; + item.ParameterInfos = stock.ParameterInfos; + item.OutboundTime = Convert.ToDateTime(item.LinedProcessFeedbackTime == null ? item.CreateDate : item.LinedProcessFeedbackTime).AddHours(Convert.ToDouble(stock.SpecialParameterDuration)); + } + var isUpdates = await _stockInfoRepository.UpdateDataAsync(stocks); + } + // 娣诲姞鍘嗗彶浠诲姟 var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0; @@ -1419,6 +1552,16 @@ task.CurrentAddress = input.Position; task.TargetAddress = "002-021-000"; task.NextAddress = "002-021-000"; + task.TaskState = (int)TaskInStatusEnum.Line_InFinish; + bool isResult = await BaseDal.UpdateDataAsync(task); + return content.OK(data: task); + } + else if (task.TaskType == (int)TaskInboundTypeEnum.InQuality) + { + var stockInfo = _stockInfoRepository.QueryFirst(x => x.PalletCode == input.PalletCode); + task.CurrentAddress = input.Position; + task.TargetAddress = stockInfo.LocationInfo.LocationCode; + task.NextAddress = stockInfo.LocationInfo.LocationCode; task.TaskState = (int)TaskInStatusEnum.Line_InFinish; bool isResult = await BaseDal.UpdateDataAsync(task); return content.OK(data: task); @@ -1538,6 +1681,11 @@ { task.TaskId = taskId; isResult = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(input.PalletCode, input.Position, ToAddress, TaskInStatusEnum.InNew.GetIntegralRuleTypeEnumDesc())); + + //var location = _locationRepository.QueryFirst(x => x.RoadwayNo == task.Roadway && x.LocationCode == task.TargetAddress); + //location.LocationStatus = (int)LocationEnum.Lock; + //var isLocation = _locationRepository.UpdateData(location); + if (isResult) { // 鍒涘缓WMS浠诲姟 @@ -1612,7 +1760,7 @@ .OrderByDescending(g => g.Count()) // 鏍规嵁姣忎釜缁勭殑鍏冪礌鏁伴噺鎺掑簭 .ToList(); // 鍙栧嚭鏁伴噺鏈�澶氱殑缁� - Dictionary<string,int> result = new Dictionary<string,int>(); + Dictionary<string, int> result = new Dictionary<string, int>(); foreach (var item in minGroup) { var number = BaseDal.QueryData(x => x.TargetAddress == item.Key).Count(); -- Gitblit v1.9.3