From 741cc4cde8bc475366891e795988a11153eae07c Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期五, 10 一月 2025 22:48:39 +0800 Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 128 ++++++++++++++++++++++++++++++++---------- 1 files changed, 98 insertions(+), 30 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 7115035..36030d6 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" @@ -68,6 +68,7 @@ private readonly IInvokeERPService _invokeERPService; private readonly IInboundRepository _inboundRepository; private readonly IInboundOrderService _inboundOrderService; + private readonly IPalletTypeInfoRepository _palletTypeInfoRepository; public ITaskRepository Repository => BaseDal; @@ -81,7 +82,7 @@ public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); - public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService, IInboundRepository inboundRepository, IInboundOrderService inboundOrderService) : base(BaseDal) + public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService, IInboundRepository inboundRepository, IInboundOrderService inboundOrderService, IPalletTypeInfoRepository palletTypeInfoRepository) : base(BaseDal) { _mapper = mapper; _unitOfWorkManage = unitOfWorkManage; @@ -95,6 +96,7 @@ _invokeERPService = invokeERPService; _inboundRepository = inboundRepository; _inboundOrderService = inboundOrderService; + _palletTypeInfoRepository = palletTypeInfoRepository; } /// <summary> @@ -110,7 +112,12 @@ { x.AGVArea = agvDescription; }); - string response = HttpHelper.Post("http://127.0.0.1:9281/api/Task/ReceiveTask", taskDTOs.Serialize()); + string address = AppSettings.Get("WCSApiAddress"); + if (string.IsNullOrEmpty(address)) + { + return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃"); + } + string response = HttpHelper.Post($"{address}/api/Task/ReceiveTask", taskDTOs.Serialize()); return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒"); } @@ -128,7 +135,12 @@ { try { - string response = HttpHelper.Post("http://127.0.0.1:9281/api/CTU_AGV/PutFinish", code); + string address = AppSettings.Get("WCSApiAddress"); + if (string.IsNullOrEmpty(address)) + { + return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃"); + } + string response = HttpHelper.Post($"{address}/api/CTU_AGV/PutFinish?code=" + code); return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒"); } @@ -164,7 +176,7 @@ return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅"); } - if (stockInfo.Details.Count == 0) + if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt()) { return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅"); } @@ -185,18 +197,31 @@ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId); stockInfo.LocationCode = locationInfo.LocationCode; + + #region 绌虹鍏ュ簱 + if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt()) + { + stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); + 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); + _stockRepository.StockInfoRepository.UpdateData(stockInfo); + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted); + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + #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>(); + List<ERPInboundDetailModel> detailModels = new List<ERPInboundDetailModel>(); if (stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()) { - //鎺ㄩ�佸叆搴撳畬鎴愮粰Erp if (inboundOrder == null) { 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); @@ -233,17 +258,14 @@ { inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt(); } - if (!_inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder, detailModels).Status)//todo 淇敼澶勭悊 - { - return WebResponseContent.Instance.Error($"鍏ュ簱鍚屾Erp澶辫触"); - } + } 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, 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 }); } } @@ -265,7 +287,7 @@ task.TaskStatus = (int)TaskStatusEnum.Finish; _unitOfWorkManage.BeginTran(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚); - _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); + _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); @@ -276,6 +298,10 @@ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); } _unitOfWorkManage.CommitTran(); + if (stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()) + { + _inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder, detailModels); + } return WebResponseContent.Instance.OK(); } catch (Exception ex) @@ -314,8 +340,9 @@ Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId); List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.TaskNum == taskNum); List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); + List<Dt_MesOutboundOrder> mesOutboundOrders = new List<Dt_MesOutboundOrder>(); - if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString()) + if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType != TaskTypeEnum.OutEmpty.ObjToInt()) { return WebResponseContent.Instance.Error($"鏈壘鍒板嚭搴撹鎯呬俊鎭�"); } @@ -323,39 +350,80 @@ { foreach (var item in outStockLockInfos) { - Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == item.OrderDetailId); - if (outboundOrderDetail != null) + if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) { - outboundOrderDetail.OverOutQuantity = item.AssignQuantity; - if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity) + Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.Id == item.OrderDetailId); + if (mesOutboundOrder != null) { - outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); + mesOutboundOrder.OverOutQuantity = item.AssignQuantity; + if (mesOutboundOrder.OverOutQuantity == mesOutboundOrder.OrderQuantity) + { + mesOutboundOrder.OrderStatus = OrderDetailStatusEnum.Over.ObjToInt(); + } + mesOutboundOrders.Add(mesOutboundOrder); } - outboundOrderDetails.Add(outboundOrderDetail); } + else + { + Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == item.OrderDetailId); + if (outboundOrderDetail != null) + { + outboundOrderDetail.OverOutQuantity = item.AssignQuantity; + if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity) + { + outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); + } + outboundOrderDetails.Add(outboundOrderDetail); + } + } + item.Status = OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt(); } } - + task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); _unitOfWorkManage.BeginTran(); - if (outboundOrderDetails.Count > 0) + + if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) { - _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); + if (outboundOrderDetails.Count > 0) + { + _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); + } + + stockInfo.LocationCode = ""; + stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); } - stockInfo.LocationCode = ""; - stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); - _stockService.StockInfoService.Repository.UpdateData(stockInfo); + else if (task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt()) + { + _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); + _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚); + } + else if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) + { + _outboundService.MesOutboundOrderService.Repository.UpdateData(mesOutboundOrders); + _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚); + _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚); + } + _outboundService.OutboundStockLockInfoService.Repository.UpdateData(outStockLockInfos); + int beforeStatus = locationInfo.LocationStatus; locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); - _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); + _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚); _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, (LocationStatusEnum)beforeStatus, LocationStatusEnum.Free, LocationChangeType.OutboundCompleted, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); _unitOfWorkManage.CommitTran(); - if (warehouse.WarehouseCode != WarehouseEnum.HA64.ToString()) + if (warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) { - _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().Id, outStockLockInfos); + _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().OrderId, outStockLockInfos); + } + if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt()) + { + MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, mesOutboundOrders.FirstOrDefault().OrderQuantity); + UploadMesMaterialLotaAcept(model); } return WebResponseContent.Instance.OK(); } -- Gitblit v1.9.3