From dadf6427874eed4fe6becf4be3a28a64cbb3fb5f Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Fri, 16 Jan 2026 15:43:30 +0800
Subject: [PATCH] 1. 增加精细化巡检分组业务优化。

---
 ard-inspection/src/main/java/com/ard/inspection/service/impl/ArdInspectionGroupServiceImpl.java |    4 +-
 ard-admin/src/main/java/com/ard/web/controller/inspection/ArdInspectionGroupController.java     |   28 +++----------
 ard-inspection/src/main/resources/mapper/ArdInspectionGroupMapper.xml                           |   43 ++++++++++++++++-----
 3 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/ard-admin/src/main/java/com/ard/web/controller/inspection/ArdInspectionGroupController.java b/ard-admin/src/main/java/com/ard/web/controller/inspection/ArdInspectionGroupController.java
index f001c77..06b8006 100644
--- a/ard-admin/src/main/java/com/ard/web/controller/inspection/ArdInspectionGroupController.java
+++ b/ard-admin/src/main/java/com/ard/web/controller/inspection/ArdInspectionGroupController.java
@@ -44,23 +44,9 @@
     @ApiOperation("查询精细化巡检分组列表")
     @PreAuthorize("@ss.hasPermi('inspection:group:list')")
     @GetMapping("/list")
