| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.SquareCabin; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_ISquareCabinServices; |
| | | using WIDESEA_IWMsInfoServices; |
| | | using WIDESEA_Model.Models; |
| | | using static WIDESEA_DTO.SquareCabin.OrderDto; |
| | | |
| | |
| | | |
| | | namespace WIDESEA_SquareCabinServices |
| | | { |
| | | public class DeliveryOrderServices : ServiceBase<Dt_DeliveryOrder, IRepository<Dt_DeliveryOrder>>, IDeliveryOrderServices |
| | | public partial class DeliveryOrderServices : ServiceBase<Dt_DeliveryOrder, IRepository<Dt_DeliveryOrder>>, IDeliveryOrderServices |
| | | { |
| | | static string SearchDate = ""; |
| | | |
| | | public DeliveryOrderServices(IRepository<Dt_DeliveryOrder> BaseDal) : base(BaseDal) |
| | | private readonly IBasicService _basicService; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IInventory_BatchServices _inventory_BatchServices; |
| | | private readonly IInventoryInfoService _inventoryInfoService; |
| | | private readonly IDeliveryOrderDetailServices _deliveryOrderDetailServices; |
| | | private readonly ISupplyTaskService _supplyTaskService; |
| | | private readonly ICabinOrderServices _cabinOrderServices; |
| | | 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) : base(BaseDal) |
| | | { |
| | | _basicService = basicService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _deliveryOrderDetailServices = deliveryOrderDetailServices; |
| | | _supplyTaskService = supplyTaskService; |
| | | _inventory_BatchServices = inventory_BatchServices; |
| | | _inventoryInfoService = inventoryInfoService; |
| | | _cabinOrderServices = cabinOrderServices; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | Batch_num = inv.BatchNo, |
| | | Exp_date = inv.ValidityPeriod, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 1, // â
ç«åº |
| | | Status = 0, //ç«åº |
| | | Reservoirarea = inv.LocationCode |
| | | }; |
| | | entityOrder.Details.Add(detail); |
| | | |
| | | inv.OutboundQuantity += (float)use; |
| | | inv.OutboundQuantity += use; |
| | | BaseDal.Db.Updateable(inv).ExecuteCommand(); |
| | | |
| | | remainingPartial -= use; |
| | |
| | | }; |
| | | entityOrder.Details.Add(detail); |
| | | |
| | | inv.OutboundQuantity += (float)use; |
| | | inv.OutboundQuantity += use; |
| | | BaseDal.Db.Updateable(inv).ExecuteCommand(); |
| | | |
| | | remainingPartial -= use; |
| | |
| | | }; |
| | | entityOrder.Details.Add(detail); |
| | | |
| | | inv.OutboundQuantity += (float)useQty; |
| | | inv.OutboundQuantity += useQty; |
| | | BaseDal.Db.Updateable(inv).ExecuteCommand(); |
| | | |
| | | remainingFullBoxes -= useBoxes; |
| | |
| | | Batch_num = inv.BatchNo, |
| | | Exp_date = inv.ValidityPeriod, |
| | | OotDetailStatus = "æ°å»º", |
| | | Status = 0, // â
ç«åºï¼è¡¥æ´ç®±ï¼ |
| | | Status = 0, //ç«åºï¼è¡¥æ´ç®±ï¼ |
| | | Reservoirarea = inv.LocationCode |
| | | }; |
| | | entityOrder.Details.Add(detail); |
| | | |
| | | inv.OutboundQuantity += (float)useQty; |
| | | inv.OutboundQuantity += useQty; |
| | | BaseDal.Db.Updateable(inv).ExecuteCommand(); |
| | | |
| | | remainingFullBoxes -= useBoxes; |
| | |
| | | |
| | | // æ´æ°æç»ç¶æ |
| | | BaseDal.Db.Updateable<Dt_DeliveryOrderDetail>() |
| | | .SetColumns(d => new Dt_DeliveryOrderDetail { Status = 1,OotDetailStatus="已宿" }) |
| | | .SetColumns(d => new Dt_DeliveryOrderDetail { Status = 1, OotDetailStatus = "已宿" }) |
| | | .Where(d => d.DeliveryOrderId == order.Id && d.Status == 0) |
| | | .ExecuteCommand(); |
| | | |
| | |
| | | .ToList(); |
| | | |
| | | var inventoryDict = inventoryList.ToDictionary(i => i.Goods_no, i => i); |
| | | |
| | | string url = "http://172.16.1.2:9357/file-admin/api/out/ediOut"; |
| | | bool allSuccess = true; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public WebResponseContent GetPdDeliveryOrders(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | int pageNo = saveModel.MainData["pageNo"].ObjToInt(); |
| | | string warehouseCode = saveModel.MainData["warehouseId"].ToString(); |
| | | string orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent GetDeliveryOrders(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | int pageNo = saveModel.MainData["pageNo"].ObjToInt(); |
| | | string warehouseCode = saveModel.MainData["warehouseId"].ToString(); |
| | | string orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent GetDeliveryOrderDetail(int pageNo, string orderNo, bool isPick) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_DeliveryOrder cabinOrder = new Dt_DeliveryOrder(); |
| | | if (isPick) |
| | | cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Includes(x => x.Details).First(x => x.Out_no == orderNo && x.Out_type == "3"); |
| | | else |
| | | cabinOrder = Db.Queryable<Dt_DeliveryOrder>().Includes(x => x.Details).First(x => x.Out_no == orderNo && x.Out_type != "3"); |
| | | List<Dt_DeliveryOrderDetail>? cabinOrderDetails = cabinOrder.Details?.Where(x => x.Reservoirarea == pageNo.ToString()).ToList(); |
| | | content.OK(data: cabinOrderDetails); |
| | | return content; |
| | | } |
| | | public WebResponseContent MatPicking(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var LocationCode = saveModel.MainData["LocationCode"].ToString(); |
| | | var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | var batchNo = saveModel.MainData["batchNo"].ToString(); |
| | | var Inqty = saveModel.MainData["Inqty"].ObjToInt(); |
| | | var warehouseCode = saveModel.MainData["warehouseCode"].ToString(); |
| | | Dt_DeliveryOrder cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == orderNo && x.Warehouse_no == warehouseCode && x.Out_type == "3").Includes(x => x.Details).First(); |
| | | if (cabinOrder == null) return WebResponseContent.Instance.Error($"çç¹å已宿"); |
| | | Dt_DeliveryOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Batch_num == batchNo && x.Reservoirarea == warehouseCode).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 += Inqty; |
| | | if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) |
| | | return WebResponseContent.Instance.Error($"å®çæ°éä¸å¯è¶
åºè´¦é¢æ°é"); |
| | | |
| | | #region å¤çåºåºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | #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); |
| | | #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.SupplyQuantity += Inqty; |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | #endregion |
| | | |
| | | #region ä»»å¡è®°å½ |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = cabinOrderDetail.Reservoirarea, |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskType = TaskTypeEnum.OutInventory.ObjToInt(), |
| | | TaskStatus = SupplyStatusEnum.CheckFinish.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = LocationCode, |
| | | OrderNo = cabinOrder.Out_no, |
| | | StockQuantity = inventoryInfo.StockQuantity, |
| | | SupplyQuantity = Inqty, |
| | | Remark = "çç¹" |
| | | }; |
| | | _supplyTaskService.AddData(supplyTask); |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode); |
| | | if (inventory_Batch != null) |
| | | { |
| | | inventory_Batch.SupplyQuantity += Inqty; |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | |
| | | content.OK(cabinOrderDetail.Order_Outqty.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent FeedbackOut(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var LocationCode = saveModel.MainData["LocationCode"].ToString(); |
| | | var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | var batchNo = saveModel.MainData["batchNo"].ToString(); |
| | | var Inqty = saveModel.MainData["Inqty"].ObjToInt(); |
| | | var warehouseCode = saveModel.MainData["warehouseCode"].ToString(); |
| | | Dt_DeliveryOrder cabinOrder = BaseDal.Db.Queryable<Dt_DeliveryOrder>().Where(x => x.Out_no == orderNo && x.Warehouse_no == warehouseCode && x.Out_type != "3").Includes(x => x.Details).First(); |
| | | if (cabinOrder == null) return WebResponseContent.Instance.Error($"åºåºå已宿"); |
| | | Dt_DeliveryOrderDetail cabinOrderDetail = cabinOrder.Details.Where(x => x.Batch_num == batchNo && x.Reservoirarea == warehouseCode).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 += Inqty; |
| | | if (cabinOrderDetail.Order_Outqty > cabinOrderDetail.Order_qty) |
| | | return WebResponseContent.Instance.Error($"åºåºæ°éä¸å¯è¶
åºåæ®æ°é"); |
| | | |
| | | #region å¤çåºåºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | #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 = "已宿"; |
| | | Repository.UpdateData(cabinOrder); |
| | | #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 -= Inqty; |
| | | if (inventoryInfo.StockQuantity <= 0) |
| | | _inventoryInfoService.DeleteData(inventoryInfo); |
| | | else |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | #endregion |
| | | |
| | | #region è´§ä½ |
| | | var location = _basicService.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}ãå·²ç¦ç¨ï¼è¯·æ¢å¤æ£å¸¸å使ç¨"); |
| | | Dt_InventoryInfo inventoryInfo1 = _inventoryInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode); |
| | | if (inventoryInfo1 == null) |
| | | { |
| | | location.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | } |
| | | #endregion |
| | | |
| | | #region ä»»å¡è®°å½ |
| | | Dt_SupplyTask supplyTask = new Dt_SupplyTask() |
| | | { |
| | | WarehouseCode = cabinOrderDetail.Reservoirarea, |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | TaskStatus = SupplyStatusEnum.OutFinish.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutPick.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = location.LocationCode, |
| | | OrderNo = cabinOrder.Out_no, |
| | | StockQuantity = Inqty, |
| | | SupplyQuantity = 0, |
| | | Remark = "åºåº" |
| | | }; |
| | | _supplyTaskService.AddData(supplyTask); |
| | | #endregion |
| | | |
| | | #region åºåæ¹æ¬¡ |
| | | Dt_Inventory_Batch inventory_Batch = _inventory_BatchServices.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo && x.MaterielCode == inventoryInfo.MaterielCode); |
| | | if (inventory_Batch != null) |
| | | { |
| | | inventory_Batch.StockQuantity -= Inqty; |
| | | if (inventory_Batch.StockQuantity <= 0) |
| | | _inventory_BatchServices.DeleteData(inventory_Batch); |
| | | else |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | |
| | | content.OK(cabinOrderDetail.Order_Outqty.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |