Преглед на файлове

项目信息申报及前期手续办理情况只查询前期手续相关内容--修改SQL

Wayne преди 4 месеца
родител
ревизия
13f730d01a

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

@@ -25,4 +25,7 @@ public interface SubInfoMapper {
 
     @Select("SELECT count(1) FROM sub_pre_new WHERE DATE_ADD(date_plan, INTERVAL IFNULL(num2, 1) - 1 DAY) <= CURDATE() and sub_id = #{subId} and status = #{status} and status_conf = #{statusConf} and logic_delete_flag = #{logicDeleteFlag}")
     Integer selectSubPreNewYellow(@Param("subId") String subId, @Param("status") String status, @Param("statusConf") String statusConf, @Param("logicDeleteFlag") String logicDeleteFlag);
+
+    @Select("SELECT sub_id FROM sub_info where logic_delete_flag = 0 ")
+    List<String> selectAllSubInfoIds();
 }

+ 9 - 7
projects-service/src/main/java/com/rtrh/projects/modules/projects/service/SubInfoService.java

@@ -48,7 +48,7 @@ public interface SubInfoService {
 
 
 	Page pageQueryReportListSql(Page page,LoginUserVO loginUserVO, String subName, String unitId,String kind, String status, String statusSp,
-			String propKind, String indusKind, Date beginDate, Date endDate);
+			String propKind, String indusKind, Date beginDate, Date endDate, List<String> subInfoIds);
 
 
 
