JiangPengLi 4 сар өмнө
parent
commit
436882bd61
16 өөрчлөгдсөн 500 нэмэгдсэн , 185 устгасан
  1. 32 0
      projects-service/src/main/java/com/rtrh/projects/modules/projects/enums/SubInfoStatusEnum.java
  2. 3 0
      projects-service/src/main/java/com/rtrh/projects/modules/projects/mapper/SubInfoMapper.java
  3. 121 74
      projects-service/src/main/java/com/rtrh/projects/modules/projects/mapper/SubInfoMapper.xml
  4. 2 0
      projects-service/src/main/java/com/rtrh/projects/modules/projects/po/SubInfoGxj.java
  5. 56 64
      projects-service/src/main/java/com/rtrh/projects/modules/projects/service/impl/SubInfoQueryServiceImpl.java
  6. 4 5
      projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoCbVO.java
  7. 5 6
      projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoTcVO.java
  8. 5 6
      projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoXjVO.java
  9. 5 6
      projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoZjVO.java
  10. 8 13
      projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoZkVO.java
  11. 240 0
      projects/src/main/java/com/rtrh/projects/web/controller/subject/SubInfoExportController.java
  12. 2 2
      projects/src/main/webapp/vmodules/subject/subInfo/tz/cb.jsp
  13. 2 2
      projects/src/main/webapp/vmodules/subject/subInfo/tz/end.jsp
  14. 2 2
      projects/src/main/webapp/vmodules/subject/subInfo/tz/main.jsp
  15. 2 2
      projects/src/main/webapp/vmodules/subject/subInfo/tz/new.jsp
  16. 11 3
      projects/src/main/webapp/vmodules/subject/subInfo/tz/xmzk.jsp

+ 32 - 0
projects-service/src/main/java/com/rtrh/projects/modules/projects/enums/SubInfoStatusEnum.java

@@ -0,0 +1,32 @@
+package com.rtrh.projects.modules.projects.enums;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+
+/**
+ * 4库 项目状态
+ */
+@Getter
+@AllArgsConstructor
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+public enum SubInfoStatusEnum {
+
+    CB("1", "储备"),
+    XJ("2", "新建"),
+    ZJ("3", "在建"),
+    TC("9", "投产");
+
+    private final String code;
+    private final String desc;
+
+    public static SubInfoStatusEnum getEnum(String code) {
+        return Arrays.stream(values()).filter(x -> x.code.equals(code)).findFirst().orElse(null);
+    }
+    public static String getMessage(String code) {
+        SubInfoStatusEnum anEnum = getEnum(code);
+        return anEnum != null ? getEnum(code).desc : null;
+    }
+}

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

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.rtrh.projects.modules.projects.dto.SubFixCbSearch;
+import com.rtrh.projects.modules.projects.po.RptCont;
 import com.rtrh.projects.modules.projects.po.SubFix;
 import com.rtrh.projects.modules.projects.po.SubInfo;
 import com.rtrh.projects.modules.projects.vo.*;
@@ -61,4 +62,6 @@ public interface SubInfoMapper {
     List<SubInfoFixDetail> exportFixDetailExcel(@Param("stateFix")String stateFix, @Param("year") String year);
 
     List<SubInfoFixDetailPreNew> selectSubPreNewBySubIds(@Param("subIdList")List<String> subIdList);
+
+    List<RptCont> selectNewestMonthReport(@Param("ids") List<String> ids);
 }

+ 121 - 74
projects-service/src/main/java/com/rtrh/projects/modules/projects/mapper/SubInfoMapper.xml

@@ -124,99 +124,119 @@
 
     <select id="queryPage" resultType="com.rtrh.projects.modules.projects.po.SubInfoGxj">
         SELECT
