From 6b8585fc452ecdcaa82d86fab79a9f27bb442851 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 十一月 2026 09:13:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_南通_苏珩' into dev_南通_苏珩

---
 yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java
index 04edd6b..dcebb8a 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/dal/mysql/item/MdmItemMapper.java
@@ -6,17 +6,22 @@
 import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemPageReqVO;
 import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemDO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * MDM 鐗╂枡涓绘暟鎹� Mapper
  *
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
  */
 @Mapper
 public interface MdmItemMapper extends BaseMapperX<MdmItemDO> {
+
+    @org.apache.ibatis.annotations.Select("SELECT COALESCE(MAX(CAST(SUBSTRING(code, 5) AS UNSIGNED)), 0) FROM mdm_item WHERE deleted = 0 AND code LIKE CONCAT(#{prefix}, '%')")
+    Integer selectMaxSequenceByPrefix(@Param("prefix") String prefix);
 
     default PageResult<MdmItemDO> selectPage(MdmItemPageReqVO reqVO, Collection<Long> categoryIds) {
         return selectPage(reqVO, new LambdaQueryWrapperX<MdmItemDO>()
@@ -28,7 +33,8 @@
                 .eqIfPresent(MdmItemDO::getBrandId, reqVO.getBrandId())
                 .eqIfPresent(MdmItemDO::getStatus, reqVO.getStatus())
                 .betweenIfPresent(MdmItemDO::getCreateTime, reqVO.getCreateTime())
-                .orderByDesc(MdmItemDO::getId));
+                // 鍒楄〃鎸夌墿鏂欑紪鐮佹帓搴忥紙鍘熸潵鍏堟寜鐗╂枡鍒嗙被鍒嗙粍鍐嶆寜缂栫爜锛屽悓涓�鍒嗙被鐨勭墿鏂欐墠鎺掑湪涓�璧凤紝璺ㄥ垎绫荤湅缂栫爜鏄贡搴忕殑锛�
+                .orderByAsc(MdmItemDO::getCode));
     }
 
     default List<MdmItemDO> selectList(MdmItemPageReqVO reqVO, Collection<Long> categoryIds) {
@@ -43,6 +49,10 @@
 
     default MdmItemDO selectByCode(String code) {
         return selectOne(MdmItemDO::getCode, code);
+    }
+
+    default List<MdmItemDO> selectListByCode(String code) {
+        return selectList(MdmItemDO::getCode, code);
     }
 
     /**
@@ -81,4 +91,12 @@
         return selectList(MdmItemDO::getId, ids);
     }
 
-}
\ No newline at end of file
+    /**
+     * 鏌ヨ鐗╂枡琚摢浜涗笟鍔¤〃寮曠敤锛堟湭鍒犻櫎鐨勮褰曪級
+     *
+     * @param itemId 鐗╂枡缂栧彿
+     * @return 寮曠敤鏉ユ簮鍒楄〃锛屾瘡椤瑰寘鍚� source(鏉ユ簮鍚�) 鍜� cnt(寮曠敤鏁伴噺)锛屼粎杩斿洖 cnt > 0 鐨�
+     */
+    List<Map<String, Object>> selectItemReferenceCount(@Param("itemId") Long itemId);
+
+}

--
Gitblit v1.9.3