diff --git a/deliverables/auto/pom.xml b/deliverables/auto/pom.xml
index 292ddf9d6..831bfe4c9 100644
--- a/deliverables/auto/pom.xml
+++ b/deliverables/auto/pom.xml
@@ -18,6 +18,6 @@
goojia-auto
- ../../projects/goojia-auto
+
diff --git a/projects/fangjia-bkoff/src/main/webapp/style/address/main.css.baiduyun.uploading.cfg b/projects/fangjia-bkoff/src/main/webapp/style/address/main.css.baiduyun.uploading.cfg
new file mode 100644
index 000000000..74aacef5a
Binary files /dev/null and b/projects/fangjia-bkoff/src/main/webapp/style/address/main.css.baiduyun.uploading.cfg differ
diff --git a/projects/fangjia-bkoff/src/main/webapp/style/audit/list.css.baiduyun.uploading.cfg b/projects/fangjia-bkoff/src/main/webapp/style/audit/list.css.baiduyun.uploading.cfg
new file mode 100644
index 000000000..f612f71b5
Binary files /dev/null and b/projects/fangjia-bkoff/src/main/webapp/style/audit/list.css.baiduyun.uploading.cfg differ
diff --git a/projects/fangjia-bkoff/src/main/webapp/style/theme.css.baiduyun.uploading.cfg b/projects/fangjia-bkoff/src/main/webapp/style/theme.css.baiduyun.uploading.cfg
new file mode 100644
index 000000000..0c2959a18
Binary files /dev/null and b/projects/fangjia-bkoff/src/main/webapp/style/theme.css.baiduyun.uploading.cfg differ
diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AaController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AaController.java
index d83085e01..ce11d95e3 100644
--- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AaController.java
+++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AaController.java
@@ -22,16 +22,16 @@ public class AaController {
private AddressModeParserChain addressModeParserChain;
public Object pickAction() throws Exception {
- File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
- File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_picker.txt");
+ File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\涓婃捣-0730.txt");
+ File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\涓婃捣-0730_picker.txt");
if (file2.exists()) {
file2.delete();
}
- BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
+ BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 鎸囧畾缂栫爜鏍煎紡锛屼互鍏嶈鍙栨椂涓枃瀛楃寮傚父
- // 全部写入缓存中的内容
+ // 鍏ㄩ儴鍐欏叆缂撳瓨涓殑鍐呭
- InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
+ InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 鑰冭檻鍒扮紪鐮佹牸寮�
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
@@ -42,7 +42,7 @@ public class AaController {
List tokens = CnAddressTokenizer.tokenizer(lineTxt);
addressPickerChain.doPick(tokens, ret);
- // parserChain.doParse("上海", lineTxt, ret);
+ // parserChain.doParse("涓婃捣", lineTxt, ret);
ret.remove(AddressAnalyseResultKeyEnum.orgAddress.name());
// ret.remove(AddressAnalyseResultKeyEnum.shortAddress.name());
@@ -64,16 +64,16 @@ public class AaController {
}
public Object parseAction() throws Exception {
- File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
- File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_parser.txt");
+ File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\涓婃捣-0730.txt");
+ File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\涓婃捣-0730_parser.txt");
if (file2.exists()) {
file2.delete();
}
- BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
+ BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 鎸囧畾缂栫爜鏍煎紡锛屼互鍏嶈鍙栨椂涓枃瀛楃寮傚父
- // 全部写入缓存中的内容
+ // 鍏ㄩ儴鍐欏叆缂撳瓨涓殑鍐呭
- InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
+ InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 鑰冭檻鍒扮紪鐮佹牸寮�
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
@@ -81,7 +81,7 @@ public class AaController {
ret.put(AddressAnalyseResultKeyEnum.orgAddress.name(), lineTxt);
System.out.println(lineTxt);
- addressModeParserChain.doParse("上海", lineTxt, ret);
+ addressModeParserChain.doParse("涓婃捣", lineTxt, ret);
ret.remove(AddressAnalyseResultKeyEnum.orgAddress.name());
ret.remove(AddressAnalyseResultKeyEnum.shortAddress.name());
diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java
new file mode 100644
index 000000000..710ced096
--- /dev/null
+++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java
@@ -0,0 +1,1316 @@
+package com.fangjia.open.controllers;
+
+import com.fangjia.core.util.*;
+import com.fangjia.dal.common.DistrictKey;
+import com.fangjia.dal.mongo.fangjia.model.ServerArea;
+import com.fangjia.dal.mongo.model.ApiUserCfg;
+import com.fangjia.dal.mongo.model.DistrictFacilitys;
+import com.fangjia.dal.mongo.model.Evaluation;
+import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap;
+import com.fangjia.dal.mongo.model.bkoff.Loudong;
+import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
+import com.fangjia.dal.mongo.open.model.EvaluateRatio;
+import com.fangjia.dal.seaweed.model.District;
+import com.fangjia.open.HttpCode;
+import com.fangjia.open.OpenHttpCodeEnum;
+import com.fangjia.open.dto.HouseValueInformationDto;
+import com.fangjia.open.dto.UniversalDto;
+import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto;
+import com.fangjia.open.interceptors.AuthenticationBean;
+import com.fangjia.open.interceptors.Authority;
+import com.fangjia.open.interceptors.Role;
+import com.fangjia.open.model.*;
+import com.fangjia.open.util.CommonDtoUtils;
+import com.fangjia.open.util.CommonUtils;
+import com.fangjia.open.ws.query.SampleQuery;
+import com.fangjia.service.api.AddressMatchProxyService;
+import com.fangjia.service.api.ApiUserCfgService;
+import com.fangjia.service.bo.Collateral;
+import com.fangjia.service.bo.DistrictStatBo;
+import com.fangjia.service.bo.Sample;
+import com.fangjia.service.datastore.*;
+import com.fangjia.service.datastore.bean.CollateralSampleQueryBean;
+import com.fangjia.service.district.*;
+import com.fangjia.service.mongo.bkoff.HouseLoudongService;
+import com.fangjia.service.mongo.bkoff.LoudongService;
+import com.fangjia.service.mongo.fangjia.*;
+import com.fangjia.service.open.*;
+import com.fangjia.service.tool.OpenLogService;
+import com.fangjia.service.web.AddressService;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.slf4j.Logger;
+import org.sothis.web.mvc.ActionContext;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.ParseException;
+import java.util.*;
+
+import static com.poseidon.util.TypeConverter.convertToString;
+
+/**
+ * @author 13607
+ * @since 2023/12/12 10:29
+ */
+@Authority(role = Role.USER)
+public class ComprehensiveQueryController {
+ private DistrictService districtService;
+
+ private DistrictStatService districtStatService;
+
+ private FangjiaOfficialAreaService fangjiaOfficialAreaService;
+ private AddressMatchProxyService addressMatchProxyService;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class);
+ private HouseLoudongService houseLoudongService;
+ private LoudongService loudongService;
+ private EvaluationService evaluationService;
+ private BatchEvaluateService batchEvaluateService;
+ private ApiUserAuthorityService apiUserAuthorityService;
+ private AverageStatisticsService averageStatisticsService;
+ private ServerAreaService serverAreaService;
+ private ApiUserCfgService apiUserCfgService;
+ private OpenApiLogService openApiLogService;
+ private EvaluateFactorService evaluateFactorService;
+
+ private CzbankSampleService czbankSampleService;
+
+ private DistrictFacilitysService districtFacilitysService;
+
+ private static final int DEFAULT_PAGE_SIZE = 20;
+ private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "lat2", "lng2", "lat", "lng", "block", "estateType2", "addrAlias"};
+ static final int BAI_DU_GEO = 1;// 百度系坐标
+ static final int GAO_DE_GEO = 2;// 高德系坐标
+
+
+
+ private EvaluateRatioService evaluateRatioService;
+
+ private static final int EVALUATE_SHOW_DETAIL = 1;
+ private static final Map PROPERTY_TYPES = new HashMap() {
+ {
+ put(null, "普通住宅");
+ put("0", "普通住宅");
+ put("1", "别墅");
+ put("2", "商住");
+ }
+ };
+
+ private static final Map DIRECTION = new HashMap() {
+ {
+ put(null, "南");
+ put("1", "西南");
+ put("2", "东南");
+ put("3", "南");
+ put("4", "西北");
+ put("5", "东北");
+ put("6", "东");
+ put("7", "西");
+ put("8", "北");
+ put("9", "东西");
+ put("10", "南北");
+ }
+ };
+
+ private static final Map FITMENT = new HashMap() {
+ {
+ put(null, "简装");
+ put("1", "毛坯");
+ put("2", "简装");
+ put("3", "精装");
+ put("4", "豪装");
+ }
+ };
+
+ private static final Map EVALUATION_MODEL_FITMENT = new HashMap() {
+ {
+ put(null, "简单装修");
+ put("简装", "简单装修");
+ put("毛坯", "毛坯");
+ put("精装", "精装修");
+ put("豪装", "豪华装修");
+ }
+ };
+
+ private static final Map SIGHT = new HashMap() {
+ {
+ put(null, "一般");
+ put("1", "景观房");
+ put("2", "侧景观房");
+ put("3", "一般");
+ put("4", "差");
+ }
+ };
+
+ private static final Map NOISE = new HashMap() {
+ {
+ put(null, "无噪音");
+ put("0", "无噪音");
+ put("1", "噪音较小");
+ put("2", "噪音大");
+ }
+ };
+ private static final Map FACILITIES = new HashMap() {
+ {
+ put("0", "健身房");
+ put("1", "游泳池");
+ put("2", "会所");
+ put("3", "网球场");
+ put("4", "球场");
+ put("5", "棋牌室");
+ put("6", "停车场");
+ put("7", "图书馆");
+ put("8", "活动中心");
+ }
+ };
+
+ private static final Map NEGATIVE_FACTOR = new HashMap() {
+ {
+ put(null, "无");
+ put("1", "很近");
+ put("2", "较近");
+ put("3", "无");
+ }
+ };
+
+
+ Map listKeyMap = new HashMap() {
+ {
+ put("school", "schools");
+ put("hospital", "hospitals");
+ put("bank", "banks");
+ put("supermarket", "supermarkets");
+ put("market", "markets");
+ put("beautySalon", "beautySalons");
+ put("gym", "gyms");
+ put("park", "parks");
+ put("bus", "buses");
+ put("metro", "metros");
+ put("dock", "docks");
+ put("airport", "airports");
+ put("trainStation", "trainStations");
+ put("restaurant", "restaurants");
+ put("hotel", "hotels");
+ }
+ };
+
+ private static final Map CITYLEVEL_MAP = new HashMap() {
+ {
+ put("1000", "one");// 一线
+ put("1500", "newOne");// 新一线
+ put("2000", "two");// 二线
+ put("3000", "three");// 三线
+ put("4000", "four");// 四线
+ put("5000", "five");// 五线
+ }
+ };
+
+ public Object houseValueInformationAction(HouseInfomationModel model, HttpServletRequest httpServletRequest) {
+
+ // 原小区均价
+ HouseValueInformationDto houseValueInformation = new HouseValueInformationDto();
+ RestfulModelAndView mav = new RestfulModelAndView();
+
+ if (StringUtils.isBlank(model.getAddress()) || StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(String.valueOf(model.getSize()))) {
+ mav.setModel(BasicModel.buildBadRequestModel("城市(city),地址(address),面积(size)为必填字段"));
+ return mav;
+ }
+
+ HttpRequest httpRequest = new HttpRequest();
+ JSONObject json = null;
+ Map communityAvgPriceParams = new HashMap();
+ communityAvgPriceParams.put("city", model.getCity());
+ communityAvgPriceParams.put("address", model.getAddress());
+ communityAvgPriceParams.put("category", model.getCategory());
+ communityAvgPriceParams.put("useMap", String.valueOf(model.isUseMap()));
+ JSONObject matchResponse = null;
+ try {
+ matchResponse = httpRequest.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8");
+ } catch (HttpRequestException e) {
+
+ }
+ if(matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) {
+ mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
+ return mav;
+ }
+ String id = matchResponse.getJSONObject("result").getString("id");
+ District district = districtService.findById(id);
+ if (district == null) {
+ mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
+ return mav;
+ }
+
+ MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, matchResponse.getJSONObject("result"));
+ DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(district));
+ if (null != statBo) {
+ if (statBo.getDistrictStat() != null) {
+ dto.setAvgPrice(statBo.getDistrictStat().getAvgPrice());
+ } else if (statBo.getVillaDistrictStat() != null) {
+ dto.setAvgPrice(statBo.getVillaDistrictStat().getAvgPrice());
+ }
+
+ }
+ // 保存小区均价的返回结果
+ houseValueInformation.setCommunityAvgPrice(dto);
+
+ //原房屋价值评估
+ //根据model给PropertyEvaluationModel赋值
+ PropertyEvaluationModel propertyEvaluationModel = createPropertyEvaluationModelFromHouseInfomationModel(model);
+ boolean villaFlag = DataUtil.isVilla(propertyEvaluationModel.getSize(), propertyEvaluationModel.getName(), propertyEvaluationModel.getHeight(), propertyEvaluationModel.getRoom());
+ String propertyType = district.getEstateType2();
+ if (villaFlag && StringUtils.isNotBlank(propertyType) && !propertyType.equals("别墅")) {
+ District bieShuDistrict = districtService.findByNameAndAlias(district.getCity(), district.getRegion(), district.getName() + "别墅", "district");
+ if (bieShuDistrict != null) {
+ district = bieShuDistrict;
+ }
+ }
+ propertyEvaluationModel.setDistrict(district.getRegion());
+ propertyEvaluationModel.setName(district.getName());
+ try {
+ evaluateAction(propertyEvaluationModel, httpServletRequest, houseValueInformation, mav);
+ } catch (IllegalAccessException e) {
+
+ }
+// houseValueInformation.setAddressValue(modelAndView);
+
+ //房源样本
+
+ //构造sampleQuery对象
+ SampleQuery sampleQuery = new SampleQuery();
+ sampleQuery.setCity(model.getCity());
+ sampleQuery.setStrctureArea(model.getSize());
+ sampleQuery.setAddress(model.getAddress());
+
+// RestfulModelAndView houseCaseMav = new RestfulModelAndView();
+ List querys = null;
+ try {
+ querys = convertSampileQueryToBean(district,sampleQuery);
+ } catch (Exception e) {
+ mav.setModel(BasicModel.buildBadRequestModel(e.getMessage()));
+ return mav;
+ }
+ if (null == sampleQuery.getMax()) {
+ sampleQuery.setMax(10);
+ }
+ // 此处慢
+ long start = System.currentTimeMillis();
+ List collaterals = czbankSampleService.findSample2(querys, sampleQuery.getMax());
+ long end = System.currentTimeMillis();
+ System.out.println("用时:"+(end-start));
+ Collateral collateral = collaterals.get(0);
+ List samples = collateral.getSample();
+ UniversalDto houseCaseDto = UniversalDto.newDto();
+ if (null != collateral.getMaxPrice()) {
+ houseCaseDto.append("maxUnitPrice", collateral.getMaxPrice());
+ }
+ if (null != collateral.getMinPrice()) {
+ houseCaseDto.append("minUnitPrice", collateral.getMinPrice());
+ }
+ houseCaseDto.append("datas", samples);
+// if(samples!= null && samples.size()>=2){
+// Sample minSample = samples.get(samples.size()-2);
+// Sample maxSample = samples.get(samples.size()-1);
+// dto.append("minUnitPrice", minSample.getUnitPrice());
+// dto.append("maxUnitPrice", maxSample.getUnitPrice());
+// }
+// if(samples.size()>2){
+// dto.append("datas", samples.subList(0, samples.size()-2));
+// }else{
+// dto.append("datas", samples);
+// }
+
+// houseCaseMav.setModel(BasicModel.buildOKModel().setResult(dto));
+// return houseCaseMav;
+
+ //将房源数据放到结果集
+ houseValueInformation.setHouseCase(houseCaseDto);
+
+ // 原周边POI
+ DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(district);
+ // 将周边POI数据放到结果集
+ houseValueInformation.setSurroundingPoi(facilitys);
+ mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation));
+ return mav;
+ }
+
+ private PropertyEvaluationModel createPropertyEvaluationModelFromHouseInfomationModel(HouseInfomationModel model) {
+ PropertyEvaluationModel propertyModel = new PropertyEvaluationModel();
+ propertyModel.setCity(model.getCity());
+ propertyModel.setAddress(model.getAddress());
+ propertyModel.setSize(model.getSize());
+
+ if (StringUtils.isNotBlank(model.getDistrict())) {
+ propertyModel.setDistrict(model.getDistrict());
+ }
+ if (StringUtils.isNotBlank(model.getName())) {
+ propertyModel.setName(model.getName());
+ }
+ if (StringUtils.isNotBlank(model.getBuildingNumber())) {
+ propertyModel.setBuildingNumber(model.getBuildingNumber());
+ }
+ if (StringUtils.isNotBlank(model.getUnitNumber())) {
+ propertyModel.setUnitNumber(model.getUnitNumber());
+ }
+ if (model.getFloor() != null && model.getFloor() != 0) {
+ propertyModel.setFloor(model.getFloor());
+ }
+ if (model.getMaxFloor() != null && model.getMaxFloor() != 0) {
+ propertyModel.setMaxFloor(model.getMaxFloor());
+ }
+ if (model.getRoom() != null && model.getRoom() != 0) {
+ propertyModel.setRoom(model.getRoom());
+ }
+ if (model.getHall() != 0) {
+ propertyModel.setHall(model.getHall());
+ }
+ if (model.getToilet() != 0) {
+ propertyModel.setToilet(model.getToilet());
+ }
+ if (model.getCalDate() != null) {
+ propertyModel.setCalDate(model.getCalDate());
+ }
+ if (model.getPropertyType() != null) {
+ propertyModel.setPropertyType(model.getPropertyType());
+ }
+ if (StringUtils.isNotBlank(model.getDirection())) {
+ propertyModel.setDirection(model.getDirection());
+ }
+ if (StringUtils.isNotBlank(model.getDecoration())) {
+ propertyModel.setDecoration(model.getDecoration());
+ }
+
+ if (model.getDecorationCost() != null && model.getDecorationCost() != 0) {
+ propertyModel.setDecorationCost(model.getDecorationCost());
+ }
+
+ if (model.getDecorationAge() != 0) {
+ propertyModel.setDecorationAge(model.getDecorationAge());
+ }
+ if (StringUtils.isNotBlank(model.getView())) {
+ propertyModel.setView(model.getView());
+ }
+ if (StringUtils.isNotBlank(model.getNoise())) {
+ propertyModel.setNoise(model.getNoise());
+ }
+ if (model.getGardenSize() != null && model.getGardenSize() != 0) {
+ propertyModel.setGardenSize(model.getGardenSize());
+ }
+ if (model.getBasementSize() != null && model.getBasementSize() != 0) {
+ propertyModel.setBasementSize(model.getBasementSize());
+ }
+ if (model.getOuterSize() != null && model.getOuterSize() != 0) {
+ propertyModel.setOuterSize(model.getOuterSize());
+ }
+ if (model.getAtticSize() != null && model.getAtticSize() != 0) {
+ propertyModel.setAtticSize(model.getAtticSize());
+ }
+ if (StringUtils.isNotBlank(model.getNegativeFactor())) {
+ propertyModel.setNegativeFactor(model.getNegativeFactor());
+ }
+ if (model.getAge() != 0) {
+ propertyModel.setAge(model.getAge());
+ }
+ if (model.getCarportPrice() != null && model.getCarportPrice() != 0) {
+ propertyModel.setCarportPrice(model.getCarportPrice());
+ }
+
+ if (StringUtils.isNotBlank(model.getFacilities())) {
+ propertyModel.setFacilities(model.getFacilities());
+ }
+ if (StringUtils.isNotBlank(model.getInsidePosition())) {
+ propertyModel.setInsidePosition(model.getInsidePosition());
+ }
+ return propertyModel;
+ }
+
+ private List convertSampileQueryToBean(District district,SampleQuery... queries) throws Exception {
+
+ List queryBeans = new ArrayList(queries.length);
+ for (SampleQuery q : queries) {
+
+ CollateralSampleQueryBean queryBean = new CollateralSampleQueryBean();
+ BeanUtils.copyProperties(q, queryBean);
+ queryBean.setProperty(district);
+ String estateType = queryBean.getProperty().getEstateType2();
+ queryBean.setPropertyTypeCode("01");
+ if (StringUtils.isNotBlank(estateType)) {
+ if (estateType.equals("普通住宅")) {
+ queryBean.setPropertyTypeCode("01");
+ } else if (estateType.equals("别墅")) {
+ queryBean.setPropertyTypeCode("02");
+ } else if (estateType.equals("商住")) {
+ queryBean.setPropertyTypeCode("03");
+ }
+ }
+
+ Integer decrCondCode = queryBean.getDecrCondCode();
+ if (decrCondCode == null) {
+ decrCondCode = 2;
+ }
+ if (decrCondCode > 5 || decrCondCode < 1) {
+ throw new Exception("decrCondCode取值非法");
+ }
+ Integer towardDirectCode = queryBean.getTowardDirectCode();
+ if (towardDirectCode == null) {
+ towardDirectCode = 3;
+ }
+ if (towardDirectCode > 10 || towardDirectCode < 1) {
+ throw new Exception("towardDirectCode取值非法");
+ }
+ queryBeans.add(queryBean);
+ }
+ return queryBeans;
+ }
+
+ private void adjustPriceByRatio(District district, Evaluation evaluation) {
+
+ try {
+ ApiUserCfg apiUserCfg_pt = apiUserCfgService.findByUserId(Long.valueOf(evaluation.getFromUserId()), ApiUserCfg.ApiUserCfgKey.PRICE_TYPE);
+ if (apiUserCfg_pt != null && apiUserCfg_pt.getCfgValue() != null) {
+ String priceType = apiUserCfg_pt.getCfgValue().toString();
+ // 评估价则系数调整
+ if (StringUtils.isNotBlank(priceType) && "evaluate".equals(priceType)) {
+ EvaluateRatio evaluateRatio = null;
+ if (StringUtils.isNotBlank(district.getRegion())) {
+ evaluateRatio = evaluateRatioService.findByCityAndRegion(district.getCity(), district.getRegion());
+ }
+ if (evaluateRatio == null) {
+ evaluateRatio = evaluateRatioService.findByCity(district.getCity());
+ }
+ if (evaluateRatio != null) {
+ // 系数添加
+ long totalPrice = evaluation.getBigTotalPrice();
+ totalPrice = (long) (totalPrice * (1 + evaluateRatio.getRatio()));
+ evaluation.setBigTotalPrice(totalPrice);
+ evaluation.setAvgPrice((int) (totalPrice / evaluation.getArea()));
+ }
+ }
+ }
+ } catch (Exception ex) {
+ LOGGER.error("系数下调异常{}", ex.getMessage());
+ }
+ }
+
+ public Object evaluateAction(PropertyEvaluationModel model, HttpServletRequest request, HouseValueInformationDto houseValueInformation, RestfulModelAndView mav)
+ throws NumberFormatException, IllegalAccessException {
+// RestfulModelAndView mav = new RestfulModelAndView();
+// mav.setViewType("rest");
+ if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName())
+ || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) {
+ mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项"));
+ return mav;
+ }
+ if (model.getCity().endsWith("市")) {
+ model.setCity(model.getCity().replaceAll("市$", ""));
+ }
+ if (StringUtils.isNotBlank(request.getParameter("calDate"))) {
+ Date calDate = null;
+ try {
+ calDate = DateUtils.parseDate(request.getParameter("calDate"), new String[]{"yyyy-MM-dd"});
+ } catch (ParseException e) {
+
+ }
+ if (calDate == null) {
+ mav.setModel(BasicModel.buildBadRequestModel("calDate:数据类型不合法"));
+ return mav;
+ } else {
+ model.setCalDate(calDate);
+ }
+ }
+ /* 先到CPDB库中查找小区 */
+ District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),
+ "district");
+ if (district == null) {
+ if (model.getDistrict().contains("市辖区") || model.getDistrict().contains(model.getCity())) {
+ district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "district");
+ }
+ if (district == null) {
+ mav.setModel(BasicModel.buildBadRequestModel("该小区不存在"));
+ return mav;
+ }
+ }
+ model.setName(district.getName());
+
+ if (model.getCarportPrice() != null && (model.getCarportPrice() < 0 || model.getCarportPrice() > 1000000)) {
+ mav.setModel(BasicModel.buildBadRequestModel("carportPrice(车位)取值不合法"));
+ return mav;
+ }
+ if (model.getMaxFloor() != null && (model.getMaxFloor() <= 0 || model.getMaxFloor() > 59)) {
+ mav.setModel(BasicModel.buildBadRequestModel("maxFloor取值非法,正确范围[1,60)"));
+ return mav;
+ }
+
+ if (model.getFloor() != null && (model.getFloor() <= 0 || model.getFloor() > 59)) {
+ mav.setModel(BasicModel.buildBadRequestModel("floor取值非法,正确范围[1,60)"));
+ return mav;
+ }
+ if (model.getMaxFloor() != null && model.getFloor() != null && model.getFloor() > model.getMaxFloor()) {
+ mav.setModel(BasicModel.buildBadRequestModel("所在楼层不能大于总楼层"));
+ return mav;
+ }
+
+ if (model.getFloor() == null) {
+ JSONObject structureOb = addressMatchProxyService.addressStructure(district.getCity(), model.getAddress());
+ if (structureOb != null) {
+ if (structureOb.containsKey("buildingNumber")) {
+ model.setBuildingNumber(structureOb.getString("buildingNumber"));
+ }
+
+ if (structureOb.containsKey("roomNumber")) {
+ String roomNumber = structureOb.getString("roomNumber");
+ model.setFloor(getFloor(roomNumber));
+ }
+
+ }
+ }
+
+ if (model.getMaxFloor() == null && model.getFloor() != null && StringUtils.isNotBlank(model.getBuildingNumber())) {
+ Loudong loudong = loudongService.findForEvaluate(district.getId(), model.getBuildingNumber(), model.getUnitNumber());
+ if (loudong != null && loudong.getFloors() >= model.getFloor()) {
+ model.setMaxFloor(loudong.getFloors());
+ }
+ }
+ model.setRegion(district.getRegion());
+ model.setDistrictName(district.getName());
+ if (StringUtils.isBlank(model.getPropertyType())) {
+ if (district.getEstateType2() != null && district.getEstateType2().contains("别墅")) {
+ model.setPropertyType("1");
+ }
+ }
+
+ if (model.getCalDate() != null) {
+ if (new Date().before(model.getCalDate())) {
+ model.setCalDate(DateUtil.getFirstDayOfWeek(new Date()));
+ } else {
+ model.setCalDate(DateUtil.getFirstDayOfWeek(model.getCalDate()));
+ }
+ } else {
+ model.setCalDate(DateUtil.getFirstDayOfWeek(new Date()));
+ }
+
+
+ Evaluation evaluation = evaluationService.evaluate(district, buildEvaluation(model, request),
+ model.getCalDate());
+ Double cityPriceCredit = null;
+ if (StringUtils.isNotBlank(evaluation.getFromUserId())) {
+ try {
+ ApiUserAuthority apiUserAuthority = apiUserAuthorityService
+ .findByUserId(Long.valueOf(evaluation.getFromUserId()));
+ if (apiUserAuthority.getCityCreditMap() != null
+ && apiUserAuthority.getCityCreditMap().containsKey(evaluation.getCity())) {
+ cityPriceCredit = apiUserAuthority.getCityCreditMap().get(evaluation.getCity());
+ if (cityPriceCredit > 1 || cityPriceCredit < 0) {
+ cityPriceCredit = null;
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ this.adjustPriceByRatio(district, evaluation);
+ }
+
+ // 调整面积不同面积价格
+ try {
+ DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district));
+ int orgAvgPrice = 0;
+ if (districtStatBo != null) {
+ if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().contains("别墅") && districtStatBo.getVillaDistrictStat() != null) {
+ orgAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice();
+ } else if (districtStatBo.getDistrictStat() != null) {
+ orgAvgPrice = districtStatBo.getDistrictStat().getAvgPrice();
+ }
+ }
+ if (evaluation != null && evaluation.getAvgPrice() != null && evaluation.getAvgPrice() > 0) {
+ int factorPrice = evaluation.getAvgPrice();
+ int avgPrice = evaluateFactorService.recompose(district.getCity(), district.getRegion(), evaluation.getArea(), factorPrice, orgAvgPrice);
+ Integer minPrice = (int) (evaluation.getAvgPrice() * 0.95);
+ Integer maxPrice = (int) (evaluation.getAvgPrice() * 1.05);
+ // 偏离度超过5%不进行调整
+ if (minPrice <= avgPrice && avgPrice <= maxPrice) {
+ evaluation.setAvgPrice(avgPrice);
+ evaluation.setBigTotalPrice((long) (avgPrice * evaluation.getArea()));
+ }
+ }
+ } catch (Exception ex) {
+ LOGGER.error("调整面积不同面积价格异常{}", ex.getMessage());
+ }
+
+ if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0
+ && (cityPriceCredit == null || evaluation.getCredit() >= cityPriceCredit)) {
+ Map districtPriceMap = new HashMap();
+ districtPriceMap.put("city", district.getCity());
+ districtPriceMap.put("district", district.getRegion());
+ districtPriceMap.put("name", district.getName());
+ districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice());
+ districtPriceMap.put("avgPrice", evaluation.getAvgPrice());
+
+ // 根据城市等 级设置D级可信度
+ ApiUserAuthority apiUserAuthority = apiUserAuthorityService
+ .findByUserId(Long.valueOf(evaluation.getFromUserId()));
+ if (apiUserAuthority != null && null != apiUserAuthority.getCreditLevelStatus()
+ && apiUserAuthority.getCreditLevelStatus() == 1) {
+ double dCredit = 0.61;
+ if (null != apiUserAuthority.getPriceRatingMap()) {
+ ServerArea serverArea = serverAreaService.findByDisplay(evaluation.getCity());
+ Map rateMap = apiUserAuthority.getPriceRatingMap();
+ if (null != rateMap) {
+ dCredit = rateMap.get(CITYLEVEL_MAP.get(serverArea.getNewCityGrade().toString()));
+ }
+ }
+ Map rMap = getLastEvaluationPrice(district, evaluation, dCredit);
+
+ if (model.getScope() == EVALUATE_SHOW_DETAIL) {
+ if (null != rMap) {
+ if (rMap.containsKey("level")) {
+ districtPriceMap.put("level", rMap.get("level"));
+ }
+ if (rMap.containsKey("other_price")) {
+ districtPriceMap.put("other_price", rMap.get("other_price"));
+ }
+ }
+ }
+
+ Long lastPrice = (Long) rMap.get("lastPrice");
+
+ if (null != lastPrice) {
+ districtPriceMap.put("totalPrice", lastPrice);
+ if (lastPrice > 0 && lastPrice != evaluation.getBigTotalPrice()) {
+ districtPriceMap.put("avgPrice", (int) (lastPrice / evaluation.getArea()));
+ }
+ } else {
+ mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData());
+ return mav;
+ }
+
+ } else {
+ districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice());
+ }
+
+ if (model.getScope() == EVALUATE_SHOW_DETAIL) {
+ districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay());
+ districtPriceMap.put("credit", evaluation.getCredit());
+ districtPriceMap.put("id", evaluation.getId());
+ }
+ // 将评估价放到结果集
+ houseValueInformation.setAddressValue(districtPriceMap);
+// mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
+ try {
+ if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) {
+ openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/property/evaluate");
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return mav;
+ } else {
+ evaluationService.remove(evaluation.getId());
+ mav.setModel(BasicModel.buildOKModel().setMsg("暂时不支持该小区的估价").markNoData());
+ return mav;
+ }
+ }
+
+ private Integer getFloor(String roomNumber) {
+ if (StringUtils.isNotBlank(roomNumber) && DataUtil.isNumber(roomNumber)) {
+ if (roomNumber.length() == 3) {
+ return Integer.valueOf(roomNumber.substring(0, 1));
+ } else if (roomNumber.length() == 4) {
+ return Integer.valueOf(roomNumber.substring(0, 2));
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) {
+ Evaluation evaluation = new Evaluation();
+ evaluation.setCity(model.getCity());
+ evaluation.setRegion(model.getRegion());
+ evaluation.setDistrictName(model.getName());
+ evaluation.setDirection(DIRECTION.get(model.getDirection()));
+ evaluation.setFitment(EVALUATION_MODEL_FITMENT.get(FITMENT.get(StringUtils.isNotBlank(model.getDecoration()) ?
+ model.getDecoration() : model.getFitment())));
+ evaluation.setNoise(NOISE.get(model.getNoise()));
+ evaluation.setEstateType(PROPERTY_TYPES.get(model.getPropertyType()));
+ evaluation.setSight(SIGHT.get(model.getView()));
+ evaluation.setAtticArea(model.getAtticSize());
+ evaluation.setTerraceArea(model.getOuterSize());
+ evaluation.setBasementArea(model.getBasementSize());
+ evaluation.setGardenArea(model.getGardenSize());
+ String worryFacility = model.getNegativeFactor();
+ evaluation.setWorryFacility(NEGATIVE_FACTOR.get(worryFacility));
+ evaluation.setCreationDate(new Date());
+ evaluation.setModificationDate(new Date());
+ evaluation.setClientNo(model.getClientNo());
+ if (0 != model.getAge()) {
+ evaluation.setAge(model.getAge());
+ }
+ evaluation.setArea(model.getSize());
+ if (ArrayUtils.isNotEmpty(model.getBuildQuality())) {
+ evaluation.setBuildQuality(convertToString(model.getBuildQuality()));
+ }
+ if (StringUtils.isNotBlank(model.getBuildType())) {
+ evaluation.setBuildType(model.getBuildType());
+ }
+ if (StringUtils.isNotBlank(model.getCarport())) {
+ evaluation.setCarport(model.getCarport());
+ }
+ if (model.getDecorationAge() >= 1 && model.getDecorationAge() <= 5) {
+ evaluation.setFitmentAge(model.getDecorationAge());
+ }
+ evaluation.setCarportPrice(model.getCarportPrice());
+ evaluation.setCity(model.getCity());
+ evaluation.setDistrictName(model.getName());
+ if (model.getDecorationCost() != null && model.getDecorationCost() > 0) {
+ evaluation.setFitmentCharge(model.getDecorationCost());
+ }
+ if (0 != model.getHall()) {
+ evaluation.setHall(model.getHall());
+ }
+ if (null != model.getFloor()) {
+ evaluation.setFloor(model.getFloor());
+ }
+ if (model.getMaxFloor() != null && 0 != model.getMaxFloor()) {
+ evaluation.setHeight(model.getMaxFloor());
+ }
+ if (StringUtils.isNotBlank(model.getBuildingNumber())) {
+ evaluation.setHouseNum(model.getBuildingNumber());
+ }
+ if (StringUtils.isNotBlank(model.getHouseProperty())) {
+ evaluation.setHouseProperty(model.getHouseProperty());
+ }
+ if (StringUtils.isNotBlank(model.getInsidepos())) {
+ evaluation.setInsidepos(model.getInsidepos());
+ }
+ if (StringUtils.isNotBlank(model.getLightingVentilation())) {
+ evaluation.setLightingVentilation(model.getLightingVentilation());
+ }
+
+ if (StringUtils.isNotBlank(model.getOtherFactor())) {
+ evaluation.setOtherFactor(model.getOtherFactor());
+ }
+ evaluation.setRegion(model.getDistrict());
+ if (null != model.getRoom()) {
+ evaluation.setRoom(model.getRoom());
+ }
+ if (StringUtils.isNotBlank(model.getRoomNumber())) {
+ evaluation.setRoomNum(model.getRoomNumber());
+ }
+ if (StringUtils.isNotBlank(model.getSideset())) {
+ evaluation.setSideset(model.getSideset());
+ }
+ if (0 != model.getToilet()) {
+ evaluation.setToilet(model.getToilet());
+ }
+ if (model.getFacilities() != null) {
+ String facilities = model.getFacilities();
+ String[] fs = facilities.split(",");
+ for (int i = 0; i < fs.length; i++) {
+ fs[i] = FACILITIES.get(fs[i]);
+ }
+ evaluation.setFacilities(convertToString(fs));
+ }
+
+ if (StringUtils.isNotBlank(model.getFacade())) {
+ evaluation.setFacade(model.getFacade());
+ }
+ if (StringUtils.isNotBlank(model.getTraffice())) {
+ evaluation.setTraffice(model.getTraffice());
+ }
+ if (StringUtils.isNotBlank(model.getShape())) {
+ evaluation.setShape(model.getShape());
+ }
+ if (StringUtils.isNotBlank(model.getObstacle())) {
+ evaluation.setObstacle(model.getObstacle());
+ }
+ if (StringUtils.isNotBlank(model.getIndustry())) {
+ evaluation.setIndustry(model.getIndustry());
+ }
+ if (StringUtils.isNotBlank(model.getSupportDevice())) {
+ evaluation.setSupportDevice(model.getSupportDevice());
+ }
+ if (StringUtils.isNotBlank(model.getLeftPosition())) {
+ evaluation.setLeftPosition(model.getLeftPosition());
+ }
+ if (StringUtils.isNotBlank(model.getShopType())) {
+ evaluation.setShopType(model.getShopType());
+ }
+ if (StringUtils.isNotBlank(model.getShopUnique())) {
+ evaluation.setShopUnique(model.getShopUnique());
+ }
+ if (StringUtils.isNotBlank(model.getLocation())) {
+ evaluation.setLocation(model.getLocation());
+ }
+ if (model.isNewDistrict()) {
+ evaluation.setNewDistrict(model.isNewDistrict());
+ }
+ String ip = AnalyticsUtil.getIpAddress(ActionContext.getContext().getRequest());
+ evaluation.setIp(ip);
+ AuthenticationBean authenticationBean = (AuthenticationBean) request
+ .getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN);
+ if (authenticationBean != null && authenticationBean.apiUser != null) {
+ evaluation.setFromUserId(String.valueOf(authenticationBean.apiUser.getId()));
+ }
+ evaluation.setSource("api_property_evaluation");
+ return evaluation;
+ }
+
+ private Map getLastEvaluationPrice(District district, Evaluation evaluation, double dCredit)
+ throws NumberFormatException, IllegalAccessException {
+ Date startDate = DateUtil.parseDate(DateUtil.addMonth(new Date(), -6), "yyyy-MM-dd");
+ // 第三方价格
+ Map otherPriceRets = averageStatisticsService.findFirstAverageStatictics(district.getCity(),
+ district.getRegion(), district.getName(), district.getCategory(), startDate);
+ if (null == otherPriceRets) {
+ otherPriceRets = new HashMap();
+ }
+
+ otherPriceRets.put("fjw_price", evaluation.getAvgPrice());
+ Map levelMap = getPriceLevel(otherPriceRets, evaluation.getCredit());
+ Long lastPrice = getLastPrice(levelMap, otherPriceRets, evaluation, dCredit);
+
+ Map rMap = new HashMap();
+ rMap.put("lastPrice", lastPrice);
+ if (null != levelMap && levelMap.containsKey("level")) {
+ String priceLevel = (String) levelMap.get("level");
+ rMap.put("level", priceLevel);
+ }
+ rMap.put("other_price", otherPriceRets);
+ return rMap;
+ }
+
+ private Map getPriceLevel(Map otherPriceRets, double credit) {
+
+ Integer avgPrice = (Integer) otherPriceRets.get("fjw_price");
+
+ int keyCount = 0;
+ int commonCount = 0;
+ int isExistCount = 0;
+
+ List prices = new ArrayList();
+ List smallPrices = new ArrayList();
+
+ if (null != otherPriceRets.get("fanggugu_price")) {
+ Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price");
+ int mod = avgPrice - fangguguPrice;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ keyCount++;
+ } else {
+ prices.add(fangguguPrice);
+ }
+ isExistCount++;
+ }
+ if (null != otherPriceRets.get("yungujia_price")) {
+ Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price");
+ int mod = avgPrice - yungujiaPrice;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ keyCount++;
+ } else {
+ prices.add(yungujiaPrice);
+ }
+
+ isExistCount++;
+ }
+
+ if (null != otherPriceRets.get("zhugezhaofang_price")) {
+ Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price");
+ int mod = avgPrice - zhugezhaofangPrice;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ keyCount++;
+ } else {
+ prices.add(zhugezhaofangPrice);
+ }
+
+ isExistCount++;
+ }
+
+ if (null != otherPriceRets.get("lianjia_price")) {
+ Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price");
+ int mod = avgPrice - lianjiaPrice;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ keyCount++;
+ } else {
+ prices.add(lianjiaPrice);
+ }
+ isExistCount++;
+ }
+ if (null != otherPriceRets.get("anjuke_price")) {
+ Integer anjukePrice = (Integer) otherPriceRets.get("anjuke_price");
+ int mod = avgPrice - anjukePrice;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ commonCount++;
+ smallPrices.add(anjukePrice);
+ } else {
+ prices.add(anjukePrice);
+ }
+
+ isExistCount++;
+ }
+ if (null != otherPriceRets.get("ganji_price")) {
+ Integer ganjiPrice = (Integer) otherPriceRets.get("ganji_price");
+ int mod = avgPrice - ganjiPrice;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ commonCount++;
+ smallPrices.add(ganjiPrice);
+ } else {
+ prices.add(ganjiPrice);
+ }
+
+ isExistCount++;
+ }
+ if (null != otherPriceRets.get("soufan_price")) {
+ Integer soufan_price = (Integer) otherPriceRets.get("soufan_price");
+ int mod = avgPrice - soufan_price;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ commonCount++;
+ smallPrices.add(soufan_price);
+ } else {
+ prices.add(soufan_price);
+ }
+
+ isExistCount++;
+ }
+ if (null != otherPriceRets.get("tobushi_price")) {
+ Integer tobushi = (Integer) otherPriceRets.get("tobushi_price");
+ int mod = avgPrice - tobushi;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ commonCount++;
+ smallPrices.add(tobushi);
+ } else {
+ prices.add(tobushi);
+ }
+
+ isExistCount++;
+ }
+
+ if (null != otherPriceRets.get("zhongyuan_price")) {
+ Integer zhongyuanPrice = (Integer) otherPriceRets.get("zhongyuan_price");
+ int mod = avgPrice - zhongyuanPrice;
+ double temp = DataUtil.getDoubleRound(2, mod * 100 / avgPrice);
+ temp = Math.abs(temp);
+ if (temp <= 15) {
+ commonCount++;
+ smallPrices.add(zhongyuanPrice);
+ } else {
+ prices.add(zhongyuanPrice);
+ }
+
+ isExistCount++;
+ }
+
+ Map retMap = new HashMap();
+ String level = null;
+ if (keyCount >= 2) {
+ level = "A";
+ } else if (keyCount >= 1 && commonCount >= 1) {
+ level = "A";
+ } else if (keyCount >= 1 || commonCount >= 2) {
+ level = "B";
+ } else if (commonCount >= 1) {
+ level = "C";
+ } else if (isExistCount == 0) {
+ level = "D";
+ } else if (isExistCount >= 1) {
+ if (isExistCount == 1) {
+ level = "D";
+ } else {
+ level = "E";
+ }
+ }
+
+ if (credit == 0) {
+ level = "E";
+ }
+
+ if (StringUtils.isNotBlank(level)) {
+ retMap.put("level", level);
+ retMap.put("prices", prices);
+ retMap.put("small_prices", smallPrices);
+ }
+ return retMap;
+ }
+
+ private Long getLastPrice(Map retMap, Map otherPriceRets, Evaluation evaluation, double dCredit) {
+ Long lastPrice = null;
+ if (null != retMap) {
+ String priceLevel = (String) retMap.get("level");
+
+ if (priceLevel.equals("D")) {
+
+ lastPrice = inputResultByWebsite(otherPriceRets, evaluation, dCredit);
+
+ } else if (priceLevel.equals("E")) {
+ if (evaluation.getCredit() >= 0.65) {
+ lastPrice = evaluation.getBigTotalPrice();
+ } else {
+ List prices = (List) retMap.get("prices");
+ int avgPrice = 0;
+ if (prices != null) {
+ avgPrice = findNewPrice(prices, evaluation.getAvgPrice());
+ }
+ // 在 dCredit与0.65之间
+ if (evaluation.getCredit() >= dCredit && dCredit < 0.65) {
+ if (avgPrice > 0) {
+ Double newTotalPrice = avgPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else {
+ if (null != otherPriceRets.get("lianjia_price")) {
+ Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price");
+ Double newTotalPrice = lianjiaPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("zhugezhaofang_price")) {
+ Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price");
+ Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("yungujia_price")) {
+ Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price");
+ Double newTotalPrice = yungujiaPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("fanggugu_price")) {
+ Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price");
+ Double newTotalPrice = fangguguPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else {
+ lastPrice = evaluation.getBigTotalPrice();
+ }
+ }
+ } else if (evaluation.getCredit() < dCredit) {// 在dCredit以下
+ if (avgPrice > 0) {
+ Double newTotalPrice = avgPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else {
+ if (null != otherPriceRets.get("lianjia_price")) {
+ Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price");
+ Double newTotalPrice = lianjiaPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("zhugezhaofang_price")) {
+ Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price");
+ Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("yungujia_price")) {
+ Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price");
+ Double newTotalPrice = yungujiaPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("fanggugu_price")) {
+ Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price");
+ Double newTotalPrice = fangguguPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ }
+ }
+ }
+ }
+
+ } else if (priceLevel.equals("C")) {
+ List smallPrices = (List) retMap.get("small_prices");
+ if (smallPrices != null) {
+ smallPrices.add(evaluation.getAvgPrice());
+ int avgPrice = sum(smallPrices) / smallPrices.size();
+ Double newTotalPrice = avgPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ }
+ } else {
+ lastPrice = evaluation.getBigTotalPrice();
+ }
+ }
+ return lastPrice;
+ }
+
+ private Integer sum(List smallPrices) {
+ int sum = 0;
+ for (int price : smallPrices) {
+ sum += price;
+ }
+ return sum;
+ }
+
+ private Long inputResultByWebsite(Map otherPriceRets, Evaluation evaluation, double dCredit) {
+ Long lastPrice = null;
+ if (evaluation.getCredit() >= dCredit) {
+ lastPrice = evaluation.getBigTotalPrice();
+ } else {
+ if (evaluation.getCredit() < dCredit) {
+ if (null != otherPriceRets.get("lianjia_price")) {
+ Integer lianjiaPrice = (Integer) otherPriceRets.get("lianjia_price");
+ Double newTotalPrice = lianjiaPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("zhugezhaofang_price")) {
+ Integer zhugezhaofangPrice = (Integer) otherPriceRets.get("zhugezhaofang_price");
+ Double newTotalPrice = zhugezhaofangPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("yungujia_price")) {
+ Integer yungujiaPrice = (Integer) otherPriceRets.get("yungujia_price");
+ Double newTotalPrice = yungujiaPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else if (null != otherPriceRets.get("fanggugu_price")) {
+ Integer fangguguPrice = (Integer) otherPriceRets.get("fanggugu_price");
+ Double newTotalPrice = fangguguPrice * evaluation.getArea();
+ lastPrice = newTotalPrice.longValue();
+ } else {
+ lastPrice = evaluation.getBigTotalPrice();
+ }
+ } else {
+ lastPrice = evaluation.getBigTotalPrice();
+ }
+ }
+ return lastPrice;
+ }
+
+ private Integer findNewPrice(List prices, int avgPrice) {
+ int minValue1 = Integer.MAX_VALUE;
+ List> values = new ArrayList>();
+ int fjw_price = avgPrice;
+
+ // 找出最小差
+ for (int i = 0; i < prices.size() - 1; i++) {
+ int a = prices.get(i);
+ for (int j = i + 1; j < prices.size(); j++) {
+ int b = prices.get(j);
+ int mod = Math.abs(a - b);
+ if (mod < minValue1) {
+ minValue1 = mod;
+ }
+ }
+ }
+
+ // 根据最小差找出结果
+ for (int i = 0; i < prices.size() - 1; i++) {
+ int a = prices.get(i);
+ for (int j = i + 1; j < prices.size(); j++) {
+ int b = prices.get(j);
+ int mod = Math.abs(a - b);
+ if (mod == minValue1) {
+ values.add(Arrays.asList(a, b));
+ }
+ }
+ }
+
+ int minValue2 = Integer.MAX_VALUE;
+ int lastValue = 0;
+ if (values.size() >= 1) {
+ for (List value : values) {
+ int newPrice = (value.get(0) + value.get(1)) / 2;
+ int mod = Math.abs(fjw_price - newPrice);
+ if (mod < minValue2) {
+ minValue2 = mod;
+ lastValue = newPrice;
+ }
+ }
+ }
+
+ if (lastValue > 0) {
+ double temp = DataUtil.getDoubleRound(2, minValue1 * 100 / lastValue);
+ temp = Math.abs(temp);
+ if (temp > 15) {
+ lastValue = 0;
+ }
+ }
+ return lastValue;
+ }
+
+
+
+
+ public void setEvaluationService(EvaluationService evaluationService) {
+ this.evaluationService = evaluationService;
+ }
+
+ public void setDistrictService(DistrictService districtService) {
+ this.districtService = districtService;
+ }
+
+ public void setAddressService(AddressService addressService) {
+ }
+
+ public void setDistrictStatService(DistrictStatService districtStatService) {
+ this.districtStatService = districtStatService;
+ }
+
+ protected AddressMatchLogService addressMatchLogService;
+
+ public void setAddressMatchLogService(AddressMatchLogService addressMatchLogService) {
+ this.addressMatchLogService = addressMatchLogService;
+ }
+
+
+
+ public BatchEvaluateService getBatchEvaluateService() {
+ return batchEvaluateService;
+ }
+
+ public void setBatchEvaluateService(BatchEvaluateService batchEvaluateService) {
+ this.batchEvaluateService = batchEvaluateService;
+ }
+
+ public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) {
+ this.addressMatchProxyService = addressMatchProxyService;
+ }
+
+ public void setLoudongService(LoudongService loudongService) {
+ this.loudongService = loudongService;
+ }
+
+ public void setApiUserAuthorityService(ApiUserAuthorityService apiUserAuthorityService) {
+ this.apiUserAuthorityService = apiUserAuthorityService;
+ }
+
+ public void setAverageStatisticsService(AverageStatisticsService averageStatisticsService) {
+ this.averageStatisticsService = averageStatisticsService;
+ }
+
+ public void setServerAreaService(ServerAreaService serverAreaService) {
+ this.serverAreaService = serverAreaService;
+ }
+
+ public void setApiUserCfgService(ApiUserCfgService apiUserCfgService) {
+ this.apiUserCfgService = apiUserCfgService;
+ }
+
+ public void setOpenApiLogService(OpenApiLogService openApiLogService) {
+ this.openApiLogService = openApiLogService;
+ }
+
+ public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) {
+ this.fangjiaOfficialAreaService = fangjiaOfficialAreaService;
+ }
+
+
+ public void setEvaluateRatioService(EvaluateRatioService evaluateRatioService) {
+ this.evaluateRatioService = evaluateRatioService;
+ }
+
+
+ public void setEvaluateFactorService(EvaluateFactorService evaluateFactorService) {
+ this.evaluateFactorService = evaluateFactorService;
+ }
+
+ public void setCzbankSampleService(CzbankSampleService czbankSampleService) {
+ this.czbankSampleService = czbankSampleService;
+ }
+
+ public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) {
+ this.districtFacilitysService = districtFacilitysService;
+ }
+
+}
+
diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java
index 083ae48f0..f3548c9cc 100644
--- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java
+++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java
@@ -903,7 +903,10 @@ public class HouseController {
if(null == sampleQuery.getMax()){
sampleQuery.setMax(10);
}
+ long start = System.currentTimeMillis();
List collaterals = czbankSampleService.findSample2(querys, sampleQuery.getMax());
+ long end = System.currentTimeMillis();
+ System.out.println("用时:"+(end-start));
Collateral collateral = collaterals.get(0);
List samples = collateral.getSample();
UniversalDto dto = UniversalDto.newDto();
@@ -913,7 +916,8 @@ public class HouseController {
if(null != collateral.getMinPrice()){
dto.append("minUnitPrice", collateral.getMinPrice());
}
- dto.append("datas", samples);
+
+ dto.append("datas", samples);
// if(samples!= null && samples.size()>=2){
// Sample minSample = samples.get(samples.size()-2);
// Sample maxSample = samples.get(samples.size()-1);
diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/TestController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/TestController.java
new file mode 100644
index 000000000..07fbed914
--- /dev/null
+++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/TestController.java
@@ -0,0 +1,1608 @@
+/*
+package com.fangjia.open.controllers;
+
+import com.fangjia.core.util.*;
+import com.fangjia.dal.common.DistrictKey;
+import com.fangjia.dal.mongo.fangjia.model.ServerArea;
+import com.fangjia.dal.mongo.model.ApiUserCfg;
+import com.fangjia.dal.mongo.model.DistrictFacilitys;
+import com.fangjia.dal.mongo.model.Evaluation;
+import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap;
+import com.fangjia.dal.mongo.model.bkoff.Loudong;
+import com.fangjia.dal.mongo.open.model.ApiUserAuthority;
+import com.fangjia.dal.mongo.open.model.EvaluateRatio;
+import com.fangjia.dal.seaweed.model.District;
+import com.fangjia.open.HttpCode;
+import com.fangjia.open.OpenHttpCodeEnum;
+import com.fangjia.open.dto.HouseValueInformationDto;
+import com.fangjia.open.dto.UniversalDto;
+import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto;
+import com.fangjia.open.interceptors.AuthenticationBean;
+import com.fangjia.open.model.*;
+import com.fangjia.open.util.CommonDtoUtils;
+import com.fangjia.open.util.CommonUtils;
+import com.fangjia.open.ws.query.SampleQuery;
+import com.fangjia.service.api.AddressMatchProxyService;
+import com.fangjia.service.api.ApiUserCfgService;
+import com.fangjia.service.bo.Collateral;
+import com.fangjia.service.bo.DistrictStatBo;
+import com.fangjia.service.bo.Sample;
+import com.fangjia.service.datastore.*;
+import com.fangjia.service.datastore.bean.CollateralSampleQueryBean;
+import com.fangjia.service.district.*;
+import com.fangjia.service.mongo.bkoff.HouseLoudongService;
+import com.fangjia.service.mongo.bkoff.LoudongService;
+import com.fangjia.service.mongo.fangjia.*;
+import com.fangjia.service.open.*;
+import com.fangjia.service.tool.OpenLogService;
+import com.fangjia.service.web.AddressService;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.slf4j.Logger;
+import org.sothis.web.mvc.ActionContext;
+import org.sothis.web.mvc.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.ParseException;
+import java.util.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import static com.poseidon.util.TypeConverter.convertToString;
+
+*/
+/**
+ * @author 13607
+ * @since 2023/12/12 10:29
+ *//*
+
+
+
+public class TestController {
+ private DistrictService districtService;
+
+ private DistrictStatService districtStatService;
+
+ private FangjiaOfficialAreaService fangjiaOfficialAreaService;
+ private AddressMatchProxyService addressMatchProxyService;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class);
+ private HouseLoudongService houseLoudongService;
+ private LoudongService loudongService;
+ private EvaluationService evaluationService;
+ private BatchEvaluateService batchEvaluateService;
+ private ApiUserAuthorityService apiUserAuthorityService;
+ private AverageStatisticsService averageStatisticsService;
+ private ServerAreaService serverAreaService;
+ private ApiUserCfgService apiUserCfgService;
+ private OpenApiLogService openApiLogService;
+ private EvaluateFactorService evaluateFactorService;
+
+ private CzbankSampleService czbankSampleService;
+
+ private DistrictFacilitysService districtFacilitysService;
+
+ private static final int DEFAULT_PAGE_SIZE = 20;
+ private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "lat2", "lng2", "lat", "lng", "block", "estateType2", "addrAlias"};
+ static final int BAI_DU_GEO = 1;// 百度系坐标
+ static final int GAO_DE_GEO = 2;// 高德系坐标
+
+
+ private EvaluateRatioService evaluateRatioService;
+
+ private static final int EVALUATE_SHOW_DETAIL = 1;
+ private static final Map PROPERTY_TYPES = new HashMap() {
+ {
+ put(null, "普通住宅");
+ put("0", "普通住宅");
+ put("1", "别墅");
+ put("2", "商住");
+ }
+ };
+
+ private static final Map DIRECTION = new HashMap() {
+ {
+ put(null, "南");
+ put("1", "西南");
+ put("2", "东南");
+ put("3", "南");
+ put("4", "西北");
+ put("5", "东北");
+ put("6", "东");
+ put("7", "西");
+ put("8", "北");
+ put("9", "东西");
+ put("10", "南北");
+ }
+ };
+
+ private static final Map FITMENT = new HashMap() {
+ {
+ put(null, "简装");
+ put("1", "毛坯");
+ put("2", "简装");
+ put("3", "精装");
+ put("4", "豪装");
+ }
+ };
+
+ private static final Map EVALUATION_MODEL_FITMENT = new HashMap() {
+ {
+ put(null, "简单装修");
+ put("简装", "简单装修");
+ put("毛坯", "毛坯");
+ put("精装", "精装修");
+ put("豪装", "豪华装修");
+ }
+ };
+
+ private static final Map SIGHT = new HashMap() {
+ {
+ put(null, "一般");
+ put("1", "景观房");
+ put("2", "侧景观房");
+ put("3", "一般");
+ put("4", "差");
+ }
+ };
+
+ private static final Map NOISE = new HashMap() {
+ {
+ put(null, "无噪音");
+ put("0", "无噪音");
+ put("1", "噪音较小");
+ put("2", "噪音大");
+ }
+ };
+ private static final Map FACILITIES = new HashMap() {
+ {
+ put("0", "健身房");
+ put("1", "游泳池");
+ put("2", "会所");
+ put("3", "网球场");
+ put("4", "球场");
+ put("5", "棋牌室");
+ put("6", "停车场");
+ put("7", "图书馆");
+ put("8", "活动中心");
+ }
+ };
+
+ private static final Map NEGATIVE_FACTOR = new HashMap() {
+ {
+ put(null, "无");
+ put("1", "很近");
+ put("2", "较近");
+ put("3", "无");
+ }
+ };
+
+
+ Map listKeyMap = new HashMap() {
+ {
+ put("school", "schools");
+ put("hospital", "hospitals");
+ put("bank", "banks");
+ put("supermarket", "supermarkets");
+ put("market", "markets");
+ put("beautySalon", "beautySalons");
+ put("gym", "gyms");
+ put("park", "parks");
+ put("bus", "buses");
+ put("metro", "metros");
+ put("dock", "docks");
+ put("airport", "airports");
+ put("trainStation", "trainStations");
+ put("restaurant", "restaurants");
+ put("hotel", "hotels");
+ }
+ };
+
+ private static final Map CITYLEVEL_MAP = new HashMap() {
+ {
+ put("1000", "one");// 一线
+ put("1500", "newOne");// 新一线
+ put("2000", "two");// 二线
+ put("3000", "three");// 三线
+ put("4000", "four");// 四线
+ put("5000", "five");// 五线
+ }
+ };
+
+
+ //全局json
+ private JSONObject globalJson = null;
+
+
+ public Object houseValueInformationAction(HouseInfomationModel model, HttpServletRequest httpServletRequest) throws IllegalAccessException, HttpRequestException {
+
+ HouseValueInformationDto houseValueInformation = new HouseValueInformationDto();
+ RestfulModelAndView mav = new RestfulModelAndView();
+
+ if (StringUtils.isBlank(model.getAddress()) || StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(String.valueOf(model.getSize()))) {
+ mav.setModel(BasicModel.buildBadRequestModel("城市(city),地址(address),面积(size)为必填字段"));
+ return mav;
+ }
+
+ HttpRequest httpRequest = new HttpRequest();
+
+ Map communityAvgPriceParams = new HashMap();
+ communityAvgPriceParams.put("city", model.getCity());
+ communityAvgPriceParams.put("address", model.getAddress());
+ communityAvgPriceParams.put("category", model.getCategory());
+ communityAvgPriceParams.put("useMap", String.valueOf(model.isUseMap()));
+ globalJson = httpRequest.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", communityAvgPriceParams, "UTF-8");
+
+ // 创建线程池
+ ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+ Future avgPriceFuture = executorService.submit(new UpdateCommunityAvgPriceCallable(globalJson, mav));
+ Future