From 4ca4444ad33a2a1a51f5c06e78ee9365dfb1eed6 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期四, 08 十月 2026 17:11:11 +0800
Subject: [PATCH] feat(mes): 种子二维码标签国标四要素合规改造
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/trace/MesProTracePublicServiceImpl.java | 63 +++++++++++++++++++++++++++----
1 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/trace/MesProTracePublicServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/trace/MesProTracePublicServiceImpl.java
index b19e03a..98da11f 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/trace/MesProTracePublicServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/trace/MesProTracePublicServiceImpl.java
@@ -6,6 +6,7 @@
import cn.iocoder.yudao.module.mes.controller.admin.wm.batch.vo.MesWmBatchProcessTraceRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.batch.vo.MesWmBatchPurchaseSourceRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.batch.vo.MesWmBatchSalesTargetRespVO;
+import cn.iocoder.yudao.module.mes.controller.pub.trace.vo.MesProTracePublicConfigRespVO;
import cn.iocoder.yudao.module.mes.controller.pub.trace.vo.MesProTracePublicRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.mdm.MesMdmItemDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.bagcode.MesProBagCodeDO;
@@ -18,6 +19,9 @@
import cn.iocoder.yudao.module.mes.enums.pro.MesProBagCodeStatusEnum;
import cn.iocoder.yudao.module.mes.enums.pro.MesProBatchStatusEnum;
import cn.iocoder.yudao.module.mes.enums.pro.MesProBatchWorkerTypeEnum;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProPalletStatusEnum;
+import cn.iocoder.yudao.module.mes.enums.trace.MesTraceCodeStatusEnum;
+import cn.iocoder.yudao.module.mes.framework.qrcode.MesProQrLabelBuilder;
import cn.iocoder.yudao.module.mes.service.mdm.MesMdmItemService;
import cn.iocoder.yudao.module.mes.service.pro.bagcode.MesProBagCodeService;
import cn.iocoder.yudao.module.mes.service.pro.batch.MesProBatchService;
@@ -112,8 +116,8 @@
if (entry.batchId == null && entry.bagItemId == null) {
throw exception(MES_TRACE_CODE_NOT_FOUND);
}
- // 2. 鑱氬悎鍏ㄧ▼淇℃伅
- MesProTracePublicRespVO result = buildRespVO(rawCode, traceCode, entry.sourceType, entry.batchId, entry.bagItemId);
+ // 2. 鑱氬悎鍏ㄧ▼淇℃伅锛堜綔搴熺爜浠嶆甯歌繑鍥炲苟璁板綍鎵爜锛氫綔搴熺爜琚壂鏄噸瑕佺殑闃蹭吉淇″彿锛屼笉搴旇涓烘煡璇㈠け璐ワ級
+ MesProTracePublicRespVO result = buildRespVO(rawCode, traceCode, entry);
recordConsumerScan(rawCode, traceCode, entry.sourceType, entry.batchId, true);
return result;
} catch (RuntimeException ex) {
@@ -121,6 +125,15 @@
entry == null ? null : entry.batchId, false);
throw ex;
}
+ }
+
+ @Override
+ public MesProTracePublicConfigRespVO getPublicConfig() {
+ MesProTracePublicConfigRespVO respVO = new MesProTracePublicConfigRespVO();
+ respVO.setOperatorName(MesProQrLabelBuilder.resolveOperatorName());
+ respVO.setTraceUrl(MesProQrLabelBuilder.resolveTraceUrl());
+ respVO.setImported(MesProQrLabelBuilder.isImported());
+ return respVO;
}
/**
@@ -173,7 +186,13 @@
// 鈶� 琚嬬爜
MesProBagCodeDO bag = bagCodeService.getBagCodeByCode(traceCode);
if (bag != null) {
- return new TraceEntry("BAG", bag.getBatchId(), bag.getItemId());
+ // 宸蹭綔搴熺殑琚嬬爜锛堢牬鎹熸浛鎹㈠悗浣滃簾锛夊繀椤诲澶栧け鏁堬細鍥芥爣瑕佹眰浜岀淮鐮佷笉寰楅噸澶嶄娇鐢紝
+ // 鑻ヤ綔搴熺爜浠嶈繑鍥炴湁鏁堟函婧愪俊鎭紝浣滃簾鐮佸嵆鍙鍐掔敤閿�鍞�
+ if (MesProBagCodeStatusEnum.CANCELED.getStatus().equals(bag.getStatus())) {
+ return new TraceEntry("BAG", bag.getBatchId(), bag.getItemId(),
+ MesTraceCodeStatusEnum.CANCELED.getStatus());
+ }
+ return TraceEntry.valid("BAG", bag.getBatchId(), bag.getItemId());
}
// 鈶� 鎵樼洏鐮�
MesProPalletDO pallet = palletService.getPalletByCode(traceCode);
@@ -181,19 +200,30 @@
// 鏈綍鍏ユ壒娆$殑鎵樼洏鍙栨墭鐩樺唴浠讳竴琚嬬爜鍝佺锛屼繚璇佷粛鑳藉睍绀哄搧绉嶄俊鎭�
Long itemId = pallet.getBatchId() == null
? firstItemId(bagCodeService.getBagCodeListByPalletId(pallet.getId())) : null;
- return new TraceEntry("PALLET", pallet.getBatchId(), itemId);
+ if (MesProPalletStatusEnum.CANCELED.getStatus().equals(pallet.getStatus())) {
+ return new TraceEntry("PALLET", pallet.getBatchId(), itemId,
+ MesTraceCodeStatusEnum.CANCELED.getStatus());
+ }
+ return TraceEntry.valid("PALLET", pallet.getBatchId(), itemId);
}
// 鈶� 鎵规鐮侊紙鍚复鏃舵壒娆$爜锛実etBatchByCode 鍐呴儴鍏煎锛�
MesProBatchDO batch = batchService.getBatchByCode(traceCode);
if (batch != null) {
- return new TraceEntry("BATCH", batch.getId(), null);
+ if (MesProBatchStatusEnum.CANCELED.getStatus().equals(batch.getStatus())) {
+ return new TraceEntry("BATCH", batch.getId(), null,
+ MesTraceCodeStatusEnum.CANCELED.getStatus());
+ }
+ return TraceEntry.valid("BATCH", batch.getId(), null);
}
- return new TraceEntry("", null, null);
+ return new TraceEntry("", null, null, MesTraceCodeStatusEnum.VALID.getStatus());
}
// ==================== 鑱氬悎鏋勫缓 ====================
- private MesProTracePublicRespVO buildRespVO(String requestCode, String traceCode, String sourceType, Long batchId, Long bagItemId) {
+ private MesProTracePublicRespVO buildRespVO(String requestCode, String traceCode, TraceEntry entry) {
+ String sourceType = entry.sourceType();
+ Long batchId = entry.batchId();
+ Long bagItemId = entry.bagItemId();
MesProBatchDO batch = batchId == null ? null : batchService.getBatch(batchId);
if (batchId != null && batch == null) {
throw exception(MES_TRACE_CODE_NOT_FOUND);
@@ -201,6 +231,10 @@
MesProTracePublicRespVO resp = new MesProTracePublicRespVO();
resp.setSourceType(sourceType);
resp.setRequestCode(requestCode);
+ // 杩芥函鐮佹湁鏁堟�� + 鏍囩鍥涜绱犱腑鐨勭敓浜х粡钀ヨ�呬笌杩芥函缃戝潃锛屼繚璇佷笌鏍囩鍗板埛鍐呭涓�鑷�
+ resp.setCodeStatus(entry.codeStatus());
+ resp.setOperatorName(MesProQrLabelBuilder.resolveOperatorName());
+ resp.setTraceUrl(MesProQrLabelBuilder.resolveTraceUrl());
// 鍝佺鍖哄潡
fillItem(resp, batch, bagItemId);
if (batch == null) {
@@ -505,7 +539,20 @@
};
}
- private record TraceEntry(String sourceType, Long batchId, Long bagItemId) {
+ /**
+ * 杩芥函鍏ュ彛瑙f瀽缁撴灉
+ *
+ * @param sourceType 鍏ュ彛绫诲瀷锛欱AG / PALLET / BATCH锛屾湭鍖归厤鍒版椂涓虹┖涓�
+ * @param batchId 鐢熶骇鎵规缂栧彿
+ * @param bagItemId 琚嬬爜缁戝畾鐨勫搧绉嶇紪鍙凤紙鏈綍鎵规鏃剁敤浜庡睍绀哄搧绉嶏級
+ * @param codeStatus 杩芥函鐮佹湁鏁堟�э細{@link MesTraceCodeStatusEnum#VALID} / {@link MesTraceCodeStatusEnum#CANCELED}
+ */
+ private record TraceEntry(String sourceType, Long batchId, Long bagItemId, String codeStatus) {
+
+ static TraceEntry valid(String sourceType, Long batchId, Long bagItemId) {
+ return new TraceEntry(sourceType, batchId, bagItemId, MesTraceCodeStatusEnum.VALID.getStatus());
+ }
+
}
}
--
Gitblit v1.9.3