diff --git a/Jenkinsfile b/Jenkinsfile index b8b0cf0b7..fe1323a0e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent any parameters { - choice(name: 'PROJECT_NAME', choices: ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'], description: '请选择å�‘布的项目') + choice(name: 'PROJECT_NAME', choices: ['chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'], description: '请选择å�‘布的项目') } tools { jdk 'JDK8' @@ -17,7 +17,7 @@ pipeline { stage('Maven Build') { steps { script { - def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'] + def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'] for (def project : projects) { if (params.PROJECT_NAME == project) { dir("deliverables/${project}") { @@ -33,8 +33,8 @@ pipeline { stage('Docker Build') { steps { script { - def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'] - def imagesName = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke"] + def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'] + def imagesName = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke", 'fangjiaopen': 'fangjia-open'] for (def project : projects) { if (params.PROJECT_NAME == project) { dir("projects/${imagesName[project]}") { @@ -53,8 +53,8 @@ pipeline { stage('K8S Deploy') { steps { script { - def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke'] - def k8s_config_map = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke"] + def projects = ['fangjiabkoff', 'chafangtong', 'fangjia', 'fangjiapds', 'fangjiastatic', 'geluke', 'fangjiaopen'] + def k8s_config_map = ['fangjiabkoff': 'fangjia-bkoff', 'chafangtong': 'chafangtong', 'fangjia': 'fangjia-coresite', 'fangjiapds': 'fangjia-pds', 'fangjiastatic': 'fangjia-static', 'geluke':"geluke", 'fangjiaopen': 'fangjia-open'] for (def project : projects) { if (params.PROJECT_NAME == project) { dir("deliverables/k8s") { diff --git a/deliverables/k8s/fangjia-open.yaml b/deliverables/k8s/fangjia-open.yaml index 32ce4bb75..09660e137 100644 --- a/deliverables/k8s/fangjia-open.yaml +++ b/deliverables/k8s/fangjia-open.yaml @@ -1,4 +1,4 @@ -:apiVersion: apps/v1 +apiVersion: apps/v1 kind: Deployment metadata: name: fangjia-open @@ -37,20 +37,39 @@ spec: - containerPort: 8080 name: web protocol: TCP + # readinessProbe: + # httpGet: + # path: /k8s/readiness + # port: web + # initialDelaySeconds: 5 + # periodSeconds: 10 + # livenessProbe: + # httpGet: + # path: /k8s/liveness + # port: web + # initialDelaySeconds: 10 + # periodSeconds: 5 volumeMounts: - name: host-time mountPath: /etc/localtime - - name: nfs + - name: goojiaconfig mountPath: /home/goojia/goojiaconfig volumes: - name: host-time hostPath: path: /etc/localtime - - name: nfs - nfs: - path: /home/nfs_data/goojiaconfig - server: 192.168.0.18 + - name: goojiaconfig + cephfs: + monitors: + - 192.168.0.208:6789 + - 192.168.0.209:6789 + - 192.168.0.210:6789 + user: admin + path: /k8s/goojiaconfig + secretRef: + name: ceph-secret + readOnly: false --- apiVersion: v1 @@ -69,4 +88,4 @@ spec: ports: - port: 8080 targetPort: 8080 - nodePort: 38089 \ No newline at end of file + nodePort: 31088 \ No newline at end of file diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java index 7628d085f..3aae49c4d 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DataController.java @@ -1071,6 +1071,8 @@ public class DataController { map.put("divisible", "ÊÇ·ñ¿É·Ö¸î"); map.put("landFloor","µØÉϲãÊý"); map.put("undergroundFloor","µØÏ²ãÊý"); + map.put("rentPrice","×â½ð¼Û¸ñ"); + map.put("halfYearRentPrice","½ü°ëÄê×â½ð¼Û¸ñ"); return map; } diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java index c17210062..68961d219 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/DataUtil.java @@ -1,12 +1,26 @@ package com.fangjia.core.util; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; +import com.hankcs.hanlp.HanLP; +import com.hankcs.hanlp.dictionary.py.Pinyin; +import com.mongodb.BasicDBList; +import com.mongodb.BasicDBObject; +import net.sf.json.JSONArray; +import net.sf.json.JSONNull; +import net.sf.json.JSONObject; +import net.sourceforge.pinyin4j.PinyinHelper; +import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; +import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; +import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; +import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sothis.core.util.CollectionUtils; + +import java.io.*; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -23,28 +37,6 @@ import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import com.hankcs.hanlp.HanLP; -import com.hankcs.hanlp.dictionary.py.Pinyin; -import net.sf.json.JSONArray; -import net.sf.json.JSONNull; -import net.sf.json.JSONObject; -import net.sourceforge.pinyin4j.PinyinHelper; -import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; -import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; -import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; -import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; - -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.apache.lucene.queryParser.QueryParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sothis.core.util.CollectionUtils; - -import com.mongodb.BasicDBList; -import com.mongodb.BasicDBObject; - public class DataUtil { public static Pattern cellPhonePattern = Pattern.compile("^(1[23456789][0-9]{1})(-)?([0-9]{8})$");// ÅжÏÊÇ·ñÊÖ»úºÅÂë private final static Logger LOGGER = LoggerFactory.getLogger(DataUtil.class); @@ -1040,10 +1032,11 @@ public class DataUtil { keyword = keyword.replace("\"", ""); keyword = keyword.replaceAll(SPACIAL_PATTERN, ""); keyword = keyword.replace("\\", " "); - keyword = QueryParser.escape(keyword.trim()).trim(); +// keyword = QueryParser.escape(keyword.trim()); keyword = DataUtil.toDBCcase(keyword.replace(";", " ")); keyword = keyword.replaceAll(SPACIAL_PATTERN, ""); - keyword = QueryParser.escape(keyword.trim()).trim(); +// keyword = QueryParser.escape(keyword.trim()).trim(); + keyword = keyword.trim(); for (String reservedWord : new String[] { "AND", "OR" }) { if (keyword.contains(reservedWord)) { keyword = keyword.replace(keyword, "\\" + keyword); @@ -1063,10 +1056,11 @@ public class DataUtil { s = s.replace("\"", ""); s = s.replaceAll(SPACIAL_PATTERN, ""); s = s.replace("\\", " "); - s = QueryParser.escape(s.trim()).trim(); +// s = QueryParser.escape(s.trim()).trim(); s = DataUtil.toDBCcase(s.replace(";", " ")); s = s.replaceAll(SPACIAL_PATTERN, ""); - s = QueryParser.escape(s.trim()).trim(); +// s = QueryParser.escape(s.trim()).trim(); + s = s.trim(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java index 29702030e..f3c007e17 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java @@ -6,6 +6,7 @@ import org.json.JSONObject; import java.util.HashMap; import java.util.Map; + public class GeoUtils { public static final String LAT = "lat"; diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java index 23728998e..0e25c9471 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java @@ -325,7 +325,85 @@ public class DistrictController { return model.redirectPermanently(model.getCityUrl() + "/ershoufang/" + URLEncoder.encode(model.getKeyword(), "UTF-8") + "--"); } - /*if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { +// if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { +// return model.redirectPermanently("http://www.fangjia.com"); +// } + +// Pager pager = model.getPager(20); +// pager.setMaxPage(FangjiaConfig.getConfig().getSearchListMaxPageNo()); +// +// // Ð¡ÇøÁбíÖ§³ÖÐÂÅÌËÑË÷ +// model.setCategory("district"); +// Object obj = FangjiaRudder.listMan(model.getKeyword()); +// if (obj != null) { +// return obj; +// } +// +// String city = ((ServerArea) FangjiaServerAreaContextHolder.getServerAreaDefault()).getDisplay(); +// Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, +// getCurrentParams(), 1); +// model.setMenu(menu); +// +// FacetQueryResult result; +// DistrictQueryBean queryBean = modelToBean(model); +// queryBean.setCity(city); +// +// // ÀÏÍøÕ¾µÄURLÖÐÇøÓòÊÇ´ø¡°Çø¡±µÄ +// if (StringUtils.isNotBlank(queryBean.getRegion())) { +// List gList = menu.getGroupList(); +// for (Group g : gList) { +// if (!"region".equals(g.getName())) { +// continue; +// } +// +// List iList = g.getItemList(); +// for (Item i : iList) { +// if (i.isSelected()) { +// queryBean.setRegion(i.getName()); +// break; +// } +// } +// break; +// } +// } +// +// if (StringUtils.isBlank(model.getKeyword())) { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, "bscore", false, false); +// } else { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, null, false, false); +// if (result.getNumberFound() <= 0) { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, null, false, false, true); +// } +// } +// +// List districtList = districtService.processDistrictInfo(result.getEntityResults(), model.getKeyword()); +// model.setDistrictList(districtList); +// if (StringUtils.isNotBlank(model.getKeyword()) && districtList.size() <= 3) { +// Map parseMap = knowbaseService.parseKeyword(model.getKeyword()); +// if (parseMap.get("district_name") != null) { +// List otherDistrictList = otherCitiesDistrict(model.getKeyword(), model.getKeyword()); +// model.setOtherDistrictList(otherDistrictList); +// } +// } +// +// pager.setTotalRows(result.getNumberFound()); +// model.setPager(pager); +// +// model.setConditions(menuService.getConditions(((ServerArea) FangjiaServerAreaContextHolder.getServerAreaDefault()), +// MenuCategoryEnum.xiaoqu, getCurrentParams())); +// model.setConditionItems(menuService.getConditionItems(FangjiaServerAreaContextHolder.getServerAreaDefault(), +// MenuCategoryEnum.xiaoqu, getCurrentParams())); +// +//// */ +//// * gasmͳ¼Æ +//// */ +// model.addGaMap(Gakey.rc, pager.getTotalRows()); +// +// feedFooter(model); +// return model; + } + public Object hidelistAction(HttpServletRequest request,DistrictModel model) throws Exception { + if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { return model.redirectPermanently("http://www.fangjia.com"); } @@ -394,26 +472,12 @@ public class DistrictController { model.setConditionItems(menuService.getConditionItems(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, getCurrentParams())); - *//** - * gasmͳ¼Æ - *//* + model.addGaMap(Gakey.rc, pager.getTotalRows()); feedFooter(model); - return model;*/ - } - public Object hidelistAction(HttpServletRequest request,DistrictModel model) throws Exception { - if(StringUtils.isNotBlank(model.getCityName())){ - List params = new ArrayList(); - params.add(new QueryParam("visible", 0)); - params.add(new QueryParam("city", model.getCityName())); - params.add(new QueryParam("category", "district")); - List districts = districtService.findAllByParams(params, 0, 0,new String[]{"city", "region", "name"}); - model.setDistricts(districts); - CacheUtils.putValue(CacheUtils.CachePolicyEnum.NEXT_MONTH, this.getClass(), "district-hide-list-crawl-"+model.getCityName(), (Serializable) districts); - } - return model; + } /** @@ -1764,6 +1828,47 @@ public class DistrictController { // return model; } + + /** + * Ð¡ÇøÐÅÏ¢ + * + * @param model + * @return + */ + @SuppressWarnings("unchecked") + public Object seoInfoAction(DistrictModel model) { + + District district = districtService.findDistrictById(model.getId()); + if (district == null) + return model; + + model.setCityName(district.getCity()); + model.setDistrictName(district.getName()); + model.setDistrictAddress(district.getAddress()); + model.setRegion(district.getRegion()); + model.setId(district.getId()); + model.setType(String.valueOf(model.getType())); + + + DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district.getCity(), district.getRegion(), district.getName())); + if (null == districtStatBo || null == districtStatBo.getDefaultDistrictStat()) { + return model; + } + + int districtAvgPrice = 0; + int villaAvgPrice = 0; + if (null != districtStatBo.getDistrictStat()) { + districtAvgPrice = districtStatBo.getDistrictStat().getAvgPrice(); + } + if (null != districtStatBo.getVillaDistrictStat()) { + villaAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice(); + } + model.setDistrictAvgPrice((Integer) (districtAvgPrice / 100) * 100); + model.setVillaAvgPrice((Integer) (villaAvgPrice / 100) * 100); + model.setDistrictStatBo(districtStatBo); + return model; + } + private List getSubList(List fullList, int start, int pageSize, int total) { if (start >= total) { return Collections.emptyList(); diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java index be342ece4..30a73fa2f 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java @@ -3665,12 +3665,14 @@ public Object checkUserAction(EvaluationModel model, HttpServletRequest req, Htt SimpleDateFormat format = new SimpleDateFormat("yyyy.MM"); for (Date key : districtStatMap.keySet()) { DistrictStat ds = districtStatMap.get(key); - districtMap.put(format.format(ds.getWeekend()),ds.getAvgPrice()); + Integer avgPrice = ds.getAvg_price_2b() != null ? ds.getAvg_price_2b() : ds.getAvgPrice(); + districtMap.put(format.format(ds.getWeekend()), avgPrice); } for (Date key : villaDistrictStatMap.keySet()) { DistrictStat ds = villaDistrictStatMap.get(key); - districtMap.put(format.format(ds.getWeekend()),ds.getAvgPrice()); + Integer avgPrice = ds.getAvg_price_2b() != null ? ds.getAvg_price_2b() : ds.getAvgPrice(); + districtMap.put(format.format(ds.getWeekend()), avgPrice); } } diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java index 5ac69e8ef..2e5f579d3 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java @@ -140,6 +140,8 @@ public class DistrictModel extends BaseModel { private int allPicCount; private List districts; + private String type; + public boolean isHousePriceInfo() { return housePriceInfo; } @@ -787,4 +789,12 @@ public class DistrictModel extends BaseModel { public void setDistricts(List districts) { this.districts = districts; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/projects/fangjia-coresite/src/main/webapp/WEB-INF/web.xml b/projects/fangjia-coresite/src/main/webapp/WEB-INF/web.xml index f519876c6..1a2bced8b 100644 --- a/projects/fangjia-coresite/src/main/webapp/WEB-INF/web.xml +++ b/projects/fangjia-coresite/src/main/webapp/WEB-INF/web.xml @@ -36,18 +36,22 @@ com.fangjia.coresite.filters.AccessLogFilter - - AntiSpiderFilter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - antiSpiderFilter - - - targetFilterLifecycle - true - - + + + + + + + + + + + + + + + + AnalyticsFilter @@ -90,11 +94,11 @@ REQUEST - - AntiSpiderFilter - /* - REQUEST - + + + + + AnalyticsFilter diff --git a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl index 9963b48ae..7c88e857e 100644 --- a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl +++ b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl @@ -1,21 +1,130 @@ <#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <#compress> - - - - <#include "../jsconstants.ftl" /> - - - - + + + - -
- <#list districts! as dist> - ${dist.name!} - -
-<#include "/analytics.ftl" /> - - + <#assign fangjiaShareContent = "房价网: �供${cityName!}�区房价�在售房�,还有�区周边�套�新闻评论�" /> + <#assign title="${cityName}"> + <#assign keywords="${cityName}"> + <#assign descr="${cityName}房价网为您�供热门�区�索�务"> + <#assign addedKeywords="false"> + + <#if region?exists && region != ''> + <#assign keywords="${keywords}${region}"> + <#assign descr="${descr!''}${region!''}"> + <#assign title="${title!''}${region!''}"> + <#assign addedKeywords="true"> + + + <#if keyword?exists && keyword != ''> + <#assign keywords="${keywords}${keyword}"> + <#assign descr="${descr!''}${keyword!''}"> + <#assign title="${title!''}${keyword!''}"> + <#assign addedKeywords="true"> + + + <#assign title="${title}"> + <#assign keywords="${keywords}�区,热门�区�索"> + <#assign descr="${descr}二手房"> + + <#if block?exists && block != ''> + <#assign title="${title!''}${block!''}��"> + <#assign keywords="${keywords!''}${block!''}��"> + <#assign descr="${descr!''}${block!''}��"> + <#assign addedKeywords="true"> + + + <#assign title2="${cityName}�区信�"> + <#if (conditions?? && conditions?size gt 0)> + <#list conditions as c> + <#assign title2="${title2}${c}"> + <#if c_has_next> + <#assign title2="${title2}_"> + <#else> + <#assign title2="${title2}附近�区房价"> + + + <#else> + <#assign title2="${cityName}�区信�"> + + + <#assign PAGE_TITLE>�${title2}】 + <#assign PAGE_DESCRIPTION>${title2!''}�区�索, 房价网�时�供${cityName!''}�区房价,�区在售二手房房�,新房房�,租房房�.以��区�套设施,�区相关新闻等内容. + <#assign PAGE_KEYWORDS>${keywords!''},房价网 + <#assign GA_PAGEVIEW_PATH = "/district/list/${fullQueryString}" /> + <#include "/header/head.ftl" /> + + + + + + + + + + + + <#include "../jsconstants.ftl" /> + + + + + <#include "/header/v6/_header.ftl"/> +
+
+ <#if pager.totalRows gt 0> +
+ <@d_pager action="hidelist" currentPage=pager.currentPage controller="district" totalPages=pager.totalPages theme="topSearch" anchor="pagelist"/> +
+ + + +
+ <#if pager.totalRows gt pager.pageSize> +
+ <@d_pager action="hidelist" currentPage=pager.currentPage controller="district" totalPages=pager.totalPages anchor="pagelist"/> +
+ +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl b/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl new file mode 100644 index 000000000..076a12008 --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl @@ -0,0 +1,111 @@ + +<#compress> + + + + <#include "../jsconstants.ftl" /> + + + + + + + + + + + + + + + + +<#include "/header/v6/_header.ftl"/> + + +
+
+
+
+
+

+

${city!} ${region!} ${districtAddress!}

+
+
+
  • å°�区å�‡ä»·
  • 56565å…ƒ/㎡
+
  • 环比
  • 3.6
+
  • å�Œæ¯”
  • 12.3
+
+
+ + <#include "../houseReport/district_price.ftl"/> + + + <#include "../houseReport/district_around_map2.ftl"/> +
+
+
+<#include "/header/v6/_footer.ftl"/> + + + +<#----> +<#----> + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl b/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl index d93369690..34a2e10c4 100644 --- a/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl +++ b/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl @@ -3,7 +3,7 @@ ${cityName}房产在线评估 - 房价网 fangjia.com - + <#include "../jsconstants.ftl" /> @@ -36,6 +36,7 @@ .adBoxLoan{width:100%;height:auto;background:none;border:solid 1px #f3f3f3;} .swiper-container{margin:0 1rem;margin-top:2rem;padding-bottom:1.5rem;top:0;} .swiper-container-horizontal > .swiper-pagination{bottom:0;} + .evaluation_content1 .error {top: 380px;} } @media (min-width:450px) and (max-width:600px) { .evaluation_inputInfo .cityChoice,.evaluation_inputInfo > div > div span{width:82%;} diff --git a/projects/fangjia-coresite/src/main/webapp/header/v6/_header.ftl b/projects/fangjia-coresite/src/main/webapp/header/v6/_header.ftl index 280861ade..2b45d159d 100644 --- a/projects/fangjia-coresite/src/main/webapp/header/v6/_header.ftl +++ b/projects/fangjia-coresite/src/main/webapp/header/v6/_header.ftl @@ -80,11 +80,11 @@
  • - 房产大数æ�® + 在线估值
      -
    • 全国房价查询
    • -
    • 在线房产估值
    • +
    • 房价查询
    • +
    • 房产估值
    • <#--
    • æ•°æ�®èƒ½åŠ›
    • --> <#--
    • 法æ‹�房
    • --> <#--
    • 咨询研究
    • --> diff --git a/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl b/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl new file mode 100644 index 000000000..4b1b758da --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl @@ -0,0 +1,128 @@ + + + + + +
      +
      �区周边�套 +<#-- --> +
      +
      +
      +
      +
      +
      +
      + + + + + + + \ No newline at end of file diff --git a/projects/fangjia-coresite/src/main/webapp/index.ftl b/projects/fangjia-coresite/src/main/webapp/index.ftl index 0cbd06b3f..356dea3ad 100644 --- a/projects/fangjia-coresite/src/main/webapp/index.ftl +++ b/projects/fangjia-coresite/src/main/webapp/index.ftl @@ -3,7 +3,8 @@ - + +<#-- --> 选择房价网-为金�机构解决地�标准化难题_治�率高达90% - 房价网 fangjia.com @@ -47,14 +48,7 @@ <#--
    --> <#----> -<<<<<<< HEAD -<#--fixedNav01--> -======= -<#----> ->>>>>>> c7c2bae298951f01848f2b654c4c5e7fdba454c0 +
    @@ -971,7 +965,7 @@
    - + <#include "/header/v6/_footer.ftl"/> diff --git a/projects/fangjia-coresite/src/main/webapp/industry/bank.ftl b/projects/fangjia-coresite/src/main/webapp/industry/bank.ftl index 858f366db..676b36ebb 100644 --- a/projects/fangjia-coresite/src/main/webapp/industry/bank.ftl +++ b/projects/fangjia-coresite/src/main/webapp/industry/bank.ftl @@ -4,7 +4,7 @@ 银行洞察客户�网点布局�业务�销_选房价网 - 房价网 fangjia.com - + <#include "../jsconstants.ftl" /> diff --git a/projects/fangjia-coresite/src/main/webapp/jsconstants.ftl b/projects/fangjia-coresite/src/main/webapp/jsconstants.ftl index bf723dca2..5363a5992 100644 --- a/projects/fangjia-coresite/src/main/webapp/jsconstants.ftl +++ b/projects/fangjia-coresite/src/main/webapp/jsconstants.ftl @@ -21,4 +21,5 @@ var Constants = { + <#include "baidu_analysis.ftl" /> diff --git a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl index d0962de10..c3fbbf0d3 100644 --- a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl +++ b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl @@ -18,8 +18,8 @@ <#assign _currentCityDisplay>${cityName} - <#assign PAGE_TITLE>${affectValue}房价走势 - 房价网 fangjia.com - <#assign PAGE_KEYWORDS>${affectValue}房价走势,${affectValue}房产数�,${affectValue}房价 + <#assign PAGE_TITLE>${affectValue}房价走势 - ${cityName}房产网 fangjia.com + <#assign PAGE_KEYWORDS>${affectValue}房价走势,${affectValue}房产数�,${affectValue}房价,二手房�价查询,楼盘估值,在线评估 <#assign headDesc>房价网�供${affectValue}�时���的房价走势图,�费查询最新季度房价�最近�年房价走势�去年�期房价走势�以�${affectValue}房价历�走势等信�。 <#assign PAGE_DESCRIPTION>${headDesc} @@ -80,7 +80,7 @@

    房价网自2006年起累计在线估值次数

    -

      æ¬¡

    +

      æ¬¡

    房产数�覆盖全国367个城市地区�80万楼盘�8000万房�库�70万楼盘字段�5000万POI数�。

    @@ -273,13 +273,13 @@ �区 - 80万 + 91万 >95% �庄 - 56.2万 + 380万 @@ -297,7 +297,7 @@ 写字楼 - 4.18万 + 14万 @@ -321,7 +321,7 @@ �路 - 44.6万 + 105万 >95% 年更新 @@ -389,10 +389,12 @@ timeout: 100000, success: function(model) { // $("#evalCount").text(toThousands(model.evalCount)); - var startNum = document.getElementById("evalCount").innerHTML; + // var startNum = document.getElementById("evalCount").innerHTML; + var startNum = toThousands(model.evalCount - 10000) if (startNum == ''){ $("#evalCount").text(toThousands(model.evalCount)); }else{ + $("#evalCount").text(startNum); numScroll(startNum,model.evalCount); } }, diff --git a/projects/fangjia-coresite/src/main/webapp/user/login.ftl b/projects/fangjia-coresite/src/main/webapp/user/login.ftl index ec4a9dc8b..254c8002f 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/login.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/login.ftl @@ -28,7 +28,7 @@ .main{width:768px;padding-top:0;} .main_left{width:768px;height: 650px;} .main_left div{padding-top: 140px;margin-left:30px;} - .main_left div p{text-align: left;} + .main_left div p{text-align: left; margin-top: 20px;} .main_left div p label{font-size: 42px;letter-spacing: 0px;} .main_left div p span{font-size: 30px;} .main_left div p small{display: none;} @@ -38,10 +38,10 @@ @media(max-device-width:414px){ .main_left{background:url(${staticUrl}/images/fangjia/v6/login-1.jpg);background-size: 100% 100%;background-repeat: no-repeat;background-position: center;} .main{width:414px;} - .main_left{width:414px;height: 450px;} + .main_left{width:414px;height: 200px;} .main_right{width:414px;height: 560px;} .main_left div {margin-left: 10px;margin-right: 70px;padding-top: 20px;} - .main_left div p label{font-size: 42px;letter-spacing: 0px;} + .main_left div p label{font-size: 22px;letter-spacing: 0px;} .main_left div p span {font-size: 27px;} .user00{width: 350px;height: 400px;margin-top: 30px;} .inputInfo {margin-bottom: 20px;} @@ -74,6 +74,7 @@ } .error {top: -20px;left: 106px;} + .main_left div {margin-top: 50px;} diff --git a/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl b/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl index 5e5d02187..cd9b74e06 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl @@ -62,12 +62,12 @@ diff --git a/projects/fangjia-coresite/src/main/webapp/user/register.ftl b/projects/fangjia-coresite/src/main/webapp/user/register.ftl index 53127ca3a..6fce0e272 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/register.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/register.ftl @@ -12,11 +12,11 @@ - + @@ -69,7 +99,7 @@
      -
    • 欢迎注册房价网
    • +
    • 欢迎注册房价网
    @@ -99,7 +129,7 @@
    - +
    两次密��一致
    @@ -110,11 +140,13 @@ 我已阅读并接�《用户�议》
    - -
    或
    - -

    若有任何问题,请致电客�:400-188-3787

    + + + +
    或
    + +

    若有任何问题,请致电客�:400-188-3787

    diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java index 4eac9a928..7ce356ffa 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/SeawaterQuery.java @@ -37,6 +37,7 @@ public class SeawaterQuery { private Double lng; private Integer radius; + private String level; public String getId() { return id; @@ -269,4 +270,12 @@ public class SeawaterQuery { public void setRadius(Integer radius) { this.radius = radius; } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java index da86e9653..63a13c075 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/datastore/model/RentHouse.java @@ -38,6 +38,8 @@ public class RentHouse extends BaseHouse implements DatastoreEntity { private String block; private Integer totalPrice; private Integer totalPriceRange; + + private Integer avgPrice; /** * ³ö×âÀàÐÍ */ @@ -760,4 +762,14 @@ public class RentHouse extends BaseHouse implements DatastoreEntity { this.houseRequire = houseRequire; } + @Transient + @Column(name = "avg_price") + public Integer getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Integer avgPrice) { + this.avgPrice = avgPrice; + } + } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/SeaweedImagesDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/SeaweedImagesDao.java new file mode 100644 index 000000000..f4b8ba4b2 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/SeaweedImagesDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.DevelopmentZone; +import com.fangjia.dal.mongo.model.SeaweedImages; + +public interface SeaweedImagesDao extends MongoDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/SeaweedImagesDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/SeaweedImagesDaoImpl.java new file mode 100644 index 000000000..898d882c0 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/SeaweedImagesDaoImpl.java @@ -0,0 +1,7 @@ +package com.fangjia.dal.mongo.dao; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.SeaweedImages; + +public class SeaweedImagesDaoImpl extends MongoDaoImpl implements SeaweedImagesDao{ +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java new file mode 100644 index 000000000..1a4066162 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.office; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.OfficeRentStat; + +public interface OfficeRentStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDaoImpl.java new file mode 100644 index 000000000..7cbafebad --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeRentStatDaoImpl.java @@ -0,0 +1,23 @@ +package com.fangjia.dal.mongo.dao.office; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fangjia.dal.mongo.dao.RegionStatDao; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import org.apache.commons.lang.StringUtils; + +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.model.RegionStat; + +public class OfficeRentStatDaoImpl extends MongoDaoImpl implements OfficeRentStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDao.java new file mode 100644 index 000000000..272f601d5 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.office; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.OfficeSellStat; + +public interface OfficeSellStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDaoImpl.java new file mode 100644 index 000000000..8cf424796 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/office/OfficeSellStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.office; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.OfficeSellStat; + +public class OfficeSellStatDaoImpl extends MongoDaoImpl implements OfficeSellStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java new file mode 100644 index 000000000..a03b21129 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.ShopRentStat; + +public interface ShopRentStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java new file mode 100644 index 000000000..e1f611b37 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopRentStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.ShopRentStat; + +public class ShopRentStatDaoImpl extends MongoDaoImpl implements ShopRentStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java new file mode 100644 index 000000000..2fec3b1d9 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.ShopSellStat; + +public interface ShopSellStatDao extends MongoDao { + + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java new file mode 100644 index 000000000..c233ba1db --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/shop/ShopSellStatDaoImpl.java @@ -0,0 +1,8 @@ +package com.fangjia.dal.mongo.dao.shop; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.ShopSellStat; + +public class ShopSellStatDaoImpl extends MongoDaoImpl implements ShopSellStatDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java index 692beb580..7c8dd0ca2 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/Evaluation.java @@ -1,17 +1,10 @@ package com.fangjia.dal.mongo.model; -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; - import com.fangjia.dal.MongoEntity; +import javax.persistence.*; +import java.util.Date; + @Entity @Table(name = "fangjia.evaluation") public class Evaluation implements MongoEntity { @@ -128,6 +121,31 @@ public class Evaluation implements MongoEntity { //ÎÒ²é²é״̬×Ö¶Î private int statusCha; + private Double unitPrice; + + /** + * д×ÖÂ¥ÀàÐÍ£º1£º±ê׼д×ÖÂ¥£»2£º´´ÒâÔ°Çø£»3£ºÉÌסÁ½Óã»4£º×ÛºÏÌå + */ + private Integer type; + + /** + * д×ÖÂ¥µÈ¼¶ 1£º¼×¼¶£»2£ºÒÒ¼¶£»3£º±û¼¶ + */ + private Integer level; + + /** + * Ãâ×âÆÚ£¨Ô£© + */ + private Integer rentFreePeriod; + + /** + * ÎïÒµ·Ñ(Ôª/m?/ÔÂ) + */ + private Double propertyManagementFee; + /** + * Â¥²ãÃèÊö + */ + private String floorDesc; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "_id") @@ -180,6 +198,7 @@ public class Evaluation implements MongoEntity { return totalPrice; } + public void setTotalPrice(Integer totalPrice) { this.totalPrice = totalPrice; } @@ -995,4 +1014,56 @@ public class Evaluation implements MongoEntity { this.statusCha = statusCha; } + @Column(name = "unit_price") + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + @Column(name = "type") + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + @Column(name = "level") + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + @Column(name = "rent_free_period") + public Integer getRentFreePeriod() { + return rentFreePeriod; + } + + public void setRentFreePeriod(Integer rentFreePeriod) { + this.rentFreePeriod = rentFreePeriod; + } + + @Column(name = "property_management_fee") + public Double getPropertyManagementFee() { + return propertyManagementFee; + } + + public void setPropertyManagementFee(Double propertyManagementFee) { + this.propertyManagementFee = propertyManagementFee; + } + + public String getFloorDesc() { + return floorDesc; + } + + public void setFloorDesc(String floorDesc) { + this.floorDesc = floorDesc; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java new file mode 100644 index 000000000..046cf8604 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeRentStat.java @@ -0,0 +1,116 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; + +@Entity +@Table(name = "fangjia_stat.office_rent_stat") +public class OfficeRentStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Double avgPrice; + private String name; + @JsonIgnore + private Object location; + private String estateType2; + private String bedKind; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "location") + public Object getLocation() { + return location; + } + + public void setLocation(Object location) { + this.location = location; + } + + @Column(name = "estate_type2") + public String getEstateType2() { + return estateType2; + } + + public void setEstateType2(String estateType2) { + this.estateType2 = estateType2; + } + + @Column(name = "bed_kind") + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java new file mode 100644 index 000000000..c027e5345 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/OfficeSellStat.java @@ -0,0 +1,138 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import javax.persistence.*; +import java.util.Date; + +@Entity +@Table(name = "fangjia_stat.office_sell_stat") +public class OfficeSellStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private Integer date; + private String district; + private String name; + private Integer avgPrice; + private String estateType2; + private String bedKind; + @JsonIgnore + private Object location; + private Integer calcType; + private Date updatedDate; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "avg_price") + public Integer getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Integer avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "estate_type2") + public String getEstateType2() { + return estateType2; + } + + public void setEstateType2(String estateType2) { + this.estateType2 = estateType2; + } + + @Column(name = "bed_kind") + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } + + @Column(name = "location") + public Object getLocation() { + return location; + } + + public void setLocation(Object location) { + this.location = location; + } + + + @Column(name = "calc_type") + public Integer getCalcType() { + return calcType; + } + + public void setCalcType(Integer calcType) { + this.calcType = calcType; + } + + @Column(name = "updated_date") + public Date getUpdatedDate() { + return updatedDate; + } + + public void setUpdatedDate(Date updatedDate) { + this.updatedDate = updatedDate; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java new file mode 100644 index 000000000..33d6b6dee --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java @@ -0,0 +1,90 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Entity +@Table(name = "fangjia_base.seaweed_images") +public class SeaweedImages implements MongoEntity { + + private static final long serialVersionUID = 4356189537384834754L; + private String id; + private String city; + private String district; + + private Map> floorplanPics; + + private Date mDate; + private String name; + private List outPics; + + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "_id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + @Column(name = "floorplan_pics") + public Map> getFloorplanPics() { + return floorplanPics; + } + + public void setFloorplanPics(Map> floorplanPics) { + this.floorplanPics = floorplanPics; + } + + @Column(name = "m_date") + public Date getmDate() { + return mDate; + } + + public void setmDate(Date mDate) { + this.mDate = mDate; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "out_pics") + public List getOutPics() { + return outPics; + } + + public void setOutPics(List outPics) { + this.outPics = outPics; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java new file mode 100644 index 000000000..510e8e392 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopRentStat.java @@ -0,0 +1,84 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; + +@Entity +@Table(name = "fangjia_stat.shop_rent_stat") +public class ShopRentStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Double avgPrice; + private String name; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Double getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Double avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java new file mode 100644 index 000000000..97c6c4623 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ShopSellStat.java @@ -0,0 +1,84 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; + +@Entity +@Table(name = "fangjia_stat.shop_sell_stat") +public class ShopSellStat implements MongoEntity { + private static final long serialVersionUID = 4425229045088250573L; + + private String id; + private String cat; + private String city; + private String district; + private Integer date; + private Integer avgPrice; + private String name; + + @Id + @GeneratedValue + @Column(name = "_id", unique = true, nullable = false) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "date") + public Integer getDate() { + return date; + } + + public void setDate(Integer date) { + this.date = date; + } + + @Column(name = "avg_price") + public Integer getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(Integer avgPrice) { + this.avgPrice = avgPrice; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index dd74c4224..04379c299 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -1,521 +1,549 @@ package com.fangjia.dal.seawater.dao; -import java.util.*; - -import com.fangjia.dal.SeawaterQuery; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang.StringUtils; - import com.fangjia.core.util.HttpRequest; import com.fangjia.core.util.HttpRequestException; +import com.fangjia.dal.SeawaterQuery; import com.fangjia.dal.seawater.model.Seawater; - import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; import org.sothis.core.util.Pager; +import java.util.*; + public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl implements SeawaterDao { - - - private static final String ES_USER = "developer"; - private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; - - - @Override - public long findSeawatersCountFromEs(String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Integer room, String root,String table) { - int count = queryCount(null,category,city,region,name,alias,regionAlias,startDate,endDate,room,root,null,false,-1,-1,table); - return count; - } - - @Override - public Seawater findByIdFromEs(String id,String table) { - Seawater seawater = null; - SeawaterQuery query = new SeawaterQuery(); - query.setId(id); - query.setTable(table); - Pager pager = new Pager(); - pager.setStartRow(-1); - pager.setPageSize(-1); - query.setPager(pager); - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - List seawaterList = wrapSeawater(jsonList); - if(seawaterList.size() > 0){ - seawater = seawaterList.get(0); - } - } - return seawater; - } - - @Override - public List findSeawatersFromEs(String category, String city, String region, String name, List alias, List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String table) { - List seawaterList= new ArrayList(); - SeawaterQuery query = new SeawaterQuery(); - query.setCat(category); - query.setCityDisplay(city); - query.setRegion(region); - query.setDistrictName(name); - query.setDistrictAlias(alias); - query.setRegionAlias(regionAlias); - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setStartArea(startArea); - query.setEndArea(endArea); - query.setStartPrice(startPrice); - query.setEndPrice(endPrice); - query.setRoom(room); - query.setRootName(root); - query.setOrder(order); - Pager pager = new Pager(); - pager.setStartRow(start); - pager.setPageSize(limit); - query.setPager(pager); - query.setTable(table); - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - seawaterList = wrapSeawater(jsonList); - } - return seawaterList; - } - - @Override - public List findSeawatersByQuery(SeawaterQuery query){ - List seawaterList; - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - seawaterList = wrapSeawater(jsonList); - } - return seawaterList; - } - - @Override - public long findSeawatersCountByQuery(SeawaterQuery query) { - int count = queryCount(query); - return count; - } - - @Override - public List findHouses(String city, String region, List alias, Integer minPrice, Integer maxPrice, Integer limit) { - JSONObject reqBody = new JSONObject(); - reqBody.put("from", 0); - reqBody.put("size", limit); - JSONObject query = new JSONObject(); - JSONObject bool = new JSONObject(); - JSONArray must = new JSONArray(); - must.add(addMatch("city", city)); - must.add(addMatch("region", region)); - must.add(addTerms("district_name", alias)); - must.add(addMatch("cat", "sell")); - must.add(addRange("avg_price", minPrice, maxPrice)); - must.add(addRangeGte("p_date", 20210501)); - - bool.put("must", must); - query.put("bool", bool); - reqBody.put("query", query); - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); - HttpRequest request = new HttpRequest(); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); - try { - String response = request.postWithBody("http://es.fangjia.com:9200/latest_seawater/_search", reqBody, headers, "UTF-8"); - JSONObject json = JSONObject.fromObject(response); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ - return Collections.emptyList(); - } - JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); - List results = new ArrayList(); - for(int i=0 ;i < hits.size(); i++){ - JSONObject jsonObject = hits.getJSONObject(i); - results.add(jsonObject); - } - return wrapSeawater(results); - - } catch (HttpRequestException e) { - e.printStackTrace(); - } - return new ArrayList(); - } - - @Override - public void deleteById(String id) { - deleteByIds(Arrays.asList(id)); - } - - private Map buildHeader() { - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic " + authenticationEncoding + ""); - return headers; - } - - @Override - public void deleteByIds(List idList) { - HttpRequest request = new HttpRequest(); - - JSONObject reqBody = new JSONObject(); - JSONObject query = new JSONObject(); - JSONObject bool = new JSONObject(); - JSONArray must = new JSONArray(); - must.add(addTerms("_id", idList)); - bool.put("must", must); - query.put("bool", bool); - reqBody.put("query", query); - - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.status=1"); - reqBody.put("script", script); - - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } - - @Override - public void batchDeleteByParams(SeawaterQuery query) { - HttpRequest request = new HttpRequest(); - - JSONObject reqBody = wrapQueryParams(query); - - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.status=1"); - script.put("lang", "painless"); - reqBody.put("script", script); - - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } - - @Override - public void batchUpdateEstateType(SeawaterQuery query) { - HttpRequest request = new HttpRequest(); - - JSONObject reqBody = wrapQueryParams(query); - - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.estate_type="+"'"+query.getEditEstateType()+"'"); - script.put("lang", "painless"); - reqBody.put("script", script); - - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } - - private JSONObject addMatch(String name, String value){ - JSONObject term = new JSONObject(); - JSONObject match = new JSONObject(); - match.put(name, value); - term.put("match", match); - return term; - } - - private JSONObject addTerms(String name, List value){ - JSONObject terms = new JSONObject(); - JSONObject match = new JSONObject(); - match.put(name, value); - terms.put("terms", match); - return terms; - } - - private JSONObject addRange(String name, Number min, Number max){ - JSONObject term = new JSONObject(); - JSONObject range = new JSONObject(); - JSONObject rangeValue = new JSONObject(); - rangeValue.put("gt", min); - rangeValue.put("lt", max); - range.put(name, rangeValue); - term.put("range", range); - return term; - } - - private JSONObject addRangeGte(String name, Number min){ - JSONObject term = new JSONObject(); - JSONObject range = new JSONObject(); - JSONObject rangeValue = new JSONObject(); - rangeValue.put("gte", min); - range.put(name, rangeValue); - term.put("range", range); - return term; - } - private List wrapSeawater(List jsonList){ - List seawaterList= new ArrayList(); - for(int i=0 ;i < jsonList.size(); i++){ - Seawater seawater = new Seawater(); - seawater.setId(jsonList.get(i).getString("_id")); - JSONObject source = jsonList.get(i).getJSONObject("_source"); - seawater.setCategory(source.getString("cat")); - seawater.setCity(source.getString("city")); - seawater.setRegion(source.getString("region")); - seawater.setDistrictName(source.getString("district_name")); - if(source.containsKey("address")){ - seawater.setAddress(source.getString("address")); - } - if(source.containsKey("name")){ - seawater.setName(source.getString("name")); - } - if(source.containsKey("direction")){ - seawater.setDirection(source.getString("direction")); - } - if(source.containsKey("block")){ - seawater.setBlock(source.getString("block")); - } - try{ - seawater.setTotalPrice(source.getInt("total_price")); - }catch(NumberFormatException e){ - seawater.setTotalPrice(0); - } - try{ - seawater.setArea(source.getDouble("area")); - }catch(NumberFormatException e){ - seawater.setArea(0d); - } - try{ - seawater.setHeight(source.getInt("height")); - }catch(Exception e){ - seawater.setHeight(0); - } - try{ - seawater.setFloor(source.getInt("floor")); - }catch(Exception e){ - seawater.setFloor(0); - } - try{ - seawater.setFloorInfo(source.getString("floor_info")); - }catch(Exception e){ + private static final String ES_USER = "developer"; + private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; - } - if(source.containsKey("fitment")){ - seawater.setFitment(source.getString("fitment")); - } - try{ - seawater.setRoom(source.getInt("room")); - }catch(Exception e){ - seawater.setRoom(0); - } - try{ - seawater.setHall(source.getInt("hall")); - }catch(Exception e){ - seawater.setHall(0); - } - try{ - seawater.setToilet(source.getInt("toilet")); - }catch(Exception e){ - seawater.setToilet(0); - } - try{ - seawater.setpDate(source.getInt("p_date")); - }catch(Exception e){ - seawater.setpDate(0); - } - if(source.containsKey("url")){ - seawater.setUrl(source.getString("url")); - } - if(source.containsKey("avg_price")){ - seawater.setAvgPrice(source.getInt("avg_price")); - } - if(source.containsKey("root")){ - seawater.setRoot(source.getString("root")); - } - if(source.containsKey("estate_type")){ - seawater.setEstateType(source.getString("estate_type")); - } + @Override + public long findSeawatersCountFromEs(String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Integer room, String root, String table) { + int count = queryCount(null, category, city, region, name, alias, regionAlias, startDate, endDate, room, root, null, false, -1, -1, table); + return count; + } - if(source.containsKey("build_type")){ - seawater.setBuildType(source.getString("build_type")); - } - if(source.containsKey("status")){ - seawater.setStatus(source.getInt("status")); - } - - if(source.containsKey("lift")){ - seawater.setLift(source.getInt("lift")); - } - - if(source.containsKey("lift_household")){ - seawater.setLiftHousehold(source.getInt("lift_household")); - } - - if(source.containsKey("room_structure")){ - seawater.setRoomStructure(source.getString("room_structure")); - } - - if(source.containsKey("trade_property")){ - seawater.setTradeProperty(source.getString("trade_property")); - } - if(source.containsKey("property_ownership")){ - seawater.setPropertyOwnership(source.getString("property_ownership")); - } - if(source.containsKey("housing_age")){ - seawater.setHousingAge(source.getString("housing_age")); - } - if(source.containsKey("elevator")){ - seawater.setElevator(source.getString("elevator")); - } - seawaterList.add(seawater); + @Override + public Seawater findByIdFromEs(String id, String table) { + Seawater seawater = null; + SeawaterQuery query = new SeawaterQuery(); + query.setId(id); + query.setTable(table); + Pager pager = new Pager(); + pager.setStartRow(-1); + pager.setPageSize(-1); + query.setPager(pager); + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + List seawaterList = wrapSeawater(jsonList); + if (seawaterList.size() > 0) { + seawater = seawaterList.get(0); + } } - return seawaterList; - } - - private JSONObject query(String id,String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, - Integer room, String root,String sort, boolean order, int start, int limit,String table){ - long time1 = System.currentTimeMillis(); - JSONObject reqBody = new JSONObject(); + return seawater; + } + + @Override + public List findSeawatersFromEs(String category, String city, String region, String name, List alias, List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String table) { + List seawaterList = new ArrayList(); + SeawaterQuery query = new SeawaterQuery(); + query.setCat(category); + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(name); + query.setDistrictAlias(alias); + query.setRegionAlias(regionAlias); + query.setStartDate(startDate); + query.setEndDate(endDate); + query.setStartArea(startArea); + query.setEndArea(endArea); + query.setStartPrice(startPrice); + query.setEndPrice(endPrice); + query.setRoom(room); + query.setRootName(root); + query.setOrder(order); + Pager pager = new Pager(); + pager.setStartRow(start); + pager.setPageSize(limit); + query.setPager(pager); + query.setTable(table); + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + seawaterList = wrapSeawater(jsonList); + } + return seawaterList; + } + + @Override + public List findSeawatersByQuery(SeawaterQuery query) { + List seawaterList; + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + seawaterList = wrapSeawater(jsonList); + } + return seawaterList; + } + + @Override + public long findSeawatersCountByQuery(SeawaterQuery query) { + int count = queryCount(query); + return count; + } + + @Override + public List findHouses(String city, String region, List alias, Integer minPrice, Integer maxPrice, Integer limit) { + JSONObject reqBody = new JSONObject(); + reqBody.put("from", 0); + reqBody.put("size", limit); + JSONObject query = new JSONObject(); + JSONObject bool = new JSONObject(); + JSONArray must = new JSONArray(); + must.add(addMatch("city", city)); + must.add(addMatch("region", region)); + must.add(addTerms("district_name", alias)); + must.add(addMatch("cat", "sell")); + must.add(addRange("avg_price", minPrice, maxPrice)); + must.add(addRangeGte("p_date", 20210501)); + + bool.put("must", must); + query.put("bool", bool); + reqBody.put("query", query); + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + try { + String response = request.postWithBody("http://es.fangjia.com:9200/latest_seawater/_search", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) { + return Collections.emptyList(); + } + JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); + List results = new ArrayList(); + for (int i = 0; i < hits.size(); i++) { + JSONObject jsonObject = hits.getJSONObject(i); + results.add(jsonObject); + } + return wrapSeawater(results); + + } catch (HttpRequestException e) { + e.printStackTrace(); + } + return new ArrayList(); + } + + @Override + public void deleteById(String id) { + deleteByIds(Arrays.asList(id)); + } + + private Map buildHeader() { + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + return headers; + } + + @Override + public void deleteByIds(List idList) { + HttpRequest request = new HttpRequest(); + + JSONObject reqBody = new JSONObject(); + JSONObject query = new JSONObject(); + JSONObject bool = new JSONObject(); + JSONArray must = new JSONArray(); + must.add(addTerms("_id", idList)); + bool.put("must", must); + query.put("bool", bool); + reqBody.put("query", query); + + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.status=1"); + reqBody.put("script", script); + + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } + + @Override + public void batchDeleteByParams(SeawaterQuery query) { + HttpRequest request = new HttpRequest(); + + JSONObject reqBody = wrapQueryParams(query); + + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.status=1"); + script.put("lang", "painless"); + reqBody.put("script", script); + + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } + + @Override + public void batchUpdateEstateType(SeawaterQuery query) { + HttpRequest request = new HttpRequest(); + + JSONObject reqBody = wrapQueryParams(query); + + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.estate_type=" + "'" + query.getEditEstateType() + "'"); + script.put("lang", "painless"); + reqBody.put("script", script); + + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } + + private JSONObject addMatch(String name, String value) { + JSONObject term = new JSONObject(); + JSONObject match = new JSONObject(); + match.put(name, value); + term.put("match", match); + return term; + } + + private JSONObject addTerms(String name, List value) { + JSONObject terms = new JSONObject(); + JSONObject match = new JSONObject(); + match.put(name, value); + terms.put("terms", match); + return terms; + } + + private JSONObject addRange(String name, Number min, Number max) { + JSONObject term = new JSONObject(); + JSONObject range = new JSONObject(); + JSONObject rangeValue = new JSONObject(); + rangeValue.put("gt", min); + rangeValue.put("lt", max); + range.put(name, rangeValue); + term.put("range", range); + return term; + } + + private JSONObject addRangeGte(String name, Number min) { + JSONObject term = new JSONObject(); + JSONObject range = new JSONObject(); + JSONObject rangeValue = new JSONObject(); + rangeValue.put("gte", min); + range.put(name, rangeValue); + term.put("range", range); + return term; + } + + + private List wrapSeawater(List jsonList) { + List seawaterList = new ArrayList(); + for (int i = 0; i < jsonList.size(); i++) { + Seawater seawater = new Seawater(); + seawater.setId(jsonList.get(i).getString("_id")); + JSONObject source = jsonList.get(i).getJSONObject("_source"); + seawater.setCategory(source.getString("cat")); + seawater.setCity(source.getString("city")); + seawater.setRegion(source.getString("region")); + seawater.setDistrictName(source.getString("district_name")); + if (source.containsKey("location")) { + String location = source.getJSONObject("location").getString("lon") + "," + source.getJSONObject("location").getString("lat"); + seawater.setLocation(location); + } + if (source.containsKey("address")) { + seawater.setAddress(source.getString("address")); + } + if (source.containsKey("name")) { + seawater.setName(source.getString("name")); + } + if (source.containsKey("direction")) { + seawater.setDirection(source.getString("direction")); + } + if (source.containsKey("block")) { + seawater.setBlock(source.getString("block")); + } + try { + seawater.setTotalPrice(source.getInt("total_price")); + } catch (NumberFormatException e) { + seawater.setTotalPrice(0); + } + try { + seawater.setArea(source.getDouble("area")); + } catch (NumberFormatException e) { + seawater.setArea(0d); + } + try { + seawater.setHeight(source.getInt("height")); + } catch (Exception e) { + seawater.setHeight(0); + } + try { + seawater.setFloor(source.getInt("floor")); + } catch (Exception e) { + seawater.setFloor(0); + } + try { + seawater.setFloorInfo(source.getString("floor_info")); + } catch (Exception e) { + + } + if (source.containsKey("fitment")) { + seawater.setFitment(source.getString("fitment")); + } + try { + seawater.setRoom(source.getInt("room")); + } catch (Exception e) { + seawater.setRoom(0); + } + try { + seawater.setHall(source.getInt("hall")); + } catch (Exception e) { + seawater.setHall(0); + } + try { + seawater.setToilet(source.getInt("toilet")); + } catch (Exception e) { + seawater.setToilet(0); + } + try { + seawater.setpDate(source.getInt("p_date")); + } catch (Exception e) { + seawater.setpDate(0); + } + if (source.containsKey("publish_date")){ + seawater.setPublishDate(source.getString("publish_date")); + } + if (source.containsKey("url")) { + seawater.setUrl(source.getString("url")); + } + if (source.containsKey("avg_price")) { + seawater.setAvgPrice(source.getInt("avg_price")); + } + if (source.containsKey("root")) { + seawater.setRoot(source.getString("root")); + } + + if (source.containsKey("estate_type")) { + seawater.setEstateType(source.getString("estate_type")); + } + + if (source.containsKey("build_type")) { + seawater.setBuildType(source.getString("build_type")); + } + if (source.containsKey("status")) { + seawater.setStatus(source.getInt("status")); + } + + if (source.containsKey("lift")) { + seawater.setLift(source.getInt("lift")); + } + + if (source.containsKey("lift_household")) { + seawater.setLiftHousehold(source.getInt("lift_household")); + } + + if (source.containsKey("room_structure")) { + seawater.setRoomStructure(source.getString("room_structure")); + } + + if (source.containsKey("trade_property")) { + seawater.setTradeProperty(source.getString("trade_property")); + } + if (source.containsKey("property_ownership")) { + seawater.setPropertyOwnership(source.getString("property_ownership")); + } + if (source.containsKey("housing_age")) { + seawater.setHousingAge(source.getString("housing_age")); + } + if (source.containsKey("elevator")) { + seawater.setElevator(source.getString("elevator")); + } + if (source.containsKey("level")) { + seawater.setLevel(source.getString("level")); + } + if (source.containsKey("business_range")) { + seawater.setBusinessRange(source.getString("business_range")); + } + if (source.containsKey("day_rent_price")) { + seawater.setDayUnitPrice(source.getDouble("day_rent_price")); + } + if (source.containsKey("pay_type")) { + seawater.setPayType(source.getString("pay_type")); + } + if (source.containsKey("rent_type")) { + seawater.setRentType(source.getString("rent_type")); + } + if (source.containsKey("business_status")) { + seawater.setBusinessStatus(source.getString("business_status")); + } + try { + seawater.setDistance((int) jsonList.get(i).getJSONArray("sort").getDouble(0)); + } catch (Exception e) { + seawater.setDistance(null); + } + seawaterList.add(seawater); + } + return seawaterList; + } + + private JSONObject query(String id, String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, + Integer room, String root, String sort, boolean order, int start, int limit, String table) { + long time1 = System.currentTimeMillis(); + JSONObject reqBody = new JSONObject(); JSONObject q = new JSONObject(); JSONObject query = new JSONObject(); List jsonList = new ArrayList(); - if(StringUtils.isNotBlank(id)) { - JSONObject param = new JSONObject(); - param.put("_id", id); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(category)) { - JSONObject param = new JSONObject(); - param.put("cat", category); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - + if (StringUtils.isNotBlank(id)) { + JSONObject param = new JSONObject(); + param.put("_id", id); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(category)) { + JSONObject param = new JSONObject(); + param.put("cat", category); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(name)) { - namesList.add(name); - } - if (alias != null) { - namesList.addAll(alias); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } - - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(region)) { - regionsList.add(region); - } - if (regionAlias != null) { - regionsList.addAll(regionAlias); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } - - if(StringUtils.isNotBlank(city)){ - JSONObject param = new JSONObject(); - param.put("city", city); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(room != null) { - JSONObject param = new JSONObject(); - param.put("room", room); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(root)) { - JSONObject param = new JSONObject(); - param.put("root", root); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - - if(startDate != null || endDate != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startDate != null){ - temp2.put("gte", startDate); - } - if(endDate != null){ - temp2.put("lte", endDate); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(name)) { + namesList.add(name); + } + if (alias != null) { + namesList.addAll(alias); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } + + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(region)) { + regionsList.add(region); + } + if (regionAlias != null) { + regionsList.addAll(regionAlias); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } + + if (StringUtils.isNotBlank(city)) { + JSONObject param = new JSONObject(); + param.put("city", city); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (room != null) { + JSONObject param = new JSONObject(); + param.put("room", room); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(root)) { + JSONObject param = new JSONObject(); + param.put("root", root); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + + if (startDate != null || endDate != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startDate != null) { + temp2.put("gte", startDate); + } + if (endDate != null) { + temp2.put("lte", endDate); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(startArea != null || endArea != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startArea != null){ - temp2.put("gte", startArea); - } - if(endArea != null){ - temp2.put("lte", endArea); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (startArea != null || endArea != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startArea != null) { + temp2.put("gte", startArea); + } + if (endArea != null) { + temp2.put("lte", endArea); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(startPrice != null || endPrice != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startPrice != null){ - temp2.put("gte", startPrice); - } - if(endPrice != null){ - temp2.put("lte", endPrice); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } - - if(StringUtils.isNotBlank(sort)){ - JSONObject jsonOrder = new JSONObject(); - if(order){ - jsonOrder.put("order", "asc"); - }else{ - jsonOrder.put("order", "desc"); - } - JSONObject jsonSort = new JSONObject(); - jsonSort.put(sort, jsonOrder); - List sortJsonList = new ArrayList(); - sortJsonList.add(jsonSort); - reqBody.put("sort", sortJsonList); - } - - if(start >= 0){ + if (startPrice != null || endPrice != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startPrice != null) { + temp2.put("gte", startPrice); + } + if (endPrice != null) { + temp2.put("lte", endPrice); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } + + if (StringUtils.isNotBlank(sort)) { + JSONObject jsonOrder = new JSONObject(); + if (order) { + jsonOrder.put("order", "asc"); + } else { + jsonOrder.put("order", "desc"); + } + JSONObject jsonSort = new JSONObject(); + jsonSort.put(sort, jsonOrder); + List sortJsonList = new ArrayList(); + sortJsonList.add(jsonSort); + reqBody.put("sort", sortJsonList); + } + + if (start >= 0) { reqBody.put("from", start); } - if(limit >= 0){ + if (limit >= 0) { reqBody.put("size", limit); } @@ -529,232 +557,255 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i query.put("must", jsonList); q.put("bool", query); reqBody.put("query", q); - //Óû§Ãû:ÃÜÂë + //Óû§Ãû:ÃÜÂë Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); HttpRequest request = new HttpRequest(); Map headers = new HashMap(); headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); try { - String response = request.postWithBody("http://es.fangjia.com:9200/"+table+"/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + String response = request.postWithBody("http://es.fangjia.com:9200/" + table + "/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); JSONObject json = JSONObject.fromObject(response); long time2 = System.currentTimeMillis(); - System.out.println(time2-time1); + System.out.println(time2 - time1); return json; } catch (HttpRequestException e) { e.printStackTrace(); } return null; - } + } - private JSONObject query(SeawaterQuery query){ - long time1 = System.currentTimeMillis(); - JSONObject reqBody = new JSONObject(); - JSONObject q = new JSONObject(); - JSONObject queryJson = new JSONObject(); - List jsonList = new ArrayList(); - Double lat = query.getLat(); - Double lng = query.getLng(); - Integer radius = query.getRadius(); - if (lat != null && lng != null && radius != null) { - // 1. ÉèÖõØÀíλÖòÎÊý - JSONObject geoDistanceParam = new JSONObject(); - geoDistanceParam.put("lat", lat); - geoDistanceParam.put("lon", lng); + private JSONObject query(SeawaterQuery query) { + long time1 = System.currentTimeMillis(); + JSONObject reqBody = new JSONObject(); + JSONObject q = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + Double lat = query.getLat(); + Double lng = query.getLng(); + Integer radius = query.getRadius(); + JSONObject filter = new JSONObject(); + // Ìí¼ÓµØÀíλÖùýÂËÆ÷ºÍÅÅÐò + if (lat != null && lng != null && radius != null) { + // 1. ÉèÖõØÀíλÖòÎÊý + JSONObject geoDistanceParam = new JSONObject(); + geoDistanceParam.put("lat", lat); + geoDistanceParam.put("lon", lng); - // 2. ÉèÖà geo_distance ¹ýÂËÆ÷£¬ÏÞÖÆ½á¹ûÔÚÖ¸¶¨µÄ°ë¾¶·¶Î§ÄÚ - JSONObject geoDistanceFilter = new JSONObject(); - JSONObject geoDistance = new JSONObject(); - geoDistance.put("distance", radius + "m"); // °ë¾¶ÉèÖÃΪ 3000km - geoDistance.put("location", geoDistanceParam); // ʹÓøø¶¨µÄ¾­Î³¶È - geoDistanceFilter.put("geo_distance", geoDistance); + // 2. ÉèÖà geo_distance ¹ýÂËÆ÷£¬ÏÞÖÆ½á¹ûÔÚÖ¸¶¨µÄ°ë¾¶·¶Î§ÄÚ - // 3. ¹¹½¨²éѯÌå - reqBody.put("query", new JSONObject().put("filter", geoDistanceFilter)); - // 4. Ìí¼Ó°´¾àÀëÅÅÐòµÄ²¿·Ö - JSONObject geoDistanceSort = new JSONObject(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("order", "asc"); - jsonObject.put("location", geoDistanceParam); - jsonObject.put("unit", "m"); - jsonObject.put("distance_type", "arc"); - geoDistanceSort.put("_geo_distance", jsonObject); - // 5. ½«ÅÅÐò²¿·ÖÌí¼Óµ½ÇëÇóÌå - List sortJsonList = new ArrayList(); - sortJsonList.add(geoDistanceSort); - reqBody.put("sort", sortJsonList); - } - if(StringUtils.isNotBlank(query.getId())) { - JSONObject param = new JSONObject(); - param.put("_id", query.getId()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getCat())) { - JSONObject param = new JSONObject(); - param.put("cat", query.getCat()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + JSONObject geoDistance = new JSONObject(); + geoDistance.put("distance", radius + "m"); // °ë¾¶ÉèÖÃΪ 3000km + geoDistance.put("location", geoDistanceParam); // ʹÓøø¶¨µÄ¾­Î³¶È + filter.put("geo_distance", geoDistance); - Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getDistrictName())) { - namesList.add(query.getDistrictName()); - } - if (query.getDistrictAlias() != null) { - namesList.addAll(query.getDistrictAlias()); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + // 3. ¹¹½¨²éѯÌå +// filter.put("filter", geoDistanceFilter); +// jsonList.add(filter); +// reqBody.put("query", filter); + // 4. Ìí¼Ó°´¾àÀëÅÅÐòµÄ²¿·Ö + JSONObject geoDistanceSort = new JSONObject(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("order", "asc"); + jsonObject.put("location", geoDistanceParam); + jsonObject.put("unit", "m"); + jsonObject.put("distance_type", "arc"); + geoDistanceSort.put("_geo_distance", jsonObject); + // 5. ½«ÅÅÐò²¿·ÖÌí¼Óµ½ÇëÇóÌå + List sortJsonList = new ArrayList(); + sortJsonList.add(geoDistanceSort); + reqBody.put("sort", sortJsonList); + } + if (StringUtils.isNotBlank(query.getId())) { + JSONObject param = new JSONObject(); + param.put("_id", query.getId()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getCat())) { + JSONObject param = new JSONObject(); + param.put("cat", query.getCat()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getFitment())) { + JSONObject param = new JSONObject(); + param.put("fitment", query.getFitment()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getDirection())) { + JSONObject param = new JSONObject(); + param.put("direction", query.getDirection()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getRegion())) { - regionsList.add(query.getRegion()); - } - if (query.getRegionAlias() != null) { - regionsList.addAll(query.getRegionAlias()); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set namesList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getDistrictName())) { + namesList.add(query.getDistrictName()); + } + if (query.getDistrictAlias() != null) { + namesList.addAll(query.getDistrictAlias()); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getCityDisplay())){ - JSONObject param = new JSONObject(); - param.put("city", query.getCityDisplay()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getEstateType())) { - JSONObject param = new JSONObject(); - param.put("estate_type", query.getEstateType()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(query.getRoom() != null) { - JSONObject param = new JSONObject(); - param.put("room", query.getRoom()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getRootName())) { - JSONObject param = new JSONObject(); - param.put("root", query.getRootName()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getRegion())) { + regionsList.add(query.getRegion()); + } + if (query.getRegionAlias() != null) { + regionsList.addAll(query.getRegionAlias()); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(query.getStartDate() != null || query.getEndDate() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartDate() != null){ - temp2.put("gte", query.getStartDate()); - } - if(query.getEndDate() != null){ - temp2.put("lte", query.getEndDate()); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(query.getCityDisplay())) { + JSONObject param = new JSONObject(); + param.put("city", query.getCityDisplay()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getEstateType())) { + JSONObject param = new JSONObject(); + param.put("estate_type", query.getEstateType()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (query.getRoom() != null) { + JSONObject param = new JSONObject(); + param.put("room", query.getRoom()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getRootName())) { + JSONObject param = new JSONObject(); + param.put("root", query.getRootName()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + + if (query.getStartDate() != null || query.getEndDate() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartDate() != null) { + temp2.put("gte", query.getStartDate()); + } + if (query.getEndDate() != null) { + temp2.put("lte", query.getEndDate()); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartArea() != null || query.getEndArea() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartArea() != null){ - temp2.put("gte", query.getStartArea()); - } - if(query.getEndArea() != null){ - temp2.put("lte", query.getEndArea()); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartArea() != null || query.getEndArea() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartArea() != null) { + temp2.put("gte", query.getStartArea()); + } + if (query.getEndArea() != null) { + temp2.put("lte", query.getEndArea()); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartPrice() != null || query.getEndPrice() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartPrice() != null){ - temp2.put("gte", query.getStartPrice()); - } - if(query.getEndPrice() != null){ - temp2.put("lte", query.getEndPrice()); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartPrice() != null || query.getEndPrice() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartPrice() != null) { + temp2.put("gte", query.getStartPrice()); + } + if (query.getEndPrice() != null) { + temp2.put("lte", query.getEndPrice()); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getSortField())){ - JSONObject jsonOrder = new JSONObject(); - if(query.getOrder()){ - jsonOrder.put("order", "asc"); - }else{ - jsonOrder.put("order", "desc"); - } - JSONObject jsonSort = new JSONObject(); - jsonSort.put(query.getSortField(), jsonOrder); - List sortJsonList = new ArrayList(); - sortJsonList.add(jsonSort); - reqBody.put("sort", sortJsonList); - } + if (StringUtils.isNotBlank(query.getSortField())) { + JSONObject jsonOrder = new JSONObject(); + if (query.getOrder()) { + jsonOrder.put("order", "asc"); + } else { + jsonOrder.put("order", "desc"); + } + JSONObject jsonSort = new JSONObject(); + jsonSort.put(query.getSortField(), jsonOrder); + List sortJsonList = new ArrayList(); + sortJsonList.add(jsonSort); + reqBody.put("sort", sortJsonList); + } - if(query.getPager().getStartRow() >= 0){ - reqBody.put("from", query.getPager().getStartRow()); - } - if(query.getPager().getPageSize() >= 0){ - reqBody.put("size", query.getPager().getPageSize()); - } + if (query.getPager().getStartRow() >= 0) { + reqBody.put("from", query.getPager().getStartRow()); + } + if (query.getPager().getPageSize() >= 0) { + reqBody.put("size", query.getPager().getPageSize()); + } - if(query.getStatus() != null){ - JSONObject param = new JSONObject(); - param.put("status", query.getStatus()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (query.getStatus() != null) { + JSONObject param = new JSONObject(); + param.put("status", query.getStatus()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - queryJson.put("must", jsonList); - q.put("bool", queryJson); - reqBody.put("query", q); - //Óû§Ãû:ÃÜÂë - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); - HttpRequest request = new HttpRequest(); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); - try { - String response = request.postWithBody("http://es.fangjia.com:9200/"+query.getTable()+"/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); - JSONObject json = JSONObject.fromObject(response); - long time2 = System.currentTimeMillis(); - System.out.println(time2-time1); - return json; - } catch (HttpRequestException e) { - e.printStackTrace(); - } - return null; - } + queryJson.put("must", jsonList); + ArrayList filterList = new ArrayList(); + if (filter.size() > 0) { + filterList.add(filter); + queryJson.put("filter", filterList); + } + q.put("bool", queryJson); + reqBody.put("query", q); + //Óû§Ãû:ÃÜÂë + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + try { + String response = request.postWithBody("http://es.fangjia.com:9200/" + query.getTable() + "/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + long time2 = System.currentTimeMillis(); + System.out.println(time2 - time1); + return json; + } catch (HttpRequestException e) { + e.printStackTrace(); + } + return null; + } // private List queryList(String id,String category, String city, String region, String name, List alias, // List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root,String sort, boolean order, int start, int limit,String table){ @@ -771,188 +822,188 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i // return results; // } - private List queryList(SeawaterQuery query){ - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ - return null; - } - JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); - List results = new ArrayList(); - for(int i=0 ;i < hits.size(); i++){ - JSONObject jsonObject = hits.getJSONObject(i); - results.add(jsonObject); - } - return results; - } + private List queryList(SeawaterQuery query) { + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) { + return null; + } + JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); + List results = new ArrayList(); + for (int i = 0; i < hits.size(); i++) { + JSONObject jsonObject = hits.getJSONObject(i); + results.add(jsonObject); + } + return results; + } - private int queryCount(String id,String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Integer room, String root,String sort, boolean order, int start, int limit,String table){ - SeawaterQuery query = new SeawaterQuery(); - query.setCat(category); - query.setCityDisplay(city); - query.setRegion(region); - query.setDistrictName(name); - query.setDistrictAlias(alias); - query.setRegionAlias(regionAlias); - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setRoom(room); - query.setRootName(root); - query.setOrder(order); - Pager pager = new Pager(); - pager.setStartRow(start); - pager.setPageSize(limit); - query.setPager(pager); - query.setTable(table); - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){ + private int queryCount(String id, String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Integer room, String root, String sort, boolean order, int start, int limit, String table) { + SeawaterQuery query = new SeawaterQuery(); + query.setCat(category); + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(name); + query.setDistrictAlias(alias); + query.setRegionAlias(regionAlias); + query.setStartDate(startDate); + query.setEndDate(endDate); + query.setRoom(room); + query.setRootName(root); + query.setOrder(order); + Pager pager = new Pager(); + pager.setStartRow(start); + pager.setPageSize(limit); + query.setPager(pager); + query.setTable(table); + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")) { return 0; } return json.getJSONObject("hits").getInt("total"); - } + } - private int queryCount(SeawaterQuery query){ - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){ - return 0; - } - return json.getJSONObject("hits").getInt("total"); - } + private int queryCount(SeawaterQuery query) { + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")) { + return 0; + } + return json.getJSONObject("hits").getInt("total"); + } - private JSONObject wrapQueryParams(SeawaterQuery query){ - JSONObject reqBody = new JSONObject(); - JSONObject q = new JSONObject(); - JSONObject queryJson = new JSONObject(); - List jsonList = new ArrayList(); - if(StringUtils.isNotBlank(query.getId())) { - JSONObject param = new JSONObject(); - param.put("_id", query.getId()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getCat())) { - JSONObject param = new JSONObject(); - param.put("cat", query.getCat()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + private JSONObject wrapQueryParams(SeawaterQuery query) { + JSONObject reqBody = new JSONObject(); + JSONObject q = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + if (StringUtils.isNotBlank(query.getId())) { + JSONObject param = new JSONObject(); + param.put("_id", query.getId()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getCat())) { + JSONObject param = new JSONObject(); + param.put("cat", query.getCat()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getDistrictName())) { - namesList.add(query.getDistrictName()); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set namesList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getDistrictName())) { + namesList.add(query.getDistrictName()); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getRegion())) { - regionsList.add(query.getRegion()); - } - if (query.getRegionAlias() != null) { - regionsList.addAll(query.getRegionAlias()); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getRegion())) { + regionsList.add(query.getRegion()); + } + if (query.getRegionAlias() != null) { + regionsList.addAll(query.getRegionAlias()); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getCityDisplay())){ - JSONObject param = new JSONObject(); - param.put("city", query.getCityDisplay()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getEstateType())) { - JSONObject param = new JSONObject(); - param.put("estate_type", query.getEstateType()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(query.getRoom() != null) { - JSONObject param = new JSONObject(); - param.put("room", query.getRoom()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getRootName())) { - JSONObject param = new JSONObject(); - param.put("root", query.getRootName()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(query.getCityDisplay())) { + JSONObject param = new JSONObject(); + param.put("city", query.getCityDisplay()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getEstateType())) { + JSONObject param = new JSONObject(); + param.put("estate_type", query.getEstateType()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (query.getRoom() != null) { + JSONObject param = new JSONObject(); + param.put("room", query.getRoom()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getRootName())) { + JSONObject param = new JSONObject(); + param.put("root", query.getRootName()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - if(query.getStartDate() != null || query.getEndDate() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartDate() != null){ - temp2.put("gte", query.getStartDate()); - } - if(query.getEndDate() != null){ - temp2.put("lte", query.getEndDate()); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartDate() != null || query.getEndDate() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartDate() != null) { + temp2.put("gte", query.getStartDate()); + } + if (query.getEndDate() != null) { + temp2.put("lte", query.getEndDate()); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartArea() != null || query.getEndArea() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartArea() != null){ - temp2.put("gte", query.getStartArea()); - } - if(query.getEndArea() != null){ - temp2.put("lte", query.getEndArea()); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartArea() != null || query.getEndArea() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartArea() != null) { + temp2.put("gte", query.getStartArea()); + } + if (query.getEndArea() != null) { + temp2.put("lte", query.getEndArea()); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartPrice() != null || query.getEndPrice() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartPrice() != null){ - temp2.put("gte", query.getStartPrice()); - } - if(query.getEndPrice() != null){ - temp2.put("lte", query.getEndPrice()); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartPrice() != null || query.getEndPrice() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartPrice() != null) { + temp2.put("gte", query.getStartPrice()); + } + if (query.getEndPrice() != null) { + temp2.put("lte", query.getEndPrice()); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStatus() != null){ - JSONObject param = new JSONObject(); - param.put("status", query.getStatus()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (query.getStatus() != null) { + JSONObject param = new JSONObject(); + param.put("status", query.getStatus()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - queryJson.put("must", jsonList); - q.put("bool", queryJson); - reqBody.put("query", q); - return reqBody; - } + queryJson.put("must", jsonList); + q.put("bool", queryJson); + reqBody.put("query", q); + return reqBody; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index 88cd97297..b490c892c 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -37,7 +37,7 @@ public class Seawater implements SeawaterEntity { private String id; private String category; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int status; + private Integer status; private String city; private String region; private String district; @@ -80,6 +80,31 @@ public class Seawater implements SeawaterEntity { private String decoration; + private Integer distance; + + private String location; + + private String title; + + // ÉÌÆÌ¾­Óª·¶Î§ + private String businessScope; + private String businessRange; + + //ÉÌÆÌÀàÐÍ + private String shopType; + + // д×ÖÂ¥µÈ¼¶ + private String level; + + private Double dayUnitPrice; + + private String payType; + + private String rentType; + + private String businessStatus; + + @Id @Column(name = "_id") public String getId() { @@ -100,11 +125,11 @@ public class Seawater implements SeawaterEntity { } @Column(name = "status") - public int getStatus() { + public Integer getStatus() { return status; } - public void setStatus(int status) { + public void setStatus(Integer status) { this.status = status; } @@ -216,7 +241,7 @@ public class Seawater implements SeawaterEntity { this.floor = floor; } - @Column(name = "floorInfo") + @Column(name = "floor_info") public String getFloorInfo() { return floorInfo; } @@ -453,4 +478,98 @@ public class Seawater implements SeawaterEntity { public void setDecoration(String decoration) { this.decoration = decoration; } + + public Integer getDistance() { + return distance; + } + + public void setDistance(Integer distance) { + this.distance = distance; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBusinessScope() { + return businessScope; + } + + public void setBusinessScope(String businessScope) { + this.businessScope = businessScope; + } + + public String getShopType() { + return shopType; + } + + public void setShopType(String shopType) { + this.shopType = shopType; + } + + @Column(name = "level") + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + @Column(name = "business_range") + public String getBusinessRange() { + return businessRange; + } + + public void setBusinessRange(String businessRange) { + this.businessRange = businessRange; + } + + @Column(name = "day_rent_price") + public Double getDayUnitPrice() { + return dayUnitPrice; + } + + public void setDayUnitPrice(Double dayUnitPrice) { + this.dayUnitPrice = dayUnitPrice; + } + + @Column(name = "pay_type") + public String getPayType() { + return payType; + } + + public void setPayType(String payType) { + this.payType = payType; + } + + @Column(name = "rent_type") + public String getRentType() { + return rentType; + } + + public void setRentType(String rentType) { + this.rentType = rentType; + } + + @Column(name = "business_status") + public String getBusinessStatus() { + return businessStatus; + } + + public void setBusinessStatus(String businessStatus) { + this.businessStatus = businessStatus; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java new file mode 100644 index 000000000..408097537 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/SeawaterDto.java @@ -0,0 +1,96 @@ +package com.fangjia.dal.seawater.model; + +public class SeawaterDto { + + private String city; + private String district; + private String name; + private String fitment; + private Double area; + private Double unitPrice; + private String publishDate; + private String floorInfo; + + private String estateType; + private String bedKind; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFitment() { + return fitment; + } + + public void setFitment(String fitment) { + this.fitment = fitment; + } + + public Double getArea() { + return area; + } + + public void setArea(Double area) { + this.area = area; + } + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public String getPublishDate() { + return publishDate; + } + + public void setPublishDate(String publishDate) { + this.publishDate = publishDate; + } + + public String getFloorInfo() { + return floorInfo; + } + + public void setFloorInfo(String floorInfo) { + this.floorInfo = floorInfo; + } + + public String getEstateType() { + return estateType; + } + + public void setEstateType(String estateType) { + this.estateType = estateType; + } + + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java index 4b72f411c..90af3ec7e 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/FjtEvaluation.java @@ -92,6 +92,8 @@ public class FjtEvaluation implements SqlEntity{ private String contact; private String reportNum; private Double carSiteArea; + + private Integer carSitePrice; // ³µÎ»¼Û private String source; private String accountChecker; private String floorDesc; //±ðÊûÂ¥²ãÃèÊö @@ -783,6 +785,15 @@ public class FjtEvaluation implements SqlEntity{ this.loan = loan; } + @Column(name = "car_site_price") + public Integer getCarSitePrice() { + return carSitePrice; + } + + public void setCarSitePrice(Integer carSitePrice) { + this.carSitePrice = carSitePrice; + } + @Override public String toString() { return "FjtEvaluation{" + diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java b/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java index 402218d72..a20704090 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java @@ -8,7 +8,8 @@ public enum HttpStatusCodeEnum { BAD_REQUEST_DECRYPT_ERROR(4002,"¼ÓÃܲÎÊý½âÃÜʧ°Ü"), UN_AUTHORIZED(401,"ÇëÇóδ±»ÊÚȨ"), SERVER_ERROR(500,"·þÎñÆ÷ÄÚ²¿´íÎó"), - SERVER_FORBID(403,"ÇëÇ󯵷±"); + SERVER_FORBID(403,"ÇëÇ󯵷±"), + UPGRADE(503,"·þÎñÉý¼¶ÖÐ"); private final int code; private final String msg; diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 9b4164baf..eea2463b2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -44,10 +44,7 @@ import java.io.IOException; import java.net.Authenticator; import java.net.PasswordAuthentication; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * µØÖ·ÖÎÀí @@ -519,7 +516,7 @@ public class AddrSvcController { } else { try { //Èç¹ûÊǽ­ËÕÊ¡»òÕßÕã½­Ê¡ µ÷ÓÃÆëÁºµÄ½á¹û - if (result.containsKey("province") && ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province")))) { + if (result.containsKey("province") && ("Öйú".equals(result.getString("province")))) { //½á¹û±È½Ï£¬Èç¹ûɿũ½á¹û²»Ò»Ö //µ÷ÓÃÆëÁº type £º1 ¶Ô¹« 0 ¶Ô˽ //ÎÒÃÇ type £º1 ¶Ô˽ 2 ¶Ô¹² @@ -661,7 +658,8 @@ public class AddrSvcController { } else { try { //Èç¹ûÊǽ­ËÕÊ¡»òÕßÕã½­Ê¡ µ÷ÓÃÆëÁºµÄ½á¹û - if ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province"))) { +// if ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province"))) { + if (result.containsKey("province") && ("Öйú".equals(result.getString("province")))) { //½á¹û±È½Ï£¬Èç¹ûɿũ½á¹û²»Ò»Ö //µ÷ÓÃÆëÁº type £º1 ¶Ô¹« 0 ¶Ô˽ //ÎÒÃÇ type £º1 ¶Ô˽ 2 ¶Ô¹² @@ -718,6 +716,377 @@ public class AddrSvcController { return mav; } + /** + * ¶Ô¹«ÉæÅ©Ê¶±ð-йæÔò-ÉϺ£ÒøÐÐ + * + * @param model + * @return + */ + public Object boscEnterpriseVillageIdentifyAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("µØÖ·²»ÄÜΪ¿Õ")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/boscEnterpriseVillageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/boscEnterpriseVillageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + if (json.containsKey("result")) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + HashMap map = new LinkedHashMap(); + //ÎÒÃǵĽá¹û +// "province": "½­ËÕÊ¡", +// "city": "ËÕÖÝÊÐ", +// "district": "À¥É½ÊÐ", +// "town": "ÓñɽÕò", +// "committee": "ÄÏÐÇä´åί»á", +// "provinceCode": "320000000000", +// "cityCode": "320500000000", +// "districtCode": "320583000000", +// "townCode": "320583100000", +// "committeeCode": "320583100222", +// "typeCode": "220", +// "typeName": "´åׯ", +// "verifyFlag": "·ÇÅ©", +// "addrVerify": "µØÖ·ÓÐЧ", +// "countyLevelCity": "ÊÇ", +// "administrativeTowns": "·ñ", +// "countyGov": "·ñ", +// "devDistrict": "ÊÇ", +// "devDistrictName": "À¥É½¸ßм¼Êõ²úÒµ¿ª·¢Çø", +// "devLevel": "¹ú¼Ò¼¶", +// "addrArea": "¿ª·¢Çø", +// "countyGovTown": "À¥É½¿ª·¢Çø" + JSONObject result = json.getJSONObject("result"); + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("town")) { + map.put("town", result.getString("town")); + } + if (result.containsKey("committee")) { + map.put("committee", result.getString("committee")); + } + if (result.containsKey("provinceCode")) { + map.put("provinceCode", result.getString("provinceCode")); + } + if (result.containsKey("cityCode")) { + map.put("cityCode", result.getString("cityCode")); + } + if (result.containsKey("districtCode")) { + map.put("districtCode", result.getString("districtCode")); + } + if (result.containsKey("townCode")) { + map.put("townCode", result.getString("townCode")); + } + if (result.containsKey("committeeCode")) { + map.put("committeeCode", result.getString("committeeCode")); + } + if (result.containsKey("typeCode")) { + map.put("typeCode", result.getString("typeCode")); + } + if (result.containsKey("typeName")) { + map.put("typeName", result.getString("typeName")); + } + if (result.containsKey("verifyFlag")) { + map.put("verifyFlag", result.getString("verifyFlag")); + } else { + basicModel.markNoData(); + } + if (result.containsKey("addrVerify")) { + map.put("addrVerify", result.getString("addrVerify")); + } + if (result.containsKey("countyLevelCity")) { + map.put("countyLevelCity", result.getString("countyLevelCity")); + } + if (result.containsKey("administrativeTowns")) { + map.put("administrativeTowns", result.getString("administrativeTowns")); + } + if (result.containsKey("countyGov")) { + map.put("countyGov", result.getString("countyGov")); + } + if (result.containsKey("devDistrict")) { + map.put("devDistrict", result.getString("devDistrict")); + } + if (result.containsKey("devLevel")) { + map.put("devLevel", result.getString("devLevel")); + } + + if (result.containsKey("addrArea")) { + map.put("addrArea", result.getString("addrArea")); + } + if (result.containsKey("devDistrictName")) { + map.put("devDistrictName", result.getString("devDistrictName")); + } + if (result.containsKey("countyGovTown")) { + map.put("countyGovTown", result.getString("countyGovTown")); + } + basicModel.setResult(map); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("·þÎñÉý¼¶ÖÐ...")); + } + } + return mav; + } + + /** + * ¶ÔË½ÉæÅ©Ê¶±ð + */ + public Object residentialVillageIdentifyAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("µØÖ·²»ÄÜΪ¿Õ")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; + // ¶Ô¹« + model.setType("1"); + String villageType = "2".equals(model.getType()) ? "¶Ô¹«" : "¶Ô˽"; + params.put("type", type); + params.put("showFullValue", "2"); + Pager pager = new Pager(1, 1); + List villageIdentifyList = villageIdentifyService.findByCityAndAddress(villageType, model.getCity(), model.getAddress(), pager); + VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null; + if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) { + Map resultMap = new HashMap(); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); + resultMap.put("addrVerify", villageResult.getAddrVerify()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); + BasicModel basicModel = new BasicModel(200, "OK"); + if (StringUtils.isBlank(resultMap.get("verifyFlag"))) { + basicModel.markNoData(); + } + basicModel.setResult(resultMap); + mav.setModel(basicModel); + } else { +// params.put("showTestValue", "2"); + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/residentialVillageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/residentialVillageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + //ÎÒÃǵĽá¹û + JSONObject result = json.getJSONObject("result"); + basicModel.setResult(result); + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("·þÎñÉý¼¶ÖÐ...")); + } + } + return mav; + } + + /** + * ¶Ô¹«ÉæÅ©Ê¶±ð + */ + public Object enterpriseVillageIdentifyAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("µØÖ·²»ÄÜΪ¿Õ")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; + // ¶Ô¹« + model.setType("2"); + String villageType = "2".equals(model.getType()) ? "¶Ô¹«" : "¶Ô˽"; + params.put("type", type); + params.put("showFullValue", "2"); + Pager pager = new Pager(1, 1); + List villageIdentifyList = villageIdentifyService.findByCityAndAddress(villageType, model.getCity(), model.getAddress(), pager); + VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null; + if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) { + Map resultMap = new HashMap(); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); + resultMap.put("addrVerify", villageResult.getAddrVerify()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); + if (StringUtils.isNotBlank(villageResult.getDistrict()) && villageResult.getDistrict().endsWith("Çø")) { + resultMap.put("prefectureLevelOrAbove ", "ÊÇ"); + }else { + resultMap.put("prefectureLevelOrAbove ", "·ñ"); + } + BasicModel basicModel = new BasicModel(200, "OK"); + if (StringUtils.isBlank(resultMap.get("verifyFlag"))) { + basicModel.markNoData(); + } + basicModel.setResult(resultMap); + mav.setModel(basicModel); + } else { +// params.put("showTestValue", "2"); + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/enterpriseVillageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/enterpriseVillageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + //ÎÒÃǵĽá¹û + JSONObject result = json.getJSONObject("result"); + //ÎÒÃÇÊ¡¼¶¼°ÒÔÉÏÓпª·¢Çø£¬Ö±½ÓÓÃÎÒÃǵĽá¹û + if (result.containsKey("devDistrictName")) { + basicModel.setResult(result); + } else if (!"2".equals(type)) { // ¶Ô˽µÄ²»ÓÃÆëÁº + basicModel.setResult(result); + } else { + try { + //Èç¹ûÊǽ­ËÕÊ¡»òÕßÕã½­Ê¡ µ÷ÓÃÆëÁºµÄ½á¹û +// if ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province"))) { + // ÆëÁº²»¿ÉÓã¬ÆÁ±Î + if (result.containsKey("province") && ("Öйú".equals(result.getString("province")))) { + + //½á¹û±È½Ï£¬Èç¹ûɿũ½á¹û²»Ò»Ö + //µ÷ÓÃÆëÁº type £º1 ¶Ô¹« 0 ¶Ô˽ + //ÎÒÃÇ type £º1 ¶Ô˽ 2 ¶Ô¹² + String qltype = "2".equals(type) ? "1" : "0"; + Map map = senRequest(address, qltype); + // ɿũ½á¹û²»Ò»Ñù + if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { + // ÆëÁºÏØÕþ¸®µ«ÊÇÉæÅ©ÎªÅ©£¬È¡ÎÒÃǵĽá¹û ÑïÖÐÊÐÈýé½ÖµÀÖлª´åÓÀ¹ÌºÓ·1ºÅ + if ("ÊÇ".equals(map.get("countyGov")) && "Å©".equals(map.get("verifyFlag"))) { + basicModel.setResult(result); + mav.setModel(basicModel); + return mav; + } + //ÓÐÊÐϽ½¨ÖÆÕò, »òÕß³ÇÊв»Ò»Ñù ÓÃÎÒÃÇ + if (result.containsKey("city")) { + if ("ÊÇ".equals(result.get("administrativeTowns")) || (!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { + basicModel.setResult(result); + } else { + map.put("addrVerify", "µØÖ·ÓÐЧ"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); + map.put("typeName", areaMap.get(map.get("typeCode"))); + basicModel.setResult(map); + } + } else { + map.put("addrVerify", "µØÖ·ÓÐЧ"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); + map.put("typeName", areaMap.get(map.get("typeCode"))); + basicModel.setResult(map); + } + + } else { + basicModel.setResult(result); + } + + } else { + basicModel.setResult(result); + + } + + } catch (Exception e) { + e.printStackTrace(); + basicModel.setResult(result); + } + + } + + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("·þÎñÉý¼¶ÖÐ...")); + } + } + return mav; + } /** * ÉæÅ©Ê¶±ð-йæÔò-»ù´¡°æ±¾ @@ -770,6 +1139,9 @@ public class AddrSvcController { resultMap.put("devLevel", villageResult.getDevLevel()); resultMap.put("addrArea", villageResult.getAddrArea()); BasicModel basicModel = new BasicModel(200, "OK"); + if (StringUtils.isBlank(resultMap.get("verifyFlag"))) { + basicModel.markNoData(); + } basicModel.setResult(resultMap); mav.setModel(basicModel); } else { @@ -802,7 +1174,8 @@ public class AddrSvcController { } else { try { //Èç¹ûÊǽ­ËÕÊ¡»òÕßÕã½­Ê¡ µ÷ÓÃÆëÁºµÄ½á¹û - if ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province"))) { +// if ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province"))) { + if (result.containsKey("province") && ("Öйú".equals(result.getString("province")))) { //½á¹û±È½Ï£¬Èç¹ûɿũ½á¹û²»Ò»Ö //µ÷ÓÃÆëÁº type £º1 ¶Ô¹« 0 ¶Ô˽ 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 index 1abcab0fa..e0d0fddff 100644 --- 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 @@ -1,9 +1,8 @@ package com.fangjia.open.controllers; import com.fangjia.core.util.*; -import com.fangjia.dal.mongo.model.AdministrativeDivision; import com.fangjia.dal.common.DistrictKey; -import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.AdministrativeDivision; import com.fangjia.dal.mongo.model.ApiUserCfg; import com.fangjia.dal.mongo.model.DistrictFacilitys; import com.fangjia.dal.mongo.model.Evaluation; @@ -17,7 +16,10 @@ 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.model.BasicModel; +import com.fangjia.open.model.HouseInfomationModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.open.util.CommonUtils; import com.fangjia.open.ws.query.SampleQuery; @@ -26,9 +28,13 @@ 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.CzbankSampleService; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.datastore.OpenApiLogService; import com.fangjia.service.datastore.bean.CollateralSampleQueryBean; -import com.fangjia.service.district.*; +import com.fangjia.service.district.DistrictFacilitysService; +import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.mongo.bkoff.HouseLoudongService; import com.fangjia.service.mongo.bkoff.LoudongService; import com.fangjia.service.mongo.fangjia.*; @@ -90,6 +96,8 @@ public class ComprehensiveQueryController { private EvaluateRatioService evaluateRatioService; + private AdministrativeMappingService administrativeMappingService; + private static final int EVALUATE_SHOW_DETAIL = 1; private static final Map PROPERTY_TYPES = new HashMap() { { @@ -226,38 +234,43 @@ public class ComprehensiveQueryController { } String cityStr = model.getCity(); - if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+")) { - AdministrativeDivision administrativeDivision = administrativeDivisionService.findcityByCode(cityStr); - if(administrativeDivision == null){ + String districtStr = model.getDistrict(); + String cityShort = model.getCity(); + if (StringUtils.isNotBlank(cityStr) && cityStr.matches("\\d+") && StringUtils.isBlank(districtStr)) { + cityShort = administrativeMappingService.findCityShortByCityCode(cityStr); + if (StringUtils.isBlank(cityShort)) { mav.setModel(BasicModel.buildBadRequestModel("³ÇÊдúÂë´íÎó")); return mav; } - String city = administrativeDivision.getCityShort(); - if (StringUtils.isBlank(city)) { - mav.setModel(BasicModel.buildBadRequestModel("³ÇÊдúÂë´íÎó")); + } else if (StringUtils.isNotBlank(districtStr) && districtStr.matches("\\d+")) { + cityShort = administrativeMappingService.findDistrictShortByDistrictCode(cityStr, districtStr); + if (StringUtils.isBlank(cityShort)) { + mav.setModel(BasicModel.buildBadRequestModel("ÇøÏØ´úÂë´íÎó")); return mav; } - model.setCity(city); } + model.setCity(cityShort); 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("category", "district"); communityAvgPriceParams.put("useMap", "true"); communityAvgPriceParams.put("suggestName", String.valueOf(model.getName())); - communityAvgPriceParams.put("preciseLevel", "strict"); +// communityAvgPriceParams.put("preciseLevel", "strict"); communityAvgPriceParams.put("propertyType", model.getPropertyType()); communityAvgPriceParams.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"); JSONObject matchResponse = null; try { matchResponse = httpRequest.getJsonContent("http://open.fangjia.com/address/match", communityAvgPriceParams, "UTF-8"); // matchResponse = httpRequest.getJsonContent("http://192.168.0.19:31080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8"); - } catch (HttpRequestException e) { + } catch ( + HttpRequestException e) { } + // È¥µô¾­Î³¶È½âÎö // if (matchResponse == null || !matchResponse.containsKey("result") || !matchResponse.getJSONObject("result").containsKey("id")) { // //¼ÓÉϸߵ»ñÈ¡¾­Î³¶È ºÍ ¸ù¾Ý¾­Î³¶È¹ÀÖµ @@ -289,16 +302,18 @@ public class ComprehensiveQueryController { // return mav; // } JSONObject result = matchResponse.getJSONObject("result"); - if(!result.containsKey("id")){ + if (!result.containsKey("id")) { mav.setModel(BasicModel.buildBadRequestModel("¸ÃµØÖ·²»Ö§³Ö¹À¼Û£¡")); return mav; } - String id = matchResponse.getJSONObject("result") .getString("id"); + + 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) { @@ -350,7 +365,8 @@ public class ComprehensiveQueryController { propertyEvaluationModel.setName(district.getName()); try { evaluateAction(propertyEvaluationModel, httpServletRequest, houseValueInformation, mav); - } catch (IllegalAccessException e) { + } catch ( + IllegalAccessException e) { } // ¼Û¸ñϵ÷10% @@ -370,17 +386,19 @@ public class ComprehensiveQueryController { sampleQuery.setStrctureArea(model.getSize()); sampleQuery.setAddress(model.getAddress()); -// RestfulModelAndView houseCaseMav = new RestfulModelAndView(); + // RestfulModelAndView houseCaseMav = new RestfulModelAndView(); List querys = null; try { querys = convertSampileQueryToBean(district, sampleQuery); - } catch (Exception e) { + } 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.findSampleForBse(querys, sampleQuery.getMax()); @@ -416,9 +434,25 @@ public class ComprehensiveQueryController { // Ô­ÖܱßPOI DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(district); + if (facilitys != null) { + List hospitalList = facilitys.getHospital(); + List hospitals = new ArrayList(); + if (hospitalList != null && !hospitalList.isEmpty()) { + for (String hospital : hospitalList) { + if (hospital.endsWith("Ò½Ôº")) { + hospitals.add(hospital); + } + } + } + facilitys.setHospital(hospitals); + } else { + facilitys = new DistrictFacilitys(); + } // ½«ÖܱßPOIÊý¾Ý·Åµ½½á¹û¼¯ houseValueInformation.setSurroundingPoi(facilitys); - mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); + mav.setModel(BasicModel.buildOKModel(). + + setResult(houseValueInformation)); return mav; } @@ -739,54 +773,10 @@ public class ComprehensiveQueryController { districtPriceMap.put("city", district.getCity()); districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("name", district.getName()); - districtPriceMap.put("totalPrice", evaluation.getBigTotalPrice()); - if (evaluation.getAvgPrice2b() != null && evaluation.getAvgPrice2b() != 0) { - districtPriceMap.put("avgPrice", evaluation.getAvgPrice2b()); - } else { - 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()); - } + // ¹ÀÖµÖÐÒѾ­È¡¹ýÆÀ¹À2B¼Û¸ñ£¬ÇÒ¾­¹ýϵÊýµ÷Õû£¬²»ÄÜÔÚ¸²¸Ç + districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); + Long totalPrice = new BigDecimal((Integer) districtPriceMap.get("avgPrice")).multiply(new BigDecimal(evaluation.getArea())).longValue(); + districtPriceMap.put("totalPrice", totalPrice); if (model.getScope() == EVALUATE_SHOW_DETAIL) { districtPriceMap.put("evaluateWay", evaluation.getEvaluateWay()); @@ -804,7 +794,10 @@ public class ComprehensiveQueryController { } catch (Exception e) { e.printStackTrace(); } - + // ¸ù¾Ýµ¥¼ÛÖØÐ¼ÆËã×Ü¼Û + Integer avgPrice = (Integer) districtPriceMap.get("avgPrice"); + totalPrice = new BigDecimal(avgPrice).multiply(new BigDecimal(evaluation.getArea())).longValue(); + districtPriceMap.put("totalPrice", totalPrice); return mav; } else { evaluationService.remove(evaluation.getId()); @@ -1415,5 +1408,9 @@ public class ComprehensiveQueryController { public void setAdministrativeDivisionService(AdministrativeDivisionService administrativeDivisionService) { this.administrativeDivisionService = administrativeDivisionService; } + + public void setAdministrativeMappingService(AdministrativeMappingService administrativeMappingService) { + this.administrativeMappingService = administrativeMappingService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java index 90bd877e3..28559ace3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java @@ -10,8 +10,8 @@ import com.fangjia.core.util.DateUtil; import com.fangjia.core.util.HttpRequest; import com.fangjia.dal.mongo.model.*; import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; -import com.fangjia.open.model.AvgPriceQueryModel; -import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.*; +import com.fangjia.open.model.weixin.DistrictModel; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.service.datastore.RegionStatService; import com.fangjia.service.district.DistrictFacilitysService; @@ -20,6 +20,7 @@ import com.fangjia.service.district.RegionStatRentService; import com.fangjia.service.mongo.fangjia.AverageAnalyService; import com.fangjia.service.mongo.fangjia.RegionBlockService; +import com.fangjia.service.mongo.fangjia.SeaweedImagesService; import net.sf.json.JSONArray; import net.sf.json.JSONException; import net.sf.json.JSONObject; @@ -56,8 +57,6 @@ import com.fangjia.open.dto.NewDistrictDto; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.DistrictSearchModel; -import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.service.api.AutoCompleteService; import com.fangjia.service.api.CategoryEnum; import com.fangjia.service.api.KnowbaseService; @@ -77,654 +76,655 @@ import com.fangjia.service.web.MenuService; /** * Ð¡Çø½Ó¿Ú - * + * * @author velna - * */ @Authority(role = Role.USER) public class DistrictController { - private DistrictService districtService; - private MenuService menuService; - private DistrictStatService districtStatService; - private DistrictHouseService districtHouseService; - private AutoCompleteService autoCompleteService; - private KnowbaseService knowbaseService; - private ApiUserService apiUserService; - private ExtractDistrictService extractDistrictService; + private DistrictService districtService; + private MenuService menuService; + private DistrictStatService districtStatService; + private DistrictHouseService districtHouseService; + private AutoCompleteService autoCompleteService; + private KnowbaseService knowbaseService; + private ApiUserService apiUserService; + private ExtractDistrictService extractDistrictService; private RegionBlockService regionBlockService; private RegionStatService regionStatService; private RegionStatRentService regionStatRentService; - private DistrictFacilitysService districtFacilitysService; - + private DistrictFacilitysService districtFacilitysService; + private SeaweedImagesService seaweedImagesService; - public static final String[] COLUMNS = { "id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", - "householdCount", "address", "city", "region", "block", "alias", "lat", "lng", "lat2", "lng2", "finishBuildingDate", - "description", "kind", "carSite", "estateCharge", "cubagePercent", "virescencePercent", "estateCompany", "developer", - "facilities", "traffic", "loopLineInfo", "houseProperty", "buildStructure", "openDate", "sellAddress", "discount", - "fitmentMaterials", "floorInfo", "creationDate", "modificationDate" }; - public Object searchAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - @Param(name = "cat") String cat, @Param(name = "limit") int limit) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ËùÔÚ³ÇÊбØÐëÊäÈë")); - } + public static final String[] COLUMNS = {"id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", + "householdCount", "address", "city", "region", "block", "alias", "lat", "lng", "lat2", "lng2", "finishBuildingDate", + "description", "kind", "carSite", "estateCharge", "cubagePercent", "virescencePercent", "estateCompany", "developer", + "facilities", "traffic", "loopLineInfo", "houseProperty", "buildStructure", "openDate", "sellAddress", "discount", + "fitmentMaterials", "floorInfo", "creationDate", "modificationDate"}; - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "¹Ø¼ü×Ö±ØÐëÊäÈë")); - } + public Object searchAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + @Param(name = "cat") String cat, @Param(name = "limit") int limit) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ËùÔÚ³ÇÊбØÐëÊäÈë")); + } - List districts = this.districtService.searchByKeyword(cat, city, keyword, limit); + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "¹Ø¼ü×Ö±ØÐëÊäÈë")); + } - List> result = new ArrayList>(); + List districts = this.districtService.searchByKeyword(cat, city, keyword, limit); - for (District district : districts) { - Map resMap = new HashMap(); - resMap.put("_id", district.getId()); - resMap.put("city", district.getCity()); - resMap.put("region", district.getRegion()); - resMap.put("block", district.getBlock()); - resMap.put("districtName", district.getName()); - resMap.put("address", district.getAddress()); - resMap.put("category", district.getCategory()); - result.add(resMap); - } + List> result = new ArrayList>(); - mav.setModel(result); - return mav; - } + for (District district : districts) { + Map resMap = new HashMap(); + resMap.put("_id", district.getId()); + resMap.put("city", district.getCity()); + resMap.put("region", district.getRegion()); + resMap.put("block", district.getBlock()); + resMap.put("districtName", district.getName()); + resMap.put("address", district.getAddress()); + resMap.put("category", district.getCategory()); + result.add(resMap); + } - public Object fetchByCityAction(@Param(name = "city") String city, @Param(name = "cat") final String cat, - @Param(name = "skip") Integer skip, @Param(name = "limit") Integer limit, - @Param(name = "lastUpdateTime") Long lastUpdateTime) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); - return mav; - } + mav.setModel(result); + return mav; + } - if (!"district".equals(cat) && !"new_district".equals(cat)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøÀàÐͱØÐëÊäÈëÕýÈ·")); - return mav; - } + public Object fetchByCityAction(@Param(name = "city") String city, @Param(name = "cat") final String cat, + @Param(name = "skip") Integer skip, @Param(name = "limit") Integer limit, + @Param(name = "lastUpdateTime") Long lastUpdateTime) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); + return mav; + } - skip = null == skip ? 0 : skip; - limit = null == limit ? 20 : limit; - System.out.println(new Date().getTime()); + if (!"district".equals(cat) && !"new_district".equals(cat)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøÀàÐͱØÐëÊäÈëÕýÈ·")); + return mav; + } - if (skip < 0 || skip > 1000000 || limit < 0 || limit > 10000) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ÇëÇóÊýÁ¿²ÎÊý²»ÕýÈ·")); - return mav; - } + skip = null == skip ? 0 : skip; + limit = null == limit ? 20 : limit; + System.out.println(new Date().getTime()); - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("category", cat)); - params.add(new QueryParam("visible", 0)); - if (null != lastUpdateTime) { - params.add(new QueryParam("modificationDate", QueryParam.GREATER_THAN_OPERATOR, new Date(lastUpdateTime))); - } + if (skip < 0 || skip > 1000000 || limit < 0 || limit > 10000) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ÇëÇóÊýÁ¿²ÎÊý²»ÕýÈ·")); + return mav; + } - Pager pager = new Pager(limit); - pager.setStartRow(skip); - List districtLists = districtService.findDistrictList(pager, params, COLUMNS); + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("category", cat)); + params.add(new QueryParam("visible", 0)); + if (null != lastUpdateTime) { + params.add(new QueryParam("modificationDate", QueryParam.GREATER_THAN_OPERATOR, new Date(lastUpdateTime))); + } - List districtDtos = org.sothis.core.util.CollectionUtils.collect(districtLists, - new Closure() { - public DistrictDto execute(District obj) { - DistrictBo bo = new DistrictBo(obj); - DistrictDto ret = null; - if ("new_district".equals(cat)) { - ret = new NewDistrictDto(bo, true); - } else { - ret = new DistrictDto(bo, true); - } - ret.setAlias(obj.getAlias()); - return ret; - } - }); + Pager pager = new Pager(limit); + pager.setStartRow(skip); + List districtLists = districtService.findDistrictList(pager, params, COLUMNS); - mav.setModel(districtDtos); - return mav; - } + List districtDtos = org.sothis.core.util.CollectionUtils.collect(districtLists, + new Closure() { + public DistrictDto execute(District obj) { + DistrictBo bo = new DistrictBo(obj); + DistrictDto ret = null; + if ("new_district".equals(cat)) { + ret = new NewDistrictDto(bo, true); + } else { + ret = new DistrictDto(bo, true); + } + ret.setAlias(obj.getAlias()); + return ret; + } + }); - /** - * ¸ù¾Ý³ÇÊк͹ؼü´ÊÈ¡Ð¡Çø - * - * @param city - * @param keyword - * @param request - * @return - */ - public Object fetchByKeywordAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); - return mav; - } - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "¹Ø¼ü´Ê±ØÐëÊäÈë")); - return mav; - } - List districtNames = autoCompleteService.suggestDistrict(keyword, city, 10); - if (CollectionUtils.isNotEmpty(districtNames)) { - DistrictDto districtDto = null; - for (String districtName : districtNames) { - DistrictQueryBean queryBean = new DistrictQueryBean(); - queryBean.setCity(city); - queryBean.setCategory("district"); - queryBean.setName(districtName); - List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); - if (CollectionUtils.isNotEmpty(districtBos)) { - DistrictBo bo = districtBos.get(0); - if ("district".equals(bo.getCategory())) { - districtDto = new DistrictDto(bo, isSupportLatLng(request)); - } else { - districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); - } - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - break; - } - } - if (null != districtDto) { - mav.setModel(districtDto); - } - } - return mav; - } + mav.setModel(districtDtos); + return mav; + } - /** - * ¸ù¾Ý¹Ø¼ü´ÊÈ¡Ð¡Çø - * - * @param city - * @param keyword - * @param request - * @return - */ - public Object fetchSimpleAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "¹Ø¼ü´Ê±ØÐëÊäÈë")); - return mav; - } + /** + * ¸ù¾Ý³ÇÊк͹ؼü´ÊÈ¡Ð¡Çø + * + * @param city + * @param keyword + * @param request + * @return + */ + public Object fetchByKeywordAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); + return mav; + } + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "¹Ø¼ü´Ê±ØÐëÊäÈë")); + return mav; + } + List districtNames = autoCompleteService.suggestDistrict(keyword, city, 10); + if (CollectionUtils.isNotEmpty(districtNames)) { + DistrictDto districtDto = null; + for (String districtName : districtNames) { + DistrictQueryBean queryBean = new DistrictQueryBean(); + queryBean.setCity(city); + queryBean.setCategory("district"); + queryBean.setName(districtName); + List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); + if (CollectionUtils.isNotEmpty(districtBos)) { + DistrictBo bo = districtBos.get(0); + if ("district".equals(bo.getCategory())) { + districtDto = new DistrictDto(bo, isSupportLatLng(request)); + } else { + districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); + } + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + break; + } + } + if (null != districtDto) { + mav.setModel(districtDto); + } + } + return mav; + } - ServerArea serverArea = ServerAreaData.getServerAreaByDisplayDefaultNull(city); - if (serverArea == null) { - serverArea = ServerAreaData.getServerAreaBySpellDefaultNull(city); - if (null == serverArea) { - serverArea = ServerAreaData.valueOfName(city); - } - } + /** + * ¸ù¾Ý¹Ø¼ü´ÊÈ¡Ð¡Çø + * + * @param city + * @param keyword + * @param request + * @return + */ + public Object fetchSimpleAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "¹Ø¼ü´Ê±ØÐëÊäÈë")); + return mav; + } - List districtNames = autoCompleteService.suggestDistrict(keyword, serverArea.getDisplay(), 10); - if (CollectionUtils.isNotEmpty(districtNames)) { - List> ret = new ArrayList>(10); - for (String districtName : districtNames) { - DistrictQueryBean queryBean = new DistrictQueryBean(); - queryBean.setCity(serverArea.getDisplay()); - queryBean.setCategory("district"); - queryBean.setName(districtName); - List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); - if (CollectionUtils.isNotEmpty(districtBos)) { - DistrictKey key = districtBos.get(0).getDistrictKey(); - Map info = new HashMap(3); - info.put("city", serverArea.getDisplay()); - info.put("region", key.getRegion()); - info.put("name", key.getName()); - ret.add(info); - } - } - if (ret.size() > 0) { - mav.setModel(ret); - } - } - return mav; - } + ServerArea serverArea = ServerAreaData.getServerAreaByDisplayDefaultNull(city); + if (serverArea == null) { + serverArea = ServerAreaData.getServerAreaBySpellDefaultNull(city); + if (null == serverArea) { + serverArea = ServerAreaData.valueOfName(city); + } + } - /** - * Ð¡ÇøËÑË÷ - * - * @return - */ - public Object listAction(DistrictSearchModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); - return mav; - } - Pager pager = new Pager(); - int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); - int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); - if (model.getPageSize() != null && model.getPageSize() > 0) { - pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); - } else { - pager.setPageSize(20); - } - if (model.getPageIndex() != null && model.getPageIndex() > 1) { - int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); - int startRow = (pageIndex - 1) * pager.getPageSize(); - pager.setStartRow(startRow); - } - // ÊÇ·ñÊäÈë°ë¾¶²éѯ£¬ÆäËûÇé¿öÖ±½Ómoedel²éѯ¼´¿É - if (isRadiusSearch(model)) { - Long lng = model.getLng(); - Long lat = model.getLat(); + List districtNames = autoCompleteService.suggestDistrict(keyword, serverArea.getDisplay(), 10); + if (CollectionUtils.isNotEmpty(districtNames)) { + List> ret = new ArrayList>(10); + for (String districtName : districtNames) { + DistrictQueryBean queryBean = new DistrictQueryBean(); + queryBean.setCity(serverArea.getDisplay()); + queryBean.setCategory("district"); + queryBean.setName(districtName); + List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); + if (CollectionUtils.isNotEmpty(districtBos)) { + DistrictKey key = districtBos.get(0).getDistrictKey(); + Map info = new HashMap(3); + info.put("city", serverArea.getDisplay()); + info.put("region", key.getRegion()); + info.put("name", key.getName()); + ret.add(info); + } + } + if (ret.size() > 0) { + mav.setModel(ret); + } + } + return mav; + } - model.setLng(lng); - model.setLat(lat); + /** + * Ð¡ÇøËÑË÷ + * + * @return + */ + public Object listAction(DistrictSearchModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); + return mav; + } + Pager pager = new Pager(); + int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); + int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); + } else { + pager.setPageSize(20); + } + if (model.getPageIndex() != null && model.getPageIndex() > 1) { + int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); + int startRow = (pageIndex - 1) * pager.getPageSize(); + pager.setStartRow(startRow); + } + // ÊÇ·ñÊäÈë°ë¾¶²éѯ£¬ÆäËûÇé¿öÖ±½Ómoedel²éѯ¼´¿É + if (isRadiusSearch(model)) { + Long lng = model.getLng(); + Long lat = model.getLat(); - Long lngMin = (lng - (model.getRadius() * 100000L)); - model.setLngMin(lngMin); - Long lngMax = (lng + (model.getRadius() * 100000L)); - model.setLngMax(lngMax); - Long latMin = (lat - (model.getRadius() * 100000L)); - model.setLatMin(latMin); - Long latMax = (lat + (model.getRadius() * 100000L)); - model.setLatMax(latMax); + model.setLng(lng); + model.setLat(lat); - model.setRegion(null); - model.setName(null); - } else if (model.getLatA() != null && model.getLatB() != null && model.getLngA() != null && model.getLngB() != null) { - Long lngMin = Math.min(model.getLngA(), model.getLngB()); - Long lngMax = Math.max(model.getLngA(), model.getLngB()); - Long latMin = Math.min(model.getLatA(), model.getLatB()); - Long latMax = Math.max(model.getLatA(), model.getLatB()); + Long lngMin = (lng - (model.getRadius() * 100000L)); + model.setLngMin(lngMin); + Long lngMax = (lng + (model.getRadius() * 100000L)); + model.setLngMax(lngMax); + Long latMin = (lat - (model.getRadius() * 100000L)); + model.setLatMin(latMin); + Long latMax = (lat + (model.getRadius() * 100000L)); + model.setLatMax(latMax); - model.setLngMin(lngMin); - model.setLngMax(lngMax); - model.setLatMin(latMin); - model.setLatMax(latMax); - } - Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, - getCurrentParams(), 1); - FacetQueryResult result; - if (StringUtils.isBlank(model.getKeyword())) { - result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), "bscore", - false, false); - } else { - result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), null, false, - false); - } - Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); - FacetQueryResult districtList = new FacetQueryResult(result.size()); - for (District district : result) { - DistrictBo districtBo = new DistrictBo(district); - districtBo.setStat(statMap.get(district.getDistrictKey())); - districtList.add(districtBo); - } - districtList.setNumberFound(result.getNumberFound()); + model.setRegion(null); + model.setName(null); + } else if (model.getLatA() != null && model.getLatB() != null && model.getLngA() != null && model.getLngB() != null) { + Long lngMin = Math.min(model.getLngA(), model.getLngB()); + Long lngMax = Math.max(model.getLngA(), model.getLngB()); + Long latMin = Math.min(model.getLatA(), model.getLatB()); + Long latMax = Math.max(model.getLatA(), model.getLatB()); - FacetQueryResult districtDtos = new FacetQueryResult(); - for (DistrictBo bo : districtList) { - DistrictDto districtDto = null; - if ("district".equals(bo.getCategory())) { - districtDto = new DistrictDto(bo, isSupportLatLng(request)); - } else { - districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); - } - if (StringUtils.isNotBlank(model.getHouseCountType())) { - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - if (CategoryEnum.sell.name().equals(model.getHouseCountType())) { - districtDto.setSellCount(dh.getSellCount()); - } else if (CategoryEnum.rent.name().equals(model.getHouseCountType())) { - districtDto.setRentCount(dh.getRentCount()); - } - } - } - // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ - List outPics = bo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // ±ê־ͼȡÖмäÒ»ÕÅ - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "s", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDtos.add(districtDto); - } - districtDtos.setNumberFound(districtList.getNumberFound()); - mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); - return mav; - } + model.setLngMin(lngMin); + model.setLngMax(lngMax); + model.setLatMin(latMin); + model.setLatMax(latMax); + } + Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, + getCurrentParams(), 1); + FacetQueryResult result; + if (StringUtils.isBlank(model.getKeyword())) { + result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), "bscore", + false, false); + } else { + result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), null, false, + false); + } + Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); + FacetQueryResult districtList = new FacetQueryResult(result.size()); + for (District district : result) { + DistrictBo districtBo = new DistrictBo(district); + districtBo.setStat(statMap.get(district.getDistrictKey())); + districtList.add(districtBo); + } + districtList.setNumberFound(result.getNumberFound()); - private Map getCurrentParams() { - Map paramMap = ActionContext.getContext().getParameters(); - Map ret = new HashMap(); + FacetQueryResult districtDtos = new FacetQueryResult(); + for (DistrictBo bo : districtList) { + DistrictDto districtDto = null; + if ("district".equals(bo.getCategory())) { + districtDto = new DistrictDto(bo, isSupportLatLng(request)); + } else { + districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); + } + if (StringUtils.isNotBlank(model.getHouseCountType())) { + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + if (CategoryEnum.sell.name().equals(model.getHouseCountType())) { + districtDto.setSellCount(dh.getSellCount()); + } else if (CategoryEnum.rent.name().equals(model.getHouseCountType())) { + districtDto.setRentCount(dh.getRentCount()); + } + } + } + // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ + List outPics = bo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // ±ê־ͼȡÖмäÒ»ÕÅ + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "s", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDtos.add(districtDto); + } + districtDtos.setNumberFound(districtList.getNumberFound()); + mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); + return mav; + } - for (String key : paramMap.keySet()) { - Object[] obj = paramMap.get(key); - if (obj != null && obj.length > 0) { - ret.put(key, obj[0].toString()); - } - } - return ret; - } + private Map getCurrentParams() { + Map paramMap = ActionContext.getContext().getParameters(); + Map ret = new HashMap(); - /** - * ÊÇ·ñ¿ÉÒÔÌṩ¾­Î³¶È - * - * @param request - * @return - */ - private boolean isSupportLatLng(HttpServletRequest request) { - AuthenticationBean bean = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); - if (null != bean) { - if (null != bean.auth) { - return bean.auth.isSupportLatLng(); - } - } - return false; - } + for (String key : paramMap.keySet()) { + Object[] obj = paramMap.get(key); + if (obj != null && obj.length > 0) { + ret.put(key, obj[0].toString()); + } + } + return ret; + } - /** - * Ð¡ÇøÏêÇé - * - * @return - */ - public Object showAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃû,ËùÔÚÇøÓò±Ø±ØÐëÊäÈë")); - return mav; - } else { - DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(city, region, name)); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ£¬Çë¼ì²é²éѯÌõ¼þ")); - return mav; - } - districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); - // È¥³ýÐ¡ÇøÃèÊöÖеÄhtml±êÇ© - districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); - DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ£¬ÈôÎÞÍ⾰ͼÔòÎÞͼƬ£¬È¡Ç°5ÕÅ - List outPics = districtBo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // ±ê־ͼȡÖмäÒ»ÕÅ - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "o", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" - + name + "-" + region); - mav.setModel(districtDto); - return mav; - } - } + /** + * ÊÇ·ñ¿ÉÒÔÌṩ¾­Î³¶È + * + * @param request + * @return + */ + private boolean isSupportLatLng(HttpServletRequest request) { + AuthenticationBean bean = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + if (null != bean) { + if (null != bean.auth) { + return bean.auth.isSupportLatLng(); + } + } + return false; + } - /** - * ÖÇÄܽâÎöÐ¡ÇøÏêÇé - * - * @return - */ - public Object showDetailAction(DistrictSearchModel model, @Param(name = "city") String city, - @Param(name = "region") String region, @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃû,ËùÔÚÇøÓò±Ø±ØÐëÊäÈë")); - return mav; - } - city = knowbaseService.matchingCityDefaultNull(city); - region = knowbaseService.matchingRegionDefaultNull(region, city); - if (null == city || null == region) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøËùÔÚ³ÇÊлòËùÔÚÇøÓò²»´æÔÚ")); - return mav; - } - District tempDistrict = null; - Map konwbase = knowbaseService.parseWord(name); - List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase - .get("district_name") : Collections.EMPTY_LIST; - if (CollectionUtils.isNotEmpty(districts)) { - for (Map district : districts) { - Map extra_data = (Map) district.get("extra_data"); - if (MapUtils.isNotEmpty(extra_data)) { - region = (String) extra_data.get("region"); - name = (String) district.get("value"); - String tempCity = (String) extra_data.get("city"); - if (null == city && tempCity != null) { - city = tempCity; - } else if (tempCity == null || (tempCity != null && !tempCity.equals(city))) { - continue; - } - District d = districtService.findDistrict(new DistrictKey(city, region, name), false); - if (null == d) { - continue; - } - tempDistrict = d; - break; - } - } - } - if (null == tempDistrict) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ£¬Çë¼ì²é²éѯÌõ¼þ")); - return mav; - } - DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(tempDistrict.getCity(), tempDistrict.getRegion(), - tempDistrict.getName())); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ£¬Çë¼ì²é²éѯÌõ¼þ")); - return mav; - } - districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); - // È¥³ýÐ¡ÇøÃèÊöÖеÄhtml±êÇ© - districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); - DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } + /** + * Ð¡ÇøÏêÇé + * + * @return + */ + public Object showAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃû,ËùÔÚÇøÓò±Ø±ØÐëÊäÈë")); + return mav; + } else { + DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(city, region, name)); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ£¬Çë¼ì²é²éѯÌõ¼þ")); + return mav; + } + districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); + // È¥³ýÐ¡ÇøÃèÊöÖеÄhtml±êÇ© + districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); + DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ£¬ÈôÎÞÍ⾰ͼÔòÎÞͼƬ£¬È¡Ç°5ÕÅ + List outPics = districtBo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // ±ê־ͼȡÖмäÒ»ÕÅ + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "o", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" + + name + "-" + region); + mav.setModel(districtDto); + return mav; + } + } - // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ£¬ÈôÎÞÍ⾰ͼÔòÎÞͼƬ£¬È¡Ç°5ÕÅ - List outPics = districtBo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // ±ê־ͼȡÖмäÒ»ÕÅ - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "o", "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" - + name + "-" + region); - mav.setModel(districtDto); - return mav; - } + /** + * ÖÇÄܽâÎöÐ¡ÇøÏêÇé + * + * @return + */ + public Object showDetailAction(DistrictSearchModel model, @Param(name = "city") String city, + @Param(name = "region") String region, @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃû,ËùÔÚÇøÓò±Ø±ØÐëÊäÈë")); + return mav; + } + city = knowbaseService.matchingCityDefaultNull(city); + region = knowbaseService.matchingRegionDefaultNull(region, city); + if (null == city || null == region) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøËùÔÚ³ÇÊлòËùÔÚÇøÓò²»´æÔÚ")); + return mav; + } + District tempDistrict = null; + Map konwbase = knowbaseService.parseWord(name); + List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase + .get("district_name") : Collections.EMPTY_LIST; + if (CollectionUtils.isNotEmpty(districts)) { + for (Map district : districts) { + Map extra_data = (Map) district.get("extra_data"); + if (MapUtils.isNotEmpty(extra_data)) { + region = (String) extra_data.get("region"); + name = (String) district.get("value"); + String tempCity = (String) extra_data.get("city"); + if (null == city && tempCity != null) { + city = tempCity; + } else if (tempCity == null || (tempCity != null && !tempCity.equals(city))) { + continue; + } + District d = districtService.findDistrict(new DistrictKey(city, region, name), false); + if (null == d) { + continue; + } + tempDistrict = d; + break; + } + } + } + if (null == tempDistrict) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ£¬Çë¼ì²é²éѯÌõ¼þ")); + return mav; + } + DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(tempDistrict.getCity(), tempDistrict.getRegion(), + tempDistrict.getName())); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ£¬Çë¼ì²é²éѯÌõ¼þ")); + return mav; + } + districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); + // È¥³ýÐ¡ÇøÃèÊöÖеÄhtml±êÇ© + districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); + DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } - public Object showListAction(DistrictSearchModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); - return mav; - } - Pager pager = new Pager(); - int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); - int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); - if (model.getPageSize() != null && model.getPageSize() > 0) { - pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); - } else { - pager.setPageSize(20); - } - if (model.getPageIndex() != null && model.getPageIndex() > 1) { - int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); - int startRow = (pageIndex - 1) * pager.getPageSize(); - pager.setStartRow(startRow); - } - FacetQueryResult result; - if (StringUtils.isBlank(model.getKeyword())) { - result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); - } else { - result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); - } - Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); - FacetQueryResult districtList = new FacetQueryResult(result.size()); - for (District district : result) { - DistrictBo districtBo = new DistrictBo(district); - districtBo.setStat(statMap.get(district.getDistrictKey())); - districtList.add(districtBo); - } - districtList.setNumberFound(result.getNumberFound()); + // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ£¬ÈôÎÞÍ⾰ͼÔòÎÞͼƬ£¬È¡Ç°5ÕÅ + List outPics = districtBo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // ±ê־ͼȡÖмäÒ»ÕÅ + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "o", "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" + + name + "-" + region); + mav.setModel(districtDto); + return mav; + } - FacetQueryResult districtDtos = new FacetQueryResult(); - for (DistrictBo bo : districtList) { - DistrictDto districtDto = new DistrictDto(bo, isSupportLatLng(request)); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ - List outPics = bo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // ±ê־ͼȡÖмäÒ»ÕÅ - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "s", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setDescription(null); - districtDtos.add(districtDto); - } - districtDtos.setNumberFound(districtList.getNumberFound()); - mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); - return mav; - } + public Object showListAction(DistrictSearchModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊбØÐëÊäÈë")); + return mav; + } + Pager pager = new Pager(); + int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); + int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); + } else { + pager.setPageSize(20); + } + if (model.getPageIndex() != null && model.getPageIndex() > 1) { + int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); + int startRow = (pageIndex - 1) * pager.getPageSize(); + pager.setStartRow(startRow); + } + FacetQueryResult result; + if (StringUtils.isBlank(model.getKeyword())) { + result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); + } else { + result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); + } + Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); + FacetQueryResult districtList = new FacetQueryResult(result.size()); + for (District district : result) { + DistrictBo districtBo = new DistrictBo(district); + districtBo.setStat(statMap.get(district.getDistrictKey())); + districtList.add(districtBo); + } + districtList.setNumberFound(result.getNumberFound()); + + FacetQueryResult districtDtos = new FacetQueryResult(); + for (DistrictBo bo : districtList) { + DistrictDto districtDto = new DistrictDto(bo, isSupportLatLng(request)); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + // Èô´æÔÚÍ⾰ͼÔòÖ»¿¼ÂÇÍ⾰ͼ + List outPics = bo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // ±ê־ͼȡÖмäÒ»ÕÅ + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "s", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setDescription(null); + districtDtos.add(districtDto); + } + districtDtos.setNumberFound(districtList.getNumberFound()); + mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); + return mav; + } /** * Ð¡Çø¾ù¼Û²éѯ½Ó¿Ú + * * @param model * @return */ - public Object avgPriceAction(AvgPriceQueryModel model){ + public Object avgPriceAction(AvgPriceQueryModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { mav.setModel(BasicModel.buildBadRequestModel("²ÎÊýȱʧ:city(³ÇÊÐ),district(ÇøÓò)ÊDZØÐë²ÎÊý")); return mav; } - if(!RegionData.isCity(model.getCity())){ - String city = RegionData.formatCity(model.getCity()); - if(null == city){ - mav.setModel(BasicModel.buildBadRequestModel("·Ç·¨³ÇÊÐ:" + model.getCity())); - return mav; - }else{ - model.setCity(city); - } - } + if (!RegionData.isCity(model.getCity())) { + String city = RegionData.formatCity(model.getCity()); + if (null == city) { + mav.setModel(BasicModel.buildBadRequestModel("·Ç·¨³ÇÊÐ:" + model.getCity())); + return mav; + } else { + model.setCity(city); + } + } String region = RegionData.formatRegion(model.getCity(), model.getDistrict()); model.setDistrict(region); - if(!RegionData.isRegion(model.getCity(), region)){ + if (!RegionData.isRegion(model.getCity(), region)) { mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); return mav; } - if(model.getPeriodCount() == null){ + if (model.getPeriodCount() == null) { model.setPeriodCount(1); } - if(model.getPeriodCount()< 1 || model.getPeriodCount()>156){ + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { mav.setModel(BasicModel.buildBadRequestModel("periodCountÖµ²»ºÏ·¨,ȡֵ·¶Î§ÊÇ£º[1-156]")); return mav; } - if(StringUtils.isBlank(model.getPeriodType())){ + if (StringUtils.isBlank(model.getPeriodType())) { model.setPeriodType("weekly"); - }else{ - if(!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())){ + } else { + if (!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())) { mav.setModel(BasicModel.buildBadRequestModel("periodModelÖµ·Ç·¨£¬ºÏ·¨ÖµÎª:weekly,monthly")); return mav; } } Calendar calendar = Calendar.getInstance(); - if("weekly".equals(model.getPeriodType())){ - calendar.add(Calendar.DATE, -model.getPeriodCount().intValue()*7); - }else{ + if ("weekly".equals(model.getPeriodType())) { + calendar.add(Calendar.DATE, -model.getPeriodCount().intValue() * 7); + } else { calendar.add(Calendar.MONTH, -model.getPeriodCount().intValue()); } - List regionStats = regionStatService.findRegionBlockStat(model.getCity(),model.getDistrict(),null,calendar.getTime(),new Date(),model.getPeriodType()); - if(regionStats.size() > model.getPeriodCount()){ - regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(),regionStats.size()); + List regionStats = regionStatService.findRegionBlockStat(model.getCity(), model.getDistrict(), null, calendar.getTime(), new Date(), model.getPeriodType()); + if (regionStats.size() > model.getPeriodCount()) { + regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(), regionStats.size()); } - List> result = new ArrayList>(model.getPeriodCount()); + List> result = new ArrayList>(model.getPeriodCount()); for (RegionStat regionStat : regionStats) { - Map item = new LinkedHashMap(); + Map item = new LinkedHashMap(); item.put("city", regionStat.getCity()); item.put("district", regionStat.getRegion()); item.put("block", regionStat.getBlock()); item.put("avgPrice", String.valueOf(regionStat.getAvgPrice())); - if("monthly".equals(model.getPeriodType())){ + if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM")); - }else{ + } else { item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM-dd")); } item.put("changePercent", String.valueOf(regionStat.getMarkup() / 100d)); @@ -733,53 +733,55 @@ public class DistrictController { mav.setModel(BasicModel.buildOKModel().setResult(result)); return mav; } + /** * ÇøÓò¾ù¼Û²éѯ½Ó¿Ú + * * @param model * @return */ - public Object rentAction(AvgPriceQueryModel model){ + public Object rentAction(AvgPriceQueryModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { mav.setModel(BasicModel.buildBadRequestModel("²ÎÊýȱʧ:city(³ÇÊÐ),district(ÇøÓò)ÊDZØÐë²ÎÊý")); return mav; } - if(!RegionData.isCity(model.getCity())){ - String city = RegionData.formatCity(model.getCity()); - if(null == city){ - mav.setModel(BasicModel.buildBadRequestModel("·Ç·¨³ÇÊÐ:" + model.getCity())); - return mav; - }else{ - model.setCity(city); - } - } + if (!RegionData.isCity(model.getCity())) { + String city = RegionData.formatCity(model.getCity()); + if (null == city) { + mav.setModel(BasicModel.buildBadRequestModel("·Ç·¨³ÇÊÐ:" + model.getCity())); + return mav; + } else { + model.setCity(city); + } + } String region = RegionData.formatRegion(model.getCity(), model.getDistrict()); model.setDistrict(region); - if(!RegionData.isRegion(model.getCity(), region)){ + if (!RegionData.isRegion(model.getCity(), region)) { mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); return mav; } - if (model.getHouseType() == null ||model.getHouseType() < 1) { + if (model.getHouseType() == null || model.getHouseType() < 1) { mav.setModel(BasicModel.buildBadRequestModel("·¿ÎÝÀàÐͲ»ºÏ·¨")); return mav; } - if(model.getPeriodCount() == null){ + if (model.getPeriodCount() == null) { model.setPeriodCount(1); } - if(model.getPeriodCount() < 1 || model.getPeriodCount() > 72){ + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 72) { mav.setModel(BasicModel.buildBadRequestModel("periodCountÖµ²»ºÏ·¨,ȡֵ·¶Î§ÊÇ£º[1-72]")); return mav; } - List regionStats = regionStatRentService.findAllByDistrictKeyAndHouseType(model.getCity(),model.getDistrict(),model.getHouseType(),model.getPeriodCount()); - if(regionStats.size() > model.getPeriodCount()){ - regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(),regionStats.size()); + List regionStats = regionStatRentService.findAllByDistrictKeyAndHouseType(model.getCity(), model.getDistrict(), model.getHouseType(), model.getPeriodCount()); + if (regionStats.size() > model.getPeriodCount()) { + regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(), regionStats.size()); } - List> result = new ArrayList>(model.getPeriodCount()); + List> result = new ArrayList>(model.getPeriodCount()); for (RegionStatRent regionStat : regionStats) { - Map item = new LinkedHashMap(); + Map item = new LinkedHashMap(); item.put("city", regionStat.getCity()); item.put("district", regionStat.getRegion()); item.put("rent", regionStat.getAvgPrice()); @@ -865,401 +867,542 @@ public class DistrictController { // mav.setModel(map); // return mav; // } - - - /** - * »ñÈ¡Ð¡ÇøµÄ¾ù¼ÛAction - * - * @param city - * @param region - * @param name - * @return - */ - public Object curAvgPriceAction(@Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,ËùÔÚÇøÓò,Ð¡ÇøÃûΪ±ØÌîÏî")); - return mav; - } - DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(city, region, name)); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡Çø²»´æÔÚ£¬Çë¼ì²é³ÇÊÐÃû,ÇøÓò,Ð¡ÇøÃû")); - return mav; - } - - - String kind = ""; - if(StringUtils.isNotBlank(districtBo.getEstateType2())){ - if(districtBo.getEstateType2().indexOf(DistrictKindEnum.bieshu.getValue())!=-1){ - kind = DistrictKindEnum.bieshu.getValue(); - } - if(districtBo.getEstateType2().indexOf("סլ")!=-1||districtBo.getEstateType2().indexOf("Ð¡Çø")!=-1){ - if(kind.length()>1){ - kind = kind + ","; - } - kind = kind + DistrictKindEnum.gongyu.getValue(); - } - districtBo.setKind(kind); - - } - if (StringUtils.isEmpty(districtBo.getKind())) { - districtBo.setKind(DistrictKindEnum.gongyu.getValue()); - } - - - String[] kinds = districtBo.getKind().split(","); - - List districtStatList = null; - List villaStatList = null; - Date date = new Date(); - if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { - villaStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.bieshu.getValue(), date, 1); - if (kinds.length > 1) { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, 1); - } - } else { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, 1); - } - if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¶ÔÓ¦µÄÐ¡ÇøÎÞ¾ù¼ÛÊý¾Ý")); - return mav; - } - - DistrictStat stat = null; - if(CollectionUtils.isNotEmpty(districtStatList)){ - stat = districtStatList.get(0); - } - if(CollectionUtils.isNotEmpty(villaStatList)){ - stat = villaStatList.get(0); - } - - Map map = new HashMap(1); - map.put("avgPrice", stat.getAvgPrice()); - map.put("weekendMarkup", stat.getWeekendMarkup()); - mav.setModel(map); - return mav; - } - - /** - * »ñÈ¡Ð¡ÇøµÄÀúÊ·¾ù¼ÛAction - * - * @param city - * @param region - * @param name - * @param weekCount - * @return - */ - public Object historyPriceAction(@Param(name = "city") String city, @Param(name = "name") String name, - @Param(name = "weekCount") Integer weekCount) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - int count = OfcChartUtils.YEAR_COUNT * 7; - if (null != weekCount && weekCount > 0) { - count = weekCount; - } - if (StringUtils.isBlank(name)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃûΪ±ØÌîÏî")); - return mav; - } - District currentDistrict = null; - city = knowbaseService.matchingCityDefaultNull(city); - if (StringUtils.isBlank(city)) { - city = "ÉϺ£"; - } - Map konwbase = knowbaseService.parseWord(name); - List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase - .get("district_name") : Collections.EMPTY_LIST; - if (CollectionUtils.isNotEmpty(districts)) { - for (Map district : districts) { - Map extra_data = (Map) district.get("extra_data"); - if (MapUtils.isNotEmpty(extra_data)) { - String region = (String) extra_data.get("region"); - name = (String) district.get("value"); - String tempCity = (String) extra_data.get("city"); - if (!city.equals(tempCity)) { - continue; - } - District d = districtService.findDistrict(new DistrictKey(city, region, name), false); - if (null == d) { - continue; - } - currentDistrict = d; - break; - } - } - } - - if (null == currentDistrict) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "δÕÒµ½Ïà¹ØÐ¡ÇøÐÅÏ¢")); - return mav; - } - - // ½âÎö³ö³ÇÊÐÇøÓòÐ¡ÇøÃûÂ¥¶°ºÅ - DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(currentDistrict.getCity(), currentDistrict - .getRegion(), currentDistrict.getName())); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡Çø²»´æÔÚ£¬Çë¼ì²é³ÇÊÐÃû,Ð¡ÇøÃû")); - return mav; - } - if (StringUtils.isEmpty(districtBo.getKind())) { - districtBo.setKind(DistrictKindEnum.gongyu.getValue()); - } - String[] kinds = districtBo.getKind().split(","); - List districtStatList = null; - List villaStatList = null; - Date date = new Date(); - if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { - villaStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.bieshu.getValue(), date, count); - if (kinds.length > 1) { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, count); - } - } else { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, count); - } - if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¶ÔÓ¦µÄÐ¡ÇøÎÞ¾ù¼ÛÊý¾Ý")); - return mav; - } - districtStatList = (List) OfcChartUtils.fixYDatas(date, districtStatList, count, null); - villaStatList = (List) OfcChartUtils.fixYDatas(date, villaStatList, count, null); - Map map = new HashMap(1); - map.put("stat", - DtoConverter.convertFromDistrictBoList(DataUtil.descCollection(districtStatList), - DataUtil.descCollection(villaStatList))); - mav.setModel(map); - return mav; - } - - /** - * ¸ù¾ÝÐ¡ÇøÃûµÈ»ñÈ¡Ð¡ÇøÊôÐÔ - * - * @param uniqueCodes - * @param districtNames - * @param regionNames - * @param cityNames - * @return - */ - public Object fetchDistrictsPropertiesAction(@Param(name = "uniqueCodes") String[] uniqueCodes, - @Param(name = "districtNames") String[] districtNames, @Param(name = "regionNames") String[] regionNames, - @Param(name = "cityNames") String[] cityNames) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - if (uniqueCodes.length * districtNames.length * regionNames.length * cityNames.length == 0) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøÎ¨Ò»Âë¡¢Ð¡ÇøÃû¡¢Ð¡ÇøËùÔÚÇøÓò¡¢Ð¡ÇøËùÔÚ³ÇÊбØÌî")); - return mav; - } - if (uniqueCodes.length - districtNames.length + regionNames.length - cityNames.length != 0) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøÎ¨Ò»ÂëÊý×é¡¢Ð¡ÇøÃûÊý×é¡¢Ð¡ÇøËùÔÚÇøÓòÊý×é¡¢Ð¡ÇøËùÔÚ³ÇÊÐÊý×éÊýÁ¿±ØÐëÏàͬ")); - return mav; - } - - ArrayList keys = new ArrayList(1); - Map key_uniqueCode = new HashMap(1); - for (int i = 0; i < cityNames.length; i++) { - cityNames[i] = this.knowbaseService.matchingCity(cityNames[i]); - regionNames[i] = this.knowbaseService.matchingRegion(regionNames[i], cityNames[i]); - DistrictKey key = new DistrictKey(cityNames[i], regionNames[i], districtNames[i]); - keys.add(key); - key_uniqueCode.put(key, uniqueCodes[i]); - } - Map districtMap = this.districtService.findDistrictByKeyList(keys, false); - Map newDistrictMap = this.districtService.findDistrictByKeyList(keys, true, false); - - Map dtoMap = new HashMap(1); - for (DistrictKey key : districtMap.keySet()) { - District d = districtMap.get(key); - if (null != d) { - String uniqueCode = key_uniqueCode.get(key); - DistrictsPropertiesDto dto = new DistrictsPropertiesDto(); - dto.setUniqueCode(uniqueCode); - dto.setDistrictName(d.getName()); - if (null != newDistrictMap.get(key)) { - dto.setNewDistrict(true); - if (d.getStatus() == 5) { - dto.setOnSale(true); - } - if (StringUtils.isNotBlank(d.getDiscount())) { - dto.setDiscount(true); - } - } - if (null == dto.getOnSale()) { - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(key); - if (dh != null && dh.getSellCount() != 0) { - dto.setOnSale(true); - } - } - if (StringUtils.isNotBlank(d.getVideoUrl())) { - dto.setVideo(true); - } - dtoMap.put(uniqueCode, dto); - } - } - mav.setModel(dtoMap); - return mav; - } - - private boolean isRadiusSearch(DistrictSearchModel model) { - return null != model.getRadius() && model.getRadius() > 0 && StringUtils.isNotBlank(model.getCity()) - && model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; - } - - public Object uploadAction(@Param(name = "token") String token, @Param(name = "data") String data) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - Map ret = new HashMap(1); - ret.put("RESULT", 500); - - ApiUser apiUser = checkNewAuthorized(token); - if (null == apiUser) { - return mav; - } - - try { - JSONArray disJsonArr = JSONArray.fromObject(data); - for (int i = 0; i < disJsonArr.size(); i++) { - JSONObject disJsonObj = disJsonArr.getJSONObject(i); - ExtractDistrict dis = (ExtractDistrict) JSONObject.toBean(disJsonObj, ExtractDistrict.class); - dis.setSource("open_api"); - dis.setUserId((int) apiUser.getId()); - dis.setCreationDate(new Date()); - dis.setModificationDate(dis.getCreationDate()); - extractDistrictService.save(dis); - } - } catch (JSONException e) { - return mav; - } - - ret.put("RESULT", 200); - return mav; - } - - public Object facilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃû,ËùÔÚÇøÓò±Ø±ØÐëÊäÈë")); - return mav; - } else { - District districtBo = districtService.findDistrict(new DistrictKey(city, region, name), "district"); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ")); - return mav; - } - DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(districtBo); - mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); - } - return mav; - } - public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception{ - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(address)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "µØÖ·±ØÐëÊäÈë")); - return mav; - } else { - String cat = "district"; + /** + * »ñÈ¡Ð¡ÇøµÄ¾ù¼ÛAction + * + * @param city + * @param region + * @param name + * @return + */ + public Object curAvgPriceAction(@Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,ËùÔÚÇøÓò,Ð¡ÇøÃûΪ±ØÌîÏî")); + return mav; + } + DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(city, region, name)); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡Çø²»´æÔÚ£¬Çë¼ì²é³ÇÊÐÃû,ÇøÓò,Ð¡ÇøÃû")); + return mav; + } - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", city); - params.put("address", address); - params.put("category", "property"); - //ÐÂÆ¥Åä½Ó¿Ú - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); - District property = null; - if (json != null && json.size() > 0) { - MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json); - property = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), cat); - if (null == property) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ")); - return mav; - } - DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(property); - mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); - }else{ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ")); - } - } - return mav; - } - - - /** - * аætokenÑéÖ¤ - * - * @param token - * @return - */ - private ApiUser checkNewAuthorized(String token) { - Map tokenMap = FangjiaApiUtil.parseToken(token); - if (tokenMap == null) { - return null; - } - // tokenÑéÖ¤ºó£¬ÄÃÈ¡³öµÄ×Ö¶ÎÔÙÈ¥Êý¾Ý¿âÑéÖ¤Ò»±é - if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { - List params = new ArrayList(); - params.add(new QueryParam("ID", tokenMap.get("userid"))); - ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); - if (apiUser != null) { - if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { - return apiUser; - } - } - } - return null; - } - public void setDistrictService(DistrictService districtService) { - this.districtService = districtService; - } + String kind = ""; + if (StringUtils.isNotBlank(districtBo.getEstateType2())) { + if (districtBo.getEstateType2().indexOf(DistrictKindEnum.bieshu.getValue()) != -1) { + kind = DistrictKindEnum.bieshu.getValue(); + } + if (districtBo.getEstateType2().indexOf("סլ") != -1 || districtBo.getEstateType2().indexOf("Ð¡Çø") != -1) { + if (kind.length() > 1) { + kind = kind + ","; + } + kind = kind + DistrictKindEnum.gongyu.getValue(); + } + districtBo.setKind(kind); - public void setDistrictStatService(DistrictStatService districtStatService) { - this.districtStatService = districtStatService; - } + } + if (StringUtils.isEmpty(districtBo.getKind())) { + districtBo.setKind(DistrictKindEnum.gongyu.getValue()); + } - public void setDistrictHouseService(DistrictHouseService districtHouseService) { - this.districtHouseService = districtHouseService; - } - public void setAutoCompleteService(AutoCompleteService autoCompleteService) { - this.autoCompleteService = autoCompleteService; - } + String[] kinds = districtBo.getKind().split(","); - public void setMenuService(MenuService menuService) { - this.menuService = menuService; - } + List districtStatList = null; + List villaStatList = null; + Date date = new Date(); + if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { + villaStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.bieshu.getValue(), date, 1); + if (kinds.length > 1) { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, 1); + } + } else { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, 1); + } + if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¶ÔÓ¦µÄÐ¡ÇøÎÞ¾ù¼ÛÊý¾Ý")); + return mav; + } - public void setKnowbaseService(KnowbaseService knowbaseService) { - this.knowbaseService = knowbaseService; - } + DistrictStat stat = null; + if (CollectionUtils.isNotEmpty(districtStatList)) { + stat = districtStatList.get(0); + } + if (CollectionUtils.isNotEmpty(villaStatList)) { + stat = villaStatList.get(0); + } - public void setApiUserService(ApiUserService apiUserService) { - this.apiUserService = apiUserService; - } + Map map = new HashMap(1); + map.put("avgPrice", stat.getAvgPrice()); + map.put("weekendMarkup", stat.getWeekendMarkup()); + mav.setModel(map); + return mav; + } - public void setExtractDistrictService(ExtractDistrictService extractDistrictService) { - this.extractDistrictService = extractDistrictService; - } + /** + * »ñÈ¡Ð¡ÇøµÄÀúÊ·¾ù¼ÛAction + * + * @param city + * @param region + * @param name + * @param weekCount + * @return + */ + public Object historyPriceAction(@Param(name = "city") String city, @Param(name = "name") String name, + @Param(name = "weekCount") Integer weekCount) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + int count = OfcChartUtils.YEAR_COUNT * 7; + if (null != weekCount && weekCount > 0) { + count = weekCount; + } + if (StringUtils.isBlank(name)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃûΪ±ØÌîÏî")); + return mav; + } + District currentDistrict = null; + city = knowbaseService.matchingCityDefaultNull(city); + if (StringUtils.isBlank(city)) { + city = "ÉϺ£"; + } + Map konwbase = knowbaseService.parseWord(name); + List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase + .get("district_name") : Collections.EMPTY_LIST; + if (CollectionUtils.isNotEmpty(districts)) { + for (Map district : districts) { + Map extra_data = (Map) district.get("extra_data"); + if (MapUtils.isNotEmpty(extra_data)) { + String region = (String) extra_data.get("region"); + name = (String) district.get("value"); + String tempCity = (String) extra_data.get("city"); + if (!city.equals(tempCity)) { + continue; + } + District d = districtService.findDistrict(new DistrictKey(city, region, name), false); + if (null == d) { + continue; + } + currentDistrict = d; + break; + } + } + } + + if (null == currentDistrict) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "δÕÒµ½Ïà¹ØÐ¡ÇøÐÅÏ¢")); + return mav; + } + + // ½âÎö³ö³ÇÊÐÇøÓòÐ¡ÇøÃûÂ¥¶°ºÅ + DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(currentDistrict.getCity(), currentDistrict + .getRegion(), currentDistrict.getName())); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡Çø²»´æÔÚ£¬Çë¼ì²é³ÇÊÐÃû,Ð¡ÇøÃû")); + return mav; + } + if (StringUtils.isEmpty(districtBo.getKind())) { + districtBo.setKind(DistrictKindEnum.gongyu.getValue()); + } + String[] kinds = districtBo.getKind().split(","); + List districtStatList = null; + List villaStatList = null; + Date date = new Date(); + if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { + villaStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.bieshu.getValue(), date, count); + if (kinds.length > 1) { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, count); + } + } else { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, count); + } + if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¶ÔÓ¦µÄÐ¡ÇøÎÞ¾ù¼ÛÊý¾Ý")); + return mav; + } + districtStatList = (List) OfcChartUtils.fixYDatas(date, districtStatList, count, null); + villaStatList = (List) OfcChartUtils.fixYDatas(date, villaStatList, count, null); + Map map = new HashMap(1); + map.put("stat", + DtoConverter.convertFromDistrictBoList(DataUtil.descCollection(districtStatList), + DataUtil.descCollection(villaStatList))); + mav.setModel(map); + return mav; + } + + /** + * ¸ù¾ÝÐ¡ÇøÃûµÈ»ñÈ¡Ð¡ÇøÊôÐÔ + * + * @param uniqueCodes + * @param districtNames + * @param regionNames + * @param cityNames + * @return + */ + public Object fetchDistrictsPropertiesAction(@Param(name = "uniqueCodes") String[] uniqueCodes, + @Param(name = "districtNames") String[] districtNames, @Param(name = "regionNames") String[] regionNames, + @Param(name = "cityNames") String[] cityNames) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + if (uniqueCodes.length * districtNames.length * regionNames.length * cityNames.length == 0) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøÎ¨Ò»Âë¡¢Ð¡ÇøÃû¡¢Ð¡ÇøËùÔÚÇøÓò¡¢Ð¡ÇøËùÔÚ³ÇÊбØÌî")); + return mav; + } + if (uniqueCodes.length - districtNames.length + regionNames.length - cityNames.length != 0) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøÎ¨Ò»ÂëÊý×é¡¢Ð¡ÇøÃûÊý×é¡¢Ð¡ÇøËùÔÚÇøÓòÊý×é¡¢Ð¡ÇøËùÔÚ³ÇÊÐÊý×éÊýÁ¿±ØÐëÏàͬ")); + return mav; + } + + ArrayList keys = new ArrayList(1); + Map key_uniqueCode = new HashMap(1); + for (int i = 0; i < cityNames.length; i++) { + cityNames[i] = this.knowbaseService.matchingCity(cityNames[i]); + regionNames[i] = this.knowbaseService.matchingRegion(regionNames[i], cityNames[i]); + DistrictKey key = new DistrictKey(cityNames[i], regionNames[i], districtNames[i]); + keys.add(key); + key_uniqueCode.put(key, uniqueCodes[i]); + } + Map districtMap = this.districtService.findDistrictByKeyList(keys, false); + Map newDistrictMap = this.districtService.findDistrictByKeyList(keys, true, false); + + Map dtoMap = new HashMap(1); + for (DistrictKey key : districtMap.keySet()) { + District d = districtMap.get(key); + if (null != d) { + String uniqueCode = key_uniqueCode.get(key); + DistrictsPropertiesDto dto = new DistrictsPropertiesDto(); + dto.setUniqueCode(uniqueCode); + dto.setDistrictName(d.getName()); + if (null != newDistrictMap.get(key)) { + dto.setNewDistrict(true); + if (d.getStatus() == 5) { + dto.setOnSale(true); + } + if (StringUtils.isNotBlank(d.getDiscount())) { + dto.setDiscount(true); + } + } + if (null == dto.getOnSale()) { + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(key); + if (dh != null && dh.getSellCount() != 0) { + dto.setOnSale(true); + } + } + if (StringUtils.isNotBlank(d.getVideoUrl())) { + dto.setVideo(true); + } + dtoMap.put(uniqueCode, dto); + } + } + mav.setModel(dtoMap); + return mav; + } + + private boolean isRadiusSearch(DistrictSearchModel model) { + return null != model.getRadius() && model.getRadius() > 0 && StringUtils.isNotBlank(model.getCity()) + && model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; + } + + public Object uploadAction(@Param(name = "token") String token, @Param(name = "data") String data) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + Map ret = new HashMap(1); + ret.put("RESULT", 500); + + ApiUser apiUser = checkNewAuthorized(token); + if (null == apiUser) { + return mav; + } + + try { + JSONArray disJsonArr = JSONArray.fromObject(data); + for (int i = 0; i < disJsonArr.size(); i++) { + JSONObject disJsonObj = disJsonArr.getJSONObject(i); + ExtractDistrict dis = (ExtractDistrict) JSONObject.toBean(disJsonObj, ExtractDistrict.class); + dis.setSource("open_api"); + dis.setUserId((int) apiUser.getId()); + dis.setCreationDate(new Date()); + dis.setModificationDate(dis.getCreationDate()); + extractDistrictService.save(dis); + } + } catch (JSONException e) { + return mav; + } + + ret.put("RESULT", 200); + return mav; + } + + public Object facilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "Ð¡ÇøËùÔÚ³ÇÊÐ,Ð¡ÇøÃû,ËùÔÚÇøÓò±Ø±ØÐëÊäÈë")); + return mav; + } else { + District districtBo = districtService.findDistrict(new DistrictKey(city, region, name), "district"); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ")); + return mav; + } + DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(districtBo); + mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); + } + return mav; + } + + // ±£´æÖܱßÅäÌ× + public Object saveFacilitiesAction(DistrictFacilitysModel model) { + model = processParam(model); + if (StringUtils.isNotBlank(model.getId())) { + Map data = new HashMap(); + data.put("kindergarten", model.getKindergarten()); + data.put("primarySchool", model.getPrimarySchool()); + data.put("middleSchool", model.getMiddleSchool()); + data.put("university", model.getUniversity()); + data.put("hospital", model.getHospital()); + data.put("shop", model.getShop()); + data.put("supermarket", model.getSupermarket()); + data.put("foodShop", model.getFoodShop()); + data.put("bus", model.getBus()); + data.put("bank", model.getBank()); + data.put("atm", model.getAtm()); + data.put("metro",model.getMetro()); + districtService.updateDistrictFacilitysById(data, model.getId()); + } else { + DistrictFacilitys districtFacilitys = CommonDtoUtils.transformV(DistrictFacilitys.class, model); + districtService.saveDistrictFacilitys(districtFacilitys); + } + return null; + } + + public static List convertToList(String value) { + List result = new ArrayList(); + + if (value != null && !value.isEmpty()) { + value = value.replaceAll("\\[", "").replaceAll("]", "").replaceAll(" ",""); + String[] splitValues = value.split(","); // °´¶ººÅ·Ö¸î + + // ±éÀúÊý×é²¢¹ýÂË¿Õ×Ö·û´® + for (String str : splitValues) { + if (!str.isEmpty()) { // Ö»Ìí¼Ó·Ç¿Õ×Ö·û´® + result.add(str); + } + } + } + + return result.isEmpty() ? null : result; // Èç¹û½á¹ûΪ¿Õ£¬Ôò·µ»Ø null + } + + public static DistrictFacilitysModel processParam(DistrictFacilitysModel model) { + // ´¦Àíÿ¸ö×ֶΣ¬È·±£Ö»ÓÐ·Ç null ×ֶβŽøÐд¦Àí + if (model.getKindergarten() != null) { + model.setKindergarten(convertToList(model.getKindergarten().toString())); + } + + if (model.getPrimarySchool() != null) { + model.setPrimarySchool(convertToList(model.getPrimarySchool().toString())); + } + + if (model.getMiddleSchool() != null) { + model.setMiddleSchool(convertToList(model.getMiddleSchool().toString())); + } + + if (model.getUniversity() != null) { + model.setUniversity(convertToList(model.getUniversity().toString())); + } + + if (model.getHospital() != null) { + model.setHospital(convertToList(model.getHospital().toString())); + } + + if (model.getShop() != null) { + model.setShop(convertToList(model.getShop().toString())); + } + + if (model.getSupermarket() != null) { + model.setSupermarket(convertToList(model.getSupermarket().toString())); + } + + if (model.getFoodShop() != null) { + model.setFoodShop(convertToList(model.getFoodShop().toString())); + } + + if (model.getBus() != null) { + model.setBus(convertToList(model.getBus().toString())); + } + + if (model.getBank() != null) { + model.setBank(convertToList(model.getBank().toString())); + } + + if (model.getAtm() != null) { + model.setAtm(convertToList(model.getAtm().toString())); + } + if (model.getMetro() != null) { + model.setMetro(convertToList(model.getMetro().toString())); + } + return model; + } + + /** + * »ñÈ¡Ð¡ÇøÍ¼Æ¬ + * + * @param districtModel + * @return + */ + public Object listPicAction(DistrictModel districtModel) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(districtModel.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID±ØÐëÊäÈë")); + return mav; + } + SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); + if (seaweedImages != null) { + mav.setModel(BasicModel.buildOKModel().setResult(seaweedImages)); + } else { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "ͼƬÊý¾Ý²»´æÔÚ")); + } + return mav; + } + public Object deletePicAction(DistrictModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID±ØÐëÊäÈë")); + return mav; + } + seaweedImagesService.deleteImage(model.getId(),model.getUrl(),model.getPicType(), model.getRoomType()); + mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "ɾ³ý³É¹¦")); + return mav; + } + public Object addPicAction(DistrictModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getImageUrls()!=null){ + model.setImageUrls(convertToList(model.getImageUrls().toString())); + } + if (StringUtils.isBlank(model.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID±ØÐëÊäÈë")); + return mav; + } + seaweedImagesService.addImage(model.getId(),model.getImageUrls(),model.getPicType(), model.getRoomType()); + mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "Ìí¼Ó³É¹¦")); + return mav; + } + + + public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(address)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "µØÖ·±ØÐëÊäÈë")); + return mav; + } else { + String cat = "district"; + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", city); + params.put("address", address); + params.put("category", "property"); + //ÐÂÆ¥Åä½Ó¿Ú + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); + District property = null; + if (json != null && json.size() > 0) { + MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json); + property = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), cat); + if (null == property) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ")); + return mav; + } + DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(property); + mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); + } else { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "Ð¡ÇøÊý¾Ý²»´æÔÚ")); + } + } + return mav; + } + + + /** + * аætokenÑéÖ¤ + * + * @param token + * @return + */ + private ApiUser checkNewAuthorized(String token) { + Map tokenMap = FangjiaApiUtil.parseToken(token); + if (tokenMap == null) { + return null; + } + // tokenÑéÖ¤ºó£¬ÄÃÈ¡³öµÄ×Ö¶ÎÔÙÈ¥Êý¾Ý¿âÑéÖ¤Ò»±é + if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { + List params = new ArrayList(); + params.add(new QueryParam("ID", tokenMap.get("userid"))); + ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); + if (apiUser != null) { + if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { + return apiUser; + } + } + } + return null; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setDistrictStatService(DistrictStatService districtStatService) { + this.districtStatService = districtStatService; + } + + public void setDistrictHouseService(DistrictHouseService districtHouseService) { + this.districtHouseService = districtHouseService; + } + + public void setAutoCompleteService(AutoCompleteService autoCompleteService) { + this.autoCompleteService = autoCompleteService; + } + + public void setMenuService(MenuService menuService) { + this.menuService = menuService; + } + + public void setKnowbaseService(KnowbaseService knowbaseService) { + this.knowbaseService = knowbaseService; + } + + public void setApiUserService(ApiUserService apiUserService) { + this.apiUserService = apiUserService; + } + + public void setExtractDistrictService(ExtractDistrictService extractDistrictService) { + this.extractDistrictService = extractDistrictService; + } public DistrictService getDistrictService() { return districtService; @@ -1285,7 +1428,11 @@ public class DistrictController { this.regionStatRentService = regionStatRentService; } - public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) { - this.districtFacilitysService = districtFacilitysService; - } + public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) { + this.districtFacilitysService = districtFacilitysService; + } + + public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { + this.seaweedImagesService = seaweedImagesService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java index 304f4813b..8745f5969 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java @@ -89,7 +89,7 @@ public class GdBankController { } /** - * ÉæÅ©Ê¶±ð-йæÔò-¹â´óÒøÐÐ + * ÉæÅ©Ê¶±ð-йæÔò-¹â´óÒøÐжԹ«Ê¶±ð½Ó¿Ú * * @param model * @return @@ -108,15 +108,15 @@ public class GdBankController { JSONObject json = null; Map params = new HashMap(); params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("type", type); - params.put("redis", (model.getRadius() != null && model.getRadius() != 0) ? model.getRadius().toString() : null); + //params.put("type", type); + //params.put("redis", (model.getRadius() != null && model.getRadius() != 0) ? model.getRadius().toString() : null); params.put("address", model.getAddress()); - params.put("showFullValue", "2"); + //params.put("showFullValue", "2"); try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cebEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception e) { try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cebEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception ex) { ex.printStackTrace(); } @@ -129,62 +129,65 @@ public class GdBankController { //ÎÒÃǵĽá¹û JSONObject result = json.getJSONObject("result"); //ÎÒÃÇÊ¡¼¶¼°ÒÔÉÏÓпª·¢Çø£¬Ö±½ÓÓÃÎÒÃǵĽá¹û - if (result.containsKey("devDistrictName")) { - basicModel.setResult(result); - - } else if (!"2".equals(type)) { // ¶Ô˽µÄ²»ÓÃÆëÁº - basicModel.setResult(result); - } else { - try { - //Èç¹ûÊǽ­ËÕÊ¡»òÕßÕã½­Ê¡ µ÷ÓÃÆëÁºµÄ½á¹û - if ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province"))) { - //½á¹û±È½Ï£¬Èç¹ûɿũ½á¹û²»Ò»Ö - //µ÷ÓÃÆëÁº type £º1 ¶Ô¹« 0 ¶Ô˽ - //ÎÒÃÇ type £º1 ¶Ô˽ 2 ¶Ô¹² - String qltype = "2".equals(type) ? "1" : "0"; - Map map = senRequest(address, qltype); - // ɿũ½á¹û²»Ò»Ñù - if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { - // ÆëÁºÏØÕþ¸®µ«ÊÇÉæÅ©ÎªÅ©£¬È¡ÎÒÃǵĽá¹û ÑïÖÐÊÐÈýé½ÖµÀÖлª´åÓÀ¹ÌºÓ·1ºÅ - if ("ÊÇ".equals(map.get("countyGov")) && "Å©".equals(map.get("verifyFlag"))) { - basicModel.setResult(result); - mav.setModel(basicModel); - return mav; - } - //³ÇÊв»Ò»Ñù ÓÃÎÒÃÇ - if (result.containsKey("city")) { - if ((!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { - basicModel.setResult(result); - } else { - map.put("addrVerify", "µØÖ·ÓÐЧ"); - map.put("typeName", areaMap.get(map.get("typeCode"))); - map.put("addrArea", addrArea(map, type)); - map.put("countyLevelCity", countyLevelCity(map)); - basicModel.setResult(map); - } - } else { - map.put("addrVerify", "µØÖ·ÓÐЧ"); - map.put("typeName", areaMap.get(map.get("typeCode"))); - map.put("addrArea", addrArea(map, type)); - map.put("countyLevelCity", countyLevelCity(map)); - basicModel.setResult(map); - } - - } else { - basicModel.setResult(result); - } - - } else { - basicModel.setResult(result); - - } - - } catch (Exception e) { - e.printStackTrace(); - basicModel.setResult(result); - } - - } + basicModel.setResult(result); +// if (result.containsKey("devDistrictName")) { +// } else { +// try { +// // ÎÒÃÇÊÇÏØÕþ¸®£¬ÇÒɿũ½á¹ûΪũ£¬È¡ÎÒÃǽá¹û£¬ÒòΪ¹â´ó²¿·ÖÂß¼­µ÷Õû +// if ("ÊÇ".equals(result.get("countyGov")) && "Å©".equals(result.get("verifyFlag"))) { +// basicModel.setResult(result); +// mav.setModel(basicModel); +// return mav; +// } +// //Èç¹ûÊǽ­ËÕÊ¡»òÕßÕã½­Ê¡ µ÷ÓÃÆëÁºµÄ½á¹û +// if ("½­ËÕÊ¡".equals(result.getString("province")) || "Õã½­Ê¡".equals(result.getString("province"))) { +// //½á¹û±È½Ï£¬Èç¹ûɿũ½á¹û²»Ò»Ö +// //µ÷ÓÃÆëÁº type £º1 ¶Ô¹« 0 ¶Ô˽ +// //ÎÒÃÇ type £º1 ¶Ô˽ 2 ¶Ô¹² +// String qltype = "2".equals(type) ? "1" : "0"; +// Map map = senRequest(address, qltype); +// // ɿũ½á¹û²»Ò»Ñù +// if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { +// // ÆëÁºÏØÕþ¸®µ«ÊÇÉæÅ©ÎªÅ©£¬È¡ÎÒÃǵĽá¹û ÑïÖÐÊÐÈýé½ÖµÀÖлª´åÓÀ¹ÌºÓ·1ºÅ +// if ("ÊÇ".equals(map.get("countyGov")) && "Å©".equals(map.get("verifyFlag"))) { +// basicModel.setResult(result); +// mav.setModel(basicModel); +// return mav; +// } +// //³ÇÊв»Ò»Ñù ÓÃÎÒÃÇ +// if (result.containsKey("city")) { +// if ((!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { +// basicModel.setResult(result); +// } else { +// map.put("addrVerify", "µØÖ·ÓÐЧ"); +// map.put("typeName", areaMap.get(map.get("typeCode"))); +// map.put("addrArea", addrArea(map, type)); +// map.put("countyLevelCity", countyLevelCity(map)); +// basicModel.setResult(map); +// } +// } else { +// map.put("addrVerify", "µØÖ·ÓÐЧ"); +// map.put("typeName", areaMap.get(map.get("typeCode"))); +// map.put("addrArea", addrArea(map, type)); +// map.put("countyLevelCity", countyLevelCity(map)); +// basicModel.setResult(map); +// } +// +// } else { +// basicModel.setResult(result); +// } +// +// } else { +// basicModel.setResult(result); +// +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// basicModel.setResult(result); +// } +// +// } } mav.setModel(basicModel); 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 69313c28b..cc49ec68a 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 @@ -8,6 +8,7 @@ import com.fangjia.dal.SeawaterQuery; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.common.ServerAreaData; import com.fangjia.dal.datastore.model.House; +import com.fangjia.dal.datastore.model.RentHouse; import com.fangjia.dal.mongo.model.DistrictFacilitys; import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap; import com.fangjia.dal.mongo.model.Metro; @@ -26,10 +27,7 @@ import com.fangjia.open.dto.UniversalDto; import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.BasicModel; -import com.fangjia.open.model.HousePublishModel; -import com.fangjia.open.model.HouseSearchModel; -import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.model.*; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.open.util.FileDao; import com.fangjia.open.ws.query.CollateralSampleQuery; @@ -67,6 +65,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import java.io.IOException; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; @@ -77,6 +76,8 @@ public class HouseController { private AddressParser addressParser; private HouseService houseService; + + private RentHouseService rentHouseService; private MenuService menuService; private NoHouseDistrictService noHouseDistrictService; private ApiUserService apiUserService; @@ -895,8 +896,29 @@ public class HouseController { @Authority(role = Role.USER) public Object aroundAction(final HouseSearchModel model) { + List type3 = Arrays.asList("1", "2", "0"); + List type2 = Arrays.asList("1", "0"); RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); + String city = model.getCity(); + String region = model.getRegion(); + String districtName = model.getName(); + if (StringUtils.isNotBlank(districtName) && (StringUtils.isBlank(city) || StringUtils.isBlank(region))) { + mav.setModel(BasicModel.buildBadRequestModel("city,region,nameΪһ×é²ÎÊý")); + return mav; + } + if (StringUtils.isNotBlank(model.getLocationType()) && !type3.contains(model.getLocationType())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý(locationType)ÓÐÎó")); + return mav; + } + if (StringUtils.isNotBlank(model.getPropertyType()) && !type3.contains(model.getPropertyType())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý(propertyType)ÓÐÎó")); + return mav; + } + if (StringUtils.isNotBlank(model.getHouseType()) && !type2.contains(model.getHouseType())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý(houseType)ÓÐÎó")); + return mav; + } // »ñÈ¡µ±Ç°ÈÕÆÚ Calendar today = Calendar.getInstance(); @@ -912,7 +934,9 @@ public class HouseController { model.setStartTime(sixMonthsAgoInt); model.setEndTime(todayInt); // ĬÈÏ3000MÄÚ - model.setRadius(3000); + if (model.getRadius() == null) { + model.setRadius(3000); + } if (StringUtils.isBlank(model.getLocation())) { mav.setModel(BasicModel.buildBadRequestModel("location(¾­Î³¶È)²»ÄÜΪ¿Õ")); return mav; @@ -923,8 +947,17 @@ public class HouseController { return mav; } String[] locationStr = model.getLocation().split(","); + String numberPattern = "-?\\d+(\\.\\d+)?"; // Æ¥ÅäÕûÊý»ò¸¡µãÊý + for (String loc : locationStr) { + if (!loc.trim().matches(numberPattern)) { + mav.setModel(BasicModel.buildBadRequestModel("location(¾­Î³¶È)¸ñʽ´íÎó")); + return mav; + } + } Double lng = Double.valueOf(locationStr[0]); Double lat = Double.valueOf(locationStr[1]); + +// if (model.getSize()) if ("2".equals(model.getLocationType())) { Map gcj02Location = GeoUtils.bd09ToGcj02(lat, lng); lng = gcj02Location.get("lng"); @@ -958,82 +991,122 @@ public class HouseController { cat = "shop_sell"; } } - List houses = null; + List houses = new ArrayList(); + List houseSelf = new ArrayList(); + List houseAround =new ArrayList(); List houseList = new ArrayList(); - if (cat.contains("_")) { - // ÉÌÆÌ£¬Ð´×ÖÂ¥Óо­Î³¶È£¬Ö±½Ó²é - SeawaterQuery query = new SeawaterQuery(); +// if (cat.contains("_")) { + // ÉÌÆÌ£¬Ð´×ÖÂ¥Óо­Î³¶È£¬Ö±½Ó²é + SeawaterQuery query = new SeawaterQuery(); + // ÏÈÓÃÃû×Ö²é×ÔÉíµÄÑù±¾ + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(districtName); + query.setCat(cat); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + Pager pager = new Pager(); + pager.setStartRow(0); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize()); + } else { + pager.setPageSize(5); + } + query.setPager(pager); + query.setSortField("p_date"); + query.setOrder(false); + query.setTable("latest_seawater"); + houseSelf = seawaterDao.findSeawatersByQuery(query); + houses.addAll(houseSelf); + // Èç¹û×ÔÉíÑù±¾Êý²»¹»£¬ÔÙ²éÖÜ±ß + if (houseSelf != null && houseSelf.size() < pager.getPageSize()){ + query.setRegion(null); + query.setDistrictName(null); query.setLat(lat); query.setLng(lng); - query.setCat(cat); query.setRadius(model.getRadius()); - query.setStartDate(model.getStartTime()); - query.setEndDate(model.getEndTime()); - if (model.getSize() != null && model.getSize() != 0) { - query.setStartArea(model.getSize() * 0.9); - query.setEndArea(model.getSize() * 1.1); - } - query.setCityDisplay(model.getCity()); - Pager pager = new Pager(); - pager.setStartRow(0); - pager.setPageSize(5); - query.setPager(pager); - query.setTable("latest_seawater"); - houses = seawaterDao.findSeawatersByQuery(query); - if (houses != null && !houses.isEmpty()) { - for (Seawater house : houses) { - Seawater seawater = new Seawater(); - seawater.setCity(house.getCity()); - seawater.setDistrict(house.getRegion()); - seawater.setAddress(house.getAddress()); - seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea()); - seawater.setUnitPrice(house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice()); - seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor()); - seawater.setMaxFloor(house.getHeight()); - seawater.setRoom(house.getRoom()); - seawater.setHall(house.getHall()); - seawater.setToilet(house.getToilet()); - seawater.setDecoration(house.getFitment()); - if (house.getpDate() != null && house.getpDate() > 10000000) { - String numberStr = String.valueOf(house.getpDate()); - // ²ð·Ö×Ö·û´®²¢¸ñʽ»¯ - String year = numberStr.substring(0, 4); // ǰËÄλÊÇÄê·Ý - String month = numberStr.substring(4, 6); // ÖмäÁ½Î»ÊÇÔÂ·Ý - String day = numberStr.substring(6, 8); // ×îºóÁ½Î»ÊÇÈÕÆÚ - String formattedDate = year + "-" + month + "-" + day; - seawater.setPublishDate(formattedDate); - } - houseList.add(seawater); + houseAround = seawaterDao.findSeawatersByQuery(query); + houses.addAll(houseAround); + } + if (houses != null && !houses.isEmpty()) { + Set seenIds = new HashSet(); + Iterator iterator = houses.iterator(); + while (iterator.hasNext()) { + Seawater s = iterator.next(); + if (!seenIds.add(s.getId())) { + // Èç¹ûÒѾ­´æÔÚ£¬Ôò´ÓÁбíÖÐÒÆ³ý + iterator.remove(); } } - } else { - List nearestHasHouseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); - if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) { - for (House house : nearestHasHouseByLocation) { - Seawater seawater = new Seawater(); - seawater.setCity(house.getCity()); - seawater.setDistrict(house.getRegion()); - seawater.setAddress(house.getAddress()); - seawater.setName(house.getDistrictName()); - seawater.setSize(house.getArea()); - seawater.setUnitPrice(house.getAvgPrice()); - seawater.setTotalPrice(house.getTotalPrice()); - seawater.setDirection(house.getDirection()); - seawater.setFloor(house.getFloor()); - seawater.setMaxFloor(house.getHeight()); - seawater.setRoom(house.getRoom()); - seawater.setHall(house.getHall()); - seawater.setToilet(house.getToilet()); - seawater.setDecoration(house.getFitment()); - if (house.getPublishDate() != null) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - seawater.setPublishDate(sdf.format(house.getPublishDate())); - } - houseList.add(seawater); + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"ÔÝÎÞÊý¾Ý".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); } + if (cat.contains("office")) { + seawater.setLevel(house.getLevel()); + } + if (cat.contains("shop")) { + if (StringUtils.isNotBlank(house.getEstateType()) && !"ÆäËû".equals(house.getEstateType())) { + seawater.setShopType(house.getEstateType()); + } + if (StringUtils.isNotBlank(house.getBusinessRange())) { + seawater.setBusinessScope(house.getBusinessRange()); + } + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); +// seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); +// seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); +// seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDayUnitPrice(house.getDayUnitPrice() == null || house.getDayUnitPrice() == 0 ? null : house.getDayUnitPrice()); + seawater.setRentType(house.getRentType()); + seawater.setPayType(house.getPayType()); + seawater.setBusinessStatus(house.getBusinessStatus()); + seawater.setBlock(house.getBlock()); + seawater.setDecoration(house.getFitment()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // ²ð·Ö×Ö·û´®²¢¸ñʽ»¯ + String year = numberStr.substring(0, 4); // ǰËÄλÊÇÄê·Ý + String month = numberStr.substring(4, 6); // ÖмäÁ½Î»ÊÇÔÂ·Ý + String day = numberStr.substring(6, 8); // ×îºóÁ½Î»ÊÇÈÕÆÚ + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + seawater.setDistance(house.getDistance()); + if (StringUtils.isNotBlank(house.getLocation())) { + if ("2".equals(model.getLocationType())) { + String[] split = house.getLocation().split(","); + Double lon = Double.valueOf(split[0]); + Double latt = Double.valueOf(split[1]); + Map toBd09 = GeoUtils.gcj02ToBd09(latt, lon); + seawater.setLocation(sub6(toBd09.get("lng")) + "," + sub6(toBd09.get("lat"))); + } else { + String location = house.getLocation(); + String[] split = location.split(","); + if (split.length == 2) { + String location1 = sub6(Double.valueOf(split[0])) + "," + sub6(Double.valueOf(split[1])); + seawater.setLocation(location1); + } + } + } + houseList.add(seawater); } } @@ -1046,6 +1119,230 @@ public class HouseController { return mav; } + public Object rentAction(final HouseSearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getSize() != null && model.getSize() < 0) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý(size)ÓÐÎó")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("³ÇÊÐ(city),ÇøÓò(district),Ð¡ÇøÃû(name)Ϊ±ØÌî²ÎÊý")); + return mav; + } + District property = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + if (null == property) { + mav.setModel(BasicModel.buildBadRequestModel("δÕÒµ½¸ÃÐ¡Çø")); + return mav; + } + + // »ñÈ¡µ±Ç°ÈÕÆÚ + Calendar today = Calendar.getInstance(); + + // ¸´ÖÆÒ»·Ýµ±Ç°ÈÕÆÚ£¬ÓÃÓÚ¼ÆËã°ëÄêǰµÄÈÕÆÚ + Calendar sixMonthsAgo = (Calendar) today.clone(); + + // ¼õÈ¥ 6 ¸öÔ + sixMonthsAgo.add(Calendar.MONTH, -6); + + // ¸ñʽ»¯ÈÕÆÚΪ yyyyMMdd + int todayInt = formatDate(today); + int sixMonthsAgoInt = formatDate(sixMonthsAgo); + model.setStartTime(sixMonthsAgoInt); + model.setEndTime(todayInt); + + List houses = null; + List houseList = new ArrayList(); +// if (cat.contains("_")) { + // ÉÌÆÌ£¬Ð´×ÖÂ¥Óо­Î³¶È£¬Ö±½Ó²é + SeawaterQuery query = new SeawaterQuery(); + query.setCat("rent"); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + query.setCityDisplay(model.getCity()); + query.setRegion(model.getDistrict()); + query.setDistrictName(model.getName()); + query.setDistrictAlias(property.getAlias()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + houses = seawaterDao.findSeawatersByQuery(query); + if (houses != null && !houses.isEmpty()) { + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"ÔÝÎÞÊý¾Ý".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDecoration(house.getFitment()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // ²ð·Ö×Ö·û´®²¢¸ñʽ»¯ + String year = numberStr.substring(0, 4); // ǰËÄλÊÇÄê·Ý + String month = numberStr.substring(4, 6); // ÖмäÁ½Î»ÊÇÔÂ·Ý + String day = numberStr.substring(6, 8); // ×îºóÁ½Î»ÊÇÈÕÆÚ + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + houseList.add(seawater); + } + } + BasicModel basicModel = new BasicModel(200, "ok"); + // ×é×°Êý¾Ý + basicModel.setResult(houseList); + mav.setModel(basicModel); + mav.setViewType("rest"); + return mav; + } + + public Object resourcesAction(final HouseSearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getSize() != null && model.getSize() < 0) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý(size)ÓÐÎó")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("³ÇÊÐ(city),ÇøÓò(district),Ð¡ÇøÃû(name)Ϊ±ØÌî²ÎÊý")); + return mav; + } + District property = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + if (null == property) { + mav.setModel(BasicModel.buildBadRequestModel("δÕÒµ½¸ÃÐ¡Çø")); + return mav; + } + // ûÓÐÊäÈëʱ¼ä·¶Î§£¬ÔòÊÇĬÈÏÁù¸öÔ嵀 + if (model.getStartTime() == null && model.getEndTime() == null) { + // »ñÈ¡µ±Ç°ÈÕÆÚ + Calendar today = Calendar.getInstance(); + + // ¸´ÖÆÒ»·Ýµ±Ç°ÈÕÆÚ£¬ÓÃÓÚ¼ÆËã°ëÄêǰµÄÈÕÆÚ + Calendar sixMonthsAgo = (Calendar) today.clone(); + + // ¼õÈ¥ 6 ¸öÔ + sixMonthsAgo.add(Calendar.MONTH, -6); + + // ¸ñʽ»¯ÈÕÆÚΪ yyyyMMdd + int todayInt = formatDate(today); + int sixMonthsAgoInt = formatDate(sixMonthsAgo); + model.setStartTime(sixMonthsAgoInt); + model.setEndTime(todayInt); + } + + List houses = null; + List houseList = new ArrayList(); + SeawaterQuery query = new SeawaterQuery(); + List catList = Arrays.asList("rent", "sell", "office_rent", "office_sell", "shop_sell", "shop_rent"); + if (!catList.contains(model.getCat())) { + model.setCat("rent"); + } + query.setCat(model.getCat()); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + query.setCityDisplay(model.getCity()); + query.setRegion(model.getDistrict()); + query.setDistrictName(model.getName()); + query.setDistrictAlias(property.getAlias()); + Pager pager = new Pager(); + // ûÓвéѯÊýÁ¿£¬Ä¬ÈϲéǰÎå¸ö + if (model.getPageIndex() == null) { + pager.setStartRow(0); + } else { + pager.setStartRow(model.getPageIndex()); + } + pager.setPageSize(model.getPageSize()); + query.setPager(pager); + query.setTable("latest_seawater"); + if (StringUtils.isNotBlank(model.getSortField())) { + query.setSortField(model.getSortField()); + } else { + query.setSortField("p_date"); + } + if ("asc".equals(model.getSortBy())) { + query.setOrder(true); + } else { + query.setOrder(false); + } + houses = seawaterDao.findSeawatersByQuery(query); + if (houses != null && !houses.isEmpty()) { + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"ÔÝÎÞÊý¾Ý".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDecoration(house.getFitment()); + seawater.setFloorInfo(house.getFloorInfo()); + seawater.setRoot(house.getRoot()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // ²ð·Ö×Ö·û´®²¢¸ñʽ»¯ + String year = numberStr.substring(0, 4); // ǰËÄλÊÇÄê·Ý + String month = numberStr.substring(4, 6); // ÖмäÁ½Î»ÊÇÔÂ·Ý + String day = numberStr.substring(6, 8); // ×îºóÁ½Î»ÊÇÈÕÆÚ + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + houseList.add(seawater); + } + } + BasicPageModel pageModel = new BasicPageModel(200, "ok"); + pager.setPageSize(-1); + pager.setStartRow(-1); + query.setPager(pager); + long count = seawaterDao.findSeawatersCountByQuery(query); + pageModel.setTotal((int) count); + // ×é×°Êý¾Ý + pageModel.setResult(houseList); + mav.setModel(pageModel); + mav.setViewType("rest"); + return mav; + } + + Double sub6(Double a) { + BigDecimal bd = new BigDecimal(a); + BigDecimal bigDecimal = bd.setScale(6, BigDecimal.ROUND_DOWN); + return bigDecimal.doubleValue(); + } + // ¸ñʽ»¯ÈÕÆÚΪ yyyyMMdd private static int formatDate(Calendar calendar) { int year = calendar.get(Calendar.YEAR); @@ -1869,4 +2166,8 @@ public class HouseController { public void setSeaweedService(SeaweedService seaweedService) { this.seaweedService = seaweedService; } + + public void setRentHouseService(RentHouseService rentHouseService) { + this.rentHouseService = rentHouseService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java new file mode 100644 index 000000000..1a8370a0c --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeController.java @@ -0,0 +1,883 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.*; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.seaweed.model.District; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.dto.DistrictInfoDto; +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.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; +import com.fangjia.service.address.AddressParser; +import com.fangjia.service.api.AddressMatchProxyService; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.datastore.FieldFilterService; +import com.fangjia.service.datastore.OfficeService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.bson.types.ObjectId; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * @author shenjian + * @since 2025/1/21 + */ +@Authority(role = Role.USER) +public class OfficeController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private OfficeService officeService; + + private DistrictService districtService; + + private AddressMatchProxyService addressMatchProxyService; + + private OpenApiLogService openApiLogService; + + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + + /** + * ³ÇÊгö×â¾ù¼Û + * + * @return + */ + public Object cityRentAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = officeService.findOfficeRentStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ã³ÇÊÐûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * ÇøÓò³ö×â¾ù¼Û + * + * @return + */ + public Object districtRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = officeService.findOfficeRentStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸ÃÇøÓòûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×ÖÂ¥¾ù¼Û×ßÊÆ + * + * @return + */ + public Object officeRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = officeService.findOfficeRentStat(city, region, name, "office", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ãд×Ö¥ûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×Ö¥¥×â½ðµØÖ·¹ÀÖµ + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐ,µØÖ·,Ãæ»ý(size)Ϊ±ØÌîÏî")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + + 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(model.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)); + } + + } + } + + OfficeEvaluationDto evaluation = officeService.addressEvaluateRent(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/addressEvaluateRent"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("ÔÝʱ²»Ö§³Ö¸ÃµØÖ·Ð´×ÖÂ¥µÄÆÀ¹À").markNoData()); + return mav; + } + } + + /** + * д×ÖÂ¥ÏêÇé + * + * @param model + * @return + */ + public Object detailAction(PropertySearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId()) + && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) + || StringUtils.isBlank(model.getName())) + && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) + || StringUtils.isBlank(model.getAddress()))) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:ÇëÊäÈëÕýÈ·µÄ²ÎÊý×éºÏ")); + return mav; + } + + District district = null; + if (StringUtils.isNotBlank(model.getId())) { + if (ObjectId.isValid(model.getId())) { + district = districtService.findById(model.getId()); + } else { + mav.setModel(BasicModel.buildBadRequestModel("·Ç·¨µÄд×ÖÂ¥ID")); + return mav; + } + } + + if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) + && StringUtils.isNotBlank(model.getName())) { + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "office"); + if (district != null) { + district = districtService.findById(district.getId()); + } + } + + if (district == null && StringUtils.isNotBlank(model.getCity()) && StringUtils.isNotBlank(model.getDistrict()) + && StringUtils.isNotBlank(model.getAddress())) { + Map result = addressParser.parse2(model.getCity(), model.getAddress(), "office", false); + Integer status = (Integer) result.get("status"); + Integer precise = (Integer) result.get("precise"); + if (status != null && status == 0 && precise == 0) { + String id = (String) result.get("id"); + district = districtService.findById(id); + } + } + + if (district != null) { + fieldFilterService.filterWithProcessNUll(district); + DistrictInfoDto districtInfoDto = new DistrictInfoDto(); + if (model.getDetailLevel() == null || model.getDetailLevel() >= 0) { + districtInfoDto.setId(district.getId()); + districtInfoDto.setCity(district.getCity()); + districtInfoDto.setDistrict(district.getRegion()); + districtInfoDto.setName(district.getName()); + districtInfoDto.setAddress(district.getAddress()); + districtInfoDto.setPropertyType(district.getEstateType2()); + if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null + && district.getLng2() != 0) { + districtInfoDto.setLat2(district.getLat2() / 10000000000D); + districtInfoDto.setLng2(district.getLng2() / 10000000000D); + } + if (district.getLat() != null && district.getLat() != 0 && district.getLng() != null + && district.getLng() != 0) { + districtInfoDto.setLat(district.getLat() / 10000000000D); + districtInfoDto.setLng(district.getLng() / 10000000000D); + } + } + + districtInfoDto.setBlock(district.getBlock()); + districtInfoDto.setLoopLine(district.getLoopLineInfo()); + if (HouseValidator.validateBuildingType(district.getBuildType())) { + districtInfoDto.setBuildingType(district.getBuildType()); + } else { + districtInfoDto.setBuildingType(""); + } + districtInfoDto.setAlias(district.getMappingAlias()); + districtInfoDto.setAddressAlias(district.getAddrAlias()); + districtInfoDto.setCommunity(district.getStreetCommunity()); + districtInfoDto.setCommercialArea(district.getBusinessQuarter()); + if (district.getHouseholdCount() != null) { + districtInfoDto.setTotalUnitCount(SeaweedUtils.formatHouseholdCount(district.getHouseholdCount().toString())); + } else { + districtInfoDto.setTotalUnitCount(""); + } + districtInfoDto.setManagementFee(district.getEstateCharge()); + if (district.getCarSiteCount() != null) { + districtInfoDto.setParking(SeaweedUtils.formatCarSiteCount(district.getCarSiteCount().toString())); + } else { + districtInfoDto.setParking(""); + } + districtInfoDto.setParkingDescription(district.getCarSite()); + districtInfoDto.setOwnershipPeriod(district.getPropertyLife()); + districtInfoDto.setOwnershipType(district.getHouseProperty()); + districtInfoDto.setStartBuildTime(district.getStartBuildingDate()); + if (district.getOpenDate() != null) { + Date minDate = DateUtil.parseDate("1900-01-01", "yyyy-MM-dd"); + Date maxDate = DateUtil.parseDate("2025-01-01", "yyyy-MM-dd"); + if (district.getOpenDate().after(minDate) && district.getOpenDate().before(maxDate)) { + districtInfoDto + .setStartSellingTime(DateUtil.formatByPattern(district.getOpenDate(), "yyyy-MM-dd")); + } + } else { + districtInfoDto.setStartSellingTime(""); + } + + districtInfoDto.setFinishBuildTime(district.getFinishBuildingDate()); + districtInfoDto.setMoveinTime(district.getLiveDate()); + districtInfoDto.setFloorSpace(SeaweedUtils.formatAllArea(district.getAllArea())); + districtInfoDto.setConstructionSpace(district.getBuildArea()); + districtInfoDto.setPlotRatio(SeaweedUtils.formatCubagePercent(district.getCubagePercent())); + districtInfoDto.setGreenPercentage(SeaweedUtils.formatVirescencePercent(district.getVirescencePercent())); + districtInfoDto.setPreSalePermit(district.getLicence()); + districtInfoDto.setDeveloper(district.getDeveloper()); + districtInfoDto.setDiscount(district.getDiscount()); + districtInfoDto.setPropertyManagement(district.getEstateCompany()); + if (HouseValidator.fetchFitmentInfo(district.getFitment()) == null) { + districtInfoDto.setDecorationStandard(""); + } else { + districtInfoDto.setDecorationStandard(HouseValidator.fetchFitmentInfo(district.getFitment())); + } + districtInfoDto.setBuildingStructure(district.getBuildStructure()); + districtInfoDto.setSupportingFacilities(district.getFacilities()); + districtInfoDto.setTransportation(district.getTraffic()); + districtInfoDto.setRelatedInfo(district.getRelateInfo()); + districtInfoDto.setDescription(district.getDescription()); + districtInfoDto.setSalesOfficeAdd(district.getSellAddress()); + districtInfoDto.setSalesPhoneNumber(district.getMobile()); + districtInfoDto.setTownship(district.getTownship()); + districtInfoDto.setBedKind(district.getBedKind()); + districtInfoDto.setEstateType2(district.getEstateType2()); + if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { + districtInfoDto.setBuildingCount(district.getLoudongCount()); + } + Integer finishYear = districtService.getCreateYear(district); + if (finishYear != null) { + districtInfoDto.setFinishYear(finishYear); + } + + mav.setModel(BasicModel.buildOKModel().setResult(districtInfoDto)); + return mav; + } + mav.setModel(BasicModel.buildBadRequestModel("¸Ãд×ÖÂ¥²»´æÔÚ")); + return mav; + } + + + /** + * д×ÖÂ¥×â½ðÆÀ¹À + * + * @param model + * @param request + * @return + */ + public Object evaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0 || model.getCity().contains("È«¹ú") + || model.getDistrict().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐ,ÇøÓò,д×ÖÂ¥Ãû,Ãæ»ý(size)Ϊ±ØÌîÏî")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + /* Ïȵ½CPDB¿âÖвéÕÒд×ÖÂ¥ */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office"); + if (district == null) { + if (model.getDistrict().contains("ÊÐÏ½Çø") || model.getDistrict().contains(model.getCity())) { + district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "office"); + } + 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)); + } + + } + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + + OfficeEvaluationDto evaluation = officeService.evaluateRent(district, buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("samples", evaluation.getSeawater()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/office/evaluateRent"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("ÔÝʱ²»Ö§³Ö¸Ãд×ÖÂ¥µÄÆÀ¹À").markNoData()); + return mav; + } + } + + /** + * ÉêÇë¹ÀÖµ±¨¸æ + * + * @param model ÉêÇ뱨¸æÇëÇó²ÎÊý + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:ίÍлú¹¹Îª±ØÌîÏî")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:±êµÄÎïΪ±ØÌîÏî")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐΪ±ØÌîÏîÇÒ²»ÄÜΪȫ¹ú")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:ÇøÓòΪ±ØÌîÏîÇÒ²»ÄÜΪȫ¹ú")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:Ãæ»ý(size)Ϊ±ØÌîÏîÇÒ´óÓÚ0")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + if (model.getDistrict().endsWith("Çø")) { + model.setDistrict(model.getDistrict().replaceAll("Çø$", "")); + } + 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; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇë¹ÀÖµ±¨¸æÊ§°Ü£º" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇë¹ÀÖµ±¨¸æÊ§°Ü£ºµ÷ÓÃÉêÇ뱨¸æ½Ó¿Ú·µ»ØÎª¿Õ")); + } + return mav; + } + + /** + * »ñÈ¡¹ÀÖµ±¨¸æ + * + * @param caseId ¹ÀÖµ±¨¸æID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:¹ÀÖµ±¨¸æÒµÎñ±àºÅΪ±ØÌîÏî")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("»ñÈ¡¹ÀÖµ±¨¸æÊ§°Ü£º" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇ뱨¸æÊ§°Ü£ºµ÷ÓûñÈ¡¹ÀÖµ±¨¸æ½Ó¿Ú·µ»ØÎª¿Õ")); + } + 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; + } + + /** + * ͨ¹ýEvaluationModel×é×°EvaluationʵÌå + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + 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 floorDesc = "ÖÐ"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "µÍ"; + } else if (floorInfo > 0.66) { + floorDesc = "¸ß"; + } + evaluation.setFloorDesc(floorDesc); + } + 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_office_evaluateRent"); + return evaluation; + } + + 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", "»î¶¯ÖÐÐÄ"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setOfficeService(OfficeService officeService) { + this.officeService = officeService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) { + this.addressMatchProxyService = addressMatchProxyService; + } + + public void setAddressParser(AddressParser addressParser) { + this.addressParser = addressParser; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java new file mode 100644 index 000000000..340914d13 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/OfficeSellController.java @@ -0,0 +1,567 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.OfficeSellStat; +import com.fangjia.dal.seaweed.model.District; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.service.api.AddressMatchProxyService; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.datastore.OfficeService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * @author liuhongyang + * @since 2025/3/25 + */ +@Authority(role = Role.USER) +public class OfficeSellController { + + private static final Logger LOGGER = LoggerFactory.getLogger(OfficeSellController.class); + private OfficeService officeService; + private DistrictService districtService; + private OpenApiLogService openApiLogService; + private AddressMatchProxyService addressMatchProxyService; + + /** + * д×ÖÂ¥³ÇÊгöÊÛ¾ù¼Û + * + * @return + */ + public Object citySellAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List sellList = officeService.findOfficeSellStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(sellList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ã³ÇÊÐûÓÐд×ÖÂ¥¾ù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(sellList)); + return mav; + } + + /** + * д×ÖÂ¥ÇøÓò³öÊÛ¾ù¼Û + * + * @return + */ + public Object districtSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = officeService.findOfficeSellStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸ÃÇøÓòûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×ÖÂ¥³öÊÛ¾ù¼Û×ßÊÆ + * + * @return + */ + public Object officeSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = officeService.findOfficeSellStat(city, region, name, "office", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ãд×Ö¥ûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×ÖÂ¥ÊÛ¼ÛÆÀ¹À + * + * @param model + * @param request + * @return + */ + public Object evaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) + || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0 || model.getCity().contains("È«¹ú") + || model.getDistrict().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐ,ÇøÓò,д×ÖÂ¥Ãû,Ãæ»ý(size)Ϊ±ØÌîÏî")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + /* Ïȵ½CPDB¿âÖвéÕÒд×ÖÂ¥ */ + District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "office"); + if (district == null) { + if (model.getDistrict().contains("ÊÐÏ½Çø") || model.getDistrict().contains(model.getCity())) { + district = districtService.findByNameAndAlias(model.getCity(), null, model.getName(), "office"); + } + 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)); + } + + } + } + model.setRegion(district.getRegion()); + model.setDistrictName(district.getName()); + + OfficeEvaluationDto evaluation = officeService.evaluateSell(district, buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("city", district.getCity()); + districtPriceMap.put("district", district.getRegion()); + districtPriceMap.put("name", district.getName()); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("samples", evaluation.getSeawater()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/officeSell/evaluateSell"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("ÔÝʱ²»Ö§³Ö¸Ãд×ÖÂ¥µÄÆÀ¹À").markNoData()); + return mav; + } + } + + /** + * д×ÖÂ¥ÊÛ¼ÛµØÖ·¹ÀÖµ + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐ,µØÖ·,Ãæ»ý(size)Ϊ±ØÌîÏî")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + + 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(model.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)); + } + + } + } + + OfficeEvaluationDto evaluation = officeService.addressEvaluateSell(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/officeSell/addressEvaluateSell"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + 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; + } + + /** + * ͨ¹ýEvaluationModel×é×°EvaluationʵÌå + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + 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 floorDesc = "ÖÐ"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "µÍ"; + } else if (floorInfo > 0.66) { + floorDesc = "¸ß"; + } + evaluation.setFloorDesc(floorDesc); + } + 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_office_evaluateSell"); + return evaluation; + } + + public void setOfficeService(OfficeService officeService) { + this.officeService = officeService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setAddressMatchProxyService(AddressMatchProxyService addressMatchProxyService) { + this.addressMatchProxyService = addressMatchProxyService; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java index 1cc608e7e..08c74dfef 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PoiController.java @@ -17,8 +17,10 @@ import com.fangjia.service.api.AmapPoiService; import com.fangjia.service.bo.Point; import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.mongo.fangjia.CbmRegionService; +import com.fangjia.service.open.AdministrativeMappingService; import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; +import org.apache.commons.codec.binary.Base64; import javax.validation.Valid; import java.util.*; @@ -30,7 +32,11 @@ public class PoiController { private CbmRegionService cbmRegionService; private AddressParserService addressParserService; private DistrictService districtService; + + private AdministrativeMappingService administrativeMappingService; private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "addrAlias"}; + private static final String ES_USER = "developer"; + private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; public Object getAntiFraudQuestionAction(@Valid AntiFraudQuestionModel model) { RestfulModelAndView mav = new RestfulModelAndView(); @@ -221,7 +227,7 @@ public class PoiController { public Object searchAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getLocation()) || StringUtils.isBlank(model.getCity())) { + if (StringUtils.isBlank(model.getLocation()) || StringUtils.isBlank(model.getCity())) { mav.setModel(BasicModel.buildBadRequestModel("³ÇÊк;­Î³¶ÈΪ±ØÌîÏî")); return mav; } @@ -268,6 +274,115 @@ public class PoiController { return mav; } + public Object facilitiesAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + String city = administrativeMappingService.findCityByCityShort(model.getCity()); + String lngStr = model.getLng(); + String latStr = model.getLat(); + String numberPattern = "-?\\d+(\\.\\d+)?"; // Æ¥ÅäÕûÊý»ò¸¡µãÊý + if (!lngStr.matches(numberPattern) || !latStr.matches(numberPattern)) { + mav.setModel(BasicModel.buildBadRequestModel("location(¾­Î³¶È)¸ñʽ´íÎó")); + return mav; + } + double lng = Double.parseDouble(lngStr); + double lat = Double.parseDouble(latStr); + Map> result = new HashMap>(); + List bankSmallType = Arrays.asList("ÒøÐÐ", "ÖйúÈËÃñÒøÐÐ", "¹ú¼Ò¿ª·¢ÒøÐÐ", "Öйú½ø³ö¿ÚÒøÐÐ", + "ÖйúÒøÐÐ", "Öйú¹¤ÉÌÒøÐÐ", "Öйú½¨ÉèÒøÐÐ", "ÖйúÅ©ÒµÒøÐÐ", "½»Í¨ÒøÐÐ", "ÕÐÉÌÒøÐÐ", "»ªÏÄÒøÐÐ", + "ÖÐÐÅÒøÐÐ", "ÖйúÃñÉúÒøÐÐ", "Öйú¹â´óÒøÐÐ", "ÉϺ£ÒøÐÐ", "ÉϺ£ÆÖ¶«·¢Õ¹ÒøÐÐ", "ƽ°²ÒøÐÐ", "ÐËÒµÒøÐÐ", + "±±¾©ÒøÐÐ", "¹ã·¢ÒøÐÐ", "Å©´åÉÌÒµÒøÐÐ", "Ïã¸ÛºãÉúÒøÐÐ", "¶«ÑÇÒøÐÐ", "»¨ÆìÒøÐÐ", "Ôü´òÒøÐÐ", "»ã·áÒøÐÐ", + "ºÉÀ¼ÒøÐÐ", "ÃÀ¹úÔËÍ¨ÒøÐÐ", "ÈðÊ¿ÓѰîÒøÐÐ", "ÃÀ¹úÒøÐÐ", "ÃÉÌØÀû¶ûÒøÐÐ", "Å¦Ô¼ÒøÐÐ", "ËÕ¸ñÀ¼»Ê¼ÒÒøÐÐ", "·¨¹úÐËÒµÒøÐÐ", + "µÂÒâÖ¾ÒøÐÐ", "ÈÕ±¾ÈýÁâ¶«¾©ÈÕÁªÒøÐÐ", "°Í¿ËÀ³ÒøÐÐ", "Ħ¸ù´óÍ¨ÒøÐÐ", "ÖйúÓÊÕþ´¢ÐîÒøÐÐ", "Ïã¸ÛÐÇÕ¹ÒøÐÐ", "ÄÏÑóÉÌÒµÒøÐÐ", + "ÉϺ£ÉÌÒµÒøÐÐ", "ÓÀºàÒøÐÐ", "Ïã¸ÛÓÀÂ¡ÒøÐÐ", "´´ÐËÒøÐÐ", "´óÐÂÒøÐÐ", "ÖÐÐÅÒøÐÐ(¹ú¼Ê)", "´óÖÚÒøÐÐ(Ïã¸Û)", + "±±¾©Å©ÉÌÒøÐÐ", "ÉϺ£Å©ÉÌÒøÐÐ", "¹ãÖÝÅ©ÉÌÒøÐÐ", "ÉîÛÚÅ©´åÉÌÒµÒøÐÐ"); + List busSmallType = Collections.singletonList("¹«½»³µÕ¾Ïà¹Ø"); + List hospitalSmallType = Arrays.asList("×ÛºÏÒ½Ôº", "Èý¼¶¼×µÈÒ½Ôº", "ר¿ÆÒ½Ôº"); + List schoolSmallType = Arrays.asList("ѧУ", "¸ßµÈԺУ", "ÖÐѧ", "Сѧ", "Ó×¶ùÔ°"); + List subwaySmallType = Collections.singletonList("µØÌúÕ¾"); + List supermarketSmallType = Arrays.asList("É̳¡", "¹ºÎïÖÐÐÄ", "ÆÕͨÉ̳¡"); + + result.put("bank", findAroundByLocation(city, lng, lat, bankSmallType, 1000, true)); + result.put("bus", findAroundByLocation(city, lng, lat, busSmallType, 1000, false)); + result.put("hospital", findAroundByLocation(city, lng, lat, hospitalSmallType, 1000, true)); + result.put("school", findAroundByLocation(city, lng, lat, schoolSmallType, 1000, true)); + result.put("subway", findAroundByLocation(city, lng, lat, subwaySmallType, 1000, false)); + result.put("supermarket", findAroundByLocation(city, lng, lat, supermarketSmallType, 1000, true)); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + return mav; + } + + private List findAroundByLocation(String city, double lng, double lat, List smallTypes, int distance, boolean excludeStatus) { + List poiNames = new ArrayList(); + JSONObject reqBody = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + List mustNotList = new ArrayList(); + + if (excludeStatus) { + JSONObject statusParam = new JSONObject(); + statusParam.put("status", 1); + JSONObject statusTerm = new JSONObject(); + statusTerm.put("term", statusParam); + mustNotList.add(statusTerm); + } + JSONObject mainTypeParam = new JSONObject(); + mainTypeParam.put("main_type", 0); + JSONObject mainTypeTerm = new JSONObject(); + mainTypeTerm.put("term", mainTypeParam); + mustNotList.add(mainTypeTerm); + + JSONObject cityParam = new JSONObject(); + cityParam.put("city", city); + JSONObject cityTerm = new JSONObject(); + cityTerm.put("term", cityParam); + jsonList.add(cityTerm); + + JSONObject smallTypeParam = new JSONObject(); + smallTypeParam.put("small_type", smallTypes); + JSONObject smallTypeTerm = new JSONObject(); + smallTypeTerm.put("terms", smallTypeParam); + jsonList.add(smallTypeTerm); + + JSONObject geoDistance = new JSONObject(); + geoDistance.put("distance", distance + "m"); + geoDistance.put("location", Arrays.asList(lng, lat)); + JSONObject geoQuery = new JSONObject(); + geoQuery.put("geo_distance", geoDistance); + jsonList.add(geoQuery); + + queryJson.put("must", jsonList); + if (!mustNotList.isEmpty()) { + queryJson.put("must_not", mustNotList); + } + JSONObject boolQuery = new JSONObject(); + boolQuery.put("bool", queryJson); + reqBody.put("query", boolQuery); + + Base64 token = new Base64(); + String authEncoding = token.encodeAsString((ES_USER + ":" + ES_PASSWORD).getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authEncoding); + + try { + String response = request.postWithBody("http://192.168.0.89:9200/gaode_map_poi/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + List> hits = (List>) json.getJSONObject("hits").get("hits"); + + for (Map hit : hits) { + Map source = (Map) hit.get("_source"); + if (source.containsKey("name")) { + poiNames.add(source.get("name").toString()); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return poiNames; + } + public void setAmapPoiService(AmapPoiService amapPoiService) { this.amapPoiService = amapPoiService; } @@ -283,4 +398,8 @@ public class PoiController { public void setDistrictService(DistrictService districtService) { this.districtService = districtService; } + + public void setAdministrativeMappingService(AdministrativeMappingService administrativeMappingService) { + this.administrativeMappingService = administrativeMappingService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index adc9f45e3..57f2da122 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -6,6 +6,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; +import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.Charset; import java.text.ParseException; @@ -539,8 +540,12 @@ public class PropertyController { } } + String cat = "district"; + if (StringUtils.isNotBlank(model.getCat())) { + cat = model.getCat(); + } List result = districtService.searchByKeyword(model.getCity(), model.getDistrict(), - model.getKeyword(), "district", sdQuery, PROPERTY_SEARCH_API_FIELDS, model.getMax()); + model.getKeyword(), cat, sdQuery, PROPERTY_SEARCH_API_FIELDS, model.getMax()); if (result.isEmpty() && StringUtils.isNotBlank(model.getKeyword())) { District matchDistrict = matchDistrict(model.getCity(), model.getKeyword(), model.getDistrict(), null); if (matchDistrict != null) { @@ -751,15 +756,22 @@ public class PropertyController { districtInfoDto.setDistrict(district.getRegion()); districtInfoDto.setName(district.getName()); districtInfoDto.setAddress(district.getAddress()); - int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); + //int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); + // ·µ»Ø2B¼Û¸ñ£¬Ð¡³ÌÐòÓã¬ÆäËûÒ²¸ÄΪ2B + int avgPrice = districtStatService.findLatestDistrictAvgPrice2B(new DistrictKey(district), null); if (avgPrice != 0) { districtInfoDto.setAvgPrice(avgPrice); } districtInfoDto.setPropertyType(district.getEstateType2()); if (district.getLat2() != null && district.getLat2() != 0 && district.getLng2() != null && district.getLng2() != 0) { - districtInfoDto.setLat(district.getLat2() / 10000000000D); - districtInfoDto.setLng(district.getLng2() / 10000000000D); + districtInfoDto.setLat2(district.getLat2() / 10000000000D); + districtInfoDto.setLng2(district.getLng2() / 10000000000D); + } + if (district.getLat() != null && district.getLat() != 0 && district.getLng() != null + && district.getLng() != 0) { + districtInfoDto.setLat(district.getLat() / 10000000000D); + districtInfoDto.setLng(district.getLng() / 10000000000D); } } @@ -820,9 +832,14 @@ public class PropertyController { districtInfoDto.setTransportation(district.getTraffic()); districtInfoDto.setRelatedInfo(district.getRelateInfo()); districtInfoDto.setDescription(district.getDescription()); + districtInfoDto.setEstateCharge(district.getEstateCharge()); + districtInfoDto.setRegister(district.getRegister()); + districtInfoDto.setElevatorsCount(district.getElevatorsCount()); districtInfoDto.setSalesOfficeAdd(district.getSellAddress()); districtInfoDto.setSalesPhoneNumber(district.getMobile()); districtInfoDto.setTownship(district.getTownship()); + districtInfoDto.setBedKind(district.getBedKind()); + districtInfoDto.setEstateType2(district.getEstateType2()); if (district.getLoudongCount() != null && district.getLoudongCount() > 0) { districtInfoDto.setBuildingCount(district.getLoudongCount()); } @@ -1055,7 +1072,7 @@ public class PropertyController { mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName()) || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0 || model.getCity().contains("È«¹ú") - || model.getDistrict().contains("È«¹ú")) { + || model.getDistrict().contains("È«¹ú")) { mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐ,ÇøÓò,Ð¡ÇøÃû,Ãæ»ý(size)Ϊ±ØÌîÏî")); return mav; } @@ -1645,8 +1662,8 @@ public class PropertyController { json = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8"); if (json.containsKey("msg") && "³É¹¦".equals(json.getString("msg"))) { HashMap resultMap = new HashMap(); - resultMap.put("avgPrice",json.getString("unitPrice")); - resultMap.put("totalPrice",json.getString("totalPrice")); + resultMap.put("avgPrice", json.getString("unitPrice")); + resultMap.put("totalPrice", json.getString("totalPrice")); mav.setModel(BasicModel.buildOKModel().setResult(resultMap)); } else { mav.setModel(BasicModel.buildBadRequestModel("¸ÃµØÖ·²»Ö§³Ö¹À¼Û£¡")); @@ -2426,7 +2443,11 @@ public class PropertyController { item.put("city", districtStat.getCity()); item.put("district", districtStat.getRegion()); item.put("name", districtStat.getDistrictName()); - item.put("avgPrice", districtStat.getAvgPrice()); + if (districtStat.getAvg_price_2b() != null) { + item.put("avgPrice", districtStat.getAvg_price_2b()); + } else { + item.put("avgPrice", districtStat.getAvgPrice()); + } if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM")); } else { @@ -2513,20 +2534,21 @@ public class PropertyController { mav.setModel(BasicModel.buildBadRequestModel("²ÎÊýȱʧ:cat(×â½ðÀàÐÍ)ÊDZØÐë²ÎÊý")); return mav; } - if ("city".equals(model.getCity()) && StringUtils.isBlank(model.getCity())) { + if ("city".equals(model.getCat()) && StringUtils.isBlank(model.getCity())) { mav.setModel(BasicModel.buildBadRequestModel("³ÇÊÐÆ½Ã××â½ð,city(³ÇÊÐ)ÊDZØÐë²ÎÊý")); return mav; } - if ("region".equals(model.getCity()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()))) { + if ("region".equals(model.getCat()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()))) { mav.setModel(BasicModel.buildBadRequestModel("ÇøÓòƽÃ××â½ð,city(³ÇÊÐ),district(ÇøÓò)ÊDZØÐë²ÎÊý")); return mav; } - if ("district".equals(model.getCity()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName()))) { + if ("district".equals(model.getCat()) && (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName()))) { mav.setModel(BasicModel.buildBadRequestModel("Ð¡ÇøÆ½Ã××â½ð,city(³ÇÊÐ),district(ÇøÓò),name(Ð¡ÇøÃû)ÊDZØÐë²ÎÊý")); return mav; } + District district = null; if ("district".equals(model.getCat())) { - District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); if (null == district) { mav.setModel(BasicModel.buildBadRequestModel("Ð¡Çø²»´æÔÚ")); @@ -2542,7 +2564,7 @@ public class PropertyController { } Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -model.getPeriodCount()); - List sqmetreRents = sqmetreRentService.findSqmetreRents(RegionData.formatCity(model.getCity()), RegionData.formatRegion(model.getCity(), model.getDistrict()), model.getName(), model.getCat(), startDate, null); + List sqmetreRents = sqmetreRentService.findSqmetreRents(RegionData.formatCity(model.getCity()), RegionData.formatRegion(model.getCity(), model.getDistrict()), district.getName(), model.getCat(), startDate, null); List> result = new ArrayList>(model.getPeriodCount()); for (SqmetreRent sqmetreRent : sqmetreRents) { @@ -2583,9 +2605,10 @@ public class PropertyController { int total = Integer.valueOf(rankDesc[1]); UniversalDto dto = new UniversalDto(); dto.append("relativeRank", DataUtil.roundDouble(((total - rank) / (double) total) * 100, 2)); - + dto.append("rank", districtAnalyData.getCityRank()); if (null != districtAnalyData.getRegionRank()) { dto.append("regionRelativeRank", DataUtil.roundDouble(((districtAnalyData.getRegionRankTotal() - districtAnalyData.getRegionRank()) / (double) districtAnalyData.getRegionRankTotal()) * 100, 2)); + dto.append("regionRank", districtAnalyData.getRegionRank()); } mav.setModel(BasicModel.buildOKModel().setResult(dto)); } else { @@ -5879,7 +5902,8 @@ public class PropertyController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("address", district.getAddress()); districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); - districtPriceMap.put("cal_date", model.getCalDate()); + //districtPriceMap.put("cal_date", model.getCalDate()); + districtPriceMap.put("unitPrice", new BigDecimal(evaluation.getTotalPrice() / evaluation.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); return mav; } else { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java new file mode 100644 index 000000000..3afc679c3 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopController.java @@ -0,0 +1,614 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.ReportApplyModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; +import com.fangjia.service.address.AddressParser; +import com.fangjia.service.datastore.FieldFilterService; +import com.fangjia.service.datastore.AiShopService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * ÉÌÆÌ³ö×â·þÎñÀà + * + * @author shenjian + * @since 2025/4/10 + */ +@Authority(role = Role.USER) +public class ShopController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private AiShopService aiShopService; + + private OpenApiLogService openApiLogService; + + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + + /** + * ³ÇÊгö×â¾ù¼Û + * + * @return + */ + public Object cityRentAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ã³ÇÊÐûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * ÇøÓò³ö×â¾ù¼Û + * + * @return + */ + public Object districtRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸ÃÇøÓòûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×ÖÂ¥¾ù¼Û×ßÊÆ + * + * @return + */ + public Object shopRentAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = aiShopService.findShopRentStat(city, region, name, "shop", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ãд×Ö¥ûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×Ö¥¥×â½ðµØÖ·¹ÀÖµ + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateRentAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐ,µØÖ·,Ãæ»ý(size)Ϊ±ØÌîÏî")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + + 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; + } + + ShopEvaluationDto evaluation = aiShopService.addressEvaluateRent(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/shop/addressEvaluateRent"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("ÔÝʱ²»Ö§³Ö¸ÃµØÖ·Ð´×ÖÂ¥µÄÆÀ¹À").markNoData()); + return mav; + } + } + + /** + * ÉêÇë¹ÀÖµ±¨¸æ + * + * @param model ÉêÇ뱨¸æÇëÇó²ÎÊý + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:ίÍлú¹¹Îª±ØÌîÏî")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:±êµÄÎïΪ±ØÌîÏî")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐΪ±ØÌîÏîÇÒ²»ÄÜΪȫ¹ú")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:ÇøÓòΪ±ØÌîÏîÇÒ²»ÄÜΪȫ¹ú")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:Ãæ»ý(size)Ϊ±ØÌîÏîÇÒ´óÓÚ0")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + if (model.getDistrict().endsWith("Çø")) { + model.setDistrict(model.getDistrict().replaceAll("Çø$", "")); + } + 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; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇë¹ÀÖµ±¨¸æÊ§°Ü£º" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇë¹ÀÖµ±¨¸æÊ§°Ü£ºµ÷ÓÃÉêÇ뱨¸æ½Ó¿Ú·µ»ØÎª¿Õ")); + } + return mav; + } + + /** + * »ñÈ¡¹ÀÖµ±¨¸æ + * + * @param caseId ¹ÀÖµ±¨¸æID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:¹ÀÖµ±¨¸æÒµÎñ±àºÅΪ±ØÌîÏî")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("»ñÈ¡¹ÀÖµ±¨¸æÊ§°Ü£º" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇ뱨¸æÊ§°Ü£ºµ÷ÓûñÈ¡¹ÀÖµ±¨¸æ½Ó¿Ú·µ»ØÎª¿Õ")); + } + 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; + } + + /** + * ͨ¹ýEvaluationModel×é×°EvaluationʵÌå + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + 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 floorDesc = "ÖÐ"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "µÍ"; + } else if (floorInfo > 0.66) { + floorDesc = "¸ß"; + } + evaluation.setFloorDesc(floorDesc); + } + 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_shop_evaluateRent"); + return evaluation; + } + + 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", "»î¶¯ÖÐÐÄ"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } + + public void setAiShopService(AiShopService aiShopService) { + this.aiShopService = aiShopService; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java new file mode 100644 index 000000000..9aae9fb84 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ShopSellController.java @@ -0,0 +1,614 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.AnalyticsUtil; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.LoggerFactory; +import com.fangjia.dal.common.ServerAreaData; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.open.HttpCode; +import com.fangjia.open.OpenHttpCodeEnum; +import com.fangjia.open.interceptors.AuthenticationBean; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.PropertyEvaluationModel; +import com.fangjia.open.model.ReportApplyModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.util.CommonUtils; +import com.fangjia.open.util.FangJiaTongUrl; +import com.fangjia.service.address.AddressParser; +import com.fangjia.service.datastore.AiShopService; +import com.fangjia.service.datastore.FieldFilterService; +import com.fangjia.service.datastore.OpenApiLogService; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.fangjia.open.util.CommonUtils.convertToString; +import static com.fangjia.open.util.EvaluationFactorUtil.*; + +/** + * ÉÌÆÌ³öÊÛ·þÎñÀà + * + * @author shenjian + * @since 2025/4/14 + */ +@Authority(role = Role.USER) +public class ShopSellController { + + private static final Logger LOGGER = LoggerFactory.getLogger(PropertyController.class); + + private AiShopService aiShopService; + + private OpenApiLogService openApiLogService; + + private AddressParser addressParser; + private FieldFilterService fieldFilterService; + + /** + * ³ÇÊгö×â¾ù¼Û + * + * @return + */ + public Object citySellAction(@Param(name = "city") String city, @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, null, null, "city", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ã³ÇÊÐûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * ÇøÓò³ö×â¾ù¼Û + * + * @return + */ + public Object districtSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "startDate") Integer startDate, @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, region, null, "district", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸ÃÇøÓòûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×ÖÂ¥¾ù¼Û×ßÊÆ + * + * @return + */ + public Object shopSellAction(@Param(name = "city") String city, @Param(name = "district") String district, + @Param(name = "name") String name, @Param(name = "startDate") Integer startDate, + @Param(name = "endDate") Integer endDate) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(BasicModel.buildBadRequestModel("city²»ÄÜΪnull")); + return mav; + } + if (StringUtils.isBlank(district)) { + mav.setModel(BasicModel.buildBadRequestModel("district²»ÄÜΪnull")); + return mav; + } + if (!RegionData.isCity(city)) { + String formatCity = RegionData.formatCity(city); + if (StringUtils.isNotBlank(formatCity)) { + city = formatCity; + } else { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + } + ServerArea serverArea = ServerAreaData.getServerAreaByCity(city); + if (null == serverArea) { + mav.setModel(BasicModel.buildBadRequestModel("city·Ç·¨")); + return mav; + } + String region = RegionData.formatRegion(city, district); + if (!RegionData.isRegion(city, region)) { + mav.setModel(BasicModel.buildBadRequestModel("ûÓÐÕÒÄãÊäÈëµÄÇøÓò")); + return mav; + } + + if (startDate == null || endDate == null) { + mav.setModel(BasicModel.buildBadRequestModel("startDate»òendDate²»ÄÜΪnull")); + return mav; + } + if (startDate > endDate) { + mav.setModel(BasicModel.buildBadRequestModel("startDate²»ÄÜ´óÓÚendDate")); + return mav; + } + + List regionStats = aiShopService.findShopSellStat(city, region, name, "shop", startDate, endDate); + + if (CollectionUtils.isEmpty(regionStats)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "¸Ãд×Ö¥ûÓоù¼ÛÊý¾Ý")); + return mav; + } + mav.setModel(BasicModel.buildOKModel().setResult(regionStats)); + return mav; + } + + /** + * д×Ö¥¥×â½ðµØÖ·¹ÀÖµ + * + * @param model + * @param request + * @return + */ + public Object addressEvaluateSellAction(PropertyEvaluationModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getAddress()) || model.getSize() <= 0) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐ,µØÖ·,Ãæ»ý(size)Ϊ±ØÌîÏî")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + + 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; + } + + ShopEvaluationDto evaluation = aiShopService.addressEvaluateSell(buildEvaluation(model, request)); + + if (evaluation.getUnitPrice() != null && evaluation.getUnitPrice() != 0) { + Map districtPriceMap = new HashMap(); + districtPriceMap.put("unitPrice", evaluation.getUnitPrice()); + districtPriceMap.put("city", evaluation.getCity()); + districtPriceMap.put("district", evaluation.getDistrict()); + districtPriceMap.put("name", evaluation.getName()); + districtPriceMap.put("samples", evaluation.getSeawater()); + districtPriceMap.put("location", evaluation.getLocation()); + + mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); + try { + if (StringUtils.isNotBlank(evaluation.getFromUserId()) && !evaluation.getFromUserId().equals("1007497")) { + openApiLogService.saveLog(CommonUtils.convertToMap(model), districtPriceMap, evaluation, "/shop/addressEvaluateSell"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return mav; + } else { + mav.setModel(BasicModel.buildOKModel().setMsg("ÔÝʱ²»Ö§³Ö¸ÃµØÖ·Ð´×ÖÂ¥µÄÆÀ¹À").markNoData()); + return mav; + } + } + + /** + * ÉêÇë¹ÀÖµ±¨¸æ + * + * @param model ÉêÇ뱨¸æÇëÇó²ÎÊý + * @return + */ + public Object assessPriceReportApplyAction(ReportApplyModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getClient())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:ίÍлú¹¹Îª±ØÌîÏî")); + return mav; + } + if (StringUtils.isBlank(model.getSubjectMatter())) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:±êµÄÎïΪ±ØÌîÏî")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || model.getCity().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:³ÇÊÐΪ±ØÌîÏîÇÒ²»ÄÜΪȫ¹ú")); + return mav; + } + if (StringUtils.isBlank(model.getDistrict()) || model.getDistrict().contains("È«¹ú")) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:ÇøÓòΪ±ØÌîÏîÇÒ²»ÄÜΪȫ¹ú")); + return mav; + } + if (model.getSize() == null || model.getSize() <= 0 ) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:Ãæ»ý(size)Ϊ±ØÌîÏîÇÒ´óÓÚ0")); + return mav; + } + if (model.getCity().endsWith("ÊÐ")) { + model.setCity(model.getCity().replaceAll("ÊÐ$", "")); + } + if (model.getDistrict().endsWith("Çø")) { + model.setDistrict(model.getDistrict().replaceAll("Çø$", "")); + } + 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; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("client", model.getClient()); + params.put("subjectMatter", model.getSubjectMatter()); + params.put("city", model.getCity()); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + params.put("district", model.getDistrict()); + params.put("name", StringUtils.isNotBlank(model.getName()) ? model.getName() : null); + params.put("houseNum", StringUtils.isNotBlank(model.getBuildingNumber()) ? model.getBuildingNumber() : null); + params.put("roomNum", StringUtils.isNotBlank(model.getUnitNumber()) ? model.getUnitNumber() : null); + params.put("size", String.valueOf(model.getSize())); + params.put("houseFloor", model.getFloor() != null ? String.valueOf(model.getFloor()) : null); + params.put("houseHeight", model.getMaxFloor() != null ? String.valueOf(model.getMaxFloor()) : null); + params.put("buildType", StringUtils.isNotBlank(model.getPropertyType()) ? model.getPropertyType() : "0"); + params.put("direction", StringUtils.isNotBlank(model.getDirection()) ? model.getDirection() : "3"); + params.put("fitment", StringUtils.isNotBlank(model.getDecoration()) ? model.getDecoration() : "2"); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_APPLY, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + HashMap result = new HashMap(); + result.put("caseId", String.valueOf(json.get("data"))); + mav.setModel(BasicModel.buildOKModel().setResult(result)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇë¹ÀÖµ±¨¸æÊ§°Ü£º" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇë¹ÀÖµ±¨¸æÊ§°Ü£ºµ÷ÓÃÉêÇ뱨¸æ½Ó¿Ú·µ»ØÎª¿Õ")); + } + return mav; + } + + /** + * »ñÈ¡¹ÀÖµ±¨¸æ + * + * @param caseId ¹ÀÖµ±¨¸æID + * @return + */ + public Object assessPriceReportFetchAction(@Param(name = "caseId") String caseId) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(caseId)) { + mav.setModel(BasicModel.buildBadRequestModel("²ÎÊý·Ç·¨:¹ÀÖµ±¨¸æÒµÎñ±àºÅΪ±ØÌîÏî")); + return mav; + } + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("caseId", caseId); + JSONObject jsonObject = JSONObject.fromObject(params); + Map headers = new HashMap(); + headers.put("Authorization", "Bearer " + FangJiaTongUrl.FANG_JIA_TONG_TOKEN); + headers.put("Content-Type", "application/json"); + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception e) { + try { + String ret = request.postWithBody(FangJiaTongUrl.FANG_JIA_TONG_URL_UAT + FangJiaTongUrl.ASSESS_PRICE_REPORT_FETCH, jsonObject, headers, "UTF-8"); + json = JSONObject.fromObject(FangJiaTongUrl.replaceAll(ret)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + if (json != null) { + if (json.getInt("code") == 200 && json.containsKey("data")) { + JSONObject resultJson = json.getJSONObject("data"); + mav.setModel(BasicModel.buildOKModel().setResult(resultJson)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("»ñÈ¡¹ÀÖµ±¨¸æÊ§°Ü£º" + json.getString("message"))); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("ÉêÇ뱨¸æÊ§°Ü£ºµ÷ÓûñÈ¡¹ÀÖµ±¨¸æ½Ó¿Ú·µ»ØÎª¿Õ")); + } + 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; + } + + /** + * ͨ¹ýEvaluationModel×é×°EvaluationʵÌå + * + * @param model + * @param request + * @return + */ + private Evaluation buildEvaluation(PropertyEvaluationModel model, HttpServletRequest request) { + Evaluation evaluation = new Evaluation(); + evaluation.setLevel(model.getLevel()); + evaluation.setFitment(model.getFitment()); + evaluation.setType(model.getType()); + + evaluation.setCity(model.getCity()); + evaluation.setRegion(model.getRegion()); + evaluation.setDistrictName(model.getName()); + evaluation.setAddress(model.getAddress()); + evaluation.setDirection(model.getDirection()); + evaluation.setNoise(NOISE.get(model.getNoise())); + evaluation.setType(model.getType()); + 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 floorDesc = "ÖÐ"; + if (evaluation.getFloor() != null && evaluation.getHeight() != null) { + Double floorInfo = evaluation.getFloor() * 1.0 / evaluation.getHeight(); + if (floorInfo <= 0.33) { + floorDesc = "µÍ"; + } else if (floorInfo > 0.66) { + floorDesc = "¸ß"; + } + evaluation.setFloorDesc(floorDesc); + } + 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_shop_evaluateRent"); + return evaluation; + } + + 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", "»î¶¯ÖÐÐÄ"); + } + }; + + public void setOpenApiLogService(OpenApiLogService openApiLogService) { + this.openApiLogService = openApiLogService; + } + + public void setFieldFilterService(FieldFilterService fieldFilterService) { + this.fieldFilterService = fieldFilterService; + } + + public void setAiShopService(AiShopService aiShopService) { + this.aiShopService = aiShopService; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/SqmetreRentController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/SqmetreRentController.java new file mode 100644 index 000000000..313fa748a --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/SqmetreRentController.java @@ -0,0 +1,267 @@ +package com.fangjia.open.controllers; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.mongo.model.SqmetreRent; +import com.fangjia.dal.seaweed.model.District; +import com.fangjia.open.interceptors.Authority; +import com.fangjia.open.interceptors.Role; +import com.fangjia.open.model.AvgPriceQueryModel; +import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.district.SqmetreRentService; +import org.apache.commons.lang.StringUtils; + +import java.util.*; + +/** + * ƽÃ××â½ð + */ +@Authority(role = Role.USER) +public class SqmetreRentController { + + private SqmetreRentService sqmetreRentService; + private DistrictService districtService; + + + /** + * ³ÇÊÐÆ½Ã××â½ð + * + * @param model + * @return + */ + public Object cityAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + model.setCat("city"); + + // УÑé³ÇÊвÎÊý + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(³ÇÊÐ)ÊDZØÐë²ÎÊý")); + return mav; + } + + // ÉèÖÃĬÈÏ periodCount ²¢Ð£Ñ鷶Χ + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCountÖµ²»ºÏ·¨,ȡֵ·¶Î§ÊÇ£º[1-156]")); + return mav; + } + + // ¼ÆËãÆðʼÈÕÆÚ + Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -(model.getPeriodCount() + 1)); + + // ²éѯƽÃ××â½ðÊý¾Ý + List sqmetreRents = sqmetreRentService.findSqmetreRents( + RegionData.formatCity(model.getCity()), + RegionData.formatRegion(model.getCity(), model.getDistrict()), + model.getName(), + model.getCat(), + startDate, + null + ); + + // ×¼±¸½á¹ûÁбí + List> result = new ArrayList>(model.getPeriodCount()); + Double lastMonthRent = null; + + // ±éÀú²¢Ìî³ä½á¹û + if (sqmetreRents != null && !sqmetreRents.isEmpty()) { + for (SqmetreRent sqmetreRent : sqmetreRents) { + Map item = new LinkedHashMap(); + item.put("city", sqmetreRent.getCity()); + Integer currentRent = (sqmetreRent.getAvgPrice() != null) ? sqmetreRent.getAvgPrice().intValue() : 0; + item.put("rent", currentRent); + item.put("date", sqmetreRent.getWeekend() != null ? DateUtil.formatByPattern(sqmetreRent.getWeekend(), "yyyy-MM") : "δ֪ÈÕÆÚ"); + + // ¼ÆËãÔÂÕÇ·ù + if (lastMonthRent != null && lastMonthRent != 0) { + double changePercent = ((double) currentRent - lastMonthRent) / lastMonthRent; + item.put("changePercent", Double.valueOf(String.format("%.2f", changePercent))); + } else { + item.put("changePercent", null); + } + + lastMonthRent = (double) currentRent; + result.add(item); + } + } + + // ÉèÖ÷µ»Ø½á¹û£¬·ÀÖ¹ subList Ô½½ç + if (result.size() > 1) { + mav.setModel(BasicModel.buildOKModel().setResult(result.subList(1, result.size()))); + } else { + mav.setModel(BasicModel.buildOKModel().setResult(null)); + } + return mav; + } + /** + * ÇøÓòƽÃ××â½ð + * + * @param model + * @return + */ + public Object districtAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + model.setCat("region"); + + // УÑé³ÇÊвÎÊý + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("city(³ÇÊÐ),district(ÇøÓò)ÊDZØÐë²ÎÊý")); + return mav; + } + + // ÉèÖÃĬÈÏ periodCount ²¢Ð£Ñ鷶Χ + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCountÖµ²»ºÏ·¨,ȡֵ·¶Î§ÊÇ£º[1-156]")); + return mav; + } + + // ¼ÆËãÆðʼÈÕÆÚ + Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -(model.getPeriodCount() + 1)); + + // ²éѯƽÃ××â½ðÊý¾Ý + List sqmetreRents = sqmetreRentService.findSqmetreRents( + RegionData.formatCity(model.getCity()), + RegionData.formatRegion(model.getCity(), model.getDistrict()), + model.getName(), + model.getCat(), + startDate, + null + ); + + // ×¼±¸½á¹ûÁбí + List> result = new ArrayList>(model.getPeriodCount()); + Double lastMonthRent = null; + + // ±éÀú²¢Ìî³ä½á¹û + if (sqmetreRents != null && !sqmetreRents.isEmpty()) { + for (SqmetreRent sqmetreRent : sqmetreRents) { + Map item = new LinkedHashMap(); + item.put("city", sqmetreRent.getCity()); + item.put("district", sqmetreRent.getRegion()); + Integer currentRent = (sqmetreRent.getAvgPrice() != null) ? sqmetreRent.getAvgPrice().intValue() : 0; + item.put("rent", currentRent); + item.put("date", sqmetreRent.getWeekend() != null ? DateUtil.formatByPattern(sqmetreRent.getWeekend(), "yyyy-MM") : "δ֪ÈÕÆÚ"); + + // ¼ÆËãÔÂÕÇ·ù + if (lastMonthRent != null && lastMonthRent != 0) { + double changePercent = ((double) currentRent - lastMonthRent) / lastMonthRent; + item.put("changePercent", Double.valueOf(String.format("%.2f", changePercent))); + } else { + item.put("changePercent", null); + } + + lastMonthRent = (double) currentRent; + result.add(item); + } + } + + // ÉèÖ÷µ»Ø½á¹û£¬·ÀÖ¹ subList Ô½½ç + if (result.size() > 1) { + mav.setModel(BasicModel.buildOKModel().setResult(result.subList(1, result.size()))); + } else { + mav.setModel(BasicModel.buildOKModel().setResult(null)); + } + return mav; + } + /** + * Ð¡ÇøÆ½Ã××â½ð + * + * @param model + * @return + */ + public Object propertyAction(AvgPriceQueryModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + model.setCat("district"); + + // УÑé³ÇÊвÎÊý + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("city(³ÇÊÐ),district(ÇøÓò),name(Ð¡ÇøÃû)ÊDZØÐë²ÎÊý")); + return mav; + } + District district = null; + if ("district".equals(model.getCat())) { + district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), + "district"); + if (null == district) { + mav.setModel(BasicModel.buildBadRequestModel("¸ÃÐ¡Çø²»´æÔÚ")); + return mav; + } + } + + // ÉèÖÃĬÈÏ periodCount ²¢Ð£Ñ鷶Χ + if (model.getPeriodCount() == null) { + model.setPeriodCount(1); + } + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { + mav.setModel(BasicModel.buildBadRequestModel("periodCountÖµ²»ºÏ·¨,ȡֵ·¶Î§ÊÇ£º[1-156]")); + return mav; + } + + // ¼ÆËãÆðʼÈÕÆÚ + Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -(model.getPeriodCount() + 1)); + + // ²éѯƽÃ××â½ðÊý¾Ý + List sqmetreRents = sqmetreRentService.findSqmetreRents( + RegionData.formatCity(model.getCity()), + RegionData.formatRegion(model.getCity(), model.getDistrict()), + district.getName(), + model.getCat(), + startDate, + null + ); + + // ×¼±¸½á¹ûÁбí + List> result = new ArrayList>(model.getPeriodCount()); + Double lastMonthRent = null; + + // ±éÀú²¢Ìî³ä½á¹û + if (sqmetreRents != null && !sqmetreRents.isEmpty()) { + for (SqmetreRent sqmetreRent : sqmetreRents) { + Map item = new LinkedHashMap(); + item.put("city", sqmetreRent.getCity()); + item.put("district", sqmetreRent.getRegion()); + item.put("name", sqmetreRent.getDistrictName()); + Integer currentRent = (sqmetreRent.getAvgPrice() != null) ? sqmetreRent.getAvgPrice().intValue() : 0; + item.put("rent", currentRent); + item.put("date", sqmetreRent.getWeekend() != null ? DateUtil.formatByPattern(sqmetreRent.getWeekend(), "yyyy-MM") : "δ֪ÈÕÆÚ"); + + // ¼ÆËãÔÂÕÇ·ù + if (lastMonthRent != null && lastMonthRent != 0) { + double changePercent = ((double) currentRent - lastMonthRent) / lastMonthRent; + item.put("changePercent", Double.valueOf(String.format("%.2f", changePercent))); + } else { + item.put("changePercent", null); + } + + lastMonthRent = (double) currentRent; + result.add(item); + } + } + + // ÉèÖ÷µ»Ø½á¹û£¬·ÀÖ¹ subList Ô½½ç + if (result.size() > 1) { + mav.setModel(BasicModel.buildOKModel().setResult(result.subList(1, result.size()))); + } else { + mav.setModel(BasicModel.buildOKModel().setResult(null)); + } + return mav; + } + + public void setSqmetreRentService(SqmetreRentService sqmetreRentService) { + this.sqmetreRentService = sqmetreRentService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index 6ad4b19bc..17ab2c4b2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -6,6 +6,7 @@ import com.fangjia.dal.QueryParam; import com.fangjia.dal.SdQuery; import com.fangjia.dal.SrQuery; import com.fangjia.dal.common.DistrictKey; +import com.fangjia.dal.mongo.model.SeaweedImages; import com.fangjia.dal.seaweed.model.District; import com.fangjia.dal.sql.model.FjtUsers; import com.fangjia.open.compatible.model.JsonModel; @@ -18,6 +19,7 @@ import com.fangjia.service.bo.DistrictStatRentBo; import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.district.DistrictStatRentService; import com.fangjia.service.district.DistrictStatService; +import com.fangjia.service.mongo.fangjia.SeaweedImagesService; import com.fangjia.service.sql.FjtUsersService; import com.fangjia.service.sql.UserCityService; import com.fangjia.service.user.UsersInfoService; @@ -44,7 +46,9 @@ public class DistrictController { private DistrictStatRentService districtStatRentService; private DistrictStatService districtStatService; private UserCityService userCityService; - private FjtUsersService fjtUsersService; + private FjtUsersService fjtUsersService; + + private SeaweedImagesService seaweedImagesService; /********************************************* new start *****************************************************/ /** @@ -55,14 +59,14 @@ public class DistrictController { * @param keyword * @return */ - public Object suggestAction( @Param(name = "city") String city, @Param(name = "cat") String cat, @Param(name = "keyword") String keyword, - @Param(name = "limit") Integer limit,@Param(name="lat")Double lat, @Param(name="lng")Double lng) { + public Object suggestAction(@Param(name = "city") String city, @Param(name = "cat") String cat, @Param(name = "keyword") String keyword, + @Param(name = "limit") Integer limit, @Param(name = "lat") Double lat, @Param(name = "lng") Double lng) { JsonModel model = new JsonModel(); if (limit == null || limit > 100 || limit <= 0) { limit = 10; } System.out.println(cat + "#" + city + "#" + keyword + "#" + limit + "#" + lng + "#" + lat); - List suggestList = getDistrictByKeyword(cat, city, keyword, limit, lng, lat); + List suggestList = getDistrictByKeyword(cat, city, keyword, limit, lng, lat); model.setJsonModel(suggestList); return model; } @@ -75,25 +79,30 @@ public class DistrictController { String login_user_type = CookieUtils.getCookieValue(request, "login_user_type"); //±£´æÆóÒµÓû§Ñ¡ÔñµÄ³ÇÊÐ,ÆóÒµÓû§7Ìì - String weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id"); + String weiXinId = CookieUtils.getCookieValue(request, "we_chat_open_id"); // if(StringUtils.isBlank(login_user_type) || StringUtils.isBlank(weiXinId)){ // response.sendRedirect("/coming"); // return null; // } - if("b".equals(login_user_type) || "gb".equals(login_user_type)){ - CacheUtils.putValue(CachePolicyEnum.LONG, UsersInfoService.class, weiXinId + "_city_"+ login_user_type , model.getCityName()); - } - Long userId = Long.parseLong(CookieUtils.getCookieValue(request,"login_user_id")); - if(userId != null){ - FjtUsers users = fjtUsersService.findById(userId); - if(users != null){ - model.setRole(users.getRole()); - } - } + if ("b".equals(login_user_type) || "gb".equals(login_user_type)) { + CacheUtils.putValue(CachePolicyEnum.LONG, UsersInfoService.class, weiXinId + "_city_" + login_user_type, model.getCityName()); + } + try { + Long userId = Long.parseLong(CookieUtils.getCookieValue(request, "login_user_id")); + if (userId != null) { + FjtUsers users = fjtUsersService.findById(userId); + if (users != null) { + model.setRole(users.getRole()); + } + } + } catch (Exception ex) { + + } model.setType(login_user_type); return model; } + private List getDistrictByKeyword(String cat, String city, String keyword, int limit, final Double lng, final Double lat) { keyword = DataUtil.escapeSolr(keyword); @@ -109,14 +118,14 @@ public class DistrictController { BooleanQuery srQuery1 = new BooleanQuery(); BooleanQuery nameQuery = new BooleanQuery(); - // nameQuery.add(new TermQuery(new Term("district_name", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("alias_std", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("address", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("addr_alias_std", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("district_name", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("alias_std", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("address", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("addr_alias_std", keyword)), BooleanClause.Occur.SHOULD); nameQuery.add(new TermQuery(new Term("keyword", keyword)), BooleanClause.Occur.SHOULD); //nameQuery.add(new TermQuery(new Term("keyword_cjk", keyword)), BooleanClause.Occur.SHOULD);//Õâ¸öÖØÒª£¬Òòseaweed²»Ö§³ÖÄ£ºýËÑË÷£¬µ±ÊäÈë"ÖÐÔ¶Á½"ÐèÓô˽øÐÐËÑË÷ srQuery1.add(nameQuery, BooleanClause.Occur.SHOULD); - if(lat != null && lng != null && lat != 0 && lng != 0){ + if (lat != null && lng != null && lat != 0 && lng != 0) { Map geo = GeocodeUtils.geoconvBaiduToGoogle(lng, lat); SdQuery sdQuery = new SdQuery(); sdQuery.setPoint(geo.get("lat") + "," + geo.get("lng")); @@ -125,7 +134,7 @@ public class DistrictController { params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); } params.add(new QueryParam("$sr", new SrQuery(srQuery1))); - List districts = districtService.findAllByParams(params, 0, limit, new String[]{"region", "name", "address", "addrAlias","id"}); + List districts = districtService.findAllByParams(params, 0, limit, new String[]{"region", "name", "address", "addrAlias", "id", "alias"}); List ret = new ArrayList(districts.size()); for (District district : districts) { AutoCompleteBo bo = new AutoCompleteBo(); @@ -134,24 +143,42 @@ public class DistrictController { bo.setDesc(district.getAddress()); bo.setRegion(district.getRegion()); bo.setId(district.getId()); + if (!district.getName().contains(keyword)) { + if (district.getAlias() != null && !district.getAlias().isEmpty()) { + for (String alias : district.getAlias()) { + if (alias.contains(keyword)) { + bo.setAlias(alias); + break; + } + } + } + if (district.getAddrAlias() != null && !district.getAddrAlias().isEmpty()) { + for (String addrAlias : district.getAddrAlias()) { + if (addrAlias.contains(keyword)) { + bo.setAddrAlias(addrAlias); + break; + } + } + } + } ret.add(bo); } return ret; } - public Object districtDetailAction(DistrictModel districtModel,HttpServletRequest request,HttpServletResponse response) { + public Object districtDetailAction(DistrictModel districtModel, HttpServletRequest request, HttpServletResponse response) { //idºÍname²»ÄÜͬʱΪ¿Õ - if(StringUtils.isBlank(districtModel.getId()) && (StringUtils.isBlank(districtModel.getCityName()) || StringUtils.isBlank(districtModel.getName()))) { + if (StringUtils.isBlank(districtModel.getId()) && (StringUtils.isBlank(districtModel.getCityName()) || StringUtils.isBlank(districtModel.getName()))) { districtModel.setMsg("²ÎÊý´íÎó"); return districtModel; } District district = null; - if(StringUtils.isNotBlank(districtModel.getId())) { + if (StringUtils.isNotBlank(districtModel.getId())) { district = districtService.findById(districtModel.getId()); - if(district != null) { + if (district != null) { districtModel.setCityName(district.getCity()); districtModel.setRegion(district.getRegion()); districtModel.setName(district.getName()); @@ -167,24 +194,26 @@ public class DistrictController { String userId = CookieUtils.getCookieValue(request, "login_user_id"); - //Ð¡Çø×â½ð List districtStatRentBos = districtStatRentService.findAllHouseTypeByDistrictStatRent(new DistrictKey(district)); //´¦ÀíͼƬÁ´½Ó - List outPics = Lists.newArrayList(); - if(district.getOutPics() != null) { - for (String outPic : district.getOutPics()) { -// outPics.add(districtModel.getPicUrl() + DataUtil.encodePicUrl(outPic, "s", "district")); - outPics.add("http://static.fangjia.com/stc/fs/" + DataUtil.encodePicUrl(outPic, "s", "district")); - } +// List outPics = Lists.newArrayList(); +// if(district.getOutPics() != null) { +// for (String outPic : district.getOutPics()) { +//// outPics.add(districtModel.getPicUrl() + DataUtil.encodePicUrl(outPic, "s", "district")); +// outPics.add("http://static.fangjia.com/stc/fs/" + DataUtil.encodePicUrl(outPic, "s", "district")); +// } +// } + SeaweedImages seaweedImages = seaweedImagesService.findById(district.getId()); + if (seaweedImages != null) { + district.setOutPics(seaweedImages.getOutPics()); } - district.setOutPics(outPics); districtModel.setDistrict(district); districtModel.setDistrictStatBo(districtStatBo); districtModel.setDistrictStatRentBos(districtStatRentBos); - String city=request.getParameter("city"); - boolean is=true; + String city = request.getParameter("city"); + boolean is = true; if (null != districtStatBo && null != districtStatBo.getDefaultDistrictStat()) { double credit = districtStatBo.getDefaultDistrictStat().getCredit(); @@ -203,7 +232,7 @@ public class DistrictController { } else { is = true; } - if(!is){ + if (!is) { try { response.sendRedirect("wrongPrice"); } catch (Exception e) { @@ -213,7 +242,6 @@ public class DistrictController { } - private DistrictStatBo getDistrictStat(DistrictKey districtKey) { District district = districtService.findDistrict(districtKey, true); DistrictStatBo statBo = null; @@ -227,8 +255,8 @@ public class DistrictController { // ͬ±ÈÊý¾Ý if (statBo != null) { Date date = DateUtil.getThisWeekInLastYear(); - Date[] dateList = { DateUtil.getBeforeDay(date, 14), DateUtil.getBeforeDay(date, 7), DateUtil.getAfterDay(date, 7), - DateUtil.getAfterDay(date, 14), date }; + Date[] dateList = {DateUtil.getBeforeDay(date, 14), DateUtil.getBeforeDay(date, 7), DateUtil.getAfterDay(date, 7), + DateUtil.getAfterDay(date, 14), date}; DistrictStatBo yearPeriodStatBo = null; Integer markup = Integer.MAX_VALUE; @@ -318,9 +346,11 @@ public class DistrictController { this.userCityService = userCityService; } - public void setFjtUsersService(FjtUsersService fjtUsersService) { - this.fjtUsersService = fjtUsersService; - } - - + public void setFjtUsersService(FjtUsersService fjtUsersService) { + this.fjtUsersService = fjtUsersService; + } + + public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { + this.seaweedImagesService = seaweedImagesService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java index 3005fcf82..18c8f0bbe 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java @@ -559,7 +559,7 @@ public class DistrictTrendController { DistrictStat ds = districtStatMap.get(key); JSONArray ja = new JSONArray(); ja.put(DateUtil.getBeforeDay(ds.getWeekend(), -1).getTime()); - ja.put(ds.getAvgPrice()); + ja.put(ds.getAvg_price_2b()); districtJa.put(ja); } @@ -567,7 +567,7 @@ public class DistrictTrendController { DistrictStat ds = villaDistrictStatMap.get(key); JSONArray ja = new JSONArray(); ja.put(DateUtil.getBeforeDay(ds.getWeekend(), -1).getTime()); - ja.put(ds.getAvgPrice()); + ja.put(ds.getAvg_price_2b()); villaJa.put(ja); } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java index 73e27d8a6..460a95e78 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/UserController.java @@ -65,6 +65,10 @@ public class UserController { return model; } + public Object aiLoginPageAction(UserModel model) { + return model; + } + //²³º£ÒøÐеǼ public Object bhydLoginPageAction(UserModel model, HttpServletResponse response, HttpServletRequest request) { String type = StringUtils.trimToNull(model.getType()); @@ -263,11 +267,22 @@ public class UserController { try { FjtUsers user = usersInfoService.getUser(mobile); if(user == null) { - long userId = usersInfoService.addUser(mobile, "", weiXinId); - if(userId == 0){ - return resultModel; + String cookieUserId = CookieUtils.getCookieValue(request, "login_user_id"); + if(StringUtils.isNotBlank(cookieUserId)){ + long userId = Long.valueOf(cookieUserId); + user = fjtUsersService.findById(Long.valueOf(userId)); } - CookieUtils.setCookie("login_user_id", userId + "", "/", 60 * 60 * 24 *7, response); + if(user!=null){ + usersInfoService.bindWeiXin(weiXinId, user.getId()); + CookieUtils.setCookie("login_user_id", user.getId() + "", "/", 60 * 60 * 24 *7, response); + }else{ + long userId = usersInfoService.addUser(mobile, "", weiXinId); + if(userId == 0){ + return resultModel; + } + CookieUtils.setCookie("login_user_id", userId + "", "/", 60 * 60 * 24 *7, response); + } + } else { usersInfoService.bindWeiXin(weiXinId, user.getId()); CookieUtils.setCookie("login_user_id", user.getId() + "", "/", 60 * 60 * 24 *7, response); @@ -296,6 +311,14 @@ public class UserController { String pass = StringUtils.trimToNull(model.getPass()); String weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id"); + String source = model.getSource(); + + // AI¹À¼ÛС³ÌÐò + if ("ai-price-mp".equals(source)) { + model.setAppId("wx30979dc8c24a82b6"); + model.setAppSecret("ec013ae42882368bf3b157545042249a"); + } + if(StringUtils.isBlank(weiXinId) && StringUtils.isNotBlank(model.getCode())){ System.out.println("С³ÌÐòcode:"+model.getCode()); System.out.println("С³ÌÐòAppId:"+model.getAppId()); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java index 716c2156f..a98ea59a0 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java @@ -763,6 +763,29 @@ public class WeiXinEvaluationController { } return model; } + + // ¾ù¼Û¶Ô±È½Ó¿Ú(·¿¼ÛͨС³ÌÐòÓÃ) + public Object otherSourcePlusAction(EvaluationModel model){ + + JsonModel jsonMmodel = new JsonModel(); + Map dataMap = new HashMap(); + if(StringUtils.isNotBlank(model.getCityName()) && StringUtils.isNotBlank(model.getRegion()) && StringUtils.isNotBlank(model.getName()) && model.getBuildType() != null){ + String category = getEnCategory(model.getBuildType()); + AverageStatistics averageStatistics = averageStatisticsService.findOneAverageStatictics(model.getCityName(), model.getName(), category); + + Integer tradeAvgPrice = dealPriceService.findDealPrices(model.getCityName(), model.getRegion(), model.getName(), DateUtil.getFirstDayOfMonth(new Date(), -6), DateUtil.getFirstDayOfMonth(new Date(), 0)); + //columnX = "['³É½»¾ù¼Û(½ü°ëÄê)','·¿¼ÛÍø¹ÒÅÆ¾ù¼Û','ËÑ·¿¹ÒÅÆ¾ù¼Û','°²¾Ó¿Í¹ÒÅÆ¾ù¼Û']"; + dataMap.put("dealPrice", tradeAvgPrice); + if (averageStatistics != null) { + dataMap.put("fjw", averageStatistics.getFangjiaPrice()); + dataMap.put("soufang", averageStatistics.getSoufangEsfPrice()); + dataMap.put("anjuke", averageStatistics.getAnjukeEsfPrice()); + } + } + jsonMmodel.setJsonModel(dataMap); + return jsonMmodel; + } + //¾ù¼Û¶Ô±È public Object otherSourceAction(EvaluationModel model){ diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java index 8d24c760f..f30ccbf54 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/DistrictInfoDto.java @@ -17,6 +17,9 @@ public class DistrictInfoDto { private String district; private String block; private String kind; + private String bedKind; + + private String estateType2; private List floorplanPics; private List pics; private List outPics; @@ -46,6 +49,8 @@ public class DistrictInfoDto { private String carSite; private Long sellCount; // ³öÊÛ·¿Ô´Á¿ private Long rentCount; // ³ö×â·¿Ô´Á¿ + private String register; // ÊÇ·ñ¿É×¢²á + private String elevatorsCount; // µçÌÝÊýÁ¿ private Integer avgPrice; private Integer villaAvgPrice; private Integer totalPrice; @@ -857,4 +862,36 @@ public class DistrictInfoDto { public void setLandProperty(String landProperty) { this.landProperty = landProperty; } + + public String getBedKind() { + return bedKind; + } + + public void setBedKind(String bedKind) { + this.bedKind = bedKind; + } + + public String getEstateType2() { + return estateType2; + } + + public void setEstateType2(String estateType2) { + this.estateType2 = estateType2; + } + + public String getRegister() { + return register; + } + + public void setRegister(String register) { + this.register = register; + } + + public String getElevatorsCount() { + return elevatorsCount; + } + + public void setElevatorsCount(String elevatorsCount) { + this.elevatorsCount = elevatorsCount; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 7848e9b25..cf8cf4e7c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -1,18 +1,15 @@ package com.fangjia.open.exceptionhander; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - import com.fangjia.core.util.DingDingMessageUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.ExceptionHandler; + +import javax.servlet.ServletException; +import java.io.IOException; import java.net.Inet4Address; +import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; @@ -26,7 +23,7 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { ActionContext context = ActionContext.getContext(); String ip = getLocalHostIP(); - String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; + String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4"; try { DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"·þÎñÆ÷ÄÚ²¿´íÎó£¬Ç뼰ʱ¹Ø×¢£¡"); } catch (Exception e1) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java index b3e60dcbd..98784a878 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java @@ -109,9 +109,9 @@ public class AuthenticationInterceptor implements Interceptor { } } catch (Exception e) { String ip = getLocalHostIP(); - String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; + String token = "ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4"; try { - DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"·þÎñÆ÷ÄÚ²¿´íÎó£¬Ç뼰ʱ¹Ø×¢£¡"); + DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication ´íÎó£¡"); } catch (Exception e1) { e1.printStackTrace(); } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java new file mode 100644 index 000000000..34512f434 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java @@ -0,0 +1,115 @@ +package com.fangjia.open.model; + +import com.fangjia.open.APIConstant; +import com.fangjia.open.HttpStatusCodeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import org.sothis.web.mvc.ActionContext; + +@XStreamAlias("xml") +public class BasicPageModel { + + private int code; + + private String msg; + + private Object result; + + private String tid; + + private int total; + + public BasicPageModel(int code, String msg) { + super(); + this.code = code; + this.msg = msg; + } + + public BasicPageModel(HttpStatusCodeEnum status){ + this.code = status.getCode(); + this.msg = status.getMsg(); + } + + public static BasicPageModel buildOKModel() { + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.OK); + return model; + } + + public static BasicPageModel buildModel(int code, String msg){ + return new BasicPageModel( code, msg); + } + + public static BasicPageModel buildUnAuthorizedModel() { + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.UN_AUTHORIZED); + return model; + } + + public static BasicPageModel buildBadRequestModel(String msg){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.BAD_REQUEST); + model.setMsg(msg); + return model; + } + + public static BasicPageModel buildForbidModel(String msg){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.SERVER_FORBID); + model.setMsg(msg); + return model; + } + + + public static BasicPageModel buildServerErrorModel(){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.SERVER_ERROR); + return model; + } + + public static void markNoDataRequest(){ + ActionContext.getContext().set(APIConstant.IS_RETURN_DATA, Boolean.FALSE); + } + + public BasicPageModel markNoData(){ + markNoDataRequest(); + return this; + } + + public int getCode() { + return code; + } + + public BasicPageModel setCode(int code) { + this.code = code; + return this; + } + + public String getMsg() { + return msg; + } + + public BasicPageModel setMsg(String msg) { + this.msg = msg; + return this; + } + + public Object getResult() { + return result; + } + + public BasicPageModel setResult(Object result) { + this.result = result; + return this; + } + + public void setTid(String tid) { + this.tid = tid; + } + + public String getTid() { + return tid; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java new file mode 100644 index 000000000..ca5c12046 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java @@ -0,0 +1,344 @@ +package com.fangjia.open.model; + +import java.util.Date; +import java.util.List; + +/** + * Ð¡ÇøÖܱßÅäÌ× + */ +public class DistrictFacilitysModel { + private static final long serialVersionUID = -9200383212669643823L; + private String id; + private String city; + private String region; + private String districtName; + private List kindergarten; + private List primarySchool; + private List middleSchool; + private List university; + private List hospital; + private List shop; + private List supermarket; + private List foodShop; + private List bus; + private List metro; + private List bank; + private List atm; + private String innerFacilities; + private String carSite; + private String carSiteDes; + + private Double trafficScore; + private Double hospitalScore; + private Double shopScore; + private Double schoolScore; + private Double bankScore; + + private Date creationDate; + + private List positives; // ÕýÃæ + private List negatives; // ¸ºÃæ + private List appraisalNegative; // ¸ºÃæ + private List appraisalPositive; // ÕýÃæ + + /** + * 标签得分 + */ + private Double traScore; + private Double virScore; + private Double aroScore; + private Double tradScore; + + private String imgUrl3D; + + private List school; + private List keySchool; + + public String getCity() { + return city; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getDistrictName() { + return districtName; + } + + public void setDistrictName(String districtName) { + this.districtName = districtName; + } + + public List getKindergarten() { + return kindergarten; + } + + public void setKindergarten(List kindergarten) { + this.kindergarten = kindergarten; + } + + public List getPrimarySchool() { + return primarySchool; + } + + public void setPrimarySchool(List primarySchool) { + this.primarySchool = primarySchool; + } + + public List getMiddleSchool() { + return middleSchool; + } + + public void setMiddleSchool(List middleSchool) { + this.middleSchool = middleSchool; + } + + public List getUniversity() { + return university; + } + + public void setUniversity(List university) { + this.university = university; + } + + public List getHospital() { + return hospital; + } + + public void setHospital(List hospital) { + this.hospital = hospital; + } + + public List getShop() { + return shop; + } + + public void setShop(List shop) { + this.shop = shop; + } + + public List getSupermarket() { + return supermarket; + } + + public void setSupermarket(List supermarket) { + this.supermarket = supermarket; + } + + public List getFoodShop() { + return foodShop; + } + + public void setFoodShop(List foodShop) { + this.foodShop = foodShop; + } + + public List getBus() { + return bus; + } + + public void setBus(List bus) { + this.bus = bus; + } + + public List getMetro() { + return metro; + } + + public void setMetro(List metro) { + this.metro = metro; + } + + public List getBank() { + return bank; + } + + public void setBank(List bank) { + this.bank = bank; + } + + public List getAtm() { + return atm; + } + + public void setAtm(List atm) { + this.atm = atm; + } + + public String getInnerFacilities() { + return innerFacilities; + } + + public void setInnerFacilities(String innerFacilities) { + this.innerFacilities = innerFacilities; + } + + public String getCarSite() { + return carSite; + } + + public void setCarSite(String carSite) { + this.carSite = carSite; + } + + public String getCarSiteDes() { + return carSiteDes; + } + + public void setCarSiteDes(String carSiteDes) { + this.carSiteDes = carSiteDes; + } + + public Double getTrafficScore() { + return trafficScore; + } + + public void setTrafficScore(Double trafficScore) { + this.trafficScore = trafficScore; + } + + public Double getHospitalScore() { + return hospitalScore; + } + + public void setHospitalScore(Double hospitalScore) { + this.hospitalScore = hospitalScore; + } + + public Double getShopScore() { + return shopScore; + } + + public void setShopScore(Double shopScore) { + this.shopScore = shopScore; + } + + public Double getSchoolScore() { + return schoolScore; + } + + public void setSchoolScore(Double schoolScore) { + this.schoolScore = schoolScore; + } + + public Double getBankScore() { + return bankScore; + } + + public void setBankScore(Double bankScore) { + this.bankScore = bankScore; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + public List getPositives() { + return positives; + } + + public void setPositives(List positives) { + this.positives = positives; + } + + public List getNegatives() { + return negatives; + } + + public void setNegatives(List negatives) { + this.negatives = negatives; + } + + public List getAppraisalNegative() { + return appraisalNegative; + } + + public void setAppraisalNegative(List appraisalNegative) { + this.appraisalNegative = appraisalNegative; + } + + public List getAppraisalPositive() { + return appraisalPositive; + } + + public void setAppraisalPositive(List appraisalPositive) { + this.appraisalPositive = appraisalPositive; + } + + public Double getTraScore() { + return traScore; + } + + public void setTraScore(Double traScore) { + this.traScore = traScore; + } + + public Double getVirScore() { + return virScore; + } + + public void setVirScore(Double virScore) { + this.virScore = virScore; + } + + public Double getAroScore() { + return aroScore; + } + + public void setAroScore(Double aroScore) { + this.aroScore = aroScore; + } + + public Double getTradScore() { + return tradScore; + } + + public void setTradScore(Double tradScore) { + this.tradScore = tradScore; + } + + public String getImgUrl3D() { + return imgUrl3D; + } + + public void setImgUrl3D(String imgUrl3D) { + this.imgUrl3D = imgUrl3D; + } + + public List getSchool() { + return school; + } + + public void setSchool(List school) { + this.school = school; + } + + public List getKeySchool() { + return keySchool; + } + + public void setKeySchool(List keySchool) { + this.keySchool = keySchool; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index a78519c7a..39fefbbdc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -23,6 +23,12 @@ public class HouseSearchModel extends SearchModel { private String propertyType; private String houseType; + + private String district; + + private String cat; + + private Integer pageSize; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -177,4 +183,30 @@ public class HouseSearchModel extends SearchModel { public void setHouseType(String houseType) { this.houseType = houseType; } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Override + public Integer getPageSize() { + return pageSize; + } + + @Override + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java index 2abc1acf1..feb2119bd 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java @@ -1,7 +1,5 @@ package com.fangjia.open.model; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; import java.util.Date; public class PropertyEvaluationModel extends FangjiaApiModel { @@ -291,6 +289,8 @@ public class PropertyEvaluationModel extends FangjiaApiModel { private Integer avgPrice; + private Integer level; + private Integer type; public void setDecorationAge(int decorationAge) { this.decorationAge = decorationAge; @@ -926,4 +926,20 @@ public class PropertyEvaluationModel extends FangjiaApiModel { public void setId(String id) { this.id = id; } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java index b381d4f31..a4607d7ab 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertySearchModel.java @@ -40,6 +40,9 @@ public class PropertySearchModel { // ÊҺŠprivate String roomNum; + // ÀàÐÍ + private String cat; + public Boolean getUseOrQuery() { return useOrQuery; } @@ -270,4 +273,11 @@ public class PropertySearchModel { this.roomNum = roomNum; } + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/ReportApplyModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ReportApplyModel.java new file mode 100644 index 000000000..89cbcfbea --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ReportApplyModel.java @@ -0,0 +1,174 @@ +package com.fangjia.open.model; + +public class ReportApplyModel extends FangjiaApiModel { + + /** + * ίÍлú¹¹ + */ + private String client; + /** + * ±êµÄÎï + */ + private String subjectMatter; + /** + * ±êµÄÎïËùÔÚ³ÇÊÐ + */ + private String city; + /** + * ±êµÄÎïµØÖ· + */ + private String address; + /** + * ±êµÄÎïÇøÓò + */ + private String district; + /** + * ±êµÄÎïÐ¡ÇøÃû³Æ + */ + private String name; + /** + * Â¥ºÅ + */ + private String buildingNumber; + /** + * ÊҺŠ+ */ + private String unitNumber; + /** + * Ãæ»ý£¬µ¥Î»£ºÆ½Ã× + */ + private Float size; + /** + * ËùÔÚÂ¥²ã + */ + private Integer floor; + /** + * ×ÜÂ¥²ã + */ + private Integer maxFloor; + /** + * ÎïÒµÀàÐÍ È¡ÖµÎª£º 0=ÆÕͨסլ(ĬÈÏ) 1=±ðÊû 2=ÉÌס + */ + private String propertyType; + /** + * ³¯Ïò£¬¿ÉѡֵÓУº 1=Î÷ÄÏ 2=¶«ÄÏ 3=ÄÏ(ĬÈÏ) 4=Î÷±± 5=¶«±± 6=¶« 7=Î÷ 8=±± 9=¶«Î÷ 10=Äϱ± + */ + private String direction; + /** + * ×°ÐÞÇé¿ö£¬¿ÉѡֵÓУº 1=ëÅ÷ 2=¼ò×°(ĬÈÏ) 3=¾«×° 4=ºÀ×° + */ + private String decoration; + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public String getSubjectMatter() { + return subjectMatter; + } + + public void setSubjectMatter(String subjectMatter) { + this.subjectMatter = subjectMatter; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getBuildingNumber() { + return buildingNumber; + } + + public void setBuildingNumber(String buildingNumber) { + this.buildingNumber = buildingNumber; + } + + public String getUnitNumber() { + return unitNumber; + } + + public void setUnitNumber(String unitNumber) { + this.unitNumber = unitNumber; + } + + public Float getSize() { + return size; + } + + public void setSize(Float size) { + this.size = size; + } + + public Integer getFloor() { + return floor; + } + + public void setFloor(Integer floor) { + this.floor = floor; + } + + public Integer getMaxFloor() { + return maxFloor; + } + + public void setMaxFloor(Integer maxFloor) { + this.maxFloor = maxFloor; + } + + public String getPropertyType() { + return propertyType; + } + + public void setPropertyType(String propertyType) { + this.propertyType = propertyType; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getDecoration() { + return decoration; + } + + public void setDecoration(String decoration) { + this.decoration = decoration; + } + +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java index 5f9c5a223..b3c210301 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java @@ -57,6 +57,15 @@ public class DistrictModel extends BaseModel { * ÅжÏÊDz»ÊÇÓÑ´ï */ private boolean isYouDa; + //ÓÃÓÚɾ³ýºÍÐÂÔö + // ͼƬurl + private String url; + //·¿ÐÍͼ »ò Í⾰ͼ + private String PicType; + //¼¸ÊÒ + private String roomType; + + private List imageUrls; public Boolean getShowPrice() { return showPrice; @@ -241,4 +250,35 @@ public class DistrictModel extends BaseModel { // public void setBuildName(String buildName) { // this.buildName = buildName; // } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getRoomType() { + return roomType; + } + public void setRoomType(String roomType) { + this.roomType = roomType; + } + + public String getPicType() { + return PicType; + } + + public void setPicType(String picType) { + PicType = picType; + } + + public List getImageUrls() { + return imageUrls; + } + + public void setImageUrls(List imageUrls) { + this.imageUrls = imageUrls; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java index cdf645a31..44cc2ca36 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java @@ -57,6 +57,9 @@ public class EvaluationModel extends BaseModel{ private Map> reportFileMap; private UserTrades userTrades; private String address; + private Integer buildType; + private String name; + private String region; public void setId(String id) { @@ -326,4 +329,28 @@ public class EvaluationModel extends BaseModel{ public void setLoan(Integer loan) { this.loan = loan; } + + public Integer getBuildType() { + return buildType; + } + + public void setBuildType(Integer buildType) { + this.buildType = buildType; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java index 400112bfb..88d8fb971 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/UserModel.java @@ -22,6 +22,11 @@ public class UserModel extends BaseModel { private String appId;//²âÊÔ private String appSecret;//²âÊÔ private String sid;//²âÊÔ + + /** + * µÇ¼À´Ô´£ºAI¹À¼ÛС³ÌÐò + */ + private String source; public List getCitys() { return citys; @@ -126,4 +131,12 @@ public class UserModel extends BaseModel { public void setPass2(String pass2) { this.pass2 = pass2; } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java index f5b3497e9..f5c8ea110 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/CommonUtils.java @@ -1,18 +1,21 @@ package com.fangjia.open.util; +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; + import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; -import org.apache.commons.beanutils.BeanUtils; //¹«Óà public class CommonUtils { - + //¶ÔÏóתmap public static Map convertToMap(Object obj) { try { if (obj instanceof Map) { - return (Map)obj; + return (Map) obj; } Map returnMap = BeanUtils.describe(obj); returnMap.remove("class"); @@ -26,4 +29,19 @@ public class CommonUtils { } return new HashMap(); } + + public static String convertToString(String[] strs) { + if (ArrayUtils.isNotEmpty(strs)) { + StringBuffer ret = new StringBuffer(); + for (String str : strs) { + if (StringUtils.isEmpty(ret.toString())) { + ret.append(str); + } else { + ret.append(",").append(str); + } + } + return ret.toString(); + } + return null; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java new file mode 100644 index 000000000..47d8fa603 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FangJiaTongUrl.java @@ -0,0 +1,47 @@ +package com.fangjia.open.util; + +import org.apache.commons.lang.StringUtils; + +public class FangJiaTongUrl { + + /** + * ·¿¼Ûͨºǫ́·þÎñtoken + */ + public static final String FANG_JIA_TONG_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhY2NvdW50Ijoib3BlbiIsImV4cCI6MTMxMzQxNTk0MTQ5MTkzLCJvcmdDb2RlIjoiMDAxLjAwMSIsInJvbGVzIjpbImFkbWluIl0sInVzZXJJZCI6IjE4OTkwMDc1OTc0MDY3NzMyNDgiLCJ1c2VybmFtZSI6Ik9QRU7osIPnlKjotKblj7cifQ.ImHYDRYqmrZ13Wtzx87IlUFkUCy-HGf07M4IuaSyXTfPjNjG7FT_zyceWC2V0iTjexwfLyrPAlJtVflNgIsJYQ"; + + /** + * ·¿¼Ûͨºǫ́·þÎñUATµØÖ· + */ + public static final String FANG_JIA_TONG_URL_UAT = "https://api-uat.fangjia.com"; + + /** + * ·¿¼Ûͨºǫ́·þÎñÉú²úµØÖ· + */ + public static final String FANG_JIA_TONG_URL_PROD = "https://api.fangjia.com"; + + /** + * д×ÖÂ¥ÉêÇë¹ÀÖµ±¨¸æ½Ó¿Ú + */ + public static final String ASSESS_PRICE_REPORT_APPLY = "/office/assessPriceReport/apply"; + + /** + * д×ÖÂ¥»ñÈ¡¹ÀÖµ±¨¸æ½Ó¿Ú + */ + public static final String ASSESS_PRICE_REPORT_FETCH = "/office/assessPriceReport/fetch"; + + /** + * ´¦Àíµ÷ÓýӿڻزÎÖеÄÌØÊâ×Ö·û + * @param str + * @return + */ + public static String replaceAll(String str){ + String replaceAll3 = null; + if(!StringUtils.isBlank(str)){ + String replaceAll = str.replaceAll("\\\\", ""); + String replaceAll2 = replaceAll.replaceAll("\"[{]", "{"); + replaceAll3 = replaceAll2.replaceAll("[}]\"", "}"); + } + return replaceAll3; + } + +} diff --git a/projects/fangjia-open/src/main/webapp/H9YtlL0T8j.txt b/projects/fangjia-open/src/main/webapp/H9YtlL0T8j.txt new file mode 100644 index 000000000..a1532152f --- /dev/null +++ b/projects/fangjia-open/src/main/webapp/H9YtlL0T8j.txt @@ -0,0 +1 @@ +9995d79df0ea4a6f4d1f55fd2eeabb38 \ No newline at end of file diff --git a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl index 761d749d7..32a704887 100644 --- a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl +++ b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl @@ -14,10 +14,21 @@ + - + +〈 +
    @@ -65,7 +76,7 @@
    �区租金
    -

    +

    <#if districtStatRentBos?? && districtStatRentBos?size gt 0> <#list districtStatRentBos as districtStatRentBo>

    <#if districtStatRentBo.districtStatRent??>${districtStatRentBo.districtStatRent.avgPrice} å…ƒ/月

    @@ -89,7 +100,7 @@ <#if district.outPics?? && district.outPics?size gt 0> <#list district.outPics as pics> <#if pics_index < 6> - + @@ -119,10 +130,11 @@
    <#include '/layout/footer.ftl'/> - + + diff --git a/projects/fangjia-open/src/main/webapp/report/downloadList.ftl b/projects/fangjia-open/src/main/webapp/report/downloadList.ftl index 55d2fbd97..f54286437 100644 --- a/projects/fangjia-open/src/main/webapp/report/downloadList.ftl +++ b/projects/fangjia-open/src/main/webapp/report/downloadList.ftl @@ -13,10 +13,23 @@ + -
    + +〈 + +
    diff --git a/projects/fangjia-open/src/main/webapp/static/js/autoCompletion.js b/projects/fangjia-open/src/main/webapp/static/js/autoCompletion.js index 607f70dfb..25543e105 100644 --- a/projects/fangjia-open/src/main/webapp/static/js/autoCompletion.js +++ b/projects/fangjia-open/src/main/webapp/static/js/autoCompletion.js @@ -54,7 +54,7 @@ $(function () { if ($("#t").val() != "c") { saveCookie(id, name, addr, region) } - if ($("#t").val() == "b") { + if ($("#t").val() == "b" || $("#t").val() == "gb") { location.href = "districtDetail?id=" + id+"&city="+city } else if ($("#t").val() == "c") { $('#districtSearch').val(name) @@ -122,7 +122,7 @@ function resumeHistory() { $("#searchSpan ul").empty().append(content).find("li>a.item-link").click(function () { var li = $(this).parent() var id = $(li).attr("data-id") - if ($("#t").val() == "b") { + if ($("#t").val() == "b"||$("#t").val() == "gb") { location.href = "districtDetail?id=" + id+"&city="+city } else if ($("#t").val() == "c") { location.href = "../ccbRent/index?city="+city diff --git a/projects/fangjia-open/src/main/webapp/static/js/highcharts5.0.6.js b/projects/fangjia-open/src/main/webapp/static/js/highcharts5.0.6.js new file mode 100644 index 000000000..fef4b636c --- /dev/null +++ b/projects/fangjia-open/src/main/webapp/static/js/highcharts5.0.6.js @@ -0,0 +1,385 @@ +// JavaScript Document + +/* + Highcharts JS v5.0.6 (2016-12-07) + + (c) 2009-2016 Torstein Honsi + + License: www.highcharts.com/license +*/ +(function(L,a){"object"===typeof module&&module.exports?module.exports=L.document?a(L):a:L.Highcharts=a(L)})("undefined"!==typeof window?window:this,function(L){L=function(){var a=window,D=a.document,C=a.navigator&&a.navigator.userAgent||"",G=D&&D.createElementNS&&!!D.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,I=/(edge|msie|trident)/i.test(C)&&!window.opera,h=!G,f=/Firefox/.test(C),p=f&&4>parseInt(C.split("Firefox/")[1],10);return a.Highcharts?a.Highcharts.error(16,!0):{product:"Highcharts", +version:"5.0.6",deg2rad:2*Math.PI/360,doc:D,hasBidiBug:p,hasTouch:D&&void 0!==D.documentElement.ontouchstart,isMS:I,isWebKit:/AppleWebKit/.test(C),isFirefox:f,isTouchDevice:/(Mobile|Android|Windows Phone)/.test(C),SVG_NS:"http://www.w3.org/2000/svg",chartCount:0,seriesTypes:{},symbolSizes:{},svg:G,vml:h,win:a,charts:[],marginNames:["plotTop","marginRight","marginBottom","plotLeft"],noop:function(){}}}();(function(a){var D=[],C=a.charts,G=a.doc,I=a.win;a.error=function(h,f){h=a.isNumber(h)?"Highcharts error #"+ +h+": www.highcharts.com/errors/"+h:h;if(f)throw Error(h);I.console&&console.log(h)};a.Fx=function(a,f,p){this.options=f;this.elem=a;this.prop=p};a.Fx.prototype={dSetter:function(){var a=this.paths[0],f=this.paths[1],p=[],v=this.now,l=a.length,u;if(1===v)p=this.toD;else if(l===f.length&&1>v)for(;l--;)u=parseFloat(a[l]),p[l]=isNaN(u)?a[l]:v*parseFloat(f[l]-u)+u;else p=f;this.elem.attr("d",p,null,!0)},update:function(){var a=this.elem,f=this.prop,p=this.now,v=this.options.step;if(this[f+"Setter"])this[f+ +"Setter"]();else a.attr?a.element&&a.attr(f,p,null,!0):a.style[f]=p+this.unit;v&&v.call(a,p,this)},run:function(a,f,p){var h=this,l=function(a){return l.stopped?!1:h.step(a)},u;this.startTime=+new Date;this.start=a;this.end=f;this.unit=p;this.now=this.start;this.pos=0;l.elem=this.elem;l.prop=this.prop;l()&&1===D.push(l)&&(l.timerId=setInterval(function(){for(u=0;u=u+this.startTime){this.now=this.end;this.pos=1;this.update();a=d[this.prop]=!0;for(c in d)!0!==d[c]&&(a=!1);a&&l&&l.call(h);h=!1}else this.pos=v.easing((f-this.startTime)/u),this.now=this.start+(this.end-this.start)*this.pos,this.update(),h=!0;return h},initPath:function(h,f,p){function v(a){var e,b;for(q=a.length;q--;)e="M"===a[q]||"L"===a[q],b=/[a-zA-Z]/.test(a[q+3]),e&&b&&a.splice(q+1,0,a[q+1],a[q+2],a[q+1],a[q+ +2])}function l(a,e){for(;a.lengthd?"AM":"PM",P:12>d?"am":"pm",S:z(l.getSeconds()),L:z(Math.round(f% +1E3),3)},a.dateFormats);for(u in v)for(;-1!==h.indexOf("%"+u);)h=h.replace("%"+u,"function"===typeof v[u]?v[u](f):v[u]);return p?h.substr(0,1).toUpperCase()+h.substr(1):h};a.formatSingle=function(h,f){var p=/\.([0-9])/,v=a.defaultOptions.lang;/f$/.test(h)?(p=(p=h.match(p))?p[1]:-1,null!==f&&(f=a.numberFormat(f,p,v.decimalPoint,-1=p&&(f=[1/p]))); +for(v=0;v=h||!l&&u<=(f[v]+(f[v+1]||f[v]))/2);v++);return d*p};a.stableSort=function(a,f){var p=a.length,h,l;for(l=0;lp&&(p=a[f]);return p};a.destroyObjectProperties=function(a,f){for(var p in a)a[p]&&a[p]!==f&&a[p].destroy&& +a[p].destroy(),delete a[p]};a.discardElement=function(h){var f=a.garbageBin;f||(f=a.createElement("div"));h&&f.appendChild(h);f.innerHTML=""};a.correctFloat=function(a,f){return parseFloat(a.toPrecision(f||14))};a.setAnimation=function(h,f){f.renderer.globalAnimation=a.pick(h,f.options.chart.animation,!0)};a.animObject=function(h){return a.isObject(h)?a.merge(h):{duration:h?500:0}};a.timeUnits={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5,month:24192E5,year:314496E5};a.numberFormat= +function(h,f,p,v){h=+h||0;f=+f;var l=a.defaultOptions.lang,u=(h.toString().split(".")[1]||"").length,d,c,n=Math.abs(h);-1===f?f=Math.min(u,20):a.isNumber(f)||(f=2);d=String(a.pInt(n.toFixed(f)));c=3h?"-":"")+(c?d.substr(0,c)+v:"");h+=d.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+v);f&&(v=Math.abs(n-d+Math.pow(10,-Math.max(f,u)-1)),h+=p+v.toFixed(f).slice(2));return h};Math.easeInOutSine=function(a){return-.5*(Math.cos(Math.PI* +a)-1)};a.getStyle=function(h,f){return"width"===f?Math.min(h.offsetWidth,h.scrollWidth)-a.getStyle(h,"padding-left")-a.getStyle(h,"padding-right"):"height"===f?Math.min(h.offsetHeight,h.scrollHeight)-a.getStyle(h,"padding-top")-a.getStyle(h,"padding-bottom"):(h=I.getComputedStyle(h,void 0))&&a.pInt(h.getPropertyValue(f))};a.inArray=function(a,f){return f.indexOf?f.indexOf(a):[].indexOf.call(f,a)};a.grep=function(a,f){return[].filter.call(a,f)};a.find=function(a,f){return[].find.call(a,f)};a.map=function(a, +f){for(var p=[],h=0,l=a.length;hf;f++)v[f]+=h(255*a),0>v[f]&&(v[f]=0),255E.width)E={width:0, +height:0}}else E=this.htmlGetBBox();H.isSVG&&(a=E.width,H=E.height,e&&c&&"11px"===c.fontSize&&"16.9"===H.toPrecision(3)&&(E.height=H=14),g&&(E.width=Math.abs(H*Math.sin(k))+Math.abs(a*Math.cos(k)),E.height=Math.abs(H*Math.cos(k))+Math.abs(a*Math.sin(k))));if(x&&0]*>/g,"")))},textSetter:function(a){a!==this.textStr&&(delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this))},fillSetter:function(a, +g,e){"string"===typeof a?e.setAttribute(g,a):a&&this.colorGradient(a,g,e)},visibilitySetter:function(a,g,e){"inherit"===a?e.removeAttribute(g):e.setAttribute(g,a)},zIndexSetter:function(a,g){var e=this.renderer,k=this.parentGroup,b=(k||e).element||e.box,c,B=this.element,H;c=this.added;var r;u(a)&&(B.zIndex=a,a=+a,this[g]===a&&(c=!1),this[g]=a);if(c){(a=this.zIndex)&&k&&(k.handleZ=!0);g=b.childNodes;for(r=0;ra||!u(a)&&u(c)||0>a&&!u(c)&&b!==e.box)&&(b.insertBefore(B, +k),H=!0);H||b.appendChild(B)}return H},_defaultSetter:function(a,g,e){e.setAttribute(g,a)}};D.prototype.yGetter=D.prototype.xGetter;D.prototype.translateXSetter=D.prototype.translateYSetter=D.prototype.rotationSetter=D.prototype.verticalAlignSetter=D.prototype.scaleXSetter=D.prototype.scaleYSetter=function(a,g){this[g]=a;this.doTransform=!0};D.prototype["stroke-widthSetter"]=D.prototype.strokeSetter=function(a,g,e){this[g]=a;this.stroke&&this["stroke-width"]?(D.prototype.fillSetter.call(this,this.stroke, +"stroke",e),e.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0):"stroke-width"===g&&0===a&&this.hasStroke&&(e.removeAttribute("stroke"),this.hasStroke=!1)};C=a.SVGRenderer=function(){this.init.apply(this,arguments)};C.prototype={Element:D,SVG_NS:S,init:function(a,g,e,k,b,c){var B;k=this.createElement("svg").attr({version:"1.1","class":"highcharts-root"}).css(this.getStyle(k));B=k.element;a.appendChild(B);-1===a.innerHTML.indexOf("xmlns")&&h(B,"xmlns",this.SVG_NS);this.isSVG=!0; +this.box=B;this.boxWrapper=k;this.alignedObjects=[];this.url=(F||A)&&n.getElementsByTagName("base").length?R.location.href.replace(/#.*?$/,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(n.createTextNode("Created with Highcharts 5.0.6"));this.defs=this.createElement("defs").add();this.allowHTML=c;this.forExport=b;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(g,e,!1);var H;F&&a.getBoundingClientRect&&(g=function(){v(a, +{left:0,top:0});H=a.getBoundingClientRect();v(a,{left:Math.ceil(H.left)-H.left+"px",top:Math.ceil(H.top)-H.top+"px"})},g(),this.unSubPixelFix=G(R,"resize",g))},getStyle:function(a){return this.style=t({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},setStyle:function(a){this.boxWrapper.css(this.getStyle(a))},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy(); +c(this.gradients||{});this.gradients=null;a&&(this.defs=a.destroy());this.unSubPixelFix&&this.unSubPixelFix();return this.alignedObjects=null},createElement:function(a){var g=new this.Element;g.init(this,a);return g},draw:w,getRadialAttr:function(a,g){return{cx:a[0]-a[2]/2+g.cx*a[2],cy:a[1]-a[2]/2+g.cy*a[2],r:g.r*a[2]}},buildText:function(a){for(var g=a.element,e=this,k=e.forExport,c=K(a.textStr,"").toString(),r=-1!==c.indexOf("\x3c"),m=g.childNodes,w,E,q,x,d=h(g,"x"),t=a.styles,A=a.textWidth,z=t&& +t.lineHeight,l=t&&t.textOutline,F=t&&"ellipsis"===t.textOverflow,f=m.length,u=A&&!a.added&&this.box,p=function(a){var k;k=/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:t&&t.fontSize||e.style.fontSize||12;return z?J(z):e.fontMetrics(k,a.getAttribute("style")?a:g).h};f--;)g.removeChild(m[f]);r||l||F||A||-1!==c.indexOf(" ")?(w=/<.*class="([^"]+)".*>/,E=/<.*style="([^"]+)".*>/,q=/<.*href="(http[^"]+)".*>/,u&&u.appendChild(g),c=r?c.replace(/<(b|strong)>/g,'\x3cspan style\x3d"font-weight:bold"\x3e').replace(/<(i|em)>/g, +'\x3cspan style\x3d"font-style:italic"\x3e').replace(//g,"\x3c/span\x3e").split(//g):[c],c=b(c,function(a){return""!==a}),y(c,function(b,c){var r,H=0;b=b.replace(/^\s+|\s+$/g,"").replace(//g,"\x3c/span\x3e|||");r=b.split("|||");y(r,function(b){if(""!==b||1===r.length){var m={},l=n.createElementNS(e.SVG_NS,"tspan"),z,f;w.test(b)&&(z=b.match(w)[1],h(l,"class",z));E.test(b)&&(f=b.match(E)[1].replace(/(;| |^)color([ :])/, +"$1fill$2"),h(l,"style",f));q.test(b)&&!k&&(h(l,"onclick",'location.href\x3d"'+b.match(q)[1]+'"'),v(l,{cursor:"pointer"}));b=(b.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"\x3c").replace(/>/g,"\x3e");if(" "!==b){l.appendChild(n.createTextNode(b));H?m.dx=0:c&&null!==d&&(m.x=d);h(l,m);g.appendChild(l);!H&&c&&(!B&&k&&v(l,{display:"block"}),h(l,"dy",p(l)));if(A){m=b.replace(/([^\^])-/g,"$1- ").split(" ");z="nowrap"===t.whiteSpace;for(var K=1A,void 0===x&&(x=u),F&&x?(N/=2,""===O||!u&&.5>N?m=[]:(O=b.substring(0,O.length+(u?-1:1)*Math.ceil(N)),m=[O+(3A&&(A=y)),m.length&& +l.appendChild(n.createTextNode(m.join(" ").replace(/- /g,"-")));a.rotation=P}H++}}})}),x&&a.attr("title",a.textStr),u&&u.removeChild(g),l&&a.applyTextOutline&&a.applyTextOutline(l)):g.appendChild(n.createTextNode(c.replace(/</g,"\x3c").replace(/>/g,"\x3e")))},getContrast:function(a){a=p(a).rgba;return 510e?k>g+B&&kr?k>g+B&&kb&&r>a+B&&rk&&r>a+B&&ra?a+3:Math.round(1.2* +a);return{h:g,b:Math.round(.8*g),f:a}},rotCorr:function(a,g,e){var b=a;g&&e&&(b=Math.max(b*Math.cos(g*d),4));return{x:-a/3*Math.sin(g*d),y:b}},label:function(a,g,e,b,c,B,r,m,w){var q=this,x=q.g("button"!==w&&"label"),d=x.text=q.text("",0,0,r).attr({zIndex:1}),H,n,l=0,A=3,z=0,F,f,K,p,J,h={},M,S,E=/^url\((.*?)\)$/.test(b),v=E,P,R,O,Q;w&&x.addClass("highcharts-"+w);v=E;P=function(){return(M||0)%2/2};R=function(){var a=d.element.style,g={};n=(void 0===F||void 0===f||J)&&u(d.textStr)&&d.getBBox();x.width= +(F||n.width||0)+2*A+z;x.height=(f||n.height||0)+2*A;S=A+q.fontMetrics(a&&a.fontSize,d).b;v&&(H||(x.box=H=q.symbols[b]||E?q.symbol(b):q.rect(),H.addClass(("button"===w?"":"highcharts-label-box")+(w?" highcharts-"+w+"-box":"")),H.add(x),a=P(),g.x=a,g.y=(m?-S:0)+a),g.width=Math.round(x.width),g.height=Math.round(x.height),H.attr(t(g,h)),h={})};O=function(){var a=z+A,g;g=m?0:S;u(F)&&n&&("center"===J||"right"===J)&&(a+={center:.5,right:1}[J]*(F-n.width));if(a!==d.x||g!==d.y)d.attr("x",a),void 0!==g&&d.attr("y", +g);d.x=a;d.y=g};Q=function(a,g){H?H.attr(a,g):h[a]=g};x.onAdd=function(){d.add(x);x.attr({text:a||0===a?a:"",x:g,y:e});H&&u(c)&&x.attr({anchorX:c,anchorY:B})};x.widthSetter=function(a){F=a};x.heightSetter=function(a){f=a};x["text-alignSetter"]=function(a){J=a};x.paddingSetter=function(a){u(a)&&a!==A&&(A=x.padding=a,O())};x.paddingLeftSetter=function(a){u(a)&&a!==z&&(z=a,O())};x.alignSetter=function(a){a={left:0,center:.5,right:1}[a];a!==l&&(l=a,n&&x.attr({x:K}))};x.textSetter=function(a){void 0!== +a&&d.textSetter(a);R();O()};x["stroke-widthSetter"]=function(a,g){a&&(v=!0);M=this["stroke-width"]=a;Q(g,a)};x.strokeSetter=x.fillSetter=x.rSetter=function(a,g){"fill"===g&&a&&(v=!0);Q(g,a)};x.anchorXSetter=function(a,g){c=a;Q(g,Math.round(a)-P()-K)};x.anchorYSetter=function(a,g){B=a;Q(g,a-p)};x.xSetter=function(a){x.x=a;l&&(a-=l*((F||n.width)+2*A));K=Math.round(a);x.attr("translateX",K)};x.ySetter=function(a){p=x.y=Math.round(a);x.attr("translateY",p)};var V=x.css;return t(x,{css:function(a){if(a){var g= +{};a=k(a);y(x.textProps,function(e){void 0!==a[e]&&(g[e]=a[e],delete a[e])});d.css(g)}return V.call(x,a)},getBBox:function(){return{width:n.width+2*A,height:n.height+2*A,x:n.x-A,y:n.y-A}},shadow:function(a){a&&(R(),H&&H.shadow(a));return x},destroy:function(){N(x.element,"mouseenter");N(x.element,"mouseleave");d&&(d=d.destroy());H&&(H=H.destroy());D.prototype.destroy.call(x);x=q=R=O=Q=null}})}};a.Renderer=C})(L);(function(a){var D=a.attr,C=a.createElement,G=a.css,I=a.defined,h=a.each,f=a.extend,p= +a.isFirefox,v=a.isMS,l=a.isWebKit,u=a.pInt,d=a.SVGRenderer,c=a.win,n=a.wrap;f(a.SVGElement.prototype,{htmlCss:function(a){var c=this.element;if(c=a&&"SPAN"===c.tagName&&a.width)delete a.width,this.textWidth=c,this.updateTransform();a&&"ellipsis"===a.textOverflow&&(a.whiteSpace="nowrap",a.overflow="hidden");this.styles=f(this.styles,a);G(this.element,a);return this},htmlGetBBox:function(){var a=this.element;"text"===a.nodeName&&(a.style.position="absolute");return{x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth, +height:a.offsetHeight}},htmlUpdateTransform:function(){if(this.added){var a=this.renderer,c=this.element,m=this.translateX||0,b=this.translateY||0,q=this.x||0,d=this.y||0,n=this.textAlign||"left",e={left:0,center:.5,right:1}[n],r=this.styles;G(c,{marginLeft:m,marginTop:b});this.shadows&&h(this.shadows,function(a){G(a,{marginLeft:m+1,marginTop:b+1})});this.inverted&&h(c.childNodes,function(e){a.invertChild(e,c)});if("SPAN"===c.tagName){var x=this.rotation,A=u(this.textWidth),k=r&&r.whiteSpace,w=[x, +n,c.innerHTML,this.textWidth,this.textAlign].join();w!==this.cTT&&(r=a.fontMetrics(c.style.fontSize).b,I(x)&&this.setSpanRotation(x,e,r),G(c,{width:"",whiteSpace:k||"nowrap"}),c.offsetWidth>A&&/[ \-]/.test(c.textContent||c.innerText)&&G(c,{width:A+"px",display:"block",whiteSpace:k||"normal"}),this.getSpanCorrection(c.offsetWidth,r,e,x,n));G(c,{left:q+(this.xCorr||0)+"px",top:d+(this.yCorr||0)+"px"});l&&(r=c.offsetHeight);this.cTT=w}}else this.alignOnAdd=!0},setSpanRotation:function(a,d,m){var b={}, +q=v?"-ms-transform":l?"-webkit-transform":p?"MozTransform":c.opera?"-o-transform":"";b[q]=b.transform="rotate("+a+"deg)";b[q+(p?"Origin":"-origin")]=b.transformOrigin=100*d+"% "+m+"px";G(this.element,b)},getSpanCorrection:function(a,c,m){this.xCorr=-a*m;this.yCorr=-c}});f(d.prototype,{html:function(a,c,m){var b=this.createElement("span"),q=b.element,d=b.renderer,l=d.isSVG,e=function(a,e){h(["opacity","visibility"],function(b){n(a,b+"Setter",function(a,b,c,r){a.call(this,b,c,r);e[c]=b})})};b.textSetter= +function(a){a!==q.innerHTML&&delete this.bBox;q.innerHTML=this.textStr=a;b.htmlUpdateTransform()};l&&e(b,b.element.style);b.xSetter=b.ySetter=b.alignSetter=b.rotationSetter=function(a,e){"align"===e&&(e="textAlign");b[e]=a;b.htmlUpdateTransform()};b.attr({text:a,x:Math.round(c),y:Math.round(m)}).css({fontFamily:this.style.fontFamily,fontSize:this.style.fontSize,position:"absolute"});q.style.whiteSpace="nowrap";b.css=b.htmlCss;l&&(b.add=function(a){var c,r=d.box.parentNode,k=[];if(this.parentGroup= +a){if(c=a.div,!c){for(;a;)k.push(a),a=a.parentGroup;h(k.reverse(),function(a){var m,x=D(a.element,"class");x&&(x={className:x});c=a.div=a.div||C("div",x,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display,opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},c||r);m=c.style;f(a,{on:function(){b.on.apply({element:k[0].div},arguments);return a},translateXSetter:function(e,g){m.left=e+"px";a[g]=e;a.doTransform=!0},translateYSetter:function(e,g){m.top= +e+"px";a[g]=e;a.doTransform=!0}});e(a,m)})}}else c=r;c.appendChild(q);b.added=!0;b.alignOnAdd&&b.htmlUpdateTransform();return b});return b}})})(L);(function(a){var D,C,G=a.createElement,I=a.css,h=a.defined,f=a.deg2rad,p=a.discardElement,v=a.doc,l=a.each,u=a.erase,d=a.extend;D=a.extendClass;var c=a.isArray,n=a.isNumber,y=a.isObject,t=a.merge;C=a.noop;var m=a.pick,b=a.pInt,q=a.SVGElement,z=a.SVGRenderer,F=a.win;a.svg||(C={docMode8:v&&8===v.documentMode,init:function(a,b){var e=["\x3c",b,' filled\x3d"f" stroked\x3d"f"'], +c=["position: ","absolute",";"],k="div"===b;("shape"===b||k)&&c.push("left:0;top:0;width:1px;height:1px;");c.push("visibility: ",k?"hidden":"visible");e.push(' style\x3d"',c.join(""),'"/\x3e');b&&(e=k||"span"===b||"img"===b?e.join(""):a.prepVML(e),this.element=G(e));this.renderer=a},add:function(a){var e=this.renderer,b=this.element,c=e.box,k=a&&a.inverted,c=a?a.element||a:c;a&&(this.parentGroup=a);k&&e.invertChild(b,c);c.appendChild(b);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform(); +if(this.onAdd)this.onAdd();this.className&&this.attr("class",this.className);return this},updateTransform:q.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=Math.cos(a*f),c=Math.sin(a*f);I(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11\x3d",b,", M12\x3d",-c,", M21\x3d",c,", M22\x3d",b,", sizingMethod\x3d'auto expand')"].join(""):"none"})},getSpanCorrection:function(a,b,c,q,k){var e=q?Math.cos(q*f):1,r=q?Math.sin(q*f):0,x=m(this.elemHeight,this.element.offsetHeight), +d;this.xCorr=0>e&&-a;this.yCorr=0>r&&-x;d=0>e*r;this.xCorr+=r*b*(d?1-c:c);this.yCorr-=e*b*(q?d?c:1-c:1);k&&"left"!==k&&(this.xCorr-=a*c*(0>e?-1:1),q&&(this.yCorr-=x*c*(0>r?-1:1)),I(this.element,{textAlign:k}))},pathToVML:function(a){for(var e=a.length,b=[];e--;)n(a[e])?b[e]=Math.round(10*a[e])-5:"Z"===a[e]?b[e]="x":(b[e]=a[e],!a.isArc||"wa"!==a[e]&&"at"!==a[e]||(b[e+5]===b[e+7]&&(b[e+7]+=a[e+7]>a[e+5]?1:-1),b[e+6]===b[e+8]&&(b[e+8]+=a[e+8]>a[e+6]?1:-1)));return b.join(" ")||"x"},clip:function(a){var e= +this,b;a?(b=a.members,u(b,e),b.push(e),e.destroyClip=function(){u(b,e)},a=a.getCSS(e)):(e.destroyClip&&e.destroyClip(),a={clip:e.docMode8?"inherit":"rect(auto)"});return e.css(a)},css:q.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&p(a)},destroy:function(){this.destroyClip&&this.destroyClip();return q.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a=F.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,c){var e;a=a.split(/[ ,]/); +e=a.length;if(9===e||11===e)a[e-4]=a[e-2]=b(a[e-2])-10*c;return a.join(" ")},shadow:function(a,c,q){var e=[],k,r=this.element,d=this.renderer,x,n=r.style,g,B=r.path,l,t,z,f;B&&"string"!==typeof B.value&&(B="x");t=B;if(a){z=m(a.width,3);f=(a.opacity||.15)/z;for(k=1;3>=k;k++)l=2*z+1-2*k,q&&(t=this.cutOffPath(B.value,l+.5)),g=['\x3cshape isShadow\x3d"true" strokeweight\x3d"',l,'" filled\x3d"false" path\x3d"',t,'" coordsize\x3d"10 10" style\x3d"',r.style.cssText,'" /\x3e'],x=G(d.prepVML(g),null,{left:b(n.left)+ +m(a.offsetX,1),top:b(n.top)+m(a.offsetY,1)}),q&&(x.cutOff=l+1),g=['\x3cstroke color\x3d"',a.color||"#000000",'" opacity\x3d"',f*k,'"/\x3e'],G(d.prepVML(g),null,null,x),c?c.element.appendChild(x):r.parentNode.insertBefore(x,r),e.push(x);this.shadows=e}return this},updateShadows:C,setAttr:function(a,b){this.docMode8?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){(this.added?this.element:this).className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]|| +G(this.renderer.prepVML(["\x3cstroke/\x3e"]),null,null,c))[b]=a||"solid";this[b]=a},dSetter:function(a,b,c){var e=this.shadows;a=a||[];this.d=a.join&&a.join(" ");c.path=a=this.pathToVML(a);if(e)for(c=e.length;c--;)e[c].path=e[c].cutOff?this.cutOffPath(a,e[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var e=c.nodeName;"SPAN"===e?c.style.color=a:"IMG"!==e&&(c.filled="none"!==a,this.setAttr("fillcolor",this.renderer.color(a,c,b,this)))},"fill-opacitySetter":function(a,b,c){G(this.renderer.prepVML(["\x3c", +b.split("-")[0],' opacity\x3d"',a,'"/\x3e']),null,null,c)},opacitySetter:C,rotationSetter:function(a,b,c){c=c.style;this[b]=c[b]=a;c.left=-Math.round(Math.sin(a*f)+1)+"px";c.top=Math.round(Math.cos(a*f))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b,this))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a;this[b]=a;n(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){"inherit"===a&& +(a="visible");this.shadows&&l(this.shadows,function(c){c.style[b]=a});"DIV"===c.nodeName&&(a="hidden"===a?"-999em":0,this.docMode8||(c.style[b]=a?"visible":"hidden"),b="top");c.style[b]=a},xSetter:function(a,b,c){this[b]=a;"x"===b?b="left":"y"===b&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}},C["stroke-opacitySetter"]=C["fill-opacitySetter"],a.VMLElement=C=D(q,C),C.prototype.ySetter=C.prototype.widthSetter=C.prototype.heightSetter= +C.prototype.xSetter,C={Element:C,isIE8:-1h[0]&&b.push([1,h[1]]);l(b,function(g,b){d.test(g[1])?(r=a.color(g[1]),B=r.get("rgb"),t=r.get("a")):(B=g[1],t=1);y.push(100*g[0]+"% "+B);b?(H=t,A=B):(F=t,u=B)});if("fill"===m)if("gradient"===x)m=z.x1||z[0]||0,b=z.y1||z[1]||0,f=z.x2||z[2]||0,z=z.y2||z[3]||0,p='angle\x3d"'+(90-180*Math.atan((z-b)/(f-m))/Math.PI)+'"', +v();else{var g=z.r,C=2*g,D=2*g,I=z.cx,U=z.cy,L=c.radialReference,T,g=function(){L&&(T=q.getBBox(),I+=(L[0]-T.x)/T.width-.5,U+=(L[1]-T.y)/T.height-.5,C*=L[2]/T.width,D*=L[2]/T.height);p='src\x3d"'+a.getOptions().global.VMLRadialGradientURL+'" size\x3d"'+C+","+D+'" origin\x3d"0.5,0.5" position\x3d"'+I+","+U+'" color2\x3d"'+u+'" ';v()};q.added?g():q.onAdd=g;g=A}else g=B}else d.test(b)&&"IMG"!==c.tagName?(r=a.color(b),q[m+"-opacitySetter"](r.get("a"),m,c),g=r.get("rgb")):(g=c.getElementsByTagName(m), +g.length&&(g[0].opacity=1,g[0].type="solid"),g=b);return g},prepVML:function(a){var b=this.isIE8;a=a.join("");b?(a=a.replace("/\x3e",' xmlns\x3d"urn:schemas-microsoft-com:vml" /\x3e'),a=-1===a.indexOf('style\x3d"')?a.replace("/\x3e",' style\x3d"display:inline-block;behavior:url(#default#VML);" /\x3e'):a.replace('style\x3d"','style\x3d"display:inline-block;behavior:url(#default#VML);')):a=a.replace("\x3c","\x3chcv:");return a},text:z.prototype.html,path:function(a){var b={coordsize:"10 10"};c(a)?b.d= +a:y(a)&&d(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,c){var e=this.symbol("circle");y(a)&&(c=a.r,b=a.y,a=a.x);e.isCircle=!0;e.r=c;return e.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement("div").attr(b)},image:function(a,b,c,m,k){var e=this.createElement("img").attr({src:a});1t&&h-m*bc&&(e=Math.round((d-h)/Math.cos(t*p)));else if(d=h+(1-m)*b,h-m*bc&&(z=c-a.x+z*m,F=-1),z=Math.min(q, +z),zz||l.autoRotation&&(y.styles||{}).width)e=z;e&&(r.width=e,(l.options.labels.style||{}).textOverflow||(r.textOverflow="ellipsis"),y.css(r))},getPosition:function(a,f,h,d){var c=this.axis,n=c.chart,l=d&&n.oldChartHeight||n.chartHeight;return{x:a?c.translate(f+h,null,null,d)+c.transB:c.left+c.offset+(c.opposite?(d&&n.oldChartWidth||n.chartWidth)-c.right-c.left:0),y:a?l-c.bottom+c.offset-(c.opposite?c.height:0):l-c.translate(f+h,null, +null,d)-c.transB}},getLabelPosition:function(a,f,h,d,c,n,y,t){var m=this.axis,b=m.transA,q=m.reversed,z=m.staggerLines,l=m.tickRotCorr||{x:0,y:0},e=c.y;C(e)||(e=0===m.side?h.rotation?-8:-h.getBBox().height:2===m.side?l.y+8:Math.cos(h.rotation*p)*(l.y-h.getBBox(!1,0).height/2));a=a+c.x+l.x-(n&&d?n*b*(q?-1:1):0);f=f+e-(n&&!d?n*b*(q?1:-1):0);z&&(h=y/(t||1)%z,m.opposite&&(h=z-h-1),f+=m.labelOffset/z*h);return{x:a,y:Math.round(f)}},getMarkPath:function(a,f,h,d,c,n){return n.crispLine(["M",a,f,"L",a+(c? +0:-h),f+(c?h:0)],d)},render:function(a,l,h){var d=this.axis,c=d.options,n=d.chart.renderer,p=d.horiz,t=this.type,m=this.label,b=this.pos,q=c.labels,z=this.gridLine,F=t?t+"Tick":"tick",e=d.tickSize(F),r=this.mark,x=!r,A=q.step,k={},w=!0,K=d.tickmarkOffset,J=this.getPosition(p,b,K,l),u=J.x,J=J.y,g=p&&u===d.pos+d.len||!p&&J===d.pos?-1:1,B=t?t+"Grid":"grid",S=c[B+"LineWidth"],M=c[B+"LineColor"],v=c[B+"LineDashStyle"],B=f(c[F+"Width"],!t&&d.isXAxis?1:0),F=c[F+"Color"];h=f(h,1);this.isActive=!0;z||(k.stroke= +M,k["stroke-width"]=S,v&&(k.dashstyle=v),t||(k.zIndex=1),l&&(k.opacity=0),this.gridLine=z=n.path().attr(k).addClass("highcharts-"+(t?t+"-":"")+"grid-line").add(d.gridGroup));if(!l&&z&&(b=d.getPlotLinePath(b+K,z.strokeWidth()*g,l,!0)))z[this.isNew?"attr":"animate"]({d:b,opacity:h});e&&(d.opposite&&(e[0]=-e[0]),x&&(this.mark=r=n.path().addClass("highcharts-"+(t?t+"-":"")+"tick").add(d.axisGroup),r.attr({stroke:F,"stroke-width":B})),r[x?"attr":"animate"]({d:this.getMarkPath(u,J,e[0],r.strokeWidth()* +g,p,n),opacity:h}));m&&I(u)&&(m.xy=J=this.getLabelPosition(u,J,m,p,q,K,a,A),this.isFirst&&!this.isLast&&!f(c.showFirstLabel,1)||this.isLast&&!this.isFirst&&!f(c.showLastLabel,1)?w=!1:!p||d.isRadial||q.step||q.rotation||l||0===h||this.handleOverflow(J),A&&a%A&&(w=!1),w&&I(J.y)?(J.opacity=h,m[this.isNew?"attr":"animate"](J)):m.attr("y",-9999),this.isNew=!1)},destroy:function(){G(this,this.axis)}}})(L);(function(a){var D=a.addEvent,C=a.animObject,G=a.arrayMax,I=a.arrayMin,h=a.AxisPlotLineOrBandExtension, +f=a.color,p=a.correctFloat,v=a.defaultOptions,l=a.defined,u=a.deg2rad,d=a.destroyObjectProperties,c=a.each,n=a.extend,y=a.fireEvent,t=a.format,m=a.getMagnitude,b=a.grep,q=a.inArray,z=a.isArray,F=a.isNumber,e=a.isString,r=a.merge,x=a.normalizeTickInterval,A=a.pick,k=a.PlotLineOrBand,w=a.removeEvent,K=a.splat,J=a.syncTimeout,N=a.Tick;a.Axis=function(){this.init.apply(this,arguments)};a.Axis.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M", +day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,labels:{enabled:!0,style:{color:"#666666",cursor:"default",fontSize:"11px"},x:0},minPadding:.01,maxPadding:.01,minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle",style:{color:"#666666"}},type:"linear",minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",lineColor:"#ccd6eb",lineWidth:1, +gridLineColor:"#e6e6e6",tickColor:"#ccd6eb"},defaultYAxisOptions:{endOnTick:!0,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},maxPadding:.05,minPadding:.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return a.numberFormat(this.total,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"#000000",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15}, +title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},init:function(a,b){var g=b.isX;this.chart=a;this.horiz=a.inverted?!g:g;this.isXAxis=g;this.coll=this.coll||(g?"xAxis":"yAxis");this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var c=this.options,e=c.type;this.labelFormatter=c.labels.formatter||this.defaultLabelFormatter; +this.userOptions=b;this.minPixelPadding=0;this.reversed=c.reversed;this.visible=!1!==c.visible;this.zoomEnabled=!1!==c.zoomEnabled;this.hasNames="category"===e||!0===c.categories;this.categories=c.categories||this.hasNames;this.names=this.names||[];this.isLog="logarithmic"===e;this.isDatetimeAxis="datetime"===e;this.isLinked=l(c.linkedTo);this.ticks={};this.labelEdge=[];this.minorTicks={};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=c.minRange||c.maxZoom; +this.range=c.range;this.offset=c.offset||0;this.stacks={};this.oldStacks={};this.stacksTouched=0;this.min=this.max=null;this.crosshair=A(c.crosshair,K(a.options.tooltip.crosshairs)[g?0:1],!1);var k;b=this.options.events;-1===q(this,a.axes)&&(g?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];a.inverted&&g&&void 0===this.reversed&&(this.reversed=!0);this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(k in b)D(this,k,b[k]); +this.isLog&&(this.val2lin=this.log2lin,this.lin2val=this.lin2log)},setOptions:function(a){this.options=r(this.defaultOptions,"yAxis"===this.coll&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],r(v[this.coll],a))},defaultLabelFormatter:function(){var g=this.axis,b=this.value,c=g.categories,e=this.dateTimeLabelFormat,k=v.lang,m=k.numericSymbols,k=k.numericSymbolMagnitude||1E3,q=m&&m.length,d,r=g.options.labels.format, +g=g.isLog?b:g.tickInterval;if(r)d=t(r,this);else if(c)d=b;else if(e)d=a.dateFormat(e,b);else if(q&&1E3<=g)for(;q--&&void 0===d;)c=Math.pow(k,q+1),g>=c&&0===10*b%c&&null!==m[q]&&0!==b&&(d=a.numberFormat(b/c,-1)+m[q]);void 0===d&&(d=1E4<=Math.abs(b)?a.numberFormat(b,-1):a.numberFormat(b,-1,void 0,""));return d},getSeriesExtremes:function(){var a=this,e=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();c(a.series,function(g){if(g.visible|| +!e.options.chart.ignoreHiddenSeries){var c=g.options,k=c.threshold,B;a.hasVisibleSeries=!0;a.isLog&&0>=k&&(k=null);if(a.isXAxis)c=g.xData,c.length&&(g=I(c),F(g)||g instanceof Date||(c=b(c,function(a){return F(a)}),g=I(c)),a.dataMin=Math.min(A(a.dataMin,c[0]),g),a.dataMax=Math.max(A(a.dataMax,c[0]),G(c)));else if(g.getExtremes(),B=g.dataMax,g=g.dataMin,l(g)&&l(B)&&(a.dataMin=Math.min(A(a.dataMin,g),g),a.dataMax=Math.max(A(a.dataMax,B),B)),l(k)&&(a.threshold=k),!c.softThreshold||a.isLog)a.softThreshold= +!1}})},translate:function(a,b,c,e,k,m){var g=this.linkedParent||this,B=1,q=0,d=e?g.oldTransA:g.transA;e=e?g.oldMin:g.min;var r=g.minPixelPadding;k=(g.isOrdinal||g.isBroken||g.isLog&&k)&&g.lin2val;d||(d=g.transA);c&&(B*=-1,q=g.len);g.reversed&&(B*=-1,q-=B*(g.sector||g.len));b?(a=(a*B+q-r)/d+e,k&&(a=g.lin2val(a))):(k&&(a=g.val2lin(a)),a=B*(a-e)*d+q+B*r+(F(m)?d*m:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a- +(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,e,k){var g=this.chart,B=this.left,m=this.top,q,d,r=c&&g.oldChartHeight||g.chartHeight,n=c&&g.oldChartWidth||g.chartWidth,f;q=this.transB;var w=function(a,g,b){if(ab)e?a=Math.min(Math.max(g,a),b):f=!0;return a};k=A(k,this.translate(a,null,null,c));a=c=Math.round(k+q);q=d=Math.round(r-k-q);F(k)?this.horiz?(q=m,d=r-this.bottom,a=c=w(a,B,B+this.width)):(a=B,c=n-this.right,q=d=w(q,m,m+this.height)):f=!0;return f&&!e?null:g.renderer.crispLine(["M", +a,q,"L",c,d],b||1)},getLinearTickPositions:function(a,b,c){var g,k=p(Math.floor(b/a)*a),e=p(Math.ceil(c/a)*a),B=[];if(b===c&&F(b))return[b];for(b=k;b<=e;){B.push(b);b=p(b+a);if(b===g)break;g=b}return B},getMinorTickPositions:function(){var a=this.options,b=this.tickPositions,c=this.minorTickInterval,k=[],e,m=this.pointRangePadding||0;e=this.min-m;var m=this.max+m,q=m-e;if(q&&q/c=this.minRange,q,d,r,f,n,w;this.isXAxis&&void 0===this.minRange&&!this.isLog&&(l(a.min)||l(a.max)?this.minRange=null:(c(this.series,function(a){f=a.xData;for(d=n=a.xIncrement? +1:f.length-1;0=J?(N=J,t=0):g.dataMax<=J&&(v=J,w=0)),g.min=A(C,N,g.dataMin),g.max=A(D,v,g.dataMax));q&&(!b&&0>= +Math.min(g.min,A(g.dataMin,g.min))&&a.error(10,1),g.min=p(d(g.min),15),g.max=p(d(g.max),15));g.range&&l(g.max)&&(g.userMin=g.min=C=Math.max(g.min,g.minFromRange()),g.userMax=D=g.max,g.range=null);y(g,"foundExtremes");g.beforePadding&&g.beforePadding();g.adjustForMinRange();!(K||g.axisPointRange||g.usePercentage||n)&&l(g.min)&&l(g.max)&&(d=g.max-g.min)&&(!l(C)&&t&&(g.min-=d*t),!l(D)&&w&&(g.max+=d*w));F(e.floor)?g.min=Math.max(g.min,e.floor):F(e.softMin)&&(g.min=Math.min(g.min,e.softMin));F(e.ceiling)? +g.max=Math.min(g.max,e.ceiling):F(e.softMax)&&(g.max=Math.max(g.max,e.softMax));u&&l(g.dataMin)&&(J=J||0,!l(C)&&g.min=J?g.min=J:!l(D)&&g.max>J&&g.dataMax<=J&&(g.max=J));g.tickInterval=g.min===g.max||void 0===g.min||void 0===g.max?1:n&&!z&&h===g.linkedParent.options.tickPixelInterval?z=g.linkedParent.tickInterval:A(z,this.tickAmount?(g.max-g.min)/Math.max(this.tickAmount-1,1):void 0,K?1:(g.max-g.min)*h/Math.max(g.len,h));f&&!b&&c(g.series,function(a){a.processData(g.min!==g.oldMin||g.max!== +g.oldMax)});g.setAxisTranslation(!0);g.beforeSetTickPositions&&g.beforeSetTickPositions();g.postProcessTickInterval&&(g.tickInterval=g.postProcessTickInterval(g.tickInterval));g.pointRange&&!z&&(g.tickInterval=Math.max(g.pointRange,g.tickInterval));b=A(e.minTickInterval,g.isDatetimeAxis&&g.closestPointRange);!z&&g.tickIntervalg.tickInterval&&1E3g.max)),!!this.tickAmount)); +this.tickAmount||(g.tickInterval=g.unsquish());this.setTickPositions()},setTickPositions:function(){var a=this.options,b,c=a.tickPositions,k=a.tickPositioner,e=a.startOnTick,m=a.endOnTick,q;this.tickmarkOffset=this.categories&&"between"===a.tickmarkPlacement&&1===this.tickInterval?.5:0;this.minorTickInterval="auto"===a.minorTickInterval&&this.tickInterval?this.tickInterval/5:a.minorTickInterval;this.tickPositions=b=c&&c.slice();!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval, +a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,this.min,this.max),b.length>this.len&&(b=[b[0],b.pop()]),this.tickPositions=b,k&&(k=k.apply(this,[this.min,this.max])))&&(this.tickPositions=b=k);this.isLinked||(this.trimTicks(b,e,m),this.min===this.max&&l(this.min)&&!this.tickAmount&&(q=!0,this.min-=.5,this.max+=.5),this.single=q,c||k||this.adjustTickAmount())}, +trimTicks:function(a,b,c){var g=a[0],k=a[a.length-1],e=this.minPointOffset||0;if(b)this.min=g;else for(;this.min-e>a[0];)a.shift();if(c)this.max=k;else for(;this.max+eb&&(this.finalTickAmt=b,b=5);this.tickAmount=b},adjustTickAmount:function(){var a=this.tickInterval,b=this.tickPositions,c=this.tickAmount,k=this.finalTickAmt,e=b&&b.length;if(ec&&(this.tickInterval*=2,this.setTickPositions());if(l(k)){for(a=c=b.length;a--;)(3===k&&1===a%2||2>=k&&0k&&(a=k)),l(c)&&(bk&&(b=k))),this.displayBtn=void 0!==a||void 0!==b,this.setExtremes(a,b,!1,void 0,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsetLeft||0,k=this.horiz,e=A(b.width,a.plotWidth-c+(b.offsetRight||0)),m=A(b.height,a.plotHeight),q=A(b.top,a.plotTop),b=A(b.left, +a.plotLeft+c),c=/%$/;c.test(m)&&(m=Math.round(parseFloat(m)/100*a.plotHeight));c.test(q)&&(q=Math.round(parseFloat(q)/100*a.plotHeight+a.plotTop));this.left=b;this.top=q;this.width=e;this.height=m;this.bottom=a.chartHeight-m-q;this.right=a.chartWidth-e-b;this.len=Math.max(k?e:m,0);this.pos=k?b:q},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?p(b(this.min)):this.min,max:a?p(b(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}}, +getThreshold:function(a){var b=this.isLog,g=this.lin2log,c=b?g(this.min):this.min,b=b?g(this.max):this.max;null===a?a=c:c>a?a=c:ba?"right":195a?"left":"center"},tickSize:function(a){var b=this.options,g=b[a+"Length"],c=A(b[a+"Width"],"tick"===a&&this.isXAxis?1:0);if(c&&g)return"inside"===b[a+"Position"]&&(g=-g),[g,c]},labelMetrics:function(){return this.chart.renderer.fontMetrics(this.options.labels.style&& +this.options.labels.style.fontSize,this.ticks[0]&&this.ticks[0].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,k=this.tickInterval,e=k,m=this.len/(((this.categories?1:0)+this.max-this.min)/k),q,d=a.rotation,r=this.labelMetrics(),f,n=Number.MAX_VALUE,w,t=function(a){a/=m||1;a=1=a)f=t(Math.abs(r.h/Math.sin(u*a))),b=f+ +Math.abs(a/360),b(c.step||0)&&!c.rotation&&(this.staggerLines||1)*a.plotWidth/k||!b&&(e&&e-a.spacing[3]||.33*a.chartWidth)},renderUnsquish:function(){var a=this.chart,b=a.renderer,k=this.tickPositions,m=this.ticks,q=this.options.labels,d=this.horiz, +f=this.getSlotWidth(),n=Math.max(1,Math.round(f-2*(q.padding||5))),w={},t=this.labelMetrics(),z=q.style&&q.style.textOverflow,h,l=0,x,F;e(q.rotation)||(w.rotation=q.rotation||0);c(k,function(a){(a=m[a])&&a.labelLength>l&&(l=a.labelLength)});this.maxLabelLength=l;if(this.autoRotation)l>n&&l>t.h?w.rotation=this.labelRotation:this.labelRotation=0;else if(f&&(h={width:n+"px"},!z))for(h.textOverflow="clip",x=k.length;!d&&x--;)if(F=k[x],n=m[F].label)n.styles&&"ellipsis"===n.styles.textOverflow?n.css({textOverflow:"clip"}): +m[F].labelLength>f&&n.css({width:f+"px"}),n.getBBox().height>this.len/k.length-(t.h-t.f)&&(n.specCss={textOverflow:"ellipsis"});w.rotation&&(h={width:(l>.5*a.chartHeight?.33*a.chartHeight:a.chartHeight)+"px"},z||(h.textOverflow="ellipsis"));if(this.labelAlign=q.align||this.autoLabelAlign(this.labelRotation))w.align=this.labelAlign;c(k,function(a){var b=(a=m[a])&&a.label;b&&(b.attr(w),h&&b.css(r(h,b.specCss)),delete b.specCss,a.rotation=w.rotation)});this.tickRotCorr=b.rotCorr(t.b,this.labelRotation|| +0,0!==this.side)},hasData:function(){return this.hasVisibleSeries||l(this.min)&&l(this.max)&&!!this.tickPositions},addTitle:function(a){var b=this.chart.renderer,g=this.horiz,c=this.opposite,k=this.options.title,e;this.axisTitle||((e=k.textAlign)||(e=(g?{low:"left",middle:"center",high:"right"}:{low:c?"right":"left",middle:"center",high:c?"left":"right"})[k.align]),this.axisTitle=b.text(k.text,0,0,k.useHTML).attr({zIndex:7,rotation:k.rotation||0,align:e}).addClass("highcharts-axis-title").css(k.style).add(this.axisGroup), +this.axisTitle.isNew=!0);this.axisTitle[a?"show":"hide"](!0)},getOffset:function(){var a=this,b=a.chart,k=b.renderer,e=a.options,m=a.tickPositions,q=a.ticks,d=a.horiz,r=a.side,n=b.inverted?[1,0,3,2][r]:r,w,f,t=0,z,h=0,x=e.title,F=e.labels,p=0,K=b.axisOffset,b=b.clipOffset,J=[-1,1,1,-1][r],u,y=e.className,v=a.axisParent,C=this.tickSize("tick");w=a.hasData();a.showAxis=f=w||A(e.showEmpty,!0);a.staggerLines=a.horiz&&F.staggerLines;a.axisGroup||(a.gridGroup=k.g("grid").attr({zIndex:e.gridZIndex||1}).addClass("highcharts-"+ +this.coll.toLowerCase()+"-grid "+(y||"")).add(v),a.axisGroup=k.g("axis").attr({zIndex:e.zIndex||2}).addClass("highcharts-"+this.coll.toLowerCase()+" "+(y||"")).add(v),a.labelGroup=k.g("axis-labels").attr({zIndex:F.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels "+(y||"")).add(v));if(w||a.isLinked)c(m,function(b){q[b]?q[b].addLabel():q[b]=new N(a,b)}),a.renderUnsquish(),!1===F.reserveSpace||0!==r&&2!==r&&{1:"left",3:"right"}[r]!==a.labelAlign&&"center"!==a.labelAlign||c(m,function(a){p= +Math.max(q[a].getLabelSize(),p)}),a.staggerLines&&(p*=a.staggerLines,a.labelOffset=p*(a.opposite?-1:1));else for(u in q)q[u].destroy(),delete q[u];x&&x.text&&!1!==x.enabled&&(a.addTitle(f),f&&(t=a.axisTitle.getBBox()[d?"height":"width"],z=x.offset,h=l(z)?0:A(x.margin,d?5:10)));a.renderLine();a.offset=J*A(e.offset,K[r]);a.tickRotCorr=a.tickRotCorr||{x:0,y:0};k=0===r?-a.labelMetrics().h:2===r?a.tickRotCorr.y:0;h=Math.abs(p)+h;p&&(h=h-k+J*(d?A(F.y,a.tickRotCorr.y+8*J):F.x));a.axisTitleMargin=A(z,h); +K[r]=Math.max(K[r],a.axisTitleMargin+t+J*a.offset,h,w&&m.length&&C?C[0]:0);e=e.offset?0:2*Math.floor(a.axisLine.strokeWidth()/2);b[n]=Math.max(b[n],e)},getLinePath:function(a){var b=this.chart,c=this.opposite,g=this.offset,k=this.horiz,e=this.left+(c?this.width:0)+g,g=b.chartHeight-this.bottom-(c?this.height:0)+g;c&&(a*=-1);return b.renderer.crispLine(["M",k?this.left:e,k?g:this.top,"L",k?b.chartWidth-this.right:e,k?g:b.chartHeight-this.bottom],a)},renderLine:function(){this.axisLine||(this.axisLine= +this.chart.renderer.path().addClass("highcharts-axis-line").add(this.axisGroup),this.axisLine.attr({stroke:this.options.lineColor,"stroke-width":this.options.lineWidth,zIndex:7}))},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,k=this.len,e=this.options.title,m=a?b:c,q=this.opposite,d=this.offset,r=e.x||0,n=e.y||0,w=this.chart.renderer.fontMetrics(e.style&&e.style.fontSize,this.axisTitle).f,k={low:m+(a?0:k),middle:m+k/2,high:m+(a?k:0)}[e.align],b=(a?c+this.height:b)+(a?1:-1)* +(q?-1:1)*this.axisTitleMargin+(2===this.side?w:0);return{x:a?k+r:b+(q?this.width:0)+d+r,y:a?b+n-(q?this.height:0)+d:k+n}},render:function(){var a=this,b=a.chart,e=b.renderer,m=a.options,q=a.isLog,d=a.lin2log,r=a.isLinked,n=a.tickPositions,w=a.axisTitle,f=a.ticks,t=a.minorTicks,z=a.alternateBands,h=m.stackLabels,l=m.alternateGridColor,x=a.tickmarkOffset,p=a.axisLine,A=b.hasRendered&&F(a.oldMin),K=a.showAxis,u=C(e.globalAnimation),y,v;a.labelEdge.length=0;a.overlap=!1;c([f,t,z],function(a){for(var b in a)a[b].isActive= +!1});if(a.hasData()||r)a.minorTickInterval&&!a.categories&&c(a.getMinorTickPositions(),function(b){t[b]||(t[b]=new N(a,b,"minor"));A&&t[b].isNew&&t[b].render(null,!0);t[b].render(null,!1,1)}),n.length&&(c(n,function(b,c){if(!r||b>=a.min&&b<=a.max)f[b]||(f[b]=new N(a,b)),A&&f[b].isNew&&f[b].render(c,!0,.1),f[b].render(c)}),x&&(0===a.min||a.single)&&(f[-1]||(f[-1]=new N(a,-1,null,!0)),f[-1].render(-1))),l&&c(n,function(c,g){v=void 0!==n[g+1]?n[g+1]+x:a.max-x;0===g%2&&c=c.second?0:A*Math.floor(e.getMilliseconds()/A));if(x>=c.second)e[C.hcSetSeconds](x>=c.minute?0:A*Math.floor(e.getSeconds()/A));if(x>=c.minute)e[C.hcSetMinutes](x>=c.hour?0:A*Math.floor(e[C.hcGetMinutes]()/A));if(x>=c.hour)e[C.hcSetHours](x>=c.day?0:A*Math.floor(e[C.hcGetHours]()/A));if(x>=c.day)e[C.hcSetDate](x>=c.month?1:A*Math.floor(e[C.hcGetDate]()/A));x>=c.month&&(e[C.hcSetMonth](x>=c.year?0:A*Math.floor(e[C.hcGetMonth]()/A)),F=e[C.hcGetFullYear]()); +if(x>=c.year)e[C.hcSetFullYear](F-F%A);if(x===c.week)e[C.hcSetDate](e[C.hcGetDate]()-e[C.hcGetDay]()+d(m,1));F=e[C.hcGetFullYear]();m=e[C.hcGetMonth]();var w=e[C.hcGetDate](),K=e[C.hcGetHours]();if(C.hcTimezoneOffset||C.hcGetTimezoneOffset)k=(!n||!!C.hcGetTimezoneOffset)&&(t-y>4*c.month||l(y)!==l(t)),e=e.getTime(),e=new C(e+l(e));n=e.getTime();for(y=1;np&&(!l||q<=v)&&void 0!==q&&y.push(q),q>v&&(z=!0),q=b;else p=c(p),v=c(v),a=f[l?"minorTickInterval":"tickInterval"],a=h("auto"===a?null:a,this._minorAutoInterval,f.tickPixelInterval/(l?5:1)*(v-p)/((l?d/this.tickPositions.length:d)||1)),a=I(a,null,C(a)),y=G(this.getLinearTickPositions(a,p,v),n),l||(this._minorAutoInterval=a/5);l||(this.tickInterval=a);return y};D.prototype.log2lin= +function(a){return Math.log(a)/Math.LN10};D.prototype.lin2log=function(a){return Math.pow(10,a)}})(L);(function(a){var D=a.dateFormat,C=a.each,G=a.extend,I=a.format,h=a.isNumber,f=a.map,p=a.merge,v=a.pick,l=a.splat,u=a.syncTimeout,d=a.timeUnits;a.Tooltip=function(){this.init.apply(this,arguments)};a.Tooltip.prototype={init:function(a,d){this.chart=a;this.options=d;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.split=d.split&&!a.inverted;this.shared=d.shared||this.split},cleanSplit:function(a){C(this.chart.series, +function(c){var d=c&&c.tt;d&&(!d.isActive||a?c.tt=d.destroy():d.isActive=!1)})},getLabel:function(){var a=this.chart.renderer,d=this.options;this.label||(this.split?this.label=a.g("tooltip"):(this.label=a.label("",0,0,d.shape||"callout",null,null,d.useHTML,null,"tooltip").attr({padding:d.padding,r:d.borderRadius}),this.label.attr({fill:d.backgroundColor,"stroke-width":d.borderWidth}).css(d.style).shadow(d.shadow)),this.label.attr({zIndex:8}).add());return this.label},update:function(a){this.destroy(); +this.init(this.chart,p(!0,this.options,a))},destroy:function(){this.label&&(this.label=this.label.destroy());this.split&&this.tt&&(this.cleanSplit(this.chart,!0),this.tt=this.tt.destroy());clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},move:function(a,d,f,t){var c=this,b=c.now,q=!1!==c.options.animation&&!c.isHidden&&(1n-q?n:n-q);else if(w)b[a]=Math.max(e,g+q+k>c?g:g+q);else return!1},p=function(a,c,k,g){var e;gc-m?e=!1:b[a]=gc-k/2?c-k-2:g-k/2;return e},k=function(a){var b=h;h=e;e=b;n=a},w=function(){!1!==l.apply(0,h)?!1!==p.apply(0,e)||n||(k(!0),w()):n?b.x=b.y=0:(k(!0), +w())};(c.inverted||1w&&(q=!1);a=(c.series&&c.series.yAxis&&c.series.yAxis.pos)+(c.plotY||0);a-=m.plotTop;n.push({target:c.isHeader? +m.plotHeight+l:a,rank:c.isHeader?1:0,size:r.tt.getBBox().height+1,point:c,x:w,tt:k})});this.cleanSplit();a.distribute(n,m.plotHeight+l);C(n,function(a){var b=a.point,c=b.series;a.tt.attr({visibility:void 0===a.pos?"hidden":"inherit",x:q||b.isHeader?a.x:b.plotX+m.plotLeft+v(h.distance,16),y:a.pos+m.plotTop,anchorX:b.isHeader?b.plotX+m.plotLeft:b.plotX+c.xAxis.pos,anchorY:b.isHeader?a.pos+m.plotTop-15:b.plotY+c.yAxis.pos})})},updatePosition:function(a){var c=this.chart,d=this.getLabel(),d=(this.options.positioner|| +this.getPosition).call(this,d.width,d.height,a);this.move(Math.round(d.x),Math.round(d.y||0),a.plotX+c.plotLeft,a.plotY+c.plotTop)},getXDateFormat:function(a,f,h){var c;f=f.dateTimeLabelFormats;var m=h&&h.closestPointRange,b,q={millisecond:15,second:12,minute:9,hour:6,day:3},n,l="millisecond";if(m){n=D("%m-%d %H:%M:%S.%L",a.x);for(b in d){if(m===d.week&&+D("%w",a.x)===h.options.startOfWeek&&"00:00:00.000"===n.substr(6)){b="week";break}if(d[b]>m){b=l;break}if(q[b]&&n.substr(q[b])!=="01-01 00:00:00.000".substr(q[b]))break; +"week"!==b&&(l=b)}b&&(c=f[b])}else c=f.day;return c||f.year},tooltipFooterHeaderFormatter:function(a,d){var c=d?"footer":"header";d=a.series;var f=d.tooltipOptions,m=f.xDateFormat,b=d.xAxis,q=b&&"datetime"===b.options.type&&h(a.key),c=f[c+"Format"];q&&!m&&(m=this.getXDateFormat(a,f,b));q&&m&&(c=c.replace("{point.key}","{point.key:"+m+"}"));return I(c,{point:a,series:d})},bodyFormatter:function(a){return f(a,function(a){var c=a.series.tooltipOptions;return(c.pointFormatter||a.point.tooltipFormatter).call(a.point, +c.pointFormat)})}}})(L);(function(a){var D=a.addEvent,C=a.attr,G=a.charts,I=a.color,h=a.css,f=a.defined,p=a.doc,v=a.each,l=a.extend,u=a.fireEvent,d=a.offset,c=a.pick,n=a.removeEvent,y=a.splat,t=a.Tooltip,m=a.win;a.Pointer=function(a,c){this.init(a,c)};a.Pointer.prototype={init:function(a,m){this.options=m;this.chart=a;this.runChartClick=m.chart.events&&!!m.chart.events.click;this.pinchDown=[];this.lastValidTouch={};t&&m.tooltip.enabled&&(a.tooltip=new t(a,m.tooltip),this.followTouchMove=c(m.tooltip.followTouchMove, +!0));this.setDOMEvents()},zoomOption:function(a){var b=this.chart,m=b.options.chart,d=m.zoomType||"",b=b.inverted;/touch/.test(a.type)&&(d=c(m.pinchType,d));this.zoomX=a=/x/.test(d);this.zoomY=d=/y/.test(d);this.zoomHor=a&&!b||d&&b;this.zoomVert=d&&!b||a&&b;this.hasZoom=a||d},normalize:function(a,c){var b,q;a=a||m.event;a.target||(a.target=a.srcElement);q=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;c||(this.chartPosition=c=d(this.chart.container));void 0===q.pageX?(b=Math.max(a.x, +a.clientX-c.left),c=a.y):(b=q.pageX-c.left,c=q.pageY-c.top);return l(a,{chartX:Math.round(b),chartY:Math.round(c)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};v(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},runPointActions:function(b){var m=this.chart,d=m.series,f=m.tooltip,e=f?f.shared:!1,r=!0,n=m.hoverPoint,h=m.hoverSeries,k,w,l,t=[],u;if(!e&&!h)for(k=0;kb.series.index?-1:1}));if(e)for(k=t.length;k--;)(t[k].x!==t[0].x||t[k].series.noSharedTooltip)&& +t.splice(k,1);if(t[0]&&(t[0]!==this.prevKDPoint||f&&f.isHidden)){if(e&&!t[0].series.noSharedTooltip){for(k=0;kn+w&&(m=n+w),ek+h&&(e=k+h),this.hasDragged=Math.sqrt(Math.pow(g-m,2)+Math.pow(p-e,2)),10k.max&&(f=k.max-e,B=!0);B?(J-=.8*(J-n[m][0]),w||(g-=.8*(g-n[m][1])),h()):n[m]=[J, +g];A||(c[m]=r-p,c[l]=e);c=A?1/x:x;d[l]=e;d[m]=f;u[A?a?"scaleY":"scaleX":"scale"+b]=x;u["translate"+b]=c*p+(J-c*K)},pinch:function(a){var p=this,l=p.chart,u=p.pinchDown,d=a.touches,c=d.length,n=p.lastValidTouch,y=p.hasZoom,t=p.selectionMarker,m={},b=1===c&&(p.inClass(a.target,"highcharts-tracker")&&l.runTrackerClick||p.runChartClick),q={};1c-6&&h(p||b.chartWidth-2*k-B-m.x)&&(this.itemX=B,this.itemY+=g+this.lastLineHeight+y,this.lastLineHeight=0);this.maxItemWidth=Math.max(this.maxItemWidth,e);this.lastItemY=g+this.itemY+y;this.lastLineHeight=Math.max(h,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];f?this.itemX+=e: +(this.itemY+=g+h+y,this.lastLineHeight=h);this.offsetWidth=p||Math.max((f?this.itemX-B-w:e)+k,this.offsetWidth)},getAllItems:function(){var a=[];f(this.chart.series,function(b){var c=b&&b.options;b&&d(c.showInLegend,h(c.linkedTo)?!1:void 0,!0)&&(a=a.concat(b.legendItems||("point"===c.legendType?b.data:b)))});return a},adjustMargins:function(a,b){var c=this.chart,m=this.options,n=m.align.charAt(0)+m.verticalAlign.charAt(0)+m.layout.charAt(0);m.floating||f([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/, +/(lbv|lm|ltv)/],function(e,f){e.test(n)&&!h(a[f])&&(c[l[f]]=Math.max(c[l[f]],c.legend[(f+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][f]*m[f%2?"x":"y"]+d(m.margin,12)+b[f]))})},render:function(){var a=this,b=a.chart,c=b.renderer,d=a.group,h,e,r,l,t=a.box,k=a.options,w=a.padding;a.itemX=a.initialItemX;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;d||(a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup));a.renderTitle(); +h=a.getAllItems();n(h,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});k.reversed&&h.reverse();a.allItems=h;a.display=e=!!h.length;a.lastLineHeight=0;f(h,function(b){a.renderItem(b)});r=(k.width||a.offsetWidth)+w;l=a.lastItemY+a.lastLineHeight+a.titleHeight;l=a.handleOverflow(l);l+=w;t||(a.box=t=c.rect().addClass("highcharts-legend-box").attr({r:k.borderRadius}).add(d),t.isNew=!0);t.attr({stroke:k.borderColor,"stroke-width":k.borderWidth||0,fill:k.backgroundColor|| +"none"}).shadow(k.shadow);0c&&!1!==t.enabled?(this.clipHeight=n=Math.max(c-20-this.titleHeight-y,0),this.currentPage=d(this.currentPage,1),this.fullHeight= +a,f(B,function(a,b){var c=a._legendItemPos[1];a=Math.round(a.legendItem.getBBox().height);var k=u.length;if(!k||c-u[k-1]>n&&(g||c)!==u[k-1])u.push(g||c),k++;b===B.length-1&&c+a-u[k-1]>n&&u.push(c);c!==g&&(g=c)}),l||(l=b.clipRect=m.clipRect(0,y,9999,0),b.contentGroup.clip(l)),v(n),p||(this.nav=p=m.g().attr({zIndex:1}).add(this.group),this.up=m.symbol("triangle",0,0,w,w).on("click",function(){b.scroll(-1,k)}).add(p),this.pager=m.text("",15,10).addClass("highcharts-legend-navigation").css(t.style).add(p), +this.down=m.symbol("triangle-down",0,0,w,w).on("click",function(){b.scroll(1,k)}).add(p)),b.scroll(0),a=c):p&&(v(),p.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0);return a},scroll:function(a,b){var d=this.pages,f=d.length;a=this.currentPage+a;var m=this.clipHeight,e=this.options.navigation,h=this.pager,n=this.padding;a>f&&(a=f);0m&&(d=typeof a[0],"string"===d?c.name=a[0]:"number"===d&&(c.x=a[0]),b++);l=h.value;)h=c[++f];h&&h.color&&!this.options.color&&(this.color=h.color);return h},destroy:function(){var a=this.series.chart,c=a.hoverPoints,f;a.pointCount--;c&&(this.setState(),I(c,this),c.length||(a.hoverPoints=null));if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)u(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(f in this)this[f]=null},destroyElements:function(){for(var a= +["graphic","dataLabel","dataLabelUpper","connector","shadowGroup"],c,f=6;f--;)c=a[f],this[c]&&(this[c]=this[c].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,color:this.color,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var c=this.series,d=c.tooltipOptions,h=l(d.valueDecimals,""),t=d.valuePrefix||"",m=d.valueSuffix||"";C(c.pointArrayMap||["y"],function(b){b="{point."+b; +if(t||m)a=a.replace(b+"}",t+b+"}"+m);a=a.replace(b+"}",b+":,."+h+"f}")});return f(a,{point:this,series:this.series})},firePointEvent:function(a,c,f){var d=this,n=this.series.options;(n.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();"click"===a&&n.allowPointSelect&&(f=function(a){d.select&&d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});h(this,a,c,f)},visible:!0}})(L);(function(a){var D=a.addEvent,C=a.animObject,G=a.arrayMax,I=a.arrayMin,h=a.correctFloat, +f=a.Date,p=a.defaultOptions,v=a.defaultPlotOptions,l=a.defined,u=a.each,d=a.erase,c=a.extend,n=a.fireEvent,y=a.grep,t=a.isArray,m=a.isNumber,b=a.isString,q=a.merge,z=a.pick,F=a.removeEvent,e=a.splat,r=a.SVGElement,x=a.syncTimeout,A=a.win;a.Series=a.seriesType("line",null,{lineWidth:2,allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},marker:{lineWidth:0,lineColor:"#ffffff",radius:4,states:{hover:{animation:{duration:50},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc", +lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{align:"center",formatter:function(){return null===this.y?"":a.numberFormat(this.y,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0,padding:5},cropThreshold:300,pointRange:0,softThreshold:!0,states:{hover:{lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3},{isCartesian:!0,pointClass:a.Point,sorted:!0,requireSorting:!0, +directTouch:!1,axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],coll:"series",init:function(a,b){var k=this,e,d,g=a.series,f;k.chart=a;k.options=b=k.setOptions(b);k.linkedSeries=[];k.bindAxes();c(k,{name:b.name,state:"",visible:!1!==b.visible,selected:!0===b.selected});d=b.events;for(e in d)D(k,e,d[e]);if(d&&d.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;k.getColor();k.getSymbol();u(k.parallelArrays,function(a){k[a+"Data"]=[]});k.setData(b.data, +!1);k.isCartesian&&(a.hasCartesianSeries=!0);g.length&&(f=g[g.length-1]);k._i=z(f&&f._i,-1)+1;for(a=this.insert(g);a=z(a[c].options.index,a[c]._i)){a.splice(c+1,0,this);break}-1===c&&a.unshift(this);c+=1}else a.push(this);return z(c,a.length-1)},bindAxes:function(){var b=this,c=b.options,e=b.chart,d;u(b.axisTypes||[],function(k){u(e[k],function(a){d= +a.options;if(c[k]===d.index||void 0!==c[k]&&c[k]===d.id||void 0===c[k]&&0===d.index)b.insert(a.series),b[k]=a,a.isDirty=!0});b[k]||b.optionalAxis===k||a.error(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,k=arguments,e=m(b)?function(g){var k="y"===g&&c.toYData?c.toYData(a):a[g];c[g+"Data"][b]=k}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(k,2))};u(c.parallelArrays,e)},autoIncrement:function(){var a=this.options,b=this.xIncrement,c,e=a.pointIntervalUnit, +b=z(b,a.pointStart,0);this.pointInterval=c=z(this.pointInterval,a.pointInterval,1);e&&(a=new f(b),"day"===e?a=+a[f.hcSetDate](a[f.hcGetDate]()+c):"month"===e?a=+a[f.hcSetMonth](a[f.hcGetMonth]()+c):"year"===e&&(a=+a[f.hcSetFullYear](a[f.hcGetFullYear]()+c)),c=a-b);this.xIncrement=b+c;return b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},k=b.plotOptions||{},e=c[this.type];this.userOptions=a;c=q(e,c.series,a);this.tooltipOptions=q(p.tooltip,p.plotOptions[this.type].tooltip, +b.tooltip,k.series&&k.series.tooltip,k[this.type]&&k[this.type].tooltip,a.tooltip);null===e.marker&&delete c.marker;this.zoneAxis=c.zoneAxis;a=this.zones=(c.zones||[]).slice();!c.negativeColor&&!c.negativeFillColor||c.zones||a.push({value:c[this.zoneAxis+"Threshold"]||c.threshold||0,className:"highcharts-negative",color:c.negativeColor,fillColor:c.negativeFillColor});a.length&&l(a[a.length-1].value)&&a.push({color:this.color,fillColor:this.fillColor});return c},getCyclic:function(a,b,c){var k,e=this.userOptions, +g=a+"Index",d=a+"Counter",f=c?c.length:z(this.chart.options.chart[a+"Count"],this.chart[a+"Count"]);b||(k=z(e[g],e["_"+g]),l(k)||(e["_"+g]=k=this.chart[d]%f,this.chart[d]+=1),c&&(b=c[k]));void 0!==k&&(this[g]=k);this[a]=b},getColor:function(){this.options.colorByPoint?this.options.color=null:this.getCyclic("color",this.options.color||v[this.type].color,this.chart.options.colors)},getSymbol:function(){this.getCyclic("symbol",this.options.marker.symbol,this.chart.options.symbols)},drawLegendSymbol:a.LegendSymbolMixin.drawLineMarker, +setData:function(c,e,d,f){var k=this,g=k.points,h=g&&g.length||0,n,r=k.options,w=k.chart,l=null,q=k.xAxis,p=r.turboThreshold,x=this.xData,A=this.yData,F=(n=k.pointArrayMap)&&n.length;c=c||[];n=c.length;e=z(e,!0);if(!1!==f&&n&&h===n&&!k.cropped&&!k.hasGroupedData&&k.visible)u(c,function(a,b){g[b].update&&a!==r.data[b]&&g[b].update(a,!1,null,!1)});else{k.xIncrement=null;k.colorCounter=0;u(this.parallelArrays,function(a){k[a+"Data"].length=0});if(p&&n>p){for(d=0;null===l&&dh||this.forceCrop))if(c[e-1]p)c=[], +k=[];else if(c[0]p)d=this.cropData(this.xData,this.yData,t,p),c=d.xData,k=d.yData,d=d.start,g=!0;for(h=c.length||1;--h;)e=q?n(c[h])-n(c[h-1]):c[h]-c[h-1],0e&&this.requireSorting&&a.error(15);this.cropped=g;this.cropStart=d;this.processedXData=c;this.processedYData=k;this.closestPointRange=f},cropData:function(a,b,c,e){var k=a.length,g=0,d=k,f=z(this.cropShoulder,1),h;for(h=0;h=c){g=Math.max(0,h-f);break}for(c=h;ce){d=c+f;break}return{xData:a.slice(g, +d),yData:b.slice(g,d),start:g,end:d}},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,f=this.processedYData,g=this.pointClass,h=d.length,m=this.cropStart||0,n,r=this.hasGroupedData,l,q=[],t;b||r||(b=[],b.length=a.length,b=this.data=b);for(t=0;t=d&&(c[r-1]||n)<=f,h&&n)if(h=l.length)for(;h--;)null!==l[h]&&(k[g++]= +l[h]);else k[g++]=l;this.dataMin=I(k);this.dataMax=G(k)},translate:function(){this.processedXData||this.processData();this.generatePoints();var a=this.options,b=a.stacking,c=this.xAxis,e=c.categories,d=this.yAxis,g=this.points,f=g.length,n=!!this.modifyValue,r=a.pointPlacement,t="between"===r||m(r),q=a.threshold,p=a.startFromThreshold?q:0,x,u,A,F,v=Number.MAX_VALUE;"between"===r&&(r=.5);m(r)&&(r*=z(a.pointRange||c.pointRange));for(a=0;a=D&&(y.isNull=!0);y.plotX=x=h(Math.min(Math.max(-1E5,c.translate(C,0,0,0,1,r,"flags"===this.type)),1E5));b&&this.visible&&!y.isNull&&G&&G[C]&&(F=this.getStackIndicator(F,C,this.index),I=G[C],D=I.points[F.key],u=D[0],D=D[1],u===p&&F.key===G[C].base&&(u=z(q,d.min)),d.isLog&&0>=u&&(u=null),y.total=y.stackTotal=I.total,y.percentage=I.total&&y.y/I.total*100,y.stackY=D,I.setOffset(this.pointXOffset||0,this.barW||0));y.yBottom=l(u)?d.translate(u,0, +1,0,1):null;n&&(D=this.modifyValue(D,y));y.plotY=u="number"===typeof D&&Infinity!==D?Math.min(Math.max(-1E5,d.translate(D,0,1,0,1)),1E5):void 0;y.isInside=void 0!==u&&0<=u&&u<=d.len&&0<=x&&x<=c.len;y.clientX=t?h(c.translate(C,0,0,0,1,r)):x;y.negative=y.y<(q||0);y.category=e&&void 0!==e[y.x]?e[y.x]:y.x;y.isNull||(void 0!==A&&(v=Math.min(v,Math.abs(x-A))),A=x);y.zone=this.zones.length&&y.getZone()}this.closestPointRangePx=v},getValidPoints:function(a,b){var c=this.chart;return y(a||this.points||[], +function(a){return b&&!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options,e=b.renderer,k=b.inverted,g=this.clipBox,d=g||b.clipBox,f=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,d.height,c.xAxis,c.yAxis].join(),h=b[f],m=b[f+"m"];h||(a&&(d.width=0,b[f+"m"]=m=e.clipRect(-99,k?-b.plotLeft:-b.plotTop,99,k?b.chartWidth:b.chartHeight)),b[f]=h=e.clipRect(d),h.count={length:0});a&&!h.count[this.index]&&(h.count[this.index]=!0,h.count.length+= +1);!1!==c.clip&&(this.group.clip(a||g?h:b.clipRect),this.markerGroup.clip(m),this.sharedClipKey=f);a||(h.count[this.index]&&(delete h.count[this.index],--h.count.length),0===h.count.length&&f&&b[f]&&(g||(b[f]=b[f].destroy()),b[f+"m"]&&(b[f+"m"]=b[f+"m"].destroy())))},animate:function(a){var b=this.chart,c=C(this.options.animation),e;a?this.setClip(c):(e=this.sharedClipKey,(a=b[e])&&a.animate({width:b.plotSizeX},c),b[e+"m"]&&b[e+"m"].animate({width:b.plotSizeX+99},c),this.animate=null)},afterAnimate:function(){this.setClip(); +n(this,"afterAnimate")},drawPoints:function(){var a=this.points,b=this.chart,c,e,d,g,f=this.options.marker,h,n,r,l,t=this.markerGroup,q=z(f.enabled,this.xAxis.isRadial?!0:null,this.closestPointRangePx>2*f.radius);if(!1!==f.enabled||this._hasPointMarkers)for(e=a.length;e--;)d=a[e],c=d.plotY,g=d.graphic,h=d.marker||{},n=!!d.marker,r=q&&void 0===h.enabled||h.enabled,l=d.isInside,r&&m(c)&&null!==d.y?(c=z(h.symbol,this.symbol),d.hasImage=0===c.indexOf("url"),r=this.markerAttribs(d,d.selected&&"select"), +g?g[l?"show":"hide"](!0).animate(r):l&&(0g&&b.shadow));d&&(d.startX=c.xMap,d.isArea=c.isArea)})},applyZones:function(){var a=this,b=this.chart,c=b.renderer,e=this.zones,d,g,f=this.clips||[], +h,m=this.graph,n=this.area,r=Math.max(b.chartWidth,b.chartHeight),l=this[(this.zoneAxis||"y")+"Axis"],q,t,p=b.inverted,x,A,F,y,v=!1;e.length&&(m||n)&&l&&void 0!==l.min&&(t=l.reversed,x=l.horiz,m&&m.hide(),n&&n.hide(),q=l.getExtremes(),u(e,function(e,k){d=t?x?b.plotWidth:0:x?0:l.toPixels(q.min);d=Math.min(Math.max(z(g,d),0),r);g=Math.min(Math.max(Math.round(l.toPixels(z(e.value,q.max),!0)),0),r);v&&(d=g=l.toPixels(q.max));A=Math.abs(d-g);F=Math.min(d,g);y=Math.max(d,g);l.isXAxis?(h={x:p?y:F,y:0,width:A, +height:r},x||(h.x=b.plotHeight-h.x)):(h={x:0,y:p?y:F,width:r,height:A},x&&(h.y=b.plotWidth-h.y));p&&c.isVML&&(h=l.isXAxis?{x:0,y:t?F:y,height:h.width,width:b.chartWidth}:{x:h.y-b.plotLeft-b.spacingBox.x,y:0,width:h.height,height:b.chartHeight});f[k]?f[k].animate(h):(f[k]=c.clipRect(h),m&&a["zone-graph-"+k].clip(f[k]),n&&a["zone-area-"+k].clip(f[k]));v=e.value>q.max}),this.clips=f)},invertGroups:function(a){function b(){var b={width:c.yAxis.len,height:c.xAxis.len};u(["group","markerGroup"],function(e){c[e]&& +c[e].attr(b).invert(a)})}var c=this,e;c.xAxis&&(e=D(c.chart,"resize",b),D(c,"destroy",e),b(a),c.invertGroups=b)},plotGroup:function(a,b,c,e,d){var g=this[a],k=!g;k&&(this[a]=g=this.chart.renderer.g(b).attr({zIndex:e||.1}).add(d),g.addClass("highcharts-series-"+this.index+" highcharts-"+this.type+"-series highcharts-color-"+this.colorIndex+" "+(this.options.className||"")));g.attr({visibility:c})[k?"attr":"animate"](this.getPlotBox());return g},getPlotBox:function(){var a=this.chart,b=this.xAxis,c= +this.yAxis;a.inverted&&(b=c,c=this.xAxis);return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,e=a.options,d=!!a.animate&&b.renderer.isSVG&&C(e.animation).duration,g=a.visible?"inherit":"hidden",f=e.zIndex,h=a.hasRendered,m=b.seriesGroup,n=b.inverted;c=a.plotGroup("group","series",g,f,m);a.markerGroup=a.plotGroup("markerGroup","markers",g,f,m);d&&a.animate(!0);c.inverted=a.isCartesian?n:!1;a.drawGraph&&(a.drawGraph(),a.applyZones()); +a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&!1!==a.options.enableMouseTracking&&a.drawTracker();a.invertGroups(n);!1===e.clip||a.sharedClipKey||h||c.clip(b.clipRect);d&&a.animate();h||(a.animationTimeout=x(function(){a.afterAnimate()},d));a.isDirty=a.isDirtyData=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,e=this.xAxis,d=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:z(e&& +e.left,a.plotLeft),translateY:z(d&&d.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdDimensions:1,kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,e=this.yAxis,d=this.chart.inverted;return this.searchKDTree({clientX:d?c.len-a.chartY+c.pos:a.chartX-c.pos,plotY:d?e.len-a.chartX+e.pos:a.chartY-e.pos},b)},buildKDTree:function(){function a(c,e,g){var d,k;if(k=c&&c.length)return d=b.kdAxisArray[e%g],c.sort(function(a,b){return a[d]-b[d]}),k=Math.floor(k/ +2),{point:c[k],left:a(c.slice(0,k),e+1,g),right:a(c.slice(k+1),e+1,g)}}var b=this,c=b.kdDimensions;delete b.kdTree;x(function(){b.kdTree=a(b.getValidPoints(null,!b.directTouch),c,c)},b.options.kdNow?0:1)},searchKDTree:function(a,b){function c(a,b,f,h){var m=b.point,n=e.kdAxisArray[f%h],r,q,t=m;q=l(a[d])&&l(m[d])?Math.pow(a[d]-m[d],2):null;r=l(a[g])&&l(m[g])?Math.pow(a[g]-m[g],2):null;r=(q||0)+(r||0);m.dist=l(r)?Math.sqrt(r):Number.MAX_VALUE;m.distX=l(q)?Math.sqrt(q):Number.MAX_VALUE;n=a[n]-m[n];r= +0>n?"left":"right";q=0>n?"right":"left";b[r]&&(r=c(a,b[r],f+1,h),t=r[k]p;)q--;this.updateParallelArrays(g,"splice",q,0,0);this.updateParallelArrays(g,q);m&&g.name&&(m[p]=g.name);n.splice(q,0,a);l&&(this.data.splice(q,0,null),this.processData());"point"===e.legendType&&this.generatePoints();c&&(f[0]&&f[0].remove? +f[0].remove(!1):(f.shift(),this.updateParallelArrays(g,"shift"),n.shift()));this.isDirtyData=this.isDirty=!0;b&&h.redraw(d)},removePoint:function(a,b,c){var e=this,d=e.data,f=d[a],h=e.points,m=e.chart,n=function(){h&&h.length===d.length&&h.splice(a,1);d.splice(a,1);e.options.data.splice(a,1);e.updateParallelArrays(f||{series:e},"splice",a,1);f&&f.destroy();e.isDirty=!0;e.isDirtyData=!0;b&&m.redraw()};z(c,m);b=t(b,!0);f?f.firePointEvent("remove",null,n):n()},remove:function(a,b,c){function e(){d.destroy(); +f.isDirtyLegend=f.isDirtyBox=!0;f.linkSeries();t(a,!0)&&f.redraw(b)}var d=this,f=d.chart;!1!==c?u(d,"remove",null,e):e()},update:function(a,b){var c=this,e=this.chart,d=this.userOptions,f=this.type,h=a.type||d.type||e.options.chart.type,m=q[f].prototype,n=["group","markerGroup","dataLabelsGroup"],g;if(h&&h!==f||void 0!==a.zIndex)n.length=0;p(n,function(a){n[a]=c[a];delete c[a]});a=y(d,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1,null,!1);for(g in m)this[g]= +void 0;l(this,q[h||f].prototype);p(n,function(a){c[a]=n[a]});this.init(e,a);e.linkSeries();t(b,!0)&&e.redraw(!1)}});l(G.prototype,{update:function(a,b){var c=this.chart;a=c.options[this.coll][this.options.index]=y(this.userOptions,a);this.destroy(!0);this.init(c,l(a,{events:void 0}));c.isDirtyBox=!0;t(b,!0)&&c.redraw()},remove:function(a){for(var b=this.chart,c=this.coll,e=this.series,d=e.length;d--;)e[d]&&e[d].remove(!1);v(b.axes,this);v(b[c],this);b.options[c].splice(this.options.index,1);p(b[c], +function(a,b){a.options.index=b});this.destroy();b.isDirtyBox=!0;t(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}})})(L);(function(a){var D=a.color,C=a.each,G=a.map,I=a.pick,h=a.Series,f=a.seriesType;f("area","line",{softThreshold:!1,threshold:0},{singleStacks:!1,getStackPoints:function(){var a=[],f=[],h=this.xAxis,u=this.yAxis,d=u.stacks[this.stackKey],c={},n=this.points,y=this.index,t=u.series,m=t.length,b,q=I(u.options.reversedStacks, +!0)?1:-1,z,F;if(this.options.stacking){for(z=0;za&&l>f?(l=Math.max(a,f),d=2*f-l):lI&&d>f?(d=Math.max(I,f),l=2*f-d):d=Math.abs(c)&&.5a.closestPointRange*a.xAxis.transA,h=a.borderWidth=p(f.borderWidth,h?0:1),l=a.yAxis,m=a.translatedThreshold=l.getThreshold(f.threshold),b=p(f.minPointLength, +5),q=a.getColumnMetrics(),u=q.width,F=a.barW=Math.max(u,1+2*h),e=a.pointXOffset=q.offset;c.inverted&&(m-=.5);f.pointPadding&&(F=Math.ceil(F));v.prototype.translate.apply(a);G(a.points,function(d){var f=p(d.yBottom,m),h=999+Math.abs(f),h=Math.min(Math.max(-h,d.plotY),l.len+h),k=d.plotX+e,n=F,q=Math.min(h,f),r,t=Math.max(h,f)-q;Math.abs(t)b?f-b:m-(r?b:0));d.barX=k;d.pointWidth=u;d.tooltipPos=c.inverted?[l.len+l.pos-c.plotLeft- +h,a.xAxis.len-k-n/2,t]:[k+n/2,h+l.pos-c.plotTop,t];d.shapeType="rect";d.shapeArgs=a.crispCol.apply(a,d.isNull?[d.plotX,l.len/2,0,0]:[k,q,n,t])})},getSymbol:a.noop,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,drawGraph:function(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")},pointAttribs:function(a,c){var d=this.options,f,h=this.pointAttrToOptions||{};f=h.stroke||"borderColor";var m=h["stroke-width"]||"borderWidth",b=a&&a.color||this.color,l=a[f]||d[f]||this.color|| +b,p=a[m]||d[m]||this[m]||0,h=d.dashStyle;a&&this.zones.length&&(b=(b=a.getZone())&&b.color||a.options.color||this.color);c&&(a=d.states[c],c=a.brightness,b=a.color||void 0!==c&&C(b).brighten(a.brightness).get()||b,l=a[f]||l,p=a[m]||p,h=a.dashStyle||h);f={fill:b,stroke:l,"stroke-width":p};d.borderRadius&&(f.r=d.borderRadius);h&&(f.dashstyle=h);return f},drawPoints:function(){var a=this,c=this.chart,l=a.options,p=c.renderer,t=l.animationLimit||250,m;G(a.points,function(b){var d=b.graphic;if(h(b.plotY)&& +null!==b.y){m=b.shapeArgs;if(d)d[c.pointCountl;++l)u=p[l],a=2>l||2===l&&/%$/.test(u),p[l]=C(u,[f,I,v,p[2]][l])+(a?h:0);p[3]>p[2]&&(p[3]=p[2]);return p}}})(L);(function(a){var D=a.addEvent,C=a.defined,G=a.each,I=a.extend,h=a.inArray,f=a.noop,p=a.pick,v=a.Point,l=a.Series,u=a.seriesType,d=a.setAnimation;u("pie","line",{center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return null===this.y? +void 0:this.point.name},x:0},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,stickyTracking:!1,tooltip:{followPointer:!0},borderColor:"#ffffff",borderWidth:1,states:{hover:{brightness:.1,shadow:!1}}},{isCartesian:!1,requireSorting:!1,directTouch:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttribs:a.seriesTypes.column.prototype.pointAttribs,animate:function(a){var c=this,d=c.points,f=c.startAngleRad;a||(G(d,function(a){var b= +a.graphic,d=a.shapeArgs;b&&(b.attr({r:a.startR||c.center[3]/2,start:f,end:f}),b.animate({r:d.r,start:d.start,end:d.end},c.options.animation))}),c.animate=null)},updateTotals:function(){var a,d=0,f=this.points,h=f.length,m,b=this.options.ignoreHiddenPoint;for(a=0;am.y&&(m.y=null),d+=b&&!m.visible?0:m.y;this.total=d;for(a=0;a1.5*Math.PI?u-=2*Math.PI:u<-Math.PI/2&&(u+=2*Math.PI);w.slicedTranslation={translateX:Math.round(Math.cos(u)*f),translateY:Math.round(Math.sin(u)*f)};b=Math.cos(u)*a[2]/2;l=Math.sin(u)*a[2]/2;w.tooltipPos=[a[0]+.7*b,a[1]+.7*l];w.half=u<-Math.PI/2||u>Math.PI/2?1:0;w.angle=u;h=Math.min(h,x/5);w.labelPos=[a[0]+b+Math.cos(u)*x,a[1]+l+Math.sin(u)*x,a[0]+b+Math.cos(u)*h,a[1]+l+Math.sin(u)* +h,a[0]+b,a[1]+l,0>x?"center":w.half?"right":"left",u]}},drawGraph:null,drawPoints:function(){var a=this,d=a.chart.renderer,f,h,m,b,l=a.options.shadow;l&&!a.shadowGroup&&(a.shadowGroup=d.g("shadow").add(a.group));G(a.points,function(c){if(null!==c.y){h=c.graphic;b=c.shapeArgs;f=c.sliced?c.slicedTranslation:{};var n=c.shadowGroup;l&&!n&&(n=c.shadowGroup=d.g("shadow").add(a.shadowGroup));n&&n.attr(f);m=a.pointAttribs(c,c.selected&&"select");h?h.setRadialReference(a.center).attr(m).animate(I(b,f)):(c.graphic= +h=d[c.shapeType](b).addClass(c.getClassName()).setRadialReference(a.center).attr(f).add(a.group),c.visible||h.attr({visibility:"hidden"}),h.attr(m).attr({"stroke-linejoin":"round"}).shadow(l,n))}})},searchPoint:f,sortByAngle:function(a,d){a.sort(function(a,c){return void 0!==a.angle&&(c.angle-a.angle)*d})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,getCenter:a.CenteredSeriesMixin.getCenter,getSymbol:f},{init:function(){v.prototype.init.apply(this,arguments);var a=this,d;a.name=p(a.name,"Slice"); +d=function(c){a.slice("select"===c.type)};D(a,"select",d);D(a,"unselect",d);return a},setVisible:function(a,d){var c=this,f=c.series,m=f.chart,b=f.options.ignoreHiddenPoint;d=p(d,b);a!==c.visible&&(c.visible=c.options.visible=a=void 0===a?!c.visible:a,f.options.data[h(c,f.data)]=c.options,G(["graphic","dataLabel","connector","shadowGroup"],function(b){if(c[b])c[b][a?"show":"hide"](!0)}),c.legendItem&&m.legend.colorizeItem(c,a),a||"hover"!==c.state||c.setState(""),b&&(f.isDirty=!0),d&&m.redraw())}, +slice:function(a,f,l){var c=this.series;d(l,c.chart);p(f,!0);this.sliced=this.options.sliced=a=C(a)?a:!this.sliced;c.options.data[h(this,c.data)]=this.options;a=a?this.slicedTranslation:{translateX:0,translateY:0};this.graphic.animate(a);this.shadowGroup&&this.shadowGroup.animate(a)},haloPath:function(a){var c=this.shapeArgs;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.x,c.y,c.r+a,c.r+a,{innerR:this.shapeArgs.r,start:c.start,end:c.end})}})})(L);(function(a){var D= +a.addEvent,C=a.arrayMax,G=a.defined,I=a.each,h=a.extend,f=a.format,p=a.map,v=a.merge,l=a.noop,u=a.pick,d=a.relativeLength,c=a.Series,n=a.seriesTypes,y=a.stableSort;a.distribute=function(a,c){function b(a,b){return a.target-b.target}var d,f=!0,h=a,e=[],m;m=0;for(d=a.length;d--;)m+=a[d].size;if(m>c){y(a,function(a,b){return(b.rank||0)-(a.rank||0)});for(m=d=0;m<=c;)m+=a[d].size,d++;e=a.splice(d-1,a.length)}y(a,b);for(a=p(a,function(a){return{size:a.size,targets:[a.target]}});f;){for(d=a.length;d--;)f= +a[d],m=(Math.min.apply(0,f.targets)+Math.max.apply(0,f.targets))/2,f.pos=Math.min(Math.max(0,m-f.size/2),c-f.size);d=a.length;for(f=!1;d--;)0a[d].pos&&(a[d-1].size+=a[d].size,a[d-1].targets=a[d-1].targets.concat(a[d].targets),a[d-1].pos+a[d-1].size>c&&(a[d-1].pos=c-a[d-1].size),a.splice(d,1),f=!0)}d=0;I(a,function(a){var b=0;I(a.targets,function(){h[d].pos=a.pos+b;b+=h[d].size;d++})});h.push.apply(h,e);y(h,b)};c.prototype.drawDataLabels=function(){var a=this,c=a.options, +b=c.dataLabels,d=a.points,l,n,e=a.hasRendered||0,r,p,A=u(b.defer,!0),k=a.chart.renderer;if(b.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(b),p=a.plotGroup("dataLabelsGroup","data-labels",A&&!e?"hidden":"visible",b.zIndex||6),A&&(p.attr({opacity:+e}),e||D(a,"afterAnimate",function(){a.visible&&p.show(!0);p[c.animation?"animate":"attr"]({opacity:1},{duration:200})})),n=b,I(d,function(e){var d,m=e.dataLabel,q,g,t=e.connector,F=!0,x,A={};l=e.dlOptions||e.options&&e.options.dataLabels; +d=u(l&&l.enabled,n.enabled)&&null!==e.y;if(m&&!d)e.dataLabel=m.destroy();else if(d){b=v(n,l);x=b.style;d=b.rotation;q=e.getLabelConfig();r=b.format?f(b.format,q):b.formatter.call(q,b);x.color=u(b.color,x.color,a.color,"#000000");if(m)G(r)?(m.attr({text:r}),F=!1):(e.dataLabel=m=m.destroy(),t&&(e.connector=t.destroy()));else if(G(r)){m={fill:b.backgroundColor,stroke:b.borderColor,"stroke-width":b.borderWidth,r:b.borderRadius||0,rotation:d,padding:b.padding,zIndex:1};"contrast"===x.color&&(A.color=b.inside|| +0>b.distance||c.stacking?k.getContrast(e.color||a.color):"#000000");c.cursor&&(A.cursor=c.cursor);for(g in m)void 0===m[g]&&delete m[g];m=e.dataLabel=k[d?"text":"label"](r,0,-9999,b.shape,null,null,b.useHTML,null,"data-label").attr(m);m.addClass("highcharts-data-label-color-"+e.colorIndex+" "+(b.className||"")+(b.useHTML?"highcharts-tracker":""));m.css(h(x,A));m.add(p);m.shadow(b.shadow)}m&&a.alignDataLabel(e,m,b,null,F)}})};c.prototype.alignDataLabel=function(a,c,b,d,f){var m=this.chart,e=m.inverted, +l=u(a.plotX,-9999),n=u(a.plotY,-9999),p=c.getBBox(),k,q=b.rotation,t=b.align,v=this.visible&&(a.series.forceDL||m.isInsidePlot(l,Math.round(n),e)||d&&m.isInsidePlot(l,e?d.x+1:d.y+d.height-1,e)),z="justify"===u(b.overflow,"justify");v&&(k=b.style.fontSize,k=m.renderer.fontMetrics(k,c).b,d=h({x:e?m.plotWidth-n:l,y:Math.round(e?m.plotHeight-l:n),width:0,height:0},d),h(b,{width:p.width,height:p.height}),q?(z=!1,e=m.renderer.rotCorr(k,q),e={x:d.x+b.x+d.width/2+e.x,y:d.y+b.y+{top:0,middle:.5,bottom:1}[b.verticalAlign]* +d.height},c[f?"attr":"animate"](e).attr({align:t}),l=(q+720)%360,l=180l,"left"===t?e.y-=l?p.height:0:"center"===t?(e.x-=p.width/2,e.y-=p.height/2):"right"===t&&(e.x-=p.width,e.y-=l?0:p.height)):(c.align(b,null,d),e=c.alignAttr),z?this.justifyDataLabel(c,b,e,p,d,f):u(b.crop,!0)&&(v=m.isInsidePlot(e.x,e.y)&&m.isInsidePlot(e.x+p.width,e.y+p.height)),b.shape&&!q&&c.attr({anchorX:a.plotX,anchorY:a.plotY}));v||(c.attr({y:-9999}),c.placed=!1)};c.prototype.justifyDataLabel=function(a,c,b,d,f,h){var e= +this.chart,m=c.align,l=c.verticalAlign,n,k,p=a.box?0:a.padding||0;n=b.x+p;0>n&&("right"===m?c.align="left":c.x=-n,k=!0);n=b.x+d.width-p;n>e.plotWidth&&("left"===m?c.align="right":c.x=e.plotWidth-n,k=!0);n=b.y+p;0>n&&("bottom"===l?c.verticalAlign="top":c.y=-n,k=!0);n=b.y+d.height-p;n>e.plotHeight&&("top"===l?c.verticalAlign="bottom":c.y=e.plotHeight-n,k=!0);k&&(a.placed=!h,a.align(c,null,f))};n.pie&&(n.pie.prototype.drawDataLabels=function(){var d=this,f=d.data,b,h=d.chart,l=d.options.dataLabels,n= +u(l.connectorPadding,10),e=u(l.connectorWidth,1),r=h.plotWidth,v=h.plotHeight,A,k=l.distance,w=d.center,y=w[2]/2,D=w[1],G=0m-2?u:H,e),g._attr={visibility:P,align:L[6]},g._pos={x:E+l.x+({left:n,right:-n}[L[6]]||0),y:H+l.y-10},L.x=E,L.y=H,null===d.options.size&&(B=g.width,E-Br-n&& +(O[1]=Math.max(Math.round(E+B-r+n),O[1])),0>H-M/2?O[0]=Math.max(Math.round(-H+M/2),O[0]):H+M/2>v&&(O[2]=Math.max(Math.round(H+M/2-v),O[2])))}),0===C(O)||this.verifyDataLabelOverflow(O))&&(this.placeDataLabels(),G&&e&&I(this.points,function(a){var b;A=a.connector;if((g=a.dataLabel)&&g._pos&&a.visible){P=g._attr.visibility;if(b=!A)a.connector=A=h.renderer.path().addClass("highcharts-data-label-connector highcharts-color-"+a.colorIndex).add(d.dataLabelsGroup),A.attr({"stroke-width":e,stroke:l.connectorColor|| +a.color||"#666666"});A[b?"attr":"animate"]({d:d.connectorPath(a.labelPos)});A.attr("visibility",P)}else A&&(a.connector=A.destroy())}))},n.pie.prototype.connectorPath=function(a){var c=a.x,b=a.y;return u(this.options.dataLabels.softConnector,!0)?["M",c+("left"===a[6]?5:-5),b,"C",c,b,2*a[2]-a[4],2*a[3]-a[5],a[2],a[3],"L",a[4],a[5]]:["M",c+("left"===a[6]?5:-5),b,"L",a[2],a[3],"L",a[4],a[5]]},n.pie.prototype.placeDataLabels=function(){I(this.points,function(a){var c=a.dataLabel;c&&a.visible&&((a=c._pos)? +(c.attr(c._attr),c[c.moved?"animate":"attr"](a),c.moved=!0):c&&c.attr({y:-9999}))})},n.pie.prototype.alignDataLabel=l,n.pie.prototype.verifyDataLabelOverflow=function(a){var c=this.center,b=this.options,f=b.center,h=b.minSize||80,l,e;null!==f[0]?l=Math.max(c[2]-Math.max(a[1],a[3]),h):(l=Math.max(c[2]-a[1]-a[3],h),c[0]+=(a[3]-a[1])/2);null!==f[1]?l=Math.max(Math.min(l,c[2]-Math.max(a[0],a[2])),h):(l=Math.max(Math.min(l,c[2]-a[0]-a[2]),h),c[1]+=(a[0]-a[2])/2);lu(this.translatedThreshold,e.yAxis.len)),p=u(b.inside,!!this.options.stacking);m&&(f=v(m),0>f.y&&(f.height+=f.y,f.y=0),m=f.y+f.height-e.yAxis.len,0a+d||e+lc+f||h+mthis.pointCount))}, +pan:function(a,b){var c=this,e=c.hoverPoints,d;e&&p(e,function(a){a.setState()});p("xy"===b?[1,0]:[1],function(b){b=c[b?"xAxis":"yAxis"][0];var e=b.horiz,f=a[e?"chartX":"chartY"],e=e?"mouseDownX":"mouseDownY",h=c[e],k=(b.pointRange||0)/2,g=b.getExtremes(),l=b.toValue(h-f,!0)+k,k=b.toValue(h+b.len-f,!0)-k,m=kk&&0>g&&(b.setExtremes(h,l,!1,!1,{trigger:"pan"}),d=!0);c[e]=f});d&&c.redraw(!1);I(c.container, +{cursor:"move"})}});v(m.prototype,{select:function(a,b){var c=this,e=c.series,f=e.chart;a=t(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=c.options.selected=a;e.options.data[d(c,e.data)]=c.options;c.setState(a&&"select");b||p(f.getSelectedPoints(),function(a){a.selected&&a!==c&&(a.selected=a.options.selected=!1,e.options.data[d(a,e.data)]=a.options,a.setState(""),a.firePointEvent("unselect"))})})},onMouseOver:function(a,b){var c=this.series,e=c.chart,d= +e.tooltip,f=e.hoverPoint;if(this.series){if(!b){if(f&&f!==this)f.onMouseOut();if(e.hoverSeries!==c)c.onMouseOver();e.hoverPoint=this}!d||d.shared&&!c.noSharedTooltip?d||this.setState("hover"):(this.setState("hover"),d.refresh(this,a));this.firePointEvent("mouseOver")}},onMouseOut:function(){var a=this.series.chart,b=a.hoverPoints;this.firePointEvent("mouseOut");b&&-1!==d(this,b)||(this.setState(),a.hoverPoint=null)},importEvents:function(){if(!this.hasImportedEvents){var a=y(this.series.options.point, +this.options).events,b;this.events=a;for(b in a)D(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,b){var c=Math.floor(this.plotX),d=this.plotY,e=this.series,h=e.options.states[a]||{},l=f[e.type].marker&&e.options.marker,m=l&&!1===l.enabled,n=l&&l.states&&l.states[a]||{},p=!1===n.enabled,g=e.stateMarkerGraphic,q=this.marker||{},u=e.chart,y=e.halo,z,F=l&&e.markerAttribs;a=a||"";if(!(a===this.state&&!b||this.selected&&"select"!==a||!1===h.enabled||a&&(p||m&&!1===n.enabled)||a&&q.states&& +q.states[a]&&!1===q.states[a].enabled)){F&&(z=e.markerAttribs(this,a));if(this.graphic)this.state&&this.graphic.removeClass("highcharts-point-"+this.state),a&&this.graphic.addClass("highcharts-point-"+a),this.graphic.attr(e.pointAttribs(this,a)),z&&this.graphic.animate(z,t(u.options.chart.animation,n.animation,l.animation)),g&&g.hide();else{if(a&&n){l=q.symbol||e.symbol;g&&g.currentSymbol!==l&&(g=g.destroy());if(g)g[b?"animate":"attr"]({x:z.x,y:z.y});else l&&(e.stateMarkerGraphic=g=u.renderer.symbol(l, +z.x,z.y,z.width,z.height).add(e.markerGroup),g.currentSymbol=l);g&&g.attr(e.pointAttribs(this,a))}g&&(g[a&&u.isInsidePlot(c,d,u.inverted)?"show":"hide"](),g.element.point=this)}(c=h.halo)&&c.size?(y||(e.halo=y=u.renderer.path().add(F?e.markerGroup:e.group)),y[b?"animate":"attr"]({d:this.haloPath(c.size)}),y.attr({"class":"highcharts-halo highcharts-color-"+t(this.colorIndex,e.colorIndex)}),y.point=this,y.attr(v({fill:this.color||e.color,"fill-opacity":c.opacity,zIndex:-1},c.attributes))):y&&y.point&& +y.point.haloPath&&y.animate({d:y.point.haloPath(0)});this.state=a}},haloPath:function(a){return this.series.chart.renderer.symbols.circle(Math.floor(this.plotX)-a,this.plotY-a,2*a,2*a)}});v(b.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&&l(this,"mouseOver");this.setState("hover");a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;b.hoverSeries=null;if(d)d.onMouseOut(); +this&&a.events.mouseOut&&l(this,"mouseOut");!c||a.stickyTracking||c.shared&&!this.noSharedTooltip||c.hide();this.setState()},setState:function(a){var b=this,c=b.options,d=b.graph,f=c.states,h=c.lineWidth,c=0;a=a||"";if(b.state!==a&&(p([b.group,b.markerGroup],function(c){c&&(b.state&&c.removeClass("highcharts-series-"+b.state),a&&c.addClass("highcharts-series-"+a))}),b.state=a,!f[a]||!1!==f[a].enabled)&&(a&&(h=f[a].lineWidth||h+(f[a].lineWidthPlus||0)),d&&!d.dashstyle))for(f={"stroke-width":h},d.attr(f);b["zone-graph-"+ +c];)b["zone-graph-"+c].attr(f),c+=1},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,f,h=d.options.chart.ignoreHiddenSeries,m=c.visible;f=(c.visible=a=c.options.visible=c.userOptions.visible=void 0===a?!m:a)?"show":"hide";p(["group","dataLabelsGroup","markerGroup","tracker","tt"],function(a){if(c[a])c[a][f]()});if(d.hoverSeries===c||(d.hoverPoint&&d.hoverPoint.series)===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&p(d.series,function(a){a.options.stacking&& +a.visible&&(a.isDirty=!0)});p(c.linkedSeries,function(b){b.setVisible(a,!1)});h&&(d.isDirtyBox=!0);!1!==b&&d.redraw();l(c,f)},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=void 0===a?!this.selected:a;this.checkbox&&(this.checkbox.checked=a);l(this,a?"select":"unselect")},drawTracker:a.drawTrackerGraph})})(L);(function(a){var D=a.Chart,C=a.each,G=a.inArray,I=a.isObject,h=a.pick,f=a.splat;D.prototype.setResponsive=function(a){var f=this.options.responsive; +f&&f.rules&&C(f.rules,function(f){this.matchResponsiveRule(f,a)},this)};D.prototype.matchResponsiveRule=function(f,v){var l=this.respRules,p=f.condition,d;d=p.callback||function(){return this.chartWidth<=h(p.maxWidth,Number.MAX_VALUE)&&this.chartHeight<=h(p.maxHeight,Number.MAX_VALUE)&&this.chartWidth>=h(p.minWidth,0)&&this.chartHeight>=h(p.minHeight,0)};void 0===f._id&&(f._id=a.uniqueKey());d=d.call(this);!l[f._id]&&d?f.chartOptions&&(l[f._id]=this.currentOptions(f.chartOptions),this.update(f.chartOptions, +v)):l[f._id]&&!d&&(this.update(l[f._id],v),delete l[f._id])};D.prototype.currentOptions=function(a){function h(a,d,c){var l,p;for(l in a)if(-15', - onClick: function () { - $("#room").val("") - $(".create-actions01").empty().text(">5") - } - }) - - var buttons2 = [ - { - text: '�消', - bg: 'gray' - } - ]; - var groups = [buttons1, buttons2]; - $.actions(groups); -}); +// +// // 选择�作-房型-室 +// $(document).on('click', '.create-actions01', function () { +// var buttons1 = [ +// { +// text: '请选择室', +// label: true +// } +// ]; +// for (var i = 1; i < 6; i++) { +// buttons1.push({ +// text: i + '', +// onClick: function () { +// $("#room").val(this.text) +// $(".create-actions01").empty().text(this.text).addClass("selected") +// } +// }) +// } +// buttons1.push({ +// text: '>5', +// onClick: function () { +// $("#room").val("") +// $(".create-actions01").empty().text(">5") +// } +// }) +// +// var buttons2 = [ +// { +// text: '�消', +// bg: 'gray' +// } +// ]; +// var groups = [buttons1, buttons2]; +// $.actions(groups); +// }); // 选择�作-房型-� $(document).on('click', '.create-actions02', function () { @@ -144,7 +144,7 @@ $(document).on('click', '.create-actions03', function () { label: true }, { - text: '公寓', + text: '普通�宅', bold: true, onClick: function () { $("a.create-actions03").empty().text(this.text).addClass("selected") diff --git a/projects/fangjia-open/src/main/webapp/static/js/trend-charts.js b/projects/fangjia-open/src/main/webapp/static/js/trend-charts.js index dbd6dc45b..fbbe9a135 100644 --- a/projects/fangjia-open/src/main/webapp/static/js/trend-charts.js +++ b/projects/fangjia-open/src/main/webapp/static/js/trend-charts.js @@ -2,7 +2,7 @@ var chart = new Highcharts.Chart({ credits:{ enabled:true, - text: '房价网', + text: '', href: Constants.cityUrl, position: { align: 'center', @@ -76,7 +76,7 @@ type: 'spline' }, title: { - text: '房价网', + text: '', floating: false, align: 'center', x : 0, @@ -128,7 +128,7 @@ }, credits:{ enabled:true, - text: '房价网', + text: '', href: Constants.cityUrl, position: { align: 'center', diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl new file mode 100644 index 000000000..cec747b40 --- /dev/null +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -0,0 +1,167 @@ +<#ftl attributes={"content_type":"text/html; charset=UTF-8"}> +<#compress> + + + + + + +用户登录 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/bhreport.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/bhreport.ftl index a64bb2f90..2a1515696 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/bhreport.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/bhreport.ftl @@ -460,7 +460,7 @@ <#include '/layout/footer.ftl'/> - + diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index 1f48d1dc5..8a35807f4 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -14,16 +14,25 @@ - + +〈 +
    -
    +
    @@ -83,9 +92,9 @@
    -
    建筑类型:
    +
    房屋类型:
    -

    请选择建筑类型

    +

    请选择房屋类型

    @@ -100,7 +109,7 @@ placeholder="请输入所在楼层" min="1" max="200"> + placeholder="请输入楼层�述">
    @@ -211,13 +220,33 @@
  • +<#--
  • --> +<#--
    --> +<#--
    --> +<#--
    --> +<#--
    车�情况:
    --> +<#-- --> +<#--

    请选择车�情况

    --> +<#--
    --> +<#--
    --> +<#--
    --> +<#--
  • -->
  • -
    -
    车�情况:
    - -

    请选择车�情况

    +
    车��积:
    +
    + +
    +
    +
    +
  • +
  • +
    +
    +
    车�价:
    +
    +
    @@ -407,6 +436,13 @@ } }) }) + + if (typeof WeixinJSBridge !== "undefined") { + WeixinJSBridge.on('menu:back', function () { + window.history.back(); // 返回上一页 + }); + } + diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl index 93cc7a993..cf6070a5c 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl @@ -13,11 +13,22 @@ - + - + +〈 + -
    +
    diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl index fd5351b5d..821f5f2a7 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl @@ -16,11 +16,20 @@ - + +〈 +
    @@ -180,7 +189,7 @@ <#if evaluation?? && (fjtEvaluation.buildType)! == 3> �宅 <#elseif fjtEvaluation.buildType! == 8> - 公寓 + 普通�宅 <#elseif fjtEvaluation.buildType! == 4> 独立别墅 <#elseif fjtEvaluation.buildType! == 5> @@ -209,21 +218,22 @@ -

    -

    -

    - <#if role?? && role==16> -

    - - - <#if fjtEvaluation.onlyOne! == 1> - 是 - <#elseif fjtEvaluation.onlyOne! == 2> - � - <#else> - - - - -

    - +

    <#if fjtEvaluation.carSitePrice??>${fjtEvaluation.carSitePrice!}万元<#else>-

    + <#--

    -

    --> +<#-- <#if role?? && role==16>--> +<#--

    --> +<#-- --> +<#-- --> +<#-- <#if fjtEvaluation.onlyOne! == 1>--> +<#-- 是--> +<#-- <#elseif fjtEvaluation.onlyOne! == 2>--> +<#-- �--> +<#-- <#else>--> +<#-- - --> +<#-- --> +<#-- --> +<#--

    --> +<#-- -->

    @@ -273,10 +283,7 @@

    <#if fjtEvaluation.gardenArea??>${fjtEvaluation.gardenArea!?string('0.##')}平米<#else>-

    <#if fjtEvaluation.outerArea??>${fjtEvaluation.outerArea!?string('0.##')}平米<#else>-

    -

    <#if fjtEvaluation.carSiteArea??>${fjtEvaluation.carSiteArea!?string('0.##')}平米<#else>-

    - <#if fjtEvaluation.city! == "上海"> -

    ${fjtEvaluation.loopLine!}

    - +

    <#if fjtEvaluation.carSiteArea??>${fjtEvaluation.carSiteArea!?string('0.##')}平米<#else>-

    @@ -326,20 +333,23 @@

    <#if fjtEvaluation.basementArea??&&(fjtEvaluation.basementArea!>0)>${fjtEvaluation.basementArea!?string('0.##')}平米<#else>-

    <#if fjtEvaluation.basementArea??&&(fjtEvaluation.atticArea!>0)>${fjtEvaluation.atticArea!?string('0.##')}平米<#else>-

    -

    - - - <#if fjtEvaluation.carport! == 1> - 已租 - <#elseif fjtEvaluation.carport! == 3> - 已购 - <#elseif fjtEvaluation.carport! == 2> - 暂无 - <#else> - - - - -

    + <#if fjtEvaluation.city! == "上海"> +

    ${fjtEvaluation.loopLine!}

    + + <#--

    --> +<#-- --> +<#-- --> +<#-- <#if fjtEvaluation.carport! == 1>--> +<#-- 已租--> +<#-- <#elseif fjtEvaluation.carport! == 3>--> +<#-- 已购--> +<#-- <#elseif fjtEvaluation.carport! == 2>--> +<#-- 暂无--> +<#-- <#else>--> +<#-- ---> +<#-- --> +<#-- --> +<#--

    -->
    全部信�
    @@ -381,7 +391,7 @@ <#include '/layout/footer.ftl'/> - + + diff --git a/projects/fangjia-script/pom.xml b/projects/fangjia-script/pom.xml index e639f76e3..ee869ba86 100644 --- a/projects/fangjia-script/pom.xml +++ b/projects/fangjia-script/pom.xml @@ -537,6 +537,24 @@ 1.70 + + org.locationtech.jts + jts-core + 1.18.2 + + + + org.apache.commons + commons-text + 1.9 + + + + com.hankcs.hanlp.restful + hanlp-restful + 0.0.12 + + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy index 5a3ce647a..39edb1dfe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/BaseBatch.groovy @@ -1,6 +1,6 @@ package com.fangjia.script - +import com.fangjia.core.util.HttpRequest import com.fangjia.script.util.* import com.fangjia.script.yinjihaun.util.DingDingMessageUtil import com.mongodb.BasicDBObject @@ -112,6 +112,18 @@ abstract class BaseBatch { } if(SystemUtils.IS_OS_LINUX){ sendDingDingMsg("2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c",msg) + + try { + Map params = new HashMap(); + params.put("phone", "13764369683"); + params.put("type", "taskFail"); + params.put("msg", batchName.substring(batchName.length() - 20, batchName.length())); + HttpRequest httpRequest = new HttpRequest(); + httpRequest.get("http://didata-cloud-server.fangjia.com/sms/send", params, "utf-8"); + } catch (Exception ex) { + + } + task.exception = msg.toString() } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy index 1f2b994d6..bf662b6ea 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/ClickHouseDistrictStatMarkupCalcBatch.groovy @@ -21,7 +21,7 @@ import java.sql.DriverManager @BatchOwner(Watcher.WangWenYan) class ClickHouseDistrictStatMarkupCalcBatch extends BaseBatch { - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo", 27017) static void main(String[] args) { runBatch(new ClickHouseDistrictStatMarkupCalcBatch(), args) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy index fdc1746c9..25296b2a6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DatabaseStatWatcherBatch.groovy @@ -35,7 +35,7 @@ class DatabaseStatWatcherBatch extends BaseBatch { def yesterday = DateUtil.add(today, -1) for(def host : hosts){ - Mongo mongo = new Mongo(new MongoURI("mongodb://${host}")) + Mongo mongo = new Mongo(new MongoURI("mongodb://developer:G00IDCDEV12385@${host}:28017")) for(def databaseName : mongo.getDatabaseNames()){ if(NOT_WATCH_DBS.contains(databaseName)){ continue diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy index 099982429..32afa22f9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ana/DistrictStatMarkupCalcBatch.groovy @@ -18,7 +18,7 @@ import com.mongodb.DBCollection @BatchOwner(Watcher.WangWenYan) class DistrictStatMarkupCalcBatch extends BaseBatch { - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 27017) Date oneYearAgo = DateUtil.add(new Date(), Calendar.MONTH, -1) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy index 0bf6ec4b9..d96e0da05 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy @@ -1,16 +1,17 @@ package com.fangjia.script.ccbevaluation -import com.fangjia.script.util.DateUtils + import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection - /** * ÉîÛÚ¹«Öںųɽ»Êý¾Ý¼Èë */ -def datas = ExcelUtils.read("D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\³É½»\\2024Äê9ÔÂÉîÛÚ¶þÊÖ·¿³É½».xlsx", 0, 1) -def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + +def datas = ExcelUtils.read("D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\³É½»\\2025Äê01ÔÂÉîÛÚ¶þÊÖ·¿³É½»µÄ.xlsx", 0, 1) + +def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) //ûÓгɽ»Ê±¼ä£¬Ëæ»úÉú³É diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy index d3df8510d..195dc1183 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddThirdPriceSample.groovy @@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicLong */ class AddThirdPriceSample { - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static final DBCollection NO_PRICE_DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia_crawl", "deal_price_all", "mongo.db.fangjia.com") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy index c65f09175..77f92137f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy @@ -43,7 +43,7 @@ class BigdataDealBatch extends BaseBatch{ DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") @@ -71,8 +71,7 @@ class BigdataDealBatch extends BaseBatch{ for(def city : allCitys){ addDealPriceMatch(city); } - updateCrawlTradeDate()//Ð޸ĺóץȡµÄ³É½»£¬½«Ê±¼ä¸ÄΪ±¾Ô - +// updateCrawlTradeDate()//Ð޸ĺóץȡµÄ³É½»£¬½«Ê±¼ä¸ÄΪ±¾Ô def rows = [] def headers = []//["³ÇÊÐID","³É½»ID","³ÇÊÐÃû³Æ","ÐÐÕþÇøID","ÐÐÕþÇøÃû³Æ","½ÖµÀ","ÃÅÅÆºÅ","Ð¡ÇøID","Ð¡ÇøÃû³Æ","Â¥¶°ID","Â¥¶°±àºÅ","Â¥¶°Ãû³Æ","µ¥ÔªID","µ¥Ôª±àºÅ","µ¥ÔªÃû³Æ","»§ID","ÏêϸµØÖ·","½¨ÖþÄê´ú","ȨÊô","ȨÊôÄêÏÞ","ÆÚÊý","ËùÔÚÂ¥²ã","²ãÀàÐÍ","×ÜÂ¥²ãÊý","½¨ÖþÀàÐÍ","½¨Öþ½á¹¹","½¨ÖþÃæ»ý","Ì×ÄÚÃæ»ý","»§ÐÍ","ÊÒ","Ìü","³ø","ÎÀ","·¿ÎÝÓÃ;","ÊÒÄڽṹ","³¯Ïò","×°ÐÞÇé¿ö","ÆÀ¹À±àºÅ","³É½»µ¥¼Û","³É½»×ܼÛ","É걨×ܼÛ","ÆÀ¹À×ܼÛ","ÍøÇ©ºÏͬ±àºÅ","½»Ò×ÈÕÆÚ","½»Ò×ÀàÐÍ","³öÊÛ¸¶¿î·½Ê½","³É½»ÖÜÆÚ","ÊÇ·ñÓеçÌÝ","ÔùËÍÃæ»ý£¨µØÃ滨԰£©","ÔùËÍÃæ»ý£¨Â¶Ì¨£©","ÔùËÍÃæ»ý£¨Ñǫ̂£©","ÔùËÍÃæ»ý£¨Æ®´°£©","ÔùËÍÃæ»ý£¨¸óÂ¥£©","ÔùËÍÃæ»ý£¨³µ¿â£©","ÔùËÍÃæ»ý£¨µØÏÂÊÒ£©","ÔùËÍÃæ»ý£¨ÆäËû£©","·¿Ô´Êý¾ÝÀ´Ô´","Öн鹫˾ID","Öн鹫˾Ãû³Æ","±¸×¢","´´½¨Ê±¼ä","¸üÐÂʱ¼ä","À´Ô´¹«Ë¾","³É½»½ð¶î","Êý¾Ýʱ¼ä"] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy index 624690a6e..d1696dd94 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/CcbCommonUtils.groovy @@ -61,25 +61,25 @@ class CcbCommonUtils { def countStr = args[0] if(countStr=="344"){ citys = CcbCommonUtils.citys_all - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") }else if(countStr=="92"){ citys = CcbCommonUtils.citys_92 - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") }else if(countStr=="252"){ citys = CcbCommonUtils.citys_252 - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") }else if(countStr=="all"){ citys = CcbCommonUtils.citys_fjw_all - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") } }else{ citys = CcbCommonUtils.citys_all - sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +// sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") } println "ÔËÐгÇÊÐÊýÁ¿£º"+citys.size() return citys; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy index eaef4e568..a7681d9f0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DistrictDelete.groovy @@ -45,7 +45,7 @@ class DistrictDelete { def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new DistrictDelete() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy index 3ccdc43ef..ce47aa8db 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/Test.groovy @@ -1353,13 +1353,14 @@ def findAvgPrice(def commid, def pgsqlInstance, def cityid){ //},0) -def fileName = "D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\Ö¸µ¼¼Û\\20241025È˹¤Ö¸µ¼¼Û.xlsx" +def fileName = "D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\Ö¸µ¼¼Û\\¸üÐÂÈ˹¤Ö¸µ¼¼Û_0314.xlsx" ExcelUtils.multiThreadingModify(fileName, { d -> - def dist = CommonDatautils.findDistrictById(d['J']) + def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ - d['A'] = dist.city - d['B'] = dist.region - d['C'] = dist.name + d['C'] = dist.city + d['D'] = dist.region + d['E'] = dist.name + d['F'] = dist.status } }) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy index 98612d573..b17f2aae6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy @@ -27,11 +27,14 @@ class ThirdPartyPriceBatch extends BaseBatch { def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 // def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -6, "yyyyMM")); - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - def sourceMap = ["Öî¸ðÕÒ·¿":"01", "°²¾Ó¿Í":"02","·¿ÌìÏÂ":"03","Á´¼Ò":"04","³ÇÊмҾÓ":"05","ÂóÌï":"06","±´¿Ç":"07","ÌÔ·¿365":"08","ÖÐÔ­":"09","Íò©Ê¿":"10","Q·¿":"11","·¿Ì½":"12", - "·¿¶à¶à":"13","ÎÒ°®ÎÒ¼Ò":"14","ìûÌ©Êý¾Ý":"15","¼ªÎÝÍø":"16","ÀÖ¾Ó":"17","21ÊÀ¼Í":"18","·¿²ú³¬ÊÐ":"19","58ͬ³Ç":"20"] + def sourceMap = ["Öî¸ðÕÒ·¿":"01", "°²¾Ó¿Í":"02","·¿ÌìÏÂ":"03","Á´¼Ò":"04","³ÇÊмҾÓ":"05","ÂóÌï":"06","±´¿Ç":"07", + "ÌÔ·¿365":"08","ÖÐÔ­":"09","Íò©Ê¿":"10","Q·¿":"11","·¿Ì½":"12","·¿¶à¶à":"13","ÎÒ°®ÎÒ¼Ò":"14", + "ìûÌ©Êý¾Ý":"15","¼ªÎÝÍø":"16","ÀÖ¾Ó":"17","21ÊÀ¼Í":"18","·¿²ú³¬ÊÐ":"19","58ͬ³Ç":"20", + "ÀÖÓмÒ":"21","ÐÒ¸£Àï":"22","Öйú·¿¼ÛÐÐÇé":"23","³£ÖÝס·¿":"24" + ] def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") @@ -263,6 +266,30 @@ class ThirdPartyPriceBatch extends BaseBatch { if(third.get("csjj_esf_price")){ price_map.csjj_avg_price = third.get("csjj_esf_price") } + + if(third.get("leyoujia_esf_price")){ + price_map.leyoujia_avg_price = third.get("leyoujia_esf_price") + } + + if(third.get("c21_esf_price")){ + price_map.c21_avg_price = third.get("c21_esf_price") + } + + if(third.get("jiwu_esf_price")){ + price_map.jiwu_avg_price = third.get("jiwu_esf_price") + } + + if(third.get("xingfuli_esf_price")){ + price_map.xingfuli_avg_price = third.get("xingfuli_esf_price") + } + + if(third.get("zwfc_esf_price")){ + price_map.zwfc_avg_price = third.get("zwfc_esf_price") + } + + if(third.get("creprice_esf_price")){ + price_map.creprice_avg_price = third.get("creprice_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -313,6 +340,18 @@ class ThirdPartyPriceBatch extends BaseBatch { web = "·¿²ú³¬ÊÐ" }else if(k=="csjj_avg_price"){ web = "³ÇÊоӼÒ" + }else if(k=="leyoujia_avg_price"){ + web = "ÀÖÓмÒ" + }else if(k=="c21_avg_price"){ + web = "C21" + }else if(k=="jiwu_avg_price"){ + web = "¼ªÎÝÍø" + }else if(k=="xingfuli_avg_price"){ + web = "ÐÒ¸£Àï" + }else if(k=="creprice_avg_price"){ + web = "Öйú·¿¼ÛÐÐÇé" + }else if(k=="zwfc_avg_price"){ + web = "³£ÖÝס·¿" } ret << sourceMap.get(web) @@ -603,6 +642,30 @@ class ThirdPartyPriceBatch extends BaseBatch { if(!dataMap.get("csjj_esf_price") && db.get("csjj_esf_price") && db.get("csjj_esf_price")>3000){ dataMap.put("csjj_esf_price", db.get("csjj_esf_price")) } + + if(!dataMap.get("leyoujia_esf_price") && db.get("leyoujia_esf_price") && db.get("leyoujia_esf_price")>3000){ + dataMap.put("leyoujia_esf_price", db.get("leyoujia_esf_price")) + } + + if(!dataMap.get("c21_esf_price") && db.get("c21_esf_price") && db.get("c21_esf_price")>3000){ + dataMap.put("c21_esf_price", db.get("c21_esf_price")) + } + + if(!dataMap.get("jiwu_esf_price") && db.get("jiwu_esf_price") && db.get("jiwu_esf_price")>3000){ + dataMap.put("jiwu_esf_price", db.get("jiwu_esf_price")) + } + + if(!dataMap.get("xingfuli_esf_price") && db.get("xingfuli_esf_price") && db.get("xingfuli_esf_price")>3000){ + dataMap.put("xingfuli_esf_price", db.get("xingfuli_esf_price")) + } + + if(!dataMap.get("creprice_esf_price") && db.get("creprice_esf_price") && db.get("creprice_esf_price")>3000){ + dataMap.put("creprice_esf_price", db.get("creprice_esf_price")) + } + + if(!dataMap.get("zwfc_esf_price") && db.get("zwfc_esf_price") && db.get("zwfc_esf_price")>3000){ + dataMap.put("zwfc_esf_price", db.get("zwfc_esf_price")) + } // if(db.zhugezhaofang_esf_price || db.anjuke_esf_price ||db.soufang_esf_price || db.lianjia_esf_price || db.cityhouse_esf_price || db.maitian_esf_price || db.beike_esf_price || db.get("365house_esf_price") || db.zhongyuan_esf_price || db.tuboshi_esf_price || db.qfang_esf_price || db.fangtan_esf_price || db.fangduoduo_esf_price || db.get("5i5j_esf_price")){ // map.put(key, db) // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy index c2caf475f..73c6676eb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/TradeStatLog.groovy @@ -36,7 +36,7 @@ class TradeStatLog { def pssqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse?stringtype=unspecified", "postgres", "postgres", "org.postgresql.Driver") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy index be649cf9d..f23121d0c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/ExcelDataTest.groovy @@ -18,10 +18,10 @@ import com.mongodb.QueryOperators import groovy.sql.Sql -DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") -DBCollection CITY_STAT = MongoUtils.getCollectionByName("fangjia_stat", "city_stat", "192.168.0.43") -DBCollection CITY_INFO = MongoUtils.getCollectionByName("fangjia_data_ana", "city_info", "192.168.0.43") -DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") +DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") +DBCollection CITY_STAT = MongoUtils.getCollectionByName("fangjia_stat", "city_stat", "mongo.db.fangjia.com") +DBCollection CITY_INFO = MongoUtils.getCollectionByName("fangjia_data_ana", "city_info", "mongo.db.fangjia.com") +DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy index 167fda35a..903a4b107 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/MatchDealPriceRegion.groovy @@ -12,7 +12,7 @@ class MatchDealPriceRegion { static DBCollection collection = MongoUtils.getCollectionByName("fangjia_craw", "third_party_price", "192.168.0.235", 27018) - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy index e45fc62c6..06213a708 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/BlankEvaluationBatch.groovy @@ -21,7 +21,7 @@ import org.apache.lucene.queryparser.classic.QueryParser */ class EvaluationBatch { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy index 66f7dd391..7f992095b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/FumingTest.groovy @@ -18,7 +18,7 @@ class FumingTest { def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -3, "yyyyMM")) //202302 def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse", "postgres", "postgres", "org.postgresql.Driver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy index 25560ff03..55cf2b8dd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/HailanTest.groovy @@ -38,7 +38,7 @@ class HailanTest { } static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(80) - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy index 42aedde30..3d8bc3152 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/PocStat.groovy @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicLong class PocStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection HOUSE_LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", lineUrl) public static final DBCollection LOUDONG_LINE_COLL = MongoUtils.getCollectionByName2("fangjia_base", "loudong", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy index 2d862b119..c067c7694 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/RuiFenPocTest.groovy @@ -15,7 +15,7 @@ class RuiFenPocTest { def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -3, "yyyyMM")) //202302 def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse", "postgres", "postgres", "org.postgresql.Driver") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index 9db36e3d8..17a82f2fc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -7,6 +7,7 @@ import com.fangjia.datastore.driver.DSCursor import com.fangjia.datastore.driver.DataStore import com.fangjia.httpclient.UserAgents import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.newDistrict.InvokeHttpRequest import com.fangjia.script.util.* @@ -98,11 +99,13 @@ class CommonDatautils { } public static final DBCollection COMMUNITY_CONN = MongoUtils.getCollectionByName2("fangjia", "community", "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009") - public static final DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + public static final DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com", 28017) public static final DBCollection OPERATION_LOG_COLL = MongoUtils.getCollectionByName("fangjia", "operation_log", "mongo.db.fangjia.com") public static final DBCollection STATS_INDEX_COLL = MongoUtils.getCollectionByName("fangjia_stat", "stats_index", "mongo.db.fangjia.com") + public static final DBCollection bk_business_coll = MongoUtils.getCollectionByName("fangjia_base", "bk_business", "mongo.db.fangjia.com") + public static DSCollection getHouseDataStoreConnection(){ if(house_dataStoreConnection != null) { return house_dataStoreConnection @@ -259,7 +262,7 @@ class CommonDatautils { q.put("status", 0); q.put("cat", cat); q.put("city", city); -// q.put("name","ÍÐ˹¿¨ÄÉׯ԰") +// q.put("name","ÐÂãþÈý´å") DBObject keys = new BasicDBObject(); if(fields){ @@ -597,9 +600,9 @@ class CommonDatautils { keys.put("region", 1); keys.put("name", 1); keys.put("_id", 1); - DSCursor cursor = getDataStoreConnection().find(q, keys).batchSize(2000); + DSCursor cursor = DbUtils.seaweed.find(q, keys).batchSize(2000); Iterator iters = cursor.iterator() - def result = []; + def result = new HashSet(); try{ while(iters.hasNext()) { DBObject obj = iters.next() @@ -755,7 +758,10 @@ class CommonDatautils { DBObject q = new BasicDBObject(); q.put("city", city); - q.put("region", region); + if(region){ + q.put("region", region); + } + q.put("name", name); q.put("cat", cat) q.put("status", 0) @@ -786,7 +792,8 @@ class CommonDatautils { keys.put(field, 1); } } - def dbsour = DbUtils.seaweed.find(q, keys).batchSize(2000) + + def dbsour = SEAWEED_COLL.find(q, keys).batchSize(2000) // def dbsour = getDataStoreConnection().find(q, keys).batchSize(2000) def rets = [] for(def d : dbsour){ @@ -814,7 +821,9 @@ class CommonDatautils { def dbsour = SEAWEED_COLL.find(q, keys).batchSize(5000) def rets = [] for(def d : dbsour){ - rets << d + if(!d.township){ + rets << d + } } return rets; } @@ -1131,6 +1140,26 @@ class CommonDatautils { return ret; } + public static def findNormalDistrict(String city, String region, String name, String cat, List fields){ + + DBObject q = new BasicDBObject(); + q.put("city", city); + q.put("cat", cat); + q.put("name", name); + if(region){ + q.put("region", region); + } + q.put("status",0) + + DBObject keys = new BasicDBObject(); + if(fields){ + for(def field : fields){ + keys.put(field, 1); + } + } + return SEAWEED_COLL.findOne(q, keys); + } + public static def findDistrictsByCityAndName(String city, String name, String cat){ DBObject q = new BasicDBObject(); q.put("city", city); @@ -4209,19 +4238,21 @@ class CommonDatautils { static def findAllNewPoiDatas(city){ - String sql = "select pname,cityname,adname,name,address,location,type,id from poi_amap_2024 where cityname='${city}'" + String sql = "select cityname,adname,name,address,location,type,id,parent from amap_poi_2024 where cityname='${city}'" def rets = [] def index= 0 ElasticUtils.executeSqlQuery(sql, { map-> // if(map.address && map.address.contains("Îå½Ç³¡")){ index++ - rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y] + rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y, "parent_id":map.parent] // } }) return rets; } + + static def findOneThirdNetWorkOffice(city, region, name){ String sql = "select location from office where city='${city}' and region='${region}' and name='${name}'" def map = [:] @@ -4234,6 +4265,16 @@ class CommonDatautils { return map } + static def findThirdNetWorkOffices(city, region, name){ + String sql = "select * from office where city='${city}' and region='${region}' and name='${name}'" + def datas = [] + + ElasticUtils.executeSqlQuery(sql, { m-> + datas << m + }) + return datas + } + static def findThirdNetWorkOffice(){ String sql = "select city,region,name,address,location from office where city='ÑĮ̀' or city='±±¾©'" @@ -4678,6 +4719,14 @@ class CommonDatautils { } + + static def httpSaveData89(def newUrl,def params){ + def header = [:] + header.put("Authorization","Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString()) + doPost(newUrl,header, params, true, "utf-8") + } + + static def doPost(def targetUrl, def headers, def params, def isJson, def charset){ StringBuilder buffer = new StringBuilder(); try{ @@ -4965,6 +5014,20 @@ class CommonDatautils { return regionMap } + static def queryRangeByCat(cat){ + def q = new BasicDBObject() + q.put("type",cat) + q.put("shape",new BasicDBObject('$exists', true)) + def keys = new BasicDBObject() + keys.put("city_short",1) + keys.put("district_short",1) + keys.put("city",1) + keys.put("district",1) + keys.put("mzb_district_name", 1) + keys.put("shape", 1) + return ADMINISTRATIVE_MAPPING_COLL.find(q,keys).toList() + } + static def queryAllRegionNameByCity(){ @@ -5135,21 +5198,66 @@ class CommonDatautils { def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) def townMap = [:] for(def d : dbcursor){ + def distName = null if(d.mzb_district_name){ - def list = townMap.get(d.mzb_district_name) + distName = d.mzb_district_name + }else{ + distName = d.district + } + if(distName){ + def list = townMap.get(distName) if(!list){ list = [] } list << d - townMap.put(d.mzb_district_name, list) + townMap.put(distName, list) } } - - println "[${city}] ÏçÕò½ÖµÀ ¼ÓÔØÍê³É "+new Date().format("yyyy-MM-dd HH:mm:ss") +// println "[${city}] ÏçÕò½ÖµÀ ¼ÓÔØÍê³É "+new Date().format("yyyy-MM-dd HH:mm:ss") return townMap } + + static def queryAllTown(fields){ + + def q = new BasicDBObject() + q.put("type","ÏçÕò½ÖµÀ") + + def keys = new BasicDBObject() + for(def key : fields){ + keys.put(key,1) + } + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) + def cityMap = [:] + for(def d : dbcursor){ + def townMap = cityMap.get(d.city) + if(!townMap){ + townMap = [:] + cityMap.put(d.city, townMap) + } + + def distName = null + if(d.mzb_district_name){ + distName = d.mzb_district_name + }else{ + distName = d.district + } + if(distName){ + def list = townMap.get(distName) + if(!list){ + list = [] + } + list << d + townMap.put(distName, list) + } + } +// println "[${city}] ÏçÕò½ÖµÀ ¼ÓÔØÍê³É "+new Date().format("yyyy-MM-dd HH:mm:ss") + return cityMap + } + + + static def queryFullRegionTownByCity(city, fields){ def q = new BasicDBObject() @@ -5515,4 +5623,25 @@ class CommonDatautils { return 0 } + static def findBusinessByCity(city){ + def q = new BasicDBObject() + q.put("short_city", city) + return bk_business_coll.find(q).toList() + } + + + static def findOfficeByMap(city, small_type){ + + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("small_type", small_type)) + def rets = [] + def index= 0 + ElasticUtils89.executeQuery("192.168.0.89", "gaode_map_poi_2024", queryBuilder, { String id, Map map-> +// if(map.address && map.address.contains("Îå½Ç³¡")){ + + index++ + rets << ["map_id":map.data_id,"province":map.province,"city":map.city, "district":map.district, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.lon, "lat":map.location.lat, "parent_id":map.parent] +// } + }) + return rets; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy index 86ebec035..34d890e67 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/FewerHouseDistrictCrawlCommandBatch.groovy @@ -23,7 +23,7 @@ import org.apache.commons.lang.StringUtils class FewerHouseDistrictCrawlCommandBatch extends BaseBatch { private static final DBCollection ARTEMIS_COLL = MongoUtils.getCollectionByName("fangjia_log", "artemis_message", "mongo.db.fangjia.com") - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") static void main(String[] args) { runBatch(new FewerHouseDistrictCrawlCommandBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy index 68c1dc184..d569dba6d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/crawl/Test_weilei.groovy @@ -15,7 +15,7 @@ import org.bson.types.ObjectId //new FewerHouseDistrictCrawlCommandBatch().process(null); //return; // -//DBCollection col_43_artemis_message = MongoUtils.getCollectionByName("fangjia_log", "artemis_message", "192.168.0.43", 27017); +//DBCollection col_43_artemis_message = MongoUtils.getCollectionByName("fangjia_log", "artemis_message", "mongo.db.fangjia.com", 27017); //DBCursor cursor_artemis_message = col_43_artemis_message.find(new BasicDBObject("status", 0)); //int count = 0; //while(cursor_artemis_message.hasNext()){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy index d008b0f48..004acafbe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy @@ -1,8 +1,18 @@ package com.fangjia.script.dataAna -import com.fangjia.script.ccbevaluation.CcbCommonUtils -import com.fangjia.script.commData.CommonDatautils +import com.fangjia.core.util.DateUtil +import com.fangjia.datastore.driver.DSCursor +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.Jms import com.fangjia.script.util.MongoUtils +import com.google.common.collect.Lists +import com.google.common.collect.Sets +import com.mongodb.* +import org.apache.commons.codec.digest.DigestUtils import java.text.DecimalFormat import java.util.concurrent.CountDownLatch @@ -10,30 +20,6 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.Semaphore -import org.apache.commons.codec.digest.DigestUtils -import org.bson.types.ObjectId - -import com.fangjia.core.util.DataUtil -import com.fangjia.core.util.DateUtil -import com.fangjia.datastore.driver.DSCollection -import com.fangjia.datastore.driver.DSCursor -import com.fangjia.datastore.driver.FacetResult -import com.fangjia.script.BaseBatch -import com.fangjia.script.BatchOwner -import com.fangjia.script.Watcher -import com.fangjia.script.util.DbUtils -import com.fangjia.script.util.ExcelUtils -import com.fangjia.script.util.Jms -import com.google.common.collect.Lists -import com.google.common.collect.Sets -import com.mongodb.BasicDBList -import com.mongodb.BasicDBObject -import com.mongodb.Bytes -import com.mongodb.DBCollection -import com.mongodb.DBCursor -import com.mongodb.DBObject -import com.mongodb.Mongo - @BatchOwner(Watcher.LiXue) class CityInfoAnaBatch extends BaseBatch { @@ -53,8 +39,10 @@ class CityInfoAnaBatch extends BaseBatch { final static DBCollection LOUDONG_CONN = MongoUtils.getCollectionByName("fangjia_base", "loudong", MongoUtils.MongoDB_Domain_mongo); final static DBCollection fsDB = MongoUtils.getCollectionByName("fangjia_fs", "files", MongoUtils.MongoDB_Domain_fs_mongo, 27000); final static DBCollection FACILITY_CONN = MongoUtils.getCollectionByName("fangjia", "district_facilitys", MongoUtils.MongoDB_Domain_mongo) + final static DBCollection OFFICE_RENT_STAT_CONN = MongoUtils.getCollectionByName("fangjia_stat", "office_rent_stat", MongoUtils.MongoDB_Domain_mongo); static Jms jms = Jms.create('tcp://jms.db.fangjia.com:61616') - final static DSCollection SEAWEED = DbUtils.seaweed +// final static DSCollection SEAWEED = DbUtils.seaweed + static final DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com") public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) final static def CITYS = []; @@ -125,7 +113,7 @@ class CityInfoAnaBatch extends BaseBatch { SERVER_AREA_CONN.find(cityQuery).each { allCitys.put(it.display, it); } allCitys.each {k,v -> -// if(["ÄϾ©"].contains(k.toString())){ +// if(["±±¾©"].contains(k.toString())){ CITYS << k.toString(); // } } @@ -140,72 +128,47 @@ class CityInfoAnaBatch extends BaseBatch { // ³ÇÊÐÐ¡ÇøÊý def allCityDisCount = [:]; - LinkedHashMap facet = new LinkedHashMap(2); - facet.put("fields", ["city"]); - facet.put('limit', 500); - - DBObject disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'district'); - - DSCursor sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - List disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityDisCount.put(it.name, it.count.intValue()); - } + BasicDBObject match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "district")); + DBObject groupFields = new BasicDBObject(); + groupFields.put("_id", new BasicDBObject("city", '$city')) + groupFields.put("count", new BasicDBObject('$sum', 1)); + DBObject group = new BasicDBObject('$group', groupFields); + // ¶¨Òå¾ÛºÏ¹ÜµÀ£¬°´ city ×ֶηÖ×飬²¢¼ÆËãÿ¸ö³ÇÊеÄÊýÁ¿ + AggregationOutput output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityDisCount.put(obj.get("city"), result.get("count")) } // ³ÇÊÐÐÂÅÌÊý def allCityNewDisCount = [:]; - disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'new_district'); - - sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityNewDisCount.put(it.name, it.count.intValue()); - } + match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "new_district")); + output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityNewDisCount.put(obj.get("city"), result.get("count")) } // ³ÇÊÐд×ÖÂ¥Êý def allCityOfficeCount = [:]; - disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'office'); + match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "office")); - sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityOfficeCount.put(it.name, it.count.intValue()); - } + output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityOfficeCount.put(obj.get("city"), result.get("count")) } - // ³ÇÊÐÉÌÆÌÊý def allCityShopCount = [:]; - disQuery = new BasicDBObject(); - disQuery.put('$facet', facet); - disQuery.put("visible", 0); - disQuery.put("cat", 'shop'); + match = new BasicDBObject('$match', new BasicDBObject("status", 0).append("cat", "shop")); - sellDSCursor = SEAWEED.find(disQuery).skip(0).limit(0); - disFacetResult = sellDSCursor.getFacetResults(); - if (disFacetResult) { - def obj = disFacetResult[0].values; - obj.each { - allCityShopCount.put(it.name, it.count.intValue()); - } + output = SEAWEED.aggregate(Arrays.asList(match, group)); + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + allCityShopCount.put(obj.get("city"), result.get("count")) } + // ³ÇÊоù¼Û def allCityStats = [:]; query = new BasicDBObject(); @@ -220,10 +183,10 @@ class CityInfoAnaBatch extends BaseBatch { doProcess(allCitys.get(it), weekend, laseWeekend, allHouseStats, allCityDisCount, allCityNewDisCount, allCityOfficeCount, allCityShopCount, allCityStats); } - //ͳ¼ÆÓÐÂ¥¶°µÄÐ¡ÇøÊýºÍÓз¿ºÅµÄÐ¡ÇøÊý -// countDistrictsHasLoudong(allCitys, weekend) - //countDistrictsHasLoudongNew(allCitys, weekend) - +// //ͳ¼ÆÓÐÂ¥¶°µÄÐ¡ÇøÊýºÍÓз¿ºÅµÄÐ¡ÇøÊý +//// countDistrictsHasLoudong(allCitys, weekend) +// //countDistrictsHasLoudongNew(allCitys, weekend) +// final CountDownLatch latch = new CountDownLatch(CITYS.size()) final Semaphore semaphore = new Semaphore(10) CITYS.each { @@ -239,13 +202,13 @@ class CityInfoAnaBatch extends BaseBatch { } finally { semaphore.release() latch.countDown() - } + } }; }) } latch.await() println "${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())}\tÂ¥¶°¸²¸ÇÂÊͳ¼ÆÍê³É" - + latch = new CountDownLatch(CITYS.size()) semaphore = new Semaphore(10) CITYS.each { @@ -267,12 +230,12 @@ class CityInfoAnaBatch extends BaseBatch { } latch.await() println "${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())}\t·¿ºÅ¸²¸ÇÂÊͳ¼ÆÍê³É" - - + + //71¸ö³ÇÊеĸ²¸ÇÂÊͳ¼Æ sendCountData(weekend) - - + + //×îºóͳ¼ÆÖ®Ç°ÒòΪ̫ÂýÈ¡Ïûͳ¼ÆµÄ±¾ÖܹÀ¼Û´ÎÊý latch = new CountDownLatch(CITYS.size()) semaphore = new Semaphore(10) @@ -292,14 +255,14 @@ class CityInfoAnaBatch extends BaseBatch { query.put('city', cityName); query.put('c_date', new BasicDBObject('$gte', laseWeekend).append('$lte', weekend)); entity.put('evaluation_count', (int) EVALUATION_CONN.count(query)); - + if (entity.get('evaluation_count')) { entity.put('price_to_eva', DataUtil.roundDouble(entity.get('price_total_count'), entity.get('evaluation_count'))); } CITY_INFO_CONN.save(entity) println cityName+"±¾ÖܹÀ¼Û´ÎÊýͳ¼ÆÍê±Ï" } - + } catch (Exception e) { println e.getMessage() } finally { @@ -343,21 +306,21 @@ class CityInfoAnaBatch extends BaseBatch { def totalDbhouseloudongCount = HOUSE_LOUDONG_CONN.count(findObj) datas << ['', totalDistrictCount, totalLoudongCount, df.format(totalLoudongCount * 1.0/ totalDistrictCount), totalFanghaoCount, df.format(totalFanghaoCount * 1.0/ totalDistrictCount), totalDbLoudongCount, totalDbhouseloudongCount] - ExcelUtils.write(fileName, datas, resultTitle) - String id = ObjectId.get().toString() - BasicDBObject file = new BasicDBObject() - file.put("t", "upload") - file.put("content_type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") - file.put("c_date", new Date()) - file.put("_id", idGenerator(id, "o")) - file.put("data", new File(fileName).getBytes()) - fsDB.save(file) - def href = DataUtil.encodePicUrl(id, "o", "upload") - href = "µã»÷ÏÂÔØ¸½¼þ" - receivers.each {receiver-> - jms.sendMail(receiver, resultTitle, href) - } - new File(fileName).deleteOnExit() +// ExcelUtils.write(fileName, datas, resultTitle) +// String id = ObjectId.get().toString() +// BasicDBObject file = new BasicDBObject() +// file.put("t", "upload") +// file.put("content_type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") +// file.put("c_date", new Date()) +// file.put("_id", idGenerator(id, "o")) +// file.put("data", new File(fileName).getBytes()) +// fsDB.save(file) +// def href = DataUtil.encodePicUrl(id, "o", "upload") +// href = "µã»÷ÏÂÔØ¸½¼þ" +// receivers.each {receiver-> +// jms.sendMail(receiver, resultTitle, href) +// } +// new File(fileName).deleteOnExit() } private String idGenerator(String url, String size) { @@ -585,8 +548,8 @@ class CityInfoAnaBatch extends BaseBatch { print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} Ð¡ÇøÍê³É]" -// if (allCityNewDisCount.get(cityName)) { -// def newDisCount = allCityNewDisCount.get(cityName); +// if (allCityNewDisCount.get(cityName)) { +// def newDisCount = allCityNewDisCount.get(cityName); // entity.put('new_district_detail', newDistrictDetail(newDisCount, cityName)); // } else { // entity.put('new_district_detail', [:]); @@ -604,23 +567,30 @@ class CityInfoAnaBatch extends BaseBatch { if (officePrices) { detail.put('price', roundDouble(officePrices.size(), officeCount)); } - - query = new BasicDBObject(); - query.put('city', cityName); - query.put('kind', 'д×ÖÂ¥'); - query.put('weekend', weekend); - def officeRents = RENT_STAT_CONN.distinct("name", query); + + def officeRents = findOfficeRent(cityName) if (officeRents) { detail.put('rentPrice', roundDouble(officeRents.size(), officeCount)); } + + def halfYearofficeRentCount = findHalfYearOfficeRentCount(cityName) + if (halfYearofficeRentCount) { + detail.put('halfYearRentPrice', roundDouble(halfYearofficeRentCount, officeCount)); + } + entity.put('office_detail', detail); entity.put('existing_office_count', officeCount); } else { entity.put('office_detail', [:]); } - - print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} д×ÖÂ¥Íê³É]" + +// if(curInfo){ +// CITY_INFO_CONN.update(new BasicDBObject("_id", curInfo._id), new BasicDBObject('$set', entity)) +// print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} д×ÖÂ¥Íê³É]" +// } + + if (entity.get('official_population') && entity.get('district_avg_population')) { entity.put('prediction_district_count', (int) (entity.get('official_population') / entity.get('district_avg_population'))); @@ -628,12 +598,12 @@ class CityInfoAnaBatch extends BaseBatch { entity.put('district_coverage', roundDouble(entity.get('existing_district_count'), entity.get('prediction_district_count'))); } } - - + + if (allCityShopCount.get(cityName)) { def shopCount = allCityShopCount.get(cityName); def detail = shopDetail(shopCount, cityName); - + DBObject query = new BasicDBObject(); query.put('city', cityName); //query.put('estate_type', 'ÉÌÆÌ'); @@ -642,7 +612,7 @@ class CityInfoAnaBatch extends BaseBatch { if (shopPrices) { detail.put('price', roundDouble(shopPrices.size(), shopCount)); } - + query = new BasicDBObject(); query.put('city', cityName); query.put('kind', 'ÉÌÆÌ'); @@ -651,45 +621,41 @@ class CityInfoAnaBatch extends BaseBatch { if (shopRents) { detail.put('rentPrice', roundDouble(shopRents.size(), shopCount)); } - + entity.put('shop_detail', detail); entity.put('existing_shop_count', shopCount); }else { entity.put('shop_detail', [:]); } print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} ÉÌÆÌÍê³É]" - + def cityStat = allCityStats.get(cityName); if (cityStat) { entity.put('avg_price', cityStat.avg_price); } - + DBObject query = new BasicDBObject(); query.put('city', cityName); query.put('c_date', new BasicDBObject('$gte', lastWeekend).append('$lte', weekend)); //entity.put('evaluation_count', (int) EVALUATION_CONN.count(query));ÓÉÓÚ¹À¼Û¼Ç¼Êý¾ÝÁ¿´ó£¬²éѯÂý£¬ÏÈÈ¥µôÕâ¸ö£¬×îºóÃæÔÚÓöàÏß³Ìͳ¼Æ entity.put('price_total_count', (int) PRICE_JIUCUO_CONN.count(query)); - + query.put('price_lev', 'Æ«¸ß'); entity.put('price_high_count', (int) PRICE_JIUCUO_CONN.count(query)); - + query.put('price_lev', 'Æ«µÍ'); entity.put('price_low_count', (int) PRICE_JIUCUO_CONN.count(query)); - + /*if (entity.get('evaluation_count')) {ÓÉÓÚ¹À¼Û¼Ç¼Êý¾ÝÁ¿´ó£¬²éѯÂý£¬ÏÈÈ¥µôÕâ¸ö£¬×îºóÃæÔÚÓöàÏß³Ìͳ¼Æ entity.put('price_to_eva', roundDouble(entity.get('price_total_count'), entity.get('evaluation_count'))); }*/ - + if (entity.get('price_high_count')) { entity.put('low_to_high', roundDouble(entity.get('price_low_count'), entity.get('price_high_count'))); } - + print "\t[${DateUtil.formatToTightYYYYMMDDhhmmss(new Date())} ¹À¼ÛÍê³É]" - - - - - + // query = new BasicDBObject(); // query.put('city', cityName); // query.put('weekend', weekend); @@ -710,7 +676,7 @@ class CityInfoAnaBatch extends BaseBatch { // } // } // } -// +// // if (total > 0) { // BigDecimal bg = new BigDecimal(webZhunque * 1.0 / total); // entity.put('web_average', bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue()); @@ -1284,7 +1250,7 @@ class CityInfoAnaBatch extends BaseBatch { fields.put(key, 1) } - DSCursor cur = SEAWEED.find(query, fields).batchSize(2000) + def cur = SEAWEED.find(query, fields).batchSize(2000) Iterator iter = cur.iterator() def countMap = [:] println cur.count() @@ -1335,7 +1301,7 @@ class CityInfoAnaBatch extends BaseBatch { fields.put(key, 1) } - DSCursor cur = SEAWEED.find(query, fields).batchSize(2000) + def cur = SEAWEED.find(query, fields).batchSize(2000) Iterator iter = cur.iterator() def countMap = [:] @@ -1546,6 +1512,69 @@ class CityInfoAnaBatch extends BaseBatch { } return true; } + + def findOfficeRent(cityName){ + def query = new BasicDBObject(); + query.put('city', cityName); +// query.put('kind', 'д×ÖÂ¥'); +// query.put('weekend', weekend); +// def officeRents = RENT_STAT_CONN.distinct("name", query); +// if (officeRents) { +// detail.put('rentPrice', roundDouble(officeRents.size(), officeCount)); +// } + query.put('cat', 'office'); + def date1 = new Date() + date1.setDate(28) + if(new Date().getTime()> date1.getTime()){ + query.put('date', Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM"))); + }else{ + query.put('date', Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -2, "yyyyMM"))); + } + def officeRents = OFFICE_RENT_STAT_CONN.distinct("name", query); + return officeRents + } + + def findHalfYearOfficeRentCount(cityName){ + + def date1 = new Date() + date1.setDate(28) + def months = [] + if(new Date().getTime()> date1.getTime()){ + for(def i=1;i<=6;i++){ + months << Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1*i, "yyyyMM")) + } + }else{ + for(def i=2;i<=7;i++){ + months << Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1*i, "yyyyMM")) + } + } + def map = [:] + for(def month : months){ + def query = new BasicDBObject(); + query.put('city', cityName); + query.put('cat', 'office'); + query.put('date', month); + def officeRents = OFFICE_RENT_STAT_CONN.distinct("name", query); + + officeRents.each{k-> + def count = map.get(k) + if(!count){ + map.put(k, 1) + }else{ + map.put(k, count + 1) + } + + } + } + def total = 0 + map.each{k,v-> + if(v==6){ + total ++ + } + } + + return total + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy index 590386984..6f6512322 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/DistrictTradeHouseStatBatch.groovy @@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit @BatchOwner(Watcher.GaoJuan) class DistrictTradeHouseStatBatch extends BaseBatch{ - public static DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") - public static DBCollection DISTRICT_TRADE_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_trade_stat", "192.168.0.43") + public static DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") + public static DBCollection DISTRICT_TRADE_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_trade_stat", "mongo.db.fangjia.com") static main(args) { runBatch(new DistrictTradeHouseStatBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy new file mode 100644 index 000000000..e85220e8e --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -0,0 +1,140 @@ +package com.fangjia.script.dealPrice + +import com.fangjia.core.util.MongoUtils +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ElasticUtils +import com.mongodb.AggregationOutput +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import com.mongodb.DBObject +import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.common.xcontent.XContentType + +/** + * ³É½»Í¬²½206£¬°´ÈÕͬ²½ + */ +@BatchOwner(Watcher.GaoJuan) +class SynchDealPriceToEs extends BaseBatch{ + static DBCollection dealPriceConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) + + static main(args) { + runBatch(new SynchDealPriceToEs(), args) + } + + + @Override + void process(Object args) { + run(); + } + + def run(){ + def startDate = DateUtils.formatDateByPattern(new Date()-1, "yyyy-MM-dd") + def q = new BasicDBObject() + q.put("m_date", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate))) + def dbcursor = dealPriceConn.find(q) + println DateUtils.formatDateByPattern(new Date(),"yyyy-MM-dd")+" ¸üÐÂÁ¿£º"+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) + +// def batchsize = 2000 +// def citys = getCityCount() +// citys.each{city,count-> +// if(city instanceof String){ +// for(def year = 1999;year<=2025;year++){ +// def q = new BasicDBObject("city", city) +// q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) +// def dbcursor = dealPriceConn.find(q).batchSize(batchsize) +// println city +" "+ dbcursor.count() +// def ret = [] +// for(def o : dbcursor){ +// ret << o +// } +// save(ret) +// } +// } +// } + } + + + def getCityCount(){ + + BasicDBObject match = null; + // ¶¨Òå¾ÛºÏ¹ÜµÀ£¬°´ city ×ֶηÖ×飬²¢¼ÆËãÿ¸ö³ÇÊеÄÊýÁ¿ + DBObject groupFields = new BasicDBObject(); + +// match = new BasicDBObject('$match', new BasicDBObject("level", "³ÇÊÐ")); + groupFields.put("_id", new BasicDBObject("city",'$city')) + + groupFields.put("count", new BasicDBObject('$sum', 1)); + DBObject group = new BasicDBObject('$group', groupFields); + + // Ö´Ðоۺϲéѯ + AggregationOutput output = dealPriceConn.aggregate(Arrays.asList(group)); + def map = [:] + // ±éÀú½á¹û + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + if(obj.get("city")) { + int count = (Integer) result.get("count"); + map.put(obj.get("city"), count) + } + } + return map; + } + + + + def save(rows){ + BulkRequest request = new BulkRequest(); + int batchSize = 500; + int processedCount = 0; + def client = ElasticUtils.getClient("192.168.0.206") + + for(def map : rows){ +// def map = rows.get(key) + def data_id = map._id.toString() + map.remove("_id") + request.add(new IndexRequest("trades", "_doc", data_id).source(map, XContentType.JSON)); + + // ÅúÁ¿Ìá½»Êý¾Ý + if (request.numberOfActions() >= batchSize) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + print "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents "+new Date().format("yyyy-MM-dd HH:mm:ss") + } + + request = new BulkRequest(); + } + } + + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + } + + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy index 038134ea4..b670962db 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/district/DistrictDealSellRentRankBatch.groovy @@ -1,6 +1,5 @@ package com.fangjia.script.district -import com.fangjia.core.util.DataUtil import com.fangjia.core.util.DateUtil import com.fangjia.datastore.driver.DSCollection import com.fangjia.datastore.driver.DSCursor @@ -9,11 +8,20 @@ import com.fangjia.datastore.driver.FacetResult import com.fangjia.script.BaseBatch import com.fangjia.script.BatchOwner import com.fangjia.script.Watcher +import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.DBObject +import org.elasticsearch.index.query.BoolQueryBuilder +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong /** * Created by dxy on 2016/12/15. */ @@ -26,6 +34,10 @@ class DistrictDealSellRentRankBatch extends BaseBatch { private static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") private static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName("fangjia", "house_loudong", "mongo.db.fangjia.com") private static final DBCollection DISTRICT_ANALY_DATA_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_analy_data", "mongo.db.fangjia.com") + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(60) + // ×î´óÖØÊÔ´ÎÊý + private static final int MAX_TRY_COUNT = 5; + public void process(Object args) { def cities = [ @@ -47,7 +59,7 @@ class DistrictDealSellRentRankBatch extends BaseBatch { "Í¼Ä¾Êæ¿Ë","Îå¼ÒÇþ","¼ÃÔ´","ÏÉÌÒ","DZ½­","ÌìÃÅ","¾°µÂÕò", "ÉñÅ©¼Ü","Îåָɽ","Çíº£","ÙÙÖÝ","ÎIJý","ÍòÄþ","¶«·½","¶¨°²","ÍͲý","³ÎÂõ","ÁÙ¸ß","°×ɳ","²ý½­","ÀÖ¶«","ÁêË®", "±£Í¤","ÇíÖÐ","±±ÍÍ","ÌúÃŹØ","Ë«ºÓ","¿É¿Ë´ïÀ­" ] - cities = ["ÎÞÎý"] + cities = ["º×¸Ú"] println cities for(String city : cities) { List districts = findDistrictByCity(city) @@ -63,14 +75,14 @@ class DistrictDealSellRentRankBatch extends BaseBatch { for(DBObject district : districts) { String key = district.get("name").toString().trim() + "_" + district.get("region") + "_" + district.get("city") long sellCount = sellCountMap.get(key) ? sellCountMap.get(key) : 0 - if(district.get('alias')) { - for (String ali : district.get('alias')) { - if(ali) { - String skey = ali.toString().trim() + "_" + district.get("region") + "_" + district.get("city") - sellCount += (sellCountMap.get(skey) ? sellCountMap.get(skey) : 0) - } - } - } +// if(district.get('alias')) { +// for (String ali : district.get('alias')) { +// if(ali) { +// String skey = ali.toString().trim() + "_" + district.get("region") + "_" + district.get("city") +// sellCount += (sellCountMap.get(skey) ? sellCountMap.get(skey) : 0) +// } +// } +// } sellCountsList << (int)sellCount } sellCountsList = sellCountsList.unique() @@ -219,67 +231,74 @@ class DistrictDealSellRentRankBatch extends BaseBatch { } private def findDistrictHouseCount(String city, List districts, Date date) { - def regionDistrictMap = [:] - for(DBObject dbo : districts) { - def names = [] - String n = DataUtil.escapeSolr(dbo.get('name')) - if(n) { - names << n - } - if(dbo.get("alias")) { - for(String ali : dbo.get("alias")) { - ali = DataUtil.escapeSolr(ali) - if(ali) { - names << ali - } - } - } - String region = dbo.get('region') - if(!regionDistrictMap.containsKey(region)) { - regionDistrictMap.put(region, names) - }else { - def list = regionDistrictMap.get(region) - list.addAll(names) - regionDistrictMap.put(region, list) - } - } + def startDate = DateUtil.formatByPattern(DateUtil.getFirstDayOfMonth(DateUtil.addMonthToDate(date, -1)),"yyyyMMdd") + def endDate = DateUtil.formatByPattern(DateUtil.getFirstDayOfMonth(date),"yyyyMMdd") + Map monthMap = findAllCommHouse(city, districts, startDate.toInteger(), endDate.toInteger()) - Map halfMap = new HashMap(); - Map monthMap = new HashMap(); - for(String region : regionDistrictMap.keySet()) { - def nameGroups = [] - int len = 0 - def nameList = [] - for(String name : regionDistrictMap.get(region)) { - if(len >= 600 || nameList.size() >= 100) { - nameGroups << new ArrayList(nameList); - nameList.clear() - len = 0 - } - len += name.length() - nameList << name - } - if(nameList.size() > 0) { - nameGroups << new ArrayList(nameList); - } + def startDate2 = DateUtil.formatByPattern(DateUtil.getFirstDayOfMonth(DateUtil.addMonthToDate(date, -6)),"yyyyMMdd") + Map halfMap = findAllCommHouse(city, districts, startDate2.toInteger(), endDate.toInteger()) - println city + "\t" + region + "\t" + regionDistrictMap.get(region).size() + "/" + nameGroups.size() + "\t" + DateUtil.formatToTightYYYYMMDDhhmmss(new Date()) - for(List names : nameGroups) { - def halfRegionResult = [:] - def monthRegionResult = [:] - try { - halfRegionResult = facetDistrictCount(city, region, names, date, 7) - monthRegionResult = facetDistrictCount(city, region, names, date, 2) - }catch (e) { - sleep(10 * 1000) - halfRegionResult = facetDistrictCount(city, region, names, date, 7) - monthRegionResult = facetDistrictCount(city, region, names, date, 2) - } - halfMap.putAll(halfRegionResult) - monthMap.putAll(monthRegionResult) - } - } +// def regionDistrictMap = [:] +// for(DBObject dbo : districts) { +// def names = [] +// String n = DataUtil.escapeSolr(dbo.get('name')) +// if(n) { +// names << n +// } +// if(dbo.get("alias")) { +// for(String ali : dbo.get("alias")) { +// ali = DataUtil.escapeSolr(ali) +// if(ali) { +// names << ali +// } +// } +// } +// +// String region = dbo.get('region') +// if(!regionDistrictMap.containsKey(region)) { +// regionDistrictMap.put(region, names) +// }else { +// def list = regionDistrictMap.get(region) +// list.addAll(names) +// regionDistrictMap.put(region, list) +// } +// } +// +// +// for(String region : regionDistrictMap.keySet()) { +// def nameGroups = [] +// int len = 0 +// def nameList = [] +// for(String name : regionDistrictMap.get(region)) { +// if(len >= 600 || nameList.size() >= 100) { +// nameGroups << new ArrayList(nameList); +// nameList.clear() +// len = 0 +// } +// len += name.length() +// nameList << name +// } +// if(nameList.size() > 0) { +// nameGroups << new ArrayList(nameList); +// } +// +// println city + "\t" + region + "\t" + regionDistrictMap.get(region).size() + "/" + nameGroups.size() + "\t" + DateUtil.formatToTightYYYYMMDDhhmmss(new Date()) +// for(List names : nameGroups) { +// def halfRegionResult = [:] +// def monthRegionResult = [:] +// try { +// halfRegionResult = facetDistrictCount(city, region, names, date, 7) +// monthRegionResult = facetDistrictCount(city, region, names, date, 2) +// }catch (e) { +// sleep(10 * 1000) +// halfRegionResult = facetDistrictCount(city, region, names, date, 7) +// monthRegionResult = facetDistrictCount(city, region, names, date, 2) +// } +// halfMap.putAll(halfRegionResult) +// monthMap.putAll(monthRegionResult) +// } +// } return [halfMap, monthMap]; } @@ -352,6 +371,106 @@ class DistrictDealSellRentRankBatch extends BaseBatch { return ret } + def findAllCommHouse(city, districts, startDate, endDate){ + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(districts.size()) + println city +" Ð¡ÇøÁ¿£º"+districts.size() + + def retMap = new ConcurrentHashMap() + for(def i=0;i0){ + BoolQueryBuilder inBuilder = QueryBuilders.boolQuery(); + for(def s : alias){ + inBuilder.should(QueryBuilders.matchQuery("district_name", s)); + } + queryBuilder.must(inBuilder) + } + + def hosts = ["192.168.0.206","192.168.0.211","192.168.0.212","192.168.0.213","192.168.0.214","192.168.0.215"] + def index = new Random().nextInt(6); + + def houses = ElasticUtils.executeSimpleQuery(hosts[index], "seawater-20*", queryBuilder); + return houses.size(); + } + + + static main(args) { runBatch(new DistrictDealSellRentRankBatch(), args) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy index f1f8918e6..459c68770 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/AbcEvaluationRowsBatch.groovy @@ -20,7 +20,7 @@ class AbcEvaluationRowsBatch extends BaseBatch{ static final def fjtSqlInstance = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/goojia_fangjia?&characterEncoding=utf8", "sa", "G00jia", "com.mysql.jdbc.Driver"); - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", dbUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy index 377a7a6c0..d49b696f3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictInfoExportBatch.groovy @@ -29,7 +29,7 @@ class DistrictInfoExportBatch extends BaseBatch{ def charset = "GBK" - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection FZ_ADDR_COLL = MongoUtils.getCollectionByName2("business", "fz_district_address", lineUrl) public static final DBCollection FZ_DIST_COLL = MongoUtils.getCollectionByName2("business", "fz_district", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy index 585e7bc0b..d049deab9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/FzDataResultStat.groovy @@ -23,7 +23,7 @@ class FzDataResultStat { public static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com") - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection FZ_DIST_COLL = MongoUtils.getCollectionByName2("business", "fz_district", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy index b0ce64f12..2fc6f160d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test.groovy @@ -16,7 +16,7 @@ import net.sf.json.JSONObject import org.apache.commons.io.FileUtils import org.bson.types.ObjectId -DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") +DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") import com.fangjia.core.util.HttpRequest diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy index f96bf753a..f391d5dad 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/Test1.groovy @@ -169,7 +169,7 @@ DingDingMessageUtil.sendTextMessage(access_token, s) // // //def count(name, sDate){ -// DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") +// DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") // def q = new BasicDBObject() // q.put("city","¸£ÖÝ") // q.put("s_date", sDate) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy index 11d76c586..fb6631ba3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdPriceExportBatch.groovy @@ -21,7 +21,7 @@ class ThirdPriceExportBatch extends BaseBatch{ def sDate= Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -6, "yyyyMM")); def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static final DBCollection FZ_DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("business", "fz_district_stat", "mongo.db.fangjia.com") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy index 22604b2ec..57b9f852c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/ThirdTest.groovy @@ -16,7 +16,7 @@ import java.util.concurrent.CountDownLatch class ThirdTest { - DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy index cd6252fb6..94efbb6df 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/TradeExportBatch.groovy @@ -25,7 +25,7 @@ class TradeExportBatch extends BaseBatch{ def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); - DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") static def districtMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy index a7ba664d1..599ef8f1e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/CzBankStat.groovy @@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger class CzBankStat { public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("business", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("business", "average_statistics", "mongo.db.fangjia.com") def static final DBCollection CZLOG = MongoUtils.getCollectionByName("fangjia_log", "cz_log2", "192.168.0.136") static main(args) { def task = new CzBankStat(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy index 493c42d8c..c6ce91e86 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DealPriceProcess.groovy @@ -16,7 +16,7 @@ import org.apache.commons.lang.StringUtils import java.util.regex.Pattern class DealPriceProcess { - final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") def total = 0 static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy index a38cf6268..8fccafde8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/DistrictDetailBatch.groovy @@ -17,7 +17,7 @@ import java.util.concurrent.Executors class DistrictDetailBatch { - public static DBCollection DISTRICT_DETAIL_COLL = MongoUtils.getCollectionByName("fangjia_youfang", "district_detail", "192.168.0.43") + public static DBCollection DISTRICT_DETAIL_COLL = MongoUtils.getCollectionByName("fangjia_youfang", "district_detail", "mongo.db.fangjia.com") public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy index da0c07889..9d7c97533 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/EsHouseStat.groovy @@ -40,7 +40,7 @@ class EsHouseStat { dataSource.setProperties(connectionProperties) } - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) public static void main(String[] args){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy index 6c33b2553..423764526 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZDataExport.groovy @@ -16,8 +16,8 @@ import java.sql.ResultSet class FZDataExport { - final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static EsDataSource dataSource = new EsDataSource() private static final String address = "jdbc:es://http://seawater.es.db.fangjia.com:9200/timezone=UTC&page.size=250&connect.timeout=120s&network.timeout=120s&page.timeout=120s" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy index 11123e02b..6e5a99f52 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FZHouseEvaluation.groovy @@ -8,7 +8,7 @@ import com.mongodb.DBCollection class FZHouseEvaluation { - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", dbUrl) def regionMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy index 3932cc7d9..29f729c63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FangjiatongUserStat.groovy @@ -1,5 +1,6 @@ package com.fangjia.script.gj +import com.fangjia.script.common.DataHandleUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection; @@ -12,12 +13,13 @@ import com.fangjia.script.util.ExcelUtils; class FangjiatongUserStat { public static final DBCollection FJT_USER_COLL = MongoUtils.getCollectionByName("fangjiatong_log", "utm_gif_log", "222.73.242.42", 52002) - static final def onLineSqlInstance = Sql.newInstance("jdbc:mysql://222.73.242.42:4306/goojia_fangjia?&characterEncoding=utf8", "sa", "G00jia", "com.mysql.jdbc.Driver"); + static final def onLineSqlInstance = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/goojia_fangjia?&characterEncoding=utf8", "sa", "G00jia", "com.mysql.jdbc.Driver"); public static void main(String[] args) { def task = new FangjiatongUserStat(); - task.run(); +// task.run(); + task.stat() } def run(){ @@ -60,4 +62,59 @@ class FangjiatongUserStat { return ret; } + def stat(){ + def users = findUses(12) + def months = ["2019-01-01","2019-02-01","2019-03-01","2019-04-01","2019-05-01","2019-06-01","2019-07-01","2019-08-01","2019-09-01","2019-10-01","2019-11-01","2019-12-01","2020-01-01"] + def rets = [] + def header = ["Óû§id","Ö§ÐÐÃû³Æ", "±¸×¢Ãû³Æ"] + months.each{m-> + header << m.substring(0, 7) + } + rets << header + for(def m : users){ + def ret = [] + ret << m.user_id + ret << m.name + ret << m.org_name + for(def i=1;i=5000 && v<=10000000){ + if(v>=1000 && v<=10000000){ return v.toString().toDouble().toInteger() } } @@ -288,11 +285,25 @@ class FiledStrand { return null } + + + static def processLobbyHeight(height){ + if(height){ + def v = getValue(height) + if(v>=2.4 && v<=30){ + return v.toString() + } + } + return null + } + static def processElevators(elevators){ if(elevators){ def v = getValue(elevators) - if(v>0 && v<=100){ - return v.toString() + if(v instanceof Integer){ + if(v>0 && v<=100){ + return v.toString() + } } } return null @@ -317,24 +328,34 @@ class FiledStrand { static def processStandardArea(area){ if(area){ - area = area.toString().replace("£¬",",").replace("©O", "").replace("m", "").replace("/","") - area = Pattern.compile("[\\u4e00-\\u9fa5]").matcher(area).replaceAll(""); - return area + def v = getValue(area) + if(v>=500 && v<=20000){ + return v.toString().toDouble().toInteger() + } } return null } static def processCarSiteRent(rent){ if(rent){ - def v = getNumberRange(rent) - if(v){ - if(v=="0"){ + if(["-","0Ôª/ÔÂ","ÎÞ","²»Ïê","δ֪","´ý²é","Ãâ·ÑÔª/ÔÂ","/","0","*","´ýÈ·ÈÏ","undefinedÔª/ÔÂ","0Ôª","0ԪÿÔÂ","δ֪Ԫ/ÔÂ","0.00Ôª/ÔÂ","䶨","Ôݶ¨","²âËãÖÐ","ÎÞÔª/ÔÂ","δ¶¨Ôª/ÔÂ","ÁíÒéÔª/ÔÂ","ÃæÒéÔª/ÔÂ","ÃæÒéÔª/ÔÂ","ÓÐÔª/ÔÂ","ÔÝʱδȷ¶¨","0Ôª£¨ÎÞÍ£³µÎ»£©"," Ôª/ÔÂ"].contains(rent)){ + return null + }else if(rent.contains("ÔÝÎÞ") || rent.contains("³µÎ»²»¹é") || rent.contains("´ý¶¨") || rent.contains("Ôݶ¨") || rent.contains("ÔÝÍêÉÆ") || rent.contains("´ýÉóÅú") || rent.contains("²»Ïê") || rent.contains("䶨¼Û¸ñ") || rent.contains("ÖйúµçÐÅ") || rent.contains("ÃæÌ¸")){ + return null + }else{ + rent = rent.replace("Ôª£¯ÔÂ","Ôª/ÔÂ").replace(",","").replace("#","").replace(".00","") + if(rent.toString().length()>100){ return null - }else{ - return v.toString() } + if(rent instanceof Double && rent.toDouble()<100){ + return null + } + + if(rent instanceof Integer && rent.toInteger()<100){ + return null + } + return rent } - return null } return null } @@ -382,7 +403,7 @@ class FiledStrand { static def processCarSite(car_site_count){ def v = getValue(car_site_count.toString()); if(v){ - if(v>5 && v<=100000){ + if(v>5 && v<=10000){ try { return v.toString().toInteger(); }catch(Exception e){ @@ -533,12 +554,82 @@ class FiledStrand { return null } + static def processLevel(val){ + def level = null + if (val) { + if(val.contains("³¬¼×") || val.contains("5A") || val.contains("6A") || val.contains("¶¥¼¶")){ + level = "³¬¼×¼¶" + }else if(val.indexOf("¼×")>-1 || val.contains("A")){ + level = "¼×¼¶" + }else if(val.indexOf("ÒÒ")>-1 || val.contains("B")){ + level = "ÒÒ¼¶"; + }else if(val.indexOf("±û")>-1 || val.contains("C")){ + level = "±û¼¶"; + } + } + return level + } + + + static def processLoopLine(val){ + def line = null + if (val) { + if(!val.contains("ÔÝ") && !val.contains("ÎÞ")){ + if(val.indexOf("»·")>-1){ + line = val + } + } + } + return line + } + + static def processForeign(val){ + def foreign = null + if (val) { + if(val.indexOf("ÊÇ")>-1){ + foreign = "ÊÇ" + }else if(val.indexOf("·ñ")>-1){ + foreign = "·ñ"; + } + } + return foreign + } + + static def processRegister(val){ + def register = null + if (val) { + if(val.contains("²»¿ÉÒÔ×¢²á") || val.contains("²»ÄÜ×¢²á")){ + register = "·ñ"; + }else if(val.contains("¿ÉÒÔ×¢²á")){ + register = "ÊÇ" + }else if(val.indexOf("ÊÇ")>-1){ + register = "ÊÇ" + }else if(val.indexOf("·ñ")>-1){ + register = "·ñ"; + } + } + return register + } + + static def processFitment(val){ + def fitment = null + if(val){ + if(val.indexOf("¾«×°")>-1){ + fitment = "¾«×°" + }else if(val.indexOf("¼òµ¥")>-1 || val.indexOf("¼ò×°")>-1 || val.indexOf("Ò»°ã")>-1 || val.indexOf("ÆÕͨ")>-1){ + fitment = "¼ò×°"; + }else if(val.indexOf("ëÅ÷")>-1){ + fitment = "ëÅ÷"; + } + } + return fitment + } static def processLngAndLat(val) { - if (val) { + if (val && val!="null") { def map = [:] - def lng = DataHandleUtils.getDoubleRound(6, val.x) - def lat = DataHandleUtils.getDoubleRound(6, val.y) + def lng = DataHandleUtils.getDoubleRound(6, val.lon) + def lat = DataHandleUtils.getDoubleRound(6, val.lat) Long gd_lat = lat * 10000000000L Long gd_lng = lng * 10000000000L map.lat = gd_lat @@ -618,7 +709,8 @@ class FiledStrand { if(cubage_percent){ def v = getValue(cubage_percent) if(v){ - if(v>=0.3 && v<=10){ + v = DataHandleUtils.getDoubleRound(2, v.toString().toDouble()) + if(v>=0.3 && v<=20){ return v.toString() } } @@ -644,7 +736,7 @@ class FiledStrand { static def processVirescencePercent(virescence_percent){ if(virescence_percent){ def v = getValue(virescence_percent) - if(v && v>15 && v<=70){ + if(v && v>=10 && v<=70){ return v.toString() } } @@ -788,6 +880,20 @@ class FiledStrand { return null } + static def processUndergroundFloor(floor){ + def v = getValue(floor.toString()); + if(v){ + if(v>=1 && v<=5){ + try { + return v.toString(); + }catch(Exception e){ + println e.getMessage() + } + } + } + return null + } + static def processRealUsePercent(percent){ def v = getValue(percent.toString()); if(v){ @@ -834,15 +940,40 @@ class FiledStrand { static def processCompany(val){ if(val){ - if(val.length()>20){ + if(val.length()>20 || val.length()<4){ return null }else{ - if(val.contains("ÔÝÎÞ")){ + if(["#NA","*"].contains(val)){ + return null + } + if(val.contains("ÔÝÎÞ") || val.contains("Ôݶ¨")){ + return null + } + if(val.contains("δ֪") || val.contains("²»Ïé")){ + return null + } + if(val.contains("´ý¶¨") || val.contains("´ýÏêÇé")){ + return null + } + if(val.contains("ÉÐδ¹«¿ª")){ + return null + } + if(val.contains("ÔÚÏß×Éѯ")){ + return null + } + + if(val.contains("ƽÃ×") || val.contains("ԪƽÔÂ")){ return null } if(val == "ÎÞ"){ return null } + if(val == "-"){ + return null + } + if(val == "--"){ + return null + } if(val.isNumber()){ return null } @@ -863,7 +994,7 @@ class FiledStrand { if (pattern.matcher(val).matches()) { return null } - return val + return val.replace("£ª","").replace("*","") } } @@ -909,14 +1040,18 @@ class FiledStrand { } static def getNumber(def input) { - Pattern pattern = Pattern.compile("\\d+(\\.\\d+)?"); - Matcher matcher = pattern.matcher(input); - List list = new ArrayList(); - while (matcher.find()) { - list.add(matcher.group()); - } - if(list.size()>0){ - return list.get(0); + try{ + Pattern pattern = Pattern.compile("\\d+(\\.\\d+)?"); + Matcher matcher = pattern.matcher(input); + List list = new ArrayList(); + while (matcher.find()) { + list.add(matcher.group()); + } + if(list.size()>0){ + return list.get(0); + } + }catch(Exception e){ + println input+" error" } return null; } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy index 5f73a32b9..a941d08e9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FjwUserStat.groovy @@ -8,7 +8,7 @@ import com.mongodb.DBCollection class FjwUserStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection USER_COLL = MongoUtils.getCollectionByName2("fangjia_coresite", "user", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy index 1ffbaa246..a337263f9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/HouseLouDongMatchBatch.groovy @@ -18,7 +18,7 @@ import org.bson.Document; import org.bson.conversions.Bson; class HouseLouDongMatch { - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", dbUrl) public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy index 29bd4df02..e153f90b6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LandDetailCrawl.groovy @@ -22,7 +22,7 @@ class LandDetailCrawl { DBCollection LAND_COLL = MongoUtils.getCollectionByName("fangjia_crawl", "land_deal_price1", "192.168.0.235", 27018) - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; public static final DBCollection FJT_LAND_COLL = MongoUtils.getCollectionByName2("business", "land_distinct", lineUrl) public static final DBCollection OFF_FJT_LAND_COLL = MongoUtils.getCollectionByName2("business", "land_distinct", offlineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy index 7c62d7229..b99f162e1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/LogStat.groovy @@ -14,10 +14,10 @@ import org.apache.lucene.queryparser.classic.QueryParser class LogStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def static final DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new LogStat() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy index 276235d1d..7f1f0b25b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/NoHouseDistrictStatBatch.groovy @@ -21,8 +21,8 @@ import java.util.concurrent.Executors @BatchOwner(Watcher.GaoJuan) class NoHouseDistrictStatBatch extends BaseBatch{ - public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; -// public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; +// public static final def dbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_stat", dbUrl) public static final DBCollection AVERAGER_CONFIG_COLL = MongoUtils.getCollectionByName2("fangjia", "averager_config", dbUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy index 77c705569..e0e481909 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/PingAnAddressLevalTest.groovy @@ -13,7 +13,7 @@ class PingAnAddressLevalTest { String token = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"; - DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "192.168.0.43") + DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "mongo.db.fangjia.com") static main(args) { def task = new PingAnAddressLevalTest() task.run(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy new file mode 100644 index 000000000..72495191d --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy @@ -0,0 +1,62 @@ +package com.fangjia.script.gj + +import groovy.json.JsonOutput + +class ProxyHttpUtils { + + static String proxyHost = 'tunnel2.qg.net'; + static Integer proxyPort = 14186; + static String proxyUsername = '113BBC06'; + static String proxyPassword = '3B2FBD05B0AF'; + + static String getProxyResult(targetUrl, data){ + // ½« JSON ¶ÔÏóת»»Îª×Ö·û´® + String jsonData = new JsonOutput().toJson(data); + // ´´½¨´úÀí¶ÔÏó + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); + + // ´´½¨ URL ¶ÔÏó + URL url = new URL(targetUrl); + + // ´´½¨Á¬½Ó¶ÔÏó + URLConnection connection = url.openConnection(proxy); + + // ÉèÖôúÀíÈÏÖ¤ + java.net.Authenticator.setDefault(new java.net.Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()) + } + }) + + // ÉèÖÃÇëÇó·½·¨Îª POST + connection.setRequestMethod("POST"); + + // ÔÊÐíÊä³öÁ÷ + connection.setDoOutput(true); + + // ÉèÖÃÇëÇóÍ· + connection.setRequestProperty("Content-Type", "application/json"); + + // ·¢ËÍÇëÇó²ÎÊý + OutputStream outputStream = connection.getOutputStream(); + outputStream.write(jsonData.getBytes("UTF-8")); + outputStream.flush(); + outputStream.close(); + + // ¶ÁÈ¡ÏìÓ¦ + int responseCode = connection.getResponseCode() + if (responseCode == HttpURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + return response.toString(); + } else { + println "HTTP request failed with response code ${responseCode}"; + } + return null; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy index 30c9481ef..62ae568e5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat.groovy @@ -329,7 +329,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy index 67e127805..eb85734e0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/QinLingStat1.groovy @@ -343,7 +343,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy index 92b2a9409..937c82184 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/RegionBlockSetting.groovy @@ -6,7 +6,7 @@ import com.mongodb.DBCollection class RegionBlockSetting { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection REGION_BLOCK_COLL = MongoUtils.getCollectionByName2("fangjia", "region_block", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy index 1cd14588a..d0f6320d7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/SynchDistrictStatBatch.groovy @@ -17,8 +17,8 @@ import com.mongodb.DBObject class SynchDistrictStatBatch extends BaseBatch{ - //public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + //public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; public static final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_stat", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy index b9147952a..2b7e1049e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/UpdateThirdPrice.groovy @@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicLong class UpdateThirdPrice { - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def static final DBCollection AVERAGE_STATISTICS_OFFLINE = CrawalDBUtil.getAverage_statistics_col(); public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy index 16063d88b..4ca121052 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/apiLog/ApiUserCountAnalyBatch.groovy @@ -14,7 +14,7 @@ import groovy.sql.Sql class ApiUserCountAnalyBatch extends BaseBatch{ static final dbFangjia = Sql.newInstance("jdbc:mysql://mysql.db.fangjia.com:4306/fangjia?autoReconnect=true&characterEncoding=utf-8&autoReconnect=true", "sa", "G00jia", "com.mysql.jdbc.Driver"); - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection AUTHORITY_COLL = MongoUtils.getCollectionByName2("fangjia", "authority.api_user_authority", lineUrl) DBCollection VISIT_COLL = MongoUtils.getCollectionByName2("business", "api_visit_count", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy index 19709dd22..7ea251213 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/CcbCityPriceStat.groovy @@ -10,7 +10,7 @@ import com.mongodb.DBCollection class CcbCityPriceStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy index 795297501..576869ecd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ccb/FileUtils.groovy @@ -104,6 +104,43 @@ class FileUtils { sb.setLength(0) } out.close(); + return sb.toString().getBytes(charset) + } + + static def createEncryptFile(fileName, outputStr, isAppend){ + OutputStream out = new FileOutputStream(fileName, isAppend); + out.write(outputStr.getBytes("utf-8")); + out.close(); + } + + + static def createFileStringByCustomSuffix(ret, fileName, charset, suffix, lineSuffix){ + File file = new File(fileName); +// if (file.exists()) { +// file.delete(); +// } + + if (!file.getParentFile().exists()) { + boolean result = file.getParentFile().mkdirs(); + if (!result) { + System.out.println("´´½¨Ä¿Â¼Ê§°Ü"); + } + } + def sb = new StringBuffer(); + def index = 0 + for(def row : ret){ + if(row){ + index++ + sb.append(StringUtils.join(row.toArray(), suffix)) + if(index + println s + } + existList.each{s-> + println s + } + + println " ÐÂÔöÓ³ÉäÏçÕò£º"+results.size()+" ÒÑ´æÔÚÏçÕò£º"+existList.size() + + } + + def addDevStreetToMapping(city,streetShapes, devShapes){ + def addCount = 0 + def existsCount = 0 + + + for(def streetObj : streetShapes){ + + def coordinates = streetObj.shape.coordinates + for(def pointList : coordinates){ + def objList = findDevInStreetRange(streetObj, pointList, devShapes) + if(objList){ + for(def obj : objList){ + def existsFlag = isExistStreetByDevName(obj.name, streetObj.street) + if(existsFlag){ + existsCount++ + existList << "[´æÔÚ] "+obj.name+" "+ streetObj.street + }else{ + addCount++ + results << "[ÐÂÔö] "+obj.name+"#"+ streetObj.street + if(!streetObj.street){ + println streetObj + } + } + } + } + } + } + + + } + + def findDevInStreetRange(streetObj,pointList, devShapes){ + def devList = [] + def minDis =200 + for(def devObj : devShapes){ + def flagList = [] + def distances = [] + for(def pointArr : pointList){ +// def flag = InsidePolygon.isInArea(pointArr[0].toString().toDouble(), pointArr[1].toString().toDouble(), InsidePolygon.createPoint4(devObj.shape.coordinates)) + Point2D.Double point = new Point2D.Double(DataHandleUtils.getDoubleRound(6,pointArr[0].toString().toDouble()), DataHandleUtils.getDoubleRound(6, pointArr[1].toString().toDouble())); + def flag = InPolygon.isInArea(point, InPolygon.createPoint(devObj.shape.coordinates)) + flagList << flag + if(!flag){ + distances << findNearestDistances(pointArr, devObj.shape.coordinates) + } + } + + def trueCount = statResult(flagList) + def pre = trueCount*100/flagList.size() + println streetObj.district+" "+streetObj.street +" "+devObj.name +" "+flagList.size()+" "+pre+"%" + if(pre>=100){ + devList << devObj + } +// else{ +// if(distances && pre>=50){ +// def minCount = 0 +// for(def d : distances){ +// if(d <= minDis){ +// minCount++ +// } +// } +// def simlarPointPre = minCount*100/distances.size() +// if(simlarPointPre>=90){ +// devList << devObj +// } +// println "²»ÔÚ¶à±ßÐÍ·¶Î§Äڵĵ㣬¾àÀëСÓÚ${minDis}Ã×ÓУº"+minCount+" Õ¼±È£º"+simlarPointPre +// } +// } + } + + return devList + } + + def findNearestDistances(pointArr, coordinates){ + def minDis = Integer.MAX_VALUE + for(def pointlist : coordinates){ + for(def devPoint : pointlist){ + def distance = GeoUtils.calculateDistance(pointArr[0], pointArr[1], devPoint[0], devPoint[1]) + if(distance < minDis){ + minDis = distance + } + } + } + return minDis + } + + def statResult(rows){ + def count = 0 + for(def s : rows){ + if(s){ + count++ + } + } + return count + } + + def findStreetShapeByCity(city){ + def list = [] + def dbcurosr = administrative_mapping_coll.find(new BasicDBObject("city", city).append("type", "ÏçÕò½ÖµÀ").append("shape", new BasicDBObject('$exists', true))) + for(def d : dbcurosr){ + list << d + } + return list + } + def findDevShapeByCity(city){ + def list = [] + def dbcurosr = DEVELOPMENT_ZONE_43_COLL.find(new BasicDBObject("city", city).append('shape', new BasicDBObject('$exists',true))) + for(def d : dbcurosr){ + list << d + } + return list + } + + def isExistStreetByDevName(devName, street){ + def list = dev_mapping_CONN.find(new BasicDBObject("name", devName).append("type","ÏçÕò½ÖµÀ").append("township",street)).toList() + if(list){ + return true + } + } + + + def run(){ + def directoryPath = 'D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢ÇøÍâ°ü\\ÁÙʱ-û¸¶·Ñ\\' + def dir = new File(directoryPath) + if (dir.isDirectory()) { + dir.eachFileRecurse(FileType.FILES) { file -> + process(file.absolutePath) + } + addDevInfo("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢ÇøÍâ°ü\\ËùÓпª·¢Çø.xlsx") + } else { + println "The specified path is not a directory." + } + } + + def addDevInfo(file){ + ExcelUtils.multiThreadingModify(file, {d-> +// if(!d['I']){ + def name = d['E'] + def q = new BasicDBObject() + q.put('_id',new ObjectId(d['A'])) + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(q) + if(obj){ + if(obj.operator){ + d['H'] = obj.operator + } + if(obj.operate_result){ + d['I'] = obj.operate_result + } + if(obj.shape){ + d['T'] = "ÓÐ" + } +// if(obj.m_date){ +// d['P'] = DateUtils.formatDateByPattern(obj.m_date, "yyyy-MM-dd") +// } + +// if(devAreaMap){ +// devAreaMap.each {k,v-> +// if(obj.name && k && obj.name.contains(k)){ +// d['M'] = v.area_info +// d['N'] = v.count +// d['O'] = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd") +// } +// } +// +// }else{ +// println name+" ¿ÕÖµ" +// } + } +// } + + }) + } + + def process(file){ + def retMap = getNewLocations(file) + if(retMap && retMap.gaode.size()>0){ + def q = new BasicDBObject() + q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+retMap.name+'.*$', Pattern.CASE_INSENSITIVE))) + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(q) + if(obj){ + for(def i=0;i0){ + obj.removeField("_id") + obj.put("create_time", new Date()) + obj.put("block", retMap.name+"-µØ¿é"+i) + obj.put("shape", resultMap) + obj.put("m_date", new Date()) + obj.put("bd_shape",bd_resultMap) + obj.put("operator", "Íâ°ü") + obj.put( "operate_result" , "ÒÑ´¦Àí") + DEVELOPMENT_ZONE_43_COLL.save(obj) + }else{ + udata.put("shape", resultMap) +// udata.put("m_date", new Date()) + udata.put("bd_shape",bd_resultMap) + udata.put("operate_result" , "ÒÑ´¦Àí") + udata.put("operator", "Íâ°ü") + DEVELOPMENT_ZONE_43_COLL.update(q, new BasicDBObject('$set', udata), false, false) + } + } + } + } + } + + def getNewLocations(file){ + def jsonObj = readJson(file) + def features = jsonObj.features + def gaode_locations = [] + def baidu_locations = [] + def name = null + def areaMap = [:] + if(features && features.size()==1){ + name = features[0].properties.Name + def coordinates = features[0].geometry.coordinates + + def index = 0 + println file.toString()+" "+name +" ÓÐ "+coordinates.size()+" ¿é" + + areaMap.count = coordinates.size() + def areas = [] +// if(name.contains("½­ËÕ³£Êì×ۺϱ£Ë°Çø")){ + for(def pointList : coordinates){ + index ++ + def gaode_coordinates = [] + def bd_coordinates = [] + def points = null + if(pointList.size()>1){ + points = pointList + }else{ + points = pointList[0] + } + double area = com.fangjia.script.util.GeoHelper.calculateArea(points) + println name +" µØ¿é"+index + "ΧÀ¸Ãæ»ýÊÇ: ${area} ƽ·½¹«Àï" + areas << area + def locationstr = "" + for(def arrs : points){ + def gaode_map = GeoUtils.gps84ToGcj02(arrs[1].toString().toDouble(), arrs[0].toString().toDouble()) + gaode_coordinates << [gaode_map.get("lng"), gaode_map.get("lat")] + + //´Ë¸ßµÂת°Ù¶È ÓÐÆ«²î + def bd_map = GeoUtils.gcj02ToBd09(gaode_map.get("lat"), gaode_map.get("lng")) +// bd_coordinates << [bd_map.get("lng"), bd_map.get("lat")] + // ¸ßµÂת°Ù¶È ͨ¹ý½Ó¿ÚÓдÎÊýÏÞÖÆ +// def baidu = BaiDuApiUtils.geoconv(gaode_map.get("lng"), gaode_map.get("lat"), 3) +// bd_coordinates << [baidu.x, baidu.y] + + locationstr = arrs[0].toString()+","+arrs[1].toString() + def bdpoint = FangjiaClientUtils.convert(locationstr.substring(0, locationstr.length()), 6) + if(bdpoint){ + bd_coordinates << bdpoint + } + } + //Õû¸öÒ»´®Ò»Æð´«³¬¹ý4029»á±¨´í +// bd_coordinates = FangjiaClientUtils.convert(locationstr.substring(0, locationstr.length()-1), 6) + gaode_locations << gaode_coordinates + if(bd_coordinates){ + baidu_locations << bd_coordinates + }else{ + println name +" ת»»ÓÐÎÊÌâ" + } + + } + areaMap.area_info = areas.join("\n") +// } + + }else{ + println file +" Óжà¸ö" + } + + devAreaMap.put(name, areaMap) + def retMap = [:] + retMap.name = name + retMap.gaode = gaode_locations + retMap.baidu = baidu_locations + return retMap + } + + def readJson(def file){ + def jsonSlurper = new JsonSlurper() + def jsonFile = new File(file) + def jsonText = jsonFile.text + def jsonObj = jsonSlurper.parseText(jsonText) + return jsonObj + } + + def streetInfo(){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢ÇøÍâ°ü\\ËùÓпª·¢Çø.xlsx", {d-> + def count = dev_mapping_CONN.count(new BasicDBObject("name", d['E']).append("type", "ÏçÕò½ÖµÀ")) + d['L'] = count + }) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy new file mode 100644 index 000000000..977423309 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy @@ -0,0 +1,448 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.BaseBatch +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.lixue.util.DBUtils +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import groovy.json.JsonSlurper +import net.sf.json.JSONObject + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +//²¹³ä¿âÖÐûÓÐÏêϸµØÖ·µÄÐ¡Çø +class AddDistrictAddress extends BaseBatch{ + +// def fullCityMap = CommonDatautils.queryFullNameCity() +// def mcaDistMap = CommonDatautils.queryDistNameCityByMapping() +// +// DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) +// public static final DBCollection seaweed_fence_coll = MongoUtils.getCollectionByName("fangjia_base", "seaweed_fence", "mongo.db.fangjia.com") +// +// +// public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") +// +// def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; +// DBCollection seaweed_fence100_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_fence", MONGO100_URL) +// +// public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + + static main(args) { + runBatch(new AddDistrictAddress(), args) + } + + @Override + public void process(Object args) { +// addNoAddressDist() //Ϊ²»¾«È·µÄµØÖ·Í¨¹ýµØÍ¼²¹³äµØÖ· +// mapOtherAddress() //Óо«È·µØÖ·µÄѰÕÒÆäËüµØÖ· + +// addressSelect() + addrUpdateToDB() + } + + + def addNoAddressDist(){ + // def citys = CommonDatautils.findAllCity() +// def index = 0 +// def allrets = [] +// for(def c : citys){ +// index ++ +// def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "estate_type2", "address"]) +// def noRoadInfoDists = noDetailRoadInfoDistricts(districts) +// println c +" "+index +" Ô­Ê¼Ð¡ÇøÁ¿£º"+districts.size() +" ÐèÐÂÔöµØÖ·Á¿£º"+noRoadInfoDists.size() +// noRoadInfoDists = baiduMatch(c, noRoadInfoDists) +// noRoadInfoDists = gaodeMatch(c, noRoadInfoDists) +// +// def rets = [] +// rets << ["id", "³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "µØÖ·", "°Ù¶ÈÔ­µØÖ·", "°Ù¶È±ê×¼µØÖ·", "¸ßµÂÔ­µØÖ·", "¸ßµÂ±ê×¼µØÖ·"] +// for(def d : noRoadInfoDists){ +// rets << [d._id.toString(), d.city, d.region, d.name, d.address, d.baidu_old_addr?d.baidu_old_addr:'',d.baidu_address?d.baidu_address:'', d.gaode_old_addr?d.gaode_old_addr:'', d.gaode_addr?d.gaode_addr:""] +// } +// allrets.addAll(rets) +// if(allrets.size()>50000){ +// ExcelUtils.write("D:\\Êý¾Ý\\Ð¡Çø\\Ð¡ÇøÄ£ºýµØÖ·²¹³ä"+index+".xlsx", allrets, "ÐÂÔöµØÖ·") +// allrets.clear() +// } +// } + updateDistAddr() + } + + + def mapOtherAddress(){ + def citys = CommonDatautils.findAllCity() + def index = 0 + def allrets = [] + for(def c : citys){ + index ++ + def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "estate_type2", "address", "addr_alias"]) + def radInfoDists = haveRoadInfoDistricts(districts) + println c +" "+index +" Ô­Ê¼Ð¡ÇøÁ¿£º"+districts.size() +" ÓÐÏêϸµØÖ·Á¿£º"+radInfoDists.size() + radInfoDists = baiduMatch(c, radInfoDists) + radInfoDists = gaodeMatch(c, radInfoDists) + + def rets = [] + rets << ["id", "³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "µØÖ·","µØÖ·±ðÃû", "°Ù¶ÈÔ­µØÖ·", "°Ù¶È±ê×¼µØÖ·", "¸ßµÂÔ­µØÖ·", "¸ßµÂ±ê×¼µØÖ·"] + for(def d : radInfoDists){ + def addr_alias_str = ''; + if(d.addr_alias){ + addr_alias_str = d.addr_alias.join(" ") + } + rets << [d._id.toString(), d.city, d.region, d.name, d.address, addr_alias_str,d.baidu_old_addr?d.baidu_old_addr:'',d.baidu_address?d.baidu_address:'', d.gaode_old_addr?d.gaode_old_addr:'', d.gaode_addr?d.gaode_addr:""] + } + allrets.addAll(rets) + if(allrets.size()>50000){ + ExcelUtils.write("D:\\Êý¾Ý\\Ð¡Çø\\Ð¡Çø¾«È·µØÖ·²¹³ä"+index+".xlsx", allrets, "²¹³äµØÖ·") + allrets.clear() + } + } + } + + def addressSelect(){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Ð¡Çø\\¾«È·µØÖ·²¹³ä-all-2.xlsx",{d-> + if(d['G']){ + d['O'] = AddressUtil.formatAddress(d['B'], d['G']) + } + if(d['I']){ + d['P'] = AddressUtil.formatAddress(d['B'], d['I']) + } + }) + } + + def addrUpdateToDB(){ + def updateDist = 0 + def addAddrCount = 0 + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Ð¡Çø\\¾«È·µØÖ·²¹³ä-Èë¿â-2.xlsx",{d-> + def dist = CommonDatautils.findDistrictById(d['A']) + if(dist){ + def oldAddrAliasCount = 0 + if(dist.addr_alias){ + oldAddrAliasCount = dist.addr_alias.size() + } + def new_addr_alias = null + if(d['K'].contains("ÐÂÔö°Ù¶ÈµØÖ·") || d['K'].contains("Ë«µØÍ¼ÐÂÔö")){ + new_addr_alias = getNewAddressAlias(d['L'], dist.address, dist.addr_alias) + } + if(d['K'].contains("ÐÂÔö¸ßµÂµØÖ·") || d['K'].contains("Ë«µØÍ¼ÐÂÔö")){ + new_addr_alias = getNewAddressAlias(d['M'], dist.address, dist.addr_alias) + } + if(new_addr_alias){ + updateDist++ + println updateDist + addAddrCount = addAddrCount + new_addr_alias.size()-oldAddrAliasCount + + def udata = new BasicDBObject() + udata.put("addr_alias", new_addr_alias) + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id', dist._id),new BasicDBObject('$set',udata)) + } + } + }) + println "ÐÞ¸ÄÐ¡ÇøÊý£º"+updateDist + println "ÐÂÔöµØÖ·Êý£º"+addAddrCount + } + + def getNewAddressAlias(new_addr, old_addr, dist_addr_alias){ + def arrs = new_addr.split(";") + def addr_alias = [] + if(dist_addr_alias){ + addr_alias = dist_addr_alias + } + for(def address : arrs){ + if(old_addr!=address && !addr_alias.contains(address)){ + addr_alias << address + } + } + return addr_alias + } + + def updateDistAddr(){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Ð¡Çø\\´ýÐÂÔöÐ¡ÇøµØÖ·.xlsx",{d-> + def dist = CommonDatautils.findDistrictById(d['A']) + if(dist){ + def udata = new BasicDBObject() + udata.put("address", d['J']) + def addr_alias = dist.addr_alias + if(!dist.addr_alias){ + addr_alias = [] + } + if(d['K'] && !addr_alias.contains(d['K'])){ + addr_alias << d['K'] + } + + if(addr_alias){ + udata.put("addr_alias", addr_alias) + } + DbUtils.seaweed.update(new BasicDBObject('_id', dist._id),new BasicDBObject('$set',udata)) + d['L'] = "ÒѸüÐÂ" + } + }) + } + + def noDetailRoadInfoDistricts(districts){ + def rets = [] + for(def d : districts){ + if(d.address){ + def flag = DataHandleUtils.isStandardRoad(d.address) + if(!flag){ + rets << d + } + }else{ + rets << d + } + } + return rets; + } + + def haveRoadInfoDistricts(districts){ + def rets = [] + for(def d : districts){ + if(d.address){ + def flag = DataHandleUtils.isStandardRoad(d.address) + if(flag){ + rets << d + } + } + } + return rets; + } + + def baiduMatch(city,districts){ + def data = fullCityMap.get(city) + def fullCityName = null + if(data){ + fullCityName = data.city + } + final CountDownLatch latch = new CountDownLatch(districts.size()) + + if(fullCityName){ + def totalCount = new AtomicLong() + for(def i=0;i1){ count++ - println count +" "+ d.city +" "+d.name + println count +" "+ d.city +" "+d.street } }else{ - println d.city + " "+d.name + println d.city + " "+d.street } if(index%1000==0){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy new file mode 100644 index 000000000..45d1c598a --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -0,0 +1,211 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.ccb.FileUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +import java.util.regex.Pattern + +class AddrAlaisProcess { + + DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) + def fullCityMap = CommonDatautils.queryFullNameCity() + + static main(args) { + def task = new AddrAlaisProcess() +// task.run() +// task.splitDist() +// task.addAddr() + task.nineApi() +// task.createResult() +// task.mergeResult() + } + + def splitDist(){ + def rows = ExcelUtils.read("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\È«Á¿Ð¡ÇøµØÖ·¼°µØÖ·±ðÃû.xlsx",0,1) + println "ԭʼ×ܼƣº"+rows.size() + def rets = [] + for(def d : rows){ + def addr = d['F'] + if(d['G']){ + addr = addr +","+d['G'] + } + + def addrs = addr.split(",") + for(def s : addrs){ + rets << [d['A'], d['B'], d['C'], d['D'], d['E'], s] + } + } + println "×ܼƣº"+rets.size() + FileUtils.batchCreateFileByCustomSuffix(rets, "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\ÓеØÖ·Ð¡ÇøµØÖ·±ê×¼»¯(Ò»ÐÐÒ»¸öµØÖ·).bat", null, "utf-8", false, " ",""); + } + + def addAddr(){ + def fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\ÎÞµØÖ·Ð¡Çø.xlsx" + ExcelUtils.multiThreadingModify(fileName,{d-> + def dist = CommonDatautils.findDistrictById(d['B']) + if(dist){ +// d['F'] = dist.address + if(dist.addr_alias){ + d['G'] = dist.addr_alias.join(",") + } + } + }) + } + + + def mergeResult(){ + def rets = ExcelUtils.read("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\ai-½á¹û-0221.xlsx",0,1) + def retMap = [:] + for(def r : rets){ + def num = r['B'].toString().toDouble().toInteger() + def list = retMap.get(num) + if(!list){ + list = new HashSet() + retMap.put(num, list) + } + if(r['C']){ + list << r['C'] + } + + } + def fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\Ð¡Çø±ðÃû-´ý¶¨.xlsx" + ExcelUtils.modify(fileName,{d-> + def num = d['A'].toString().toDouble().toInteger() + def aiList = retMap.get(num) + if(aiList){ + d['K'] = aiList.join(",") + } + }) + } + + def createResult(){ + def fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\Ð¡Çø±ðÃû-´ý¶¨.xlsx" + def results = [] +// results << ["ID", "³ÇÊÐ", "µØÖ·"] + ExcelUtils.modify(fileName,{d-> + def str = d['C'] + def addressList = str.split(",") + for(def addr : addressList){ + results << [d['A'].toString().toDouble().toInteger(), d['B'], addr] + } + }) + println results.size() + FileUtils.batchCreateFileByCustomSuffix(results, "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\ai-´ýÖ§ÐÐ.bat", null, "utf-8", false, " ",""); + } + + + def nineApi(){ + + def i = 0; + while(i<20) { + def fileName = "/home/goojia/gj/district/dist_addr_${i}.xlsx" + if (CommonDatautils.isWindow()) { + fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\dist_addr_0.xlsx" + } + File file=new File(fileName); + if(file.exists()){ + ExcelUtils.multiThreadingModify(fileName, {d-> + def addrMap = nineAddrSplit(d['D'], d['G']) + def addrList = [] + if(addrMap && addrMap.address){ + d['H'] = addrMap.road + d['I'] = addrMap.road_num + } + if(d['H']){ + def data = fullCityMap.get(d['D']) + if(data){ + def roadObj = findBaiduDatas( data.city, d['H']) + if(roadObj){ + d['J'] = "°Ù¶È´æÔÚ" + } + } + } +// if(d['F']){ +// def addrs = d['F'].split(",") +// def addr_alias = [] +// for(def addr : addrs){ +// def map = nineAddrSplit(d['B'], addr) +// if(map && map.address && DataHandleUtils.isStandardRoad(map.address)){ +// if(!addrList.contains(map.address)){ +// addrList << map.address +// addr_alias << map.address +// } +// } +// } +// d['I'] = addr_alias.join(",") +// } + }) + println fileName +" Íê³É " + } + i++ + } + + } + + def nineAddrSplit(city, addr){ + def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(city, addr) + def address = "" + def map = [:] + if (jsonObject) { + if (jsonObject.get("province") && jsonObject.get("province") != "null") { + map.province = jsonObject.get("province") + }else{ + map.province = "" + } + if (jsonObject.get("city") && jsonObject.get("city") != "null") { + map.city = jsonObject.get("city") + }else{ + map.city = "" + } + if (jsonObject.get("district") && jsonObject.get("district") != "null") { + map.district = jsonObject.get("district") + }else{ + map.district = "" + } + if (jsonObject.get("street") && jsonObject.get("street") != "null") { + address = jsonObject.get("street") + map.road = address + } + if (jsonObject.get("streetNumber") && jsonObject.get("streetNumber") != "null") { + address = address + jsonObject.get("streetNumber") + map.road_num = jsonObject.get("streetNumber") + } + map.address = address + } + return map + } + + def run(){ + def citys = CommonDatautils.findAllCity() + def rows = [] + citys.each{c-> + def districts = CommonDatautils.findAllDistricts(c, "district", ["city","region", "name","address", "addr_alias"]) + println c +" "+districts.size() + def num = 0 + for(def d : districts){ + num++ + def row = [num, d._id.toString(), d.city, d.region, d.name, d.address] + if(d.addr_alias){ + row << d.addr_alias.join(",") + } + rows << row + } + } +// ExcelUtils.write("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\Ð¡ÇøµØÖ·¼°µØÖ·±ðÃû±ê×¼»¯.xlsx", rows, "Ð¡Çø") + FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\Ð¡ÇøµØÖ·¼°µØÖ·±ðÃû±ê×¼»¯-20250402.bat", null, "utf-8", false, "#",""); + } + + def findBaiduDatas(city, name){ + def q = new BasicDBObject() + q.put("city", city) + q.put("name", name) + q.put('std_tag', Pattern.compile('^µÀ·')) + def obj = BAIDU_POI_COLL.findOne(q) + return obj; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy index 5367882e6..9d4bc3bb9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy @@ -4,6 +4,7 @@ import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.CosineSimilarAlgorithm import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils @@ -30,7 +31,10 @@ class AutoAddDistrictBatch extends BaseBatch{ def mcaDistMap = CommonDatautils.queryDistNameCityByMapping() static main(args) { - runBatch(new AutoAddDistrictBatch(), args) +// runBatch(new AutoAddDistrictBatch(), args) + + def task = new AutoAddDistrictBatch(); + task.checkMap() } @Override @@ -38,7 +42,7 @@ class AutoAddDistrictBatch extends BaseBatch{ //²éÕÒµÚÈý·½Æ¥ÅäûÓÐÆ¥ÅäÉϵÄÐ¡Çø def citys = CommonDatautils.findAllCity() def list = [] - list << ["³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "³É½»Á¿", "·¿Ô´Á¿", "°Ù¶ÈµØÍ¼", "¸ßµÂµØÍ¼"] + list << ["³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "³É½»Á¿", "·¿Ô´Á¿", "°Ù¶ÈµØÍ¼", "°Ù¶ÈÀàÐÍ","¸ßµÂµØÍ¼", "¸ßµÂÀàÐÍ"] for(def c : citys){ def noMatchDatas = findNoMatchResult(c) println c +" оÉË㷨δƥÅäµÄÊý¾ÝÁ¿£º"+noMatchDatas.size() @@ -48,11 +52,10 @@ class AutoAddDistrictBatch extends BaseBatch{ def fileName = "/home/goojia/gj/add_dist_info.xlsx" if (CommonDatautils.isWindow()) { - fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\µÚÈý·½´ýÈë¿âÊý¾Ý.xlsx" + fileName = "D:\\Êý¾Ý\\add_dist_info_1.xlsx" } ExcelUtils.write(fileName, list, "´ýÈë¿âÊý¾Ý") - check(fileName) } @@ -61,6 +64,11 @@ class AutoAddDistrictBatch extends BaseBatch{ def dists = CommonDatautils.findAllDistrictByName(d[0], d[1], d[2], "district") if(dists){ d['J'] = "¿âÖÐÒÑ´æÔÚ" + }else{ + dists = CommonDatautils.findDistrictByAlias(d[0], d[1], d[2], "district") + if(dists){ + d['J'] = "¿âÖбðÃûÖдæÔÚ" + } } }) } @@ -154,10 +162,10 @@ class AutoAddDistrictBatch extends BaseBatch{ } def findGaoDeDatas(city, region, name){ - String sql = "select name,type from amap_poi_detail where cityname='${city}' and adname='${region}' and MATCH(name, '${name}')" + String sql = "select name,type from amap_poi_2024 where cityname='${city}' and adname='${region}' and MATCH(name, '${name}')" def obj = null ElasticUtils.executeSqlQuery(sql,{ d-> - if(d.name == name && d.type.contains("סլ") ){ //&& d.shape + if(d.name == name){ //&& d.shape obj = d } }) @@ -250,8 +258,37 @@ class AutoAddDistrictBatch extends BaseBatch{ q.put("city", city) q.put("district", district) q.put("name", name) - q.put('std_tag', '·¿µØ²ú;×¡Õ¬Çø') +// q.put('std_tag', '·¿µØ²ú;×¡Õ¬Çø') def obj = BAIDU_POI_COLL.findOne(q) return obj; } + + + def checkMap(){ + ExcelUtils.modify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\д×ÖÂ¥\\д×ÖÂ¥´æÔÚÐÔÅжÏ-test.xlsx",{d-> + + def gaode_obj = findGaodeCount(d['B'], d['C'], d['D']) + if(gaode_obj){ + d['H'] = "ÊÇ" + d['I'] = gaode_obj.type + }else{ + def baidu_obj = findBaiduCount(d['B'], d['C'], d['D']) + if(baidu_obj){ + d['E'] = "ÊÇ" + d['F'] = baidu_obj.std_tag + } + } + +// def baidu_obj1 = findBaiduCount(d['B'], d['G'], d['H']) +// if(baidu_obj1){ +// d['M'] = "ÊÇ" +// } +// def gaode_obj1 = findGaodeCount(d['B'], d['G'], d['H']) +// if(gaode_obj1){ +// d['N'] = "ÊÇ" +// } +// def score = CosineSimilarAlgorithm.getSimilarityRatio(d['D'], d['H']); +// d['O'] = score + }) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy new file mode 100644 index 000000000..5f8062242 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddOfficeBatch.groovy @@ -0,0 +1,563 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.RegionData +import com.fangjia.script.BaseBatch +import com.fangjia.script.ccbevaluation.CcbCommonUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.util.CosineSimilarAlgorithm +import com.fangjia.script.util.DataUtil +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.GeoHelper +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import groovy.sql.Sql + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CopyOnWriteArraySet +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +class AutoAddOfficeBatch extends BaseBatch { + + def fullCityMap = CommonDatautils.queryFullNameByCity() + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206", 27020) + + //235Ϊ·¿¼ÛÍøÄÚ²¿¼ÆËã¾ù¼ÛµÄ¿â + def pgsqlInstance235 = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", + "postgres", "Goojia123456", "org.postgresql.Driver") + + static main(args) { +// runBatch(new AutoAddOfficeBatch(), args) + + def task = new AutoAddOfficeBatch() +// task.repeatOffice() + task.repeatDist() + } + + @Override + void process(Object args) { + +// def pattern = /[A-Z0-9]×ù|[0-9a-z]¶°|[A-Z]¶°|¡¤|\(½¨ÉèÖÐ\)|[0-9]ºÅÂ¥|\(×°ÐÞÖÐ\)|[A-Z]Â¥|[0-9]´±/ +// def newName = "¿ª·Å¹ã³¡".replaceAll(pattern, "") +// println newName +// findAddOfficeDatas() //²éÕÒÐèÒªÐÂÔöµÄд×ÖÂ¥Êý¾Ý +// checkInBaiduMapOffice()//²éѰÔڰٶȵØÍ¼ÉÏÓеÄд×ÖÂ¥Êý¾Ý +// addOffice()//ÐÂÔöд×ÖÂ¥ + + + } + + def findAddOfficeDatas() { + def citys = CommonDatautils.findAllCity() + def allAddOffices = [] + allAddOffices << ["µØÍ¼ID", "Ê¡", "ÊÐ", "Çø", "д×ÖÂ¥Ãû³Æ", "µØÖ·", "¾­¶È", "γ¶È", "Æ¥Åä³ÇÊÐ", "Æ¥ÅäÇøÓò", "Æ¥ÅäÃû³Æ", "Æ¥Å䷽ʽ"] + for (def c : citys) { + def cityObj = fullCityMap.get(c) + if (cityObj) { + def officeMaps = CommonDatautils.findOfficeByMap(cityObj.city, "ÉÌÎñд×ÖÂ¥") + officeMaps = filterOffice(officeMaps) + if (officeMaps) { + def offices = matchOffice(officeMaps) + + allAddOffices.addAll(offices) + } + } + } + ExcelUtils.write("D:\\Êý¾Ý\\¸ßµÂд×ÖÂ¥.xlsx", allAddOffices, "Êý¾Ý") + } + + def checkInBaiduMapOffice() { + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\¸ßµÂд×ÖÂ¥1.xlsx", { d -> + if (!d['L']) { + def obj = findBaiduDatas(d['C'], d['D'], d['E']) + if (obj) { + d['L'] = "°Ù¶È´æÔÚ" + d['M'] = obj.std_tag.toString() + } + } + + }, 0) + } + + def filterOffice(officeMaps) { + def offices = [] + def keys = [] + for (def o : officeMaps) { + if (!o) { + continue + } + if (o.name.startsWith("д×ÖÂ¥") || o.name.startsWith("×ÛºÏÂ¥") || o.name.contains("ÏúÊÛ") || o.name.startsWith("°ì¹«Â¥") || o.name.startsWith("¹«ÎñÂ¥") || o.name.startsWith("ÐÐÕþÂ¥") || o.name.startsWith("ÉÌÎñ°ì¹«Â¥") || o.name.startsWith("×ۺϰ칫¥")) { + println "[ ¹ýÂË ] " + o.city + " " + o.name + continue + } + if (o.name.contains("·д×ÖÂ¥")) { + println "[ ¹ýÂË ] " + o.city + " " + o.name + continue + } + + def pattern = /[A-Z0-9]×ù|[0-9a-z]¶°|[A-Z]¶°|¡¤|\(½¨ÉèÖÐ\)|[0-9]ºÅÂ¥|\(×°ÐÞÖÐ\)|[A-Z]Â¥|[0-9]´±/ + def newName = o.name.replaceAll(pattern, "") + o.name = newName + def keyName = o.city + "#" + o.district + "#" + o.name + if (!keys.contains(keyName)) { + offices << o + keys << keyName + } + } + println "Ô­£º" + officeMaps.size() + " Уº" + offices.size() + return offices + } + + def matchOffice(offices) { + + def addCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(offices.size()) + def total = offices.size() + def rets = new CopyOnWriteArrayList() + + for (def i = 0; i < offices.size(); i++) { + final def nmd = offices[i] + fixedThreadPool.execute(new Runnable() { + void run() { + try { + addCount.addAndGet(1) + + def office = matchDB(nmd) + if (!office) { + office = matchApi(nmd) + } + if (office) { + rets << [nmd.map_id, nmd.province, nmd.city, nmd.district, nmd.name, nmd.address, nmd.lng, nmd.lat, office.city, office.region, office.name, office.match_way] + println addCount.get() + "/" + total + " [success] " + office.get("region") + " " + office.get("name") + " " + office.match_way + } else { + rets << [nmd.map_id, nmd.province, nmd.city, nmd.district, nmd.name, nmd.address, nmd.lng, nmd.lat, "", "", "", ""] + println addCount.get() + "/" + total + " [fail] " + nmd.city + " " + nmd.name + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + latch.await() + return rets + } + + def matchDB(nmd) { + def simpleCity = RegionData.formatCity(nmd.city) + def simpleDistrict = RegionData.formatRegion(simpleCity, nmd.district) + if (simpleCity && simpleDistrict) { + def office = null + def rets = CommonDatautils.findDistrictList(simpleCity, simpleDistrict, nmd.name, "office") + if (rets) { + if (rets.size() >= 1) { + office = rets[0] + } + } else { + rets = CommonDatautils.findDistrictByAlias(simpleCity, simpleDistrict, nmd.name, "office") + if (rets && rets.size() >= 1) { + office = rets[0] + } else { + rets = CommonDatautils.findDistrictByAddress(simpleCity, simpleDistrict, nmd.name, "district") + if (rets && rets.size() >= 1) { + office = rets[0] + } + } + } + if (office) { + office.match_way = "Êý¾Ý¿â" + } + return office + } + return null + } + + def matchApi(nmd) { + def address = nmd.city + if (nmd.district) { + address = address + nmd.district + } + address = address + nmd.name + def jsonObject = FangjiaClientUtils.newMatch(nmd.city, address, "office", false) + if (!jsonObject) { + if (DataUtil.isPreciseAddress(nmd.address)) { + address = nmd.city + if (nmd.district) { + address = address + nmd.district + } + address = address + nmd.address + jsonObject = FangjiaClientUtils.newMatch(nmd.city, address, "office", false) + } + } + if (jsonObject) { + def udata = [:] + udata.put("_id", jsonObject.get("id")) + udata.put("city", jsonObject.get("city")) + udata.put("region", jsonObject.get("district")) + udata.put("name", jsonObject.get("name")) + udata.put("match_type", jsonObject.get("propertyType")) + udata.put("match_credit", jsonObject.get("credit")) + udata.put("match_way", "½Ó¿Ú") + return udata + } + return null + } + + def repeatOffice() { + def citys = CommonDatautils.findAllCity() + def allrets = [] + allrets << ["ID", "³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "µØÖ·", "¿ÉÒÉID", "¿ÉÒɳÇÊÐ", "¿ÉÒÉÇøÓò", "¿ÉÒÉÃû³Æ", "¿ÉÒɵØÖ·", "ÏàËÆ¶È", "¾àÀë"] + for (def c : citys) { + def offices = CommonDatautils.findAllDistricts(c, "office", ["city", "region", "name", "address", "lat", "lng"]) + def rets = checkRepeatOfficeBatch(offices) + println c + " " + offices.size() + allrets.addAll(rets) + } + ExcelUtils.write("D:\\Êý¾Ý\\д×ÖÂ¥\\ÖØ¸´¿ÉÒÉд×ÖÂ¥1.xlsx", allrets, "Êý¾Ý") + } + + def repeatDist(){ + def citys = CommonDatautils.findAllCity() + def allrets = [] + allrets << [ "³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "±ðÃû","¼ÆË㷽ʽ","µØÖ·","Ãû³ÆÏàËÆ¶È","µØÖ·ÏàËÆ¶È","×ÜÏàËÆ¶È"] + def index = 0 + for (def c : citys) { + index++ + if(["Äþ²¨","ÎÞÎý","Çൺ"].contains(c)){ + continue + } + def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "address", "alias"]) + def rets = checkRepeatDistrictBatch(c, districts) + println c + " " + districts.size() + allrets.addAll(rets) + println "${index}"+ c +" ÔËAÐÐÍê³É "+rets.size() + + if (CommonDatautils.isWindow()) { + ExcelUtils.write("D://Êý¾Ý//Ð¡Çø/ÖØ¸´¿ÉÒÉÐ¡Çø-${c}.xlsx", allrets, "Êý¾Ý") + }else{ + ExcelUtils.write("/home/goojia/gj/ÖØ¸´¿ÉÒÉÐ¡Çø-${c}.xlsx", allrets, "Êý¾Ý") + } + } + + + } + + def checkRepeatDistrictBatch(city,districts) { + def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() + def cityId = cityCodeDataMap.get(city) + + def fjwPriceMap = findNewFjwAvgPriceList(cityId, 202502) + def addCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(districts.size()) + def total = districts.size() + def rets = new CopyOnWriteArrayList() + def sets = new CopyOnWriteArraySet() + for (def i = 0; i < total; i++) { + final def o1 = districts[i] +// fixedThreadPool.execute(new Runnable() { +// void run() { + try { + addCount.addAndGet(1) +// if(!o1.name.contains("ËĹ«Ë¾")){ +// continue +// } + if(!sets.contains(o1._id.toString())){ + def similarRets = findListSimilar(o1, districts) + if (similarRets) { + def newPriceMap1 = fjwPriceMap.get(o1._id.toString()) + def new_price1 = null + if(newPriceMap1){ + new_price1 = newPriceMap1.calc_type + } + def ailas_str1 = "" + if(o1.alias){ + ailas_str1 = o1.alias.join(",") + } + def rows = [] + for(def similar : similarRets){ + if (!sets.contains(similar._id.toString())) { + sets.add(similar._id.toString()) + def ailas_str = "" + if(similar.alias){ + ailas_str = similar.alias.join(",") + } + def newPriceMap = fjwPriceMap.get(o1._id.toString()) + def new_price = null + if(newPriceMap){ + new_price = newPriceMap.calc_type + } + rows << [ similar.city, similar.region, similar.name, ailas_str,new_price, similar.address, similar.nameScore, similar.addrScore, similar.score] +// rets << [ similar.city, similar.region, similar.name, ailas_str,new_price, similar.address, similar.nameScore, similar.addrScore, similar.score] + } + } + if(rows){ + sets.add(o1._id.toString()) + rets << [ o1.city, o1.region, o1.name, ailas_str1,new_price1, o1.address, "Ö÷", "Ö÷", "Ö÷"] + rets.addAll(rows) + } + + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } +// } +// }); + } +// latch.await() + return rets + } + + def checkRepeatOfficeBatch(offices) { + def addCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(offices.size()) + def total = offices.size() + def rets = new CopyOnWriteArrayList() + def sets = new CopyOnWriteArraySet() + for (def i = 0; i < total; i++) { + final def o1 = offices[i] + fixedThreadPool.execute(new Runnable() { + void run() { + try { + addCount.addAndGet(1) + def maxObj = findOneSimilarOffice(o1, offices) + if (maxObj) { + if (!sets.contains(o1._id.toString())) { + sets.add(maxObj._id.toString()) + rets << [o1._id.toString(), o1.city, o1.region, o1.name, o1.address, maxObj._id.toString(), maxObj.city, maxObj.region, maxObj.name, maxObj.address, maxObj.score, maxObj.distance] + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + latch.await() + return rets + } + + def findListSimilar(o1, datas){ + def rets = new CopyOnWriteArrayList() + def ids = [] + ids << o1._id.toString() + for (def o2 : datas) { + if (o1._id.toString() != o2._id.toString() && o1.region==o2.region) { + +// if(!o2.name.contains("ËĹ«Ë¾")){ +// continue +// } + + def name1 = o1.name//.replace("Ð¡Çø","").replace("±ðÊû","") + def name2 = o2.name//.replace("Ð¡Çø","").replace("±ðÊû","") + def nameScore = CosineSimilarAlgorithm.levenshteinSimilarity(name1, name2); + def addrScore = null + if(o1.address && o2.address){ + addrScore = CosineSimilarAlgorithm.levenshteinSimilarity(o1.address, o2.address); + } + def str = null + if(o1.name.length() > o2.name.length()){ + str = o1.name.replace(o2.name, "") + }else{ + str = o2.name.replace(o1.name, "") + } + if (nameScore > 0.6 && !["Ò»ÆÚ","¶þÆÚ","ÈýÆÚ","ËÄÆÚ","ÎåÆÚ","ÁùÆÚ","ÆßÆÚ","°ËÆÚ","¾ÅÆÚ","Ê®ÆÚ","¶«Çø","Î÷Çø","ÄÏÇø","±±Çø","AÇø","BÇø","CÇø","DÇø"].contains(str)) { + o2.nameScore = nameScore + o2.addrScore = addrScore + o2.score = nameScore + rets << o2 + ids << o2._id.toString() + def maxObj = findMaxSimilar(ids, o2, datas) + while(maxObj){ + maxObj.nameScore = CosineSimilarAlgorithm.levenshteinSimilarity(maxObj.name, o1.name); + if(o1.address && maxObj.address){ + maxObj.addrScore = CosineSimilarAlgorithm.levenshteinSimilarity(o1.address, maxObj.address); + } + maxObj.score = maxObj.nameScore + rets << maxObj + ids << maxObj._id.toString() + maxObj = findMaxSimilar(ids, maxObj, datas) + } + } + } + } + + rets.sort{a,b-> + def a1 = a.score + def b1 = b.score + return b1.compareTo(a1) + } + + if (rets.size()>2) { + return rets[0..2] + } + return rets + } + + def findMaxSimilar(ids, o1, datas){ + def maxObj = null + def maxScore = -1000 + for (def o2 : datas) { + if (o1._id.toString() != o2._id.toString() && o1.region==o2.region && !ids.contains(o2._id.toString())) { + def name1 = o1.name//.replace("Ð¡Çø","").replace("±ðÊû","") + def name2 = o2.name//.replace("Ð¡Çø","").replace("±ðÊû","") + def nameScore = CosineSimilarAlgorithm.levenshteinSimilarity(name1, name2); + def addrScore = null + if(o1.address && o2.address){ + addrScore = CosineSimilarAlgorithm.levenshteinSimilarity(o1.address, o2.address); + } + def str = null + if(o1.name.length() > o2.name.length()){ + str = o1.name.replace(o2.name, "") + }else{ + str = o2.name.replace(o1.name, "") + } + if (nameScore > 0.6 && nameScore>maxScore && !["Ò»ÆÚ","¶þÆÚ","ÈýÆÚ","ËÄÆÚ","ÎåÆÚ","ÁùÆÚ","ÆßÆÚ","°ËÆÚ","¾ÅÆÚ","Ê®ÆÚ","¶«Çø","Î÷Çø","ÄÏÇø","±±Çø","AÇø","BÇø","CÇø","DÇø"].contains(str)) { + maxObj = o2 + o2.nameScore = nameScore + o2.addrScore = addrScore + o2.score = nameScore + } + } + } + + return maxObj + } + + def findOneSimilarOffice(o1, offices) { + def maxScore = 0 + def maxObj = null + for (def o2 : offices) { + if (o1._id.toString() != o2._id.toString()) { + double nameScore = CosineSimilarAlgorithm.getSimilarity(o1.name, o2.name); + double addrScore = CosineSimilarAlgorithm.getSimilarity(o1.address, o2.address); + if (nameScore + addrScore > maxScore) { + maxScore = nameScore + addrScore + maxObj = o2 + } + } + } + def distance = -1000 + if (o1.lat && maxObj && maxObj.lat) { + distance = GeoHelper.GetDistance(o1.lat / 10000000000.0, o1.lng / 10000000000.0, maxObj.lat / 10000000000.0, maxObj.lng / 10000000000.0) + } + if (maxObj) { + maxObj.distance = distance + maxObj.score = maxScore + return maxObj + } + return null + } + + + def findBaiduDatas(city, district, name){ + def q = new BasicDBObject() + q.put("city", city) + q.put("district", district) + q.put("name", name) +// q.put('std_tag', '·¿µØ²ú;×¡Õ¬Çø') + def obj = BAIDU_POI_COLL.findOne(q) + return obj; + } + + def addOffice(){ + ExcelUtils.modify("D:\\Êý¾Ý\\¸ßµÂ´ýÈë¿âд×ÖÂ¥.xlsx",{d-> + if(d['L']!='È˹¤É¾³ý'){ + def city = RegionData.formatCity(d['C']) + def region = RegionData.formatRegion(city, d['D']) + if(city && region){ + def locationstr = d['G'].toString()+","+d['H'].toString() + def bdpoint = FangjiaClientUtils.convert(locationstr, 1) + def udata = new BasicDBObject() + if(bdpoint){ + udata.put("lng2", (bdpoint[0]*10000000000).longValue()) + udata.put("lat2", (bdpoint[1]*10000000000).longValue()) + } + + udata.put("city", city) + udata.put("region", region) + udata.put("name", d['E']) + udata.put("address", d['I']) + udata.put("cat", "office") + udata.put("status", 0) + udata.put("c_date",new Date()) + udata.put("m_date",new Date()) + udata.put("lng", (d['G'].toString().toDouble()*10000000000).longValue()) + udata.put("lat", (d['H'].toString().toDouble()*10000000000).longValue()) + + def estate_type = null + if(d['M'] && d['M'].contains("Ô°Çø")){ + estate_type = "´´ÒâÔ°Çø" + } + + if(!estate_type && d['E'].contains("´´Òâ")){ + estate_type = "´´ÒâÔ°Çø" + } + if(estate_type){ + udata.put("estate_type2", estate_type) + } + + def markMap = [:] + markMap.put("data_source", "»úÆ÷Èë¿â") + udata.put("mark_map", markMap) + DbUtils.seaweed.save(udata) + println d['E'] +" "+udata._id.toString() + } + } + }) + } + + + def findNewFjwAvgPrice(def commid, def cityid){ + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" + def map = [:] + pgsqlInstance235.eachRow(sql, { r -> + map.avg_price = r.gujia_bds_clc_avprc + map.type = r.gujia_bds_clmtd + map.month = r.gujiabds_clc_yrmo_val + map.credit_value = r.gujia_bds_cfdc_dgr + if(r.gujia_bds_clmtd == 1){ + map.calc_type = "È˹¤¹ÀÖµ" + }else if(r.gujia_bds_clmtd == 2){ + map.calc_type = "Ñù±¾¼ÆËã" + }else if(r.gujia_bds_clmtd == 3){ + map.calc_type = "Éñ¾­ÍøÂç" + } + }) + return map + } + + def findNewFjwAvgPriceList(def cityid, date){ + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr,gujia_bds_id from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujiabds_clc_yrmo_val=${date}" + def retMap = [:] + pgsqlInstance235.eachRow(sql, { r -> + def map = [:] + map.avg_price = r.gujia_bds_clc_avprc + map.type = r.gujia_bds_clmtd + map.month = r.gujiabds_clc_yrmo_val + map.credit_value = r.gujia_bds_cfdc_dgr + if(r.gujia_bds_clmtd == 1){ + map.calc_type = "È˹¤¹ÀÖµ" + }else if(r.gujia_bds_clmtd == 2){ + map.calc_type = "Ñù±¾¼ÆËã" + }else if(r.gujia_bds_clmtd == 3){ + map.calc_type = "Éñ¾­ÍøÂç" + } + retMap.put(r.gujia_bds_id, map) + }) + return retMap + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy new file mode 100644 index 000000000..f122be3c0 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy @@ -0,0 +1,268 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.RegionData +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.lixue.util.DBUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.bson.types.ObjectId +import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest +import org.elasticsearch.action.update.UpdateRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.common.xcontent.XContentType + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +class BusinessQuarterProcess { + + def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() + def fullCityMap = CommonDatautils.queryFullNameCity() + DBCollection bk_map_bussiness_COLL = MongoUtils.getCollectionByName("crawl", "bk_map_sq", "192.168.0.206",27020) + + public static final DBCollection bk_business_coll = MongoUtils.getCollectionByName("fangjia_base", "bk_business", "mongo.db.fangjia.com") + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + def task = new BusinessQuarterProcess() + task.run() + } + def run(){ +// synchBusinessData() +// updateBusinessQuarter() +// addRegion() + synchBusinessToEs() + } + + def addRegion(){ + def list = CommonDatautils.queryRangeByCat("ÇøÓò") + println list.size() + def dbcursor = bk_business_coll.find(new BasicDBObject("_id", new ObjectId("67a318893b75f388c80979f2"))) + for(def d : dbcursor){ + if(d.district){ + continue + } + for(def regionShape : list){ + if(d.short_city!=regionShape.city_short){ + continue + } + def flag = InsidePolygon.isInArea(d.location.lon, d.location.lat, InsidePolygon.createPoint4(regionShape.shape.coordinates)) + if(flag){ + def udata = new BasicDBObject() + udata.put("district", regionShape.mzb_district_name) + udata.put("short_district", regionShape.district_short) + bk_business_coll.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + break + } + } + } + } + + def synchBusinessData(){ + def datas = bk_map_bussiness_COLL.find(new BasicDBObject("type", null)).toList() + synchMongoProcess(datas) + + } + + def synchMongoProcess(datas){ + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(datas.size()) + for(def i=0;i=100){ +// updateByEs(rows) +// rows.clear() +// } + updateByEs(d, index) + } + } + + def updateByEs(row, index){ + BulkRequest request = new BulkRequest(); + def client = ElasticUtils89.getClient("192.168.0.89") + int processedCount = 0; + + def id = row.get("_id").toString() + def doc = [:] + doc.put("province",row.province) + doc.put("short_province",row.short_province) + doc.put("city",row.city) + doc.put("short_city",row.short_city) + doc.put("district",row.district) + doc.put("short_district",row.short_district) + doc.put("name", row.name) + doc.put("location", row.location) + doc.put("bd_location", row.bd_location) + doc.put("shape", row.shape) + doc.put("bd_shape", row.bd_shape) + + + request.add(new IndexRequest("bk_business", "_doc", id).source(doc, XContentType.JSON)); + if (request.numberOfActions() >= 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "[${index}] Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); +// println "Processed " + processedCount + " documents" + } + } + + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index f722db94c..a6503133c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -5,21 +5,15 @@ import com.fangjia.core.util.GeoUtils import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.district.FangjiaClientUtils -import com.fangjia.script.gj.district.SeaweedDataMatchProcess import com.fangjia.script.linxsh.util.AddressUtil -import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject -import com.mongodb.Bytes import com.mongodb.DBCollection import net.sf.json.JSONObject -import org.apache.poi.ss.util.RegionUtil import org.bson.types.ObjectId -import org.joda.time.Instant -import java.time.format.DateTimeFormatter import java.util.regex.Pattern class DevProcess { @@ -64,6 +58,7 @@ class DevProcess { // task.deleteAddr() // task.deleteAddr2() task.synchDevTo100() +// task.statShape() // task.addNewDev2() // task.addAlias() @@ -77,7 +72,7 @@ class DevProcess { // println DateUtils.add("2024-7-24", 7); // task.addKfc() -// task.devToPark() //¿ª·¢ÇøÏÂÏ½Ô°Çø +// task.devToPark() //¿ª·¢ÇøÏÂϽ԰ // task.checkTown() // task.repeatSave() @@ -87,6 +82,9 @@ class DevProcess { // task.matchDevShape()//Æ¥Å俪·¢ÇøÎ§À¸ // task.addQiDevResult() //»ñÈ¡ÆëÁºÊý¾Ý½á¹û + +// task.updateDevShape()//Ð޸Ŀª·¢Çø½á¹¹ + } @@ -442,30 +440,33 @@ class DevProcess { } def matchDev(){ - ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢Çø\\ÐÂÅÜÊ¡·Ý\\½­ËÕÊ¡\\½­ËÕÊ¡-ÆëÁº´ýÅܵØÖ·.xlsx",{d-> - if(!d['B'] && d['A']){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢Çø\\¸ßÐÂÇø.xls",{d-> + if(!d['E'] && d['D']){ def q = new BasicDBObject() -// q.put("name", d['A']) -// q.put("city",d['G']) -// q.put('alias', new BasicDBObject('$in',[d['A']])) - def name = d['A'].replace('¾­¼Ã¼¼Êõ¿ª·¢Çø','¾­¼Ã¿ª·¢Çø') +// q.put("name", d['D']) + q.put("city",d['C']) +// q.put('alias', new BasicDBObject('$in',[d['D']])) + def name = d['D'] //.replace('¾­¼Ã¼¼Êõ¿ª·¢Çø','¾­¼Ã¿ª·¢Çø') q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //Ãû³Æ Ä£ºý²éѯ def obj = development_zone_CONN.findOne(q) if(obj){ - d['I'] = "¿âÖÐÓпª·¢Çø-ÏàËÆ2" + d['G'] = "ÏàËÆ" // d['K'] = obj.name // d['C'] = obj._id.toString() - d['B'] = obj.name -// if(obj.name == d['A']){ -// d['E'] = "Ïàͬ" + d['E'] = obj.name +// if(obj.name == d['D']){ +// d['G'] = "Ïàͬ" // }else{ -// d['E'] = "°üº¬" +// d['G'] = "°üº¬" // } + if(obj.shape){ + d['F'] = "ÊÇ" + } // d['E'] = "±ðÃû" // d['F'] = obj.name } } - },1); + },0); } def calAddrDistince(){ @@ -794,6 +795,18 @@ class DevProcess { development_zone_CONN.insert(rets) } + def statShape(){ + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find(new BasicDBObject("shape", new BasicDBObject('$exists', true))) + def index = 0 + for(def r : dbcursor){ + index ++ + def coordinates = r.shape.coordinates + println index+" "+r.name+" "+coordinates.size() + + + } + } + def matchDevAndAddAddress(){ ExcelUtils.modify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢Çø\\ÐÂÅÜÊ¡·Ý\\¸£½¨ÖØÇìÈ¥ÖØºóµØÖ·.xlsx",{d-> @@ -1148,4 +1161,26 @@ class DevProcess { } },0) } + + def updateDevShape(){ + def q = new BasicDBObject() + q.put("shape", new BasicDBObject('$exists', true)) + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find(q) + for(def d : dbcursor){ + if(d.name!="¸£Öݳ¤ÀÖ¹ú¼Ê»ú³¡×ۺϱ£Ë°Çø"){ + def udata = new BasicDBObject() + if(d.shape.coordinates){ + d.shape.coordinates = [d.shape.coordinates] + udata.put("shape", d.shape) + } + if(d.bd_shape && d.bd_shape.coordinates){ + d.bd_shape.coordinates = [d.bd_shape.coordinates] + udata.put("bd_shape", d.bd_shape) + } + def updateQuery = new BasicDBObject("_id",d._id) + DEVELOPMENT_ZONE_43_COLL.update(updateQuery, new BasicDBObject('$set',udata)) + } + + } + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy new file mode 100644 index 000000000..f37e917d2 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy @@ -0,0 +1,113 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.util.ExcelUtil +import com.fangjia.script.gj.ProxyHttpUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import net.sf.json.JSONObject +import org.apache.commons.io.FileUtils + +class DevQlCheck { + + //http://146.56.217.44:8088/uams/index + String targetUrl = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + static main(args) { + def task = new DevQlCheck() + task.run() + } + + def run(){ + def devName = "¸£½¨Áúº£¾­¼Ã¿ª·¢Çø" + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(new BasicDBObject("name",devName)) + def pois = readCSV("C:\\Users\\gaojuan\\Downloads\\ÕÄÖÝÊÐPOI.csv") + def devPois = [] + devPois << ["Ê¡", "³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "µØÖ·", "ÀàÐÍ", "¾­¶È", "γ¶È", "ÆëÁº¿ª·¢Çø"] + for(def poi : pois){ + def flag = InsidePolygon.isInArea(poi.lng.toString().toDouble(), poi.lat.toString().toDouble(), InsidePolygon.createPoint4(obj.shape.coordinates)) + if(flag){ + devPois << [poi.province, poi.city, poi.district, poi.name, poi.address, poi.cat, poi.lng, poi.lat] + } + } + println "¹²£º"+devPois.size()+" ¸ö" + ExcelUtils.write("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢ÇøÍâ°ü\\${devName}poiÆëÁºÐ£Ñé.xlsx", devPois, "ÆëÁº¿ª·¢Çø") + def index = 0 + ExcelUtils.modify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢ÇøÍâ°ü\\${devName}poiÆëÁºÐ£Ñé.xlsx",{d-> + def address = d['B']+d['C']+d['D'] +// if(d['E']){ +// address = address + d['E'] +// } + Thread.sleep(3000) + def s = getQlResult(address) + d['I'] = s + index ++ + println index+" "+ s + }) + + + } + + def getQlResult(address){ + def params = [ + 'address': address, + 'type': '1' //1£º¶Ô¹« 0£º¶Ô˽ + ] + try{ + def str = ProxyHttpUtils.getProxyResult(targetUrl, params); + println address +" "+ str + JSONObject result = JSONObject.fromObject(str) + if(result && result.code==20000){ + def data = result.data + if(data){ + def list = data.indusParkList + if(list && list!="null"){ + def s = "" + for(def r : list){ + s = s + r.indusParkName +"-"+r.indusParkLevel+"\n" + } + return s + } + } + } + }catch(Exception e){ + println address +" "+e.getMessage() + } + + return null + } + + + def readCSV(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + for(line in lines) { + if(line){ + String[] arrs = line.split("\\|@\\|") + def o = new BasicDBObject() + try{ + o.put("province", arrs[0]) + o.put("city", arrs[1]) + o.put("district", arrs[2]) + o.put("name", arrs[3]) + o.put("township", arrs[4]) + o.put("address", arrs[5]) + o.put("cat", arrs[6]) + o.put("lng", arrs[7]) + o.put("lat", arrs[8]) + o.put("data_source", arrs[9]) + rets << o + }catch(Exception e){ + println filename+" ÎļþÒì³£" + } + + } + + } + return rets; + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy index 49d2547b7..671266e38 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy @@ -7,7 +7,6 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -import com.rabbitmq.client.AMQP import net.sf.json.JSONObject import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse @@ -34,8 +33,8 @@ class DevUpdateTestBatch { static main(args) { def task = new DevUpdateTestBatch() def path = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\¿ª·¢Çø\\¿ª·¢Çø-Ô°Çø.xlsx"//¿ª·¢Çø-Ô°Çø.xlsx -// task.addDev(path) - task.addDevAddress(path) + task.addDev(path) +// task.addDevAddress(path) // // task.updateHasGov("н®Î¬Îá¶û×ÔÖÎÇø","¿¦Ê²µØÇø","Âó¸ÇÌáÏØ", "Âó¸ÇÌáÕò", "ÊÇ") @@ -168,7 +167,7 @@ class DevUpdateTestBatch { println d['A'] +" ²»´æÔÚ" } } - },2) + },1) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy index ee54817e6..8a5fc6eec 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy @@ -1,12 +1,14 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData +import com.fangjia.core.util.BaiDuApiUtils import com.fangjia.script.ccbevaluation.CcbCommonUtils import com.fangjia.script.ccbevaluation.PgsqlCommUtils import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.EsSearchUtils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils @@ -28,14 +30,24 @@ class GXDdistrictMatch { static main(args) { def task = new GXDdistrictMatch(); // task.run() - task.addOldMatch2() +// task.addOldMatch2() // task.runDb() +// task.hainanMatch() // task.updateDistStatus()//»Ö¸´name_cat²»Õý³£Êý¾Ý // task.saveToDB() //±£´æÐÂÔöÐ¡Çø // task.restoreDist()//»Ö¸´Ð¡Çøstatus=0 // task.runMatch() + +// task.checkDist() + + task.addPrice() + + } + + def addPrice(){ + addPrice(row['K'],row['L'],row['M'], row['T'], DateUtils.parseFromTightByPattern('2023-10-01','yyyy-MM-dd'),DateUtils.parseFromTightByPattern('2023-10-25','yyyy-MM-dd')) } def addOldMatch(){ @@ -94,6 +106,46 @@ class GXDdistrictMatch { } + def hainanMatch(){ + def fileName = "D:\\Êý¾Ý\\Ð¡Çø\\º£ÄÏδƥÅ䵨ַ-1.xlsx" + ExcelUtils.multiThreadingModify(fileName, { d -> + if(d['D'] && d['F'] ){// +// def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(null, d['I']) +// if(jsonObject){ +//// if(jsonObject.get("district") && jsonObject.get("district")!='null'){ +//// d['AO'] = jsonObject.get("district") +//// } +// if(jsonObject.get("province") && jsonObject.get("province")!="null"){ +// d['AP'] = jsonObject.get("province") +// } +// if(jsonObject.get("city") && jsonObject.get("city")!="null"){ +// d['AI'] = jsonObject.get("city") +// } +// } + def formatCity = RegionData.formatCity(d['F']) + def fullCityObj = fullCityMap.get(formatCity) + if(fullCityObj){ +// def fullRegion = regionCodeDataMap.get(d['A']+"#"+d['E']) + + def obj = findDatasByCityAndName(formatCity, d['D'].replaceAll('[¡¤\\(\\)£¨£©]|¡¤', '')) + if(obj){ + d['U'] = "Â¥ÅÌץȡ¿â" + d['V'] = obj.city + d['W'] = obj.region + d['X'] = obj.name + d['Y'] = obj.property_type + d['Z'] = obj.address + def loc = obj.location + if(loc){ + d['AA'] = loc.x + d['AB'] = loc.y + } + } + } + } + }) + } + def runDb(){ def fileName = "D:\\Êý¾Ý\\¹úÐÅ´ï\\¹úÐÅ´ï11³ÇδƥÅäÊý¾Ý.xlsx" ExcelUtils.modify(fileName, { d -> @@ -238,43 +290,41 @@ class GXDdistrictMatch { def saveToDB(){ // def fileName = "D:\\Êý¾Ý\\¹úÐÅ´ï\\¹úÐÅ´ï11³ÇδƥÅäÊý¾Ý.xlsx" - def fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\¶«Ý¸Î´Æ¥Åä³É½»Êý¾Ý.xlsx" + def fileName = "D:\\Êý¾Ý\\Ð¡Çø\\º£ÄÏÐÂÔöÐ¡Çø.xlsx" ExcelUtils.modify(fileName, { d -> - if(d['A']){ + if(d['A'] && d['C']){ def udata = new BasicDBObject() udata.put("city", d['A']) udata.put("region", d['B']) def name = d['C'].replaceAll('[¡¤\\(\\)£¨£©]|¡¤', '').replace("½¨ÉèÖÐ", "") udata.put("name", name) - def alias = [] - if(d['G'] && name!=d['G']){ - alias << d['G'] - } +// def alias = [] +// if(d['G'] && name!=d['G']){ +// alias << d['G'] +// } // if(d['AI'] && !alias.contains(d['AI']) && d['AI']!=name){ // alias << d['AI'] // } - if(alias){ - udata.put("alias", alias) - } +// if(alias){ +// udata.put("alias", alias) +// } - def addr = AddressUtil.formatAddress(d['A'], d['D']) + def addr = AddressUtil.formatAddress(d['A'], d['E']) if(addr){ udata.put("address", addr) } - udata.put("status", "0") - udata.put("name_cat", "0") + udata.put("status", 0) + udata.put("name_cat", 0) udata.put("cat", "district") - udata.put("username", "¸ß¾ê") +// udata.put("username", "¸ß¾ê") def estateType2 = "ÆÕͨסլ" def type = "" -// if(d['AH']){ -// type = d['AH'] -// }else{ -// type = d['Y'] -// } + if(d['D']){ + type = d['D'] + } if(type){ if(type.contains("±ðÊû")){ estateType2 = "±ðÊû" @@ -282,26 +332,50 @@ class GXDdistrictMatch { estateType2 = "ÉÌס" } } - udata.put("estateType2", estateType2) + udata.put("estate_type2", estateType2) + if(d['F']){ Long lng = d['F']*10000000000 - udata.put("lng", lng) - } - if(d['E']){ - Long lat = d['E'] * 10000000000 + Long lat = d['G'] * 10000000000 udata.put("lat", lat) - } - - def s = FangjiaClientUtils.saveOrUpdateDistrict(udata) - def opt = "add" - if(s && s=='³É¹¦'){ - saveOptLog(udata.city, udata.region, udata.name, opt) + udata.put("lng", lng) + // ¸ßµÂת°Ù¶È + def baidu = BaiDuApiUtils.geoconv(d['F'].toString().toDouble(), d['G'].toString().toDouble(), 3) + def lng2 = baidu.x + def lat2 = baidu.y + if(lng2){ + Long lng2_new = lng2 *10000000000L + Long lat2_new = lat2 *10000000000L + udata.put("lng2", lng2_new) + udata.put("lat2", lat2_new) } } + udata.put("c_date", new Date()) + udata.put("m_date", new Date()) + def markMap = [:] + markMap.put("data_source", "»úÆ÷Èë¿â") + udata.put("mark_map",markMap) +// udata.put("is_new", 0) + DbUtils.seaweed.save(udata) + saveOptLog(udata.city, udata.region, udata.name, "add") +// def s = FangjiaClientUtils.saveOrUpdateDistrict(udata) + println name +// def opt = "add" +// if(s && s=='³É¹¦'){ +// saveOptLog(udata.city, udata.region, udata.name, opt) +// } + } }) } + def checkDist(){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Ð¡Çø\\º£ÄÏδƥÅ䵨ַ-1.xlsx", { d -> + if(d['V'] && d['W'] && d['X']){ + matching(d['V'], d['W'], d, d['X'], null, null) + } + }) + } def match(city, region, d){ d = matching(city, region, d, d['C'].replaceAll('[¡¤\\(\\)£¨£©]|¡¤', ''), d['D'], "") @@ -391,7 +465,7 @@ class GXDdistrictMatch { if(rets && rets.size()>=1){ d = setRowValue(rets[0], d, "Ãû³ÆÔÚµØÖ·ÖÐ"+str) }else{ - if (d['D']) { + if (d['D'] && alias) { rets = CommonDatautils.findDistrictByAlias(city, region, alias.replaceAll('[¡¤\\(\\)£¨£©]|¡¤', ''), "district") if (rets) { if (rets.size() >= 1) { @@ -449,14 +523,14 @@ class GXDdistrictMatch { def setRowValue(dbo, d, remark){ if (dbo) { - d['V'] = dbo.city - d['W'] = dbo.region - d['X'] = dbo.name - d['Y'] = dbo.estate_type2 - d['Z'] = dbo.status - d['AA'] = dbo.name_cat - d['U'] = remark - d['AH'] = dbo.address +// d['V'] = dbo.city +// d['W'] = dbo.region +// d['X'] = dbo.name +// d['Y'] = dbo.estate_type2 + d['AK'] = dbo.status +// d['AA'] = dbo.name_cat + d['AJ'] = remark +// d['AH'] = dbo.address } return d; } @@ -510,6 +584,33 @@ class GXDdistrictMatch { return null; } + + def findDatasByCityAndName(def city, def name){ + def sql = "select * from community where city='${city}' and name='${name}'" + def rets = [] + ElasticUtils.executeSqlQuery(sql, { d-> + rets << d + println d.property_type + }) + + if(rets){ + def obj = null + for(def r : rets){ + if(r.property_type && (r.property_type.contains("סլ") || r.property_type.contains("±ðÊû") || r.property_type.contains("¹«Ô¢"))){ + obj = r + break + } + } + if(obj){ + return obj; + }else{ + return rets[0]; + } + + } + return null; + } + def saveOptLog(city, region, name, type){ def obj = new BasicDBObject(); obj.put("city",city); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy index 1c94475bc..99b05841f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy @@ -5,10 +5,8 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -import com.rabbitmq.client.impl.AMQImpl import java.util.regex.Pattern - /** * Ãû¼¼¯ */ @@ -31,12 +29,13 @@ class MinglujiData { } def run(){ - def prov = "ºÓ±±Ê¡" - def city = "ʯ¼ÒׯÊÐ" + def prov = "½­ËÕÊ¡" + def city = "ÎÞÎý" + exportDatas(city) // exportDatas(city) // matchDev(prov, city) // matchCommunity(city) - fiveLevelSplit(city) +// fiveLevelSplit(city) // nineLevelSplit(city) // tempMatchDev(prov) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 822eee441..ea28d2c0b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -1,5 +1,6 @@ package com.fangjia.script.gj.data_handle +import com.fangjia.core.util.GeoUtils import com.fangjia.script.BaseBatch import com.fangjia.script.BatchOwner import com.fangjia.script.Watcher @@ -8,13 +9,19 @@ import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.ProvinceData +import com.mongodb.BasicDBObject +import org.apache.commons.io.FileUtils import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse import org.elasticsearch.action.index.IndexRequest import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders +import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService @@ -39,12 +46,13 @@ class NewGaoDePoiBatch extends BaseBatch{ @Override void process(Object args) { - run() +// run() + oldPoiMagre() } def run(){ if (CommonDatautils.isWindow()) { - TAGS = getAllPoiType("D:\\Êý¾Ý\\¸£½¨Ê¡_POI_GCJ02_20240630\\POI·ÖÀà°×Ãûµ¥.xlsx") + TAGS = getAllPoiType("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Poi\\POI·ÖÀà°×Ãûµ¥.xlsx") }else{ TAGS = getAllPoiType("/home/goojia/gj/POI_TYPES.xlsx") } @@ -145,6 +153,7 @@ class NewGaoDePoiBatch extends BaseBatch{ saveObj.data_id = map.map_id saveObj.data_source = "¸ßµÂµØÍ¼" saveObj.data_source_year = "2024-11" + saveObj.parent_id = map.parent_id if(saveObj.cat && TAGS.contains(saveObj.cat)){ saveObj.status = 0 @@ -314,7 +323,7 @@ class NewGaoDePoiBatch extends BaseBatch{ rows.each{map-> // def map = rows.get(key) - request.add(new IndexRequest("didata_map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); // ÅúÁ¿Ìá½»Êý¾Ý if (request.numberOfActions() >= batchSize) { @@ -346,4 +355,177 @@ class NewGaoDePoiBatch extends BaseBatch{ } + def oldPoiMagre(){ + def cityList = CommonDatautils.findFullNameCitys().reverse() + def index = 0 + for(def cityObj : cityList){ + index ++ + if(index <291){ + continue + } + def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\Êý¾Ý\\merge_poi\\${cityObj.city}.csv" + } + println fileName + File file=new File(fileName); + if(file.exists()){ + def results = readCSV(fileName) + println "ÔËÐгÇÊУº"+cityObj.province+" " +cityObj.city+" "+results.size() + if(results){ + def megerMap = poiRepeat(cityObj.city, results) + println "´ý±£´æ£º" + cityObj.city +" "+megerMap.size() + save(megerMap.values()) + } + }else{ + println fileName +" ²»´æÔÚ" + } + } + } + + + def poiRepeat(city, oldPois){ + def rets = new ConcurrentHashMap() + + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(oldPois.size()) + def townMap = CommonDatautils.queryTownByCity(city) + def esMap = findEsPoiByCity(city) + + println "Es ¼ÓÔØÍê³É£º"+new Date().format("yyyy-MM-dd HH:mm:ss") + for(def i=0;i + def district = "¼ÎÓø¹ØÊÐ" + if(d.district){ + district = d.district + } + def regionMap = map.get(district) + if(!regionMap){ + regionMap = new HashMap() + } + def o = new BasicDBObject() + o.put("city", d.city) + o.put("district", district) + o.put("name", d.name) + o.put("township", d.township) + o.put("location", d.location) + regionMap.put(d.name.replace("-","").replace("¡¤",""), o) +// map.put(district, regionMap) + map.put(district, regionMap) + }) + return map + } + + + def readCSV(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + for(line in lines) { + if(line){ + String[] arrs = line.split("\\|@\\|") + def o = new BasicDBObject() + o.put("province",arrs[0]) + o.put("city" , arrs[1]) + o.put("district",arrs[2]) + o.put("name",arrs[3]) + o.put("township",arrs[4]) + o.put("address",arrs[5]) + o.put("cat",arrs[6]) + o.put("type",arrs[7]) + o.put("secondary_type",arrs[8]) + o.put("small_type" ,arrs[9]) + if(arrs[10]){ + o.put("data_id",arrs[10]) + }else{ + o.put("data_id",arrs[11]) + } + + o.put("spell_name",arrs[12]) + def location = [:] + if(arrs[13]){ + location.lon = arrs[13].toString().toDouble() + location.lat = arrs[14].toString().toDouble() + } + o.put("location",location) + o.put("data_source",arrs[15]) + o.put("status",arrs[16]) + o.put("version",arrs[17]) + rets << o + } + } + return rets; + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewPoiData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewPoiData.groovy new file mode 100644 index 000000000..767209f83 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewPoiData.groovy @@ -0,0 +1,175 @@ +package com.fangjia.script.gj.data_handle + + +import com.fangjia.core.util.BaiDuApiUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.DataUtil +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.GeoHelper +import com.mongodb.BasicDBObject + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +class NewPoiData { + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + def task = new NewPoiData() + task.run() + } + def run(){ +// export() +// exportNetWorkOffice() +// matchByCity() +// noMatchData() + calcuteDistance() + } + + def noMatchData(){ + ExcelUtils.multiThreadingModify("d:\\Êý¾Ý\\δƥÅäд×ÖÂ¥2.xlsx", { d -> + if(d['H']!='µØÍ¼'){ + def map = CommonDatautils.findOneThirdNetWorkOffice(d['A'], d['B'], d['C']) + if(map){ + d['E'] = map.lng + d['F'] = map.lat + } + } + }) + } + def matchByCity(){ + ExcelUtils.multiThreadingModify("d:\\Êý¾Ý\\Èë¿âд×ÖÂ¥.xlsx",{d-> + def jsonObject = FangjiaClientUtils.newMatch(d['A'], d['A']+d['B']+d['C'], "office", false) + def formatAddress = null + if(d['D']){ + formatAddress = AddressUtil.formatAddress(d['A'], d['D']) + d['G'] = formatAddress + } + if(!jsonObject && formatAddress){ + if(DataUtil.isPreciseAddress(formatAddress)){ + def address = d['A'] + if(d['B']){ + address = address + d['B'] + } + address = address + formatAddress + jsonObject = FangjiaClientUtils.newMatch(d['A'], address, "office", false) + } + } + if(jsonObject) { + d['H'] = jsonObject.get("id") + d['I'] = jsonObject.get("city") + d['J'] = jsonObject.get("district") + d['K'] = jsonObject.get("name") + d['L'] = jsonObject.get("propertyType") + d['M'] = jsonObject.get("credit") + } + }) + } + + + def export(){ + def rets = [] + rets << ["³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "µØÖ·", "¾­¶È", "γ¶È"] + rets.addAll(CommonDatautils.findNewPoiDatas()) + ExcelUtils.write("d:\\Êý¾Ý\\poiд×ÖÂ¥.xlsx", rets, "д×ÖÂ¥") + } + + def exportNetWorkOffice(){ + def rets = [] + rets << ["³ÇÊÐ", "ÇøÓò", "Ãû³Æ", "µØÖ·", "¾­¶È", "γ¶È"] + rets.addAll(CommonDatautils.findThirdNetWorkOffice()) + ExcelUtils.write("d:\\Êý¾Ý\\poiд×ÖÂ¥-ÍøÕ¾.xlsx", rets, "д×ÖÂ¥") + } + + def calcuteDistance(){ + ExcelUtils.multiThreadingModify("d:\\Êý¾Ý\\д×ÖÂ¥²âÊÔ-1118-ÐÂÔö.xlsx", { d -> + if(d['F']){ + if(d['A'].contains("±±¾©")){ + def distance = GeoHelper.GetDistance(d['F'].toString().toDouble(), d['E'].toString().toDouble(), 39.996743, 116.481075) + d['K'] = distance + }else if(d['A'].contains("ÑĮ̀")){ + def distance = GeoHelper.GetDistance(d['F'].toString().toDouble(), d['E'].toString().toDouble(), 37.459645, 121.438616) + d['K'] = distance + } + } + }, 1) + } + + + + + def addDistrict(){ + def path = "D:\\Êý¾Ý\\Èë¿âд×ÖÂ¥.xlsx" + def keys = new CopyOnWriteArrayList() + def index = 0 + ExcelUtils.modify(path, { d-> + def city = d['A'] + def region = d['B'] + def name = d['C'] + + def formatAddress = null + def address = d['D'] + if(address){ + if(d['G']){ + formatAddress = AddressUtil.formatAddress(city, address) + } + if(!formatAddress){ + if(address.contains("½»²æ¿Ú")){ + formatAddress = address.substring(0, address.toString().indexOf("½»²æ¿Ú")+3) + }else if(address.contains("½»²æ")){ + formatAddress = address.substring(0, address.toString().indexOf("½»²æ")+2) + } + } + } + + Long glat = null + Long glng = null + Long blat = null + Long blng = null + if(d['K']){ + glat = d['L'].toString().toDouble() * 10000000000L + glng = d['K'].toString().toDouble() * 10000000000L + def baidu = BaiDuApiUtils.geoconv(d['K'].toString().toDouble(), d['L'].toString().toDouble(), 3) + blng = baidu.x * 10000000000L + blat = baidu.y * 10000000000L + } + + def estateType2 = "ÆÕͨסլ" + def key = city+"##"+region+"##"+name + if(name && !keys.contains(key)){ + def dist = CommonDatautils.findDistrict(city, region, name, "district") + if(!dist){ + keys << key + def data = new BasicDBObject(); + data.put("name_cat",0) + data.put("status",0) + data.put("cat","office") + data.put("c_date", new Date()) + data.put("m_date", new Date()) + data.put("city", city) + data.put("region",region) + data.put("name", name) + data.put("estate_type2",estateType2) + data.put("address", formatAddress) + if(glat){ + data.put("lat",glat) + data.put("lng",glng) + data.put("lat2",blat) + data.put("lng2",blng) + } + def markMap = [:] + markMap.put("data_source", "»úÆ÷Èë¿â") + data.put("mark_map",markMap) + index++ + DbUtils.seaweed.save(data); + println index+" "+data + } + } + },0) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy index c5ea6d76d..bf7a84c06 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy @@ -1,22 +1,20 @@ package com.fangjia.script.gj.data_handle -import com.fangjia.script.BaseBatch -import com.fangjia.script.BatchOwner -import com.fangjia.script.Watcher + import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.util.ExcelUtils -@BatchOwner(Watcher.GaoJuan) -class PoiNineSplitBatch extends BaseBatch{ +class PoiNineSplitBatch{ - static main(args) { - runBatch(new PoiNineSplitBatch(), args) + public static void main(args) { + def task = new PoiNineSplitBatch() + task.run() } - @Override - void process(Object args) { - run() - } +// @Override +// void process(Object args) { +// run() +// } def run(){ def i = 0; while(i<360) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy index abce57fe0..e6a6feaa8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionStandardBatch.groovy @@ -4,9 +4,12 @@ import com.fangjia.core.RegionData import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils import com.mongodb.BasicDBObject import org.apache.commons.io.FileUtils +import org.bson.types.ObjectId import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.update.UpdateRequest import org.elasticsearch.client.RequestOptions @@ -31,12 +34,16 @@ class RegionStandardBatch extends BaseBatch{ @Override void process(Object args) { + seaweedRegionStandard() +// poiRegionStandard() // seaweedRegionStandard() - poiRegionStandard() +// poiRegionStandard() + //ͨ¹ýÏçÕò½ÖµÀÐÞ¸ÄÇøÓò È磺¶«Ý¸ÊÐ +// updateRegionByTown() } def seaweedRegionStandard(){ - seaweedRegionStandardByCat("district") + seaweedRegionStandardByCat("office") } def poiRegionStandard(){ @@ -93,7 +100,7 @@ class RegionStandardBatch extends BaseBatch{ def seaweedRegionStandardByCat(cat){ - def citys = CommonDatautils.findAllCity() + def citys = ["ÒÁ´º"]//CommonDatautils.findAllCity() for(def city : citys){ def rMap = regionMap.get(city) @@ -148,8 +155,12 @@ class RegionStandardBatch extends BaseBatch{ def streetMap = CommonDatautils.queryAllStreetNameByCity(fullCityName) if(streetMap){ set = streetMap.keySet() - def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name"]) + def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name","lng","lat"]) + println city +" "+ districts.size() + def index = 0 for(def d : districts){ + index ++ + println index +" "+ d.region if(set.contains(d.region)){ continue } @@ -157,8 +168,12 @@ class RegionStandardBatch extends BaseBatch{ def updateRegion = null def flag = null for(def key : set){ - def alias = streetMap.get(key) - if((alias && alias.contains(d.region)) || (!alias && key.contains(d.region))){ + def obj = streetMap.get(key) + def alias = null + if(obj && obj.alias){ + alias = obj.alias + } + if((alias && alias.contains(d.region)) || (!alias && key==d.region)){ def newRegion = RegionData.formatRegion(d.city, key) if(newRegion!=d.region){ updateRegion = newRegion @@ -166,13 +181,26 @@ class RegionStandardBatch extends BaseBatch{ flag = "pass" break; } + + if(obj.shape){ + def inAreaFlag = InsidePolygon.isInArea(d.lng/10000000000.0, d.lat/10000000000.0, InsidePolygon.createPoint4(obj.shape.coordinates)) + if(inAreaFlag){ + def newRegion = obj.street + newRegion = RegionData.formatRegion(d.city, newRegion) + if(newRegion!=d.region){ + updateRegion = newRegion + } + flag = "pass" + break; + } + } } if(updateRegion){ def udata = new BasicDBObject() udata.put("region", updateRegion) udata.put("m_date", new Date()) println d.city +" "+d.region+" "+d.name +" ÇøÓòÐÞ¸ÄΪ£º"+updateRegion -// DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) }else{ if(flag!="pass"){ def udata = new BasicDBObject() @@ -402,4 +430,27 @@ class RegionStandardBatch extends BaseBatch{ return rets; } + def updateRegionByTown(){ + ExcelUtils.modify("d:\\Êý¾Ý\\³ÇÊÐÓëÇøÓòÏàͬд×ÖÂ¥.xlsx",{d-> + def town = RegionData.formatRegion(d['B'], d['F']) + if(town){ + + def obj = CommonDatautils.findDistrict(d['B'], town, d['E'], "office") + if(!obj){ + def udata = new BasicDBObject() + udata.put("region", town) + udata.put("m_date", new Date()) + println d['F']+" "+" ÇøÓòÐÞ¸ÄΪ£º" + town + DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId(d['A'])), new BasicDBObject('$set', udata)) + }else{ + def udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("status", 1) + println d['F']+" "+" ɾ³ý£º" + town + DbUtils.seaweed.update(new BasicDBObject("_id", new ObjectId(d['A'])), new BasicDBObject('$set', udata)) + } + + } + }) + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy index 6fce88fa6..748447212 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy @@ -16,7 +16,7 @@ class RegionUpdateBatch { public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50) - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new RegionUpdateBatch() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy new file mode 100644 index 000000000..ddb9616bd --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy @@ -0,0 +1,110 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.BaseBatch +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.CopyOnWriteArrayList + +class SynchAdministrativeMappingDataBatch extends BaseBatch{ + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection ADMINISTRATIVE_MAPPING_COLL_100 = MongoUtils.getCollectionByName2("fangjia", "administrative_mapping", MONGO100_URL) + + DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + + static main(args) { + runBatch(new SynchAdministrativeMappingDataBatch(), args); + } + + @Override + public void process(Object args) { + def indexName = "administrative_mapping" + def retMap = synchAdminiMappingTo100() + synchToEs(retMap, "192.168.0.89", indexName) + synchToEs(retMap, "192.168.0.52", indexName) + println(" ÔËÐÐÍê³É") + + } + + def synchAdminiMappingTo100(city){ + //ɾ³ý¾ÉµÄ£¬ÔÙͬ²½Ð嵀 + ADMINISTRATIVE_MAPPING_COLL_100.remove(new BasicDBObject()) + + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(new BasicDBObject()).batchSize(1000) + def datas = [] + def retMap = [:] + for(def d : dbcursor){ + datas << d + retMap.put(d._id.toString(), d) + if (datas.size() >= 2000) { + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); + datas.clear(); + } + } + + if (datas.size() >= 0) { + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); + datas.clear(); + } + + return retMap; + } + + def synchToEs(retMap, host, indexName){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery() + def oldIds = new CopyOnWriteArrayList() + + ElasticUtils89.queryUpdate(host, indexName, queryBuilder, { String id, doc-> + oldIds << id + def mongoObj = retMap.get(id) + def updateFieldCount = 0 + mongoObj.each{k,v-> + if(!["id","_id","c_date","m_date","polyline_source","operator","city_simple_pinyin","prefecture_level_city"].contains(k)){ + def val = doc.get(k) + if(val!=v){ + if(k!="shape" || (k=="shape" && v.type!="MultiPolygon")){ + println k +" ÐÞ¸Ä "+id + updateFieldCount++ + doc.put(k,v) + } + } + } + } + if(mongoObj && updateFieldCount){ + //½øÐÐÐÞ¸Ä + return true + }else{ + if(!mongoObj){ + println "ɾ³ý£º"+id +" "+doc.name + ElasticUtils.delete(id, host, indexName) + return false + } + } + }) + + + def addEsDatasMap = [:] + retMap.each{id,map-> + if(!oldIds.contains(id)){ + println "ÐèÐÂÔö£º"+id + map.remove("c_date") + map.remove("m_date") + map.remove("polyline_source") + map.remove("operator") + map.remove("_id") + addEsDatasMap.put(id, map) + } + } + if(addEsDatasMap){ + ElasticUtils89.updateEs(addEsDatasMap, host, indexName) + } + + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy new file mode 100644 index 000000000..ea5a16f8e --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy @@ -0,0 +1,142 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.BaseBatch +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CopyOnWriteArrayList + +/** + * ½«43ÉϵĿª·¢ÇøÍ¬²½µ½mongo-100, es-89, es-52 + */ +class SynchDevDataBatch extends BaseBatch{ + + def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection development_zone_CONN = MongoUtils.getCollectionByName2("fangjia", "development_zone", MONGO100_URL) + + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + static main(args) { + runBatch(new SynchDevDataBatch(), args); + } + + @Override + public void process(Object args) { + def indexName = "development_zone" + def devMap = synchDevTo100() + synchDevEs(devMap, "192.168.0.89", indexName) + synchDevEs(devMap, "192.168.0.52", indexName) + } + + def synchDevTo100(){ + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find() + def rets = [] + def devMap = [:] + for(def r : dbcursor){ + rets << r + devMap.put(r._id.toString(), r) + } + //ɾ³ý¾ÉµÄ£¬ÔÙͬ²½Ð嵀 + development_zone_CONN.remove(new BasicDBObject()) + development_zone_CONN.insert(rets) + return devMap; + } + + def synchDevToEs(devMap){ +// def esDevs = findEsDevDatas() +// def ids = [] +// for(def dev : devDatas){ +// ids << dev._id.toString() +// def esObj = esDevs.get(dev._id.toString()) +// def updateValMap = [:] +// if(esObj){ +// dev.each{k,v-> +// if(k!="id" && k!="_id"){ +// def val = dev.get(k) +// if(val!=v){ +// updateValMap.put(k,val) +// } +// } +// } +// } +// if(!esObj || (esObj && updateValMap)){ +// ElasticUtils.modify(dev._id.toString(), dev, "192.168.0.89", "development_zone") +// ElasticUtils.modify(dev._id.toString(), dev, "192.168.0.52", "development_zone") +// } +// } +// +// def esDelIds = [] +// esDevs.each{id,map-> +// if(!ids.contains(id)){ +// ElasticUtils.delete(id, "192.168.0.89", "development_zone") +// ElasticUtils.delete(id, "192.168.0.52", "development_zone") +// esDelIds << id +// } +// } +// println "Esɾ³ý¿ª·¢ÇøÊýÁ¿£º"+esDelIds.size() + } + + + def synchDevEs(devMap, host, indexName){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery() + def oldIds = new CopyOnWriteArrayList() + + ElasticUtils89.executeQuery(host, indexName, queryBuilder, { String id, doc-> + oldIds << id + def mongoObj = devMap.get(id) + def updateFieldCount = 0 + mongoObj.each{k,v-> + if(!["id","_id" ,"build_date" ,"create_time","bd_shape","img_url","operator","operate_result","m_date","township","block"].contains(k)){ + def val = doc.get(k) + if(val!=v){ + println doc.name +" ÐÞ¸Ä "+k+" "+ v+" "+id + updateFieldCount++ + doc.put(k,v) + } + } + } + if(mongoObj && updateFieldCount){ + //½øÐÐÐÞ¸Ä + return true + }else{ + if(!mongoObj){ + println "ɾ³ý£º"+id +" "+doc.name + ElasticUtils.delete(id, host, indexName) + return false + } + } + }) + + def addEsDatasMap = [:] + devMap.each{id,map-> + if(!oldIds.contains(id)){ + println "ÐèÐÂÔö£º"+id + map.remove("create_time") + map.remove("build_date") + map.remove("bd_shape") + map.remove("img_url") + map.remove("operator") + map.remove("operate_result") + map.remove("m_date") + map.remove("township") + map.remove("block") + map.remove("_id") + addEsDatasMap.put(id, map) + } + } + if(addEsDatasMap){ + ElasticUtils89.updateEs(addEsDatasMap, host, indexName) + } + } + + + + + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy index d9d86dbf8..c3d0bf761 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TempExportData.groovy @@ -1,7 +1,13 @@ package com.fangjia.script.gj.data_handle +import com.fangjia.core.RegionData import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.GeoHelper +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch @@ -9,17 +15,79 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicLong +import java.util.regex.Pattern class TempExportData { - ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) - + ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") + DBCollection qianzhan_coll = MongoUtils.getCollectionByName("crawl", "yuanqu_qianzhan_com_map", "192.168.0.206", 27020) static main(args) { def task = new TempExportData() // task.run() - def rets = task.fzHouseStat() - ExcelUtils.write("/home/goojia/gj/¸£ÖÝÐ¡Çø·¿Ô´¼°µÚÈý·½Çé¿öͳ¼Æ.xlsx", rets,"Êý¾Ý") - println "ÎļþÒÑÉú³É" +// def rets = task.fzHouseStat() +// ExcelUtils.write("/home/goojia/gj/¸£ÖÝÐ¡Çø·¿Ô´¼°µÚÈý·½Çé¿öͳ¼Æ.xlsx", rets,"Êý¾Ý") +// println "ÎļþÒÑÉú³É" +// exportDistShape() +// task.exportDistrictAlias() + task.exportOfficeHouseCount() + } + + def exportDistShape(){ + def task = new BasicDBObject() + } + + def exportDistrictAlias(){ + def citys = CommonDatautils.findAllCity() + def allRets = [] + allRets << ["Id","³ÇÊÐ","ÇøÓò","Ãû³Æ","µØÖ·","ÒÑɾID","ÒÑÉ¾ÇøÓò","ÒÑɾÃû³Æ","ÒÑɾµØÖ·","¾àÀë"] + + for (def city : citys) { + def dists = CommonDatautils.findAllDistricts(city, "district", ["city", "region", "name", "address", "alias", "lat","lng"]) + def rets = findDelDistBatch(dists) + allRets.addAll(rets) + } + ExcelUtils.write("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\Ð¡Çø\\ÈںϴæÒÉÐ¡Çø.xlsx",allRets, "Ð¡Çø") + } + + + def findDelDistBatch(dists){ + def rets = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(dists.size()) + for(def i=0;i + total = data.c + }) + return total + } + + def findYuanQu(city, name){ + def q = new BasicDBObject("name", Pattern.compile("^${name}")) + def dbcursor = qianzhan_coll.find(q) + def obj = null + for(def d : dbcursor){ + if(d.city.contains(city)){ + obj = d + break; + } + } + return obj + } + + def exportOfficeHouseCount(){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\¸ßµÂд×ÖÂ¥-·¿Ô´µÚÈý·½ÑéÖ¤.xlsx",{d-> +// def obj = findYuanQu(d['B'], d['D']) +// if(obj){ +// d['T'] = "ǰհ´æÔÚ" +// } +// if(!d['T']){ +// def city = RegionData.formatCity(d['C']) +// def obj = findYuanQu(city, d['E']) +// if(obj){ +// d['T'] = "ǰհ´æÔÚ" +// d['U'] = obj.name +// } +// } +// if(!d['T']) { +// def city = RegionData.formatCity(d['C']) +// def region = RegionData.formatRegion(city, d['D']) +// +// def count = findHouseCountByCat(city, region, d['E'], "office_sell") +// if (!count) { +// count = findHouseCountByCat(city, region, d['E'], "office_rent") +// } +// d['T'] = count +// } + + if(!d['T']){ + def city = RegionData.formatCity(d['C']) + def region = RegionData.formatRegion(city, d['D']) + def datas = CommonDatautils.findThirdNetWorkOffices(city, region, d['E']) + if(datas){ + def sources = [] + for(def o : datas){ + sources << o.source + } + if(sources){ + d['V'] = sources.join(",") + } + } + } + }) + } + } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy index 4d77b4cdf..1d22f4cc3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/Test.groovy @@ -1,105 +1,57 @@ package com.fangjia.script.gj.data_handle -import com.fangjia.script.ccbevaluation.CcbCommonUtils -import com.fangjia.script.gj.ccb.CcbCodeUtils -import com.google.common.hash.BloomFilter -import com.google.common.hash.Funnels - -import java.nio.charset.StandardCharsets -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.CopyOnWriteArrayList -import java.util.concurrent.CountDownLatch -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors -import java.util.concurrent.atomic.AtomicLong - -class Test{ - - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(60) -// ×î´óÖØÊÔ´ÎÊý - private static final int MAX_TRY_COUNT = 5; - - static main(args) { - def task = new Test() - task.run() - } - - def run(){ - def i=1 - while(i<2){ - def districts = CcbCommonUtils.findAllDistrictByCity("ÉîÛÚ", "district", ["city", "region", "name", "lng", "estate_type2", "name_cat", "address", "alias", "finish_building_date", "house_property", "property_life", "build_type", "build_structure"], "all"); - def rets = process(districts) - println i + " "+districts.size() +" "+rets.size() - i++ - } - - } - - def process(districts){ - def totalCount = new AtomicLong() - final CountDownLatch latch = new CountDownLatch(districts.size()) - - - def rets = new CopyOnWriteArrayList() - for(def i=0;i +// def date = d['B'] +// def start = DateUtils.getFirstDayOfMonth(date) +// def end = DateUtils.getLastDayOfMonth(date) +// def weekends = DateUtils.getWeekendBetweenDates(start, end) +// for(def weekend : weekends){ +// def avg_price = d['I'] +// def val = random(-200,200) +// def new_price = (int)(avg_price*val/10000 + avg_price) +// def last_weekend = DateUtils.add(DateUtils.formatDateByPattern(weekend, "yyyy-MM-dd"), -7) +// def last_price = CommonDatautils.queryCityPriceByWeekend(city, last_weekend) +// +// def o = new BasicDBObject() +// o.put("avg_price", new_price) +// o.put("c_date" , new Date()) +// o.put("city", city) +// o.put("m_date" , new Date()) +// o.put("weekend", weekend) +// o.put("cat","³ÇÊÐ") +// o.put("moving_average" , (int)avg_price) +// if(!last_price){ +// o.put("weekend_markup" , 0) +// }else{ +// def weekend_markup = (int)((new_price-last_price)*100/last_price) +// o.put("weekend_markup" , weekend_markup) +// } +// +// def q = new BasicDBObject("cat", "³ÇÊÐ").append("city", city).append("weekend", weekend) +// REGION_STAT_COLL.update(q, new BasicDBObject('$set', o),true, false) +// } +//},1) +// +// +//public static final int random(int i1, int i2) { +// int max = Math.max(i1, i2); +// int min = Math.min(i1, i2); +// return min + RandomUtils.nextInt(max - min + 1); +//} +// +// +// +// +// diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy index a6180d973..7560c83ef 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy @@ -52,9 +52,6 @@ class ThirdPriceMappingBatch extends BaseBatch{ def index = 0 for(def c : citys){ index ++ - if(index < 206){ - continue - } def query = new BasicDBObject("city", c).append("match_id", new BasicDBObject('$exists', false)) def noMatchDatas = thirdSeaweedMappingColl.find(query).toList() matchByCity(c, noMatchDatas) @@ -123,9 +120,6 @@ class ThirdPriceMappingBatch extends BaseBatch{ def index = 0 for(def c : citys){ index ++ - if(index < 70){ - continue - } def crawlDatas = thirdPartyPriceColl.find(new BasicDBObject("city", c).append("s_date", curDate)).toList() def addCount = addDatasToDB(crawlDatas) println c + " ÐÂÔö£º"+ addCount diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy index 4ecd49ed0..31105176e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownMiddleProcess.groovy @@ -3,23 +3,22 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData import com.fangjia.core.util.BaiDuApiUtils import com.fangjia.core.util.GeocodeUtils +import com.fangjia.core.util.HttpRequest import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.util.BaiduMapUtils -import com.fangjia.script.util.DataUtil import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.ProvinceData import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject +import com.mongodb.Bytes import com.mongodb.DBCollection import com.mongodb.DBObject -import com.mongodb.client.AggregateIterable -import org.bson.Document +import net.sf.json.JSONObject import org.bson.types.ObjectId import java.util.regex.Pattern - /** * ÏçÕò½ÖµÀÖмä±í * °üº¬ÊУ¬Çø£¬ÏçÕò½ÖµÀ±ðÃû£¬À´Ô´ ͳ¼Æ¾Öcommunity±í @@ -45,6 +44,8 @@ class TownMiddleProcess { DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + static DBCollection POLYLINECOLL2025 = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline_2025") + def fullCityMap = CommonDatautils.queryFullNameCity() static main(args) { @@ -64,7 +65,7 @@ class TownMiddleProcess { //ÐÞ¸ÄÏçÕò½ÖµÀ±ðÃû // updateTownAlias() //Öмä±íͬ²½µ½100 -// synchTown() + synchTown() //Ìí¼ÓµØ¼¶ÊбêÖ¾ // addCityFlag() // addPinyin() @@ -95,7 +96,13 @@ class TownMiddleProcess { // addTownCenter()//°Ù¶È½Ó¿ÚÌí¼ÓÖÐÐĵã // checkCenterInTownRang()//¼ì²âÏçÕò½ÖµÀÖÐÐĵãÊÇ·ñÔÚΧÀ¸ÖÐ - addSpecialCityTownAlias() +// addSpecialCityTownAlias() + + +// updateNewRegionPoyline()//¸üÐÂеÄÇøÓòΧÀ¸ + + updateMappingPolyline() + } @@ -451,16 +458,16 @@ class TownMiddleProcess { for(def d : dbcursor){ datas << d if (datas.size() >= 2000) { -// ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); - ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); +// ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) println datas.size() datas.clear(); } } if (datas.size() >= 0) { -// ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); - ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) + ADMINISTRATIVE_MAPPING_COLL_100.insert(datas); +// ADMINISTRATIVE_MAPPING_43base_COLL.insert(datas) datas.clear(); } } @@ -681,7 +688,7 @@ class TownMiddleProcess { } def regionPolyline(){ - def dbcursor = REGIONPOLYLINE_COLL.find(new BasicDBObject("level","district")) + def dbcursor = POLYLINECOLL2025.find(new BasicDBObject("level","district")) def map = [:] for(def d : dbcursor){ def resultMap = [:] @@ -1356,4 +1363,90 @@ class TownMiddleProcess { keys.put("street", 1) return ADMINISTRATIVE_MAPPING_COLL.find(q, keys).toList() } + + def updateNewRegionPoyline(){ + + def regionPolylineMap = regionPolyline() + def q = new BasicDBObject() + q.put("type","ÇøÓò") +// q.put("city", "ËÕÖÝÊÐ") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) + for(def d : dbcursor){ + def shapeData = regionPolylineMap.get(d.city+"|@|"+d.district) + println d.city+" "+d.district + if(shapeData){ + println "ÐÂΧÀ¸Êý£º"+shapeData.shape.coordinates.size() + } + + if(d.shape){ + println "¾ÉΧÀ¸Êý£º"+d.shape.coordinates.size() + } + + if(d.shape && shapeData && shapeData.shape!=d.shape){ + def udata = new BasicDBObject() + udata.shape = shapeData.shape + udata.location = shapeData.location + udata.m_date = new Date() + ADMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",d._id), new BasicDBObject('$set',udata)) +// if(shapeData && d.shape && shapeData.shape.type=="polygon" && d.shape.type=="polygon"){ +// double area = com.fangjia.script.util.GeoHelper.calculateArea(shapeData.shape.coordinates[0]) +// double area1 = com.fangjia.script.util.GeoHelper.calculateArea(d.shape.coordinates[0]) +// if(Math.abs(area1-area)>=1){ +// println "Уº"+area +// println "¾É£º"+area1 +// def udata = new BasicDBObject() +// udata.shape = shapeData.shape +// udata.location = shapeData.location +// //DMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",d._id), new BasicDBObject('$set',udata)) +// } +// } + } + } + } + + def updateMappingPolyline(){ + def q = new BasicDBObject() + q.put("type","ÇøÓò") + q.put("shape.type","polygon") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q) + for(def d : dbcursor){ + updateAdministrativeMapping(d._id.toString(), d.shape) + } + } + + + def updateAdministrativeMapping(def id, def shape){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/administrative_mapping/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.shape = params.newshape", + "params":{ + "newshape":{ + "type":"${shape.type}", + "coordinates":${shape.coordinates} + } + } + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + println(response) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 4d3e00e32..3797a3924 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -1,17 +1,36 @@ package com.fangjia.script.gj.data_handle +import com.fangjia.core.RegionData +import com.fangjia.core.util.HttpRequest import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.lixue.util.DBUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.BaiduMapUtils +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject +import net.sf.json.JSONObject import org.apache.commons.io.FileUtils +import org.bson.types.ObjectId import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.action.update.UpdateRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong /** * ÇøÓò±ê×¼»¯ * 1.Ð¡Çø¿âÏçÕò½ÖµÀ±ê×¼»¯£¬°üº¬Ð¡Çø£¬ÉÌÆÌ£¬Ð´×ÖÂ¥ @@ -22,6 +41,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) def updateList = [] def addAliasList = [] @@ -37,12 +57,17 @@ class TownStandardBatch extends BaseBatch{ } def TownStandard(){ -// townStandardByCat("office") - townStandardByPoi() + townStandardByCat("office") +// townStandardByPoi() +// addTownByTownShape()//ΪûÓÐÏçÕò½ÖµÀµÄpoi£¬²¹³äÏçÕò½ÖµÀ£¬ºöÂÔÇøÓò£¬²¢Ê¹ÓõØÍ¼ +// standardTown() +// updateTownData() + + } def townStandardByCat(def cat){ //"ÈýÃ÷","ÁúÑÒ","ÄÏÆ½","ÕÄÖÝ","¸£ÖÝ","ÏÃÃÅ","ȪÖÝ","ÆÎÌï","ÄþµÂ", - def citys = ["ÖØÇì","ÁúÑÒ","ÄÏÆ½","ÕÄÖÝ","¸£ÖÝ","ÏÃÃÅ","ȪÖÝ","ÆÎÌï","ÈýÃ÷","ÄþµÂ"]//CommonDatautils.findAllCity() + def citys = ["Ìì½ò"]//CommonDatautils.findAllCity() for(def city : citys){ def data = fullCityMap.get(city) @@ -53,10 +78,10 @@ class TownStandardBatch extends BaseBatch{ def mzbRegionMap = CommonDatautils.queryMzbRegion(fullCityName) def shortRegionNameMap = CommonDatautils.getRegionShortName(fullCityName) - def townMap = CommonDatautils.queryTownByCity(fullCityName, ["city","district", "street", "alias"], mzbRegionMap) + def townMap = CommonDatautils.queryTownByCity(fullCityName, ["city","district", "street", "alias","shape"], mzbRegionMap) if(townMap){ def regionSet = townMap.keySet() - if(regionSet.size()>1){ + if(regionSet.size()>=1){ haveRegionProcess(city, fullCityName, townMap, cat, shortRegionNameMap) }else{ println city +" ÎÞÇøÓò" @@ -69,11 +94,15 @@ class TownStandardBatch extends BaseBatch{ updateList << ["Êý¾ÝID", "³ÇÊÐ","ÇøÓò","ÏçÕò½ÖµÀ","Ãû³Æ","״̬", "ÐÞ¸Ä"] addAliasList << ["³ÇÊÐ","ÇøÓò","ÏçÕò½ÖµÀ", "ÐÂÔö±ðÃû"] - //Õã½­£¬½­ËÕ£¬°²»Õ - def citys = ['º¼ÖÝ','Äþ²¨','ÎÂÖÝ','¼ÎÐË','̨ÖÝ','ºþÖÝ','ÉÜÐË','½ð»ª','ÖÛɽ','áéÖÝ','ÀöË®']//CommonDatautils.findAllCity() + def runProvinces = ["¸£½¨Ê¡","Õã½­Ê¡","½­ËÕÊ¡","°²»ÕÊ¡","ɽ¶«Ê¡","¸ÊËàÊ¡"] + def citys = CommonDatautils.findAllCity() + def index = 0 for(def city : citys){ - + index++ def data = fullCityMap.get(city) +// if(runProvinces.contains(data.province)){ +// continue +// } def fullCityName = null if(data){ fullCityName = data.city @@ -95,11 +124,16 @@ class TownStandardBatch extends BaseBatch{ def rets = readPoiCsv(fileName) println city +" "+rets.size() if(set.size()>1){ - poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap) + poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap, data) }else{ // haveStreetProcess(city, set, cat) } } + if(updateList.size()>50000){ + ExcelUtils.write("D:\\Êý¾Ý\\ÏçÕò½ÖµÀ´ý²éÊý¾Ý-${index}.xlsx", updateList, "Êý¾Ý") + ExcelUtils.write("D:\\Êý¾Ý\\ÏçÕò½ÖµÀ´ý²éÊý¾Ý-ÐèÐÂÔö±ðÃû-${index}.xlsx", addAliasList, "Êý¾Ý") + updateList.clear() + } }else{ println fileName+" ÎļþûÕÒµ½" } @@ -107,18 +141,18 @@ class TownStandardBatch extends BaseBatch{ println "ûÕÒµ½ÏàÓ¦µÄÈ«³Æ£º"+city } } - ExcelUtils.write("D:\\Êý¾Ý\\ÏçÕò½ÖµÀ´ý²éÊý¾Ý.xlsx", updateList, "Êý¾Ý") - ExcelUtils.write("D:\\Êý¾Ý\\ÏçÕò½ÖµÀ´ý²éÊý¾Ý-ÐèÐÂÔö±ðÃû.xlsx", addAliasList, "Êý¾Ý") + ExcelUtils.write("D:\\Êý¾Ý\\ÏçÕò½ÖµÀ´ý²éÊý¾Ý-×îºó.xlsx", updateList, "Êý¾Ý") } def haveRegionProcess(city, fullCityName, townMap, cat, shortRegionNameMap){ def results = [] if(fullCityName){ - def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name", "township"]) + def districts = CommonDatautils.findAllDistricts(city, cat, ["city","region","name", "township","lng","lat"]) for(def d : districts){ - if(d.township){ - def towns = null - def updateTown = null + + def towns = null + def updateTown = null + if(d.region){ for(def m : townMap){ def fullRegionName = shortRegionNameMap.get(d.region) if(m.key == fullRegionName){ @@ -126,41 +160,51 @@ class TownStandardBatch extends BaseBatch{ break } } + } + if(!towns){ + towns = townMap.get(fullCityName) + } - def opt = true - if(towns){ - for(def town : towns){ - def townAlias = [] - if(town.alias){ - townAlias = town.alias - } - townAlias << town.street - if(townAlias.contains(d.township)){ - if(d.township!=town.street){ - updateTown = town.street - }else{ - opt = false - } - break - } + def opt = true + if(towns){ + for(def town : towns){ + def townAlias = [] + if(town.alias){ + townAlias = town.alias } - } - if(opt){ - if(updateTown){ - def udata = new BasicDBObject() - udata.put("township", updateTown) - udata.put("m_date", new Date()) - println d.city +" "+d.region+" "+d.name+" "+d.township +" ÏçÕòÐÞ¸ÄΪ£º"+updateTown -// DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + townAlias << town.street + if(townAlias.contains(d.township)){ + if(d.township!=town.street){ + updateTown = town.street + }else{ + opt = false + } + break }else{ - def udata = new BasicDBObject() - udata.put("township", "") - udata.put("m_date", new Date()) - println d.city +" "+d.region+" "+d.name+" "+d.township +" ÏçÕòÐÞ¸ÄΪ£º¿ÕÖµ" -// DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + if(town.shape){ + def flag = InsidePolygon.isInArea(d.lng/10000000000.0, d.lat/10000000000.0, InsidePolygon.createPoint4(town.shape.coordinates)) + if(flag){ + updateTown = town.street + break + } + } } } - + } + if(opt){ + if(updateTown){ + def udata = new BasicDBObject() + udata.put("township", updateTown) + udata.put("m_date", new Date()) + println d.city +" "+d.region+" "+d.name+" "+d.township +" ÏçÕòÐÞ¸ÄΪ£º"+updateTown + DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + }else{ + def udata = new BasicDBObject() + udata.put("township", "") + udata.put("m_date", new Date()) + println d.city +" "+d.region+" "+d.name+" "+d.township +" ÏçÕòÐÞ¸ÄΪ£º¿ÕÖµ" + DbUtils.seaweed.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + } } } } @@ -168,7 +212,7 @@ class TownStandardBatch extends BaseBatch{ } - def poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap){ + def poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap, data){ def results = [] if(fullCityName){ for(def d : rets){ @@ -221,21 +265,21 @@ class TownStandardBatch extends BaseBatch{ def m = [:] m.put(d.id, ["township":updateTown]) results << m -// if(results.size()%100==0){ -// updateByEs(results) -// results.clear() -// } - updateList << [d.id, d.city, d.district, d.name,d.township, d.status, updateTown] + if(results.size()%100==0){ + updateByEs(results) + results.clear() + } + updateList << [d.id, d.province, d.city, d.district, d.name,d.township, d.status, updateTown] // println d.city +" "+d.district+" "+d.name +" "+d.township+" ÏçÕòÐÞ¸ÄΪ£º"+updateTown }else{ def m = [:] m.put(d.id, ["township":""]) -// results << m -// if(results.size()%100==0){ -// updateByEs(results) -// results.clear() -// } - updateList << [d.id, d.city, d.district, d.name, d.township, d.status, ""] + results << m + if(results.size()%100==0){ + updateByEs(results) + results.clear() + } + updateList << [d.id, d.province, d.city, d.district, d.name, d.township, d.status, ""] println d.city +" "+d.district+" "+d.name +" "+d.township+" ״̬ÐÞ¸ÄΪ£º¿ÕÖµ" } } @@ -244,10 +288,10 @@ class TownStandardBatch extends BaseBatch{ } } -// if(results.size()>0){ -// updateByEs(results) -// results.clear() -// } + if(results.size()>0){ + updateByEs(results) + results.clear() + } println fullCityName +" ´¦ÀíÍê³É" } @@ -322,18 +366,475 @@ class TownStandardBatch extends BaseBatch{ if(line){ String[] arrs = line.split("\\|@\\|") def o = new BasicDBObject() - o.put("city", arrs[0]) - o.put("district", arrs[1]) - o.put("name", arrs[2]) - o.put("township", arrs[3]) - o.put("status", arrs[4]) - o.put("id", arrs[5]) - rets << o + try{ + o.put("city", arrs[0]) + o.put("district", arrs[1]) + o.put("name", arrs[2]) + o.put("township", arrs[3]) + o.put("status", arrs[4]) + o.put("id", arrs[5]) + rets << o + }catch(Exception e){ + println arrs + } + } } return rets; } + def readCSV3(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + def index = 0 + for(line in lines) { + if(line && index>=1){ + String[] arrs = line.split(",") + if(arrs.size()>=11 && arrs[10]=="ÊÇ" && arrs[6]!=arrs[7]){ + def o = new BasicDBObject() + try{ + o.put("id", arrs[0]) + o.put("township", arrs[7]) + o.put("city", arrs[2]) + o.put("old_district", arrs[3]) + o.put("new_district", arrs[8]) + rets << o + }catch(Exception e){ + println arrs + } + } + + } + index++ + } + return rets; + } + + def readCSV2(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + def index = 0 + for(line in lines) { + if(line && index>=1){ + String[] arrs = line.split(",") + def o = new BasicDBObject() + try{ + o.put("id", arrs[1]) + o.put("province", arrs[2]) + o.put("city", arrs[3]) + o.put("district", arrs[4]) + o.put("lng", arrs[5]) + o.put("lat", arrs[6]) + o.put("data_source", arrs[7]) + if(arrs.size()>=9){ + o.put("township", arrs[8]) + o.put("new_district", arrs[9]) + o.put("town_source", arrs[10]) + } + rets << o + }catch(Exception e){ + println arrs + } + } + index++ + } + return rets; + } + + def addTownByTownShape(){ + def i = 0 + def headers = ["_id","province","city","district","lng","lat","data_source","ÏçÕò½ÖµÀ", "ÐÂÇøÓò", "·½Ê½", "±ê×¼ÏçÕò"] + while(i<=50){ + def fileName = "/home/goojia/gj/new_poi/input/map/no_township_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\ÏçÕò½ÖµÀ\\no_township_${i}.csv" + } + File file=new File(fileName); + if(file.exists()) { + def rets = readCSV2(fileName) + println i +" "+ rets.size() + def rows = addTownshipBatch(rets) + if (CommonDatautils.isWindow()) { + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\ÏçÕò½ÖµÀ\\´ý²¹³äÏçÕò½ÖµÀ\\½á¹û-µØÍ¼\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + }else{ + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + } + println fileName +" ÔËÐÐÍê³É" + }else{ + println fileName +" ²»´æÔÚ" + } + i++ + } + } + + + def standardTown(){ + def i = 49 + def headers = ["_id","province","city","district","lng","lat","data_source","ÏçÕò½ÖµÀ", "ÐÂÇøÓò", "·½Ê½", "±ê×¼ÏçÕò"] + + def cityTownMap = CommonDatautils.queryAllTown(["city", "district", "mzb_district_name", "street", "alias"]) + while(i<=50){ + def fileName = "/home/goojia/gj/new_poi/input/map/no_township_result_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\ÏçÕò½ÖµÀ\\´ý²¹³äÏçÕò½ÖµÀ\\½á¹û-µØÍ¼\\no_township_result_${i}.csv" + } + File file=new File(fileName); + if(file.exists()) { + def rets = readCSV2(fileName) + println i +" "+ rets.size() + def rows = addTownshipBatch2(rets, cityTownMap) + if (CommonDatautils.isWindow()) { + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\ÏçÕò½ÖµÀ\\´ý²¹³äÏçÕò½ÖµÀ\\½á¹û-µØÍ¼-ÑéÖ¤ÏçÕò\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + }else{ + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + } + println fileName +" ÔËÐÐÍê³É" + }else{ + println fileName +" ²»´æÔÚ" + } + i++ + } + } + + def addTownshipBatch(def rets){ + def results = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(rets.size()) + for(def i=0;i= 1) { + addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) + results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source, r.strand_town] +// } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } +// } +// }); + } + latch.await() + return results + } + + + def addTownshipBatch2(def rets, def cityTownMap){ + def results = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(rets.size()) + for(def i=0;i= 1) { + if(townMap.size()>=1){ + r.strand_town = isStandTown(townMap, r.new_district, r.township) + } + results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source, r.strand_town] + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + latch.await() + return results + } + + def addTown(saveObj, townMap, location) { + //ÔÚpoi±¾ÇøÓòÏÂͨ¹ýÏçÕò½ÖµÀΧÀ¸Ñ¡³öËùÔÚÏçÕò½ÖµÀ +// def towns = townMap.get(saveObj.district) +// if (towns) { +// for (def town : towns) { +// if (town.shape && town.shape.coordinates) { +// def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) +// if (flag) { +// saveObj.township = town.street +// saveObj.town_source = "Í¬ÇøÓò" +// saveObj.strand_town = "ÊÇ" +// break +// } +// } +// } +// } + //ºöÂÔpoiÖеÄÇøÓò ͨ¹ýÏçÕò½ÖµÀΧÀ¸Ñ¡³öËùÔÚÏçÕò½ÖµÀ +// if(!saveObj.township){ +// def townNames = townMap.keySet() +// for(def townName : townNames){ +// towns = townMap.get(townName) +// for (def town : towns) { +// if (town.shape && town.shape.coordinates) { +// def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) +// if (flag) { +// saveObj.township = town.street +// saveObj.new_district = town.mzb_district_name +// saveObj.town_source = "ºöÂÔÇøÓò" +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// break +// } +// } +// } +// if(saveObj.township){ +// break; +// } +// } +// } + //ͨ¹ýµ÷È¡µØÍ¼api½Ó¿Ú»ñÈ¡ÏçÕò½ÖµÀ + if(!saveObj.township){ + def gaodeMap = getTownshipInfo(location.lon+","+location.lat) + if(gaodeMap && gaodeMap.township){ + saveObj.township = gaodeMap.township + saveObj.new_district = gaodeMap.district + saveObj.town_source = "¸ßµÂAPI" + saveObj.strand_town = "" +// if(townMap.size()>=1){ +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// } + } + } + +// //ͨ¹ýµ÷È¡µØÍ¼api½Ó¿Ú»ñÈ¡ÏçÕò½ÖµÀ +// if(!saveObj.township){ + def gaodeMap = BaiduMapUtils.geocoding(location.lat+","+location.lon) +// if(gaodeMap && gaodeMap.addressComponent) { +// def addressComponent = gaodeMap.addressComponent +// if(addressComponent){ +// if(addressComponent.town){ +// saveObj.township = addressComponent.town +// saveObj.new_district = addressComponent.district +// saveObj.town_source = "°Ù¶ÈAPI" +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// } +// } +// } +// } + return saveObj + } + + def isStandTown(townMap, district, town){ + def towns = townMap.get(district) + def flag = "·Ç" + if(towns){ + for(def t : towns){ + if(t.street == town){ + flag = "ÊÇ" + break + } + } + } + return flag + } + + + def getTownshipInfo(def glocation){ + def township = null + def district = null + def city = null + def format_addr = null + def stop = false + def count = 0 + def jsonObject = null +// while(!stop){ + if(glocation){ + jsonObject = GaoDeApiUtils.geocode(glocation) + + if(jsonObject && jsonObject.regeocode) { + def addressComponent = jsonObject.regeocode.addressComponent + if(addressComponent){ + township = addressComponent.township + district = addressComponent.district + city = addressComponent.city + format_addr = jsonObject.regeocode.formatted_address + + } + } + } +// if(jsonObject.status==0 || count>3){ +// stop = true +// println "¸ßµÂµ÷Óó¬3´Î" +// }else{ +// count ++ +// Thread.sleep(3000) +// print "." +// } +// } + + def map = [:] + map.city = city + map.district = district + map.township = township + map.format_addr = format_addr + return map; + } + + def updateTownData(){ + def i = 49 + while(i<50) { + def fileName = "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\ÏçÕò½ÖµÀ\\´ý²¹³äÏçÕò½ÖµÀ\\½á¹û-µØÍ¼-ÑéÖ¤ÏçÕò\\no_township_result_${i}.csv" + } + File file = new File(fileName); + if (file.exists()) { + def rets = readCSV3(fileName) + println file.getAbsoluteFile().getName() +" "+(rets.size()*100/200000)+"%"+" "+rets.size() + if(rets){ +// updateToEs(rets)//²»ÄÜÓÃÕâÖÖ·½·¨Ð޸쬷ñÔòÆäËü×ֶζ¼½«¶ªÊ§ +// updateToEs2(rets) + updateDistTownship(rets) + } + } + i++ + } + } + + + def updateToEs(rows){ + BulkRequest request = new BulkRequest(); + int batchSize = 1; + int processedCount = 0; + def client = ElasticUtils.getClient89("192.168.0.89") + for (int i = 0; i < rows.size(); i++) { + def map = rows[i] + if(map.containsKey("way")){ + map.remove("way") + } + request.add(new IndexRequest("map_poi_2024", "_doc", map.id).source(map, XContentType.JSON)); + if(i%1000==0){ + print "." + } + + // ÅúÁ¿Ìá½»Êý¾Ý + if (request.numberOfActions() >= batchSize) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + print "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + + request = new BulkRequest(); + } + + } + + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + } + + println "½áÊøÊ±¼ä "+new Date() + } + + def updateToEs2(rows) { + for (int i = 0; i < rows.size(); i++) { + def map = rows[i] + updateMapPoi(map.id, map.township) + } + } + + + def updateMapPoi(def id, def township){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/map_poi_2024/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.township='${township}'", + "lang": "painless" + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + + def updateDistTownship(rets){ + for(def m : rets){ + + def obj = CommonDatautils.findDistrictById(m.id) + if(obj.township != m.township){ + def udata = new BasicDBObject() + udata.put("township", m.township) + if(!m.new_district.contains(m.old_district)){ + def lists = CommonDatautils.findAllDistrictByName(obj.city, null, obj.name, obj.cat) + if(lists.size()<2){ + continue + } + def region = RegionData.formatRegion(m.city, m.new_district) + if(region){ + def dbo = CommonDatautils.findDistrict(m.city, region, obj.name, obj.cat) + if(dbo){ + udata.put("status", 1) + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(m.id)), new BasicDBObject('$set', udata)) + println "ɾ³ý "+m.city +" "+obj.name+" "+m.id+" "+obj.cat + continue + }else{ + udata.put("region", region) + } + } + } + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(m.id)), new BasicDBObject('$set', udata)) + } + } + + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy index d99e249c9..da5899b14 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy @@ -1,6 +1,7 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData +import com.fangjia.core.util.HttpRequest import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.CosineSimilarAlgorithm @@ -11,6 +12,7 @@ import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.impl.AMQImpl +import net.sf.json.JSONObject import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch @@ -42,13 +44,16 @@ class TownshipStrandUpdate { // task.updateTown() // task.stat() - task.updateDiffRegionTown() +// task.updateDiffRegionTown() // task.cleanTown() // task.checkTownFromMongo() // task.updateTownMapping() // task.updateDevMapping() - println new Date().getTime() +// println new Date().getTime() // task.updateSpecCityTown() + + + task.updateTownshipAlias() } @@ -629,4 +634,69 @@ class TownshipStrandUpdate { } } + + + def updateTownshipAlias(){ + def fileName = "D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\ÏçÕò½ÖµÀ\\20250219--ÏçÕò½ÖµÀÌí¼Ó±ðÃû.xlsx" + ExcelUtils.modify(fileName,{d-> + def q = new BasicDBObject("type","ÏçÕò½ÖµÀ").append("city", d["A"]).append("district",d["B"]).append("street",d["C"]) + def list = ADMINISTRATIVE_MAPPING_COLL.find(q).toList() + def newAlias = d['D'] + if(list.size()==0){ + list = q.put("street", d['D']) + newAlias = d['C'] + list = ADMINISTRATIVE_MAPPING_COLL.find(q).toList() + } + if(list && list.size()==1){ + def obj = list[0] + def alias = obj.alias + if(!alias){ + alias = [] + } + if(!alias.contains(newAlias)){ + alias << newAlias + } + if(alias){ + def udata = new BasicDBObject() + udata.put("alias", alias) + udata.put("m_date", new Date()) + udata.put("operator","³Â½Ü") + ADMINISTRATIVE_MAPPING_COLL.update(new BasicDBObject("_id",obj._id), new BasicDBObject('$set',udata)) + } + +// updateStreetAlias(obj._id.toString(), alias.join("','")) + }else{ + println d["C"] +" "+ d["D"] + } + }) + } + + + def updateStreetAlias(def id, def alias){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/administrative_mapping/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.alias=['${alias}']", + "lang": "painless" + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/VillaHouseBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/VillaHouseBatch.groovy new file mode 100644 index 000000000..73571b916 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/VillaHouseBatch.groovy @@ -0,0 +1,148 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.BaseBatch +import com.fangjia.script.ccbevaluation.CcbCommonUtils +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ElasticUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBObject +import groovy.sql.Sql +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +class VillaHouseBatch extends BaseBatch{ + + def pgsqlInstance236 = Sql.newInstance("jdbc:postgresql://192.168.0.236:5432/warehouse", + "postgres", "postgres", "org.postgresql.Driver") + //235Ϊ·¿¼ÛÍøÄÚ²¿¼ÆËã¾ù¼ÛµÄ¿â + def sqlInstance235 = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", + "postgres", "Goojia123456", "org.postgresql.Driver") + + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + runBatch(new VillaHouseBatch(), args) + } + + @Override + void process(Object args) { + + def dists = CcbCommonUtils.findAllDistrictByCity("ÉϺ£", "district", ["city", "region", "name", "estate_type2"], "all") + def villaDists = findVillaDists(dists) + addVillaTypeFlag(villaDists) + println "ÔËÐÐÍê³É" + } + + def findVillaDists(dists){ + def villaDists = [] + for(def d : dists){ + if(d.estate_type2 == "±ðÊû"){ + villaDists << d + } + } + return villaDists + } + + def addVillaTypeFlag(def villaDists){ + for(def i=0;i + sellIds << r.gujia_sell_id + }) + return sellIds + } + + def findHouseInfo(sell_id, houseMap){ + def flag = findHouseDetail(sell_id) + if(flag){ + houseMap.put(sell_id, flag) + } + return houseMap + } + + def findHouseDetail(houseId){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("_id", houseId)) + def flag = null + + def hosts = ["192.168.0.206","192.168.0.211","192.168.0.212","192.168.0.213","192.168.0.214","192.168.0.215"] + def index = new Random().nextInt(5); + def houses = ElasticUtils.executeSimpleQuery(hosts[index], "seawater-20*", queryBuilder); + if(houses){ + for (int k=0;k + def sql = "update base.bigdata_forsale set villa_type='${type}' where gujia_sell_id='${sell_id}'" + sqlInstance235.executeUpdate(sql) + } + + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index 3b3aed61a..8507f7d00 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -18,6 +18,8 @@ import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.impl.AMQImpl import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders import java.text.SimpleDateFormat import java.util.concurrent.CopyOnWriteArrayList @@ -39,7 +41,7 @@ class DistrictFieldAddBatch extends BaseBatch{ //"°²¾Ó¿Í":"°²¾Ó¿ÍС³ÌÐò","Á´¼Ò":"Á´¼Ò","ÐÒ¸£Àï":"ÐÒ¸£Àï","³ÇÊз¿²ú":"³ÇÊз¿²úС³ÌÐò","ËÑ·¿":"ËÑ·¿" // - def sourceMap = ["ÐÒ¸£Àï":"ÐÒ¸£ÀïAPP","³ÇÊз¿²ú":"³ÇÊз¿²úС³ÌÐò","°²¾Ó¿ÍС³ÌÐò":"°²¾Ó¿ÍС³ÌÐò","°²¾Ó¿ÍÒÆ¶¯¶Ë":"°²¾Ó¿ÍÒÆ¶¯¶Ë","±´¿ÇÕÒ·¿":"±´¿ÇÕÒ·¿","°²¾Ó¿Í-з¿":"°²¾Ó¿Í-з¿","°²¾Ó¿Í":"°²¾Ó¿Í","Á´¼Ò":"Á´¼Ò","±´¿ÇÕÒ·¿-з¿":"±´¿ÇÕÒ·¿-з¿","Â¥ÅÌÍø-з¿":"Â¥ÅÌÍø-з¿","ìûÌ©":"Öйú·¿¼ÛÐÐÇé","Á´¼Ò":"Á´¼Ò","ËÑ·¿":"ËÑ·¿","ÎÒ°®ÎÒ¼Ò":"ÎÒ°®ÎÒ¼Ò","Öî¸ðÕÒ·¿":"Öî¸ðÕÒ·¿APP","±´¿ÇÕÒ·¿":"±´¿ÇÕÒ·¿", + def sourceMap = ["±´¿ÇÕÒ·¿":"±´¿ÇÕÒ·¿","Á´¼Ò":"Á´¼Ò","±´¿ÇÕÒ·¿-з¿":"±´¿ÇÕÒ·¿-з¿","°²¾Ó¿Í":"°²¾Ó¿Í","ÐÒ¸£Àï":"ÐÒ¸£Àï","°²¾Ó¿ÍС³ÌÐò":"°²¾Ó¿ÍС³ÌÐò","³ÇÊз¿²ú":"³ÇÊз¿²úС³ÌÐò","°²¾Ó¿ÍÒÆ¶¯¶Ë":"°²¾Ó¿ÍÒÆ¶¯¶Ë","°²¾Ó¿Í-з¿":"°²¾Ó¿Í-з¿","Â¥ÅÌÍø-з¿":"Â¥ÅÌÍø-з¿","ìûÌ©":"Öйú·¿¼ÛÐÐÇé", "³ÇÊз¿²ú":"³ÇÊз¿²ú","ËÑ·¿":"ËÑ·¿","ÎÒ°®ÎÒ¼Ò":"ÎÒ°®ÎÒ¼Ò","Öî¸ðÕÒ·¿":"Öî¸ðÕÒ·¿", "ÀÖÓмÒ":"ÀÖÓмÒ","¼ªÎÝ":"¼ªÎÝ","C21":"C21","365ÌÔ·¿":"365ÌÔ·¿"] //key:ÄÂÈںϱíµÄÀ´Ô´ valve:es½âÎö±íµÄÀ´Ô´ @@ -61,6 +63,7 @@ class DistrictFieldAddBatch extends BaseBatch{ "car_site_count":"³µÎ»","car_site":"³µÎ»ÃèÊö","property_life":"²úȨÄêÏÞ","address":"µØÖ·","build_structure":"½¨Öþ½á¹¹", "build_type":"½¨ÖþÀàÐÍ", "land_property":"ȨÊôÀà±ð","live_date":"Èëסʱ¼ä","loop_line_info":"»·Ïß"] + final DBCollection thirdSeaweedMappingColl = MongoUtils.getCollectionByName("fangjia_craw", "third_seaweed_mapping", "192.168.0.235", 27018) final static def EMAILS = [ "gaojuan@fangjia.com" @@ -68,6 +71,38 @@ class DistrictFieldAddBatch extends BaseBatch{ static main(args) { runBatch(new DistrictFieldAddBatch(), args) +// ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Ð¡Çø\\ÉϺ£±ðÊû.xlsx",{d-> +// def dist = CommonDatautils.findDistrict(d['B'], d['G'], d['C'], "district") +//// if(dist){ +//// d['L'] = dist.loudong_count +//// d['M'] = dist.household_count +//// d['Q'] = dist.estate_type2 +//// } +// def list = findEsDatasByCityAndName(d['B'], d['G'], d['C'], "ËÑ·¿") +// if(!list && dist){ +// def alias = dist.alias +// for(def name : alias){ +// list = findEsDatasByCityAndName(d['B'], d['G'], name, "ËÑ·¿") +// if(list){ +// d['Z'] = "±ðÃû" +// } +// } +// }else{ +// d['Z'] = "Ãû³Æ" +// } +// if(list){ +// def obj = list[0] +// if(obj.loudong_cnt){ +// d['W'] = obj.loudong_cnt +// } +// +// if(obj.households){ +// d['X'] = obj.households +// } +// d['Y'] = obj.url +// } +// +// }) } @Override @@ -83,18 +118,13 @@ class DistrictFieldAddBatch extends BaseBatch{ headers << fieldsNameMap.get(it) } - headers << "ץȡÁ¿" - headers << "Æ¥ÅäÁ¿" - headers << "0.9·ÖÒÔÉÏÁ¿" - headers << "Æ¥ÅäÂÊ" - headers << "0.9ÒÔÉÏÆ¥ÅäÂÊ" -// analysRets << headers - for(def c : citys){ + def totalCount = CommonDatautils.findAllDistrictCount("district", c) if(totalCount){ // rh_analysRets = addFieldFromRonghe(c, totalCount, rh_analysRets)//ÈÚºÏ - analysRets = addFieldFromMatch(c, totalCount, analysRets)//Æ¥Åä +// analysRets = addFieldFromMatch(c, totalCount, analysRets)//Æ¥Åä + analysRets = addFieldFromMatchMapping(c, totalCount, analysRets)//ÐÂ¾ÉÆ¥ÅäÖмä±í } } println analysRets.toString() @@ -107,8 +137,10 @@ class DistrictFieldAddBatch extends BaseBatch{ sourceMap.each { seaweedmapSource, esWebSource -> def esRets = findEsDatas(c, esWebSource) + def matchRets1 = matchApi(esRets) def matchRets2 = selectRestByCredit(matchRets1) + println esWebSource +" ץȡÁ¿£º"+esRets.size()+" Æ¥ÅäÁ¿£º"+matchRets1.size()+" 0.9·ÖÒÔÉÏÁ¿£º"+matchRets2.size() def updateRets = processFieldsFromMatch(c , matchRets2, esWebSource) @@ -140,6 +172,65 @@ class DistrictFieldAddBatch extends BaseBatch{ } + def addFieldFromMatchMapping(c, totalCount, analysRets){ + def fields = fieldsMap.keySet() as List + + sourceMap.each { seaweedmapSource, esWebSource -> + def esRets = findMatchSameDatas(c, esWebSource) + println esWebSource +" ÐÂÀÏË㷨ƥÅäÏàͬÁ¿£º"+esRets.size() + + def updateRets = processFieldsFromMatch(c , esRets, esWebSource) + + def precentMap = fieldUpdate(totalCount, updateRets) + println c +" "+precentMap.toString() + updateDB(c, updateRets) + println "------------------------------------------------------------------------------" + + def analyRet = [] + analyRet << seaweedmapSource + analyRet << c + fields.each{key-> + analyRet << precentMap.get(key) + } + analyRet << esRets.size() + analysRets << analyRet + } + return analysRets; + + } + + + def findMatchSameDatas(c, esWebSource){ + def query = new BasicDBObject("city", c).append("source", esWebSource).append("match_id", new BasicDBObject('$exists', true)).append("old_match_id", new BasicDBObject('$exists',true)) + def siteDatas = thirdSeaweedMappingColl.find(query).toList() + def rows = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(siteDatas.size()) + for(def i=0;i + list << r + }) + return list + } + def fieldUpdate(total,updateRets){ def countMap = [:] @@ -621,4 +722,26 @@ class DistrictFieldAddBatch extends BaseBatch{ jms.sendMail(email, "×Ö¶ÎÌî³äÇé¿ö·ÖÎö", sb.toString()+rh_sb.toString()); } } + + def findCommunities(url){ + if(!url){ + return null + } + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("url", url)) + def rets = [] + def datas = null + try{ + datas = ElasticUtils.executeSimpleQuery("192.168.0.206", "community", queryBuilder); + }catch(Exception e){ + findCommunities(url) + } + def obj = null + if(datas) { + for (int k = 0; k < datas.size(); k++) { + def d = datas[k]; + obj = d + } + } + return obj; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictStatRentCleanBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictStatRentCleanBatch.groovy new file mode 100644 index 000000000..edb26ccb1 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictStatRentCleanBatch.groovy @@ -0,0 +1,54 @@ +package com.fangjia.script.gj.district + +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +@BatchOwner(Watcher.GaoJuan) +class DistrictStatRentCleanBatch extends BaseBatch{ + + public static final def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; + public static final DBCollection RENT_DIST_STAT_COLL = MongoUtils.getCollectionByName2("fangjia", "district_stat_rent", mongoDbUrl) + + static main(args) { + runBatch(new DistrictStatRentCleanBatch(), args) + } + + @Override + void process(Object args) { + def citys = CommonDatautils.findAllCity() + for(def c : citys){ + def keys = CommonDatautils.getSimpleDistricts("district", c) + running(keys, c) + println c +" ÔËÐÐÍê³É" + } + } + + def running(keys, c){ + def q = new BasicDBObject("city", c).append("district_name", new BasicDBObject('$ne','')) + def fields = new BasicDBObject() + fields.put("city", 1) + fields.put("region", 1) + fields.put("district_name", 1) + def dbcursor = RENT_DIST_STAT_COLL.find(q, fields).batchSize(10000) + def delRets = [] + for(def d : dbcursor){ + if(d.district_name && !keys.contains(d.city+"@"+d.region+"@"+d.district_name)){ + println d.city+"@"+d.region+"@"+d.district_name + delRets << d._id + } + if(delRets.size()>=100){ + def delquery = new BasicDBObject() + delquery.put("_id", new BasicDBObject('$in', delRets)) + RENT_DIST_STAT_COLL.remove(delquery) + delRets.clear() + } + } + } + + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 15e4cc80b..fd1066677 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -1,16 +1,9 @@ package com.fangjia.script.gj.district import com.fangjia.core.util.HttpRequest -import com.fangjia.script.addrepo.InvokeHttpRequest -import com.fangjia.script.statistics.poi.AmapPoi -import com.fangjia.script.temp.shenjian.util.GaoDeUtils import com.fangjia.script.temp.shenjian.util.HttpUtils -import com.fangjia.script.util.HttpRequestUtil -import com.mongodb.DBObject import net.sf.json.JSONArray import net.sf.json.JSONObject -import org.apache.commons.collections.CollectionUtils -import org.apache.commons.lang.StringUtils class FangjiaClientUtils { @@ -336,7 +329,7 @@ class FangjiaClientUtils { try { address = address.replace("{","") // def url = "http://192.168.0.19:31080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8") - def url = "http://192.168.0.93:8080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8") + def url = "http://192.168.0.93:8080/FangJiaNlpService/formatFivelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=true&addressAssessment=false" if(city){ url = url +"&city="+URLEncoder.encode(city,"UTF-8") } @@ -354,7 +347,7 @@ class FangjiaClientUtils { def jsonObj = null def content = null def url = null - address = address.replace("{","") + address = address.toString().replace("{","") int retryCount = 0 while (retryCount < 3) { url = "http://192.168.0.93:8080/FangJiaNlpService/formatNinelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=false&addressAssessment=true&fields=dev_confi" @@ -398,4 +391,32 @@ class FangjiaClientUtils { return jsonObj; } + + /** + * ¾­Î³¶Èת»» + * 1¡¢¸ßµÂת°Ù¶È 2¡¢¸ßµÂתWGS84 3¡¢°Ù¶Èת¸ßµÂ 4¡¢WGS84ת¸ßµÂ 5¡¢°Ù¶ÈתWGS84 6¡¢WGS84ת°Ù¶È + */ + public static def convert(String locationstr, type){ + def jsonObj = null + def content = null + def points = [] + try { + def url = "http://192.168.0.19:31080/FangJiaNlpService/convert?locations="+URLEncoder.encode(locationstr,"UTF-8")+"&coordsys=${type}" + + content = new HttpRequest().newGet(url, null, "utf-8") + jsonObj = JSONObject.fromObject(content) + if(jsonObj && jsonObj.locations){ + def locations = jsonObj.locations + for(def s : locations){ + def arrs = s.split(",") + points = [arrs[0].toString().toDouble(), arrs[1].toString().toDouble()] + } + } + return points + } catch (Exception e) { + println e.getMessage() + } + return null; + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldAddBatch.groovy new file mode 100644 index 000000000..741193c36 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldAddBatch.groovy @@ -0,0 +1,320 @@ +package com.fangjia.script.gj.district + +import com.fangjia.core.util.ExcelUtil +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.FiledStrand +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils +import com.mongodb.BasicDBObject +import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +/** + * д×ÖÂ¥×Ö¶ÎÌî³äÈë¿â£¨×Ô¶¯Èë¿â£© + */ +@BatchOwner(Watcher.GaoJuan) +class OfficeFieldAddBatch extends BaseBatch{ + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + + def sources = ["°²¾Ó¿Íapp","°ì°ìÍø","·¿ÌìÏÂ","ÖлªÐ´×ÖÂ¥", "µãµã×â"] + + //type:×âÊÛÀà±ð wall:Íâǽ +// def fieldsMap = ["elevators_count":"elevator_num","person_elevators_count":"elevator_num","goods_elevator_count":"elevator_num","block":"block", +// "estate_type2":"property_type","estate_company":"property_company","estate_charge":"property_fee","all_area":"area", +// "standard_area":"standard_area","sight":"open_area","build_area":"build_area","build_type":"build_type","total_floor":"total_floor", +// "finish_building_date":"complete_time","loop_line_info":"ring_location","standard_height":"floor_height", +// "virescence_percent":"green_rate","cubage_percent":"volume_rate","developer":"developer","fitment":"decoration","parking":"parking_cnt", +// "feature":"characteristic","description":"introduction","parking_fee":"car_fee","property_life":"property_life","bed_kind":"level", +// "lobby_height":"lobby_height","clear_height":"clear_height","foreign":"foreign","build_structure":"structure","address":"address", +// "lng":"location","open_date":"open_date","live_date":"live_date","real_use_percent":"room_rate","land_car_site":"land_car_site", +// "underground_car_site":"underground_car_site","land_floor":"land_floor","underground_floor":"underground_floor"] + + def fieldsMap = ["build_area":"build_area"] + +// "virescence_percent":"green_rate","cubage_percent":"volume_rate","estate_charge":"property_fee","finish_building_date":"complete_time", +// "bed_kind":"level","land_car_site":"land_car_site","underground_car_site":"underground_car_site","parking_fee":"car_fee", +// "elevators_count":"elevator_num","person_elevators_count":"elevator_num","goods_elevator_count":"elevator_num","clear_height":"clear_height", +// "foreign":"foreign","standard_area":"standard_area","foreign":"foreign","parking_fee":"car_fee","estate_company":"property_company","developer":"developer","all_area":"area", + + static main(args) { +// runBatch(new OfficeFieldAddBatch(), args) + + def task = new OfficeFieldAddBatch() +// task.fieldTempProcess() + task.deleteNotNormalOffice() + } + + @Override + void process(Object args) { + def citys = ["ÉîÛÚ"]//CommonDatautils.findAllCity() + def fields = fieldsMap.keySet() as List + def analysRets = [] + for(def c : citys){ + def totalCount = CommonDatautils.findAllDistrictCount("office", c) + + sources.each {source-> + def esRets = findAllEsDataByCity(c, source) + def updateRets = processFieldsFromMatch(c , esRets, source) + + def precentMap = fieldUpdate(totalCount, updateRets) + println c +" "+precentMap.toString() + updateDB(c, updateRets) + println "------------------------------------------------------------------------------" + + def analyRet = [] + analyRet << source + analyRet << c + fields.each{key-> + analyRet << precentMap.get(key) + } + analyRet << esRets.size() + analysRets << analyRet + } + } + println analysRets.toString() + } + + def processFieldsFromMatch(c,matchRets, source){ + def fields = fieldsMap.keySet() as List + fields << "city" + def fieldValueMap = [:] + for(def esOffice : matchRets){ +// if(esOffice.name!="¶«·½½¨¸»Ê±Éй㳡"){ +// continue +// } + def office = CommonDatautils.findNormalDistrict(esOffice.city, esOffice.region, esOffice.name, "office", fields) + if(!office){ +// println c+" "+esOffice.name+" ²»´æÔÚ" + continue + } + def newValues = strandField(c, office, esOffice, source) + if(newValues){ + println office._id.toString()+" "+newValues.toString() + fieldValueMap.put(office._id.toString(), newValues) + } + } + + return fieldValueMap; + } + +// ["loop_line_info":"ring_location","feature":"characteristic","description":"introduction","lng":"location","open_date":"open_date"] + def strandField( c, office, esOffice, source){ + def newValues = [:] + fieldsMap.each{seaweedfield,esField-> + def val = office.get(seaweedfield) + if(!val){ + def esVal = esOffice.get(esField) + if(esVal){ + def newVal = null + + if(seaweedfield == "estate_type2"){ + newVal = FiledStrand.processEstateType(esVal) + } + if(seaweedfield == "estate_charge"){ + newVal = FiledStrand.processEstateCharge(c, FiledStrand.getNumber(esVal), office.estate_type2) + if(newVal) { + newVal = newVal.toString() + } + } + if(seaweedfield == "build_date" || seaweedfield == "live_date"){ + newVal = FiledStrand.processFinishBuildingDate(esVal) + } + if(seaweedfield == "estate_company" || seaweedfield == "developer"){ + newVal = FiledStrand.processCompany(esVal) + } + if(seaweedfield =="virescence_percent"){ + newVal = FiledStrand.processVirescencePercent(esVal) + } + + if(seaweedfield == "loop_line_info"){ + newVal = FiledStrand.processLoopLine(esVal) + } + if(seaweedfield =="cubage_percent"){ + newVal = FiledStrand.processCubagePercent(esVal) + } + + if(seaweedfield =="all_area" || seaweedfield =="build_area" || seaweedfield=="sight"){ + newVal = FiledStrand.processArea(esVal.toString()) + if(newVal){ + newVal = newVal.toString() + } + } + + if(seaweedfield =="car_site_count" || seaweedfield =="land_car_site" || seaweedfield =="underground_car_site"){ + newVal = FiledStrand.processCarSite(esVal) + } + + if(seaweedfield =="property_life"){ + newVal = FiledStrand.processPropertyLife(esVal) + } + + if(seaweedfield =="address"){ + newVal = FiledStrand.processAddress(esVal, office.city) + } + if(seaweedfield =="block"){ + newVal = FiledStrand.processBlock(office.city, office.region, esVal) + } + + if(seaweedfield == "fitment"){ + newVal = FiledStrand.processFitment(esVal) + } + + if(seaweedfield == "build_type"){ + newVal = FiledStrand.processBuildType(esVal, "office") + } + if(seaweedfield == "build_structure"){ + newVal = FiledStrand.processBuildStructure(esVal) + } + if(seaweedfield == "bed_kind"){ + newVal = FiledStrand.processLevel(esVal) + } + + if(seaweedfield == "total_floor" || seaweedfield == "land_floor"){ + newVal = FiledStrand.processFloor(esVal) + } + + if(seaweedfield == "underground_floor"){ + newVal = FiledStrand.processUndergroundFloor(esVal) + } + + if(seaweedfield == "real_use_percent"){ + newVal = FiledStrand.processRealUsePercent(esVal) + } + if(seaweedfield == "parking_fee"){ + newVal = FiledStrand.processCarSiteRent(esVal) + println "[ ${source} ] old: "+esVal +" new:"+newVal + } + + if(seaweedfield == "elevators_count"){ + newVal = FiledStrand.processElevators(esVal) + } + if(seaweedfield == "person_elevators_count" && esVal.contains("¿ÍÌÝ")){ + newVal = FiledStrand.processElevators(esVal.substring(esVal.indexOf("¿ÍÌÝ"))) + } + + if(seaweedfield == "goods_elevator_count" && esVal.contains("»õÌÝ")){ + newVal = FiledStrand.processElevators(esVal.substring(esVal.indexOf("»õÌÝ"))) + } + + if(seaweedfield == "standard_height" || seaweedfield=="lobby_height" || seaweedfield=="clear_height"){ + newVal = FiledStrand.processStandardHeight(esVal) + } + + if(seaweedfield == "standard_area"){ + newVal = FiledStrand.processStandardArea(esVal.toString()) + } + + if(seaweedfield == "finish_building_date"){ + newVal = FiledStrand.processFinishBuildingDate(esVal) + } + if(seaweedfield == "foreign"){ + newVal = FiledStrand.processForeign(esVal) + } + + if(newVal){ + newValues.put(seaweedfield, newVal) + } + if(seaweedfield == "lng"){ + try{ + def locationMap = FiledStrand.processLngAndLat(esVal) + if(locationMap){ + newValues.put("lat", locationMap.lat) + newValues.put("lng", locationMap.lng) + newValues.put("lat2", locationMap.lat2) + newValues.put("lng2", locationMap.lng2) + } + }catch(Exception e){ + println esVal + } + } + } + } + } + return newValues; + } + + + def findAllEsDataByCity(city, source){ + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("source", source)) + def datas = null + try{ + datas = ElasticUtils.executeSimpleQuery("192.168.0.206", "office2", queryBuilder); + }catch(Exception e){ + datas = findAllEsDataByCity(city, source) + } + + return datas; + } + + def fieldUpdate(total,updateRets){ + + def countMap = [:] + + for(def rm : updateRets){ + def valMap = rm.value + fieldsMap.each{seaweedfield,esField-> + if(valMap.containsKey(seaweedfield)) { + if(countMap.containsKey(seaweedfield)) { + countMap.put(seaweedfield, countMap.get(seaweedfield) + 1) + }else{ + countMap.put(seaweedfield, 1) + } + } + } + } + + println countMap.toString() + def precentMap = [:] + fieldsMap.each() {key,skey-> + if(countMap.containsKey(key)) { + precentMap.put(key, DataHandleUtils.getDoubleRound(2, countMap.get(key)*100/total)) + }else { + precentMap.put(key, 0) + } + } + return precentMap; + } + + def updateDB(c, updateRets){ + + for(def rm : updateRets) { + def id = rm.key + def valMap = rm.value + + BasicDBObject udata = new BasicDBObject() + valMap.each {k,v-> + udata.put(k,v) + } + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(id)),new BasicDBObject('$set',udata)) + } + } + + + def fieldTempProcess(){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\д×ÖÂ¥\\д×ÖÂ¥´ý´¦ÀíµØÖ·.xlsx",{d-> + BasicDBObject udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("address", d['F']) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(d['A'])),new BasicDBObject('$set',udata)) + }) + } + + def deleteNotNormalOffice(){ + ExcelUtils.modify("D:\\Êý¾Ý\\Êý¾Ý½¨Éè\\д×ÖÂ¥\\Ðèɾ³ýд×ÖÂ¥.xlsx",{d-> + BasicDBObject udata = new BasicDBObject() + udata.put("m_date", new Date()) + udata.put("status", 1) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(d['A'])),new BasicDBObject('$set',udata)) + }) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy index f17e815dc..1be279a43 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/OfficeFieldCleanBatch.groovy @@ -74,11 +74,11 @@ class OfficeFieldCleanBatch extends BaseBatch{ // addBlock() // addFieldValue() -// updateErrorField() + updateErrorField() // export() // test() // addOffice() - fileAddBlock() +// fileAddBlock() } def export(){ @@ -134,33 +134,196 @@ class OfficeFieldCleanBatch extends BaseBatch{ } def updateErrorField(){ -// def offices = CommonDatautils.findAllDistrict("office", ["city","estate_charge","addr_alias","property_life", "total_floor","finish_building_date","real_use_percent", "land_car_site", "underground_car_site","parking_fee"]) - def offices = CommonDatautils.findAllDistricts("ÉϺ£","office", ["city","estate_charge","addr_alias","property_life", "total_floor","finish_building_date","real_use_percent", "land_car_site", "underground_car_site","parking_fee"]) + def offices = CommonDatautils.findAllDistrict("office", ["underground_car_site"]) +// def offices = CommonDatautils.findAllDistricts("ÉϺ£","office", ["build_area"]) def totalCount = new AtomicLong() final CountDownLatch latch = new CountDownLatch(offices.size()) for(def i=0;i60 || val < 0.35){ -//// println val -// udata.put("estate_charge", null) -//// } -// } + if(udata){ udata.put("m_date", new Date()) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy index 975d618ee..beabc5fd2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/PricePkTest.groovy @@ -9,7 +9,7 @@ import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; +def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def city = "³£ÖÝ" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy new file mode 100644 index 000000000..f44d8bf4b --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy @@ -0,0 +1,414 @@ +package com.fangjia.script.gj.district + +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.FiledStrand +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +/** + * ¸ù¾ÝÁ´¼ÒÊý¾ÝÐÞ¸ÄÐ¡Çø¿âÖÐ×Ö¶Î + * ʹÓõ½ÖмäÓ³Éä±í + */ +@BatchOwner(Watcher.GaoJuan) +class UpdateDistrictField extends BaseBatch{ + + final DBCollection thirdSeaweedMappingColl = MongoUtils.getCollectionByName("fangjia_craw", "third_seaweed_mapping", "192.168.0.235", 27018) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + def fields = ["developer","estate_company","household_count","loudong_count","estate_charge","car_site_count"] + + def sources = ["Á´¼Ò", "ÎÒ°®ÎÒ¼Ò", "°²¾Ó¿Í"] + + def statMap = [:] + + static main(args) { + runBatch(new UpdateDistrictField(), args) + } + + @Override + void process(Object args) { + def sourceMap = [:] + sources.each {source-> + def valMap = findThirdMatchDist(source) + println source +" "+valMap.size() + if(valMap){ + sourceMap.put(source, valMap) + } + } + def margeResults = megerDatas(sourceMap) + updateDB(margeResults) + println "ÐÞ¸ÄÍê³É "+new Date().toString() + } + + def megerDatas(sourceMap){ + def set = new HashSet() + sources.each {source-> + def valMap = sourceMap.get(source) + set.addAll(valMap.keySet()) + } + def lastValues = [] + set.each {id-> + + def dbObj = CommonDatautils.findDistrictById(id) + + def datas = [] + sources.each {source-> + def valMap = sourceMap.get(source) + def sourceEsObj = findCommunities(valMap.get(id)) + if(sourceEsObj){ + if(source == "Á´¼Ò"){ + sourceEsObj.source = "lianjia" + }else if(source == "ÎÒ°®ÎÒ¼Ò"){ + sourceEsObj.source = "wiwj" + }else if(source == "°²¾Ó¿Í"){ + sourceEsObj.source = "anjuke" + } + datas << sourceEsObj + } + } + if(dbObj && datas){ + def newValMap = getNewField2(datas, dbObj) + if(newValMap){ + newValMap.put("id", id) + lastValues << newValMap + } + } + } + + statMap.each {source,fieldMap-> + println source +" "+fieldMap.size() + fieldMap.each{f,v-> + println f+" "+ v + } + println "----------------------------------------" + } + return lastValues + } + + +// def margeValue(lianjiaMap, wiwjMap, anjukeMap){ +// def lianjisIds = lianjiaMap.keySet() +// def wiwjIds = wiwjMap.keySet() +// def anjukeIds = anjukeMap.keySet() +// def set = new HashSet() +// set.addAll(lianjisIds) +// set.addAll(wiwjIds) +// set.addAll(anjukeIds) +// +// def lastValues = [] +// def lianjiaUpdateCount = 0 +// def wiwjUpdateCount = 0 +// def anjukeUpdateCount = 0 +// def lianjiaCountMap = [:] +// def wiwjCountMap = [:] +// def anjukeCountMap = [:] +// set.each {id-> +// BasicDBObject newValMap = new BasicDBObject() +// fields.each {field-> +// def lianjiaValMap = lianjiaMap.get(id) +// def wiwjValMap = wiwjMap.get(id) +// def anjukeValMap = anjukeMap.get(id) +// if(lianjiaValMap && lianjiaValMap.containsKey(field)){ +// newValMap.put(field, lianjiaValMap.get(field)) +// lianjiaUpdateCount++ +// def count = lianjiaCountMap.get(field) +// if(!count){ +// lianjiaCountMap.put(field, 1) +// }else{ +// lianjiaCountMap.put(field, count + 1) +// } +// }else if(wiwjValMap && wiwjValMap.containsKey(field)){ +// newValMap.put(field, wiwjValMap.get(field)) +// wiwjUpdateCount++ +// def count = wiwjCountMap.get(field) +// if(!count){ +// wiwjCountMap.put(field, 1) +// }else{ +// wiwjCountMap.put(field, count + 1) +// } +// }else if(anjukeValMap && anjukeValMap.containsKey(field)){ +// newValMap.put(field, anjukeValMap.get(field)) +// anjukeUpdateCount++ +// def count = anjukeCountMap.get(field) +// if(!count){ +// anjukeCountMap.put(field, 1) +// }else{ +// anjukeCountMap.put(field, count + 1) +// } +// } +// } +// newValMap.put("id", id) +// lastValues << newValMap +// } +// +// lianjiaCountMap.each {k,v-> +// println "[Á´¼Ò] "+k+" "+v +// } +// +// wiwjCountMap.each {k,v-> +// println "[ÎÒ°®ÎÒ¼Ò] "+k+" "+v +// } +// +// anjukeCountMap.each {k,v-> +// println "[°²¾Ó¿Í] "+k+" "+v +// } +// return lastValues +// } + + def updateDB(margeResults){ + for(def mr : margeResults){ + def id = mr.get("id") + mr.remove("id") + mr.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(id)),new BasicDBObject('$set',mr)) + } + } + +// def batchUpdateDist(source){ +//// def rets = findThirdMatchDist(source) +// println "[${source}] ·û±£Ìõ¼þÐ¡ÇøÁ¿£º"+rets.size() +// def updateIndex = new AtomicLong() +// final CountDownLatch latch = new CountDownLatch(rets.size()) +// def allUpdateList = new CopyOnWriteArrayList() +// +// def sourceMap = new ConcurrentHashMap() +// +// for(def i=0;i +// def count = countMap.get(k) +// if(!count){ +// countMap.put(k, 1) +// }else{ +// countMap.put(k, count+1) +// } +// } +// } +// +// countMap.each {k,v-> +// println k +" ¸üÐÂÁ¿£º"+v +// } +// +// println "---------------------------------------------------------" +// return sourceMap +// } + + def running(url, old_match_id){ + def esObj = findCommunities(url) + def dbObj = CommonDatautils.findDistrictById(old_match_id) + if(dbObj){ + def newValMap = getNewField(esObj, dbObj) + return newValMap + } + return null + } + + def getNewField(esObj, dbObj){ + BasicDBObject newValMap = new BasicDBObject() + esObj.each{field, esVal-> + def dbVal = dbObj.get(field) + def newVal = null + if(esVal && field=="developer" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + + } + if(esVal && field=="estate_company" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(esVal && field=="household_count" && esVal!=dbVal){ + newVal = FiledStrand.processHouseholdCount(esVal, dbObj.estate_type2) + } + + if(esVal && field=="loudong_count" && esVal!=dbVal){ + newVal = FiledStrand.processLoudongCount(esVal) + } + + if(esVal && field=="estate_charge" && esVal!=dbVal){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toDouble()!=dbVal){ + newVal = FiledStrand.processEstateCharge(dbObj.city, numVal, dbObj.estate_type2) + newVal = newVal.toString() + } + } + if(esVal && field=="car_site_count"){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toInteger()!=dbVal){ + newVal = FiledStrand.processCarSite(numVal) + } + } + if(newVal){ + newValMap.put(field, newVal) + } + + } + + return newValMap + } + + def getNewField2(esDatas, dbObj){ + BasicDBObject newValMap = new BasicDBObject() + def lastValueMap = [:] + def haveValueMap = [:] + fields.each{field-> + for(def esData : esDatas){ + def esVal = esData.get(field) + def dbVal = dbObj.get(field) + def newVal = null + if(haveValueMap.containsKey(field)){ + continue + }else{ + if(lastValueMap.containsKey(field)){ + continue + } + if(esVal){ + + if(field=="estate_charge" || field=="car_site_count") { + esVal = FiledStrand.getNumber(esVal) + } + if(dbVal && esVal.toString()==dbVal.toString()){ + haveValueMap.put(field, esVal) + }else{ + if(field=="developer" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(field=="estate_company" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(field=="household_count" && esVal!=dbVal){ + newVal = FiledStrand.processHouseholdCount(esVal, dbObj.estate_type2) + } + + if(esVal && field=="loudong_count" && esVal!=dbVal){ + newVal = FiledStrand.processLoudongCount(esVal) + } + + if(field=="estate_charge" && esVal!=dbVal){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toDouble()!=dbVal){ + newVal = FiledStrand.processEstateCharge(dbObj.city, numVal, dbObj.estate_type2) + newVal = newVal.toString() + } + } + if(field=="car_site_count"){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toInteger()!=dbVal){ + newVal = FiledStrand.processCarSite(numVal) + } + } + } + } + if(newVal){ + lastValueMap.put(field, newVal) + + //ÒÔÏÂΪͳ¼Æ¸÷ÍøÕ¾¸÷×ֶεĸüÐÂÇé¿ö + def fieldStatMap = statMap.get(esData.source) + if(!fieldStatMap){ + fieldStatMap = [:] + statMap.put(esData.source, fieldStatMap) + } + def count = fieldStatMap.get(field) + if(!count){ + fieldStatMap.put(field, 1) + }else{ + fieldStatMap.put(field, count + 1) + } + } + } + } + } + return lastValueMap + } + + def findThirdMatchDist(source){ + def query = new BasicDBObject("source",source).append("old_match_way", 1) + def keys = new BasicDBObject() + keys.put("url", 1) + keys.put("old_match_id", 1) + keys.put("old_match_city", 1) + keys.put("old_match_district", 1) + keys.put("old_match_name", 1) + def idsMap = [:] + def dbcursor = thirdSeaweedMappingColl.find(query, keys) + for(def db : dbcursor){ + if(!db.old_match_id && db.old_match_name){ + def dbo = CommonDatautils.findDistrict(db.old_match_city, db.old_match_district, db.old_match_name, "district") + if(dbo){ + idsMap.put(dbo._id.toString(), db.url) + } + }else{ + idsMap.put(db.old_match_id, db.url) + } + + } + return idsMap + } + + static def findCommunities(url){ + if(!url){ + return null + } + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("url", url)) + def rets = [] + def datas = null + try{ + datas = ElasticUtils.executeSimpleQuery("192.168.0.206", "community", queryBuilder); + }catch(Exception e){ + findCommunities(url) + } + def data = [:] + if(datas) { + for (int k = 0; k < datas.size(); k++) { + def d = datas[k]; + data.put("household_count", d.households) + data.put("loudong_count", d.loudong_cnt) + data.put("developer", d.developer) + data.put("estate_company", d.property_company) + data.put("estate_charge", d.property_fee) + data.put("car_site_count", d.parking_cnt) + } + } + return data; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy index 9be75aeb0..d5d3956e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy @@ -14,7 +14,7 @@ import org.apache.lucene.queryparser.classic.QueryParser class EsMonthHouseStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { @@ -26,7 +26,8 @@ class EsMonthHouseStat { // task.statHouseUpdateCount() // task.statDistHouse() - task.statRent() +// task.statRent() +// task.statOfficeHouse() } def statRent(){ @@ -201,6 +202,51 @@ class EsMonthHouseStat { },0) } + def statOfficeHouse(){ + def citys = CommonDatautils.findAllCity() + def allLists = [] + allLists << ["³ÇÊÐ", "½üÒ»Äêд×ÖÂ¥³öÊÛÁ¿", "д×ÖÂ¥Á¿", "½üÒ»Äê³öÊÛ·¿Ô´Á¿´óÓÚ3µÄд×ÖÂ¥Á¿", "´óÓÚ3д×ÖÂ¥Á¿Õ¼±È"] + citys.each{c-> + def count = findHouseCountByCat(c, "office_sell",20240101, 20250201) + + def districts = CommonDatautils.findAllDistricts(c, "office", ["city", "region", "name", "alias"]); + def disthouseCount = 0 + for(def dist : districts){ + def alias = [] + if(dist.alias){ + if(!dist.alias.contains(dist.name)){ + dist.alias << dist.name + } + alias = dist.alias + }else{ + alias << dist.name + } + + def distCount = 0 + if(count){ + distCount = findHouseCountByCat(dist.city, dist.region, alias, 20240101, 20250201, "office_sell") + if(distCount && distCount>=3){ + disthouseCount++ + } + } +// println dist.city+" "+dist.region+" "+dist.name+" "+distCount + } + + println "disthouseCount:"+disthouseCount +// println districts.size() + def precent = 0 + if(districts){ + precent = DataHandleUtils.getDoubleRound(2, disthouseCount*100.0/districts.size()) + } + def row = [c , count, districts.size(), disthouseCount, precent+"%"] + println row + allLists << row + } + + ExcelUtils.write("D:\\Êý¾Ý\\д×ÖÂ¥\\È«¹úд×ÖÂ¥Çé¿öÕ¼±Èͳ¼Æ.xlsx", allLists, "д×ÖÂ¥Çé¿ö") + + } + def findHouseCount(def city, def region, def alias, def startDate, def endDate){ def aliasStr = null; @@ -219,6 +265,23 @@ class EsMonthHouseStat { return total } + def findHouseCountByCat(def city, def region, def alias, def startDate, def endDate, cat){ + def aliasStr = null; + def total = 0 + try{ + aliasStr = escapeExprSpecialWord(alias.join("','")) + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} and region='${region}' and district_name in ('${aliasStr}') " + + ElasticUtils.executeSqlQuery(sql,{data-> + total = data.c + }) + }catch(Exception e){ + e.printStackTrace() + } + + return total + } + /** * תÒå×Ö·û´®ÖеÄÌØÊâ×Ö·û * ½ö¹ýÂËLucene regexps, ÆäËûµÄÎðÓà @@ -240,6 +303,17 @@ class EsMonthHouseStat { } + def findHouseCountByCat(def city, def cat, def startDate, def endDate){ + + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} " + def total = 0 + ElasticUtils.executeSqlQuery(sql,{ data-> + total = data.c + }) + return total + } + + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/OfficeStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/OfficeStat.groovy new file mode 100644 index 000000000..eaae19e43 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/OfficeStat.groovy @@ -0,0 +1,254 @@ +package com.fangjia.script.gj.es + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils + +class OfficeStat { + static main(args) { + def task = new OfficeStat() +// task.run() +// task.sampleFieldPrecent() +// task.cityRun() + task.tempStat() + } + + def tempStat(){ + ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\д×ÖÂ¥\\д×ÖÂ¥×â½ðͳ¼Æ.xlsx",{d-> + def cityObj = CommonDatautils.findAlCityDetail(d['A']) + if(cityObj){ + if(cityObj.new_city_grade==1000){ + d['P'] = "Ò»Ïß" + }else if(cityObj.new_city_grade==1500){ + d['P'] = "ÐÂÒ»Ïß" + }else if(cityObj.new_city_grade==2000){ + d['P'] = "¶þÏß" + }else if(cityObj.new_city_grade==3000){ + d['P'] = "ÈýÏß" + }else if(cityObj.new_city_grade==4000){ + d['P'] = "ËÄÏß" + }else if(cityObj.new_city_grade==5000){ + d['P'] = "ÎåÏß" + } + } +// def count3s = [] +// if(d['C']>=3){ +// count3s << d['C'] +// } +// if(d['D']>=3 ){ +// count3s << d['D'] +// } +// if(d['E']>=3 ){ +// count3s << d['E'] +// } +// if(d['F']>=3 ){ +// count3s << d['F'] +// } +// if(d['G']>=3 ){ +// count3s << d['G'] +// } +// if(d['H']>=3 ){ +// count3s << d['H'] +// } +// if(d['I']>=3 ){ +// count3s << d['I'] +// } +// if(d['J']>=3 ){ +// count3s << d['J'] +// } +// if(d['K']>=3 ){ +// count3s << d['K'] +// } +// if(d['L']>=3 ){ +// count3s << d['L'] +// } +// if(d['M']>=3 ){ +// count3s << d['M'] +// } +// if(d['N']>=3 ){ +// count3s << d['N'] +// } +// d['O'] = DataHandleUtils.getDoubleRound(4, count3s.size()/12) + },2) + } + + def sampleFieldPrecent(){ + def citys = CommonDatautils.findAllCity() + def rets = [] + rets << ["³ÇÊÐ","ÇøÓò","Ãû³Æ","¼¶±ð","Ãæ»ý","×î¸ßÂ¥","×°ÐÞ","µ¥¼Û£¨Ôª/ƽÃ×/Ì죩","·¢²¼Ê±¼ä","×ÜÁ¿"] + citys.each { c -> + def regionMap = CommonDatautils.getRegionsByCity(c) + def ret = sampleFieldStat(c, regionMap, "office_rent") + rets.addAll(ret) + } + ///home/goojia/gj + ExcelUtils.write("D:\\Êý¾Ý\\д×ÖÂ¥\\д×ÖÂ¥×â½ðͳ¼Æ.xlsx", rets, "д×ÖÂ¥×â½ðÑù±¾×ֶθ²¸ÇÂÊ") + } + def run(){ + def citys = CommonDatautils.findAllCity() + def rets = [] + rets << ["³ÇÊÐ","ÇøÓò","½ü1¸öÔÂÑù±¾Á¿","½ü2¸öÔÂÑù±¾Á¿","½ü3¸öÔÂÑù±¾Á¿","½ü4¸öÔÂÑù±¾Á¿","½ü5¸öÔÂÑù±¾Á¿","½ü6¸öÔÂÑù±¾Á¿","½ü7¸öÔÂÑù±¾Á¿","½ü8¸öÔÂÑù±¾Á¿","½ü9¸öÔÂÑù±¾Á¿","½ü10¸öÔÂÑù±¾Á¿","½ü11¸öÔÂÑù±¾Á¿","½ü12¸öÔÂÑù±¾Á¿","Ñù±¾¸²¸ÇÂÊ(ÇøÓò×ßÊÆ£©" ] + citys.each{c-> + def regionMap = CommonDatautils.getRegionsByCity(c) + def ret = statHouse(c, regionMap, "office_rent") + rets.addAll(ret) + } + ExcelUtils.write("D:\\Êý¾Ý\\д×ÖÂ¥\\д×ÖÂ¥×â½ðͳ¼Æ.xlsx", rets, "д×ÖÂ¥ÇøÓò×â½ðÑù±¾¸²¸ÇÂÊ") + } + + def cityRun(){ + def citys = CommonDatautils.findAllCity() + def rets = [] + rets << ["³ÇÊÐ","ÇøÓò","½ü1¸öÔÂÑù±¾Á¿","½ü2¸öÔÂÑù±¾Á¿","½ü3¸öÔÂÑù±¾Á¿","½ü4¸öÔÂÑù±¾Á¿","½ü5¸öÔÂÑù±¾Á¿","½ü6¸öÔÂÑù±¾Á¿","½ü7¸öÔÂÑù±¾Á¿","½ü8¸öÔÂÑù±¾Á¿","½ü9¸öÔÂÑù±¾Á¿","½ü10¸öÔÂÑù±¾Á¿","½ü11¸öÔÂÑù±¾Á¿","½ü12¸öÔÂÑù±¾Á¿","Ñù±¾¸²¸ÇÂÊ(ÇøÓò×ßÊÆ£©" ] + citys.each{c-> + def ret = statCityHouse(c, "office_rent") + rets.addAll(ret) + } + ExcelUtils.write("D:\\Êý¾Ý\\д×ÖÂ¥\\д×ÖÂ¥×â½ðͳ¼Æ.xlsx", rets, "д×ÖÂ¥³ÇÊÐ×â½ðÑù±¾¸²¸ÇÂÊ") + } + + def statHouse(city, regionMap, cat){ + def regions = regionMap.keySet() + def rows = [] + def months = [20250201, 20250101,20241201,20241101,20241001,20240901,20240801,20240701,20240601,20240501,20240401,20240301,20240201] + regions.each{region-> + def row = [] + row << city + row << region + + def count3s = [] + for(def i=1;i=3){ + count3s << count + } + } + def precent = DataHandleUtils.getDoubleRound(4, count3s.size()/12) + row << precent + println row + rows << row + } + return rows + } + + def statCityHouse(city, cat){ + def months = [20250201, 20250101,20241201,20241101,20241001,20240901,20240801,20240701,20240601,20240501,20240401,20240301,20240201] + def row = [] + row << city + + def count3s = [] + for(def i=1;i=3){ + count3s << count + } + } + def precent = DataHandleUtils.getDoubleRound(4, count3s.size()/12) + row << precent + println row + return row + } + + def sampleFieldStat(city, regionMap, cat){ + def regions = regionMap.keySet() + def rows = [] + regions.each{region-> + def results = findHouseByCat(city, region, cat, 20240201,20250201) + def row = [] + def total = results.size() + def nameCount = 0 + def levelCount = 0 + def heightCount = 0 + def areaCount = 0 + def priceCount = 0 + def dateCount = 0 + def fitmentCount = 0 + row << city + row << region + results.each{m-> + def name = m.get("name") + if(name){ + nameCount++ + } + + def level = m.get("level") + if(level){ + levelCount++ + } + + def height = m.get("height") + if(height){ + heightCount++ + } + + def fitment = m.get("fitment") + if(fitment){ + fitmentCount++ + } + + def area = m.get("area") + if(area){ + areaCount++ + } + def day_rent_price = m.get("day_rent_price") + if(day_rent_price){ + priceCount++ + } + + def p_date = m.get("p_date") + if(p_date){ + dateCount++ + } + } + if(total){ + row << DataHandleUtils.getDoubleRound(4, nameCount/total) + row << DataHandleUtils.getDoubleRound(4, levelCount/total) + row << DataHandleUtils.getDoubleRound(4, areaCount/total) + row << DataHandleUtils.getDoubleRound(4, heightCount/total) + row << DataHandleUtils.getDoubleRound(4, fitmentCount/total) + row << DataHandleUtils.getDoubleRound(4, priceCount/total) + row << DataHandleUtils.getDoubleRound(4, dateCount/total) + }else{ + row << 0 + row << 0 + row << 0 + row << 0 + row << 0 + row << 0 + row << 0 + } + + row << total + rows << row + println row + } + return rows + } + + + def findHouseCountByCat(def city, def region, def cat, def startDate, def endDate){ + + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} " + if(region){ + sql = sql + " and region='${region}'" + } + def total = 0 + ElasticUtils.executeSqlQuery(sql,{ data-> + total = data.c + }) + return total + } + + def findHouseByCat(def city, def region, def cat, def startDate, def endDate){ + + String sql = "select * from latest_seawater where cat='${cat}' and city='${city}' and region='${region}' and p_date >= ${startDate} and p_date<${endDate} " + def results =[] + ElasticUtils.executeSqlQuery(sql,{ data-> + results << ["level":data.level,"name":data.district_name,"day_rent_price":data.total_price,"height":data.height,"area":data.area,"p_date":data.p_date,"fitment":data.fitment] + }) + return results + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy index e4a76bd99..f37ffa535 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwBigdataDealBatch.groovy @@ -5,6 +5,7 @@ import com.fangjia.core.util.DataUtil import com.fangjia.script.BaseBatch import com.fangjia.script.BatchOwner import com.fangjia.script.Watcher +import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.ccb.CcbCodeUtils import com.fangjia.script.gj.district.SeaweedDataMatchProcess import com.fangjia.script.util.DateUtils @@ -25,7 +26,7 @@ import java.util.regex.Pattern @BatchOwner(Watcher.GaoJuan) class FjwBigdataDealBatch extends BaseBatch{ - def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -24, "yyyyMM")); + def startDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -12, "yyyyMM")); def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMMdd"), -1, "yyyyMMdd")); @@ -37,7 +38,7 @@ class FjwBigdataDealBatch extends BaseBatch{ DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", @@ -52,11 +53,11 @@ class FjwBigdataDealBatch extends BaseBatch{ def citys = CcbCommonUtils.getRunningCitys(["all"]) -// println "curDate:"+curDate -// def allCitys = CommonDatautils.findAllCity() -// for(def city : allCitys){ -// addDealPriceMatch(city); -// } + println "curDate:"+curDate + def allCitys = CommonDatautils.findAllCity() + for(def city : allCitys){ + addDealPriceMatch(city); + } def rows = [] def headers = []//["³ÇÊÐID","³É½»ID","³ÇÊÐÃû³Æ","ÐÐÕþÇøID","ÐÐÕþÇøÃû³Æ","½ÖµÀ","ÃÅÅÆºÅ","Ð¡ÇøID","Ð¡ÇøÃû³Æ","Â¥¶°ID","Â¥¶°±àºÅ","Â¥¶°Ãû³Æ","µ¥ÔªID","µ¥Ôª±àºÅ","µ¥ÔªÃû³Æ","»§ID","ÏêϸµØÖ·","½¨ÖþÄê´ú","ȨÊô","ȨÊôÄêÏÞ","ÆÚÊý","ËùÔÚÂ¥²ã","²ãÀàÐÍ","×ÜÂ¥²ãÊý","½¨ÖþÀàÐÍ","½¨Öþ½á¹¹","½¨ÖþÃæ»ý","Ì×ÄÚÃæ»ý","»§ÐÍ","ÊÒ","Ìü","³ø","ÎÀ","·¿ÎÝÓÃ;","ÊÒÄڽṹ","³¯Ïò","×°ÐÞÇé¿ö","ÆÀ¹À±àºÅ","³É½»µ¥¼Û","³É½»×ܼÛ","É걨×ܼÛ","ÆÀ¹À×ܼÛ","ÍøÇ©ºÏͬ±àºÅ","½»Ò×ÈÕÆÚ","½»Ò×ÀàÐÍ","³öÊÛ¸¶¿î·½Ê½","³É½»ÖÜÆÚ","ÊÇ·ñÓеçÌÝ","ÔùËÍÃæ»ý£¨µØÃ滨԰£©","ÔùËÍÃæ»ý£¨Â¶Ì¨£©","ÔùËÍÃæ»ý£¨Ñǫ̂£©","ÔùËÍÃæ»ý£¨Æ®´°£©","ÔùËÍÃæ»ý£¨¸óÂ¥£©","ÔùËÍÃæ»ý£¨³µ¿â£©","ÔùËÍÃæ»ý£¨µØÏÂÊÒ£©","ÔùËÍÃæ»ý£¨ÆäËû£©","·¿Ô´Êý¾ÝÀ´Ô´","Öн鹫˾ID","Öн鹫˾Ãû³Æ","±¸×¢","´´½¨Ê±¼ä","¸üÐÂʱ¼ä","À´Ô´¹«Ë¾","³É½»½ð¶î","Êý¾Ýʱ¼ä"] @@ -519,7 +520,7 @@ class FjwBigdataDealBatch extends BaseBatch{ def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) - +// def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20250131", "yyyyMMdd")) // def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20240501", "yyyyMMdd")) // def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20240701", "yyyyMMdd"))//DateUtils.getFirstDayOfMonth(new Date()) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy index f1925938e..c5f33716f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy @@ -29,11 +29,14 @@ class FjwThirdPartyPriceBatch extends BaseBatch { def endDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); //202304 // def curDate = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -6, "yyyyMM")); - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - def sourceMap = ["Öî¸ðÕÒ·¿":"01", "°²¾Ó¿Í":"02","·¿ÌìÏÂ":"03","Á´¼Ò":"04","³ÇÊмҾÓ":"05","ÂóÌï":"06","±´¿Ç":"07","ÌÔ·¿365":"08","ÖÐÔ­":"09","Íò©Ê¿":"10","Q·¿":"11","·¿Ì½":"12", - "·¿¶à¶à":"13","ÎÒ°®ÎÒ¼Ò":"14","ìûÌ©Êý¾Ý":"15","¼ªÎÝÍø":"16","ÀÖ¾Ó":"17","21ÊÀ¼Í":"18","·¿²ú³¬ÊÐ":"19","58ͬ³Ç":"20"] + def sourceMap = ["Öî¸ðÕÒ·¿":"01", "°²¾Ó¿Í":"02","·¿ÌìÏÂ":"03","Á´¼Ò":"04","³ÇÊмҾÓ":"05","ÂóÌï":"06","±´¿Ç":"07", + "ÌÔ·¿365":"08","ÖÐÔ­":"09","Íò©Ê¿":"10","Q·¿":"11","·¿Ì½":"12","·¿¶à¶à":"13","ÎÒ°®ÎÒ¼Ò":"14", + "ìûÌ©Êý¾Ý":"15","¼ªÎÝÍø":"16","ÀÖ¾Ó":"17","21ÊÀ¼Í":"18","·¿²ú³¬ÊÐ":"19","58ͬ³Ç":"20", + "ÀÖÓмÒ":"21","ÐÒ¸£Àï":"22","Öйú·¿¼ÛÐÐÇé":"23","³£ÖÝס·¿":"24" + ] def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", @@ -269,6 +272,33 @@ class FjwThirdPartyPriceBatch extends BaseBatch { if(third.get("fccs_esf_price")){ price_map.fccs_avg_price = third.get("fccs_esf_price") } + if(third.get("csjj_esf_price")){ + price_map.csjj_avg_price = third.get("csjj_esf_price") + } + + if(third.get("leyoujia_esf_price")){ + price_map.leyoujia_avg_price = third.get("leyoujia_esf_price") + } + + if(third.get("c21_esf_price")){ + price_map.c21_avg_price = third.get("c21_esf_price") + } + + if(third.get("jiwu_esf_price")){ + price_map.jiwu_avg_price = third.get("jiwu_esf_price") + } + + if(third.get("xingfuli_esf_price")){ + price_map.xingfuli_avg_price = third.get("xingfuli_esf_price") + } + + if(third.get("zwfc_esf_price")){ + price_map.zwfc_avg_price = third.get("zwfc_esf_price") + } + + if(third.get("creprice_esf_price")){ + price_map.creprice_avg_price = third.get("creprice_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -317,6 +347,20 @@ class FjwThirdPartyPriceBatch extends BaseBatch { web = "ÎÒ°®ÎÒ¼Ò" }else if(k=="fccs_avg_price"){ web = "·¿²ú³¬ÊÐ" + }else if(k=="csjj_avg_price"){ + web = "³ÇÊоӼÒ" + }else if(k=="leyoujia_avg_price"){ + web = "ÀÖÓмÒ" + }else if(k=="c21_avg_price"){ + web = "C21" + }else if(k=="jiwu_avg_price"){ + web = "¼ªÎÝÍø" + }else if(k=="xingfuli_avg_price"){ + web = "ÐÒ¸£Àï" + }else if(k=="creprice_avg_price"){ + web = "Öйú·¿¼ÛÐÐÇé" + }else if(k=="zwfc_avg_price"){ + web = "³£ÖÝס·¿" } ret << sourceMap.get(web) @@ -470,6 +514,33 @@ class FjwThirdPartyPriceBatch extends BaseBatch { dataMap.put("fccs_esf_price", db.get("fccs_esf_price")) } + if(!dataMap.get("csjj_esf_price") && db.get("csjj_esf_price") && db.get("csjj_esf_price")>3000){ + dataMap.put("csjj_esf_price", db.get("csjj_esf_price")) + } + + if(!dataMap.get("leyoujia_esf_price") && db.get("leyoujia_esf_price") && db.get("leyoujia_esf_price")>3000){ + dataMap.put("leyoujia_esf_price", db.get("leyoujia_esf_price")) + } + + if(!dataMap.get("c21_esf_price") && db.get("c21_esf_price") && db.get("c21_esf_price")>3000){ + dataMap.put("c21_esf_price", db.get("c21_esf_price")) + } + + if(!dataMap.get("jiwu_esf_price") && db.get("jiwu_esf_price") && db.get("jiwu_esf_price")>3000){ + dataMap.put("jiwu_esf_price", db.get("jiwu_esf_price")) + } + + if(!dataMap.get("xingfuli_esf_price") && db.get("xingfuli_esf_price") && db.get("xingfuli_esf_price")>3000){ + dataMap.put("xingfuli_esf_price", db.get("xingfuli_esf_price")) + } + + if(!dataMap.get("creprice_esf_price") && db.get("creprice_esf_price") && db.get("creprice_esf_price")>3000){ + dataMap.put("creprice_esf_price", db.get("creprice_esf_price")) + } + + if(!dataMap.get("zwfc_esf_price") && db.get("zwfc_esf_price") && db.get("zwfc_esf_price")>3000){ + dataMap.put("zwfc_esf_price", db.get("zwfc_esf_price")) + } // if(db.zhugezhaofang_esf_price || db.anjuke_esf_price ||db.soufang_esf_price || db.lianjia_esf_price || db.cityhouse_esf_price || db.maitian_esf_price || db.beike_esf_price || db.get("365house_esf_price") || db.zhongyuan_esf_price || db.tuboshi_esf_price || db.qfang_esf_price || db.fangtan_esf_price || db.fangduoduo_esf_price || db.get("5i5j_esf_price")){ // map.put(key, db) // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy index 7a00efd46..da8902cab 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/guangfa/GuangfaBlankSelectDistrict.groovy @@ -27,7 +27,7 @@ class GuangfaBlankSelectDistrict { public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; public static final DBCollection youda_esfhouse_coll = MongoUtils.getCollectionByName2("business", "res_esfdealprice", offlineUrl) - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new GuangfaBlankSelectDistrict(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy index 9ba1fe9ca..e545a78e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy @@ -38,8 +38,8 @@ class AddDistImagesBatch extends BaseBatch{ @Override public void process(Object args) { -// def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1), "yyyy-MM-dd") def mdate = DateUtils.getFirstDayOfMonth(new Date(), -1) +// def mdate = DateUtils.getFirstDayOfMonth(new Date(), -1) def citys = CommonUtils.findAllCity() citys.each {city-> def communitys = findAllEsData2(city, mdate) @@ -47,14 +47,13 @@ class AddDistImagesBatch extends BaseBatch{ //µÚÈý·½Æ¥ÅäÐ¡Çø matchCommunitys(communitys) } + + statImgCount() } - - - def findAllEsData2(city, mdate){ QueryBuilder date_range = QueryBuilders.rangeQuery("m_date").from(mdate.getTime()).includeLower(true) - - QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("source", "°²¾Ó¿ÍС³ÌÐò")) + //°²¾Ó¿ÍС³ÌÐò + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("source", "±´¿ÇÕÒ·¿")) .must(date_range).must(date_range) def rets = [] @@ -106,41 +105,69 @@ class AddDistImagesBatch extends BaseBatch{ def total = communitys.size() for(def i=0;i + floor_count = floor_count + v.size() + } + } + } + println out_pics_count + println floor_count + } + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy index e80dd9c35..030658e63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/RegionPoint.groovy @@ -5,6 +5,7 @@ import com.fangjia.core.RegionData import com.fangjia.core.util.HttpRequest import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject +import com.mongodb.Bytes import com.mongodb.DBCollection import net.sf.json.JSONObject import org.apache.commons.lang.math.RandomUtils @@ -17,8 +18,9 @@ import java.util.regex.Pattern */ class RegionPointCrawl { - static DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline") + static DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline_2025") static DBCollection GAODECITYCODECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "gaode_city_code") + static DBCollection OLD_POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_crawl", "region_polyline") static main(args) { def task = new RegionPointCrawl(); @@ -26,16 +28,19 @@ class RegionPointCrawl { //4¸öֱϽÊÐ ±±¾©ÊС¢ÉϺ£ÊС¢Ìì½òÊС¢ÖØÇìÊÐ //5¸ö×ÔÖÎÇø "ÄÚÃɹÅ×ÔÖÎÇø","¹ãÎ÷׳×å×ÔÖÎÇø","Î÷²Ø×ÔÖÎÇø","ÄþÏÄ»Ø×å×ÔÖÎÇø","н®Î¬Îá¶û×ÔÖÎÇø" // def provinces = ["ºÓ±±Ê¡", "ɽÎ÷Ê¡","¼ªÁÖÊ¡","ÁÉÄþÊ¡", "ºÚÁú½­Ê¡", "ÉÂÎ÷Ê¡", "¸ÊËàÊ¡", "Çຣʡ", "ɽ¶«Ê¡", "¸£½¨Ê¡", "Õã½­Ê¡", "̨ÍåÊ¡", "ºÓÄÏÊ¡", "ºþ±±Ê¡", "ºþÄÏÊ¡", "½­Î÷Ê¡", "½­ËÕÊ¡", "°²»ÕÊ¡", "¹ã¶«Ê¡", "º£ÄÏÊ¡", "ËÄ´¨Ê¡", "¹óÖÝÊ¡", "ÔÆÄÏÊ¡"] - def provinces = ["¸ÊËàÊ¡"] - def index = 0 - for(def p : provinces){ - index ++ - println index +"/"+provinces.size() +" "+p - task.crawlCityAndDistrictCode(p); - println "³ÇÊÐ ÇøÓò code Íê³É" - task.run(p); - println "ÇøÓòΧÀ¸ Íê³É" - } + //ÒÑÅÜ£º¸ÊËàÊ¡£¬ºÓ±±Ê¡,ɽÎ÷Ê¡,"¼ªÁÖÊ¡","ÁÉÄþÊ¡", "ºÚÁú½­Ê¡", "ÉÂÎ÷Ê¡", "Çຣʡ", "ɽ¶«Ê¡", "¸£½¨Ê¡", "Õã½­Ê¡", "̨ÍåÊ¡", "ºÓÄÏÊ¡", "ºþ±±Ê¡", "ºþÄÏÊ¡", "½­Î÷Ê¡", "½­ËÕÊ¡", "°²»ÕÊ¡", "¹ã¶«Ê¡", "º£ÄÏÊ¡", "ËÄ´¨Ê¡", "¹óÖÝÊ¡","ÔÆÄÏÊ¡" +// def provinces = ["±±¾©ÊÐ","ÉϺ£ÊÐ","Ìì½òÊÐ","ÖØÇìÊÐ" ] +// def index = 0 +// for(def p : provinces){ +// index ++ +// println index +"/"+provinces.size() +" "+p +// task.crawlCityAndDistrictCode(p); +// println "³ÇÊÐ ÇøÓò code Íê³É" +// task.run(p); +// println "ÇøÓòΧÀ¸ Íê³É" +// } + + task.statSame() } @@ -47,7 +52,10 @@ class RegionPointCrawl { def cityCodes = findCityCode(pro); if(cityCodes){ for(def cityMap : cityCodes){ - def codeMap = findAllDistrictCode(cityMap.city_code); + def codeMap = findAllDistrictCode(cityMap.city_code, "district"); +// if(!codeMap){ +// codeMap = findAllDistrictCode(cityMap.city_code, "street"); +// } def index = 0 for(def m : codeMap){ index ++ @@ -93,7 +101,7 @@ class RegionPointCrawl { def saveGaoDeRegionCode(province, cityName,districts){ if(districts){ for(def dist : districts){ - if(dist.level=="district" || cityName=="¶«Ý¸ÊÐ"){ + if(dist.level=="district" || dist.level=="street" ){ saveGaoDeCityRegionCode(province, dist.name, dist.citycode, dist.adcode, dist.center, dist.level); } } @@ -125,10 +133,10 @@ class RegionPointCrawl { return new BasicDBObject("$regex", pattern); } - def findAllDistrictCode(def citycode){ + def findAllDistrictCode(def citycode, def level){ def q = new BasicDBObject() q.put("city_code", citycode) - q.put("level", "district") + q.put("level", level) def dbcursor = GAODECITYCODECOLL.find(q) def rets = [] for(def d : dbcursor){ @@ -149,6 +157,7 @@ class RegionPointCrawl { def o = GAODECITYCODECOLL.findOne(q) if(!o){ + println name +" "+adcode+" ÐÂÔö" q.put("c_date", new Date()) q.put("center", center) GAODECITYCODECOLL.save(q); @@ -233,4 +242,62 @@ class RegionPointCrawl { def count = RandomUtils.nextInt(KeyList.size()) return KeyList.get(count); } + + def statSame(){ + def dbcursor = POLYLINECOLL.find(new BasicDBObject()).setOptions(Bytes.QUERYOPTION_NOTIMEOUT) + + def index = 0 + for(def d : dbcursor){ + index++ + def q = new BasicDBObject() + q.put("city",d.city) + q.put("region", d.region) + def obj = OLD_POLYLINECOLL.findOne(q) + if(obj){ + if(obj.polyline!=d.polyline){ + println index +" "+ d.city +" "+d.region+" 2´ÎÇøÓò²»Í¬" + } + }else{ + println index +" "+ d.city +" "+d.region+" ûÓдËÇøÓò" + } + } + } + + + def regionPolyline(){ + def dbcursor = POLYLINECOLL.find(new BasicDBObject("level","district")) + def map = [:] + for(def d : dbcursor){ + def resultMap = [:] + resultMap.type = "polygon" + def arrs = d.polyline.split("\\|") + def rets = [] + for(def s : arrs){ + def points = s.split(";") + def pointList = [] + for(def pointStr : points){ + def pointArr = pointStr.split(",") + pointList << [pointArr[0].toString().toDouble(), pointArr[1].toString().toDouble()] + } + rets << pointList + } + resultMap.coordinates = rets + if(rets.size()>1) { + resultMap.type = "MultiPolygon" + } + println d.city+" "+d.region+" "+rets.size() + + def udata = new BasicDBObject() + udata.put("shape", resultMap) + def center = d.center + if(center){ + def pointArrs = center.split(",") + udata.put("location", ["lon":pointArrs[0].toString().toDouble(), "lat":pointArrs[1].toString().toDouble()]) + } + + def fullCity = fullCityMap.get(d.city) + map.put(fullCity.city+"|@|"+d.region, udata) + } + return map; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy index cb6e34cda..e58c11ff5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy @@ -13,18 +13,18 @@ class MsbPocTest { task.run(); } def run(){ - def inputfile = "D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\_ÒµÎñ5Ô·Ýϵͳ·´À¡ÎÊÌâ¼Û¸ñºË²é20240416-20240516 - ¹úÐÅ´ï0524.xlsx" + def inputfile = "D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\·¿Ñ¶Í¨10Ô¼۸ñºË²é_1126-FXTÌá½»½á¹û20241205.xlsx" // def inputfile = "D:\\Êý¾Ý\\ÃÀÊõ±¦\\ÃÀÊõ±¦²âÊÔÊý¾Ý(Æ¥ÅäV2).xlsx"//ÃÀÊõ±¦²âÊÔÊý¾Ý(Æ¥Åä).xlsx // standard(inputfile) // match(inputfile) -// matchOld(inputfile) + matchOld(inputfile) // addPrice("D:\\Êý¾Ý\\ÃÀÊõ±¦\\ÃÀÊõ±¦²âÊÔÊý¾Ý(¼Û¸ñ).xlsx") // test("D:\\Êý¾Ý\\ÃÀÊõ±¦\\FiveLevelTest.xlsx") // cityPrice() // mergeMatchPrice("D:\\Êý¾Ý\\ÃÀÊõ±¦\\ÃÀÊõ±¦-нӿڼ۸ñ.xlsx") - addCCBPrice(inputfile) +// addCCBPrice(inputfile) } def cityPrice(){ @@ -69,24 +69,24 @@ class MsbPocTest { def matchOld(path){ ExcelUtils.multiThreadingModify(path, { row -> - if(!row['Y'] && row['G']){ + if(!row['AD'] ){ def city = row['C'] def region = null //row['D'] - def name = row['E'] - def address = row['G'] + def name = null// row['E'] + def address = row['D'] println "[match] city:"+city+" region:"+region+" address:"+address def jsonObject = OpenApiClient.addressMatch(city, address, "property", false, region, name) if(jsonObject != null && jsonObject.precise!=-1) { - row['Y'] = jsonObject.get("id") - row['Z'] = jsonObject.get("city") - row['AA'] = jsonObject.get("district") - row['AB'] = jsonObject.get("name") - row['AC'] = jsonObject.get("propertyType") + row['AD'] = jsonObject.get("id") + row['AE'] = jsonObject.get("city") + row['AF'] = jsonObject.get("district") + row['AG'] = jsonObject.get("name") + row['AH'] = jsonObject.get("propertyType") // row['X'] = jsonObject.get("credit") } } - }) + },1) } @@ -114,7 +114,7 @@ class MsbPocTest { if(!row['Y']){ def city = row['C'] def region = null //row['B'] - def address = row['G'] //row['G']//row['F'] + def address = row['D'] //row['G']//row['F'] println "[match] city:"+city+" region:"+region+" address:"+address def jsonObject = FangjiaClientUtils.newMatch(city, address, "property", false) @@ -125,7 +125,7 @@ class MsbPocTest { row['AB'] = jsonObject.get("name") } } - }) + },1) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy index 2003db863..62474f6c5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/BeiKeCrawlByChrome.groovy @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicLong public class BeiKeCrawlByChrome { def DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def startMonth = DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyy-MM"), -1, "yyyy-MM") WebDriver driver = null; @@ -118,7 +118,7 @@ public class BeiKeCrawlByChrome { } def crawlData(driver, citys){ - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def runedCitys = FileUtils.readTxt("d:\\Êý¾Ý\\³É½»×¥È¡\\±´¿ÇÒÑ×¥³ÇÊÐ.txt") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy index a458ccd56..b994d31e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/ExportPaimai.groovy @@ -15,7 +15,7 @@ import java.util.regex.Pattern class ExportPaimai { - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy index ec1ad4acd..1730f28b7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/LianjiaCrawlByChrome.groovy @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicLong public class LianjiaCrawlByChrome { def DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def startMonth = DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyy-MM"), -1, "yyyy-MM") WebDriver driver = null; @@ -189,7 +189,7 @@ public class LianjiaCrawlByChrome { } def crawlData(driver, cityList){ - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) def runedCitys = FileUtils.readTxt("d:\\Êý¾Ý\\³É½»×¥È¡\\Á´¼ÒÒÑ×¥³ÇÊÐ.txt") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy index cf4bed800..f457e323e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiDataSend.groovy @@ -28,7 +28,7 @@ class PaimaiDataSend { DBCollection jd_coll = MongoUtils.getCollectionByName("fangjia_crawl", "fapai_jd_detail", "192.168.0.235", 27018) DBCollection rmfysszc_coll = MongoUtils.getCollectionByName("fangjia_crawl", "fapai_rmfysszc_detail", "192.168.0.235", 27018) - def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy index 52add2e69..36ee62699 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/paimai/PaimaiTest.groovy @@ -26,7 +26,7 @@ class PaimaiTest { DBCollection paimaiResultColl = MongoUtils.getCollectionByAuth20190102("fangjia", "pai_mai") - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection paimai43_COLL = MongoUtils.getCollectionByName2("fangjia_crawl", "pai_mai", lineUrl) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy index d314427a9..9eaa268fc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy @@ -30,7 +30,7 @@ class AddPriceTest { def pgsqlInstance235 = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", "postgres", "Goojia123456", "org.postgresql.Driver") - static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") public static final DBCollection confirm_price_date = MongoUtils.getCollectionByName("fangjia", "confirm_price_data", "mongo.db.fangjia.com") static main(args) { @@ -38,18 +38,60 @@ class AddPriceTest { task.run(); } def run(){ - def filePath = "D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\202410²âÊÔÆ«²î½Ï´ó°¸Àýͳ¼ÆÊý¾Ýtest.xlsx" - addGXDPrice(filePath) + def filePath = "D:\\Êý¾Ý\\¼Û¸ñ\\»ÝÖÝ.xlsx" +// addGXDPrice(filePath) // addCcbPrice(filePath) // addThirdPrice(filePath) // addFjwPrice(filePath) // exportPkPrice() // addRegion() // addTradePrice(filePath) - + addThirdSamplePrice("D:\\Êý¾Ý\\½¨ÐÐ\\·¿²ú¹ÀÖµ\\Ö¸µ¼¼Û\\¼¶Áª¡¢¹úÐÅ´ï¼Û¸ñµ¼Èë_0313.xlsx") } + def addThirdSamplePrice(filePath){ + ExcelUtils.modify(filePath,{d-> + def dist = CommonDatautils.findDistrictById(d['A']) + def o = new BasicDBObject() + o.put("city" , dist.city) + o.put("region" , dist.region) + o.put("district_name" , dist.name) + o.put("isGuidancePrice" , 0) + o.put("category", "district") + o.put("c_date" , new Date()) + o.put("user_name" , "·¿¼ÛÍø") + + if(d['B']){ + o.put("price", d['B'].toString().toDouble().toInteger()) + o.put("source", "JL") + if(o.containsKey("_id")){ + o.removeField("_id") + } + confirm_price_date.save(o) + } + if(d['C']){ + o.put("price", d['C'].toString().toDouble().toInteger()) + o.put("source", "GXD") + if(o.containsKey("_id")){ + o.removeField("_id") + } + confirm_price_date.save(o) + } + + if(d['D']){ + o.put("price", d['D'].toString().toDouble().toInteger()) + o.put("source", "FXT") + if(o.containsKey("_id")){ + o.removeField("_id") + } + confirm_price_date.save(o) + } + }) + } + + + def addTradePrice(filePath){ ExcelUtils.multiThreadingModify(filePath, { d -> if(d['Y']){ @@ -174,26 +216,30 @@ class AddPriceTest { def addCcbPrice(filepath){ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() ExcelUtils.multiThreadingModify(filepath,{ d-> - if(d['U']){ - def cityId = cityCodeDataMap.get(d['V']) - def map = findAvgPrice(d['U'], cityId) + if(d['A']){ + def cityId = cityCodeDataMap.get(d['B']) + def map = findAvgPrice(d['A'], cityId) if(map){ - d['H'] = map.avg_price - d['I'] = map.calc_type + d['I'] = map.avg_price + d['J'] = map.month +// d['H'] = map.calc_type // d['AM'] = map.credit_value } -// def newPriceMap = findNewFjwAvgPrice(d['U'], cityId) -// if(newPriceMap){ -// d['Q'] = newPriceMap.avg_price -// } + def newPriceMap = findNewFjwAvgPrice(d['A'], cityId) + if(newPriceMap){ + d['G'] = newPriceMap.avg_price + d['H'] = newPriceMap.month + d['H'] = map.calc_type +// d['AM'] = map.credit_value + } } }) } def findAvgPrice(def commid, def cityid){ - def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202409 order by gujiabds_clc_yrmo_val desc limit 1" + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc @@ -213,7 +259,7 @@ class AddPriceTest { def findNewFjwAvgPrice(def commid, def cityid){ - def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202409 order by gujiabds_clc_yrmo_val desc limit 1" + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance235.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc @@ -270,14 +316,14 @@ class AddPriceTest { def addGXDPrice(filepath){ ExcelUtils.multiThreadingModify(filepath, { d -> - if (!d['B']) { + if (!d['H']) { def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ def gxdPrice = findGXDPrice(dist.city, dist.region, dist.name) // def gxdPrice = findGXDPrice(d['D'], d['E'], d['C']) if(gxdPrice){ - d['B'] = gxdPrice.price - d['C'] = DateUtils.formatDateByPattern(gxdPrice.c_date, "yyyy-MM-dd") + d['H'] = gxdPrice.price + d['I'] = DateUtils.formatDateByPattern(gxdPrice.c_date, "yyyy-MM-dd") } } @@ -305,11 +351,11 @@ class AddPriceTest { ExcelUtils.multiThreadingModify(path,{d-> // if(!d['L']){ // if(d['J'] instanceof String){ - def dist = CommonDatautils.findDistrictById(d['AJ']) + def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ // d['A'] = dist.city // d['B'] = dist.region - d['E'] = dist.name +// d['E'] = dist.name // d['D'] = dist.status // d['E'] = dist.name_cat // d['F'] = dist.estate_type2 @@ -318,9 +364,9 @@ class AddPriceTest { // d['N'] = dist.region def dbo = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name) if(dbo){ - d['G'] = dbo.avg_price + d['E'] = dbo.avg_price_2b // d['X'] = dbo.cal_type -// d['E'] = dbo.avg_price_2b +// d['E'] = dbo.avg_price } } // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy index d4440f329..4633e64b4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/ExportToDealPrice.groovy @@ -13,8 +13,8 @@ import java.util.concurrent.atomic.AtomicInteger class ExportToDealPrice { - DBCollection DEAL_PRICE_MATCH_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price_match", "192.168.0.43") - DBCollection DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") + DBCollection DEAL_PRICE_MATCH_COLL = MongoUtils.getCollectionByName("fangjia", "deal_price_match", "mongo.db.fangjia.com") + DBCollection DISTRICT_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") DBCollection TRADE_MATCH_PRICE_COLL = MongoUtils.getCollectionByName("fangjia", "trade_match_price", "192.168.0.136") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy index 976e008ba..5a8f83a8f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/FzBlankTest.groovy @@ -14,7 +14,7 @@ import java.util.regex.Pattern class FzBlankTest { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection FZ_ADDR_COLL = MongoUtils.getCollectionByName2("business", "fz_district_address", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy index 838fcbd20..63543c6b5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JiangShuBlankDataStat.groovy @@ -20,7 +20,7 @@ import java.util.regex.Pattern class JiangShuBlankDataStat { - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new JiangShuBlankDataStat() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy index d7b18e371..531870d89 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/TestArroundPrice.groovy @@ -12,7 +12,7 @@ import com.mongodb.DBCollection class TestArroundPrice { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection DIST_DATA_COLL = MongoUtils.getCollectionByName2("fangjia_stat", "district_analy_data", lineUrl) public static final def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy index 967fa21ce..d7e5fe6fe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/township/StreetProcess.groovy @@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicLong class StreetProcess { - final DBCollection TOWNSHIP = MongoUtils.getCollectionByName("fangjia", "township", "192.168.0.43") + final DBCollection TOWNSHIP = MongoUtils.getCollectionByName("fangjia", "township", "mongo.db.fangjia.com") public static final def MONGODB_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; public static final DBCollection TOWNSHIP100 = MongoUtils.getCollectionByName2("fangjia", "township", MONGODB_URL) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy index 980d2863d..8aa7b2d42 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/govLocation.groovy @@ -19,7 +19,7 @@ DBCollection COMMUNITY_CONN = MongoUtils.getCollectionByName2("fangjia", "commun //def s = getTownshipInfo("118.702988,39.740979") def filePath = "D:\\Êý¾Ý\\ɿũ\\ÏØÕþ¸®(×îÖÕ).xlsx" ExcelUtils.modify(filePath, { row -> - if(!row['I'] && row['I']=='±¦Ó¦ÏØ'){ + if(!row['I'] && row['I']=='½¨ê±ÊÐ'){ def rets = EsSearchUtils.findPois(row['B'], row['C'], row['C']+"ÈËÃñÕþ¸®") if(rets){ def obj = findOneByName(rets, row['C']+"ÈËÃñÕþ¸®") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy index a401bf480..dd2c2e5e1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/ElasticUtils89.groovy @@ -1,5 +1,6 @@ package com.fangjia.script.gj.xiamen +import com.fangjia.script.util.ElasticUtils import org.apache.http.HttpHost import org.apache.http.auth.AuthScope import org.apache.http.auth.UsernamePasswordCredentials @@ -7,8 +8,10 @@ import org.apache.http.client.CredentialsProvider import org.apache.http.client.config.RequestConfig import org.apache.http.impl.client.BasicCredentialsProvider import org.apache.http.impl.nio.client.HttpAsyncClientBuilder +import org.apache.solr.client.solrj.request.UpdateRequest import org.elasticsearch.action.ActionListener import org.elasticsearch.action.bulk.BackoffPolicy +import org.elasticsearch.action.bulk.BulkItemResponse import org.elasticsearch.action.bulk.BulkProcessor import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse @@ -17,11 +20,13 @@ import org.elasticsearch.action.search.ClearScrollRequest import org.elasticsearch.action.search.SearchRequest import org.elasticsearch.action.search.SearchResponse import org.elasticsearch.action.search.SearchScrollRequest +import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.client.RestClient import org.elasticsearch.client.RestClientBuilder import org.elasticsearch.client.RestHighLevelClient import org.elasticsearch.common.unit.TimeValue +import org.elasticsearch.common.xcontent.XContentType import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.search.Scroll import org.elasticsearch.search.SearchHit @@ -99,6 +104,29 @@ class ElasticUtils89 { return new RestHighLevelClient(builder) } + static RestHighLevelClient getClientOther(String host) { + RestClientBuilder builder = RestClient.builder(new HttpHost(host, 9200, "http")); + builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { + @Override + RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) { + requestConfigBuilder.setConnectionRequestTimeout(1000 * 60); + requestConfigBuilder.setSocketTimeout(1000 * 180); + return requestConfigBuilder; + } + }) + builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { + @Override + HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) { + httpAsyncClientBuilder.disableAuthCaching(); + CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "goojia123456"));// + httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider); + return httpAsyncClientBuilder; + } + }) + return new RestHighLevelClient(builder) + } + static RestHighLevelClient getClient89(String host) { RestClientBuilder builder = RestClient.builder(new HttpHost(host, 9200, "http")); @@ -137,8 +165,17 @@ class ElasticUtils89 { } @Override - void afterBulk(long executionId, BulkRequest request, - BulkResponse response) { + public void afterBulk(long executionId, BulkRequest request, BulkResponse response) { + if (response.hasFailures()) { + for (BulkItemResponse itemResponse : response.getItems()) { + if (itemResponse.isFailed()) { + // ´¦Àíʧ°ÜÏî + String failureMessage = itemResponse.getFailureMessage(); + println failureMessage + // ÈÕÖ¾¼Ç¼¡¢¸æ¾¯»òÖØÊÔ + } + } + } } @Override @@ -174,9 +211,15 @@ class ElasticUtils89 { static executeQuery(String host, String indexName, QueryBuilder qb, Closure closure){ - RestHighLevelClient client = getClient(host) + RestHighLevelClient client = null + if(host == "192.168.0.89"){ + client = getClient(host); + }else if(host == "192.168.0.52"){ + client = getClientOther(host); + } BulkProcessor bulkProcessor = createBulkProcessor(host, client) final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(60L)) + SearchRequest searchRequest = new SearchRequest(indexName); searchRequest.scroll(scroll); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); @@ -190,10 +233,11 @@ class ElasticUtils89 { while (searchHits != null && searchHits.length > 0) { for (int k=0; k < searchHits.size(); k++) { final SearchHit hit = searchHits[k]; - executorService.submit(new Runnable() { - @Override - void run() { - try{ +// executorService.submit(new Runnable() { +// @Override +// void run() { +// try{ + if(closure.getMaximumNumberOfParameters() == 1){ def update = closure.call(hit.getSourceAsMap()) if(update){ @@ -203,14 +247,16 @@ class ElasticUtils89 { def update = closure.call(hit.getId(), hit.getSourceAsMap()) if(update){ bulkProcessor.add(new IndexRequest(indexName).id(hit.getId()).source(hit.getSourceAsMap())) + } } - }catch (Exception e){ - e.printStackTrace() - } - } - }) +// }catch (Exception e){ +// e.printStackTrace() +// } +// } +// }) } + SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); scrollRequest.scroll(scroll); searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT); @@ -227,6 +273,120 @@ class ElasticUtils89 { client.close() } + static queryUpdate(String host, String indexName, QueryBuilder qb, Closure closure){ + RestHighLevelClient client = null + if(host == "192.168.0.89"){ + client = getClient(host); + }else if(host == "192.168.0.52"){ + client = getClientOther(host); + } + BulkProcessor bulkProcessor = createBulkProcessor(host, client) + + final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(30)) + // 2. ³õʼ»¯¹ö¶¯²éѯ + SearchRequest searchRequest = new SearchRequest(indexName); + searchRequest.scroll(scroll); + + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(qb); + searchRequest.source(searchSourceBuilder); + + SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); + String scrollId = searchResponse.getScrollId(); + SearchHit[] hits = searchResponse.getHits().getHits(); + + // 3. ÅúÁ¿²Ù×÷ÈÝÆ÷ + BulkRequest bulkRequest = new BulkRequest(); + + // 4. ´¦Àí¹ö¶¯½á¹û + while (hits.length > 0){ + for (SearchHit hit : hits) { + // ʾÀýÐÞ¸ÄÂß¼­£ºµ±Âú×ãÌõ¼þʱ¸üÐÂÎĵµ + if(closure.getMaximumNumberOfParameters() == 2){ + def update = closure.call(hit.getId(), hit.getSourceAsMap()) + if(update){ + bulkRequest.add(new IndexRequest(indexName).id(hit.getId()).source(hit.getSourceAsMap())) + } + } + // ÅúÁ¿Ìá½»¿ØÖÆ + if (bulkRequest.numberOfActions() >= 1) { + bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(bulkRequest, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + System.err.println("ÅúÁ¿²Ù×÷²¿·Öʧ°Ü: " + bulkResponse.buildFailureMessage()); + // ÕâÀï¿ÉÒÔÌí¼ÓÖØÊÔÂß¼­ + } + bulkRequest = new BulkRequest(); // ÖØÖÃÈÝÆ÷ + } + } + + // 5. »ñÈ¡ÏÂÒ»Åú¹ö¶¯½á¹û + SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId).scroll(TimeValue.timeValueMinutes(5)); + searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT); + scrollId = searchResponse.getScrollId(); + hits = searchResponse.getHits().getHits(); + } + + // 6. ÌύʣÓàÅúÁ¿²Ù×÷ + if (bulkRequest.numberOfActions() > 0) { + BulkResponse bulkResponse = client.bulk(bulkRequest, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + System.err.println("ÅúÁ¿²Ù×÷²¿·Öʧ°Ü: " + bulkResponse.buildFailureMessage()); + } + } + + // 7. ÇåÀí¹ö¶¯ÉÏÏÂÎÄ + ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); + clearScrollRequest.addScrollId(scrollId); + client.clearScroll(clearScrollRequest, RequestOptions.DEFAULT); + + bulkProcessor.close() + bulkProcessor.awaitClose(1, TimeUnit.DAYS) + client.close() + } + + + static updateEs(addEsDatasMap, host, indexName){ + BulkRequest request = new BulkRequest(); + int processedCount = 0; + def client = null + if(host && host == "192.168.0.89"){ + client = ElasticUtils89.getClient(host) + }else if(host && host == "192.168.0.52"){ + client = ElasticUtils.getClient(host) + } + + addEsDatasMap.each{id, map-> + request.add(new IndexRequest(indexName, "_doc", id).source(map, XContentType.JSON)); + if (request.numberOfActions() >= 100) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents "+host + } + request = new BulkRequest(); + } + } + + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents "+host + } + } + } + + + static def executeSimpleQuery(String host, String indexName, QueryBuilder qb, includes){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy index bf848d990..627c30884 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/NetworkDistanceBatch.groovy @@ -27,9 +27,9 @@ class NetworkDistanceBatch extends BaseBatch{ public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) - final DBCollection NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network", "192.168.0.43") + final DBCollection NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network", "mongo.db.fangjia.com") - final DBCollection MAP_NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network_map", "192.168.0.43") + final DBCollection MAP_NETWORK_COLL = MongoUtils.getCollectionByName("business", "xm_network_map", "mongo.db.fangjia.com") static main(args) { runBatch(new NetworkDistanceBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy index e44d4424e..5cf2d132a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy @@ -7,6 +7,7 @@ import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.ccb.FileUtils import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.looplineinfo.Point import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils @@ -17,7 +18,7 @@ import com.mongodb.DBCollection */ -@BatchOwner(Watcher.GaoJuan) +//@BatchOwner(Watcher.GaoJuan) class RelatedTaiWanBatch extends BaseBatch{ @@ -69,7 +70,9 @@ class RelatedTaiWanBatch extends BaseBatch{ if(r.lon && r.lat){ for(def m : zimaoqu_range_datas){ // def flag = InsidePolygon.isInArea(r.lon, r.lat, InsidePolygon.createPoint5(m.shape)) - def flag = InsidePolygon.isPtInPoly(r.lon, r.lat, InsidePolygon.createPoint5(m.shape)) + List> pointsList = InsidePolygon.createPoint4(m.shape) +// def flag = InsidePolygon.isPtInPoly(r.lon, r.lat, pointsList) + def flag = InsidePolygon.isInArea(r.lon, r.lat, pointsList) if(flag){ resKey = m.name break diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy index e78bc7018..7bd1a3cdb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy @@ -1,33 +1,53 @@ package com.fangjia.script.gj.xiamen import com.fangjia.core.util.GeoUtils +import com.fangjia.core.util.HttpRequest import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils + import com.fangjia.script.util.DateUtil import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.ProvinceData import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.AMQP +import net.sf.json.JSONObject + +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.util.* +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + import org.bson.types.ObjectId +import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.common.xcontent.XContentType +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong -import com.fangjia.script.common.DataHandleUtils +/** + * ͬ²½Ð¡Çø£¬ÉÌÆÌ£¬Ð´×ÖÂ¥µ½89£¬52ÉÏ + */ class SeaweedDataSynch extends BaseBatch{ - static def targetUrl = "http://192.168.0.12:9200/seaweed/" + static def targetUrl = "http://192.168.0.89:9200/seaweed/" public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; - DBCollection SEAWEED_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed", MONGO100_URL) + DBCollection SEAWEED_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_dishu", MONGO100_URL) DBCollection administrative_division_100_CONN = MongoUtils.getCollectionByName2("fangjia", "administrative_division_2023", MONGO100_URL) DBCollection administrative_division_2022_CONN = MongoUtils.getCollectionByName2("fangjia", "administrative_division", MONGO100_URL) @@ -58,8 +78,6 @@ class SeaweedDataSynch extends BaseBatch{ @Override public void process(Object args) { - - run() // println "È«¹údistrict, shop, officeͬ²½Íê³É" //ÃñÕþ²¿±àÂëÉÏ´« @@ -131,18 +149,106 @@ class SeaweedDataSynch extends BaseBatch{ fullCityMap = CommonDatautils.queryFullNameCity() mcaDistMap = CommonDatautils.queryDistNameCityByMapping() -// priceMap = findAllDistrictSellPrice() - def citys = CommonDatautils.findAllCity().reverse() + priceMap = findAllDistrictSellPrice() + def citys = CommonDatautils.findAllCity() def index = 0 for(def c : citys){ index++ - updating(c, "district") - updating(c, "office") - updating(c, "shop") - println index +" "+ c + " Íê³É" + + def dists = updating(c, "district") + updateEs(c, dists, "district", "192.168.0.89") + updateEs(c, dists, "district", "192.168.0.52") + + def offices = updating(c, "office") + updateEs(c, offices, "office", "192.168.0.89") + updateEs(c, offices, "office", "192.168.0.52") + + def shops = updating(c, "shop") + updateEs(c, shops, "shop", "192.168.0.89") + updateEs(c, shops, "shop", "192.168.0.52") + + println index +" "+ c + " Íê³É "+new Date().toString() } } + def updateEs(city, dists, cat, host){ + def data = fullCityMap.get(city) + def distEsDatas = findEsSeaweedDatas(data.city, cat, host) + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(dists.size()) + def updateDatas = new CopyOnWriteArrayList() + def ids = new CopyOnWriteArrayList() + //¸üÐÂ89Es + for(def i=0;i + if(!ids.contains(id)){ + delEsData(id, host, "seaweed") + esDelIds << id + } + } + println "Es ɾ³ý ${cat}ÀàÐÍ£º"+esDelIds.size() + //½«100 mongodbÖзÇÕý³£Ð¡ÇøÉ¾³ý + def mongoIds = findMongoDbDatas(cat, data.city) + + mongoIds.each{id-> + if(!ids.contains(id)){ + SEAWEED_CONN.remove(new BasicDBObject("_id", new ObjectId(id))) + } + } + + } + + def updatingEs(d, esObj, host){ + def map = [:] + def diffMap = [:] + d.each {k,v-> + if(v && k!="_id"){ + map.put(k, v) + } + if(esObj && k!="_id"){ + def esVal = esObj.get(k) + if(esVal!=v){ + diffMap.put(k,v) + } + } + } + if(!esObj || (esObj && diffMap)){ + map.put("id", d._id.toString()) + map.put("status", 0) //ÒòΪÅжÏÊÇ·ñÓÐÖµ£¬0»á·µ»Øfalse,ËùÔÚÕâÀïÉèÖÃĬÈÏÖµ£¬ÔÚ89ºÍ52ÉϵͼÊÇÓÐЧÊý¾Ý + return map + } + return null + } + def updating(city, cat){ def dists = CommonDatautils.findAllDistrictsFromMg(city, cat, ["city","region","name","address","block","mapping_alias","addr_alias","cat","estate_type2","status","township","lng","lat","build_type","household_count","committee","estate_charge","car_site_count","property_life","house_property","build_area","all_area","build_structure","developer","estate_company","cubage_percent","virescence_percent","loudong_count","schools","main_type","main_type_area","create_year"]) def rets = new CopyOnWriteArrayList() @@ -154,15 +260,13 @@ class SeaweedDataSynch extends BaseBatch{ void run() { try{ totalCount.addAndGet(1) - def map = createData(dist) - //Íù100 ÉÏͬ²½ updateData(map) - - //Íù12 esÉÏͬ²½ -// def newUrl = targetUrl +"_doc/"+map.id -// CommonDatautils.httpSaveData(newUrl, map) + rets << map +// //Íù89 esÉÏͬ²½ +// def newUrl = targetUrl +"_doc/"+map._id +// CommonDatautils.httpSaveData89(newUrl, map) println city +" "+cat +" "+totalCount.get() +"/"+dists.size()+" "+dist.name+" "+map._id } catch (Exception e) { @@ -178,6 +282,33 @@ class SeaweedDataSynch extends BaseBatch{ return rets; } + def updateMapPoi(def id, def township){ + def header = [:] + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + String seawaterUrl = "http://192.168.0.89:9200/seaweed/_update_by_query?conflicts=proceed&scroll_size=1000&wait_for_completion=false" + def body = """ + { + "script": { + "source": "ctx._source.township='${township}'", + "lang": "painless" + }, + "query": { + "term": { + "_id": "${id}" + } + } + } + """ + HttpRequest request = new HttpRequest() + try{ + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + def response = JSONObject.fromObject(res) + }catch(Exception e){ + println "error : "+e.getMessage() + } + + } + def updateData(map){ def udata = new BasicDBObject() map.each{k,v-> @@ -196,14 +327,14 @@ class SeaweedDataSynch extends BaseBatch{ if(province){ map.province = ProvinceData.getFullProvince(province) } - map.fangjia_province = province +// map.fangjia_province = province def data = fullCityMap.get(dist.city) if(data){ map.city = data.city area_code = data.mca_city_code } - map.fangjia_city = dist.city +// map.fangjia_city = dist.city def distData = mcaDistMap.get(dist.city+"#"+dist.region) if(distData){ @@ -213,9 +344,8 @@ class SeaweedDataSynch extends BaseBatch{ // map.region = dist.region println dist.city +" "+dist.region+" ÃñÕþ²¿ÖÐûÓÐÕÒµ½ÏàÓ¦µÄÇøÓòÈ«³Æ" } - map.area_code = area_code - - map.fangjia_region = dist.region +// map.area_code = area_code +// map.fangjia_region = dist.region map.name = dist.name @@ -226,16 +356,17 @@ class SeaweedDataSynch extends BaseBatch{ for(def key : dist.mapping_alias){ if(key && !key.toString().equals("null")){ aliasNames << key - if(aliasNames.size()>5){ - map.alias = aliasNames - break; - }else{ - if(aliasNames){ - map.alias = aliasNames - } - } +// if(aliasNames.size()>5){ +// map.alias = aliasNames +// break; +// }else{ +// if(aliasNames){ +// map.alias = aliasNames +// } +// } } } + map.alias = aliasNames } if(dist.addr_alias){ @@ -243,16 +374,17 @@ class SeaweedDataSynch extends BaseBatch{ for(def key : dist.addr_alias){ if(key && !key.toString().equals("null")){ names << key - if(names.size()>5){ - map.addr_alias = names - break; - }else{ - if(names){ - map.addr_alias = names - } - } +// if(names.size()>5){ +// map.addr_alias = names +// break; +// }else{ +// if(names){ +// map.addr_alias = names +// } +// } } } + map.addr_alias = names } map.category = dist.cat @@ -334,7 +466,7 @@ class SeaweedDataSynch extends BaseBatch{ map.avg_price = dataMap.avg_price } } - + map.status = 0 // map.update_date = org.apache.commons.httpclient.util.DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss").replace(" ","T") return map } @@ -388,6 +520,95 @@ class SeaweedDataSynch extends BaseBatch{ DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(row['A'])), new BasicDBObject('$set', udata)) } }) - } + + def findEsSeaweedDatas(city, cat, host){ + def map = new HashMap() + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)).must(QueryBuilders.termQuery("category", cat)) + ElasticUtils89.executeQuery(host, "seaweed", queryBuilder, { String id, doc-> + map.put(id, doc) + }) + return map; + } + + def updateSeaweedEs(updateDatas, host, indexName){ + BulkRequest request = new BulkRequest(); + int processedCount = 0; + def client = null + if(host && host == "192.168.0.89"){ + client = ElasticUtils89.getClient(host) + }else if(host && host == "192.168.0.52"){ + client = ElasticUtils.getClient(host) + } + + updateDatas.each{map-> + request.add(new IndexRequest(indexName, "_doc", map.id).source(map, XContentType.JSON)); + if (request.numberOfActions() >= 100) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents "+host + } + request = new BulkRequest(); + } + } + + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents "+host + } + } + } + + def delEsData(id, host, indexName){ + def header = [:] + if(host && host == "192.168.0.89"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + }else if(host && host == "192.168.0.52"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:goojia123456".getBytes("UTF-8"))}".toString() + } + String seawaterUrl = "http://${host}:9200/${indexName}/_delete_by_query" + def body = """ + { + "query": { + "bool": { + "must": [ + { + "match": { + "id": "${id}" + } + } + ] + } + } + } + """ + HttpRequest request = new HttpRequest() + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + println(res) + } + + def findMongoDbDatas(cat, city){ + def q = new BasicDBObject("category", cat).append("city", city) + def keys = new BasicDBObject() + keys.put("_id",1) + def dbcursor = SEAWEED_CONN.find(q, keys) + def mongoIds = [] + for(def d : dbcursor){ + mongoIds << d._id.toString() + } + return mongoIds + } + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/zhongshu/DistrictArrountOffice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/zhongshu/DistrictArrountOffice.groovy new file mode 100644 index 000000000..34a98e33d --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/zhongshu/DistrictArrountOffice.groovy @@ -0,0 +1,134 @@ +package com.fangjia.script.gj.zhongshu + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.ExcelUtils + +class DistrictArrountOffice { + + static main(args) { + def task = new DistrictArrountOffice() + task.run() + } + + def run(){ + def dataMap = ["±±¾©":"116.481075,39.996743", "ÑĮ̀":"121.438616,37.459645"] + def rets = [] + rets << ["³ÇÊÐ","ÇøÓò","Ãû³Æ","µØÖ·","¾­¶È","γ¶È","д×ÖÂ¥µÈ¼¶","×â½ð(Æð)","×â½ð(Ö¹)", "¼Û¸ñÀ´Ô´"] + dataMap.each {k,v-> + def locations = v.split(",") + def arroundOffices = CommonDatautils.getSeaweedArroundByCat(k, locations[0], locations[1], "office") + println k +" "+arroundOffices.size() + if(arroundOffices){ + def index = 0 + for(def o : arroundOffices){ + index++ + def priceMap = findEsOffice(o.city, o.region, o.name) + if(!priceMap){ + priceMap = findEsHouse(o, "20231112") + } + def start_price = null + def end_price = null + def source = null + if(priceMap){ + if(priceMap.avg_start_price){ + start_price = DataHandleUtils.getDoubleRound(2, priceMap.avg_start_price) + } + if(priceMap.avg_end_price){ + end_price = DataHandleUtils.getDoubleRound(2, priceMap.avg_end_price) + } + source = priceMap.source + } + def lng = DataHandleUtils.getDoubleRound(6, o.lng/10000000000.0) + def lat = DataHandleUtils.getDoubleRound(6, o.lat/10000000000.0) + def row = [o.city, o.region, o.name, o.address, lng, lat, o.bed_kind, start_price, end_price, source] + rets << row + println index +" "+ row + } + } + } + ExcelUtils.write("d:\\Êý¾Ý\\д×ÖÂ¥²âÊÔ-1118.xlsx", rets, "Êý¾Ý") + } + + + def findEsOffice(city, region, name){ + def map = [:] + def start_rent_prices = [] + def end_rent_prices = [] + def rent_prices = [] + + ElasticUtils.executeSqlQuery("select * from office where city='${city}' and region='${region}' and name='${name}'", { r-> + if(r.start_rent_price){ + start_rent_prices << r.start_rent_price + } + if(r.end_rent_price){ + end_rent_prices << r.end_rent_price + } + if(r.rent_price){ + rent_prices << r.rent_price + } + + }) + def avg_start_price = null + if(start_rent_prices){ + avg_start_price = start_rent_prices.sum()/start_rent_prices.size() + } + def avg_end_price = null + if(end_rent_prices){ + avg_end_price = end_rent_prices.sum()/end_rent_prices.size() + } + + if(!avg_start_price && !avg_end_price){ + if(rent_prices){ + if(rent_prices.size()>1){ + rent_prices = rent_prices.sort() + avg_start_price = rent_prices[0] + avg_end_price = rent_prices[rent_prices.size()-1] + }else{ + avg_start_price = rent_prices[0] - rent_prices[0]*0.2 + avg_end_price = rent_prices[0] + rent_prices[0]*0.2 + } + } + } + + if(avg_start_price){ + map.put("avg_start_price", avg_start_price) + } + if(avg_end_price){ + map.put("avg_end_price", avg_end_price) + } + if(map){ + map.source = "·Ç·¿Ô´" + } + return map + } + + def findEsHouse(o, startDate){ + def rent_prices = CommonDatautils.findHousePriceByDate(o.city, o.region, o.name, o.alias, "office_rent", startDate) + def avg_start_price = null + def avg_end_price = null + def map = [:] + if(rent_prices){ + if(rent_prices.size()>1){ + rent_prices = rent_prices.sort() + avg_start_price = rent_prices[0] + avg_end_price = rent_prices[rent_prices.size()-1] + }else{ + avg_start_price = rent_prices[0] - rent_prices[0]*0.2 + avg_end_price = rent_prices[0] + rent_prices[0]*0.2 + } + } + if(avg_start_price){ + map.put("avg_start_price", avg_start_price) + } + if(avg_end_price){ + map.put("avg_end_price", avg_end_price) + } + if(map){ + map.source = "·¿Ô´" + } + return map + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy index 4dc7c2384..43fd17c7d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/grade/ConsumptionRatingBatch.groovy @@ -20,10 +20,10 @@ import java.util.regex.Pattern class ConsumptionRatingBatch extends BaseBatch { def weekend = DateUtil.truncateDay(DateUtil.getFirstDayOfWeek(new Date())) public static - final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") + final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") public static - final DBCollection CONSUMPTION_GRADE_COLL = MongoUtils.getCollectionByName("fangjia_stat", "consumption_grade", "192.168.0.85") + final DBCollection CONSUMPTION_GRADE_COLL = MongoUtils.getCollectionByName("fangjia_stat", "consumption_grade", "mongo.db.fangjia.com") final DBCollection AMAP_POI_New_COLL = MongoUtils.getCollectionByName("m_dianping", "dianping_9", "114.80.150.196", 27777) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy index bd24b9fc6..dcf8bd62f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/hubingliang/IndividuateEvaAndRegisterTimeStatistical.groovy @@ -40,10 +40,10 @@ import groovy.sql.Sql @BatchOwner(Watcher.Hubingliang) class IndividuateEvaAndRegisterTimeStatistical extends BaseBatch{ final static def mongoDomain = "mongo.db.fangjia.com" - public static final DBCollection EVALUATION_TIME = MongoUtils.getCollectionByName("fangjia", "evaluation", "mongo.db.fangjia.com", 27017) - public static final DBCollection REGISTER_EVALUATION = MongoUtils.getCollectionByName("fangjia_base", "register_evaluation", "mongo.db.fangjia.com", 27017) + public static final DBCollection EVALUATION_TIME = MongoUtils.getCollectionByName("fangjia", "evaluation", "mongo.db.fangjia.com", 28017) + public static final DBCollection REGISTER_EVALUATION = MongoUtils.getCollectionByName("fangjia_base", "register_evaluation", "mongo.db.fangjia.com", 28017) - public static final DBCollection USER_COLL = MongoUtils.getCollectionByName("fangjia_coresite", "user", "mongo.db.fangjia.com", 27017) + public static final DBCollection USER_COLL = MongoUtils.getCollectionByName("fangjia_coresite", "user", "mongo.db.fangjia.com", 28017) static main(args) { def s = System.currentTimeMillis() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy index 84d62abc6..a015638cf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/index/SeaweedReIndexBatch.groovy @@ -16,7 +16,7 @@ import com.mongodb.DBCollection class SeaweedReIndexBatch extends BaseBatch { - DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 27017) + DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) static main(args) { println "==================== start reIndex seaweed district " + DateUtils.formatToTightYYYYMMDDhhmmss(new Date()) + " ==============================" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy index e6c049461..b6418a792 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/SMSOutgoingListener.groovy @@ -310,7 +310,7 @@ class SMSOutgoingListener extends BaseBatch { if(StringUtils.isNotBlank(checkCode)){ JSONObject con = new JSONObject() con.put("code", checkCode); - return AliyunSmsClient.sendSms(mobile, "SMS_135220034", con.toString()) + return AliyunSmsClient.sendSms(mobile, "SMS_483345375", con.toString()) } } int resCode = SingletonClient.getClient().sendSMS([mobile] as String[],content, 5) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy index 05435c508..ededaa1db 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jms/aliyun/AliyunSmsClient.groovy @@ -52,7 +52,7 @@ class AliyunSmsClient { } public static void main(String[] args) { - sendSms("13916076378", "SMS_135220034", '{"code":12345}') + sendSms("15021384995", "SMS_482915107", '{"code":12345}') } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy index 586237d04..e99c9b8c4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jusfoun/HousingTransactionExportBatch.groovy @@ -30,7 +30,7 @@ import java.sql.SQLException class HousingTransactionExportBatch extends BaseBatch { - final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + final DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") static DBCollection _db_esf_transaction = MongoUtils.getCollectionByName("vip_site", "esf_transaction", "192.168.0.235", 27018); static MongoCollection PAI_MAI = Mongo3Utils.getDbCollection(Constants.FANGJIA_MONGO_URI, "fangjia_crawl", "pai_mai") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy new file mode 100644 index 000000000..4d79373ca --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy @@ -0,0 +1,132 @@ +package com.fangjia.script.looplineinfo + +import com.fangjia.script.common.DataHandleUtils + +import java.awt.geom.Point2D; + +class InPolygon { + + + public static List> createPoint(def pointList){ + List> alllist = new ArrayList<>(); + for(def pointArr : pointList){ + List list = new ArrayList<>(); + for(def arr : pointArr){ + double x = DataHandleUtils.getDoubleRound(6, arr[0]); + double y = DataHandleUtils.getDoubleRound(6, arr[1]); + Point2D.Double point = new Point2D.Double(x,y); + list.add(point); + } + alllist << list + } + return alllist + } + + public static def isInArea(Point2D.Double point, List> pointList){ + def flag = false; + for(List pointArr : pointList){ + flag = isPtInPoly(point, pointArr) + if(flag){ + break; + } + } + return flag; + } + + /** + * ÅжϵãÊÇ·ñÔÚ¶à±ßÐÎÄÚ + *

    + * Õû¸öËã·¨µÄ˼·Ϊ£º×÷µãƽÐÐÓÚyÖáµÄÉäÏߣ¬ÕâÑù¾Í¿ÉÒÔÖ±½Ó±È½Ï½»µãÊÇ·ñ´óÓÚµã(x,y)ÖÐyµÄÖµ£¬¿ÉÒÔ¼ò»¯Åжϡ£ + * + * @param point ¼ì²âµã + * @param pts ¶à±ßÐεĶ¥µã + * @return µãÔÚ¶à±ßÐÎÄÚ·µ»Øtrue, ·ñÔò·µ»Øfalse + */ + public static boolean isPtInPoly(Point2D.Double point, List pts) { + int polygonSidesCount = pts.size(); + //Èç¹ûµãλÓÚ¶à±ßÐεĶ¥µã»ò±ßÉÏ£¬Ò²Ëã×öµãÔÚ¶à±ßÐÎÄÚ£¬Ö±½Ó·µ»Øtrue + boolean boundOrVertex = true; + // ÉäÏßÓë¶à±ßÐÎÏཻµÄ´ÎÊý + int intersectCount = 0; + //¸¡µãÀàÐͼÆËãʱºòÓë0±È½ÏʱºòµÄÈݲî + double precision = 2e-10; + // ÏàÁÚÁ½µã + Point2D.Double p1, p2; + // µ±Ç°µã + Point2D.Double p = point; + // Ïß¶ÎÆðµã + p1 = pts.get(0); + for (int i = 1; i <= polygonSidesCount; ++i) { + //°´ÕÕµã¼ÈëµÄ˳ÐòÒÀ´Î¼ì²éÏàÁÚÁ½µã×é³ÉµÄÏ߶κ͵±Ç°µÄµãµÄ¹ØÏµ¡£ + if (p.equals(p1)) { + //Èç¹ûµ±Ç°µã¾ÍÊǶà±ßÐεĶ¥µãÖ®Ò»£¬Ö±½Ó·µ»Ø¡£ + return boundOrVertex; + } + // Ïß¶ÎÖÕµã + p2 = pts.get(i % polygonSidesCount); + if (p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)) { + //µãÔÚxÖáÉϵÄÓ³É䣬Ã÷ÏÔ³¬³öÁËÏß¶ÎÔÚxÖáÉϵÄͶӰ¡£´Ëʱ³å×ÅÉÏ×öÉäÏߣ¬¿Ï¶¨Ã»Óн»µã£¬Ö±½ÓÌø¹ý¡£ + p1 = p2; + continue; + } + if (p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)) { + // µ±Ç°µãÔÚÏß¶ÎÓÚxÖáÉϵÄͶӰÄÚ + if (p.y <= Math.max(p1.y, p2.y)) { + //µ±Ç°µãµÄ y ×ø±êСÓÚ Ï߶ζÔyÖáͶӰµÄ×î´óÖµ + if (p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)) { + // ÈôÏß¶ÎͬÑùÊÇÆ½ÐÐÓÚyÖᣬÔò¿ÉÒԶ϶¨£¬µ±Ç°µã£¬ÔÚ¶à±ßÐεÄÕâÌõ´¹Ö±ÓÚxÖáµÄ±ßÉÏ¡£ + return boundOrVertex; + } + if (p1.y == p2.y) { + // ÈôÏß¶ÎΪƽÐÐÓÚxÖáµÄˮƽÏß + if (p1.y == p.y) { + //µ±Ç°µãÕýºÃλÓÚ¸ÃˮƽÏßÉÏ£¬Ö±½Ó·µ»Ø¸ÃµãλÓÚ¶à±ßÐεÄÒ»Ìõ±ßÉÏ¡£ + return boundOrVertex; + } else { + //Èç¹ûµ±Ç°µãÔÚˮƽÏßÒÔÏ£¬Ôö¼ÓÒ»¸ö½»µã¡£ + ++intersectCount; + } + } else { + // Èç¹û²»ÊÇˮƽÏߣ¬ÔòÓÃÁ½µãʽÇóµ±Ç°µãµÄx´øÈë¶à±ßÐÎÏ߶εÄÖ±Ïß·½³Ìºó£¬¶ÔÓ¦µÄyµÄ×ø±ê + double xInSideLineFormulaResultY = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y; + if (Math.abs(p.y - xInSideLineFormulaResultY) < precision) { + // Îó²îÔÊÐí·¶Î§ÄÚ£¬¸Äµã¾ÍÔÚÏß¶ÎÉÏ£¬Ôò±íÃ÷£¬¸ÃµãλÓÚ¶à±ßÐεÄÒ»¸ö±ßÉÏ¡£ + return boundOrVertex; + } + + if (p.y < xInSideLineFormulaResultY) { + // Èç¹ûÏß¶ÎÉÏÈ¡µÃµÄy±Èµ±Ç°µãµÄyÒª´ó£¬µ±Ç°×öÏòÉϵÄÉäÏߣ¬¿Ï¶¨½»ÓÚÉÏ·½µÄÒ»¸öµã¡£ + ++intersectCount; + } + } + } + } else { + // µ±Ç°µã²»ÔÚÏß¶ÎͶӰµ½xÖáµÄÇø¼äÖÐ + if (p.x == p2.x && p.y <= p2.y) { + // µ«Ç¡ºÃλÓÚÏß¶ÎÖÕµãµÄx×ø±ê¶ÔÓ¦µÄƽÐÐÓÚyÖáÉϵÄÏßÉϵĵÍÓÚÖÕµãyµÄÒ»µã + // ´Ëʱ¼ì²éÏÂÒ»µãÄÜ·ñ½«Æäx±ß½ç°üº¬¡£ + Point2D.Double p3 = pts.get((i + 1) % polygonSidesCount); + if (p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)) { + // Èôµ±Ç°µãµÄx×ø±êλÓÚ p1ºÍp3×é³ÉµÄÏ߶ιØÓÚxÖáµÄͶӰÖУ¬Ôò¼ÇΪ¸ÃµãµÄÉäÏßÖ»´©¹ý¶ËµãÒ»´Î¡£ + ++intersectCount; + } else { + // Èôµ±Ç°µãµÄx×ø±ê²»Äܰüº¬ÔÚp1ºÍp3×é³ÉµÄÏ߶ιØÓÚxÖáµÄͶӰÖУ¬ÔòµãÉäÏßͨ¹ýµÄÁ½ÌõÏß¶Î×é³ÉÁËÒ»¸öÍäÕ۵IJ¿·Ö£¬ + // ´ËʱÎÒÃǼÇÉäÏß´©¹ý¸Ã¶ËµãÁ½´Î + intersectCount += 2; + } + // ´ËÅжϵĺËÐÄ˼·ÊÇÓɵãÔÚÁ½ÌõÏ߶εÄÄÚ²¿»¹ÊÇÍⲿȥ˼¿¼µÃ³öµÄ + } + } + // ½øÐÐÏÂÒ»¸öÏ߶εÄÅÐ¶Ï + p1 = p2; + } + if (intersectCount % 2 == 0) { + //żÊýÔÚ¶à±ßÐÎÍâ + return false; + } else { + //ÆæÊýÔÚ¶à±ßÐÎÄÚ + return true; + } + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy index 58a13a34d..25f5c45ed 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy @@ -324,4 +324,8 @@ class InsidePolygon { } return name; } + + + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy index 2a231a42c..22f0a1f93 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/loudong/CqfdcMatch.groovy @@ -23,7 +23,7 @@ import java.util.regex.Pattern class CqfdcMatch { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection HOUSE_LOUDONG_COLL = MongoUtils.getCollectionByName2("fangjia", "house_loudong", lineUrl) static DBCollection loudongFdcConn = MongoUtils.getCollectionByName("fangjia_crawl", "loudong_cqfdc", "192.168.0.235", 27018) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy index 9bd28e7fd..e557d8799 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/GaodePOI2Baidu.groovy @@ -53,8 +53,8 @@ def pcmap = [:] provinceList.remove("¹ãÎ÷Ê¡") provinceList.add("¹ãÎ÷׳×å×ÔÖÎÇø") -DSCollection seabird = new DataStore("192.168.0.43", 28017).getCollection("fangjia_base.baidu_place_poi2") -DBCollection m43 = MongoUtils.getCollectionByName("fangjia_base", "baidu_place_poi2", "192.168.0.43", 28017) +DSCollection seabird = new DataStore("mongo.db.fangjia.com", 28017).getCollection("fangjia_base.baidu_place_poi2") +DBCollection m43 = MongoUtils.getCollectionByName("fangjia_base", "baidu_place_poi2", "mongo.db.fangjia.com", 28017) //def type3Not = ["ѧУÄÚ²¿ÉèÊ©", "½ø¸Û", "³ö¸Û", "ºò´¬ÊÒ", "סËÞ·þÎñÏà¹Ø"] // //def type2Not = ["ѧУ", "ר¿ÆÒ½Ôº", "×ÛºÏÒ½Ôº", "ÕïËù", "ÒøÐÐ", "×Ô¶¯Ìá¿î»ú", "±ãÃñÉ̵ê/±ãÀûµê", "¼Òµçµç×ÓÂô³¡", "³¬¼¶Êг¡", "É̳¡", "ÃÀÈÝÃÀ·¢µê", "µØÌúÕ¾", "¸Û¿ÚÂëÍ·", "סËÞ·þÎñ"] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy index 6c8d9c9a8..5107646d1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/CPDBAvgGrowthRateBatch.groovy @@ -32,9 +32,9 @@ class CPDBAvgGrowthRateBatch extends BaseBatch { @Override public void process(Object args) { - println "¿ªÊ¼Í³¼ÆcpdbµÖѺƷ¿âÖÐÆ½¾ùÔö³¤ÂÊÅÅÃû" - cpdb_price_coll.remove(new BasicDBObject("date", getBeforeMonth(-1))) - stat() +// println "¿ªÊ¼Í³¼ÆcpdbµÖѺƷ¿âÖÐÆ½¾ùÔö³¤ÂÊÅÅÃû" +// cpdb_price_coll.remove(new BasicDBObject("date", getBeforeMonth(-1))) +// stat() } def stat() { @@ -46,7 +46,7 @@ class CPDBAvgGrowthRateBatch extends BaseBatch { def region = data.region def name = data.original_district_name if (city && region && name) { - JSONObject json = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-1)) + JSONObject json = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-1)) JSONObject json2 = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-2)) if (json == null) { json = OpenApiClient.evaluateDistrictPrice(city, region, name, area, 0, null, null, getBeforeMonthDate(-1)) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy index f05096eb1..ca0e3b0b8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/pds/PriceIncreaesLevelBatch.groovy @@ -24,9 +24,9 @@ class PriceIncreaesLevelBatch extends BaseBatch { static DBCollection pds_price_increaes_level_coll = MongoUtils.getCollectionByName("fangjia_stat", "pds.pds_price_increaes_level", "mongo.db.fangjia.com", 27017) static DBCollection cpdb_price_coll = MongoUtils.getCollectionByName("fangjia_stat", "pds.cpdb_price", "mongo.db.fangjia.com", 27017) - static main(args) { - runBatch(new PriceIncreaesLevelBatch(), args) - } +// static main(args) { +// runBatch(new PriceIncreaesLevelBatch(), args) +// } @Override public void process(Object args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy index f5c0a94c6..5bfa86aee 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CommunityHouseSampleBatch.groovy @@ -16,9 +16,9 @@ import com.mongodb.DBCollection //@BatchOwner(Watcher.MaJinTao) class CommunityHouseSampleBatch extends BaseBatch { - DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017) - DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) - DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017) + DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) + DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) + DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "mongo.db.fangjia.com", 28017) DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird") static void main(String[] args) { @@ -160,13 +160,13 @@ import com.mongodb.DBCollection @BatchOwner(Watcher.MaJinTao) class CommunityHouseSampleBatch extends BaseBatch { - DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017) + DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) - DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) + DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) - DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017) + DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "mongo.db.fangjia.com", 28017) -// DBCollection SEABIRD = MongoUtils.getCollectionByName("fangjia", "seabird", "192.168.0.43", 28017) +// DBCollection SEABIRD = MongoUtils.getCollectionByName("fangjia", "seabird", "1mongo.db.fangjia.com", 28017) DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy index 5ba702a2e..cb11ad4c7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/DistrictStatClickhouseSyncBatch.groovy @@ -16,7 +16,7 @@ import java.sql.Statement @BatchOwner(Watcher.WangWenYan) class DistrictStatClickhouseSyncBatch extends BaseBatch{ - DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) + DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 27017) static void main(String[] args) { runBatch(new DistrictStatClickhouseSyncBatch(), args) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy index 9f532247a..63cf10b20 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/DealPriceDetailExport.groovy @@ -19,9 +19,9 @@ import java.util.concurrent.* class DealPriceDetailExport { // Ð¡Çø¾ù¼Û¼¯ºÏ - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017) // Ð¡Çø³É½»¼¯ºÏ - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43", 28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com", 28017) static final Map retMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(10) static ExecutorService districtExecutorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy index fb9b88402..2e0d4181a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15Export.groovy @@ -23,9 +23,9 @@ import java.util.concurrent.atomic.AtomicInteger class PPE15Export { // Ð¡Çø¾ù¼Û¼¯ºÏ - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // Ð¡Çø³É½»¼¯ºÏ - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(30) static ExecutorService districtExecutorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy index 40a866be1..41d8a59b2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/PPE15ExportTest.groovy @@ -23,9 +23,9 @@ import java.util.concurrent.atomic.AtomicInteger class PPE15ExportTest { // Ð¡Çø¾ù¼Û¼¯ºÏ - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // Ð¡Çø³É½»¼¯ºÏ - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy index dbcf2139f..00b5638de 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/RentExport.groovy @@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicInteger */ class RentExport { - static DBCollection collection = MongoUtils.getCollectionByName("fangjia", "district_stat_rent", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia", "district_stat_rent", "mongo.db.fangjia.com",28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) static Map retMap = new ConcurrentHashMap() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy index b0e7a120e..316e602cf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/TotalTestExport.groovy @@ -20,9 +20,9 @@ import java.util.concurrent.CountDownLatch class TotalTestExport { // Ð¡Çø¾ù¼Û¼¯ºÏ - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // Ð¡Çø³É½»¼¯ºÏ - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() // Ôڴ˸ü¸Äʱ¼ä static final def TRADE_DATE_START = "2020-03-28" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy index 82f000f52..c39dbc23d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/ValueRateCityInfoExport.groovy @@ -20,9 +20,9 @@ import java.util.concurrent.CountDownLatch class ValueRateCityInfoExport { // Ð¡Çø¾ù¼Û¼¯ºÏ - static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43",28017) + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com",28017) // Ð¡Çø³É½»¼¯ºÏ - static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + static DBCollection fangjiaConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com",28017) static Map retMap = new ConcurrentHashMap() // Ôڴ˸ü¸Äʱ¼ä static final def TRADE_DATE_START = "2020-03-28" diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy index 3f03c1c01..76d9104bd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/business/BusinessDianpingExport.groovy @@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils class BusinessDianpingExport { static DBCollection collection = MongoUtils.getCollectionByName("fangjia_crawl", "business", "192.168.0.235", 27018) - static DBCollection cityCollection = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityCollection = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static void main(String[] args) { def cityCodes = ["320500","610100","340100"]; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy index 3bffc1300..be6b759e2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundExportByNewWay.groovy @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger */ class AroundExportByNewWay { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static def resultMap = new ConcurrentHashMap() static def unMatchedMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy index 89b1c7b3c..2e5f11e3e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/AroundFormatExport.groovy @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger */ class AroundFormatExport { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static def resultMap = new ConcurrentHashMap() static def unMatchedMap = new ConcurrentHashMap() static ExecutorService executorService = Executors.newFixedThreadPool(30) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy index b8f0452ee..242dd4c63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/ImportSchool.groovy @@ -14,7 +14,7 @@ import com.mongodb.DBObject */ class ImportSchool { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static void main(String[] args) { List> data = ExcelUtils.read("F:\\Êý¾Ý\\ÖØÇìÅ©ÉÌÐÐ\\ÖØÇìѧУ_0902.xlsx", 1) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy index 9ce164947..4c4cfcffc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MarkUnNeedExport.groovy @@ -16,7 +16,7 @@ import sun.swing.BakedArrayList */ class MarkUnNeedExport { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static void main(String[] args) { List> data = ExcelUtils.read("F:\\Êý¾Ý\\ÖØÇìÅ©ÉÌÐÐ\\Öܱ߲¹³ä.xlsx", 1) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy index c641a4fc8..cceebeef6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/MoveArroundTemp.groovy @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger class MoveArroundTemp { static DBCollection conn = MongoUtils.getCollectionByName("seeddb_dev", "arround_temp", "192.168.0.235", 27018) - static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy index 1c907e236..02fda673e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/POIRule.groovy @@ -16,7 +16,7 @@ import java.util.regex.Pattern */ class POIRule { - static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection poiConn = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy index 40c42f36a..496be8386 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SavePoi.groovy @@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicInteger class SavePoi { static DBCollection conn = MongoUtils.getCollectionByName("seeddb_dev", "arround_temp", "192.168.0.235", 27018) - static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "192.168.0.43", 28017) + static DBCollection conn43 = MongoUtils.getCollectionByName("address_analytics", "gaode_address_poi", "mongo.db.fangjia.com", 28017) //3km·¶Î§ÄÚµØÌúÕ¾¡¢¹«½»Õ¾¡¢ÒøÐС¢Ò½Ôº¡¢É̳¡¡¢Ñ§Ð£µÈÃû³Æ¼°¾àÀëÐÅÏ¢ static def types = "150500|1507|090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211|1601|0601|141200|141201|141202|141203|141204" static def radius = 3000 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy index 9817c00cb..854052b17 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/cqrcb/SeaweedExport.groovy @@ -27,9 +27,9 @@ import java.util.concurrent.Executors */ class SeaweedExport { - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) - static final DBCollection seaweed = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017) + static final DBCollection seaweed = MongoUtils.getCollectionByName("fangjia", "seaweed", "mongo.db.fangjia.com", 28017) static def map = new ConcurrentHashMap() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy index 79bf00e9a..0dab33e51 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/crawl/58/Seed58.groovy @@ -15,7 +15,7 @@ import com.mongodb.DBObject class Seaweed58 { static DBCollection districtSeedsConn = MongoUtils.getCollectionByName("seeddb", "district_seeds", "192.168.0.235", 27018) - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static void main(String[] args) { List list = cityMapConn.distinct("fangjia_city") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy index 53b0679f0..60e5e17ce 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeGeoHash.groovy @@ -18,7 +18,7 @@ import java.util.concurrent.Executors */ class CommitteeGeoHash { - static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) + static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(30) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy index db1f5a13d..d83e43625 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy @@ -20,7 +20,7 @@ import java.util.concurrent.Executors */ class CommitteeLatLng { - static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) + static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) static ExecutorService executorService = Executors.newFixedThreadPool(10) static void main(String[] args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy index f466ed3be..b190fbd0b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetCodeFromExcel.groovy @@ -9,7 +9,7 @@ import com.mongodb.DBObject import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang.StringUtils -final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) +final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) /** * »ñȡʡÊÐÇø±àÂë diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy index c8481a44a..4a12ce369 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetTownshipFromExcel.groovy @@ -9,7 +9,7 @@ import com.mongodb.DBObject import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang.StringUtils -final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) +final DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "mongo.db.fangjia.com", 28017) /** * »ñÈ¡¹ú¼Ò±ê×¼¾Óί½ÖµÀ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy index 2949d3803..c73026057 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/CityUtils.groovy @@ -9,7 +9,7 @@ import com.mongodb.DBCollection */ class CityUtils { - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static listCitySet() { List list = cityMapConn.distinct("fangjia_city") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy index c17285a78..d843c3034 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/SeaweedUtils.groovy @@ -17,7 +17,7 @@ import java.util.concurrent.ConcurrentHashMap */ class SeaweedUtils { - static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "192.168.0.43", 28017) + static DBCollection cityMapConn = MongoUtils.getCollectionByName("business", "fangjia_official_area_map", "mongo.db.fangjia.com", 28017) static def map = new ConcurrentHashMap() static getRegionByCode(def district_code) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy index b57cdd659..d8efa9ac3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStandardBatch.groovy @@ -1062,6 +1062,7 @@ class DataStandardBatch extends BaseBatch{ q.put("s_date", SHORT_DATE); DBObject udata2 = new BasicDBObject() + udata2.put("match_id", district._id.toString()); udata2.put("match_city", district.city); udata2.put("match_region", district.region); udata2.put("match_name", district.name); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy index 42972bc05..b0bde2dcf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/DataStat.groovy @@ -15,7 +15,7 @@ import org.apache.commons.codec.binary.Base64; class DataStat { def static final thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") static main(args) { def task = new DataStat(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy index 5f07adb27..1b9e9e1e1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy @@ -27,7 +27,9 @@ class SynchDistrictPrice extends BaseBatch{ // "¼ªÎÝ":"¼ªÎÝ","365ÌÔ·¿":"365ÌÔ·¿","ÎÒ°®ÎÒ¼Ò":"ÎÒ°®ÎÒ¼Ò","Öî¸ðÕÒ·¿APP":"Öî¸ðÕÒ·¿","±´¿Ç":"±´¿ÇÕÒ·¿","Á´¼Ò":"Á´¼Ò","Q·¿":"Q·¿","ÂóÌï":"ÂóÌï", // "ÖÐÔ­µØ²ú":"ÖÐÔ­µØ²ú","°²¾Ó¿ÍС³ÌÐò":"°²¾Ó¿Í","ËÑ·¿":"ËÑ·¿","ÀÖÓмÒ":"ÀÖÓмÒ","C21":"C21","³ÇÊз¿²ú":"³ÇÊз¿²ú","Íò©Ê¿PC¶Ë":"Íò©Ê¿" // def esSources = ["ËÑ·¿":"ËÑ·¿"] - def esSources = ["ÎÒ°®ÎÒ¼Ò":"ÎÒ°®ÎÒ¼Ò","Íò©Ê¿PC¶Ë":"Íò©Ê¿","¼ªÎÝ":"¼ªÎÝ","±´¿ÇÕÒ·¿":"±´¿ÇÕÒ·¿","ÀÖÓмÒ":"ÀÖÓмÒ","365ÌÔ·¿":"365ÌÔ·¿","Öî¸ðÕÒ·¿APP":"Öî¸ðÕÒ·¿","Á´¼Ò":"Á´¼Ò","Q·¿":"Q·¿","ÂóÌï":"ÂóÌï","ÖÐÔ­µØ²ú":"ÖÐÔ­µØ²ú","°²¾Ó¿ÍС³ÌÐò":"°²¾Ó¿Í","ËÑ·¿":"ËÑ·¿","C21":"C21","³ÇÊз¿²úС³ÌÐò":"³ÇÊз¿²ú","ÐÒ¸£ÀïAPP":"ÐÒ¸£Àï", "Öйú·¿¼ÛÐÐÇé":"Öйú·¿¼ÛÐÐÇé","³£ÖÝס·¿":"³£ÖÝס·¿"] + def esSources = ["°²¾Ó¿ÍС³ÌÐò":"°²¾Ó¿Í","ËÑ·¿":"ËÑ·¿","Öî¸ðÕÒ·¿APP":"Öî¸ðÕÒ·¿","ÐÒ¸£ÀïAPP":"ÐÒ¸£Àï","¼ªÎÝ":"¼ªÎÝ","Öйú·¿¼ÛÐÐÇé":"Öйú·¿¼ÛÐÐÇé","±´¿ÇÕÒ·¿":"±´¿ÇÕÒ·¿", + "Á´¼Ò":"Á´¼Ò","C21":"C21","³ÇÊз¿²úС³ÌÐò":"³ÇÊз¿²ú","ÀÖÓмÒ":"ÀÖÓмÒ","ÎÒ°®ÎÒ¼Ò":"ÎÒ°®ÎÒ¼Ò","ÖÐÔ­µØ²ú":"ÖÐÔ­µØ²ú","Íò©Ê¿PC¶Ë":"Íò©Ê¿", + "365ÌÔ·¿":"365ÌÔ·¿","Q·¿":"Q·¿","ÂóÌï":"ÂóÌï","³£ÖÝס·¿":"³£ÖÝס·¿"] static main(args) { runBatch(new SynchDistrictPrice(), args); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy index aa6e24350..195136215 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/TestDistrict.groovy @@ -12,7 +12,7 @@ import java.util.regex.Pattern class Test { - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43")//192.168.0.85 + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com")//192.168.0.85 def static final fieldMap = [ "·¿¹À¹À":"fanggugu_esf","Öî¸ðÕÒ·¿":"zhugezhaofang_esf","°²¾Ó¿Í":"anjuke_esf","ËÑ·¿":"soufang_esf","ÖÐÔ­µØ²ú":"zhongyuan_esf","¸Ï¼¯":"ganji_esf", "Á´¼Ò":"lianjia_esf","Íò©Ê¿":"tuboshi_esf","³ÇÊз¿²ú":"cityhouse_esf","±´¿ÇÕÒ·¿":"beike_esf","Q·¿":"qfang_esf","Q·¿(ÐÂ)":"qfang_new","ÖÐÔ­µØ²ú(ÐÂ)":"zhongyuan_new", diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy index aaf9d6380..f903f3172 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy @@ -27,13 +27,13 @@ class ThirdDataToGatherBatch extends BaseBatch{ def static final DBCollection AVERAGE_STATISTICS_OFFLINE = CrawalDBUtil.getAverage_statistics_col(); //MongoUtils.getMongoDBByAuth().getCollection("average_statistics") // def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com",38888) - def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43")//192.168.0.85 + def static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com")//192.168.0.85 def static final fieldMap = [ "·¿¹À¹À":"fanggugu_esf","Öî¸ðÕÒ·¿":"zhugezhaofang_esf","°²¾Ó¿Í":"anjuke_esf","ËÑ·¿":"soufang_esf","ÖÐÔ­µØ²ú":"zhongyuan_esf","¸Ï¼¯":"ganji_esf", "Á´¼Ò":"lianjia_esf","Íò©Ê¿":"tuboshi_esf","³ÇÊз¿²ú":"cityhouse_esf","±´¿ÇÕÒ·¿":"beike_esf","Q·¿":"qfang_esf","Q·¿(ÐÂ)":"qfang_new","ÖÐÔ­µØ²ú(ÐÂ)":"zhongyuan_new", "ÀÖÓмÒ":"leyoujia_esf","ÀÖÓмÒ(ÐÂ)":"leyoujia_new","·¿Ì½":"fangtan_esf","·¿¶à¶à":"fangdoudou_esf","С×ʼÒ":"xiaozijia_esf","ÎÒ°®ÎÒ¼Ò":"5i5j_esf","ÂóÌï":"maitian_esf", "·¿Í¾":"fangtoo_esf","C21":"c21_esf","ÀÖ¾Ó":"leju_esf","·¿²ú³¬ÊÐ":"fccs_esf","58ͬ³Ç":"58tc_esf","365ÌÔ·¿":"365house_esf","¼ªÎÝ":"jiwu_esf","ÐÒ¸£Àï":"xingfuli_esf", - "Öйú·¿¼ÛÐÐÇé":"creprice_esf","³£ÖÝס·¿":"zwfc_esf" + "Öйú·¿¼ÛÐÐÇé":"creprice_esf","³£ÖÝס·¿":"zwfc_esf", "·¿ÌìÏÂ":"fang_esf" ] public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(2) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy index 67858c081..e2e874695 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/TradeDealPriceStat.groovy @@ -12,7 +12,7 @@ import java.sql.ResultSet class TradeDealPriceStat { - DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") + DBCollection DEAL_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") static def districtMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy index cb84af2c7..9a4003b7d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy @@ -9,13 +9,8 @@ import net.sf.json.JSONObject class BaiduMapUtils { - private static String AK = "9E99D3540e4dafb7894f7b9fe27fa6b5"; - def static AKS = ["hj5KqPjaGA3uivtg8uS8XfAnj9X1kPMr","xjFg7DfDqvQleIZasM3ph8Zi2Lw8kgCg", - "4pb6fzrWIzvibDu8L1o8DGoY2h1wRIUq","ZzX6mRFfE5GKn4cpUp24Q3OyUIHnfQAR","79ac4ea49e7dedbf80b0ecd475d07784", - "9E99D3540e4dafb7894f7b9fe27fa6b5","W3M5uHfcrmlAdhQjf6v93LCI", "C8bb035aacf602551e829e4c64575224", - "B42b12d01f2dee712fd66c3e886158a4", "1a3cde429f38434f1811a75e1a90310c","W3M5uHfcrmlAdhQjf6v93LCI", - "C8bb035aacf602551e829e4c64575224", "B42b12d01f2dee712fd66c3e886158a4", - "1a3cde429f38434f1811a75e1a90310c","9E99D3540e4dafb7894f7b9fe27fa6b5"]; + private static String AK = "1a3cde429f38434f1811a75e1a90310c"; + def static AKS = ["1a3cde429f38434f1811a75e1a90310c","1a3cde429f38434f1811a75e1a90310c"]; public static boolean HAS_AVAILABLE_AK = true; static def getAddress(lng, lat) throws Exception{ @@ -83,8 +78,8 @@ class BaiduMapUtils { throw new RuntimeException("ÎÞ¿ÉÓðٶÈAK"); } System.out.println("¸ü»»AK"); - for(int i = 0 ;i < AKS.length; i++){ - if(i == AKS.length - 1){ + for(int i = 0 ;i < AKS.size(); i++){ + if(i == AKS.size() - 1){ AK = AKS[0]; HAS_AVAILABLE_AK = false; throw new RuntimeException("ÎÞ¿ÉÓðٶÈAK"); @@ -127,6 +122,35 @@ class BaiduMapUtils { return null } + + public static JSONObject geocoding(locationstr) { + String url = "https://api.map.baidu.com/reverse_geocoding/v3/?ak="+AK+"&output=json&coordtype=gcj02ll&location="+locationstr + boolean stop = false; + int recount = 0; + JSONObject jsonObj = null + while(!stop && recount<6) { + try{ + HttpRequest request = new HttpRequest(); + try{ + String result = request.get(url,null,"UTF-8"); + def json = JSONObject.fromObject(result); + if(json.getInt("status") >= 300){ + changeAK(); + recount++ + }else{ + jsonObj = json.result + } + }catch (Exception e){ + e.printStackTrace(); + } + }catch (Exception e){ + recount++; + println e.getMessage() + } + } + return jsonObj + } + public static def searchByBounds(key, min_lat, min_lng, max_lat, max_lng){ boolean stop = false; int recount = 0; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy index 3f12f1b79..300c1ea6b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CosineSimilarAlgorithm.groovy @@ -1,12 +1,28 @@ package com.fangjia.script.util +import com.hankcs.hanlp.restful.HanLPClient +import org.apache.commons.text.similarity.* +import org.apache.commons.text.similarity.JaroWinklerSimilarity + class CosineSimilarAlgorithm { + public static void main(String[] args){ - println CosineSimilarAlgorithm.getSimilarity("À¼ÆºÂ·301Ū","À¼ÆºÂ·301Ū12֧Ū,À¼ÆºÂ·301Ū22Ö§"); - println CosineSimilarAlgorithm.getSimilarity("À¼ÆºÂ·301Ū12֧Ū,À¼ÆºÂ·301Ū22Ö§","À¼ÆºÂ·301Ū"); - println CosineSimilarAlgorithm.getSimilarityRatio("½­´¨Â·291ºÅ","½­´¨Â·291Ū") - println CosineSimilarAlgorithm.getSimilarityRatio("½­´¨Â·291ºÅ","½­´¨Â·290ºÅ"); + + def address1 = "Êн¨ËĹ«Ë¾ËÞÉá" + def address2 = "Êн¨ËĹ«Ë¾Ð¡Çø" + + println "ÓàÏÒÏàËÆ:"+CosineSimilarAlgorithm.getSimilarity(address1, address2);//ÓàÏÒÏàËÆ + println "±à¼­¾àÀë:"+CosineSimilarAlgorithm.levenshteinSimilarity(address1, address2);//±à¼­¾àÀë + println "Jaro-Winkler ÏàËÆ¶È:"+CosineSimilarAlgorithm.jaroWinklerSimilarity(address1, address2)//Jaro-Winkler ÏàËÆ¶È + println "×ÛºÏÏàËÆ:"+CosineSimilarAlgorithm.calculateSimilarity(address1, address2);//×ÛºÏÏàËÆ + println "jaccard:"+CosineSimilarAlgorithm.jaccardSimilarity(address1, address2); + println "jaccard:"+CosineSimilarAlgorithm.jaccardSimilarity2(address1, address2); + +// def customTokenizer = { text -> text.split(" ").toSet() } +// +// def score2 = jaccardSimilarity(address1, address2, customTokenizer) +// println "°´´ÊÓï·Ö¸îµÄJaccardÏàËÆ¶È: ${(score2 * 100).round(2)}%" } @@ -160,7 +176,73 @@ class CosineSimilarAlgorithm { public static float getSimilarityRatio(String str, String target) { return 1 - (float)compare(str, target)/Math.max(str.length(), target.length()); } - - + // ¼ÆËã Levenshtein ÏàËÆ¶È (»ùÓڱ༭¾àÀë) + static def levenshteinSimilarity(String s1, String s2) { + def maxLength = Math.max(s1.size(), s2.size()) + if (maxLength == 0) return 1.0 + def lev = new LevenshteinDistance() + return 1 - (lev.apply(s1, s2) / maxLength) + } + + // ¼ÆËã Jaro-Winkler ÏàËÆ¶È + static def jaroWinklerSimilarity(String s1, String s2) { + def jw = new JaroWinklerSimilarity() + jw.apply(s1, s2) + } + + static def jaccardSimilarity(String str1, String str2, Closure tokenizer = null) { + // ĬÈÏ·Ö´ÊÂß¼­£º°´×Ö·û·Ö¸îΪ¼¯ºÏ + if (tokenizer == null) { + tokenizer = { text -> text.chars.collect { it as String } as Set } + } + + def set1 = tokenizer(str1) + def set2 = tokenizer(str2) + + // ´¦Àí¿Õ¼¯ºÏÇé¿ö + if (set1.isEmpty() && set2.isEmpty()) return 1.0 + if (set1.isEmpty() || set2.isEmpty()) return 0.0 + + def intersection = set1.intersect(set2).size() + def union = set1.size() + set2.size() - intersection + intersection / union as Double + } + + +// ×ÛºÏÏàËÆ¶È (¿Éµ÷ÕûÈ¨ÖØ) + static def calculateSimilarity(String s1, String s2) { + def levScore = levenshteinSimilarity(s1, s2) + def jwScore = jaroWinklerSimilarity(s1, s2) + // ¼ÓȨƽ¾ù (Levenshtein Õ¼40%, Jaro-Winkler Õ¼60%) + (levScore * 0.4 + jwScore * 0.6).round(2) + } + + + static def jaccardSimilarity2(str1, str2) { + // ½«×Ö·û´®×ª»»Îª×Ö·û¼¯ºÏ + def set1 = str1.chars.toSet() + def set2 = str2.chars.toSet() + + // ¼ÆËã½»¼¯ºÍ²¢¼¯ + def intersection = set1.intersect(set2).size() + def union = set1.size() + set2.size() - intersection + + // ¼ÆËãJaccardÏàËÆ¶È + def similarity = (double) intersection / union + + return similarity + } + + static def jaccardByChineseSegmentation(String str1, String str2) { + // ÖÐÎÄ·Ö´Ê£¨ÐèÒªHanLPÒÀÀµ£© + HanLPClient HanLP = new HanLPClient("https://www.hanlp.com/api", null); + def seg1 = HanLP.segment(str1).collect { it.word }.toSet() + def seg2 = HanLP.segment(str2).collect { it.word }.toSet() + + def intersection = seg1.intersect(seg2).size() + def union = seg1.size() + seg2.size() - intersection + + return union == 0 ? 0 : (double) intersection / union + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy index 6aba12207..a611fedc8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ElasticUtils.groovy @@ -1,5 +1,8 @@ package com.fangjia.script.util +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import net.sf.json.JSONObject import org.apache.http.HttpHost import org.apache.http.auth.AuthScope import org.apache.http.auth.UsernamePasswordCredentials @@ -17,11 +20,13 @@ import org.elasticsearch.action.search.ClearScrollRequest import org.elasticsearch.action.search.SearchRequest import org.elasticsearch.action.search.SearchResponse import org.elasticsearch.action.search.SearchScrollRequest +import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.client.RestClient import org.elasticsearch.client.RestClientBuilder import org.elasticsearch.client.RestHighLevelClient import org.elasticsearch.common.unit.TimeValue +import org.elasticsearch.common.xcontent.XContentType import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.search.Scroll import org.elasticsearch.search.SearchHit @@ -262,4 +267,68 @@ class ElasticUtils { client.close() return results; } + + static def modify(id, map, host, indexName){ + BulkRequest request = new BulkRequest(); + int processedCount = 0; + def client = null + if(host && host == "192.168.0.89"){ + client = ElasticUtils89.getClient(host) + }else if(host && host == "192.168.0.52"){ + client = ElasticUtils.getClient(host) + } + + request.add(new IndexRequest(indexName, "_doc", id).source(map, XContentType.JSON)); + if (request.numberOfActions() > 100) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + } + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // ´¦Àí´íÎó + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + } + } + + static def delete(id, host, indexName){ + def header = [:] + if(host && host == "192.168.0.89"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:elasticsearch".getBytes("UTF-8"))}".toString() + }else if(host && host == "192.168.0.52"){ + header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:goojia123456".getBytes("UTF-8"))}".toString() + } + String seawaterUrl = "http://${host}:9200/${indexName}/_delete_by_query" + def body = """ + { + "query": { + "bool": { + "must": [ + { + "match": { + "id": "${id}" + } + } + ] + } + } + } + """ + HttpRequest request = new HttpRequest() + String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8") + println(res) + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy index cb59203cf..e04562271 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy @@ -1,4 +1,8 @@ package com.fangjia.script.util + + +import java.text.DecimalFormat + class GeoHelper { @@ -60,10 +64,159 @@ class GeoHelper { // return GetLatLon(a, distance, angle); // } // - public static void main(String[] args){ - GeoHelper.GetLatLon( 31.222361, 121.380462, 0.6, 0); - GetDistance(31.222361, 121.380462, 31.227757176233904, 121.380462); - } + public static haversine(lat1, lon1, lat2, lon2) { + def R = 6371; // µØÇò°ë¾¶£¨¹«À + def lat1Rad = lat1 * (Math.PI / 180); + def lat2Rad = lat2 * (Math.PI / 180); + def deltaLat = (lat2 - lat1) * (Math.PI / 180); + def deltaLon = (lon2 - lon1) * (Math.PI / 180); + + def a = Math.sin(deltaLat / 2) ** 2 + + Math.cos(lat1Rad) * Math.cos(lat2Rad) * + Math.sin(deltaLon / 2) ** 2; + + def c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + return R * c; // ·µ»Ø¾àÀ루¹«À + } + + public static calculateArea(coords) { + def area = 0; + def n = coords.size(); + + for (def i = 0; i < n; i++) { + def j = (i + 1) % n; + area += coords[i][0] * coords[j][1]; + area -= coords[j][0] * coords[i][1]; + } + area = Math.abs(area) / 2; // ƽ·½¶È + + // ת»»ÎªÆ½·½¹«Àï + def conversionFactor = 111.32; // ´óԼÿ¶È¾­Î³¶ÈµÄ¹«ÀïÊý£¨¿¼Âǵ½µØÇòµÄÇúÂÊ£© + + def df = new DecimalFormat("#.000000") + return Double.parseDouble(df.format(area * conversionFactor * conversionFactor)) // ·µ»ØÃæ»ý£¨Æ½·½¹«À +// return area * conversionFactor * conversionFactor + } + + + public static void main(String[] args){ +// GeoHelper.GetLatLon( 31.222361, 121.380462, 0.6, 0); +// GetDistance(31.222361, 121.380462, 31.227757176233904, 121.380462); + + List> coordinates = [ + [ + 117.61878540582734, + 24.667331307258223 + ], + [ + 117.61400840589488, + 24.670008244935104 + ], + [ + 117.60936140565889, + 24.671837202755682 + ], + [ + 117.60834440585768, + 24.668667276729821 + ], + [ + 117.60696440583342, + 24.667256309201207 + ], + [ + 117.60517040553236, + 24.667762297657362 + ], + [ + 117.60272340547806, + 24.660100475272998 + ], + [ + 117.60254340555321, + 24.658630509428463 + ], + [ + 117.60206940590035, + 24.654781598282568 + ], + [ + 117.60254840557604, + 24.652731645907636 + ], + [ + 117.60346440599301, + 24.651555673447035 + ], + [ + 117.6070314057805, + 24.652578649754957 + ], + [ + 117.61605140571805, + 24.651939664372833 + ], + [ + 117.6156454058372, + 24.654165613124405 + ], + [ + 117.61559340595863, + 24.655023593107103 + ], + [ + 117.61535440558418, + 24.658990501065318 + ], + [ + 117.61662340528017, + 24.659352492642654 + ], + [ + 117.61678740531192, + 24.661365445721003 + ], + [ + 117.61472940542001, + 24.661623439403797 + ], + [ + 117.61462940586114, + 24.661837434759093 + ], + [ + 117.61470140583106, + 24.662665415879701 + ], + [ + 117.61487240553515, + 24.663165403873506 + ], + [ + 117.61522940591078, + 24.663494396452791 + ], + [ + 117.6157014059138, + 24.663523395394918 + ], + [ + 117.61627240565099, + 24.663438397829282 + ], + [ + 117.61693540544979, + 24.663181403867725 + ], + [ + 117.61878540582734, + 24.667331307258223 + ] + ] + + double area = calculateArea(coordinates) + println "The area of the polygon is: ${String.format("%.2f", area)} square kilometers" + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy index 54d093d7e..3ecfd9680 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/MongoUtils.groovy @@ -57,7 +57,7 @@ class MongoUtils { static def collectionMap = [:] static def loudongCollectionMap = [:] - static def getCollectionByName(db, name, domainUrl, port = 27017) { + static def getCollectionByName(db, name, domainUrl, port = 28017) { if ((domainUrl == MongoDB_IP_43 || domainUrl == MongoDB_IP_136 || domainUrl == MongoDB_Domain_offline_fangjia || domainUrl == MongoDB_IP_85 || domainUrl == MongoDB_Domain_mongo) && port == 28017) { return com.fangjia.core.util.MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, db, name) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy index 0519c71eb..6012d1cb0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20181123.groovy @@ -8,7 +8,7 @@ import com.mongodb.BasicDBObject import com.mongodb.Bytes import com.mongodb.DBCollection -DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia", "district_stat", "192.168.0.43") +DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia", "district_stat", "mongo.db.fangjia.com") def query =new BasicDBObject(); query.put('weekend', DateUtils.parseFromTightYYYYMMDD("2018-11-18")); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy index a77707ae6..2a6223d63 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190115.groovy @@ -11,7 +11,7 @@ import com.mongodb.DBCursor import com.mongodb.DBObject import org.apache.commons.lang.StringUtils -DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat", "192.168.0.43", 28017); +DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat", "mongo.db.fangjia.com", 28017); DBObject q = new BasicDBObject("city": "Î÷Äþ"); q.put("date", 201812); //q.put("date", new BasicDBObject('gt', 201806).append('lte', 201812)); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy index 8c8aa0990..6158704c7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Daily/20190121.groovy @@ -13,7 +13,7 @@ import org.apache.commons.lang.StringUtils List> detailRows = new ArrayList>(); detailRows.add(["³ÇÊÐ", "ÇøÓò", "Ð¡ÇøÃû", "¿ÉÐÔ¶È"]); -DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017); +DBCollection DIST_SELL_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 28017); DBObject q = new BasicDBObject(); //new BasicDBObject('city', new BasicDBObject('$in', ["³£ÖÝ", "ËÕÖÝ", "»´°²"])) q.put("city", "»´°²"); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy index 772e91d06..050ba67fb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/weilei/Test.groovy @@ -27,7 +27,7 @@ for (int i = 0; i < FangGuGuCrawl.accountUsers.size(); i++) { } return 1; -DBCollection col_district_stat_1 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43"); +DBCollection col_district_stat_1 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com"); DBCollection col_district_stat_2 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.136", 27018); DBCollection col_district_stat_18 = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.18", 28018); DBCursor cursor = col_district_stat_1.find().sort(new BasicDBObject("weekend", -1)).batchSize(2000).addOption(Bytes.QUERYOPTION_NOTIMEOUT); @@ -76,7 +76,7 @@ println "End - " + count; //return; // // -//DBCollection col_guiding_price = MongoUtils.getCollectionByName("fangjia", "guiding_price", "192.168.0.43", 27017); +//DBCollection col_guiding_price = MongoUtils.getCollectionByName("fangjia", "guiding_price", "mongo.db.fangjia.com", 27017); // //DBCursor cursor = col_guiding_price.find(new BasicDBObject('$where' , "this.name == this.guiding_person")); //while(cursor.hasNext()){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy index e67e057e5..47325a59c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/address/Test1.groovy @@ -12,7 +12,7 @@ import java.sql.Connection import java.sql.ResultSet import java.sql.Statement -//final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +//final DBCollection DIST_STAT_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") //def key = [] //int i =0 //DIST_STAT_COLL.find(new BasicDBObject("weekend", DateUtil.parseDate("20180826", "yyyyMMdd"))).batchSize(1000).each {def dbo-> diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy index b260aa415..f1563a0bb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/CityHousePrice.groovy @@ -4,7 +4,7 @@ import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection -DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") +DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "average_statistics", "mongo.db.fangjia.com") def data = ExcelUtils.read("D:\\Users\\wenyan\\Desktop\\³ÇÊÐÆÀ¹À¾ù¼Û¶Ô±È.xlsx", 1) long total = 0 int count = 0 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy index d2ba9610a..9ee9d0379 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DealPrice.groovy @@ -20,7 +20,7 @@ import java.sql.Statement //Class.forName("ru.yandex.clickhouse.ClickHouseDriver"); //Connection connection = DriverManager.getConnection("jdbc:clickhouse://192.168.0.19:8123?max_memory_usage=50000000000") -//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") //DbUtils.multiThreadingExecuteQueryOnSeaweed(DbUtils.buildSeaweedQuery("ÉϺ£"),{BasicDBObject district-> // def estate_type = "Ð¡Çø" // if(district.estate_type2.toString().contains("±ðÊû")){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy index 75b6728d1..f86633ef6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/DistrictStatRepeatRemover.groovy @@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicLong // //def removeRepeatDistrictStat(city, region, name, estate_type){ -// DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +// DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") // List stats = DISTRICT_STAT.find(new BasicDBObject("city", city).append("region", region).append("district_name", name).append("estate_type",estate_type)).toList() // def map = [:] // stats.each {BasicDBObject stat-> @@ -60,7 +60,7 @@ import java.util.concurrent.atomic.AtomicLong //}) -DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43") +DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") def keys = new BasicDBObject() keys.city = 1 keys.region = 1 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy index 7961e4d15..4ac5450d7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test13.groovy @@ -12,7 +12,7 @@ import com.mongodb.DBCollection import net.sf.json.JSONArray import net.sf.json.JSONObject -DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat_new", "192.168.0.43") +DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat_new", "mongo.db.fangjia.com") def trend(city, region, name, weekend, estate_type) { def cmd = new BasicDBObject() cmd.city = city diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy index 1c7fa0a2c..bcfff62f7 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Test14.groovy @@ -11,7 +11,7 @@ import com.mongodb.Bytes import com.mongodb.DBCollection import net.sf.json.JSONObject -//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 27017) +//DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com", 27017) //def int count =0 //ExcelUtils.multiThreadingModify("D:\\Õǵø·ù½Ï´óÐ¡Çø.xlsx",{ List item-> // def query = new BasicDBObject() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy index 016d99b3d..af9993be3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/Trend.groovy @@ -10,7 +10,7 @@ import com.mongodb.Bytes import com.mongodb.DBCollection //def cities = ["±±¾©", "ÉϺ£", "¹ãÖÝ","ÉîÛÚ","º¼ÖÝ","ÄϾ©","Î人","³É¶¼","Î÷°²","³¤É³","Äϲý","¹óÑô","ÈýÑÇ"] -//DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43") +//DBCollection GUIDING_PRICE = MongoUtils.getCollectionByName("fangjia", "deal_price", "mongo.db.fangjia.com") //cities.each {def city-> // def one = GUIDING_PRICE.find(new BasicDBObject("city", city)).sort(new BasicDBObject("trade_date", 1)).limit(0)[0] // println(city + "\t" + ((Date)one.trade_date).format("yyyy")) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy index 2ebfa4262..41c5483ab 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/wenyan/temp/XingYe.groovy @@ -12,7 +12,7 @@ import java.sql.Connection import java.sql.ResultSet import java.sql.Statement -DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "192.168.0.43") +DBCollection DIST_COLL = MongoUtils.getCollectionByName("fangjia_stat", "district_grade", "mongo.db.fangjia.com") def String hasElevator(BasicDBObject seaweed){ EsDataSource dataSource = new EsDataSource() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy index e53eec2b6..d0a3a74c2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/DealPriceStat.groovy @@ -14,7 +14,7 @@ import com.mongodb.DBCollection */ class DealPriceStat { - public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; + public static final def lineUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; public static final DBCollection deal_price_coll = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) static main(args) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy index 65da1a7be..60dc4ddb2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy @@ -12,7 +12,8 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { - def static GAO_DE_AK = "c6fcd4bfbc40d73ee762b8115dca3390" //±¦½£ + //94c74c60e102972a8d17b7b75d7403be + def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //±¦½£:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995£ºdfc2245bac8a7b2d5b62e060e59d4eca /** @@ -29,12 +30,28 @@ class GaoDeApiUtils { params.put("location", location) params.put("extensions","all") String content - try { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") - } catch (Exception e) { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + def stop = true + JSONObject jsonObj = null + def errorCount = 1 + while (stop){ + try { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } catch (Exception e) { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } + jsonObj = JSONObject.fromObject(content) + if(jsonObj.status!="1"){ + println jsonObj + errorCount ++ + Thread.sleep(3000) + if(errorCount>3){ + stop = false + } + }else{ + stop = false + } } - JSONObject jsonObj = JSONObject.fromObject(content) + return jsonObj } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy index 5236cc675..db03ae997 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/DistrictRateStat.groovy @@ -330,7 +330,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy index 8b49db263..7e9558e4a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/price/QinLingStat1.groovy @@ -344,7 +344,7 @@ def findDistrictPrice(def city, def region){ q.put("region", region); } //districtStatConn.addOption(Bytes.QUERYOPTION_SLAVEOK); - final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@192.168.0.43:28017","fangjia_stat", "district_stat"); + final def districtStatConn = Mongo3Utils.getDbCollection("mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017","fangjia_stat", "district_stat"); def count = districtStatConn.count(q) return count; } \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy index 6c1344eb9..e1cddfa83 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/zsbank/DistrictLevelBatch.groovy @@ -8,21 +8,27 @@ import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection - /** - * 浙商本地化部署å�Œæ­¥è„šæœ¬ + * ÕãÉ̱¾µØ»¯²¿Êðͬ²½½Å±¾-Âß¼­ÐÞ¸Ä */ @BatchOwner(Watcher.GaoJuan) class DistrictLevelBatch extends BaseBatch{ public static final def ZS_MONGODB_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; public static final DBCollection ZS_LEVEL_CONN = MongoUtils.getCollectionByName2("fangjia", "district_analy", ZS_MONGODB_URL) + public static final zsDistLevelMap = [:] static main(args) { runBatch(new DistrictLevelBatch(), args); } @Override public void process(Object args) { + + def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject()) + for(def distLevel : zsDistLevelCursor){ + zsDistLevelMap.put(distLevel._id.toString(), distLevel) + } + def citys = CommonDatautils.findAllCity(); def weekend = DateUtils.getFirstDayOfWeek(new Date()); for(def city : citys){ @@ -31,7 +37,7 @@ class DistrictLevelBatch extends BaseBatch{ def datas = addPriceData(dists, priceMap); datas = calcuteLevel(datas); saveOrUpdateDB(city, datas); - println city +" 楼盘评级å�Œæ­¥å®Œæˆ�" + println city +" Â¥ÅÌÆÀ¼¶Í¬²½Íê³É!" } } @@ -93,13 +99,12 @@ class DistrictLevelBatch extends BaseBatch{ } def saveOrUpdateDB(city, datas){ - def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject("city",city)) - def zsDistLevelMap = [:] def zsDistLevels = [] + def zsDistLevelCursor = ZS_LEVEL_CONN.find(new BasicDBObject("city",city)) for(def distLevel : zsDistLevelCursor){ - zsDistLevelMap.put(distLevel._id.toString(), distLevel) - zsDistLevels << distLevel + zsDistLevels << distLevel._id.toString() } + def newDataMap = [:] def addDatas = [] for(def d : datas){ @@ -130,13 +135,13 @@ class DistrictLevelBatch extends BaseBatch{ ZS_LEVEL_CONN.insert(addDatas); } if(zsDistLevels.size()>0){ - for(def zs : zsDistLevels){ - def newData = newDataMap.get(zs._id.toString()); + for(def zs_id : zsDistLevels){ + def newData = newDataMap.get(zs_id.toString()); if(!newData){ def udata = new BasicDBObject() udata.put("status",1) udata.put("update_date",new Date().getTime()) - ZS_LEVEL_CONN.update(new BasicDBObject("_id",zs._id), new BasicDBObject('$set',udata)) + ZS_LEVEL_CONN.update(new BasicDBObject("_id",zs_id), new BasicDBObject('$set',udata)) } } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java index 5928f1294..ce98de284 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AddressMatchProxyServiceImpl.java @@ -1,25 +1,24 @@ package com.fangjia.service.api; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.StringUtils; - -import net.sf.json.JSONArray; -import net.sf.json.JSONException; -import net.sf.json.JSONObject; - -import com.fangjia.core.util.GeoUtils; -import com.fangjia.core.util.HttpRequest; -import com.fangjia.core.util.HttpRequestException; -import com.fangjia.core.util.JsonUtils; +import com.fangjia.core.util.*; +import com.fangjia.dal.mongo.open.model.WaitCrawlKeywords; +import com.fangjia.service.address.AddressParserService; +import com.fangjia.service.address.AddressParserUtil; +import com.fangjia.service.address.mode.*; import com.fangjia.service.bo.CheckMatchDistrictCorrectParam; import com.fangjia.service.bo.MatchAddressScore; import com.fangjia.service.bo.MatchDistrictResult; +import com.fangjia.service.datastore.EvaluationService; +import com.fangjia.service.dto.UniversalDto; +import com.fangjia.service.mongo.bkoff.HouseLoudongService; +import com.fangjia.service.open.WaitCrawlKeywordsService; +import com.fangjia.service.sql.FjtEvaluationService; +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; +import org.apache.commons.lang.StringUtils; + +import java.util.*; /** * Created by wenyan on 2016/1/15. @@ -28,17 +27,143 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme public static final int MIN_TIMEOUT = 1000 * 2; private final static String TOKEN = "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB"; + private AddressParserService addressParserService; - public AddressMatchProxyServiceImpl(String apiHost) { + private HouseLoudongService houseLoudongService; + private FjtEvaluationService fjtEvaluationService; + private EvaluationService evaluationService; + private WaitCrawlKeywordsService waitCrawlKeywordsService; + + public AddressMatchProxyServiceImpl(String apiHost) { super(apiHost); } + private String realMatch(Map paramsMap) { + String address = paramsMap.get("address").toString(); + address = address.replaceAll("@@", "#");// ¿ò¼ÜÎÞ·¨´¦Àí²ÎÊý´øÓÐ#µÄBuge ÓÃ@@´úÌæ + BuildingType buildingType = null; + if (paramsMap.containsKey("category")) { + if ("property".equals(paramsMap.get("category"))) { + paramsMap.put("category", "district"); + } + try { + buildingType = BuildingType.valueOf(((String)paramsMap.get("category")).toUpperCase()); + } catch (Exception e) { + + } + } + PreciseLevel preciseLevel = PreciseLevel.FUZZY; + if ("strict".equals(paramsMap.get("preciseLevel"))) { + preciseLevel = PreciseLevel.STRICT; + } + MatchParams params = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + params.setCity(paramsMap.get("city").toString()); + } + if (paramsMap.containsKey("suggestDistrict") && paramsMap.get("suggestDistrict") != null) { + params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); + } + if (paramsMap.containsKey("suggestName") && paramsMap.get("suggestName") != null) { + params.setSuggestName(paramsMap.get("suggestName").toString()); + } + params.setAddress(address); + params.setBuildingType(buildingType); + params.setPreciseLevel(preciseLevel); + if (paramsMap.containsKey("province") && paramsMap.get("province") != null) { + params.setProvince(paramsMap.get("province").toString()); + } + if (paramsMap.containsKey("useMap") && paramsMap.get("useMap") != null) { + params.setUseMap("false".equals(paramsMap.get("useMap")) ? false : true); + } + if (paramsMap.containsKey("debugName") && paramsMap.get("debugName") != null) { + params.setDebugName(paramsMap.get("debugName").toString()); + } + if (paramsMap.containsKey("propertyType") && paramsMap.get("propertyType") != null) { + params.setPropertyType(paramsMap.get("propertyType").toString()); + } + long start = System.currentTimeMillis(); + Building building = addressParserService.parser(params); + long end = System.currentTimeMillis(); + if (end - start > 200) { + LOGGER.warn("Æ¥ÅäparserºÄʱ:\t" + (end - start) + "ms"); + } + if (paramsMap.containsKey("verify") && "true".equalsIgnoreCase(paramsMap.get("verify").toString())) { + verify(building); + } + + JSONObject baseModel = new JSONObject(); + + Map result = convertBuildingToMap(building); + if (paramsMap.containsKey("token") && !TOKEN.equals(paramsMap.get("token"))) { + submitFetchTask(building); + result.remove("precise"); + result.remove("searchAddress"); + result.remove("map"); + } + + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", result); + + + return baseModel.toString(); + } + + public String realMatchAll(Map paramsMap) { + String address = paramsMap.get("address").toString();; + address = address.replaceAll("@@", "#");// ¿ò¼ÜÎÞ·¨´¦Àí²ÎÊý´øÓÐ#µÄBuge ÓÃ@@´úÌæ + BuildingType buildingType = null; + if (paramsMap.containsKey("category")) { + if ("property".equals(paramsMap.get("category"))) { + paramsMap.put("category", "district"); + } + try { + buildingType = BuildingType.valueOf(((String)paramsMap.get("category")).toUpperCase()); + } catch (Exception e) { + + } + } + PreciseLevel preciseLevel = PreciseLevel.FUZZY; + if ("strict".equals(paramsMap.get("preciseLevel"))) { + preciseLevel = PreciseLevel.STRICT; + } + MatchParams params = new MatchParams(); + if (paramsMap.containsKey("city")) { + params.setCity(paramsMap.get("city").toString()); + } + if (paramsMap.containsKey("suggestDistrict")) { + params.setSuggestDistrict(paramsMap.get("suggestDistrict").toString()); + } + if (paramsMap.containsKey("suggestName")) { + params.setSuggestName(paramsMap.get("suggestName").toString()); + } + + params.setAddress(address); + params.setBuildingType(buildingType); + params.setPreciseLevel(preciseLevel); + + if (paramsMap.containsKey("province")) { + params.setProvince(paramsMap.get("province").toString()); + } + AddressParseResult addressParseResult = addressParserService.parserAll(params); + List buildings = addressParseResult.getBuildings(); + List> buildingObjs = new ArrayList>(buildings.size()); + for (Building building : buildings) { + buildingObjs.add(convertBuildingToMap(building)); + } + JSONObject baseModel = new JSONObject(); + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", buildingObjs); + return baseModel.toString(); + } + @Override public String parser(Map params) { params.put("token", TOKEN); long start = System.currentTimeMillis(); try { - String result = this.invoke("address/realMatch", params, "UTF-8"); + String result = realMatch(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -54,7 +179,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme public String parserAll(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realMatchAll", params, "UTF-8"); + String result = realMatchAll(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -62,11 +187,25 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String cleanCache(final Map paramsMap) { + + new Thread() { + @Override + public void run() { + addressParserService.clearCache((String) paramsMap.get("city")); + } + }.start(); + JSONObject baseModel = new JSONObject(); + baseModel.put("code", 200); + baseModel.put("msg", "¿ªÊ¼Ë¢Ð»º´æ"); + return baseModel.toString(); + } + @Override public String cacheFlush(Map params){ params.put("token", TOKEN); try { - String result = this.invoke("address/cleanCache", params, "UTF-8"); + String result = cleanCache(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -74,11 +213,85 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realStandard(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "µØÖ·²»ÄÜΪ¿Õ"); + return baseModel.toString(); + } + + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity(paramsMap.get("city").toString()); + } + matchParams.setAddress(paramsMap.get("address").toString()); + matchParams.setAddressParserGoal(AddressParserGoal.Match); + matchParams.setPreciseLevel(PreciseLevel.STRICT); + if (paramsMap.containsKey("province") && paramsMap.get("province") != null) { + matchParams.setProvince(paramsMap.get("province").toString()); + } + + matchParams.setUseAliyunApi(false); + matchParams.setContainsLocation("false".equals(paramsMap.get("containsLocation")) ? false : true); + Building building = addressParserService.standard(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + dto.append("province", address.getProvince()); + dto.append("city", address.getCity()); + if (address.getDistrict() != null) { + dto.append("district", address.getDistrict()); + } else { + dto.append("district", building.getDistrict()); + } + dto.append("developmentZone", address.getDevelopmentZone()); + dto.append("township", address.getTownship()); + dto.append("street", address.getStreet()); + dto.append("streetNumber", address.getStreetNumber()); + if (StringUtils.isBlank(building.getSuggestName())) { + if (StringUtils.isNotBlank(address.getParsedPropertyName())) { + dto.append("name", address.getParsedPropertyName()); + } else if (StringUtils.isNotBlank(address.getOrgKeywords())) { + dto.append("name", address.getOrgKeywords()); + } + } else { + dto.append("name", building.getSuggestName()); + } + if (StringUtils.isBlank(address.getStreet()) && StringUtils.isNotBlank(building.getAddress())) { + String addr = building.getAddress(); + String street = AddressParserUtil.extractStreet(addr); + if (street != null) { + dto.append("street", street); + if (addr.length() != street.length()) { + dto.append("streetNumber", AddressParserUtil.match(AddressParserUtil.STREET_NUMBER_CONNECTOR_PATTERN, addr)); + } + } else if (StringUtils.isNotBlank(building.getStreet())) { + dto.append("street", building.getStreet()); + if (StringUtils.isNotBlank(building.getStreetno())) { + dto.append("streetNumber", building.getStreetno()); + } + } + } + dto.append("buildingNumber", address.getBuildingNumber()); + dto.append("floor", address.getFloor()); + dto.append("unitNumber", address.getUnitNumber()); + dto.append("roomNumber", address.getRoomNumber()); + dto.append("formattedAddress", address.getFormattedAddress()); + if (matchParams.isContainsLocation()) { + dto.append("lat", building.getLat()); + dto.append("lng", building.getLng()); + } + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String standard(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realStandard", params, "UTF-8"); + String result = realStandard(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -86,6 +299,48 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realCertificateAction(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "µØÖ·²»ÄÜΪ¿Õ"); + return baseModel.toString(); + } + + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity(paramsMap.get("city").toString()); + } + matchParams.setAddress(paramsMap.get("address").toString()); + matchParams.setAddressParserGoal(AddressParserGoal.Certificate); + matchParams.setPreciseLevel(PreciseLevel.STRICT); + Building building = addressParserService.certificate(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + dto.append("province", address.getProvince()); + dto.append("city", address.getCity()); + if (address.getDistrict() != null) { + dto.append("district", address.getDistrict()); + } else { + dto.append("district", building.getDistrict()); + } + dto.append("developmentZone", address.getDevelopmentZone()); + dto.append("township", address.getTownship()); + dto.append("street", address.getStreet()); + dto.append("streetNumber", address.getStreetNumber()); + dto.append("name", building.getSuggestName()); + dto.append("buildingNumber", address.getBuildingNumber()); + dto.append("unitNumber", address.getUnitNumber()); + dto.append("roomNumber", address.getRoomNumber()); + dto.append("formattedAddress", address.getFormattedAddress()); + dto.append("certified", address.getCertified()); + dto.append("floor", address.getFloor()); + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String certificate(Map params) { params.put("token", TOKEN); @@ -98,11 +353,75 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } + public String realAuth(Map paramsMap) { + JSONObject baseModel = new JSONObject(); + if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) { + baseModel.put("code", 400); + baseModel.put("msg", "µØÖ·²»ÄÜΪ¿Õ"); + return baseModel.toString(); + } + MatchParams matchParams = new MatchParams(); + if (paramsMap.containsKey("city") && paramsMap.get("city") != null) { + matchParams.setCity((String) paramsMap.get("city")); + } + matchParams.setAddress((String) paramsMap.get("address")); + matchParams.setAddressParserGoal(AddressParserGoal.Certificate); + matchParams.setUseMap(true); + Building building = addressParserService.certificate(matchParams); + Address address = building.getSearchAddress(); + UniversalDto dto = UniversalDto.newDto(); + if (StringUtils.isNotBlank(address.getProvince())) { + dto.append("province", address.getProvince()); + } + if (StringUtils.isNotBlank(address.getCity())) { + dto.append("city", address.getCity()); + } + if (StringUtils.isNotBlank(address.getCity())) { + dto.append("district", address.getDistrict()); + } + if (StringUtils.isNotBlank(address.getDevelopmentZone())) { + dto.append("developmentZone", address.getDevelopmentZone()); + } + if (StringUtils.isNotBlank(address.getTownship())) { + dto.append("township", address.getTownship()); + } + if (StringUtils.isNotBlank(address.getStreet())) { + dto.append("street", address.getStreet()); + } + if (StringUtils.isNotBlank(address.getStreetNumber())) { + dto.append("streetNumber", address.getStreetNumber()); + } + if (StringUtils.isNotBlank(address.getBuildingNumber())) { + dto.append("buildingNumber", address.getBuildingNumber()); + } + if (StringUtils.isNotBlank(address.getUnitNumber())) { + dto.append("unitNumber", address.getUnitNumber()); + } + if (StringUtils.isNotBlank(address.getRoomNumber())) { + dto.append("roomNumber", address.getRoomNumber()); + } + if (StringUtils.isNotBlank(address.getFormattedAddress())) { + dto.append("formattedAddress", address.getFormattedAddress()); + } + List certified = address.getCertified(); + if (certified.contains("roomNumber")) { + dto.append("authLevel", "A"); + } else if (certified.contains("buildingNumber")) { + dto.append("authLevel", "B"); + } else { + dto.append("authLevel", "C"); + } + baseModel.put("code", 200); + baseModel.put("msg", "ok"); + baseModel.put("result", dto); + return baseModel.toString(); + } + @Override public String auth(Map params) { params.put("token", TOKEN); try { - String result = this.invoke("address/realAuth", params, "UTF-8"); + String result = realAuth(params); return result; } catch (JSONException e) { LOGGER.error("", e); @@ -429,5 +748,141 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme return null; } - + + Map convertBuildingToMap(Building building) { + Map result = new LinkedHashMap(); + if (building != null) { + if (StringUtils.isNotBlank(building.getId())) { + result.put("id", building.getId()); + } + result.put("credit", building.getCredit()); + result.put("precise", building.getPrecise()); + result.put("province", building.getProvince()); + result.put("city", building.getCity()); + result.put("district", building.getDistrict()); + result.put("name", building.getName()); + if (StringUtils.isNotBlank(building.getSuggestName())) { + result.put("suggestName", building.getSuggestName()); + } + if (StringUtils.isNotBlank(building.getMap())) { + result.put("map", building.getMap()); + } + result.put("propertyType", building.getPropertyType()); + if (StringUtils.isNotBlank(building.getTownship())) { + result.put("township", building.getTownship()); + } + if (StringUtils.isNotBlank(building.getSuggestAddress())) { + result.put("suggestAddress", building.getSuggestAddress()); + } + if ("district".equals(building.getCategory())) { + result.put("category", "property"); + } else { + result.put("category", building.getCategory()); + } + if (StringUtils.isNotBlank(building.getAddress())) { + result.put("address", building.getAddress()); + } + if (StringUtils.isNotBlank(building.getBlock())) { + result.put("block", building.getBlock()); + } + if (building.getLng() != null && building.getLat() != null) { + result.put("lng", building.getLng()); + result.put("lat", building.getLat()); + } + if (building.getAlias() != null) { + result.put("alias", building.getAlias()); + } + if (building.getSearchAddress() != null) { + result.put("searchAddress", building.getSearchAddress()); + } + } + return result; + } + + private void submitFetchTask(Building building) { + if (building.getPrecise() == -1) { + List keywords = new ArrayList(); + Address address = building.getSearchAddress(); + if (StringUtils.isNotBlank(address.getKeywords()) && address.getKeywords().length() > 2) { + keywords.add(address.getKeywords()); + } else if (address.getOrgAddress().length() > 2 && address.getOrgAddress().length() < 10) {// Ò»°ãÐ¡ÇøÃû²»»á³¬¹ý10¸ö×Ö + keywords.add(address.getOrgAddress()); + } + if (address.isStandardAddress()) { + if (address.getStreetNumbers() != null) { + for (String b : address.getStreetNumbers()) { + keywords.add(address.getStreet() + b); + } + } else { + keywords.add(address.getStreet()); + } + } + keywords = DataUtil.uniqueList(keywords); + for (String k : keywords) { + WaitCrawlKeywords waitCrawlKeywords = new WaitCrawlKeywords(); + waitCrawlKeywords.setCity(address.getCity()); + waitCrawlKeywords.setDateCreated(new Date()); + waitCrawlKeywords.setRead(0); + waitCrawlKeywords.setKeywords(k); + waitCrawlKeywordsService.save(waitCrawlKeywords); + } + } + } + + private void verify(Building building) { + String city = building.getCity(); + String region = building.getDistrict(); + String name = null; + if (building.getPrecise() > -1) { + name = building.getName(); + } else { + name = building.getSearchAddress().getOrgKeywords(); + } + if (StringUtils.isNotBlank(region) && StringUtils.isNotBlank(name)) { + String buildingNumber = AddressParserUtil + .standardizeBuildingNumber(building.getSearchAddress().getOrgBuildingNumber()); + if (buildingNumber != null) { + if (houseLoudongService.findHouseLoudong(city, region, name, buildingNumber, null, null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } else if (fjtEvaluationService.findFjtEvaluationByConditions(city, region, name, buildingNumber, + null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } else if (evaluationService.findEvaluationByNum(city, region, name, buildingNumber, null) != null) { + building.getSearchAddress().setBuildingNumberCertified(true); + } + } + + String roomNumber = AddressParserUtil.standardizeRoomNumber(building.getSearchAddress().getOrgRoomNumber()); + if (roomNumber != null) { + if (houseLoudongService.findHouseLoudong(city, region, name, null, null, roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } else if (fjtEvaluationService.findFjtEvaluationByConditions(city, region, name, null, + roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } else if (evaluationService.findEvaluationByNum(city, region, name, null, roomNumber) != null) { + building.getSearchAddress().setRoomNumberCertified(true); + } + } + } + } + + public void setHouseLoudongService(HouseLoudongService houseLoudongService) { + this.houseLoudongService = houseLoudongService; + } + + public void setFjtEvaluationService(FjtEvaluationService fjtEvaluationService) { + this.fjtEvaluationService = fjtEvaluationService; + } + + public void setEvaluationService(EvaluationService evaluationService) { + this.evaluationService = evaluationService; + } + + public void setAddressParserService(AddressParserService addressParserService) { + this.addressParserService = addressParserService; + } + + public void setWaitCrawlKeywordsService(WaitCrawlKeywordsService waitCrawlKeywordsService) { + this.waitCrawlKeywordsService = waitCrawlKeywordsService; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java index 0b886ac78..d21cfa34c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java @@ -2,6 +2,8 @@ package com.fangjia.service.api; import com.fangjia.dal.mongo.model.PriceJiucuo; +import java.util.List; + public class AutoCompleteBo { private String val; private String desc; @@ -20,6 +22,10 @@ public class AutoCompleteBo { private Double lat; private Double lng; + private String alias; + + private String addrAlias; + /*** @Deprecated end ****/ public String getName() { @@ -133,4 +139,20 @@ public class AutoCompleteBo { public void setLng(Double lng) { this.lng = lng; } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getAddrAlias() { + return addrAlias; + } + + public void setAddrAlias(String addrAlias) { + this.addrAlias = addrAlias; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java new file mode 100644 index 000000000..efe2d3287 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopService.java @@ -0,0 +1,49 @@ +package com.fangjia.service.datastore; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; + +import java.util.List; + +public interface AiShopService { + + /** + * ×â½ð¾ù¼Û + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * ×â½ðµØÖ·Î¬¶ÈÆÀ¹À + * + * @param evaluation + * @return + */ + ShopEvaluationDto addressEvaluateRent(Evaluation evaluation); + + /** + * ³ÇÊÐд×ÖÂ¥³öÊÛ¾ù¼Û + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * ÊÛ¼ÛµØÖ·Î¬¶ÈÆÀ¹À + * + * @param evaluation + * @return + */ + ShopEvaluationDto addressEvaluateSell(Evaluation evaluation); +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java new file mode 100644 index 000000000..0998d0437 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/AiShopServiceImpl.java @@ -0,0 +1,529 @@ +package com.fangjia.service.datastore; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.CacheUtils; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SeawaterQuery; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.dao.shop.ShopRentStatDao; +import com.fangjia.dal.mongo.dao.shop.ShopSellStatDao; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.ShopRentStat; +import com.fangjia.dal.mongo.model.ShopSellStat; +import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; +import com.fangjia.service.datastore.dto.ShopEvaluationDto; +import com.fangjia.service.mongo.fangjia.SeawaterService; +import com.fangjia.service.util.GeoUtils; +import com.fangjia.service.util.dto.GaodeDto; +import org.apache.commons.collections.CollectionUtils; +import org.sothis.core.util.Closure; +import org.sothis.core.util.Pager; +import weiboclient4j.utils.StringUtils; + +import java.util.*; + +public class AiShopServiceImpl implements AiShopService { + + private ShopRentStatDao shopRentStatDao; + private SeawaterService seawaterService; + private ShopSellStatDao shopSellStatDao; + + + // ËùÔÚÂ¥²ã +// ×ÜÂ¥²ã + private static final Map FITMENT_MAP = new HashMap() { + { + put("1", "ëÅ÷"); + put("2", "¼ò×°"); + put("3", "¾«×°"); + put("4", "ºÀ×°"); + } + }; + + private static final Map DIRECTION_MAP = new HashMap() { + { + 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_FACTOR = new HashMap() { + { + put("ëÅ÷", 0.9983); + put("¼ò×°", 1.0); + put("¾«×°", 1.0153); + put("ºÀ×°", 1.0199); + } + }; + private static final Map DIRECTION_FACTOR = new HashMap() { + { + put("¶«", 1.0040); + put("¶«±±", 1.0048); + put("¶«ÄÏ", 1.0121); + put("¶«Î÷", 1.0003); + put("±±", 0.9999); + put("ÄÏ", 1.0000); + put("Äϱ±", 1.0080); + put("Î÷", 1.0060); + put("Î÷±±", 1.0099); + put("Î÷ÄÏ", 1.0103); + } + }; + + public ShopEvaluationDto calcRent(Evaluation evaluation) { + // µÚÒ»²½£º°´Ð´×Ö¥ͬ¥²ã¡¢×°ÐÞ¡¢³¯Ïòѡȡ3¸ö£¬¼ÆËãÆ½¾ùÖµ×÷Ϊ½á¹û + // µÚ¶þ²½£º»ù×¼¼Û*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + // µÚÈý²½£ºÖܱߣ¨Èý¹«ÀïÄÚ×î½üµÄ10¸öд×ÖÂ¥£©Í¬µÈ¼¶¡¢Í¬ÀàÐÍд×ÖÂ¥µÄ¾ùÖµ*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + String floorDesc = evaluation.getFloorDesc(); + List selectedSeawaters = new ArrayList(); + // µÚÒ»²½£º°´Ð´×Ö¥ͬ¥²ã¡¢×°ÐÞ¡¢³¯Ïòѡȡ3¸ö£¬¼ÆËãÆ½¾ùÖµ×÷Ϊ½á¹û + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setDistrictName(evaluation.getDistrictName()); + query.setFitment(FITMENT_MAP.get(evaluation.getFitment())); + query.setDirection(DIRECTION_MAP.get(evaluation.getDirection())); + query.setCat("shop_rent"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) { + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null && floorDesc != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "µÍ".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "ÖÐ".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "¸ß".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { + + } + } + } + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getShopEvaluationDto(selectedSeawaters, evaluation, "shop_rent"); + } + } + } + // ²éÕÒ»ù×¼¼Û + List params = new ArrayList(); + params.add(new QueryParam("cat", "shop")); + params.add(new QueryParam("city", evaluation.getCity())); + params.add(new QueryParam("district", evaluation.getRegion())); + params.add(new QueryParam("name", evaluation.getDistrictName())); + // »ñÈ¡ÉϸöÔÂyyyyMMÈÕÆÚ + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // °´ÈÕÆÚ½µÐòÅÅÐò£¬È¡×îеÄÊý¾Ý£¬¿ÉÄÜÉÏÔ»¹Î´¸üУ¬ÔòÈ¡ÉÏÉϸöÔµÄÊý¾Ý + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + // µÚ¶þ²½£º»ù×¼¼Û*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + ShopRentStat shopRentStat = shopRentStatDao.findFirstByParams(params); + Double avgPrice = shopRentStat.getAvgPrice(); + if (avgPrice != null) { + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + avgPrice = avgPrice * factor; + return getShopEvaluationDtoWithAvgPrice(avgPrice, evaluation, "shop_rent"); + } + + return null; + } + + /** + * ¸ù¾Ý¾ù¼Û²éѯÑù±¾ + * + * @param avgPrice + * @param evaluation + * @return + */ + private ShopEvaluationDto getShopEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) { + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + if ("shop_rent".equals(cat)) { + query.setStartPrice((int) (avgPrice * 30 * 0.9)); + query.setEndPrice((int) (avgPrice * 30 * 1.1)); + } else { + query.setStartPrice((int) (avgPrice * 0.9)); + query.setEndPrice((int) (avgPrice * 1.1)); + } + query.setCat(cat); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List seawaters = seawaterService.findSeawatersByQuery(query); + return getShopEvaluationDto(seawaters, evaluation, cat); + } + + private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) { + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getRegion()); + seawaterDto.setName(seawater.getName()); + seawaterDto.setArea(seawater.getArea()); + seawaterDto.setFitment(seawater.getFitment()); + if (cat != null && cat.contains("rent")) { + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + } else { + seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue()); + } + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDto.setBedKind(seawater.getLevel()); + seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); + seawaterDto.setFloorInfo(seawater.getFloorInfo()); + return seawaterDto; + } + + /** + * ´¿Ñù±¾²éѯ½á¹û¹ÀÖµ + * + * @param seawaters + * @param evaluation + * @return + */ + private static ShopEvaluationDto getShopEvaluationDto(List seawaters, Evaluation evaluation, String cat) { + Integer sum = 0; + Double size = 0.0; + + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + + List seawaterList = new ArrayList(); + if ("shop_rent".equals(cat)) { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaterList); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + } else { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() > 0) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size, 2); + shopEvaluationDto.setUnitPrice(unitPrice); + shopEvaluationDto.setSeawater(seawaterList); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + } + } + + return shopEvaluationDto; + } + + + @Override + public ShopEvaluationDto addressEvaluateRent(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // ÆÀ¹ÀÂß¼­ +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return rentEvaluateByLocation(evaluation); + } + + @Override + public List findShopSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindShopSellStat(city, region, name, cat, startDate, endDate); + } + }); + } + + private ShopEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + shopEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat("shop_rent"); + query.setRadius(1000); + // ²éѯ½üÒ»ÄêÑù±¾ + query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); + query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List shops = seawaterService.findSeawatersByQuery(query); + List seawaterDtoList = new ArrayList(); + if (CollectionUtils.isNotEmpty(shops)) { + // Çó¾ùÖµ + Double totalPrice = 0D; + int count = 0; + for (Seawater seawater : shops) { + if (seawater.getAvgPrice() != null) { + totalPrice += seawater.getDayUnitPrice(); + count += 1; + } + SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_rent"); + seawaterDtoList.add(seawaterDto); + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + shopEvaluationDto.setUnitPrice(avgPrice); + shopEvaluationDto.setSeawater(seawaterDtoList); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + return shopEvaluationDto; + } + } + return shopEvaluationDto; + } + + private ShopEvaluationDto sellEvaluateByLocation(Evaluation evaluation) { + ShopEvaluationDto shopEvaluationDto = new ShopEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + shopEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + SeawaterQuery query = new SeawaterQuery(); + query.setLat(lat); + query.setLng(lng); + query.setCat("shop_sell"); + query.setRadius(1000); + // ²éѯ½üÒ»ÄêÑù±¾ + query.setStartDate(Integer.parseInt(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"))); + query.setEndDate(Integer.parseInt(DateUtil.formatByPattern(new Date(), "yyyyMMdd"))); + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List shops = seawaterService.findSeawatersByQuery(query); + + List seawaterDtoList = new ArrayList(); + if (CollectionUtils.isNotEmpty(shops)) { + // Çó¾ùÖµ + Double totalPrice = 0D; + int count = 0; + for (Seawater seawater : shops) { + if (seawater.getAvgPrice() != null) { + totalPrice += seawater.getAvgPrice(); + count += 1; + } + SeawaterDto seawaterDto = getSeawaterDto(seawater, "shop_sell"); + seawaterDtoList.add(seawaterDto); + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + int avgPrice = (int) (totalPrice / count * factor); + shopEvaluationDto.setUnitPrice((double) avgPrice); + shopEvaluationDto.setSeawater(seawaterDtoList); + shopEvaluationDto.setCity(evaluation.getCity()); + shopEvaluationDto.setDistrict(evaluation.getRegion()); + shopEvaluationDto.setName(evaluation.getDistrictName()); + return shopEvaluationDto; + } + } + return shopEvaluationDto; + } + + private String getLocation(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + return gaodeDto.getLng() + "," + gaodeDto.getLat(); + } + return ""; + } + + private GaodeDto getGaodeGeo(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + return gaodeDto; + } + + public List findShopRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findShopRentStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindShopRentStat(city, region, name, cat, startDate, endDate); + } + }); + } + + public List doFindShopRentStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("¿ªÊ¼ÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (endDate == null) { + throw new IllegalArgumentException("½áÊøÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat²»ÄÜΪ¿Õ"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List regionStats = shopRentStatDao.findAllByParams(params, sortParams); + return regionStats; + } + + @Override + public ShopEvaluationDto addressEvaluateSell(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // ÆÀ¹ÀÂß¼­ +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return sellEvaluateByLocation(evaluation); + } + + public List doFindShopSellStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("¿ªÊ¼ÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (endDate == null) { + throw new IllegalArgumentException("½áÊøÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat²»ÄÜΪ¿Õ"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List sellStatList = shopSellStatDao.findAllByParams(params, sortParams); + return sellStatList; + } + + public void setSeawaterService(SeawaterService seawaterService) { + this.seawaterService = seawaterService; + } + + public void setShopRentStatDao(ShopRentStatDao shopRentStatDao) { + this.shopRentStatDao = shopRentStatDao; + } + + public void setShopSellStatDao(ShopSellStatDao shopSellStatDao) { + this.shopSellStatDao = shopSellStatDao; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java index f6177cfca..8cdd9018a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java @@ -1,9 +1,8 @@ package com.fangjia.service.datastore; import com.fangjia.core.util.*; -import com.fangjia.dal.QueryParam; -import com.fangjia.dal.SortParam; -import com.fangjia.dal.SrQuery; +import com.fangjia.dal.*; +import com.fangjia.dal.seawater.dao.SeawaterDao; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.datastore.dao.HouseDao; import com.fangjia.dal.datastore.model.House; @@ -14,6 +13,7 @@ import com.fangjia.dal.mongo.model.DistrictStat; import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap; import com.fangjia.dal.mongo.model.bkoff.DealPrice; import com.fangjia.dal.mongo.model.bkoff.Loudong; +import com.fangjia.dal.seawater.model.Seawater; import com.fangjia.dal.seaweed.model.District; import com.fangjia.service.address.mode.ProvinceData; import com.fangjia.service.bo.Collateral; @@ -24,12 +24,15 @@ import com.fangjia.service.datastore.bean.CollateralSampleQueryBean; import com.fangjia.service.datastore.bean.ShopCollateralSampleQueryBean; import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.open.FangjiaOfficialAreaService; +import com.fangjia.service.util.CommonUtil; +import com.fangjia.service.util.CommonUtils; import org.apache.commons.lang.StringUtils; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.TermQuery; import org.apache.solr.client.solrj.util.ClientUtils; +import org.sothis.core.util.Pager; import java.math.BigDecimal; import java.util.*; @@ -59,6 +62,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { private DistrictSellStatService districtSellStatService; private FangjiaOfficialAreaService fangjiaOfficialAreaService; private LoudongDao loudongDao; + private SeawaterDao seawaterDao; @Override @@ -227,7 +231,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List querySamples = new ArrayList(); District hasHouseDist = districtService.findDistrictHasHouseFlag(district);//²éѯÊÇ·ñÊÇÓз¿Ô´µÄÐ¡Çø - if(hasHouseDist != null){ + if (hasHouseDist != null) { List keys = new ArrayList(); String key = district.getName() + "_" + district.getRegion() + "_" + district.getCity(); // ÐÞ¸Ä @@ -269,7 +273,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List arroundKeys = new ArrayList(); for (District d : districts) { d = districtService.findById(d.getId()); - if(district.getName().equals(d.getName())){ + if (district.getName().equals(d.getName())) { continue; } @@ -531,8 +535,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { if (!map.containsKey(districtName)) { List sampleWrappers = new ArrayList(); sampleWrappers.add(sample); - map.put(districtName,sampleWrappers); - }else { + map.put(districtName, sampleWrappers); + } else { map.get(districtName).add(sample); } } @@ -540,9 +544,9 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { for (Map.Entry> entry : map.entrySet()) { //ÿ¸öÐ¡ÇøÈ¡5¸öÑù±¾ - if (entry.getValue().size()>=5){ - querySamples.addAll(entry.getValue().subList(0,5)); - }else { + if (entry.getValue().size() >= 5) { + querySamples.addAll(entry.getValue().subList(0, 5)); + } else { // ²»³¬¹ýÎå¸ö£¬È«²¿·ÅÈë querySamples.addAll(entry.getValue()); } @@ -659,7 +663,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { querySamples.addAll(samples); if (querySamples.size() < max + 10) { - // ²éѯ³É½»²¹³ä TODO + // ²éѯ³É½»²¹³ä TODO List dealPriceQuery = new ArrayList(); dealPriceQuery.add(new QueryParam("city", district.getCity())); dealPriceQuery.add(new QueryParam("region", district.getRegion())); @@ -1126,18 +1130,22 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { /** * ½­ÄÏÐвéÕÒÐ¡ÇøÑù±¾£¨ÓÅÏÈʹÓñ´¿ÇÁ´¼Ò£© * - * @param estateType Óû§²éѯÎïÒµÀàÐÍ + * @param estateType Óû§²éѯÎïÒµÀàÐÍ * @param startDate * @return */ - private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat,double area) { - + private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat, double area) { + //¸ÄΪ´ÓES ²é·¿Ô´ + ArrayList districtNames = new ArrayList(); BooleanQuery nameQuery = new BooleanQuery(); int c = 0; for (String namekey : keys) { if (StringUtils.isNotBlank(namekey)) { namekey = ClientUtils.escapeQueryChars(namekey); + if (namekey.contains("_")) { + districtNames.add(namekey.split("_")[0]); + } c++; nameQuery.add(new TermQuery(new Term("districtname_key", namekey)), BooleanClause.Occur.SHOULD); } @@ -1149,15 +1157,19 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List houseQuery = new ArrayList(); houseQuery.add(new QueryParam("city", district.getCity())); houseQuery.add(new QueryParam("region", district.getRegion())); + SeawaterQuery seawaterQuery = new SeawaterQuery(); if (districtStat != null && districtStat.getAvgPrice() > 0) { int avgPrice = districtStat.getAvgPrice(); - houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.5)));//0.85 - houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.5)));//1.15 + // ¼Û¸ñ·¶Î§µ÷ÕûΪÉÏϸ¡¶¯30% + seawaterQuery.setStartPrice((int) (avgPrice * 0.7)); + seawaterQuery.setEndPrice((int) (avgPrice * 1.3)); + houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.7))); + houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.3))); } houseQuery.add(new QueryParam("area", QueryParam.LESS_THAN_EQUAL_OPERATOR, area + 30)); houseQuery.add(new QueryParam("area", QueryParam.GREATER_THAN_EQUAL_OPERATOR, area - 30)); - if (nameQuery.clauses().isEmpty()){ + if (nameQuery.clauses().isEmpty()) { return samples; } BooleanQuery srQuery = new BooleanQuery(); @@ -1169,7 +1181,24 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { List houseSortParams = new ArrayList(); houseSortParams.add(new SortParam("publishDate", false)); - List houses = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS); + + seawaterQuery.setCityDisplay(district.getCity()); + seawaterQuery.setDistrictAlias(names); + seawaterQuery.setRegion(district.getRegion()); + seawaterQuery.setDistrictName(district.getName()); + seawaterQuery.setStartArea(area - 30); + seawaterQuery.setEndArea(area + 30); + seawaterQuery.setSortField("p_date"); + seawaterQuery.setOrder(false); + Pager pager = new Pager(0, 200); + pager.setPageSize(200); + seawaterQuery.setTable("latest_seawater"); + seawaterQuery.setPager(pager); + seawaterQuery.setCat("sell"); + List seawaters = seawaterDao.findSeawatersByQuery(seawaterQuery); + List houses = CommonUtils.transformListV(House.class, seawaters); + +// List houses1 = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS); int height = 0; int maxFloor = 0; boolean allSampleHasHeight = true; @@ -1730,4 +1759,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) { this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; } + + public void setSeawaterDao(SeawaterDao seawaterDao) { + this.seawaterDao = seawaterDao; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/DistrictServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/DistrictServiceImpl.java index 57420ac78..9628214e5 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/DistrictServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/DistrictServiceImpl.java @@ -2011,6 +2011,9 @@ public class DistrictServiceImpl implements DistrictService { if (!RegionData.isCity(city)) { city = RegionData.formatCity(city); } + if (city == null){ + return null; + } District districtInfo = findDistrict(new DistrictKey(city, region, name), target); // ÏȾ«È·²éѯ£¬²é²»µ½ÔÙ¸ù¾Ý±ðÃûÆ¥Åä if (districtInfo != null) { diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java index 070094dc1..0146770f1 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/EvaluationServiceImpl.java @@ -1,5 +1,6 @@ package com.fangjia.service.datastore; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -338,7 +339,10 @@ public class EvaluationServiceImpl implements EvaluationService { if(useAvgMode) { DistrictStatBo districtStatBo = districtStatService.findDistrictStat(districtKey); if (districtStatBo != null && districtStatBo.getDefaultDistrictStat() != null && districtStatBo.getDefaultDistrictStat().getAvgPrice() > 0) { - long totalPrice = evaluationRateService.evaluation(districtStatBo.getDefaultDistrictStat().getAvgPrice(), evaluation); + Double avgPrice = (double) (districtStatBo.getDefaultDistrictStat().getAvg_price_2b() != null ? districtStatBo.getDefaultDistrictStat().getAvg_price_2b() : districtStatBo.getDefaultDistrictStat().getAvgPrice()); + // ¾ù¼Û³ËÒÔϵÊý + avgPrice *= 1.04; + long totalPrice = evaluationRateService.evaluation(BigDecimal.valueOf(avgPrice).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(), evaluation); avgModeValue = ((Number) (totalPrice)).intValue(); avgModeCredit = districtStatBo.getDefaultDistrictStat().getCredit(); } @@ -1898,7 +1902,8 @@ public class EvaluationServiceImpl implements EvaluationService { private void buildWeekAvgPrice(EvaluationBeforeLoanBean dto, Evaluation evaluation) { DistrictStatBo bo = getNearestDistrictStat(new DistrictKey(evaluation.getCity(), evaluation.getRegion(), evaluation.getDistrictName())); if (bo != null) { - dto.setWeekAvgPrice(bo.getDistrictStat().getAvgPrice()); + Integer avgPrice = bo.getDistrictStat().getAvg_price_2b() != null ? bo.getDistrictStat().getAvg_price_2b() : bo.getDistrictStat().getAvgPrice(); + dto.setWeekAvgPrice(avgPrice); dto.setTopWeekUpDownRange(bo.getDistrictStat().getWeekendMarkup()); } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java index ac2e7863b..1b112e38c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseService.java @@ -7,6 +7,7 @@ import java.util.Map; import com.fangjia.dal.FacetQuery; import com.fangjia.dal.common.DistrictKey; +import com.fangjia.dal.datastore.model.RentHouse; import com.fangjia.datastore.driver.FacetResult; import com.fangjia.service.bo.HousePDSBo; import com.fangjia.service.bo.HouseScorer; @@ -470,5 +471,7 @@ public interface HouseService extends ModeService { HashMap findHouseStat(District districtKey, Integer avgPrice); - List findNearestHasHouseByLocation(String city, Double lat,Double lng,String cat, int radiusMeters, int limit); + List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit); + + } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java index c380ef49f..5eb20dfea 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/HouseServiceImpl.java @@ -8,6 +8,7 @@ import com.fangjia.dal.common.FangjiaServerAreaContextHolder; import com.fangjia.dal.common.ServerAreaData; import com.fangjia.dal.datastore.dao.HouseDao; import com.fangjia.dal.datastore.model.House; +import com.fangjia.dal.datastore.model.RentHouse; import com.fangjia.dal.mongo.dao.UserHouseDao; import com.fangjia.dal.mongo.fangjia.model.ServerArea; import com.fangjia.dal.mongo.model.UserHouse; @@ -2612,23 +2613,24 @@ public class HouseServiceImpl implements HouseService { CacheUtils.putValue(CacheUtils.CachePolicyEnum.MIDDLE, HouseServiceImpl.class, key, value); return value; } + @Override - public List findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) { + public List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit) { if (lat == null || lng == null || lat <= 0 ||lng <= 0) { return Collections.EMPTY_LIST; } List params = new ArrayList(); -// params.add(new QueryParam("cat", cat)); + params.add(new QueryParam("cat", cat)); if (StringUtils.isNotBlank(city)){ params.add(new QueryParam("city", city)); } SdQuery sdQuery = new SdQuery(); sdQuery.setPoint(lat + "," + lng); sdQuery.setField("lat_lng"); -// sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); - sdQuery.setDistance(String.valueOf(radiusMeters)); + sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); +// sdQuery.setDistance(String.valueOf(radiusMeters)); params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); -// List sortParams = Arrays.asList(new SortParam("distance", true)); + List sortParams = Arrays.asList(new SortParam("latLng", true)); List list = houseDao.findAllByParams(params, null, 0, limit); return list; } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java new file mode 100644 index 000000000..643e5b0b5 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeService.java @@ -0,0 +1,73 @@ +package com.fangjia.service.datastore; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.mongo.model.OfficeSellStat; +import com.fangjia.dal.seaweed.model.District; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/1/21 + */ +public interface OfficeService { + + + /** + * ×â½ð¾ù¼Û + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findOfficeRentStat(final String city, final String region,final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * ×â½ðÆÀ¹À + * + * @param district + * @param evaluation + * @return + */ + OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation); + + /** + * ×â½ðµØÖ·Î¬¶ÈÆÀ¹À + * + * @param evaluation + * @return + */ + OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation); + + /** + * ³ÇÊÐд×ÖÂ¥³öÊÛ¾ù¼Û + * + * @param city + * @param region + * @param startDate + * @param endDate + * @return + */ + List findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate); + + /** + * ÊÛ¼ÛÆÀ¹À + * + * @param district + * @param evaluation + * @return + */ + OfficeEvaluationDto evaluateSell(District district, Evaluation evaluation); + + /** + * ÊÛ¼ÛµØÖ·Î¬¶ÈÆÀ¹À + * + * @param evaluation + * @return + */ + OfficeEvaluationDto addressEvaluateSell(Evaluation evaluation); +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java new file mode 100644 index 000000000..5b46682f0 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/OfficeServiceImpl.java @@ -0,0 +1,819 @@ +package com.fangjia.service.datastore; + +import com.fangjia.core.RegionData; +import com.fangjia.core.util.CacheUtils; +import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SeawaterQuery; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.dao.office.OfficeRentStatDao; +import com.fangjia.dal.mongo.dao.office.OfficeSellStatDao; +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.mongo.model.OfficeRentStat; +import com.fangjia.dal.mongo.model.OfficeSellStat; +import com.fangjia.dal.seawater.model.Seawater; +import com.fangjia.dal.seawater.model.SeawaterDto; +import com.fangjia.dal.seaweed.model.District; +import com.fangjia.service.datastore.dto.OfficeEvaluationDto; +import com.fangjia.service.mongo.fangjia.SeawaterService; +import com.fangjia.service.util.GeoUtils; +import com.fangjia.service.util.dto.GaodeDto; +import com.mongodb.BasicDBObject; +import org.apache.commons.collections.CollectionUtils; +import org.sothis.core.util.Closure; +import org.sothis.core.util.Pager; +import weiboclient4j.utils.StringUtils; + +import java.util.*; + +/** + * д×ÖÂ¥Ïà¹Ø·þÎñÀà + * + * @author shenjian + * @since 2025/1/21 + */ +public class OfficeServiceImpl implements OfficeService { + + private OfficeRentStatDao officeRentStatDao; + private SeawaterService seawaterService; + private OfficeSellStatDao officeSellStatDao; + + @Override + public OfficeEvaluationDto evaluateRent(District district, Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + OfficeEvaluationDto officeEvaluationDto = this.calcRent(evaluation); + // Èç¹û´Ó»ù¼Û±íÖÐÕÒ²»µ½,// µÚÈý²½£ºÖܱߣ¨Èý¹«ÀïÄÚ×î½üµÄ10¸öд×ÖÂ¥£©Í¬µÈ¼¶¡¢Í¬ÀàÐÍд×ÖÂ¥µÄ¾ùÖµ*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + if (officeEvaluationDto == null || officeEvaluationDto.getUnitPrice() == null) { + if (StringUtils.isNotBlank(evaluation.getLocation())) { + officeEvaluationDto = rentEvaluateByLocation(evaluation); + } else if (district != null && district.getLat() != null) { + evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10)); + officeEvaluationDto = rentEvaluateByLocation(evaluation); + } + } + + return officeEvaluationDto; + } + + // ËùÔÚÂ¥²ã +// ×ÜÂ¥²ã + private static final Map FITMENT_MAP = new HashMap() { + { + put("1", "ëÅ÷"); + put("2", "¼ò×°"); + put("3", "¾«×°"); + put("4", "ºÀ×°"); + } + }; + + private static final Map DIRECTION_MAP = new HashMap() { + { + put("1", "Î÷ÄÏ"); + put("2", "¶«ÄÏ"); + put("3", "ÄÏ"); + put("4", "Î÷±±"); + put("5", "¶«±±"); + put("6", "¶«"); + put("7", "Î÷"); + put("8", "±±"); + put("9", "¶«Î÷"); + put("10", "Äϱ±"); + } + }; + private static final Map LEVEL_MAP = new HashMap() { + { + put(1, "¼×¼¶"); + put(2, "ÒÒ¼¶"); + put(3, "±û¼¶"); + } + }; + private static final Map TYPE_MAP = new HashMap() { + { + put(1, "±ê׼д×ÖÂ¥"); + put(2, "´´ÒâÔ°Çø"); + put(3, "ÉÌסÁ½ÓÃ"); + put(4, "×ÛºÏÌå"); + } + }; + // Ëæ»úÉ­ÁÖÄ£ÐÍϵÊý¼ÆËã + private static final Map FLOOR_FACTOR = new HashMap() { + { + put("Öвã", 1.0); + put("µÍ²ã", 0.9940); + put("¸ß²ã", 1.0185); + put("ÖÐ", 1.0); + put("µÍ", 0.9940); + put("¸ß", 1.0185); + } + }; + private static final Map FITMENT_FACTOR = new HashMap() { + { + put("ëÅ÷", 0.9983); + put("¼ò×°", 1.0); + put("¾«×°", 1.0153); + put("ºÀ×°", 1.0199); + } + }; + private static final Map DIRECTION_FACTOR = new HashMap() { + { + put("¶«", 1.0040); + put("¶«±±", 1.0048); + put("¶«ÄÏ", 1.0121); + put("¶«Î÷", 1.0003); + put("±±", 0.9999); + put("ÄÏ", 1.0000); + put("Äϱ±", 1.0080); + put("Î÷", 1.0060); + put("Î÷±±", 1.0099); + put("Î÷ÄÏ", 1.0103); + } + }; + + public OfficeEvaluationDto calcRent(Evaluation evaluation) { + // µÚÒ»²½£º°´Ð´×Ö¥ͬ¥²ã¡¢×°ÐÞ¡¢³¯Ïòѡȡ3¸ö£¬¼ÆËãÆ½¾ùÖµ×÷Ϊ½á¹û + // µÚ¶þ²½£º»ù×¼¼Û*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + // µÚÈý²½£ºÖܱߣ¨Èý¹«ÀïÄÚ×î½üµÄ10¸öд×ÖÂ¥£©Í¬µÈ¼¶¡¢Í¬ÀàÐÍд×ÖÂ¥µÄ¾ùÖµ*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + String floorDesc = evaluation.getFloorDesc(); + List selectedSeawaters = new ArrayList(); + // µÚÒ»²½£º°´Ð´×Ö¥ͬ¥²ã¡¢×°ÐÞ¡¢³¯Ïòѡȡ3¸ö£¬¼ÆËãÆ½¾ùÖµ×÷Ϊ½á¹û + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setDistrictName(evaluation.getDistrictName()); + query.setFitment(FITMENT_MAP.get(evaluation.getFitment())); + query.setDirection(DIRECTION_MAP.get(evaluation.getDirection())); + query.setCat("office_rent"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) { + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null && floorDesc != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "µÍ".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "ÖÐ".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "¸ß".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { + + } + } + } + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getOfficeEvaluationDto(selectedSeawaters, evaluation, "office_rent"); + } + } + } + // ²éÕÒ»ù×¼¼Û + List params = new ArrayList(); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("city", evaluation.getCity())); + params.add(new QueryParam("district", evaluation.getRegion())); + params.add(new QueryParam("name", evaluation.getDistrictName())); + // »ñÈ¡ÉϸöÔÂyyyyMMÈÕÆÚ + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // °´ÈÕÆÚ½µÐòÅÅÐò£¬È¡×îеÄÊý¾Ý£¬¿ÉÄÜÉÏÔ»¹Î´¸üУ¬ÔòÈ¡ÉÏÉϸöÔµÄÊý¾Ý + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + // µÚ¶þ²½£º»ù×¼¼Û*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + OfficeRentStat officeRentStat = officeRentStatDao.findFirstByParams(params); + Double avgPrice = officeRentStat.getAvgPrice(); + if (avgPrice != null) { + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (floorDesc != null) { + factor *= FLOOR_FACTOR.get(floorDesc); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + avgPrice = avgPrice * factor; + return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation, "office_rent"); + } + + return null; + } + + public OfficeEvaluationDto calcSell(Evaluation evaluation) { + // µÚÒ»²½£º°´Ð´×Ö¥ͬ¥²ã¡¢×°ÐÞ¡¢³¯Ïòѡȡ3¸ö£¬¼ÆËãÆ½¾ùÖµ×÷Ϊ½á¹û + // µÚ¶þ²½£º»ù×¼¼Û*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + // µÚÈý²½£ºÖܱߣ¨Èý¹«ÀïÄÚ×î½üµÄ10¸öд×ÖÂ¥£©Í¬µÈ¼¶¡¢Í¬ÀàÐÍд×ÖÂ¥µÄ¾ùÖµ*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + String floorDesc = evaluation.getFloorDesc(); + List selectedSeawaters = new ArrayList(); + // µÚÒ»²½£º°´Ð´×Ö¥ͬ¥²ã¡¢×°ÐÞ¡¢³¯Ïòѡȡ3¸ö£¬¼ÆËãÆ½¾ùÖµ×÷Ϊ½á¹û + List seawaters; + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + query.setDistrictName(evaluation.getDistrictName()); + query.setFitment(FITMENT_MAP.get(evaluation.getFitment())); + query.setDirection(DIRECTION_MAP.get(evaluation.getDirection())); + query.setCat("office_sell"); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(100); + query.setPager(pager); + query.setTable("latest_seawater"); + seawaters = seawaterService.findSeawatersByQuery(query); + if (StringUtils.isNotBlank(query.getFitment()) && StringUtils.isNotBlank(query.getDirection())) { + for (Seawater seawater : seawaters) { + boolean sameFloorDesc = false; + + if (seawater.getFloorInfo() != null && floorDesc != null) { + if (seawater.getFloorInfo().contains(floorDesc)) { + sameFloorDesc = true; + } else { + try { + Integer floor = Integer.parseInt(seawater.getFloorInfo()); + if (floor <= 6 && "µÍ".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 6 && floor <= 15 && "ÖÐ".equals(floorDesc)) { + sameFloorDesc = true; + } else if (floor > 15 && "¸ß".equals(floorDesc)) { + sameFloorDesc = true; + } + } catch (Exception ex) { + + } + } + } + if (sameFloorDesc) { + selectedSeawaters.add(seawater); + } + if (selectedSeawaters.size() == 3) { + return getOfficeEvaluationDto(selectedSeawaters, evaluation, "office_sell"); + } + } + } + // ²éÕÒ»ù×¼¼Û + List params = new ArrayList(); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("city", evaluation.getCity())); + params.add(new QueryParam("district", evaluation.getRegion())); + params.add(new QueryParam("name", evaluation.getDistrictName())); + // »ñÈ¡ÉϸöÔÂyyyyMMÈÕÆÚ + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // °´ÈÕÆÚ½µÐòÅÅÐò£¬È¡×îеÄÊý¾Ý£¬¿ÉÄÜÉÏÔ»¹Î´¸üУ¬ÔòÈ¡ÉÏÉϸöÔµÄÊý¾Ý + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + // µÚ¶þ²½£º»ù×¼¼Û*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + OfficeSellStat officeSellStat = officeSellStatDao.findFirstByParams(params); + Double avgPrice = Double.valueOf(officeSellStat.getAvgPrice()); + if (avgPrice != null) { + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (floorDesc != null) { + factor *= FLOOR_FACTOR.get(floorDesc); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + avgPrice = avgPrice * factor; + return getOfficeEvaluationDtoWithAvgPrice(avgPrice, evaluation, "office_sell"); + } + + return null; + } + + /** + * ¸ù¾Ý¾ù¼Û²éѯÑù±¾ + * + * @param avgPrice + * @param evaluation + * @return + */ + private OfficeEvaluationDto getOfficeEvaluationDtoWithAvgPrice(Double avgPrice, Evaluation evaluation, String cat) { + SeawaterQuery query = new SeawaterQuery(); + query.setRegion(evaluation.getRegion()); + if ("office_rent".equals(cat)) { + query.setStartPrice((int) (avgPrice * 30 * 0.9)); + query.setEndPrice((int) (avgPrice * 30 * 1.1)); + } else { + query.setStartPrice((int) (avgPrice * 0.9)); + query.setEndPrice((int) (avgPrice * 1.1)); + } + query.setCat(cat); + query.setRadius(3000); + + Integer endDate = Integer.valueOf(DateUtil.formatByPattern(new Date(), "yyyyMMdd")); + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd")); + query.setStartDate(startDate); + query.setEndDate(endDate); + + query.setCityDisplay(evaluation.getCity()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + List seawaters = seawaterService.findSeawatersByQuery(query); + return getOfficeEvaluationDto(seawaters, evaluation, cat); + } + + /** + * »ù×¼¼Û*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + * + * @param seawaters + * @param evaluation + * @return + */ + private static OfficeEvaluationDto getOfficeEvaluationDtoWithFactor(List seawaters, Evaluation evaluation) { + Double sum = 0.0; + Double size = 0.0; + + String fitment = FITMENT_MAP.get(evaluation.getFitment()); + String direction = DIRECTION_MAP.get(evaluation.getDirection()); + List seawaterDtoList = new ArrayList(); + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + Double price = Double.valueOf(seawater.getTotalPrice()); + // Â¥²ãϵÊýÐÞÕý + if (seawater.getFloorInfo() != null) { + try { + if (seawater.getFloorInfo().contains("µÍ")) { + price = price / FLOOR_FACTOR.get("µÍ") * FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } else if (seawater.getFloorInfo().contains("ÖÐ")) { + price = price / FLOOR_FACTOR.get("ÖÐ") * FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } else if (seawater.getFloorInfo().contains("¸ß")) { + price = price / FLOOR_FACTOR.get("¸ß") * FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } + } catch (Exception ex) { + + } + } + // ×°ÐÞ + if (seawater.getFitment() != null) { + try { + price = price / FITMENT_FACTOR.get(seawater.getFitment()) * FITMENT_FACTOR.get(fitment); + } catch (Exception ex) { + + } + } + // ³¯Ïò + if (seawater.getDirection() != null) { + try { + price = price / DIRECTION_FACTOR.get(seawater.getDirection()) * DIRECTION_FACTOR.get(direction); + } catch (Exception ex) { + + } + } + + sum += price; + size += seawater.getArea(); + } + SeawaterDto seawaterDto = getSeawaterDto(seawater, null); + seawaterDtoList.add(seawaterDto); + } + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaterDtoList); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + } + return officeEvaluationDto; + } + + /** + * ´¿Ñù±¾²éѯ½á¹û¹ÀÖµ + * + * @param seawaters + * @param evaluation + * @return + */ + private static OfficeEvaluationDto getOfficeEvaluationDto(List seawaters, Evaluation evaluation, String cat) { + Integer sum = 0; + Double size = 0.0; + + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + + List seawaterList = new ArrayList(); + if ("office_rent".equals(cat)) { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() / 30 > 0 && seawater.getTotalPrice() / seawater.getArea() / 30 < 30) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size / 30, 2); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaterList); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + } + } else { + for (Seawater seawater : seawaters) { + if (seawater.getTotalPrice() != null && seawater.getArea() != null && seawater.getTotalPrice() / seawater.getArea() > 0) { + sum += seawater.getTotalPrice(); + size += seawater.getArea(); + } + SeawaterDto seawaterDto = getSeawaterDto(seawater, cat); + seawaterList.add(seawaterDto); + } + if (size > 0) { + Double unitPrice = DataUtil.roundDouble(sum / size, 0); + officeEvaluationDto.setUnitPrice(unitPrice); + officeEvaluationDto.setSeawater(seawaterList); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + } + } + + return officeEvaluationDto; + } + + private static SeawaterDto getSeawaterDto(Seawater seawater, String cat) { + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(seawater.getCity()); + seawaterDto.setDistrict(seawater.getRegion()); + seawaterDto.setName(seawater.getDistrictName()); + seawaterDto.setArea(seawater.getArea()); + seawaterDto.setFitment(seawater.getFitment()); + if (cat != null && cat.contains("rent")) { + seawaterDto.setUnitPrice(seawater.getDayUnitPrice()); + } else { + seawaterDto.setUnitPrice(seawater.getAvgPrice().doubleValue()); + } + seawaterDto.setEstateType(seawater.getEstateType()); + seawaterDto.setBedKind(seawater.getLevel()); + seawaterDto.setPublishDate(String.valueOf(seawater.getpDate())); + seawaterDto.setFloorInfo(seawater.getFloorInfo()); + return seawaterDto; + } + + + @Override + public OfficeEvaluationDto addressEvaluateRent(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // ÆÀ¹ÀÂß¼­ +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return rentEvaluateByLocation(evaluation); + } + + private OfficeEvaluationDto rentEvaluateByLocation(Evaluation evaluation) { + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + officeEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + // ²éѯ¸½½ü5¸öд×ÖÂ¥»ù×¼¼Û + BasicDBObject geo = new BasicDBObject(); + BasicDBObject nearQuery = new BasicDBObject(); + nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); + nearQuery.append("$maxDistance", 3000); + geo.append("$near", nearQuery); + + List params = new ArrayList(5); + if (TYPE_MAP.get(evaluation.getType()) != null) { + params.add(new QueryParam("estateType2", TYPE_MAP.get(evaluation.getType()))); + } + if (LEVEL_MAP.get(evaluation.getLevel()) != null) { + params.add(new QueryParam("bedKind", LEVEL_MAP.get(evaluation.getLevel()))); + } + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // °´ÈÕÆÚ½µÐòÅÅÐò£¬È¡×îеÄÊý¾Ý£¬¿ÉÄÜÉÏÔ»¹Î´¸üУ¬ÔòÈ¡ÉÏÉϸöÔµÄÊý¾Ý + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + List infos = officeRentStatDao.findAllByParams(params, sortParams, 5); + List seawaterDtoList = new ArrayList(); + if (CollectionUtils.isEmpty(infos)) { + // È¥µôÀàÐÍ£¬ÖØÐ²éÕÒ + params = new ArrayList(5); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + params.add(new QueryParam("date", Integer.parseInt(date))); + infos = officeRentStatDao.findAllByParams(params, sortParams); + } + if (CollectionUtils.isNotEmpty(infos)) { + // Çó¾ùÖµ + Double totalPrice = 0D; + int count = 0; + for (OfficeRentStat officeRentStat : infos) { + if (officeRentStat.getAvgPrice() != null) { + totalPrice += officeRentStat.getAvgPrice(); + count += 1; + } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(officeRentStat.getCity()); + seawaterDto.setDistrict(officeRentStat.getDistrict()); + seawaterDto.setName(officeRentStat.getName()); + seawaterDto.setUnitPrice(officeRentStat.getAvgPrice()); + seawaterDto.setPublishDate(String.valueOf(officeRentStat.getDate())); + seawaterDto.setEstateType(officeRentStat.getEstateType2()); + seawaterDto.setBedKind(officeRentStat.getBedKind()); + seawaterDtoList.add(seawaterDto); + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getFloorDesc() != null) { + factor *= FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 2); + officeEvaluationDto.setUnitPrice(avgPrice); + officeEvaluationDto.setSeawater(seawaterDtoList); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + return officeEvaluationDto; + } + } + return officeEvaluationDto; + } + + private OfficeEvaluationDto sellEvaluateByLocation(Evaluation evaluation) { + OfficeEvaluationDto officeEvaluationDto = new OfficeEvaluationDto(); + if (StringUtils.isNotBlank(evaluation.getLocation())) { + officeEvaluationDto.setLocation(evaluation.getLocation()); + Double lng = Double.valueOf(evaluation.getLocation().split(",")[0]); + Double lat = Double.valueOf(evaluation.getLocation().split(",")[1]); + // ²éѯ¸½½ü5¸öд×ÖÂ¥»ù×¼¼Û + BasicDBObject geo = new BasicDBObject(); + BasicDBObject nearQuery = new BasicDBObject(); + nearQuery.append("$geometry", new BasicDBObject("type", "Point").append("coordinates", new double[]{lng, lat})); + nearQuery.append("$maxDistance", 3000); + geo.append("$near", nearQuery); + + List params = new ArrayList(5); + if (TYPE_MAP.get(evaluation.getType()) != null) { + params.add(new QueryParam("estateType2", TYPE_MAP.get(evaluation.getType()))); + } + if (LEVEL_MAP.get(evaluation.getLevel()) != null) { + params.add(new QueryParam("bedKind", LEVEL_MAP.get(evaluation.getLevel()))); + } + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + + String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM"); + params.add(new QueryParam("date", Integer.parseInt(date))); + + // °´ÈÕÆÚ½µÐòÅÅÐò£¬È¡×îеÄÊý¾Ý£¬¿ÉÄÜÉÏÔ»¹Î´¸üУ¬ÔòÈ¡ÉÏÉϸöÔµÄÊý¾Ý + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + + List infos = officeSellStatDao.findAllByParams(params, sortParams, 5); + if (CollectionUtils.isEmpty(infos)) { + // È¥µôÀàÐÍ£¬ÖØÐ²éÕÒ + params = new ArrayList(5); + params.add(new QueryParam("cat", "office")); + params.add(new QueryParam("location", geo)); + params.add(new QueryParam("date", Integer.parseInt(date))); + infos = officeSellStatDao.findAllByParams(params, sortParams); + } + List seawaterDtoList = new ArrayList(); + if (CollectionUtils.isNotEmpty(infos)) { + // Çó¾ùÖµ + Double totalPrice = 0D; + int count = 0; + for (OfficeSellStat officeSellStat : infos) { + if (officeSellStat.getAvgPrice() != null) { + totalPrice += officeSellStat.getAvgPrice(); + count += 1; + } + SeawaterDto seawaterDto = new SeawaterDto(); + seawaterDto.setCity(officeSellStat.getCity()); + seawaterDto.setDistrict(officeSellStat.getDistrict()); + seawaterDto.setName(officeSellStat.getName()); + seawaterDto.setUnitPrice(officeSellStat.getAvgPrice().doubleValue()); + seawaterDto.setPublishDate(String.valueOf(officeSellStat.getDate())); + seawaterDto.setEstateType(officeSellStat.getEstateType2()); + seawaterDto.setBedKind(officeSellStat.getBedKind()); + seawaterDtoList.add(seawaterDto); + } + Double factor = 1.0; + if (evaluation.getFitment() != null) { + factor *= FITMENT_FACTOR.get(FITMENT_MAP.get(evaluation.getFitment())); + } + if (evaluation.getFloorDesc() != null) { + factor *= FLOOR_FACTOR.get(evaluation.getFloorDesc()); + } + if (evaluation.getDirection() != null) { + factor *= DIRECTION_FACTOR.get(DIRECTION_MAP.get(evaluation.getDirection())); + } + Double avgPrice = DataUtil.roundDouble(totalPrice / count * factor, 0); + officeEvaluationDto.setUnitPrice(avgPrice); + officeEvaluationDto.setSeawater(seawaterDtoList); + officeEvaluationDto.setCity(evaluation.getCity()); + officeEvaluationDto.setDistrict(evaluation.getRegion()); + officeEvaluationDto.setName(evaluation.getDistrictName()); + return officeEvaluationDto; + } + } + return officeEvaluationDto; + } + + private String getLocation(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + return gaodeDto.getLng() + "," + gaodeDto.getLat(); + } + return ""; + } + + private GaodeDto getGaodeGeo(String city, String address) { + GaodeDto gaodeDto = GeoUtils.geo(city, address); + return gaodeDto; + } + + public List findOfficeRentStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findOfficeRentStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindRegionBlockStat(city, region, name, cat, startDate, endDate); + } + }); + } + + public List doFindRegionBlockStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("¿ªÊ¼ÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (endDate == null) { + throw new IllegalArgumentException("½áÊøÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat²»ÄÜΪ¿Õ"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List regionStats = officeRentStatDao.findAllByParams(params, sortParams); + return regionStats; + } + + @Override + public List findOfficeSellStat(final String city, final String region, final String name, final String cat, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), "findOfficeSellStat", city + region + name + startDate + endDate, + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return doFindOfficeSellStat(city, region, name, cat, startDate, endDate); + } + }); + } + + @Override + public OfficeEvaluationDto evaluateSell(District district, Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + OfficeEvaluationDto officeEvaluationDto = this.calcSell(evaluation); + // Èç¹û´Ó»ù¼Û±íÖÐÕÒ²»µ½,// µÚÈý²½£ºÖܱߣ¨Èý¹«ÀïÄÚ×î½üµÄ10¸öд×ÖÂ¥£©Í¬µÈ¼¶¡¢Í¬ÀàÐÍд×ÖÂ¥µÄ¾ùÖµ*Â¥²ãϵÊý*×°ÐÞϵÊý*³¯ÏòϵÊý + if (officeEvaluationDto == null || officeEvaluationDto.getUnitPrice() == null) { + if (StringUtils.isNotBlank(evaluation.getLocation())) { + officeEvaluationDto = sellEvaluateByLocation(evaluation); + } else if (district != null && district.getLat() != null) { + evaluation.setLocation(district.getLng() / Math.pow(10, 10) + "," + district.getLat() / Math.pow(10, 10)); + officeEvaluationDto = sellEvaluateByLocation(evaluation); + } + } + + return officeEvaluationDto; + } + + @Override + public OfficeEvaluationDto addressEvaluateSell(Evaluation evaluation) { + if (null == evaluation.getFloor() || 0 == evaluation.getFloor() || null == evaluation.getHeight() || 0 == evaluation.getHeight()) { + evaluation.setFloor(null); + evaluation.setHeight(null); + } + // ÆÀ¹ÀÂß¼­ +// String location = getLocation(evaluation.getCity(), evaluation.getAddress()); + GaodeDto gaodeDto = getGaodeGeo(evaluation.getCity(), evaluation.getAddress()); + if (gaodeDto.getLng() != null && gaodeDto.getLat() != null) { + evaluation.setLocation(gaodeDto.getLng() + "," + gaodeDto.getLat()); + } else { + evaluation.setLocation(""); + } + evaluation.setRegion(RegionData.formatRegion(evaluation.getCity(), gaodeDto.getDistrict())); + return sellEvaluateByLocation(evaluation); + } + + public List doFindOfficeSellStat(final String city, final String region, final String name, final String cat, Integer startDate, Integer endDate) { + if (startDate == null) { + throw new IllegalArgumentException("¿ªÊ¼ÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (endDate == null) { + throw new IllegalArgumentException("½áÊøÈÕÆÚ²»ÄÜΪ¿Õ"); + } + if (StringUtils.isBlank(cat)) { + throw new IllegalArgumentException("cat²»ÄÜΪ¿Õ"); + } + + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("district", region)); + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + params.add(new QueryParam("cat", cat)); + + if (startDate != null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + if (endDate != null) { + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", true)); + List sellStatList = officeSellStatDao.findAllByParams(params, sortParams); + return sellStatList; + } + + public void setSeawaterService(SeawaterService seawaterService) { + this.seawaterService = seawaterService; + } + + public void setOfficeRentStatDao(OfficeRentStatDao officeRentStatDao) { + this.officeRentStatDao = officeRentStatDao; + } + + public void setOfficeSellStatDao(OfficeSellStatDao officeSellStatDao) { + this.officeSellStatDao = officeSellStatDao; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java index e12108154..1bdd09d3c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseService.java @@ -3,6 +3,7 @@ package com.fangjia.service.datastore; import java.util.List; import java.util.Map; +import com.fangjia.dal.datastore.model.House; import org.sothis.core.util.Pager; import com.fangjia.dal.FacetQueryResult; @@ -208,4 +209,6 @@ public interface RentHouseService extends ModeService { boolean refreshHouse(String houseId, int userId); // Óû§ÖÐÐÄ·¢²¼·¿Ô´½Ó¿Ú END + + List findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java index 647f14f8d..7cfdba6f9 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RentHouseServiceImpl.java @@ -1,14 +1,10 @@ package com.fangjia.service.datastore; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import com.fangjia.dal.*; +import com.fangjia.dal.datastore.dao.HouseDao; +import com.fangjia.dal.datastore.model.House; import org.apache.commons.lang.StringUtils; import org.apache.lucene.search.Query; import org.sothis.core.util.CollectionUtils; @@ -16,11 +12,6 @@ import org.sothis.core.util.Pager; import com.fangjia.core.util.DateUtil; import com.fangjia.core.util.RandomUtil; -import com.fangjia.dal.FacetQuery; -import com.fangjia.dal.FacetQueryResult; -import com.fangjia.dal.QueryParam; -import com.fangjia.dal.SortParam; -import com.fangjia.dal.SrQuery; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.common.FangjiaServerAreaContextHolder; import com.fangjia.dal.common.ServerAreaData; @@ -70,6 +61,8 @@ public class RentHouseServiceImpl implements RentHouseService { private UserHouseDao userHouseDao; private MetroDistanceService metroDistanceService; + private HouseDao houseDao; + public FacetQueryResult randomGainHouse(RentHouseQueryBean queryBean, int count) { long totalCount = this.findHouseCount(queryBean); int endCount = count * 100; @@ -831,6 +824,27 @@ public class RentHouseServiceImpl implements RentHouseService { return true; } + @Override + public List findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) { + if (lat == null || lng == null || lat <= 0 ||lng <= 0) { + return Collections.EMPTY_LIST; + } + List params = new ArrayList(); + params.add(new QueryParam("cat", cat)); + if (StringUtils.isNotBlank(city)){ + params.add(new QueryParam("city", city)); + } + SdQuery sdQuery = new SdQuery(); + sdQuery.setPoint(lat + "," + lng); + sdQuery.setField("lat_lng"); + sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0)); +// sdQuery.setDistance(String.valueOf(radiusMeters)); + params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); + List sortParams = Arrays.asList(new SortParam("latLng", true)); + List list = rentHouseDao.findAllByParams(params, null, 0, limit); + return list; + } + public boolean refreshHouse(String houseId, int userId,String source) { List params = new ArrayList(2); params.add(new QueryParam("userId", userId)); @@ -899,4 +913,7 @@ public class RentHouseServiceImpl implements RentHouseService { this.metroDistanceService = metroDistanceService; } + public void setHouseDao(HouseDao houseDao) { + this.houseDao = houseDao; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java index e66e53e25..7665fd814 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/ShopService.java @@ -1,11 +1,11 @@ package com.fangjia.service.datastore; -import java.util.List; - import com.fangjia.dal.QueryParam; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.seaweed.model.Shop; +import java.util.List; + public interface ShopService { List findByKeyword(String city, String keyword); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java new file mode 100644 index 000000000..0752ee8e3 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeEvaluationDto.java @@ -0,0 +1,53 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.seawater.model.SeawaterDto; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class OfficeEvaluationDto extends Evaluation { + + private Double unitPrice; + + private List seawater; + + private String district; + + private String name; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java new file mode 100644 index 000000000..262858055 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/OfficeRentDto.java @@ -0,0 +1,32 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class OfficeRentDto { + + private Double unitPrice; + + private List seawater; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java new file mode 100644 index 000000000..14f9def80 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopEvaluationDto.java @@ -0,0 +1,54 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.mongo.model.Evaluation; +import com.fangjia.dal.seawater.model.SeawaterDto; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class ShopEvaluationDto extends Evaluation { + + private Double unitPrice; + + private List seawater; + + private String district; + + private String name; + + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java new file mode 100644 index 000000000..02e2379f4 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/dto/ShopRentDto.java @@ -0,0 +1,32 @@ +package com.fangjia.service.datastore.dto; + +import com.fangjia.dal.seawater.model.Seawater; + +import java.util.List; + +/** + * @author shenjian + * @since 2025/2/19 + */ +public class ShopRentDto { + + private Double unitPrice; + + private List seawater; + + public Double getUnitPrice() { + return unitPrice; + } + + public void setUnitPrice(Double unitPrice) { + this.unitPrice = unitPrice; + } + + public List getSeawater() { + return seawater; + } + + public void setSeawater(List seawater) { + this.seawater = seawater; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java index a308e1a67..623a779b0 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java @@ -295,6 +295,17 @@ public interface DistrictStatService { * @return */ public int findLatestDistrictAvgPrice(DistrictKey districtKey,Date weekend); + + /** + * »ñµÃÖ¸¶¨Ê±¼äµÄÐ¡Çø¾ù¼Û2B + * + * @param districtKey + * @param weekend + * @return + */ + int findLatestDistrictAvgPrice2B(DistrictKey districtKey,Date weekend); + + /** diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index 242aac83e..6065c2063 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java @@ -1524,6 +1524,52 @@ public class DistrictStatServiceImpl implements DistrictStatService { return value; } + @Override + public int findLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend) { + if (weekend == null) { + weekend = DateUtil.getFirstDayOfWeek(new Date()); + } + String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_2B_" + DateUtil.formatToYYMMDD(weekend); + Object obj = CacheUtils.getValue(this.getClass(), cacheKey); + if (obj != null) { + return (Integer)obj; + } + Integer value = doFindLatestDistrictAvgPrice2B(districtKey, weekend); + CacheUtils.putValue(CachePolicyEnum.LONG, this.getClass(), cacheKey, value); + return value; + } + + public Integer doFindLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend){ + + DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); + if (statBo != null && statBo.getDefaultDistrictStat() != null) { + if (statBo.getDefaultDistrictStat().getAvg_price_2b() != null && statBo.getDefaultDistrictStat().getAvg_price_2b() > 0) { + return statBo.getDefaultDistrictStat().getAvg_price_2b(); + } + if (statBo.getDefaultDistrictStat().getAvgPrice() > 0) { + return statBo.getDefaultDistrictStat().getAvgPrice(); + } + } + + double r = AveragerUtil.getFloatingRate(districtKey, weekend); + if (StringUtils.isNotBlank(districtKey.getCity()) && StringUtils.isNotBlank(districtKey.getRegion())) { + RegionStat regionStat = regionStatService.findRegionStat(districtKey.getCity(), districtKey.getRegion(), null); + if (regionStat != null) { + return (int) (regionStat.getAvgPrice() * r); + } + } + + if (StringUtils.isNotBlank(districtKey.getCity())) { + RegionStat regionStat = regionStatService.findRegionStat(districtKey.getCity(), null, null); + if (regionStat != null) { + return (int) (regionStat.getAvgPrice() * r); + } + } + + return 0; + + } + public Integer doFindLatestDistrictAvgPrice(DistrictKey districtKey, Date weekend){ DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java new file mode 100644 index 000000000..01fbb1490 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/dto/UniversalDto.java @@ -0,0 +1,23 @@ +package com.fangjia.service.dto; + +import java.util.LinkedHashMap; + +/** + * ͨÓÃDto,¼õÉÙDtoµÄ´´½¨ + * @author ÍõÎÄÑÞ + * @create 2016-10-08 + **/ +public class UniversalDto extends LinkedHashMap { + + + public static UniversalDto newDto(){ + return new UniversalDto(); + } + + public UniversalDto append(String key, Object value){ + this.put(key, value); + return this; + } + + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java new file mode 100644 index 000000000..ae7dd522d --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java @@ -0,0 +1,19 @@ +package com.fangjia.service.mongo.fangjia; + +import com.fangjia.dal.mongo.model.DevelopmentZone; +import com.fangjia.dal.mongo.model.SeaweedImages; +import org.sothis.core.util.Pager; + +import java.util.List; +import java.util.Map; + +/** + * Created by dxy on 2015/6/8. + */ +public interface SeaweedImagesService { + public SeaweedImages findById(String id); + + public void deleteImage(String id, String url,String picType,String roomType); + public void addImage(String id, List urls,String picType,String roomType); + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java new file mode 100644 index 000000000..e738c4d3b --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java @@ -0,0 +1,70 @@ +package com.fangjia.service.mongo.fangjia; + +import com.fangjia.dal.mongo.dao.SeaweedImagesDao; +import com.fangjia.dal.mongo.model.SeaweedImages; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SeaweedImagesServiceImpl implements SeaweedImagesService { + private SeaweedImagesDao seaweedImagesDao; + + @Override + public SeaweedImages findById(String id) { + return seaweedImagesDao.findById(id); + } + + @Override + public void deleteImage(String id, String url, String picType, String roomType) { + SeaweedImages seaweedImages = seaweedImagesDao.findById(id); + if ("floorplanPics".equals(picType)) { + Map> floorplanPics = seaweedImages.getFloorplanPics(); + List roomPicList = floorplanPics.get(roomType); + if (roomPicList!=null && !roomPicList.isEmpty()){ + roomPicList.remove(url); + floorplanPics.put(roomType,roomPicList); + seaweedImages.setFloorplanPics(floorplanPics); + } + } else if ("outPics".equals(picType)) { + List outPics = seaweedImages.getOutPics(); + if (outPics != null && !outPics.isEmpty()) { + outPics.remove(url); + seaweedImages.setOutPics(outPics); + } + } + seaweedImagesDao.update(seaweedImages); + } + + @Override + public void addImage(String id, List urls, String picType, String roomType) { + SeaweedImages seaweedImages = seaweedImagesDao.findById(id); + if ("floorplanPics".equals(picType)) { + Map> floorplanPics = seaweedImages.getFloorplanPics(); + if (floorplanPics==null){ + floorplanPics = new HashMap>(); + } + List roomPicList = floorplanPics.get(roomType); + if (roomPicList!=null && !roomPicList.isEmpty()){ + roomPicList.addAll(urls); + floorplanPics.put(roomType,roomPicList); + }else { + floorplanPics.put(roomType,urls); + } + seaweedImages.setFloorplanPics(floorplanPics); + } else if ("outPics".equals(picType)) { + List outPics = seaweedImages.getOutPics(); + if (outPics != null && !outPics.isEmpty()) { + outPics.addAll(urls); + seaweedImages.setOutPics(outPics); + }else { + seaweedImages.setOutPics(urls); + } + } + seaweedImagesDao.update(seaweedImages); + } + + public void setSeaweedImagesDao(SeaweedImagesDao seaweedImagesDao) { + this.seaweedImagesDao = seaweedImagesDao; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java new file mode 100644 index 000000000..3c26ea411 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingService.java @@ -0,0 +1,23 @@ +package com.fangjia.service.open; + +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.mongo.dao.AdministrativeMappingDao; +import com.fangjia.dal.mongo.model.AdministrativeMapping; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public interface AdministrativeMappingService { + + + public String findCityCodeByCityShort(String cityShort); + + public String findCityByCityShort(String cityShort); + + public String findCityShortByCityCode(String cityCode); + + public String findDistrictShortByDistrictCode(String cityCode,String districtCode); + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java new file mode 100644 index 000000000..7b7cbbeed --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/AdministrativeMappingServiceImpl.java @@ -0,0 +1,133 @@ +package com.fangjia.service.open; + +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.mongo.dao.AdministrativeMappingDao; +import com.fangjia.dal.mongo.model.AdministrativeMapping; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class AdministrativeMappingServiceImpl implements AdministrativeMappingService { + private AdministrativeMappingDao administrativeMappingDao; + private List CITY_SHORT = new ArrayList(Arrays.asList( + "Îå¼ÒÇþ", "Í¼Ä¾Êæ¿Ë", "ʯºÓ×Ó", "ͳ·¬", "ÖÐÎÀ", "ʯ×ìɽ", "º£±±ÖÝ", + "ÕÅÒ´", "ÌìË®", "Í­´¨", "ɽÄÏ", "²ý¶¼", "À­Èø", "ÏÌÑô", "µÏÇìÖÝ", + "³þÐÛ", "°×Òø", "ÓÜÁÖ", "ÆÕ¶ý", "Àö½­", "À¥Ã÷", "ÓñÊ÷ÖÝ", "¸Ê×ÎÖÝ", + "°¢°ÓÖÝ", "Òø´¨", "ÑŰ²", "ÎÄɽÖÝ", "Î÷Ë«°æÄÉÖÝ", "ÇíÖÐ", "±£Í¤", "ÀÖ¶«", + "²ý½­", "°×ɳ", "ÁÙ¸ß", "¤ÄÏ", "¶¨°²", "ÍòÄþ", "±¦¼¦", "ÈýÑÇ", "À´±ö", + "ºØÖÝ", "Å­½­ÖÝ", "ºÓ³Ø", "¹ó¸Û", "·À³Ç¸Û", "ÎàÖÝ", "ÁøÖÝ", "ÖÐɽ", "ÇåÔ¶", + "¶¨Î÷", "ÁÙ²×", "µÂºêÖÝ", "Çíº£", "³ç×ó", "º×¸Ú", "°²Ñô", "ËÞǨ", + "Ì©ÖÝ", "ÑγÇ", "ÆëÆë¹þ¶û", "»´°²", "³ÎÂõ", "Óª¿Ú", "ËÞÖÝ", "¸ÊÄÏ", "Ì©°²", + "ÎÞÎý", "¶õÖÝ", "ÎâÖÒ", "ÓñÁÖ", "¶õ¶û¶à˹", "ºþÖÝ", "ÁÉÔ´", "ºªµ¦", "Áù°²", + "º£¿Ú", "˫Ѽɽ", "¸§Ë³", "°×³Ç", "¹óÑô", "Ô˳Ç", "ÐìÖÝ", "°ö²º", + "°×ɽ", "ÑÓ°²", "ͨ»¯", "ĵµ¤½­", "ÁÙ·Ú", "ÔÆ¸¡", "³¯Ñô", "±£É½", + "ÌúÁë", "»´ÄÏ", "½ð»ª", "³¤ÖÎ", "¿Ë×ÎÀÕËÕ", "ËÄÆ½", "̫ԭ", "÷ÖÝ", + "±±¾©", "¸·ÐÂ", "½úÖÐ", "°¢À­ÉÆÃË", "½ú³Ç", "ʯ¼Òׯ", "Îåָɽ", "¼¦Î÷", + "¸§ÖÝ", "¹ûÂåÖÝ", "פÂíµê", "Îߺþ", "ºôºÍºÆÌØ", "ÐĮ̈", "ºÚºÓ", "Æß̨ºÓ", + "³ÐµÂ", "ÁúÑÒ", "Õò½­", "ËÕÖÝ", "ºâË®", "°²¿µ", "ÄÏÄþ", "°üÍ·", + "³à·å", "¼ÃÔ´", "ÉÜÐË", "ÕżҿÚ", "´óͬ", "ÑôȪ", "ÂÀÁº", "ÎÚº£", + "ºÓÔ´", "ͨÁÉ", "³üÖÝ", "¶«Ý¸", "º¼ÖÝ", "°ÍÑåÄ×¶û", "³£ÖÝ", "ÎÚÀ¼²ì²¼", + "ÐÂÓà", "ÑÓ±ß", "¾Å½­", "ÁÙÏÄ", "ÏæÎ÷", "±£¶¨", "ÁÖÖ¥", "²×ÖÝ", + "¸·Ñô", "ÁÙÒÊ", "ÎÚ³ľÆë", "ÎýÁÖ¹ùÀÕÃË", "±¾Ïª", "µÂÖÝ", "ÑïÖÝ", + "°°É½", "ËÉÔ­", "ÀöË®", "áéÖÝ", "ºÏ·Ê", "ÍͲý", "»ÆÉ½", "ÎäÍþ", + "ÙñÖÝ", "Ðû³Ç", "ÈýÃ÷", "Ë绯", "ÏæÌ¶", "ºâÑô", "ÄÏÆ½", "ÉòÑô", + "ÁÉÑô", "Äϲý", "¾°µÂÕò", "ӥ̶", "¸ÓÖÝ", "Ð˰²ÃË", "¼ª°²", + "ÇìÑô", "ÒË´º", "ÉÏÈÄ", "Ϋ·»", "¼ÃÄÏ", "×Ͳ©", "¹þ¶û±õ", + "Ôæ×¯", "ÐÃÖÝ", "¼ÃÄþ", "ÈÕÕÕ", "ÉØ¹Ø", "¿ª·â", "ÉÌÇð", "´óÀí", + "ºÊÔó", "Î÷Äþ", "Ö£ÖÝ", "ÉñÅ©¼Ü", "ƽ¶¥É½", "Ë·ÖÝ", "º×±Ú", + "ÐÂÏç", "¶«·½", "½¹×÷", "ÒÁ´º", "ƼÏç", "³£µÂ", "ÖÜ¿Ú", + "μÄÏ", "Õżҽç", "°¢Àï", "¹ðÁÖ", "´óÇì", "³¤É³", "ÒæÑô", + "ÖêÖÞ", "ÉÛÑô", "³»ÖÝ", "ÓÀÖÝ", "¦µ×", "ºúÑîºÓ", "À¥Óñ", + "¼ÎÓø¹Ø", "±±ÍÍ", "Ëþ³Ç", "°ÍÒô¹ùÀã", "²©¶ûËþÀ­", "²ý¼ª", + "°¢À­¶û", "¿ËÀ­ÂêÒÀ", "º£Î÷ÖÝ", "»ÆÄÏÖÝ", "¾ÆÈª", "ƽÁ¹", + "ººÖÐ", "ÕÑͨ", "Ç­Î÷ÄÏ", "Í­ÈÊ", "×ñÒå", "×ÊÑô", "°ÍÖÐ", + "¹ã°²", "Ò˱ö", "üɽ", "Äϳä", "±Ï½Ú", "ÀÖɽ", "´ïÖÝ", + "ËìÄþ", "¹ãÔª", "ÃàÑô", "µÂÑô", "ÒÁÀç", "³É¶¼", "°²Ë³", + "ÖØÇì", "ÁêË®", "ºìºÓ", "¿É¿Ë´ïÀ­", "ÎIJý", "ÙÙÖÝ", "°ÙÉ«", + "±±º£", "½ÒÑô", "³±ÖÝ", "Ñô½­", "ÉÇβ", "Ë«ºÓ", "ÕØÇì", + "Õ¿½­", "ÉÇÍ·", "ÉîÛÚ", "ÄÚ½­", "¹ãÖÝ", "̨ÖÝ", "¼ÎÐË", + "ïÃû", "Äþ²¨", "Èýɳ", "ÄÏͨ", "ºÍÌï", "ÖÛɽ", "Á¬ÔƸÛ", + "¿¦Ê²", "ÄϾ©", "½õÖÝ", "³¤´º", "¹ÌÔ­", "ÎÂÖÝ", "ÉϺ£", + "·ðɽ", "ÇÕÖÝ", "ÁùÅÌË®", "DZ½­", "ºù«µº", "ÔÀÑô", "Çú¾¸", + "¼Ñľ˹", "´óÐ˰²Áë", "å§Ñô", "ÐÅÑô", "ÑĮ̀", "°²Çì", + "ÇØ»Êµº", "Ìì½ò", "ÀÈ·»", "Ç­ÄÏ", "ÄÇÇú", "º£ÄÏÖÝ", + "ÈÕ¿¦Ôò", "Î人", "»³»¯", "ÈýÃÅÏ¿", "º£¶«", "À¼ÖÝ", + "ÁijÇ", "Á¹É½ÖÝ", "ãòÖÝ", "ÄÏÑô", "Ç­¶«ÄÏ", "¼ªÁÖ", + "°¢¿ËËÕ", "±õÖÝ", "ÌÆÉ½", "Í­Áê", "½ð²ý", "µ¤¶«", + "ÓñϪ", "°×Ñî", "ºôÂ×±´¶û", "ÌúÃŹØ", "ÏÉÌÒ", "ËæÖÝ", + "»´±±", "ÉÌÂå", "½­ÃÅ", "³ØÖÝ", "Å̽õ", "ÏÃÃÅ", + "Î÷°²", "×Ô¹±", "ÆÎÌï", "ȪÖÝ", "ÕÄÖÝ", "¸£ÖÝ", + "Âí°°É½", "ÄþµÂ", "´óÁ¬", "Т¸Ð", "Ê®Ñß", "Çൺ", + "ÅÊÖ¦»¨", "¶«Óª", "Íþº£", "ÐÂÐÇ", "ÂåÑô", "»ÆÊ¯", + "°¢ÀÕÌ©", "Ðí²ý", "äðºÓ", "Ò˲ý", "¹þÃÜ", "ÏåÑô", + "¾£ÃÅ", "¾£ÖÝ", "»Æ¸Ô", "¶÷Ê©", "ÌìÃÅ", "ÏÌÄþ", + "»ÝÖÝ", "Ö麣" + )); + + + public String findCityCodeByCityShort(String cityShort) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("cityShort", cityShort)); + params.add(new QueryParam("type", "³ÇÊÐ")); + AdministrativeMapping firstByParams = administrativeMappingDao.findFirstByParams(params); + if (firstByParams != null && StringUtils.isNotBlank(firstByParams.getMzbCityCode())) { + return firstByParams.getMzbCityCode(); + } + return null; + } + + public String findCityByCityShort(String cityShort) { + if (CITY_SHORT.contains(cityShort)) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("cityShort", cityShort)); + params.add(new QueryParam("type", "³ÇÊÐ")); + AdministrativeMapping firstByParams = administrativeMappingDao.findFirstByParams(params); + if (firstByParams != null && StringUtils.isNotBlank(firstByParams.getMzbCityCode())) { + return firstByParams.getCity(); + } + } + return cityShort; + } + + @Override + public String findCityShortByCityCode(String cityCode) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("mzbCityCode", cityCode)); + params.add(new QueryParam("type", "³ÇÊÐ")); + List allByParams = administrativeMappingDao.findAllByParams(params); + + if (allByParams != null && !allByParams.isEmpty()) { + if (allByParams.size() == 1) { + AdministrativeMapping firstByParams = allByParams.get(0); + return StringUtils.isBlank(firstByParams.getCityShort()) ? "" : firstByParams.getCityShort(); + } + return ""; + } + return ""; + } + + @Override + public String findDistrictShortByDistrictCode(String cityCode, String districtCode) { + ArrayList params = new ArrayList(); + params.add(new QueryParam("mzbCityCode", cityCode)); + params.add(new QueryParam("mzbDistrictCode", districtCode)); + params.add(new QueryParam("type", "ÇøÓò")); + List allByParams = administrativeMappingDao.findAllByParams(params); + + if (allByParams != null && !allByParams.isEmpty()) { + if (allByParams.size() == 1) { + AdministrativeMapping firstByParams = allByParams.get(0); + return StringUtils.isBlank(firstByParams.getCityShort()) ? "" : firstByParams.getCityShort(); + } + return ""; + } + return ""; + } + + + public void setAdministrativeMappingDao(AdministrativeMappingDao administrativeMappingDao) { + this.administrativeMappingDao = administrativeMappingDao; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java new file mode 100644 index 000000000..d19f8eda2 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/CommonUtils.java @@ -0,0 +1,41 @@ +package com.fangjia.service.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +/** + * ͨÓÃʵÌåÓëDTO»¥Ïàת»»¹¤¾ßÀà + * + * @author shenjian + * @date 2021/06/16 + */ +public class CommonUtils { + public static T transformV(Class targetClass, Object source) { + if (source == null) { + return null; + } else { + try { + String jsonSource = JSON.toJSONString(source); + return JSONObject.parseObject(jsonSource, targetClass); + } catch (Exception var3) { + return null; + } + } + } + + public static List transformListV(Class targetClass, List listSource) { + if (listSource == null) { + return null; + } else { + try { + String jsonSource = JSON.toJSONString(listSource); + return JSONArray.parseArray(jsonSource, targetClass); + } catch (Exception var3) { + return null; + } + } + } +} \ No newline at end of file diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java index 0bc28d9f5..2bc49ea24 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java @@ -52,6 +52,9 @@ public class EvaluateParamMap { BUILD_TYPE_MAP.put("6", "ÁªÅűðÊû"); BUILD_TYPE_MAP.put("7", "µþ¼Ó±ðÊû"); BUILD_TYPE_MAP.put("8", "¹«Ô¢"); + BUILD_TYPE_MAP.put("9","ÁªÁÐסլ"); + BUILD_TYPE_MAP.put("10","»¨Ô°×¡Õ¬"); + BUILD_TYPE_MAP.put("11","¾ÉʽÀïŪ2"); HOUSE_PROPERTY_MAP.put("1","¸öÈ˲úȨ"); HOUSE_PROPERTY_MAP.put("2","¼¯Ìå²úȨ"); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java new file mode 100644 index 000000000..85d968763 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/GeoUtils.java @@ -0,0 +1,60 @@ +package com.fangjia.service.util; + +import com.fangjia.core.util.HttpRequest; +import com.fangjia.service.util.dto.GaodeDto; +import groovy.util.logging.Slf4j; +import net.sf.json.JSONArray; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + + +/** + * ¸ßµÂ¾­Î³¶ÈÄæ½âÎö + */ +@Slf4j +public class GeoUtils { + + private final static Logger LOGGER = LoggerFactory.getLogger(GeoUtils.class); + + public static GaodeDto geo(String city, String address) { + GaodeDto gaodeDto = new GaodeDto(); + Map params = new HashMap(); + params.put("address", address); + params.put("key", "0cb105e7c10e9ae2b178e4744d62319a"); + params.put("city", city); + params.put("batch", "true"); + params.put("output", "json"); + try { + net.sf.json.JSONObject response = new HttpRequest().getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "utf-8"); + if ("10004".equals(response.getInt("infocode"))) { + LOGGER.error("¸ßµÂ·þÎñµ¥Î»Ê±¼äÄÚ£¨1·ÖÖÓ£©·ÃÎÊÁ¿³¬ÏÞ, ˯Ãß1·ÖÖÓ"); + // ¿ª·¢Õߵĵ¥Î»Ê±¼äÄÚ£¨1·ÖÖÓ£©·ÃÎÊÁ¿³¬ÏÞ£¬±»ÏµÍ³×Ô¶¯·âÍ££¬ÏÂÒ»·ÖÖÓ×Ô¶¯½â·â¡£ + Thread.sleep(60000); + response = new HttpRequest().getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "utf-8"); + } + if ("OK".equals(response.getString("info"))) { + JSONArray geocodes = response.getJSONArray("geocodes"); + if (geocodes.size() > 0) { + net.sf.json.JSONObject geocode = net.sf.json.JSONObject.fromObject(geocodes.get(0)); + String level = geocode.getString("level"); + if (!Arrays.asList("Ê¡", "ÊÐ", "ÇøÏØ", "¿ª·¢Çø", "ÏçÕò").contains(level)) { + String location = geocode.getString("location"); + Double lng = Double.valueOf(location.split(",")[0]); + Double lat = Double.valueOf(location.split(",")[1]); + gaodeDto.setLevel(level); + gaodeDto.setLng(lng); + gaodeDto.setLat(lat); + gaodeDto.setDistrict(geocode.getString("district")); + } + } + } + } catch (Exception e) { + LOGGER.error("µØÍ¼¸¨Öú½âÎö³ö´í:" + city + " " + city); + } + return gaodeDto; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java new file mode 100644 index 000000000..9d0efe820 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/dto/GaodeDto.java @@ -0,0 +1,49 @@ +package com.fangjia.service.util.dto; + +/** + * @author shenjian + * @since 2023/4/26 + */ +public class GaodeDto { + + + private Double lng; + + private Double lat; + + private String level; + + private String district; + + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } +} diff --git a/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js b/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js index 42db3b6a2..3457900c1 100644 --- a/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js +++ b/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js @@ -239,7 +239,9 @@ $(function() { if(refererUrl.endWith("gujia/report")){ refererUrl = refererUrl+"?fangjia=true"; } - window.location.href = wwwUrl + "/user/register/success?backUrl="+refererUrl; + //æˆ�功页é�¢ + // window.location.href = wwwUrl + "/user/register/success?backUrl="+refererUrl; + window.location.href = refererUrl } else { if (re.msg == "输入的验è¯�ç �ä¸�正确,请é‡�新输入") { $(".smscode_err").html("短信验è¯�ç �错误"); diff --git a/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css new file mode 100644 index 000000000..83c2d72fe --- /dev/null +++ b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css @@ -0,0 +1,37 @@ +@charset "utf-8"; +/* CSS Document */ +.main { width: 1200px;margin: auto; margin-top: 100px;overflow: hidden;position: relative;} +.main_left {margin: auto;} +.topic {padding: 40px 0;border-bottom: solid 1px #e5e5e5;} +.topic_top {font-size: 18px;margin-bottom: 20px;align-items: center;display: flex;float: left;} +.topic_top i {width: 30px;height: 36px;display: inline-flex;background: url(../../../images/fangjia/v6/4-2-13.png) no-repeat left bottom;margin-left: -10px;} +.overview01 .overview_left{margin-bottom: 80px;} +.overview01 .overview_left p { margin-bottom: 10px;width: 100%; text-align: justify;font-size: 20px;line-height: 30px;} +.overview01 .overview_left p label {color: #3c3f46;font-size: 24px;font-weight: 500;} +.overview01 .overview_left p i {width: 11px;height: 30px;background: url(../../../images/fangjia/v6/address.png) no-repeat center center;float: left;margin-right: 5px;} +.overview01 .overview_left p{font-size: 16px;} + +.price_div{display: flex;float: left;flex-direction: row;justify-content: flex-start;width: 1200px; margin: auto auto; padding-bottom: 10px;} +.price_div ul{width:25%;} +.price_div ul li{color: #878682;} +.price_div ul li .unit_price{color: #db4c3f;font-size: 32px;font-weight: bold;line-height: 50px;} +.price_div ul li .dw{color: #db4c3f;font-size: 16px;} +.price_div ul li .up{ color: #db4c3f;} +.price_div ul li .down{color:#00ae66;} +.price_div ul li .hb_tb{font-size: 22px;line-height: 50px;} +.price_div ul li .down i {background: url(../../../images/fangjia/v6/down.png) no-repeat left center;} +.price_div ul li .up i {background: url(../../../images/fangjia/v6/up.png) no-repeat left center;} + + +.districtMap{width:100%;height:400px;} +/* 地图样å¼� */ +.mark-icon-box .mark-icon {width: 20px;height: 30px;display: block;cursor: pointer;font-size: 14px;color: #fff;font-weight: bold;text-align: center;line-height: 24px;background: url(../../../images/fangjia/v5/dw.png) no-repeat;} +.mark-icon-box { width: 24px; height: 30px; position: absolute; z-index: 98; } +.mark-icon-box .mark-icon:hover, .mark-icon-box .mark-icon-h { background: url(../../../images/fangjia/v5/dw_h.png) no-repeat ; } + +.mark-tip {font-size: 14px;position: absolute;z-index: 99;margin-top: -74px;margin-left: -20px;} +.mark-tip .title1 {line-height: 20px;color: #000;background: #fff;padding: 5px 40px 5px 15px;border-radius: 5px;box-shadow: 3px 3px 8px #888;height: 20px;} +.mark-tip .title1 span {display: inline-block;max-width: 170px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;margin-right: 25px;} +.mark-tip .title1 b { font-weight: normal; display: block; position: absolute; top: 5px; right: 10px; } +.mark-tip .icon { width: 21px; height:14px; background: url(../../../images/fangjia/v5/sj.png) no-repeat ; position: absolute; bottom: -14px; left: 20px; } +