-        id,
-        sub_id AS subId,
-        unit_id AS unitId,
-        unit_desc AS unitDesc,
-        sub_code AS subCode,
-        sub_name AS subName,
-        indus_kind AS indusKind,
-        amt_total AS amtTotal,
-        abc,
-        subject_id AS subjectId,
-        begin_date AS beginDate,
-        end_date AS endDate,
-        rt_date AS rtDate,
-        content AS content,
-        progress AS progress,
-        cb_status AS cbStatus,
-        qy_date AS qyDate,
-        xj_date AS xjDate,
-        zj_date AS zjDate,
-        tc_date AS tcDate,
-        cb_num AS cbNum,
-        xj_num AS xjNum,
-        zj_num AS zjNum,
-        remark,
-        name_zrr AS nameZrr,
-        tel AS tel,
-        name_lead AS nameLead,
-        tel_lead AS telLead,
-        status AS status,
-        is_rg AS isRg,
-        rg_date AS rgDate,
-        create_user_id AS createUserId,
-        create_user_name AS createUserName,
-        create_time AS createTime,
-        last_update_user_id AS lastUpdateUserId,
-        last_update_user_name AS lastUpdateUserName,
-        last_update_time AS lastUpdateTime,
-        logic_delete_flag AS logicDeleteFlag,
-        status_lamp AS statusLamp,
-        kind_nature AS kindNature
-        from sub_info
+        s.id,
+        s.sub_id AS subId,
+        s.unit_id AS unitId,
+        s.unit_desc AS unitDesc,
+        s.sub_code AS subCode,
+        s.sub_name AS subName,
+        s.indus_kind AS indusKind,
+        s.amt_total AS amtTotal,
+        s.abc,
+        s.subject_id AS subjectId,
+        s.begin_date AS beginDate,
+        s.end_date AS endDate,
+        s.rt_date AS rtDate,
+        s.content AS content,
+        s.progress AS progress,
+        s.cb_status AS cbStatus,
+        s.qy_date AS qyDate,
+        s.xj_date AS xjDate,
+        s.zj_date AS zjDate,
+        s.tc_date AS tcDate,
+        s.cb_num AS cbNum,
+        s.xj_num AS xjNum,
+        s.zj_num AS zjNum,
+        s.remark,
+        s.name_zrr AS nameZrr,
+        s.tel AS tel,
+        s.name_lead AS nameLead,
+        s.tel_lead AS telLead,
+        s.status AS status,
+        s.is_rg AS isRg,
+        s.rg_date AS rgDate,
+        s.create_user_id AS createUserId,
+        s.create_user_name AS createUserName,
+        s.create_time AS createTime,
+        s.last_update_user_id AS lastUpdateUserId,
+        s.last_update_user_name AS lastUpdateUserName,
+        s.last_update_time AS lastUpdateTime,
+        s.logic_delete_flag AS logicDeleteFlag,
+        s.status_lamp AS statusLamp,
+        s.kind_nature AS kindNature
+        <if test="vo.status!=null and vo.status==3 and vo.month!=null and vo.month!=''">
+            ,src.yearAmtSj
+        </if>
+        from sub_info s
+        <if test="vo.status!=null and vo.status==3 and vo.month!=null and vo.month!=''">
+            LEFT JOIN
+            (SELECT sub_id,sum(amt) AS yearAmtSj FROM sub_rpt_cont WHERE logic_delete_flag = 0 AND kj_month >= #{vo.month} GROUP BY sub_id) src
+            ON s.id=src.sub_id
+        </if>
         <where>
-            logic_delete_flag = 0
+            s.logic_delete_flag = 0
             <if test="vo.subName!=null and vo.subName!=''">
-                and sub_name like CONCAT('%', #{vo.subName}, '%')
+                and s.sub_name like CONCAT('%', #{vo.subName}, '%')
             </if>
             <if test="vo.kindNature!=null and vo.kindNature!=''">
-                and kind_nature = #{vo.kindNature}
+                and s.kind_nature = #{vo.kindNature}
             </if>
             <if test="vo.subjects!=null and vo.subjects!=''">
-                and subject_id = #{vo.subjects}
+                and s.subject_id = #{vo.subjects}
             </if>
             <if test="vo.subjectId!=null and vo.subjectId!=''">
-                and subject_id = #{vo.subjectId}
+                and s.subject_id = #{vo.subjectId}
             </if>
             <if test="vo.indusKind!=null and vo.indusKind!=''">
-                and indus_kind = #{vo.indusKind}
+                and s.indus_kind = #{vo.indusKind}
             </if>
             <if test="vo.indusKinds!=null and vo.indusKinds!=''">
-                and indus_kind = #{vo.indusKinds}
+                and s.indus_kind = #{vo.indusKinds}
             </if>
             <if test="vo.startAmt!=null and vo.startAmt!=''">
-                and amt_total >= #{vo.startAmt}
+                and s.amt_total >= #{vo.startAmt}
             </if>
             <if test="vo.endAmt!=null and vo.endAmt!=''">
-                and amt_total &lt;= #{vo.endAmt}
-            </if>
-            <if test="vo.status=='2' and vo.beginDate!=null and vo.beginDate!=''">
-                and begin_date >= #{vo.beginDate}
-            </if>
-            <if test="vo.status=='2' and vo.endDate!=null and vo.endDate!=''">
-                and begin_date &lt;= #{vo.endDate}
-            </if>
-            <if test="vo.status=='3' and vo.beginDate!=null and vo.beginDate!=''">
-                and end_date >= #{vo.beginDate}
-            </if>
-            <if test="vo.status=='3' and vo.endDate!=null and vo.endDate!=''">
-                and end_date &lt;= #{vo.endDate}
-            </if>
-            <if test="vo.status=='9' and vo.beginDate!=null and vo.beginDate!=''">
-                and rg_date >= #{vo.beginDate}
-            </if>
-            <if test="vo.status=='9' and vo.endDate!=null and vo.endDate!=''">
-                and rg_date &lt;= #{vo.endDate}
+                and s.amt_total &lt;= #{vo.endAmt}
             </if>
             <if test="vo.sbdw!=null and vo.sbdw!=''">
-                and unit_desc = #{vo.sbdw}
-            </if>
-            <if test="vo.status!=null and vo.status!=''">
-                and status = #{vo.status}
+                and s.unit_desc = #{vo.sbdw}
             </if>
             <if test="vo.abc!=null and vo.abc!=''">
-                and abc = #{vo.abc}
+                and s.abc = #{vo.abc}
+            </if>
+            <if test="vo.status!=null and vo.status!=''">
+                and s.status = #{vo.status}
+                <if test="vo.status==3">
+                    <if test="vo.yearMixAmt!=null and vo.yearMixAmt!=''">
+                        and src.yearAmtSj >=#{vo.yearMixAmt}
+                    </if>
+                    <if test="vo.yearMixAmt!=null and vo.yearMixAmt!=''">
+                        and src.yearAmtSj &lt;=#{vo.yearMaxAmt}
+                    </if>
+                    <if test="vo.beginDate!=null and vo.beginDate!=''">
+                        and s.end_date >= #{vo.beginDate}
+                    </if>
+                    <if test="vo.endDate!=null and vo.endDate!=''">
+                        and s.end_date &lt;= #{vo.endDate}
+                    </if>
+                </if>
+                <if test="vo.status=='2'">
+                    <if test="vo.beginDate!=null and vo.beginDate!=''">
+                        and s.begin_date >= #{vo.beginDate}
+                    </if>
+                    <if test="vo.endDate!=null and vo.endDate!=''">
+                        and s.begin_date &lt;= #{vo.endDate}
+                    </if>
+                </if>
+                <if test="vo.status=='9'">
+                    <if test="vo.beginDate!=null and vo.beginDate!=''">
+                        and s.rg_date >= #{vo.beginDate}
+                    </if>
+                    <if test="vo.endDate!=null and vo.endDate!=''">
+                        and s.rg_date &lt;= #{vo.endDate}
+                    </if>
+                </if>
             </if>
         </where>
     </select>
@@ -400,5 +420,32 @@
             AND a.status = 1
             AND a.status_conf IN (1, 2);
     </select>
-
+    <select id="selectNewestMonthReport" resultType="com.rtrh.projects.modules.projects.po.RptCont">
+        SELECT
+            src.sub_id AS subId,src.content
+        FROM
+            sub_rpt_cont src
+                JOIN (
+                SELECT
+                    sub_id,
+                    MAX(kj_month) AS latest_kj_month
+                FROM
+                    sub_rpt_cont
+                WHERE
+                    logic_delete_flag = 0
+                  AND sub_id IN
+                  <foreach collection="ids" item="item" separator="," open="(" close=")">
+                      #{item}
+                  </foreach>
+                  AND kind = '1'
+                  AND content IS NOT NULL
+                GROUP BY
+                    sub_id
+            ) AS latest_src ON src.sub_id = latest_src.sub_id
+                AND src.kj_month = latest_src.latest_kj_month
+        WHERE
+            src.logic_delete_flag = 0
+          AND src.kind = '1'
+          AND src.content IS NOT NULL;
+    </select>
 </mapper>

+ 2 - 0
projects-service/src/main/java/com/rtrh/projects/modules/projects/po/SubInfoGxj.java

@@ -159,4 +159,6 @@ public class SubInfoGxj extends TableBaseColomn implements Serializable {
     private String preProceNum;
     private String preEndNum;
     private String yearAmtSj;
+
+    private String preContent;
 }

+ 56 - 64
projects-service/src/main/java/com/rtrh/projects/modules/projects/service/impl/SubInfoQueryServiceImpl.java

@@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -16,6 +17,7 @@ import com.google.common.collect.Lists;
 import com.rtrh.projects.modules.projects.dao.*;
 import com.rtrh.projects.modules.projects.dto.SubFixCbSearch;
 import com.rtrh.projects.modules.projects.enums.RptContKindEnum;
+import com.rtrh.projects.modules.projects.enums.SubInfoStatusEnum;
 import com.rtrh.projects.modules.projects.po.*;
 import com.rtrh.projects.modules.projects.service.SubPreNewService;
 import com.rtrh.projects.modules.projects.vo.*;
@@ -162,39 +164,65 @@ public class SubInfoQueryServiceImpl implements SubInfoQueryService {
 
     @Override
     public List<SubInfoGxj> queryAll(LoginUserVO loginUser, SubInfoQueryTzVO queryVO) {
+        queryVO.setMonth(DateUtil.thisYear() + "01");
         List<SubInfoGxj> data = subInfoMapper.queryPage(queryVO);
+        List<String> ids = data.stream().map(SubInfoGxj::getId).collect(Collectors.toList());
+        // 项目前期手续办理情况
+        List<SubInfoFixDetailPreNew> preNewList =  subInfoMapper.selectSubPreNewBySubIds(ids);
+        Map<String, List<SubInfoFixDetailPreNew>> preNewMap = preNewList.stream().collect(Collectors.groupingBy(SubInfoFixDetailPreNew::getSubId));
+
+        // 查询项目 最新月报内容(建设进度)
+        List<RptCont> rptContList = subInfoMapper.selectNewestMonthReport(ids);
+        Map<String, String> rptContentMap = rptContList.stream().collect(Collectors.toMap(RptCont::getSubId, RptCont::getContent));
+
         List<TSystable> byKind = tSysTableService.getByKind(SysTableKind.JSDD);
+        Map<String, String> kindMap = byKind.stream().collect(Collectors.toMap(TSystable::getCode, TSystable::getTitle));
+
         if (CollectionUtil.isNotEmpty(data)) {
             for (SubInfoGxj e : data) {
-                // 查询月报中的建设进度
-                if (!Lists.newArrayList("1", "2").contains(e.getStatus())) {
-                    String hql = "FROM RptCont WHERE logicDeleteFlag = 0 AND subId = :subId AND kind = :kind AND content IS NOT NULL ORDER BY kjMonth DESC";
-                    Query query = rptContDao.createQuery(hql);
-                    query.setParameter("subId", e.getSubId());
-                    query.setParameter("kind", RptContKindEnum.MONTH.getCode());
-                    query.setMaxResults(1);
-                    Object result = query.uniqueResult();
-                    Optional.ofNullable(result).map(o -> (RptCont) o).ifPresent(o -> e.setProgress(o.getContent()));
+                e.setSubjectName(kindMap.get(e.getSubjectId()));
+                // 除了储备和新建项目外 其余项目进度为月报内容
+                if (!Lists.newArrayList(SubInfoStatusEnum.CB.getCode(), SubInfoStatusEnum.XJ.getCode()).contains(e.getStatus())) {
+                    e.setProgress(rptContentMap.getOrDefault(e.getSubId(),e.getProgress()));
                 }
-
-                byKind.stream()
-                        .filter(k -> e.getSubjectId().equals(k.getCode()))
-                        .findFirst()
-                        .ifPresent(k -> e.setSubjectName(k.getTitle()));
-                if ("2".equals(e.getStatus())) {
-                    // 新建库查询前期手续
-                    List<SubPreNewResultVO> preList = subPreNewService.listBySubId(e.getSubId());
-                    Map<String, Long> numMap = preList.stream().collect(Collectors.groupingBy(SubPreNewResultVO::getStatusConf, Collectors.counting()));
-                    e.setPreProceNum(numMap.getOrDefault("1", 0L) + "");
-                    e.setPreEndNum(numMap.getOrDefault("2", 0L) + "");
+                // 新建库前期手续
+                if (SubInfoStatusEnum.XJ.getCode().equals(e.getStatus())) {
+                    if (CollUtil.isNotEmpty(preNewMap.get(e.getSubId()))){
+                        Map<String, Long> numMap = preNewMap.get(e.getSubId()).stream().collect(Collectors.groupingBy(SubInfoFixDetailPreNew::getStatusConf, Collectors.counting()));
+                        e.setPreProceNum(numMap.getOrDefault("1", 0L) + "");
+                        e.setPreEndNum(numMap.getOrDefault("2", 0L) + "");
+                    }
                 }
-                // 在建项目年度投资
-                if ("3".equals(e.getStatus())) {
-                    Object o = rptContDao.queryForObjectBySql("SELECT sum(src.amt) AS yearAmtSj FROM sub_rpt_cont src WHERE src.logic_delete_flag = 0 AND src.kj_month >= ? AND src.sub_id=? GROUP BY src.sub_id", DateUtil.thisYear() + "01", e.getSubId());
-                    if (o != null) {
-                        Object o1 = ((Map<String, Object>) o).get("yearAmtSj");
-                        e.setYearAmtSj(o1 != null ? o1.toString() : "");
+
+                // 项目前期手续办理情况
+                List<SubInfoFixDetailPreNew> subInfoFixDetailPreNewList = preNewMap.get(e.getId());
+                StringBuilder sb = new StringBuilder();
+                if (com.rtrh.common.util.CollectionUtil.isNotEmpty(subInfoFixDetailPreNewList)){
+                    //已经完成的手续
+                    StringBuilder end = new StringBuilder("已完成:");
+                    //正在办理的手续
+                    StringBuilder yellow = new StringBuilder("进行中:");
+                    //判断是否有已完成手续
+                    boolean endBoolean = subInfoFixDetailPreNewList.stream().anyMatch(f->"2".equals(f.getStatusConf()));
+                    //判断是否有正在进行手续
+                    boolean yellowBoolean = subInfoFixDetailPreNewList.stream().anyMatch(f->"1".equals(f.getStatusConf()));
+                    subInfoFixDetailPreNewList.forEach(f->{
+                        if ("1".equals(f.getStatusConf())){
+                            yellow.append(f.getTitle()).append(",");
+                        }else if ("2".equals(f.getStatusConf())){
+                            end.append(f.getTitle()).append(",");
+                        }
+                    });
+                    if (endBoolean){
+                        sb.append(end, 0, end.length()-1).append("。");
+                    }
+                    if (yellowBoolean){
+                        sb.append(yellow, 0, yellow.length()-1).append("。");
                     }
+                    if (!endBoolean && !yellowBoolean){
+                        sb.append("暂无手续办理情况!");
+                    }
+                    e.setPreContent(sb.toString());
                 }
             }
         }
@@ -207,51 +235,15 @@ public class SubInfoQueryServiceImpl implements SubInfoQueryService {
             String abcs = queryVO.getAbcs();
             queryVO.setAbc(abcs);
         }
-        PageHelper.startPage(page.getPageNo(), page.getPageSize());
         if (StringUtils.isNotBlank(queryVO.getStartAmt()))
             queryVO.setStartAmt(new BigDecimal(queryVO.getStartAmt()).multiply(new BigDecimal("10000")).toString());
         if (StringUtils.isNotBlank(queryVO.getEndAmt())) {
             queryVO.setEndAmt(new BigDecimal(queryVO.getEndAmt()).multiply(new BigDecimal("10000")).toString());
         }
 
-        List<SubInfoGxj> data = subInfoMapper.queryPage(queryVO);
-
-
-        List<TSystable> byKind = tSysTableService.getByKind(SysTableKind.JSDD);
-        if (CollectionUtil.isNotEmpty(data)) {
-            for (SubInfoGxj e : data) {
-                // 查询月报中的建设进度
-                if (!Lists.newArrayList("1", "2").contains(e.getStatus())) {
-                    String hql = "FROM RptCont WHERE logicDeleteFlag = 0 AND subId = :subId AND kind = :kind AND content IS NOT NULL ORDER BY kjMonth DESC";
-                    Query query = rptContDao.createQuery(hql);
-                    query.setParameter("subId", e.getSubId());
-                    query.setParameter("kind", RptContKindEnum.MONTH.getCode());
-                    query.setMaxResults(1);
-                    Object result = query.uniqueResult();
-                    Optional.ofNullable(result).map(o -> (RptCont) o).ifPresent(o -> e.setProgress(o.getContent()));
-                }
 
-                byKind.stream()
-                        .filter(k -> e.getSubjectId().equals(k.getCode()))
-                        .findFirst()
-                        .ifPresent(k -> e.setSubjectName(k.getTitle()));
-                if ("2".equals(e.getStatus())) {
-                    // 新建库查询前期手续
-                    List<SubPreNewResultVO> preList = subPreNewService.listBySubId(e.getSubId());
-                    Map<String, Long> numMap = preList.stream().collect(Collectors.groupingBy(SubPreNewResultVO::getStatusConf, Collectors.counting()));
-                    e.setPreProceNum(numMap.getOrDefault("1", 0L) + "");
-                    e.setPreEndNum(numMap.getOrDefault("2", 0L) + "");
-                }
-                // 在建项目年度投资
-                if ("3".equals(e.getStatus())) {
-                    Object o = rptContDao.queryForObjectBySql("SELECT sum(src.amt) AS yearAmtSj FROM sub_rpt_cont src WHERE src.logic_delete_flag = 0 AND src.kj_month >= ? AND src.sub_id=? GROUP BY src.sub_id", DateUtil.thisYear() + "01", e.getSubId());
-                    if (o != null) {
-                        Object o1 = ((Map<String, Object>) o).get("yearAmtSj");
-                        e.setYearAmtSj(o1 != null ? o1.toString() : "");
-                    }
-                }
-            }
-        }
+        PageHelper.startPage(page.getPageNo(), page.getPageSize());
+        List<SubInfoGxj> data = this.queryAll(loginUser, queryVO);
         PageInfo<SubInfoGxj> pageInfo = new PageInfo<>(data);
         page.setList(data);
         page.setTotalCount(pageInfo.getTotal());

+ 4 - 5
projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoCbVO.java

@@ -4,21 +4,20 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 import lombok.Data;
 
 import java.math.BigDecimal;
-import java.util.Date;
 
 @Data
 public class SubInfoCbVO {
 
-    @Excel(name = "项目名称")
+    @Excel(name = "项目名称",width = 20.0)
     private String subName;
 
-    @Excel(name = "项目所在地")
+    @Excel(name = "项目所在地",width = 15.0)
     private String subjectName;
 
-    @Excel(name = "项目建设内容")
+    @Excel(name = "项目建设内容",width = 50.0)
     private String content;
 
-    @Excel(name = "计划总投资(亿元)")
+    @Excel(name = "计划总投资(亿元)",width = 15.0)
     private BigDecimal amtTotal;
 
     @Excel(name = "进展情况")

+ 5 - 6
projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoTcVO.java

@@ -10,20 +10,19 @@ import java.util.Date;
 @Data
 public class SubInfoTcVO {
 
-    @Excel(name = "项目名称")
+    @Excel(name = "项目名称",width = 20.0)
     private String subName;
 
-    @Excel(name = "项目所在地")
+    @Excel(name = "项目所在地",width = 15.0)
     private String subjectName;
 
-    @Excel(name = "项目建设内容")
+    @Excel(name = "项目建设内容",width = 50.0)
     private String content;
 
-    @Excel(name = "计划总投资(亿元)")
+    @Excel(name = "计划总投资(亿元)",width = 15.0)
     private Float amtTotal;
 
-    @Excel(name = "预计开工时间")
-    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
+    @Excel(name = "预计开工时间",format = "yyyy-MM-dd",width = 15.0)
     private Date beginDate;
 
     @Excel(name = "前期手续办理情况")

+ 5 - 6
projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoXjVO.java

@@ -10,20 +10,19 @@ import java.util.Date;
 @Data
 public class SubInfoXjVO {
 
-    @Excel(name = "项目名称")
+    @Excel(name = "项目名称",width = 20.0)
     private String subName;
 
-    @Excel(name = "项目所在地")
+    @Excel(name = "项目所在地",width = 15.0)
     private String subjectName;
 
-    @Excel(name = "项目建设内容")
+    @Excel(name = "项目建设内容",width = 50.0)
     private String content;
 
-    @Excel(name = "计划总投资(亿元)")
+    @Excel(name = "计划总投资(亿元)",width = 15.0)
     private Float amtTotal;
 
-    @Excel(name = "预计开工时间")
-    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
+    @Excel(name = "预计开工时间",format = "yyyy-MM-dd",width = 15.0)
     private Date beginDate;
 
     @Excel(name = "前期手续办理情况")

+ 5 - 6
projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoZjVO.java

@@ -9,20 +9,19 @@ import java.util.Date;
 
 @Data
 public class SubInfoZjVO {
-    @Excel(name = "项目名称")
+    @Excel(name = "项目名称",width = 20.0)
     private String subName;
 
-    @Excel(name = "项目所在地")
+    @Excel(name = "项目所在地",width = 15.0)
     private String subjectName;
 
-    @Excel(name = "项目建设内容")
+    @Excel(name = "项目建设内容",width = 50.0)
     private String content;
 
-    @Excel(name = "计划总投资(亿元)")
+    @Excel(name = "计划总投资(亿元)",width = 15.0)
     private Float amtTotal;
 
-    @Excel(name = "建成投产时间")
-    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
+    @Excel(name = "建成投产时间",format = "yyyy-MM-dd",width = 15.0)
     private Date endDate;
 
     @Excel(name = "年度投资")

+ 8 - 13
projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoZkVO.java

@@ -10,32 +10,27 @@ import java.util.Date;
 @Data
 public class SubInfoZkVO {
 
-    @Excel(name = "项目名称")
+    @Excel(name = "项目名称",width = 20.0)
     private String subName;
 
-    @Excel(name = "项目所在地")
+    @Excel(name = "项目所在地",width = 15.0)
     private String subjectName;
 
-    @Excel(name = "项目建设内容")
+    @Excel(name = "项目建设内容",width = 50.0)
     private String content;
 
-    @Excel(name = "计划总投资(亿元)")
+    @Excel(name = "计划总投资(亿元)",width = 15.0)
     private Float amtTotal;
 
-    @Excel(name = "状态")
+    @Excel(name = "状态",width = 10.0)
     private String statusName;
 
-    @Excel(name = "计划开工时间")
-    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
+    @Excel(name = "计划开工时间",format = "yyyy-MM-dd",width = 15.0)
     private Date beginDate;
 
-    @Excel(name = "计划完工时间")
-    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
+    @Excel(name = "计划完工时间",format = "yyyy-MM-dd",width = 15.0)
     private Date endDate;
 
-    @Excel(name = "前期手续办理情况")
-    private String preContent;
-
-    @Excel(name = "备注")
+    @Excel(name = "备注",width = 10.0)
     private String remark;
 }

+ 240 - 0
projects/src/main/java/com/rtrh/projects/web/controller/subject/SubInfoExportController.java

@@ -29,6 +29,7 @@ import com.rtrh.common.util.StringUtil;
 import com.rtrh.core.vo.ListMessage;
 import com.rtrh.projects.modules.projects.dao.SubSourceDao;
 import com.rtrh.projects.modules.projects.enums.ProjectStatusEnum;
+import com.rtrh.projects.modules.projects.enums.SubInfoStatusEnum;
 import com.rtrh.projects.modules.projects.po.SubInfoGxj;
 import com.rtrh.projects.modules.projects.vo.SubInfoTotalExcel;
 import com.rtrh.projects.modules.projects.vo.export.*;
@@ -791,6 +792,245 @@ public class SubInfoExportController extends BaseController {
             }
         }
     }
+    /**
+     * 导出明细
+     *
+     * @param response
+     */
+    @PostMapping("/exportDetailExcel")
+    public void exportDetailExcel(HttpServletResponse response, @RequestBody SubInfoQueryTzVO queryVO) {
+        List<SubInfoGxj> list = subInfoQueryService.queryAll(getCurUser().getLoginUser(), queryVO);
+        ExportParams exportParams = new ExportParams();
+        exportParams.setType(ExcelType.XSSF);
+        Workbook workbook;
+        if (SubInfoStatusEnum.CB.getCode().equals(queryVO.getStatus())){
+            List<SubInfoCbVO> cbVOList = list.stream().map(e -> {
+                SubInfoCbVO subInfoCbVO = new SubInfoCbVO();
+                BeanUtil.copyProperties(e, subInfoCbVO);
+                return subInfoCbVO;
+            }).collect(Collectors.toList());
+            exportParams.setTitle("“四个一批”工业项目表(储备项目库)");
+            exportParams.setSheetName("储备项目库");
+            workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoCbVO.class, cbVOList);
+        }else if (SubInfoStatusEnum.XJ.getCode().equals(queryVO.getStatus())){
+            List<SubInfoXjVO> xjVOList = list.stream().map(e -> {
+                SubInfoXjVO subInfoTzVO = new SubInfoXjVO();
+                BeanUtil.copyProperties(e, subInfoTzVO);
+                return subInfoTzVO;
+            }).collect(Collectors.toList());
+            exportParams.setTitle("“四个一批”工业项目表(新建项目库)");
+            exportParams.setSheetName("新建项目库");
+            workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoXjVO.class, xjVOList);
+        }else if (SubInfoStatusEnum.ZJ.getCode().equals(queryVO.getStatus())){
+            List<SubInfoZjVO> zjVoList = list.stream().map(e -> {
+                SubInfoZjVO subInfoTzVO = new SubInfoZjVO();
+                BeanUtil.copyProperties(e, subInfoTzVO);
+                return subInfoTzVO;
+            }).collect(Collectors.toList());
+            exportParams.setTitle("“四个一批”工业项目表(在建项目库)");
+            exportParams.setSheetName("在建项目库");
+            workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoZjVO.class, zjVoList);
+        }else if (SubInfoStatusEnum.TC.getCode().equals(queryVO.getStatus())){
+            List<SubInfoTcVO> tcList = list.stream().map(e -> {
+                SubInfoTcVO subInfoTzVO = new SubInfoTcVO();
+                BeanUtil.copyProperties(e, subInfoTzVO);
+                return subInfoTzVO;
+            }).collect(Collectors.toList());
+            exportParams.setTitle("“四个一批”工业项目表(投产项目库)");
+            exportParams.setSheetName("投产项目库");
+            workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoTcVO.class, tcList);
+        }else {
+            List<SubInfoZkVO> zkVOList = list.stream().map(e -> {
+                SubInfoZkVO subInfoTzVO = new SubInfoZkVO();
+                BeanUtil.copyProperties(e, subInfoTzVO);
+                return subInfoTzVO;
+            }).collect(Collectors.toList());
+            exportParams.setTitle("“四个一批”工业项目表(项目总库)");
+            exportParams.setSheetName("项目总库");
+            workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoZkVO.class, zkVOList);
+        }
+        response.setContentType("application/xlsx;charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment; filename=" + URLEncodeUtil.encode("项目明细表") + System.currentTimeMillis() + ".xlsx");
+        try (OutputStream outputStream = response.getOutputStream()) {
+            workbook.write(outputStream);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 4库导出
+     *
+     * @param response
+     * @param vo
+     */
+    @PostMapping("/exportTotalExcelByStatus")
+    public void exportTotalExcelByStatus(HttpServletResponse response, @RequestBody SubInfoQueryTzVO vo) {
+
+        try {
+            List<SubInfoTotalExcel> subInfoTotalExcel = subInfoService.exportTotalExcelByStatus(vo);
+
+            //获取属地字典
+            List<TSystable> jsddList = tSysTableService.getByKind(SysTableKind.JSDD);
+            //获取行业字典
+            List<TSystable> hyflList = tSysTableService.getByKind(SysTableKind.HYFL);
+            //遍历subInfoTotalExcel,将subjectId替换为jsddList中code=subjectId的title
+            for (SubInfoTotalExcel data : subInfoTotalExcel) {
+                if (data == null) {
+                    continue;
+                }
+                String subjectId = data.getSubjectId();
+                String induskind = data.getInduskind();
+                if (StringUtil.isNotEmpty(induskind)) {
+                    Optional<TSystable> first = hyflList.stream().filter(item -> item.getCode().equals(induskind)).findFirst();
+                    first.ifPresent(tSystable -> data.setInduskind(tSystable.getTitle()));
+                }
+                if (StringUtil.isNotEmpty(subjectId)) {
+                    Optional<TSystable> first = jsddList.stream().filter(item -> item.getCode().equals(subjectId)).findFirst();
+                    first.ifPresent(tSystable -> data.setSubjectId(tSystable.getTitle()));
+                }
+            }
+
+            //通过ExcelUtil.getBigWriter()创建Writer对象,BigExcelWriter用于大数据量的导出,不会引起溢出;
+            cn.hutool.poi.excel.ExcelWriter writer = ExcelUtil.getBigWriter();
+
+            //写入标题
+            // 写入标题行
+            List<String> titleRow = CollUtil.newArrayList("储备项目库基本情况");
+            writer.writeHeadRow(titleRow);
+            // 合并标题行的所有单元格
+            writer.merge(0, 0, 0, 3, null, true);
+
+            List<String> rowHead2 = CollUtil.newArrayList("项目分类", "项目分类", "项目个数", "计划总投资(亿元)");
+            writer.writeHeadRow(rowHead2);
+            writer.merge(1, 1, 0, 1, null, true);
+
+            // 获取 SXSSFSheet 对象(确保在写入数据之后)
+            SXSSFSheet sheet = ((SXSSFWorkbook) writer.getWorkbook()).getSheetAt(0);
+
+            // 设置每列的默认宽度
+            int defaultColumnWidth = 40; // 默认宽度为20个字符
+            for (int i = 0; i < rowHead2.size(); i++) {
+                sheet.setColumnWidth(i, defaultColumnWidth * 256); // 其他列保持默认宽度
+            }
+
+            //4、对数据按照属地字段进行分组
+            LinkedHashMap<String, List<SubInfoTotalExcel>> subjectIdList = subInfoTotalExcel.stream().collect(Collectors.groupingBy(SubInfoTotalExcel::getSubjectId, LinkedHashMap::new, Collectors.toList()));
+            //5、对数据按照金额1000-3000,3000-5000,5000-10000进行分组
+            LinkedHashMap<String, List<SubInfoTotalExcel>> moneyList = subInfoTotalExcel.stream().collect(Collectors.groupingBy(data -> {
+                if (data.getAmtTotal().compareTo(new BigDecimal(1000000)) >= 0) {
+                    return "100亿元以上";
+                } else if (data.getAmtTotal().compareTo(new BigDecimal(500000)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(1000000)) < 0) {
+                    return "50-100亿元";
+                } else if (data.getAmtTotal().compareTo(new BigDecimal(100000)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(500000)) < 0) {
+                    return "10-50亿元";
+                } else {
+                    return "10亿元以下";
+                }
+            }, LinkedHashMap::new, Collectors.toList()));
+            //6、对数据按照行业进行分组
+            LinkedHashMap<String, List<SubInfoTotalExcel>> industryList = subInfoTotalExcel.stream().collect(Collectors.groupingBy(SubInfoTotalExcel::getInduskind, LinkedHashMap::new, Collectors.toList()));
+
+            //遍历subInfoTotalExcel数据计算总金额
+            BigDecimal totalAmt = subInfoTotalExcel.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
+            Integer totalNum = subInfoTotalExcel.size();
+
+            LinkedHashMap<String, List<List<String>>> finalDataMap = new LinkedHashMap<>();
+
+            //7、需要保存的数据
+            List<List<String>> areaData = CollUtil.newArrayList();
+            for (Map.Entry<String, List<SubInfoTotalExcel>> subInfoListEntry : subjectIdList.entrySet()) {
+                List<String> data = CollUtil.newArrayList();
+                data.add("按属地分");
+                data.add(subInfoListEntry.getKey());
+                data.add(String.valueOf(subInfoListEntry.getValue().size()));
+                data.add(String.valueOf(subInfoListEntry.getValue().stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add)));
+                areaData.add(data);
+            }
+            finalDataMap.put("按属地划分", areaData);
+
+            List<List<String>> moneyData = CollUtil.newArrayList();
+            for (Map.Entry<String, List<SubInfoTotalExcel>> subInfoListEntry : moneyList.entrySet()) {
+                List<String> data = CollUtil.newArrayList();
+                data.add("按金额分");
+                data.add(subInfoListEntry.getKey());
+                data.add(String.valueOf(subInfoListEntry.getValue().size()));
+                data.add(String.valueOf(subInfoListEntry.getValue().stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add)));
+                moneyData.add(data);
+            }
+            finalDataMap.put("按金额划分", moneyData);
+
+            List<List<String>> industryData = CollUtil.newArrayList();
+            for (Map.Entry<String, List<SubInfoTotalExcel>> subInfoListEntry : industryList.entrySet()) {
+                List<String> data = CollUtil.newArrayList();
+                data.add("按行业分");
+                data.add(subInfoListEntry.getKey());
+                data.add(String.valueOf(subInfoListEntry.getValue().size()));
+                data.add(String.valueOf(subInfoListEntry.getValue().stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add)));
+                industryData.add(data);
+            }
+            finalDataMap.put("按行业划分", industryData);
+
+            ServletOutputStream out = null;
+
+            try {
+                //6.定义容器保存人物数据
+                List<List<String>> finalDataRows = new LinkedList<>();
+                int indexStart = 2;   //行业分类起始行
+
+                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;
+                    }
+                    //18.保存数据
+                    finalDataRows.addAll(dataList);
+                }
+                writer.write(finalDataRows, true);
+
+                // 创建合计行
+                List<String> totalRow = CollUtil.newArrayList("合计", "合计", totalNum.toString(), totalAmt.toString());
+                writer.writeHeadRow(totalRow);
+                writer.merge(indexStart, indexStart, 0, 1, null, true);
+
+
+                response.setContentType("application/vnd.ms-excel;charset=utf-8");
+                Date currentDate = new Date();
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+                String date = sdf.format(currentDate);
+                response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("重点项目调度-项目数据.xlsx", "UTF-8"));
+                out = response.getOutputStream();
+                writer.flush(out, true);
+            } finally {
+                //关闭输出Servlet流
+                IoUtil.close(out);
+                //关闭writer,释放内存
+                writer.close();
+            }
+        } catch (IOException e) {
+            // 设置错误状态码和消息
+            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            try {
+                e.printStackTrace();
+                response.getWriter().write("导出 Excel 文件时出现错误:" + e.getMessage());
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        } catch (Exception e) {
+            // 处理其他可能的异常
+            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+            e.printStackTrace();
+            try {
+                response.getWriter().write("请求参数错误或发生其他错误:" + e.getMessage());
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
 
     /**
      * 导出重点项目明细表

+ 2 - 2
projects/src/main/webapp/vmodules/subject/subInfo/tz/cb.jsp

@@ -1008,12 +1008,12 @@
             exportTotalExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '1'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(储备库).xlsx", "导出失败");
             },
             exportDetailExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '1'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目明细(储备库).xlsx", "导出失败");
             },
             exportExcelByIndusKind: function () {
                 var param = this.getSearchParams();

+ 2 - 2
projects/src/main/webapp/vmodules/subject/subInfo/tz/end.jsp

@@ -1247,12 +1247,12 @@
             exportTotalExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '9'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(投产库).xlsx", "导出失败");
             },
             exportDetailExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '9'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目明细表(投产库).xlsx", "导出失败");
             },
             exportExcel: function () {
                 var param = this.getSearchParams();

+ 2 - 2
projects/src/main/webapp/vmodules/subject/subInfo/tz/main.jsp

@@ -1271,12 +1271,12 @@
             exportTotalExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '3'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(在建库).xlsx", "导出失败");
             },
             exportDetailExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '3'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目明细表(在建库).xlsx", "导出失败");
             },
             exportExcel: function () {
                 var param = this.getSearchParams();

+ 2 - 2
projects/src/main/webapp/vmodules/subject/subInfo/tz/new.jsp

@@ -1226,12 +1226,12 @@
             exportTotalExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '2'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(新建库).xlsx", "导出失败");
             },
             exportDetailExcel: function () {
                 var param = this.getSearchParams();
                 param.status = '2'
-                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目情况表(按所属行业统计).xlsx", "导出失败");
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目明细表(新建库).xlsx", "导出失败");
             },
             exportExcel: function () {
                 var param = this.getSearchParams();

+ 11 - 3
projects/src/main/webapp/vmodules/subject/subInfo/tz/xmzk.jsp

@@ -103,9 +103,9 @@
                 项目总库
             </div>
             <div class="layui-btn-container" style="margin-top: 20px;margin-left: 20px">
-                <button type="button" class="layui-btn">导出明细</button>
-                <button type="button" class="layui-btn">导出总表</button>
-                <button type="button" class="layui-btn">自定义导出</button>
+                <button type="button" class="layui-btn" @click="exportDetailExcel">导出明细</button>
+                <button type="button" class="layui-btn" @click="exportTotalExcel">导出总表</button>
+                <button type="button" class="layui-btn" @click="exportMoreExcel">自定义导出</button>
             </div>
             <div class="layui-collapse">
                 <div class="layui-colla-item">
@@ -1091,6 +1091,14 @@
                     }
                 })
             },
+            exportTotalExcel: function () {
+                var param = this.getSearchParams();
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportTotalExcelByStatus"), "POST", param, "项目情况表(总库).xlsx", "导出失败");
+            },
+            exportDetailExcel: function () {
+                var param = this.getSearchParams();
+                App.common.utils.downFile(App.getUrl("subInfoExport/exportDetailExcel"), "POST", param, "项目明细表(总库).xlsx", "导出失败");
+            },
             exportExcel: function () {
                 var param = this.getSearchParams();
                 App.common.utils.downFile(App.getUrl("subInfoExport/exportSumExcel"), "POST", param, "项目情况表.xlsx", "导出失败");