|
|
@@ -24,6 +24,17 @@ public class HouseServiceImpl implements IHouselService {
|
|
|
private ZrzMapper zrzMapper;
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Zrz> zrzList(String djzqdm) {
|
|
|
+ if (StringUtils.isBlank(djzqdm) || djzqdm.matches("[0]+")) {
|
|
|
+ djzqdm = "";
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(djzqdm) && djzqdm.length() != 12) {
|
|
|
+ throw new ServiceException("地籍代码长度必须为12位");
|
|
|
+ }
|
|
|
+ return zrzMapper.getListByDjzqdm(djzqdm);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public HouseStatisticsRes statistics(String djzqdm) {
|
|
|
if (StringUtils.isBlank(djzqdm) || djzqdm.matches("[0]+")) {
|
|
|
@@ -72,6 +83,48 @@ public class HouseServiceImpl implements IHouselService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HouseStatisticsAreaRes statisticsOfArea(String djzqdm) {
|
|
|
+ if (StringUtils.isBlank(djzqdm) || djzqdm.matches("[0]+")) {
|
|
|
+ djzqdm = "";
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(djzqdm) && djzqdm.length() != 12) {
|
|
|
+ throw new ServiceException("地籍代码长度必须为12位");
|
|
|
+ }
|
|
|
+
|
|
|
+ HouseStatisticsAreaRes res = new HouseStatisticsAreaRes();
|
|
|
+ List<Zrz> zrzList = zrzMapper.getListByDjzqdm(djzqdm);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(zrzList)) {
|
|
|
+ List<HouseStatisticsAreaRes.DetailDTO> detailList = new ArrayList<>();
|
|
|
+ List<Zrz> registeredList = new ArrayList<>();
|
|
|
+ List<Zrz> unregisteredList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Zrz zrz : zrzList) {
|
|
|
+ String djzt = zrz.getDjzt();
|
|
|
+ if ("1".equals(djzt)) {
|
|
|
+ registeredList.add(zrz);
|
|
|
+ } else if ("2".equals(djzt) || "3".equals(djzt)) {
|
|
|
+ unregisteredList.add(zrz);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ detailList.add(buildAreaDetailDTO(registeredList, "1"));
|
|
|
+ detailList.add(buildAreaDetailDTO(unregisteredList, "2"));
|
|
|
+ detailList.add(buildAreaDetailDTO(zrzList, "0"));
|
|
|
+ res.setLandNumStatisticsList(detailList);
|
|
|
+
|
|
|
+ res.setFwytStatisticsList(getFwytAreaStatistics(zrzList, "A11", "ghyt"));
|
|
|
+ res.setQlxzStatisticsList(getFwxzAreaStatistics(zrzList, "A13", "fwxz"));
|
|
|
+ res.setFwjgStatisticsList(getFwjgAreaStatistics(zrzList, "A16", "fwjg"));
|
|
|
+ res.setJsnfStatisticsList(getJsnfAreaStatistics(zrzList));
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private HouseStatisticsRes.DetailDTO buildDetailDTO(List<Zrz> list, String djzt) {
|
|
|
HouseStatisticsRes.DetailDTO detail = new HouseStatisticsRes.DetailDTO();
|
|
|
detail.setDjzt(djzt);
|
|
|
@@ -207,6 +260,126 @@ public class HouseServiceImpl implements IHouselService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private HouseStatisticsAreaRes.DetailDTO buildAreaDetailDTO(List<Zrz> list, String djzt) {
|
|
|
+ HouseStatisticsAreaRes.DetailDTO detail = new HouseStatisticsAreaRes.DetailDTO();
|
|
|
+ detail.setDjzt(djzt);
|
|
|
+ int zrzs = list.size();
|
|
|
+ double totalZdmj = 0.0;
|
|
|
+ double totalScjzmj = 0.0;
|
|
|
+
|
|
|
+ for (Zrz zrz : list) {
|
|
|
+ totalZdmj += convertAreaToMu(zrz.getZzdmj());
|
|
|
+ totalScjzmj += convertAreaToMu(zrz.getScjzmj());
|
|
|
+ }
|
|
|
+
|
|
|
+ detail.setZrzs(zrzs);
|
|
|
+ detail.setZdmj(totalZdmj);
|
|
|
+ detail.setJzzmj(totalScjzmj);
|
|
|
+
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<HouseStatisticsAreaRes.FwytDTO> getFwytAreaStatistics(List<Zrz> zrzList, String dictType, String fieldName) {
|
|
|
+ List<HouseStatisticsAreaRes.FwytDTO> result = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> dictList = zrzMapper.getDictByType(dictType, null);
|
|
|
+
|
|
|
+ Map<String, Double> groupedData = zrzList.stream()
|
|
|
+ .filter(zrz -> getFieldValue(zrz, fieldName) != null)
|
|
|
+ .collect(Collectors.groupingBy(zrz -> getFieldValue(zrz, fieldName),
|
|
|
+ Collectors.summingDouble(zrz -> convertAreaToMu(zrz.getScjzmj()))));
|
|
|
+
|
|
|
+ for (Map<String, Object> dict : dictList) {
|
|
|
+ String name = MapUtils.getString(dict, "name");
|
|
|
+ String value = MapUtils.getString(dict, "value");
|
|
|
+ if (groupedData.containsKey(value)) {
|
|
|
+ HouseStatisticsAreaRes.FwytDTO dto = new HouseStatisticsAreaRes.FwytDTO();
|
|
|
+ dto.setFwytmc(name);
|
|
|
+ dto.setFwytmj(String.valueOf(groupedData.get(value)));
|
|
|
+ result.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<HouseStatisticsAreaRes.FwxzDTO> getFwxzAreaStatistics(List<Zrz> zrzList, String dictType, String fieldName) {
|
|
|
+ List<HouseStatisticsAreaRes.FwxzDTO> result = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> dictList = zrzMapper.getDictByType(dictType, null);
|
|
|
+
|
|
|
+ Map<String, Double> groupedData = zrzList.stream()
|
|
|
+ .filter(zrz -> getFieldValue(zrz, fieldName) != null)
|
|
|
+ .collect(Collectors.groupingBy(zrz -> getFieldValue(zrz, fieldName),
|
|
|
+ Collectors.summingDouble(zrz -> convertAreaToMu(zrz.getScjzmj()))));
|
|
|
+
|
|
|
+ for (Map<String, Object> dict : dictList) {
|
|
|
+ String name = MapUtils.getString(dict, "name");
|
|
|
+ String value = MapUtils.getString(dict, "value");
|
|
|
+ if (groupedData.containsKey(value)) {
|
|
|
+ HouseStatisticsAreaRes.FwxzDTO dto = new HouseStatisticsAreaRes.FwxzDTO();
|
|
|
+ dto.setFwxzmc(name);
|
|
|
+ dto.setFwxzmj(String.valueOf(groupedData.get(value)));
|
|
|
+ result.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<HouseStatisticsAreaRes.FwjgDTO> getFwjgAreaStatistics(List<Zrz> zrzList, String dictType, String fieldName) {
|
|
|
+ List<HouseStatisticsAreaRes.FwjgDTO> result = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> dictList = zrzMapper.getDictByType(dictType, null);
|
|
|
+
|
|
|
+ Map<String, Double> groupedData = zrzList.stream()
|
|
|
+ .filter(zrz -> getFieldValue(zrz, fieldName) != null)
|
|
|
+ .collect(Collectors.groupingBy(zrz -> getFieldValue(zrz, fieldName),
|
|
|
+ Collectors.summingDouble(zrz -> convertAreaToMu(zrz.getScjzmj()))));
|
|
|
+
|
|
|
+ for (Map<String, Object> dict : dictList) {
|
|
|
+ String name = MapUtils.getString(dict, "name");
|
|
|
+ String value = MapUtils.getString(dict, "value");
|
|
|
+ if (groupedData.containsKey(value)) {
|
|
|
+ HouseStatisticsAreaRes.FwjgDTO dto = new HouseStatisticsAreaRes.FwjgDTO();
|
|
|
+ dto.setFwjgmc(name);
|
|
|
+ dto.setFwjgmj(String.valueOf(groupedData.get(value)));
|
|
|
+ result.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<HouseStatisticsAreaRes.FwjsnfDTO> getJsnfAreaStatistics(List<Zrz> zrzList) {
|
|
|
+ List<HouseStatisticsAreaRes.FwjsnfDTO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ String[] labels = {"1960年之前", "1961年-1969年", "1970年-1979年", "1980年-1989年", "1990年-1999年", "2000年-2009年", "2010年-2019年", "2020年之后"};
|
|
|
+ double[] areas = new double[labels.length];
|
|
|
+
|
|
|
+ for (Zrz zrz : zrzList) {
|
|
|
+ if (zrz.getJgrq() != null) {
|
|
|
+ java.util.Calendar cal = java.util.Calendar.getInstance();
|
|
|
+ cal.setTime(zrz.getJgrq());
|
|
|
+ int year = cal.get(java.util.Calendar.YEAR);
|
|
|
+ double area = convertAreaToMu(zrz.getScjzmj());
|
|
|
+
|
|
|
+ if (year <= 1960) areas[0] += area;
|
|
|
+ else if (year >= 1961 && year <= 1969) areas[1] += area;
|
|
|
+ else if (year >= 1970 && year <= 1979) areas[2] += area;
|
|
|
+ else if (year >= 1980 && year <= 1989) areas[3] += area;
|
|
|
+ else if (year >= 1990 && year <= 1999) areas[4] += area;
|
|
|
+ else if (year >= 2000 && year <= 2009) areas[5] += area;
|
|
|
+ else if (year >= 2010 && year <= 2019) areas[6] += area;
|
|
|
+ else if (year >= 2020) areas[7] += area;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < labels.length; i++) {
|
|
|
+ if (areas[i] > 0) {
|
|
|
+ HouseStatisticsAreaRes.FwjsnfDTO dto = new HouseStatisticsAreaRes.FwjsnfDTO();
|
|
|
+ dto.setFwjsnfmc(labels[i]);
|
|
|
+ dto.setFwjsnfmj(String.valueOf(areas[i]));
|
|
|
+ result.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|