diff --git a/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java b/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java index c1a9a50..c5215f4 100644 --- a/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java +++ b/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java @@ -644,24 +644,20 @@ public class ReportLabelListServiceImpl extends ServiceImpl(); + } if (!printFlag) { // 生成前缀:A+site+YYYYMMDD String prefix = "A" + "5520250929"; List unitIds = Collections.singletonList(prefix+"00000001"); queryParams.put("unitIds", unitIds); - if ("IFST".equalsIgnoreCase(ifsDBName)) { - // 测试库(IFST)保留现有默认测试数据 - queryParams.put("consignmentId", "1654576"); - queryParams.put("jobNo", "71305202"); - queryParams.put("lineNo", "1"); - queryParams.put("relNo", "1"); - queryParams.put("lineItemNo", 0); + if (isPreviewNeedManualIfsParams(labelSetting.getLabelType())) { + // 外箱/内箱标签:真实数据预览时必须由用户输入IFS参数 + normalizePreviewIfsParams(queryParams); } else { - queryParams.put("consignmentId", "1773845"); - queryParams.put("jobNo", "71330430"); - queryParams.put("lineNo", "19"); - queryParams.put("relNo", "1"); - queryParams.put("lineItemNo",0); + // 其他标签沿用原有默认参数策略,避免影响已有功能 + fillDefaultPreviewIfsParams(queryParams); } } // 使用真实数据生成ZPL代码 @@ -799,6 +795,76 @@ public class ReportLabelListServiceImpl extends ServiceImpl queryParams) { + if ("IFST".equalsIgnoreCase(ifsDBName)) { + queryParams.putIfAbsent("consignmentId", "1654576"); + queryParams.putIfAbsent("jobNo", "71305202"); + queryParams.putIfAbsent("lineNo", "1"); + queryParams.putIfAbsent("relNo", "1"); + queryParams.putIfAbsent("lineItemNo", 0); + } else { + queryParams.putIfAbsent("consignmentId", "1773845"); + queryParams.putIfAbsent("jobNo", "71330430"); + queryParams.putIfAbsent("lineNo", "19"); + queryParams.putIfAbsent("relNo", "1"); + queryParams.putIfAbsent("lineItemNo", 0); + } + } + + /** + * 外箱/内箱标签真实预览参数校验与标准化 + */ + private void normalizePreviewIfsParams(Map queryParams) { + Integer consignmentId = parseRequiredIntegerParam(queryParams, "consignmentId", "发货单ID"); + String jobNo = parseRequiredStringParam(queryParams, "jobNo", "作业单号"); + String lineNo = parseRequiredStringParam(queryParams, "lineNo", "行号"); + String relNo = parseRequiredStringParam(queryParams, "relNo", "关联号"); + Integer lineItemNo = parseRequiredIntegerParam(queryParams, "lineItemNo", "行项目号"); + + queryParams.put("consignmentId", consignmentId); + queryParams.put("jobNo", jobNo); + queryParams.put("lineNo", lineNo); + queryParams.put("relNo", relNo); + queryParams.put("lineItemNo", lineItemNo); + } + + private String parseRequiredStringParam(Map queryParams, String key, String fieldName) { + Object value = queryParams.get(key); + if (value == null || StringUtils.isBlank(value.toString())) { + throw new RuntimeException("真实数据预览请填写" + fieldName); + } + return value.toString().trim(); + } + + private Integer parseRequiredIntegerParam(Map queryParams, String key, String fieldName) { + Object value = queryParams.get(key); + if (value == null || StringUtils.isBlank(value.toString())) { + throw new RuntimeException("真实数据预览请填写" + fieldName); + } + try { + if (value instanceof Number) { + return ((Number) value).intValue(); + } + return Integer.parseInt(value.toString().trim()); + } catch (NumberFormatException e) { + throw new RuntimeException(fieldName + "必须为整数"); + } + } + /** * 根据客户编码解析标签编号(仅当前端传了customerId时生效) */