|
@@ -1,13 +1,18 @@
|
|
|
package com.dayou.utils;
|
|
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import com.dayou.dto.Address;
|
|
|
import com.dayou.enums.HouseTargetTableColumn;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static com.dayou.enums.HouseTargetTableColumn.*;
|
|
|
+import static com.dayou.utils.CollectionUtil.sortedByCounting;
|
|
|
|
|
|
/**
|
|
|
* 房地产报告相关工具类
|
|
@@ -23,11 +28,10 @@ public class HouseDocumentUtil {
|
|
|
JSONArray targets = new JSONArray();
|
|
|
if (jsonArray.size()>1){
|
|
|
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
Set<String> columns = jsonObject.keySet();
|
|
|
for (int i = 0; i < jsonArray.size(); i++){
|
|
|
JSONObject item = (JSONObject) jsonArray.get(i);
|
|
|
- if (item.get(HouseTargetTableColumn.LOCATION.getZhName())!=null
|
|
|
+ if (item.get(LOCATION.getZhName())!=null
|
|
|
&& item.get(HouseTargetTableColumn.CERTIFICATE_NO.getZhName())!=null){
|
|
|
for (String key : columns){
|
|
|
if (item.get(key)==null || item.get(key)==""){
|
|
@@ -41,4 +45,168 @@ public class HouseDocumentUtil {
|
|
|
}
|
|
|
return targets;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化项目名称
|
|
|
+ * @param array
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getProjectName(JSONArray array){
|
|
|
+ List<Object> addresses = array.stream().map(obj -> ((JSONObject) obj).get(LOCATION.getZhName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Address> addressList = AddressUtil.parseAddress(addresses);
|
|
|
+ return CollectionUtil.formatSplitAndRemoveMiddle(mergeAddress(addressList));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化权利人
|
|
|
+ * @param array
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getOwnShipUser(JSONArray array){
|
|
|
+ Set<Object> ownShipUsers = array.stream().map(obj -> ((JSONObject) obj).get(OWE_SHIP_USER.getZhName()))
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ return CollectionUtil.formatDotAndRemoveMiddle(ownShipUsers);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合并地址
|
|
|
+ * @param addressList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ public static List<String> mergeAddress(List<Address> addressList){
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ //一级分组
|
|
|
+ Map<String, List<Address>> collect1 = addressList.stream().collect(Collectors.groupingBy(Address::getProvince));
|
|
|
+ collect1 = (Map<String, List<Address>>) sortedByCounting(collect1);
|
|
|
+ for (Map.Entry<String, List<Address>> entry1 : collect1.entrySet()) {
|
|
|
+ String province = entry1.getKey();
|
|
|
+ StringBuilder stringBuilder = new StringBuilder(province);
|
|
|
+ List<Address> addresses1 = entry1.getValue();
|
|
|
+ Map<String, List<Address>> collect2 = addresses1.stream().collect(Collectors.groupingBy(Address::getCity));
|
|
|
+ collect2 = (Map<String, List<Address>>) sortedByCounting(collect2);
|
|
|
+ int index2 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry2 : collect2.entrySet()){
|
|
|
+ if (collect2.size()>1 && index2!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String city = entry2.getKey();
|
|
|
+ stringBuilder.append(city);
|
|
|
+ List<Address> addresses2 = entry2.getValue();
|
|
|
+ Map<String, List<Address>> collect3 = addresses2.stream().collect(Collectors.groupingBy(Address::getDistrict));
|
|
|
+ collect3 = (Map<String, List<Address>>) sortedByCounting(collect3);
|
|
|
+ index2 ++;
|
|
|
+ int index3 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry3 : collect3.entrySet()){
|
|
|
+ if (collect3.size()>1 && index3!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String district = entry3.getKey();
|
|
|
+ stringBuilder.append(district);
|
|
|
+ List<Address> addresses3 = entry3.getValue();
|
|
|
+ Map<String, List<Address>> collect4 = addresses3.stream().collect(Collectors.groupingBy(Address::getTown));
|
|
|
+ collect4 = (Map<String, List<Address>>) sortedByCounting(collect4);
|
|
|
+ index3 ++;
|
|
|
+ int index4 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry4 : collect4.entrySet()){
|
|
|
+ if (collect4.size()>1 && index4!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String town = entry4.getKey();
|
|
|
+ stringBuilder.append(town);
|
|
|
+ List<Address> addresses4 = entry4.getValue();
|
|
|
+ Map<String, List<Address>> collect5 = addresses4.stream().collect(Collectors.groupingBy(Address::getCommunity));
|
|
|
+ collect5 = (Map<String, List<Address>>) sortedByCounting(collect5);
|
|
|
+ index4 ++;
|
|
|
+ int index5 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry5 : collect5.entrySet()){
|
|
|
+ if (collect5.size()>1 && index5!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String community = entry5.getKey();
|
|
|
+ stringBuilder.append(community);
|
|
|
+ List<Address> addresses5 = entry5.getValue();
|
|
|
+ Map<String, List<Address>> collect6 = addresses5.stream().collect(Collectors.groupingBy(Address::getRoad));
|
|
|
+ collect6 = (Map<String, List<Address>>) sortedByCounting(collect6);
|
|
|
+ index5 ++;
|
|
|
+ int index6 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry6 : collect6.entrySet()){
|
|
|
+ if (collect6.size()>1 && index6!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String road = entry6.getKey();
|
|
|
+ stringBuilder.append(road);
|
|
|
+ List<Address> addresses6 = entry6.getValue();
|
|
|
+ Map<String, List<Address>> collect7 = addresses6.stream().collect(Collectors.groupingBy(Address::getRoadNumber));
|
|
|
+ collect7 = (Map<String, List<Address>>) sortedByCounting(collect7);
|
|
|
+ index6 ++;
|
|
|
+ int index7 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry7 : collect7.entrySet()){
|
|
|
+ if (collect7.size()>1 && index7!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String roadNumber = entry7.getKey();
|
|
|
+ stringBuilder.append(roadNumber);
|
|
|
+ List<Address> addresses7 = entry7.getValue();
|
|
|
+ Map<String, List<Address>> collect8 = addresses7.stream().collect(Collectors.groupingBy(Address::getBuilding));
|
|
|
+ collect8 = (Map<String, List<Address>>) sortedByCounting(collect8);
|
|
|
+ index7 ++;
|
|
|
+ int index8 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry8 : collect8.entrySet()){
|
|
|
+ if (collect8.size()>1 && index8!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String building = entry8.getKey();
|
|
|
+ stringBuilder.append(building);
|
|
|
+ List<Address> addresses8 = entry8.getValue();
|
|
|
+ Map<String, List<Address>> collect9 = addresses8.stream().collect(Collectors.groupingBy(Address::getUnit));
|
|
|
+ collect9 = (Map<String, List<Address>>) sortedByCounting(collect9);
|
|
|
+ index8 ++;
|
|
|
+ int index9 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry9 : collect9.entrySet()){
|
|
|
+ if (collect9.size()>1 && index9!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String unit = entry9.getKey();
|
|
|
+ stringBuilder.append(unit);
|
|
|
+ List<Address> addresses9 = entry9.getValue();
|
|
|
+ Map<String, List<Address>> collect10 = addresses9.stream().collect(Collectors.groupingBy(Address::getFloor));
|
|
|
+ collect10 = (Map<String, List<Address>>) sortedByCounting(collect10);
|
|
|
+ index9 ++;
|
|
|
+ int index10 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry10 : collect10.entrySet()){
|
|
|
+ if (collect10.size()>1 && index10!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String floor = entry10.getKey();
|
|
|
+ stringBuilder.append(floor);
|
|
|
+ List<Address> addresses10 = entry10.getValue();
|
|
|
+ Map<String, List<Address>> collect11 = addresses10.stream().collect(Collectors.groupingBy(Address::getRoom));
|
|
|
+ collect11 = (Map<String, List<Address>>) sortedByCounting(collect11);
|
|
|
+ index10 ++;
|
|
|
+ int index11 = 0;
|
|
|
+ for (Map.Entry<String,List<Address>> entry11 : collect11.entrySet()){
|
|
|
+ if (collect11.size()>1 && index11!=0){
|
|
|
+ stringBuilder.append("、");
|
|
|
+ }
|
|
|
+ String room = entry11.getKey();
|
|
|
+ stringBuilder.append(room);
|
|
|
+ index11 ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ result.add(stringBuilder.toString());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|