yanjinhui
2025-12-01 2b49f7643d15b74889d190f216630559006ed93a
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs
@@ -207,7 +207,7 @@
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            try
            {
             {
                Dt_Tactics tactics = _tacticsService.Repository.QueryFirst(x => x.TacticeName == "出库策略");
                #region ç‰¹æ®Šåº“房出库
                string WareCodeMJ = WarehouseEnum.麻精库.ObjToInt().ToString("000");
@@ -247,6 +247,7 @@
                        Dt_Inventory_Batch? inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num).FirstOrDefault();
                        if (inventory_Batch == null) throw new Exception($"未找到出库单号【{entityOrder.Out_no}】中物料编号【{item.Goods_no}】物料批次【{item.Batch_num}】的库存批次信息");
                        if (inventory_Batch.AvailableQuantity < item.Order_qty) throw new Exception($"出库单号【{entityOrder.Out_no}】中物料编号【{item.Goods_no}】物料批次【{item.Batch_num}】的库存批次信息可用数量不足");
                        if (inventory_Batch.SupplyQuantity > 0) throw new Exception($"出库单号【{entityOrder.Out_no}】中物料编号【{item.Goods_no}】物料批次【{item.Batch_num}】的库存批次信息存在未完成的盘点任务,无法创建出库单");
                        inventory_Batch.AvailableQuantity -= item.Order_qty;
                        inventory_Batch.OutboundQuantity += item.Order_qty;
                        List<Dt_InventoryInfo> dt_InventoryInfos = InventoryInfos.Where(x => x.MaterielCode == item.Goods_no && x.BatchNo == item.Batch_num).ToList();
@@ -280,6 +281,7 @@
                                    OrderNo = entityOrder.Out_no,
                                    StockQuantity = InventoryInfo.AvailableQuantity,
                                    SupplyQuantity = 0,
                                    Modifier= InventoryInfo.ValidityPeriod,//有效期次
                                    Remark = "出库"
                                };
                                supplyTasks.Add(supplyTask);
@@ -324,6 +326,7 @@
                #endregion
                else
                {
                    string WareCodeDJ = WarehouseEnum.大件库.ObjToInt().ToString("000");
                    string WareCodeLK = WarehouseEnum.立库.ObjToInt().ToString("000");
                    #region åˆ›å»ºå¤§ä»¶åº“、立库出库头表
@@ -363,10 +366,11 @@
                        Dt_Inventory_Batch? inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == detail.goods_no && x.BatchNo == detail.batch_num).FirstOrDefault();
                        if (inventory_Batch == null) throw new Exception($"未找到出库单号【{outorder.order_no}】中物料编号【{detail.goods_no}】物料批次【{detail.batch_num}】的库存批次信息");
                        if (inventory_Batch.AvailableQuantity < detail.order_qty) throw new Exception($"出库单号【{outorder.order_no}】中物料编号【{detail.goods_no}】物料批次【{detail.batch_num}】的库存批次信息可用数量不足");
                        if(inventory_Batch.SupplyQuantity>0) throw new Exception($"出库单号【{outorder.order_no}】中物料编号【{detail.goods_no}】物料批次【{detail.batch_num}】的库存批次信息存在未完成的盘点任务,无法创建出库单");
                        inventory_Batch.AvailableQuantity -= detail.order_qty;
                        inventory_Batch.OutboundQuantity += detail.order_qty;
                        List<Dt_InventoryInfo> dt_InventoryInfos = InventoryInfos.Where(x => x.MaterielCode == inventory_Batch.MaterielCode && x.BatchNo == inventory_Batch.BatchNo).ToList();
                        if (dt_InventoryInfos.Count < 1) throw new Exception($"出库单号【{outorder.order_no}】中物料编号【{detail.goods_no}】物料批次【{detail.batch_num}】的可用库存不足");
                        if (dt_InventoryInfos.Count < 1) throw new Exception($"没有找到库存信息中的:出库单号【{outorder.order_no}】的物料编号【{detail.goods_no}】物料批次【{detail.batch_num}】");
                        #endregion
                        #region æŒ‰å‡ºåº“策略查找库存
                        if (tactics.SelectTactice == TacticsEnum.ComeOutonFirstTime.ObjToInt())
@@ -421,6 +425,7 @@
                                        LocationCode = InventoryInfo.LocationCode,
                                        OrderNo = entityOrder.Out_no,
                                        StockQuantity = InventoryInfo.AvailableQuantity,
                                        Modifier=InventoryInfo.ValidityPeriod,//有效期次
                                        SupplyQuantity = 0,
                                        Remark = "出库"
                                    };
@@ -445,6 +450,7 @@
                                        LocationCode = InventoryInfo.LocationCode,
                                        OrderNo = entityOrder.Out_no,
                                        StockQuantity = Order_qty,
                                        Modifier = InventoryInfo.ValidityPeriod,//有效期次
                                        SupplyQuantity = 0,
                                        Remark = "出库"
                                    };
@@ -531,6 +537,7 @@
                                    LocationCode = item.LocationCode,
                                    OrderNo = entityOrder.Out_no,
                                    StockQuantity = outqty,
                                    Modifier= item.ValidityPeriod,//有效期
                                    SupplyQuantity = 0,
                                    Remark = "出库"
                                };
@@ -587,6 +594,7 @@
                                    LocationCode = inventoryInfo.LocationCode,
                                    OrderNo = entityOrder.Out_no,
                                    StockQuantity = orderDetailLK.Order_qty,
                                    Modifier = inventoryInfo.ValidityPeriod,//有效期
                                    SupplyQuantity = 0,
                                    Remark = "出库"
                                };
@@ -991,7 +999,12 @@
                    foreach (var item in order.details)
                    {
                        //找库存批次信息
                        Dt_Inventory_Batch inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num).First();
                        Dt_Inventory_Batch inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num).FirstOrDefault();
                        if (inventory_Batch==null)
                        {
                            _messageInfoService.AddMessageInfo(MessageGroupByEnum.OutOrderAlarm, "ERP报损出库错误", $"盘亏出库单【{order.order_no}】物料编号【{item.goods_no}】物料批次【{item.batch_num}】的库存批次信息有错");
                            throw new Exception($"盘亏出库单【{order.order_no}】物料编号【{item.goods_no}】物料批次【{item.batch_num}】的库存批次信息有错");
                        }
                        var Qty = Math.Abs(inventory_Batch.SupplyQuantity);
                        if (Qty != item.order_qty)
                        {
@@ -1104,7 +1117,12 @@
                    foreach (var item in order.details)
                    {
                        //找库存批次信息
                        Dt_Inventory_Batch inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num).First();
                        Dt_Inventory_Batch inventory_Batch = inventory_Batchs.Where(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num).FirstOrDefault();
                        if (inventory_Batch==null)
                        {
                            _messageInfoService.AddMessageInfo(MessageGroupByEnum.OutOrderAlarm, "ERP报损出库错误", $"盘亏出库单【{order.order_no}】物料编号【{item.goods_no}】物料批次【{item.batch_num}】的库存批次信息有错");
                            throw new Exception($"盘亏出库单【{order.order_no}】物料编号【{item.goods_no}】物料批次【{item.batch_num}】的库存批次信息有错");
                        }
                        var Qty = Math.Abs(inventory_Batch.SupplyQuantity);
                        if (Qty != item.order_qty)
                        {
@@ -1650,8 +1668,8 @@
                }
                else
                {
                    var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk";
                    if (deliveryOrder.Out_type == "3") url = "http://121.37.118.63:80/GYZ2/95fck/inOrderOk";
                    var url = "http://192.168.1.100:80/GYZ2/95fck/outOrderOk";
                    if (deliveryOrder.Out_type == "3") url = "http://192.168.1.100:80/GYZ2/95fck/inOrderOk";
                    var requestDate = new
                    {
                        order_no = deliveryOrder.Out_no