yanjinhui
2025-10-27 92e1560e29419d855c9e23b31c11ef261d391e45
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/DeliveryOrderServices.cs
@@ -43,8 +43,9 @@
        private readonly ISupplyTaskService _supplyTaskService;
        private readonly ISupplyTaskHtyService _supplyTaskHtyService;
        private readonly ITacticsService _tacticsService;
        private readonly IMessageInfoService _messageInfoService;
        public IRepository<Dt_DeliveryOrder> Repository => BaseDal;
        public DeliveryOrderServices(IRepository<Dt_DeliveryOrder> BaseDal, IBasicService basicService, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, IDeliveryOrderDetailServices deliveryOrderDetailServices, ISupplyTaskService supplyTaskService, ICabinOrderServices cabinOrderServices, ITacticsService tacticsService, ISupplyTaskHtyService supplyTaskHtyService) : base(BaseDal)
        public DeliveryOrderServices(IRepository<Dt_DeliveryOrder> BaseDal, IBasicService basicService, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, IDeliveryOrderDetailServices deliveryOrderDetailServices, ISupplyTaskService supplyTaskService, ICabinOrderServices cabinOrderServices, ITacticsService tacticsService, ISupplyTaskHtyService supplyTaskHtyService, IMessageInfoService messageInfoService) : base(BaseDal)
        {
            _basicService = basicService;
            _unitOfWorkManage = unitOfWorkManage;
@@ -55,6 +56,7 @@
            _cabinOrderServices = cabinOrderServices;
            _tacticsService = tacticsService;
            _supplyTaskHtyService = supplyTaskHtyService;
            _messageInfoService = messageInfoService;
        }
        #region åˆ›å»ºå‡ºåº“单
        /// <summary>
@@ -555,7 +557,7 @@
                        if (Qty != item.order_qty) throw new Exception($"盘盈入库单【{order.order_no}】物料编号【{item.goods_no}】物料批次【{item.batch_num}】的盘盈数量有误");
                        //找所有库存
                        List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.MaterielCode == inventory_Batch.MaterielCode && x.BatchNo == inventory_Batch.BatchNo);
                        //获取立库盘点差异数
                        //获取立库盘点差异数.。。。。。。。。。。。。
                        var inventoryLK = inventoryInfos.Where(x => x.WarehouseCode == WareCodeLK).First();
                        var LkQty = Math.Abs(inventoryLK.StockQuantity - inventoryLK.SupplyQuantity);
                        //获取大件库盘点差异数
@@ -624,7 +626,8 @@
                                    Status = 2,
                                }).ToList()
                            };
                            Repository.AddData(entityOrder);
                            Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand();
                            //Repository.AddData(entityOrder);
                            #endregion
                        }
                        else
@@ -653,7 +656,7 @@
                                        OrderNo = order.order_no,
                                        StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity),
                                        SupplyQuantity = 0,
                                        Remark = "盘盈入库"
                                        Remark = "盘亏出库"
                                    };
                                    _supplyTaskHtyService.AddData(supplyTask_Hty);
                                }
@@ -689,7 +692,8 @@
                                        Status = 2,
                                    }).ToList()
                                };
                                Repository.AddData(cabinOrder);
                                //Repository.AddData(cabinOrder);
                                Db.InsertNav(cabinOrder).Include(it => it.Details).ExecuteCommand();
                            }
                            #endregion
@@ -714,15 +718,17 @@
                                    Status = 0,
                                }).ToList()
                            };
                            Repository.AddData(entityOrder);
                            Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand();
                            //Repository.AddData(entityOrder);
                            #endregion
                        }
                        return WebResponseContent.Instance.OK("成功");
                    }
                }
            }
            catch (Exception e)
            catch (Exception ex)
            {
                content.Error(e.Message);
                content.Error(ex.Message);
            }
            return content;
        }
@@ -964,5 +970,42 @@
            }
            return content;
        }
        public WebResponseContent FinishOutOrder(int key)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_DeliveryOrder deliveryOrder = BaseDal.QueryFirst(x => x.Id == key);
                List<Dt_DeliveryOrder> deliveryOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == deliveryOrder.Out_no).Includes(x => x.Details).ToList();//找出所有出库单号相同的出库单
                _unitOfWorkManage.BeginTran();
                foreach (var item in deliveryOrders)
                {
                    if (item.Details != null)
                        _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(item.Details, OperateTypeEnum.人工完成);
                    item.Modifier = App.User.UserName;
                    item.ModifyDate = DateTime.Now;
                    item.Details = null;
                }
                BaseDal.DeleteAndMoveIntoHty(deliveryOrders, OperateTypeEnum.人工完成);
                var url = "http://121.37.118.63:80/GYZ2/95fck/outOrderOk";
                var requestDate = new
                {
                    order_no = deliveryOrder.Out_no
                };
                var result = HttpHelper.Post(url, requestDate.ToJsonString());
                var response = JsonConvert.DeserializeObject<UpstreamOrderResponse>(result);
                if (response == null) throw new Exception("上报ERP出库单完成失败!");
                if (response.resultCode != "0") throw new Exception(response.resultMsg);
                _unitOfWorkManage.CommitTran();
                content.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
    }
}