|
@@ -1,16 +1,24 @@
|
|
|
package com.siwei.apply.service.cadastre.impl;
|
|
package com.siwei.apply.service.cadastre.impl;
|
|
|
|
|
|
|
|
|
|
+import com.siwei.apply.common.Constant;
|
|
|
|
|
+import com.siwei.apply.domain.GongdiJihua;
|
|
|
|
|
+import com.siwei.apply.domain.LandType;
|
|
|
import com.siwei.apply.domain.cadastre.*;
|
|
import com.siwei.apply.domain.cadastre.*;
|
|
|
|
|
+import com.siwei.apply.domain.res.*;
|
|
|
|
|
+import com.siwei.apply.domain.vo.GongdiJihuaFilterVo;
|
|
|
|
|
+import com.siwei.apply.enums.LandUseTypeEnum;
|
|
|
import com.siwei.apply.mapper.GongdiJihuaMapper;
|
|
import com.siwei.apply.mapper.GongdiJihuaMapper;
|
|
|
|
|
+import com.siwei.apply.mapper.LandTypeMapper;
|
|
|
|
|
+import com.siwei.apply.mapper.TdgyMapper;
|
|
|
import com.siwei.apply.service.cadastre.ISupplyService;
|
|
import com.siwei.apply.service.cadastre.ISupplyService;
|
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -19,11 +27,193 @@ public class SupplyServiceImpl implements ISupplyService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private GongdiJihuaMapper gongdiJihuaMapper;
|
|
private GongdiJihuaMapper gongdiJihuaMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TdgyMapper dgyMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private LandTypeMapper landTypeMapper;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Object GetList(String param) {
|
|
public Object GetList(String param) {
|
|
|
|
|
+
|
|
|
|
|
+ ///Map<String, Object> planSummary = gongdiJihuaMapper.getList(startTime, endTime);
|
|
|
|
|
+
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 年度统计
|
|
|
|
|
+ * @param year
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public SupplyYearStatisticsRes yearStatistics(String year) {
|
|
|
|
|
+ SupplyYearStatisticsRes res = new SupplyYearStatisticsRes();
|
|
|
|
|
+ GongdiJihuaFilterVo filterVo = new GongdiJihuaFilterVo();
|
|
|
|
|
+ filterVo.setYear(year);
|
|
|
|
|
+ filterVo.setPageSize(100000);
|
|
|
|
|
+ List<GongdiJihua> list = gongdiJihuaMapper.getList(filterVo);
|
|
|
|
|
+
|
|
|
|
|
+ List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(year);
|
|
|
|
|
+
|
|
|
|
|
+ if(CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
+ double completeRate =0;
|
|
|
|
|
+ if(CollectionUtils.isNotEmpty(completeList)) {
|
|
|
|
|
+ completeRate = (double) completeList.size() / list.size() * 100;
|
|
|
|
|
+ }
|
|
|
|
|
+ SupplyRateRes supplyRate = new SupplyRateRes();
|
|
|
|
|
+ //这里先计算一个供应率,后续可以根据实际需求计算其他数据
|
|
|
|
|
+ supplyRate.setCompleteRate((int) completeRate);
|
|
|
|
|
+ supplyRate.setPlanProjectCount(list.size());
|
|
|
|
|
+ supplyRate.setCompleteProjectCount(completeList.size());
|
|
|
|
|
+
|
|
|
|
|
+ //根据GongdiJihua 对象的MjMu 计算加总值
|
|
|
|
|
+ double planArea = list.stream()
|
|
|
|
|
+ .filter(g -> g.getMjMu() != null)
|
|
|
|
|
+ .mapToDouble(g -> g.getMjMu().doubleValue())
|
|
|
|
|
+ .sum();
|
|
|
|
|
+ supplyRate.setPlanArea((float) planArea);
|
|
|
|
|
+
|
|
|
|
|
+ //完成的计算加总值
|
|
|
|
|
+ double completeArea = completeList.stream()
|
|
|
|
|
+ .filter(g -> g.getMjMu() != null)
|
|
|
|
|
+ .mapToDouble(g -> g.getMjMu().doubleValue())
|
|
|
|
|
+ .sum();
|
|
|
|
|
+ supplyRate.setCompleteArea((float)completeArea);
|
|
|
|
|
+ supplyRate.setGdUnit("亩");
|
|
|
|
|
+ res.setSupplyRate(supplyRate);
|
|
|
|
|
+
|
|
|
|
|
+ //这里计算用途分析和供应方式分析的list,后续可以根据实际需求计算其他数据
|
|
|
|
|
+ List<LandUseRes> landUseStatisticsList = new ArrayList<>(); // 用途分析
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Double> planAreaMap = list.stream()
|
|
|
|
|
+ .filter(g -> g.getTdyt() != null)
|
|
|
|
|
+ .map(g -> {
|
|
|
|
|
+ for (LandUseTypeEnum type : LandUseTypeEnum.values()) {
|
|
|
|
|
+ if (type.getName().equals(g.getTdyt())) {
|
|
|
|
|
+ return Map.entry(type.getParentName(), g.getMjMu() != null ? g.getMjMu().doubleValue() : 0.0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ })
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.groupingBy(Map.Entry::getKey, Collectors.summingDouble(Map.Entry::getValue)));
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Double> completeAreaMap = new HashMap<>();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(completeList)) {
|
|
|
|
|
+ Map<String, String> codeToNameCache = new HashMap<>();
|
|
|
|
|
+ for (TdgyStatisticsRes g : completeList) {
|
|
|
|
|
+ if (g.getTdyt() != null && g.getTdyt().length() >= 2) {
|
|
|
|
|
+ String code = g.getTdyt().substring(0, 2);
|
|
|
|
|
+ String categoryName = codeToNameCache.computeIfAbsent(code, k -> {
|
|
|
|
|
+ LandType landType = landTypeMapper.selectByCode(k);
|
|
|
|
|
+ return landType != null ? landType.getName() : null;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ if (categoryName != null) {
|
|
|
|
|
+ double area = g.getMjMu() != null ? g.getMjMu().doubleValue() : 0.0;
|
|
|
|
|
+ completeAreaMap.put(categoryName, completeAreaMap.getOrDefault(categoryName, 0.0) + area);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Set<String> allCategories = new HashSet<>(planAreaMap.keySet());
|
|
|
|
|
+ allCategories.addAll(completeAreaMap.keySet());
|
|
|
|
|
+
|
|
|
|
|
+ for (String category : allCategories) {
|
|
|
|
|
+ LandUseRes landUseRes = new LandUseRes();
|
|
|
|
|
+ landUseRes.setLandUseTypeName(category);
|
|
|
|
|
+ landUseRes.setPlanLandUseArea(planAreaMap.getOrDefault(category, 0.0).intValue());
|
|
|
|
|
+ landUseRes.setCompleteLandUseArea(completeAreaMap.getOrDefault(category, 0.0).intValue());
|
|
|
|
|
+ landUseStatisticsList.add(landUseRes);
|
|
|
|
|
+ }
|
|
|
|
|
+ res.setLandUseStatisticsList(landUseStatisticsList);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 根据当前list中的字段,统计不同供应方式(gyfs)进行分组,如果是 gyfs=划拨或出让分别分组,其它为一组,然后分别计算每个供应方式的计划供应面积(mjMu)和完成供应面积(0填充),最后封装成 ProjectSupplyRes 对象添加到 projectSupplyList 中
|
|
|
|
|
+ List<ProjectSupplyRes> projectSupplyList = new ArrayList<>(); // 供应方式
|
|
|
|
|
+
|
|
|
|
|
+ // 预先按供应方式对已完成列表进行分组求和
|
|
|
|
|
+ Map<String, Double> completeModeAreaMap = new HashMap<>();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(completeList)) {
|
|
|
|
|
+ for (TdgyStatisticsRes g : completeList) {
|
|
|
|
|
+ String mode = g.getGyfs();
|
|
|
|
|
+ String category = ("划拨".equals(mode) || "出让".equals(mode)) ? mode : "其它";
|
|
|
|
|
+ double area = g.getMjMu() != null ? g.getMjMu().doubleValue() : 0.0;
|
|
|
|
|
+ completeModeAreaMap.put(category, completeModeAreaMap.getOrDefault(category, 0.0) + area);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 划拨
|
|
|
|
|
+ List<GongdiJihua> hbList = list.stream()
|
|
|
|
|
+ .filter(g -> "划拨".equals(g.getGyfs()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(hbList)) {
|
|
|
|
|
+ ProjectSupplyRes resHb = new ProjectSupplyRes();
|
|
|
|
|
+ resHb.setGdType("划拨");
|
|
|
|
|
+ resHb.setGdUnit("亩");
|
|
|
|
|
+ resHb.setCount(hbList.size());
|
|
|
|
|
+ float hbPlanArea = (float) hbList.stream()
|
|
|
|
|
+ .filter(g -> g.getMjMu() != null)
|
|
|
|
|
+ .mapToDouble(g -> g.getMjMu().doubleValue())
|
|
|
|
|
+ .sum();
|
|
|
|
|
+ resHb.setPlanArea(hbPlanArea);
|
|
|
|
|
+ resHb.setGdArea(hbPlanArea);
|
|
|
|
|
+ resHb.setCompleteArea(completeModeAreaMap.getOrDefault("划拨", 0.0).floatValue());
|
|
|
|
|
+ projectSupplyList.add(resHb);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 出让
|
|
|
|
|
+ List<GongdiJihua> crList = list.stream()
|
|
|
|
|
+ .filter(g -> "出让".equals(g.getGyfs()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(crList)) {
|
|
|
|
|
+ ProjectSupplyRes resCr = new ProjectSupplyRes();
|
|
|
|
|
+ resCr.setGdType("出让");
|
|
|
|
|
+ resCr.setGdUnit("亩");
|
|
|
|
|
+ resCr.setCount(crList.size());
|
|
|
|
|
+ float crPlanArea = (float) crList.stream()
|
|
|
|
|
+ .filter(g -> g.getMjMu() != null)
|
|
|
|
|
+ .mapToDouble(g -> g.getMjMu().doubleValue())
|
|
|
|
|
+ .sum();
|
|
|
|
|
+ resCr.setPlanArea(crPlanArea);
|
|
|
|
|
+ resCr.setGdArea(crPlanArea);
|
|
|
|
|
+ resCr.setCompleteArea(completeModeAreaMap.getOrDefault("出让", 0.0).floatValue());
|
|
|
|
|
+ projectSupplyList.add(resCr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 其它
|
|
|
|
|
+ List<GongdiJihua> qtList = list.stream()
|
|
|
|
|
+ .filter(g -> !"划拨".equals(g.getGyfs()) && !"出让".equals(g.getGyfs()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(qtList)) {
|
|
|
|
|
+ ProjectSupplyRes resQt = new ProjectSupplyRes();
|
|
|
|
|
+ resQt.setGdType("其它");
|
|
|
|
|
+ resQt.setGdUnit("亩");
|
|
|
|
|
+ resQt.setCount(qtList.size());
|
|
|
|
|
+ float qtPlanArea = (float) qtList.stream()
|
|
|
|
|
+ .filter(g -> g.getMjMu() != null)
|
|
|
|
|
+ .mapToDouble(g -> g.getMjMu().doubleValue())
|
|
|
|
|
+ .sum();
|
|
|
|
|
+ resQt.setPlanArea(qtPlanArea);
|
|
|
|
|
+ resQt.setGdArea(qtPlanArea);
|
|
|
|
|
+ resQt.setCompleteArea(completeModeAreaMap.getOrDefault("其它", 0.0).floatValue());
|
|
|
|
|
+ projectSupplyList.add(resQt);
|
|
|
|
|
+ }
|
|
|
|
|
+ res.setProjectSupplyList(projectSupplyList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public LandSupplyReportDTO getTdgyReport(String startTime, String endTime) {
|
|
public LandSupplyReportDTO getTdgyReport(String startTime, String endTime) {
|
|
|
LandSupplyReportDTO report = new LandSupplyReportDTO();
|
|
LandSupplyReportDTO report = new LandSupplyReportDTO();
|