| | |
| | | try |
| | | { |
| | | //è·åä»åºä¿¡æ¯ |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x=>x.WarehouseCode==erpInOrder.WaId); |
| | | if (warehouse==null) |
| | | 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) |
| | | Dt_InboundOrder inboundOrder = BaseDal.QueryFirst(x => x.InboundOrderNo == erpInOrder.OrderNo); |
| | | if (erpInOrder.Way == 1) |
| | | { |
| | | if (inboundOrder!=null) |
| | | if (inboundOrder != null) |
| | | { |
| | | |
| | | } |
| | | } |
| | | else if(erpInOrder.Way==2) |
| | | else if (erpInOrder.Way == 2) |
| | | { |
| | | |
| | | } |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.OrderStatus>=InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | if (inboundOrder.OrderStatus >= InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåå·²ç»æ"); |
| | | } |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨å
¥åºåæç»ä¸æ¾å°è¯¥ç©æä¿¡æ¯"); |
| | | } |
| | | if (inboundOrderDetail.OrderDetailStatus>OrderDetailStatusEnum.GroupAndInbound.ObjToInt()) |
| | | if (inboundOrderDetail.OrderDetailStatus > OrderDetailStatusEnum.GroupAndInbound.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"对åºå
¥åºåæç»å·²ç»æ"); |
| | | } |
| | | float inboundDetailSum = inboundOrderDetail.OverInQuantity + inboundOrderDetail.ReceiptQuantity ; |
| | | float inboundDetailSum = inboundOrderDetail.OverInQuantity + inboundOrderDetail.ReceiptQuantity; |
| | | if (inboundDetailSum == inboundOrderDetail.OrderQuantity) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥ç©æå
¥åºåæç»å·²å
¨é¨ç»ç宿"); |
| | |
| | | return WebResponseContent.Instance.Error($"ä¸è¯¥æ¶è´§åæç»æ¶è´§æ°éä¸ä¸è´"); |
| | | } |
| | | Dt_StockInfo oldStockinfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if(oldStockinfo!=null) |
| | | if (oldStockinfo != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçéå¤"); |
| | | } |
| | |
| | | PalletCode = palletCode, |
| | | StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | WarehouseId = inboundOrder.WarehouseId, |
| | | Details=new List<Dt_StockInfoDetail> { stockInfoDetail } |
| | | Details = new List<Dt_StockInfoDetail> { stockInfoDetail } |
| | | }; |
| | | inboundOrderDetail.ReceiptQuantity += model.Quantity; |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (inboundOrderDetail.OrderDetailStatus==OrderDetailStatusEnum.New.ObjToInt()) |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | } |
| | |
| | | /// å
¥åºå®æä¸æ¥ERP |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent FeedbackInboundOrder(Dt_StockInfo stockInfo,Dt_InboundOrder inboundOrder) |
| | | public WebResponseContent FeedbackInboundOrder(Dt_StockInfo stockInfo, Dt_InboundOrder inboundOrder, List<ERPInboundDetailModel> detailModels) |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (inboundOrder.Details.Count == 0) |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåæ®å·²å®æ"); |
| | | } |
| | | List<ERPInboundDetailModel> detailModels = new List<ERPInboundDetailModel>(); |
| | | |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == stockInfo.WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x=>x.RowNo==item.InboundOrderRowNo); |
| | | if (inboundOrderDetail == null) |
| | | { |
| | | continue; |
| | | } |
| | | ERPInboundDetailModel detailModel = new ERPInboundDetailModel() |
| | | { |
| | | ExpiryDate = item.EffectiveDate ?? "", |
| | | LocationCode = warehouse.WarehouseCode, |
| | | MaterialsCode = item.MaterielCode, |
| | | MfgDate = item.ProductionDate ?? "", |
| | | QtyCustoms = "0", |
| | | Quantity = item.StockQuantity.ToString(), |
| | | Rack = stockInfo.LocationCode, |
| | | ReceiptCode = inboundOrder.UpperOrderNo, |
| | | ReceiptSerNo = item.InboundOrderRowNo.ToString() |
| | | }; |
| | | inboundOrderDetail.OverInQuantity += detailModel.Quantity.ObjToInt(); |
| | | if (inboundOrderDetail.OverInQuantity== inboundOrderDetail.OrderQuantity) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | inboundOrderDetails.Add(inboundOrderDetail); |
| | | detailModels.Add(detailModel); |
| | | } |
| | | |
| | | ERPInboundModel model = new ERPInboundModel() |
| | | { |
| | | Code = inboundOrder.InboundOrderNo, |
| | | CreatorCode = "TC20082",//æµè¯ |
| | | CreatorCode = inboundOrder.Creater,//æµè¯ |
| | | EntDate = inboundOrder.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | StockDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | SuppliersId = inboundOrder.SupplierId, |
| | |
| | | Way = 1, |
| | | Details = detailModels |
| | | }; |
| | | //å
¥åºæç»æ°å¢å®ææ°é |
| | | int newCount = inboundOrderDetails.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; |
| | | //å
¥åºæç»å宿æ°é |
| | | int oldCount = inboundOrder.Details.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; |
| | | string response = _invokeERPService.InvokeInboundOrderApi(model); |
| | | ErpRequestContent requestContent = JsonConvert.DeserializeObject<ErpRequestContent>(response); |
| | | if (requestContent==null) |
| | | ErpRequestContent? requestContent = JsonConvert.DeserializeObject<ErpRequestContent>(response); |
| | | if (requestContent == null) |
| | | { |
| | | return WebResponseContent.Instance.Error(); |
| | | } |
| | | if (requestContent.res==0) |
| | | if (requestContent.res == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error(requestContent.Data); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails); |
| | | if (inboundOrder.Details.Count == (newCount + oldCount)) |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºå®æåä¼ å°ERP æµè¯ |
| | | /// å
¥åºå®æåä¼ å°ERP |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | |
| | | ERPInboundModel model = new ERPInboundModel() |
| | | { |
| | | Code = inboundOrder.InboundOrderNo, |
| | | CreatorCode = "TC20082",//æµè¯ |
| | | CreatorCode = inboundOrder.Creater,//æµè¯ |
| | | EntDate = inboundOrder.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | StockDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | SuppliersId = inboundOrder.SupplierId, |