| | |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_ISystemService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Common.Constants; |
| | | using WIDESEA_Common.StockEnum; |
| | | using System.Diagnostics; |
| | | |
| | |
| | | private readonly IMesService _mesService; |
| | | private readonly ISys_DictionaryService _sysDictionaryService; |
| | | private readonly IStockInfoService _stockInfoService; |
| | | private readonly IMESDeviceConfigService _mesDeviceConfigService; |
| | | |
| | | public StockInfoDetailController( |
| | | IStockInfoDetailService service, |
| | | IMesLogService mesLogService, |
| | | IMesService mesService, |
| | | ISys_DictionaryService sysDictionaryService, |
| | | IStockInfoService stockInfoService) : base(service) |
| | | IStockInfoService stockInfoService, |
| | | IMESDeviceConfigService mesDeviceConfigService) : base(service) |
| | | { |
| | | _mesLogService = mesLogService; |
| | | _mesService = mesService; |
| | | _sysDictionaryService = sysDictionaryService; |
| | | _stockInfoService = stockInfoService; |
| | | _mesDeviceConfigService = mesDeviceConfigService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id); |
| | | |
| | | // 3. 构造MES请求 - 将电芯列表转换为ContainerSfcItem格式 |
| | | // 3. 动态获取MES凭证 |
| | | var mesConfig = _mesDeviceConfigService.GetByDeviceName("组盘机械手"); |
| | | string equipmentCode = mesConfig?.EquipmentCode ?? StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = mesConfig?.ResourceCode ?? StockConstants.MES_RESOURCE_CODE; |
| | | string token = mesConfig?.Token; |
| | | |
| | | // 4. 构造MES请求 - 将电芯列表转换为ContainerSfcItem格式 |
| | | var mesRequest = new BindContainerRequest |
| | | { |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "STK-GROUP-001", |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = stockInfo.PalletCode, |
| | | ContainerSfcList = dto.SfcList.Select(sfc => new ContainerSfcItem |
| | |
| | | |
| | | string requestJson = System.Text.Json.JsonSerializer.Serialize(mesRequest); |
| | | |
| | | // 4. 异步调用MES接口(fire-and-forget) |
| | | // 5. 异步调用MES接口(fire-and-forget) |
| | | var localToken = token; |
| | | _ = Task.Run(async () => |
| | | { |
| | | var localStopwatch = Stopwatch.StartNew(); |
| | | try |
| | | { |
| | | var result = _mesService.BindContainer(mesRequest); |
| | | var result = string.IsNullOrWhiteSpace(localToken) |
| | | ? _mesService.BindContainer(mesRequest) |
| | | : _mesService.BindContainer(mesRequest, localToken); |
| | | localStopwatch.Stop(); |
| | | |
| | | bool isSuccess = result?.IsSuccess ?? false; |
| | |
| | | } |
| | | }); |
| | | |
| | | // 5. 立即返回成功响应 |
| | | // 6. 立即返回成功响应 |
| | | return response.OK("托盘电芯绑定成功"); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id); |
| | | |
| | | // 3. 构造MES请求 |
| | | // 3. 动态获取MES凭证 |
| | | var mesConfig = _mesDeviceConfigService.GetByDeviceName("组盘机械手"); |
| | | string equipmentCode = mesConfig?.EquipmentCode ?? StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = mesConfig?.ResourceCode ?? StockConstants.MES_RESOURCE_CODE; |
| | | string token = mesConfig?.Token; |
| | | |
| | | // 4. 构造MES请求 |
| | | var mesRequest = new UnBindContainerRequest |
| | | { |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "STK-GROUP-001", |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | ContainCode = stockInfo.PalletCode, |
| | | SfcList = dto.SfcList |
| | |
| | | |
| | | string requestJson = System.Text.Json.JsonSerializer.Serialize(mesRequest); |
| | | |
| | | // 4. 异步调用MES接口(fire-and-forget) |
| | | // 5. 异步调用MES接口(fire-and-forget) |
| | | var localToken = token; |
| | | _ = Task.Run(async () => |
| | | { |
| | | var localStopwatch = Stopwatch.StartNew(); |
| | | try |
| | | { |
| | | var result = _mesService.UnBindContainer(mesRequest); |
| | | var result = string.IsNullOrWhiteSpace(localToken) |
| | | ? _mesService.UnBindContainer(mesRequest) |
| | | : _mesService.UnBindContainer(mesRequest, localToken); |
| | | localStopwatch.Stop(); |
| | | |
| | | bool isSuccess = result?.IsSuccess ?? false; |
| | |
| | | } |
| | | }); |
| | | |
| | | // 5. 立即返回成功响应 |
| | | // 6. 立即返回成功响应 |
| | | return response.OK("托盘电芯解绑成功"); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id); |
| | | |
| | | // 3. 构造MES请求 - 将DTO格式转换为MES请求格式 |
| | | // 3. 动态获取MES凭证 |
| | | var mesConfig = _mesDeviceConfigService.GetByDeviceName("组盘机械手"); |
| | | string equipmentCode = mesConfig?.EquipmentCode ?? StockConstants.MES_EQUIPMENT_CODE; |
| | | string resourceCode = mesConfig?.ResourceCode ?? StockConstants.MES_RESOURCE_CODE; |
| | | |
| | | // 4. 构造MES请求 - 将DTO格式转换为MES请求格式 |
| | | var mesRequest = new ContainerNgReportRequest |
| | | { |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "RESOURCE-001", |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = stockInfo.PalletCode, |
| | | NgSfcList = dto.NgSfcList.Select(ng => new NgSfcItem |
| | |
| | | |
| | | string requestJson = System.Text.Json.JsonSerializer.Serialize(mesRequest); |
| | | |
| | | // 4. 异步调用MES接口(fire-and-forget) |
| | | // 5. 异步调用MES接口(fire-and-forget) |
| | | _ = Task.Run(async () => |
| | | { |
| | | var localStopwatch = Stopwatch.StartNew(); |
| | |
| | | } |
| | | }); |
| | | |
| | | // 5. 立即返回成功响应 |
| | | // 6. 立即返回成功响应 |
| | | return response.OK("NG电芯上报成功"); |
| | | } |
| | | catch (Exception ex) |