|
@@ -8,6 +8,7 @@ import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
@@ -16,6 +17,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil;
|
|
|
import cn.afterturn.easypoi.word.entity.MyXWPFDocument;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
@@ -30,10 +32,9 @@ import com.rtrh.common.util.StringUtil;
|
|
|
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.LogOperate;
|
|
|
-import com.rtrh.projects.modules.projects.po.SubIndu;
|
|
|
-import com.rtrh.projects.modules.projects.po.SubInfoGxj;
|
|
|
-import com.rtrh.projects.modules.projects.service.ILogOperateService;
|
|
|
+import com.rtrh.projects.modules.projects.po.*;
|
|
|
+import com.rtrh.projects.modules.projects.service.*;
|
|
|
+import com.rtrh.projects.modules.projects.vo.LogOperateVO;
|
|
|
import com.rtrh.projects.modules.projects.vo.StatusChangeCountersVO;
|
|
|
import com.rtrh.projects.modules.projects.vo.SubInfoTotalExcel;
|
|
|
import com.rtrh.projects.modules.projects.vo.export.*;
|
|
@@ -57,6 +58,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
|
|
+import org.apache.poi.xwpf.usermodel.XWPFRun;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -66,9 +68,6 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import com.rtrh.common.util.CollectionUtil;
|
|
|
import com.rtrh.core.repository.Page;
|
|
|
-import com.rtrh.projects.modules.projects.service.SubInfoExportService;
|
|
|
-import com.rtrh.projects.modules.projects.service.SubInfoQueryService;
|
|
|
-import com.rtrh.projects.modules.projects.service.SubInfoService;
|
|
|
import com.rtrh.projects.modules.projects.vo.SubInfoQueryTzVO;
|
|
|
import com.rtrh.projects.modules.system.enums.SysTableKind;
|
|
|
import com.rtrh.projects.modules.system.po.TSystable;
|
|
@@ -107,6 +106,11 @@ public class SubInfoExportController extends BaseController {
|
|
|
private HttpServletResponse response;
|
|
|
@Autowired
|
|
|
private ILogOperateService logOperateService;
|
|
|
+ @Autowired
|
|
|
+ private SubPreNewService subPreNewService;
|
|
|
+ @Autowired
|
|
|
+ private SubRptContService subRptContService;
|
|
|
+
|
|
|
/**
|
|
|
* 导出汇总表
|
|
|
*
|
|
@@ -871,12 +875,253 @@ public class SubInfoExportController extends BaseController {
|
|
|
|
|
|
return result.toString();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新建库 导出明细
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @PostMapping("/exportNewDetailExcel")
|
|
|
+ public void exportNewDetailExcel(@RequestBody SubInfoQueryTzVO queryVO) {
|
|
|
+ queryVO.setSubjectAuthIds(getSubjectIds());
|
|
|
+ List<SubInfoGxj> list = subInfoQueryService.queryAll(getCurUser().getLoginUser(), queryVO);
|
|
|
+ // 行业字典
|
|
|
+ Map<String, String> hyDictMap = subInduService.queryParentAll().stream().collect(Collectors.toMap(SubIndu::getCode, SubIndu::getTitle));
|
|
|
+ // 按行业分组
|
|
|
+ Map<String, List<SubInfoGxj>> groupMap = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(e -> {
|
|
|
+ if (StringUtils.isNotBlank(e.getIndusKind())){
|
|
|
+ return e.getIndusKind().substring(0, 2);
|
|
|
+ }
|
|
|
+ return "未知行业";
|
|
|
+ }));
|
|
|
+ // 查询手续
|
|
|
+ List<SubPreNew> subPreNewList = subPreNewService.findList();
|
|
|
+ Map<String, List<SubPreNew>> subIdGroups = subPreNewList.stream().collect(Collectors.groupingBy(SubPreNew::getSubId));
|
|
|
+
|
|
|
+ ExportParams exportParams = new ExportParams("“四个一批”工业项目表(新建项目库)","新建项目库",ExcelType.XSSF);
|
|
|
+ exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
+
|
|
|
+ List<SubInfoXjVO> exportList = new ArrayList<>();
|
|
|
+ // 合计行
|
|
|
+ SubInfoXjVO hjCount = BeanUtils.instantiateClass(SubInfoXjVO.class);
|
|
|
+ hjCount.setIndex(String.format("合计(%s个)", list.size()));
|
|
|
+ BigDecimal total = list.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getAmtTotal()), BigDecimal::add);
|
|
|
+ hjCount.setAmtTotal(convertAmount(total));
|
|
|
+ exportList.add(hjCount);
|
|
|
+
|
|
|
+ int index = 1;
|
|
|
+ List<Integer> allSize = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<SubInfoGxj>> entry : groupMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ List<SubInfoGxj> value = entry.getValue();
|
|
|
+ List<SubInfoXjVO> hyList = new ArrayList<>();
|
|
|
+ // 行业合计行
|
|
|
+ SubInfoXjVO hyCount = BeanUtils.instantiateClass(SubInfoXjVO.class);
|
|
|
+ hyCount.setIndex(String.format("%s、%s( %s个 )", toChineseNumber(index), hyDictMap.getOrDefault(key, key), value.size()));
|
|
|
+ BigDecimal reduce = value.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getAmtTotal()), BigDecimal::add);
|
|
|
+ hyCount.setAmtTotal(convertAmount(reduce));
|
|
|
+ // 每条数据行
|
|
|
+ hyList.add(hyCount);
|
|
|
+ for (int i = 0; i < value.size(); i++) {
|
|
|
+ SubInfoGxj subInfoGxj = value.get(i);
|
|
|
+ SubInfoXjVO vo = BeanUtils.instantiateClass(SubInfoXjVO.class);
|
|
|
+ BeanUtils.copyProperties(subInfoGxj, vo);
|
|
|
+ vo.setAmtTotal(convertAmount(subInfoGxj.getAmtTotal()));
|
|
|
+ vo.setIndex(i + 1 + "");
|
|
|
+ SubInfoXjVO.PreNewInfo preNewInfo = new SubInfoXjVO.PreNewInfo();
|
|
|
+ vo.setPreNewInfo(Collections.singletonList(preNewInfo));
|
|
|
+ List<SubPreNew> preNews = subIdGroups.get(subInfoGxj.getSubId());
|
|
|
+ if (CollUtil.isNotEmpty(preNews)){
|
|
|
+ preNews.forEach(e -> {
|
|
|
+ if ("3".equals(e.getPreFlowId()) || "5".equals(e.getPreFlowId())) {
|
|
|
+ preNewInfo.setRecord(e.getDateConfirm());
|
|
|
+ } else if ("2".equals(e.getPreFlowId())) {
|
|
|
+ preNewInfo.setPrePlan(e.getDateConfirm());
|
|
|
+ } else if ("13".equals(e.getPreFlowId())) {
|
|
|
+ preNewInfo.setProPlanPermit(e.getDateConfirm());
|
|
|
+ } else if ("14".equals(e.getPreFlowId())) {
|
|
|
+ preNewInfo.setWorkPermit(e.getDateConfirm());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ hyList.add(vo);
|
|
|
+ }
|
|
|
+ // 添加前计算行业类型合并行
|
|
|
+ allSize.add(exportList.size() + 3);
|
|
|
+ // 合计(832个)行
|
|
|
+ allSize.add(3);
|
|
|
+ exportList.addAll(hyList);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoXjVO.class, exportList);
|
|
|
+ extracted(response, list, workbook, allSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在建库 导出明细
|
|
|
+ */
|
|
|
+ @PostMapping("/exportMainDetailExcel")
|
|
|
+ public void exportMainDetailExcel(@RequestBody SubInfoQueryTzVO queryVO) {
|
|
|
+ queryVO.setSubjectAuthIds(getSubjectIds());
|
|
|
+ List<SubInfoGxj> list = subInfoQueryService.queryAll(getCurUser().getLoginUser(), queryVO);
|
|
|
+ // 行业字典
|
|
|
+ Map<String, String> hyDictMap = subInduService.queryParentAll().stream().collect(Collectors.toMap(SubIndu::getCode, SubIndu::getTitle));
|
|
|
+ // 按行业分组
|
|
|
+ Map<String, List<SubInfoGxj>> groupMap = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(e -> {
|
|
|
+ if (StringUtils.isNotBlank(e.getIndusKind())){
|
|
|
+ return e.getIndusKind().substring(0, 2);
|
|
|
+ }
|
|
|
+ return "未知行业";
|
|
|
+ }));
|
|
|
+
|
|
|
+ ExportParams exportParams = new ExportParams("“四个一批”工业项目表(在建项目库)","在建项目库",ExcelType.XSSF);
|
|
|
+ exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
+ List<SubInfoZjVO> exportList = new ArrayList<>();
|
|
|
+ // 合计行
|
|
|
+ SubInfoZjVO hjCount = BeanUtils.instantiateClass(SubInfoZjVO.class);
|
|
|
+ hjCount.setIndex(String.format("合计(%s个)", list.size()));
|
|
|
+ BigDecimal total = list.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getAmtTotal()), BigDecimal::add);
|
|
|
+ hjCount.setAmtTotal(convertAmount(total));
|
|
|
+ exportList.add(hjCount);
|
|
|
+
|
|
|
+ // 每月工程完成量
|
|
|
+ int year = DateUtil.thisYear();
|
|
|
+ List<RptCont> rptContList = subRptContService.listByYear(year);
|
|
|
+ Map<String, List<RptCont>> rptContGroup = rptContList.stream().collect(Collectors.groupingBy(RptCont::getSubId));
|
|
|
+
|
|
|
+ int index = 1;
|
|
|
+ List<Integer> allSize = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<SubInfoGxj>> entry : groupMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ List<SubInfoGxj> value = entry.getValue();
|
|
|
+ List<SubInfoZjVO> hyList = new ArrayList<>();
|
|
|
+ // 行业合计行
|
|
|
+ SubInfoZjVO hyCount = BeanUtils.instantiateClass(SubInfoZjVO.class);
|
|
|
+ hyCount.setIndex(String.format("%s、%s( %s个 )", toChineseNumber(index), hyDictMap.getOrDefault(key, key), value.size()));
|
|
|
+ BigDecimal reduce = value.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getAmtTotal()), BigDecimal::add);
|
|
|
+ hyCount.setAmtTotal(convertAmount(reduce));
|
|
|
+ // 每条数据行
|
|
|
+ hyList.add(hyCount);
|
|
|
+ for (int i = 0; i < value.size(); i++) {
|
|
|
+ SubInfoGxj subInfoGxj = value.get(i);
|
|
|
+ SubInfoZjVO vo = BeanUtils.instantiateClass(SubInfoZjVO.class);
|
|
|
+ BeanUtils.copyProperties(subInfoGxj, vo);
|
|
|
+ vo.setAmtTotal(convertAmount(subInfoGxj.getAmtTotal()));
|
|
|
+ vo.setIndex(i + 1 + "");
|
|
|
+
|
|
|
+ // 每月完成工程量
|
|
|
+ List<RptCont> subRptConts = rptContGroup.get(subInfoGxj.getSubId());
|
|
|
+ if (CollUtil.isNotEmpty(subRptConts)) {
|
|
|
+ SubInfoZjVO.MonthNumBl monthNumBl = new SubInfoZjVO.MonthNumBl();
|
|
|
+ Map<String, BigDecimal> map = subRptConts.stream().collect(Collectors.toMap(RptCont::getKjMonth, RptCont::getNumBl, (a, b) -> a));
|
|
|
+ monthNumBl.setMonth1(map.getOrDefault(DateUtil.thisYear() + "01", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth2(map.getOrDefault(DateUtil.thisYear() + "02", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth3(map.getOrDefault(DateUtil.thisYear() + "03", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth4(map.getOrDefault(DateUtil.thisYear() + "04", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth5(map.getOrDefault(DateUtil.thisYear() + "05", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth6(map.getOrDefault(DateUtil.thisYear() + "06", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth7(map.getOrDefault(DateUtil.thisYear() + "07", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth8(map.getOrDefault(DateUtil.thisYear() + "08", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth9(map.getOrDefault(DateUtil.thisYear() + "09", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth10(map.getOrDefault(DateUtil.thisYear() + "10", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth11(map.getOrDefault(DateUtil.thisYear() + "11", BigDecimal.ZERO) + "%");
|
|
|
+ monthNumBl.setMonth12(map.getOrDefault(DateUtil.thisYear() + "12", BigDecimal.ZERO) + "%");
|
|
|
+ vo.setMonthNumBlList(Collections.singletonList(monthNumBl));
|
|
|
+ } else {
|
|
|
+ SubInfoZjVO.MonthNumBl monthNumBl = new SubInfoZjVO.MonthNumBl();
|
|
|
+ monthNumBl.setMonth1(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth2(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth3(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth4(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth5(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth6(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth7(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth8(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth9(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth10(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth11(BigDecimal.ZERO + "%");
|
|
|
+ monthNumBl.setMonth12(BigDecimal.ZERO + "%");
|
|
|
+ vo.setMonthNumBlList(Collections.singletonList(monthNumBl));
|
|
|
+ }
|
|
|
+ hyList.add(vo);
|
|
|
+ }
|
|
|
+ // 添加前计算合并行
|
|
|
+ allSize.add(exportList.size() + 3);
|
|
|
+ allSize.add(3);
|
|
|
+ exportList.addAll(hyList);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ // 构建表头
|
|
|
+ List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>(){{
|
|
|
+ add(new ExcelExportEntity("序号", "index", 12));
|
|
|
+ add(new ExcelExportEntity("项目名称", "subName", 20));
|
|
|
+ add(new ExcelExportEntity("项目所在地", "subjectName", 15));
|
|
|
+ add(new ExcelExportEntity("项目建设内容", "content", 70));
|
|
|
+ add(new ExcelExportEntity("计划总投资(亿元)", "amtTotal", 20));
|
|
|
+ add(new ExcelExportEntity("建成投产时间", "endDate", 15));
|
|
|
+
|
|
|
+ ExcelExportEntity monthNumBlEntity = new ExcelExportEntity(year + "年1-12月项目工程进度(每月完成工程量)", "monthNumBlList", 12);
|
|
|
+ List<ExcelExportEntity> subHeadEntities = new ArrayList<ExcelExportEntity>(){{
|
|
|
+ add(new ExcelExportEntity("1月", "month1"));
|
|
|
+ add(new ExcelExportEntity("2月", "month2"));
|
|
|
+ add(new ExcelExportEntity("3月", "month3"));
|
|
|
+ add(new ExcelExportEntity("4月", "month4"));
|
|
|
+ add(new ExcelExportEntity("5月", "month5"));
|
|
|
+ add(new ExcelExportEntity("6月", "month6"));
|
|
|
+ add(new ExcelExportEntity("7月", "month7"));
|
|
|
+ add(new ExcelExportEntity("8月", "month8"));
|
|
|
+ add(new ExcelExportEntity("9月", "month9"));
|
|
|
+ add(new ExcelExportEntity("10月", "month10"));
|
|
|
+ add(new ExcelExportEntity("11月", "month11"));
|
|
|
+ add(new ExcelExportEntity("12月", "month12"));
|
|
|
+ }};
|
|
|
+ monthNumBlEntity.setList(subHeadEntities);
|
|
|
+ add(monthNumBlEntity);
|
|
|
+
|
|
|
+ add(new ExcelExportEntity("年度投资(亿元)", "yearPlanAmt", 12));
|
|
|
+ add(new ExcelExportEntity("进展情况", "progress", 30));
|
|
|
+ add(new ExcelExportEntity("牵头部门", "deptName", 30));
|
|
|
+ add(new ExcelExportEntity("责任领导", "leader", 15));
|
|
|
+ add(new ExcelExportEntity("备注", "remark", 15));
|
|
|
+ }};
|
|
|
+ List<Map<String, Object>> collect = exportList.stream().map(e->{
|
|
|
+ Map<String, Object> map = BeanUtil.beanToMap(e);
|
|
|
+ Object o = map.get("endDate");
|
|
|
+ if (o != null) {
|
|
|
+ map.put("endDate", DateUtil.format((Date) o, "yyyy年MM月"));
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, collect);
|
|
|
+ extracted(response, list, workbook, allSize);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 4库/总库 导出明细
|
|
|
*
|
|
|
*/
|
|
|
@PostMapping("/exportDetailExcel")
|
|
|
public void exportDetailExcel(@RequestBody SubInfoQueryTzVO queryVO) {
|
|
|
+ WebLogAspect.content.set(String.format("页面:【项目四库管理-%s库】,执行操作:导出明细", StringUtils.isBlank(queryVO.getStatus()) ? "项目总" : SubInfoStatusEnum.getDesc(queryVO.getStatus())));
|
|
|
+ if (SubInfoStatusEnum.CB.getCode().equals(queryVO.getStatus())) {
|
|
|
+ exportCbDetailExcel(queryVO);
|
|
|
+ }else if (SubInfoStatusEnum.XJ.getCode().equals(queryVO.getStatus())){
|
|
|
+ exportNewDetailExcel(queryVO);
|
|
|
+ }else if (SubInfoStatusEnum.ZJ.getCode().equals(queryVO.getStatus())){
|
|
|
+ exportMainDetailExcel(queryVO);
|
|
|
+ } else if (SubInfoStatusEnum.TC.getCode().equals(queryVO.getStatus())) {
|
|
|
+ exportTcDetailExcel(queryVO);
|
|
|
+ } else {
|
|
|
+ exportZkDetailExcel(queryVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 总库 导出明细
|
|
|
+ */
|
|
|
+ private void exportZkDetailExcel(SubInfoQueryTzVO queryVO) {
|
|
|
WebLogAspect.content.set(String.format("页面:【项目四库管理-%s库】,执行操作:导出明细", StringUtils.isBlank(queryVO.getStatus()) ? "项目总" : SubInfoStatusEnum.getDesc(queryVO.getStatus())));
|
|
|
queryVO.setSubjectAuthIds(getSubjectIds());
|
|
|
List<SubInfoGxj> list = subInfoQueryService.queryAll(getCurUser().getLoginUser(), queryVO);
|
|
@@ -891,93 +1136,121 @@ public class SubInfoExportController extends BaseController {
|
|
|
return "未知行业";
|
|
|
}));
|
|
|
Workbook workbook;
|
|
|
- if (SubInfoStatusEnum.CB.getCode().equals(queryVO.getStatus())) {
|
|
|
- ExportParams exportParams = new ExportParams("“四个一批”工业项目表(储备项目库)", "储备项目库", ExcelType.XSSF);
|
|
|
- exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
- exportDetail(response, exportParams, SubInfoCbVO.class, list, hyDictMap, groupMap);
|
|
|
- }else if (SubInfoStatusEnum.XJ.getCode().equals(queryVO.getStatus())){
|
|
|
- ExportParams exportParams = new ExportParams("“四个一批”工业项目表(新建项目库)","新建项目库",ExcelType.XSSF);
|
|
|
- exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
- exportDetail(response, exportParams, SubInfoXjVO.class, list, hyDictMap, groupMap);
|
|
|
- }else if (SubInfoStatusEnum.ZJ.getCode().equals(queryVO.getStatus())){
|
|
|
- ExportParams exportParams = new ExportParams("“四个一批”工业项目表(在建项目库)","在建项目库",ExcelType.XSSF);
|
|
|
- exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
- exportDetail(response, exportParams, SubInfoZjVO.class, list, hyDictMap, groupMap);
|
|
|
- } else if (SubInfoStatusEnum.TC.getCode().equals(queryVO.getStatus())) {
|
|
|
- List<SubInfoTcVO> exportList = new ArrayList<>();
|
|
|
- // 合计行
|
|
|
- SubInfoTcVO hjCount = new SubInfoTcVO();
|
|
|
- hjCount.setIndex(String.format("合计(%s个)", list.size()));
|
|
|
- exportList.add(hjCount);
|
|
|
-
|
|
|
- int index = 1;
|
|
|
- List<Integer> allSize = new ArrayList<>();
|
|
|
- for (Map.Entry<String, List<SubInfoGxj>> entry : groupMap.entrySet()) {
|
|
|
- String key = entry.getKey();
|
|
|
- List<SubInfoGxj> value = entry.getValue();
|
|
|
- List<SubInfoTcVO> hyList = new ArrayList<>();
|
|
|
- // 行业合计行
|
|
|
- SubInfoTcVO hyCount = new SubInfoTcVO();
|
|
|
- hyCount.setIndex(String.format("%s、%s( %s个 )", toChineseNumber(index), hyDictMap.getOrDefault(key, key), value.size()));
|
|
|
- // 每条数据行
|
|
|
- hyList.add(hyCount);
|
|
|
- for (int i = 0; i < value.size(); i++) {
|
|
|
- SubInfoGxj subInfoGxj = value.get(i);
|
|
|
- SubInfoTcVO vo = new SubInfoTcVO();
|
|
|
- BeanUtils.copyProperties(subInfoGxj, vo);
|
|
|
- // BigDecimal divide = subInfoGxj.getAmtTotal() != null ? subInfoGxj.getAmtTotal().divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
|
|
- // vo.setAmtTotal(divide);
|
|
|
- vo.setIndex(i + 1 + "");
|
|
|
- hyList.add(vo);
|
|
|
- }
|
|
|
- // 添加前计算合并行
|
|
|
- allSize.add(exportList.size() + 2);
|
|
|
- exportList.addAll(hyList);
|
|
|
- index++;
|
|
|
+ // 项目总库
|
|
|
+ List<SubInfoZkVO> exportList = new ArrayList<>();
|
|
|
+ // 合计行
|
|
|
+ SubInfoZkVO hjCount = new SubInfoZkVO();
|
|
|
+ hjCount.setIndex(String.format("合计(%s个)", list.size()));
|
|
|
+ exportList.add(hjCount);
|
|
|
+
|
|
|
+ int index = 1;
|
|
|
+ List<Integer> allSize = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<SubInfoGxj>> entry : groupMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ List<SubInfoGxj> value = entry.getValue();
|
|
|
+ List<SubInfoZkVO> hyList = new ArrayList<>();
|
|
|
+ // 行业合计行
|
|
|
+ SubInfoZkVO hyCount = new SubInfoZkVO();
|
|
|
+ hyCount.setIndex(String.format("%s、%s( %s个 )", toChineseNumber(index), hyDictMap.getOrDefault(key, key), value.size()));
|
|
|
+ // 每条数据行
|
|
|
+ hyList.add(hyCount);
|
|
|
+ for (int i = 0; i < value.size(); i++) {
|
|
|
+ SubInfoGxj subInfoGxj = value.get(i);
|
|
|
+ SubInfoZkVO vo = new SubInfoZkVO();
|
|
|
+ BeanUtils.copyProperties(subInfoGxj, vo);
|
|
|
+ vo.setAmtTotal(convertAmount(subInfoGxj.getAmtTotal()));
|
|
|
+ vo.setIndex(i + 1 + "");
|
|
|
+ hyList.add(vo);
|
|
|
}
|
|
|
- ExportParams exportParams = new ExportParams("“四个一批”工业项目表(投产项目库)", "投产项目库", ExcelType.XSSF);
|
|
|
- exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
- // 设置默认样式(这里设置所有单元格都有边框)
|
|
|
- workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoTcVO.class, exportList);
|
|
|
- extracted(response, list, workbook, allSize);
|
|
|
- } else {
|
|
|
- // 项目总库
|
|
|
- List<SubInfoZkVO> exportList = new ArrayList<>();
|
|
|
- // 合计行
|
|
|
- SubInfoZkVO hjCount = new SubInfoZkVO();
|
|
|
- hjCount.setIndex(String.format("合计(%s个)", list.size()));
|
|
|
- exportList.add(hjCount);
|
|
|
-
|
|
|
- int index = 1;
|
|
|
- List<Integer> allSize = new ArrayList<>();
|
|
|
- for (Map.Entry<String, List<SubInfoGxj>> entry : groupMap.entrySet()) {
|
|
|
- String key = entry.getKey();
|
|
|
- List<SubInfoGxj> value = entry.getValue();
|
|
|
- List<SubInfoZkVO> hyList = new ArrayList<>();
|
|
|
- // 行业合计行
|
|
|
- SubInfoZkVO hyCount = new SubInfoZkVO();
|
|
|
- hyCount.setIndex(String.format("%s、%s( %s个 )", toChineseNumber(index), hyDictMap.getOrDefault(key, key), value.size()));
|
|
|
- // 每条数据行
|
|
|
- hyList.add(hyCount);
|
|
|
- for (int i = 0; i < value.size(); i++) {
|
|
|
- SubInfoGxj subInfoGxj = value.get(i);
|
|
|
- SubInfoZkVO vo = new SubInfoZkVO();
|
|
|
- BeanUtils.copyProperties(subInfoGxj, vo);
|
|
|
- vo.setAmtTotal(convertAmount(subInfoGxj.getAmtTotal()));
|
|
|
- vo.setIndex(i + 1 + "");
|
|
|
- hyList.add(vo);
|
|
|
- }
|
|
|
- // 添加前计算合并行
|
|
|
- allSize.add(exportList.size() + 2);
|
|
|
- exportList.addAll(hyList);
|
|
|
- index++;
|
|
|
+ // 添加前计算合并行
|
|
|
+ allSize.add(exportList.size() + 2);
|
|
|
+ allSize.add(2);
|
|
|
+ exportList.addAll(hyList);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ ExportParams exportParams = new ExportParams("“四个一批”工业项目表(项目总库)", "项目总库", ExcelType.XSSF);
|
|
|
+ exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
+ // exportParams.setHeight((short) -1);
|
|
|
+ workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoZkVO.class, exportList);
|
|
|
+ extracted(response, list, workbook, allSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 投产 导出明细
|
|
|
+ */
|
|
|
+ private void exportTcDetailExcel(SubInfoQueryTzVO queryVO) {
|
|
|
+ WebLogAspect.content.set(String.format("页面:【项目四库管理-%s库】,执行操作:导出明细", StringUtils.isBlank(queryVO.getStatus()) ? "项目总" : SubInfoStatusEnum.getDesc(queryVO.getStatus())));
|
|
|
+ queryVO.setSubjectAuthIds(getSubjectIds());
|
|
|
+ List<SubInfoGxj> list = subInfoQueryService.queryAll(getCurUser().getLoginUser(), queryVO);
|
|
|
+ // 行业字典
|
|
|
+ Map<String, String> hyDictMap = subInduService.queryParentAll().stream().collect(Collectors.toMap(SubIndu::getCode, SubIndu::getTitle));
|
|
|
+ // 按行业分组
|
|
|
+ Map<String, List<SubInfoGxj>> groupMap = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(e -> {
|
|
|
+ if (StringUtils.isNotBlank(e.getIndusKind())){
|
|
|
+ return e.getIndusKind().substring(0, 2);
|
|
|
+ }
|
|
|
+ return "未知行业";
|
|
|
+ }));
|
|
|
+ Workbook workbook;
|
|
|
+ List<SubInfoTcVO> exportList = new ArrayList<>();
|
|
|
+ // 合计行
|
|
|
+ SubInfoTcVO hjCount = new SubInfoTcVO();
|
|
|
+ hjCount.setIndex(String.format("合计(%s个)", list.size()));
|
|
|
+ exportList.add(hjCount);
|
|
|
+
|
|
|
+ int index = 1;
|
|
|
+ List<Integer> allSize = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<SubInfoGxj>> entry : groupMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ List<SubInfoGxj> value = entry.getValue();
|
|
|
+ List<SubInfoTcVO> hyList = new ArrayList<>();
|
|
|
+ // 行业合计行
|
|
|
+ SubInfoTcVO hyCount = new SubInfoTcVO();
|
|
|
+ hyCount.setIndex(String.format("%s、%s( %s个 )", toChineseNumber(index), hyDictMap.getOrDefault(key, key), value.size()));
|
|
|
+ // 每条数据行
|
|
|
+ hyList.add(hyCount);
|
|
|
+ for (int i = 0; i < value.size(); i++) {
|
|
|
+ SubInfoGxj subInfoGxj = value.get(i);
|
|
|
+ SubInfoTcVO vo = new SubInfoTcVO();
|
|
|
+ BeanUtils.copyProperties(subInfoGxj, vo);
|
|
|
+ // BigDecimal divide = subInfoGxj.getAmtTotal() != null ? subInfoGxj.getAmtTotal().divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
|
|
+ // vo.setAmtTotal(divide);
|
|
|
+ vo.setIndex(i + 1 + "");
|
|
|
+ hyList.add(vo);
|
|
|
}
|
|
|
- ExportParams exportParams = new ExportParams("“四个一批”工业项目表(项目总库)", "项目总库", ExcelType.XSSF);
|
|
|
- exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
- // exportParams.setHeight((short) -1);
|
|
|
- workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoZkVO.class, exportList);
|
|
|
- extracted(response, list, workbook, allSize);
|
|
|
+ // 添加前计算合并行
|
|
|
+ allSize.add(exportList.size() + 2);
|
|
|
+ allSize.add(2);
|
|
|
+ exportList.addAll(hyList);
|
|
|
+ index++;
|
|
|
}
|
|
|
+ ExportParams exportParams = new ExportParams("“四个一批”工业项目表(投产项目库)", "投产项目库", ExcelType.XSSF);
|
|
|
+ exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
+ // 设置默认样式(这里设置所有单元格都有边框)
|
|
|
+ workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoTcVO.class, exportList);
|
|
|
+ extracted(response, list, workbook, allSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 储备库 导出明细
|
|
|
+ */
|
|
|
+ private void exportCbDetailExcel(SubInfoQueryTzVO queryVO) {
|
|
|
+ queryVO.setSubjectAuthIds(getSubjectIds());
|
|
|
+ List<SubInfoGxj> list = subInfoQueryService.queryAll(getCurUser().getLoginUser(), queryVO);
|
|
|
+ // 行业字典
|
|
|
+ Map<String, String> hyDictMap = subInduService.queryParentAll().stream().collect(Collectors.toMap(SubIndu::getCode, SubIndu::getTitle));
|
|
|
+ // 按行业分组
|
|
|
+ Map<String, List<SubInfoGxj>> groupMap = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(e -> {
|
|
|
+ if (StringUtils.isNotBlank(e.getIndusKind())){
|
|
|
+ return e.getIndusKind().substring(0, 2);
|
|
|
+ }
|
|
|
+ return "未知行业";
|
|
|
+ }));
|
|
|
+ ExportParams exportParams = new ExportParams("“四个一批”工业项目表(储备项目库)", "储备项目库", ExcelType.XSSF);
|
|
|
+ exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
+ exportDetail(response, exportParams, SubInfoCbVO.class, list, hyDictMap, groupMap);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1009,7 +1282,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
statusGroupList.forEach((key, value) -> {
|
|
|
SubInfoStatusEnum anEnum = SubInfoStatusEnum.getEnum(key);
|
|
|
String statusRate = new BigDecimal(value.size()).multiply(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, RoundingMode.HALF_UP) + "%";
|
|
|
- BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP);
|
|
|
String format = String.format("%s项目%s个,占工业项目总数的%s,计划总投资%s亿元;", anEnum.getDesc(), value.size(), statusRate, totalAmt);
|
|
|
statusStrBuilder.append(format);
|
|
|
});
|
|
@@ -1021,7 +1294,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
Map<String, List<SubInfoTotalExcel>> subjectGroupList = list.stream().collect(Collectors.groupingBy(SubInfoTotalExcel::getSubjectId));
|
|
|
subjectGroupList.forEach((key, value) -> {
|
|
|
String rate = new BigDecimal(value.size()).multiply(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, RoundingMode.HALF_UP) + "%";
|
|
|
- BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP);
|
|
|
String format = String.format("%s%s个,占工业项目总数的%s,计划总投资%s亿元;", jsddMap.get(key), value.size(), rate, totalAmt);
|
|
|
subjectStrBuilder.append(format);
|
|
|
});
|
|
@@ -1044,7 +1317,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
}));
|
|
|
scaleGroupList.forEach((key, value) -> {
|
|
|
String rate = new BigDecimal(value.size()).multiply(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, RoundingMode.HALF_UP) + "%";
|
|
|
- BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP);
|
|
|
String format = String.format("计划总投资%s项目%s个,占工业项目总数的%s,计划总投资%s亿元;", key, value.size(), rate, totalAmt);
|
|
|
scaleStrBuilder.append(format);
|
|
|
});
|
|
@@ -1064,7 +1337,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
}));
|
|
|
hyGroupList.forEach((key, value) -> {
|
|
|
String rate = new BigDecimal(value.size()).multiply(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, RoundingMode.HALF_UP) + "%";
|
|
|
- BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalAmt = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP);
|
|
|
String format = String.format("%s项目%s个,占工业项目总数的%s,计划总投资%s亿元;", hyflMap.getOrDefault(key, key), value.size(), rate, totalAmt);
|
|
|
hyStrBuilder.append(format);
|
|
|
});
|
|
@@ -1072,7 +1345,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
data.put("hyStr", hyStr);
|
|
|
|
|
|
// 一、项目转化情况
|
|
|
- List<LogOperate> logList = logOperateService.queryByYear(year);
|
|
|
+ List<LogOperateVO> logList = logOperateService.queryByYear(year);
|
|
|
StatusChangeCountersVO totalCounterVo = new StatusChangeCountersVO();
|
|
|
addNum(logList, totalCounterVo);
|
|
|
data.put("cbToXjNum", totalCounterVo.cbToXjNum);
|
|
@@ -1082,7 +1355,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
data.put("xjToCbNum", totalCounterVo.xjToCbNum);
|
|
|
data.put("rgToZjNum", totalCounterVo.rgToZjNum);
|
|
|
|
|
|
- List<LogOperate> lastLogList = logList.stream().filter(logOperate -> DateUtil.month(logOperate.getCreateTime()) < DateUtil.month(new Date())).collect(Collectors.toList());
|
|
|
+ List<LogOperateVO> lastLogList = logList.stream().filter(logOperate -> DateUtil.month(logOperate.getCreateTime()) < DateUtil.month(new Date())).collect(Collectors.toList());
|
|
|
StatusChangeCountersVO lastCounterVo = new StatusChangeCountersVO();
|
|
|
addNum(lastLogList, lastCounterVo);
|
|
|
data.put("lastCbToXjNum", lastCounterVo.cbToXjNum);
|
|
@@ -1092,54 +1365,92 @@ public class SubInfoExportController extends BaseController {
|
|
|
data.put("lastXjToCbNum", lastCounterVo.xjToCbNum);
|
|
|
data.put("lastRgToZjNum", lastCounterVo.rgToZjNum);
|
|
|
|
|
|
- // 分属地看
|
|
|
+
|
|
|
String text = "%s年1-%s月,%s储备项目转新建%s个、新建项目转在建%s个、在建项目转投产%s个、投产项目转入规%s个,新建项目降级为储备%s个、入规项目转为在建%s个。" +
|
|
|
"其中,%s月当月,储备项目转新建%s个、新建项目转在建%s个、在建项目转投产%s个、投产项目转入规%s个,新建项目降级为储备%s个、入规项目转为在建%s个。" +
|
|
|
"1-%s月,项目开工率%s、投产率%s、入规率%s,较1-(%s)月,分别增长%s、%s、%s个百分点。";
|
|
|
- String subjectZhStr = String.format(text,
|
|
|
- year, month, "subjectName", totalCounterVo.cbToXjNum, totalCounterVo.xjToZjNum, totalCounterVo.zjToTcNum, totalCounterVo.tcToRgNum, totalCounterVo.xjToCbNum, totalCounterVo.rgToZjNum,
|
|
|
- month, totalCounterVo.cbToXjNum, totalCounterVo.xjToZjNum, totalCounterVo.zjToTcNum, totalCounterVo.tcToRgNum, totalCounterVo.xjToCbNum, totalCounterVo.rgToZjNum,
|
|
|
- month, "kgl", "tcl", "rgl", lastMonth, "1", "2", "3"
|
|
|
- );
|
|
|
+ // 分属地看
|
|
|
+ Map<String, List<LogOperateVO>> subjectZhGroups = logList.stream().collect(Collectors.groupingBy(LogOperateVO::getSubjectId));
|
|
|
+ StringBuilder subjectZhStr = new StringBuilder();
|
|
|
+ subjectZhGroups.forEach((key, value) -> {
|
|
|
+ StatusChangeCountersVO tempVo = new StatusChangeCountersVO();
|
|
|
+ addNum(value, tempVo);
|
|
|
+ subjectZhStr.append(String.format(text,
|
|
|
+ year, month, jsddMap.get(key), tempVo.cbToXjNum, tempVo.xjToZjNum, tempVo.zjToTcNum, tempVo.tcToRgNum, tempVo.xjToCbNum, tempVo.rgToZjNum,
|
|
|
+ month, tempVo.cbToXjNum, tempVo.xjToZjNum, tempVo.zjToTcNum, tempVo.tcToRgNum, tempVo.xjToCbNum, tempVo.rgToZjNum,
|
|
|
+ month, "0%", "0%", "0%", lastMonth, "0", "0", "0"));
|
|
|
+ subjectZhStr.append("\n").append("\t");
|
|
|
+ });
|
|
|
data.put("subjectZhStr", subjectZhStr);
|
|
|
+
|
|
|
// 分规模看
|
|
|
- String scaleZhStr = String.format(text,
|
|
|
- year, month, "计划总投资100亿元以上", totalCounterVo.cbToXjNum, totalCounterVo.xjToZjNum, totalCounterVo.zjToTcNum, totalCounterVo.tcToRgNum, totalCounterVo.xjToCbNum, totalCounterVo.rgToZjNum,
|
|
|
- month, totalCounterVo.cbToXjNum, totalCounterVo.xjToZjNum, totalCounterVo.zjToTcNum, totalCounterVo.tcToRgNum, totalCounterVo.xjToCbNum, totalCounterVo.rgToZjNum,
|
|
|
- month, "kgl", "tcl", "rgl", lastMonth, "1", "2", "3"
|
|
|
- );
|
|
|
+ Map<String, List<LogOperateVO>> scaleZhGroups = logList.stream().collect(Collectors.groupingBy(transaction -> {
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : groupBoundaries.entrySet()) {
|
|
|
+ if (transaction.getAmtTotal().compareTo(entry.getValue()) < 0) {
|
|
|
+ return entry.getKey();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "100亿元以上";
|
|
|
+ }));
|
|
|
+ StringBuilder scaleZhStr = new StringBuilder();
|
|
|
+ scaleZhGroups.forEach((key, value) -> {
|
|
|
+ StatusChangeCountersVO tempVo = new StatusChangeCountersVO();
|
|
|
+ addNum(value, tempVo);
|
|
|
+ scaleZhStr.append(String.format(text,
|
|
|
+ year, month, "计划总投资" + key, tempVo.cbToXjNum, tempVo.xjToZjNum, tempVo.zjToTcNum, tempVo.tcToRgNum, tempVo.xjToCbNum, tempVo.rgToZjNum,
|
|
|
+ month, tempVo.cbToXjNum, tempVo.xjToZjNum, tempVo.zjToTcNum, tempVo.tcToRgNum, tempVo.xjToCbNum, tempVo.rgToZjNum,
|
|
|
+ month, "0%", "0%", "0%", lastMonth, "0", "0", "0"
|
|
|
+ ));
|
|
|
+ scaleZhStr.append("\n").append("\t");
|
|
|
+ });
|
|
|
data.put("scaleZhStr", scaleZhStr);
|
|
|
+
|
|
|
// 分行业看
|
|
|
- String hyZhStr = String.format(text,
|
|
|
- year, month, "制造业", totalCounterVo.cbToXjNum, totalCounterVo.xjToZjNum, totalCounterVo.zjToTcNum, totalCounterVo.tcToRgNum, totalCounterVo.xjToCbNum, totalCounterVo.rgToZjNum,
|
|
|
- month, totalCounterVo.cbToXjNum, totalCounterVo.xjToZjNum, totalCounterVo.zjToTcNum, totalCounterVo.tcToRgNum, totalCounterVo.xjToCbNum, totalCounterVo.rgToZjNum,
|
|
|
- month, "kgl", "tcl", "rgl", lastMonth, "1", "2", "3"
|
|
|
- );
|
|
|
+ Map<String, List<LogOperateVO>> hyZhGroups = logList.stream()
|
|
|
+ .collect(Collectors.groupingBy(transaction -> {
|
|
|
+ String code = transaction.getIndusKind();
|
|
|
+ // 确保code不为空且长度至少为2
|
|
|
+ if (code == null || code.length() < 2) {
|
|
|
+ return "未知行业"; // 默认未知行业
|
|
|
+ }
|
|
|
+ return code.substring(0, 2);
|
|
|
+ }));
|
|
|
+ StringBuilder hyZhStr = new StringBuilder();
|
|
|
+ hyZhGroups.forEach((key, value) -> {
|
|
|
+ StatusChangeCountersVO tempVo = new StatusChangeCountersVO();
|
|
|
+ addNum(value, tempVo);
|
|
|
+ hyZhStr.append(String.format(text,
|
|
|
+ year, month, hyflMap.get(key), tempVo.cbToXjNum, tempVo.xjToZjNum, tempVo.zjToTcNum, tempVo.tcToRgNum, tempVo.xjToCbNum, tempVo.rgToZjNum,
|
|
|
+ month, tempVo.cbToXjNum, tempVo.xjToZjNum, tempVo.zjToTcNum, tempVo.tcToRgNum, tempVo.xjToCbNum, tempVo.rgToZjNum,
|
|
|
+ month, "0%", "0%", "0%", lastMonth, "0", "0", "0"
|
|
|
+ ));
|
|
|
+ hyZhStr.append("\n").append("\t");
|
|
|
+ });
|
|
|
data.put("hyZhStr", hyZhStr);
|
|
|
// 二、存在问题
|
|
|
// (一)项目落地方面
|
|
|
- data.put("xmldSubNameStr", "a项目、b项目、c项目");
|
|
|
- data.put("xmldNum", 3);
|
|
|
- data.put("xmldMonthNum", 3);
|
|
|
+ data.put("xmldSubNameStr", "、、");
|
|
|
+ data.put("xmldNum", 0);
|
|
|
+ data.put("xmldMonthNum", 0);
|
|
|
// (二)前期手续方面
|
|
|
- data.put("qqsxNum", 3);
|
|
|
- data.put("qqsxHpNames", "a项目、b项目、c项目");
|
|
|
- data.put("qqsxHpNum", 3);
|
|
|
- data.put("qqsxNpNames", "a项目、b项目、c项目");
|
|
|
- data.put("qqsxNpNum", 3);
|
|
|
- data.put("qqsxYdNames", "a项目、b项目、c项目");
|
|
|
- data.put("qqsxYdNum", 3);
|
|
|
+ data.put("qqsxNum", 0);
|
|
|
+ data.put("qqsxHpNames", "、、");
|
|
|
+ data.put("qqsxHpNum", 0);
|
|
|
+ data.put("qqsxNpNames", "、、");
|
|
|
+ data.put("qqsxNpNum", 0);
|
|
|
+ data.put("qqsxYdNames", "、、");
|
|
|
+ data.put("qqsxYdNum", 0);
|
|
|
// (三)工程建设方面
|
|
|
- data.put("gcjsNum", 3);
|
|
|
- data.put("gcjsZjzhNames", "a项目、b项目、c项目");
|
|
|
- data.put("gcjsZjzhNum", 3);
|
|
|
- data.put("gcjsAqsgNames", "a项目、b项目、c项目");
|
|
|
+ data.put("gcjsNum", 0);
|
|
|
+ data.put("gcjsZjzhNames", "、、");
|
|
|
+ data.put("gcjsZjzhNum", 0);
|
|
|
+ data.put("gcjsAqsgNames", "、、");
|
|
|
// (四)升规入统方面
|
|
|
- data.put("sgrtNum", 3);
|
|
|
- data.put("sgrtCqNames", "a项目、b项目、c项目");
|
|
|
- data.put("sgrtCqNum", 3);
|
|
|
- data.put("sgrtZlzhNames", "a项目、b项目、c项目");
|
|
|
- data.put("sgrtZlzhNum", 3);
|
|
|
+ data.put("sgrtNum", 0);
|
|
|
+ data.put("sgrtCqNames", "、、");
|
|
|
+ data.put("sgrtCqNum", 0);
|
|
|
+ data.put("sgrtZlzhNames", "、、");
|
|
|
+ data.put("sgrtZlzhNum", 0);
|
|
|
|
|
|
// Map<String, List<LogOperate>> collect = logList.stream().collect(Collectors.groupingBy(LogOperate::getTitle));
|
|
|
// String currentYearZhStr = buildZhData(collect);
|
|
@@ -1153,12 +1464,13 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
|
|
|
WordExportUtil.exportWord07(word, data);
|
|
|
+ addBreakInCell(word.getParagraphs());
|
|
|
response.setHeader("content-disposition","attachment;filename="+new String("analysis".getBytes(),"ISO8859-1"));
|
|
|
- response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
|
|
word.write(response.getOutputStream());
|
|
|
}
|
|
|
|
|
|
- private void addNum(List<LogOperate> lastLogList, StatusChangeCountersVO vo) {
|
|
|
+ private void addNum(List<LogOperateVO> lastLogList, StatusChangeCountersVO vo) {
|
|
|
for (LogOperate logOperate : lastLogList) {
|
|
|
if (SubInfoStatusEnum.CB.getCode().equals(logOperate.getStatusFirst()) && SubInfoStatusEnum.XJ.getCode().equals(logOperate.getStatusAfter())) {
|
|
|
++vo.cbToXjNum;
|
|
@@ -1181,16 +1493,25 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private String buildZhData(Map<String, List<LogOperate>> collect) {
|
|
|
- StringBuilder zhStrBuilder = new StringBuilder();
|
|
|
- collect.forEach((key, value) -> {
|
|
|
- zhStrBuilder.append(key).append(value.size()).append("个、");
|
|
|
- });
|
|
|
- return zhStrBuilder.toString().replaceAll("、$", "。");
|
|
|
+ public static void addBreakInCell(List<XWPFParagraph> paragraphs) {
|
|
|
+ for (XWPFParagraph p : paragraphs) {
|
|
|
+ for (XWPFRun run : p.getRuns()) {//XWPFRun对象定义具有一组公共属性的文本区域
|
|
|
+ if(run.getText(0)!= null && run.getText(0).contains("\n")) {
|
|
|
+ String[] lines = run.getText(0).split("\n");
|
|
|
+ if(lines.length > 0) {
|
|
|
+ run.setText(lines[0], 0); // set first line into XWPFRun
|
|
|
+ for(int i=1;i<lines.length;i++){
|
|
|
+ // add break and insert new text
|
|
|
+ run.addBreak();//中断
|
|
|
+// run.addCarriageReturn();//回车符,但是不起作用
|
|
|
+ run.setText(lines[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 导出重点项目储备明细表
|
|
|
*
|
|
@@ -1226,7 +1547,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
writer.addHeaderAlias("content", "项目建设内容");
|
|
|
writer.addHeaderAlias("amtTotal", "计划总投资(万元)");
|
|
|
writer.addHeaderAlias("indusKind", "行业分类");
|
|
|
- writer.addHeaderAlias("cbStatus", "状态[正在谋划,正在洽谈,已签约,已备案/已核准]");
|
|
|
+ writer.addHeaderAlias("cbStatus", "状态[正在谋划,正在洽谈,\n已签约,已备案/已核准]");
|
|
|
writer.addHeaderAlias("beginDate", "计划开始日期");
|
|
|
writer.addHeaderAlias("endDate", "计划投产日期");
|
|
|
writer.addHeaderAlias("progress", "项目进展情况");
|
|
@@ -1241,15 +1562,28 @@ public class SubInfoExportController extends BaseController {
|
|
|
cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
|
|
|
|
// 设置每列的默认宽度
|
|
|
- int defaultColumnWidth = 40; // 默认宽度为20个字符
|
|
|
- for (int i = 0; i < 11; i++) {
|
|
|
- if (i == 0) {
|
|
|
- sheet.setColumnWidth(i, 4 * 256); // 序号列宽度为20个字符
|
|
|
- continue;
|
|
|
- }
|
|
|
- sheet.setColumnWidth(i, defaultColumnWidth * 256); // 其他列保持默认宽度
|
|
|
- }
|
|
|
+ // int defaultColumnWidth = 40; // 默认宽度为20个字符
|
|
|
+ // for (int i = 0; i < 11; i++) {
|
|
|
+ // if (i == 0) {
|
|
|
+ // sheet.setColumnWidth(i, 4 * 256); // 序号列宽度为20个字符
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ // sheet.setColumnWidth(i, defaultColumnWidth * 256); // 其他列保持默认宽度
|
|
|
+ // }
|
|
|
|
|
|
+ sheet.setColumnWidth(0, 4 * 256);
|
|
|
+ sheet.setColumnWidth(1, 40 * 256);
|
|
|
+ sheet.setColumnWidth(2, 14 * 256);
|
|
|
+ sheet.setColumnWidth(3, 40 * 256);
|
|
|
+ sheet.setColumnWidth(4, 12 * 256);
|
|
|
+ sheet.setColumnWidth(5, 40 * 256);
|
|
|
+ sheet.setColumnWidth(6, 20 * 256);
|
|
|
+ sheet.setColumnWidth(7, 12 * 256);
|
|
|
+ sheet.setColumnWidth(8, 20 * 256);
|
|
|
+ sheet.setColumnWidth(9, 14 * 256);
|
|
|
+ sheet.setColumnWidth(10, 14 * 256);
|
|
|
+ sheet.setColumnWidth(11, 14 * 256);
|
|
|
+ sheet.setColumnWidth(12, 14 * 256);
|
|
|
|
|
|
|
|
|
//根据合并行进行合并
|
|
@@ -1257,8 +1591,19 @@ public class SubInfoExportController extends BaseController {
|
|
|
subInfoTotalExcel.get(i).setNumber(i);
|
|
|
}
|
|
|
|
|
|
+ List<Map<String, Object>> list = subInfoTotalExcel.stream().map(item -> {
|
|
|
+ Map<String, Object> map = BeanUtil.beanToMap(item);
|
|
|
+ if (map.get("beginDate") != null) {
|
|
|
+ map.put("beginDate", DateUtil.format(item.getBeginDate(), "yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+ if (map.get("endDate") != null) {
|
|
|
+ map.put("endDate", DateUtil.format(item.getBeginDate(), "yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
//写入行业明细行
|
|
|
- writer.write(subInfoTotalExcel, true);
|
|
|
+ writer.write(list, true);
|
|
|
// 输出到客户端
|
|
|
writer.flush(out, true);
|
|
|
|
|
@@ -1303,6 +1648,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
// 添加前计算合并行
|
|
|
allSize.add(exportList.size() + 2);
|
|
|
+ allSize.add(2);
|
|
|
exportList.addAll(hyList);
|
|
|
index++;
|
|
|
}
|
|
@@ -1321,8 +1667,8 @@ public class SubInfoExportController extends BaseController {
|
|
|
// 合并单元格
|
|
|
CellStyle nonCenterCellStyle = createNonCenterBoldCellStyle(workbook);
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
- allSize.add(2);
|
|
|
- for (Integer row : allSize) {
|
|
|
+ // allSize.add(2);
|
|
|
+ for (Integer row : new HashSet<>(allSize)) {
|
|
|
sheet.addMergedRegion(new CellRangeAddress(row, row, 0, 3));
|
|
|
// 获取合并区域的左上角单元格并设置样式
|
|
|
Row mergedRow = sheet.getRow(row);
|
|
@@ -1380,13 +1726,10 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 4库导出总表
|
|
|
- *
|
|
|
- * @param response
|
|
|
- * @param vo
|
|
|
+ * 四库、总库导出总表
|
|
|
*/
|
|
|
@PostMapping("/exportTotalExcelByStatus")
|
|
|
- @Log("4库导出总表")
|
|
|
+ @Log("导出总表")
|
|
|
public void exportTotalExcelByStatus(@RequestBody SubInfoQueryTzVO vo) {
|
|
|
WebLogAspect.content.set(String.format("页面:【项目四库管理-%s库】,执行操作:导出汇总",
|
|
|
StringUtils.isBlank(vo.getStatus()) ? "项目总" : SubInfoStatusEnum.getDesc(vo.getStatus())));
|
|
@@ -1397,193 +1740,258 @@ public class SubInfoExportController extends BaseController {
|
|
|
Map<String, String> jsddMap = jsddDict.stream().collect(Collectors.toMap(TSystable::getCode, TSystable::getTitle));
|
|
|
Map<String, String> jsddTitleMap = jsddDict.stream().collect(Collectors.toMap(TSystable::getTitle, TSystable::getCode));
|
|
|
Map<String, String> hyflMap = subInduService.queryParentAll().stream().collect(Collectors.toMap(SubIndu::getCode, SubIndu::getTitle));
|
|
|
- // 0.项目总库导出总表
|
|
|
- if (StringUtils.isBlank(vo.getStatus())){
|
|
|
- // 0.1 按区域构建表头
|
|
|
- List<String> subjectIds = list.stream().map(SubInfoTotalExcel::getSubjectId).distinct().collect(Collectors.toList());
|
|
|
- // 创建主表头
|
|
|
- List<ExcelExportEntity> entityList = new ArrayList<>();
|
|
|
- // 添加表头
|
|
|
- ExcelExportEntity lbEntity = new ExcelExportEntity("项目类别", "subjectName");
|
|
|
- entityList.add(lbEntity);
|
|
|
-
|
|
|
- ExcelExportEntity hj = new ExcelExportEntity("合计", "hj");
|
|
|
- List<ExcelExportEntity> subHeadEntities = new ArrayList<>();
|
|
|
- subHeadEntities.add(getExcelExportEntity("项目个数", "count", 12));
|
|
|
- subHeadEntities.add(getExcelExportEntity("计划总投资(亿元)", "amt", 20));
|
|
|
- hj.setList(subHeadEntities);
|
|
|
- entityList.add(hj);
|
|
|
-
|
|
|
- // 创建for循环,循环5次
|
|
|
- List<String> newSubjectIds = new ArrayList<>();
|
|
|
- if (subjectIds.contains(jsddTitleMap.get("伊州区"))){
|
|
|
- newSubjectIds.add(jsddTitleMap.get("伊州区"));
|
|
|
- }
|
|
|
- if (subjectIds.contains(jsddTitleMap.get("巴里坤县"))){
|
|
|
- newSubjectIds.add(jsddTitleMap.get("巴里坤县"));
|
|
|
- }
|
|
|
- if (subjectIds.contains(jsddTitleMap.get("伊吾县"))){
|
|
|
- newSubjectIds.add(jsddTitleMap.get("伊吾县"));
|
|
|
- }
|
|
|
- if (subjectIds.contains(jsddTitleMap.get("高新区"))){
|
|
|
- newSubjectIds.add(jsddTitleMap.get("高新区"));
|
|
|
- }
|
|
|
- if (subjectIds.contains(jsddTitleMap.get("市本级"))){
|
|
|
- newSubjectIds.add(jsddTitleMap.get("市本级"));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- for (String subjectId : newSubjectIds) {
|
|
|
- ExcelExportEntity jsdd = null;
|
|
|
- if (jsddMap.get(subjectId).equals("市本级")) {
|
|
|
- jsdd = new ExcelExportEntity("其他", subjectId);
|
|
|
- }else {
|
|
|
- jsdd = new ExcelExportEntity(jsddMap.get(subjectId), subjectId);
|
|
|
+ if (StringUtils.isBlank(vo.getStatus())) {
|
|
|
+ // 项目总库导出总表
|
|
|
+ exportZkTotal(list, jsddMap, jsddTitleMap);
|
|
|
+ } else {
|
|
|
+ // 四库导出总表
|
|
|
+ exportFourDbTotal(vo, list, jsddMap, hyflMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目总库导出总表
|
|
|
+ */
|
|
|
+ private void exportFourDbTotal(SubInfoQueryTzVO vo, List<SubInfoTotalExcel> list, Map<String, String> jsddMap, Map<String, String> hyflMap) {
|
|
|
+ // 处理数据
|
|
|
+ List<SubInfoTotalInfoVO> exportData = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ // 1.按属地划分
|
|
|
+ List<SubInfoTotalInfoVO> ddList = new ArrayList<SubInfoTotalInfoVO>() {{
|
|
|
+ jsddMap.forEach((k, v) -> {
|
|
|
+ add(new SubInfoTotalInfoVO("按属地划分", v, 0, BigDecimal.ZERO));
|
|
|
+ });
|
|
|
+ }};
|
|
|
+ Map<String, SubInfoTotalInfoVO> ddGroup = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(SubInfoTotalExcel::getSubjectId))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> new SubInfoTotalInfoVO(
|
|
|
+ "按属地划分",
|
|
|
+ jsddMap.getOrDefault(entry.getKey(), entry.getKey()),
|
|
|
+ entry.getValue().size(),
|
|
|
+ entry.getValue().stream()
|
|
|
+ .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toMap(SubInfoTotalInfoVO::getTypeItem, Function.identity()));
|
|
|
+ ddList = ddList.stream().map(e -> {
|
|
|
+ if (ddGroup.get(e.getTypeItem()) != null) {
|
|
|
+ return ddGroup.get(e.getTypeItem());
|
|
|
+ } else {
|
|
|
+ return e;
|
|
|
}
|
|
|
- List<ExcelExportEntity> ddHead = new ArrayList<>();
|
|
|
- ddHead.add(getExcelExportEntity("项目个数", "count", 12));
|
|
|
- ddHead.add(getExcelExportEntity("计划总投资(亿元)", "amt", 20));
|
|
|
- jsdd.setList(ddHead);
|
|
|
- entityList.add(jsdd);
|
|
|
- }
|
|
|
- // 0.2 构建数据
|
|
|
- Map<String, List<SubInfoTotalExcel>> statusGroup = list.stream().collect(Collectors.groupingBy(SubInfoTotalExcel::getStatus));
|
|
|
- List<Map<String,Object>> dataList = new ArrayList<>();
|
|
|
- // 0.2.1 储备项目
|
|
|
- List<SubInfoTotalExcel> cb = statusGroup.getOrDefault(SubInfoStatusEnum.CB.getCode(),new ArrayList<>());
|
|
|
- List<SubInfoTotalExcel> xj = statusGroup.getOrDefault(SubInfoStatusEnum.XJ.getCode(),new ArrayList<>());
|
|
|
- List<SubInfoTotalExcel> zj = statusGroup.getOrDefault(SubInfoStatusEnum.ZJ.getCode(),new ArrayList<>());
|
|
|
- List<SubInfoTotalExcel> tc = statusGroup.getOrDefault(SubInfoStatusEnum.TC.getCode(),new ArrayList<>());
|
|
|
-
|
|
|
- fillRowData(subjectIds, dataList, cb, SubInfoStatusEnum.CB.getDesc() + "项目");
|
|
|
- fillRowData(subjectIds, dataList, xj, SubInfoStatusEnum.XJ.getDesc() + "项目");
|
|
|
- fillRowData(subjectIds, dataList, zj, SubInfoStatusEnum.ZJ.getDesc() + "项目");
|
|
|
- fillRowData(subjectIds, dataList, tc, SubInfoStatusEnum.TC.getDesc() + "项目");
|
|
|
- fillRowData(subjectIds, dataList, list, "合计");
|
|
|
-
|
|
|
-
|
|
|
- // 3.导出
|
|
|
- ExportParams exportParams = new ExportParams("哈密市“四个一批”工业项目库总体情况", "项目库总体情况", ExcelType.XSSF);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 2.按金额划分 定义分组边界
|
|
|
+ Map<String, BigDecimal> groupBoundaries = new LinkedHashMap<>();
|
|
|
+ groupBoundaries.put("10亿元以下", new BigDecimal("100000"));
|
|
|
+ groupBoundaries.put("10-50亿元", new BigDecimal("500000"));
|
|
|
+ groupBoundaries.put("50-100亿元", new BigDecimal("1000000"));
|
|
|
+ // 默认
|
|
|
+ List<SubInfoTotalInfoVO> amtList = new ArrayList<SubInfoTotalInfoVO>() {{
|
|
|
+ add(new SubInfoTotalInfoVO("按金额划分", "10亿元以下", 0, BigDecimal.ZERO));
|
|
|
+ add(new SubInfoTotalInfoVO("按金额划分", "10-50亿元", 0, BigDecimal.ZERO));
|
|
|
+ add(new SubInfoTotalInfoVO("按金额划分", "50-100亿元", 0, BigDecimal.ZERO));
|
|
|
+ add(new SubInfoTotalInfoVO("按金额划分", "100亿元以上", 0, BigDecimal.ZERO));
|
|
|
+ }};
|
|
|
+ Map<String, SubInfoTotalInfoVO> amtGroup = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(transaction -> {
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : groupBoundaries.entrySet()) {
|
|
|
+ if (transaction.getAmtTotal().compareTo(entry.getValue()) < 0) {
|
|
|
+ return entry.getKey();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "100亿元以上"; // 超过最高范围的默认分组
|
|
|
+ }))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> new SubInfoTotalInfoVO(
|
|
|
+ "按金额划分",
|
|
|
+ entry.getKey(),
|
|
|
+ entry.getValue().size(),
|
|
|
+ entry.getValue().stream()
|
|
|
+ .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toMap(SubInfoTotalInfoVO::getTypeItem, Function.identity()));
|
|
|
+ amtList = amtList.stream().map(e -> {
|
|
|
+ if (amtGroup.get(e.getTypeItem()) != null) {
|
|
|
+ return amtGroup.get(e.getTypeItem());
|
|
|
+ } else {
|
|
|
+ return e;
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 3.按行业划分
|
|
|
+ List<SubInfoTotalInfoVO> hyList = new ArrayList<SubInfoTotalInfoVO>() {{
|
|
|
+ hyflMap.forEach((k, v) -> {
|
|
|
+ add(new SubInfoTotalInfoVO("按行业划分", v, 0, BigDecimal.ZERO));
|
|
|
+ });
|
|
|
+ }};
|
|
|
+ Map<String, SubInfoTotalInfoVO> hyGroup = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(transaction -> {
|
|
|
+ String code = transaction.getInduskind();
|
|
|
+ // 确保code不为空且长度至少为2
|
|
|
+ if (code == null || code.length() < 2) {
|
|
|
+ return "未知行业"; // 默认未知行业
|
|
|
+ }
|
|
|
+ return code.substring(0, 2);
|
|
|
+ }))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> new SubInfoTotalInfoVO(
|
|
|
+ "按行业划分",
|
|
|
+ hyflMap.getOrDefault(entry.getKey(), entry.getKey()),
|
|
|
+ entry.getValue().size(),
|
|
|
+ entry.getValue().stream()
|
|
|
+ .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
+ )
|
|
|
+ )
|
|
|
+ .collect(Collectors.toMap(SubInfoTotalInfoVO::getTypeItem, Function.identity()));
|
|
|
+ hyList = hyList.stream().map(e -> {
|
|
|
+ if (hyGroup.get(e.getTypeItem()) != null) {
|
|
|
+ return hyGroup.get(e.getTypeItem());
|
|
|
+ } else {
|
|
|
+ return e;
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if (hyGroup.get("未知行业") != null) {
|
|
|
+ hyList.add(hyGroup.get("未知行业"));
|
|
|
+ }
|
|
|
+
|
|
|
+ exportData.addAll(ddList);
|
|
|
+ exportData.addAll(amtList);
|
|
|
+ exportData.addAll(hyList);
|
|
|
+ BigDecimal reduce = list.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ exportData.add(new SubInfoTotalInfoVO("合计", "合计", list.size(), reduce.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)));
|
|
|
+ // 4.导出
|
|
|
+ ExportParams exportParams = null;
|
|
|
+ if (vo.getStatus().equals("1")){
|
|
|
+ exportParams = new ExportParams("“四个一批”储备项目库基本情况","“四个一批”储备项目库基本情况", ExcelType.XSSF);
|
|
|
+ }else if (vo.getStatus().equals("2")){
|
|
|
+ exportParams = new ExportParams("“四个一批”新建项目库基本情况","“四个一批”新建项目库基本情况", ExcelType.XSSF);
|
|
|
+ }else if (vo.getStatus().equals("3")){
|
|
|
+ exportParams = new ExportParams("“四个一批”在建项目库基本情况","“四个一批”在建项目库基本情况", ExcelType.XSSF);
|
|
|
+ }else if (vo.getStatus().equals("9")){
|
|
|
+ exportParams = new ExportParams("“四个一批”投产库基本情况","“四个一批”投产库基本情况", ExcelType.XSSF);
|
|
|
+ }else {
|
|
|
+ exportParams = new ExportParams("“四个一批”项目库基本情况","“四个一批”项目库基本情况", ExcelType.XSSF);
|
|
|
+ }
|
|
|
exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
- Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, dataList);
|
|
|
+ int mergeTotalStartRow = exportData.size() + 1;
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoTotalInfoVO.class, exportData);
|
|
|
response.setContentType("application/xlsx;charset=utf-8");
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename=" + URLEncodeUtil.encode("项目库总体情况") + System.currentTimeMillis() + ".xlsx");
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + URLEncodeUtil.encode("项目明细表") + System.currentTimeMillis() + ".xlsx");
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ // 合并单元格
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 1));
|
|
|
+
|
|
|
+ if (ddList.size() > 1){
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(2, ddList.size() + 1, 0, 0));
|
|
|
+ }
|
|
|
+ if (amtList.size() > 1){
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(ddList.size() + 2, ddList.size() + amtList.size() + 1, 0, 0));
|
|
|
+ }
|
|
|
+ if (hyList.size() > 1) {
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(ddList.size() + amtList.size() + 2, ddList.size() + amtList.size() + hyList.size() + 1, 0, 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(mergeTotalStartRow, mergeTotalStartRow, 0, 1));
|
|
|
|
|
|
try (OutputStream outputStream = response.getOutputStream()) {
|
|
|
workbook.write(outputStream);
|
|
|
+ workbook.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
- try {
|
|
|
- workbook.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
}
|
|
|
- }else {
|
|
|
- // 处理数据
|
|
|
- List<SubInfoTotalInfoVO> exportData = new ArrayList<>();
|
|
|
- if (CollectionUtil.isNotEmpty(list)) {
|
|
|
- // 1.按属地分
|
|
|
- List<SubInfoTotalInfoVO> ddList = list.stream()
|
|
|
- .collect(Collectors.groupingBy(SubInfoTotalExcel::getSubjectId))
|
|
|
- .entrySet().stream()
|
|
|
- .map(entry -> new SubInfoTotalInfoVO(
|
|
|
- "按属地分",
|
|
|
- jsddMap.getOrDefault(entry.getKey(), entry.getKey()),
|
|
|
- entry.getValue().size(),
|
|
|
- entry.getValue().stream()
|
|
|
- .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
- .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
- ))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- // 2.按金额分 定义分组边界
|
|
|
- Map<String, BigDecimal> groupBoundaries = new LinkedHashMap<>();
|
|
|
- groupBoundaries.put("10亿元以下", new BigDecimal("100000"));
|
|
|
- groupBoundaries.put("10-50亿元", new BigDecimal("500000"));
|
|
|
- groupBoundaries.put("50-100亿元", new BigDecimal("1000000"));
|
|
|
- List<SubInfoTotalInfoVO> amtList = list.stream()
|
|
|
- .collect(Collectors.groupingBy(transaction -> {
|
|
|
- for (Map.Entry<String, BigDecimal> entry : groupBoundaries.entrySet()) {
|
|
|
- if (transaction.getAmtTotal().compareTo(entry.getValue()) < 0) {
|
|
|
- return entry.getKey();
|
|
|
- }
|
|
|
- }
|
|
|
- return "100亿元以上"; // 超过最高范围的默认分组
|
|
|
- }))
|
|
|
- .entrySet().stream()
|
|
|
- .map(entry -> new SubInfoTotalInfoVO(
|
|
|
- "按金额分",
|
|
|
- entry.getKey(),
|
|
|
- entry.getValue().size(),
|
|
|
- entry.getValue().stream()
|
|
|
- .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
- .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
- ))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- // 3.按行业分
|
|
|
- List<SubInfoTotalInfoVO> hyList = list.stream()
|
|
|
- .collect(Collectors.groupingBy(transaction ->{
|
|
|
- String code = transaction.getInduskind();
|
|
|
- // 确保code不为空且长度至少为2
|
|
|
- if (code == null || code.length() < 2) {
|
|
|
- return "未知行业"; // 默认未知行业
|
|
|
- }
|
|
|
- return code.substring(0, 2);
|
|
|
- }))
|
|
|
- .entrySet().stream()
|
|
|
- .map(entry -> new SubInfoTotalInfoVO(
|
|
|
- "按行业分",
|
|
|
- hyflMap.getOrDefault(entry.getKey(),entry.getKey()),
|
|
|
- entry.getValue().size(),
|
|
|
- entry.getValue().stream()
|
|
|
- .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
- .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
- )
|
|
|
- )
|
|
|
- .collect(Collectors.toList());
|
|
|
- exportData.addAll(ddList);
|
|
|
- exportData.addAll(amtList);
|
|
|
- exportData.addAll(hyList);
|
|
|
- BigDecimal reduce = list.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- exportData.add(new SubInfoTotalInfoVO("合计", "合计", list.size(), reduce.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)));
|
|
|
- // 4.导出
|
|
|
- ExportParams exportParams = null;
|
|
|
- if (vo.getStatus().equals("1")){
|
|
|
- exportParams = new ExportParams("“四个一批”储备项目库基本情况","“四个一批”储备项目库基本情况", ExcelType.XSSF);
|
|
|
- }else if (vo.getStatus().equals("2")){
|
|
|
- exportParams = new ExportParams("“四个一批”新建项目库基本情况","“四个一批”新建项目库基本情况", ExcelType.XSSF);
|
|
|
- }else if (vo.getStatus().equals("3")){
|
|
|
- exportParams = new ExportParams("“四个一批”在建项目库基本情况","“四个一批”在建项目库基本情况", ExcelType.XSSF);
|
|
|
- }else if (vo.getStatus().equals("9")){
|
|
|
- exportParams = new ExportParams("“四个一批”投产库基本情况","“四个一批”投产库基本情况", ExcelType.XSSF);
|
|
|
- }else {
|
|
|
- exportParams = new ExportParams("“四个一批”项目库基本情况","“四个一批”项目库基本情况", ExcelType.XSSF);
|
|
|
- }
|
|
|
- exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
- int mergeTotalStartRow = exportData.size() + 1;
|
|
|
- Workbook workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoTotalInfoVO.class, exportData);
|
|
|
- response.setContentType("application/xlsx;charset=utf-8");
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename=" + URLEncodeUtil.encode("项目明细表") + System.currentTimeMillis() + ".xlsx");
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- // 合并单元格
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 1));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(2, ddList.size() + 1, 0, 0));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(ddList.size() + 2, ddList.size() + amtList.size() + 1, 0, 0));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(ddList.size() + amtList.size() + 2, ddList.size() + amtList.size() + hyList.size() + 1, 0, 0));
|
|
|
- sheet.addMergedRegion(new CellRangeAddress(mergeTotalStartRow, mergeTotalStartRow, 0, 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- try (OutputStream outputStream = response.getOutputStream()) {
|
|
|
- workbook.write(outputStream);
|
|
|
- workbook.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 四库导出总表
|
|
|
+ */
|
|
|
+ private void exportZkTotal(List<SubInfoTotalExcel> list, Map<String, String> jsddMap, Map<String, String> jsddTitleMap) {
|
|
|
+ // 0.1 按区域构建表头
|
|
|
+ List<String> subjectIds = list.stream().map(SubInfoTotalExcel::getSubjectId).distinct().collect(Collectors.toList());
|
|
|
+ // 创建主表头
|
|
|
+ List<ExcelExportEntity> entityList = new ArrayList<>();
|
|
|
+ // 添加表头
|
|
|
+ ExcelExportEntity lbEntity = new ExcelExportEntity("项目类别", "subjectName");
|
|
|
+ entityList.add(lbEntity);
|
|
|
+
|
|
|
+ ExcelExportEntity hj = new ExcelExportEntity("合计", "hj");
|
|
|
+ List<ExcelExportEntity> subHeadEntities = new ArrayList<>();
|
|
|
+ subHeadEntities.add(getExcelExportEntity("项目个数", "count", 12));
|
|
|
+ subHeadEntities.add(getExcelExportEntity("计划总投资(亿元)", "amt", 20));
|
|
|
+ hj.setList(subHeadEntities);
|
|
|
+ entityList.add(hj);
|
|
|
+
|
|
|
+ // 创建for循环,循环5次
|
|
|
+ List<String> newSubjectIds = new ArrayList<>();
|
|
|
+ if (subjectIds.contains(jsddTitleMap.get("伊州区"))){
|
|
|
+ newSubjectIds.add(jsddTitleMap.get("伊州区"));
|
|
|
+ }
|
|
|
+ if (subjectIds.contains(jsddTitleMap.get("巴里坤县"))){
|
|
|
+ newSubjectIds.add(jsddTitleMap.get("巴里坤县"));
|
|
|
+ }
|
|
|
+ if (subjectIds.contains(jsddTitleMap.get("伊吾县"))){
|
|
|
+ newSubjectIds.add(jsddTitleMap.get("伊吾县"));
|
|
|
+ }
|
|
|
+ if (subjectIds.contains(jsddTitleMap.get("高新区"))){
|
|
|
+ newSubjectIds.add(jsddTitleMap.get("高新区"));
|
|
|
+ }
|
|
|
+ if (subjectIds.contains(jsddTitleMap.get("市本级"))){
|
|
|
+ newSubjectIds.add(jsddTitleMap.get("市本级"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (String subjectId : newSubjectIds) {
|
|
|
+ ExcelExportEntity jsdd = null;
|
|
|
+ if (jsddMap.get(subjectId).equals("市本级")) {
|
|
|
+ jsdd = new ExcelExportEntity("其他", subjectId);
|
|
|
+ }else {
|
|
|
+ jsdd = new ExcelExportEntity(jsddMap.get(subjectId), subjectId);
|
|
|
+ }
|
|
|
+ List<ExcelExportEntity> ddHead = new ArrayList<>();
|
|
|
+ ddHead.add(getExcelExportEntity("项目个数", "count", 12));
|
|
|
+ ddHead.add(getExcelExportEntity("计划总投资(亿元)", "amt", 20));
|
|
|
+ jsdd.setList(ddHead);
|
|
|
+ entityList.add(jsdd);
|
|
|
+ }
|
|
|
+ // 0.2 构建数据
|
|
|
+ Map<String, List<SubInfoTotalExcel>> statusGroup = list.stream().collect(Collectors.groupingBy(SubInfoTotalExcel::getStatus));
|
|
|
+ List<Map<String,Object>> dataList = new ArrayList<>();
|
|
|
+ // 0.2.1 储备项目
|
|
|
+ List<SubInfoTotalExcel> cb = statusGroup.getOrDefault(SubInfoStatusEnum.CB.getCode(),new ArrayList<>());
|
|
|
+ List<SubInfoTotalExcel> xj = statusGroup.getOrDefault(SubInfoStatusEnum.XJ.getCode(),new ArrayList<>());
|
|
|
+ List<SubInfoTotalExcel> zj = statusGroup.getOrDefault(SubInfoStatusEnum.ZJ.getCode(),new ArrayList<>());
|
|
|
+ List<SubInfoTotalExcel> tc = statusGroup.getOrDefault(SubInfoStatusEnum.TC.getCode(),new ArrayList<>());
|
|
|
+
|
|
|
+ fillRowData(subjectIds, dataList, cb, SubInfoStatusEnum.CB.getDesc() + "项目");
|
|
|
+ fillRowData(subjectIds, dataList, xj, SubInfoStatusEnum.XJ.getDesc() + "项目");
|
|
|
+ fillRowData(subjectIds, dataList, zj, SubInfoStatusEnum.ZJ.getDesc() + "项目");
|
|
|
+ fillRowData(subjectIds, dataList, tc, SubInfoStatusEnum.TC.getDesc() + "项目");
|
|
|
+ fillRowData(subjectIds, dataList, list, "合计");
|
|
|
+
|
|
|
+
|
|
|
+ // 3.导出
|
|
|
+ ExportParams exportParams = new ExportParams("哈密市“四个一批”工业项目库总体情况", "项目库总体情况", ExcelType.XSSF);
|
|
|
+ exportParams.setStyle(ExcelStyleUtil.class);
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, dataList);
|
|
|
+ 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();
|
|
|
+ }finally {
|
|
|
+ try {
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|