Forráskód Böngészése

储备库问题修复

Wayne 4 hónapja
szülő
commit
bcec93a71a

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

@@ -10,6 +10,7 @@ import com.rtrh.projects.modules.projects.po.SubFix;
 import com.rtrh.projects.modules.projects.po.SubInfo;
 import com.rtrh.projects.modules.projects.vo.*;
 import com.rtrh.projects.modules.projects.po.SubInfoGxj;
+import com.rtrh.projects.modules.projects.vo.export.SubInfoFixCbDetail;
 import com.rtrh.projects.modules.projects.vo.export.SubInfoFixDetail;
 import org.apache.ibatis.annotations.Param;
 
@@ -64,4 +65,6 @@ public interface SubInfoMapper {
     List<SubInfoFixDetailPreNew> selectSubPreNewBySubIds(@Param("subIdList")List<String> subIdList);
 
     List<RptCont> selectNewestMonthReport(@Param("ids") List<String> ids);
+
+    List<SubInfoFixCbDetail> exportFixCbDetailExcel(@Param("stateFix") String stateFix, @Param("year") String year);
 }

+ 17 - 2
projects-service/src/main/java/com/rtrh/projects/modules/projects/mapper/SubInfoMapper.xml

@@ -375,7 +375,7 @@
         SELECT sub_info.subject_id as subjectId,
                sub_info.sub_name as subName,
                sub_info.amt_total as amtTotal,
-               sub_info.indus_kind as indusKind
+               sub_info.indus_kind as induskind
         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
@@ -400,11 +400,13 @@
                sub_info.content as content,
                sub_info.begin_date as beginDate,
                sub_info.amt_total as amtTotal,
-               sub_info.remark as remark
+               sub_info.remark as remark,
+               sub_info.indus_kind as indusKind
         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
     </select>
+
     <select id="selectSubPreNewBySubIds" resultType="com.rtrh.projects.modules.projects.vo.SubInfoFixDetailPreNew">
         SELECT
             a.sub_id as subId,
@@ -450,4 +452,17 @@
           AND src.kind = '1'
           AND src.content IS NOT NULL;
     </select>
+    <select id="exportFixCbDetailExcel" resultType="com.rtrh.projects.modules.projects.vo.export.SubInfoFixCbDetail">
+        SELECT sub_info.id as id,
+               sub_info.sub_name as subName,
+               sub_info.subject_id as subjectId,
+               sub_info.content as content,
+               sub_info.amt_total as amtTotal,
+               sub_info.remark as remark,
+               sub_info.indus_kind as indusKind,
+               sub_info.progress as progress
+        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
+    </select>
 </mapper>

+ 5 - 5
projects-service/src/main/java/com/rtrh/projects/modules/projects/po/SubIndu.java

@@ -23,18 +23,18 @@ public class SubIndu extends TableBaseColomn implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    private String id;
+    private String id;      //编号
 
-    private String code;
+    private String code;    //行业代码
 
-    private String title;
+    private String title;   //名称
 
-    private String lastId;
+    private String lastId;  //上级行业
 
     private String createUserName;
 
     private String lastUpdateUserName;
-    private String parentTitle;
+    private String parentTitle; //上级行业名称
 
     private List<SubIndu> children;
 }

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

@@ -11,6 +11,7 @@ import com.rtrh.projects.modules.projects.po.SubInfo;
 import com.rtrh.projects.modules.projects.po.SubInfoGxj;
 import com.rtrh.projects.modules.projects.po.SubLabel;
 import com.rtrh.projects.modules.projects.vo.*;
+import com.rtrh.projects.modules.projects.vo.export.SubInfoFixCbDetail;
 import com.rtrh.projects.modules.projects.vo.export.SubInfoFixDetail;
 import com.rtrh.projects.modules.projects.vo.export.SubInfoFixVO;
 import com.rtrh.projects.modules.system.vo.LoginUserVO;
@@ -413,5 +414,7 @@ public interface SubInfoService {
 
     List<SubInfoFixDetail> exportFixDetailExcel(SubInfoQueryTzVO vo);
 
+	List<SubInfoFixCbDetail> exportFixCbDetailExcel(SubInfoQueryTzVO vo);
+
 	List<SubInfoTotalExcel> exportTotalExcelByStatus(SubInfoQueryTzVO vo);
 }

