Browse Source

外箱也可以一次传3个

master
han\hanst 3 days ago
parent
commit
971389a7f3
  1. 27
      src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java

27
src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java

@ -722,13 +722,15 @@ public class ReportLabelListServiceImpl extends ServiceImpl<ReportLabelListMappe
}*/
// 则系统会替换customFields里的qty字段到ZPL代码里对应的位置
Map<String, Object> customFields = printRequest.getCustomFields();
List<String> outerQtyList = extractRequiredOuterQtyList(customFields);
// 2. 获取外箱标签打印机配置
UserLabelPrinterData outerPrinter = getRequiredLabelPrinter(printRequest.getUserId(), outerLabelSetting.getLabelNo());
// 3. 按QTY数组逐项生成外箱任务复用同一个queryParams确保IFS数据只查询一次
// 3. 生成外箱打印任务
List<Long> taskIds = new ArrayList<>();
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);
@ -752,6 +754,25 @@ public class ReportLabelListServiceImpl extends ServiceImpl<ReportLabelListMappe
}
outerBatchIndex++;
}
} else {
// 未传customerId时沿用原逻辑不强制校验customFields.QTY
if (customFields != null && !customFields.isEmpty()) {
queryParams.put("customFields", customFields);
}
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代码获取失败");
}
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("外箱标签任务已加入队列,index={} / {}, taskId={}", i + 1, totalLabels, taskId);
}
}
// 4. 外箱全部完成后仅补打一套内箱若存在内箱配置
enqueueInnerBoxTasksIfNeeded(printRequest, resolvedReportId, queryParams, outerPrinter, taskIds);

Loading…
Cancel
Save