|
@@ -1,14 +1,14 @@
|
|
|
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 com.dayou.exception.ErrorCode;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.dayou.enums.HouseTargetTableColumn.*;
|
|
@@ -65,11 +65,157 @@ public class HouseDocumentUtil {
|
|
|
*/
|
|
|
public static String getOwnShipUser(JSONArray array){
|
|
|
Set<Object> ownShipUsers = array.stream().map(obj -> ((JSONObject) obj).get(OWE_SHIP_USER.getZhName()))
|
|
|
- .collect(Collectors.toSet());
|
|
|
+ .filter(x->x!=null).collect(Collectors.toSet());
|
|
|
return CollectionUtil.formatDotAndRemoveMiddle(ownShipUsers);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 格式化用途
|
|
|
+ * @param array
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getUseTo(JSONArray array){
|
|
|
+ Set<Object> useTo = array.stream().map(obj -> ((JSONObject) obj).get(USE_TO.getZhName()))
|
|
|
+ .filter(x->x!=null).collect(Collectors.toSet());
|
|
|
+ return CollectionUtil.formatDotAndRemoveMiddle(useTo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化实勘地址
|
|
|
+ * @param targets
|
|
|
+ * @param actAddress
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getActAddress(JSONArray targets,String actAddress){
|
|
|
+ StringBuilder sb = new StringBuilder("【");
|
|
|
+ if (StrUtil.isNotBlank(actAddress)){
|
|
|
+ sb.append("实勘地址").append(actAddress).append("(未见其余门牌号);");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Object> acreage = JsonUtil.collectByKeyToList(targets, ACREAGE.getZhName());
|
|
|
+ //建筑面积
|
|
|
+ BigDecimal totalAcreage = sumList(acreage);
|
|
|
+
|
|
|
+ Set<Object> landType = JsonUtil.collectByKeyToSet(targets, LAND_TYPE.getZhName());
|
|
|
+
|
|
|
+ List<Object> outerAcreage = JsonUtil.collectByKeyToList(targets, OUTER_ACREAGE.getZhName());
|
|
|
+
|
|
|
+ Set<Object> useTo = JsonUtil.collectByKeyToSet(targets, USE_TO.getZhName());
|
|
|
+
|
|
|
+ String outDesc = outAcreageTemplate(useTo, landType, outerAcreage);
|
|
|
+ sb.append("建筑面积"+(targets.size()>1?"合计:":":")).append(totalAcreage).append("㎡;");
|
|
|
+
|
|
|
+
|
|
|
+ sb.append("房屋所有权证号:");
|
|
|
+ List<Object> certificateNos = JsonUtil.collectByKeyToList(targets, CERTIFICATE_NO.getZhName());
|
|
|
+
|
|
|
+ String certificates = CollectionUtil.formatDotAndRemoveMiddle(certificateNos);
|
|
|
+
|
|
|
+ sb.append(certificates).append(",");
|
|
|
+
|
|
|
+ sb.append(outDesc).append("】");
|
|
|
+
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 格式化估价对象描述
|
|
|
+ * @param targets 估价对象
|
|
|
+ * @param actAddress 实勘地址
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getTargetDescription(JSONArray targets,String actAddress){
|
|
|
+ //单个估价对象里面可能有多个子对象
|
|
|
+ String address = getProjectName(targets);
|
|
|
+ //实勘地址
|
|
|
+ //权利人
|
|
|
+ String ownShipUser = getOwnShipUser(targets);
|
|
|
+ //用途
|
|
|
+ String useTo = getUseTo(targets);
|
|
|
+ //编号
|
|
|
+ String id = (String) ((JSONObject) targets.get(0)).get(ID.getZhName());
|
|
|
+ //实勘描述
|
|
|
+ String actDesc = getActAddress(targets, actAddress);
|
|
|
+ //格式化 todo 段落模版从DB中获取
|
|
|
+ String template ;
|
|
|
+ if (StrUtil.isNotBlank(ownShipUser)){
|
|
|
+ template = "估价对象${id}系${ownShipUser}所有的位于${address}${useTo}房地产${actDesc}";
|
|
|
+ }else {
|
|
|
+ template = "估价对象${id}位于${address}${useTo}房地产${actDesc}";
|
|
|
+ }
|
|
|
+ return template.replace("${id}", id).replace("${ownShipUser}", ownShipUser).replace("${address}", address)
|
|
|
+ .replace("${useTo}", useTo).replace("${actDesc}", actDesc);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * List<Object>求和
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static BigDecimal sumList(List<Object> list){
|
|
|
+ BigDecimal sum = null;
|
|
|
+ try {
|
|
|
+ sum = (BigDecimal) list.stream().reduce(BigDecimal.ZERO, (a, b) -> {
|
|
|
+ return new BigDecimal(String.valueOf(a)).add(new BigDecimal(String.valueOf(b)));
|
|
|
+ });
|
|
|
+ }catch (NumberFormatException e) {
|
|
|
+ ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"数字格式化异常");
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ return sum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分摊土地描述
|
|
|
+ * @param useTo
|
|
|
+ * @param landType
|
|
|
+ * @param outerAcreage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String outAcreageTemplate(Set<Object> useTo,Set<Object> landType,List<Object> outerAcreage){
|
|
|
+ //有地类用途和分摊面积
|
|
|
+ if (cn.hutool.core.collection.CollectionUtil.isNotEmpty(outerAcreage)
|
|
|
+ && cn.hutool.core.collection.CollectionUtil.isNotEmpty(landType)){
|
|
|
+ if (landType.contains("商业用地")){
|
|
|
+ BigDecimal sum = sumList(outerAcreage);
|
|
|
+ return "估价对象分摊出让商业用地使用权面积合计为:"+sum.toString()+"㎡;详见估价结果一览表";
|
|
|
+ }
|
|
|
+ if (landType.contains("批发零售用地")){
|
|
|
+ BigDecimal sum = sumList(outerAcreage);
|
|
|
+ return "估价对象分摊出让批发零售用地使用权面积合计为:"+sum.toString()+"㎡;详见估价结果一览表";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //有用途和分摊面积
|
|
|
+ if (cn.hutool.core.collection.CollectionUtil.isNotEmpty(outerAcreage)
|
|
|
+ && cn.hutool.core.collection.CollectionUtil.isNotEmpty(useTo)){
|
|
|
+ if (useTo.contains("工厂")){
|
|
|
+ BigDecimal sum = sumList(outerAcreage);
|
|
|
+ return "估价对象分摊出让工业用地使用权面积:"+sum.toString()+"㎡。详见估价结果一览表";
|
|
|
+ }
|
|
|
+ if (useTo.contains("车位")){
|
|
|
+ BigDecimal sum = sumList(outerAcreage);
|
|
|
+ return "估价对象分摊出让住宅(地下车库)用地使用权面积合计:"+sum.toString()+"㎡。详见估价结果一览表";
|
|
|
+ }
|
|
|
+ if (useTo.contains("住宅")){
|
|
|
+ BigDecimal sum = sumList(outerAcreage);
|
|
|
+ return "估价对象分摊出让城镇住宅用地使用权面积:"+sum.toString()+"㎡。详见估价结果一览表";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //有用途和无分摊面积
|
|
|
+ if (cn.hutool.core.collection.CollectionUtil.isEmpty(outerAcreage)
|
|
|
+ && cn.hutool.core.collection.CollectionUtil.isNotEmpty(useTo)){
|
|
|
+ if (useTo.contains("商业")){
|
|
|
+ return "估价对象占用(分摊)的国有建设用地使用权系商业用地。详见估价结果一览表";
|
|
|
+ }
|
|
|
+ if (useTo.contains("住宅")){
|
|
|
+ return "估价对象分摊的土地使用权系出让城镇住宅用地。详见估价结果一览表";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "!分摊面积描述待补充!";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 合并地址
|
|
|
* @param addressList
|
|
|
* @return
|
|
@@ -207,6 +353,7 @@ public class HouseDocumentUtil {
|
|
|
}
|
|
|
result.add(stringBuilder.toString());
|
|
|
}
|
|
|
+ Collections.reverse(result);
|
|
|
return result;
|
|
|
}
|
|
|
}
|