|
@@ -0,0 +1,147 @@
|
|
|
+package com.dayou.utils;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.dayou.entity.MajorTarget;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 大中型评估计件工具类
|
|
|
+ */
|
|
|
+public class MajorEvaluateUnitUtil {
|
|
|
+
|
|
|
+ //计件 特殊的市级单位
|
|
|
+ private static List<Long> expeCitys = new ArrayList<>();
|
|
|
+
|
|
|
+ private static List<Long> cdCountys = new ArrayList<>();
|
|
|
+
|
|
|
+ private static List<Long> cqCountys = new ArrayList<>();
|
|
|
+
|
|
|
+ private static List<Long> expePros = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ static {
|
|
|
+ expePros.add(11L);
|
|
|
+ expePros.add(12L);
|
|
|
+ expePros.add(31L);
|
|
|
+ expeCitys.add(5101L);
|
|
|
+ expeCitys.add(5002L);
|
|
|
+ cdCountys.add(510121L);
|
|
|
+ cdCountys.add(510129L);
|
|
|
+ cdCountys.add(510131L);
|
|
|
+ cdCountys.add(510132L);
|
|
|
+ cdCountys.add(510181L);
|
|
|
+ cdCountys.add(510182L);
|
|
|
+ cdCountys.add(510183L);
|
|
|
+ cdCountys.add(510184L);
|
|
|
+ cdCountys.add(510185L);
|
|
|
+ cqCountys.add(500229L);
|
|
|
+ cqCountys.add(500230L);
|
|
|
+ cqCountys.add(500231L);
|
|
|
+ cqCountys.add(500233L);
|
|
|
+ cqCountys.add(500235L);
|
|
|
+ cqCountys.add(500236L);
|
|
|
+ cqCountys.add(500237L);
|
|
|
+ cqCountys.add(500238L);
|
|
|
+ cqCountys.add(500240L);
|
|
|
+ cqCountys.add(500241L);
|
|
|
+ cqCountys.add(500242L);
|
|
|
+ cqCountys.add(500243L);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计件逻辑:
|
|
|
+ * 如果一个订单中包含多个地区的评估对象,则应根据所涉及的地区数量来认定接件数。地区数量具体划分如下:
|
|
|
+ * (1)成都市/直辖市:市内各区视为1个地区;县级行政区内按县进行划分,每个县单独计算为一个地区;
|
|
|
+ * (2)其他地区:按市级行政区划分别核算地区数量。
|
|
|
+ * 认定接件数的原则如下:
|
|
|
+ * 第一个地区认定为1件;
|
|
|
+ * 第二个地区认定为0.5件;
|
|
|
+ * 第三个地区认定为0.8件;
|
|
|
+ * 从第四个地区开始,每新增一个地区,新增认定1件。
|
|
|
+ * @param targets
|
|
|
+ */
|
|
|
+ public static BigDecimal calculateEvaluateUnit(List<MajorTarget> targets){
|
|
|
+
|
|
|
+ int unit = 0;
|
|
|
+ List<String> collect = targets.stream().map(MajorTarget::getCityArray).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (collect.size()!=1){
|
|
|
+
|
|
|
+ List<Long> provinces = new ArrayList<>();
|
|
|
+ List<Long> cities = new ArrayList<>();
|
|
|
+ List<Long> counties = new ArrayList<>();
|
|
|
+
|
|
|
+ //多个估价对象
|
|
|
+ List<List<Long>> citys = collect.stream().map(x -> {return JSON.parseArray(x, Long.class);}).collect(Collectors.toList());
|
|
|
+ boolean flag = true;
|
|
|
+ for (List<Long> city : citys) {
|
|
|
+ if (city.get(1).equals(5101L)){
|
|
|
+ if (cdCountys.contains(city.get(2)) && !counties.contains(city.get(2))){
|
|
|
+ unit ++;
|
|
|
+ counties.add(city.get(2));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!cdCountys.contains(city.get(2)) && flag){
|
|
|
+ unit ++;
|
|
|
+ flag = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (counties.contains(city.get(2)) || !flag){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (city.get(1).equals(5002L) && !counties.contains(city.get(2))){
|
|
|
+ unit ++;
|
|
|
+ counties.add(city.get(2));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (counties.contains(city.get(2))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (expePros.contains(city.get(0)) && !provinces.contains(city.get(0))){
|
|
|
+ unit ++;
|
|
|
+ provinces.add(city.get(0));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (expePros.contains(city.get(0)) && provinces.contains(city.get(0))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!expePros.contains(city.get(0)) && !cities.contains(city.get(1))){
|
|
|
+ unit ++;
|
|
|
+ cities.add(city.get(1));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!expePros.contains(city.get(0)) && cities.contains(city.get(1))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ unit ++;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ unit = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal result = BigDecimal.ZERO;
|
|
|
+ for (int i = 1; i<=unit ; i++){
|
|
|
+ if (i==2){
|
|
|
+ result = result.add(new BigDecimal("0.5"));
|
|
|
+ }else if (i==3){
|
|
|
+ result = result.add(new BigDecimal("0.8"));
|
|
|
+ }else {
|
|
|
+ result = result.add(new BigDecimal("1"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|