| | |
| | | private readonly ICabinOrderDetailServices _cabinOrderDetailServices; |
| | | private readonly ISupplyTaskService _supplyTaskService; |
| | | private readonly ISupplyTaskHtyService _supplyTaskHtyService; |
| | | 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) : base(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) |
| | | { |
| | | _basicService = basicService; |
| | | _medicineGoodsServices = medicineGoodsServices; |
| | |
| | | _cabinOrderDetailServices = cabinOrderDetailServices; |
| | | _supplyTaskService = supplyTaskService; |
| | | _supplyTaskHtyService = supplyTaskHtyService; |
| | | _messageInfoService = messageInfoService; |
| | | } |
| | | |
| | | |
| | |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.InPick.ObjToInt(), |
| | | TaskType = cabinOrder.Order_type == "1" ? TaskTypeEnum.In.ObjToInt() : TaskTypeEnum.OutReturn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = location.LocationCode, |
| | |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | string WareCodeMJ = WarehouseEnum.麻精åº.ObjToInt().ToString("000"); |
| | | string WareCodeLD = WarehouseEnum.å·å»åº.ObjToInt().ToString("000"); |
| | | List<Dt_CabinOrder> dt_CabinOrders = new List<Dt_CabinOrder>(); |
| | | #region ç¹æ®è¯åå
¥ç¹æ®åºæ¿ |
| | | if (order.warehouse_no == WarehouseEnum.麻精åº.ObjToInt().ToString("000") || order.warehouse_no == WarehouseEnum.å·å»åº.ObjToInt().ToString("000")) |
| | | if (order.warehouse_no == WareCodeMJ || order.warehouse_no == WareCodeLD) |
| | | { |
| | | var entityOrder = new Dt_CabinOrder |
| | | { |
| | |
| | | return webResponseContent; |
| | | } |
| | | #endregion |
| | | |
| | | #region å建ççå
¥åºå |
| | | public WebResponseContent CreateCheckInOrder(UpstreamOrderInfo order) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string WareCodeMJ = WarehouseEnum.麻精åº.ObjToInt().ToString("000"); |
| | | string WareCodeLD = WarehouseEnum.å·å»åº.ObjToInt().ToString("000"); |
| | | #region ç¹æ®åºæ¿ |
| | | if (order.warehouse_no == WareCodeMJ || order.warehouse_no == WareCodeLD) |
| | | { |
| | | #region åºåãåºåæ¹æ¬¡å¹³è´¦ |
| | | foreach (var item in order.details) |
| | | { |
| | | //æ¾åºåæ¹æ¬¡ä¿¡æ¯ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num); |
| | | var Qty = Math.Abs(inventory_Batch.StockQuantity - inventory_Batch.SupplyQuantity); |
| | | 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); |
| | | foreach (var inventoryInfo in inventoryInfos) |
| | | { |
| | | #region æ·»å ççå
¥åºä»»å¡ |
| | | if (inventoryInfo.StockQuantity != inventoryInfo.SupplyQuantity) |
| | | { |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.InFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckIn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = order.order_no, |
| | | StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity), |
| | | SupplyQuantity = 0, |
| | | Remark = "ççå
¥åº" |
| | | }; |
| | | _supplyTaskHtyService.AddData(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity; |
| | | inventory_Batch.SupplyQuantity = 0; |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | |
| | | #region å建çç¹å |
| | | var entityOrder = new Dt_CabinOrder |
| | | { |
| | | Order_no = order.order_no, |
| | | Order_type = order.order_type, |
| | | Supplier_no = order.supplier_no, |
| | | Account_tiem = order.account_time, |
| | | OdrderStatus = "已宿", |
| | | Supplier_name = order.supplier_name, |
| | | Warehouse_no = order.warehouse_no, |
| | | Details = order.details.Select(d => new Dt_CabinOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = Math.Abs(d.order_qty), |
| | | Order_Inqty = Math.Abs(d.order_qty), |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = order.warehouse_no, |
| | | OrderDetailStatus = "已宿", |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | //Repository.AddData(entityOrder); |
| | | #endregion |
| | | } |
| | | #endregion |
| | | else |
| | | { |
| | | string WareCodeLK = WarehouseEnum.ç«åº.ObjToInt().ToString("000"); |
| | | string WareCodeDJ = WarehouseEnum.大件åº.ObjToInt().ToString("000"); |
| | | |
| | | foreach (var item in order.details) |
| | | { |
| | | //æ¾åºåæ¹æ¬¡ä¿¡æ¯ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num); |
| | | var Qty = Math.Abs(inventory_Batch.StockQuantity - inventory_Batch.SupplyQuantity); |
| | | 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); |
| | | //è·å大件åºçç¹å·®å¼æ° |
| | | var inventoryDJ = inventoryInfos.Where(x => x.WarehouseCode == WareCodeDJ).ToList(); |
| | | var DJQty = Math.Abs(inventoryDJ.Sum(x => x.StockQuantity) - inventoryDJ.Sum(x => x.SupplyQuantity)); |
| | | if (LkQty + DJQty != Qty) throw new Exception($"ã{order.order_no}ãç©æç¼å·ã{item.goods_no}ãç©ææ¹æ¬¡ã{item.batch_num}ãçç©æä¿¡æ¯ä¸ç©ææ¹æ¬¡ä¿¡æ¯ççæ°éä¸ç¬¦"); |
| | | if (LkQty == 0)//ç«åºæ å·®å¼ |
| | | { |
| | | #region åºåãåºåæ¹æ¬¡å¹³è´¦ |
| | | foreach (var inventoryInfo in inventoryInfos) |
| | | { |
| | | #region æ·»å ççå
¥åºä»»å¡ |
| | | if (inventoryInfo.StockQuantity != inventoryInfo.SupplyQuantity) |
| | | { |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.InFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckIn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = order.order_no, |
| | | StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity), |
| | | SupplyQuantity = 0, |
| | | Remark = "ççå
¥åº" |
| | | }; |
| | | _supplyTaskHtyService.AddData(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | inventory_Batch.StockQuantity = inventory_Batch.SupplyQuantity; |
| | | inventory_Batch.SupplyQuantity = 0; |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | #endregion |
| | | |
| | | #region å建大件åºçç¹å |
| | | var entityOrder = new Dt_CabinOrder |
| | | { |
| | | Order_no = order.order_no, |
| | | Order_type = order.order_type, |
| | | Supplier_no = order.supplier_no, |
| | | Account_tiem = order.account_time, |
| | | OdrderStatus = "已宿", |
| | | Supplier_name = order.supplier_name, |
| | | Warehouse_no = WareCodeDJ, |
| | | Details = order.details.Select(d => new Dt_CabinOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = Math.Abs(d.order_qty), |
| | | Order_Inqty = Math.Abs(d.order_qty), |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = WareCodeDJ, |
| | | OrderDetailStatus = "已宿", |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | //Repository.AddData(entityOrder); |
| | | Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | #region 大件åºåºå平账 |
| | | inventoryInfos = inventoryInfos.Where(x => x.WarehouseCode == WareCodeDJ).ToList(); |
| | | foreach (var inventoryInfo in inventoryInfos) |
| | | { |
| | | #region æ·»å ççå
¥åºä»»å¡ |
| | | if (inventoryInfo.StockQuantity != inventoryInfo.SupplyQuantity) |
| | | { |
| | | Dt_SupplyTask_Hty supplyTask_Hty = new Dt_SupplyTask_Hty() |
| | | { |
| | | WarehouseCode = inventoryInfo.WarehouseCode, |
| | | OperateType = OperateTypeEnum.èªå¨å®æ.ToString(), |
| | | InsertTime = DateTime.Now, |
| | | TaskStatus = SupplyStatusEnum.InFinish.ObjToInt(), |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.ChenckIn.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventoryInfo.LocationCode, |
| | | OrderNo = order.order_no, |
| | | StockQuantity = Math.Abs(inventoryInfo.StockQuantity - inventoryInfo.SupplyQuantity), |
| | | SupplyQuantity = 0, |
| | | Remark = "ççå
¥åº" |
| | | }; |
| | | _supplyTaskHtyService.AddData(supplyTask_Hty); |
| | | } |
| | | #endregion |
| | | inventoryInfo.StockQuantity = inventoryInfo.SupplyQuantity; |
| | | inventoryInfo.SupplyQuantity = 0; |
| | | inventoryInfo.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | #endregion |
| | | |
| | | #region å建大件åºçç¹å |
| | | if (DJQty != 0) |
| | | { |
| | | var cabinOrder = new Dt_CabinOrder |
| | | { |
| | | Order_no = order.order_no, |
| | | Order_type = order.order_type, |
| | | Supplier_no = order.supplier_no, |
| | | Account_tiem = order.account_time, |
| | | OdrderStatus = "已宿", |
| | | Supplier_name = order.supplier_name, |
| | | Warehouse_no = WareCodeDJ, |
| | | Details = order.details.Select(d => new Dt_CabinOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = DJQty, |
| | | Order_Inqty = DJQty, |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = WareCodeDJ, |
| | | OrderDetailStatus = "已宿", |
| | | Status = 2, |
| | | }).ToList() |
| | | }; |
| | | //Repository.AddData(cabinOrder); |
| | | Db.InsertNav(cabinOrder).Include(it => it.Details).ExecuteCommand(); |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region å建ç«åºçç¹å |
| | | var entityOrder = new Dt_CabinOrder |
| | | { |
| | | Order_no = order.order_no, |
| | | Order_type = order.order_type, |
| | | Supplier_no = order.supplier_no, |
| | | Account_tiem = order.account_time, |
| | | OdrderStatus = "æ°å»º", |
| | | Supplier_name = order.supplier_name, |
| | | Warehouse_no = WareCodeLK, |
| | | Details = order.details.Select(d => new Dt_CabinOrderDetail |
| | | { |
| | | Goods_no = d.goods_no, |
| | | Order_qty = LkQty, |
| | | Batch_num = d.batch_num, |
| | | Exp_date = d.exp_date, |
| | | Reservoirarea = WareCodeLK, |
| | | OrderDetailStatus = "æ°å»º", |
| | | Status = 0, |
| | | }).ToList() |
| | | }; |
| | | //Repository.AddData(entityOrder); |
| | | Db.InsertNav(entityOrder).Include(it => it.Details).ExecuteCommand(); |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //_messageInfoService.AddMessageInfo(MessageGroupByEnum.InOrderAlarm, "å建ççå
¥åºå", ex.Message); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | } |
| | | } |