| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | |
| | | public partial class DeliveryOrderServices |
| | | { |
| | | #region å建çç¹åãçç¹ä»»å¡ |
| | | /// <summary> |
| | | /// <summary> å¨åºåæ¹æ¬¡ä¿¡æ¯ä¸è°ç¨è¯¥æ¥å£è¿è¡çç¹ |
| | | /// å建çç¹å |
| | | /// </summary> |
| | | /// <param name="keys"></param> |
| | |
| | | { |
| | | List<Dt_DeliveryOrder> deliveryOrders = new List<Dt_DeliveryOrder>(); |
| | | List<Dt_SupplyTask> supplyTasks = new List<Dt_SupplyTask>(); |
| | | List<Dt_InventoryInfo> _InventoryInfos = new List<Dt_InventoryInfo>(); |
| | | List<Dt_Inventory_Batch> inventory_Batches = _inventory_BatchServices.Repository.QueryData(x => keys.Contains(x.Id)); |
| | | foreach (var item in inventory_Batches) |
| | | { |
| | | supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == item.MaterielCode && x.BatchNo == item.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList(); |
| | | if (supplyTasks.Count > 0) throw new Exception($"ç©æç¼å·ã{item.MaterielCode}ãæ¹æ¬¡å·ã{item.BatchNo}ãå·²åå¨çç¹ä»»å¡ï¼è¯·å
宿å½åçç¹ä»»å¡"); |
| | | List<Dt_InventoryInfo> inventoryInfos = _inventoryInfoService.Repository.QueryData(x => item.MaterielCode == x.MaterielCode && x.BatchNo == item.BatchNo); |
| | | if (inventoryInfos.Count > 0) |
| | | { |
| | |
| | | Dt_DeliveryOrder deliveryOrder = new Dt_DeliveryOrder() |
| | | { |
| | | Out_no = item.MaterielCode + "_" + item.BatchNo, |
| | | Out_type = "3", |
| | | Out_type = "20", |
| | | OutStatus = "æ°å»º", |
| | | Warehouse_no = items.Key, |
| | | Details = new List<Dt_DeliveryOrderDetail>() |
| | |
| | | deliveryOrder.Details.Add(deliveryOrderDetail); |
| | | deliveryOrders.Add(deliveryOrder); |
| | | #region å建çç¹ä»»å¡ |
| | | if (items.Key != "001") |
| | | //if (items.Key != "001")// éç«åºåºåéè¦å建çç¹ä»»å¡ |
| | | //{ |
| | | foreach (var inventory in items) |
| | | { |
| | | foreach (var inventory in items) |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = inventory.WarehouseCode, |
| | | TaskStatus = SupplyStatusEnum.NewCheck.ObjToInt(), |
| | | BatchNo = inventory.BatchNo, |
| | | MaterielName = inventory.MaterielName, |
| | | MaterielCode = inventory.MaterielCode, |
| | | MaterielSpec = inventory.MaterielSpec, |
| | | TaskType = TaskTypeEnum.OutInventory.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventory.LocationCode, |
| | | OrderNo = deliveryOrder.Out_no, |
| | | StockQuantity = inventory.StockQuantity, |
| | | SupplyQuantity = 0, |
| | | Remark = "çç¹" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | } |
| | | WarehouseCode = inventory.WarehouseCode, |
| | | TaskStatus = SupplyStatusEnum.NewCheck.ObjToInt(), |
| | | BatchNo = inventory.BatchNo, |
| | | MaterielName = inventory.MaterielName, |
| | | MaterielCode = inventory.MaterielCode, |
| | | MaterielSpec = inventory.MaterielSpec, |
| | | TaskType = TaskTypeEnum.OutInventory.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = inventory.LocationCode, |
| | | OrderNo = deliveryOrder.Out_no, |
| | | StockQuantity = inventory.StockQuantity, |
| | | SupplyQuantity = 0, |
| | | Remark = "çç¹" |
| | | }; |
| | | supplyTasks.Add(supplyTask); |
| | | _InventoryInfos.Add(inventory); |
| | | } |
| | | //} |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | _InventoryInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.çç¹éå®.ObjToInt(); |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | _inventoryInfoService.UpdateData(_InventoryInfos); |
| | | _supplyTaskService.AddData(supplyTasks); |
| | | BaseDal.Db.InsertNav(deliveryOrders) |
| | | .Include(x => x.Details) |
| | |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | #region æ¥è¯¢çç¹åä¿¡æ¯ |
| | | /// <summary> |
| | | /// æ¥è¯¢çç¹å |
| | | /// æ¥è¯¢çç¹å padæ¥è¯¢çåä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | |
| | | List<Dt_DeliveryOrder> dt_ReceiveOrders = new List<Dt_DeliveryOrder>(); |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Warehouse_no == warehouseCode && x.Out_type == "3").Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Warehouse_no == warehouseCode && x.Out_type == "20").Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5); |
| | | } |
| | | else |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.Out_no.Contains(orderNo) || x.Client_no.Contains(orderNo)) && (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Out_type == "3" && x.Warehouse_no == warehouseCode).OrderByDescending(x => x.CreateDate).Includes(x => x.Details).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_DeliveryOrder>().Where(x => (x.Out_no.Contains(orderNo) || x.Client_no.Contains(orderNo)) && (x.OutStatus == "æ°å»º" || x.OutStatus == "å¼å§") && x.Out_type == "20" && x.Warehouse_no == warehouseCode).OrderByDescending(x => x.CreateDate).Includes(x => x.Details).ToPageList(pageNo, 5); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | #region æ¥æ¾çç¹/åºåºä»»å¡ |
| | | /// <summary> |
| | | /// æ¥æ¾çç¹/åºåºä»»å¡ |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 宿çç¹ä»»å¡ |
| | | public WebResponseContent CheckFinish(SaveModel saveModel) |
| | | { |
| | |
| | | if (supplyTask == null) throw new Exception("å½åçç¹ä»»å¡å·²å®æ"); |
| | | if (supplyTask.LocationCode != LocationCode) throw new Exception($"å½åçç¹è´§ä½ã{LocationCode}ãä¸ä»»å¡åé
è´§ä½ä¸å¹é
"); |
| | | supplyTask.SupplyQuantity = qty; |
| | | content = CheckTaskFinish(supplyTask, LocationCode); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | #endregion |
| | | |
| | | #region çç¹ä»»å¡å®æ,å¹³åºåç«åº |
| | | public WebResponseContent CheckTaskFinish(Dt_SupplyTask supplyTask, string LocationCode = null) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | supplyTask.TaskStatus = SupplyStatusEnum.CheckFinish.ObjToInt(); |
| | | Dt_DeliveryOrder cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == supplyTask.OrderNo && x.Warehouse_no == supplyTask.WarehouseCode && x.Out_type == "3").Includes(x => x.Details).First(); |
| | | Dt_DeliveryOrder cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == supplyTask.OrderNo && x.Warehouse_no == supplyTask.WarehouseCode && x.Out_type == "20").Includes(x => x.Details).First(); |
| | | if (cabinOrder == null) return WebResponseContent.Instance.Error($"çç¹å已宿"); |
| | | Dt_DeliveryOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Batch_num == supplyTask.BatchNo && x.Reservoirarea == supplyTask.WarehouseCode && x.Goods_no == supplyTask.MaterielCode).First(); |
| | | if (cabinOrderDetail == null) return WebResponseContent.Instance.Error($"çç¹åæç»å·²å®æ"); |
| | | Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | if (materielInfo == null) return WebResponseContent.Instance.Error($"请维æ¤ç©æç¼å·ã{cabinOrderDetail.Goods_no}ãçç©æä¿¡æ¯"); |
| | | cabinOrderDetail.Order_Outqty += supplyTask.SupplyQuantity; |
| | | if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) |
| | | return WebResponseContent.Instance.Error($"å®çæ°éä¸å¯è¶
åºè´¦é¢æ°é"); |
| | | #region å¹³åºçç¹åªè½åºç°æ´ç®±å·®å¼ |
| | | if (supplyTask.WarehouseCode == WarehouseEnum.大件åº.ObjToInt().ToString()) |
| | | { |
| | | var Qty = supplyTask.SupplyQuantity % materielInfo.BoxQty; |
| | | if (Qty != 0) return WebResponseContent.Instance.Error($"大件åºåºå为æ´ç®±ï¼çç¹æ°éä¸è½å卿£ä»¶"); |
| | | } |
| | | #endregion |
| | | //if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) |
| | | // return WebResponseContent.Instance.Error($"å®çæ°éä¸å¯è¶
åºè´¦é¢æ°é"); |
| | | |
| | | #region å¤çåºåºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | #region åºåºå |
| | | #region ä¿®æ¹çç¹å |
| | | cabinOrder.OutStatus = "å¼å§"; |
| | | cabinOrderDetail.OotDetailStatus = "å¼å§"; |
| | | if (cabinOrderDetail.Order_Outqty == cabinOrderDetail.Order_qty) |
| | | { |
| | | cabinOrderDetail.OotDetailStatus = "已宿"; |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrderDetail, OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | else |
| | | { |
| | | _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | } |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == cabinOrder.Out_no && x.Out_type == "3").Includes(x => x.Details).First(); |
| | | if (cabinOrder1.Details == null || cabinOrder1.Details.Count < 1) cabinOrder.OutStatus = "已宿"; |
| | | if (cabinOrder.OutStatus == "已宿") |
| | | Repository.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.èªå¨å®æ); |
| | | else |
| | | Repository.UpdateData(cabinOrder); |
| | | Repository.UpdateData(cabinOrder); |
| | | _deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | #endregion |
| | | |
| | | #region åºå |
| | | Dt_InventoryInfo inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.LocationCode == LocationCode); |
| | | if (inventoryInfo == null) return WebResponseContent.Instance.Error($"æªæ¾å°è´§ä½ã{LocationCode}ãçåºåä¿¡æ¯"); |
| | | inventoryInfo.StockQuantity = supplyTask.SupplyQuantity; |
| | | Dt_InventoryInfo inventoryInfo = new Dt_InventoryInfo(); |
| | | if (supplyTask.WarehouseCode != WarehouseEnum.ç«åº.ObjToInt().ToString("000")) |
| | | { |
| | | inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.WarehouseCode == supplyTask.WarehouseCode && x.LocationCode == supplyTask.LocationCode); |
| | | if (inventoryInfo == null) return WebResponseContent.Instance.Error($"æªæ¾å°è´§ä½ã{LocationCode}ãçåºåä¿¡æ¯"); |
| | | } |
| | | else |
| | | { |
| | | inventoryInfo = _inventoryInfoService.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.WarehouseCode == supplyTask.WarehouseCode); |
| | | } |
| | | inventoryInfo.SupplyQuantity = supplyTask.SupplyQuantity; |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | #endregion |
| | | |
| | | #region ä»»å¡è®°å½ |
| | | _supplyTaskService.UpdateData(supplyTask); |
| | | //_supplyTaskService.UpdateData(supplyTask); |
| | | _supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.èªå¨å®æ); |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode); |
| | | if (inventory_Batch != null) |
| | | #region 夿å½åç©ææ¹æ¬¡ççç¹ä»»å¡æ¯å¦å
¨é¨å®æ |
| | | List<Dt_SupplyTask> supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt() && x.WarehouseCode == supplyTask.WarehouseCode).ToList(); |
| | | if (supplyTasks.Count < 1) |
| | | { |
| | | inventory_Batch.SupplyQuantity += supplyTask.SupplyQuantity; |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | #region 宿çç¹å |
| | | cabinOrder.OutStatus = "已宿"; |
| | | cabinOrder.Details.ForEach(x => |
| | | { |
| | | x.OotDetailStatus = "已宿"; |
| | | }); |
| | | _deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrder.Details, OperateTypeEnum.èªå¨å®æ); |
| | | cabinOrder.Details = null; |
| | | Repository.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.èªå¨å®æ); |
| | | |
| | | #endregion |
| | | } |
| | | #endregion |
| | | supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList(); |
| | | if (supplyTasks.Count < 1) |
| | | { |
| | | #region æ¥æ¾åºå |
| | | var inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | var SupplyQuantitys = inventoryInfos.Select(x => x.SupplyQuantity).ToList().Sum(); |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no); |
| | | if (SupplyQuantitys == inventory_Batch.StockQuantity) |
| | | { |
| | | foreach (var item in inventoryInfos) |
| | | { |
| | | item.StockQuantity = item.SupplyQuantity; |
| | | item.SupplyQuantity = 0; |
| | | item.StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | _inventoryInfoService.UpdateData(inventoryInfos); |
| | | } |
| | | else |
| | | { |
| | | inventory_Batch.SupplyQuantity = SupplyQuantitys; |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | |
| | | content.OK(); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |