| | |
| | | /// å
¥åºå®æä¸æ¥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(); |
| | | try |
| | |
| | | { |
| | | 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); |
| | | ErpRequestContent? requestContent = JsonConvert.DeserializeObject<ErpRequestContent>(response); |
| | | if (requestContent==null) |
| | | { |
| | | return WebResponseContent.Instance.Error(); |
| | |
| | | { |
| | | 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, |