|
|
@ -722,35 +722,56 @@ public class ReportLabelListServiceImpl extends ServiceImpl<ReportLabelListMappe |
|
|
}*/ |
|
|
}*/ |
|
|
// 则系统会替换customFields里的qty字段到ZPL代码里对应的位置 |
|
|
// 则系统会替换customFields里的qty字段到ZPL代码里对应的位置 |
|
|
Map<String, Object> customFields = printRequest.getCustomFields(); |
|
|
Map<String, Object> customFields = printRequest.getCustomFields(); |
|
|
List<String> outerQtyList = extractRequiredOuterQtyList(customFields); |
|
|
|
|
|
|
|
|
|
|
|
// 2. 获取外箱标签打印机配置 |
|
|
// 2. 获取外箱标签打印机配置 |
|
|
UserLabelPrinterData outerPrinter = getRequiredLabelPrinter(printRequest.getUserId(), outerLabelSetting.getLabelNo()); |
|
|
UserLabelPrinterData outerPrinter = getRequiredLabelPrinter(printRequest.getUserId(), outerLabelSetting.getLabelNo()); |
|
|
|
|
|
|
|
|
// 3. 按QTY数组逐项生成外箱任务(复用同一个queryParams,确保IFS数据只查询一次) |
|
|
|
|
|
|
|
|
// 3. 生成外箱打印任务 |
|
|
List<Long> taskIds = new ArrayList<>(); |
|
|
List<Long> taskIds = new ArrayList<>(); |
|
|
int outerBatchIndex = 1; |
|
|
|
|
|
for (String outerQty : outerQtyList) { |
|
|
|
|
|
Map<String, Object> outerCustomFields = buildOuterCustomFields(customFields, outerQty); |
|
|
|
|
|
queryParams.put("customFields", outerCustomFields); |
|
|
|
|
|
|
|
|
boolean hasCustomerId = StringUtils.isNotBlank(printRequest.getCustomerId()); |
|
|
|
|
|
if (hasCustomerId) { |
|
|
|
|
|
// 传customerId时,按QTY数组逐项生成外箱任务 |
|
|
|
|
|
List<String> outerQtyList = extractRequiredOuterQtyList(customFields); |
|
|
|
|
|
int outerBatchIndex = 1; |
|
|
|
|
|
for (String outerQty : outerQtyList) { |
|
|
|
|
|
Map<String, Object> outerCustomFields = buildOuterCustomFields(customFields, outerQty); |
|
|
|
|
|
queryParams.put("customFields", outerCustomFields); |
|
|
|
|
|
|
|
|
|
|
|
// 生成当前QTY对应的外箱标签(同一queryParams会复用IFS缓存) |
|
|
|
|
|
List<String> zplCodeList = previewLabelWithRealData(outerLabelSetting.getLabelNo(), true, queryParams); |
|
|
|
|
|
List<Map<String, Object>> labelDataList = getLabelDataForPrint(outerLabelSetting.getLabelNo(), queryParams); |
|
|
|
|
|
if (zplCodeList == null || zplCodeList.isEmpty()) { |
|
|
|
|
|
throw new RuntimeException("外箱标签ZPL代码获取失败,qty=" + outerQty); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 生成当前QTY对应的外箱标签(同一queryParams会复用IFS缓存) |
|
|
|
|
|
|
|
|
int totalLabels = zplCodeList.size(); |
|
|
|
|
|
for (int i = 0; i < totalLabels; i++) { |
|
|
|
|
|
String zplCode = zplCodeList.get(i); |
|
|
|
|
|
Map<String, Object> labelData = i < labelDataList.size() ? labelDataList.get(i) : new HashMap<>(); |
|
|
|
|
|
Long taskId = enqueueSingleTask(outerPrinter.getIpAddress(), zplCode, outerRfidFlag, labelData, printRequest); |
|
|
|
|
|
taskIds.add(taskId); |
|
|
|
|
|
log.info("外箱标签任务已加入队列,batch={} / {}, index={} / {}, qty={}, taskId={}", |
|
|
|
|
|
outerBatchIndex, outerQtyList.size(), i + 1, totalLabels, outerQty, taskId); |
|
|
|
|
|
} |
|
|
|
|
|
outerBatchIndex++; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 未传customerId时,沿用原逻辑,不强制校验customFields.QTY |
|
|
|
|
|
if (customFields != null && !customFields.isEmpty()) { |
|
|
|
|
|
queryParams.put("customFields", customFields); |
|
|
|
|
|
} |
|
|
List<String> zplCodeList = previewLabelWithRealData(outerLabelSetting.getLabelNo(), true, queryParams); |
|
|
List<String> zplCodeList = previewLabelWithRealData(outerLabelSetting.getLabelNo(), true, queryParams); |
|
|
List<Map<String, Object>> labelDataList = getLabelDataForPrint(outerLabelSetting.getLabelNo(), queryParams); |
|
|
List<Map<String, Object>> labelDataList = getLabelDataForPrint(outerLabelSetting.getLabelNo(), queryParams); |
|
|
if (zplCodeList == null || zplCodeList.isEmpty()) { |
|
|
if (zplCodeList == null || zplCodeList.isEmpty()) { |
|
|
throw new RuntimeException("外箱标签ZPL代码获取失败,qty=" + outerQty); |
|
|
|
|
|
|
|
|
throw new RuntimeException("ZPL代码获取失败"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int totalLabels = zplCodeList.size(); |
|
|
int totalLabels = zplCodeList.size(); |
|
|
for (int i = 0; i < totalLabels; i++) { |
|
|
for (int i = 0; i < totalLabels; i++) { |
|
|
String zplCode = zplCodeList.get(i); |
|
|
String zplCode = zplCodeList.get(i); |
|
|
Map<String, Object> labelData = i < labelDataList.size() ? labelDataList.get(i) : new HashMap<>(); |
|
|
Map<String, Object> labelData = i < labelDataList.size() ? labelDataList.get(i) : new HashMap<>(); |
|
|
Long taskId = enqueueSingleTask(outerPrinter.getIpAddress(), zplCode, outerRfidFlag, labelData, printRequest); |
|
|
Long taskId = enqueueSingleTask(outerPrinter.getIpAddress(), zplCode, outerRfidFlag, labelData, printRequest); |
|
|
taskIds.add(taskId); |
|
|
taskIds.add(taskId); |
|
|
log.info("外箱标签任务已加入队列,batch={} / {}, index={} / {}, qty={}, taskId={}", |
|
|
|
|
|
outerBatchIndex, outerQtyList.size(), i + 1, totalLabels, outerQty, taskId); |
|
|
|
|
|
|
|
|
log.info("外箱标签任务已加入队列,index={} / {}, taskId={}", i + 1, totalLabels, taskId); |
|
|
} |
|
|
} |
|
|
outerBatchIndex++; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 4. 外箱全部完成后仅补打一套内箱(若存在内箱配置) |
|
|
// 4. 外箱全部完成后仅补打一套内箱(若存在内箱配置) |
|
|
|