From b29d86d9ed34fd890eb14cb7a75f6ae4f7148865 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 01 九月 2026 13:58:03 +0800
Subject: [PATCH] feat(mes): 新增防伪防窜货功能模块

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/pallet/MesProPalletMapper.java |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/pallet/MesProPalletMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/pallet/MesProPalletMapper.java
index b2b6512..cbbda3f 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/pallet/MesProPalletMapper.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/pallet/MesProPalletMapper.java
@@ -23,6 +23,18 @@
         return selectOne(MesProPalletDO::getCode, code);
     }
 
+    default MesProPalletDO selectByTempCode(String tempCode) {
+        return selectOne(MesProPalletDO::getTempCode, tempCode);
+    }
+
+    /** 鐢熸垚涓存椂鎵樼洏鐮佺敤鐨勫叏灞�搴忓彿锛氳В鏋� temp_code 鐨勬暟瀛楀悗缂�锛屼笉瀛樺湪鍒欒繑鍥� 0銆�
+     *  涓嶈兘杩囨护 deleted锛屽敮涓�绱㈠紩 uk_temp_code 瀵归�昏緫鍒犻櫎琛屼粛鐢熸晥锛屽拷鐣ヨ蒋鍒犱細瀵艰嚧搴忓彿鍥為��銆佺爜鍊奸噸澶� */
+    @Select("SELECT IFNULL(MAX(CAST(SUBSTRING(temp_code, 4) AS UNSIGNED)), 0) FROM mes_pro_pallet")
+    Integer selectMaxTempCodeSeq();
+
+    @Select("SELECT * FROM mes_pro_pallet WHERE id = #{id} AND deleted = 0 FOR UPDATE")
+    MesProPalletDO selectByIdForUpdate(@Param("id") Long id);
+
     default List<MesProPalletDO> selectListByBatchId(Long batchId) {
         return selectList(MesProPalletDO::getBatchId, batchId);
     }
@@ -30,6 +42,7 @@
     default PageResult<MesProPalletDO> selectPage(MesProPalletPageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<MesProPalletDO>()
                 .likeIfPresent(MesProPalletDO::getCode, reqVO.getCode())
+                .likeIfPresent(MesProPalletDO::getTempCode, reqVO.getTempCode())
                 .eqIfPresent(MesProPalletDO::getBatchId, reqVO.getBatchId())
                 .likeIfPresent(MesProPalletDO::getBatchCode, reqVO.getBatchCode())
                 .eqIfPresent(MesProPalletDO::getStatus, reqVO.getStatus())
@@ -46,4 +59,13 @@
     @Select("SELECT IFNULL(MAX(pallet_no), 0) FROM mes_pro_pallet WHERE batch_id = #{batchId}")
     Integer selectMaxPalletNo(@Param("batchId") Long batchId);
 
+    @org.apache.ibatis.annotations.Update("UPDATE mes_pro_pallet SET sales_id = #{salesId}, outbound_time = #{outboundTime}, update_time = NOW() "
+            + "WHERE id = #{id} AND deleted = 0")
+    void markOutbound(@Param("id") Long id, @Param("salesId") Long salesId,
+                      @Param("outboundTime") java.time.LocalDateTime outboundTime);
+
+    @org.apache.ibatis.annotations.Update("UPDATE mes_pro_pallet SET sales_id = NULL, outbound_time = NULL, update_time = NOW() "
+            + "WHERE id = #{id} AND deleted = 0")
+    void clearOutbound(@Param("id") Long id);
+
 }

--
Gitblit v1.9.3