|
@@ -10,6 +10,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
@@ -1106,6 +1107,9 @@ public class SubInfoExportController extends BaseController {
|
|
|
excelExportEntity.setWidth(width);
|
|
|
return excelExportEntity;
|
|
|
}
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HttpServletResponse response;
|
|
|
/**
|
|
|
* 4库导出总表
|
|
|
*
|
|
@@ -1113,7 +1117,8 @@ public class SubInfoExportController extends BaseController {
|
|
|
* @param vo
|
|
|
*/
|
|
|
@PostMapping("/exportTotalExcelByStatus")
|
|
|
- public void exportTotalExcelByStatus(HttpServletResponse response, @RequestBody SubInfoQueryTzVO vo) {
|
|
|
+ @Log("4库导出总表")
|
|
|
+ public void exportTotalExcelByStatus(@RequestBody SubInfoQueryTzVO vo) {
|
|
|
vo.setSubjectAuthIds(getSubjectIds());
|
|
|
// 查询数据以及字典
|
|
|
List<SubInfoTotalExcel> list = subInfoService.exportTotalExcelByStatus(vo);
|
|
@@ -1149,10 +1154,10 @@ public class SubInfoExportController extends BaseController {
|
|
|
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.get(SubInfoStatusEnum.CB.getCode());
|
|
|
- List<SubInfoTotalExcel> xj = statusGroup.get(SubInfoStatusEnum.XJ.getCode());
|
|
|
- List<SubInfoTotalExcel> zj = statusGroup.get(SubInfoStatusEnum.ZJ.getCode());
|
|
|
- List<SubInfoTotalExcel> tc = statusGroup.get(SubInfoStatusEnum.TC.getCode());
|
|
|
+ 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() + "项目");
|
|
@@ -1276,37 +1281,35 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void fillRowData(List<String> subjectIds, List<Map<String, Object>> dataList, List<SubInfoTotalExcel> cb,String name) {
|
|
|
- Map<String, List<SubInfoTotalExcel>> collect = cb.stream().collect(Collectors.groupingBy(e -> StringUtils.defaultIfBlank(e.getSubjectId(), ".")));
|
|
|
+ private void fillRowData(List<String> subjectIds, List<Map<String, Object>> dataList, List<SubInfoTotalExcel> statusGroup,String name) {
|
|
|
+ Map<String, List<SubInfoTotalExcel>> collect = statusGroup.stream().collect(Collectors.groupingBy(e -> StringUtils.defaultIfBlank(e.getSubjectId(), ".")));
|
|
|
Map<String, List<Object>> map = new LinkedHashMap<>();
|
|
|
collect.forEach((key, value) -> {
|
|
|
- List<Object> list1 = new ArrayList<>();
|
|
|
- Map<String,Object> columnMap = new LinkedHashMap<>();
|
|
|
- columnMap.put("count", value.size());
|
|
|
- BigDecimal reduce = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- columnMap.put("amt", name.equals(SubInfoStatusEnum.TC.getDesc() + "项目") ? "/" : reduce.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
|
|
|
- list1.add(columnMap);
|
|
|
- map.put(key, list1);
|
|
|
+ map.put(key, Collections.singletonList(new LinkedHashMap<String, Object>() {{
|
|
|
+ put("count", value.size());
|
|
|
+ BigDecimal reduce = value.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ put("amt", name.equals(SubInfoStatusEnum.TC.getDesc() + "项目") ? "/" : reduce.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
|
|
|
+ }}));
|
|
|
});
|
|
|
|
|
|
- // 合计金额
|
|
|
- BigDecimal cbAmtSum = cb.stream()
|
|
|
- .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-
|
|
|
Map<String, Object> rowMap = new LinkedHashMap<>();
|
|
|
rowMap.put("subjectName", name);
|
|
|
|
|
|
- List<Object> list = new ArrayList<>();
|
|
|
- Map<String, Object> hjMap = new LinkedHashMap<>();
|
|
|
- hjMap.put("count", cb.size());
|
|
|
- hjMap.put("amt", name.equals(SubInfoStatusEnum.TC.getDesc() + "项目") ? "/" : cbAmtSum.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
|
|
|
- list.add(hjMap);
|
|
|
-
|
|
|
- rowMap.put("hj", list);
|
|
|
+ // 合计
|
|
|
+ BigDecimal cbAmtSum = statusGroup.stream()
|
|
|
+ .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ rowMap.put("hj", Collections.singletonList(new LinkedHashMap<String, Object>() {{
|
|
|
+ put("count", statusGroup.size());
|
|
|
+ put("amt", name.equals(SubInfoStatusEnum.TC.getDesc() + "项目") ? "/" : cbAmtSum.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP));
|
|
|
+ }}));
|
|
|
|
|
|
+ // 各区县列
|
|
|
for (String subjectId : subjectIds) {
|
|
|
- rowMap.put(subjectId, map.getOrDefault(subjectId, Collections.emptyList()));
|
|
|
+ rowMap.put(subjectId, map.getOrDefault(subjectId, Collections.singletonList(new LinkedHashMap<String, Object>() {{
|
|
|
+ put("count", 0);
|
|
|
+ put("amt", name.equals(SubInfoStatusEnum.TC.getDesc() + "项目") ? "/" :BigDecimal.ZERO);
|
|
|
+ }})));
|
|
|
}
|
|
|
dataList.add(rowMap);
|
|
|
}
|