| | |
| | | using System.Reflection.Emit; |
| | | using System.Threading.Tasks; |
| | | using System.Xml.Linq; |
| | | using WIDESEA_Common.AllocateEnum; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_ITaskInfoService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Check; |
| | | using WIDESEA_Model.Models.Outbound; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | |
| | | private readonly IRepository<Dt_StockInfo> _stockRepository; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IInboundOrderService _inboundOrderService; |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | | |
| | | private readonly IRepository<Dt_AllocateOrderDetail> _allocateOrderDetailRepository; |
| | | private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | private readonly IRepository<Dt_ReCheckOrder> _reCheckOrderRepository; |
| | | private readonly IRepository<Dt_OutboundBatch> _OutboundBatchRepository; |
| | | private readonly IOutboundOrderService _outboundOrderService; |
| | | private readonly IOutboundOrderDetailService _outboundOrderDetailService; |
| | |
| | | |
| | | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); |
| | | |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository) : base(BaseDal) |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _outStockLockInfoService = outStockLockInfoService; |
| | | _allocateService = allocateService; |
| | | _OutboundBatchRepository = outboundBatchRepository; |
| | | _reCheckOrderRepository = reCheckOrderRepository; |
| | | _allocateOrderDetailRepository = allocateOrderDetailRepository; |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | ReqCode = Guid.NewGuid().ToString(), |
| | | ReqTime = DateTime.Now.ToString(), |
| | | BusinessType = "3", |
| | | BusinessType = BusinessTypeEnum.å¤é¨ä»åºè°æºä».ObjToInt().ToString(), |
| | | FactoryArea = inboundOrder.FactoryArea, |
| | | OperationType = 1, |
| | | Operator = inboundOrder.Operator, |
| | |
| | | |
| | | }; |
| | | |
| | | var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | .Select(group => new AllocateDtoDetail |
| | | { |
| | | MaterialCode = group.Key.MaterielCode, |
| | |
| | | Qty = row.BarcodeQty, |
| | | BatchNo = row.BatchNo, |
| | | SupplyCode = row.SupplyCode, |
| | | Unit = row.Unit |
| | | Unit = row.BarcodeUnit |
| | | }).ToList() |
| | | }).ToList(); |
| | | allocatefeedmodel.Details = groupedData; |
| | |
| | | } |
| | | else if (inboundOrder.OrderType == InOrderTypeEnum.ReCheck.ObjToInt()) //鿣å
¥åº |
| | | { |
| | | |
| | | //ä¸éè¦åä¼ ãå ä¸ä¸ªä½ç½®ã |
| | | } |
| | | else if (inboundOrder.OrderType == InOrderTypeEnum.InternalAllocat.ObjToInt()) //æºä»è°æºä» |
| | | { |
| | | _logger.LogInformation($"InboundTaskCompleted ååMES : {inboundOrder.InboundOrderNo } ,ordertype: {InOrderTypeEnum.InternalAllocat.ObjToInt()} " ); |
| | | // BusinessTypeEnum.æºä»è°æºä» |
| | | if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | var allocate = _allocateService.Repository.QueryData(x => x.OrderNo == inboundOrder.InboundOrderNo).First(); |
| | | var allocatefeedmodel = new AllocateDto |
| | | { |
| | | ReqCode = Guid.NewGuid().ToString(), |
| | | ReqTime = DateTime.Now.ToString(), |
| | | BusinessType = BusinessTypeEnum.æºä»è°æºä».ObjToInt().ToString(), |
| | | FactoryArea = inboundOrder.FactoryArea, |
| | | OperationType = 1, |
| | | Operator = inboundOrder.Operator, |
| | | OrderNo = inboundOrder.UpperOrderNo, |
| | | fromWarehouse = allocate?.FromWarehouse ?? "", |
| | | toWarehouse = allocate?.ToWarehouse ?? "", |
| | | Details = new List<AllocateDtoDetail>() |
| | | |
| | | }; |
| | | |
| | | var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.lineNo, item.BarcodeUnit, item.WarehouseCode }) |
| | | .Select(group => new AllocateDtoDetail |
| | | { |
| | | MaterialCode = group.Key.MaterielCode, |
| | | LineNo = group.Key.lineNo, |
| | | WarehouseCode = group.Key.WarehouseCode, |
| | | Qty = group.Sum(x => x.BarcodeQty), |
| | | // warehouseCode= "1072", |
| | | Unit = group.Key.BarcodeUnit, |
| | | Barcodes = group.Select(row => new BarcodeInfo |
| | | { |
| | | Barcode = row.Barcode, |
| | | Qty = row.BarcodeQty, |
| | | BatchNo = row.BatchNo, |
| | | SupplyCode = row.SupplyCode, |
| | | Unit = row.BarcodeUnit |
| | | }).ToList() |
| | | }).ToList(); |
| | | allocatefeedmodel.Details = groupedData; |
| | | |
| | | var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | | _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1 }) |
| | | .Where(it => it.Id == inboundOrder.Id).ExecuteCommand(); |
| | | _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 }) |
| | | .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | |
| | | { |
| | | ReqCode = Guid.NewGuid().ToString(), |
| | | ReqTime = DateTime.Now.ToString(), |
| | | BusinessType = "3", |
| | | BusinessType = "2", |
| | | FactoryArea = outboundOrder.FactoryArea, |
| | | OperationType = 1, |
| | | Operator = outboundOrder.Operator, |
| | |
| | | var detailModel = new AllocateDtoDetail |
| | | { |
| | | MaterialCode = detail.MaterielCode, |
| | | LineNo = detail.lineNo, // 注æï¼è¿éå¯è½éè¦è°æ´å段å |
| | | LineNo = detail.lineNo, |
| | | WarehouseCode = detail.WarehouseCode, |
| | | Qty = detail.OverOutQuantity, // 使ç¨è®¢åæç»çå·²åºåºæ°é |
| | | //currentDeliveryQty = detail.OverOutQuantity, |
| | | Qty = detailLocks.Sum(x=>x.BarcodeQty), |
| | | Unit = detail.Unit, |
| | | Barcodes = detailLocks.Select(lockInfo => new BarcodeInfo |
| | | { |
| | | Barcode = lockInfo.CurrentBarcode, |
| | | SupplyCode = lockInfo.SupplyCode, |
| | | BatchNo = lockInfo.BatchNo, |
| | | Unit = lockInfo.Unit, |
| | | Qty = lockInfo.PickedQty // æ¡ç 级å«çæ°éä»ç¨éå®è®°å½ |
| | | Unit = lockInfo.BarcodeUnit, |
| | | Qty = lockInfo.BarcodeQty // æ¡ç 级å«çæ°éä»ç¨éå®è®°å½ |
| | | }).ToList() |
| | | }; |
| | | |
| | | allocatefeedmodel.Details.Add(detailModel); |
| | | } |
| | | |
| | | var result = await _invokeMESService.FeedbackAllocate(allocatefeedmodel); |
| | | if (result != null && result.code == 200) |
| | | { |
| | |
| | | materialCode = detail.MaterielCode, |
| | | lineNo = detail.lineNo, // 注æï¼è¿éå¯è½éè¦è°æ´å段å |
| | | warehouseCode = detail.WarehouseCode, |
| | | qty = detail.OverOutQuantity, // 使ç¨è®¢åæç»çå·²åºåºæ°é |
| | | currentDeliveryQty = detail.OverOutQuantity, |
| | | qty = detail.BarcodeQty, |
| | | currentDeliveryQty = detail.BarcodeQty, |
| | | unit = detail.Unit, |
| | | barcodes = detailLocks.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel |
| | | { |