-    public TableDataInfo list(ArdInspectionGroup ardInspectionGroup) {
-        startPage();
+    public AjaxResult list(ArdInspectionGroup ardInspectionGroup) {
         List<ArdInspectionGroup> list = ardInspectionGroupService.selectArdInspectionGroupList(ardInspectionGroup);
-        return getDataTable(list);
-    }
-
-    /**
-     * 导出精细化巡检分组列表
-     */
-    @ApiOperation("导出精细化巡检分组列表")
-    @PreAuthorize("@ss.hasPermi('inspection:group:export')")
-    @Log(title = "精细化巡检分组", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, ArdInspectionGroup ardInspectionGroup) {
-        List<ArdInspectionGroup> list = ardInspectionGroupService.selectArdInspectionGroupList(ardInspectionGroup);
-        ExcelUtil<ArdInspectionGroup> util = new ExcelUtil<ArdInspectionGroup>(ArdInspectionGroup.class);
-        util.exportExcel(response, list, "精细化巡检分组数据");
+        return success(list);
     }
 
     /**
@@ -70,7 +56,7 @@
     @PreAuthorize("@ss.hasPermi('inspection:group:query')")
     @GetMapping(value = "/{groupId}")
     public AjaxResult getInfo(@PathVariable("groupId") Long groupId) {
-        ardInspectionGroupService.checkInspectionGroupDataScope(groupId);
+        //ardInspectionGroupService.checkInspectionGroupDataScope(groupId);
         return success(ardInspectionGroupService.selectArdInspectionGroupByGroupId(groupId));
     }
 
@@ -119,10 +105,10 @@
         if (ardInspectionGroupService.hasChildByInspectionGroupId(groupId)){
             return warn("存在下级分组,不允许删除");
         }
-        if (ardInspectionGroupService.checkInspectionGroupExistUser(groupId)){
-            return warn("分组存在用户,不允许删除");
-        }
-        ardInspectionGroupService.checkInspectionGroupDataScope(groupId);
+        //if (ardInspectionGroupService.checkInspectionGroupExistUser(groupId)){
+        //    return warn("分组存在用户,不允许删除");
+        //}
+        //ardInspectionGroupService.checkInspectionGroupDataScope(groupId);
         return toAjax(ardInspectionGroupService.deleteArdInspectionGroupByGroupId(groupId));
     }
 
diff --git a/ard-inspection/src/main/java/com/ard/inspection/service/impl/ArdInspectionGroupServiceImpl.java b/ard-inspection/src/main/java/com/ard/inspection/service/impl/ArdInspectionGroupServiceImpl.java
index bc2002b..bd73c0c 100644
--- a/ard-inspection/src/main/java/com/ard/inspection/service/impl/ArdInspectionGroupServiceImpl.java
+++ b/ard-inspection/src/main/java/com/ard/inspection/service/impl/ArdInspectionGroupServiceImpl.java
@@ -46,7 +46,6 @@
      * @return 精细化巡检分组
      */
     @Override
-    @DataScope(deptAlias = "d")
     public List<ArdInspectionGroup> selectArdInspectionGroupList(ArdInspectionGroup ardInspectionGroup) {
         return ardInspectionGroupMapper.selectArdInspectionGroupList(ardInspectionGroup);
     }
@@ -59,6 +58,8 @@
      */
     @Override
     public int insertArdInspectionGroup(ArdInspectionGroup ardInspectionGroup) {
+        ArdInspectionGroup inspectionGroup = ardInspectionGroupMapper.selectArdInspectionGroupByGroupId(ardInspectionGroup.getGroupParentId());
+        ardInspectionGroup.setAncestors(inspectionGroup.getAncestors() + "," + ardInspectionGroup.getGroupParentId());
         ardInspectionGroup.setCreateTime(DateUtils.getNowDate());
         return ardInspectionGroupMapper.insertArdInspectionGroup(ardInspectionGroup);
     }
@@ -71,7 +72,6 @@
      */
     @Override
     public int updateArdInspectionGroup(ArdInspectionGroup ardInspectionGroup) {
-
         ArdInspectionGroup newGroup = ardInspectionGroupMapper.selectArdInspectionGroupByGroupId(ardInspectionGroup.getGroupParentId());
         ArdInspectionGroup oldGroup = ardInspectionGroupMapper.selectArdInspectionGroupByGroupId(ardInspectionGroup.getGroupId());
         if(StringUtils.isNotNull(newGroup) && StringUtils.isNotNull(oldGroup)){
diff --git a/ard-inspection/src/main/resources/mapper/ArdInspectionGroupMapper.xml b/ard-inspection/src/main/resources/mapper/ArdInspectionGroupMapper.xml
index 754ef85..a2b0da0 100644
--- a/ard-inspection/src/main/resources/mapper/ArdInspectionGroupMapper.xml
+++ b/ard-inspection/src/main/resources/mapper/ArdInspectionGroupMapper.xml
@@ -14,6 +14,7 @@
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="parentName" column="parent_name" />
     </resultMap>
 
     <sql id="selectArdInspectionGroupVo">
@@ -31,22 +32,44 @@
 
     <select id="selectArdInspectionGroupList" parameterType="ArdInspectionGroup" resultMap="ArdInspectionGroupResult">
         <include refid="selectArdInspectionGroupVo"/>
-        <where>  
-            <if test="groupParentId != null "> and group_parent_id = #{groupParentId}</if>
-            <if test="ancestors != null  and ancestors != ''"> and ancestors = #{ancestors}</if>
-            <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
-            <if test="orderNum != null "> and order_num = #{orderNum}</if>
+        <where>
+            <if test="groupId != null ">
+                and group_id = #{groupId}
+            </if>
+            <if test="groupParentId != null ">
+                and group_parent_id = #{groupParentId}
+            </if>
+            <if test="ancestors != null  and ancestors != ''">
+                and ancestors = #{ancestors}
+            </if>
+            <if test="groupName != null  and groupName != ''">
+                and group_name like concat('%', #{groupName}, '%')
+            </if>
+            <if test="orderNum != null ">
+                and order_num = #{orderNum}
+            </if>
         </where>
+        order by group_parent_id, order_num
     </select>
     
     <select id="selectArdInspectionGroupByGroupId" parameterType="Long" resultMap="ArdInspectionGroupResult">
-        <include refid="selectArdInspectionGroupVo"/>
-        where group_id = #{groupId}
+        SELECT
+            g.group_id,
+            g.group_parent_id,
+            g.ancestors,
+            g.group_name,
+            g.order_num,
+            ( SELECT group_name FROM ard_inspection_group WHERE group_id = g.group_parent_id) parent_name
+        FROM
+            ard_inspection_group g
+        WHERE
+            g.group_id = #{groupId}
     </select>
 
-    <insert id="insertArdInspectionGroup" parameterType="ArdInspectionGroup" useGeneratedKeys="true" keyProperty="groupId">
+    <insert id="insertArdInspectionGroup" parameterType="ArdInspectionGroup">
         insert into ard_inspection_group
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="groupId != null">group_id,</if>
             <if test="groupParentId != null">group_parent_id,</if>
             <if test="ancestors != null">ancestors,</if>
             <if test="groupName != null">group_name,</if>
@@ -57,6 +80,7 @@
             <if test="updateTime != null">update_time,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="groupId != null">#{groupId},</if>
             <if test="groupParentId != null">#{groupParentId},</if>
             <if test="ancestors != null">#{ancestors},</if>
             <if test="groupName != null">#{groupName},</if>
@@ -97,8 +121,7 @@
     <select id="checkInspectionGroupNameUnique" resultMap="ArdInspectionGroupResult">
         <include refid="selectArdInspectionGroupVo"/>
         where group_name=#{groupName}
-        and group_parent_id = #{groupParentId}
-        and del_flag = '0' limit 1
+        and group_parent_id = #{groupParentId} limit 1
     </select>
 
     <select id="selectChildrenInspectionGroupById" parameterType="Long" resultMap="ArdInspectionGroupResult">

--
Gitblit v1.9.3