+ 79 - 8
projects-service/src/main/java/com/rtrh/projects/modules/projects/service/impl/SubInfoServiceImpl.java

@@ -14,12 +14,14 @@ import com.rtrh.projects.modules.projects.mapper.SubInfoMapper;
 import com.rtrh.projects.modules.projects.po.*;
 import com.rtrh.projects.modules.projects.service.*;
 import com.rtrh.projects.modules.projects.vo.*;
+import com.rtrh.projects.modules.projects.vo.export.SubInfoFixCbDetail;
 import com.rtrh.projects.modules.projects.vo.export.SubInfoFixDetail;
 import com.rtrh.projects.modules.projects.vo.export.SubInfoFixVO;
 import com.rtrh.projects.modules.rolemeun.dao.SecRoleDao;
 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.system.service.ISubInduService;
 import com.rtrh.projects.modules.utils.DateUtils;
 import com.rtrh.projects.util.TargetDataSource;
 import com.rtrh.projects.vo.SubIdVO;
@@ -119,6 +121,9 @@ public class SubInfoServiceImpl implements SubInfoService {
     @Autowired
     private SecRoleDao secRoleDao;
 
+    @Autowired
+    private ISubInduService subInduService;
+
     @Autowired
     private RptContDao rptContDao;
     @Autowired
@@ -4766,16 +4771,31 @@ public class SubInfoServiceImpl implements SubInfoService {
     @Override
     public List<SubInfoFixDetail> exportFixDetailExcel(SubInfoQueryTzVO vo) {
 
-        // 查询所有的重点项目信息
-        List<SubInfoFixDetail> dataList = subInfoMapper.exportFixDetailExcel(vo.getStateFix(),vo.getYear());
-        //收集所有重点项目信息的id
-        List<String> subIdList = dataList.stream().map(SubInfoFixDetail::getId).collect(Collectors.toList());
-        //查询前期手续办理情况表中的数据,获取所有重点项目的前期手续信息
-        List<SubInfoFixDetailPreNew> preNewList =  subInfoMapper.selectSubPreNewBySubIds(subIdList);
+        // 查询所有的重点项目信息,若结果为空则初始化为一个空列表
+        List<SubInfoFixDetail> dataList = Optional.ofNullable(
+                subInfoMapper.exportFixDetailExcel(vo.getStateFix(), vo.getYear())
+        ).orElse(Collections.emptyList());
+
+        // 收集所有重点项目信息的ID
+        List<String> subIdList = dataList.stream()
+                .map(SubInfoFixDetail::getId)
+                .filter(StringUtils::isNotBlank)
+                .collect(Collectors.toList());
+
+        // 查询前期手续办理情况表中的数据,获取所有重点项目的前期手续信息
+        List<SubInfoFixDetailPreNew> preNewList = Optional.ofNullable(
+                subInfoMapper.selectSubPreNewBySubIds(subIdList)
+        ).orElse(Collections.emptyList());
+
+
         //对手续信息按照id进行分组
         Map<String, List<SubInfoFixDetailPreNew>> preNewMap = preNewList.stream().collect(Collectors.groupingBy(SubInfoFixDetailPreNew::getSubId));
-        //获取项目建设地点
-        List<TSystable> jsddList = tSysTableService.getByKind(SysTableKind.JSDD);
+
+        // 获取项目建设地点
+        List<TSystable> jsddList = Optional.ofNullable(
+                tSysTableService.getByKind(SysTableKind.JSDD)
+        ).orElse(Collections.emptyList());
+
         // 遍历重点项目信息,找到对应的前期手续信息,然后拼接手续完成情况为字符串,拼接到对应的重点项目信息中
         dataList.forEach(e->{
             List<SubInfoFixDetailPreNew> subInfoFixDetailPreNewList = preNewMap.get(e.getId());
@@ -4817,6 +4837,57 @@ public class SubInfoServiceImpl implements SubInfoService {
         return dataList;
     }
 
+    @Override
+    public List<SubInfoFixCbDetail> exportFixCbDetailExcel(SubInfoQueryTzVO vo) {
+
+        // 查询所有的重点项目信息,若结果为空则初始化为一个空列表
+        List<SubInfoFixCbDetail> dataList = Optional.ofNullable(
+                subInfoMapper.exportFixCbDetailExcel(vo.getStateFix(), vo.getYear())
+        ).orElse(Collections.emptyList());
+
+        // 获取项目建设地点
+        List<TSystable> jsddList = Optional.ofNullable(
+                tSysTableService.getByKind(SysTableKind.JSDD)
+        ).orElse(Collections.emptyList());
+
+        // 获取行业
+        List<SubIndu> subInduList = Optional.ofNullable(
+                subInduService.queryTreeALl()
+        ).orElse(Collections.emptyList());
+
+        // 遍历重点项目信息,找到对应的前期手续信息,然后拼接手续完成情况为字符串,拼接到对应的重点项目信息中
+        dataList.forEach(e->{
+            //设置项目所在地
+            if (StringUtils.isNotBlank(e.getSubjectId())){
+                e.setSubjectId(jsddList.stream().filter(f->f.getCode().equals(e.getSubjectId())).findFirst().map(TSystable::getTitle).orElse(""));
+            }
+
+            //设置行业
+            if (StringUtil.isNotEmpty(e.getIndusKind())) {
+                String induskind = e.getIndusKind();
+                //这是新的行业列表subInduList,subInduList中有children里面装的子行业,我需要将induskind替换为subInduList中的一级行业title
+                Optional<SubIndu> first = subInduList.stream().filter(item -> item.getCode().equals(induskind)).findFirst();
+                if (first.isPresent()) {
+                    //判断上级名称是否存在,如果存在将induskind替换为上级名称,否则将induskind替换为名称
+                    if (StringUtil.isNotEmpty(first.get().getParentTitle())) {
+                        e.setIndusKind(first.get().getParentTitle());
+                    } else {
+                        e.setIndusKind(first.get().getTitle());
+                    }
+                }else {
+                    e.setIndusKind("");
+                }
+            }else {
+                e.setIndusKind("");
+            }
+
+            //将万元转换为亿元
+            e.setAmtTotal(e.getAmtTotal().divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
+        });
+
+        return dataList;
+    }
+
     @Override
     public List<SubInfoTotalExcel> exportTotalExcelByStatus(SubInfoQueryTzVO vo) {
         return subInfoMapper.exportTotalExcelByStatus(vo.getStatus());

+ 27 - 0
projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoFixCbDetail.java

@@ -0,0 +1,27 @@
+package com.rtrh.projects.modules.projects.vo.export;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class SubInfoFixCbDetail {
+
+    private String id; // 序号
+
+    private String subName; // 项目名称
+
+    private String subjectId;   // 项目所在地
+
+    private String content; // 项目内容
+
+    private BigDecimal amtTotal;    // 总金额
+
+    private String remark;  // 备注
+
+    private String progress;   //进展情况
+
+    private String indusKind;   //行业
+
+}

+ 2 - 0
projects-service/src/main/java/com/rtrh/projects/modules/projects/vo/export/SubInfoFixDetail.java

@@ -25,4 +25,6 @@ public class SubInfoFixDetail {
 
     private String remark;  // 备注
 
+    private String indusKind;   //行业
+
 }

+ 27 - 0
projects-service/src/main/java/com/rtrh/projects/modules/utils/StringUtils.java

@@ -27,4 +27,31 @@ public class StringUtils {
 			return cell.getStringCellValue();
 		}
 	}
+
+	// 将数字转换为中文数字的方法
+	public static String toChineseNumber(int num) {
+		String[] chineseDigits = {"", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
+		String[] chineseUnits = {"", "十", "百", "千"};
+
+		StringBuilder result = new StringBuilder();
+		int unitPosition = 0;
+
+		while (num > 0) {
+			int digit = num % 10;
+			if (digit != 0) {
+				result.insert(0, chineseDigits[digit] + chineseUnits[unitPosition]);
+			} else if (result.length() > 0 && result.charAt(0) != '零') {
+				result.insert(0, "零");
+			}
+			num /= 10;
+			unitPosition++;
+		}
+
+		// 处理特殊情况,比如 "一十" -> "十"
+		if (result.length() > 1 && result.charAt(0) == '一' && result.charAt(1) == '十') {
+			result.deleteCharAt(0);
+		}
+
+		return result.toString();
+	}
 }

+ 164 - 16
projects/src/main/java/com/rtrh/projects/web/controller/subject/SubInfoExportController.java

@@ -39,6 +39,7 @@ import com.rtrh.projects.modules.system.service.ISubInduService;
 import com.rtrh.projects.modules.utils.CustomCellWriteWidthStrategy;
 import com.rtrh.projects.modules.utils.DateUtils;
 import com.rtrh.projects.modules.utils.QualificationsDeclareCellWriteHandler;
+import com.rtrh.projects.modules.utils.StringUtils;
 import com.rtrh.projects.outapi.result.JsonResult;
 import com.rtrh.projects.web.util.SheetData;
 import com.rtrh.projects.web.util.SheetHead;
@@ -637,11 +638,14 @@ public class SubInfoExportController extends BaseController {
 
         try {
             List<SubInfoTotalExcel> subInfoTotalExcel = subInfoService.getFixTotalExcel(vo);
+            if (subInfoTotalExcel == null) {
+                subInfoTotalExcel = new ArrayList<>();
+            }
 
             //获取属地字典
             List<TSystable> jsddList = tSysTableService.getByKind(SysTableKind.JSDD);
-            //获取行业字典
-            List<TSystable> gxjHyfl = tSysTableService.getGxjHyfl(SysTableKind.HYFL);
+            //获取行业
+            List<SubIndu> subInduList = subInduService.queryTreeALl();
             //遍历subInfoTotalExcel,将subjectId替换为jsddList中code=subjectId的title
             for (SubInfoTotalExcel data : subInfoTotalExcel) {
                 if (data == null) {
@@ -650,15 +654,42 @@ public class SubInfoExportController extends BaseController {
                 String subjectId = data.getSubjectId();
                 String induskind = data.getInduskind();
                 if (StringUtil.isNotEmpty(induskind)) {
-                    Optional<TSystable> first = gxjHyfl.stream().filter(item -> item.getId().equals(induskind)).findFirst();
-                    first.ifPresent(tSystable -> data.setInduskind(tSystable.getTitle()));
+                    //这是新的行业列表subInduList,subInduList中有children里面装的子行业,我需要将induskind替换为subInduList中的一级行业title
+                    Optional<SubIndu> first = subInduList.stream().filter(item -> item.getCode().equals(induskind)).findFirst();
+                    if (first.isPresent()) {
+                        //判断上级名称是否存在,如果存在将induskind替换为上级名称,否则将induskind替换为名称
+                        if (StringUtil.isNotEmpty(first.get().getParentTitle())) {
+                            data.setInduskind(first.get().getParentTitle());
+                        } else {
+                            data.setInduskind(first.get().getTitle());
+                        }
+                    }else {
+                        data.setInduskind("");
+                    }
+                }else {
+                    data.setInduskind("");
                 }
                 if (StringUtil.isNotEmpty(subjectId)) {
                     Optional<TSystable> first = jsddList.stream().filter(item -> item.getCode().equals(subjectId)).findFirst();
+                    if (!first.isPresent()) {
+                        data.setSubjectId("");
+                    }
                     first.ifPresent(tSystable -> data.setSubjectId(tSystable.getTitle()));
+                }else{
+                    data.setSubjectId("");
                 }
+                //将金额由万元为单位转换为亿元为单位,并且保留两位小数,避免空指针异常
+                if (data.getAmtTotal() == null) {
+                    data.setAmtTotal(new BigDecimal("0"));
+                }
+                data.setAmtTotal(data.getAmtTotal().divide(new BigDecimal("10000")).setScale(2, RoundingMode.HALF_UP));
             }
 
+            //对subInfoTotalExcel按照金额进行由小到大进行排序
+            subInfoTotalExcel.sort((o1, o2) -> {
+                return o1.getAmtTotal().compareTo(o2.getAmtTotal());
+            });
+
             //通过ExcelUtil.getBigWriter()创建Writer对象,BigExcelWriter用于大数据量的导出,不会引起溢出;
             cn.hutool.poi.excel.ExcelWriter writer = ExcelUtil.getBigWriter();
 
@@ -686,11 +717,11 @@ public class SubInfoExportController extends BaseController {
             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) {
+                if (data.getAmtTotal().compareTo(new BigDecimal(100)) >= 0) {
                     return "100亿元以上";
-                } else if (data.getAmtTotal().compareTo(new BigDecimal(500000)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(1000000)) < 0) {
+                } else if (data.getAmtTotal().compareTo(new BigDecimal(50)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(100)) < 0) {
                     return "50-100亿元";
-                } else if (data.getAmtTotal().compareTo(new BigDecimal(100000)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(500000)) < 0) {
+                } else if (data.getAmtTotal().compareTo(new BigDecimal(10)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(50)) < 0) {
                     return "10-50亿元";
                 } else {
                     return "10亿元以下";
@@ -717,16 +748,18 @@ public class SubInfoExportController extends BaseController {
             }
             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);
+            if (!"9".equals(vo.getStateFix())) {
+                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);
             }
-            finalDataMap.put("按金额划分", moneyData);
 
             List<List<String>> industryData = CollUtil.newArrayList();
             for (Map.Entry<String, List<SubInfoTotalExcel>> subInfoListEntry : industryList.entrySet()) {
@@ -976,6 +1009,14 @@ public class SubInfoExportController extends BaseController {
 
             // 获取数据
             List<SubInfoFixDetail> subInfoTotalExcel = subInfoService.exportFixDetailExcel(vo);
+            if (CollUtil.isEmpty(subInfoTotalExcel)){
+                subInfoTotalExcel = CollUtil.newArrayList();
+            }
+
+            //遍历subInfoTotalExcel将万元转换为亿元
+            subInfoTotalExcel.forEach(item -> {
+                item.setAmtTotal(item.getAmtTotal().divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
+            });
 
             // 写入标题行
             List<String> titleRow = CollUtil.newArrayList("四个一批工业项目表");
@@ -989,6 +1030,15 @@ public class SubInfoExportController extends BaseController {
                 sheet.setColumnWidth(i, defaultColumnWidth * 256); // 其他列保持默认宽度
             }
 
+            //写入合计行数据
+            String total = "合计(" + subInfoTotalExcel.size() + ")";
+            //计算总金额
+            BigDecimal totalAmt = subInfoTotalExcel.stream().map(SubInfoFixDetail::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
+            List<String> totalRow = CollUtil.newArrayList(total,total,total,total,totalAmt.toString(),"","","","");
+            writer.write(totalRow, true);
+            writer.merge(1, 1, 0, 7, null, true);
+
+
             // 自定义标题别名
             writer.addHeaderAlias("id", "序号");
             writer.addHeaderAlias("subName", "项目名称");
@@ -1018,6 +1068,104 @@ public class SubInfoExportController extends BaseController {
         }
     }
 
+    /**
+     * 导出重点项目储备明细表
+     *
+     * @param response
+     * @param vo
+     */
+    @PostMapping("/exportFixCbDetailExcel")
+    public void exportFixCbDetailExcel(HttpServletResponse response, @RequestBody SubInfoQueryTzVO vo) throws IOException {
+
+        // 设置响应头
+        response.setContentType("application/vnd.ms-excel;charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("重点项目调度-项目数据.xlsx", "UTF-8"));
+
+        try (cn.hutool.poi.excel.ExcelWriter writer = ExcelUtil.getBigWriter();
+             ServletOutputStream out = response.getOutputStream()) {
+
+            // 获取数据
+            List<SubInfoFixCbDetail> subInfoTotalExcel = subInfoService.exportFixCbDetailExcel(vo);
+
+            // 写入标题行
+            writer.writeHeadRow(CollUtil.newArrayList("四个一批工业项目表"));
+            writer.merge(0, 0, 0, 6, "四个一批工业项目表(储备项目库)", true);
+
+            // 写入子标题行
+            writer.writeHeadRow(CollUtil.newArrayList("序号", "项目名称", "项目所在地", "项目建设内容", "计划总投资(亿元)", "进展情况", "备注"));
+
+            // 设置每列的默认宽度
+            SXSSFSheet sheet = ((SXSSFWorkbook) writer.getWorkbook()).getSheetAt(0);
+            int defaultColumnWidth = 40; // 默认宽度为20个字符
+            for (int i = 0; i < 7; i++) {
+                sheet.setColumnWidth(i, defaultColumnWidth * 256); // 其他列保持默认宽度
+            }
+
+            // 写入合计行
+            BigDecimal totalAmt = subInfoTotalExcel.stream()
+                    .map(SubInfoFixCbDetail::getAmtTotal)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+            writer.writeRow(CollUtil.newArrayList(
+                    "合计(" + subInfoTotalExcel.size() + ")", "", "", "", totalAmt.toString(), "", ""));
+            writer.merge(2, 2, 0, 3, null, true);
+
+
+            //对数据根据行业进行分组
+            Map<String, List<SubInfoFixCbDetail>> hyflGroupData = subInfoTotalExcel.stream().collect(Collectors.groupingBy(SubInfoFixCbDetail::getIndusKind));
+            int startRow = 3;
+            int titleNumber = 1;
+            //初始化值
+            List<List<String>> valueList = new ArrayList<>();
+            //需要合并行的集合
+            List<Integer> mergeRowList = new ArrayList<>();
+            for (Map.Entry<String, List<SubInfoFixCbDetail>> entry : hyflGroupData.entrySet()) {
+                String key = entry.getKey();
+                List<SubInfoFixCbDetail> value = entry.getValue();
+
+                //我需要将key进行拼接,例如这是第1个key,前面就加一个中文一
+                String newKey = StringUtils.toChineseNumber(titleNumber++) + "、" + key + "(" + value.size() + ")";
+
+                //遍历value将id设置为从1开始的值,并计算总金额
+                BigDecimal hyflTotalAmt = BigDecimal.ZERO;
+                for (int i = 0; i < value.size(); i++) {
+                    value.get(i).setId(String.valueOf(i + 1));
+                    hyflTotalAmt = hyflTotalAmt.add(value.get(i).getAmtTotal());
+
+                }
+
+                //写入行业标题行
+                List<String> hyflTitleRow = CollUtil.newArrayList(newKey,newKey,newKey,newKey,hyflTotalAmt.toString(),"","");
+                valueList.add(hyflTitleRow);
+                mergeRowList.add(startRow);
+                startRow++;
+
+                //将value转换为
+                List<List<String>> data = value.stream().map(subInfoFixCbDetail -> {
+                    return CollUtil.newArrayList(subInfoFixCbDetail.getId(), subInfoFixCbDetail.getSubName(), subInfoFixCbDetail.getSubjectId(), subInfoFixCbDetail.getContent(), subInfoFixCbDetail.getAmtTotal().toString(), subInfoFixCbDetail.getProgress(), subInfoFixCbDetail.getRemark());
+                }).collect(Collectors.toList());
+                valueList.addAll(data);
+                startRow += value.size();
+            }
+
+            //根据合并行进行合并
+            for (int i = 0; i < mergeRowList.size(); i++) {
+                writer.merge(mergeRowList.get(i), mergeRowList.get(i), 0, 3, null, true);
+            }
+
+            //写入行业明细行
+            writer.write(valueList, true);
+            // 输出到客户端
+            writer.flush(out, true);
+
+        } catch (IOException e) {
+            // 处理 IO 异常
+            handleErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "导出 Excel 文件时出现错误:" + e.getMessage());
+        } catch (Exception e) {
+            // 处理其他异常
+            handleErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST, "请求参数错误或发生其他错误:" + e.getMessage());
+        }
+    }
+
     private void handleErrorResponse(HttpServletResponse response, int statusCode, String errorMessage) throws IOException {
         response.setStatus(statusCode);
         response.setContentType("text/plain;charset=UTF-8");

+ 4 - 164
projects/src/main/webapp/vmodules/subject/subInfo/tz/year_reserve.jsp

@@ -111,29 +111,7 @@
                                         </div>
                                     </div>
                                 </div>
-                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                    <div class="layui-form-item">
-                                        <label class="layui-form-label label-longers">领导</label>
-                                        <div class="layui-input-block">
-                                            <input type="text" name="leaderName" placeholder="请输入领导姓名"
-                                                   autocomplete="off"
-                                                   class="layui-input">
-                                        </div>
-                                    </div>
-                                </div>
-                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                    <div class="layui-form-item">
-                                        <label class="layui-form-label label-longers required">投资类型</label>
-                                        <div class="layui-input-block">
-                                            <select name="kindNature">
-                                                <option value="">请选择</option>
-                                                <c:forEach items="${TZXZ }" var="hy">
-                                                    <option value="${hy.code }">${hy.title }</option>
-                                                </c:forEach>
-                                            </select>
-                                        </div>
-                                    </div>
-                                </div>
+
                                 <div class="layui-col-xs3 layui-col-sm3 layui-col-md3" style="display:none;">
                                     <div class="layui-form-item">
                                         <label class="layui-form-label label-longers required">项目类型</label>
@@ -142,64 +120,7 @@
                                         </div>
                                     </div>
                                 </div>
-                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                    <div class="layui-form-item">
-                                        <label class="layui-form-label label-longers required">月份</label>
-                                        <div class="layui-input-block">
-                                            <select id="month" name="month">
-                                                <option value="">请选择</option>
-                                                <option value="1">1月</option>
-                                                <option value="2">2月</option>
-                                                <option value="3">3月</option>
-                                                <option value="4">4月</option>
-                                                <option value="5">5月</option>
-                                                <option value="6">6月</option>
-                                                <option value="7">7月</option>
-                                                <option value="8">8月</option>
-                                                <option value="9">9月</option>
-                                                <option value="10">10月</option>
-                                                <option value="11">11月</option>
-                                                <option value="12">12月</option>
-                                            </select>
-                                        </div>
-                                    </div>
-                                </div>
-                                <c:if test="${isHydw}">
-                                    <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                        <div class="layui-form-item">
-                                            <label class="layui-form-label label-longers required">预警灯</label>
-                                            <div class="layui-input-block">
-                                                <div id="light"></div>
-                                            </div>
-                                        </div>
-                                    </div>
-                                </c:if>
-                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                    <div class="layui-form-item">
-                                        <label class="layui-form-label label-longers required">建设性质</label>
-                                        <div class="layui-input-block">
-                                            <select name="propKind">
-                                                <option value="">请选择</option>
-                                                <c:forEach items="${JSXZ}" var="js">
-                                                    <option value="${js.code }">${js.title }</option>
-                                                </c:forEach>
-                                            </select>
-                                        </div>
-                                    </div>
-                                </div>
-                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                    <div class="layui-form-item">
-                                        <label class="layui-form-label label-longers required">资金来源</label>
-                                        <div class="layui-input-block">
-                                            <select name="zjly" lay-search="">
-                                                <option value="">请选择</option>
-                                                <c:forEach items="${ZJLY }" var="zj">
-                                                    <option value="${zj.id }">${zj.title }</option>
-                                                </c:forEach>
-                                            </select>
-                                        </div>
-                                    </div>
-                                </div>
+
                                 <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 ">
                                     <div class="layui-form-item">
                                         <label class="layui-form-label label-longers required">所属行业</label>
@@ -221,19 +142,7 @@
                                         </div>
                                     </div>
                                 </div>
-                                <c:if test="${isHydw }">
-                                    <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                        <div class="layui-form-item">
-                                            <label class="layui-form-label label-longers">是否分管</label>
-                                            <div class="layui-input-block">
-                                                <select name="blSub">
-                                                    <option value="false">所有项目</option>
-                                                    <option value="true">是</option>
-                                                </select>
-                                            </div>
-                                        </div>
-                                    </div>
-                                </c:if>
+
                                 <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 ">
                                     <div class="layui-form-item">
                                         <label class="layui-form-label label-longers">项目单位</label>
@@ -259,52 +168,6 @@
                                 </div>
 
 
-                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                    <div class="layui-form-item">
-                                        <label class="layui-form-label label-longers">项目状态</label>
-                                        <div class="layui-input-block">
-                                            <select name="status">
-                                                <option value="">请选择</option>
-                                                <option value="1">项目前期</option>
-                                                <option value="6">待开工</option>
-                                                <option value="7">施工中</option>
-                                                <option value="8">暂停施工</option>
-                                                <option value="A">已竣工</option>
-                                            </select>
-                                        </div>
-                                    </div>
-                                </div>
-                                <%--                   <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                                       <div class="layui-form-item">
-                                                           <label class="layui-form-label label-longers required">资金来源</label>
-                                                           <div class="layui-input-block">
-                                                               <select name="zjly" lay-search="">
-                                                                   <option value="">请选择</option>
-                                                                   <c:forEach items="${ZJLY }" var="zj">
-                                                                       <option value="${zj.id }">${zj.title }</option>
-                                                                   </c:forEach>
-                                                               </select>
-                                                           </div>
-                                                       </div>
-                                                   </div>--%>
-                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 hiddenParam">
-                                    <div class="layui-form-item">
-                                        <label class="layui-form-label label-longers ">偏离度</label>
-                                        <div class="layui-input-block time_box">
-                                            <input type="text" id="offsetMin" name="offsetMin"
-                                                   placeholder="请输入最小偏离度"
-                                                   autocomplete="off"
-                                                   class="layui-input" value="${offsetMin}">
-                                            <span class="split_txt">至</span>
-                                            <input type="text" id="offsetMax" name="offsetMax"
-                                                   placeholder="请输入最大偏离度"
-                                                   autocomplete="off"
-                                                   class="layui-input" value="${offsetMax}">
-                                        </div>
-                                    </div>
-                                </div>
-
-
                                 <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 ">
                                     <div class="layui-form-item">
                                         <label class="layui-form-label label-longers required">年份</label>
@@ -434,14 +297,6 @@
                          </label>--%>
                     </div>
                     <div style="display: flex">
-                        <label class="juli">
-                            投资进度<span class="lanse-first">{{beginRate.amtRate}}%</span>
-                            <div class="progress-div">
-                                <div class="layui-progress">
-                                    <div class="layui-progress-bar" :style="'width:'+beginRate.amtRate+'%'"></div>
-                                </div>
-                            </div>
-                        </label>
                         <label class="juli">
                             年初计划<span class="lanse-first">{{beginRate.yearAmt}}亿元</span>
                             <div class="progress-div">
@@ -923,18 +778,6 @@
                     if (params) {
                         layui.form.val("searchForm", JSON.parse(params));
                     }
-                    if (${ isHydw }) {
-                        this.light = layui.xmSelect.render({
-                            el: "#light",
-                            language: 'zn',
-                            data: [
-                                /*       {value: '0', name: '绿灯'},*/
-                                {value: '1', name: '黄灯'},
-                                {value: '2', name: '红灯'}
-                            ]
-                        })
-                    }
-                    ;
                     document.getElementById("exportId", function () {
                         self.showExport = true;
                         console.log('移入了')
@@ -1086,9 +929,6 @@
                         param.beginDate = param.year + "-01-01";
                         param.endDate = param.year + "-12-31";
                     }
-                    if (this.light) {
-                        param.light = this.light.getValue("valueStr");
-                    }
                     if (this.indusKind) {
                         param.indusKind = this.indusKind.getValue("valueStr");
                     }
@@ -1626,7 +1466,7 @@
                     var param = this.getSearchParams();
                     param.stateFix = this.getSearchParams().fixCat;
                     param.isFix = '1';
-                    App.common.utils.downFile(App.getUrl("/subInfoExport/exportFixDetailExcel"), "POST", param, "重点项目-储备明细表.xlsx", "导出失败");
+                    App.common.utils.downFile(App.getUrl("/subInfoExport/exportFixCbDetailExcel"), "POST", param, "重点项目-储备明细表.xlsx", "导出失败");
                 },
                 search: function () {
                     var param = layui.form.getValue("searchForm");