|
|
@ -47,15 +47,14 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
List<ReportLabelList> processedElements = new ArrayList<>(); |
|
|
List<ReportLabelList> processedElements = new ArrayList<>(); |
|
|
for (ReportLabelList element : elements) { |
|
|
for (ReportLabelList element : elements) { |
|
|
ReportLabelList processedElement = processElementData(element, dataMap); |
|
|
ReportLabelList processedElement = processElementData(element, dataMap); |
|
|
|
|
|
|
|
|
// 如果是图片元素且被设置为不显示,则跳过该元素 |
|
|
|
|
|
if (("image".equals(element.getType()) || "picture".equals(element.getType())) |
|
|
|
|
|
|
|
|
// 如果元素被设置为不显示,则跳过该元素 |
|
|
|
|
|
if (("onecode".equals(element.getType()) || "qrcode".equals(element.getType()) |
|
|
|
|
|
|| "text".equals(element.getType()) || "pic".equals(element.getType())) |
|
|
&& processedElement.getData().isEmpty() |
|
|
&& processedElement.getData().isEmpty() |
|
|
&& BigDecimal.ZERO.equals(processedElement.getWidth())) { |
|
|
&& BigDecimal.ZERO.equals(processedElement.getWidth())) { |
|
|
log.debug("跳过不显示的图片元素: type={}, showPic={}", element.getType(), element.getShowPic()); |
|
|
|
|
|
|
|
|
log.debug("跳过不显示的元素: type={}, showElement={}", element.getType(), element.getShowElement()); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
processedElements.add(processedElement); |
|
|
processedElements.add(processedElement); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -75,9 +74,10 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
log.debug("处理元素数据: type={}, originalData={}", element.getType(), originalData); |
|
|
log.debug("处理元素数据: type={}, originalData={}", element.getType(), originalData); |
|
|
|
|
|
|
|
|
// 处理图片元素的显示控制 |
|
|
// 处理图片元素的显示控制 |
|
|
if ("pic".equals(element.getType())) { |
|
|
|
|
|
if (!shouldShowPicture(element, dataMap)) { |
|
|
|
|
|
log.debug("根据showPic设置,隐藏图片元素: showPic={}", element.getShowPic()); |
|
|
|
|
|
|
|
|
if ("onecode".equals(element.getType()) || "qrcode".equals(element.getType()) |
|
|
|
|
|
|| "text".equals(element.getType()) || "pic".equals(element.getType())) { |
|
|
|
|
|
if (!shouldShow(element, dataMap)) { |
|
|
|
|
|
log.debug("根据showElement设置,隐藏元素: showElement={}", element.getShowElement()); |
|
|
// 返回null或设置特殊标记表示不显示该元素 |
|
|
// 返回null或设置特殊标记表示不显示该元素 |
|
|
processedElement.setData(""); |
|
|
processedElement.setData(""); |
|
|
processedElement.setWidth(BigDecimal.ZERO); |
|
|
processedElement.setWidth(BigDecimal.ZERO); |
|
|
@ -558,37 +558,37 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 判断是否应该显示图片 |
|
|
* 判断是否应该显示图片 |
|
|
* 根据showPic设置和数据源中的字段值进行判断 |
|
|
|
|
|
* showPic格式: "fieldName=value",如果数据源中fieldName的值等于value,则不显示图片 |
|
|
|
|
|
|
|
|
* 根据showElement设置和数据源中的字段值进行判断 |
|
|
|
|
|
* showElement格式: "fieldName=value",如果数据源中fieldName的值等于value,则不显示图片 |
|
|
* |
|
|
* |
|
|
* @param element 图片元素 |
|
|
* @param element 图片元素 |
|
|
* @param dataMap 数据源映射 |
|
|
* @param dataMap 数据源映射 |
|
|
* @return true表示显示图片,false表示不显示图片 |
|
|
* @return true表示显示图片,false表示不显示图片 |
|
|
*/ |
|
|
*/ |
|
|
private boolean shouldShowPicture(ReportLabelList element, Map<String, Object> dataMap) { |
|
|
|
|
|
String showPic = element.getShowPic(); |
|
|
|
|
|
|
|
|
private boolean shouldShow(ReportLabelList element, Map<String, Object> dataMap) { |
|
|
|
|
|
String showElement = element.getShowElement(); |
|
|
|
|
|
|
|
|
// 如果showPic为空或null,默认显示图片 |
|
|
|
|
|
if (showPic == null || showPic.trim().isEmpty()) { |
|
|
|
|
|
log.debug("showPic为空,默认显示图片"); |
|
|
|
|
|
|
|
|
// 如果showElement为空或null,默认显示图片 |
|
|
|
|
|
if (showElement == null || showElement.trim().isEmpty()) { |
|
|
|
|
|
log.debug("showElement为空,默认显示图片"); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 如果showPic是"true"或"Y",显示图片 |
|
|
|
|
|
if ("true".equalsIgnoreCase(showPic.trim()) || "Y".equalsIgnoreCase(showPic.trim())) { |
|
|
|
|
|
log.debug("showPic设置为显示: {}", showPic); |
|
|
|
|
|
|
|
|
// 如果showElement是"true"或"Y",显示图片 |
|
|
|
|
|
if ("true".equalsIgnoreCase(showElement.trim()) || "Y".equalsIgnoreCase(showElement.trim())) { |
|
|
|
|
|
log.debug("showElement设置为显示: {}", showElement); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 如果showPic是"false"或"N",不显示图片 |
|
|
|
|
|
if ("false".equalsIgnoreCase(showPic.trim()) || "N".equalsIgnoreCase(showPic.trim())) { |
|
|
|
|
|
log.debug("showPic设置为不显示: {}", showPic); |
|
|
|
|
|
|
|
|
// 如果showElement是"false"或"N",不显示图片 |
|
|
|
|
|
if ("false".equalsIgnoreCase(showElement.trim()) || "N".equalsIgnoreCase(showElement.trim())) { |
|
|
|
|
|
log.debug("showElement设置为不显示: {}", showElement); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 解析showPic格式: "fieldName=value" |
|
|
|
|
|
if (showPic.contains("=")) { |
|
|
|
|
|
String[] parts = showPic.split("=", 2); |
|
|
|
|
|
|
|
|
// 解析showElement格式: "fieldName=value" |
|
|
|
|
|
if (showElement.contains("=")) { |
|
|
|
|
|
String[] parts = showElement.split("=", 2); |
|
|
if (parts.length == 2) { |
|
|
if (parts.length == 2) { |
|
|
String fieldName = parts[0].trim(); |
|
|
String fieldName = parts[0].trim(); |
|
|
String expectedValue = parts[1].trim(); |
|
|
String expectedValue = parts[1].trim(); |
|
|
@ -611,7 +611,7 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 其他情况默认显示图片 |
|
|
// 其他情况默认显示图片 |
|
|
log.debug("showPic格式无法识别,默认显示图片: {}", showPic); |
|
|
|
|
|
|
|
|
log.debug("showElement格式无法识别,默认显示图片: {}", showElement); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -635,7 +635,7 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
copy.setItemNo(original.getItemNo()); |
|
|
copy.setItemNo(original.getItemNo()); |
|
|
copy.setBarcodeType(original.getBarcodeType()); |
|
|
copy.setBarcodeType(original.getBarcodeType()); |
|
|
copy.setShowContent(original.getShowContent()); |
|
|
copy.setShowContent(original.getShowContent()); |
|
|
copy.setShowPic(original.getShowPic()); |
|
|
|
|
|
|
|
|
copy.setShowElement(original.getShowElement()); |
|
|
copy.setShowMainSeq(original.getShowMainSeq()); |
|
|
copy.setShowMainSeq(original.getShowMainSeq()); |
|
|
copy.setSeqName(original.getSeqName()); |
|
|
copy.setSeqName(original.getSeqName()); |
|
|
copy.setIsChecked(original.getIsChecked()); |
|
|
copy.setIsChecked(original.getIsChecked()); |
|
|
|