فهرست منبع

后管项目列表搜索和清表搜索优化

lvy 3 روز پیش
والد
کامیت
1269066fd2

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ExcelTabMapper.java

@@ -81,7 +81,7 @@ public interface ExcelTabMapper extends BaseMapper<ExcelTab> {
 
     List<WbsFormElement> getUnMatchField(@Param("tabId") Long tabId, @Param("set") Set<String> set);
 
-    List<ExcelTabVO> selectRootExcelTab(IPage<ExcelTabVO> page, @Param("projectId") Long projectId,@Param("rootIds") Collection<Long> rootIds);
+    List<ExcelTabVO> selectRootExcelTab(IPage<ExcelTabVO> page, @Param("vo") ExcelTabVO vo,@Param("rootIds") Collection<Long> rootIds);
 
     List<ExcelTabVO> getByIds(Collection<Long> ids);
 }

+ 57 - 22
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ExcelTabMapper.xml

@@ -207,12 +207,12 @@
         <if test="excelTab.name!=null and excelTab.name!=''">
             AND x.name like concat(concat('%', #{excelTab.name}),'%')
         </if>
-        <if test="param2.parentId == null or param2.parentId == 0">
-            <if test="param2.tabType != null">
-                AND x.tab_type = #{param2.tabType}
+        <if test="excelTab.parentId == null or excelTab.parentId == 0">
+            <if test="excelTab.tabType != null">
+                AND x.tab_type = #{excelTab.tabType}
             </if>
             <if test="param2.tableTemplateType != null">
-                AND x.table_template_type = #{param2.tableTemplateType}
+                AND x.table_template_type = #{excelTab.tableTemplateType}
             </if>
         </if>
         order by x.sort
@@ -229,32 +229,67 @@
             #{item}
         </foreach>
     </select>
+<!--    <select id="selectRootExcelTab" resultType="org.springblade.manager.vo.ExcelTabVO">-->
+<!--        SELECT-->
+<!--        t.project_id as projectId,-->
+<!--        p.project_name as projectName,-->
+<!--        t.root_id as id-->
+<!--        FROM (-->
+<!--        SELECT-->
+<!--        project_id,-->
+<!--        SUBSTRING_INDEX(alias, ',', 1) as root_id-->
+<!--        FROM m_wbs_tree_private a-->
+<!--        LEFT JOIN m_excel_tab b ON a.excel_id = b.id-->
+<!--        WHERE a.type = 2-->
+<!--        AND a.is_deleted = 0-->
+<!--        AND a.excel_id IS NOT NULL-->
+<!--        <if test="vo != null ">-->
+<!--          <if test="vo.projectId != null">-->
+<!--              AND a.project_id = #{vo.projectId}-->
+<!--          </if>-->
+<!--        </if>-->
+<!--        GROUP BY project_id, root_id-->
+<!--        <if test="rootIds != null and rootIds.size() > 0">-->
+<!--            HAVING root_id IN-->
+<!--            <foreach collection="rootIds" item="item" open="(" separator="," close=")">-->
+<!--                #{item}-->
+<!--            </foreach>-->
+<!--        </if>-->
+<!--        ) t-->
+<!--        INNER JOIN m_project_info p ON p.id = t.project_id where project_id is not null-->
+<!--    </select>-->
     <select id="selectRootExcelTab" resultType="org.springblade.manager.vo.ExcelTabVO">
-        SELECT
-        t.project_id as projectId,
-        p.project_name as projectName,
-        t.root_id as id
-        FROM (
-        SELECT
-        project_id,
-        SUBSTRING_INDEX(alias, ',', 1) as root_id
+        SELECT distinct
+        a.project_id as projectId,
+        b.project_name as projectName,
+        d.id as id
         FROM m_wbs_tree_private a
-        LEFT JOIN m_excel_tab b ON a.excel_id = b.id
-        WHERE a.type = 2
-        AND a.is_deleted = 0
-        AND a.excel_id IS NOT NULL
-        <if test="projectId != null and projectId > 0">
-            AND project_id = #{projectId}
+        inner join m_project_info b on b.id = a.project_id
+        inner join m_excel_tab c on c.id = a.excel_id
+        inner join m_excel_tab d on d.id = SUBSTRING_INDEX(c.alias, ',', 1)
+        WHERE a.type = 2 AND a.is_deleted = 0 AND a.excel_id IS NOT NULL
+        <if test="vo != null ">
+            <if test="vo.projectId != null">
+                AND a.project_id = #{vo.projectId}
+            </if>
+            <if test="vo.name!=null and vo.name!=''">
+                AND d.name like concat(concat('%', #{vo.name}),'%')
+            </if>
+            <if test="vo.parentId == null or vo.parentId == 0">
+                <if test="vo.tabType != null">
+                    AND d.tab_type = #{vo.tabType}
+                </if>
+                <if test="vo.tableTemplateType != null">
+                    AND d.table_template_type = #{vo.tableTemplateType}
+                </if>
+            </if>
         </if>
-        GROUP BY project_id, root_id
         <if test="rootIds != null and rootIds.size() > 0">
-            HAVING root_id IN
+            and d.id IN
             <foreach collection="rootIds" item="item" open="(" separator="," close=")">
                 #{item}
             </foreach>
         </if>
-        ) t
-        INNER JOIN m_project_info p ON p.id = t.project_id where project_id is not null
     </select>
     <select id="getByIds" resultType="org.springblade.manager.vo.ExcelTabVO">
         select *, (select name from blade_user where id = a.create_user) as createUserName, (SELECT bdb.dict_value from blade_dict_biz bdb WHERE code = 'table_template_type' AND dict_key = a.table_template_type) as tableTemplateTypeName

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -151,7 +151,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     @Override
     public IPage<ExcelTabVO> selectExcelTabPage(IPage<ExcelTabVO> page, ExcelTabVO excelTab) {
         if (excelTab.getProjectId() != null && excelTab.getProjectId() > 0 && (excelTab.getParentId() == null || excelTab.getParentId() == 0)) {
-            List<ExcelTabVO> records  = baseMapper.selectRootExcelTab(page, excelTab.getProjectId(), null);
+            List<ExcelTabVO> records  = baseMapper.selectRootExcelTab(page, excelTab, null);
             if (!records.isEmpty()) {
                 List<Long> ids = records.stream().map(ExcelTabVO::getId).collect(Collectors.toList());
                 List<ExcelTabVO> excelTabs = this.baseMapper.getByIds(ids);

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsInfoServiceImpl.java

@@ -36,7 +36,7 @@ public class WbsInfoServiceImpl extends BaseServiceImpl<WbsInfoMapper, WbsInfo>
         Set<Long> wbsIds = new HashSet<>();
         if (StringUtil.hasText(wbsInfo.getProjectName()) || wbsInfo.getProjectId() != null) {
             List<ProjectInfo> projectInfoList;
-            if (wbsInfo.getProjectId() != null) {
+            if (wbsInfo.getProjectId() != null && StringUtil.isNumeric(wbsInfo.getProjectId())) {
                 projectInfoList = jdbcTemplate.query("select * from m_project_info where id = " + wbsInfo.getProjectId(), new BeanPropertyRowMapper<>(ProjectInfo.class));
             } else {
                 projectInfoList = jdbcTemplate.query("select * from m_project_info where project_name like '%" + wbsInfo.getProjectName() + "%'", new BeanPropertyRowMapper<>(ProjectInfo.class));