@@ -372,18 +372,18 @@ public interface SubInfoService {
 
     void saveOrUpateYgdz(SubMajorDataVO po, LoginUserVO loginUser);
 
-    Page pageQueryRreDepartment(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception;
+    Page pageQueryRreDepartment(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception;
 
-	Page pageQueryRreFile(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception;
+	Page pageQueryRreFile(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception;
 
 
-	Page pageQueryRreProject(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception;
+	Page pageQueryRreProject(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception;
 
-	Object sumDepartment(SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception;
+	Object sumDepartment(SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception;
 
-	Object sumFile(SubinfoPreQueryVo queryVO, LoginUserVO loginUser)  throws Exception;
+	Object sumFile(SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds)  throws Exception;
 
-	Object sumProject(SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception;
+	Object sumProject(SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception;
 
     void saveEditFundDetail(EditSubInfoDataVO vo, LoginUserVO loginUser);
 
@@ -395,4 +395,6 @@ public interface SubInfoService {
 	List<SubLabel> getSubLabels(SubLabelAddVO vo);
 
 	void addLabelS(SubLabelAddVO vo, List list);
+
+	List<String> selectAllSubInfoIds();
 }

+ 81 - 26
projects-service/src/main/java/com/rtrh/projects/modules/projects/service/impl/SubInfoServiceImpl.java

@@ -20,6 +20,7 @@ import com.rtrh.projects.modules.rolemeun.po.SecRole;
 import com.rtrh.projects.modules.system.dao.TSystableDao;
 import com.rtrh.projects.modules.system.po.*;
 import com.rtrh.projects.modules.utils.DateUtils;
+import com.rtrh.projects.util.TargetDataSource;
 import com.rtrh.projects.vo.SubIdVO;
 import com.rtrh.projects.vo.subject.SubinfoPreQueryVo;
 import org.apache.commons.lang3.StringUtils;
@@ -1024,7 +1025,7 @@ public class SubInfoServiceImpl implements SubInfoService {
 
     @Override
     public Page pageQueryReportListSql(Page page, LoginUserVO loginUserVO, String subName, String unitId, String kind, String status, String statusSp,
-                                       String propKind, String indusKind, Date beginDate, Date endDate) {
+                                       String propKind, String indusKind, Date beginDate, Date endDate, List<String> subInfoIds) {
 
         StringBuffer sql = new StringBuffer();
         sql.append(" select a.id,a.status ,a.sub_name subName,a.amt_total amtTotal,a.begin_date beginDate,a.end_date endDate,ju.title unitName,ts.title subjectName, ts1.title indusKindName   ");
@@ -1038,6 +1039,17 @@ public class SubInfoServiceImpl implements SubInfoService {
 
         sql.append(" where a.logic_delete_flag =0 ");
 
+        // 处理 subInfoIds 参数
+        if (subInfoIds != null && !subInfoIds.isEmpty()) {
+            String idListStr = subInfoIds.stream()
+                    .map(id -> "'" + id + "'") // 每个 ID 加单引号
+                    .collect(Collectors.joining(","));
+            sql.append(" and a.id in (").append(idListStr).append(") ");
+        }else {
+            sql.append(" and a.id in ( ) ");
+        }
+
+
 
         //2024-03-28客户提出admin用户需查询和储备台账一样的数据
         SecRole role = secRoleDao.findById(loginUserVO.getKind());
@@ -3090,7 +3102,12 @@ public class SubInfoServiceImpl implements SubInfoService {
     }
 
     @Override
-    public Page pageQueryRreDepartment(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception {
+    public Page pageQueryRreDepartment(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception {
+
+        // 将 List 转换为 SQL 中的 IN 语句---只查询工信局项目库中的数据
+        String subIdFilter = subInfoIds.stream()
+                .map(id -> "'" + id + "'") // 每个 id 加上单引号
+                .collect(Collectors.joining(", ")); // 逗号拼接
 
         if (StringUtil.isEmpty(queryVO.getBeginDate())) {
             queryVO.setBeginDate("200001");  //默认设置一个开始时间
@@ -3181,7 +3198,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\tWHERE\n" +
                 "\t\to.`status` =1 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.status_conf !=3 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
@@ -3207,7 +3224,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >= 1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getTBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getTEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3240,7 +3257,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\t\tAND o.status_conf >= 1 \n" +
                 "\t\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3267,7 +3284,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getHBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getHEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3320,7 +3337,12 @@ public class SubInfoServiceImpl implements SubInfoService {
 
 
     @Override
-    public Page pageQueryRreFile(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception {
+    public Page pageQueryRreFile(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception {
+
+        // 将 List 转换为 SQL 中的 IN 语句---只查询工信局项目库中的数据
+        String subIdFilter = subInfoIds.stream()
+                .map(id -> "'" + id + "'") // 每个 id 加上单引号
+                .collect(Collectors.joining(", ")); // 逗号拼接
 
         if (StringUtil.isEmpty(queryVO.getBeginDate())) {
             queryVO.setBeginDate("200001");  //默认设置一个开始时间
@@ -3411,7 +3433,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\tWHERE\n" +
                 "\t\to.`status` =1 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.status_conf !=3 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
@@ -3437,7 +3459,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >= 1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getTBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getTEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3469,7 +3491,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\t\tAND o.status_conf >= 1 \n" +
                 "\t\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3497,7 +3519,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getHBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getHEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3515,7 +3537,13 @@ public class SubInfoServiceImpl implements SubInfoService {
 
 
     @Override
-    public Page pageQueryRreProject(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception {
+    public Page pageQueryRreProject(Page page, SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception {
+
+        // 将 List 转换为 SQL 中的 IN 语句---只查询工信局项目库中的数据
+        String subIdFilter = subInfoIds.stream()
+                .map(id -> "'" + id + "'") // 每个 id 加上单引号
+                .collect(Collectors.joining(", ")); // 逗号拼接
+
 
         if (StringUtil.isEmpty(queryVO.getBeginDate())) {
             queryVO.setBeginDate("200001");  //默认设置一个开始时间
@@ -3582,7 +3610,8 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tWHERE\n" +
                 "\t\t\to.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
+                " AND s.id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3620,7 +3649,8 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\t\t\tAND o.status_conf != 3 \n" +
                 "\t\t\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
+                " AND s.id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3635,6 +3665,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\t) file ON a.id = file.sub_id \n" +
                 "\tWHERE\n" +
                 "\t\ta.logic_delete_flag = 0 \n" +
+                " AND a.id IN (" + subIdFilter + ")" +
                 "\t) a \n" +
                 "WHERE\n" +
                 "\ta.sub_id IS NOT NULL");
@@ -3648,7 +3679,12 @@ public class SubInfoServiceImpl implements SubInfoService {
 
 
     @Override
-    public Object sumDepartment(SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception {
+    public Object sumDepartment(SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception {
+
+        // 将 List 转换为 SQL 中的 IN 语句---只查询工信局项目库中的数据
+        String subIdFilter = subInfoIds.stream()
+                .map(id -> "'" + id + "'") // 每个 id 加上单引号
+                .collect(Collectors.joining(", ")); // 逗号拼接
 
         if (StringUtil.isEmpty(queryVO.getBeginDate())) {
             queryVO.setBeginDate("200001");  //默认设置一个开始时间
@@ -3762,7 +3798,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\tWHERE\n" +
                 "\t\to.`status` =1 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
@@ -3787,7 +3823,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >= 1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getTBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getTEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3820,7 +3856,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\t\tAND o.status_conf >= 1 \n" +
                 "\t\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3847,7 +3883,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getHBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getHEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -3866,7 +3902,12 @@ public class SubInfoServiceImpl implements SubInfoService {
 
 
     @Override
-    public Object sumFile(SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception {
+    public Object sumFile(SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception {
+
+        // 将 List 转换为 SQL 中的 IN 语句---只查询工信局项目库中的数据
+        String subIdFilter = subInfoIds.stream()
+                .map(id -> "'" + id + "'") // 每个 id 加上单引号
+                .collect(Collectors.joining(", ")); // 逗号拼接
 
         if (StringUtil.isEmpty(queryVO.getBeginDate())) {
             queryVO.setBeginDate("200001");  //默认设置一个开始时间
@@ -3982,7 +4023,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.status_conf !=3 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
@@ -4006,7 +4047,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >= 1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getTBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getTEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -4038,7 +4079,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\t\tAND o.status_conf >= 1 \n" +
                 "\t\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -4065,7 +4106,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND o.status_conf >=1 \n" +
                 "\t\tAND o.logic_delete_flag = 0 \n" +
                 " \t\t  and o.sub_unit_id is not null" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getHBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getHEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
@@ -4083,7 +4124,12 @@ public class SubInfoServiceImpl implements SubInfoService {
 
 
     @Override
-    public Object sumProject(SubinfoPreQueryVo queryVO, LoginUserVO loginUser) throws Exception {
+    public Object sumProject(SubinfoPreQueryVo queryVO, LoginUserVO loginUser, List<String> subInfoIds) throws Exception {
+
+        // 将 List 转换为 SQL 中的 IN 语句---只查询工信局项目库中的数据
+        String subIdFilter = subInfoIds.stream()
+                .map(id -> "'" + id + "'") // 每个 id 加上单引号
+                .collect(Collectors.joining(", ")); // 逗号拼接
 
         if (StringUtil.isEmpty(queryVO.getBeginDate())) {
             queryVO.setBeginDate("200001");  //默认设置一个开始时间
@@ -4136,6 +4182,7 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
+                "\t\tAND s.id IN (" + subIdFilter + ") \n" +  // 添加筛选条件
                 "\t\t\tGROUP BY\n" +
                 "\t\t\t\tsub_id,\n" +
                 "\t\t\t\tsub_unit_id \n" +
@@ -4211,15 +4258,17 @@ public class SubInfoServiceImpl implements SubInfoService {
                 "\t\t\tWHERE\n" +
                 "\t\t\t\to.logic_delete_flag = 0 \n" +
                 "\t\t\t\tAND o.sub_unit_id IS NOT NULL \n" +
-                " AND EXISTS ( SELECT 1 FROM sub_info s where s.id = o.sub_id ) " +
+                " AND o.sub_id IN (" + subIdFilter + ")" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )>= \"" + queryVO.getBeginDate() + "\" \n" +
                 "\t\tAND DATE_FORMAT( o.date_plan, \"%Y%m\" )<= \"" + queryVO.getEndDate() + "\" \n" +
                 this.getWhereSql(queryVO) +
+                "\t\t\tAND s.id IN (" + subIdFilter + ") \n" +  // 添加筛选条件
                 "\t\t\tGROUP BY\n" +
                 "\t\t\t\to.sub_id \n" +
                 "\t\t\t) bt ON a.id = bt.sub_id \n" +
                 "\t\tWHERE\n" +
                 "\t\t\ta.logic_delete_flag = 0 \n" +
+                "\t\t\tAND a.id IN (" + subIdFilter + ") \n" +  // 添加筛选条件
                 "\t\t) a \n" +
                 "\tWHERE\n" +
                 "\ta.sub_id IS NOT NULL \n" +
@@ -4663,6 +4712,12 @@ public class SubInfoServiceImpl implements SubInfoService {
         }
     }
 
+    @TargetDataSource("secondary")
+    @Override
+    public List<String> selectAllSubInfoIds() {
+        return subInfoMapper.selectAllSubInfoIds();
+    }
+
 
     public List<SubLabel> getSubLabels(SubLabelAddVO vo) {
         List<SubLabel> labelList = subLabelDao.findByCon(vo);

+ 10 - 6
projects/src/main/java/com/rtrh/projects/outapi/controller/projects/ProjectsApiController.java

@@ -1384,12 +1384,14 @@ public class ProjectsApiController extends BaseOutApiController {
     public JsonResult pageQueryRreDepartment(@RequestBody Page page, @RequestBody SubinfoPreQueryVo queryVO) {
         JsonResult result = new JsonResult();
         try {
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
             Page pageData = new Page();
             //1按部门  2 按手续 3 按项目
             List<HashMap<String, Object>> list = new ArrayList<>();
             switch (queryVO.getCat()) {
                 case "1":
-                    pageData = subInfoService.pageQueryRreDepartment(page, queryVO, getCurrUser());
+                    pageData = subInfoService.pageQueryRreDepartment(page, queryVO, getCurrUser(), subInfoIds);
                     list = pageData.getList();
                     for (int i = 0; i < list.size(); i++) {
                         List lst = new ArrayList();
@@ -1401,7 +1403,7 @@ public class ProjectsApiController extends BaseOutApiController {
                     }
                     break;
                 case "2":
-                    pageData = subInfoService.pageQueryRreFile(page, queryVO, getCurrUser());
+                    pageData = subInfoService.pageQueryRreFile(page, queryVO, getCurrUser(), subInfoIds);
                     list = pageData.getList();
                     for (int i = 0; i < list.size(); i++) {
                         List lst = new ArrayList();
@@ -1413,7 +1415,7 @@ public class ProjectsApiController extends BaseOutApiController {
                     }
                     break;
                 case "3":
-                    pageData = subInfoService.pageQueryRreProject(page, queryVO, getCurrUser());
+                    pageData = subInfoService.pageQueryRreProject(page, queryVO, getCurrUser(), subInfoIds);
                     list = pageData.getList();
                     for (int i = 0; i < list.size(); i++) {
                         List lst = new ArrayList();
@@ -1450,16 +1452,18 @@ public class ProjectsApiController extends BaseOutApiController {
         JsonResult result = new JsonResult();
         try {
             Object pageData = new Object();
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
             //1按部门  2 按手续 3 按项目
             switch (queryVO.getCat()) {
                 case "1":
-                    pageData = subInfoService.sumDepartment(queryVO, getCurrUser());
+                    pageData = subInfoService.sumDepartment(queryVO, getCurrUser(), subInfoIds);
                     break;
                 case "2":
-                    pageData = subInfoService.sumFile(queryVO, getCurrUser());
+                    pageData = subInfoService.sumFile(queryVO, getCurrUser(), subInfoIds);
                     break;
                 case "3":
-                    pageData = subInfoService.sumProject(queryVO, getCurrUser());
+                    pageData = subInfoService.sumProject(queryVO, getCurrUser(), subInfoIds);
                     break;
             }
             result.setData("list", pageData);

+ 21 - 7
projects/src/main/java/com/rtrh/projects/web/controller/subject/api/SubInfoApiController.java

@@ -157,8 +157,10 @@ public class SubInfoApiController extends BaseController {
         try {
             String currUnitId = null;
             currUnitId = getCurUser().getUnitId();
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
             Page pageData = subInfoService.pageQueryReportListSql(page, getCurUser().getLoginUser(), queryVO.getSubName(), currUnitId,
-                    null, queryVO.getStatus(), null, null, null, queryVO.getBeginDate(), queryVO.getEndDate());
+                    null, queryVO.getStatus(), null, null, null, queryVO.getBeginDate(), queryVO.getEndDate(),  subInfoIds);
             message.add(pageData.getList(), pageData.getTotalCount());
         } catch (Exception e) {
             logger.error("", e);
@@ -1174,7 +1176,9 @@ public class SubInfoApiController extends BaseController {
     public ListMessage pageQueryRreDepartment(@RequestBody Page page, @RequestBody SubinfoPreQueryVo queryVO) {
         ListMessage message = new ListMessage();
         try {
-            Page pageData = subInfoService.pageQueryRreDepartment(page, queryVO, getCurUser().getLoginUser());
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
+            Page pageData = subInfoService.pageQueryRreDepartment(page, queryVO, getCurUser().getLoginUser(), subInfoIds);
             message.add(pageData.getList(), pageData.getTotalCount());
         } catch (Exception e) {
             logger.error("", e);
@@ -1195,7 +1199,9 @@ public class SubInfoApiController extends BaseController {
     public Message sumDepartment(@RequestBody SubinfoPreQueryVo queryVO) {
         Message message = new Message();
         try {
-            Object object = subInfoService.sumDepartment(queryVO, getCurUser().getLoginUser());
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
+            Object object = subInfoService.sumDepartment(queryVO, getCurUser().getLoginUser(), subInfoIds);
             message.setData(object);
         } catch (Exception e) {
             logger.error("", e);
@@ -1215,7 +1221,9 @@ public class SubInfoApiController extends BaseController {
     public Message sumFile(@RequestBody SubinfoPreQueryVo queryVO) {
         Message message = new Message();
         try {
-            Object object = subInfoService.sumFile(queryVO, getCurUser().getLoginUser());
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
+            Object object = subInfoService.sumFile(queryVO, getCurUser().getLoginUser(), subInfoIds);
             message.setData(object);
         } catch (Exception e) {
             logger.error("", e);
@@ -1235,7 +1243,9 @@ public class SubInfoApiController extends BaseController {
     public Message sumProject(@RequestBody SubinfoPreQueryVo queryVO) {
         Message message = new Message();
         try {
-            Object object = subInfoService.sumProject(queryVO, getCurUser().getLoginUser());
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
+            Object object = subInfoService.sumProject(queryVO, getCurUser().getLoginUser(), subInfoIds);
             message.setData(object);
         } catch (Exception e) {
             logger.error("", e);
@@ -1255,7 +1265,9 @@ public class SubInfoApiController extends BaseController {
     public ListMessage pageQueryRreFile(@RequestBody Page page, @RequestBody SubinfoPreQueryVo queryVO) {
         ListMessage message = new ListMessage();
         try {
-            Page pageData = subInfoService.pageQueryRreFile(page, queryVO, getCurUser().getLoginUser());
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
+            Page pageData = subInfoService.pageQueryRreFile(page, queryVO, getCurUser().getLoginUser(), subInfoIds);
             message.add(pageData.getList(), pageData.getTotalCount());
         } catch (Exception e) {
             logger.error("", e);
@@ -1276,7 +1288,9 @@ public class SubInfoApiController extends BaseController {
     public ListMessage pageQueryRreProject(@RequestBody Page page, @RequestBody SubinfoPreQueryVo queryVO) {
         ListMessage message = new ListMessage();
         try {
-            Page pageData = subInfoService.pageQueryRreProject(page, queryVO, getCurUser().getLoginUser());
+            // 查询工信局项目列表中所有申报项目
+            List<String> subInfoIds = subInfoService.selectAllSubInfoIds();
+            Page pageData = subInfoService.pageQueryRreProject(page, queryVO, getCurUser().getLoginUser(), subInfoIds);
             message.add(pageData.getList(), pageData.getTotalCount());
         } catch (Exception e) {
             logger.error("", e);