| | |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.WareHouseEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.ERP; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_External.ERPService; |
| | | using WIDESEA_External.Model; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | |
| | | private readonly IBasicRepository _basicRepository; |
| | | private readonly IStockRepository _stockRepository; |
| | | private readonly IRecordService _recordService; |
| | | private readonly IInvokeERPService _invokeERPService; |
| | | private readonly IWarehouseService _warehouseService; |
| | | |
| | | public IInboundOrderRepository Repository => BaseDal; |
| | | |
| | | public InboundOrderService(IInboundOrderRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IInboundRepository inboundRepository, IBasicRepository basicRepository, IStockRepository stockRepository, IRecordService recordService) : base(BaseDal) |
| | | public InboundOrderService(IInboundOrderRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IInboundRepository inboundRepository, IBasicRepository basicRepository, IStockRepository stockRepository, IRecordService recordService, IInvokeERPService invokeERPService, IWarehouseService warehouseService) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _basicRepository = basicRepository; |
| | | _stockRepository = stockRepository; |
| | | _recordService = recordService; |
| | | _invokeERPService = invokeERPService; |
| | | _warehouseService = warehouseService; |
| | | } |
| | | /// <summary> |
| | | /// å
¶ä»å
¥åºåå建 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent ReceiveWarehousingOrder(ErpInOrderDTO erpInOrder) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | //è·åä»åºä¿¡æ¯ |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x=>x.WarehouseCode==erpInOrder.WaId); |
| | | if (warehouse==null) |
| | | { |
| | | return content.Error("æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | //è·åæ¯å¦åå¨è®¢å |
| | | Dt_InboundOrder inboundOrder = BaseDal.QueryFirst(x=>x.InboundOrderNo== erpInOrder.OrderNo); |
| | | if (erpInOrder.Way==1) |
| | | { |
| | | if (inboundOrder!=null) |
| | | { |
| | | |
| | | } |
| | | } |
| | | else if(erpInOrder.Way==2) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent GetInboundOrders(SaveModel saveModel) |
| | | { |
| | |
| | | try |
| | | { |
| | | int pageNo = saveModel.MainData["pageNo"].ObjToInt(); |
| | | string orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | string? orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | int warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | List<Dt_InboundOrder> dt_ReceiveOrders = new List<Dt_InboundOrder>(); |
| | | if (string.IsNullOrEmpty(orderNo)) |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5); |
| | | } |
| | | else |
| | | { |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.InboundOrderNo.Contains(orderNo)) && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt()).ToPageList(pageNo, 5); |
| | | dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.InboundOrderNo.Contains(orderNo)) && x.OrderStatus < InOrderStatusEnum.å
¥åºå®æ.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5); |
| | | } |
| | | |
| | | content.OK(data: dt_ReceiveOrders); |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åä¸ªç©æç ç»ç éç¨æµè¯æ¶ |
| | | /// </summary> |
| | | /// <param name="inboundOrderId"></param> |
| | | /// <param name="palletCode"></param> |
| | | /// <param name="serNum"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MaterielGroup(int inboundOrderId, string palletCode, string serNum) |
| | | { |
| | | try |
| | | { |
| | | Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.Id == inboundOrderId).Includes(x => x.Details).First(); |
| | | if (inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.OrderStatus>=InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåå·²ç»æ"); |
| | | } |
| | | if (inboundOrder.Details.Count <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | MatSerNumAnalysisModel model = new MatSerNumAnalysisModel() |
| | | { |
| | | MaterielCode = "504907335", |
| | | LotNo = "20241217001", |
| | | ProductionDate = "2024-12-17", |
| | | EffectiveDate = "2025-12-17", |
| | | PurchaseOrderNo = "POHA02241227285", |
| | | Quantity = 1, |
| | | SerialNumber = "M:504907335,BS:20241217001,DM:2024-12-17,DE:2025-12-17,Q:1,PO:POHA02241227285" |
| | | };//æµè¯ |
| | | //CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serNum); |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == model.MaterielCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æçä¿¡æ¯"); |
| | | } |
| | | if (materielInfo.WarehouseId != inboundOrder.WarehouseId) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥ç©æä¸å±äºæ¬ä»"); |
| | | } |
| | | Dt_ReceiveOrder receiveOrder = _inboundRepository.ReceiveOrderRepository.Db.Queryable<Dt_ReceiveOrder>().Where(x => x.ReceiveOrderNo == inboundOrder.UpperOrderNo).Includes(x => x.Details).First(); |
| | | if (receiveOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºçæ¶è´§å"); |
| | | } |
| | | if (receiveOrder.Details.Count <= 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºçæ¶è´§åæç»"); |
| | | } |
| | | List<string> purchaseOrderNos = receiveOrder.Details.Select(x => x.PurchaseOrderNo).ToList(); |
| | | if (!purchaseOrderNos.Contains(model.PurchaseOrderNo)) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºæ¶è´§åæç»ä¸éè´å"); |
| | | } |
| | | Dt_ReceiveOrderDetail? receiveOrderDetail = receiveOrder.Details.FirstOrDefault(x => x.MaterielCode == model.MaterielCode); |
| | | if (receiveOrderDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨æ¶è´§åæç»ä¸æ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.MaterielCode == model.MaterielCode); |
| | | if (inboundOrderDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨å
¥åºåæç»ä¸æ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | if (inboundOrderDetail.OrderDetailStatus>OrderDetailStatusEnum.GroupAndInbound.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"对åºå
¥åºåæç»å·²ç»æ"); |
| | | } |
| | | float inboundDetailSum = inboundOrderDetail.OverInQuantity + inboundOrderDetail.ReceiptQuantity ; |
| | | if (inboundDetailSum == inboundOrderDetail.OrderQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥ç©æå
¥åºåæç»å·²å
¨é¨ç»ç宿"); |
| | | } |
| | | if (model.Quantity > receiveOrderDetail.ReceivedQuantity || (inboundDetailSum + model.Quantity) > receiveOrderDetail.ReceivedQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"ä¸è¯¥æ¶è´§åæç»æ¶è´§æ°éä¸ä¸è´"); |
| | | } |
| | | Dt_StockInfo oldStockinfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if(oldStockinfo!=null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçéå¤"); |
| | | } |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | BatchNo = model.LotNo, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | OrderNo = inboundOrder.InboundOrderNo, |
| | | SerialNumber = model.SerialNumber, |
| | | StockQuantity = model.Quantity, |
| | | OutboundQuantity = 0, |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | ProductionDate = model.ProductionDate, |
| | | EffectiveDate = model.EffectiveDate, |
| | | InboundOrderRowNo = inboundOrderDetail.RowNo, |
| | | }; |
| | | |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = palletCode, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | WarehouseId = inboundOrder.WarehouseId, |
| | | Details=new List<Dt_StockInfoDetail> { stockInfoDetail } |
| | | }; |
| | | inboundOrderDetail.ReceiptQuantity += model.Quantity; |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (inboundOrderDetail.OrderDetailStatus==OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | } |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail); |
| | | if (inboundOrder.OrderStatus == InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | BaseDal.UpdateData(inboundOrder); |
| | | } |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// ç»ç |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent MaterielGroup(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | var palletCode = saveModel.MainData["palletCode"].ToString(); |
| | | var warehouseId = saveModel.MainData["warehouseId"].ObjToInt(); |
| | | var Initiallife = saveModel.MainData["initiallife"].ObjToInt(); |
| | | var serNums = saveModel.DelKeys.Select(x => x.ToString()).ToList(); |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == warehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»åºä¿¡æ¯"); |
| | | } |
| | | |
| | | Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo && x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).First(); |
| | | if (inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåä¿¡æ¯"); |
| | |
| | | |
| | | List<string> purchaseOrderNos = receiveOrder.Details.Select(x => x.PurchaseOrderNo).ToList(); |
| | | |
| | | MatSerNumAnalysisModel model = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serNum); |
| | | List<MatSerNumAnalysisModel> models = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serNums); |
| | | |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == model.MaterielCode).ToList(); |
| | | |
| | | if (inboundOrderDetails == null || inboundOrderDetails.Count <= 0) |
| | | if (models.Select(x => x.MaterielCode).Distinct().Count() > 1) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨å
¥åºåæç»ä¸æ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | if (receiveOrder.Details.FirstOrDefault(x => x.MaterielCode == model.MaterielCode) == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨æ¶è´§åæç»ä¸æ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | if (purchaseOrderNos.FirstOrDefault(x => x == model.PurchaseOrderNo) == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨æ¶è´§åæç»ä¸æ¾å°è¯¥éè´å"); |
| | | return WebResponseContent.Instance.Error($"ç©æä¸å¯æ··æ¾"); |
| | | } |
| | | |
| | | Dt_InboundOrderDetail? notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt() && x.OrderQuantity == model.Quantity).FirstOrDefault(); |
| | | |
| | | if (notGroupDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥ç©æå¨è¯¥å
¥åºåä¸å·²å
¨é¨ç»ç宿"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == model.MaterielCode); |
| | | string materielCode = models.FirstOrDefault()?.MaterielCode ?? ""; |
| | | Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode); |
| | | if (materielInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æçä¿¡æ¯"); |
| | | } |
| | | |
| | | Dt_StockInfo stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = palletCode, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | WarehouseId = inboundOrder.WarehouseId |
| | | }; |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode).ToList(); |
| | | |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | if (inboundOrderDetails == null || inboundOrderDetails.Count <= 0) |
| | | { |
| | | BatchNo = model.LotNo, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | OrderNo = inboundOrder.InboundOrderNo, |
| | | SerialNumber = model.SerialNumber, |
| | | StockQuantity = model.Quantity, |
| | | OutboundQuantity = 0, |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt() |
| | | }; |
| | | return WebResponseContent.Instance.Error($"æªå¨å
¥åºåæç»ä¸æ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | if (receiveOrder.Details.FirstOrDefault(x => x.MaterielCode == materielCode) == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨æ¶è´§åæç»ä¸æ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | float beforeQuantity = 0; |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = palletCode, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | WarehouseId = inboundOrder.WarehouseId, |
| | | PalletType = PalletTypeEnum.SmallPallet.ObjToInt(), |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçå·éå¤"); |
| | | } |
| | | beforeQuantity = stockInfo.Details.Sum(x => x.StockQuantity); |
| | | } |
| | | |
| | | if (warehouse.WarehouseCode == WarehouseEnum.HA64.ToString()) |
| | | { |
| | | stockInfo.Remark = Initiallife.ToString(); |
| | | } |
| | | |
| | | List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>(); |
| | | List<int> detailKeys = new List<int>(); |
| | | foreach (var model in models) |
| | | { |
| | | if (purchaseOrderNos.FirstOrDefault(x => x == model.PurchaseOrderNo) == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨æ¶è´§åæç»ä¸æ¾å°è¯¥éè´å"); |
| | | } |
| | | |
| | | Dt_InboundOrderDetail? notGroupDetail = inboundOrderDetails.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt() && x.OrderQuantity == model.Quantity && !detailKeys.Contains(x.Id) && x.OrderQuantity > x.ReceiptQuantity).FirstOrDefault(); |
| | | |
| | | if (notGroupDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥ç©æå¨è¯¥å
¥åºåä¸å·²å
¨é¨ç»ç宿"); |
| | | } |
| | | detailKeys.Add(notGroupDetail.Id); |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | BatchNo = model.LotNo, |
| | | MaterielCode = materielInfo.MaterielCode, |
| | | MaterielName = materielInfo.MaterielName, |
| | | OrderNo = inboundOrder.InboundOrderNo, |
| | | SerialNumber = model.SerialNumber, |
| | | StockQuantity = model.Quantity, |
| | | OutboundQuantity = 0, |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | ProductionDate = model.ProductionDate, |
| | | EffectiveDate = model.EffectiveDate, |
| | | InboundOrderRowNo = notGroupDetail.RowNo, |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | | { |
| | | stockInfoDetail.StockId = stockInfo.Id; |
| | | } |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | |
| | | stockInfoDetails.Add(stockInfoDetail); |
| | | |
| | | notGroupDetail.ReceiptQuantity = model.Quantity; |
| | | notGroupDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | } |
| | | |
| | | float totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity); |
| | | |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo).Include(x => x.Details, new UpdateNavOptions() { OneToManyInsertOrUpdate = true }).ExecuteCommand(); |
| | | } |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfoDetails, beforeQuantity, totalQuantity, StockChangeTypeEnum.MaterielGroup); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent MaterielGroup(int inboundOrderId, string palletCode, List<string> serNums) |
| | |
| | | SerialNumber = model.SerialNumber, |
| | | StockQuantity = model.Quantity, |
| | | OutboundQuantity = 0, |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt() |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | ProductionDate = model.ProductionDate, |
| | | EffectiveDate = model.EffectiveDate, |
| | | InboundOrderRowNo = notGroupDetail.RowNo, |
| | | }; |
| | | |
| | | if (stockInfo.Id > 0) |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent FeedbackInboundOrder(Dt_StockInfo stockInfo) |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºå®æåä¼ å°ERP æµè¯ |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent FeedbackInboundOrder(int id) |
| | | { |
| | | try |
| | | { |
| | | Dt_InboundOrder inboundOrder = Db.Queryable<Dt_InboundOrder>().Where(x => x.Id == id).Includes(x => x.Details).First(); |
| | | if (inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.Details == null || inboundOrder.Details.Count == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.OrderStatus != InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåæ®æªå®æ"); |
| | | } |
| | | if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºæç»æªå®æ"); |
| | | } |
| | | |
| | | List<Dt_StockInfo> stockInfos = Db.Queryable<Dt_StockInfo>().Where(x => x.Details.Any(v => v.OrderNo == inboundOrder.InboundOrderNo)).Includes(x => x.Details).ToList(); |
| | | List<Dt_Warehouse> warehouses = Db.Queryable<Dt_Warehouse>().ToList(); |
| | | |
| | | List<ERPInboundDetailModel> detailModels = new List<ERPInboundDetailModel>(); |
| | | foreach (var item in inboundOrder.Details) |
| | | { |
| | | Dt_StockInfo? stockInfo = stockInfos.FirstOrDefault(x => x.Details.Any(v => v.InboundOrderRowNo == item.RowNo && v.MaterielCode == item.MaterielCode)); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåä¿¡æ¯"); |
| | | } |
| | | |
| | | Dt_Warehouse? warehouse = warehouses.FirstOrDefault(x => x.WarehouseId == stockInfo.WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | |
| | | ERPInboundDetailModel detailModel = new ERPInboundDetailModel() |
| | | { |
| | | ExpiryDate = stockInfo.Details.FirstOrDefault()?.EffectiveDate ?? "", |
| | | LocationCode = warehouse.WarehouseCode, |
| | | MaterialsCode = item.MaterielCode, |
| | | MfgDate = stockInfo.Details.FirstOrDefault()?.ProductionDate ?? "", |
| | | QtyCustoms = "0", |
| | | Quantity = stockInfo.Details.Sum(x => x.StockQuantity).ToString(), |
| | | Rack = stockInfo.LocationCode, |
| | | ReceiptCode = inboundOrder.UpperOrderNo, |
| | | ReceiptSerNo = item.RowNo.ToString() |
| | | }; |
| | | detailModels.Add(detailModel); |
| | | } |
| | | Dt_Warehouse? warehouse2 = warehouses.FirstOrDefault(x => x.WarehouseId == inboundOrder.WarehouseId); |
| | | if (warehouse2 == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | ERPInboundModel model = new ERPInboundModel() |
| | | { |
| | | Code = inboundOrder.InboundOrderNo, |
| | | CreatorCode = "TC20082",//æµè¯ |
| | | EntDate = inboundOrder.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | StockDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | SuppliersId = inboundOrder.SupplierId, |
| | | Type = "S", |
| | | UniqueTag = inboundOrder.Id.ToString(), |
| | | WarehouseCode = warehouse2.WarehouseCode, |
| | | Way = 1, |
| | | Details = detailModels |
| | | }; |
| | | |
| | | string response = _invokeERPService.InvokeInboundOrderApi(model); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |