1
hutongqing
2024-12-29 89051aef8a2c1a85d457914cf6317fe70e0e321c
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -35,6 +35,7 @@
using WIDESEA_DTO.Stock;
using WIDESEA_DTO.Task;
using WIDESEA_External.ERPService;
using WIDESEA_External.Model;
using WIDESEA_IBasicRepository;
using WIDESEA_IBasicService;
using WIDESEA_IInboundRepository;
@@ -132,11 +133,6 @@
                    return WebResponseContent.Instance.Error($"未找到该任务信息");
                }
                //if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt())
                //{
                //    return WebResponseContent.Instance.Error($"任务类型错误");
                //}
                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId==task.WarehouseId).Includes(x => x.Details).First();
                if (stockInfo == null)
                {
@@ -167,6 +163,61 @@
                LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseId== task.WarehouseId);
                stockInfo.LocationCode = locationInfo.LocationCode;
                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())
                {
                    //推送入库完成给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);
                        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 += 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))
                    {
                        inboundOrder.OrderStatus = InOrderStatusEnum.入库完成.ObjToInt();
                    }
                    if (!_inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder, detailModels).Status)
                    {
                        return WebResponseContent.Instance.Error($"入库同步Erp失败");
                    }
                }
                //测试架入库库存状态
                if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() && warehouse.WarehouseCode==WarehouseEnum.HA64.ToString())
                {
@@ -181,17 +232,6 @@
                {
                    x.Status = StockStatusEmun.入库完成.ObjToInt();
                });
                stockInfo.LocationCode = locationInfo.LocationCode;
                //推送入库完成给Erp
                Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x=>x.Details).First();
                if (inboundOrder == null)
                {
                    return WebResponseContent.Instance.Error($"对应入库单不存在");
                }
                if (!_inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder).Status)
                {
                    return WebResponseContent.Instance.Error($"入库同步Erp失败");
                }
                _unitOfWorkManage.BeginTran();
                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.人工完成 : OperateTypeEnum.自动完成);
                _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
@@ -199,6 +239,8 @@
                _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details);
                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundCompleted);
                _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum);
                _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails);
                _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
                _unitOfWorkManage.CommitTran();
                return WebResponseContent.Instance.OK();
            }
@@ -271,7 +313,7 @@
                {
                    _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails);
                }
                stockInfo.LocationCode = locationInfo.LocationCode;
                stockInfo.LocationCode = "";
                stockInfo.StockStatus = StockStatusEmun.出库完成.ObjToInt();
                _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                int beforeStatus = locationInfo.LocationStatus;