Browse Source

子标签且上级就是当前外箱,才是这张外箱的内箱,没有这样的行就返回 null,调用方只打外箱。

master
han\hanst 3 weeks ago
parent
commit
cb7986dabb
  1. 52
      src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java

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

@ -1033,29 +1033,24 @@ public class ReportLabelListServiceImpl extends ServiceImpl<ReportLabelListMappe
} }
/** /**
* 根据外箱标签解析对应内箱标签
* 查外箱下面有没有内箱。ParentReportID 等于外箱编号即表示挂了内箱,返回该行的 ReportID。
* 例如 ParentReportID=A068 时,A068 的内箱是 A067。不看标签类型,也不按地址回退。
* 没有这样的行就返回 null,调用方只打外箱。
*/ */
private String resolveInnerLabelByCustomer(PrintLabelRequest printRequest, String outerLabelNo) { private String resolveInnerLabelByCustomer(PrintLabelRequest printRequest, String outerLabelNo) {
String customerId = StringUtils.trimToNull(printRequest.getCustomerId()); String customerId = StringUtils.trimToNull(printRequest.getCustomerId());
if (StringUtils.isBlank(customerId) || StringUtils.isBlank(outerLabelNo)) { if (StringUtils.isBlank(customerId) || StringUtils.isBlank(outerLabelNo)) {
return null; return null;
} }
String addressNo = StringUtils.trimToNull(printRequest.getAddressNo());
try { try {
CustomerLabelSettingData query = new CustomerLabelSettingData(); CustomerLabelSettingData query = new CustomerLabelSettingData();
query.setSearchFlag("Y"); query.setSearchFlag("Y");
query.setCustomerId(customerId.trim()); query.setCustomerId(customerId.trim());
// 不在SQL层限定addressNo,保留“地址精确匹配 -> 客户通用地址回退”的业务顺序
List<CustomerLabelSettingData> customerLabelList = baseService.getCustomerLabelSettingList(query); List<CustomerLabelSettingData> customerLabelList = baseService.getCustomerLabelSettingList(query);
if (customerLabelList == null || customerLabelList.isEmpty()) { if (customerLabelList == null || customerLabelList.isEmpty()) {
return null; return null;
} }
CustomerLabelSettingData exactInnerLabel = null;
CustomerLabelSettingData exactAnyLabel = null;
CustomerLabelSettingData fallbackInnerLabel = null;
CustomerLabelSettingData fallbackAnyLabel = null;
for (CustomerLabelSettingData item : customerLabelList) { for (CustomerLabelSettingData item : customerLabelList) {
if (item == null || StringUtils.isBlank(item.getLabelNo())) { if (item == null || StringUtils.isBlank(item.getLabelNo())) {
continue; continue;
@ -1064,51 +1059,16 @@ public class ReportLabelListServiceImpl extends ServiceImpl<ReportLabelListMappe
&& !StringUtils.equalsIgnoreCase(printRequest.getSite(), item.getSite())) { && !StringUtils.equalsIgnoreCase(printRequest.getSite(), item.getSite())) {
continue; continue;
} }
// 子标签且上级就是当前外箱,才是这张外箱的内箱
if (!"Y".equalsIgnoreCase(StringUtils.trimToEmpty(item.getSubLabelFlag()))) { if (!"Y".equalsIgnoreCase(StringUtils.trimToEmpty(item.getSubLabelFlag()))) {
continue; continue;
} }
if (!StringUtils.equalsIgnoreCase(StringUtils.trimToEmpty(item.getParentLabelNo()), outerLabelNo)) { if (!StringUtils.equalsIgnoreCase(StringUtils.trimToEmpty(item.getParentLabelNo()), outerLabelNo)) {
continue; continue;
} }
boolean isInnerLabelType = "内箱标签".equals(StringUtils.trimToEmpty(item.getLabelType()));
String itemAddressNo = StringUtils.trimToNull(item.getAddressNo());
if (StringUtils.isNotBlank(addressNo)) {
if (StringUtils.equalsIgnoreCase(addressNo, itemAddressNo)) {
if (isInnerLabelType) {
exactInnerLabel = item;
break;
}
if (exactAnyLabel == null) {
exactAnyLabel = item;
}
continue;
}
if (StringUtils.isBlank(itemAddressNo)) {
if (isInnerLabelType && fallbackInnerLabel == null) {
fallbackInnerLabel = item;
}
if (fallbackAnyLabel == null) {
fallbackAnyLabel = item;
}
}
continue;
}
if (isInnerLabelType) {
exactInnerLabel = item;
break;
}
if (exactAnyLabel == null) {
exactAnyLabel = item;
}
return item.getLabelNo();
} }
CustomerLabelSettingData targetLabel = exactInnerLabel != null ? exactInnerLabel
: (exactAnyLabel != null ? exactAnyLabel
: (fallbackInnerLabel != null ? fallbackInnerLabel : fallbackAnyLabel));
return targetLabel != null ? targetLabel.getLabelNo() : null;
return null;
} catch (Exception e) { } catch (Exception e) {
log.warn("根据外箱标签解析内箱标签失败,customerId={}, outerLabelNo={}, error={}", log.warn("根据外箱标签解析内箱标签失败,customerId={}, outerLabelNo={}, error={}",
customerId, outerLabelNo, e.getMessage()); customerId, outerLabelNo, e.getMessage());

Loading…
Cancel
Save