| | |
| | | private readonly IMesLogService _mesLogService; |
| | | private readonly IMesService _mesService; |
| | | private readonly ISys_DictionaryService _sysDictionaryService; |
| | | private readonly IStockInfoService _stockInfoService; |
| | | |
| | | public StockInfoDetailController( |
| | | IStockInfoDetailService service, |
| | | IMesLogService mesLogService, |
| | | IMesService mesService, |
| | | ISys_DictionaryService sysDictionaryService) : base(service) |
| | | ISys_DictionaryService sysDictionaryService, |
| | | IStockInfoService stockInfoService) : base(service) |
| | | { |
| | | _mesLogService = mesLogService; |
| | | _mesService = mesService; |
| | | _sysDictionaryService = sysDictionaryService; |
| | | _stockInfoService = stockInfoService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | try |
| | | { |
| | | // 1. 参数验证 |
| | | if (string.IsNullOrWhiteSpace(dto.PalletCode)) |
| | | { |
| | | return response.Error("托盘编号不能为空"); |
| | | } |
| | | |
| | | if (dto.SfcList == null || !dto.SfcList.Any()) |
| | | { |
| | | return response.Error("电芯码列表不能为空"); |
| | | } |
| | | |
| | | // 2. 验证电芯状态(非'已锁定'状态允许绑定) |
| | | var stockDetails = await Service.Repository.QueryDataAsync(x => dto.SfcList.Contains(x.SerialNumber)); |
| | | if (stockDetails != null && stockDetails.Any(d => d.Status == 99)) |
| | | var stockDetail = await Service.Repository.QueryFirstAsync(x => dto.SfcList.Contains(x.SerialNumber)); |
| | | if (stockDetail != null && stockDetail.Status == 99) |
| | | { |
| | | return response.Error("当前库存明细包含已锁定状态,不允许执行绑定操作"); |
| | | } |
| | | |
| | | // 3. 获取系统配置 |
| | | var configs = _sysDictionaryService.GetVueDictionary(new[] { "MES_EquipmentCode", "MES_ResourceCode" }); |
| | | |
| | | string equipmentCode = GetConfigValue(configs, "MES_EquipmentCode", "WCS_001"); |
| | | string resourceCode = GetConfigValue(configs, "MES_ResourceCode", "RESOURCE_001"); |
| | | var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id); |
| | | |
| | | // 3. 构造MES请求 - 将电芯列表转换为ContainerSfcItem格式 |
| | | var mesRequest = new BindContainerRequest |
| | | { |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "STK-GROUP-001", |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = dto.PalletCode, |
| | | ContainerCode = stockInfo.PalletCode, |
| | | ContainerSfcList = dto.SfcList.Select(sfc => new ContainerSfcItem |
| | | { |
| | | Sfc = sfc, |
| | |
| | | try |
| | | { |
| | | // 1. 参数验证 |
| | | if (string.IsNullOrWhiteSpace(dto.PalletCode)) |
| | | { |
| | | return response.Error("托盘编号不能为空"); |
| | | } |
| | | |
| | | if (dto.SfcList == null || !dto.SfcList.Any()) |
| | | { |
| | | return response.Error("电芯码列表不能为空"); |
| | | } |
| | | |
| | | // 2. 验证电芯状态(非'已锁定'状态允许解绑) |
| | | var stockDetails = await Service.Repository.QueryDataAsync(x => dto.SfcList.Contains(x.SerialNumber)); |
| | | if (stockDetails != null && stockDetails.Any(d => d.Status == 99)) |
| | | var stockDetail = await Service.Repository.QueryFirstAsync(x => dto.SfcList.Contains(x.SerialNumber)); |
| | | if (stockDetail != null && stockDetail.Status == 99) |
| | | { |
| | | return response.Error("当前库存明细包含已锁定状态,不允许执行解绑操作"); |
| | | } |
| | | |
| | | // 3. 获取系统配置 |
| | | var configs = _sysDictionaryService.GetVueDictionary(new[] { "MES_EquipmentCode", "MES_ResourceCode" }); |
| | | |
| | | string equipmentCode = GetConfigValue(configs, "MES_EquipmentCode", "WCS_001"); |
| | | string resourceCode = GetConfigValue(configs, "MES_ResourceCode", "RESOURCE_001"); |
| | | var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id); |
| | | |
| | | // 3. 构造MES请求 |
| | | var mesRequest = new UnBindContainerRequest |
| | | { |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "STK-GROUP-001", |
| | | LocalTime = DateTime.Now, |
| | | ContainCode = dto.PalletCode, |
| | | ContainCode = stockInfo.PalletCode, |
| | | SfcList = dto.SfcList |
| | | }; |
| | | |
| | |
| | | |
| | | // 2. 验证电芯状态(非'已锁定'状态允许NG上报) |
| | | var sfcList = dto.NgSfcList.Select(x => x.Sfc).ToList(); |
| | | var stockDetails = await Service.Repository.QueryDataAsync(x => sfcList.Contains(x.SerialNumber)); |
| | | if (stockDetails != null && stockDetails.Any(d => d.Status == 99)) |
| | | var stockDetail = await Service.Repository.QueryFirstAsync(x => sfcList.Contains(x.SerialNumber)); |
| | | if (stockDetail != null && stockDetail.Status == 99) |
| | | { |
| | | return response.Error("当前库存明细包含已锁定状态,不允许执行NG上报操作"); |
| | | } |
| | | |
| | | // 3. 获取系统配置 |
| | | var configs = _sysDictionaryService.GetVueDictionary(new[] { "MES_EquipmentCode", "MES_ResourceCode" }); |
| | | |
| | | string equipmentCode = GetConfigValue(configs, "MES_EquipmentCode", "WCS_001"); |
| | | string resourceCode = GetConfigValue(configs, "MES_ResourceCode", "RESOURCE_001"); |
| | | var stockInfo = await _stockInfoService.Repository.QueryFirstAsync(x => stockDetail.StockId == x.Id); |
| | | |
| | | // 3. 构造MES请求 - 将DTO格式转换为MES请求格式 |
| | | var mesRequest = new ContainerNgReportRequest |
| | | { |
| | | EquipmentCode = equipmentCode, |
| | | ResourceCode = resourceCode, |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "RESOURCE-001", |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = dto.PalletCode, |
| | | ContainerCode = stockInfo.PalletCode, |
| | | NgSfcList = dto.NgSfcList.Select(ng => new NgSfcItem |
| | | { |
| | | Sfc = ng.Sfc, |