| | |
| | | using HslCommunication; |
| | | using MailKit.Search; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System; |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | 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_IBasicService; |
| | | using WIDESEA_ISquareCabinServices; |
| | | using WIDESEA_IWMsInfoServices; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | using static System.Net.WebRequestMethods; |
| | |
| | | static string SearchDate = ""; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IMedicineGoodsServices _medicineGoodsServices; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IInventory_BatchServices _inventory_BatchServices; |
| | | private readonly IInventoryInfoService _inventoryInfoService; |
| | | private readonly ICabinOrderDetailServices _cabinOrderDetailServices; |
| | | private readonly ISupplyTaskService _supplyTaskService; |
| | | public IRepository<Dt_CabinOrder> Repository => BaseDal; |
| | | |
| | | public CabinOrderServices(IRepository<Dt_CabinOrder> BaseDal, IBasicService basicService, IMedicineGoodsServices medicineGoodsServices) : 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) : base(BaseDal) |
| | | { |
| | | _basicService = basicService; |
| | | _medicineGoodsServices = medicineGoodsServices; |
| | | _medicineGoodsServices = medicineGoodsServices; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _inventory_BatchServices = inventory_BatchServices; |
| | | _inventoryInfoService = inventoryInfoService; |
| | | _cabinOrderDetailServices = cabinOrderDetailServices; |
| | | _supplyTaskService = supplyTaskService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | // return responseContent.Error("åæ¥å¤±è´¥: " + ex.Message); |
| | | // } |
| | | //} |
| | | public WebResponseContent GetCabinOrders(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_CabinOrder> dt_ReceiveOrders = new List<Dt_CabinOrder>(); |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_CabinOrder>().Where(x => (x.OdrderStatus == "æ°å»º" || x.OdrderStatus == "å¼å§") && x.Warehouse_no == warehouseCode).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5); |
| | | } |
| | | else |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_CabinOrder>().Where(x => (x.Order_no.Contains(orderNo) || x.Supplier_no.Contains(orderNo)) && (x.OdrderStatus == "æ°å»º" || x.OdrderStatus == "å¼å§") && 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 GetCabinOrderDetail(int pageNo, string orderNo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_CabinOrder cabinOrder = Db.Queryable<Dt_CabinOrder>().Includes(x => x.Details).First(x => x.Order_no == orderNo); |
| | | List<Dt_CabinOrderDetail> cabinOrderDetails = cabinOrder.Details.Where(x => x.Reservoirarea == pageNo.ToString()).ToList(); |
| | | content.OK(data: cabinOrderDetails); |
| | | return content; |
| | | } |
| | | public WebResponseContent FeedbackIn([FromBody] 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_CabinOrder cabinOrder = BaseDal.Db.Queryable<Dt_CabinOrder>().Where(x => x.Order_no == orderNo && x.Warehouse_no == warehouseCode).Includes(x => x.Details).First(); |
| | | if (cabinOrder == null) return WebResponseContent.Instance.Error($"å
¥åºå已宿"); |
| | | Dt_CabinOrderDetail 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_Inqty += Inqty; |
| | | if (cabinOrderDetail.Order_Inqty > cabinOrderDetail.Order_qty) |
| | | return WebResponseContent.Instance.Error($"å
¥åºæ°éä¸å¯è¶
åºåæ®æ°é"); |
| | | |
| | | #region å¤çå
¥åºåï¼è´§ä½ï¼åºåï¼åºåæ¹æ¬¡ä¿¡æ¯ |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | #region å
¥åºå |
| | | cabinOrder.OdrderStatus = "å¼å§"; |
| | | cabinOrderDetail.OrderDetailStatus = "å¼å§"; |
| | | if (cabinOrderDetail.Order_Inqty == cabinOrderDetail.Order_qty) |
| | | { |
| | | cabinOrderDetail.OrderDetailStatus = "已宿"; |
| | | _cabinOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrderDetail, OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | else |
| | | { |
| | | _cabinOrderDetailServices.Repository.UpdateData(cabinOrderDetail); |
| | | } |
| | | var cabinOrder1 = BaseDal.Db.Queryable<Dt_CabinOrder>().Where(x => x.Order_no == cabinOrder.Order_no).Includes(x => x.Details).First(); |
| | | if (cabinOrder1.Details == null || cabinOrder1.Details.Count < 1) cabinOrder.OdrderStatus = "已宿"; |
| | | Repository.UpdateData(cabinOrder); |
| | | #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}ãå·²ç¦ç¨ï¼è¯·æ¢å¤æ£å¸¸å使ç¨"); |
| | | if (location.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | location.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | } |
| | | #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) |
| | | { |
| | | inventoryInfo.StockQuantity += Inqty; |
| | | _inventoryInfoService.UpdateData(inventoryInfo); |
| | | } |
| | | else |
| | | { |
| | | inventoryInfo = new Dt_InventoryInfo() |
| | | { |
| | | LocationCode = LocationCode, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | MaterielSpec = materielInfo.MaterielSpec, |
| | | OutboundQuantity = 0, |
| | | StockQuantity = Inqty, |
| | | StockStatus = StockStatusEmun.å
¥åºå®æ.ObjToInt(), |
| | | ValidityPeriod = cabinOrderDetail.Exp_date, |
| | | WarehouseCode = cabinOrderDetail.Reservoirarea, |
| | | SupplyQuantity = 0, |
| | | InDate = DateTime.Now, |
| | | BatchNo = cabinOrderDetail.Batch_num, |
| | | Creater = App.User.UserName, |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _inventoryInfoService.AddData(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.InPick.ObjToInt(), |
| | | CreateDate = DateTime.Now, |
| | | Creater = App.User.UserName, |
| | | LocationCode = location.LocationCode, |
| | | OrderNo = cabinOrder.Order_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; |
| | | _inventory_BatchServices.UpdateData(inventory_Batch); |
| | | } |
| | | else |
| | | { |
| | | inventory_Batch = new Dt_Inventory_Batch() |
| | | { |
| | | BatchNo = inventoryInfo.BatchNo, |
| | | CreateDate = inventoryInfo.CreateDate, |
| | | Creater = inventoryInfo.Creater, |
| | | MaterielCode = inventoryInfo.MaterielCode, |
| | | ERPStockQuantity = 0, |
| | | MaterielName = inventoryInfo.MaterielName, |
| | | MaterielSpec = inventoryInfo.MaterielSpec, |
| | | OutboundQuantity = inventoryInfo.OutboundQuantity, |
| | | ProductionDate = inventoryInfo.ProductionDate, |
| | | Status = false, |
| | | StockQuantity = inventoryInfo.StockQuantity, |
| | | ValidityPeriod = inventoryInfo.ValidityPeriod, |
| | | SupplyQuantity = inventoryInfo.SupplyQuantity, |
| | | }; |
| | | _inventory_BatchServices.AddData(inventory_Batch); |
| | | } |
| | | #endregion |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | #endregion |
| | | |
| | | content.OK(cabinOrderDetail.Order_Inqty.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent GetUpstreamOrder() |
| | | { |
| | |
| | | { |
| | | Dt_CabinOrderDetail orderDetail = new Dt_CabinOrderDetail() |
| | | { |
| | | Reservoirarea= order.warehouse_no, |
| | | Reservoirarea = order.warehouse_no, |
| | | Goods_no = item.goods_no, |
| | | Order_qty = item.order_qty, |
| | | Batch_num = item.batch_num, |