heshaofeng
16 小时以前 673b5a596f611099eaacc310f6e7def0e022daca
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -100,6 +100,7 @@
        public readonly IRepository<Dt_LocationType> _locationTypeRepository;
        public readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
        private readonly IRepository<Dt_OutStockLockInfo> _outboundLockInfoRepository;
        private readonly IRepository<Dt_PlasticContainerLedger> _plasticContainerLedger;
        public IRepository<Dt_Task> Repository => BaseDal;
        private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new()
@@ -119,7 +120,7 @@
        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, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, IRepository<Dt_AllocateMaterialInfo_Hty> allocateMaterialInfo_Hty, HttpClientHelper httpClientHelper, IBasicService basicService,IRepository<Dt_TakeStockOrder> takeStockOrder, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository) : 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, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, IRepository<Dt_AllocateMaterialInfo_Hty> allocateMaterialInfo_Hty, HttpClientHelper httpClientHelper, IBasicService basicService,IRepository<Dt_TakeStockOrder> takeStockOrder, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_PlasticContainerLedger> plasticContainerLedger) : base(BaseDal)
        {
            _mapper = mapper;
            _unitOfWorkManage = unitOfWorkManage;
@@ -151,6 +152,7 @@
            _locationTypeRepository = locationTypeRepository;
            _warehouseAreaRepository = warehouseAreaRepository;
            _outboundLockInfoRepository = outboundLockInfoRepository;
            _plasticContainerLedger = plasticContainerLedger;
        }
        public async Task TaskStatusChange(string taskNum, TaskStatusEnum taskStatusEnum)
@@ -192,6 +194,54 @@
                }
                _logger.LogInformation($"TaskService TaskCompleted: {JsonConvert.SerializeObject(task)} , {task.TaskType} ");
                var taskType = (TaskTypeEnum)task.TaskType;
                bool isInboundTask = taskType is
                    TaskTypeEnum.Inbound
                    or TaskTypeEnum.InEmpty
                    or TaskTypeEnum.InInventory
                    or TaskTypeEnum.InPick
                    or TaskTypeEnum.InQuality
                    or TaskTypeEnum.ProductionReturn
                    or TaskTypeEnum.MesMatReturn
                    or TaskTypeEnum.InAllocate
                    or TaskTypeEnum.AllocateInWarehouse;
                if (isInboundTask && !string.IsNullOrEmpty(task.PalletCode))
                {
                    string palletCode = task.PalletCode;
                    // 1. å¼‚步查询托盘对应的借出台账(正确写法)
                    var ledger = await _plasticContainerLedger.Db.Queryable<Dt_PlasticContainerLedger>()
                        .FirstAsync(x => x.PalletCode == palletCode);
                    if (ledger != null)
                    {
                        // 2. åˆ é™¤å°è´¦ï¼ˆå·²å½’还)
                        await _plasticContainerLedger.DeleteDataAsync(ledger);
                        // 3. æŸ¥è¯¢åº“å­˜
                        var stock = await _stockService.StockInfoService.Repository
                            .QueryFirstAsync(x => x.PalletCode == palletCode);
                        if (stock != null)
                        {
                            // 4. æ‹¼æŽ¥å¤‡æ³¨
                            string borrowTime = ledger.CreateDate.ToString("yyyy-MM-dd HH:mm:ss");
                            string returnTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            string remark = $"{borrowTime} å€Ÿå‡ºï¼Œ{returnTime} è¿˜å›ž";
                            stock.Remark = string.IsNullOrEmpty(stock.Remark)
                                ? remark
                                : $"{stock.Remark};{remark}";
                            stock.SupplyCode = ledger.SupplyCode;
                            stock.BorrowTime = ledger.CreateDate;
                            await _stockService.StockInfoService.Repository.UpdateDataAsync(stock);
                        }
                    }
                }
                MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted");
                if (methodInfo != null)
                {