diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/EvaluationAuditController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/EvaluationAuditController.java index 29ee2de45..52b1ecb2d 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/EvaluationAuditController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/EvaluationAuditController.java @@ -106,7 +106,13 @@ public class EvaluationAuditController { if(eval!=null){ bo.setHouseArea(eval.getHouseArea()); bo.setDistrictName(eval.getDistrictName()); - bo.setAddress(eval.getAddress()); + String address = ""; + if(StringUtils.isNotBlank(eval.getCertificateAddress())){ + address = eval.getCertificateAddress(); + }else{ + address = eval.getAddress(); + } + bo.setAddress(address); bo.setHouseNum(eval.getHouseNum()); bo.setRoomNum(eval.getRoomNum()); bo.setEvaluationDate(eval.getLastUpdated()); @@ -115,7 +121,7 @@ public class EvaluationAuditController { bo.setFloorDesc(eval.getFloorDesc()); bos.add(bo); - List evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), eval.getAddress(), eval.getHouseNum(), eval.getRoomNum()); + List evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), bo.getAddress(), eval.getHouseNum(), eval.getRoomNum()); if(evaluations!=null && evaluations.size()>=2){ List ids = new ArrayList(); for(FjtEvaluation fjtEval : evaluations){ @@ -148,7 +154,13 @@ public class EvaluationAuditController { BeanUtils.copyProperties(audit, bo); bo.setHouseArea(eval.getHouseArea()); bo.setDistrictName(eval.getDistrictName()); - bo.setAddress(eval.getAddress()); + String address = ""; + if(StringUtils.isNotBlank(eval.getCertificateAddress())){ + address = eval.getCertificateAddress(); + }else{ + address = eval.getAddress(); + } + bo.setAddress(address); bo.setHouseNum(eval.getHouseNum()); bo.setRoomNum(eval.getRoomNum()); bo.setEvaluationDate(eval.getLastUpdated()); @@ -157,7 +169,7 @@ public class EvaluationAuditController { bo.setFloorDesc(eval.getFloorDesc()); bos.add(bo); //根据地址,楼栋号判断是否是同一套房 - List evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), eval.getAddress(), eval.getHouseNum(), eval.getRoomNum()); + List evaluations = fjtEvaluationService.findAllFjtEvaluationByConditions(eval.getCity(), eval.getRegion(), bo.getAddress(), eval.getHouseNum(), eval.getRoomNum()); if(evaluations!=null && evaluations.size()>=2){ List ids = new ArrayList(); for(FjtEvaluation fjtEval : evaluations){ diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/YugudanController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/YugudanController.java index 37e2d93f7..3a51dcc61 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/YugudanController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/YugudanController.java @@ -362,8 +362,8 @@ public class YugudanController { if (model.getId()>0) { //FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(model.getId()); Map data = new HashMap(); - if(StringUtils.isNotBlank(model.getAddress())){ - data.put("address", model.getAddress()); + if(StringUtils.isNotBlank(model.getCertificateAddress())){ + data.put("certificateAddress", model.getCertificateAddress()); } // if(model.getPeopleEditDate()!=null || model.getPeopleEditPrice()!=null){ // data.put("peopleEdit", 1); diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/fjtEvaluationController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/fjtEvaluationController.java index 18e5f75ed..93eec6a06 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/fjtEvaluationController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/fjtEvaluationController.java @@ -113,7 +113,9 @@ public class fjtEvaluationController { FjtEvaluation evaluation = fjtEvaluationService.findEvaluationById(Integer.parseInt(bo.getEvaluationId())); if(evaluation != null){ String addr = ""; - if(evaluation.getAddress() != null){ + if(StringUtils.isNotBlank(evaluation.getCertificateAddress())){ + addr += evaluation.getCertificateAddress(); + }else if(evaluation.getAddress() != null){ addr += evaluation.getAddress(); } if(StringUtils.isNotBlank(evaluation.getHouseNum())){ diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/YugudanModel.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/YugudanModel.java index d710efeed..10db294b2 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/YugudanModel.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/YugudanModel.java @@ -150,8 +150,10 @@ public class YugudanModel extends BaseModel{ private String reportNum; private Integer askPriceId;//人工询价id - - + + private String certificateAddress; + + public int getId() { return id; } @@ -861,7 +863,12 @@ public class YugudanModel extends BaseModel{ public void setUnitNum(String unitNum) { this.unitNum = unitNum; } - - - + + public String getCertificateAddress() { + return certificateAddress; + } + + public void setCertificateAddress(String certificateAddress) { + this.certificateAddress = certificateAddress; + } } diff --git a/projects/fangjia-bkoff/src/main/webapp/avgPriceUpdate/districtDetail.ftl b/projects/fangjia-bkoff/src/main/webapp/avgPriceUpdate/districtDetail.ftl index 9ade46e39..929a94d63 100644 --- a/projects/fangjia-bkoff/src/main/webapp/avgPriceUpdate/districtDetail.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/avgPriceUpdate/districtDetail.ftl @@ -724,19 +724,59 @@ }); var series = new Array(); series[0] = { - name:"鎴挎簮鏁e垪鍥�", + name:"鎴挎簮鏁e垪鍥�-鏅�氫綇瀹�", data:new Array() //color:"#660099" } + series[1] = { + name:"鎴挎簮鏁e垪鍥�-鍟嗕綇", + data:new Array(), + color:"#12990f" + } + series[2] = { + name:"鎴挎簮鏁e垪鍥�-鍒", + data:new Array(), + color:"#992632" + } + var series_arry_0 = [] + var series_arry_1 = [] + var series_arry_2 = [] $(data).each(function(i,item){ var pdate = item.pDate + ""; var ds = pdate.substring(0, 4) + '-' + pdate.substring(4, 6) + '-' + pdate.substring(6) - series[0].data.push({ - x:new Date(ds), - y:Math.round(item.totalPrice/item.area), - data:item - }) + if ((item.estateType!=null) && (item.estateType.indexOf('鍒') > -1)){ + series_arry_2.push({ + x:new Date(ds), + y:Math.round(item.totalPrice/item.area), + data:item + }) + }else if((item.estateType!=null) && ((item.estateType.indexOf('鍟嗕綇') > -1) || (item.estateType.indexOf('鍏瘬閰掑簵') > -1))){ + series_arry_1.push({ + x:new Date(ds), + y:Math.round(item.totalPrice/item.area), + data:item + }) + }else{ + series_arry_0.push({ + x:new Date(ds), + y:Math.round(item.totalPrice/item.area), + data:item + }) + } + // series[0].data.push({ + // x:new Date(ds), + // y:Math.round(item.totalPrice/item.area), + // data:item + // }) + // series[1].data.push({ + // x:new Date(ds), + // y:Math.round(item.totalPrice/item.area), + // data:item + // }) }); + series[0].data = series_arry_0 + series[1].data = series_arry_1 + series[2].data = series_arry_2 $('#houseChart').highcharts({ chart: { type: 'scatter', diff --git a/projects/fangjia-bkoff/src/main/webapp/loudong/list.ftl b/projects/fangjia-bkoff/src/main/webapp/loudong/list.ftl index f131f5e6e..ff6b813b2 100644 --- a/projects/fangjia-bkoff/src/main/webapp/loudong/list.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/loudong/list.ftl @@ -152,7 +152,7 @@ <#list loudongList! as loudong> - + ${loudong.districtNo!''} diff --git a/projects/fangjia-bkoff/src/main/webapp/seawater/houseList.ftl b/projects/fangjia-bkoff/src/main/webapp/seawater/houseList.ftl index 69d4cd0f7..af17b04e3 100644 --- a/projects/fangjia-bkoff/src/main/webapp/seawater/houseList.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/seawater/houseList.ftl @@ -140,6 +140,7 @@ 鏉垮潡 瑁呬慨 鏈濆悜 + 鐗╀笟绫诲瀷 鏉ユ簮 鎿嶄綔 @@ -180,6 +181,7 @@ ${it.block!} ${it.fitment!} ${it.direction!} + ${it.estateType!} <#if it.url??> ${t_util.urlToSiteName(it.url!)!'鏈煡'} diff --git a/projects/fangjia-bkoff/src/main/webapp/yugudan/editEval.ftl b/projects/fangjia-bkoff/src/main/webapp/yugudan/editEval.ftl index 53fd8f659..0d7cdf0e7 100644 --- a/projects/fangjia-bkoff/src/main/webapp/yugudan/editEval.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/yugudan/editEval.ftl @@ -241,10 +241,10 @@ - 鐗╀笟鍦板潃 + 浜ц瘉鍦板潃 - ${(evaluation.address)!} - + <#if evaluation?? && evaluation.certificateAddress??>${(evaluation.certificateAddress)!}<#else>${(evaluation.address)!} + diff --git a/projects/fangjia-bkoff/src/main/webapp/yugudan/evallist.ftl b/projects/fangjia-bkoff/src/main/webapp/yugudan/evallist.ftl index 26c02dc4c..c2fa9b4a8 100644 --- a/projects/fangjia-bkoff/src/main/webapp/yugudan/evallist.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/yugudan/evallist.ftl @@ -68,7 +68,7 @@ 鍩庡競 鍖哄煙 妤肩洏鍚嶇О - 浼颁环鍦板潃 + 浜ц瘉鍦板潃 甯愬彿 闈㈢Н 鎬讳环 @@ -83,7 +83,7 @@ ${it.city} ${it.region!} ${it.districtName!} - ${it.address!}<#if it.houseNum??>${it.houseNum!}鍙� + <#if it.certificateAddress??>${(it.certificateAddress)!}<#else>${(it.address)!}<#if it.houseNum??>${it.houseNum!}鍙� <#if it.unitNum?? && it.unitNum?length gt 1>${it.unitNum!}鍗曞厓 <#if it.buildType!=3 && it.buildType!=8 && it.buildType!=0> <#if it.floorDesc?? && it.floorDesc?length gt 1>${it.floorDesc!}灞� 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 d4cc2d5da..e11cd2246 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 @@ -1341,6 +1341,7 @@ public class DataUtil { GZIPOutputStream outputStream = new GZIPOutputStream(bao); outputStream.write(content.getBytes("UTF-8")); outputStream.finish(); + System.out.println(bao.toString()); return bao.toByteArray(); } diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SaleLeadsController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SaleLeadsController.java index 9596069f4..eab5dbd3c 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SaleLeadsController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SaleLeadsController.java @@ -6,12 +6,20 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URLEncoder; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.logging.Handler; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.fangjia.core.util.DataUtil; +import com.fangjia.core.util.DingDingMessageUtil; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.HttpRequestException; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; import com.fangjia.coresite.model.JsonModel; @@ -27,9 +35,12 @@ import com.fangjia.service.common.CookieName; import com.fangjia.service.fangjia.NewsResourceService; import com.fangjia.service.fangjia.SaleLeadsService; import com.fangjia.service.mongo.fangjia.ServerAreaService; +import org.apache.log4j.Logger; public class SaleLeadsController { + private static final Logger LOG = Logger.getLogger(SaleLeadsController.class); + private SaleLeadsService saleLeadsService; private ServerAreaService serverAreaService; private NewsResourceService newsResourceService; @@ -41,6 +52,15 @@ public class SaleLeadsController { return model; } + /** + * 地数公众号咨询 + * @param model + * @return + */ + public Object didataApplyAction(SaleLeadsModel model) { + return model; + } + public Object doAddAction(SaleLeadsModel model, HttpServletRequest req, HttpServletResponse res) throws UnsupportedEncodingException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { @@ -129,8 +149,64 @@ public class SaleLeadsController { } saleLeads = converValue(saleLeads); + String body = + "业务需求:" + saleLeads.getBusiness() + " " + saleLeads.getOtherBusiness() + "\n\n" + + "姓名:" + saleLeads.getUname() + "\n\n" + + "城市:" + saleLeads.getCity() + "\n\n" + + "工作职能:" + saleLeads.getWork() + " " + saleLeads.getOtherWork() + "\n\n" + + "手机:" + saleLeads.getMobile() + "\n\n" + + "邮箱:" + saleLeads.getEmail() + "\n\n" + + "公司名称:" + saleLeads.getCompany() + "\n\n" + + "行业性质:" + saleLeads.getIndustryNature() + " " + saleLeads.getOtherIndustryNature() + "\n\n"; + body = body.replaceAll("null", "").replaceAll("其他,请填写", ""); + if (StringUtils.isNotBlank(refUrl) && refUrl.contains("bd_vid")) { + body += "线索来源:百度"; + } else if (StringUtils.isNotBlank(refUrl) && refUrl.contains("didata.wechat")) { + body += "线索来源: 地数公众号"; + } else { + body += "线索来源:房价网"; + } + try { + JSONObject requestBody = new JSONObject(); + requestBody.put("msgtype", "text"); + JSONObject markdown = new JSONObject(); + markdown.put("title", "销售线索"); + markdown.put("content", body); + requestBody.put("text", markdown); + HttpRequest request = new HttpRequest(); + final String ding_url = "https://oapi.dingtalk.com/robot/send?access_token=894650a12af9497bed599df1d5f93b21d6da5bbae45f35f18c5825580ebbdf64"; + Map headers = new HashMap(); + headers.put("Content-Type", "application/json; charset=utf-8"); + request.postWithBody(ding_url, requestBody, headers, "UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } saleLeadsService.save(saleLeads); - + + // 对于百度广告过来的信息,进行回传 + try { + if (StringUtils.isNotBlank(refUrl) && refUrl.contains("bd_vid")) { + HttpRequest httpRequest = new HttpRequest(); + final String baiduUrl = "https://ocpc.baidu.com/ocpcapi/api/uploadConvertData"; + Map bdHeaders = new HashMap(); + bdHeaders.put("Content-Type", "application/json; charset=utf-8"); + + JSONObject requestBody = new JSONObject(); + // https://fengchao.baidu.com/fc/toolscenter/optimize/track/user/27002539 + requestBody.put("token", "EZGISwlOClRMEZErT2ThZTEjpLAzs2wE@9POwrGLqpRtQeGhvvCug1N3OK1tq3skk"); + JSONArray jsonArray = new JSONArray(); + JSONObject contentJson = new JSONObject(); + contentJson.put("logidUrl", refUrl); + contentJson.put("newType", "3"); + jsonArray.add(contentJson); + requestBody.put("conversionTypes", jsonArray); + String result = httpRequest.postWithBody(baiduUrl, requestBody, bdHeaders, "UTF-8"); + LOG.info("百度回传成功:" + result); + } + } catch (HttpRequestException e) { + e.printStackTrace(); + } + if(StringUtils.isNotBlank(saleLeads.getBusiness()) && saleLeads.getBusiness().contains("_")){ String[] businessArray = saleLeads.getBusiness().split("_"); for(String s : businessArray){ @@ -155,7 +231,12 @@ public class SaleLeadsController { if(StringUtils.isNotBlank(refUrl) && refUrl.contains("/resource/info")){ url = refUrl.substring(refUrl.indexOf("/resource/info"), refUrl.length()); - }else{ + } else if (StringUtils.isNotBlank(refUrl) && refUrl.contains("didata.wechat")) { // 地数公众号跳转 + url = "/enquire/didataSuccess"; + if (StringUtils.isNotBlank(refUrl)) { + url = url + "?backUrl=" + URLEncoder.encode(refUrl); + } + } else{ url = "/enquire/success"; if (StringUtils.isNotBlank(refUrl)) { url = url + "?backUrl=" + URLEncoder.encode(refUrl); @@ -224,6 +305,10 @@ public class SaleLeadsController { return model; } + public Object didataResultAction(SaleLeadsModel model) { + return model; + } + public SaleLeadsService getSaleLeadsService() { return saleLeadsService; } diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SolutionController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SolutionController.java index ef220df7d..b49974a26 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SolutionController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/SolutionController.java @@ -1,6 +1,15 @@ package com.fangjia.coresite.controllers; +import com.fangjia.core.util.HttpRequest; +import com.fangjia.core.util.HttpRequestException; import com.fangjia.coresite.model.FangjiaModel; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.commons.lang3.StringUtils; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; /** * 解决方案 控制器 @@ -14,7 +23,7 @@ public class SolutionController { * @param model * @return */ - public Object apiAction(FangjiaModel model) { + public Object apiAction(FangjiaModel model, HttpServletRequest request) { return model; } diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/filters/AntiSpiderFilter.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/filters/AntiSpiderFilter.java index b33d38545..db4f0a4db 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/filters/AntiSpiderFilter.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/filters/AntiSpiderFilter.java @@ -48,6 +48,11 @@ public class AntiSpiderFilter implements Filter { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; + // 放开首页不做爬虫验证 + if (request.getRequestURL().toString().endsWith("fangjia.com") || request.getRequestURL().toString().endsWith("fangjia.com/")) { + chain.doFilter(req, resp); + return; + } if(request.getRequestURI().endsWith("/validate") || request.getRequestURI().contains("randomCode") || request.getRequestURI().contains("checkCode")|| request.getRequestURI().contains("yeepayCallBack")){ chain.doFilter(req, resp); return; diff --git a/projects/fangjia-coresite/src/main/resources/urlrewrite2.0.xml b/projects/fangjia-coresite/src/main/resources/urlrewrite2.0.xml index 5c8ab82c9..d96ca92fe 100644 --- a/projects/fangjia-coresite/src/main/resources/urlrewrite2.0.xml +++ b/projects/fangjia-coresite/src/main/resources/urlrewrite2.0.xml @@ -309,7 +309,17 @@ / - + + + + /didataApply + + + + + /didataSuccess + + diff --git a/projects/fangjia-coresite/src/main/webapp/company/about.ftl b/projects/fangjia-coresite/src/main/webapp/company/about.ftl index 16b30ed80..5e222e0da 100644 --- a/projects/fangjia-coresite/src/main/webapp/company/about.ftl +++ b/projects/fangjia-coresite/src/main/webapp/company/about.ftl @@ -153,46 +153,47 @@
浠栦滑閮藉湪鍜屾垜浠悎浣�
- - - -<#-- --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+<#-- --> +<#-- --> +<#-- --> +<#--<#– –>--> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- --> +<#-- -->
- +
diff --git a/projects/fangjia-coresite/src/main/webapp/index.ftl b/projects/fangjia-coresite/src/main/webapp/index.ftl index b5cb130e7..efec6e4b6 100644 --- a/projects/fangjia-coresite/src/main/webapp/index.ftl +++ b/projects/fangjia-coresite/src/main/webapp/index.ftl @@ -207,29 +207,29 @@ - +<#----> diff --git a/projects/fangjia-coresite/src/main/webapp/saleLeads/apply.ftl b/projects/fangjia-coresite/src/main/webapp/saleLeads/apply.ftl index c8c45e7cc..aab69abc0 100644 --- a/projects/fangjia-coresite/src/main/webapp/saleLeads/apply.ftl +++ b/projects/fangjia-coresite/src/main/webapp/saleLeads/apply.ftl @@ -555,27 +555,53 @@ $(".user_btn").click(function(){ scrollTo(0,0); return false; } - + + // 瑙e喅淇℃伅涓㈠け闂 + var work = $(".duty:visible").find("select").val() + if (work) { + work = work.replaceAll("璇烽�夋嫨鎮ㄧ殑宸ヤ綔鑱岃兘", "") + work = work.replaceAll("璇烽�夋嫨", "") + $("#work").val(work); + } + + var box = $(".demand p i.checked"); + if(box.length>0) { + $(".demand").parent().find(".error span").text("") + $(".demand").parent().find(".error").hide(); + var selectOtherFlag = false; + var content = [] + box.each(function () { + var s = $(this).parent().find("span").text(); + if (s.indexOf("璇峰~鍐�") > 0) { + selectOtherFlag = true; + } else { + content.push(s); + } + }) + $("#business").val(content.join("_")); + } + + /*if(!checkEmail()){ scrollBy(0,-300); return false; } - - if(!checkNature()){ - scrollBy(0,-200); - return false; - } if(!checkWork()){ scrollBy(0,-100); return false; } - + + if(!checkNature()){ + scrollBy(0,-200); + return false; + } if(mid=="1018"||mid=="1016"){ if(!checkOtherInfo()){ scrollBy(0,-100); return false; } - } */ + } + */ var cls = $(".agreement i").attr("class"); if(cls.indexOf("checked")>-1){ diff --git a/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl new file mode 100644 index 000000000..07a832de8 --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataApply.ftl @@ -0,0 +1,471 @@ + + + + + +鏃剁┖浠峰�兼寲鎺樺钩鍙� -鍦版暟 didata.ai + + +<#include "../jsconstants.ftl" /> + + + + + + + + + + + + + + + + +<#escape x as x?html> +
+
+ +
+
+ +
+
+
+
+

+
鎴戜滑寰堜箰鎰忎负鎮ㄦ彁渚涘府鍔�
+
√ 璇﹀敖鐨勪骇鍝佸姛鑳藉強鏈嶅姟浠嬬粛
+
√ 閽堝鎮ㄦ墍澶勭殑琛屼笟涓庝笟鍔″満鏅紝鎻愪緵涓撲笟鐨勬湇鍔℃柟妗�
+
√ 鏍规嵁鎮ㄧ殑涓氬姟瑙勬ā鍜岄渶姹傦紝鎻愪緵浼樻儬鐨勪环鏍兼柟妗�
+
绱ф�ュ挩璇㈠彲鎷ㄦ墦400-188-3787
+
棰勭害鐢宠璇风暀涓嬫偍鐨勮仈绯绘柟寮忥紝鎴戜滑浼氬敖蹇笌鎮ㄨ仈绯�
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
+
+
+ 鎻愪氦 +
+
+
+ + +<#include "../citys.ftl"/> + + + + + + + + + + + + + + + + + + + diff --git a/projects/fangjia-coresite/src/main/webapp/saleLeads/didataResult.ftl b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataResult.ftl new file mode 100644 index 000000000..d81912435 --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/saleLeads/didataResult.ftl @@ -0,0 +1,86 @@ + + + + + +鍜ㄨ淇℃伅鎻愪氦鎴愬姛 - 鍦版暟 didata.ai + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+
+
+
+

鎮ㄧ殑淇℃伅宸叉彁浜ゆ垚鍔�

+ +

鑻ユ偍鏈変换浣曢棶棰橈紝娆㈣繋鎷ㄦ墦瀹㈡湇鐢佃瘽锛�400-188-3787

+
+
+
+
+ + + + + + + + + diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java index 8daca61ed..6cb65c498 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/fangjia/enums/SalesLeadEnum.java @@ -22,7 +22,8 @@ public enum SalesLeadEnum { DOWN_APPLY("1016", "下载申请"), FDANG_DIAO_BAO_GAO("1017", "房产专业调查评估报告"), BUSINESS_ASK("1018", "业务咨询"), - HOUSE_EVAL("1019", "房产评估"); + HOUSE_EVAL("1019", "房产评估"), + DIDATA("1020", "地数平台"); diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/bkoff/Loudong.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/bkoff/Loudong.java index 12cb8ca9b..ffb9f957f 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/bkoff/Loudong.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/bkoff/Loudong.java @@ -83,6 +83,8 @@ public class Loudong implements MongoEntity { private Date modifyDate; /**户数*/ private Integer households; + /**一梯几户的户*/ + private Integer roomCount; /** 总建筑面积 */ private Double totalAreas; /** 开盘时间 */ 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 8283df958..41941514a 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 @@ -102,6 +102,7 @@ public class FjtEvaluation implements SqlEntity{ private String finishDateStr;//竣工时间 private String useType;//房屋用途 + private String certificateAddress; //产证地址 private Date downPdfDate;//下载报告时间 @@ -753,6 +754,16 @@ public class FjtEvaluation implements SqlEntity{ } + @Column(name = "certificate_address") + public String getCertificateAddress() { + return certificateAddress; + } + + public void setCertificateAddress(String certificateAddress) { + this.certificateAddress = certificateAddress; + } + + @Column(name = "down_pdf_date") public Date getDownPdfDate() { return downPdfDate; diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java index ab916308a..54c19713d 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DealPriceController.java @@ -233,8 +233,8 @@ public class DealPriceController { Integer minPrice = null; Integer maxPrice = null; if(bo.getDistrictStat()!=null){ - minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.8); - maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.2); + minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.9); + maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.1); } Date startDate = null; Date endDate = null; 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 c75ec0da7..ff5708174 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 @@ -434,8 +434,8 @@ public class HouseController { Integer minPrice = null; Integer maxPrice = null; if(bo.getDistrictStat()!=null){ - minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.8); - maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.2); + minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.9); + maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.1); } List names = new ArrayList(); names.add(district.getName()); @@ -487,8 +487,8 @@ public class HouseController { Integer minPrice = null; Integer maxPrice = null; if(bo.getDistrictStat()!=null){ - minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.8); - maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.2); + minPrice = (int)(bo.getDistrictStat().getAvgPrice() * 0.9); + maxPrice = (int)(bo.getDistrictStat().getAvgPrice() * 1.1); } List names = new ArrayList(); names.add(district.getName()); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommbuildtypeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommbuildtypeBatch.groovy index b59fe435b..1000b157c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommbuildtypeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommbuildtypeBatch.groovy @@ -41,8 +41,15 @@ class BigdataCommbuildtypeBatch extends BaseBatch{ rets.addAll(rows) println city +" "+rows.size() } + + def fileName = "/home/goojia/ccb/BIGDATA_COMMBUILDTYPE_GJ.dat" + if(CommonDatautils.isWindow()){ + fileName = "d:\\数据\\建行\\房产估值\\数据文件\\txt\\BIGDATA_COMMBUILDTYPE_GJ.dat" + } + + def headers = []//["城市ID","小区ID"," 建筑类型","备注","创建时间","更新时间","来源公司","数据时间"] - FileUtils.batchCreateFile(rets, "d:\\数据\\建行\\房产估值\\数据文件\\txt\\BIGDATA_COMMBUILDTYPE_GJ.dat",headers, "utf-8", false); + FileUtils.batchCreateFile(rets, fileName,headers, "utf-8", false); println "txt 生成" } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy index 6cd17549e..b54b97e70 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataCommunityBatch.groovy @@ -44,9 +44,7 @@ class BigdataCommunityBatch extends BaseBatch{ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() for(def city : citys){ -// if(["苏州","北京","广州","杭州","合肥","深圳","石家庄","武汉","西安","重庆"].contains(city)){ -// continue -// } + def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def dists = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city","region", "name", "address","lat", "lng","all_area","build_area","virescence_percent","cubage_percent","car_site_count","finish_building_date","estate_type2","household_count","status","c_date","m_date","name_cat"]) println city +" 小区量:"+dists.size() 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 d34dedcc2..c1ea41780 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 @@ -52,21 +52,20 @@ class BigdataDealBatch extends BaseBatch{ @Override public void process(Object args) { //def weekend = DateUtils.parseFromTightByPattern("2021-07-25","yyyy-MM-dd")//DateUtils.getFirstDayOfWeek(new Date()) - def citys = CcbCommonUtils.citys; + def citys = CommonDatautils.findAllCity()//CcbCommonUtils.citys; + def ccbCitys = CcbCommonUtils.citys; -// for(def city : citys){ -// addDealPriceMatch(city); -// } -// println citys.unique().size() + for(def city : citys){ +// if(!ccbCitys.contains(city)){ + addDealPriceMatch(city); +// } + } def rows = [] def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() for(def city : citys){ def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def ppeDists = [:] -// if(["贵阳","佛山","杭州","沈阳","天津","中山","徐州","绍兴","南通","哈尔滨","惠州","长沙","青岛","长春","烟台","温州","太原","台州","石家庄","宁波","常州","大连","嘉兴","金华","昆明"].contains(city)){ -// ppeDists = getPpeGTE15Datas(city) -// } def statMap = [:]//getDistrictStatByCity(city, weekend) if(city=="上海"){ @@ -570,8 +569,10 @@ class BigdataDealBatch extends BaseBatch{ def addDealPriceMatch(city){ - def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) - def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) +// def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) +// def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern(curDate.toString(), "yyyyMMdd")) + def startDate = DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightByPattern("20220101", "yyyyMMdd")) + def endDate = DateUtils.getLastDayOfMonth(DateUtils.parseFromTightByPattern("20220601", "yyyyMMdd")) def trades = CcbCommonUtils.findTradesByMonth(city, startDate, endDate) final CountDownLatch latch = new CountDownLatch(trades.size()) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataForsaleBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataForsaleBatch.groovy index 0bc461cc5..724682101 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataForsaleBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataForsaleBatch.groovy @@ -74,7 +74,7 @@ class BigdataForsaleBatch extends BaseBatch{ // def distIds = getDistrictIds(cityCodeDataMap.get(city)) def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) def districts = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lng","estate_type2","name_cat","address", "alias", "finish_building_date", "house_property", "property_life", "build_type", "build_structure"]); - exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20220418, 20220519); + exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20220518, 20220619); // exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20210801, 20210831); //测试通过匹配接口配房源效果 // exportSellCSV(index, city, cityCodeDataMap, distCodeMap, districts, 20201201, 20211118) 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 98fbc2d09..db3beb6ef 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 @@ -3,6 +3,7 @@ package com.fangjia.script.ccbevaluation import com.fangjia.datastore.driver.DSCollection import com.fangjia.datastore.driver.DSCursor import com.fangjia.datastore.driver.DataStore +import com.fangjia.script.lixue.util.DBUtils import com.fangjia.script.util.DataUtil import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils @@ -377,7 +378,8 @@ class CcbCommonUtils { keys.put(field, 1); } } - def dbsour = getDataStoreConnection().find(q, keys).batchSize(2000) +// def dbsour = getDataStoreConnection().find(q, keys).batchSize(2000) + def dbsour = DBUtils.seaweed.find(q,keys).batchSize(2000) println "原始:"+dbsour.count() def rets = [] for(def d : dbsour){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy index c8697c956..f35522733 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/DealAndThirdPriceDataProcess.groovy @@ -373,10 +373,10 @@ class DealPriceDataProcess { def citys = CcbCommonUtils.citys def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() def publishTime = '2021-10-01' - def month = 202204 + def month = 202205 def rows = [] for(def city : citys) { - def rets = findPeGteThirdParty(city, 202205) + def rets = findPeGteThirdParty(city, 202206) def total = 0 println city +" "+rets.size() for(def m : rets){ @@ -388,7 +388,7 @@ class DealPriceDataProcess { } def findPeGteThirdParty(cityName, yearmonth){ - def sql = "select commid,target_avg_price from avm_evaluation_item_gj where year_month=${yearmonth} and data_type='第三方' and cityname='${cityName}' and pe>50" + def sql = "select commid,target_avg_price from avm_evaluation_item_gj where year_month=${yearmonth} and data_type='第三方' and cityname='${cityName}' and pe>30" def rets = [] sqlInstance236.eachRow(sql,{r-> def map = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy index af8723b42..eaf7586a5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ExportOracleData.groovy @@ -23,7 +23,7 @@ class ExportOracleData { def run() { // def curMonth = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), 0, "yyyyMM")); def lastMonth = Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); - + def new_dists = ["350604","350605","410307","410308","450181"] //不会变 exportEvaluationRateData() exportBigdataPoiData() @@ -37,9 +37,9 @@ class ExportOracleData { exportCommunityStaging() exportCommunityBuileType() - exportThirdPartyPrice2(lastMonth) - exportBigdataForsale("2022-04-19") - exportBigdataDeal("2022-04-01") + exportThirdPartyPrice2(lastMonth, new_dists) + exportBigdataForsale("2022-05-19", new_dists) + exportBigdataDeal("2022-05-01", new_dists) //计算结果相关 @@ -293,12 +293,51 @@ class ExportOracleData { println "COMMUNITY_GUIDE_PRICE_GJ 上传Ftp完成......" } - def exportBigdataDeal(def dealDate) { - def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, \n" + - "HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, \n" + - "HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, \n" + - "PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE, CJJE, WORKDATE\n" + - "from bigdata_deal_gj where dealdate>=to_date('${dealDate}','yyyy-MM-dd')"; + def exportBigdataDeal(def dealDate, def new_dists) { + + def allRows = [] + if(new_dists){ + def newstr = "('"+new_dists.join("','")+"')" + def sql1 = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, \n" + + "HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, \n" + + "HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, \n" + + "PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE, CJJE, WORKDATE\n" + + "from bigdata_deal_gj where dealdate>=to_date('${dealDate}','yyyy-MM-dd') and distid not in ${newstr}" + def rets1 = dealData(sql1) + + def sql2 = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, \n" + + "HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, \n" + + "HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, \n" + + "PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE, CJJE, WORKDATE\n" + + "from bigdata_deal_gj where distid in ${newstr}" + def rets2 = dealData(sql2) + allRows.addAll(rets1) + allRows.addAll(rets2) + }else{ + def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, \n" + + "HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, \n" + + "HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, \n" + + "PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE, CJJE, WORKDATE\n" + + "from bigdata_deal_gj where dealdate>=to_date('${dealDate}','yyyy-MM-dd')"; + allRows = dealData(sql) + } + + def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "28"; + def fileName = "/ccb/MODEL_000000_000000_BIGDATA_DEAL_GJ_ADD_${curDate}_0001.dat" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\${curDate}\\MODEL_000000_000000_BIGDATA_DEAL_GJ_ADD_${curDate}_0001.dat" + } + def headers = [] +//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] + + FileUtils.batchCreateFile(allRows, fileName, headers, "utf-8", false); + println "BIGDATA_DEAL_GJ 数据文件输出完成......" + CcbFtpUtils.ftpUpload(null, fileName, curDate) + println "BIGDATA_DEAL_GJ 上传Ftp完成......" + } + + + def dealData(def sql){ def allRows = [] sqlInstance.eachRow(sql, { r -> def data = [] @@ -369,21 +408,9 @@ class ExportOracleData { data << r.WORKDATE allRows << data }); - def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "28"; - def fileName = "/ccb/MODEL_000000_000000_BIGDATA_DEAL_GJ_ADD_${curDate}_0001.dat" - if (CommonDatautils.isWindow()) { - fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\${curDate}\\MODEL_000000_000000_BIGDATA_DEAL_GJ_ADD_${curDate}_0001.dat" - } - def headers = [] -//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] - - FileUtils.batchCreateFile(allRows, fileName, headers, "utf-8", false); - println "BIGDATA_DEAL_GJ 数据文件输出完成......" - CcbFtpUtils.ftpUpload(null, fileName, curDate) - println "BIGDATA_DEAL_GJ 上传Ftp完成......" + return allRows } - def exportThirdPartyPrice() { def sql = "select ID, COMMID, COMMNAME, CITYID, CITYNAME, DISTID, DISTNAME, YEAR_MONTH, ZHUGE_AVG_PRICE, ANJUKE_AVG_PRICE, FANG_AVG_PRICE, LIANJIA_AVG_PRICE, CITYHOUSE_AVG_PRICE, MAITIAN_AVG_PRICE, KE_AVG_PRICE, \n" + "TAOFANG_AVG_PRICE, ZHONGYUAN_AVG_PRICE, TBS_AVG_PRICE, QFANG_AVG_PRICE, FANGTAN_AVG_PRICE, FANGDUODUO_AVG_PRICE, WIWJ_AVG_PRICE, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE\n" + @@ -433,8 +460,42 @@ class ExportOracleData { } - def exportThirdPartyPrice2(price_date) { - def sql = "select ID, CITYID, DISTID, COMMID, COMMNAME, DATA_SOURCE_ID, DATA_SOURCE, PRICE_DATE, COMMUNITY_PRICE, COMMUNITY_MAX_PRICE, COMMUNITY_MIN_PRICE, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME from BIGDATA_THIRD_PARTY_PRICE_GJ where price_date=${price_date} "; + def exportThirdPartyPrice2(price_date, new_dists) { + + def allRows = [] + if(new_dists) { + def newstr = "('"+new_dists.join("','")+"')" + def sql1 = "select ID, CITYID, DISTID, COMMID, COMMNAME, DATA_SOURCE_ID, DATA_SOURCE, PRICE_DATE, COMMUNITY_PRICE, COMMUNITY_MAX_PRICE, " + + "COMMUNITY_MIN_PRICE, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME from BIGDATA_THIRD_PARTY_PRICE_GJ where " + + "price_date=${price_date} and distid not in ${newstr} "; + def rets1 = getThirdPartyDatas(sql1) + allRows.addAll(rets1) + + def sql2 = "select ID, CITYID, DISTID, COMMID, COMMNAME, DATA_SOURCE_ID, DATA_SOURCE, PRICE_DATE, COMMUNITY_PRICE, COMMUNITY_MAX_PRICE, " + + "COMMUNITY_MIN_PRICE, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME from BIGDATA_THIRD_PARTY_PRICE_GJ where " + + "distid in ${newstr} "; + def rets2 = getThirdPartyDatas(sql2) + allRows.addAll(rets2) + }else{ + def sql = "select ID, CITYID, DISTID, COMMID, COMMNAME, DATA_SOURCE_ID, DATA_SOURCE, PRICE_DATE, COMMUNITY_PRICE, COMMUNITY_MAX_PRICE, COMMUNITY_MIN_PRICE, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME from BIGDATA_THIRD_PARTY_PRICE_GJ where price_date=${price_date} "; + allRows = getThirdPartyDatas(sql) + } + + def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "28"; + def fileName = "/ccb/MODEL_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\${curDate}\\MODEL_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" +// fileName = "D:\\MODEL_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" + } + def headers = [] +//["第三方均价ID","楼盘ID","小区名称","城市ID","城市名称","行政区ID","行政区名称","均价对应的月份","诸葛找房均价","安居客均价","房天下均价","链家均价","城市房产均价","麦田均价","贝壳均价","淘房365","中原均价","兔博士均价","Q房均价","房探均价","房多多均价","我爱我家均价","创建时间","更新时间","来源公司"] + + FileUtils.batchCreateFile(allRows, fileName, headers, "utf-8", false); + println "BIGDATA_THIRD_PARTY_PRICE_GJ 数据文件输出完成......" + CcbFtpUtils.ftpUpload(null, fileName, curDate) + } + + def getThirdPartyDatas(def sql){ def allRows = [] sqlInstance.eachRow(sql, { r -> def data = [] @@ -452,21 +513,9 @@ class ExportOracleData { data << r.UPDATETIME allRows << data }) - def curDate = DateUtils.formatDateByPattern(new Date(), "yyyyMM") + "28"; - def fileName = "/ccb/MODEL_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" - if (CommonDatautils.isWindow()) { - fileName = "D:\\数据\\建行\\房产估值\\数据文件\\txt\\${curDate}\\MODEL_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" -// fileName = "D:\\MODEL_000000_000000_BIGDATA_THIRD_PARTY_PRICE_GJ_ADD_${curDate}_0001.dat" - } - def headers = [] -//["第三方均价ID","楼盘ID","小区名称","城市ID","城市名称","行政区ID","行政区名称","均价对应的月份","诸葛找房均价","安居客均价","房天下均价","链家均价","城市房产均价","麦田均价","贝壳均价","淘房365","中原均价","兔博士均价","Q房均价","房探均价","房多多均价","我爱我家均价","创建时间","更新时间","来源公司"] - - FileUtils.batchCreateFile(allRows, fileName, headers, "utf-8", false); - println "BIGDATA_THIRD_PARTY_PRICE_GJ 数据文件输出完成......" - CcbFtpUtils.ftpUpload(null, fileName, curDate) + return allRows; } - def exportBigdataCommunity(){ def sql = "select CITYID, DISTID, COMMID, DISTNAME, COMMNAME, ADDRESS, LATITUDE, LONGITUDE, LANDAREA, BUILDAREA, GREENINGRATE, PLOTRATIO, PARKINGCNT, BUILDYEAR, HOUSEUSE, ZTS, WORKDATE, UPDATEFLAG, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,COMMTYPE, \n" + "\tCOMMALIAS, STREET, STREETNO, IFNEW, INTRODUCTION, REMARK, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, SOURCECODE, XZJDB, LJXZQHDM, LJXZQH,STATUS from bigdata_community_gj ";//where cityId in (350200,150100) @@ -521,7 +570,7 @@ class ExportOracleData { println "BIGDATA_COMMUNITY_GJ 上传Ftp完成......" } - def exportBigdataForsale(publishDate){ + def exportBigdataForsale(publishDate, new_dists){ //["北京","上海"] def citys = CcbCommonUtils.citys; def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() @@ -535,84 +584,111 @@ class ExportOracleData { for(def city : citys){ def cityCode = cityCodeDataMap.get(city) - def sql = "select CITYID,FORSALEID,PROPCODE,CITYNAME,DISTID,DISTNAME,COMMID,COMMNAME, BUILDID,BUILDNO, BUILDNAME,UNITID,UNITNO,UNITNAME,HOUSEID,ADDRESS,BUILDYEAR,PROPTYPE,PROPYEARS,UNITPRICE,TOTALPRICE,PAYTYPE,FLOORNUM,FLOORCNT,\n" + - " BUILDTYPE, HOUSESTRU,BUILDSTRU,BUILDAREA,LIVINGAREA,HOUSESTYLE,ROOMCNT,LIVINGROOMCNT,KITCHENCNT, BATHROOMCNT,HOUSEASPECT,FITMENT,IFELEVATOR,ELEVATORHOUSE,to_char(PUBLISHTIME,'yyyy-mm-dd hh24:mi:ss') as PUBLISHTIME,to_char(EXPIRETIME,'yyyy-mm-dd hh24:mi:ss') as EXPIRETIME,\n" + - " IFFIRST,DATASOURCE,AGENCYID,AGENCYNAME,PUBLISHER,PHONE,DESCRIPTION,REMARK,to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE,ATTACH from bigdata_forsale_gj where cityId='${cityCode}' and publishtime>=to_date('${publishDate}','yyyy-MM-dd')"; - def allRows = [] - def index = 0 - sqlInstance.eachRow(sql,{r-> - index = index+1 - println city +" "+index - def data = [] - data << r.CITYID - data << r.FORSALEID - data << r.PROPCODE - data << r.CITYNAME - data << r.DISTID - data << r.DISTNAME - data << r.COMMID - data << r.COMMNAME - data << r.BUILDID - data << r.BUILDNO - data << r.BUILDNAME - data << r.UNITID - data << r.UNITNO - data << r.UNITNAME - data << r.HOUSEID - data << r.ADDRESS - data << r.BUILDYEAR - data << r.PROPTYPE - data << r.PROPYEARS - data << r.UNITPRICE - data << r.TOTALPRICE - data << r.PAYTYPE - data << r.FLOORNUM - data << r.FLOORCNT - data << r.BUILDTYPE - data << r.HOUSESTRU - data << r.BUILDSTRU - data << r.BUILDAREA - data << r.LIVINGAREA - data << r.HOUSESTYLE - data << r.ROOMCNT - data << r.LIVINGROOMCNT - data << r.KITCHENCNT - data << r.BATHROOMCNT - data << r.HOUSEASPECT - data << r.FITMENT - data << r.IFELEVATOR - data << r.ELEVATORHOUSE - data << r.PUBLISHTIME - data << r.EXPIRETIME - data << r.IFFIRST - data << r.DATASOURCE - data << r.AGENCYID - data << r.AGENCYNAME - data << r.PUBLISHER - data << r.PHONE - data << "" - data << r.REMARK - data << r.CREATETIME - data << r.UPDATETIME - data << r.SOURCECODE - data << r.ATTACH - allRows << data - if(allRows.size()%200000==0){ - FileUtils.batchCreateFile(allRows, fileName, headers, "utf-8", true); - allRows.clear() - } - }); + def allRows = [] + if(new_dists){ + def newstr = "('"+new_dists.join("','")+"')" + def sql1 = "select CITYID,FORSALEID,PROPCODE,CITYNAME,DISTID,DISTNAME,COMMID,COMMNAME, BUILDID,BUILDNO, BUILDNAME,UNITID,UNITNO,UNITNAME,HOUSEID,ADDRESS,BUILDYEAR,PROPTYPE,PROPYEARS,UNITPRICE,TOTALPRICE,PAYTYPE,FLOORNUM,FLOORCNT,\n" + + " BUILDTYPE, HOUSESTRU,BUILDSTRU,BUILDAREA,LIVINGAREA,HOUSESTYLE,ROOMCNT,LIVINGROOMCNT,KITCHENCNT, BATHROOMCNT,HOUSEASPECT,FITMENT,IFELEVATOR,ELEVATORHOUSE,to_char(PUBLISHTIME,'yyyy-mm-dd hh24:mi:ss') as PUBLISHTIME,to_char(EXPIRETIME,'yyyy-mm-dd hh24:mi:ss') as EXPIRETIME,\n" + + " IFFIRST,DATASOURCE,AGENCYID,AGENCYNAME,PUBLISHER,PHONE,DESCRIPTION,REMARK,to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE,ATTACH from bigdata_forsale_gj " + + "where cityId='${cityCode}' and publishtime>=to_date('${publishDate}','yyyy-MM-dd') and distid not in ${newstr}"; + def rets1 = getHouseDatas(sql1) + allRows.addAll(rets1) + }else{ + def sql = "select CITYID,FORSALEID,PROPCODE,CITYNAME,DISTID,DISTNAME,COMMID,COMMNAME, BUILDID,BUILDNO, BUILDNAME,UNITID,UNITNO,UNITNAME,HOUSEID,ADDRESS,BUILDYEAR,PROPTYPE,PROPYEARS,UNITPRICE,TOTALPRICE,PAYTYPE,FLOORNUM,FLOORCNT,\n" + + " BUILDTYPE, HOUSESTRU,BUILDSTRU,BUILDAREA,LIVINGAREA,HOUSESTYLE,ROOMCNT,LIVINGROOMCNT,KITCHENCNT, BATHROOMCNT,HOUSEASPECT,FITMENT,IFELEVATOR,ELEVATORHOUSE,to_char(PUBLISHTIME,'yyyy-mm-dd hh24:mi:ss') as PUBLISHTIME,to_char(EXPIRETIME,'yyyy-mm-dd hh24:mi:ss') as EXPIRETIME,\n" + + " IFFIRST,DATASOURCE,AGENCYID,AGENCYNAME,PUBLISHER,PHONE,DESCRIPTION,REMARK,to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE,ATTACH from bigdata_forsale_gj where cityId='${cityCode}' and publishtime>=to_date('${publishDate}','yyyy-MM-dd')"; + allRows = getHouseDatas(sql) + } if(allRows.size()>0){ FileUtils.batchCreateFile(allRows, fileName, headers, "utf-8", true); } + } + if(new_dists){//补充被修区域的数据 + def newstr = "('"+new_dists.join("','")+"')" + def sql2 = "select CITYID,FORSALEID,PROPCODE,CITYNAME,DISTID,DISTNAME,COMMID,COMMNAME, BUILDID,BUILDNO, BUILDNAME,UNITID,UNITNO,UNITNAME,HOUSEID,ADDRESS,BUILDYEAR,PROPTYPE,PROPYEARS,UNITPRICE,TOTALPRICE,PAYTYPE,FLOORNUM,FLOORCNT,\n" + + " BUILDTYPE, HOUSESTRU,BUILDSTRU,BUILDAREA,LIVINGAREA,HOUSESTYLE,ROOMCNT,LIVINGROOMCNT,KITCHENCNT, BATHROOMCNT,HOUSEASPECT,FITMENT,IFELEVATOR,ELEVATORHOUSE,to_char(PUBLISHTIME,'yyyy-mm-dd hh24:mi:ss') as PUBLISHTIME,to_char(EXPIRETIME,'yyyy-mm-dd hh24:mi:ss') as EXPIRETIME,\n" + + " IFFIRST,DATASOURCE,AGENCYID,AGENCYNAME,PUBLISHER,PHONE,DESCRIPTION,REMARK,to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME, to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME,SOURCECODE,ATTACH " + + "from bigdata_forsale_gj where distid in ${newstr}" + def rets2 = getHouseDatas(sql2) + if(rets2.size()>0){ + FileUtils.batchCreateFile(rets2, fileName, headers, "utf-8", true); + } } println "BIGDATA_FORSALE_GJ 数据文件输出完成......" CcbFtpUtils.ftpUpload(null, fileName, curDate) println "BIGDATA_FORSALE_GJ 上传Ftp完成......" } + def getHouseDatas(sql){ + def allRows = [] + def index = 0 + sqlInstance.eachRow(sql,{r-> + index = index+1 + println r.CITYNAME +" "+index + def data = [] + data << r.CITYID + data << r.FORSALEID + data << r.PROPCODE + data << r.CITYNAME + data << r.DISTID + data << r.DISTNAME + data << r.COMMID + data << r.COMMNAME + data << r.BUILDID + data << r.BUILDNO + data << r.BUILDNAME + data << r.UNITID + data << r.UNITNO + data << r.UNITNAME + data << r.HOUSEID + data << r.ADDRESS + data << r.BUILDYEAR + data << r.PROPTYPE + data << r.PROPYEARS + data << r.UNITPRICE + data << r.TOTALPRICE + data << r.PAYTYPE + data << r.FLOORNUM + data << r.FLOORCNT + data << r.BUILDTYPE + data << r.HOUSESTRU + data << r.BUILDSTRU + data << r.BUILDAREA + data << r.LIVINGAREA + data << r.HOUSESTYLE + data << r.ROOMCNT + data << r.LIVINGROOMCNT + data << r.KITCHENCNT + data << r.BATHROOMCNT + data << r.HOUSEASPECT + data << r.FITMENT + data << r.IFELEVATOR + data << r.ELEVATORHOUSE + data << r.PUBLISHTIME + data << r.EXPIRETIME + data << r.IFFIRST + data << r.DATASOURCE + data << r.AGENCYID + data << r.AGENCYNAME + data << r.PUBLISHER + data << r.PHONE + data << "" + data << r.REMARK + data << r.CREATETIME + data << r.UPDATETIME + data << r.SOURCECODE + data << r.ATTACH + allRows << data +// if(allRows.size()%200000==0){ +// FileUtils.batchCreateFile(allRows, fileName, headers, "utf-8", true); +// allRows.clear() +// } + }); + return allRows + } + def exportAvmEvaluationGJNB(yearMonth){ def sql = "select ID,CITYID,CITYNAME, YEAR_MONTH, COMMUNITY_NUM, HAS_PRICE_COMMUNITY_NUM, PRICE_COVERAGE, ARTIFICIAL_CALC_NUM, ARTIFICIAL_CALC_COVERAGE, SAMPLE_CALC_NUM, SAMPLE_CALC_COVERAGE, \n" + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy index 2476de4c3..045cd0a82 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/GuiDingPriceBatch.groovy @@ -44,7 +44,7 @@ class GuiDingPriceBatch extends BaseBatch{ def distCodeMap = CcbCommonUtils.findAllDistrictCodeValue(city) //添加自己库中的人工指导价 - def prices = CcbCommonUtils.findPersonPrice(city, "2022-04-1", "2022-05-1") + def prices = CcbCommonUtils.findPersonPrice(city, "2022-05-1", "2022-06-1") if(prices){ def distMap = getDistrictMap(city) def rets = createCityDatas(cityCodeDatas, distCodeMap, distMap, prices) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy index b0476927d..9985dd73f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/LoadGuide.groovy @@ -23,7 +23,8 @@ class LoadGuide { } def run(){ - addPersonGuided("D:\\数据\\建行\\人工指导价更新.xlsx") +// addName("D:\\数据\\建行\\房产估值\\人工指导价更新.xlsx") + addPersonGuided("D:\\数据\\建行\\房产估值\\人工指导价更新.xlsx") // match("D:\\数据\\建行\\房产估值\\指导价\\西安指导价2-103.xlsx") // saveDongGuangPrice("D:\\数据\\建行\\房产估值\\指导价\\东莞指导价218.xlsx") @@ -38,6 +39,20 @@ class LoadGuide { } + def addName(filename){ + ExcelUtils.multiThreadingModify(filename, { d -> + if(d['A']){ + def dist = CommonDatautils.findDistrictById(d['A'].toString()) + if(dist){ + d['B'] = dist.city + d['C'] = dist.region + d['D'] = dist.name + } + } + + }) + } + def addPersonGuided(filename){ ExcelUtils.modify(filename, { d -> def city = d['B'] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/StagingDistrictBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/StagingDistrictBatch.groovy index 532a96c43..3ac7f9a28 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/StagingDistrictBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/StagingDistrictBatch.groovy @@ -34,6 +34,10 @@ class StagingDistrictBatch extends BaseBatch{ println city +" 分期量:"+rets.size() } + def fileName = "/home/goojia/ccb/COMMUNITY_STAGING_GJ.dat" + if(CommonDatautils.isWindow()){ + fileName = "d:\\数据\\建行\\房产估值\\数据文件\\txt\\COMMUNITY_STAGING_GJ.dat" + } def results =[] def headers = []//["分期ID","小区ID","小区主期ID","备注","创建时间","更新时间","来源公司"] @@ -41,7 +45,7 @@ class StagingDistrictBatch extends BaseBatch{ results.addAll(rows) //ExcelUtils.write("d:\\数据\\建行\\房产估值\\数据文件\\excel\\COMMUNITY_STAGING_GJ.xlsx", results, "数据") - FileUtils.batchCreateFile(rows, "d:\\数据\\建行\\房产估值\\数据文件\\txt\\COMMUNITY_STAGING_GJ.dat",headers, "utf-8", false); + FileUtils.batchCreateFile(rows, fileName,headers, "utf-8", false); } 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 9af443b40..41a0fe686 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 @@ -30,11 +30,11 @@ import java.util.regex.*; //def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.100:31521:orcl", // "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") -def sqlInstance236 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +//def sqlInstance236 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") -def sqlInstance94 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.94:1521:orcl", - "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") +//def sqlInstance94 = Sql.newInstance("jdbc:oracle:thin:@192.168.0.94:1521:orcl", +// "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") @@ -45,8 +45,20 @@ DBCollection POLYLINECOLL = MongoUtils.getCollectionByAuth20190102("fangjia_craw def offlineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.136:28017"; def DBCollection youda_esfhouse_coll = MongoUtils.getCollectionByName2("business", "res_esfdealprice", offlineUrl) +def url = "https://sh.anjuke.com" +def s = DataHandleUtils.findMatchPattern(name, "https://\\w+.anjuke.com") +println s +//def districts = CommonDatautils.findAllFiledDistrict("district", "南宁") +//for(def d : districts){ +// println d.name +//} +//def dists = CommonDatautils.findAllDistrictByCity("南宁", "district", ["city","region","name"]) +//for(def d : dists){ +// def o = CommonDatautils.findDistrictById(d._id.toString()) +// println o._id.toString() + " "+o.name +//} //def citys = CcbCommonUtils.citys; //def rows = [] @@ -236,16 +248,16 @@ def youdaDeal(youda_esfhouse_coll, def city, def region, def name, def area, def // println d // } //},0) -def rows = findTradePpeData(sqlInstance236) -// rows.unique() -def map=findTradeDetail(sqlInstance236,null) -def datas=[] -map.each{key,row-> - if(!rows.contains(key)){ - datas< +// if(!rows.contains(key)){ +// datas< +//ExcelUtils.modify("D:\\数据\\建行\\房产估值\\小区\\删除重复小区.xlsx",{d-> // if(d['A']){ -// def region = d['B'] -// def newRegion = RegionData.formatRegion(d['A'], region) -// if(newRegion) { -// def dist = CommonDatautils.findDistrict(d['A'], newRegion, d['C'], "district") +//// def region = d['B'] +//// def newRegion = RegionData.formatRegion(d['A'], region) +//// if(newRegion) { +//// def dist = CommonDatautils.findDistrict(d['A'], newRegion, d['C'], "district") +// def dist = CommonDatautils.findDistrictById(d['A']) // if(dist){ // def udata = new BasicDBObject() // udata.put("name_cat", 11) +// udata.put("status", 1) // udata.put("m_date",new Date()) // // def q = new BasicDBObject() @@ -331,7 +345,7 @@ ExcelUtils.write("D:\\ // }else{ // println d // } -// } +//// } // } //},0) 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 d1cc4209b..fcfd4c0bd 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 @@ -22,9 +22,9 @@ import java.util.concurrent.ConcurrentHashMap @BatchOwner(Watcher.GaoJuan) class ThirdPartyPriceBatch extends BaseBatch { - def sDate= 202204//Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); - def startDate = 202202 - def endDate = 202204 + def sDate= 202205//Integer.parseInt(DateUtils.addMonth(DateUtils.formatDateByPattern(new Date(), "yyyyMM"), -1, "yyyyMM")); + def startDate = 202203 + def endDate = 202205 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") 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 3b3e6a7c5..fc73e4867 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 @@ -75,13 +75,13 @@ class TradeStatLog { def run(){ def citys = CcbCommonUtils.citys; def rets = [] - rets << ["城市","2月总量","3月总量","4月总量","占比","贝壳","链家", "我爱我家","房天下","中原"] + rets << ["城市","3月总量","4月总量","5月总量","占比","贝壳","链家", "我爱我家","房天下","中原"] def sources = ["贝壳找房","链家在线", "我爱我家","房天下","中原地产"] //def startDate = "2021-05-01" - def startDate = "2022-02-01" - def date = "2022-03-01" - def endDate = "2022-04-01" - def newDate = "2022-05-01" + def startDate = "2022-03-01" + def date = "2022-04-01" + def endDate = "2022-05-01" + def newDate = "2022-06-01" for(def city : citys){ def lastMonthCount = findTradesCount(city, null, DateUtils.parseFromTightByPattern(startDate,"yyyy-MM-dd"), DateUtils.parseFromTightByPattern(date,"yyyy-MM-dd")) @@ -131,7 +131,7 @@ class TradeStatLog { } - ExcelUtils.write("D:\\数据\\建行\\房产估值\\成交\\2022-04成交统计.xlsx", rets, "数据") + ExcelUtils.write("D:\\数据\\建行\\房产估值\\成交\\2022-05成交统计.xlsx", rets, "数据") println "表格生成完成" } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy index 98d755434..2ee14adc4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/CcbDistrictToDB.groovy @@ -16,6 +16,7 @@ import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.util.GeoHelper +import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import java.util.concurrent.CopyOnWriteArrayList @@ -27,9 +28,20 @@ class CcbDistrictToDB { // task.run() // task.run1() // task.meituanRun() - task.meituanSqrentRun() +// task.meituanSqrentRun() // task.updateDistrict() // task.updateDongguangRegion() + task.houseDistToDB() +// task.sendCalPrice() + } + + def sendCalPrice(){ + def dists = CommonDatautils.findAllDistrictByCity("东莞", "district", ["city","region","name","estate_type2"]) + def startDate = DateUtils.parseFromTightYYYYMMDD("2022-05-27") + def endDate = DateUtils.parseFromTightYYYYMMDD("2022-06-14") + for(def data : dists){ + addPrice(data, startDate, endDate) + } } def updateDongguangRegion(){ @@ -80,6 +92,160 @@ class CcbDistrictToDB { } } + + def houseDistToDB(){ + def index = 0 + def addIndex = 0 + def keys = new CopyOnWriteArrayList() + ExcelUtils.modify("D:\\数据\\建行\\二期\\新增小区_2155.xlsx", { d -> + index++ + if(d['A']){ + def city = d['A'] + def mapInfo = getStreetInfo(d['L']+","+d['M']) + def newRegion = null + if(mapInfo){ + if(d['A']=="东莞"){ + newRegion = mapInfo.township + }else{ + newRegion = mapInfo.district + } + } + + newRegion = RegionData.formatRegion(city, newRegion) + + if(newRegion && newRegion.contains(d['B'])){ + def name = nameFileter(d['E']) + def alias = [] + if(d['C']!=name){ + alias << d['C'] + } + + + def estateType2 = "普通住宅" + if(name){ + if(name.contains("别墅")){ + estateType2 = "别墅" + }else if(name.contains("商住")){ + estateType2 = "商住" + }else{ + def type = d['K'] + if(type){ + if(type.contains("别墅")){ + estateType2 = "别墅" + }else if(type.contains("商住")){ + estateType2 = "商住" + } + } + } + } + def formatAddress = null + if (d['J']) { + formatAddress = AddressUtil.formatAddress(d['A'], d['J']) + } + + Long glat = null + Long glng = null + Long blat = null + Long blng = null + + if (d['M']) { + glat = d['M'].toString().toDouble() * 10000000000L + glng = d['L'].toString().toDouble() * 10000000000L + def baidu = BaiDuApiUtils.geoconv(d['L'].toString().toDouble(), d['M'].toString().toDouble(), 3) + blng = baidu.x * 10000000000L + blat = baidu.y * 10000000000L + } + + def key = city + "##" + newRegion + "##" + name + if (name && !keys.contains(key)) { + def dist = CommonDatautils.findDistrict(city, newRegion, name, "district") + if (!dist) { + addIndex++ + keys << key + def data = new BasicDBObject(); + data.put("name_cat", 0) + data.put("status", 0) + data.put("cat", "district") + data.put("c_date", new Date()) + data.put("m_date", new Date()) + data.put("city", city) + data.put("region", newRegion) + data.put("name", name) + data.put("estate_type2", estateType2) + data.put("address", formatAddress) + if(alias){ + data.put("alias", alias) + } + 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 addIndex + " " + data +// def stop = false +// while (!stop) { +// if (data._id.toString()) { +// addPrice(data) +// stop = true; +// } +// } + }else{ + if(alias){ + def dbAlias = dist.alias + if(!dbAlias){ + def data = new BasicDBObject(); + data.put("alias", alias) + DbUtils.seaweed.update(new BasicDBObject('_id',dist._id),new BasicDBObject('$set',data)) + }else{ + for(def n : alias){ + if(!dbAlias.contains(n)){ + dbAlias << n + } + } + + def data = new BasicDBObject(); + data.put("alias", dbAlias) + DbUtils.seaweed.update(new BasicDBObject('_id',dist._id),new BasicDBObject('$set',data)) + } + } + } + }else{ + if(alias){ + def dist = CommonDatautils.findDistrict(city, newRegion, name, "district") + if (dist) { + def dbAlias = dist.alias + if(!dbAlias){ + def data = new BasicDBObject(); + data.put("alias", alias) + DbUtils.seaweed.update(new BasicDBObject('_id',dist._id),new BasicDBObject('$set',data)) + }else{ + for(def n : alias){ + if(!dbAlias.contains(n)){ + dbAlias << n + } + } + + def data = new BasicDBObject(); + data.put("alias", dbAlias) + DbUtils.seaweed.update(new BasicDBObject('_id',dist._id),new BasicDBObject('$set',data)) + } + } + } + + } + }else{ + println d['A']+" "+d['B']+" "+d['C'] +" 经纬度所在区:"+newRegion + } + } + }); + } + def meituanSqrentRun(){ def index = 0 ExcelUtils.modify("D:\\数据\\美团\\美团待入库.xlsx", { d -> @@ -228,11 +394,8 @@ class CcbDistrictToDB { } - def addPrice(dist){ - def startDate = DateUtils.parseFromTightYYYYMMDD("2022-05-01") - def endDate = DateUtils.parseFromTightYYYYMMDD("2022-05-24") + def addPrice(dist, startDate, endDate){ def weekends = DateUtils.getWeekendBetweenDates(startDate, endDate) - for(def weekend : weekends){ CommonUtils.recalculationAverage(dist.city, dist.region, dist.name, dist.estate_type2, weekend,false,0) } @@ -521,4 +684,30 @@ class CcbDistrictToDB { return null } + + def getLocationInfo(def city, def address){ + def gloJson = GaoDeApiUtils.geo(city, address) + if(gloJson) { + def glocation = null + if (gloJson && gloJson.get("geocodes")) { + def geocodes = gloJson.get("geocodes") + glocation = geocodes.get(0).location + } + return glocation + } + return null + } + + + def getStreetInfo(def glocation){ + def township = null + if(glocation){ + def jsonObject = GaoDeApiUtils.geocode(glocation) + if(jsonObject && jsonObject.regeocode) { + def addressComponent = jsonObject.regeocode.addressComponent + return addressComponent; + } + } + return null; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy index afa2233b6..99e779ac6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/data/DistrictMarge.groovy @@ -17,11 +17,11 @@ class DistrictMarge { //task.run() // task.repeatAddress() // task.removeDist() - task.updateAddress() -// task.addMappingAlias() +// task.updateAddress() + task.addMappingAlias() } def updateAddress(){ - ExcelUtils.multiThreadingModify("D:\\数据\\建行\\更新小区地址.xlsx", { d -> + ExcelUtils.multiThreadingModify("D:\\数据\\建行\\更新小区地址_0608.xlsx", { d -> if (d['A']) { def region = d['B'].trim() def newRegion = RegionData.formatRegion(d['A'], region) @@ -41,7 +41,7 @@ class DistrictMarge { } def removeDist(){ - ExcelUtils.multiThreadingModify("D:\\数据\\建行\\删除小区.xlsx", { d -> + ExcelUtils.modify("D:\\数据\\建行\\删除小区数据_245_0608.xlsx", { d -> if (d['A']) { def region = d['B'] def newRegion = RegionData.formatRegion(d['A'], region) @@ -52,6 +52,8 @@ class DistrictMarge { udata.put("status", 1) udata.put("m_date", new Date()) DbUtils.seaweed.update(new BasicDBObject('_id', dist._id),new BasicDBObject('$set', udata)) + }else{ + println d['A']+" "+d['C']+" 不存在" } }else{ println d['A'] + " 格式化失败 "+d['B'] @@ -62,7 +64,7 @@ class DistrictMarge { def addMappingAlias(){ def index = 0 - ExcelUtils.multiThreadingModify("D:\\数据\\建行\\新增映射别名.xlsx", { d -> + ExcelUtils.multiThreadingModify("D:\\数据\\建行\\新增映射别名_0608.xlsx", { d -> index ++ if (d['A']) { def region = d['B'].trim() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy index d81974c8b..e50059409 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy @@ -25,8 +25,9 @@ class ExportDistrictRongHe extends BaseBatch{ @Override void process(Object args) { def curDate = DateUtils.formatDateByPattern(new Date()+1, "yyyyMMdd") + def new_dists = []//["350604","350605","410307","410308","450181"] //按天导(每天一个文件夹) - exportBigdataDealFJW2(curDate, DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date()+1,-1), "yyyy-MM-dd")) + exportBigdataDealFJW2(curDate, DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date()+1,-1), "yyyy-MM-dd"), new_dists) if(curDate.toString().endsWith("10")){ exportBigdataCommunityGJRH() @@ -459,7 +460,7 @@ class ExportDistrictRongHe extends BaseBatch{ } - def exportBigdataDealFJW2(curDate, dealdate){ + def exportBigdataDealFJW2(curDate, dealdate, new_dists){ def startDateStr = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(DateUtils.parseFromTightYYYYMMDD(dealdate)), "yyyy-MM-dd") def endDateStr = DateUtils.formatDateByPattern(DateUtils.getLastDayOfMonth(DateUtils.parseFromTightYYYYMMDD(dealdate)), "yyyy-MM-dd") @@ -472,86 +473,107 @@ class ExportDistrictRongHe extends BaseBatch{ def allRows = [] if(curDate.toString().endsWith("28")){ - def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ where dealdate>=to_date('${startDateStr}','yyyy-MM-dd') and dealdate<=to_date('${endDateStr}','yyyy-MM-dd')";//CITYID='${cityCode}' and - sqlInstance.eachRow(sql,{r-> - def data = [] - data << r.CITYID - data << r.DEALID - data << r.CITYNAME - data << r.DISTID - data << r.DISTNAME - data << r.STREET - data << r.STREETNO - data << r.COMMID - data << r.COMMNAME - data << r.BUILDID - data << r.BUILDNO - data << r.BUILDNAME - data << r.UNITID - data << r.UNITNO - data << r.UNITNAME - data << r.HOUSEID - data << r.ADDRESS - data << r.BUILDYEAR - data << r.PROPTYPE - data << r.PROPYEARS - data << r.PERIODNUM - data << r.FLOORNUM - data << r.FLOORTYPE - data << r.FLOORCNT - if(r.BUILDTYPE){ - def arrs = r.BUILDTYPE.replace("[","").replace("]","").split(",") - data << arrs[0].trim() - }else{ - data << '' - } - data << r.BUILDSTRU - data << r.BUILDAREA - data << r.LIVINGAREA - data << r.HOUSESTYLE - data << r.ROOMCNT - data << r.LIVINGROOMCNT - data << r.KITCHENCNT - data << r.BATHROOMCNT - data << r.HOUSEUSE - data << r.HOUSESTRU - data << r.HOUSEASPECT - data << r.FITMENT - data << r.EVALUATENO - data << r.DEALUNITPRICE - data << r.DEALTOTALPRICE - data << r.DECLAREPRICE - data << r.EVALUATEPRICE - data << r.CONTRACTNO - data << r.DEALDATE - data << r.DEALTYPE - data << r.PAYTYPE - data << r.DEALPERIOD - data << r.IFELEVATOR - data << r.COMPAREAGARDEN - data << r.COMPAREATERRACE - data << r.COMPAREABALCONY - data << r.COMPAREABAYWINDOW - data << r.COMPAREAATTIC - data << r.COMPAREAGARAGE - data << r.COMPAREABASEMENT - data << r.COMPAREAOTHER - data << r.DATASOURCE - data << r.AGENCYID - data << r.AGENCYNAME - data << r.REMARK - data << r.CREATETIME1 - data << r.UPDATETIME1 - data << r.SOURCECODE - data << r.WORKDATE - allRows << data - }); + if(new_dists){ + def newstr = "('"+new_dists.join("','")+"')" + def sql1 = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ " + + "where dealdate>=to_date('${startDateStr}','yyyy-MM-dd') and dealdate<=to_date('${endDateStr}','yyyy-MM-dd') and" + + " distid not in ${newstr} ";//CITYID='${cityCode}' and + def rets1 = createDeal(sql1) + + def sql2 = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ " + + " where distid in ${newstr}" + def rets2 = createDeal(sql2) + allRows.addAll(rets1) + allRows.addAll(rets2) + }else{ + def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ where dealdate>=to_date('${startDateStr}','yyyy-MM-dd') and dealdate<=to_date('${endDateStr}','yyyy-MM-dd')";//CITYID='${cityCode}' and + allRows = createDeal(sql) + } } FileUtils.batchCreateFile(allRows, fileName, [], "utf-8", false); CcbFtpUtils.ftpUpload("rh",fileName, curDate) println "BIGDATA_DEAL_FJW 上传Ftp完成......${endDateStr}" } + def createDeal(sql){ + def allRows = [] + sqlInstance.eachRow(sql,{r-> + def data = [] + data << r.CITYID + data << r.DEALID + data << r.CITYNAME + data << r.DISTID + data << r.DISTNAME + data << r.STREET + data << r.STREETNO + data << r.COMMID + data << r.COMMNAME + data << r.BUILDID + data << r.BUILDNO + data << r.BUILDNAME + data << r.UNITID + data << r.UNITNO + data << r.UNITNAME + data << r.HOUSEID + data << r.ADDRESS + data << r.BUILDYEAR + data << r.PROPTYPE + data << r.PROPYEARS + data << r.PERIODNUM + data << r.FLOORNUM + data << r.FLOORTYPE + data << r.FLOORCNT + if(r.BUILDTYPE){ + def arrs = r.BUILDTYPE.replace("[","").replace("]","").split(",") + data << arrs[0].trim() + }else{ + data << '' + } + data << r.BUILDSTRU + data << r.BUILDAREA + data << r.LIVINGAREA + data << r.HOUSESTYLE + data << r.ROOMCNT + data << r.LIVINGROOMCNT + data << r.KITCHENCNT + data << r.BATHROOMCNT + data << r.HOUSEUSE + data << r.HOUSESTRU + data << r.HOUSEASPECT + data << r.FITMENT + data << r.EVALUATENO + data << r.DEALUNITPRICE + data << r.DEALTOTALPRICE + data << r.DECLAREPRICE + data << r.EVALUATEPRICE + data << r.CONTRACTNO + data << r.DEALDATE + data << r.DEALTYPE + data << r.PAYTYPE + data << r.DEALPERIOD + data << r.IFELEVATOR + data << r.COMPAREAGARDEN + data << r.COMPAREATERRACE + data << r.COMPAREABALCONY + data << r.COMPAREABAYWINDOW + data << r.COMPAREAATTIC + data << r.COMPAREAGARAGE + data << r.COMPAREABASEMENT + data << r.COMPAREAOTHER + data << r.DATASOURCE + data << r.AGENCYID + data << r.AGENCYNAME + data << r.REMARK + data << r.CREATETIME1 + data << r.UPDATETIME1 + data << r.SOURCECODE + data << r.WORKDATE + allRows << data + }); + + return allRows; + } + def exportAllBigdataDealFJW(){ def sql = "select CITYID, DEALID, CITYNAME, DISTID, DISTNAME, STREET, STREETNO, COMMID, COMMNAME, BUILDID, BUILDNO, BUILDNAME, UNITID, UNITNO, UNITNAME, HOUSEID, ADDRESS, BUILDYEAR, PROPTYPE, PROPYEARS, PERIODNUM, FLOORNUM, FLOORTYPE, FLOORCNT, BUILDTYPE, BUILDSTRU, BUILDAREA, LIVINGAREA, HOUSESTYLE, ROOMCNT, LIVINGROOMCNT, KITCHENCNT, BATHROOMCNT, HOUSEUSE, HOUSESTRU, HOUSEASPECT, FITMENT, EVALUATENO, DEALUNITPRICE, DEALTOTALPRICE, DECLAREPRICE, EVALUATEPRICE, CONTRACTNO, to_char(DEALDATE,'yyyy-mm-dd') as DEALDATE, DEALTYPE, PAYTYPE, DEALPERIOD, IFELEVATOR, COMPAREAGARDEN, COMPAREATERRACE, COMPAREABALCONY, COMPAREABAYWINDOW, COMPAREAATTIC, COMPAREAGARAGE, COMPAREABASEMENT, COMPAREAOTHER, DATASOURCE, AGENCYID, AGENCYNAME, REMARK, CREATETIME, UPDATETIME, to_char(CREATETIME,'yyyy-mm-dd hh24:mi:ss') as CREATETIME1,to_char(UPDATETIME,'yyyy-mm-dd hh24:mi:ss') as UPDATETIME1,SOURCECODE,WORKDATE from BIGDATA_DEAL_GJ where DEALDATE= 0) { + + out.write(buffer, 0, n); + + } + + } catch (Exception e) { + + e.printStackTrace(); + + } + + return out.toByteArray(); + + } + + public static String uncompressToString(byte[] bytes, String encoding) { + + if (bytes == null || bytes.length == 0) { + + return null; + + } + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + ByteArrayInputStream ins = new ByteArrayInputStream(bytes); + + try { + + GZIPInputStream ungzip = new GZIPInputStream(ins); + + byte[] buffer = new byte[256]; + + int n; + + while ((n = ungzip.read(buffer)) >= 0) { + + out.write(buffer, 0, n); + + } + + return out.toString(encoding); + + } catch (Exception e) { + + e.printStackTrace(); + + } + + return null; + + } + + public static String uncompressToString(byte[] bytes) { + + return uncompressToString(bytes, GZIP_ENCODE_UTF_8); + + } + + /** + * 字符串转化成为16进制字符串 + * @param s + * @return + */ + public static String strTo16(String s) { + String str = ""; + for (int i = 0; i < s.length(); i++) { + int ch = (int) s.charAt(i); + String s4 = Integer.toHexString(ch); + str = str + s4; + } + return str; + } + + public static void main(String[] args) throws IOException { + + String s = "123"; + println "result: "+strTo16(s) + + System.out.println("字符串长度:"+s.length()); + + println compress(s) + + System.out.println("解压后:"+uncompress(compress(s)).length); + + System.out.println("解压字符串后::"+uncompressToString(compress(s)).length()); + + } + +} + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/MeituanStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/MeituanStat.groovy new file mode 100644 index 000000000..aff0e94e9 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/chongqing/MeituanStat.groovy @@ -0,0 +1,429 @@ +package com.fangjia.script.chongqing + +import com.fangjia.core.util.DataUtil +import com.fangjia.core.util.HttpRequest +import com.fangjia.httpclient.UserAgents +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.thirdPriceCrawl.CrawalDBUtil +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.JacksonUtil +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import net.bytebuddy.description.type.TypeDescription +import org.apache.commons.lang.StringUtils + +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong +import java.util.zip.GZIPInputStream + + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; + + +class MeituanStat { + + final static DBCollection CITY_INFO_CONN = MongoUtils.getCollectionByName("fangjia_data_ana", "city_info", MongoUtils.MongoDB_Domain_mongo); + + private static DBCollection on_line = MongoUtils.getCollectionByName("fangjia", "district_facilitys", MongoUtils.MongoDB_Domain_mongo) + + def arroundColl = CrawalDBUtil.getArroundTempCol(); + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30) + + static main(args) { + def task = new MeituanStat() + task.run() +// task.run1() +// task.run2() + } + + def run(){ + def hexStr = "\\x1f\\x8b\\x08\\x00\\x17U\\xa4b\\x02\\xff342\\x06\\x00\\xd2cH\\x88\\x03\\x00\\x00\\x00" + println URLDecoder.decode(hexStr.replaceAll("\\\\x", "%"), StandardCharsets.UTF_8.name()) + + println URLDecoder.decode(hexStr.replaceAll("\\\\x", "%"), "utf-8"); +// def s = com.fangjia.core.util.DataUtil.zip("123") +// String str = new String(s, "utf-8"); +// def r = com.fangjia.core.util.DataUtil.unzips(s) +// println s +// println str +// println r +// def citys = ["北京","上海","保定","成都","广州","杭州","南京","深圳","天津","武汉","西安","重庆","吉林","常州","大连","东莞","佛山","福州","贵阳","哈尔滨","合肥","济南","昆明","南宁","宁波","青岛","厦门","沈阳","石家庄","苏州","太原","温州","无锡","长春","长沙","郑州","鞍山","包头","大庆","大同","海口","邯郸","衡阳","呼和浩特","湖州","淮安","惠州","济宁","嘉兴","江门","金华","荆州","兰州","连云港","临沂","柳州","洛阳","绵阳","南昌","南通","南阳","莆田","秦皇岛","泉州","三亚","汕头","绍兴","台州","泰州","唐山","威海","潍坊","乌鲁木齐","芜湖","襄阳","徐州","烟台","盐城","扬州","宜昌","银川","岳阳","湛江","镇江","中山","珠海","株洲","淄博"] +// def path = "D:\\数据\\美团\\美团88个城市统计.xlsx" +// def rets =[] +// rets << ["城市", "楼盘总量"] +// for(def c : citys){ +// def count = CommonDatautils.findAllDistrictCount("district", c) +// rets << [c, count] +// } +// ExcelUtils.write(path, rets, "总量") + } + + def run1(){ + def citys = ["北京","上海","保定","成都","广州","杭州","南京","深圳","天津","武汉","西安","重庆","吉林","常州","大连","东莞","佛山","福州","贵阳","哈尔滨","合肥","济南","昆明","南宁","宁波","青岛","厦门","沈阳","石家庄","苏州","太原","温州","无锡","长春","长沙","郑州","鞍山","包头","大庆","大同","海口","邯郸","衡阳","呼和浩特","湖州","淮安","惠州","济宁","嘉兴","江门","金华","荆州","兰州","连云港","临沂","柳州","洛阳","绵阳","南昌","南通","南阳","莆田","秦皇岛","泉州","三亚","汕头","绍兴","台州","泰州","唐山","威海","潍坊","乌鲁木齐","芜湖","襄阳","徐州","烟台","盐城","扬州","宜昌","银川","岳阳","湛江","镇江","中山","珠海","株洲","淄博"] + def path = "D:\\数据\\美团\\美团88个城市统计.xlsx" + def rets =[] + rets << ["城市","ID","区域","小区名","小区别名","地址","地址别名","物业类型","建筑类型","经度","纬度","板块","开发商","物业公司", + "环线","商圈","楼栋总数","户数","物业费","占地面积","建筑面积","容积率","绿化率","停车位","停车位(描述)","产权年限", + "产权性质","建成年代","开工时间","开盘时间","竣工时间","交房时间","装修情况","建筑结构","周边配套","交通状况","相关信息", + "描述","售楼地址","售楼电话","折扣信息","预售许可证","房产评级","房产均价","租金均价"] + for(def c : citys){ + def dists = CommonDatautils.findAllDistrictByCity(c, "district", ["lat","lng","loudong_count","mobile","car_site","fitment","relate_info","description","sell_address","discount","facilities","traffic","region","name"]) + def rMap = statFacilices(dists, c) + def obj = findFieldCov(c) + def rentCount = CommonDatautils.findSqmetreRents(c, DateUtils.parseFromTightByPattern("2022-05-31","yyyy-MM-dd")) + def block = obj.district_detail.block?obj.district_detail.block*100:'' + def alias = obj.district_detail.alias?obj.district_detail.alias*100:'' + def address= obj.district_detail.address?obj.district_detail.address*100:'' + def addrAlias = obj.district_detail.addrAlias?obj.district_detail.addrAlias*100:'' + def estateType2 = obj.district_detail.estateType2?obj.district_detail.estateType2*100:'' + def buildType = obj.district_detail.buildType?obj.district_detail.buildType*100:'' + def lng = obj.district_detail.lng?obj.district_detail.lng*100:'' + def developer = obj.district_detail.developer?obj.district_detail.developer*100:'' + def estateCompany = obj.district_detail.estateCompany?obj.district_detail.estateCompany*100:'' + def loopLineInfo = obj.district_detail.loopLineInfo?obj.district_detail.loopLineInfo*100:'' + def businessQuarter = obj.district_detail.businessQuarter?obj.district_detail.businessQuarter*100:'' + def loudong = '' + def loudongcount = getCount(dists,"loudong_count") + if(obj.existing_district_count && loudongcount){ + def pre = loudongcount*100/obj.existing_district_count + loudong = DataHandleUtils.getDoubleRound(2, pre) + } + + def householdCount = obj.district_detail.householdCount?obj.district_detail.householdCount*100:'' + def estateCharge = obj.district_detail.estateCharge?obj.district_detail.estateCharge*100:'' + def allArea = obj.district_detail.allArea?obj.district_detail.allArea*100:'' + def buildArea = obj.district_detail.buildArea?obj.district_detail.buildArea*100:'' + def cubagePercent = obj.district_detail.cubagePercent?obj.district_detail.cubagePercent*100:'' + def virescencePercent = obj.district_detail.virescencePercent?obj.district_detail.virescencePercent*100:'' + def carSite = obj.district_detail.carSite?obj.district_detail.carSite*100:'' + def carSiteStr = '' + def car_site_count = getCount(dists,"car_site") + if(obj.existing_district_count && car_site_count){ + def pre = car_site_count*100/obj.existing_district_count + carSiteStr = DataHandleUtils.getDoubleRound(2, pre) + } + def propertyLife = obj.district_detail.propertyLife?obj.district_detail.propertyLife*100:'' + def houseProperty = obj.district_detail.houseProperty?obj.district_detail.houseProperty*100:'' + def buildDate = obj.district_detail.buildDate?obj.district_detail.buildDate*100:'' + def startBuildingDate = obj.district_detail.startBuildingDate?obj.district_detail.startBuildingDate*100:'' + def openDate = obj.district_detail.openDate?obj.district_detail.openDate*100:'' + def finishBuildingDate = obj.district_detail.finishBuildingDate?obj.district_detail.finishBuildingDate*100:'' + def liveDate = obj.district_detail.liveDate?obj.district_detail.liveDate*100:'' + def fitment = '' + def fitment_count = getCount(dists,"fitment") + if(obj.existing_district_count && fitment_count){ + def pre = fitment_count*100/obj.existing_district_count + fitment = DataHandleUtils.getDoubleRound(2, pre) + } + def buildStructure = obj.district_detail.buildStructure?obj.district_detail.buildStructure*100:'' + def arround= '' + def facilities_count = getCount(dists,"facilities") + if(obj.existing_district_count && facilities_count){ + def pre = facilities_count*100/obj.existing_district_count + arround = DataHandleUtils.getDoubleRound(2, pre) + } + + def traffic = '' + def traffic_count = getCount(dists,"traffic") + if(obj.existing_district_count && traffic_count){ + def pre = traffic_count*100/obj.existing_district_count + traffic = DataHandleUtils.getDoubleRound(2, pre) + } + + def relateInfo = '' + def relate_info_count = getCount(dists,"relate_info") + if(obj.existing_district_count && relate_info_count){ + def pre = relate_info_count*100/obj.existing_district_count + relateInfo = DataHandleUtils.getDoubleRound(2, pre) + } + def description = '' + def description_count = getCount(dists,"description") + if(obj.existing_district_count && description_count){ + def pre = description_count*100/obj.existing_district_count + description = DataHandleUtils.getDoubleRound(2, pre) + } + def sellAddress = '' + def sell_address_count = getCount(dists,"sell_address") + if(obj.existing_district_count && sell_address_count){ + def pre = sell_address_count*100/obj.existing_district_count + sellAddress = DataHandleUtils.getDoubleRound(2, pre) + } + def mobile ='' + def mobile_count = getCount(dists,"mobile") + if(obj.existing_district_count && mobile_count){ + def pre = mobile_count*100/obj.existing_district_count + mobile = DataHandleUtils.getDoubleRound(2, pre) + } + def discount = '' + def dis_count = getCount(dists,"discount") + if(obj.existing_district_count && dis_count){ + def pre = dis_count*100/obj.existing_district_count + discount = DataHandleUtils.getDoubleRound(2, pre) + } + def licence = obj.district_detail.licence?obj.district_detail.licence*100:'' + def price = obj.price_coverage?obj.price_coverage*100:'' + def level = price + def rentPrie = '' + if(obj.existing_district_count && rentCount){ + def pre = rentCount*100/obj.existing_district_count + rentPrie = DataHandleUtils.getDoubleRound(2, pre) + } + + def db_fc = '' + def db_bus = '' + if(rMap){ + def count = obj.existing_district_count + if(rMap.bus){ + def pre = rMap.bus*100/count + db_bus = DataHandleUtils.getDoubleRound(2, pre) + } + if(rMap.fc){ + def pre = rMap.fc*100/count + db_fc = DataHandleUtils.getDoubleRound(2, pre) + } + } + rets << [c, 100,100,100,alias,address,addrAlias,estateType2,buildType,lng,lng,block,developer,estateCompany, + loopLineInfo,businessQuarter,loudong,householdCount,estateCharge,allArea,buildArea,cubagePercent,virescencePercent,carSite,carSiteStr,propertyLife, + houseProperty,buildDate,startBuildingDate,openDate,finishBuildingDate,liveDate,fitment,buildStructure,arround,traffic,relateInfo, + description,sellAddress,mobile,discount,licence,level,price,rentPrie, db_bus, db_fc] + println c +" 完成" + } + ExcelUtils.write(path, rets, "覆盖率") + } + + def run2(){ + ExcelUtils.modify("D:\\数据\\美团\\美团88个城市统计.xlsx",{d-> + def dists = CommonDatautils.findAllDistrictByCity(d['A'], "district", ["name","lat","lng"]) + def rMap = statFacilices(dists) + if(rMap){ + def count = dists.size() + if(rMap.bus){ + def pre = rMap.bus*100/count + d['AT'] = DataHandleUtils.getDoubleRound(2, pre) + } + if(rMap.fc){ + def pre = rMap.fc*100/count + d['AU'] = DataHandleUtils.getDoubleRound(2, pre) + } + } + }) + } + + def findFieldCov(c){ + def q = new BasicDBObject() + q.put("city", c) + q.put("weekend", DateUtils.parseFromTightByPattern("2022-06-05", "yyyy-MM-dd")) + def obj = CITY_INFO_CONN.findOne(q) + return obj + } + + def getCount(dists,field){ + def count = 0 + for(def d : dists){ + def val = d.get(field) + if(val && !val.toString().contains("暂无")){ + count++ + } + } + return count + } + + def statFacilices(dists){ +// def distMap = findArroundFaciltices(city) + def bus_count = 0 + def fc_count = 0 +// for(def d : dists){ +// def lng = d.lng/10000000000.0 +// def lat = d.lat/10000000000.0 +// def fcCount = findFacByEs(lng, lat, ["160100","060400","141200","141201","141202","141203","090100","160300"]) +// def busCount = findFacByEs(lng, lat, ["150700", "150500"]) +// println fcCount +// println busCount +// } + + def total = new AtomicLong() + def busCount = new AtomicLong() + def fcCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(dists.size()) + for(def i=0;i0){ + busCount.addAndGet(1) + } + if(fc && fc>0){ + fcCount.addAndGet(1) + } + println total.get()+" "+ d.name + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + latch.await() + + def rMap = [:] + rMap.bus = busCount.get() + rMap.fc = fcCount.get() + return rMap + } + + def findFacByEs(lng, lat, codes){ + def must = [] + def term1 = ["terms":["typecode":codes]] + + must << term1 + def params = ["query":["bool":["must":must,"filter":["geo_distance": [ + "distance": "1km","location": ["lat": lat,"lon": lng]]]]]] + def s = httpSaveData(params, "http://192.168.0.206:9200/amap_poi/_search"); + def total = 0 + if(s){ + def doc = new groovy.json.JsonSlurper().parseText(s) + def hits = doc.hits + if(hits){ + total = hits.total.value + } + } + return total + } + + + + def findArroundFaciltices(city){ + def q = new BasicDBObject() + q.put("matched_city", city) + def dbcursor = arroundColl.find(q) + def distMap = [:] + for(def d : dbcursor){ + + def key = d.matched_region+"#"+d.matched_name + def dMap = distMap.get(key) + if(!dMap){ + dMap = [:] + distMap.put(d.region+"#"+d.district_name, dMap) + } + + def bus = 0 + def fc = 0 + if(d.type){ + if(d.type.contains("公交") || d.type.contains("地铁")){ + bus = 1 + fc = 1 + }else{ + fc = 1 + } + } +// if((d.bus && d.bus.size()>0) || (d.school && d.school.size()>0) || (d.bank && d.bank.size()>0) ||(d.supermarket && d.supermarket.size()>0) || (d.hospital && d.hospital.size()>0) || (d.atm && d.atm.size()>0)|| (d.university && d.university.size()>0)|| (d.middle_school && d.middle_school.size()>0) || (d.primary_school && d.primary_school.size()>0)|| (d.kindergarten && d.kindergarten.size()>0)){ +// fc = 1 +// } + dMap.bus = bus + dMap.fc = fc + } + return distMap + } + + def findAllFaciltices(city){ + def q = new BasicDBObject() + q.put("city", city) + def dbcursor = on_line.find(q) + def distMap = [:] + for(def d : dbcursor){ + def bus = 0 + def fc = 0 + if(d.bus && d.bus.size()>0){ + bus = 1 + } + if((d.bus && d.bus.size()>0) || (d.school && d.school.size()>0) || (d.bank && d.bank.size()>0) ||(d.supermarket && d.supermarket.size()>0) || (d.hospital && d.hospital.size()>0) || (d.atm && d.atm.size()>0)|| (d.university && d.university.size()>0)|| (d.middle_school && d.middle_school.size()>0) || (d.primary_school && d.primary_school.size()>0)|| (d.kindergarten && d.kindergarten.size()>0)){ + fc = 1 + } + def dMap = [:] + dMap.bus = bus + dMap.fc = 1 + distMap.put(d.region+"#"+d.district_name, dMap) + } + return distMap + } + + + + def httpSaveData(def params, def url){ + def header = [:] + header.put("Authorization","Basic ZGV2ZWxvcGVyOjVlOGVkZDg1MWQyZmRmYmQ3NDE1MjMyYzY3MzY3Y2Mz") + return doPost(url,header, params, true, "utf-8") + } + + + def doPost(def targetUrl, def headers, def params, def isJson, def charset){ + StringBuilder buffer = new StringBuilder(); + try{ + URL url = new URL(targetUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setUseCaches(false); + conn.setConnectTimeout(5000); + conn.setReadTimeout(5000); + conn.setRequestProperty("User-Agent", UserAgents.get()); + String param = null; + BufferedWriter mWriter = null; + InputStreamReader inStream = null; + + + if (headers != null && headers.keySet().size() > 0) { + for (String head : headers.keySet()) { + conn.setRequestProperty(head, headers.get(head)); + } + } else { + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=" + CHARSET); + } + + if (isJson) { + conn.setRequestProperty("Content-Type", "application/json; charset=" + charset); + param = JacksonUtil.beanToJson(params) + } + + conn.connect(); + + //输出流 + if (StringUtils.isNotEmpty(param)) { + mWriter = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream(), charset)); + mWriter.write(param); + mWriter.flush(); + mWriter.close(); + } + if (conn.getHeaderField("Content-Encoding") != null + && conn.getHeaderField("Content-Encoding").equals("gzip")) { + inStream = new InputStreamReader(new GZIPInputStream(conn.getInputStream()), charset); + } else { + inStream = new InputStreamReader(conn.getInputStream(), charset); + } + char[] bf = new char[1024]; + int len; + while ((len = inStream.read(bf)) != -1) { + buffer.append(bf, 0, len); + } + } catch (Exception e) { + e.printStackTrace() + + } + return buffer.toString(); + } +} 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 b8e3cd5a1..38d9b23b3 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 @@ -239,6 +239,27 @@ class CommonDatautils { } + public static def findRemoveDistricts(def city, def cat, def fields, def m_date){ + DBObject q = new BasicDBObject(); + q.put("status", 1); + q.put("cat", cat); + q.put("city", city); + q.put("m_date", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(m_date))) + DBObject keys = new BasicDBObject(); + if(fields){ + for(def field : fields){ + keys.put(field, 1); + } + } + + DSCursor cursor = getDataStoreConnection().find(q, keys).batchSize(2000) + List rets = [] + for(def obj : cursor){ + rets << obj + } + return rets; + } + /** * 获取城市中小区的经纬度 * @param city @@ -834,39 +855,42 @@ class CommonDatautils { if(!id){ return null; } - DBObject q = new BasicDBObject(); - q.put("_id", new ObjectId(id.toString().replace("[","").replace("]",""))); - - DBObject keys = new BasicDBObject(); - keys.put("alias", 1); - keys.put("addr_alias", 1); - keys.put("city", 1); - keys.put("region", 1); - keys.put("name", 1); - keys.put("estate_type2", 1); - keys.put("address", 1); - keys.put("build_structure", 1); - keys.put("out_pics", 1); - keys.put("lat", 1); - keys.put("lng", 1); - keys.put("lat2", 1); - keys.put("lng2", 1); - keys.put("name_cat", 1); - keys.put("finish_building_date", 1) - keys.put("mapping_alias", 1) - keys.put("sid", 1) try{ - DSCursor cursor = getDataStoreConnection().find(q, keys); - if(cursor){ - for(def obj : cursor){ - return obj; + DBObject q = new BasicDBObject(); + q.put("_id", new ObjectId(id.toString().replace("[","").replace("]",""))); + + DBObject keys = new BasicDBObject(); + keys.put("alias", 1); + keys.put("addr_alias", 1); + keys.put("city", 1); + keys.put("region", 1); + keys.put("name", 1); + keys.put("estate_type2", 1); + keys.put("address", 1); + keys.put("build_structure", 1); + keys.put("out_pics", 1); + keys.put("lat", 1); + keys.put("lng", 1); + keys.put("lat2", 1); + keys.put("lng2", 1); + keys.put("name_cat", 1); + keys.put("finish_building_date", 1) + keys.put("mapping_alias", 1) + keys.put("sid", 1) + try{ + DSCursor cursor = getDataStoreConnection().find(q, keys); + if(cursor){ + for(def obj : cursor){ + return obj; + } } + }catch(Exception e){ + println "error_id:"+id + e.printStackTrace() } }catch(Exception e){ - println "error_id:"+id - e.printStackTrace() - } + } return null; } @@ -3200,6 +3224,14 @@ class CommonDatautils { return dbo; } + static def findSqmetreRents(def city, def weekend){ + def q = new BasicDBObject() + q.put("city", city) + q.put("weekend", weekend) + def count = SQMETRE_RENT_COLL.count(q) + return count; + } + static def findNewSqmetreRent(def city, def region, def name){ def q = new BasicDBObject() q.put("city", city) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy index f3f386be6..5c1e8c152 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fangjiatong/FjtResponseTimeAnaly.groovy @@ -34,7 +34,8 @@ class FjtResponseTimeAnaly extends BaseBatch{ @Override public void process(Object args) { - run(); + //run(); + jms.sendMail("gaojuan@fangjia.com", "测试发邮件", "收到了?") } 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 9934cb1c7..ce903527a 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 @@ -68,14 +68,17 @@ class DistrictInfoExportBatch extends BaseBatch{ def createDatas(def city){ def result = [] def districts = CommonDatautils.findAllDistricts(city, "district", null); + def removeDists = CommonDatautils.findRemoveDistricts(city, "district", null, "2022-01-01"); + districts.addAll(removeDists) def lastDate = DateUtils.getLastDayOfMonth(new Date(), -1) def startDate = DateUtils.getFirstDayOfMonth(lastDate); def fzAddrMap = getFzAddress(); for(def rMap : districts){ - def dbo = CommonDatautils.queryDistrictPriceByDate3(city, rMap.region, rMap.name, startDate, lastDate) - if(dbo){ + //价格没有也提供 +// def dbo = CommonDatautils.queryDistrictPriceByDate3(city, rMap.region, rMap.name, startDate, lastDate) +// if(dbo){ def row = [] row << rMap.get("_id").toString() row << rMap.city @@ -112,7 +115,7 @@ class DistrictInfoExportBatch extends BaseBatch{ } //row << processAlias(rMap.addr_alias) result << row - } +// } } return result } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy index bb7b11f46..dd9cd246b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictPriceExportBatch.groovy @@ -88,6 +88,9 @@ class DistrictPriceExportBatch extends BaseBatch{ def createDatas(def city){ def districts = CommonDatautils.findAllDistricts(city, "district", null); + def removeDists = CommonDatautils.findRemoveDistricts(city, "district", null, "2022-01-01"); + districts.addAll(removeDists) + def endDateStr = DateUtils.formatDateByPattern(new Date(), "yyyy-MM")+"-10" def dataStr = DateUtils.add(endDateStr, -30) def startDate = DateUtils.parseFromTightYYYYMMDD(dataStr) @@ -105,9 +108,10 @@ class DistrictPriceExportBatch extends BaseBatch{ for(def rMap : districts){ def dbo = CommonDatautils.queryDistrictPriceByDate3(city, rMap.region, rMap.name, startDate, lastDate) + def curPrice = 0 if(dbo){ def lastMonthPrice = lastMonthPriceMap.get(rMap.get("_id").toString()) - def curPrice = dbo.get("avg_price") + curPrice = dbo.get("avg_price") if(lastMonthPrice && curPrice){ def markup = (curPrice - lastMonthPrice)*100/lastMonthPrice if(Math.abs(markup)>3){ @@ -120,36 +124,20 @@ class DistrictPriceExportBatch extends BaseBatch{ curPrice = (int)(lastMonthPrice*markup/100 + lastMonthPrice) } } - - def m = [] - m << dbo.get("_id").toString()//均价ID - m << rMap.get("_id").toString()//楼盘ID - m << rMap.city - m << rMap.region - m << rMap.name - m << curPrice -// def lastMonthPrice = map2.get(rMap.city + "##" + rMap.region+"##"+rMap.name) -// if(lastMonthPrice && dbo.get("avg_price")){ -// lastMonthPrice = lastMonthPrice.toInteger() -// def markup = (dbo.get("avg_price")-lastMonthPrice)*100.0/lastMonthPrice -// if(Math.abs(markup)>10){ -// def random = 0 -// if(dbo.get("avg_price")-lastMonthPrice>=0){ -// random = com.fangjia.core.util.RandomUtil.random(1, 9) -// }else{ -// random = com.fangjia.core.util.RandomUtil.random(-9, 0) -// } -// def newPrice = lastMonthPrice*random/100 + lastMonthPrice -// m << newPrice.toInteger() -// }else{ -// m << dbo.get("avg_price") -// } -// }else{ -// m << dbo.get("avg_price") -// } - m << curDate.toInteger(); - result << m } + def m = [] + if(curPrice){ + m << dbo.get("_id").toString()//均价ID + }else{ + m << "" + } + m << rMap.get("_id").toString()//楼盘ID + m << rMap.city + m << rMap.region + m << rMap.name + m << curPrice + m << curDate.toInteger(); + result << m } return result } 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 7e5074c7c..563e6ab47 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 @@ -14,7 +14,7 @@ import com.mongodb.DBCollection //福州第三方均价统计,发送钉钉消息 //def datas = ExcelUtils.read("d:\\数据\\福州\\福州4月2.xlsx",0,1) //def datas = CsvUtils.read("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202105.csv"); -def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202204.csv") +def datas = readTxt("d:\\数据\\福州\\FJW_THIRD_PARTY_AVG_PRICE_202205.csv") def count0 = 0 def count1 = 0 def count2 = 0 @@ -136,8 +136,8 @@ def curMonth = DateUtils.formatDateByPattern(new Date(), "yyyyMM") ExcelUtils.write("d:\\数据\\福州\\多方均价对比统计数据"+curMonth+".xlsx",rets,"统计") def s = "第三方均价总量:${total}\n6区总量:${regionCount}\ncount1: "+ count1+"( "+pre1+"% )\ncount2: "+ count2+"( "+pre2+"% )\ncount3: "+count3+"( "+pre3+"% )\ncount4: "+count4+"( "+pre4+"% )\ncount5: "+count5+"( "+pre5+"% )\ncount6: "+count6+"( "+pre6+"% )\ncount7: "+count7+"( "+pre7+"%)\ncount8: "+count8+"( "+pre8+"% )\ncount9: "+count9+" ("+pre9+"% )" println s -def access_token = "065f4a05d5f87eb39a9f9e048eeefb80c1f7560446f8926441de80453c160c60" -DingDingMessageUtil.sendTextMessage(access_token, s) +//def access_token = "065f4a05d5f87eb39a9f9e048eeefb80c1f7560446f8926441de80453c160c60" +//DingDingMessageUtil.sendTextMessage(access_token, s) ////def districts = CommonDatautils.findAllDistricts("福州", "district", ["city", "region", "name"]); 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 7b357ab95..2cceebe1e 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 @@ -143,9 +143,14 @@ class ThirdPriceExportBatch extends BaseBatch{ if(!retMap.zhugezhaofang_esf_price && d.zhugezhaofang_esf_price){ retMap.zhugezhaofang_esf_price = d.zhugezhaofang_esf_price } + if(!retMap.anjuke_esf_price && d.get("anjuke_esf_price")){ + retMap.anjuke_esf_price = d.get("anjuke_esf_price") + } + if(!retMap.anjuke_esf_price && d.get("58tc_esf_price")){ retMap.anjuke_esf_price = d.get("58tc_esf_price") } + if(!retMap.soufang_esf_price && d.soufang_esf_price){ retMap.soufang_esf_price = d.soufang_esf_price } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy index e4b621c99..5da258e86 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy @@ -165,7 +165,7 @@ class OpenApiUtils { return null; } address = address.trim().replace(" ","") - String url = "https://restapi.amap.com/v3/place/text?keywords=" + address + "&types=&city=" + city + "&output=json&offset=20&page=1&key=2af0b8533415a612b98d59bb93d664b9&extensions=all" + String url = "https://restapi.amap.com/v3/place/text?keywords=" + address + "&types=120000&city=" + city + "&output=json&offset=20&page=1&key=2af0b8533415a612b98d59bb93d664b9&extensions=all" List poiList = null; com.alibaba.fastjson.JSONObject result = null; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy index 45c2f60a5..42dd5ea08 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenUserBatch.groovy @@ -12,7 +12,8 @@ class OpenUserBatch { def task = new OpenUserBatch(); // task.run(); // task.test(); - task.addShenZhenFjtUser(); +// task.addShenZhenFjtUser(); + task.addFujianFjtUser() } def test(){ @@ -63,4 +64,23 @@ class OpenUserBatch { } } + def addFujianFjtUser(){ + def datas = ExcelUtils.read("D:\\数据\\江苏农行\\福建省农行账号开通.xlsx",0,1) + def i = 0; + for(def data : datas){ + i++; + def id = 252738 + i; + String mobile = data['A'] + String pwd = '111111' + def sql = "insert into users(id, email, password, role, user_role, city, gold_total, come_from, date_created, last_updated, status, uid, access_token, house_report_token, open_day, fangdiao_apply_add, gujia_add, fangdiao_apply_count, gujia_down_count, fangdiao_add, fangdiao_down_count, yang_ben_down, mobile, pay_password, evaluation_count, close_date, manager, role_users, weixinId) VALUES ("+id+", '"+mobile+"', '"+pwd+"', '12', NULL, NULL, '0', 'fangjiatong', now(), now(), '0', NULL, NULL, '', '0', '2', '2', '2', '100', NULL, NULL, '0', NULL, NULL, '100', '2022-07-10 00:00:00', '0', '', NULL)"; + onLineSqlInstance.execute(sql); + + def sql2 = "INSERT INTO users_detail (id, p_id,name, org_name, phone, fax, email, address, role, company, user_valid_date, online_status, last_login_date, last_operat_date, date_created, last_updated, mobile, eva_guide, ip_list, sale_name) VALUES ('"+id+"', '0', '"+data['C']+"', '福建', '"+mobile+"', NULL, NULL, NULL, NULL, NULL, NULL, b'0', now(), now(), now(), now(), NULL, b'0', '', '蒋晓春')"; + onLineSqlInstance.execute(sql2) + + def sql3 = "INSERT INTO user_city (user_id, citys, credits) VALUES("+id+",'福州,厦门,泉州,莆田,宁德,三明,龙岩,南平,漳州','福州:,厦门:,泉州:,莆田:,宁德:,三明:,龙岩:,南平:,漳州:')" + onLineSqlInstance.execute(sql3) + } + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/TestFjtLog.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/TestFjtLog.groovy index 82bb78ccd..5dac60e11 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/TestFjtLog.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/TestFjtLog.groovy @@ -10,11 +10,11 @@ import java.text.SimpleDateFormat class TestFjtLog { - public static final DBCollection COLL = MongoUtils.getCollectionByName("fangjiatong_log", "fjt_select_log", "192.168.0.42", 52002) + public static final DBCollection COLL = MongoUtils.getCollectionByName("business", "open_uri_log", "192.168.0.42", 52002) static main(args) { def q = new BasicDBObject() - q.put("cat","土地") +// q.put("cat","土地") def dbcursor = COLL.find(q).sort(new BasicDBObject("_id",-1)) def map = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/AnjukeTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/AnjukeTest.groovy new file mode 100644 index 000000000..e3ef4608c --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/AnjukeTest.groovy @@ -0,0 +1,25 @@ +package com.fangjia.script.gj.abuyun + +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +class AnjukeTest { + + DBCollection detail = MongoUtils.getCollectionByAuth20190102("fangjia_craw", "app_anjuke_detail") + + static main(args) { + def task = new AnjukeTest() + task.run() + } + + def run(){ + def q = new BasicDBObject() + def dbcursor = detail.find(q) + for(def d : dbcursor){ + def url = d.jumpAction + def s =ClaABuYun.getResponse(url) + println(s) + } + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/ProxyAuthenticator.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/ProxyAuthenticator.groovy new file mode 100644 index 000000000..36115ae9c --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/abuyun/ProxyAuthenticator.groovy @@ -0,0 +1,23 @@ +package com.fangjia.script.gj.abuyun + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.net.Authenticator; +import java.net.HttpURLConnection; +import java.net.InetSocketAddress; +import java.net.PasswordAuthentication; +import java.net.Proxy; +import java.net.URL; + +class ProxyAuthenticator extends Authenticator { + private String user, password; + + public ProxyAuthenticator(String user, String password) { + this.user = user; + this.password = password; + } + + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(user, password.toCharArray()); + } +} \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAbuyunCrawl.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAbuyunCrawl.groovy new file mode 100644 index 000000000..97dc61875 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAbuyunCrawl.groovy @@ -0,0 +1,91 @@ +package com.fangjia.script.gj.crawl + +import com.alibaba.fastjson.JSON +import com.alibaba.fastjson.JSONObject +import com.fangjia.script.crawl.JQueryUtils +import com.fangjia.script.gj.abuyun.ClaABuYun +import com.fangjia.script.temp.shenjian.util.MessageUtils +import com.fangjia.script.util.CommonUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.jsoup.Jsoup + + +class AnjukeAbuyunCrawl { + + DBCollection detail = MongoUtils.getCollectionByAuth20190102("fangjia_craw", "app_anjuke_detail") + + static main(args) { + def task = new AnjukeAbuyunCrawl(); + task.run(); + } + def run(){ + def url = "https://fz.anjuke.com/sale/?from=navigation" + for(def i=2;i<50;i++){ + url ="https://fz.anjuke.com/sale/p${i}/?from=navigation" + def doc = getABuYunDocument(url); + def eles = JQueryUtils.select(".list-main .list-left .list .property a", doc) + println "页数:"+i+" 记录数:"+eles!=null?eles.size():0 + if(eles){ + parser(eles) + } + } + } + + def parser(eles){ + def index = 0 + for(def e : eles){ + index ++ + def href = e.attr("href") + def doc = getABuYunDocument(href); + def newUrl = href.substring(0, href.indexOf("?")) + sendMq(newUrl, doc) + println "[ "+index +"] "+ newUrl + } + } + + + + def getABuYunDocument(url){ + def stop = false + def error = 0 + def doc = null + while(!stop){ + try{ + def s = ClaABuYun.getResponse(url) + doc = Jsoup.parse(s); + def els = JQueryUtils.select(".list-main .list-left .list", doc) + if(!els){ + els = JQueryUtils.select(".props-main", doc) + } + if(els && els.size()>0){ + stop = true; + }else{ + error++ + println "[${error}] error: "+url + } + }catch(Exception e){ + error++ + } + if(error>=20){ + stop = true; + } + } + return doc + } + + def sendMq(href, doc){ + JSON json = new JSONObject() + json.put("project", "sell_anjuke") + json.put("url", href) + + JSON result = new JSONObject() + result.put("content", doc.toString()) + json.put("result", result) + + byte[] packedMsg = MessageUtils.pack(json) + CommonUtils.sendMessage("result2parse", packedMsg) + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy index d55350598..5354eafe8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeAppCrawl.groovy @@ -1,31 +1,239 @@ package com.fangjia.script.gj.crawl +import com.alibaba.fastjson.JSON +import com.fangjia.core.util.GeocodeUtils import com.fangjia.script.crawl.JQueryUtils +import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.thirdPriceCrawl.CrawalDBUtil import com.fangjia.script.thirdPriceCrawl.Utils import com.fangjia.script.util.ABuYunUtil +import com.fangjia.script.util.ElasticUtils +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 net.sf.json.JSONObject +import org.apache.commons.lang.StringEscapeUtils import org.jsoup.Jsoup import org.openqa.selenium.WebDriver import org.openqa.selenium.chrome.ChromeDriver +import javax.script.Invocable +import javax.script.ScriptEngine +import javax.script.ScriptEngineManager +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + class AnjukeAppCrawl { + static def PREFIX_UNICODE = "\\u"; public static final SHORT_DATE = Utils.getLastMonth(); def static final DBCollection thirdPartyColl = CrawalDBUtil.getThirdPartyCol(); public static def SOURCE = "安居客"; DBCollection detail = MongoUtils.getCollectionByAuth20190102("fangjia_craw", "app_anjuke_detail") + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50) + static main(args) { + + + +// String line2 = StringEscapeUtils.unescapeJava(s); +// println line2 def task = new AnjukeAppCrawl(); +// task.autoRun() // task.run(); // task.run2() task.addThirdPrice() +// task.saveToEs() +// task.saveToEs1() + +// task.groupByCity() +// task.selectNoSave() +// task.statCount() + } + def saveToEs1(){ + def lists = getAllAppDatas() + anjukeToDB(lists) + } + + def statCount(){ + ExcelUtils.multiThreadingModify("D:\\数据\\anjuke\\cur_city_count.xlsx",{d-> + def city = d['B'] + if(!d['D']){ + def q = new BasicDBObject() + q.put("base.cityName",city) + def count = detail.count(q) + d['D'] = count + println city +" "+count + } + + }) + } + + def selectNoSave(){ + def esData = findAllEsData() + def q = new BasicDBObject() + def dbcursor = detail.find(q).batchSize(5000) + def index = 0 + for(def d : dbcursor){ + index++ + if(!esData.contains(d.jumpAction)){ + println "没保存 "+ d.jumpAction + } + if(index%100000==0){ + println index + } + + } + } + + def findAllEsData(){ + def urls = new HashSet() + ElasticUtils.executeSqlQuery("select url from community where source='安居客移动端'", { + urls << it.url + }) + return urls; + } + + def groupByCity(){ + def q = new BasicDBObject() + def dbcursor = detail.find(q).batchSize(5000) + def map = [:] + def index = 0 + for(def d : dbcursor){ + index++ + def city = d.base.cityName + def str = map.get(city) + if(!str){ + map.put(city, d.base.longCityListName) + } + println index + } + + map.each {k,v-> + println k + } + } + + def autoRun(){ + def rets = ExcelUtils.read("d:\\数据\\安居客城市区域编码.xlsx") + def total= rets.size() + def index =0 + for(def d : rets){ + index++ + println index+" "+ d['A']+" "+d['C'] + getDetailByRegion(d['A'], d['B'], d['D'], null) + } + + } + + def saveToEs(){ + def rets = ExcelUtils.read("d:\\数据\\安居客城市区域编码.xlsx",2,0) + def citys = ["福州"] + for(def d : rets){ + if(citys.contains(d['A'])){ + def lists = getAllAppDatas(d['A']) + anjukeToDB(lists) + citys << d['A'] + } + } + } + + def anjukeToDB(def lists){ + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(lists.size()) + for(def i=0;i + index++ + def regionDatas = getRegions(m.url+"community/?from=anjuke_home", driver) + println "[${index}] "+ch_city+" "+regionDatas.size() + regionDatas.each{k,v-> + + rets << [ch_city, m.city_id.toInteger(),v.info.name, v.info.value_str.toInteger()] + } + } + ExcelUtils.write("d:\\数据\\安居客城市区域编码.xlsx", rets, "数据") } def run2(){ @@ -46,6 +254,58 @@ class AnjukeAppCrawl { } } + def getRegions(url,driver){ + def doc = getDocument(url, driver) + def start = doc.toString().indexOf("") + if(start>0 && end>0 && end > start){ + def str = doc.toString().substring(start, end).replace("