| | |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Outbound; |
| | | |
| | | namespace WIDESEA_BasicService |
| | | { |
| | |
| | | private readonly IOutboundOrderService _outboundOrderService; |
| | | private readonly IOutboundOrderDetailService _outboundOrderDetailService; |
| | | private readonly IOutStockLockInfoService _outStockLockInfoService; |
| | | private readonly IRepository<Dt_InterfaceLog> _interfacelogRepository; |
| | | |
| | | // åå¨èµæºIDåå
¶å¯¹åºçé对象ãä½¿ç¨ ConcurrentDictionary ç¡®ä¿å¯¹åå
¸æä½æ¬èº«ç线ç¨å®å
¨ã |
| | | private static readonly ConcurrentDictionary<string, object> _resourceLocks = new ConcurrentDictionary<string, object>(); |
| | | |
| | | // å
¨å±éæéï¼ç¨äºä¿æ¤ _resourceLocks åå
¸ä¸ GetOrAdd æ TryRemove æ¶çç«äº |
| | | private static readonly object _globalLocker = new object(); |
| | | public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService, IMaterialUnitService materialUnitService, IRepository<Dt_PickingRecord> pickingRecoreRepository) |
| | | public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService, IMaterialUnitService materialUnitService, IRepository<Dt_PickingRecord> pickingRecoreRepository, IRepository<Dt_InterfaceLog> interfacelogRepository) |
| | | { |
| | | _httpClientFactory = httpClientFactory; |
| | | _logger = logger; |
| | |
| | | _outStockLockInfoService = outStockLockInfoService; |
| | | _materialUnitService = materialUnitService; |
| | | _pickingRecoreRepository = pickingRecoreRepository; |
| | | _interfacelogRepository = interfacelogRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | // æ¢é失败ï¼è¯´ææå¦ä¸ä¸ªçº¿ç¨ï¼WCSåè°æäººå·¥æä½ï¼æ£å¨å¤ç |
| | | |
| | | return WebResponseContent.Instance.OK("WMSæ£å¨å¤çæ¤åä¼ ä»»å¡ï¼è¯·å¿é夿ä½ã"); |
| | | return WebResponseContent.Instance.Error("WMSæ£å¨å¤çæ¤åä¼ ä»»å¡ï¼è¯·å¿é夿ä½ã"); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | var groups = pickingRecords.GroupBy(x => x.FeedBackMesDocumentNo).ToList(); |
| | | foreach (var group in groups) |
| | | { |
| | | |
| | | |
| | | List<Dt_PickingRecord> records = group.ToList(); // 该åç»ä¸çææè®°å½ |
| | | if (string.IsNullOrEmpty(group.Key)) |
| | | { |
| | | var emptydocumentNo = UniqueValueGenerator.Generate(); |
| | | records.ForEach(x => { x.FeedBackMesDocumentNo = emptydocumentNo; }); |
| | | var result= await _pickingRecoreRepository.Db.Insertable(records).ExecuteCommandAsync(); |
| | | var result = await _pickingRecoreRepository.Db.Updateable(records).ExecuteCommandAsync(); |
| | | |
| | | var interfacelog = new Dt_InterfaceLog |
| | | { |
| | | Content = JsonConvert.SerializeObject(records), |
| | | DocumentNo = emptydocumentNo, |
| | | OrderNo = orderNo, |
| | | OrderType = "2", |
| | | }; |
| | | _interfacelogRepository.AddData(interfacelog); |
| | | |
| | | if (result > 0) |
| | | { |
| | | (bool _flowControl, WebResponseContent _value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, emptydocumentNo); |
| | | if (!_flowControl) |
| | | { |
| | | return _value; |
| | | } |
| | | |
| | | return _value; |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | (bool _flowControl, WebResponseContent _value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, group.Key); |
| | | if (!_flowControl) |
| | | var ilog = _interfacelogRepository.QueryFirst(x => x.DocumentNo == group.Key); |
| | | if (ilog == null) |
| | | { |
| | | return _value; |
| | | var interfacelog = new Dt_InterfaceLog |
| | | { |
| | | Content = JsonConvert.SerializeObject(records), |
| | | DocumentNo = group.Key, |
| | | OrderNo = orderNo, |
| | | OrderType = "2", |
| | | }; |
| | | _interfacelogRepository.AddData(interfacelog); |
| | | } |
| | | (bool _flowControl, WebResponseContent _value) = await FeedBackBatchToMes(outboundOrder, orderNo, orderDetails, pickingRecords, group.Key); |
| | | |
| | | return _value; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | x.ReturnToMESStatus = 1; |
| | | }); |
| | | await _pickingRecoreRepository.Db.Updateable(updates).ExecuteCommandAsync(); |
| | | await _interfacelogRepository.Db.Updateable<Dt_InterfaceLog>() |
| | | .SetColumns(x => x.ReturnToMESStatus == 1) |
| | | .Where(x => x.OrderNo == orderNo) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | if (allCompleted) |
| | | { |
| | | //MESåä¼ æåï¼æ´æ°æç»ä¸ºåä¼ æåç¶æ |