1
dengjunjie
2025-09-29 d9c99e0480b4910cdb134778dd5c314b35ec4cf2
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_AGV.cs
@@ -127,7 +127,7 @@
                var qty = saveModel.MainData["qty"].ToString();
                if (string.IsNullOrEmpty(qty)) throw new Exception("袋数不可为空");
                var batchNo = saveModel.MainData["batchNo"].ToString();
                if (string.IsNullOrEmpty(batchNo)) throw new Exception("柜号不可为空");
                if (string.IsNullOrEmpty(batchNo)) throw new Exception("批号不可为空");
                #region æŸ¥è¯¢åº“存、入库单
                Dt_InventoryInfo inventoryInfo = _inventoryInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
@@ -137,8 +137,27 @@
                if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < qty.ObjToInt()) throw new Exception($"批号【{batchNo}】可组盘数量不足");
                Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.Id == inboundOrderDetail.OrderId);
                if (inboundOrder == null) throw new Exception($"未找到批号为【{batchNo}】的入库单");
                Dt_Inventory_Batch inventory_Batch = _inventoryBatchRepository.QueryFirst(x => x.BatchNo == batchNo);
                if (inventory_Batch == null) throw new Exception($"未找到批号为【{batchNo}】的批次信息");
                var materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterielCode);
                if (materielInfo == null) throw new Exception($"未找到物料信息,物料编码【{inboundOrderDetail.MaterielCode}】");
                //Dt_Inventory_Batch inventory_Batch = _inventoryBatchRepository.QueryFirst(x => x.BatchNo == batchNo);
                //if (inventory_Batch == null && inboundOrder.OrderType == InOrderTypeEnum.Quality.ObjToInt())
                //    throw new Exception($"未找到批号为【{batchNo}】的批次信息");
                //bool add = inventory_Batch == null;
                //if (add)
                //{
                var productionDate = DateTime.Now.ToString("yyyy-MM-dd");
                var validityPeriod = DateTime.Now.AddDays(materielInfo.Validity).ToString("yyyy-MM-dd");//加天
                //    inventory_Batch = new Dt_Inventory_Batch()
                //    {
                //        BatchNo = inboundOrderDetail.BatchNo,
                //        MaterielCode = inboundOrderDetail.MaterielCode,
                //        MaterielName = inboundOrderDetail.MaterielName,
                //        ProductionDate = productionDate,
                //        ShelfLife = materielInfo.Validity,
                //        ValidityPeriod = validityPeriod,
                //        Creater = "System"
                //    };
                //}
                #endregion
                #region åˆ›å»ºä»»åŠ¡
@@ -163,15 +182,15 @@
                #region æ·»åŠ åº“å­˜ä¿¡æ¯ã€å¤„ç†å…¥åº“å•
                inventoryInfo = new Dt_InventoryInfo()
                {
                    BatchNo = inventory_Batch.BatchNo,
                    MaterielCode = inventory_Batch.MaterielCode,
                    MaterielName = inventory_Batch.MaterielName,
                    BatchNo = inboundOrderDetail.BatchNo,
                    MaterielCode = inboundOrderDetail.MaterielCode,
                    MaterielName = inboundOrderDetail.MaterielName,
                    PalletCode = palletCode,
                    ProductionDate = inventory_Batch.ProductionDate,
                    ProductionDate = productionDate,
                    StockStatus = StockStatusEmun.组盘暂存.ObjToInt(),
                    ProductStatus = dt_Task.TaskType == TaskTypeEnum.InQuality.ObjToInt() ? ProductStatusEmun.待检2.ObjToInt() : ProductStatusEmun.待检1.ObjToInt(),
                    ShelfLife = inventory_Batch.ShelfLife,
                    ValidityPeriod = inventory_Batch.ValidityPeriod,
                    ShelfLife = materielInfo.Validity,
                    ValidityPeriod = validityPeriod,
                    StockQuantity = qty.ObjToInt(),
                    BoxQuantity = (qty.ObjToInt() % 8 > 0) ? (qty.ObjToInt() / 8) + 1 : qty.ObjToInt() / 8,
                    Creater = "System"
@@ -179,14 +198,22 @@
                inboundOrder.OrderStatus = InboundStatusEnum.入库中.ObjToInt();
                inboundOrderDetail.ReceiptQuantity += inventoryInfo.StockQuantity;
                inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
                inventory_Batch.ProductStatus = inventoryInfo.ProductStatus;
                //inventory_Batch.ProductStatus = inventoryInfo.ProductStatus;
                #endregion
                Db.Ado.BeginTran();
                _inboundService.InbounOrderService.UpdateData(inboundOrder);
                _inboundService.InboundOrderDetailService.UpdateData(inboundOrderDetail);
                _inventoryInfoRepository.AddData(inventoryInfo);
                _inventoryBatchRepository.UpdateData(inventory_Batch);
                //if (add)
                //{
                //    inventory_Batch.BoxQuantity = inventoryInfo.BoxQuantity;
                //    inventory_Batch.OutboundQuantity = inventoryInfo.OutboundQuantity;
                //    inventory_Batch.StockQuantity = inventoryInfo.StockQuantity;
                //    _inventoryBatchRepository.AddData(inventory_Batch);
                //}
                //else
                //    _inventoryBatchRepository.UpdateData(inventory_Batch);
                AddData(dt_Task);
                List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(new List<Dt_Task> { dt_Task });
                var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>());