1
dengjunjie
8 天以前 a770206c91e495b802b3e9371e06834586ad7715
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/CabinOrderServices.cs
@@ -35,7 +35,6 @@
{
    public class CabinOrderServices : ServiceBase<Dt_CabinOrder, IRepository<Dt_CabinOrder>>, ICabinOrderServices
    {
        private readonly IBasicService _basicService;
        private readonly IMedicineGoodsServices _medicineGoodsServices;
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly IInventory_BatchServices _inventory_BatchServices;
@@ -43,12 +42,13 @@
        private readonly ICabinOrderDetailServices _cabinOrderDetailServices;
        private readonly ISupplyTaskService _supplyTaskService;
        private readonly ISupplyTaskHtyService _supplyTaskHtyService;
        private readonly ILocationInfoService _locationInfoService;
        private readonly IMaterielInfoService _materielInfoService;
        private readonly IMessageInfoService _messageInfoService;
        public IRepository<Dt_CabinOrder> Repository => BaseDal;
        public CabinOrderServices(IRepository<Dt_CabinOrder> BaseDal, IBasicService basicService, IMedicineGoodsServices medicineGoodsServices, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, ICabinOrderDetailServices cabinOrderDetailServices, ICabinOrderHtyServices cabinOrderHtyServices, ICabinOrderDetailHtyServices cabinOrderDetailHtyServices, ISupplyTaskService supplyTaskService, ISupplyTaskHtyService supplyTaskHtyService, IMessageInfoService messageInfoService) : base(BaseDal)
        public CabinOrderServices(IRepository<Dt_CabinOrder> BaseDal, IMedicineGoodsServices medicineGoodsServices, IUnitOfWorkManage unitOfWorkManage, IInventory_BatchServices inventory_BatchServices, IInventoryInfoService inventoryInfoService, ICabinOrderDetailServices cabinOrderDetailServices, ICabinOrderHtyServices cabinOrderHtyServices, ICabinOrderDetailHtyServices cabinOrderDetailHtyServices, ISupplyTaskService supplyTaskService, ISupplyTaskHtyService supplyTaskHtyService, IMessageInfoService messageInfoService, IMaterielInfoService materielInfoService, ILocationInfoService locationInfoService) : base(BaseDal)
        {
            _basicService = basicService;
            _medicineGoodsServices = medicineGoodsServices;
            _unitOfWorkManage = unitOfWorkManage;
            _inventory_BatchServices = inventory_BatchServices;
@@ -57,6 +57,8 @@
            _supplyTaskService = supplyTaskService;
            _supplyTaskHtyService = supplyTaskHtyService;
            _messageInfoService = messageInfoService;
            _materielInfoService = materielInfoService;
            _locationInfoService = locationInfoService;
        }
@@ -132,7 +134,7 @@
                Dt_CabinOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Goods_no == materielCode && x.Batch_num == batchNo && x.Status == 2).FirstOrDefault();
                if (cabinOrderDetail == null || cabinOrderDetail.OrderDetailStatus == "已完成")
                    return WebResponseContent.Instance.Error($"入库单明细已完成");
                Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == cabinOrderDetail.Goods_no);
                Dt_MaterielInfo materielInfo = _materielInfoService.Repository.QueryFirst(x => x.MaterielCode == cabinOrderDetail.Goods_no);
                if (materielInfo == null) return WebResponseContent.Instance.Error($"请维护物料编号【{cabinOrderDetail.Goods_no}】的物料信息");
                cabinOrderDetail.Order_Inqty += Inqty;
                if (cabinOrderDetail.Order_Inqty > cabinOrderDetail.Order_qty)
@@ -155,7 +157,7 @@
                #endregion
                #region è´§ä½
                var location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode);
                var location = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode);
                if (location == null) return WebResponseContent.Instance.Error($"请维护货位编号【{LocationCode}】的货位信息");
                if (location.EnableStatus == EnableStatusEnum.Disable.ObjToInt())
                    return WebResponseContent.Instance.Error($"货位编号【{LocationCode}】已禁用,请恢复正常再使用");
@@ -164,7 +166,7 @@
                if (location.LocationStatus == LocationStatusEnum.Free.ObjToInt())
                {
                    location.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                    _basicService.LocationInfoService.UpdateData(location);
                    _locationInfoService.UpdateData(location);
                }
                #endregion
@@ -197,6 +199,21 @@
                        Creater = App.User.UserName,
                        CreateDate = DateTime.Now,
                    };
                    switch (inventoryInfo.WarehouseCode)
                    {
                        case "001":
                            inventoryInfo.Remark = "智能立库";
                            break;
                        case "002":
                            inventoryInfo.Remark = "大件库";
                            break;
                        case "003":
                            inventoryInfo.Remark = "麻精库";
                            break;
                        case "010":
                            inventoryInfo.Remark = "冷冻库";
                            break;
                    }
                    _inventoryInfoService.AddData(inventoryInfo);
                }
                #endregion
@@ -358,11 +375,10 @@
                        // å°†ä¸Šæ¸¸å…¥åº“数量转为正数
                        item.order_qty = Math.Abs(item.order_qty);
                        #region æ ¹æ®ç‰©æ–™ç¼–码查询物料信息
                        Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == item.goods_no);
                        Dt_MaterielInfo materielInfo = _materielInfoService.Repository.QueryFirst(x => x.MaterielCode == item.goods_no);
                        if (materielInfo == null) throw new Exception($"未找到药品编码【{item.goods_no}】的信息");
                        if (!Enum.IsDefined(typeof(MaterielSourceTypeEnum), materielInfo.MaterielSourceType))
                            throw new Exception($"请设置药品编号【{item.goods_no}】的属性分类");
                        if (materielInfo.BoxQty < 1) throw new Exception($"请设置药品编号【{item.goods_no}】的箱规数量");
                        #endregion
                        #region å¤§ä»¶
                        if (materielInfo.MaterielSourceType == MaterielSourceTypeEnum.PurchasePart)//如果物料是大件
@@ -382,6 +398,7 @@
                        #endregion
                        else
                        {
                            if (materielInfo.BoxQty < 1) throw new Exception($"请设置药品编号【{item.goods_no}】的箱规数量");
                            if (materielInfo.MinQty < 1) throw new Exception($"请设置药品编号【{item.goods_no}】的立库最低库存数");
                            Dt_CabinOrderDetail orderDetail = null;
                            var ys = item.order_qty % materielInfo.BoxQty; //不能整除箱规的散件数 
@@ -448,7 +465,7 @@
                            }
                            #endregion
                        }
                        _basicService.MaterielInfoService.Repository.UpdateData(materielInfo);
                        _materielInfoService.UpdateData(materielInfo);
                    }
                    if (entityOrder.Details.Count > 0) dt_CabinOrders.Add(entityOrder);
                    if (entityOrderLK.Details.Count > 0) dt_CabinOrders.Add(entityOrderLK);