Browse Source

项目汇总导出搜索框

Wayne 3 months ago
parent
commit
779c605dd0

+ 1 - 1
projects-service/src/main/java/com/rtrh/projects/modules/projects/mapper/SubInfoMapper.java

@@ -57,7 +57,7 @@ public interface SubInfoMapper {
     @Update("update sub_fix set cat = #{fixCat} where sub_id = #{subInfoId} and cat = #{oldCat}")
     void updateFixeCat(@Param("subInfoId") String subInfoId, @Param("fixCat") String fixCat, @Param("oldCat") String oldCat);
 
-    List<SubInfoTotalExcel> getFixTotalExcel(@Param("stateFix") String stateFix,@Param("year") String year);
+    List<SubInfoTotalExcel> getFixTotalExcel(@Param("stateFix") String stateFix,@Param("year") String year,@Param("subName") String subName, @Param("indusKinds") List<String> indusKinds, @Param("sbdw") String sbdw, @Param("subjectId") String subjectId, @Param("startAmt") String startAmt, @Param("endAmt") String endAmt);
 
     List<SubInfoTotalExcel> exportTotalExcelByStatus(@Param("status") String status);
 

+ 21 - 0
projects-service/src/main/java/com/rtrh/projects/modules/projects/mapper/SubInfoMapper.xml

@@ -401,6 +401,27 @@
         FROM sub_fix
         LEFT JOIN sub_info ON sub_fix.sub_id = sub_info.id
         WHERE sub_fix.cat = #{stateFix} and sub_fix.year = #{year} and sub_info.logic_delete_flag = 0
+        <if test="subName != null and subName != ''">
+            AND sub_info.sub_name LIKE CONCAT('%', #{subName}, '%')
+        </if>
+        <if test="subjectId != null and subjectId != ''">
+            AND sub_info.subject_id = #{subjectId}
+        </if>
+        <if test="indusKinds != null and indusKinds.size() &gt; 0">
+            AND sub_info.indus_kind IN
+            <foreach collection="indusKinds" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="sbdw != null and sbdw != ''">
+            AND sub_info.unit_desc LIKE CONCAT('%', #{sbdw}, '%')
+        </if>
+        <if test="startAmt != null and startAmt !=''">
+            AND sub_info.amt_total &gt;= #{startAmt}
+        </if>
+        <if test="endAmt != null and endAmt != ''">
+            AND sub_info.amt_total &lt;= #{endAmt}
+        </if>
     </select>
     <select id="exportTotalExcelByStatus" resultType="com.rtrh.projects.modules.projects.vo.SubInfoTotalExcel">
         SELECT sub_info.subject_id as subjectId,

+ 22 - 1
projects-service/src/main/java/com/rtrh/projects/modules/projects/service/impl/SubInfoServiceImpl.java

@@ -4760,8 +4760,29 @@ public class SubInfoServiceImpl implements SubInfoService {
     @Override
     public List<SubInfoTotalExcel> getFixTotalExcel(SubInfoQueryTzVO vo) {
 
+        //查询出行业分类
+        List<SubIndu> subInduList = subInduService.selectAllSubIndu();
+
+        //保存行业code
+        List<String> indusKinds = new ArrayList<>();
+        //判断搜索条件中是否有行业分类条件
+        if (StringUtils.isNotBlank(vo.getIndusKind())) {
+            //在subInduList中找到code=queryVO.getIndusKinds()的数据
+            SubIndu subIndu = subInduList.stream().filter(item -> item.getCode().equals(vo.getIndusKind())).findFirst().orElse(null);
+
+            if (subIndu != null){
+                //判断这个行业是不是上级行业
+                if (StringUtils.isBlank(subIndu.getLastId())){
+                    // 这个行业是上级行业,需要找到所有下级行业的code
+                    indusKinds = subInduList.stream().filter(item -> item.getLastId() != null && item.getLastId().equals(subIndu.getId())).map(SubIndu::getCode).collect(Collectors.toList());
+                }else {
+                    indusKinds.add(subIndu.getCode());
+                }
+            }
+        }
+
         // 查询具体的sql数据
-        List<SubInfoTotalExcel> dataList =  subInfoMapper.getFixTotalExcel(vo.getStateFix(),vo.getYear());
+        List<SubInfoTotalExcel> dataList =  subInfoMapper.getFixTotalExcel(vo.getStateFix(),vo.getYear(),vo.getSubName(),indusKinds,vo.getSbdw(),vo.getSubjectId(),vo.getStartAmt(),vo.getEndAmt());
 
         return dataList;
     }

+ 10 - 8
projects/src/main/java/com/rtrh/projects/web/controller/subject/SubInfoExportController.java

@@ -787,15 +787,17 @@ public class SubInfoExportController extends BaseController {
 
                 for (Map.Entry<String, List<List<String>>> dataListEntry : finalDataMap.entrySet()) {
                     List<List<String>> dataList = dataListEntry.getValue();
-                    int dataSize = dataList.size();
-                    if (dataSize == 1) {
-                        indexStart += dataSize;
-                    } else {
-                        writer.merge(indexStart, indexStart + dataSize - 1, 0, 0, null, true);
-                        indexStart += dataSize;
+                    if (dataList != null && dataList.size() > 0){
+                        int dataSize = dataList.size();
+                        if (dataSize == 1) {
+                            indexStart += dataSize;
+                        } else {
+                            writer.merge(indexStart, indexStart + dataSize - 1, 0, 0, null, true);
+                            indexStart += dataSize;
+                        }
+                        //18.保存数据
+                        finalDataRows.addAll(dataList);
                     }
-                    //18.保存数据
-                    finalDataRows.addAll(dataList);
                 }
                 writer.write(finalDataRows, true);