From a7ceaaa38a4394b82501ca60230e97d25a6871e3 Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期六, 18 一月 2025 17:30:33 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 123 ++++++++++++++++++++-------------------- 1 files changed, 62 insertions(+), 61 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 cc787f0..1edf744 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" @@ -112,12 +112,12 @@ { x.AGVArea = agvDescription; }); - string address = AppSettings.Get("WCSApiAddress"); - if (string.IsNullOrEmpty(address)) + string url = AppSettings.Get("WCS"); + if (string.IsNullOrEmpty(url)) { - return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃"); + return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃,璇锋鏌ラ厤缃枃浠�"); } - string response = HttpHelper.Post($"{address}/api/Task/ReceiveTask", taskDTOs.Serialize()); + string response = HttpHelper.Post($"{url}/api/Task/ReceiveTask", taskDTOs.Serialize()); return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒"); } @@ -135,12 +135,12 @@ { try { - string address = AppSettings.Get("WCSApiAddress"); - if (string.IsNullOrEmpty(address)) + string url = AppSettings.Get("WCS"); + if (string.IsNullOrEmpty(url)) { - return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃"); + return WebResponseContent.Instance.Error($"鏈壘鍒癢CSAApi鍦板潃,璇锋鏌ラ厤缃枃浠�"); } - string response = HttpHelper.Post($"{address}/api/CTU_AGV/PutFinish", code); + string response = HttpHelper.Post($"{url}/api/CTU_AGV/PutFinish?code=" + code); return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒"); } @@ -198,15 +198,20 @@ stockInfo.LocationCode = locationInfo.LocationCode; - #region 绌虹鍏ュ簱 - if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt()) + #region 绌虹鍏ュ簱/鎷i�夊洖搴�/鐢熶骇閫�鏂� + if (task.TaskType == TaskTypeEnum.InEmpty.ObjToInt() || task.TaskType == TaskTypeEnum.InPick.ObjToInt() || task.TaskType==TaskTypeEnum.ProductionReturn.ObjToInt()) { stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); + stockInfo.Details.ForEach(x => + { + x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); + }); _unitOfWorkManage.BeginTran(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚); _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); _stockRepository.StockInfoRepository.UpdateData(stockInfo); + _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted); _unitOfWorkManage.CommitTran(); return WebResponseContent.Instance.OK(); @@ -214,67 +219,61 @@ #endregion Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First(); - List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); - if (stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()) + Dt_InboundOrderDetail? inboundOrderDetail = null; + //鏍囧噯鍏ュ簱娴佺▼鏌ユ壘鍏ュ簱鍗曟嵁 + if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()) { - //鎺ㄩ�佸叆搴撳畬鎴愮粰Erp - if (inboundOrder == null) + //鏌ヨ鍘熷畬鎴愮殑鍏ュ簱鏄庣粏鏁伴噺 + int overCount = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; + if (stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()) { - return WebResponseContent.Instance.Error($"瀵瑰簲鍏ュ簱鍗曚笉瀛樺湪"); - } - - List<ERPInboundDetailModel> detailModels = new List<ERPInboundDetailModel>(); - - foreach (var item in stockInfo.Details) - { - Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == item.InboundOrderRowNo); - if (inboundOrderDetail == null) + inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == stockInfo.Details.FirstOrDefault()?.InboundOrderRowNo); + foreach (var item in stockInfo.Details) { - continue; + if (inboundOrderDetail == null) + { + continue; + } + ERPInboundDetailModel detailModel = new ERPInboundDetailModel() + { + ExpiryDate = item.EffectiveDate ?? "", + LocationCode = warehouse.WarehouseCode, + MaterialsCode = item.MaterielCode, + MfgDate = item.ProductionDate ?? "", + QtyCustoms = "0", + Quantity = item.StockQuantity.ToString(), + Rack = stockInfo.LocationCode, + ReceiptCode = inboundOrder.UpperOrderNo, + ReceiptSerNo = item.InboundOrderRowNo.ToString() + }; + inboundOrderDetail.OverInQuantity += item.StockQuantity; + if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) + { + inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); + overCount += 1; + } + else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) + { + inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt(); + } } - ERPInboundDetailModel detailModel = new ERPInboundDetailModel() - { - ExpiryDate = item.EffectiveDate ?? "", - LocationCode = warehouse.WarehouseCode, - MaterialsCode = item.MaterielCode, - MfgDate = item.ProductionDate ?? "", - QtyCustoms = "0", - Quantity = item.StockQuantity.ToString(), - Rack = stockInfo.LocationCode, - ReceiptCode = inboundOrder.UpperOrderNo, - ReceiptSerNo = item.InboundOrderRowNo.ToString() - }; - inboundOrderDetail.OverInQuantity += detailModel.Quantity.ObjToInt(); - if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) - { - inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); - } - inboundOrderDetails.Add(inboundOrderDetail); - detailModels.Add(detailModel); } - - //鍏ュ簱鏄庣粏鏂板瀹屾垚鏁伴噺 - int newCount = inboundOrderDetails.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; - //鍏ュ簱鏄庣粏鍘熷畬鎴愭暟閲� - int oldCount = inboundOrder.Details.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; - if (inboundOrder.Details.Count == (newCount + oldCount)) + if (inboundOrder.Details.Count == overCount) { inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt(); } - if (!_inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder, detailModels).Status)//todo 淇敼澶勭悊 + if (inboundOrder.OrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt()) { - return WebResponseContent.Instance.Error($"鍏ュ簱鍚屾Erp澶辫触"); + inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt(); } } - if ((stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt() || stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()) && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString()) { foreach (var model in stockInfo.Details) { - TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, /*MaterialName = model.MaterielName,*/ Life = int.TryParse(model.Remark, out int val) ? val : 1000 }); + TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, MaterialName = model.MaterielName, Life = int.TryParse(model.Remark, out int val) ? val : 1000 }); } } - //娴嬭瘯鏋跺叆搴撳簱瀛樼姸鎬� if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()) { @@ -283,14 +282,13 @@ else { stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); - } stockInfo.Details.ForEach(x => { x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); }); //鏇存柊浠诲姟鐘舵�� - task.TaskStatus = (int)TaskStatusEnum.Finish; + task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); _unitOfWorkManage.BeginTran(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚); _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); @@ -300,10 +298,13 @@ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum); if (inboundOrder != null) { - _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails); _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); + _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail); } _unitOfWorkManage.CommitTran(); + //瀛樺湪鍏ュ簱鍗曞苟鐘舵�佷负瀹屾垚鐘舵�佹帹閫佽嚦ERP + if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()) + _inboundOrderService.FeedbackInboundOrder(inboundOrder); return WebResponseContent.Instance.OK(); } catch (Exception ex) @@ -354,7 +355,7 @@ { if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) { - Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.Id == item.OrderDetailId); + Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.TaskNo == item.OrderNo); if (mesOutboundOrder != null) { mesOutboundOrder.OverOutQuantity = item.AssignQuantity; @@ -370,7 +371,7 @@ Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == item.OrderDetailId); if (outboundOrderDetail != null) { - outboundOrderDetail.OverOutQuantity = item.AssignQuantity; + outboundOrderDetail.OverOutQuantity += item.AssignQuantity; if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity) { outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); @@ -385,7 +386,7 @@ task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); _unitOfWorkManage.BeginTran(); - if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) + if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandPickOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandOutbound.ObjToInt()) { if (outboundOrderDetails.Count > 0) { @@ -424,7 +425,7 @@ } if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) { - MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, mesOutboundOrders.FirstOrDefault().OrderQuantity); + MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, stockInfo.Details.Where(x => x.MaterielCode == mesOutboundOrders.FirstOrDefault().MaterialCode).Sum(x => x.StockQuantity)); UploadMesMaterialLotaAcept(model); } return WebResponseContent.Instance.OK(); -- Gitblit v1.9.3