| | |
| | | using AutoMapper; |
| | | using HslCommunication.WebSocket; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | 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($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | 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); |
| | | MatSerNumAnalysisModel model = 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 (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(); |
| | | } |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent FeedbackInboundOrder(Dt_StockInfo stockInfo) |
| | | /// <summary> |
| | | /// å
¥åºå®æä¸æ¥ERP |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | 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($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.OrderStatus == InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåæ®å·²å®æ"); |
| | | } |
| | | |
| | | Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == stockInfo.WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°ä»åºä¿¡æ¯"); |
| | | } |
| | | |
| | | ERPInboundModel model = new ERPInboundModel() |
| | | { |
| | | Code = inboundOrder.InboundOrderNo, |
| | | 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 |
| | | }; |
| | | string response = _invokeERPService.InvokeInboundOrderApi(model); |
| | | ErpRequestContent? requestContent = JsonConvert.DeserializeObject<ErpRequestContent>(response); |
| | | if (requestContent == null) |
| | | { |
| | | return WebResponseContent.Instance.Error(); |
| | | } |
| | | if (requestContent.res == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error(requestContent.Data); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
¥åºå®æåä¼ å°ERP æµè¯ |
| | | /// å
¥åºå®æåä¼ å°ERP |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.OrderStatus != InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | if (inboundOrder.OrderStatus == InOrderStatusEnum.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåæ®æªå®æ"); |
| | | } |
| | | if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºæç»æªå®æ"); |
| | | 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(); |
| | |
| | | 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 |
| | | }; |
| | | |
| | | string response = _invokeERPService.InvokeInboundOrderApi(model); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |