| | |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ç©æçä¿¡æ¯"); |
| | | } |
| | | |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode).ToList(); |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.BatchNo==(models.FirstOrDefault()?.LotNo ?? "")).ToList(); |
| | | |
| | | if (inboundOrderDetails == null || inboundOrderDetails.Count <= 0) |
| | | { |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// å
¥åºå®æä¸æ¥ERP |
| | | /// å
¥åºå®æä¸æ¥ERP å¼ç¨ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | #region å¼ç¨ |
| | | public WebResponseContent FeedbackInboundOrder(Dt_StockInfo stockInfo, Dt_InboundOrder inboundOrder, List<ERPInboundDetailModel> detailModels) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | #endregion |
| | | /// <summary> |
| | | /// å
¥åºå®æä¸æ¥ERP |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent FeedbackInboundOrder(Dt_InboundOrder inboundOrder, List<Dt_StockInfoDetail> stockInfoDetails) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (inboundOrder.Details.Count == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (stockInfoDetails.Count==0) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåæç»ä¿¡æ¯"); |
| | | } |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == inboundOrder.WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | List<ERPInboundDetailModel>? detailModels = null; |
| | | foreach (var item in stockInfoDetails) |
| | | { |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.Id == item.StockId); |
| | | if (detailModels!=null && detailModels.FirstOrDefault(x=>x.Rack==stockInfo.LocationCode)!=null) |
| | | { |
| | | var detailModel = detailModels.FirstOrDefault(x => x.Rack == stockInfo.LocationCode); |
| | | detailModel.Quantity = (Convert.ToDouble(detailModel.Quantity) + item.StockQuantity).ToString(); |
| | | } |
| | | else |
| | | { |
| | | 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() |
| | | }; |
| | | detailModels.Add(detailModel); |
| | | } |
| | | } |
| | | ERPInboundModel model = new ERPInboundModel() |
| | | { |
| | | Code = CreateCodeByRule(nameof(RuleCodeEnum.RLCodeRule)), |
| | | 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, |
| | | Type = "S", |
| | | UniqueTag = inboundOrder.Id.ToString(), |
| | | WarehouseCode = warehouse.WarehouseCode, |
| | | Way = 1, |
| | | Details = detailModels |
| | | }; |
| | | //æ¨éERP æµè¯æ³¨é |
| | | _invokeERPService.InvokeInboundOrderApi(model); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | static object lock_code = new object(); |
| | | public string CreateCodeByRule(string ruleCode) |
| | | { |