From 4b7fe557805cf34a4f1d81da7bcfed432fdead94 Mon Sep 17 00:00:00 2001 From: mjt <13607600062@163.com> Date: Thu, 22 Feb 2024 10:42:06 +0800 Subject: [PATCH 001/230] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=89=E5=86=9C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/PoseidonOnce.groovy | 2 +- .../script/gj/meishubao/MsbPocTest.groovy | 2 +- .../script/majintao/test/FiveLevelTest.groovy | 64 ++++++++ .../script/majintao/test/SheNongTest.groovy | 124 +++++++++++++++ .../script/majintao/test/SheNongTest2.groovy | 147 ++++++++++++++++++ .../test/sdklog/sdkclient_CommunicateLog_info | 0 .../test/sdklog/sdkclient_EMAYSDK_info | 0 .../script/majintao/{ => test}/test.groovy | 2 +- .../com/fangjia/script/majintao/test2.groovy | 4 - .../com/fangjia/script/webCrawl/Test.groovy | 6 +- 10 files changed, 341 insertions(+), 10 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/FiveLevelTest.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest2.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/sdklog/sdkclient_CommunicateLog_info create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/sdklog/sdkclient_EMAYSDK_info rename projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/{ => test}/test.groovy (98%) delete mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test2.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/PoseidonOnce.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/PoseidonOnce.groovy index fa4c6891f..48b616432 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/PoseidonOnce.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/PoseidonOnce.groovy @@ -78,7 +78,7 @@ class PoseidonOnce { // DBCursor cur = coll.find() // println cur.count() String url = "http://www.fangjia.com"; - DBCollection coll = MongoUtils.getCollectionByName("fangjia", "test2", "192.168.0.188") + DBCollection coll = MongoUtils.getCollectionByName("fangjia", "FiveLevelTest", "192.168.0.188") // for(int i=426000;i<1000000;i++) { // String s = url + i + "_" + url.hashCode() // DBObject dbo = new BasicDBObject() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy index f517a80b8..522a1fe7e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy @@ -19,7 +19,7 @@ class MsbPocTest { // match(inputfile) // matchOld(inputfile) // addPrice("D:\\数据\\美术宝\\美术宝测试数据(价格).xlsx") -// test("D:\\数据\\美术宝\\test2.xlsx") +// test("D:\\数据\\美术宝\\FiveLevelTest.xlsx") // cityPrice() // mergeMatchPrice("D:\\数据\\美术宝\\美术宝-新接口价格.xlsx") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/FiveLevelTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/FiveLevelTest.groovy new file mode 100644 index 000000000..a430f9480 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/FiveLevelTest.groovy @@ -0,0 +1,64 @@ +package com.fangjia.script.majintao.test + +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.util.ExcelUtils +import net.sf.json.JSONObject + + +String excelFilePath = "C:\\Users\\Goojia\\Desktop\\临时数据\\2.xlsx"; +ExcelUtils.removeEmptyRow(excelFilePath) +ExcelUtils.singleThreadingModify(excelFilePath, { List items -> + + String url = "http://192.168.0.19:31080/FangJiaAddressService/v3/structure"; + + HttpRequest httpRequest = new HttpRequest(); + map = new HashMap() + + String address = items['A'] + + def map = [:] + map.put("address", address) + map.put("complete", "true") + map.put("addressAssessment", "true") + + def content = httpRequest.getJsonContent(url, map, "UTF-8") + def result = content.get("result") + if ("province" in result) { + items['B'] = result.get("province") + } + if ("provinceCode" in result) { + items['C'] = result.get("provinceCode") + } + if ("city" in result){ + items['D'] = result.get("city") + } + if("cityCode" in result){ + items['E'] = result.get("cityCode") + } + if ("district" in result){ + + items['F'] = result.get("district") + } + if ("districtCode" in result){ + + items['G'] = result.get("districtCode") + } + if ("township" in result){ + + items['H'] = result.get("township") + } + if ("townshipCode" in result){ + + items['I'] = result.get("townshipCode") + print(result.get("townshipCode")) + } + if ("address" in result){ + + items['J'] = result.get("address") + } + if ("formatAddress" in result){ + items['K'] = result.get("formatAddress") + } + +}) + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest.groovy new file mode 100644 index 000000000..c1575a52f --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest.groovy @@ -0,0 +1,124 @@ +package com.fangjia.script.majintao.test + +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.util.ExcelUtils + + +String excelFilePath = "C:\\Users\\Goojia\\Desktop\\涉农对私测试数据.xlsx"; +ExcelUtils.removeEmptyRow(excelFilePath) +def count = 0 +ExcelUtils.multiThreadingModify(excelFilePath, { List items -> + count += 1 + if (count % 10 == 0) { + println("已处理:" + count) + } + + + String address = items['A'] + String province = items['B'] + if (province == null) { + String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify"; + + HttpRequest httpRequest = new HttpRequest(); + map = new HashMap() + + + def map = [:] + map.put("address", address) + map.put("complete", "true") + map.put("addressAssessment", "true") + map.put("type", "1") + + def content = httpRequest.getJsonContent(url, map, "UTF-8") + def result = content.get("result") + if (result != null) { + if ("province" in result) { + items['B'] = result.get("province") + } + if ("provinceCode" in result) { + items['C'] = result.get("provinceCode") + } + if ("city" in result) { + items['D'] = result.get("city") + } + if ("cityCode" in result) { + items['E'] = result.get("cityCode") + } + if ("district" in result) { + + items['F'] = result.get("district") + } + if ("districtCode" in result) { + + items['G'] = result.get("districtCode") + } + if ("town" in result) { + + items['H'] = result.get("town") + } + if ("townCode" in result) { + + items['I'] = result.get("townCode") + } + + if ("committee" in result) { + + items['J'] = result.get("committee") + } + if ("committeeCode" in result) { + + items['K'] = result.get("committeeCode") + } + if ("typeCode" in result) { + + items['L'] = result.get("typeCode") + } + if ("typeName") { + items['M'] = result.get("typeName") + } + if ("verifyFlag") { + items['N'] = result.get("verifyFlag") + } + if ("addrVerify") { + items['O'] = result.get("addrVerify") + } + if ("countyLevelCity") { + items['P'] = result.get("countyLevelCity") + } + if ("countyGov") { + items['Q'] = result.get("countyGov") + } + if ("communitySource") { + items['R'] = result.get("communitySource") + } + + if ("administrativeTowns" in result) { + items['T'] = result.get("administrativeTowns") + } + if ("devDistrict" in result) { + items['V'] = result.get("devDistrict") + } + if ("devDistrictName" in result) { + items['W'] = result.get("devDistrictName") + } + if ("splitCommittee" in result) { + items['X'] = result.get("splitCommittee") + } + if ("splitStreet" in result) { + items['Y'] = result.get("splitStreet") + } + if ("poiName" in result) { + items['Z'] = result.get("poiName") + } + if ("splitStreetNum" in result) { + items['AA'] = result.get("splitStreetNum") + } + if ("dev" in result) { + items['AB'] = result.get("dev") + } + } + + } + +}) + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest2.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest2.groovy new file mode 100644 index 000000000..7b84a95d5 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/SheNongTest2.groovy @@ -0,0 +1,147 @@ +package com.fangjia.script.majintao.test + +import com.fangjia.core.util.HttpRequest +import com.fangjia.script.util.ExcelUtils + + +String excelFilePath = "C:\\Users\\Goojia\\Desktop\\对公.xlsx"; +ExcelUtils.removeEmptyRow(excelFilePath) +def count = 0 +ExcelUtils.singleThreadingModify(excelFilePath, { List items -> + count+=1 + if (count%10==0){ + println("已处理:"+count) + } + + String url = "http://192.168.0.100:32080/FangJiaAddressService/villageIdentify"; + + HttpRequest httpRequest = new HttpRequest(); + map = new HashMap() + + String address = items['A'] +// print(address) + +// province; +// city; +// district; +// town; +// committee; +// type; +// provinceCode; +// cityCode; +// districtCode; +// townCode; +// committeeCode; +// typeCode; +// typeName; +// verifyFlag;//涉农标识 +// addrVerify;//地址是否有效信息 +// countyLevelCity;//是否为县级市 +// administrativeTowns;//是否市辖建制镇 +// countyGov;//是否为县政府 +// devDistrict;//是否为开发区 +// devDistrictName;//开发区 +// splitCommittee; +// splitStreet; +// poiName; +// splitStreetNum; +// dev; +// communitySource;//居委来源 + + def map = [:] + map.put("address", address) + map.put("complete", "true") + map.put("addressAssessment", "true") + map.put("type", "2") + + def content = httpRequest.getJsonContent(url, map, "UTF-8") + def result = content.get("result") + if ("province" in result) { + items['B'] = result.get("province") + } + if ("provinceCode" in result) { + items['C'] = result.get("provinceCode") + } + if ("city" in result){ + items['D'] = result.get("city") + } + if("cityCode" in result){ + items['E'] = result.get("cityCode") + } + if ("district" in result){ + + items['F'] = result.get("district") + } + if ("districtCode" in result){ + + items['G'] = result.get("districtCode") + } + if ("town" in result){ + + items['H'] = result.get("town") + } + if ("townCode" in result){ + + items['I'] = result.get("townCode") + } + + if ("committee" in result){ + + items['J'] = result.get("committee") + } + if ("committeeCode" in result){ + + items['K'] = result.get("committeeCode") + } + if ("typeCode" in result){ + + items['L'] = result.get("typeCode") + } + if ("typeName"){ + items['M'] = result.get("typeName") + } + if ("verifyFlag"){ + items['N'] = result.get("verifyFlag") + } + if ("addrVerify"){ + items['O'] = result.get("addrVerify") + } + if ("countyLevelCity"){ + items['P'] = result.get("countyLevelCity") + } + if ("countyGov"){ + items['Q'] = result.get("countyGov") + } + if ("communitySource"){ + items['R'] = result.get("communitySource") + } + + if ("administrativeTowns" in result){ + items['T'] = result.get("administrativeTowns") + } + if ("devDistrict" in result){ + items['V'] = result.get("devDistrict") + } + if ("devDistrictName" in result){ + items['W'] = result.get("devDistrictName") + } + if ("splitCommittee" in result){ + items['X'] = result.get("splitCommittee") + } + if ("splitStreet" in result){ + items['Y'] = result.get("splitStreet") + } + if ("poiName" in result){ + items['Z'] = result.get("poiName") + } + if ("splitStreetNum" in result){ + items['AA'] = result.get("splitStreetNum") + } + if ("dev" in result){ + items['AB'] = result.get("dev") + } + + + +}) + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/sdklog/sdkclient_CommunicateLog_info b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/sdklog/sdkclient_CommunicateLog_info new file mode 100644 index 000000000..e69de29bb diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/sdklog/sdkclient_EMAYSDK_info b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/sdklog/sdkclient_EMAYSDK_info new file mode 100644 index 000000000..e69de29bb diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/test.groovy similarity index 98% rename from projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test.groovy rename to projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/test.groovy index 350ffa191..22a5ae18e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test/test.groovy @@ -1,4 +1,4 @@ -package com.fangjia.script.majintao +package com.fangjia.script.majintao.test import com.fangjia.core.util.HttpRequest import com.fangjia.script.util.ExcelUtils diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test2.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test2.groovy deleted file mode 100644 index 2c6e2d2ea..000000000 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/majintao/test2.groovy +++ /dev/null @@ -1,4 +0,0 @@ -import org.bson.types.ObjectId - -a = new ObjectId() -print(a) \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/webCrawl/Test.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/webCrawl/Test.groovy index 796aaedcb..11d317c09 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/webCrawl/Test.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/webCrawl/Test.groovy @@ -43,15 +43,15 @@ class Test { static main(args) { // String test1 = " qwdwqd ssss "; -// String test2 = " qwdwqd ss"; +// String FiveLevelTest = " qwdwqd ss"; // String test3 = "qwdwqd dd"; // // test1 = test1.replaceAll(" |\\s+", " "); -// test2 = test2.replaceAll(" |\\s+", " "); +// FiveLevelTest = FiveLevelTest.replaceAll(" |\\s+", " "); // test3 = test3.replaceAll(" |\\s+", " "); // // String[] arrs1 = test1.split("\\s+") -// String[] arrs2 = test2.split("\\s+") +// String[] arrs2 = FiveLevelTest.split("\\s+") // String[] arrs3 = test3.split("\\s+") // // println arrs1 From b03eb373dca3cb249bcfa545c152a58f3735c789 Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Wed, 19 Jun 2024 13:50:58 +0800 Subject: [PATCH 002/230] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=8C=87=E5=AF=BC?= =?UTF-8?q?=E4=BB=B7=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/util/CommonUtils.groovy | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy index 21887e3db..ac9704830 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/CommonUtils.groovy @@ -1,6 +1,7 @@ package com.fangjia.script.util import com.fangjia.core.RegionData +import com.fangjia.core.util.HttpRequest import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.DBObject @@ -192,6 +193,19 @@ public class CommonUtils { } } + static void recalcAverage(String city, String region, String name, Integer count =1 , String category="sell", Boolean retainHistory=true){ + def url = "http://192.168.0.100:38080/FangJiaDataService/districtPriceCalculate"; + def params = new HashMap(); + params.city = city; + params.region = region; + params.name = name; + params.count = count.toString(); + params.category = category; + params.retainHistory = retainHistory.toString(); + HttpRequest request = new HttpRequest(); + println(request.get(url, params, "UTF-8")) + } + /** * 重算小区均价 * @param city @@ -221,7 +235,7 @@ public class CommonUtils { cmd.put("name", name) cmd.put('estate_type', estateType) cmd.put("calc_date", calcDate) - cmd.put("calc_type", 0) + cmd.put("calc_type", calcType) println(cmd) DBObject data = new BasicDBObject() data.put("category", "sell") From 2188b9f96ff9c82ce32f3fdbc436cfe1dbdd65fb Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 23 Aug 2024 11:06:30 +0800 Subject: [PATCH 003/230] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkoff/controllers/ApiUserController.java | 35 +++++++-- .../com/fangjia/bkoff/model/ApiUserModel.java | 28 ++++++- .../src/main/webapp/apiUser/add.ftl | 75 +++++++++++++++++-- .../src/main/webapp/apiUser/edit.ftl | 52 ++++++++++++- .../src/main/webapp/apiUser/list.ftl | 46 ++++++++++++ .../com/fangjia/dal/sql/model/ApiUser.java | 22 ++++++ .../com/fangjia/service/open/ApiUserBo.java | 20 +++++ 7 files changed, 256 insertions(+), 22 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index 54be64383..995111eb3 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -89,7 +89,24 @@ public class ApiUserController { * @param ApiUser * :用户的appKey username、等资料 */ - List apiUsers = this.apiUserService.findApiUsersByParamsSortDate(null); + ArrayList queryParams = new ArrayList(); + if (model.getStatus() != null) { + queryParams.add(new QueryParam("status", model.getStatus())); + }else { + queryParams.add(new QueryParam("status",0)); + } + if (model.getIsTest()!=null){ + queryParams.add(new QueryParam("isTest",model.getIsTest())); + }else { + queryParams.add(new QueryParam("isTest",0)); + } + if (model.getPurpose()!=null){ + queryParams.add(new QueryParam("purpose",model.getPurpose())); + }else { + queryParams.add(new QueryParam("purpose",1)); + } + + List apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams); List apiUserBoList = new ArrayList(); for (ApiUser apiUser : apiUsers) { User user = this.userService.findById(apiUser.getId()); @@ -195,6 +212,8 @@ public class ApiUserController { apiUser.setDeadTime(model.getDeadTime()); apiUser.setManager(model.getManager()); apiUser.setIsMonitor(model.getIsMonitor()); + apiUser.setContact(model.getContact()); + apiUser.setPhone(model.getPhone()); this.apiUserService.save(apiUser); // 新增用户,默认挂牌价改为默认评估价 model.setPriceType("evaluate"); @@ -238,6 +257,8 @@ public class ApiUserController { bo.setDeadTime(apiUser.getDeadTime()); bo.setManager(apiUser.getManager()); bo.setIsMonitor(apiUser.getIsMonitor()); + bo.setContact(apiUser.getContact()); + bo.setPhone(apiUser.getPhone()); ApiUserCfg apiUserCfg_rate = apiUserCfgService.findByUserId(apiUser.getId(), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE); if (apiUserCfg_rate != null) { bo.setEvaluateRate((Double) apiUserCfg_rate.getCfgValue()); @@ -291,6 +312,8 @@ public class ApiUserController { dataApiUser.put("deadTime", model.getDeadTime()); dataApiUser.put("manager", model.getManager()); dataApiUser.put("isMonitor", model.getIsMonitor()); + dataApiUser.put("contact", model.getContact()); + dataApiUser.put("phone", model.getPhone()); this.apiUserService.update(dataApiUser, userId); // 更改用户密码 // this.userService.updateById(user,userId); @@ -1255,7 +1278,7 @@ public class ApiUserController { dataList.add(row); } - String dateStr ="("+ DateUtils.format(startDate, "yyyy/MM/dd") + "—" + DateUtils.format(endDate, "yyyy/MM/dd") +")"; + String dateStr = "(" + DateUtils.format(startDate, "yyyy/MM/dd") + "—" + DateUtils.format(endDate, "yyyy/MM/dd") + ")"; String fileName = "用户账号使用统计" + dateStr + ".xlsx"; // ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); String displayName = URLEncoder.encode(fileName, "UTF-8"); @@ -1265,10 +1288,10 @@ public class ApiUserController { Sheet sheet = workbook.createSheet("用户账号使用统计"); List head = Arrays.asList( "用户ID", "账号", "合同到期时间", "接口", "接口名称", "剩余使用次数", - "访问次数(近一周)", "日均访问量(近一周)","成功并有效(近一周)", "成功并无效(近一周)","失败次数(近一周)", - "访问次数(近一月)", "日均访问量(近一月)","成功并有效(近一月)", "成功并无效(近一月)","失败次数(近一月)", - "访问次数"+dateStr, "日均访问量"+dateStr,"成功并有效"+dateStr, "成功并无效"+dateStr,"失败次数"+dateStr - ); + "访问次数(近一周)", "日均访问量(近一周)", "成功并有效(近一周)", "成功并无效(近一周)", "失败次数(近一周)", + "访问次数(近一月)", "日均访问量(近一月)", "成功并有效(近一月)", "成功并无效(近一月)", "失败次数(近一月)", + "访问次数" + dateStr, "日均访问量" + dateStr, "成功并有效" + dateStr, "成功并无效" + dateStr, "失败次数" + dateStr + ); // 创建表头 Row headRow = sheet.createRow(0); for (int i = 0; i < head.size(); i++) { diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java index ad264fe9a..f77689d9e 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java @@ -40,6 +40,10 @@ public class ApiUserModel extends BaseModel { private Map priceRatingMap; private Integer isMonitor; + private String contact; + + private String phone; + public String getPriceType() { return priceType; } @@ -70,7 +74,7 @@ public class ApiUserModel extends BaseModel { private String type; private String citys;// spell private String unCheckCitys;// 页面反选的city - private int status; + private Integer status; private String uri; private boolean hasAuth; private boolean supportLatLng; @@ -378,15 +382,15 @@ public class ApiUserModel extends BaseModel { this.limit = limit; } - public int getStatus() { + public Integer getStatus() { return status; } - public void setStatus(int status) { + public void setStatus(Integer status) { this.status = status; } - public String getCompany() { + public String getCompany() { return company; } @@ -615,4 +619,20 @@ public class ApiUserModel extends BaseModel { public void setIsMonitor(Integer isMonitor) { this.isMonitor = isMonitor; } + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } } diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl index 2f3071de2..6520d44c3 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl @@ -34,12 +34,12 @@
鏄电О - + 鐢ㄦ埛鍚� - + 瀵嗙爜 @@ -59,7 +59,7 @@ 璐︽埛鐢ㄩ�� + 閿�鍞礋璐d汉 - + 鍏徃 - + 浼颁环璋冩暣姣旂巼 @@ -92,13 +92,21 @@ siteName - + 鍒版湡鏃堕棿 - + + 瀹㈡埛鑱旂郴浜� + + + + 瀹㈡埛鑱旂郴浜虹數璇� + + ip鍦板潃 + +
+ (姣忚涓�涓�,绗竴涓负鍙戦��,鍏朵綑鎶勯��,浠� | 缁撳熬)
+ 渚嬪瓙锛�
+ 123456@qq.com|
+ 88888@163.com|
+ 987654@gmail.com +
+ 閿�鍞礋璐d汉 diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl index 4ee6b860f..22d4a3ef9 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl @@ -97,7 +97,19 @@ Email - + +
+ +
+
+ (姣忚涓�涓�,绗竴涓负鍙戦��,鍏朵綑鎶勯��,浠� | 缁撳熬)
+ 渚嬪瓙锛�
+ 123456@qq.com|
+ 88888@163.com|
+ 987654@gmail.com +
+ 閿�鍞礋璐d汉 From e98510ae1afc2e33d79ea378eace70d6ddb03655 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 27 Aug 2024 16:02:50 +0800 Subject: [PATCH 013/230] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8A=A0=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAemail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl | 6 +++--- projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl index c40808e6e..0681d3bfe 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl @@ -81,10 +81,10 @@ style="height: 100px;width: 250px;float: left">${email!}
- (姣忚涓�涓�,绗竴涓负鍙戦��,鍏朵綑鎶勯��,浠� | 缁撳熬)
+ (姣忚涓�涓�,绗竴涓负鍙戦��,鍏朵綑鎶勯��)
渚嬪瓙锛�
- 123456@qq.com|
- 88888@163.com|
+ 123456@qq.com
+ 88888@163.com
987654@gmail.com
diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl index 22d4a3ef9..cc656fb8e 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl @@ -103,10 +103,10 @@ style="height: 100px;width: 250px;float: left">${apiUserBo.email!}
- (姣忚涓�涓�,绗竴涓负鍙戦��,鍏朵綑鎶勯��,浠� | 缁撳熬)
+ (姣忚涓�涓�,绗竴涓负鍙戦��,鍏朵綑鎶勯��)
渚嬪瓙锛�
- 123456@qq.com|
- 88888@163.com|
+ 123456@qq.com
+ 88888@163.com
987654@gmail.com
From 47faa451d0080017788b679ee9594d706c258292 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 28 Aug 2024 15:57:34 +0800 Subject: [PATCH 014/230] =?UTF-8?q?API=E6=8E=A5=E5=8F=A3=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/ApiCountLogController.java | 84 +++++++++++++ .../bkoff/controllers/ApiUserController.java | 42 ++++++- .../fangjia/bkoff/model/ApiCountLogModel.java | 116 ++++++++++++++++++ .../src/main/webapp/apiCountLog/list.ftl | 61 +++++++++ .../src/main/webapp/apiUser/auth.ftl | 39 ++++++ .../src/main/webapp/js/apiUser/auth.js | 58 ++++++++- .../src/main/webapp/layout/menu.ftl | 1 + .../fangjia/dal/mongo/dao/ApiCountLogDao.java | 9 ++ .../dal/mongo/dao/ApiCountLogDaoImpl.java | 9 ++ .../fangjia/dal/mongo/model/ApiCountLog.java | 116 ++++++++++++++++++ .../mongo/fangjia/ApiCountLogService.java | 17 +++ .../mongo/fangjia/ApiCountLogServiceImpl.java | 45 +++++++ 12 files changed, 595 insertions(+), 2 deletions(-) create mode 100644 projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiCountLogController.java create mode 100644 projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiCountLogModel.java create mode 100644 projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDaoImpl.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogService.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogServiceImpl.java diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiCountLogController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiCountLogController.java new file mode 100644 index 000000000..5b263ce18 --- /dev/null +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiCountLogController.java @@ -0,0 +1,84 @@ +package com.fangjia.bkoff.controllers; + +import com.alibaba.excel.util.DateUtils; +import com.fangjia.bkoff.model.ApiCountLogModel; +import com.fangjia.bkoff.model.ApiUserModel; +import com.fangjia.bkoff.model.JsonModel; +import com.fangjia.core.util.*; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.ApiCountLog; +import com.fangjia.dal.mongo.model.ApiInvokeStatistical; +import com.fangjia.dal.mongo.model.ApiUserCfg; +import com.fangjia.dal.mongo.model.bkoff.BkoffUsers; +import com.fangjia.dal.mongo.open.model.ApiJsonViewConfig; +import com.fangjia.dal.mongo.open.model.ApiUserAuthority; +import com.fangjia.dal.mongo.open.model.OpenResource; +import com.fangjia.dal.mongo.tool.model.ApiCountCity; +import com.fangjia.dal.mongo.tool.model.ApiVisitCount; +import com.fangjia.dal.mongo.tool.model.OpenResourceCount; +import com.fangjia.dal.mongo.tool.model.OpenUriAnaly; +import com.fangjia.dal.sql.model.ApiUser; +import com.fangjia.dal.sql.model.User; +import com.fangjia.service.api.ApiUserCfgService; +import com.fangjia.service.mongo.bkoff.ApiInvokeStatisticalService; +import com.fangjia.service.mongo.bkoff.BkoffUsersService; +import com.fangjia.service.mongo.fangjia.ApiCountLogService; +import com.fangjia.service.mongo.fangjia.ServerAreaService; +import com.fangjia.service.open.*; +import com.fangjia.service.sql.ApiUserService; +import com.fangjia.service.sql.UserService; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.json.JSONArray; +import org.sothis.core.util.CollectionUtils; +import org.sothis.core.util.Pager; +import org.sothis.web.mvc.ActionContext; +import org.sothis.web.mvc.annotation.Param; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.*; + + +/** + * api用户开通等管理controller + * + * @author + */ +public class ApiCountLogController { + private BkoffUsersService bkoffUsersService; + private ApiCountLogService apiCountLogService; + + public Object listAction(ApiCountLogModel model) { + Pager pager = model.getPager(30); + if (pager.getCurrentPage() > 100) { + pager.setCurrentPage(1); + } + List apiCountLogList = apiCountLogService.findApiCountLog(model.getUserId(), model.getUri(),pager); + model.setApiCountLogList(apiCountLogList); + pager.setTotalRows(apiCountLogList.size()); + model.setPager(pager); + return model; + } + public void setBkoffUsersService(BkoffUsersService bkoffUsersService) { + this.bkoffUsersService = bkoffUsersService; + } + + public void setApiCountLogService(ApiCountLogService apiCountLogService) { + this.apiCountLogService = apiCountLogService; + } +} diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index ff97e7722..2acac8e27 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -9,8 +9,10 @@ import com.fangjia.bkoff.model.JsonModel; import com.fangjia.core.util.*; import com.fangjia.dal.QueryParam; import com.fangjia.dal.mongo.fangjia.model.ServerArea; +import com.fangjia.dal.mongo.model.ApiCountLog; import com.fangjia.dal.mongo.model.ApiInvokeStatistical; import com.fangjia.dal.mongo.model.ApiUserCfg; +import com.fangjia.dal.mongo.model.bkoff.BkoffUsers; import com.fangjia.dal.mongo.open.model.ApiJsonViewConfig; import com.fangjia.dal.mongo.open.model.ApiUserAuthority; import com.fangjia.dal.mongo.open.model.OpenResource; @@ -22,6 +24,8 @@ import com.fangjia.dal.sql.model.ApiUser; import com.fangjia.dal.sql.model.User; import com.fangjia.service.api.ApiUserCfgService; import com.fangjia.service.mongo.bkoff.ApiInvokeStatisticalService; +import com.fangjia.service.mongo.bkoff.BkoffUsersService; +import com.fangjia.service.mongo.fangjia.ApiCountLogService; import com.fangjia.service.mongo.fangjia.ServerAreaService; import com.fangjia.service.open.*; import com.fangjia.service.sql.ApiUserService; @@ -73,6 +77,8 @@ public class ApiUserController { private ApiInvokeStatisticalService apiInvokeStatisticalService; private ApiVisitCountService apiVisitCountService; private ApiCountCityService apiCountCityService; + private BkoffUsersService bkoffUsersService; + private ApiCountLogService apiCountLogService; /** * 所有api用户的信息展示 @@ -697,6 +703,9 @@ public class ApiUserController { public Object saveAuthAction(ApiUserModel model, HttpServletRequest request) throws IllegalAccessException { + List openResourceList = openResourceService.findAll(); + Map apiMap = converMapData(openResourceList); + model.setViewType("json"); model.setViewParam("config", null); Long userId = model.getUserId(); @@ -710,6 +719,7 @@ public class ApiUserController { authority.setSupportLatLng(model.isSupportLatLng()); apiUserAuthorityService.save(authority); } else { + Map countMap = authority.getTotalCountMap(); if (model.getLimit() != null) { Map limitCountMap = authority.getLimitCountMap(); if (limitCountMap == null) { @@ -723,7 +733,29 @@ public class ApiUserController { if (totalCountMap == null) { totalCountMap = new HashMap(); } - totalCountMap.put(model.getUri(), model.getSum()); + Integer count = model.getSum(); + //增加次数修改日志 + ApiCountLog apiCountLog = new ApiCountLog(); + if (countMap != null && countMap.containsKey(model.getUri())) { + String bkoffUserId = (String) ThreadLocalData.getInstance().get(ThreadLocalKey.UserId); + BkoffUsers bkoffUser = bkoffUsersService.findBkoffUsersById(bkoffUserId); + apiCountLog.setUserId(userId); + apiCountLog.setUri(model.getUri()); + apiCountLog.setUriName(apiMap.get(model.getUri())); + apiCountLog.setOperator(bkoffUser.getRealName()); + Integer oldCount = countMap.get(model.getUri()); + apiCountLog.setOldCount(oldCount); + apiCountLog.setNewCount(count); + if (count >= oldCount){ + apiCountLog.setOperate("增加"+(count-oldCount)+"次"); + }else if (oldCount > count){ + apiCountLog.setOperate("减少"+(oldCount-count)+"次"); + } + + apiCountLog.setOperateTime(new Date()); + apiCountLogService.save(apiCountLog); + } + totalCountMap.put(model.getUri(), count); authority.setTotalCountMap(totalCountMap); } if (model.getIsCheckCount() != null) { @@ -2052,4 +2084,12 @@ public class ApiUserController { model.setViewParam("location", "/apiUser/list"); return model; } + + public void setBkoffUsersService(BkoffUsersService bkoffUsersService) { + this.bkoffUsersService = bkoffUsersService; + } + + public void setApiCountLogService(ApiCountLogService apiCountLogService) { + this.apiCountLogService = apiCountLogService; + } } diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiCountLogModel.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiCountLogModel.java new file mode 100644 index 000000000..61045484b --- /dev/null +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiCountLogModel.java @@ -0,0 +1,116 @@ +package com.fangjia.bkoff.model; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fangjia.dal.mongo.model.ApiCountLog; +import com.fangjia.dal.mongo.model.Township; + +import java.util.Date; +import java.util.List; + +public class ApiCountLogModel extends BaseModel { + @JSONField(name = "id") + private String id; + + @JSONField(name = "user_id") + private Long userId; + @JSONField(name = "uri") + private String uri; + @JSONField(name = "user_name") + private String uriName; + @JSONField(name = "operate") + private String operate; + @JSONField(name = "operator") + private String operator; + + @JSONField(name = "operate_time") + private Date operateTime; + + // 修改次数前总次数 + @JSONField(name = "old_count") + private Integer oldCount; + // 修改次数后的次数 + @JSONField(name = "new_count") + private Integer newCount; + private List apiCountLogList; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public String getUriName() { + return uriName; + } + + public void setUriName(String uriName) { + this.uriName = uriName; + } + + public String getOperate() { + return operate; + } + + public void setOperate(String operate) { + this.operate = operate; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public Date getOperateTime() { + return operateTime; + } + + public void setOperateTime(Date operateTime) { + this.operateTime = operateTime; + } + + public Integer getOldCount() { + return oldCount; + } + + public void setOldCount(Integer oldCount) { + this.oldCount = oldCount; + } + + public Integer getNewCount() { + return newCount; + } + + public void setNewCount(Integer newCount) { + this.newCount = newCount; + } + + public List getApiCountLogList() { + return apiCountLogList; + } + + public void setApiCountLogList(List apiCountLogList) { + this.apiCountLogList = apiCountLogList; + } +} + diff --git a/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl b/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl new file mode 100644 index 000000000..5c5f75cfa --- /dev/null +++ b/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl @@ -0,0 +1,61 @@ +<#ftl attributes={"content_type":"text/html; charset=UTF-8"}> +<#compress> + + + + + 瀹㈡埛API娆℃暟鎿嶄綔鏃ュ織 + + + + + <#include "/common_js.ftl" /> + <#include "/layout/header.ftl" /> +
+ +
+ + + + + + +
+ +
+ 鏌ヨ鍒�${pager.totalRows!}鏉¤褰� + + + + + + + + + + + + <#list apiCountLogList as it> + + + + + + + + + + + +
鐢ㄦ埛IDuriAPI鍚嶇О鎿嶄綔鍘熸鏁�鐜版鏁�鎿嶄綔浜哄憳淇敼鏃ユ湡
${it.userId!}${it.uri!}${it.uriName!}${it.operate!}${it.oldCount!}${it.newCount!}${it.operator!}${it.operateTime!?string("yyyy-MM-dd HH:mm:ss")}
+ <#if pager??> + <@d_pager controller="apiCountLog" action="list" currentPage=pager.currentPage totalPages=pager.totalPages theme="full"/> + +
+
+ + + \ No newline at end of file diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl index 9e0ea31e6..0a4f1da6f 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl @@ -7,6 +7,11 @@ api鐢ㄦ埛鏉冮檺鎺у埗 + + + + + <#include "/common_js.ftl" /> @@ -65,6 +70,9 @@ 璁块棶鏈�澶ф鏁�(姣忓ぉ)/(鎬绘暟) + + 璁块棶娆℃暟淇敼 + 鏄惁鎸夋煡寰楄璐�鍏ㄩ�� @@ -104,6 +112,14 @@ + + + + checked id="isCheckCount_${bo_index + 1}" > @@ -111,6 +127,9 @@ + + + @@ -130,6 +149,26 @@ +
脳 diff --git a/projects/fangjia-bkoff/src/main/webapp/js/apiUser/auth.js b/projects/fangjia-bkoff/src/main/webapp/js/apiUser/auth.js index 605dc4c3e..4775844c6 100644 --- a/projects/fangjia-bkoff/src/main/webapp/js/apiUser/auth.js +++ b/projects/fangjia-bkoff/src/main/webapp/js/apiUser/auth.js @@ -112,4 +112,60 @@ $(document).ready(function() { }); }); - }); \ No newline at end of file + // 褰撶偣鍑�"澧炲姞"鎸夐挳鏃� + $('button[data-target="#myModal"]').click( + function () { + + var idNum = $(this).closest('tr').index() + 1; // 鑾峰彇鎸夐挳鎵�鍦ㄨ鐨勭储寮� + var isAdd = $(this).attr('id').startsWith('add'); // 鍒ゆ柇鏄鍔犺繕鏄噺灏� + + // 鍔ㄦ�佽缃ā鎬佹鏍囬 + if (isAdd) { + $('#myModalLabel').text('澧炲姞娆℃暟'); + } else { + $('#myModalLabel').text('鍑忓皯娆℃暟'); + } + + // 缁戝畾淇敼娆℃暟鐨勫姛鑳� + $('#submitCount').unbind('click').click(function() { + modifyCount(isAdd, idNum); + }); + + + // var id_num = $(this).closest('tr').index(); + // var totalInputId = '#sum_' + (id_num + 1); + // var totalValue = parseInt($(totalInputId).val()) || 0; // 鑾峰彇褰撳墠鎬绘鏁扮殑鍊� + // + // // 瑙i櫎涔嬪墠鐨勭粦瀹氫簨浠� + // $('#editSubmit').unbind('click').click(function () { + // var addedCount = parseInt($('#cityPop').val()) || 0; // 鑾峰彇鐢ㄦ埛杈撳叆鐨勬鏁� + // + // var newTotal = totalValue + addedCount; // 灏嗚緭鍏ョ殑娆℃暟鍔犲埌褰撳墠鎬绘鏁颁笂 + // + // $(totalInputId).val(newTotal); // 鏇存柊鎬绘鏁拌緭鍏ユ鐨勫�� + // + // $("input[id='save_"+(id_num+1)+"']").trigger('click'); + // }); + }); + + function modifyCount(isAdd, idNum) { + var totalInputId = '#sum_' + idNum; + var totalValue = parseInt($(totalInputId).val()) || 0; // 鑾峰彇褰撳墠鎬绘鏁扮殑鍊� + var count = parseInt($('#countInput').val()) || 0; // 鑾峰彇鐢ㄦ埛杈撳叆鐨勬鏁� + + var newTotal = isAdd ? totalValue + count : totalValue - count; // 鏍规嵁澧炲姞鎴栧噺灏戣绠楁柊鐨勬�绘鏁� + + if (newTotal < 0) { + newTotal = 0; // 纭繚鎬绘鏁颁笉涓鸿礋鏁� + } + + $(totalInputId).val(newTotal); // 鏇存柊鎬绘鏁拌緭鍏ユ鐨勫�� + $('#countInput').val(''); // 娓呯┖杈撳叆妗嗙殑鍊� + + + // 璋冪敤 #auth 鐨勭偣鍑讳簨浠讹紙鏍规嵁闇�姹傦級 + $("input[id='save_"+(idNum)+"']").trigger('click'); + } + + +}); \ No newline at end of file diff --git a/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl b/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl index 339840223..2b326e80e 100644 --- a/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl @@ -295,6 +295,7 @@ <@menuitem uri='/creditRate/list' text="浠锋牸鍙俊搴︿笌鍖归厤鐜囧叧绯�" /> <@menuitem uri='/czBank/sampleLogs' text="娴欏晢閾惰" /> <@menuitem uri='/villageIdentify/importResult' text="娑夊啘缁撴灉瀵煎叆" /> + <@menuitem uri='/apiCountLog/list' text="API娆℃暟鏃ュ織" /> diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDao.java new file mode 100644 index 000000000..d60612775 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.ApiCountLog; +import com.fangjia.dal.mongo.model.DevelopmentZone; + +public interface ApiCountLogDao extends MongoDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDaoImpl.java new file mode 100644 index 000000000..4bfa0ebc0 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/ApiCountLogDaoImpl.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.ApiCountLog; +import com.fangjia.dal.mongo.model.DevelopmentZone; + +public class ApiCountLogDaoImpl extends MongoDaoImpl implements ApiCountLogDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java new file mode 100644 index 000000000..32a112ff3 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java @@ -0,0 +1,116 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +@Entity +@Table(name = "business.api_count_log") +public class ApiCountLog implements MongoEntity { + + private String id; + + private Long userId; + + private String uri; + + private String uriName; + + private String operate; + + private String operator; + + private Date operateTime; + + // 修改次数前总次数 + private Integer oldCount; + // 修改次数后的次数 + private Integer newCount; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "_id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "user_id") + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + @Column(name = "uri") + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + @Column(name = "uri_name") + public String getUriName() { + return uriName; + } + + public void setUriName(String uriName) { + this.uriName = uriName; + } + + @Column(name = "operate") + public String getOperate() { + return operate; + } + + public void setOperate(String operate) { + this.operate = operate; + } + + @Column(name = "operator") + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + @Column(name = "operate_time") + public Date getOperateTime() { + return operateTime; + } + + public void setOperateTime(Date operateTime) { + this.operateTime = operateTime; + } + + @Column(name = "old_count") + public Integer getOldCount() { + return oldCount; + } + + public void setOldCount(Integer oldCount) { + this.oldCount = oldCount; + } + + @Column(name = "new_count") + public Integer getNewCount() { + return newCount; + } + + public void setNewCount(Integer newCount) { + this.newCount = newCount; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogService.java new file mode 100644 index 000000000..a664bb95c --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogService.java @@ -0,0 +1,17 @@ +package com.fangjia.service.mongo.fangjia; + +import com.fangjia.dal.mongo.model.ApiCountLog; +import com.fangjia.dal.mongo.model.DevelopmentZone; +import org.sothis.core.util.Pager; + +import java.util.List; +import java.util.Map; + +/** + * Created by dxy on 2015/6/8. + */ +public interface ApiCountLogService { + void save(ApiCountLog apiCountLog); + + List findApiCountLog(Long userId,String uri,Pager pager); +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogServiceImpl.java new file mode 100644 index 000000000..e5822841e --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/ApiCountLogServiceImpl.java @@ -0,0 +1,45 @@ +package com.fangjia.service.mongo.fangjia; + +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.dao.AdministrativeMappingDao; +import com.fangjia.dal.mongo.dao.ApiCountLogDao; +import com.fangjia.dal.mongo.dao.DevelopmentZoneDao; +import com.fangjia.dal.mongo.model.AdministrativeMapping; +import com.fangjia.dal.mongo.model.ApiCountLog; +import com.fangjia.dal.mongo.model.DevelopmentZone; +import org.apache.commons.lang.StringUtils; +import org.sothis.core.util.Pager; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +public class ApiCountLogServiceImpl implements ApiCountLogService { + private ApiCountLogDao apiCountLogDao; + + @Override + public void save(ApiCountLog apiCountLog) { + apiCountLogDao.save(apiCountLog); + } + + @Override + public List findApiCountLog(Long userId, String uri,Pager pager) { + List params = new ArrayList(); + if (userId!= null) { + params.add(new QueryParam("userId", userId)); + } + if (StringUtils.isNotBlank(uri)) { + Pattern pattern = Pattern.compile(".*" + uri + ".*"); + params.add(new QueryParam("uri", pattern)); + } + List sortParam = Arrays.asList(new SortParam("operateTime", false)); + return apiCountLogDao.findAllByParams(params,sortParam, pager.getStartRow(), pager.getPageSize()); + } + + public void setApiCountLogDao(ApiCountLogDao apiCountLogDao) { + this.apiCountLogDao = apiCountLogDao; + } +} From a9b8e954ca802c1e25bbac142c15c8274fa333c7 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 30 Aug 2024 15:06:33 +0800 Subject: [PATCH 015/230] =?UTF-8?q?=E5=9B=BD=E4=BF=A1=E6=89=80=E9=9C=80?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 313 ++++++++++++++++-- .../dto/addressGovernance/DistrictDto.java | 9 + 2 files changed, 290 insertions(+), 32 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 28f780026..6f0117e55 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -20,6 +20,7 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpEntity; @@ -42,6 +43,7 @@ import java.net.InetSocketAddress; import java.net.PasswordAuthentication; import java.net.Proxy; import java.nio.charset.Charset; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -78,14 +80,17 @@ public class AddrSvcController { Map params = new HashMap(); params.put("city", model.getCity()); params.put("address", model.getAddress()); + params.put("addressAssessment","true"); try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure/v2", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/formatNinelevel", params, "UTF-8"); if (json != null) { int code = json.getInt("status"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { - basicModel.setResult(CommonDtoUtils.transformV(StructureDto.class, json.get("result"))); + JSONObject result = json.getJSONObject("result"); + result.remove("formatAddress"); + basicModel.setResult(result); } mav.setModel(basicModel); } else { @@ -118,13 +123,27 @@ public class AddrSvcController { params.put("city", model.getCity()); params.put("address", model.getAddress()); try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); if (json != null) { int code = json.getInt("status"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { - basicModel.setResult(CommonDtoUtils.transformV(DistrictIdentifyDto.class, json.get("result"))); + DistrictIdentifyDto districtIdentifyDto = CommonDtoUtils.transformV(DistrictIdentifyDto.class, json.get("result")); + JSONObject result = json.getJSONObject("result"); + if (result.containsKey("town")) { + districtIdentifyDto.setTownship(result.getString("town")); + } + if (result.containsKey("townCode")) { + districtIdentifyDto.setTownshipCode(result.getString("townCode")); + } + if (result.containsKey("committee")) { + districtIdentifyDto.setCommunity(result.getString("committee")); + } + if (result.containsKey("committeeCode")) { + districtIdentifyDto.setCommunityCode(result.getString("committeeCode")); + } + basicModel.setResult(districtIdentifyDto); } mav.setModel(basicModel); } else { @@ -268,17 +287,17 @@ public class AddrSvcController { params.put("region", model.getRegion()); params.put("keywords", model.getKeywords()); params.put("page", "0"); - params.put("size", String.valueOf(model.getMax() == 0 ? 20 : (model.getMax() > 100 ? 100 : model.getMax()))); + params.put("offset", String.valueOf(model.getMax() == 0 ? 10 : (model.getMax() > 100 ? 100 : model.getMax()))); try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addressAssociation2", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); if (json != null) { - int code = json.getInt("status"); + int code = json.getInt("msgCode"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { - JSONObject result = (JSONObject.fromObject(json.get("result"))); - if (result.getInt("totalElements") > 0) { - basicModel.setResult(CommonDtoUtils.transformListV(DistrictDto.class, result.getJSONArray("content"))); + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray.size() > 0) { + basicModel.setResult(CommonDtoUtils.transformListV(DistrictDto.class,jsonArray)); } } mav.setModel(basicModel); @@ -513,7 +532,7 @@ public class AddrSvcController { if (map.get("city").endsWith("区")) { return "否"; } - if (map.get("city").equals("东莞市") || map.get("city").equals("嘉峪关市") || map.get("city").equals("中山市") || map.get("city").equals("儋州市") ) { + if (map.get("city").equals("东莞市") || map.get("city").equals("嘉峪关市") || map.get("city").equals("中山市") || map.get("city").equals("儋州市")) { return "否"; } return "是"; @@ -526,7 +545,7 @@ public class AddrSvcController { * @return */ public String addrArea(Map map, String type) { - if (map.get("verifyFlag") == null ) { + if (map.get("verifyFlag") == null) { return ""; } if (map.get("verifyFlag").equals("非农")) { @@ -675,27 +694,27 @@ public class AddrSvcController { VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null; if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) { Map resultMap = new HashMap(); - resultMap.put("province",villageResult.getProvince()); - resultMap.put("city",villageResult.getCity1()); - resultMap.put("district",villageResult.getDistrict()); - resultMap.put("town",villageResult.getTown()); - resultMap.put("committee",villageResult.getCommittee()); - resultMap.put("provinceCode",villageResult.getCityCode()); - resultMap.put("cityCode",villageResult.getCityCode()); - resultMap.put("districtCode",villageResult.getDistrictCode()); - resultMap.put("townCode",villageResult.getTownCode()); - resultMap.put("committeeCode",villageResult.getCommitteeCode()); - resultMap.put("typeCode",villageResult.getTypeCode()); - resultMap.put("typeName",villageResult.getTypeName()); - resultMap.put("verifyFlag",villageResult.getVerifyFlag()); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); resultMap.put("addrVerify", villageResult.getAddrVerify()); - resultMap.put("countyLevelCity",villageResult.getCountyLevelCity()); - resultMap.put("administrativeTowns",villageResult.getAdministrativeTowns()); - resultMap.put("countyGov",villageResult.getCountyGov()); - resultMap.put("devDistrict",villageResult.getDevDistrict()); - resultMap.put("devDistrictName",villageResult.getDevDistrictName()); - resultMap.put("devLevel",villageResult.getDevLevel()); - resultMap.put("addrArea",villageResult.getAddrArea()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); BasicModel basicModel = new BasicModel(200, "OK"); basicModel.setResult(resultMap); mav.setModel(basicModel); @@ -994,6 +1013,236 @@ public class AddrSvcController { return mav; } + /** + * 市级行政区划查询接口 + * + * @param model + * @return + */ + public Object listCityAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + map.put("id", result.getString("id")); + map.put("province", result.getString("province")); + map.put("provinceCode", result.getString("tjjProvinceCode")); + map.put("city", result.getString("city")); + map.put("cityCode", result.getString("tjjCityCode")); + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 省级行政区划查询接口 + * + * @param model + * @return + */ + public Object listProvinceAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + map.put("id", result.getString("id")); + map.put("province", result.getString("province")); + map.put("provinceCode", result.getString("mzbProvinceCode")); + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 区域级行政区划查询接口 + * @param model + * @return + */ + public Object listDistrictAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + map.put("id", result.getString("id")); + map.put("province", result.getString("province")); + map.put("provinceCode", result.getString("tjjProvinceCode")); + map.put("city", result.getString("city")); + map.put("cityCode", result.getString("tjjCityCode")); + map.put("district", result.getString("district")); + map.put("districtCode", result.getString("tjjDistrictCode")); + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + public Object listTownshipAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + map.put("id", result.getString("id")); + map.put("province", result.getString("province")); + map.put("provinceCode", result.getString("tjjProvinceCode")); + map.put("city", result.getString("city")); + map.put("cityCode", result.getString("tjjCityCode")); + map.put("district", result.getString("district")); + map.put("districtCode", result.getString("tjjDistrictCode")); + map.put("street", result.getString("street")); + map.put("streetCode", result.getString("tjjStreetCode")); + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + public Object levelAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + JSONObject result = json.getJSONObject("result"); + basicModel.setResult(result); + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + public void setDistrictStatService(DistrictStatService districtStatService) { this.districtStatService = districtStatService; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/addressGovernance/DistrictDto.java b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/addressGovernance/DistrictDto.java index cc71dcf21..8f99dee2a 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/dto/addressGovernance/DistrictDto.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/dto/addressGovernance/DistrictDto.java @@ -7,6 +7,7 @@ public class DistrictDto { private String region; private String name; private String address; + private String district; public String getProvince() { return province; @@ -47,4 +48,12 @@ public class DistrictDto { public void setAddress(String address) { this.address = address; } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } } \ No newline at end of file From d21c97d31cd3842b1dc84f3a4d7162febea98fa6 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 30 Aug 2024 15:48:47 +0800 Subject: [PATCH 016/230] =?UTF-8?q?=E5=9B=BD=E4=BF=A1=E6=89=80=E9=9C=80?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/AddrSvcController.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 6f0117e55..39602ef5d 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -80,13 +80,13 @@ public class AddrSvcController { Map params = new HashMap(); params.put("city", model.getCity()); params.put("address", model.getAddress()); - params.put("addressAssessment","true"); + params.put("addressAssessment", "true"); try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/formatNinelevel", params, "UTF-8"); if (json != null) { int code = json.getInt("status"); String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); + BasicModel basicModel = new BasicModel(code == 0 ? 200 : 0, msg); if (json.containsKey("result")) { JSONObject result = json.getJSONObject("result"); result.remove("formatAddress"); @@ -127,7 +127,7 @@ public class AddrSvcController { if (json != null) { int code = json.getInt("status"); String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); + BasicModel basicModel = new BasicModel(code == 0 ? 200 : 0, msg); if (json.containsKey("result")) { DistrictIdentifyDto districtIdentifyDto = CommonDtoUtils.transformV(DistrictIdentifyDto.class, json.get("result")); JSONObject result = json.getJSONObject("result"); @@ -284,7 +284,7 @@ public class AddrSvcController { JSONObject json = null; Map params = new HashMap(); params.put("city", model.getCity()); - params.put("region", model.getRegion()); + params.put("district", model.getRegion()); params.put("keywords", model.getKeywords()); params.put("page", "0"); params.put("offset", String.valueOf(model.getMax() == 0 ? 10 : (model.getMax() > 100 ? 100 : model.getMax()))); @@ -297,7 +297,7 @@ public class AddrSvcController { if (json.containsKey("result")) { JSONArray jsonArray = json.getJSONArray("result"); if (jsonArray.size() > 0) { - basicModel.setResult(CommonDtoUtils.transformListV(DistrictDto.class,jsonArray)); + basicModel.setResult(CommonDtoUtils.transformListV(DistrictDto.class, jsonArray)); } } mav.setModel(basicModel); @@ -969,6 +969,7 @@ public class AddrSvcController { * @param model * @return */ + @Deprecated public Object addressAssociationAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); @@ -1111,6 +1112,7 @@ public class AddrSvcController { /** * 区域级行政区划查询接口 + * * @param model * @return */ @@ -1160,6 +1162,7 @@ public class AddrSvcController { } return mav; } + public Object listTownshipAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); HttpRequest request = new HttpRequest(); From 820eac09a29034a2d195024e230a12003382f781 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 2 Sep 2024 10:01:27 +0800 Subject: [PATCH 017/230] =?UTF-8?q?=E8=81=94=E6=83=B3=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E7=94=A8district?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/AddrSvcController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 39602ef5d..9893c6e7c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -284,7 +284,7 @@ public class AddrSvcController { JSONObject json = null; Map params = new HashMap(); params.put("city", model.getCity()); - params.put("district", model.getRegion()); + params.put("district", model.getDistrict()); params.put("keywords", model.getKeywords()); params.put("page", "0"); params.put("offset", String.valueOf(model.getMax() == 0 ? 10 : (model.getMax() > 100 ? 100 : model.getMax()))); From 6ce9094eba40db446068293151f9caaf9675da69 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 2 Sep 2024 11:45:18 +0800 Subject: [PATCH 018/230] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=8C=BA=E6=97=A0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4=E6=8A=A5=E9=94=99=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/developmentZone/list.ftl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-bkoff/src/main/webapp/developmentZone/list.ftl b/projects/fangjia-bkoff/src/main/webapp/developmentZone/list.ftl index 1830544ca..2f35b4de7 100644 --- a/projects/fangjia-bkoff/src/main/webapp/developmentZone/list.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/developmentZone/list.ftl @@ -74,7 +74,14 @@ ${it.operator!} - ${it.createTime!?string("yyyy-MM-dd HH:mm:ss")} + + <#if it.createTime??> + ${it.createTime!?string("yyyy-MM-dd HH:mm:ss")} + <#else> + + + + 鏌ョ湅 鏂板缓鍥存爮 From 42d16cde8f2ceb85db2fdb5e022054ae2cc01188 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 2 Sep 2024 14:08:27 +0800 Subject: [PATCH 019/230] =?UTF-8?q?api=E6=AC=A1=E6=95=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0=E5=AE=A2=E6=88=B7=E6=98=B5?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkoff/controllers/ApiUserController.java | 31 +++++++++++-------- .../src/main/webapp/apiCountLog/list.ftl | 2 ++ .../src/main/webapp/apiUser/auth.ftl | 4 +-- .../fangjia/dal/mongo/model/ApiCountLog.java | 11 +++++++ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index 2acac8e27..3f67b111c 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -98,16 +98,16 @@ public class ApiUserController { ArrayList queryParams = new ArrayList(); if (model.getStatus() != null) { queryParams.add(new QueryParam("status", model.getStatus())); - }else { - queryParams.add(new QueryParam("status",0)); + } else { + queryParams.add(new QueryParam("status", 0)); } - if (model.getIsTest()!=null){ - queryParams.add(new QueryParam("isTest",model.getIsTest())); - }else { - queryParams.add(new QueryParam("isTest",0)); + if (model.getIsTest() != null) { + queryParams.add(new QueryParam("isTest", model.getIsTest())); + } else { + queryParams.add(new QueryParam("isTest", 0)); } - if (model.getPurpose()!=null){ - queryParams.add(new QueryParam("purpose",model.getPurpose())); + if (model.getPurpose() != null) { + queryParams.add(new QueryParam("purpose", model.getPurpose())); } List apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams); List apiUserBoList = new ArrayList(); @@ -738,22 +738,27 @@ public class ApiUserController { ApiCountLog apiCountLog = new ApiCountLog(); if (countMap != null && countMap.containsKey(model.getUri())) { String bkoffUserId = (String) ThreadLocalData.getInstance().get(ThreadLocalKey.UserId); + User user = userService.findById(userId); BkoffUsers bkoffUser = bkoffUsersService.findBkoffUsersById(bkoffUserId); apiCountLog.setUserId(userId); + apiCountLog.setUserName(user.getDisplayName()); apiCountLog.setUri(model.getUri()); apiCountLog.setUriName(apiMap.get(model.getUri())); apiCountLog.setOperator(bkoffUser.getRealName()); Integer oldCount = countMap.get(model.getUri()); apiCountLog.setOldCount(oldCount); apiCountLog.setNewCount(count); - if (count >= oldCount){ - apiCountLog.setOperate("增加"+(count-oldCount)+"次"); - }else if (oldCount > count){ - apiCountLog.setOperate("减少"+(oldCount-count)+"次"); + if (count > oldCount) { + apiCountLog.setOperate("增加" + (count - oldCount) + "次"); + } else if (oldCount > count) { + apiCountLog.setOperate("减少" + (oldCount - count) + "次"); } apiCountLog.setOperateTime(new Date()); - apiCountLogService.save(apiCountLog); + // 次数改变了再记录 + if (!count.equals(oldCount)) { + apiCountLogService.save(apiCountLog); + } } totalCountMap.put(model.getUri(), count); authority.setTotalCountMap(totalCountMap); diff --git a/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl b/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl index 5c5f75cfa..06fbad4d6 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiCountLog/list.ftl @@ -30,6 +30,7 @@ + @@ -41,6 +42,7 @@ <#list apiCountLogList as it> + diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl index 0a4f1da6f..100afe5b8 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/auth.ftl @@ -106,9 +106,9 @@   / <#if bo.totalCountMap?? && bo.totalCountMap[bo.uri!]??> - + <#else> - + diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java index 32a112ff3..00b512da9 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/ApiCountLog.java @@ -16,6 +16,8 @@ public class ApiCountLog implements MongoEntity { private Long userId; + private String userName; + private String uri; private String uriName; @@ -113,4 +115,13 @@ public class ApiCountLog implements MongoEntity { public void setNewCount(Integer newCount) { this.newCount = newCount; } + + @Column(name = "user_name") + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } } From 7493c563c4aa6d2e9b075cd156ae1a9d58bd5562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 2 Sep 2024 15:39:34 +0800 Subject: [PATCH 020/230] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{trade => sync}/CopyOpenUriLog.groovy | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) rename projects/fangjia-script/src/main/groovy/com/fangjia/script/{trade => sync}/CopyOpenUriLog.groovy (66%) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/CopyOpenUriLog.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CopyOpenUriLog.groovy similarity index 66% rename from projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/CopyOpenUriLog.groovy rename to projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CopyOpenUriLog.groovy index 4b40b89e0..c00c4a79b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/CopyOpenUriLog.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/sync/CopyOpenUriLog.groovy @@ -1,28 +1,16 @@ -package com.fangjia.script.trade - - -import java.util.regex.Matcher - +package com.fangjia.script.sync +import com.fangjia.core.Constants import com.fangjia.script.BaseBatch; import com.fangjia.script.BatchOwner -import com.fangjia.script.util.DateUtils; - -import java.util.regex.Pattern - -import org.apache.commons.lang.StringUtils; - -import com.fangjia.core.util.StringUtil; -import com.fangjia.datastore.driver.DSCollection; -import com.fangjia.datastore.driver.DSCursor -import com.fangjia.datastore.driver.DataStore +import com.fangjia.script.util.DateUtils import com.mongodb.BasicDBObject import com.mongodb.DBCollection; import com.mongodb.DBObject -import com.fangjia.script.util.MongoUtils; +import com.fangjia.core.util.MongoUtils; import com.fangjia.script.Watcher; import com.mongodb.Bytes -import org.apache.commons.io.FileUtils + /** * 将线上open uri数据同步到192.168.0.60上 * @author gaojuan @@ -31,7 +19,7 @@ import org.apache.commons.io.FileUtils class CopyOpenUriLog extends BaseBatch{ - static DBCollection DESC_OPEN = MongoUtils.getCollectionByName("business", "open_uri_log", "seawater.mongo.db.fangjia.com", 27020) + static DBCollection DESC_OPEN = MongoUtils.getDbCollection(Constants.SEAWATER_MONGO_URI, "business", "open_uri_log") public static final DBCollection SOURCE_OPEN = MongoUtils.getCollectionByName("business", "open_uri_log", "log.mongo.db.fangjia.com", 52002) static main(String[] args){ runBatch(new CopyOpenUriLog(), args) From 7e37b8b793cfa69857ed42186abeb94aa497d5a8 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Sep 2024 11:21:56 +0800 Subject: [PATCH 021/230] =?UTF-8?q?api=E6=A0=B9=E6=8D=AE=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=EF=BC=8C=E9=80=89=E6=8B=A9=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/apiUser/list.ftl | 220 +++++++----------- 1 file changed, 86 insertions(+), 134 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl index 1275224a6..08c4c5c78 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl @@ -28,10 +28,28 @@ top: 0; background-color: #f2f2f2; } + .resizable-td { - resize: horizontal; /* 鍏佽姘村钩璋冩暣澶у皬 */ - overflow: auto; /* 鏄剧ず婊氬姩鏉′互渚挎煡鐪嬭秴鍑洪儴鍒� */ - min-width: 50px; /* 璁剧疆鏈�灏忓搴︼紝闃叉杩囦簬缂╁皬 */ + resize: horizontal; + overflow: auto; + min-width: 50px; + } + + .form-label { + font-size: 15px; + } + + .form-select { + font-size: 15px; + margin-right: 10px; + } + + .form-button { + font-size: 15px; + } + + .form-group { + display: inline-block; } @@ -51,16 +69,16 @@
- - +
- @@ -68,135 +86,54 @@
-
- +
鐢ㄦ埛ID鐢ㄦ埛鏄电О uri API鍚嶇О 鎿嶄綔
${it.userId!}${it.userName!} ${it.uri!} ${it.uriName!} ${it.operate!}
- - -<#-- --> - - - - - - - - - - + + + + + + + + + + + + - <#if (apiUserBoList??&&apiUserBoList?size>0)> + <#if (apiUserBoList?? && apiUserBoList?size > 0)> <#list apiUserBoList as bo> - style="background-color:#C3C3C3"> - - -<#-- --> - - - - - - - - - + style="background-color:#C3C3C3"> + + + + + + + + + + + @@ -205,24 +142,39 @@
- ID - - 鏄电О - --> -<#-- 璐︽埛鐢ㄩ��--> -<#-- - username - - password - - 閿�鍞礋璐d汉 - - 鍏徃 - - appKey - - 璐︽埛绫诲瀷 - - 璐︽埛鐢ㄩ�� - - 鏄惁鐩戞帶 - - 鍒版湡鏃堕棿 - - 鎿嶄綔 - ID鏄电Оusernamepassword閿�鍞礋璐d汉鍏徃appKey璐︽埛绫诲瀷璐︽埛鐢ㄩ��鏄惁鐩戞帶鍒版湡鏃堕棿鎿嶄綔
- ${bo.userId!} - - ${bo.displayName!} - --> -<#-- <#if bo.purpose?? && bo.purpose == 1>--> -<#-- API--> -<#-- <#elseif bo.purpose?? && bo.purpose == 2>--> -<#-- PDS--> -<#-- <#elseif bo.purpose?? && bo.purpose == 4>--> -<#-- 鎴跨敓娲�--> -<#-- --> -<#-- - ${bo.userName!} - - <#if bo.password?? && bo.password == t_util.md5Hex('123456')> - 鍒濆瀵嗙爜 - <#else> - ****** - - - ${bo.manager!} - - ${bo.company!} - - ${bo.appKey!} - - <#if bo.isTest==0> - 姝e紡璐︽埛 - <#elseif bo.isTest==1> - 娴嬭瘯璐︽埛 - <#else> - 鍐呴儴璐︽埛 - - - <#if bo.purpose?? && bo.purpose == 1> - API - <#elseif bo.purpose?? && bo.purpose == 2> - PDS - <#elseif bo.purpose?? && bo.purpose == 4> - 鎴跨敓娲� - - - <#if bo.isMonitor==1> - 鏄� - <#else> - 鍚� - - - <#if bo.deadTime??> - ${bo.deadTime?string("yyyy骞碝M鏈坉d鏃�")} - -
${bo.userId!}${bo.displayName!}${bo.userName!}<#if bo.password?? && bo.password == t_util.md5Hex('123456')>鍒濆瀵嗙爜<#else>******${bo.manager!}${bo.company!}${bo.appKey!}<#if bo.isTest == 0>姝e紡璐︽埛<#elseif bo.isTest == 1>娴嬭瘯璐︽埛<#else>鍐呴儴璐︽埛<#if bo.purpose?? && bo.purpose == 1>API<#elseif bo.purpose?? && bo.purpose == 2>PDS<#elseif bo.purpose?? && bo.purpose == 4>鎴跨敓娲�<#if bo.isMonitor == 1>鏄�<#else>鍚�<#if bo.deadTime??>${bo.deadTime?string("yyyy骞碝M鏈坉d鏃�")} API鏉冮檺鎺у埗 鏂板API 鍩庡競绠$悊 浠锋牸璇勭骇 - <#if bo.status==0> + <#if bo.status == 0> 绂佺敤 <#else> - 鍐嶅惎鐢� + 鍐嶅惎鐢�
+ - \ No newline at end of file From 13cc4bf574c6df8a77bfddf9183f129fab55f683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 3 Sep 2024 11:48:34 +0800 Subject: [PATCH 022/230] =?UTF-8?q?=E8=81=94=E6=83=B3=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=9D=9E=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/AddrSvcController.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 9893c6e7c..258d75236 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -271,10 +271,11 @@ public class AddrSvcController { public Object suggestionAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(BasicModel.buildBadRequestModel("城市不能为空")); - return mav; - } + // 城市改为非必填 +// if (StringUtils.isBlank(model.getCity())) { +// mav.setModel(BasicModel.buildBadRequestModel("城市不能为空")); +// return mav; +// } if (StringUtils.isBlank(model.getKeywords())) { mav.setModel(BasicModel.buildBadRequestModel("关键字不能为空")); return mav; From 8135d5fc17c3273e45b01e8ee8297aa3159d36c0 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Sep 2024 13:17:02 +0800 Subject: [PATCH 023/230] =?UTF-8?q?=E5=85=89=E5=A4=A7=E6=B6=89=E5=86=9C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/GdBankController.java | 83 ++++++++++++++----- 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java index fd1709bf3..304f4813b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/GdBankController.java @@ -50,6 +50,44 @@ public class GdBankController { } }; + /** + * 判断所属区域 + * + * @param map + * @return + */ + public String addrArea(Map map, String type) { + if (map.get("verifyFlag") == null) { + return ""; + } + if (map.get("verifyFlag").equals("非农")) { + return "城市区域"; + } + if (map.get("verifyFlag").equals("农")) { + return "农村区域"; + } + if ("2".equals(type) && "是".equals(map.get("countyGov"))) { + return "县城城区"; + } + return ""; + } + + /** + * 判断县级市 + */ + public String countyLevelCity(Map map) { + if (map.get("city") == null) { + return ""; + } + if (map.get("city").endsWith("区")) { + return "否"; + } + if (map.get("city").equals("东莞市") || map.get("city").equals("嘉峪关市") || map.get("city").equals("中山市") || map.get("city").equals("儋州市")) { + return "否"; + } + return "是"; + } + /** * 涉农识别-新规则-光大银行 * @@ -90,22 +128,16 @@ public class GdBankController { if (json.containsKey("result")) { //我们的结果 JSONObject result = json.getJSONObject("result"); - if (("是").equals(result.get("countyLevelCity"))) { - result.put("prefectureLevelCity", "否"); - } else if (("否").equals(result.get("countyLevelCity"))) { - result.put("prefectureLevelCity", "是"); - } - // 如果是无效信息或者没有行政区划,则用我们的 - if (result.containsKey("addrVerify") && ("无效".equals(result.getString("addrVerify")) || "没有行政区划".equals(result.getString("addrVerify")))) { + //我们省级及以上有开发区,直接用我们的结果 + if (result.containsKey("devDistrictName")) { basicModel.setResult(result); - //我们省级及以上有开发区,直接用我们的结果 - } else if (result.containsKey("devDistrictName")) { + + } else if (!"2".equals(type)) { // 对私的不用齐梁 basicModel.setResult(result); } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { - //结果比较,如果涉农结果不一致 //调用齐梁 type :1 对公 0 对私 //我们 type :1 对私 2 对共 @@ -113,23 +145,31 @@ public class GdBankController { Map map = senRequest(address, qltype); // 涉农结果不一样 if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { - //有市辖建制镇, 或者城市不一样 用我们 - if (result.containsKey("city") && ("是".equals(result.get("administrativeTowns")) || (!result.get("city").equals(map.get("city")) - && StringUtils.isNotBlank(result.getString("city"))))) { + // 齐梁县政府但是涉农为农,取我们的结果 扬中市三茅街道中华村永固河路1号 + if ("是".equals(map.get("countyGov")) && "农".equals(map.get("verifyFlag"))) { basicModel.setResult(result); + mav.setModel(basicModel); + return mav; + } + //城市不一样 用我们 + if (result.containsKey("city")) { + if ((!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { + basicModel.setResult(result); + } else { + map.put("addrVerify", "地址有效"); + map.put("typeName", areaMap.get(map.get("typeCode"))); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); + basicModel.setResult(map); + } } else { - if (("是").equals(result.get("countyLevelCity"))) { - map.put("prefectureLevelCity", "否"); - } else if (("否").equals(result.get("countyLevelCity"))) { - map.put("prefectureLevelCity", "是"); - } map.put("addrVerify", "地址有效"); - if (result.containsKey("countyLevelCity")) { - map.put("countyLevelCity", result.getString("countyLevelCity")); - } map.put("typeName", areaMap.get(map.get("typeCode"))); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); basicModel.setResult(map); } + } else { basicModel.setResult(result); } @@ -145,6 +185,7 @@ public class GdBankController { } } + } mav.setModel(basicModel); } else { From d19b33ca4464e5da2669b8ef059962bf2cccdc18 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Sep 2024 14:10:35 +0800 Subject: [PATCH 024/230] =?UTF-8?q?api=E6=A0=B9=E6=8D=AE=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=EF=BC=8C=E9=80=89=E6=8B=A9=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/apiUser/list.ftl | 236 +++++++++++------- .../src/main/webapp/layout/menu.ftl | 2 +- 2 files changed, 143 insertions(+), 95 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl index 08c4c5c78..f38b9b079 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/list.ftl @@ -28,28 +28,10 @@ top: 0; background-color: #f2f2f2; } - .resizable-td { - resize: horizontal; - overflow: auto; - min-width: 50px; - } - - .form-label { - font-size: 15px; - } - - .form-select { - font-size: 15px; - margin-right: 10px; - } - - .form-button { - font-size: 15px; - } - - .form-group { - display: inline-block; + resize: horizontal; /* 鍏佽姘村钩璋冩暣澶у皬 */ + overflow: auto; /* 鏄剧ず婊氬姩鏉′互渚挎煡鐪嬭秴鍑洪儴鍒� */ + min-width: 50px; /* 璁剧疆鏈�灏忓搴︼紝闃叉杩囦簬缂╁皬 */ } @@ -69,71 +51,152 @@
- + + + +
- + + +
- + +
- +
- - - - - - - - - - - - + + +<#-- --> + + + + + + + + + + - <#if (apiUserBoList?? && apiUserBoList?size > 0)> + <#if (apiUserBoList??&&apiUserBoList?size>0)> <#list apiUserBoList as bo> - style="background-color:#C3C3C3"> - - - - - - - - - - - + style="background-color:#C3C3C3"> + + +<#-- --> + + + + + + + + + @@ -142,39 +205,24 @@
ID鏄电Оusernamepassword閿�鍞礋璐d汉鍏徃appKey璐︽埛绫诲瀷璐︽埛鐢ㄩ��鏄惁鐩戞帶鍒版湡鏃堕棿鎿嶄綔 + ID + + 鏄电О + --> +<#-- 璐︽埛鐢ㄩ��--> +<#-- + username + + password + + 閿�鍞礋璐d汉 + + 鍏徃 + + appKey + + 璐︽埛绫诲瀷 + + 璐︽埛鐢ㄩ�� + + 鏄惁鐩戞帶 + + 鍒版湡鏃堕棿 + + 鎿嶄綔 +
${bo.userId!}${bo.displayName!}${bo.userName!}<#if bo.password?? && bo.password == t_util.md5Hex('123456')>鍒濆瀵嗙爜<#else>******${bo.manager!}${bo.company!}${bo.appKey!}<#if bo.isTest == 0>姝e紡璐︽埛<#elseif bo.isTest == 1>娴嬭瘯璐︽埛<#else>鍐呴儴璐︽埛<#if bo.purpose?? && bo.purpose == 1>API<#elseif bo.purpose?? && bo.purpose == 2>PDS<#elseif bo.purpose?? && bo.purpose == 4>鎴跨敓娲�<#if bo.isMonitor == 1>鏄�<#else>鍚�<#if bo.deadTime??>${bo.deadTime?string("yyyy骞碝M鏈坉d鏃�")}
+ ${bo.userId!} + + ${bo.displayName!} + --> +<#-- <#if bo.purpose?? && bo.purpose == 1>--> +<#-- API--> +<#-- <#elseif bo.purpose?? && bo.purpose == 2>--> +<#-- PDS--> +<#-- <#elseif bo.purpose?? && bo.purpose == 4>--> +<#-- 鎴跨敓娲�--> +<#-- --> +<#-- + ${bo.userName!} + + <#if bo.password?? && bo.password == t_util.md5Hex('123456')> + 鍒濆瀵嗙爜 + <#else> + ****** + + + ${bo.manager!} + + ${bo.company!} + + ${bo.appKey!} + + <#if bo.isTest==0> + 姝e紡璐︽埛 + <#elseif bo.isTest==1> + 娴嬭瘯璐︽埛 + <#else> + 鍐呴儴璐︽埛 + + + <#if bo.purpose?? && bo.purpose == 1> + API + <#elseif bo.purpose?? && bo.purpose == 2> + PDS + <#elseif bo.purpose?? && bo.purpose == 4> + 鎴跨敓娲� + + + <#if bo.isMonitor==1> + 鏄� + <#else> + 鍚� + + + <#if bo.deadTime??> + ${bo.deadTime?string("yyyy骞碝M鏈坉d鏃�")} + + API鏉冮檺鎺у埗 鏂板API 鍩庡競绠$悊 浠锋牸璇勭骇 - <#if bo.status == 0> + <#if bo.status==0> 绂佺敤 <#else> - 鍐嶅惎鐢� + 鍐嶅惎鐢�
- + \ No newline at end of file diff --git a/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl b/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl index 2b326e80e..da9cec860 100644 --- a/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/layout/menu.ftl @@ -295,7 +295,7 @@ <@menuitem uri='/creditRate/list' text="浠锋牸鍙俊搴︿笌鍖归厤鐜囧叧绯�" /> <@menuitem uri='/czBank/sampleLogs' text="娴欏晢閾惰" /> <@menuitem uri='/villageIdentify/importResult' text="娑夊啘缁撴灉瀵煎叆" /> - <@menuitem uri='/apiCountLog/list' text="API娆℃暟鏃ュ織" /> + <@menuitem uri='/apiCountLog/list?purpose=1&isTest=0&status=0' text="API娆℃暟鏃ュ織" /> From d399786e7f83ba42431c91c6c033bef8daa18406 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Sep 2024 14:54:28 +0800 Subject: [PATCH 025/230] =?UTF-8?q?=E6=8A=8A=E5=93=8D=E5=BA=94code=20?= =?UTF-8?q?=E4=B8=BA0=20=E7=9A=84=E6=94=B9=E4=B8=BA200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/AddrSvcController.java | 2 +- .../java/com/fangjia/open/controllers/AddressController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 258d75236..237353af9 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -177,7 +177,7 @@ public class AddrSvcController { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8"); if (json != null) { - int code = json.getInt("status"); + int code = json.getInt("status") == 0 ? 200 : 0; String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java index f036e2232..a484fd8cf 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java @@ -2277,7 +2277,7 @@ public class AddressController { } if (json != null) { - int code = json.getInt("status"); + int code = json.getInt("status") == 0 ? 200 : 0; String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { From ffebd87bae125aac78185666da63c39b384c2db8 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 3 Sep 2024 16:52:22 +0800 Subject: [PATCH 026/230] =?UTF-8?q?=E5=9B=BD=E4=BF=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 136 ++++++++++++++---- 1 file changed, 112 insertions(+), 24 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 237353af9..6b669977b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -312,6 +312,46 @@ public class AddrSvcController { return mav; } + /** + * 地址联想 + */ + public Object tipsAction(AddressModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getKeywords())) { + mav.setModel(BasicModel.buildBadRequestModel("搜索关键字不能为空")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("keywords", model.getKeywords()); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : ""); + params.put("max", model.getMax() != 0 ? String.valueOf(model.getMax()) : ""); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/tips", params, "UTF-8"); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray.size() > 0) { + basicModel.setResult(jsonArray); + } + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + } catch (Exception e) { + e.printStackTrace(); + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + public Object avgPriceAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); if (StringUtils.isBlank(model.getAddress())) { @@ -1048,11 +1088,21 @@ public class AddrSvcController { for (Object o : jsonArray) { JSONObject result = (JSONObject) o; HashMap map = new HashMap(); - map.put("id", result.getString("id")); - map.put("province", result.getString("province")); - map.put("provinceCode", result.getString("tjjProvinceCode")); - map.put("city", result.getString("city")); - map.put("cityCode", result.getString("tjjCityCode")); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("provinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("cityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } list.add(map); } } @@ -1096,9 +1146,15 @@ public class AddrSvcController { for (Object o : jsonArray) { JSONObject result = (JSONObject) o; HashMap map = new HashMap(); - map.put("id", result.getString("id")); - map.put("province", result.getString("province")); - map.put("provinceCode", result.getString("mzbProvinceCode")); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("provinceCode")) { + map.put("provinceCode", result.getString("mzbProvinceCode")); + } list.add(map); } } @@ -1145,13 +1201,27 @@ public class AddrSvcController { for (Object o : jsonArray) { JSONObject result = (JSONObject) o; HashMap map = new HashMap(); - map.put("id", result.getString("id")); - map.put("province", result.getString("province")); - map.put("provinceCode", result.getString("tjjProvinceCode")); - map.put("city", result.getString("city")); - map.put("cityCode", result.getString("tjjCityCode")); - map.put("district", result.getString("district")); - map.put("districtCode", result.getString("tjjDistrictCode")); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("provinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("cityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("districtCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } list.add(map); } } @@ -1193,15 +1263,33 @@ public class AddrSvcController { for (Object o : jsonArray) { JSONObject result = (JSONObject) o; HashMap map = new HashMap(); - map.put("id", result.getString("id")); - map.put("province", result.getString("province")); - map.put("provinceCode", result.getString("tjjProvinceCode")); - map.put("city", result.getString("city")); - map.put("cityCode", result.getString("tjjCityCode")); - map.put("district", result.getString("district")); - map.put("districtCode", result.getString("tjjDistrictCode")); - map.put("street", result.getString("street")); - map.put("streetCode", result.getString("tjjStreetCode")); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("provinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("cityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("districtCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } + if (result.containsKey("street")) { + map.put("street", result.getString("street")); + } + if (result.containsKey("streetCode")) { + map.put("streetCode", result.getString("tjjStreetCode")); + } list.add(map); } } From 48ede3457382bf9aa4e07eec7613cfb1216e43c2 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 9 Sep 2024 14:10:50 +0800 Subject: [PATCH 027/230] =?UTF-8?q?=E8=B5=B0=E5=8A=BF=E5=9B=BE=E4=B8=8D?= =?UTF-8?q?=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-coresite/src/main/webapp/trend/trend.ftl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl index 375d1ec56..57168fb3d 100644 --- a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl +++ b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl @@ -406,10 +406,10 @@ const month = now.getMonth() + 1; // 鏈� let divElement = document.getElementById("date"); - divElement.innerHTML = ""+year+"骞�"+month+"鏈�"+""; + $("#date").html(""+year+"骞�"+month+"鏈�"+"") let divElement2 = document.getElementById("date2"); - divElement2.innerHTML = ""+year+"骞�"+month+"鏈�"+""; + $("#date2").html(""+year+"骞�"+month+"鏈�"+"") $(function(){ $('.td04').each(function(i){ From 38712f886d26d2c25fbde74748d9d81c5d623c3c Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 11 Sep 2024 11:37:56 +0800 Subject: [PATCH 028/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8C=89=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E7=BB=9F=E8=AE=A1=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl index 4f5ec9781..93a24eb3f 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/apiVisitStat.ftl @@ -579,7 +579,7 @@ <#if way==1> ${bo.key!} <#else> - ${bo.key!} + ${bo.key!} <#if way?? && way==1> @@ -787,7 +787,6 @@ function submitForm(action) { const form = document.getElementById('myForm'); if (action === 'query') { - debugger form.action = "<#if way?? && way==0>../apiUser/pandect<#else>../apiUser/apiVisitStat"; } else if (action === 'download') { form.action = "../apiUser/export"; From 6c76dbc1efa58925245e3d962022a034e8b284ca Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Wed, 11 Sep 2024 15:58:15 +0800 Subject: [PATCH 029/230] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9B=B8=E4=BC=BC?= =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E9=9D=A2=E7=A7=AF=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datastore/CzbankSampleServiceImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java index 99fc3ce39..ddf48f46c 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CzbankSampleServiceImpl.java @@ -229,7 +229,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { } } - List samples = findJnbankSampleByDistrict(district, keys, names, queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat); + List samples = findJnbankSampleByDistrict(district, keys, names, queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat, target.getStrctureArea()); // scoreForSample(samples, target); sortForSample(samples, target); @@ -269,7 +269,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { } } - List nearlySample = findJnbankSampleByDistrict(district, arroundKeys, arroundNnames, queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat); + List nearlySample = findJnbankSampleByDistrict(district, arroundKeys, arroundNnames, queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat, target.getStrctureArea()); for (SampleWrapper sample : nearlySample) { sample.setProperty(district); @@ -346,13 +346,13 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { propertyLife = "40"; } else { if (sample.getBuildStructureCode() != null) { - if ("10".equals(sample.getBuildStructureCode())) { + if ("10".equals(sample.getBuildStructureCode().toString())) { propertyLife = "70"; - } else if ("20".equals(sample.getBuildStructureCode())) { + } else if ("20".equals(sample.getBuildStructureCode().toString())) { propertyLife = "60"; - } else if ("40".equals(sample.getBuildStructureCode())) { + } else if ("40".equals(sample.getBuildStructureCode().toString())) { propertyLife = "40"; - } else if ("30".equals(sample.getBuildStructureCode())) { + } else if ("30".equals(sample.getBuildStructureCode().toString())) { propertyLife = "50"; } else { propertyLife = "60"; @@ -770,7 +770,6 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { return d1.compareTo(d2); } }); - List prices = new ArrayList(); for (SampleWrapper sample : samples) { if (!prices.contains(sample.getUnitPrice())) { @@ -989,7 +988,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { * @param startDate * @return */ - private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat) { + private List findJnbankSampleByDistrict(District district, List keys, List names, String estateType, Date startDate, DistrictStat districtStat,double area) { BooleanQuery nameQuery = new BooleanQuery(); @@ -1013,8 +1012,10 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.5)));//0.85 houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.5)));//1.15 } + houseQuery.add(new QueryParam("area", QueryParam.LESS_THAN_EQUAL_OPERATOR, area + 30)); + houseQuery.add(new QueryParam("area", QueryParam.GREATER_THAN_EQUAL_OPERATOR, area - 30)); - if (nameQuery.clauses().size() == 0) { + if (nameQuery.clauses().isEmpty()){ return samples; } BooleanQuery srQuery = new BooleanQuery(); From 602b29a6b4fe90d77a598f9a12baad2e0c2b36be Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 12 Sep 2024 18:13:11 +0800 Subject: [PATCH 030/230] =?UTF-8?q?=E6=96=B0=E5=A2=9EAPI=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=95=B0=E9=87=8F=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/UsersController.java | 258 ++++++++ .../com/fangjia/open/model/ApiUserModel.java | 620 ++++++++++++++++++ 2 files changed, 878 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java index 951c354b3..a56938da9 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java @@ -4,22 +4,29 @@ import java.util.*; import com.fangjia.core.util.AnalyticsUtil; import com.fangjia.core.util.BeanUtils; +import com.fangjia.core.util.DataUtil; import com.fangjia.core.util.DateUtil; import com.fangjia.dal.QueryParam; +import com.fangjia.dal.mongo.model.ApiInvokeStatistical; import com.fangjia.dal.mongo.model.SendSmsLog; import com.fangjia.dal.mongo.open.model.ApiUserAuthority; import com.fangjia.dal.mongo.open.model.OpenResource; +import com.fangjia.dal.mongo.tool.model.ApiVisitCount; import com.fangjia.dal.mongo.tool.model.OpenUriAnaly; +import com.fangjia.dal.sql.model.ApiUser; import com.fangjia.open.HttpStatusCodeEnum; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.model.*; import com.fangjia.open.model.weixin.SendCodeJsonModel; import com.fangjia.open.model.weixin.SendCodeModel; +import com.fangjia.service.mongo.bkoff.ApiInvokeStatisticalService; import com.fangjia.service.open.*; +import com.fangjia.service.sql.ApiUserService; import net.sf.json.JSONObject; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.StringUtils; +import org.json.JSONArray; import org.sothis.web.mvc.ActionContext; import org.sothis.web.mvc.ActionInvocation; import org.sothis.web.mvc.annotation.Param; @@ -41,6 +48,8 @@ public class UsersController { private ApiUserAuthorityService apiUserAuthorityService; private OpenResourceService openResourceService; private OpenUriAnalyService openUriAnalyService; + private ApiUserService apiUserService; + private ApiInvokeStatisticalService apiInvokeStatisticalService; /** @@ -177,6 +186,247 @@ public class UsersController { return mav; } + public Object callDetailAction(ApiUserModel model) throws IllegalAccessException { + RestfulModelAndView mav = new RestfulModelAndView(); + Date startDate = null; + Date endDate = null; + if (StringUtils.isNotBlank(model.getBegDateStr())) { + startDate = DateUtil.parseStringToDate(model.getBegDateStr()); + } + if (StringUtils.isNotBlank(model.getEndDateStr())) { + endDate = DateUtil.parseStringToDate(model.getEndDateStr()); + } + List analys = openUriAnalyService.findOpenUriAnalyLogs(model.getUserId(), model.getUri(), startDate, endDate); + List bos = null; + model.setQuery("uri"); + + Long userId = model.getUserId(); + ApiUserAuthority authority = apiUserAuthorityService.findByUserId(userId); + Map countMap = authority.getTotalCountMap(); + ApiUser apiUser = apiUserService.findApiUserById(userId); + User user = userService.findById(userId); + if (user != null) { + model.setUserName(user.getDisplayName()); + } + + if (model.getQuery().equals("uri")) { + bos = createAnalyBosByLink(analys); + model.setChartSeries(toChartString(bos)); + } + + long date = DateUtil.parseStringToDate("2016-11-23").getTime(); + if ("uri".equals(model.getQuery()) && startDate.getTime() >= date && endDate.getTime() > date) { + List apiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(model.getUserId(), startDate, endDate); + if (bos != null && apiInvokeStatisticalList.size() > 0) { + Map> resultMap = getCountByUri(apiInvokeStatisticalList); + for (StatAnalyBo boTemp : bos) { + String url = boTemp.getKey(); + boTemp.setSuccessEffectiveTime(resultMap.get(url).get("successEffectiveCount")); + boTemp.setSuccessInvalidTime(resultMap.get(url).get("successInvalidCount")); + boTemp.setDefeatTime(resultMap.get(url).get("defeatCount")); + if (apiUser != null) { + boTemp.setDeadline(apiUser.getDeadTime()); + } + long curVistedCount = apiVisitCountService.findApiVisitCountByDay(userId, url, DateUtil.truncateDay(new Date())); + long historyCount = apiVisitCountService.findApiVisitAllCount(userId, url, DateUtil.truncateDay(new Date())); + if (countMap != null && countMap.containsKey(url)) { + Integer totalCount = countMap.get(url); + long usedCount = curVistedCount + historyCount; + boTemp.setSurplusCallCount(Integer.valueOf((int) (totalCount - usedCount))); + } + } + } + } + List resources = openResourceService.findOpenResource(null); + Map urlMap = converMapData(resources); + for (StatAnalyBo boTemp : bos) { + List apiVisitCounts = apiVisitCountService.findAllApiVisitCount(model.getUserId(), boTemp.getKey(), startDate, endDate); + int total = 0; + for (ApiVisitCount apiVisitCount : apiVisitCounts) { + total += apiVisitCount.getVisitCount(); + } + boTemp.setBillingCount(total); + boTemp.setUrlName(urlMap.get(boTemp.getKey())); + boTemp.setUrl(boTemp.getKey()); + boTemp.setKey(null); + } + +// model.setResourceMap(converMapData(resources)); + model.setStatAnalyBoList(sortStatAnaly(bos)); + BasicModel basicModel = new BasicModel(200, "ok"); + basicModel.setResult(model); + mav.setModel(basicModel); + return mav; + } + + private List createAnalyBosByLink(List analys) { + + + Map ret = new HashMap(); + Map> urlCodeMap = new HashMap>(); + int total = 0; + for (OpenUriAnaly openUriAnaly : analys) { + Integer temp = ret.get(openUriAnaly.getUrl()); + if (temp == null) { + ret.put(openUriAnaly.getUrl(), openUriAnaly.getUrlClickCount()); + } else { + ret.put(openUriAnaly.getUrl(), temp + openUriAnaly.getUrlClickCount()); + } + Map codeMap = urlCodeMap.get(openUriAnaly.getUrl()); + if (codeMap == null) { + codeMap = new HashMap(); + urlCodeMap.put(openUriAnaly.getUrl(), codeMap); + } + Map analyCodeMap = openUriAnaly.getCodeMap(); + for (String code : analyCodeMap.keySet()) { + Integer count = (Integer) analyCodeMap.get(code); + if ("200".equals(code)) { + Integer successCount = codeMap.get("successCount"); + if (successCount == null) { + codeMap.put("successCount", count); + } else { + codeMap.put("successCount", successCount + count); + } + } else { + Integer defeatCount = codeMap.get("defeatCount"); + if (defeatCount == null) { + codeMap.put("defeatCount", count); + } else { + codeMap.put("defeatCount", defeatCount + count); + } + } + } + total = total + openUriAnaly.getUrlClickCount(); + } + + List bos = new ArrayList(); + int index = 0; + double totalPercent = 0; + for (String url : ret.keySet()) { + Integer count = ret.get(url); + double percent = 0; + if (index + 1 == ret.size()) { + percent = 100 - totalPercent; + } else { + double a1 = count; + double val = a1 * 10000 / (double) total; + percent = DataUtil.roundDouble(val / 100, 2); + totalPercent = totalPercent + percent; + } + StatAnalyBo bo = new StatAnalyBo(); + bo.setKey(url); + bo.setCount(count); + bo.setPercent(percent); + Map codeMap = urlCodeMap.get(url); + bo.setSuccessTime(codeMap.get("successCount")); + bo.setDefeatTime(codeMap.get("defeatCount")); + if (codeMap.get("successCount") != null) { + bo.setSuccessRate(DataUtil.roundDouble((codeMap.get("successCount") * 100) / (double) count, 2)); + } + bos.add(bo); + + } + return bos; + } + + private List sortStatAnaly(List bos) { + Collections.sort(bos, new Comparator() { + @Override + public int compare(StatAnalyBo o1, StatAnalyBo o2) { + if (o1.getCount() > o2.getCount()) { + return -1; + } else if (o1.getCount() < o2.getCount()) { + return 1; + } + return 0; + } + }); + + return bos; + } + + private Map converMapData(List resources) { + Map map = new HashMap(); + for (OpenResource resource : resources) { + map.put(resource.getUri(), resource.getName()); + } + return map; + } + + + private Map> getCountByUri(List apiInvokeStatisticalList) { + Map> resultMap = new HashMap>(); + for (ApiInvokeStatistical apiInvokeStatistical : apiInvokeStatisticalList) { + Map detailMap = resultMap.get(apiInvokeStatistical.getRequestURI()); + if (detailMap == null) { + detailMap = new HashMap(); + resultMap.put(apiInvokeStatistical.getRequestURI(), detailMap); + } + Integer successEffectiveCount = detailMap.get("successEffectiveCount"); + Integer successInvalidCount = detailMap.get("successInvalidCount"); + Integer defeatCount = detailMap.get("defeatCount"); + Integer totalCount = detailMap.get("totalCount"); + if (successEffectiveCount != null) { + successEffectiveCount = successEffectiveCount + apiInvokeStatistical.getSuccessEffectiveTime(); + } else { + successEffectiveCount = apiInvokeStatistical.getSuccessEffectiveTime(); + } + if (successInvalidCount != null) { + successInvalidCount = successInvalidCount + apiInvokeStatistical.getSuccessInvalidTime(); + } else { + successInvalidCount = apiInvokeStatistical.getSuccessInvalidTime(); + ; + } + if (defeatCount != null) { + defeatCount = defeatCount + apiInvokeStatistical.getDefeatTime(); + } else { + defeatCount = apiInvokeStatistical.getDefeatTime(); + } + if (totalCount != null) { + totalCount = totalCount + apiInvokeStatistical.getTotalTime(); + } else { + totalCount = apiInvokeStatistical.getTotalTime(); + } + + detailMap.put("successEffectiveCount", successEffectiveCount); + detailMap.put("successInvalidCount", successInvalidCount); + detailMap.put("defeatCount", defeatCount); + detailMap.put("totalCount", totalCount); + } + + return resultMap; + } + + private String toChartString(List bos) { + JSONArray ja = new JSONArray(); + for (StatAnalyBo bo : bos) { + JSONArray array = new JSONArray(); + if (StringUtils.isNotBlank(bo.getKey())) { + if (bo.getKey().equals("level_0")) { + array.put("0s"); + } else if (bo.getKey().equals("level_1")) { + array.put("1s以下"); + } else if (bo.getKey().equals("level_2")) { + array.put("1-2s以下"); + } else if (bo.getKey().equals("level_3")) { + array.put("2-3s以下"); + } else if (bo.getKey().equals("level_4")) { + array.put("3s以上"); + } else if (bo.getKey().equals("level_100")) { + array.put("暂无数据"); + } else { + array.put(bo.getKey()); + } + } else { + array.put(bo.getUserId()); + } + + array.put(bo.getPercent()); + ja.put(array); + } + return ja.toString(); + } + public void setUserService(UserService userService) { this.userService = userService; } @@ -200,4 +450,12 @@ public class UsersController { public void setOpenUriAnalyService(OpenUriAnalyService openUriAnalyService) { this.openUriAnalyService = openUriAnalyService; } + + public void setApiUserService(ApiUserService apiUserService) { + this.apiUserService = apiUserService; + } + + public void setApiInvokeStatisticalService(ApiInvokeStatisticalService apiInvokeStatisticalService) { + this.apiInvokeStatisticalService = apiInvokeStatisticalService; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiUserModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiUserModel.java index 22540ffea..a3c228c25 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiUserModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/ApiUserModel.java @@ -1,6 +1,12 @@ package com.fangjia.open.model; +import com.fangjia.dal.mongo.model.ApiInvokeStatistical; +import com.fangjia.dal.mongo.open.model.ApiUserAuthority; +import com.fangjia.service.open.*; + import java.util.Date; +import java.util.List; +import java.util.Map; /** * API用户管理Model @@ -12,6 +18,620 @@ public class ApiUserModel extends FangjiaApiModel{ private Date endDate; private String uri; + private static final long serialVersionUID = 7044341510628330454L; + + private String begDateStr;// 查询开始日期 + private String endDateStr;// 查询结束日期 + private String statDate; + private String appKey; + private String userName; + private String displayName; + private String siteName; + private String password; + private String email; + private String ip; + private Integer isTest; + private Integer purpose; + private String msg; + private Long userId; + private String company; + private List apiUserBoList; + private List eachCityBoList; + private String limitCountMap; + private String totalCountMap; + private Integer creditLevelStatus; + private String priceType; + private Map priceRatingMap; + private Integer isMonitor; + + private String contact; + + private String phone; + + public String getPriceType() { + return priceType; + } + + public void setPriceType(String priceType) { + this.priceType = priceType; + } + + public List getEachCityBoList() { + return eachCityBoList; + } + + public void setEachCityBoList(List eachCityBoList) { + this.eachCityBoList = eachCityBoList; + } + + private Integer sum; + private Integer limit; + /*** 权限控制相关 **/ + private ApiUserBo apiUserBo; + private List authorityList; + private ApiUserAuthority authority; + private List authorityBoList; + //private List serverAreaList; + private List> serverAreaList; + private String openCitys;// 汉字说明 + private List cityFirstLetters;// 城市拼音首字母 + private String type; + private String citys;// spell + private String unCheckCitys;// 页面反选的city + private Integer status; + private boolean hasAuth; + private boolean supportLatLng; + private Integer maxFrequency; + private String frequencyPeriod; + private Integer maximum; + + private ApiInvokeStatistical apiInvokeStatistical; + private Double one; + private Double newOne; + private Double two; + private Double three; + private Double four; + private Double five; + private Date deadTime; + private String manager; + private Double evaluateRate; + + private String data; + + private Integer isCheckCount; + + private String openResourseUrisMap; + + public String getOpenResourseUrisMap() { + return openResourseUrisMap; + } + + public void setOpenResourseUrisMap(String openResourseUrisMap) { + this.openResourseUrisMap = openResourseUrisMap; + } + + public Integer getIsCheckCount() { + return isCheckCount; + } + + public void setIsCheckCount(Integer isCheckCount) { + this.isCheckCount = isCheckCount; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public String getDisplayName() { + return displayName; + } + + private String chartSeries; + + private List OpenUriAnalyBoList; + private List statAnalyBoList; + private Integer way; + private Map resourceMap; + private String query; + private Integer totalCount; + private String xAxis; + private String credits; + private String uncitys; + + public String getUncitys() { + return uncitys; + } + + public void setUncitys(String uncitys) { + this.uncitys = uncitys; + } + + public String getCredits() { + return credits; + } + + public void setCredits(String credits) { + this.credits = credits; + } + + public String getxAxis() { + return xAxis; + } + + public void setxAxis(String xAxis) { + this.xAxis = xAxis; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getSiteName() { + return siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + public String getAppKey() { + return appKey; + } + + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + public String getBegDateStr() { + return begDateStr; + } + + public void setBegDateStr(String begDateStr) { + this.begDateStr = begDateStr; + } + + public String getEndDateStr() { + return endDateStr; + } + + public void setEndDateStr(String endDateStr) { + this.endDateStr = endDateStr; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public List getApiUserBoList() { + return apiUserBoList; + } + + public void setApiUserBoList(List apiUserBoList) { + this.apiUserBoList = apiUserBoList; + } + + public ApiUserBo getApiUserBo() { + return apiUserBo; + } + + public void setApiUserBo(ApiUserBo apiUserBo) { + this.apiUserBo = apiUserBo; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public List getAuthorityList() { + return authorityList; + } + + public void setAuthorityList(List authorityList) { + this.authorityList = authorityList; + } + + public ApiUserAuthority getAuthority() { + return authority; + } + + public void setAuthority(ApiUserAuthority authority) { + this.authority = authority; + } + + + public boolean isHasAuth() { + return hasAuth; + } + + public void setHasAuth(boolean hasAuth) { + this.hasAuth = hasAuth; + } + + public boolean isSupportLatLng() { + return supportLatLng; + } + + public void setSupportLatLng(boolean supportLatLng) { + this.supportLatLng = supportLatLng; + } + + public List getAuthorityBoList() { + return authorityBoList; + } + + public void setAuthorityBoList(List authorityBoList) { + this.authorityBoList = authorityBoList; + } + + public List getCityFirstLetters() { + return cityFirstLetters; + } + + public void setCityFirstLetters(List cityFirstLetters) { + this.cityFirstLetters = cityFirstLetters; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /*public List getServerAreaList() { + return serverAreaList; + } + + public void setServerAreaList(List serverAreaList) { + this.serverAreaList = serverAreaList; + }*/ + public List> getServerAreaList() { + return serverAreaList; + } + + public void setServerAreaList(List> serverAreaList) { + this.serverAreaList = serverAreaList; + } + + public String getCitys() { + return citys; + } + + public void setCitys(String citys) { + this.citys = citys; + } + + public String getOpenCitys() { + return openCitys; + } + + public void setOpenCitys(String openCitys) { + this.openCitys = openCitys; + } + + public String getUnCheckCitys() { + return unCheckCitys; + } + + public void setUnCheckCitys(String unCheckCitys) { + this.unCheckCitys = unCheckCitys; + } + + public Integer getSum() { + return sum; + } + + public void setSum(Integer sum) { + this.sum = sum; + } + + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public Integer getMaximum() { + return maximum; + } + + public void setMaximum(Integer maximum) { + this.maximum = maximum; + } + + public String getFrequencyPeriod() { + return frequencyPeriod; + } + + public void setFrequencyPeriod(String frequencyPeriod) { + this.frequencyPeriod = frequencyPeriod; + } + + public Integer getMaxFrequency() { + return maxFrequency; + } + + public void setMaxFrequency(Integer maxFrequency) { + this.maxFrequency = maxFrequency; + } + public List getOpenUriAnalyBoList() { + return OpenUriAnalyBoList; + } + + public void setOpenUriAnalyBoList(List openUriAnalyBoList) { + OpenUriAnalyBoList = openUriAnalyBoList; + } + + public String getChartSeries() { + return chartSeries; + } + + public void setChartSeries(String chartSeries) { + this.chartSeries = chartSeries; + } + + public String getStatDate() { + return statDate; + } + + public void setStatDate(String statDate) { + this.statDate = statDate; + } + + public Integer getWay() { + return way; + } + + public void setWay(Integer way) { + this.way = way; + } + + public Map getResourceMap() { + return resourceMap; + } + + public void setResourceMap(Map resourceMap) { + this.resourceMap = resourceMap; + } + + public List getStatAnalyBoList() { + return statAnalyBoList; + } + + public void setStatAnalyBoList(List statAnalyBoList) { + this.statAnalyBoList = statAnalyBoList; + } + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public ApiInvokeStatistical getApiInvokeStatistical() { + return apiInvokeStatistical; + } + + public void setApiInvokeStatistical(ApiInvokeStatistical apiInvokeStatistical) { + this.apiInvokeStatistical = apiInvokeStatistical; + } + public Double getEvaluateRate() { + return evaluateRate; + } + + public void setEvaluateRate(Double evaluateRate) { + this.evaluateRate = evaluateRate; + } + + public Integer getIsTest() { + return isTest; + } + + public void setIsTest(Integer isTest) { + this.isTest = isTest; + } + + public String getLimitCountMap() { + return limitCountMap; + } + + public void setLimitCountMap(String limitCountMap) { + this.limitCountMap = limitCountMap; + } + + public String getTotalCountMap() { + return totalCountMap; + } + + public void setTotalCountMap(String totalCountMap) { + this.totalCountMap = totalCountMap; + } + + public Integer getPurpose() { + return purpose; + } + + public void setPurpose(Integer purpose) { + this.purpose = purpose; + } + + public Map getPriceRatingMap() { + return priceRatingMap; + } + + public void setPriceRatingMap(Map priceRatingMap) { + this.priceRatingMap = priceRatingMap; + } + + public Double getOne() { + return one; + } + + public void setOne(Double one) { + this.one = one; + } + + public Double getNewOne() { + return newOne; + } + + public void setNewOne(Double newOne) { + this.newOne = newOne; + } + + public Double getTwo() { + return two; + } + + public void setTwo(Double two) { + this.two = two; + } + + public Double getThree() { + return three; + } + + public void setThree(Double three) { + this.three = three; + } + + public Double getFour() { + return four; + } + + public void setFour(Double four) { + this.four = four; + } + + public Double getFive() { + return five; + } + + public void setFive(Double five) { + this.five = five; + } + + public Integer getCreditLevelStatus() { + return creditLevelStatus; + } + + public void setCreditLevelStatus(Integer creditLevelStatus) { + this.creditLevelStatus = creditLevelStatus; + } + + public Date getDeadTime() { + return deadTime; + } + + public void setDeadTime(Date deadTime) { + this.deadTime = deadTime; + } + + public String getManager() { + return manager; + } + + public void setManager(String manager) { + this.manager = manager; + } + + public Integer getIsMonitor() { + return isMonitor; + } + + public void setIsMonitor(Integer isMonitor) { + this.isMonitor = isMonitor; + } + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + public Date getStartDate() { return startDate; } From b363320ccba255110a065a718d7c66709f070fd4 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 13 Sep 2024 09:52:46 +0800 Subject: [PATCH 031/230] =?UTF-8?q?API=E8=B0=83=E7=94=A8=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E6=A0=B9=E6=8D=AEuserID=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/UsersController.java | 88 ++++++++++--------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java index a56938da9..dff7d888b 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/UsersController.java @@ -134,55 +134,61 @@ public class UsersController { return json.toString(); } - public Object surplusCallCountAction() throws IllegalAccessException { + public Object surplusCallCountAction(ApiUserModel model) throws IllegalAccessException { RestfulModelAndView mav = new RestfulModelAndView(); ActionContext context = ActionContext.getContext(); HttpServletRequest request = context.getRequest(); AuthenticationBean instance = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + User user = null; + if (model.getUserId() != null && model.getUserId() > 0) { + user = userService.findById(model.getUserId()); + } if (null != instance) { - User user = instance.user; - List openResourceList = openResourceService.findAll(); - List list = new ArrayList(); - long id = user.getId(); - ApiUserAuthority authority = apiUserAuthorityService.findByUserId(id); - if (null != authority) { - // 用户有的uri - List userResources = new ArrayList(); - for (OpenResource openResource : openResourceList) { - if (authority.getOpenResourseUris().contains(openResource.getUri())) { - userResources.add(openResource); - } - } - Map countMap = authority.getTotalCountMap(); - if (null != countMap) { - // 改成遍历用户有的uri - for (OpenResource openResource : userResources) { - String uri = openResource.getUri(); - ApiMonitorInfo info = new ApiMonitorInfo(); - info.setApiUri(uri); - info.setApiName(openResource.getName()); - info.setUserId((int) id); - info.setUsername(user.getUserName()); - if (null != countMap.get(uri) && countMap.get(uri) > 0) { - long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, uri, DateUtil.truncateDay(new Date())); - long historyCount = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date())); - Integer totalCount = countMap.get(uri); - info.setTotalCallCount(Long.valueOf(totalCount)); - long usedCount = curVistedCount + historyCount; - info.setSurplusCallCount(totalCount - usedCount); - info.setUsedCallCount(usedCount); - } - list.add(info); - - } + user = instance.user; + } + if (null == instance && user == null) { + mav.setModel(new BasicModel(HttpStatusCodeEnum.BAD_REQUEST_ERROR_KEY)); + return mav; + } + List openResourceList = openResourceService.findAll(); + List list = new ArrayList(); + long id = user.getId(); + ApiUserAuthority authority = apiUserAuthorityService.findByUserId(id); + if (null != authority) { + // 用户有的uri + List userResources = new ArrayList(); + for (OpenResource openResource : openResourceList) { + if (authority.getOpenResourseUris().contains(openResource.getUri())) { + userResources.add(openResource); + } + } + Map countMap = authority.getTotalCountMap(); + if (null != countMap) { + // 改成遍历用户有的uri + for (OpenResource openResource : userResources) { + String uri = openResource.getUri(); + ApiMonitorInfo info = new ApiMonitorInfo(); + info.setApiUri(uri); + info.setApiName(openResource.getName()); + info.setUserId((int) id); + info.setUsername(user.getUserName()); + if (null != countMap.get(uri) && countMap.get(uri) > 0) { + long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, uri, DateUtil.truncateDay(new Date())); + long historyCount = apiVisitCountService.findApiVisitAllCount(id, uri, DateUtil.truncateDay(new Date())); + Integer totalCount = countMap.get(uri); + info.setTotalCallCount(Long.valueOf(totalCount)); + long usedCount = curVistedCount + historyCount; + info.setSurplusCallCount(totalCount - usedCount); + info.setUsedCallCount(usedCount); + } + list.add(info); + } } - BasicModel basicModel = new BasicModel(200, "ok"); - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(new BasicModel(HttpStatusCodeEnum.BAD_REQUEST_ERROR_KEY)); } + BasicModel basicModel = new BasicModel(200, "ok"); + basicModel.setResult(list); + mav.setModel(basicModel); return mav; } From 9ce61bc2fa42e2be78cef25097cd1fd5225a2431 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 13 Sep 2024 10:24:54 +0800 Subject: [PATCH 032/230] =?UTF-8?q?API=E8=B0=83=E7=94=A8=E9=87=8F=E4=B8=BA?= =?UTF-8?q?0=E6=97=B6=E4=B8=BA=E6=97=A0=E9=99=90=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/bkoff/controllers/ApiUserController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index 3f67b111c..fab71c646 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -647,7 +647,6 @@ public class ApiUserController { AuthorityBo bo = new AuthorityBo(); BeanUtils.copyProperties(openResource, bo); if (authority != null) { - bo.setHasAuth(authority.getOpenResourseUris().contains(bo.getUri())); bo.setHasAuth(authority.getOpenResourseUris().contains(bo.getUri())); model.setSupportLatLng(authority.isSupportLatLng()); bo.setLimitCountMap(authority.getLimitCountMap()); @@ -760,7 +759,9 @@ public class ApiUserController { apiCountLogService.save(apiCountLog); } } - totalCountMap.put(model.getUri(), count); + if (count == 0) { + totalCountMap.remove(model.getUri()); + } authority.setTotalCountMap(totalCountMap); } if (model.getIsCheckCount() != null) { From 2ad357c18099a2819458c42665708e27437e2ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Sat, 14 Sep 2024 16:54:27 +0800 Subject: [PATCH 033/230] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=92=89=E9=92=89?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/exceptionhander/FangjiaOpenExceptionHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 8701acb19..35fdcb285 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -4,6 +4,7 @@ import java.io.IOException; import javax.servlet.ServletException; +import com.fangjia.core.util.DingDingMessageUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sothis.web.mvc.ActionContext; @@ -16,6 +17,8 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { if (LOGGER.isErrorEnabled()) { LOGGER.error("", e); } + String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; + DingDingMessageUtil.sendTextMessage(token, "[OpenApi]服务器内部错误,请及时关注!"); ActionContext context = ActionContext.getContext(); context.getResponse().setStatus(500); context.getResponse().setCharacterEncoding("UTF-8"); From b336a7bda437ea71cb79d2bc2046cda70b2b698b Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 18 Sep 2024 11:29:50 +0800 Subject: [PATCH 034/230] =?UTF-8?q?API=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=94=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkoff/controllers/ApiUserController.java | 13 +++++++- .../com/fangjia/bkoff/model/ApiUserModel.java | 30 +++++++++++++++++ .../src/main/webapp/apiUser/add.ftl | 25 ++++++++++++-- .../src/main/webapp/apiUser/edit.ftl | 21 ++++++++++++ .../com/fangjia/dal/sql/model/ApiUser.java | 33 +++++++++++++++++++ .../com/fangjia/service/open/ApiUserBo.java | 30 +++++++++++++++++ 6 files changed, 149 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index fab71c646..4f2379d4b 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -133,7 +133,9 @@ public class ApiUserController { bo.setDeadTime(apiUser.getDeadTime()); bo.setManager(apiUser.getManager()); bo.setIsMonitor(apiUser.getIsMonitor()); - + bo.setIsMonitorStatistic(apiUser.getIsMonitorStatistic()); + bo.setIsMonitorUsed(apiUser.getIsMonitorUsed()); + bo.setIsWarnExpired(apiUser.getIsWarnExpired()); apiUserBoList.add(bo); } @@ -217,6 +219,9 @@ public class ApiUserController { apiUser.setIsMonitor(model.getIsMonitor()); apiUser.setContact(model.getContact()); apiUser.setPhone(model.getPhone()); + apiUser.setIsMonitorStatistic(model.getIsMonitorStatistic()); + apiUser.setIsMonitorUsed(model.getIsMonitorUsed()); + apiUser.setIsWarnExpired(model.getIsWarnExpired()); this.apiUserService.save(apiUser); // 新增用户,默认挂牌价改为默认评估价 model.setPriceType("evaluate"); @@ -253,6 +258,9 @@ public class ApiUserController { bo.setDisplayName(user.getDisplayName()); bo.setIsTest(apiUser.getIsTest()); bo.setPurpose(apiUser.getPurpose()); + bo.setIsMonitorStatistic(apiUser.getIsMonitorStatistic()); + bo.setIsMonitorUsed(apiUser.getIsMonitorUsed()); + bo.setIsWarnExpired(apiUser.getIsWarnExpired()); bo.setSiteName(apiUser.getSiteName()); bo.setIp(apiUser.getIp()); bo.setCompany(apiUser.getCompany()); @@ -317,6 +325,9 @@ public class ApiUserController { dataApiUser.put("isMonitor", model.getIsMonitor()); dataApiUser.put("contact", model.getContact()); dataApiUser.put("phone", model.getPhone()); + dataApiUser.put("isMonitorStatistic",model.getIsMonitorStatistic()); + dataApiUser.put("isMonitorUsed",model.getIsMonitorUsed()); + dataApiUser.put("isWarnExpired",model.getIsWarnExpired()); this.apiUserService.update(dataApiUser, userId); // 更改用户密码 // this.userService.updateById(user,userId); diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java index f77689d9e..353a79d8c 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/ApiUserModel.java @@ -44,6 +44,12 @@ public class ApiUserModel extends BaseModel { private String phone; + private Integer isMonitorStatistic; + + private Integer isMonitorUsed; + + private Integer isWarnExpired; + public String getPriceType() { return priceType; } @@ -635,4 +641,28 @@ public class ApiUserModel extends BaseModel { public void setPhone(String phone) { this.phone = phone; } + + public Integer getIsMonitorStatistic() { + return isMonitorStatistic; + } + + public void setIsMonitorStatistic(Integer isMonitorStatistic) { + this.isMonitorStatistic = isMonitorStatistic; + } + + public Integer getIsMonitorUsed() { + return isMonitorUsed; + } + + public void setIsMonitorUsed(Integer isMonitorUsed) { + this.isMonitorUsed = isMonitorUsed; + } + + public Integer getIsWarnExpired() { + return isWarnExpired; + } + + public void setIsWarnExpired(Integer isWarnExpired) { + this.isWarnExpired = isWarnExpired; + } } diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl index 0681d3bfe..01b6b9d82 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/add.ftl @@ -69,8 +69,29 @@ 鏄惁鐩戞帶 - 涓嶇洃鎺� - 鐩戞帶 + 涓嶇洃鎺� + 鐩戞帶 + + + + 鏄惁闇�瑕丄PI缁熻閲� + + 涓嶉渶瑕� + 闇�瑕� + + + + 鏄惁闇�瑕丄PI璐圭敤浣跨敤閲� + + 涓嶉渶瑕� + 闇�瑕� + + + + 鏄惁鎻愰啋鍗冲皢鍒版湡 + + 涓嶆彁閱� + 鎻愰啋 diff --git a/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl b/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl index cc656fb8e..bf62526e0 100644 --- a/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/apiUser/edit.ftl @@ -95,6 +95,27 @@ checked="checked" name="isMonitor" value="1" style="margin-left: 15px;"/>鐩戞帶 + + 鏄惁闇�瑕丄PI缁熻閲� + + checked="checked" name="isMonitorStatistic" value="0" />涓嶉渶瑕� + checked="checked" name="isMonitorStatistic" value="1" style="margin-left: 15px;"/>闇�瑕� + + + + 鏄惁闇�瑕丄PI璐圭敤浣跨敤閲� + + checked="checked" name="isMonitorUsed" value="0" />涓嶉渶瑕� + checked="checked" name="isMonitorUsed" value="1" style="margin-left: 15px;"/>闇�瑕� + + + + 鏄惁鎻愰啋鍗冲皢鍒版湡 + + checked="checked" name="isWarnExpired" value="0" />涓嶆彁閱� + checked="checked" name="isWarnExpired" value="1" style="margin-left: 15px;"/>鎻愰啋 + + Email diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/ApiUser.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/ApiUser.java index 20e6390c3..216e0d6cb 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/ApiUser.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/sql/model/ApiUser.java @@ -45,6 +45,12 @@ public class ApiUser implements SqlEntity { private Integer isMonitor; + private Integer isMonitorStatistic; + + private Integer isMonitorUsed; + + private Integer isWarnExpired; + @Id @Column(name = "ID") public long getId() { @@ -207,4 +213,31 @@ public class ApiUser implements SqlEntity { public void setPhone(String phone) { this.phone = phone; } + + @Column(name = "IS_MONITOR_STATISTIC") + public Integer getIsMonitorStatistic() { + return isMonitorStatistic; + } + + public void setIsMonitorStatistic(Integer isMonitorStatistic) { + this.isMonitorStatistic = isMonitorStatistic; + } + + @Column(name = "IS_MONITOR_USED") + public Integer getIsMonitorUsed() { + return isMonitorUsed; + } + + public void setIsMonitorUsed(Integer isMonitorUsed) { + this.isMonitorUsed = isMonitorUsed; + } + + @Column(name = "IS_WARN_EXPIRED") + public Integer getIsWarnExpired() { + return isWarnExpired; + } + + public void setIsWarnExpired(Integer isWarnExpired) { + this.isWarnExpired = isWarnExpired; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/open/ApiUserBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/open/ApiUserBo.java index f00b8e6d6..1f3da2050 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/open/ApiUserBo.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/open/ApiUserBo.java @@ -32,6 +32,12 @@ public class ApiUserBo implements Serializable { private String phone; //联系人手机号 + private Integer isMonitorStatistic; + + private Integer isMonitorUsed; + + private Integer isWarnExpired; + public String getPriceType() { return priceType; } @@ -191,4 +197,28 @@ public class ApiUserBo implements Serializable { public void setPhone(String phone) { this.phone = phone; } + + public Integer getIsMonitorStatistic() { + return isMonitorStatistic; + } + + public void setIsMonitorStatistic(Integer isMonitorStatistic) { + this.isMonitorStatistic = isMonitorStatistic; + } + + public Integer getIsMonitorUsed() { + return isMonitorUsed; + } + + public void setIsMonitorUsed(Integer isMonitorUsed) { + this.isMonitorUsed = isMonitorUsed; + } + + public Integer getIsWarnExpired() { + return isWarnExpired; + } + + public void setIsWarnExpired(Integer isWarnExpired) { + this.isWarnExpired = isWarnExpired; + } } From 2e1b7418ff54e4dbb3a06ed99efba317fe6c5a68 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 18 Sep 2024 18:08:36 +0800 Subject: [PATCH 035/230] =?UTF-8?q?api=E6=AC=A1=E6=95=B0=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/bkoff/controllers/ApiUserController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java index 4f2379d4b..6e85874c7 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/ApiUserController.java @@ -770,6 +770,7 @@ public class ApiUserController { apiCountLogService.save(apiCountLog); } } + totalCountMap.put(model.getUri(), count); if (count == 0) { totalCountMap.remove(model.getUri()); } From 04b9ac375a014f3bf4404ba68c59a49aef68dcf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 19 Sep 2024 10:09:30 +0800 Subject: [PATCH 036/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=84=E4=BC=B0?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/FshController.java | 2 +- .../com/fangjia/open/model/PropertyEvaluationModel.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java index d5d69a1af..87a1e84b3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java @@ -1925,7 +1925,7 @@ public class FshController { evaluation.setFitmentCharge(model.getDecorationCost()); } evaluation.setGardenArea(model.getGardenArea()); - if (0 != model.getHall()) { + if (model.getHall() != null && 0 != model.getHall()) { evaluation.setHall(model.getHall()); } if (null != model.getFloor()) { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java index 2abc1acf1..d6848c616 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java @@ -80,7 +80,7 @@ public class PropertyEvaluationModel extends FangjiaApiModel { /** * 厅数 */ - private int hall; + private Integer hall; /** * 卫数 @@ -361,11 +361,11 @@ public class PropertyEvaluationModel extends FangjiaApiModel { this.room = room; } - public int getHall() { + public Integer getHall() { return hall; } - public void setHall(int hall) { + public void setHall(Integer hall) { this.hall = hall; } From cf6879f13ec293e4946b44a8cc9be441a78bf0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 19 Sep 2024 10:13:40 +0800 Subject: [PATCH 037/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=84=E4=BC=B0?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fangjia/open/controllers/FshController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java index 87a1e84b3..f0c267e87 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java @@ -1951,7 +1951,7 @@ public class FshController { evaluation.setOtherFactor(model.getOtherFactor()); } evaluation.setRegion(model.getDistrict()); - if (0 != model.getRoom()) { + if (model.getRoom() != null && 0 != model.getRoom()) { evaluation.setRoom(model.getRoom()); } if (StringUtils.isNotBlank(model.getRoomNumber())) { From 5d13cd5af34d9bbb7013f7d793feb7d20b010e2b Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 19 Sep 2024 15:49:01 +0800 Subject: [PATCH 038/230] =?UTF-8?q?=E7=94=BB=E5=BC=80=E5=8F=91=E5=8C=BA?= =?UTF-8?q?=E5=8A=A0=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/developmentZone/edit.ftl | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl b/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl index b64ba3bac..b75eca58f 100644 --- a/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl @@ -68,8 +68,10 @@ + + -
+
@@ -312,6 +314,52 @@ fetchProvinces() + var currentMarker = null; + + function addMarker(lng, lat){ + var markerPoint = new BMap.Point(lng, lat); + + // 绉婚櫎鏃х殑鏍囪鐐� + if (currentMarker) { + map.removeOverlay(currentMarker); + } + + // 鍒涘缓鏂扮殑鏍囪鐐� + currentMarker = new BMap.Marker(markerPoint); + map.addOverlay(currentMarker); + map.setCenter(markerPoint); + + currentMarker.enableDragging(); + + currentMarker.addEventListener("dragging", function(e) { + $("#mapLng").text(e.point.lng); + $("#mapLat").text(e.point.lat); + }); + } + $("#btn_sea").click(function() { + var keyword = $.trim($("#seaAddress").val()); + + var options = { + onSearchComplete: function(results) { + console.log(results) + // 鍒ゆ柇鐘舵�佹槸鍚︽纭� + if (local.getStatus() === BMAP_STATUS_SUCCESS) { + if (results.getCurrentNumPois() > 0) { + var lng = results.getPoi(0).point.lng; + var lat = results.getPoi(0).point.lat; + addMarker(lng, lat); // 浠呮坊鍔犳爣璁扮偣 + // var mPoint = new BMap.Point(lng, lat) + // map.centerAndZoom(mPoint,15); + // drawPolygons(); // 閲嶆柊缁樺埗鍥存爮 + } + } + } + }; + + var local = new BMap.LocalSearch(map, options); + local.search(keyword); + }); + From 3165f27f91f157e51f53e0158bf3c0bb9b306834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 19 Sep 2024 15:55:04 +0800 Subject: [PATCH 039/230] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/FshController.java | 8 ++++++-- .../com/fangjia/open/model/PropertyEvaluationModel.java | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java index f0c267e87..c8b8b64ad 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/FshController.java @@ -1925,8 +1925,12 @@ public class FshController { evaluation.setFitmentCharge(model.getDecorationCost()); } evaluation.setGardenArea(model.getGardenArea()); - if (model.getHall() != null && 0 != model.getHall()) { - evaluation.setHall(model.getHall()); + try { + if (0 != model.getHall()) { + evaluation.setHall(model.getHall()); + } + } catch (Exception ex) { + } if (null != model.getFloor()) { evaluation.setFloor(model.getFloor()); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java index d6848c616..2abc1acf1 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/PropertyEvaluationModel.java @@ -80,7 +80,7 @@ public class PropertyEvaluationModel extends FangjiaApiModel { /** * 厅数 */ - private Integer hall; + private int hall; /** * 卫数 @@ -361,11 +361,11 @@ public class PropertyEvaluationModel extends FangjiaApiModel { this.room = room; } - public Integer getHall() { + public int getHall() { return hall; } - public void setHall(Integer hall) { + public void setHall(int hall) { this.hall = hall; } From e59df996ea78121ec8378671478ddbf468f1d77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 20 Sep 2024 17:37:43 +0800 Subject: [PATCH 040/230] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fangjia/open/util/FileDao.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java index 2919c8a6c..be6fa3e75 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/util/FileDao.java @@ -34,8 +34,8 @@ public class FileDao { IMPORTANT_CATEGORY = Arrays.asList(System.getProperty("fangjia.important.category", "data_file,district,shop,office,avatar,flash,user_house,upload").split(",")); try { - filesCollection = new Mongo("fs.mongo.db.fangjia.com", 27000).getDB("fangjia_fs").getCollection("files"); - gridFs = new GridFS(filesCollection.getDB(), "fangjia_fs"); + filesCollection = new Mongo("fs.mongo.db.fangjia.com", 27000).getDB("fangjia").getCollection("files"); + gridFs = new GridFS(filesCollection.getDB(), "fangjia"); cappedCollection = new Mongo("capped.mongo.db.fangjia.com", Integer.getInteger("capped.mongo.port", 27000)).getDB("fangjia_fs").getCollection("files_capped"); } catch (Exception e) { e.printStackTrace(); From 197250766be9a4829760e8b5c5c0cf754b8da05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 20 Sep 2024 17:49:13 +0800 Subject: [PATCH 041/230] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fangjia/stc2/FileDao.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java b/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java index fcda0b3e4..9b22b5672 100644 --- a/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java +++ b/projects/fangjia-static/src/main/java/com/fangjia/stc2/FileDao.java @@ -37,8 +37,8 @@ public class FileDao { IMPORTANT_CATEGORY = Arrays.asList(System.getProperty("fangjia.important.category", "district,shop,office,avatar,flash,user_house,upload,news,attachment").split(",")); try { - filesCollection = new Mongo("fs.mongo.db.fangjia.com", Integer.getInteger("fs.mongo.port", 27017)).getDB("fangjia_fs").getCollection("files"); - gridFs = new GridFS(filesCollection.getDB(), "fangjia_fs"); + filesCollection = new Mongo("fs.mongo.db.fangjia.com", Integer.getInteger("fs.mongo.port", 27017)).getDB("fangjia").getCollection("files"); + gridFs = new GridFS(filesCollection.getDB(), "fangjia"); cappedCollection = new Mongo("capped.mongo.db.fangjia.com", Integer.getInteger("capped.mongo.port", 27017)).getDB("fangjia_fs").getCollection("files_capped"); } catch (Exception e) { e.printStackTrace(); From 888f51f0fe92e54b2494a0e9032b0e40cbb0a4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 23 Sep 2024 09:54:40 +0800 Subject: [PATCH 042/230] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=9D=87=E4=BB=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 6b669977b..11fbd8025 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -1,10 +1,12 @@ package com.fangjia.open.controllers; import com.fangjia.core.util.HttpRequest; -import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.mongo.model.VillageIdentify; import com.fangjia.dal.seaweed.model.District; -import com.fangjia.open.dto.addressGovernance.*; +import com.fangjia.open.dto.addressGovernance.DistrictDto; +import com.fangjia.open.dto.addressGovernance.DistrictIdentifyDto; +import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; +import com.fangjia.open.dto.addressGovernance.StructureAndCompleteDto; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; import com.fangjia.open.model.AddesssMatchModel; @@ -12,7 +14,7 @@ import com.fangjia.open.model.AddressModel; import com.fangjia.open.model.BasicModel; import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.open.util.CommonDtoUtils; -import com.fangjia.service.bo.DistrictStatBo; +import com.fangjia.service.bo.DistrictAvgBo; import com.fangjia.service.datastore.DistrictService; import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.mongo.fangjia.VillageIdentifyService; @@ -39,9 +41,7 @@ import sun.misc.BASE64Encoder; import java.io.IOException; import java.net.Authenticator; -import java.net.InetSocketAddress; import java.net.PasswordAuthentication; -import java.net.Proxy; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; @@ -372,18 +372,26 @@ public class AddrSvcController { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); BasicModel basicModel = new BasicModel(200, "ok"); if (json != null && json.size() > 0) { - MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json); + MatchedBuildingDto dto = new MatchedBuildingDto(); + if (json.containsKey("id")) { + dto.setId(json.getString("id")); + } + if (json.containsKey("city")) { + dto.setCity(json.getString("city")); + } + if (json.containsKey("district")) { + dto.setDistrict(json.getString("district")); + } + if (json.containsKey("name")) { + dto.setName(json.getString("name")); + } District district = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), "district"); if (null != district) { - DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(dto.getCity(), dto.getDistrict(), dto.getName())); + //DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(dto.getCity(), dto.getDistrict(), dto.getName())); + DistrictAvgBo statBo = districtStatService.findDistrictStat(district, "district", null) ; if (null != statBo) { - if (statBo.getDistrictStat() != null) { - dto.setAvgPrice(statBo.getDistrictStat().getAvgPrice()); - } else if (statBo.getVillaDistrictStat() != null) { - dto.setAvgPrice(statBo.getVillaDistrictStat().getAvgPrice()); - } - + dto.setAvgPrice(statBo.getAvgPrice()); } } basicModel.setResult(dto); From 786ea3df36c73397662a3498f0a4dac00eae4c78 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Sep 2024 11:46:55 +0800 Subject: [PATCH 043/230] =?UTF-8?q?njcb=E6=B6=89=E5=86=9C=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/AddrSvcController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 11fbd8025..b1a869b94 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -389,7 +389,7 @@ public class AddrSvcController { District district = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), "district"); if (null != district) { //DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(dto.getCity(), dto.getDistrict(), dto.getName())); - DistrictAvgBo statBo = districtStatService.findDistrictStat(district, "district", null) ; + DistrictAvgBo statBo = districtStatService.findDistrictStat(district, "district", null); if (null != statBo) { dto.setAvgPrice(statBo.getAvgPrice()); } @@ -514,7 +514,7 @@ public class AddrSvcController { } else { try { //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + if (result.containsKey("province") && ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province")))) { //结果比较,如果涉农结果不一致 //调用齐梁 type :1 对公 0 对私 //我们 type :1 对私 2 对共 From 673b0d656c5fb9cf2444051d5911f5ad540a5c54 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Sep 2024 13:06:27 +0800 Subject: [PATCH 044/230] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=88=BF=E6=BA=90?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E6=94=B9=E6=88=905=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index ae8b64282..bca8b4100 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -178,6 +178,7 @@ public class PropertyController { private FileDao fileDao = FileDao.getInstance(); private static final int DEFAULT_PAGE_SIZE = 20; + private static final int DEFAULT_HOUSE_COUNT = 5; private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "lat2", "lng2", "lat", "lng", "block", "estateType2", "addrAlias", "alias"}; static final int BAI_DU_GEO = 1;// 百度系坐标 static final int GAO_DE_GEO = 2;// 高德系坐标 @@ -2780,7 +2781,7 @@ public class PropertyController { return mav; } if (model.getMax() == null || model.getMax() < 1) { - model.setMax(DEFAULT_PAGE_SIZE); + model.setMax(DEFAULT_HOUSE_COUNT); } else if (model.getMax() > 100) { model.setMax(100); } From 2df46c820505d2743e7223657e7e7a5482f84e6a Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 24 Sep 2024 15:09:51 +0800 Subject: [PATCH 045/230] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7API?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=87=8F=E4=BD=BF=E7=94=A890%=E5=8F=91?= =?UTF-8?q?=E9=80=81kafka=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthenticationInterceptor.java | 836 +++++++++--------- .../util/kafka/KafkaProducerUtils.java | 7 + 2 files changed, 448 insertions(+), 395 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java index eff33a38f..471b6f946 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java @@ -14,6 +14,7 @@ import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.service.open.ApiUserAuthorityService; import com.fangjia.service.open.ApiVisitCountService; import com.fangjia.service.sql.ApiUserService; +import com.fangjia.service.util.kafka.KafkaProducerUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,422 +31,467 @@ import java.util.*; * API拦截器 * * @author - * */ public class AuthenticationInterceptor implements Interceptor { - private ApiUserService apiUserService; - private ApiUserAuthorityService apiUserAuthorityService; - private ApiVisitCountService apiVisitCountService; - private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticationInterceptor.class); - private static final Date OLD_USER_SPLITTED_DATE = DateUtil.parseFormatDate("2016-06-06"); - private static final List HAS_SUB_SERVICE_URIS = new ArrayList(); - private static final String SUB_SERVICE_SEPARATOR = "#"; - private static final String SERVICE_CODE_PARAM_NAME = "serviceCode"; - static { - HAS_SUB_SERVICE_URIS.add("/property/transaction"); - } - /** - * token过期时间 单位:s - */ - private static final long TOKEN_EXPIRED_TIME = 60 * 60 * 2; + private ApiUserService apiUserService; + private KafkaProducerUtils kafkaProducerUtils; + private ApiUserAuthorityService apiUserAuthorityService; + private ApiVisitCountService apiVisitCountService; + private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticationInterceptor.class); + private static final Date OLD_USER_SPLITTED_DATE = DateUtil.parseFormatDate("2016-06-06"); + private static final List HAS_SUB_SERVICE_URIS = new ArrayList(); + private static final String SUB_SERVICE_SEPARATOR = "#"; + private static final String SERVICE_CODE_PARAM_NAME = "serviceCode"; + private static final String SMS_DATA_TOPIC = "sms-data-topic"; + private static final String SMS_DATA_TOPIC_PROFIX = "sendSms90-"; - public Object intercept(ActionInvocation invocation) throws ActionInvocationException { + static { + HAS_SUB_SERVICE_URIS.add("/property/transaction"); + } - Authority authority = getAuthority(invocation); - ActionContext context = invocation.getActionContext(); - HttpServletRequest request = context.getRequest(); - RestfulModelAndView ret = new RestfulModelAndView(); - ret.setViewType("rest"); - - try { - HttpCode httpCode = null; - if(!OpenConfig.getConfig().isOpenAllAuthority()) { - String token = request.getParameter("token"); - if(isNeedToken(authority)){ - httpCode = authorized(token, request); - }else if(StringUtils.isNotBlank(token)){ - ApiUser apiUser = parseApiUserByToken(FangjiaApiUtil.parse2Token(token)); - if(apiUser != null){ - User user = apiUserService.findUserById(apiUser.getId()); - AuthenticationBean.get(request, apiUser, user, null); - } - } - } - //功能方法没有设置权限或者有该方法权限 - if (authority == null || authority.role() == Role.NONE || null == httpCode) { - Object obj; - try{ - obj = invocation.invoke(); - }catch (Exception e){ - throw e; - } - return obj; - }else { - if(httpCode.getErrorCode() == 4003){ - BasicModel basicModel = BasicModel.buildBadRequestModel(httpCode.getErrorMessage().toString()); - ret.setModel(basicModel); - return ret; - }else{ - String msg = httpCode.getMessage() + "(" + httpCode.getErrorMessage() + ")"; - BasicModel basicModel = BasicModel.buildUnAuthorizedModel().setMsg(msg); - ret.setModel(basicModel); - return ret; - } - - } - } catch (Exception e) { - LOGGER.error("Authentication error : ", e); - ret.setModel(BasicModel.buildServerErrorModel()); - ret.setViewParam("code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - return ret; - } - - } - - private boolean isNeedToken(Authority authority){ - return authority != null && authority.role() != null && authority.role() != Role.NONE; - } - - private boolean isReachUpperLimit(ApiUserAuthority auth, String uri, String serviceCode) { - - if (auth == null || auth.getLimitCountMap() == null) { - return false; - } - Date visitDate = DateUtil.truncateDay(new Date()); - Integer upperLimit = auth.getLimitCountMap().get(uri); - Long apiVisitCount; - if (upperLimit != null && upperLimit > 0) { - apiVisitCount = apiVisitCountService.findApiVisitCount(auth.getUserId(), uri, null, visitDate); - if(apiVisitCount >= upperLimit){ - return true; - } - } - if(hasSubService(uri) && StringUtils.isNotBlank(serviceCode)){ - upperLimit = auth.getLimitCountMap().get(uri + SUB_SERVICE_SEPARATOR + serviceCode); - if (upperLimit != null && upperLimit > 0) { - apiVisitCount = apiVisitCountService.findApiVisitCount(auth.getUserId(), uri, serviceCode, visitDate); - if(apiVisitCount >= upperLimit){ - return true; - } - } - } - return false; - } - - private boolean isReachDeadline(ApiUserAuthority auth, String uri, String serviceCode){ - - if(auth.getDeadlineMap() == null){ - return false; - } - Date deadline = auth.getDeadlineMap().get(uri); - if(null != deadline && deadline.before(new Date())){ - return true; - } - if(hasSubService(uri) && StringUtils.isNotBlank(serviceCode)){ - deadline = auth.getDeadlineMap().get(uri + SUB_SERVICE_SEPARATOR + serviceCode); - if(null != deadline && deadline.before(new Date())){ - return true; - } - } - - return false; - } - - private boolean isReachSumLimit(ApiUserAuthority auth, String uri, String serviceCode) { - - if (auth == null || auth.getTotalCountMap() == null) { - return false; - } - - if(auth.getTotalCountMap() != null && auth.getTotalCountMap().get(uri) != null){ - Integer totalLimit = auth.getTotalCountMap().get(uri); - Long totalApiVisitCount; - if(totalLimit != null && totalLimit > 0){ - totalApiVisitCount = apiVisitCountService.findApiVisitTotalCount(auth.getUserId(), uri, serviceCode); - if(totalApiVisitCount >= totalLimit){ - return true; - } - } - } - if(hasSubService(uri) && StringUtils.isNotBlank(serviceCode)){ - Integer totalLimit = auth.getTotalCountMap().get(uri + SUB_SERVICE_SEPARATOR + serviceCode); - if(totalLimit != null && totalLimit > 0){ - Long totalApiVisitCount = apiVisitCountService.findApiVisitTotalCount(auth.getUserId(), uri, serviceCode); - if(totalApiVisitCount >= totalLimit){ - return true; - } - } - - } - return false; - } - - private Authority getAuthority(ActionInvocation invocation) { - Authority authority; - // 获取方法上的权限注解 - authority = invocation.getAction().getActionMethod().getAnnotation(Authority.class); - if (null != authority) { - return authority; - } - // 获取类上的权限注解 - authority = invocation.getControllerInstance().getClass().getAnnotation(Authority.class); - return authority; - } - - - /** - * 检验是否有访问该Action的权限 - * - * @param tokenStr - * @param request - * @return - * @throws Exception - */ - private HttpCode authorized(String tokenStr, HttpServletRequest request) throws Exception { - - // 检查是否为api用户 - HttpCode ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD); - Token token = FangjiaApiUtil.parse2Token(tokenStr); - ApiUser apiUser = parseApiUserByToken(token); - if (null == apiUser) { - return ret; - } - if(apiUser.getDeadTime() != null && DateUtil.truncateDay(new Date()).after(apiUser.getDeadTime())){ - return new HttpCode(OpenHttpCodeEnum.USER_EXPIRED); - } - if(!isOldUser(apiUser) && isExpired(token)){ - return new HttpCode(OpenHttpCodeEnum.TOKEN_EXPIRED); - } - if (1 == apiUser.getStatus()) { - return new HttpCode(OpenHttpCodeEnum.AUTH_FAILD, "你的账户已失效"); - } - if(StringUtils.isNotBlank(apiUser.getIp())){ - String ip = AnalyticsUtil.getIpAddress(request); - if(!isAuthIp(ip,apiUser)){ - ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD,"ip[" + ip + "]无权限访问API"); - return ret; - } - } - - String uri = request.getRequestURI(); - ApiUserAuthority auth = this.apiUserAuthorityService.findByUserId(apiUser.getId()); - if(auth != null){ - User user = apiUserService.findUserById(apiUser.getId()); - AuthenticationBean.get(request, apiUser, user, auth); - } - uri = OpenConfig.getConfig().isDevelopmentEnvironment() ? uri.replace("/fangjia-open", "") : uri; - // 检查是否有访问该Action的权限 - boolean authAction = null != auth && auth.getOpenResourseUris().contains(uri); - String cityName = request.getParameter("city"); - if(StringUtils.isBlank(cityName)){ - cityName = request.getParameter("cityName"); - } - if (StringUtils.isNotBlank(cityName)) { - boolean authCity = StringUtils.isNotBlank(apiUser.getCity()) && !StringUtils.equalsIgnoreCase(apiUser.getCity(), "all"); - if(authCity){ - cityName = request.getParameter("city"); - cityName = RegionData.formatCity(cityName); - if(!RegionData.isCity(cityName)){ - ret = new HttpCode(OpenHttpCodeEnum.ARGUMENT_INVALID); - ret.setErrorMessage("城市非法"); - return ret; - } - } - } - boolean authCity = isAuthCity(cityName, apiUser); - if (!authCity) { - ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD, "您未开通城市" + (StringUtils.isNotBlank(cityName) ? cityName : StringUtils.EMPTY) + "的权限"); - } - if (authAction && authCity) { - if(hasSubService(uri)){ - List serviceCodes = getServiceCode(request); - for(String serviceCode : serviceCodes){ - if(!auth.getOpenResourseUris().contains(uri + SUB_SERVICE_SEPARATOR + serviceCode)){ - ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD ,"无权限访问服务:" + serviceCode); - return ret; - } - if(isReachDeadline(auth, uri, serviceCode)){ - ret = new HttpCode(OpenHttpCodeEnum.SERVICE_EXPIRED, serviceCode + "服务已过期"); - return ret; - } - if(isReachUpperLimit(auth, uri, serviceCode)){ - ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT ,serviceCode + "今日已达到配额上限"); - return ret; - } - // 检测是否达到总数访问上限 - if (isReachSumLimit(auth, uri, serviceCode)) { - ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, serviceCode + "已达到配额上限"); - return ret; - } - } - - }else{ - if(isReachDeadline(auth, uri, null)){ - ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, "服务已过期"); - return ret; - } - // 检测是否达到今天访问上限 - if (isReachUpperLimit(auth, uri, null)) { - ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, "今日已达到配额上限"); - return ret; - } - // 检测是否达到总数访问上限 - if (isReachSumLimit(auth, uri, null)) { - ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, "已达到配额上限"); - return ret; - } - } - return null; - } - - return ret; - } - - - - /** - * - * @param request - * @return + /** + * token过期时间 单位:s */ - private List getServiceCode(HttpServletRequest request){ + private static final long TOKEN_EXPIRED_TIME = 60 * 60 * 2; - String serviceCode = request.getParameter(SERVICE_CODE_PARAM_NAME); - if(StringUtils.isBlank(serviceCode)){ - return Collections.emptyList(); - } - return Arrays.asList(serviceCode.split(",|,")); - } - /** - * 判断该API是否拥有子权限 - * @param uri - * @return + public Object intercept(ActionInvocation invocation) throws ActionInvocationException { + + Authority authority = getAuthority(invocation); + ActionContext context = invocation.getActionContext(); + HttpServletRequest request = context.getRequest(); + RestfulModelAndView ret = new RestfulModelAndView(); + ret.setViewType("rest"); + + try { + HttpCode httpCode = null; + if (!OpenConfig.getConfig().isOpenAllAuthority()) { + String token = request.getParameter("token"); + if (isNeedToken(authority)) { + httpCode = authorized(token, request); + } else if (StringUtils.isNotBlank(token)) { + ApiUser apiUser = parseApiUserByToken(FangjiaApiUtil.parse2Token(token)); + if (apiUser != null) { + User user = apiUserService.findUserById(apiUser.getId()); + AuthenticationBean.get(request, apiUser, user, null); + } + } + } + //功能方法没有设置权限或者有该方法权限 + if (authority == null || authority.role() == Role.NONE || null == httpCode) { + Object obj; + try { + obj = invocation.invoke(); + } catch (Exception e) { + throw e; + } + return obj; + } else { + if (httpCode.getErrorCode() == 4003) { + BasicModel basicModel = BasicModel.buildBadRequestModel(httpCode.getErrorMessage().toString()); + ret.setModel(basicModel); + return ret; + } else { + String msg = httpCode.getMessage() + "(" + httpCode.getErrorMessage() + ")"; + BasicModel basicModel = BasicModel.buildUnAuthorizedModel().setMsg(msg); + ret.setModel(basicModel); + return ret; + } + + } + } catch (Exception e) { + LOGGER.error("Authentication error : ", e); + ret.setModel(BasicModel.buildServerErrorModel()); + ret.setViewParam("code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return ret; + } + + } + + private boolean isNeedToken(Authority authority) { + return authority != null && authority.role() != null && authority.role() != Role.NONE; + } + + private boolean isReachUpperLimit(ApiUserAuthority auth, String uri, String serviceCode) { + + if (auth == null || auth.getLimitCountMap() == null) { + return false; + } + Date visitDate = DateUtil.truncateDay(new Date()); + Integer upperLimit = auth.getLimitCountMap().get(uri); + Long apiVisitCount; + if (upperLimit != null && upperLimit > 0) { + apiVisitCount = apiVisitCountService.findApiVisitCount(auth.getUserId(), uri, null, visitDate); + if (apiVisitCount >= upperLimit) { + return true; + } + } + if (hasSubService(uri) && StringUtils.isNotBlank(serviceCode)) { + upperLimit = auth.getLimitCountMap().get(uri + SUB_SERVICE_SEPARATOR + serviceCode); + if (upperLimit != null && upperLimit > 0) { + apiVisitCount = apiVisitCountService.findApiVisitCount(auth.getUserId(), uri, serviceCode, visitDate); + if (apiVisitCount >= upperLimit) { + return true; + } + } + } + return false; + } + + private boolean isReachDeadline(ApiUserAuthority auth, String uri, String serviceCode) { + + if (auth.getDeadlineMap() == null) { + return false; + } + Date deadline = auth.getDeadlineMap().get(uri); + if (null != deadline && deadline.before(new Date())) { + return true; + } + if (hasSubService(uri) && StringUtils.isNotBlank(serviceCode)) { + deadline = auth.getDeadlineMap().get(uri + SUB_SERVICE_SEPARATOR + serviceCode); + if (null != deadline && deadline.before(new Date())) { + return true; + } + } + + return false; + } + + private boolean isReachSumLimit(ApiUserAuthority auth, String uri, String serviceCode) { + + if (auth == null || auth.getTotalCountMap() == null) { + return false; + } + + if (auth.getTotalCountMap() != null && auth.getTotalCountMap().get(uri) != null) { + Integer totalLimit = auth.getTotalCountMap().get(uri); + Long totalApiVisitCount; + if (totalLimit != null && totalLimit > 0) { + totalApiVisitCount = apiVisitCountService.findApiVisitTotalCount(auth.getUserId(), uri, serviceCode); + if (totalApiVisitCount >= totalLimit) { + return true; + } + } + } + if (hasSubService(uri) && StringUtils.isNotBlank(serviceCode)) { + Integer totalLimit = auth.getTotalCountMap().get(uri + SUB_SERVICE_SEPARATOR + serviceCode); + if (totalLimit != null && totalLimit > 0) { + Long totalApiVisitCount = apiVisitCountService.findApiVisitTotalCount(auth.getUserId(), uri, serviceCode); + if (totalApiVisitCount >= totalLimit) { + return true; + } + } + + } + return false; + } + + private boolean isReach90SumLimit(ApiUserAuthority auth, String uri, String serviceCode) { + + if (auth == null || auth.getTotalCountMap() == null) { + return false; + } + + if (auth.getTotalCountMap() != null && auth.getTotalCountMap().get(uri) != null) { + Integer totalLimit = auth.getTotalCountMap().get(uri); + Long totalApiVisitCount; + if (totalLimit != null && totalLimit > 0) { + totalApiVisitCount = apiVisitCountService.findApiVisitTotalCount(auth.getUserId(), uri, serviceCode); + if (totalApiVisitCount.intValue() == (int) (totalLimit * 0.9)) { + return true; + } + } + } + if (hasSubService(uri) && StringUtils.isNotBlank(serviceCode)) { + Integer totalLimit = auth.getTotalCountMap().get(uri + SUB_SERVICE_SEPARATOR + serviceCode); + if (totalLimit != null && totalLimit > 0) { + Long totalApiVisitCount = apiVisitCountService.findApiVisitTotalCount(auth.getUserId(), uri, serviceCode); + if (totalApiVisitCount.intValue() == (int) (totalLimit * 0.9)) { + return true; + } + } + + } + return false; + } + + private Authority getAuthority(ActionInvocation invocation) { + Authority authority; + // 获取方法上的权限注解 + authority = invocation.getAction().getActionMethod().getAnnotation(Authority.class); + if (null != authority) { + return authority; + } + // 获取类上的权限注解 + authority = invocation.getControllerInstance().getClass().getAnnotation(Authority.class); + return authority; + } + + + /** + * 检验是否有访问该Action的权限 + * + * @param tokenStr + * @param request + * @return + * @throws Exception */ - private boolean hasSubService(String uri){ - return HAS_SUB_SERVICE_URIS.contains(uri); - } + private HttpCode authorized(String tokenStr, HttpServletRequest request) throws Exception { - /** - * 2016年06月06日以前的用户是老用户,token不过期 - * @param apiUser - * @return - */ - private boolean isOldUser(ApiUser apiUser){ - return OLD_USER_SPLITTED_DATE.after(apiUser.getCreationDate()); - } + // 检查是否为api用户 + HttpCode ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD); + Token token = FangjiaApiUtil.parse2Token(tokenStr); + ApiUser apiUser = parseApiUserByToken(token); + if (null == apiUser) { + return ret; + } + if (apiUser.getDeadTime() != null && DateUtil.truncateDay(new Date()).after(apiUser.getDeadTime())) { + return new HttpCode(OpenHttpCodeEnum.USER_EXPIRED); + } + if (!isOldUser(apiUser) && isExpired(token)) { + return new HttpCode(OpenHttpCodeEnum.TOKEN_EXPIRED); + } + if (1 == apiUser.getStatus()) { + return new HttpCode(OpenHttpCodeEnum.AUTH_FAILD, "你的账户已失效"); + } + if (StringUtils.isNotBlank(apiUser.getIp())) { + String ip = AnalyticsUtil.getIpAddress(request); + if (!isAuthIp(ip, apiUser)) { + ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD, "ip[" + ip + "]无权限访问API"); + return ret; + } + } - /** - * 判断Token是否过期 - * @param token - * @return - */ - private boolean isExpired(Token token){ - return System.currentTimeMillis() / 1000 - token.getTimestamp() > TOKEN_EXPIRED_TIME; - } + String uri = request.getRequestURI(); + ApiUserAuthority auth = this.apiUserAuthorityService.findByUserId(apiUser.getId()); + User user = apiUserService.findUserById(apiUser.getId()); + if (auth != null) { + AuthenticationBean.get(request, apiUser, user, auth); + } + uri = OpenConfig.getConfig().isDevelopmentEnvironment() ? uri.replace("/fangjia-open", "") : uri; + // 检查是否有访问该Action的权限 + boolean authAction = null != auth && auth.getOpenResourseUris().contains(uri); + String cityName = request.getParameter("city"); + if (StringUtils.isBlank(cityName)) { + cityName = request.getParameter("cityName"); + } + if (StringUtils.isNotBlank(cityName)) { + boolean authCity = StringUtils.isNotBlank(apiUser.getCity()) && !StringUtils.equalsIgnoreCase(apiUser.getCity(), "all"); + if (authCity) { + cityName = request.getParameter("city"); + cityName = RegionData.formatCity(cityName); + if (!RegionData.isCity(cityName)) { + ret = new HttpCode(OpenHttpCodeEnum.ARGUMENT_INVALID); + ret.setErrorMessage("城市非法"); + return ret; + } + } + } + boolean authCity = isAuthCity(cityName, apiUser); + if (!authCity) { + ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD, "您未开通城市" + (StringUtils.isNotBlank(cityName) ? cityName : StringUtils.EMPTY) + "的权限"); + } + if (authAction && authCity) { + if (hasSubService(uri)) { + List serviceCodes = getServiceCode(request); + for (String serviceCode : serviceCodes) { + if (!auth.getOpenResourseUris().contains(uri + SUB_SERVICE_SEPARATOR + serviceCode)) { + ret = new HttpCode(OpenHttpCodeEnum.AUTH_FAILD, "无权限访问服务:" + serviceCode); + return ret; + } + if (isReachDeadline(auth, uri, serviceCode)) { + ret = new HttpCode(OpenHttpCodeEnum.SERVICE_EXPIRED, serviceCode + "服务已过期"); + return ret; + } + if (isReachUpperLimit(auth, uri, serviceCode)) { + ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, serviceCode + "今日已达到配额上限"); + return ret; + } + // 检测是否达到总数访问上限 + if (isReachSumLimit(auth, uri, serviceCode)) { + ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, serviceCode + "已达到配额上限"); + return ret; + } + // 检测是否达到总数的90% + if (isReach90SumLimit(auth, uri, serviceCode)) { + kafkaProducerUtils.send(SMS_DATA_TOPIC, SMS_DATA_TOPIC_PROFIX + apiUser.getPhone() + "-" + user.getUserName() + "-" + uri); + } + } - /** - * - * @param ip 验证客户IP是否在注册的白名单中 - * @param apiUser - * @return - */ - private boolean isAuthIp(String ip,ApiUser apiUser){ - if(StringUtils.isBlank(ip) || StringUtils.isBlank(apiUser.getIp())){ - return false; - } - String[] ips = apiUser.getIp().split("\n"); - for(String authIp:ips){ - if(StringUtils.isNotBlank(authIp) && ip.startsWith(authIp.replaceAll("\\s", ""))){ - return true; - } - } - return false; - } + } else { + if (isReachDeadline(auth, uri, null)) { + ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, "服务已过期"); + return ret; + } + // 检测是否达到今天访问上限 + if (isReachUpperLimit(auth, uri, null)) { + ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, "今日已达到配额上限"); + return ret; + } + // 检测是否达到总数访问上限 + if (isReachSumLimit(auth, uri, null)) { + ret = new HttpCode(OpenHttpCodeEnum.UPPER_LIMIT, "已达到配额上限"); + return ret; + } + // 检测是否达到总数的90% + if (isReach90SumLimit(auth, uri, null)) { + kafkaProducerUtils.send(SMS_DATA_TOPIC, SMS_DATA_TOPIC_PROFIX + apiUser.getPhone() + "-" + user.getUserName() + "-" + uri); + } + } + return null; + } - /** - * 是否有权限访问该城市 - * - * @param cityName - * @param apiUser - * @return - */ - private boolean isAuthCity(String cityName, ApiUser apiUser) { - // 若访问当前接口不需要城市参数,则返回true - if (StringUtils.isBlank(cityName)) { - return true; - } - if(!RegionData.isCity(cityName)){ - String city = RegionData.formatCity(cityName); - if(null != city){ - cityName = city; - } - } - // 若当前接口需要城市,检查是否有访问当前城市的权限 - boolean authCity = StringUtils.isNotBlank(apiUser.getCity()) && !StringUtils.equalsIgnoreCase(apiUser.getCity(), "all"); - if (authCity) { - ServerArea city = ServerAreaData.getServerAreaByDisplayDefaultNull(cityName); - if (null != city) { - return apiUser.getCity().contains(city.getSpell()); - } - } - return true; - } - - private ApiUser parseApiUserByToken(Token token){ - - if(token == null){ - return null; - } - ApiUser apiUser = apiUserService.findApiUserById(token.getUserId()); - if(apiUser == null){ - return null; - } - if(!apiUser.getAppKey().equals(token.getAppKey())){ - return null; - } - return apiUser; - } + return ret; + } - /** - * 新版token验证 - * - * @param token - * @return - */ - private ApiUser checkNewAuthorized(String token) { + /** + * @param request + * @return + */ + private List getServiceCode(HttpServletRequest request) { - Map tokenMap = FangjiaApiUtil.parseToken(token); - if (tokenMap == null) { - return null; - } - // token验证后,拿取出的字段再去数据库验证一遍 - if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { - ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); - if (apiUser != null) { - if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { - return apiUser; - } - } - } - return null; - } + String serviceCode = request.getParameter(SERVICE_CODE_PARAM_NAME); + if (StringUtils.isBlank(serviceCode)) { + return Collections.emptyList(); + } + return Arrays.asList(serviceCode.split(",|,")); + } + + /** + * 判断该API是否拥有子权限 + * + * @param uri + * @return + */ + private boolean hasSubService(String uri) { + return HAS_SUB_SERVICE_URIS.contains(uri); + } + + /** + * 2016年06月06日以前的用户是老用户,token不过期 + * + * @param apiUser + * @return + */ + private boolean isOldUser(ApiUser apiUser) { + return OLD_USER_SPLITTED_DATE.after(apiUser.getCreationDate()); + } + + /** + * 判断Token是否过期 + * + * @param token + * @return + */ + private boolean isExpired(Token token) { + return System.currentTimeMillis() / 1000 - token.getTimestamp() > TOKEN_EXPIRED_TIME; + } + + /** + * @param ip 验证客户IP是否在注册的白名单中 + * @param apiUser + * @return + */ + private boolean isAuthIp(String ip, ApiUser apiUser) { + if (StringUtils.isBlank(ip) || StringUtils.isBlank(apiUser.getIp())) { + return false; + } + String[] ips = apiUser.getIp().split("\n"); + for (String authIp : ips) { + if (StringUtils.isNotBlank(authIp) && ip.startsWith(authIp.replaceAll("\\s", ""))) { + return true; + } + } + return false; + } + + /** + * 是否有权限访问该城市 + * + * @param cityName + * @param apiUser + * @return + */ + private boolean isAuthCity(String cityName, ApiUser apiUser) { + // 若访问当前接口不需要城市参数,则返回true + if (StringUtils.isBlank(cityName)) { + return true; + } + if (!RegionData.isCity(cityName)) { + String city = RegionData.formatCity(cityName); + if (null != city) { + cityName = city; + } + } + // 若当前接口需要城市,检查是否有访问当前城市的权限 + boolean authCity = StringUtils.isNotBlank(apiUser.getCity()) && !StringUtils.equalsIgnoreCase(apiUser.getCity(), "all"); + if (authCity) { + ServerArea city = ServerAreaData.getServerAreaByDisplayDefaultNull(cityName); + if (null != city) { + return apiUser.getCity().contains(city.getSpell()); + } + } + return true; + } + + private ApiUser parseApiUserByToken(Token token) { + + if (token == null) { + return null; + } + ApiUser apiUser = apiUserService.findApiUserById(token.getUserId()); + if (apiUser == null) { + return null; + } + if (!apiUser.getAppKey().equals(token.getAppKey())) { + return null; + } + return apiUser; + } - public void setApiUserService(ApiUserService apiUserService) { - this.apiUserService = apiUserService; - } + /** + * 新版token验证 + * + * @param token + * @return + */ + private ApiUser checkNewAuthorized(String token) { - public void setApiUserAuthorityService(ApiUserAuthorityService apiUserAuthorityService) { - this.apiUserAuthorityService = apiUserAuthorityService; - } + Map tokenMap = FangjiaApiUtil.parseToken(token); + if (tokenMap == null) { + return null; + } + // token验证后,拿取出的字段再去数据库验证一遍 + if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { + ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); + if (apiUser != null) { + if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { + return apiUser; + } + } + } + return null; + } - public void setApiVisitCountService(ApiVisitCountService apiVisitCountService) { - this.apiVisitCountService = apiVisitCountService; - } + public void setApiUserService(ApiUserService apiUserService) { + this.apiUserService = apiUserService; + } + + public void setApiUserAuthorityService(ApiUserAuthorityService apiUserAuthorityService) { + this.apiUserAuthorityService = apiUserAuthorityService; + } + + public void setApiVisitCountService(ApiVisitCountService apiVisitCountService) { + this.apiVisitCountService = apiVisitCountService; + } + + public void setKafkaProducerUtils(KafkaProducerUtils kafkaProducerUtils) { + this.kafkaProducerUtils = kafkaProducerUtils; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/kafka/KafkaProducerUtils.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/kafka/KafkaProducerUtils.java index 6056a3003..b5a00d80f 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/util/kafka/KafkaProducerUtils.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/kafka/KafkaProducerUtils.java @@ -2,6 +2,7 @@ package com.fangjia.service.util.kafka; import com.alibaba.fastjson.JSONObject; import com.fangjia.dal.mongo.tool.model.OpenUriLog; +import org.apache.commons.lang3.StringUtils; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; @@ -39,6 +40,12 @@ public class KafkaProducerUtils implements DisposableBean { ex.printStackTrace(); } } + public void send(String topic,String msg){ + if (StringUtils.isNotBlank(topic) && StringUtils.isNotBlank(msg)){ + ProducerRecord record = new ProducerRecord(topic, msg); + this.producer.send(record); + } + } @Override public void destroy() throws Exception { From 167deaad7ebbcf1cdad9b51259cbdad408ee5fe5 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Sep 2024 16:02:00 +0800 Subject: [PATCH 046/230] =?UTF-8?q?=E8=B4=A2=E5=8A=9B=E8=AF=84=E7=BA=A7?= =?UTF-8?q?=E5=8A=A0=E5=8F=82=E6=95=B0=EF=BC=9Aid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/open/controllers/AddressController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java index a484fd8cf..bbceb44ab 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddressController.java @@ -2246,8 +2246,8 @@ public class AddressController { public Object financialRatingAction(CommunitySummaryRequestDto model) { RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getAddress()) || "null".equals(model.getAddress())) { - mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); + if ((StringUtils.isBlank(model.getAddress()) || "null".equals(model.getAddress())) && StringUtils.isBlank(model.getId())) { + mav.setModel(BasicModel.buildBadRequestModel("地址和id不能同时为空")); return mav; } @@ -2259,11 +2259,13 @@ public class AddressController { JSONObject reqBody = new JSONObject(); reqBody.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity()); - reqBody.put("address", model.getAddress()); + reqBody.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : ""); + reqBody.put("seaweedId", StringUtils.isNotBlank(model.getId()) ? model.getId() : ""); reqBody.put("area", model.getArea()); reqBody.put("maxFloor", model.getMaxFloor()); reqBody.put("housePurpose", model.getHousePurpose()); reqBody.put("memo", model.getMemo()); + reqBody.put("showOther", false); String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/financialRating", reqBody, headers, "UTF-8"); if (result != null) { try { From a68c4ef9c4fac08818472964882191f0db46dd02 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 26 Sep 2024 17:05:18 +0800 Subject: [PATCH 047/230] =?UTF-8?q?=E5=9F=8E=E5=B8=82=E3=80=81=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E3=80=81=E5=B0=8F=E5=8C=BA=E4=BB=B7=E6=A0=BC=E6=8C=87?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/dao/PropertyStatsIndexDao.java | 9 ++++ .../mongo/dao/PropertyStatsIndexDaoImpl.java | 10 ++++ .../fangjia/open/model/StatsIndexModel.java | 32 ++++++++++-- .../fangjia/PropertyStatsIndexService.java | 12 +++++ .../PropertyStatsIndexServiceImpl.java | 52 +++++++++++++++++++ .../mongo/fangjia/StatsIndexService.java | 6 ++- .../mongo/fangjia/StatsIndexServiceImpl.java | 33 ++++++++++-- 7 files changed, 145 insertions(+), 9 deletions(-) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDao.java create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDaoImpl.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java create mode 100644 projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDao.java new file mode 100644 index 000000000..c52e73f1e --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDao.java @@ -0,0 +1,9 @@ +package com.fangjia.dal.mongo.dao; + +import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.PropertyStatsIndex; +import com.fangjia.dal.mongo.model.StatsIndex; + +public interface PropertyStatsIndexDao extends MongoDao { + +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDaoImpl.java new file mode 100644 index 000000000..6c8e5f7b8 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/PropertyStatsIndexDaoImpl.java @@ -0,0 +1,10 @@ +package com.fangjia.dal.mongo.dao; + +import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.mongo.model.PropertyStatsIndex; +import com.fangjia.dal.mongo.model.StatsIndex; + + +public class PropertyStatsIndexDaoImpl extends MongoDaoImpl implements PropertyStatsIndexDao { + +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java index ec0d88a5a..3d9a4909c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java @@ -10,7 +10,10 @@ public class StatsIndexModel { private String id; private String city; - + private String district; + private String name; + private String type; + private String yearmonth; private Integer source; @@ -216,7 +219,28 @@ public class StatsIndexModel { public void setIfNew(Integer ifNew) { this.ifNew = ifNew; } - - - + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java new file mode 100644 index 000000000..dfd0645bc --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java @@ -0,0 +1,12 @@ +package com.fangjia.service.mongo.fangjia; + +import com.fangjia.dal.mongo.model.PropertyStatsIndex; +import com.fangjia.dal.mongo.model.StatsIndex; + +import java.util.List; + +public interface PropertyStatsIndexService { + + PropertyStatsIndex findById(String id); + PropertyStatsIndex findStatsIndex(String city, String district, String name, String yearmonth, String cat); +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java new file mode 100644 index 000000000..73bea049a --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java @@ -0,0 +1,52 @@ +package com.fangjia.service.mongo.fangjia; + +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.dao.PropertyStatsIndexDao; +import com.fangjia.dal.mongo.dao.StatsIndexDao; +import com.fangjia.dal.mongo.model.PropertyStatsIndex; +import com.fangjia.dal.mongo.model.StatsIndex; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +public class PropertyStatsIndexServiceImpl implements PropertyStatsIndexService { + private PropertyStatsIndexDao propertyStatsIndexDao; + + @Override + public PropertyStatsIndex findById(String id) { + return propertyStatsIndexDao.findById(id); + } + + @Override + public PropertyStatsIndex findStatsIndex(String city, String district, String name, String yearmonth, String cat) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + if (StringUtils.isNotBlank(district)) { + params.add(new QueryParam("district", district)); + } + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + if (StringUtils.isNotBlank(yearmonth)) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + if (("商铺").equals(cat)) { + params.add(new QueryParam("cat", "shop")); + } else if (("写字楼").equals(cat)) { + params.add(new QueryParam("cat", "office")); + } else { + params.add(new QueryParam("cat", "district")); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("yearmonth", false)); + return propertyStatsIndexDao.findFirstByParams(params, sortParams); + } + + public void setPropertyStatsIndexDao(PropertyStatsIndexDao propertyStatsIndexDao) { + this.propertyStatsIndexDao = propertyStatsIndexDao; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java index 2e048b298..16da71c9e 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java @@ -11,13 +11,15 @@ public interface StatsIndexService { StatsIndex findByName(String city, String yearmonth); List findAllStats(String city, String yearmonth, boolean order,String cat); - +// List findAllStats(String city, String district,String type, String yearmonth, boolean order,String cat); + int findAllStatsCount(String city, String name,String cat); void deleteById(String id); StatsIndex findLatestStstsIndex(String city, String yearmonth,String cat); - + StatsIndex findStatsIndex(String city,String district,String type,String name, String yearmonth,String cat); + public List findAllStatsNocat(String yearmonth,String cat,String source) ; Integer findEarliestMonth(String city, String cat, String source); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java index 7cb8ee88a..2530942c6 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java @@ -42,8 +42,7 @@ public class StatsIndexServiceImpl implements StatsIndexService { } @Override - public List findAllStats(String city, String yearmonth, - boolean order, String cat) { + public List findAllStats(String city, String yearmonth, boolean order, String cat) { List params = new ArrayList(); if (StringUtils.isNotBlank(city)) { params.add(new QueryParam("city", city)); @@ -124,7 +123,35 @@ public class StatsIndexServiceImpl implements StatsIndexService { return statsIndexDao.findFirstByParams(params, sortParams); } - + @Override + public StatsIndex findStatsIndex(String city, String district, String type, String name, String yearmonth, String cat) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + if (StringUtils.isNotBlank(district)) { + params.add(new QueryParam("district", district)); + } + if (StringUtils.isNotBlank(type)) { + params.add(new QueryParam("type", type)); + } + if (StringUtils.isNotBlank(name)) { + params.add(new QueryParam("name", name)); + } + if (StringUtils.isNotBlank(yearmonth)) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + if (("商铺").equals(cat)) { + params.add(new QueryParam("cat", "shop")); + } else if (("写字楼").equals(cat)) { + params.add(new QueryParam("cat", "office")); + } else { + params.add(new QueryParam("cat", "district")); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("yearmonth", false)); + return statsIndexDao.findFirstByParams(params, sortParams); + } @Override From ccb6c9ee9aefcdbc1e47414769f157ea6aba8360 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 26 Sep 2024 17:05:25 +0800 Subject: [PATCH 048/230] =?UTF-8?q?=E5=9F=8E=E5=B8=82=E3=80=81=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E3=80=81=E5=B0=8F=E5=8C=BA=E4=BB=B7=E6=A0=BC=E6=8C=87?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/model/PropertyStatsIndex.java | 282 ++++++ .../fangjia/dal/mongo/model/StatsIndex.java | 95 +- .../controllers/StatsIndexController.java | 819 ++++++++++-------- 3 files changed, 789 insertions(+), 407 deletions(-) create mode 100644 projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java new file mode 100644 index 000000000..71076ab65 --- /dev/null +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java @@ -0,0 +1,282 @@ +package com.fangjia.dal.mongo.model; + +import com.fangjia.dal.MongoEntity; + +import javax.persistence.*; +import java.util.Date; + +/** + * 价格指数 + */ +@Entity +@Table(name = "fangjia_stat.property_stats_index") +public class PropertyStatsIndex implements MongoEntity{ + /** + * + */ + private static final long serialVersionUID = -9102764355476337768L; + + private String id; + + private String city; + + private String district; + + private String name; + + private String yearmonth; + + private Integer source; + + private String remark; + + private Double chain; + + private Double yeartoyear; + + private Double fixedbase; + + private Double belowChain; + + private Double belowYeartoyear; + + private Double belowFixedbase; + + private Double amongChain; + + private Double amongYeartoyear; + + private Double amongFixedbase; + + private Double aboveChain; + + private Double aboveYeartoyear; + + private Double aboveFixedbase; + + private Date cDate; + + private String cat; + + private Double fangIndex; + + private Double fangChain; + + private String type; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "_id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "city") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + @Column(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "c_date") + public Date getcDate() { + return cDate; + } + + public void setcDate(Date cDate) { + this.cDate = cDate; + } + + @Column(name = "yearmonth") + public String getYearmonth() { + return yearmonth; + } + + public void setYearmonth(String yearmonth) { + this.yearmonth = yearmonth; + } + + @Column(name = "source") + public Integer getSource() { + return source; + } + + public void setSource(Integer source) { + this.source = source; + } + + @Column(name = "remark") + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + @Column(name = "below_chain") + public Double getBelowChain() { + return belowChain; + } + + public void setBelowChain(Double belowChain) { + this.belowChain = belowChain; + } + + @Column(name = "below_yeartoyear") + public Double getBelowYeartoyear() { + return belowYeartoyear; + } + + public void setBelowYeartoyear(Double belowYeartoyear) { + this.belowYeartoyear = belowYeartoyear; + } + + @Column(name = "below_fixedbase") + public Double getBelowFixedbase() { + return belowFixedbase; + } + + public void setBelowFixedbase(Double belowFixedbase) { + this.belowFixedbase = belowFixedbase; + } + + @Column(name = "among_chain") + public Double getAmongChain() { + return amongChain; + } + + public void setAmongChain(Double amongChain) { + this.amongChain = amongChain; + } + + @Column(name = "among_yeartoyear") + public Double getAmongYeartoyear() { + return amongYeartoyear; + } + + public void setAmongYeartoyear(Double amongYeartoyear) { + this.amongYeartoyear = amongYeartoyear; + } + + @Column(name = "among_fixedbase") + public Double getAmongFixedbase() { + return amongFixedbase; + } + + public void setAmongFixedbase(Double amongFixedbase) { + this.amongFixedbase = amongFixedbase; + } + + @Column(name = "above_chain") + public Double getAboveChain() { + return aboveChain; + } + + public void setAboveChain(Double aboveChain) { + this.aboveChain = aboveChain; + } + + @Column(name = "above_yeartoyear") + public Double getAboveYeartoyear() { + return aboveYeartoyear; + } + + public void setAboveYeartoyear(Double aboveYeartoyear) { + this.aboveYeartoyear = aboveYeartoyear; + } + + @Column(name = "above_fixedbase") + public Double getAboveFixedbase() { + return aboveFixedbase; + } + + public void setAboveFixedbase(Double aboveFixedbase) { + this.aboveFixedbase = aboveFixedbase; + } + + @Column(name = "cat") + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } + + @Column(name = "fang_index") + public Double getFangIndex() { + return fangIndex; + } + + public void setFangIndex(Double fangIndex) { + this.fangIndex = fangIndex; + } + + @Column(name = "fang_chain") + public Double getFangChain() { + return fangChain; + } + + public void setFangChain(Double fangChain) { + this.fangChain = fangChain; + } + + @Column(name = "chain") + public Double getChain() { + return chain; + } + + public void setChain(Double chain) { + this.chain = chain; + } + + @Column(name = "yeartoyear") + public Double getYeartoyear() { + return yeartoyear; + } + + public void setYeartoyear(Double yeartoyear) { + this.yeartoyear = yeartoyear; + } + + @Column(name = "fixedbase") + public Double getFixedbase() { + return fixedbase; + } + + public void setFixedbase(Double fixedbase) { + this.fixedbase = fixedbase; + } + + @Column(name = "type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java index c0565b537..066c5f424 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java @@ -14,7 +14,7 @@ import com.fangjia.dal.MongoEntity; * 价格指数 */ @Entity -@Table(name = "fangjia.stats_index") +@Table(name = "fangjia_stat.stats_index") public class StatsIndex implements MongoEntity{ /** * @@ -24,6 +24,8 @@ public class StatsIndex implements MongoEntity{ private String id; private String city; + + private String district; private String yearmonth; @@ -31,12 +33,15 @@ public class StatsIndex implements MongoEntity{ private String remark; - private Double newChain; - - private Double newYeartoyear; - - private Double newFixedbase; - +// private Double newChain; + private Double chain; + +// private Double newYeartoyear; + private Double yeartoyear; + +// private Double newFixedbase; + private Double fixedbase; + private Double belowChain; private Double belowYeartoyear; @@ -62,6 +67,8 @@ public class StatsIndex implements MongoEntity{ private Double fangIndex; private Double fangChain; + + private String type; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "_id") @@ -82,6 +89,14 @@ public class StatsIndex implements MongoEntity{ this.city = city; } + @Column(name = "district") + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } @Column(name = "c_date") public Date getcDate() { @@ -118,34 +133,6 @@ public class StatsIndex implements MongoEntity{ public void setRemark(String remark) { this.remark = remark; } - - @Column(name = "new_chain") - public Double getNewChain() { - return newChain; - } - - public void setNewChain(Double newChain) { - this.newChain = newChain; - } - - @Column(name = "new_yeartoyear") - public Double getNewYeartoyear() { - return newYeartoyear; - } - - public void setNewYeartoyear(Double newYeartoyear) { - this.newYeartoyear = newYeartoyear; - } - - @Column(name = "new_fixedbase") - public Double getNewFixedbase() { - return newFixedbase; - } - - public void setNewFixedbase(Double newFixedbase) { - this.newFixedbase = newFixedbase; - } - @Column(name = "below_chain") public Double getBelowChain() { return belowChain; @@ -253,6 +240,40 @@ public class StatsIndex implements MongoEntity{ public void setFangChain(Double fangChain) { this.fangChain = fangChain; } - - + + @Column(name = "chain") + public Double getChain() { + return chain; + } + + public void setChain(Double chain) { + this.chain = chain; + } + + @Column(name = "yeartoyear") + public Double getYeartoyear() { + return yeartoyear; + } + + public void setYeartoyear(Double yeartoyear) { + this.yeartoyear = yeartoyear; + } + + @Column(name = "fixedbase") + public Double getFixedbase() { + return fixedbase; + } + + public void setFixedbase(Double fixedbase) { + this.fixedbase = fixedbase; + } + + @Column(name = "type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java index 68d977495..4f6fd841f 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java @@ -5,7 +5,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap; +import com.fangjia.dal.mongo.model.PropertyStatsIndex; +import com.fangjia.dal.seaweed.model.District; import com.fangjia.open.model.BasicModel; +import com.fangjia.service.datastore.DistrictService; +import com.fangjia.service.mongo.fangjia.PropertyStatsIndexService; +import com.fangjia.service.open.FangjiaOfficialAreaService; import org.apache.commons.lang.StringUtils; import com.fangjia.core.util.DistrictCodeUtils; @@ -22,380 +28,453 @@ import com.fangjia.service.bo.IndexBo; import com.fangjia.service.bo.LandPriceIndexBo; import com.fangjia.service.mongo.fangjia.LandPriceIndexService; import com.fangjia.service.mongo.fangjia.StatsIndexService; +import org.sothis.core.util.CollectionUtils; public class StatsIndexController { - private StatsIndexService statsIndexService; - private LandPriceIndexService landPriceIndexService; + private StatsIndexService statsIndexService; + private LandPriceIndexService landPriceIndexService; - /** - *查询 - * param y:city : ,yearmonth: yyyyMM cat:商铺,写字楼,住宅 - */ - @Authority(role = Role.USER) - public Object searchAction(StatsIndexModel model) throws Exception { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if(StringUtils.isBlank(model.getCity())){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "请输入城市编码")); - return mav; - } - String cityName = DistrictCodeUtils.getCityName(model.getCity()); - if(cityName == null){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); - return mav; - } - if (StringUtils.isBlank(model.getYearmonth())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "请输入要查询的年月")); - return mav; - } - Map resMap = new HashMap(); - List statsIndexs=statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), true,model.getCat()); - List statsIndexList=new ArrayList(); - if("商铺".equalsIgnoreCase(model.getCat()) || "写字楼".equalsIgnoreCase(model.getCat())){ - for(StatsIndex statsIndex:statsIndexs){ - StatsIndex newStatsIndex=new StatsIndex(); - newStatsIndex.setFangChain(statsIndex.getFangChain()); - newStatsIndex.setFangIndex(statsIndex.getFangIndex()); - newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); - if(StringUtils.isNotBlank(newStatsIndex.getCity())){ - statsIndexList.add(newStatsIndex); - } - } - }else{ - for(StatsIndex statsIndex:statsIndexs){ - StatsIndex newStatsIndex=new StatsIndex(); - newStatsIndex.setNewChain(statsIndex.getNewChain()); - newStatsIndex.setNewYeartoyear(statsIndex.getNewYeartoyear()); - newStatsIndex.setNewFixedbase(statsIndex.getNewFixedbase()); - - newStatsIndex.setBelowChain(statsIndex.getBelowChain()); - newStatsIndex.setBelowYeartoyear(statsIndex.getBelowYeartoyear()); - newStatsIndex.setBelowFixedbase(statsIndex.getBelowFixedbase()); - - newStatsIndex.setAmongChain(statsIndex.getAmongChain()); - newStatsIndex.setAmongYeartoyear(statsIndex.getAmongYeartoyear()); - newStatsIndex.setAmongFixedbase(statsIndex.getAmongFixedbase()); - - newStatsIndex.setAboveChain(statsIndex.getAboveChain()); - newStatsIndex.setAboveYeartoyear(statsIndex.getAboveYeartoyear()); - newStatsIndex.setAboveFixedbase(statsIndex.getAboveFixedbase()); - - newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(String.valueOf(statsIndex.getSource())); - if(StringUtils.isNotBlank(newStatsIndex.getCity())){ - statsIndexList.add(newStatsIndex); - } - } - } - if(statsIndexList.isEmpty()){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "请检查输入的城市或者年月")); - return mav; - } - resMap.put("results",statsIndexList.get(0)); - if(statsIndexList.size()>0){ - resMap.put("count", statsIndexList.size()); - if("商铺".equals(model.getCat())){ - resMap.put("type", "商铺"); - }else if("写字楼".equals(model.getCat())){ - resMap.put("type", "写字楼"); - }else{ - resMap.put("type", "住宅"); - } - } - mav.setModel(resMap); - return mav; - } + private FangjiaOfficialAreaService fangjiaOfficialAreaService; + private DistrictService districtService; - /** - *查询新房指数 - * param yearmonth: yyyyMM - */ - @Authority(role = Role.USER) - public Object searchNewDistrictIndexAction(StatsIndexModel model) throws Exception { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if(StringUtils.isNotBlank(model.getCity())){ - String cityName = DistrictCodeUtils.getCityName(model.getCity()); - if(cityName == null){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); - return mav; - } - model.setCity(cityName); - } - if(StringUtils.isBlank(model.getYearmonth())){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); - return mav; - } - List statsIndexs = statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), false, "住宅"); - List statsIndexList = new ArrayList(); - - if(statsIndexs != null && statsIndexs.size() > 0){ - for(StatsIndex statsIndex : statsIndexs){ - IndexBo newStatsIndex = new IndexBo(); - newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); - newStatsIndex.setMOM(statsIndex.getNewChain()); - newStatsIndex.setYOY(statsIndex.getNewYeartoyear()); - newStatsIndex.setFixedBase(statsIndex.getNewFixedbase()); - newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); - if(StringUtils.isNotBlank(newStatsIndex.getCity())){ - statsIndexList.add(newStatsIndex); - } - } - } - - if(statsIndexList.isEmpty()){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); - return mav; - } - - Map resMap = new HashMap(); - resMap.put("results",statsIndexList); - resMap.put("count", statsIndexList.size()); - resMap.put("type", "新建商品房"); - mav.setModel(resMap); - return mav; - } - - /** - *查询二手房指数 - * param yearmonth: yyyyMM - */ - @Authority(role = Role.USER) - public Object searchDistrictIndexAction(StatsIndexModel model) throws Exception { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if(StringUtils.isNotBlank(model.getCity())){ - String cityName = DistrictCodeUtils.getCityName(model.getCity()); - if(cityName == null){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); - return mav; - } - model.setCity(cityName); - } - if(StringUtils.isBlank(model.getYearmonth())){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); - return mav; - } - List statsIndexs = statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), false, "住宅"); - List statsIndexList = new ArrayList(); - - if(statsIndexs != null && statsIndexs.size() > 0){ - for(StatsIndex statsIndex:statsIndexs){ - IndexBo newStatsIndex = new IndexBo(); - newStatsIndex.setSmallMOM(statsIndex.getBelowChain()); - newStatsIndex.setSmallYOY(statsIndex.getBelowYeartoyear()); - newStatsIndex.setSmallFixedBase(statsIndex.getBelowFixedbase()); - - newStatsIndex.setMediumMOM(statsIndex.getAmongChain()); - newStatsIndex.setMediumYOY(statsIndex.getAmongYeartoyear()); - newStatsIndex.setMediumFixedBase(statsIndex.getAmongFixedbase()); - - newStatsIndex.setLargeMOM(statsIndex.getAboveChain()); - newStatsIndex.setLargeYOY(statsIndex.getAboveYeartoyear()); - newStatsIndex.setLargeFixedBase(statsIndex.getAboveFixedbase()); - - newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); - newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); - if(StringUtils.isNotBlank(newStatsIndex.getCity())){ - statsIndexList.add(newStatsIndex); - }else{ - System.out.println(statsIndex.getCity()); - } - } - } - - if(statsIndexList.isEmpty()){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); - return mav; - } - - Map resMap = new HashMap(); - resMap.put("results",statsIndexList); - resMap.put("count", statsIndexList.size()); - resMap.put("type", "二手住宅"); - mav.setModel(resMap); - return mav; - } - - /** - *查询商铺指数 - * param yearmonth: yyyyMM - */ - @Authority(role = Role.USER) - public Object searchShopIndexAction(StatsIndexModel model) throws Exception { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if(StringUtils.isNotBlank(model.getCity())){ - String cityName = DistrictCodeUtils.getCityName(model.getCity()); - if(cityName == null){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); - return mav; - } - model.setCity(cityName); - } - if(StringUtils.isBlank(model.getYearmonth())){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); - return mav; - } - List statsIndexs = statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), true, "商铺"); - List statsIndexList = new ArrayList(); - - if(statsIndexs != null && statsIndexs.size() > 0){ - for(StatsIndex statsIndex:statsIndexs){ - IndexBo newStatsIndex = new IndexBo(); - newStatsIndex.setMOM(statsIndex.getFangChain()); - newStatsIndex.setIndex(statsIndex.getFangIndex()); - newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); - newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); - if(StringUtils.isNotBlank(newStatsIndex.getCity())){ - statsIndexList.add(newStatsIndex); - } - } - } - - if(statsIndexList.isEmpty()){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); - return mav; - } - - Map resMap = new HashMap(); - resMap.put("results",statsIndexList); - resMap.put("count", statsIndexList.size()); - resMap.put("type", "商铺"); - mav.setModel(resMap); - return mav; - } - - /** - *查询写字楼指数 - * yearmonth: yyyyMM - */ - @Authority(role = Role.USER) - public Object searchOfficeIndexAction(StatsIndexModel model) throws Exception { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if(StringUtils.isNotBlank(model.getCity())){ - String cityName = DistrictCodeUtils.getCityName(model.getCity()); - if(cityName == null){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); - return mav; - } - model.setCity(cityName); - } - if(StringUtils.isBlank(model.getYearmonth())){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); - return mav; - } - - List statsIndexs=statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), true, "写字楼"); - List statsIndexList = new ArrayList(); - - if(statsIndexs != null && statsIndexs.size() > 0){ - for(StatsIndex statsIndex:statsIndexs){ - IndexBo newStatsIndex = new IndexBo(); - newStatsIndex.setMOM(statsIndex.getFangChain()); - newStatsIndex.setIndex(statsIndex.getFangIndex()); - newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); - newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); - if(StringUtils.isNotBlank(newStatsIndex.getCity())){ - statsIndexList.add(newStatsIndex); - } - } - } - - if(statsIndexList.isEmpty()){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); - return mav; - } - - Map resMap = new HashMap(); - resMap.put("results",statsIndexList); - resMap.put("count", statsIndexList.size()); - resMap.put("type", "写字楼"); - mav.setModel(resMap); - return mav; - } - - /** - *查询 - * param city:城市 , year:年份 - */ - @Authority(role = Role.USER) - public Object searchLandIndexAction(LandPriceIndexModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if(StringUtils.isNotBlank(model.getCity())) { - String cityName = DistrictCodeUtils.getCityName(model.getCity()); - if(cityName == null){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); - return mav; - } - model.setCity(cityName); - } - if(model.getYear() <= 0){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年份必须输入,格式:yyyy")); - return mav; - } - List landPriceIndexList = new ArrayList(); - if(StringUtils.isNotBlank(model.getCity())) { - landPriceIndexList = landPriceIndexService.findByCityAndYear(model.getCity(), model.getYear()); - } else { - landPriceIndexList = landPriceIndexService.findAllByYear(model.getYear()); - } - List landPriceIndexBoList = new ArrayList(); - - if(landPriceIndexList != null && landPriceIndexList.size() > 0){ - for(LandPriceIndex landPriceIndex:landPriceIndexList){ - LandPriceIndexBo landPriceIndexBo = new LandPriceIndexBo(); - - landPriceIndexBo.setCity(DistrictCodeUtils.getCityCode(landPriceIndex.getCity())); - landPriceIndexBo.setYear(landPriceIndex.getYear()); - landPriceIndexBo.setCompositeIndex(landPriceIndex.getComprehensiveIndex()); - landPriceIndexBo.setCommercialIndex(landPriceIndex.getCommercialIndex()); - landPriceIndexBo.setResidentialIndex(landPriceIndex.getDistrictIndex()); - landPriceIndexBo.setIndustrialIndex(landPriceIndex.getIndustryIndex()); - - if(StringUtils.isNotBlank(landPriceIndexBo.getCity())){ - landPriceIndexBoList.add(landPriceIndexBo); - } - } - } - - if(landPriceIndexBoList.isEmpty()){ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); - return mav; - } - - Map resMap = new HashMap(); - resMap.put("results",landPriceIndexBoList); - resMap.put("count", landPriceIndexBoList.size()); - resMap.put("type", "土地"); - mav.setModel(resMap); - return mav; - } - - private String getSourceString(int source){ - if(source == 1){ - return "统计局"; - }else if(source == 2){ - return "房价网"; - }else if(source == 3){ - return "手工输入"; - } - return ""; - } - - public void setStatsIndexService(StatsIndexService statsIndexService) { - this.statsIndexService = statsIndexService; - } + private PropertyStatsIndexService propertyStatsIndexService; - public void setLandPriceIndexService(LandPriceIndexService landPriceIndexService) { - this.landPriceIndexService = landPriceIndexService; - } + /** + * 查询城市级别价格指数 + * param y:city : ,yearmonth: yyyyMM cat:商铺,写字楼,住宅 + */ + @Authority(role = Role.USER) + public Object cityAction(StatsIndexModel model) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(BasicModel.buildBadRequestModel("请输入城市编码")); + return mav; + } + if (StringUtils.isBlank(model.getYearmonth())) { + mav.setModel(BasicModel.buildBadRequestModel("请输入要查询的年月")); + return mav; + } + String cityName = DistrictCodeUtils.getCityName(model.getCity()); + if (cityName == null) { + mav.setModel(BasicModel.buildBadRequestModel("无法匹配到该城市编码")); + return mav; + } + Map resMap = new HashMap(); + StatsIndex statsIndex = statsIndexService.findStatsIndex(cityName, "", "城市", "", model.getYearmonth(), model.getCat()); + if (statsIndex != null) { + StatsIndex newStatsIndex = new StatsIndex(); + newStatsIndex.setChain(statsIndex.getChain()); + newStatsIndex.setYeartoyear(statsIndex.getYeartoyear()); + newStatsIndex.setFixedbase(statsIndex.getFixedbase()); + newStatsIndex.setBelowChain(statsIndex.getBelowChain()); + newStatsIndex.setBelowYeartoyear(statsIndex.getBelowYeartoyear()); + newStatsIndex.setBelowFixedbase(statsIndex.getBelowFixedbase()); + + newStatsIndex.setAmongChain(statsIndex.getAmongChain()); + newStatsIndex.setAmongYeartoyear(statsIndex.getAmongYeartoyear()); + newStatsIndex.setAmongFixedbase(statsIndex.getAmongFixedbase()); + + newStatsIndex.setAboveChain(statsIndex.getAboveChain()); + newStatsIndex.setAboveYeartoyear(statsIndex.getAboveYeartoyear()); + newStatsIndex.setAboveFixedbase(statsIndex.getAboveFixedbase()); + + newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); + newStatsIndex.setYearmonth(model.getYearmonth()); + resMap.put("results", newStatsIndex); + } + resMap.put("status", "200"); + resMap.put("msg", "ok"); + mav.setModel(resMap); + return mav; + } + + /** + * 查询区域级别价格指数 + * + * @param model + * @return + * @throws Exception + */ + + @Authority(role = Role.USER) + public Object districtAction(StatsIndexModel model) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getDistrict())) { + mav.setModel(BasicModel.buildBadRequestModel("请输入区域编码")); + return mav; + } + if (StringUtils.isBlank(model.getYearmonth())) { + mav.setModel(BasicModel.buildBadRequestModel("请输入要查询的年月")); + return mav; + } + FangjiaOfficialAreaMap fangjiaOfficialAreaMap = fangjiaOfficialAreaService.convertOfficialCodeToFangjia(model.getDistrict()); + if (fangjiaOfficialAreaMap == null) { + mav.setModel(BasicModel.buildBadRequestModel("无法匹配到该区域编码")); + return mav; + } + Map resMap = new HashMap(); + StatsIndex statsIndex = statsIndexService.findStatsIndex(fangjiaOfficialAreaMap.getFangjiaCity(), fangjiaOfficialAreaMap.getFangjiaDistrict(), "区域", "", model.getYearmonth(), model.getCat()); + if (statsIndex != null) { + StatsIndex newStatsIndex = new StatsIndex(); + newStatsIndex.setChain(statsIndex.getChain()); + newStatsIndex.setYeartoyear(statsIndex.getYeartoyear()); + newStatsIndex.setFixedbase(statsIndex.getFixedbase()); + newStatsIndex.setDistrict(model.getDistrict()); + newStatsIndex.setYearmonth(model.getYearmonth()); + resMap.put("results", newStatsIndex); + } + resMap.put("status", "200"); + resMap.put("msg", "ok"); + mav.setModel(resMap); + return mav; + } + + /** + * 小区价格指数 + * + * @param model + * @return + * @throws Exception + */ + @Authority(role = Role.USER) + public Object propertyAction(StatsIndexModel model) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId())) { + mav.setModel(BasicModel.buildBadRequestModel("请输入小区id")); + return mav; + } + if (StringUtils.isBlank(model.getYearmonth())) { + mav.setModel(BasicModel.buildBadRequestModel("请输入要查询的年月")); + return mav; + } + District district = districtService.findById(model.getId()); + if (district == null) { + mav.setModel(BasicModel.buildBadRequestModel("无法匹配到小区")); + return mav; + } + Map resMap = new HashMap(); + PropertyStatsIndex statsIndex = propertyStatsIndexService.findStatsIndex(district.getCity(), district.getRegion(), district.getName(), model.getYearmonth(), model.getCat()); + if (statsIndex != null) { + PropertyStatsIndex newStatsIndex = new PropertyStatsIndex(); + newStatsIndex.setChain(statsIndex.getChain()); + newStatsIndex.setYeartoyear(statsIndex.getYeartoyear()); + newStatsIndex.setFixedbase(statsIndex.getFixedbase()); + newStatsIndex.setDistrict(model.getDistrict()); + newStatsIndex.setYearmonth(model.getYearmonth()); + newStatsIndex.setId(model.getId()); + resMap.put("results", newStatsIndex); + } + + resMap.put("status", "200"); + resMap.put("msg", "ok"); + mav.setModel(resMap); + return mav; + } + + /** + * 查询新房指数 + * param yearmonth: yyyyMM + */ + @Authority(role = Role.USER) + public Object searchNewDistrictIndexAction(StatsIndexModel model) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isNotBlank(model.getCity())) { + String cityName = DistrictCodeUtils.getCityName(model.getCity()); + if (cityName == null) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); + return mav; + } + model.setCity(cityName); + } + if (StringUtils.isBlank(model.getYearmonth())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); + return mav; + } + List statsIndexs = statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), false, "住宅"); + List statsIndexList = new ArrayList(); + + if (statsIndexs != null && statsIndexs.size() > 0) { + for (StatsIndex statsIndex : statsIndexs) { + IndexBo newStatsIndex = new IndexBo(); + newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); + newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setMOM(statsIndex.getChain()); + newStatsIndex.setYOY(statsIndex.getYeartoyear()); + newStatsIndex.setFixedBase(statsIndex.getFixedbase()); + newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); + if (StringUtils.isNotBlank(newStatsIndex.getCity())) { + statsIndexList.add(newStatsIndex); + } + } + } + + if (statsIndexList.isEmpty()) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); + return mav; + } + + Map resMap = new HashMap(); + resMap.put("results", statsIndexList); + resMap.put("count", statsIndexList.size()); + resMap.put("type", "新建商品房"); + mav.setModel(resMap); + return mav; + } + + /** + * 查询二手房指数 + * param yearmonth: yyyyMM + */ + @Authority(role = Role.USER) + public Object searchDistrictIndexAction(StatsIndexModel model) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isNotBlank(model.getCity())) { + String cityName = DistrictCodeUtils.getCityName(model.getCity()); + if (cityName == null) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); + return mav; + } + model.setCity(cityName); + } + if (StringUtils.isBlank(model.getYearmonth())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); + return mav; + } + List statsIndexs = statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), false, "住宅"); + List statsIndexList = new ArrayList(); + + if (statsIndexs != null && statsIndexs.size() > 0) { + for (StatsIndex statsIndex : statsIndexs) { + IndexBo newStatsIndex = new IndexBo(); + newStatsIndex.setSmallMOM(statsIndex.getBelowChain()); + newStatsIndex.setSmallYOY(statsIndex.getBelowYeartoyear()); + newStatsIndex.setSmallFixedBase(statsIndex.getBelowFixedbase()); + + newStatsIndex.setMediumMOM(statsIndex.getAmongChain()); + newStatsIndex.setMediumYOY(statsIndex.getAmongYeartoyear()); + newStatsIndex.setMediumFixedBase(statsIndex.getAmongFixedbase()); + + newStatsIndex.setLargeMOM(statsIndex.getAboveChain()); + newStatsIndex.setLargeYOY(statsIndex.getAboveYeartoyear()); + newStatsIndex.setLargeFixedBase(statsIndex.getAboveFixedbase()); + + newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); + newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); + if (StringUtils.isNotBlank(newStatsIndex.getCity())) { + statsIndexList.add(newStatsIndex); + } else { + System.out.println(statsIndex.getCity()); + } + } + } + + if (statsIndexList.isEmpty()) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); + return mav; + } + + Map resMap = new HashMap(); + resMap.put("results", statsIndexList); + resMap.put("count", statsIndexList.size()); + resMap.put("type", "二手住宅"); + mav.setModel(resMap); + return mav; + } + + /** + * 查询商铺指数 + * param yearmonth: yyyyMM + */ + @Authority(role = Role.USER) + public Object searchShopIndexAction(StatsIndexModel model) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isNotBlank(model.getCity())) { + String cityName = DistrictCodeUtils.getCityName(model.getCity()); + if (cityName == null) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); + return mav; + } + model.setCity(cityName); + } + if (StringUtils.isBlank(model.getYearmonth())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); + return mav; + } + List statsIndexs = statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), true, "商铺"); + List statsIndexList = new ArrayList(); + + if (statsIndexs != null && statsIndexs.size() > 0) { + for (StatsIndex statsIndex : statsIndexs) { + IndexBo newStatsIndex = new IndexBo(); + newStatsIndex.setMOM(statsIndex.getFangChain()); + newStatsIndex.setIndex(statsIndex.getFangIndex()); + newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); + newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); + if (StringUtils.isNotBlank(newStatsIndex.getCity())) { + statsIndexList.add(newStatsIndex); + } + } + } + + if (statsIndexList.isEmpty()) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); + return mav; + } + + Map resMap = new HashMap(); + resMap.put("results", statsIndexList); + resMap.put("count", statsIndexList.size()); + resMap.put("type", "商铺"); + mav.setModel(resMap); + return mav; + } + + /** + * 查询写字楼指数 + * yearmonth: yyyyMM + */ + @Authority(role = Role.USER) + public Object searchOfficeIndexAction(StatsIndexModel model) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isNotBlank(model.getCity())) { + String cityName = DistrictCodeUtils.getCityName(model.getCity()); + if (cityName == null) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); + return mav; + } + model.setCity(cityName); + } + if (StringUtils.isBlank(model.getYearmonth())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); + return mav; + } + + List statsIndexs = statsIndexService.findAllStats(model.getCity(), model.getYearmonth(), true, "写字楼"); + List statsIndexList = new ArrayList(); + + if (statsIndexs != null && statsIndexs.size() > 0) { + for (StatsIndex statsIndex : statsIndexs) { + IndexBo newStatsIndex = new IndexBo(); + newStatsIndex.setMOM(statsIndex.getFangChain()); + newStatsIndex.setIndex(statsIndex.getFangIndex()); + newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); + newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); + if (StringUtils.isNotBlank(newStatsIndex.getCity())) { + statsIndexList.add(newStatsIndex); + } + } + } + + if (statsIndexList.isEmpty()) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); + return mav; + } + + Map resMap = new HashMap(); + resMap.put("results", statsIndexList); + resMap.put("count", statsIndexList.size()); + resMap.put("type", "写字楼"); + mav.setModel(resMap); + return mav; + } + + /** + * 查询 + * param city:城市 , year:年份 + */ + @Authority(role = Role.USER) + public Object searchLandIndexAction(LandPriceIndexModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isNotBlank(model.getCity())) { + String cityName = DistrictCodeUtils.getCityName(model.getCity()); + if (cityName == null) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "无法匹配到该城市编码")); + return mav; + } + model.setCity(cityName); + } + if (model.getYear() <= 0) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年份必须输入,格式:yyyy")); + return mav; + } + List landPriceIndexList = new ArrayList(); + if (StringUtils.isNotBlank(model.getCity())) { + landPriceIndexList = landPriceIndexService.findByCityAndYear(model.getCity(), model.getYear()); + } else { + landPriceIndexList = landPriceIndexService.findAllByYear(model.getYear()); + } + List landPriceIndexBoList = new ArrayList(); + + if (landPriceIndexList != null && landPriceIndexList.size() > 0) { + for (LandPriceIndex landPriceIndex : landPriceIndexList) { + LandPriceIndexBo landPriceIndexBo = new LandPriceIndexBo(); + + landPriceIndexBo.setCity(DistrictCodeUtils.getCityCode(landPriceIndex.getCity())); + landPriceIndexBo.setYear(landPriceIndex.getYear()); + landPriceIndexBo.setCompositeIndex(landPriceIndex.getComprehensiveIndex()); + landPriceIndexBo.setCommercialIndex(landPriceIndex.getCommercialIndex()); + landPriceIndexBo.setResidentialIndex(landPriceIndex.getDistrictIndex()); + landPriceIndexBo.setIndustrialIndex(landPriceIndex.getIndustryIndex()); + + if (StringUtils.isNotBlank(landPriceIndexBo.getCity())) { + landPriceIndexBoList.add(landPriceIndexBo); + } + } + } + + if (landPriceIndexBoList.isEmpty()) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "目标数据不存在")); + return mav; + } + + Map resMap = new HashMap(); + resMap.put("results", landPriceIndexBoList); + resMap.put("count", landPriceIndexBoList.size()); + resMap.put("type", "土地"); + mav.setModel(resMap); + return mav; + } + + private String getSourceString(int source) { + if (source == 1) { + return "统计局"; + } else if (source == 2) { + return "房价网"; + } else if (source == 3) { + return "手工输入"; + } + return ""; + } + + public void setStatsIndexService(StatsIndexService statsIndexService) { + this.statsIndexService = statsIndexService; + } + + public void setLandPriceIndexService(LandPriceIndexService landPriceIndexService) { + this.landPriceIndexService = landPriceIndexService; + } + + public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) { + this.fangjiaOfficialAreaService = fangjiaOfficialAreaService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setPropertyStatsIndexService(PropertyStatsIndexService propertyStatsIndexService) { + this.propertyStatsIndexService = propertyStatsIndexService; + } } From 7047b18b0e12f79acfdfd957d78cb328bc1ec37a Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 27 Sep 2024 09:57:29 +0800 Subject: [PATCH 049/230] =?UTF-8?q?=E5=9F=8E=E5=B8=82=E3=80=81=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E3=80=81=E5=B0=8F=E5=8C=BA=E4=BB=B7=E6=A0=BC=E6=8C=87?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/model/PropertyStatsIndex.java | 10 +- .../fangjia/dal/mongo/model/StatsIndex.java | 8 +- .../open/controllers/HouseController.java | 2 +- .../controllers/StatsIndexController.java | 24 +- .../fangjia/open/model/StatsIndexModel.java | 6 +- .../fangjia/PropertyStatsIndexService.java | 2 +- .../PropertyStatsIndexServiceImpl.java | 11 +- .../mongo/fangjia/StatsIndexService.java | 12 +- .../mongo/fangjia/StatsIndexServiceImpl.java | 321 +++++++++--------- 9 files changed, 193 insertions(+), 203 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java index 71076ab65..923e94247 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/PropertyStatsIndex.java @@ -24,7 +24,7 @@ public class PropertyStatsIndex implements MongoEntity{ private String name; - private String yearmonth; + private Integer yearmonth; private Integer source; @@ -109,16 +109,16 @@ public class PropertyStatsIndex implements MongoEntity{ public void setcDate(Date cDate) { this.cDate = cDate; } - + @Column(name = "yearmonth") - public String getYearmonth() { + public Integer getYearmonth() { return yearmonth; } - public void setYearmonth(String yearmonth) { + public void setYearmonth(Integer yearmonth) { this.yearmonth = yearmonth; } - + @Column(name = "source") public Integer getSource() { return source; diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java index 066c5f424..3dd495898 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/StatsIndex.java @@ -27,7 +27,7 @@ public class StatsIndex implements MongoEntity{ private String district; - private String yearmonth; + private Integer yearmonth; private Integer source; @@ -106,13 +106,13 @@ public class StatsIndex implements MongoEntity{ public void setcDate(Date cDate) { this.cDate = cDate; } - + @Column(name = "yearmonth") - public String getYearmonth() { + public Integer getYearmonth() { return yearmonth; } - public void setYearmonth(String yearmonth) { + public void setYearmonth(Integer yearmonth) { this.yearmonth = yearmonth; } 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 f3548c9cc..f0a5f24dd 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 @@ -1170,7 +1170,7 @@ public class HouseController { || statsIndex.getBelowFixedbase() == null) { return null; } - Date endDate = DateUtil.parseDate(statsIndex.getYearmonth(), "yyyyMM"); + Date endDate = DateUtil.parseDate(statsIndex.getYearmonth().toString(), "yyyyMM"); Calendar c = Calendar.getInstance(); c.setTime(endDate); c.add(Calendar.MONTH, -1); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java index 4f6fd841f..5e2514098 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/StatsIndexController.java @@ -51,7 +51,7 @@ public class StatsIndexController { mav.setModel(BasicModel.buildBadRequestModel("请输入城市编码")); return mav; } - if (StringUtils.isBlank(model.getYearmonth())) { + if (null == model.getYearmonth()) { mav.setModel(BasicModel.buildBadRequestModel("请输入要查询的年月")); return mav; } @@ -106,7 +106,7 @@ public class StatsIndexController { mav.setModel(BasicModel.buildBadRequestModel("请输入区域编码")); return mav; } - if (StringUtils.isBlank(model.getYearmonth())) { + if (null == model.getYearmonth()) { mav.setModel(BasicModel.buildBadRequestModel("请输入要查询的年月")); return mav; } @@ -147,7 +147,7 @@ public class StatsIndexController { mav.setModel(BasicModel.buildBadRequestModel("请输入小区id")); return mav; } - if (StringUtils.isBlank(model.getYearmonth())) { + if (null == model.getYearmonth()) { mav.setModel(BasicModel.buildBadRequestModel("请输入要查询的年月")); return mav; } @@ -157,7 +157,7 @@ public class StatsIndexController { return mav; } Map resMap = new HashMap(); - PropertyStatsIndex statsIndex = propertyStatsIndexService.findStatsIndex(district.getCity(), district.getRegion(), district.getName(), model.getYearmonth(), model.getCat()); + PropertyStatsIndex statsIndex = propertyStatsIndexService.findStatsIndex(district.getCity(), district.getRegion(), district.getName(), model.getYearmonth()); if (statsIndex != null) { PropertyStatsIndex newStatsIndex = new PropertyStatsIndex(); newStatsIndex.setChain(statsIndex.getChain()); @@ -191,7 +191,7 @@ public class StatsIndexController { } model.setCity(cityName); } - if (StringUtils.isBlank(model.getYearmonth())) { + if (null == model.getYearmonth()) { mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); return mav; } @@ -202,7 +202,7 @@ public class StatsIndexController { for (StatsIndex statsIndex : statsIndexs) { IndexBo newStatsIndex = new IndexBo(); newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setYearmonth(statsIndex.getYearmonth().toString()); newStatsIndex.setMOM(statsIndex.getChain()); newStatsIndex.setYOY(statsIndex.getYeartoyear()); newStatsIndex.setFixedBase(statsIndex.getFixedbase()); @@ -242,7 +242,7 @@ public class StatsIndexController { } model.setCity(cityName); } - if (StringUtils.isBlank(model.getYearmonth())) { + if (null == model.getYearmonth()) { mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); return mav; } @@ -265,7 +265,7 @@ public class StatsIndexController { newStatsIndex.setLargeFixedBase(statsIndex.getAboveFixedbase()); newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setYearmonth(statsIndex.getYearmonth().toString()); newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); if (StringUtils.isNotBlank(newStatsIndex.getCity())) { statsIndexList.add(newStatsIndex); @@ -304,7 +304,7 @@ public class StatsIndexController { } model.setCity(cityName); } - if (StringUtils.isBlank(model.getYearmonth())) { + if (null == model.getYearmonth()) { mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); return mav; } @@ -317,7 +317,7 @@ public class StatsIndexController { newStatsIndex.setMOM(statsIndex.getFangChain()); newStatsIndex.setIndex(statsIndex.getFangIndex()); newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setYearmonth(statsIndex.getYearmonth().toString()); newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); if (StringUtils.isNotBlank(newStatsIndex.getCity())) { statsIndexList.add(newStatsIndex); @@ -354,7 +354,7 @@ public class StatsIndexController { } model.setCity(cityName); } - if (StringUtils.isBlank(model.getYearmonth())) { + if (null == model.getYearmonth()) { mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "年月必须输入,格式:yyyyMM")); return mav; } @@ -368,7 +368,7 @@ public class StatsIndexController { newStatsIndex.setMOM(statsIndex.getFangChain()); newStatsIndex.setIndex(statsIndex.getFangIndex()); newStatsIndex.setCity(DistrictCodeUtils.getCityCode(statsIndex.getCity())); - newStatsIndex.setYearmonth(statsIndex.getYearmonth()); + newStatsIndex.setYearmonth(statsIndex.getYearmonth().toString()); newStatsIndex.setSource(String.valueOf(statsIndex.getSource())); if (StringUtils.isNotBlank(newStatsIndex.getCity())) { statsIndexList.add(newStatsIndex); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java index 3d9a4909c..305d4f6fe 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/StatsIndexModel.java @@ -14,7 +14,7 @@ public class StatsIndexModel { private String name; private String type; - private String yearmonth; + private Integer yearmonth; private Integer source; @@ -68,11 +68,11 @@ public class StatsIndexModel { this.city = city; } - public String getYearmonth() { + public Integer getYearmonth() { return yearmonth; } - public void setYearmonth(String yearmonth) { + public void setYearmonth(Integer yearmonth) { this.yearmonth = yearmonth; } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java index dfd0645bc..e4399d1bc 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexService.java @@ -8,5 +8,5 @@ import java.util.List; public interface PropertyStatsIndexService { PropertyStatsIndex findById(String id); - PropertyStatsIndex findStatsIndex(String city, String district, String name, String yearmonth, String cat); + PropertyStatsIndex findStatsIndex(String city, String district, String name, Integer yearmonth); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java index 73bea049a..191b5437b 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/PropertyStatsIndexServiceImpl.java @@ -20,7 +20,7 @@ public class PropertyStatsIndexServiceImpl implements PropertyStatsIndexService } @Override - public PropertyStatsIndex findStatsIndex(String city, String district, String name, String yearmonth, String cat) { + public PropertyStatsIndex findStatsIndex(String city, String district, String name, Integer yearmonth) { List params = new ArrayList(); if (StringUtils.isNotBlank(city)) { params.add(new QueryParam("city", city)); @@ -31,16 +31,9 @@ public class PropertyStatsIndexServiceImpl implements PropertyStatsIndexService if (StringUtils.isNotBlank(name)) { params.add(new QueryParam("name", name)); } - if (StringUtils.isNotBlank(yearmonth)) { + if (null == yearmonth) { params.add(new QueryParam("yearmonth", yearmonth)); } - if (("商铺").equals(cat)) { - params.add(new QueryParam("cat", "shop")); - } else if (("写字楼").equals(cat)) { - params.add(new QueryParam("cat", "office")); - } else { - params.add(new QueryParam("cat", "district")); - } List sortParams = new ArrayList(); sortParams.add(new SortParam("yearmonth", false)); return propertyStatsIndexDao.findFirstByParams(params, sortParams); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java index 16da71c9e..55c6bfc7e 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexService.java @@ -8,19 +8,19 @@ public interface StatsIndexService { StatsIndex findById(String id); - StatsIndex findByName(String city, String yearmonth); + StatsIndex findByName(String city, Integer yearmonth); - List findAllStats(String city, String yearmonth, boolean order,String cat); + List findAllStats(String city, Integer yearmonth, boolean order,String cat); // List findAllStats(String city, String district,String type, String yearmonth, boolean order,String cat); - int findAllStatsCount(String city, String name,String cat); + int findAllStatsCount(String city, Integer yearmonth,String cat); void deleteById(String id); - StatsIndex findLatestStstsIndex(String city, String yearmonth,String cat); - StatsIndex findStatsIndex(String city,String district,String type,String name, String yearmonth,String cat); + StatsIndex findLatestStstsIndex(String city, Integer yearmonth,String cat); + StatsIndex findStatsIndex(String city,String district,String type,String name, Integer yearmonth,String cat); - public List findAllStatsNocat(String yearmonth,String cat,String source) ; + public List findAllStatsNocat(Integer yearmonth,String cat,String source) ; Integer findEarliestMonth(String city, String cat, String source); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java index 2530942c6..915e63544 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/StatsIndexServiceImpl.java @@ -20,179 +20,176 @@ import com.fangjia.service.cnAnalyzer.CnTokenizer; import com.fangjia.service.datastore.DistrictService; public class StatsIndexServiceImpl implements StatsIndexService { - private StatsIndexDao statsIndexDao; + private StatsIndexDao statsIndexDao; - @Override - public StatsIndex findById(String id) { - return statsIndexDao.findById(id); - } + @Override + public StatsIndex findById(String id) { + return statsIndexDao.findById(id); + } - @Override - public StatsIndex findByName(String city, String yearmonth) { - List params = new ArrayList(1); - if (StringUtils.isNotEmpty(city)) { - params.add(new QueryParam("city", city)); - } - if (StringUtils.isNotEmpty(city)) { - params.add(new QueryParam("yearmonth", yearmonth)); - } - List allNearbys = statsIndexDao.findAllByParams(params, - null, 0, Integer.MAX_VALUE); - return allNearbys.get(0); - } + @Override + public StatsIndex findByName(String city, Integer yearmonth) { + List params = new ArrayList(1); + if (StringUtils.isNotEmpty(city)) { + params.add(new QueryParam("city", city)); + } + if (null != yearmonth) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + List allNearbys = statsIndexDao.findAllByParams(params, + null, 0, Integer.MAX_VALUE); + return allNearbys.get(0); + } - @Override - public List findAllStats(String city, String yearmonth, boolean order, String cat) { - List params = new ArrayList(); - if (StringUtils.isNotBlank(city)) { - params.add(new QueryParam("city", city)); - } - if (StringUtils.isNotBlank(yearmonth)) { - params.add(new QueryParam("yearmonth", yearmonth)); - } - if (("商铺").equals(cat)) { - params.add(new QueryParam("cat", "shop")); - } else if (("写字楼").equals(cat)) { - params.add(new QueryParam("cat", "office")); - } else { - params.add(new QueryParam("cat", "district")); - } - List sortParams = new ArrayList(2); - sortParams.add(new SortParam("yearmonth", order)); - sortParams.add(new SortParam("cDate", order)); - List allNearbys = statsIndexDao.findAllByParams(params,sortParams); - return allNearbys; - } + @Override + public List findAllStats(String city, Integer yearmonth, boolean order, String cat) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + if (null != yearmonth) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + if (("商铺").equals(cat)) { + params.add(new QueryParam("cat", "shop")); + } else if (("写字楼").equals(cat)) { + params.add(new QueryParam("cat", "office")); + } else { + params.add(new QueryParam("cat", "district")); + } + List sortParams = new ArrayList(2); + sortParams.add(new SortParam("yearmonth", order)); + sortParams.add(new SortParam("cDate", order)); + List allNearbys = statsIndexDao.findAllByParams(params, sortParams); + return allNearbys; + } - private List createQueryParam(String city, String yearmonth) { - List params = new ArrayList(); - if (StringUtils.isNotBlank(city)) { - params.add(new QueryParam("city", city)); - } - if (StringUtils.isNotBlank(yearmonth)) { - params.add(new QueryParam("yearmonth", yearmonth)); - } - return params; - } + private List createQueryParam(String city, Integer yearmonth) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + if (null != yearmonth) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + return params; + } - @Override - public int findAllStatsCount(String city, String yearmonth, String cat) { - List params = new ArrayList(); - if (StringUtils.isNotBlank(city)) { - params.add(new QueryParam("city", city)); - } - if (StringUtils.isNotBlank(yearmonth)) { - params.add(new QueryParam("yearmonth", yearmonth)); - } - if (StringUtils.isNotBlank(cat)) { - params.add(new QueryParam("cat", cat)); - } else { - params.add(new QueryParam("cat", "district")); - } - List allNearbys = statsIndexDao.findAllByParams(params); - if (allNearbys.size() == 0) { - allNearbys = statsIndexDao.findAllByParams(createQueryParam(city, - yearmonth)); - } - return allNearbys.size(); - } + @Override + public int findAllStatsCount(String city, Integer yearmonth, String cat) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + if (null != yearmonth) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + if (StringUtils.isNotBlank(cat)) { + params.add(new QueryParam("cat", cat)); + } else { + params.add(new QueryParam("cat", "district")); + } + List allNearbys = statsIndexDao.findAllByParams(params); + if (allNearbys.size() == 0) { + allNearbys = statsIndexDao.findAllByParams(createQueryParam(city, + yearmonth)); + } + return allNearbys.size(); + } - @Override - public void deleteById(String id) { - statsIndexDao.deleteById(id); - } + @Override + public void deleteById(String id) { + statsIndexDao.deleteById(id); + } - public void setStatsIndexDao(StatsIndexDao statsIndexDao) { - this.statsIndexDao = statsIndexDao; - } + public void setStatsIndexDao(StatsIndexDao statsIndexDao) { + this.statsIndexDao = statsIndexDao; + } - @Override - public StatsIndex findLatestStstsIndex(String city, String yearmonth, String cat) { - List params = new ArrayList(); - if (StringUtils.isNotBlank(city)) { - params.add(new QueryParam("city", city)); - } - if (StringUtils.isNotBlank(yearmonth)) { - params.add(new QueryParam("yearmonth", yearmonth)); - } - if(StringUtils.isNotBlank(cat)){ - params.add(new QueryParam("cat", cat)); - } - List sortParams = new ArrayList(); - sortParams.add(new SortParam("yearmonth", false)); - return statsIndexDao.findFirstByParams(params, sortParams); - } + @Override + public StatsIndex findLatestStstsIndex(String city, Integer yearmonth, String cat) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + if (null != yearmonth) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + if (StringUtils.isNotBlank(cat)) { + params.add(new QueryParam("cat", cat)); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("yearmonth", false)); + return statsIndexDao.findFirstByParams(params, sortParams); + } - @Override - public StatsIndex findStatsIndex(String city, String district, String type, String name, String yearmonth, String cat) { - List params = new ArrayList(); - if (StringUtils.isNotBlank(city)) { - params.add(new QueryParam("city", city)); - } - if (StringUtils.isNotBlank(district)) { - params.add(new QueryParam("district", district)); - } - if (StringUtils.isNotBlank(type)) { - params.add(new QueryParam("type", type)); - } - if (StringUtils.isNotBlank(name)) { - params.add(new QueryParam("name", name)); - } - if (StringUtils.isNotBlank(yearmonth)) { - params.add(new QueryParam("yearmonth", yearmonth)); - } - if (("商铺").equals(cat)) { - params.add(new QueryParam("cat", "shop")); - } else if (("写字楼").equals(cat)) { - params.add(new QueryParam("cat", "office")); - } else { - params.add(new QueryParam("cat", "district")); - } - List sortParams = new ArrayList(); - sortParams.add(new SortParam("yearmonth", false)); - return statsIndexDao.findFirstByParams(params, sortParams); - } + @Override + public StatsIndex findStatsIndex(String city, String district, String type, String name, Integer yearmonth, String cat) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + if (StringUtils.isNotBlank(district)) { + params.add(new QueryParam("district", district)); + } + if (StringUtils.isNotBlank(type)) { + params.add(new QueryParam("type", type)); + } + if (null != yearmonth) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + if (("商铺").equals(cat)) { + params.add(new QueryParam("cat", "shop")); + } else if (("写字楼").equals(cat)) { + params.add(new QueryParam("cat", "office")); + } else { + params.add(new QueryParam("cat", "district")); + } + List sortParams = new ArrayList(); + sortParams.add(new SortParam("yearmonth", false)); + return statsIndexDao.findFirstByParams(params, sortParams); + } - @Override - public List findAllStatsNocat(String yearmonth,String cat,String source) { - List params = new ArrayList(); - if (StringUtils.isNotBlank(yearmonth)) { - params.add(new QueryParam("yearmonth", yearmonth)); - } - if(StringUtils.isNotBlank(cat)){ - params.add(new QueryParam("cat", cat)); - } - if(StringUtils.isNotBlank(source)){ - params.add(new QueryParam("source", Integer.valueOf(source))); - } - List sortParams = new ArrayList(2); - List allNearbys = statsIndexDao.findAllByParams(params, - sortParams); - return allNearbys; - } + @Override + public List findAllStatsNocat(Integer yearmonth, String cat, String source) { + List params = new ArrayList(); + if (null != yearmonth) { + params.add(new QueryParam("yearmonth", yearmonth)); + } + if (StringUtils.isNotBlank(cat)) { + params.add(new QueryParam("cat", cat)); + } + if (StringUtils.isNotBlank(source)) { + params.add(new QueryParam("source", Integer.valueOf(source))); + } + List sortParams = new ArrayList(2); + List allNearbys = statsIndexDao.findAllByParams(params, + sortParams); + return allNearbys; + } - @Override - public Integer findEarliestMonth(String city, String cat, String source) { - List params = new ArrayList(); - if(StringUtils.isNotBlank(cat)){ - params.add(new QueryParam("cat", cat)); - } - if(StringUtils.isNotBlank(source)){ - params.add(new QueryParam("source", Integer.valueOf(source))); - } - if(StringUtils.isNotBlank(city)){ - params.add(new QueryParam("city", city)); - } - List statsIndexList = statsIndexDao.findAllByParams(params, null, 0, Integer.MAX_VALUE, new String[]{"yearmonth"}); - Integer min = null; - for(StatsIndex statsIndex : statsIndexList){ - Integer yearMonth = Integer.valueOf(statsIndex.getYearmonth()); - if(min == null || yearMonth < min){ - min = yearMonth; - } - } - return min; - } + @Override + public Integer findEarliestMonth(String city, String cat, String source) { + List params = new ArrayList(); + if (StringUtils.isNotBlank(cat)) { + params.add(new QueryParam("cat", cat)); + } + if (StringUtils.isNotBlank(source)) { + params.add(new QueryParam("source", Integer.valueOf(source))); + } + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } + List statsIndexList = statsIndexDao.findAllByParams(params, null, 0, Integer.MAX_VALUE, new String[]{"yearmonth"}); + Integer min = null; + for (StatsIndex statsIndex : statsIndexList) { + Integer yearMonth = Integer.valueOf(statsIndex.getYearmonth()); + if (min == null || yearMonth < min) { + min = yearMonth; + } + } + return min; + } } From 404f8cb58081cec36e51ac5c9be929a02993e828 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 27 Sep 2024 18:31:38 +0800 Subject: [PATCH 050/230] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=8C=BA=E5=9B=B4?= =?UTF-8?q?=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DevelopmentZoneController.java | 19 +- .../controllers/IndexStatsController.java | 6 +- .../bkoff/model/DevelopmentZoneModel.java | 10 + .../src/main/webapp/developmentZone/edit.ftl | 613 ++++++++---------- .../main/webapp/developmentZone/editFence.ftl | 531 +++++++++++++++ .../src/main/webapp/developmentZone/list.ftl | 5 +- .../dal/mongo/model/DevelopmentZone.java | 11 + .../fangjia/dal/mongo/model/StatsIndex.java | 33 +- 8 files changed, 875 insertions(+), 353 deletions(-) create mode 100644 projects/fangjia-bkoff/src/main/webapp/developmentZone/editFence.ftl diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DevelopmentZoneController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DevelopmentZoneController.java index 4b04e0c41..9cc24280f 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DevelopmentZoneController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DevelopmentZoneController.java @@ -33,9 +33,9 @@ public class DevelopmentZoneController { if (pager.getCurrentPage() > 100) { pager.setCurrentPage(1); } - long countDev = developmentZoneService.countDev(model.getProvince(),model.getCityName1(), model.getName(), model.getLevel()); + long countDev = developmentZoneService.countDev(model.getProvince(), model.getCityName1(), model.getName(), model.getLevel()); pager.setTotalRows((int) countDev); - List developmentZones = developmentZoneService.findDevelopmentZone(model.getProvince(),model.getCityName1(), model.getName(), model.getLevel(), pager); + List developmentZones = developmentZoneService.findDevelopmentZone(model.getProvince(), model.getCityName1(), model.getName(), model.getLevel(), pager); model.setDevelopmentZoneList(developmentZones); model.setPager(pager); return model; @@ -59,6 +59,15 @@ public class DevelopmentZoneController { return model; } + public Object editFenceAction(DevelopmentZoneModel model) { + if (model.getId() == null) { + return model; + } + + model.setDevelopmentZone(developmentZoneService.findDevelopmentZone(model.getId())); + return model; + } + public Object deleteAction(LatlngPolygonModel model) { JsonModel ret = new JsonModel(); if (model.getId() == null) { @@ -127,6 +136,7 @@ public class DevelopmentZoneController { entity.setUrl(StringUtils.isBlank(model.getUrl()) ? "" : model.getUrl()); entity.setCityName1(StringUtils.isBlank(model.getCityName1()) ? "" : model.getCityName1()); entity.setDistrict(StringUtils.isBlank(model.getDistrict()) ? "" : model.getDistrict()); + entity.setImgUrl(StringUtils.isBlank(model.getImgUrl()) ? "" : model.getImgUrl()); //记录操作人员 entity.setOperator(user.getRealName()); developmentZoneService.saveDevelopmentZone(entity); @@ -201,9 +211,12 @@ public class DevelopmentZoneController { if (StringUtils.isNotBlank(model.getCityName1())) { udata.put("cityName1", model.getCityName1()); } - if (StringUtils.isNotBlank(model.getDistrict())){ + if (StringUtils.isNotBlank(model.getDistrict())) { udata.put("district", model.getDistrict()); } + if (StringUtils.isNotBlank(model.getImgUrl())){ + udata.put("imgUrl", model.getImgUrl()); + } udata.put("createTime", new Date()); //记录操作人员 udata.put("operator", user.getRealName()); diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/IndexStatsController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/IndexStatsController.java index 3c555754b..394b7b033 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/IndexStatsController.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/IndexStatsController.java @@ -34,13 +34,13 @@ public class IndexStatsController { SimpleDateFormat sdf=new SimpleDateFormat("yyyyMM"); yearmonth=sdf.format(date); } - List statsIndexs=statsIndexService.findAllStatsNocat(yearmonth,"district",model.getSource()); + List statsIndexs=statsIndexService.findAllStatsNocat(Integer.valueOf(yearmonth),"district",model.getSource()); Integer earliestMonth = statsIndexService.findEarliestMonth(null, null, model.getSource()); model.setEarliestMonth(earliestMonth.toString().substring(0, 4) + "-" + earliestMonth.toString().substring(4)); List newStats=new ArrayList(); List oldStats=new ArrayList(); - List shopStats=statsIndexService.findAllStatsNocat(yearmonth,"shop",model.getSource()); - List officeStats=statsIndexService.findAllStatsNocat(yearmonth,"office",model.getSource()); + List shopStats=statsIndexService.findAllStatsNocat(Integer.valueOf(yearmonth),"shop",model.getSource()); + List officeStats=statsIndexService.findAllStatsNocat(Integer.valueOf(yearmonth),"office",model.getSource()); if(statsIndexs!=null && statsIndexs.size()>0){ for(StatsIndex stat:statsIndexs){ StatsIndex newstat=new StatsIndex(); diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/DevelopmentZoneModel.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/DevelopmentZoneModel.java index 54f85ab42..a4b4e7552 100644 --- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/DevelopmentZoneModel.java +++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/model/DevelopmentZoneModel.java @@ -35,6 +35,8 @@ public class DevelopmentZoneModel extends BaseModel { private String cityName1; + private String imgUrl; + public String getAlias() { return alias; } @@ -194,4 +196,12 @@ public class DevelopmentZoneModel extends BaseModel { public void setCityName1(String cityName1) { this.cityName1 = cityName1; } + + public String getImgUrl() { + return imgUrl; + } + + public void setImgUrl(String imgUrl) { + this.imgUrl = imgUrl; + } } diff --git a/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl b/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl index b75eca58f..7c48ce0c8 100644 --- a/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl +++ b/projects/fangjia-bkoff/src/main/webapp/developmentZone/edit.ftl @@ -1,368 +1,297 @@ <#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <#compress> - - - - - 寮�鍙戝尯鍥存爮鍒楄〃 - - - - -<#include "/common_js.ftl" /> -<#include "/layout/header.ftl" /> -
-

@@ -273,10 +274,7 @@

<#if fjtEvaluation.gardenArea??>${fjtEvaluation.gardenArea!?string('0.##')}骞崇背<#else>-

<#if fjtEvaluation.outerArea??>${fjtEvaluation.outerArea!?string('0.##')}骞崇背<#else>-

-

<#if fjtEvaluation.carSiteArea??>${fjtEvaluation.carSiteArea!?string('0.##')}骞崇背<#else>-

- <#if fjtEvaluation.city! == "涓婃捣"> -

${fjtEvaluation.loopLine!}

- +

<#if fjtEvaluation.carSiteArea??>${fjtEvaluation.carSiteArea!?string('0.##')}骞崇背<#else>-

@@ -326,20 +324,23 @@

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

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

-

- - - <#if fjtEvaluation.carport! == 1> - 宸茬 - <#elseif fjtEvaluation.carport! == 3> - 宸茶喘 - <#elseif fjtEvaluation.carport! == 2> - 鏆傛棤 - <#else> - - - - -

+ <#if fjtEvaluation.city! == "涓婃捣"> +

${fjtEvaluation.loopLine!}

+ + <#--

--> +<#-- --> +<#-- --> +<#-- <#if fjtEvaluation.carport! == 1>--> +<#-- 宸茬--> +<#-- <#elseif fjtEvaluation.carport! == 3>--> +<#-- 宸茶喘--> +<#-- <#elseif fjtEvaluation.carport! == 2>--> +<#-- 鏆傛棤--> +<#-- <#else>--> +<#-- ---> +<#-- --> +<#-- --> +<#--

-->
鍏ㄩ儴淇℃伅
From 27f27c2f0fdda9411151fe23c3a441ef5f62dd7c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 11:31:57 +0800 Subject: [PATCH 154/230] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index fa7fa0ac7..60ff6fe3c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -365,6 +365,7 @@ class NewGaoDePoiBatch extends BaseBatch{ if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" } + println fileName File file=new File(fileName); if(file.exists()){ def results = readCSV(fileName) @@ -373,6 +374,8 @@ class NewGaoDePoiBatch extends BaseBatch{ def megerMap = poiRepeat(cityObj.city, results) save(megerMap.values()) } + }else{ + println fileName +" 不存在" } } } From a98613692f1718d06eed81c916da44cdf47c7fb9 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 11:46:10 +0800 Subject: [PATCH 155/230] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 60ff6fe3c..d65f086bf 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -361,7 +361,7 @@ class NewGaoDePoiBatch extends BaseBatch{ // if(!cityObj.city.contains("固原")){ // continue // } - def fileName = "/home/goojia/gj/poi/poi/${cityObj.city}.csv" + def fileName = "/home/goojia/gj/poi/old_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" } From 0defcebdafd2d68b3198184317ba717b6ffa7143 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 19 Dec 2024 15:25:35 +0800 Subject: [PATCH 156/230] =?UTF-8?q?=E7=A7=9F=E9=87=91=E6=8C=82=E7=89=8C?= =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/HouseController.java | 91 +++++++++++++++++++ .../fangjia/open/model/HouseSearchModel.java | 10 ++ 2 files changed, 101 insertions(+) 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 9b723e050..68e6d22d3 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 @@ -1147,6 +1147,97 @@ public class HouseController { mav.setViewType("rest"); return mav; } + public Object rentAction(final HouseSearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getSize()<0) { + mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); + return mav; + } + if (StringUtils.isNotBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city),区域(district),小区名(name)为必填参数")); + return mav; + } + District property = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + + // 获取当前日期 + Calendar today = Calendar.getInstance(); + + // 复制一份当前日期,用于计算半年前的日期 + Calendar sixMonthsAgo = (Calendar) today.clone(); + + // 减去 6 个月 + sixMonthsAgo.add(Calendar.MONTH, -6); + + // 格式化日期为 yyyyMMdd + int todayInt = formatDate(today); + int sixMonthsAgoInt = formatDate(sixMonthsAgo); + model.setStartTime(sixMonthsAgoInt); + model.setEndTime(todayInt); + + List houses = null; + List houseList = new ArrayList(); +// if (cat.contains("_")) { + // 商铺,写字楼有经纬度,直接查 + SeawaterQuery query = new SeawaterQuery(); + query.setCat("rent"); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + query.setCityDisplay(model.getCity()); + query.setRegion(model.getDistrict()); + query.setDistrictName(model.getName()); + query.setDistrictAlias(property.getAlias()); + Pager pager = new Pager(); + pager.setStartRow(0); + pager.setPageSize(5); + query.setPager(pager); + query.setTable("latest_seawater"); + houses = seawaterDao.findSeawatersByQuery(query); + if (houses != null && !houses.isEmpty()) { + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDecoration(house.getFitment()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // 拆分字符串并格式化 + String year = numberStr.substring(0, 4); // 前四位是年份 + String month = numberStr.substring(4, 6); // 中间两位是月份 + String day = numberStr.substring(6, 8); // 最后两位是日期 + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + houseList.add(seawater); + } + } + BasicModel basicModel = new BasicModel(200, "ok"); + // 组装数据 + basicModel.setResult(houseList); + mav.setModel(basicModel); + mav.setViewType("rest"); + return mav; + } Double sub6(Double a) { BigDecimal bd = new BigDecimal(a); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index a78519c7a..987f6f3d2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -23,6 +23,8 @@ public class HouseSearchModel extends SearchModel { private String propertyType; private String houseType; + + private String district; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -177,4 +179,12 @@ public class HouseSearchModel extends SearchModel { public void setHouseType(String houseType) { this.houseType = houseType; } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } } From 2d626b5930bea667945ef392e5560d6010bba8ce Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 19 Dec 2024 16:20:55 +0800 Subject: [PATCH 157/230] =?UTF-8?q?=E7=A7=9F=E9=87=91=E6=8C=82=E7=89=8C?= =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/seawater/dao/SeawaterDaoImpl.java | 1674 +++++++++-------- .../open/controllers/HouseController.java | 4 +- 2 files changed, 840 insertions(+), 838 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java index 2fbbd9384..39a29c099 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/dao/SeawaterDaoImpl.java @@ -17,520 +17,520 @@ import org.sothis.core.util.Pager; public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl implements SeawaterDao { - private static final String ES_USER = "developer"; - private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; + private static final String ES_USER = "developer"; + private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3"; - @Override - public long findSeawatersCountFromEs(String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Integer room, String root,String table) { - int count = queryCount(null,category,city,region,name,alias,regionAlias,startDate,endDate,room,root,null,false,-1,-1,table); - return count; - } + @Override + public long findSeawatersCountFromEs(String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Integer room, String root, String table) { + int count = queryCount(null, category, city, region, name, alias, regionAlias, startDate, endDate, room, root, null, false, -1, -1, table); + return count; + } - @Override - public Seawater findByIdFromEs(String id,String table) { - Seawater seawater = null; - SeawaterQuery query = new SeawaterQuery(); - query.setId(id); - query.setTable(table); - Pager pager = new Pager(); - pager.setStartRow(-1); - pager.setPageSize(-1); - query.setPager(pager); - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - List seawaterList = wrapSeawater(jsonList); - if(seawaterList.size() > 0){ - seawater = seawaterList.get(0); - } - } - return seawater; - } + @Override + public Seawater findByIdFromEs(String id, String table) { + Seawater seawater = null; + SeawaterQuery query = new SeawaterQuery(); + query.setId(id); + query.setTable(table); + Pager pager = new Pager(); + pager.setStartRow(-1); + pager.setPageSize(-1); + query.setPager(pager); + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + List seawaterList = wrapSeawater(jsonList); + if (seawaterList.size() > 0) { + seawater = seawaterList.get(0); + } + } + return seawater; + } - @Override - public List findSeawatersFromEs(String category, String city, String region, String name, List alias, List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String table) { - List seawaterList= new ArrayList(); - SeawaterQuery query = new SeawaterQuery(); - query.setCat(category); - query.setCityDisplay(city); - query.setRegion(region); - query.setDistrictName(name); - query.setDistrictAlias(alias); - query.setRegionAlias(regionAlias); - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setStartArea(startArea); - query.setEndArea(endArea); - query.setStartPrice(startPrice); - query.setEndPrice(endPrice); - query.setRoom(room); - query.setRootName(root); - query.setOrder(order); - Pager pager = new Pager(); - pager.setStartRow(start); - pager.setPageSize(limit); - query.setPager(pager); - query.setTable(table); - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - seawaterList = wrapSeawater(jsonList); - } - return seawaterList; - } + @Override + public List findSeawatersFromEs(String category, String city, String region, String name, List alias, List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root, String sort, boolean order, int start, int limit, String table) { + List seawaterList = new ArrayList(); + SeawaterQuery query = new SeawaterQuery(); + query.setCat(category); + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(name); + query.setDistrictAlias(alias); + query.setRegionAlias(regionAlias); + query.setStartDate(startDate); + query.setEndDate(endDate); + query.setStartArea(startArea); + query.setEndArea(endArea); + query.setStartPrice(startPrice); + query.setEndPrice(endPrice); + query.setRoom(room); + query.setRootName(root); + query.setOrder(order); + Pager pager = new Pager(); + pager.setStartRow(start); + pager.setPageSize(limit); + query.setPager(pager); + query.setTable(table); + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + seawaterList = wrapSeawater(jsonList); + } + return seawaterList; + } - @Override - public List findSeawatersByQuery(SeawaterQuery query){ - List seawaterList; - List jsonList = queryList(query); - if(jsonList == null){ - return null; - }else{ - seawaterList = wrapSeawater(jsonList); - } - return seawaterList; - } + @Override + public List findSeawatersByQuery(SeawaterQuery query) { + List seawaterList; + List jsonList = queryList(query); + if (jsonList == null) { + return null; + } else { + seawaterList = wrapSeawater(jsonList); + } + return seawaterList; + } - @Override - public long findSeawatersCountByQuery(SeawaterQuery query) { - int count = queryCount(query); - return count; - } + @Override + public long findSeawatersCountByQuery(SeawaterQuery query) { + int count = queryCount(query); + return count; + } - @Override - public List findHouses(String city, String region, List alias, Integer minPrice, Integer maxPrice, Integer limit) { - JSONObject reqBody = new JSONObject(); - reqBody.put("from", 0); - reqBody.put("size", limit); - JSONObject query = new JSONObject(); - JSONObject bool = new JSONObject(); - JSONArray must = new JSONArray(); - must.add(addMatch("city", city)); - must.add(addMatch("region", region)); - must.add(addTerms("district_name", alias)); - must.add(addMatch("cat", "sell")); - must.add(addRange("avg_price", minPrice, maxPrice)); - must.add(addRangeGte("p_date", 20210501)); + @Override + public List findHouses(String city, String region, List alias, Integer minPrice, Integer maxPrice, Integer limit) { + JSONObject reqBody = new JSONObject(); + reqBody.put("from", 0); + reqBody.put("size", limit); + JSONObject query = new JSONObject(); + JSONObject bool = new JSONObject(); + JSONArray must = new JSONArray(); + must.add(addMatch("city", city)); + must.add(addMatch("region", region)); + must.add(addTerms("district_name", alias)); + must.add(addMatch("cat", "sell")); + must.add(addRange("avg_price", minPrice, maxPrice)); + must.add(addRangeGte("p_date", 20210501)); - bool.put("must", must); - query.put("bool", bool); - reqBody.put("query", query); - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); - HttpRequest request = new HttpRequest(); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); - try { - String response = request.postWithBody("http://es.fangjia.com:9200/latest_seawater/_search", reqBody, headers, "UTF-8"); - JSONObject json = JSONObject.fromObject(response); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ - return Collections.emptyList(); - } - JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); - List results = new ArrayList(); - for(int i=0 ;i < hits.size(); i++){ - JSONObject jsonObject = hits.getJSONObject(i); - results.add(jsonObject); - } - return wrapSeawater(results); + bool.put("must", must); + query.put("bool", bool); + reqBody.put("query", query); + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + try { + String response = request.postWithBody("http://es.fangjia.com:9200/latest_seawater/_search", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) { + return Collections.emptyList(); + } + JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); + List results = new ArrayList(); + for (int i = 0; i < hits.size(); i++) { + JSONObject jsonObject = hits.getJSONObject(i); + results.add(jsonObject); + } + return wrapSeawater(results); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - return new ArrayList(); - } + } catch (HttpRequestException e) { + e.printStackTrace(); + } + return new ArrayList(); + } - @Override - public void deleteById(String id) { - deleteByIds(Arrays.asList(id)); - } + @Override + public void deleteById(String id) { + deleteByIds(Arrays.asList(id)); + } - private Map buildHeader() { - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic " + authenticationEncoding + ""); - return headers; - } + private Map buildHeader() { + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + return headers; + } - @Override - public void deleteByIds(List idList) { - HttpRequest request = new HttpRequest(); + @Override + public void deleteByIds(List idList) { + HttpRequest request = new HttpRequest(); - JSONObject reqBody = new JSONObject(); - JSONObject query = new JSONObject(); - JSONObject bool = new JSONObject(); - JSONArray must = new JSONArray(); - must.add(addTerms("_id", idList)); - bool.put("must", must); - query.put("bool", bool); - reqBody.put("query", query); + JSONObject reqBody = new JSONObject(); + JSONObject query = new JSONObject(); + JSONObject bool = new JSONObject(); + JSONArray must = new JSONArray(); + must.add(addTerms("_id", idList)); + bool.put("must", must); + query.put("bool", bool); + reqBody.put("query", query); - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.status=1"); - reqBody.put("script", script); + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.status=1"); + reqBody.put("script", script); - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } - @Override - public void batchDeleteByParams(SeawaterQuery query) { - HttpRequest request = new HttpRequest(); + @Override + public void batchDeleteByParams(SeawaterQuery query) { + HttpRequest request = new HttpRequest(); - JSONObject reqBody = wrapQueryParams(query); + JSONObject reqBody = wrapQueryParams(query); - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.status=1"); - script.put("lang", "painless"); - reqBody.put("script", script); + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.status=1"); + script.put("lang", "painless"); + reqBody.put("script", script); - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } - @Override - public void batchUpdateEstateType(SeawaterQuery query) { - HttpRequest request = new HttpRequest(); + @Override + public void batchUpdateEstateType(SeawaterQuery query) { + HttpRequest request = new HttpRequest(); - JSONObject reqBody = wrapQueryParams(query); + JSONObject reqBody = wrapQueryParams(query); - JSONObject script = new JSONObject(); - script.put("source", "ctx._source.estate_type="+"'"+query.getEditEstateType()+"'"); - script.put("lang", "painless"); - reqBody.put("script", script); + JSONObject script = new JSONObject(); + script.put("source", "ctx._source.estate_type=" + "'" + query.getEditEstateType() + "'"); + script.put("lang", "painless"); + reqBody.put("script", script); - try { - request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); - } catch (HttpRequestException e) { - e.printStackTrace(); - } - } + try { + request.postWithBody("http://es.fangjia.com:9200/seawater/_update_by_query?conflicts=proceed&wait_for_completion=false", reqBody, this.buildHeader(), "UTF-8"); + } catch (HttpRequestException e) { + e.printStackTrace(); + } + } - private JSONObject addMatch(String name, String value){ - JSONObject term = new JSONObject(); - JSONObject match = new JSONObject(); - match.put(name, value); - term.put("match", match); - return term; - } + private JSONObject addMatch(String name, String value) { + JSONObject term = new JSONObject(); + JSONObject match = new JSONObject(); + match.put(name, value); + term.put("match", match); + return term; + } - private JSONObject addTerms(String name, List value){ - JSONObject terms = new JSONObject(); - JSONObject match = new JSONObject(); - match.put(name, value); - terms.put("terms", match); - return terms; - } + private JSONObject addTerms(String name, List value) { + JSONObject terms = new JSONObject(); + JSONObject match = new JSONObject(); + match.put(name, value); + terms.put("terms", match); + return terms; + } - private JSONObject addRange(String name, Number min, Number max){ - JSONObject term = new JSONObject(); - JSONObject range = new JSONObject(); - JSONObject rangeValue = new JSONObject(); - rangeValue.put("gt", min); - rangeValue.put("lt", max); - range.put(name, rangeValue); - term.put("range", range); - return term; - } + private JSONObject addRange(String name, Number min, Number max) { + JSONObject term = new JSONObject(); + JSONObject range = new JSONObject(); + JSONObject rangeValue = new JSONObject(); + rangeValue.put("gt", min); + rangeValue.put("lt", max); + range.put(name, rangeValue); + term.put("range", range); + return term; + } - private JSONObject addRangeGte(String name, Number min){ - JSONObject term = new JSONObject(); - JSONObject range = new JSONObject(); - JSONObject rangeValue = new JSONObject(); - rangeValue.put("gte", min); - range.put(name, rangeValue); - term.put("range", range); - return term; - } + private JSONObject addRangeGte(String name, Number min) { + JSONObject term = new JSONObject(); + JSONObject range = new JSONObject(); + JSONObject rangeValue = new JSONObject(); + rangeValue.put("gte", min); + range.put(name, rangeValue); + term.put("range", range); + return term; + } - private List wrapSeawater(List jsonList){ - List seawaterList= new ArrayList(); - for(int i=0 ;i < jsonList.size(); i++){ - Seawater seawater = new Seawater(); - seawater.setId(jsonList.get(i).getString("_id")); - JSONObject source = jsonList.get(i).getJSONObject("_source"); - seawater.setCategory(source.getString("cat")); - seawater.setCity(source.getString("city")); - seawater.setRegion(source.getString("region")); - seawater.setDistrictName(source.getString("district_name")); - if (source.containsKey("location")){ - String location = source.getJSONObject("location").getString("lon") + "," + source.getJSONObject("location").getString("lat"); - seawater.setLocation(location); - } - if(source.containsKey("address")){ - seawater.setAddress(source.getString("address")); - } - if(source.containsKey("name")){ - seawater.setName(source.getString("name")); - } - if(source.containsKey("direction")){ - seawater.setDirection(source.getString("direction")); - } - if(source.containsKey("block")){ - seawater.setBlock(source.getString("block")); - } - try{ - seawater.setTotalPrice(source.getInt("total_price")); - }catch(NumberFormatException e){ - seawater.setTotalPrice(0); - } - try{ - seawater.setArea(source.getDouble("area")); - }catch(NumberFormatException e){ - seawater.setArea(0d); - } - try{ - seawater.setHeight(source.getInt("height")); - }catch(Exception e){ - seawater.setHeight(0); - } - try{ - seawater.setFloor(source.getInt("floor")); - }catch(Exception e){ - seawater.setFloor(0); - } - try{ - seawater.setFloorInfo(source.getString("floor_info")); - }catch(Exception e){ - - } - if(source.containsKey("fitment")){ - seawater.setFitment(source.getString("fitment")); - } - try{ - seawater.setRoom(source.getInt("room")); - }catch(Exception e){ - seawater.setRoom(0); - } - try{ - seawater.setHall(source.getInt("hall")); - }catch(Exception e){ - seawater.setHall(0); - } - try{ - seawater.setToilet(source.getInt("toilet")); - }catch(Exception e){ - seawater.setToilet(0); - } - try{ - seawater.setpDate(source.getInt("p_date")); - }catch(Exception e){ - seawater.setpDate(0); - } - if(source.containsKey("url")){ - seawater.setUrl(source.getString("url")); - } - if(source.containsKey("avg_price")){ - seawater.setAvgPrice(source.getInt("avg_price")); - } - if(source.containsKey("root")){ - seawater.setRoot(source.getString("root")); - } - - if(source.containsKey("estate_type")){ - seawater.setEstateType(source.getString("estate_type")); - } - - if(source.containsKey("build_type")){ - seawater.setBuildType(source.getString("build_type")); - } - if(source.containsKey("status")){ - seawater.setStatus(source.getInt("status")); - } - - if(source.containsKey("lift")){ - seawater.setLift(source.getInt("lift")); - } - - if(source.containsKey("lift_household")){ - seawater.setLiftHousehold(source.getInt("lift_household")); - } - - if(source.containsKey("room_structure")){ - seawater.setRoomStructure(source.getString("room_structure")); - } - - if(source.containsKey("trade_property")){ - seawater.setTradeProperty(source.getString("trade_property")); - } - if(source.containsKey("property_ownership")){ - seawater.setPropertyOwnership(source.getString("property_ownership")); - } - if(source.containsKey("housing_age")){ - seawater.setHousingAge(source.getString("housing_age")); - } - if(source.containsKey("elevator")){ - seawater.setElevator(source.getString("elevator")); - } - if(source.containsKey("level")){ - seawater.setLevel(source.getString("level")); - } - if(source.containsKey("business_range")){ - seawater.setBusinessRange(source.getString("business_range")); - } + private List wrapSeawater(List jsonList) { + List seawaterList = new ArrayList(); + for (int i = 0; i < jsonList.size(); i++) { + Seawater seawater = new Seawater(); + seawater.setId(jsonList.get(i).getString("_id")); + JSONObject source = jsonList.get(i).getJSONObject("_source"); + seawater.setCategory(source.getString("cat")); + seawater.setCity(source.getString("city")); + seawater.setRegion(source.getString("region")); + seawater.setDistrictName(source.getString("district_name")); + if (source.containsKey("location")) { + String location = source.getJSONObject("location").getString("lon") + "," + source.getJSONObject("location").getString("lat"); + seawater.setLocation(location); + } + if (source.containsKey("address")) { + seawater.setAddress(source.getString("address")); + } + if (source.containsKey("name")) { + seawater.setName(source.getString("name")); + } + if (source.containsKey("direction")) { + seawater.setDirection(source.getString("direction")); + } + if (source.containsKey("block")) { + seawater.setBlock(source.getString("block")); + } try { - seawater.setDistance((int)jsonList.get(i).getJSONArray("sort").getDouble(0)); - }catch (Exception e){ + seawater.setTotalPrice(source.getInt("total_price")); + } catch (NumberFormatException e) { + seawater.setTotalPrice(0); + } + try { + seawater.setArea(source.getDouble("area")); + } catch (NumberFormatException e) { + seawater.setArea(0d); + } + try { + seawater.setHeight(source.getInt("height")); + } catch (Exception e) { + seawater.setHeight(0); + } + try { + seawater.setFloor(source.getInt("floor")); + } catch (Exception e) { + seawater.setFloor(0); + } + try { + seawater.setFloorInfo(source.getString("floor_info")); + } catch (Exception e) { + + } + if (source.containsKey("fitment")) { + seawater.setFitment(source.getString("fitment")); + } + try { + seawater.setRoom(source.getInt("room")); + } catch (Exception e) { + seawater.setRoom(0); + } + try { + seawater.setHall(source.getInt("hall")); + } catch (Exception e) { + seawater.setHall(0); + } + try { + seawater.setToilet(source.getInt("toilet")); + } catch (Exception e) { + seawater.setToilet(0); + } + try { + seawater.setpDate(source.getInt("p_date")); + } catch (Exception e) { + seawater.setpDate(0); + } + if (source.containsKey("url")) { + seawater.setUrl(source.getString("url")); + } + if (source.containsKey("avg_price")) { + seawater.setAvgPrice(source.getInt("avg_price")); + } + if (source.containsKey("root")) { + seawater.setRoot(source.getString("root")); + } + + if (source.containsKey("estate_type")) { + seawater.setEstateType(source.getString("estate_type")); + } + + if (source.containsKey("build_type")) { + seawater.setBuildType(source.getString("build_type")); + } + if (source.containsKey("status")) { + seawater.setStatus(source.getInt("status")); + } + + if (source.containsKey("lift")) { + seawater.setLift(source.getInt("lift")); + } + + if (source.containsKey("lift_household")) { + seawater.setLiftHousehold(source.getInt("lift_household")); + } + + if (source.containsKey("room_structure")) { + seawater.setRoomStructure(source.getString("room_structure")); + } + + if (source.containsKey("trade_property")) { + seawater.setTradeProperty(source.getString("trade_property")); + } + if (source.containsKey("property_ownership")) { + seawater.setPropertyOwnership(source.getString("property_ownership")); + } + if (source.containsKey("housing_age")) { + seawater.setHousingAge(source.getString("housing_age")); + } + if (source.containsKey("elevator")) { + seawater.setElevator(source.getString("elevator")); + } + if (source.containsKey("level")) { + seawater.setLevel(source.getString("level")); + } + if (source.containsKey("business_range")) { + seawater.setBusinessRange(source.getString("business_range")); + } + try { + seawater.setDistance((int) jsonList.get(i).getJSONArray("sort").getDouble(0)); + } catch (Exception e) { seawater.setDistance(null); } - seawaterList.add(seawater); + seawaterList.add(seawater); } - return seawaterList; - } + return seawaterList; + } - private JSONObject query(String id,String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, - Integer room, String root,String sort, boolean order, int start, int limit,String table){ - long time1 = System.currentTimeMillis(); - JSONObject reqBody = new JSONObject(); + private JSONObject query(String id, String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, + Integer room, String root, String sort, boolean order, int start, int limit, String table) { + long time1 = System.currentTimeMillis(); + JSONObject reqBody = new JSONObject(); JSONObject q = new JSONObject(); JSONObject query = new JSONObject(); List jsonList = new ArrayList(); - if(StringUtils.isNotBlank(id)) { - JSONObject param = new JSONObject(); - param.put("_id", id); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(category)) { - JSONObject param = new JSONObject(); - param.put("cat", category); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(id)) { + JSONObject param = new JSONObject(); + param.put("_id", id); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(category)) { + JSONObject param = new JSONObject(); + param.put("cat", category); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(name)) { - namesList.add(name); - } - if (alias != null) { - namesList.addAll(alias); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(name)) { + namesList.add(name); + } + if (alias != null) { + namesList.addAll(alias); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(region)) { - regionsList.add(region); - } - if (regionAlias != null) { - regionsList.addAll(regionAlias); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(region)) { + regionsList.add(region); + } + if (regionAlias != null) { + regionsList.addAll(regionAlias); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(city)){ - JSONObject param = new JSONObject(); - param.put("city", city); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(room != null) { - JSONObject param = new JSONObject(); - param.put("room", room); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(root)) { - JSONObject param = new JSONObject(); - param.put("root", root); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(city)) { + JSONObject param = new JSONObject(); + param.put("city", city); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (room != null) { + JSONObject param = new JSONObject(); + param.put("room", room); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(root)) { + JSONObject param = new JSONObject(); + param.put("root", root); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - if(startDate != null || endDate != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startDate != null){ - temp2.put("gte", startDate); - } - if(endDate != null){ - temp2.put("lte", endDate); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (startDate != null || endDate != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startDate != null) { + temp2.put("gte", startDate); + } + if (endDate != null) { + temp2.put("lte", endDate); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(startArea != null || endArea != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startArea != null){ - temp2.put("gte", startArea); - } - if(endArea != null){ - temp2.put("lte", endArea); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (startArea != null || endArea != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startArea != null) { + temp2.put("gte", startArea); + } + if (endArea != null) { + temp2.put("lte", endArea); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(startPrice != null || endPrice != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(startPrice != null){ - temp2.put("gte", startPrice); - } - if(endPrice != null){ - temp2.put("lte", endPrice); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (startPrice != null || endPrice != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (startPrice != null) { + temp2.put("gte", startPrice); + } + if (endPrice != null) { + temp2.put("lte", endPrice); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(sort)){ - JSONObject jsonOrder = new JSONObject(); - if(order){ - jsonOrder.put("order", "asc"); - }else{ - jsonOrder.put("order", "desc"); - } - JSONObject jsonSort = new JSONObject(); - jsonSort.put(sort, jsonOrder); - List sortJsonList = new ArrayList(); - sortJsonList.add(jsonSort); - reqBody.put("sort", sortJsonList); - } + if (StringUtils.isNotBlank(sort)) { + JSONObject jsonOrder = new JSONObject(); + if (order) { + jsonOrder.put("order", "asc"); + } else { + jsonOrder.put("order", "desc"); + } + JSONObject jsonSort = new JSONObject(); + jsonSort.put(sort, jsonOrder); + List sortJsonList = new ArrayList(); + sortJsonList.add(jsonSort); + reqBody.put("sort", sortJsonList); + } - if(start >= 0){ + if (start >= 0) { reqBody.put("from", start); } - if(limit >= 0){ + if (limit >= 0) { reqBody.put("size", limit); } @@ -544,239 +544,241 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i query.put("must", jsonList); q.put("bool", query); reqBody.put("query", q); - //用户名:密码 + //用户名:密码 Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); HttpRequest request = new HttpRequest(); Map headers = new HashMap(); headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); try { - String response = request.postWithBody("http://es.fangjia.com:9200/"+table+"/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + String response = request.postWithBody("http://es.fangjia.com:9200/" + table + "/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); JSONObject json = JSONObject.fromObject(response); long time2 = System.currentTimeMillis(); - System.out.println(time2-time1); + System.out.println(time2 - time1); return json; } catch (HttpRequestException e) { e.printStackTrace(); } return null; - } + } - private JSONObject query(SeawaterQuery query){ - long time1 = System.currentTimeMillis(); - JSONObject reqBody = new JSONObject(); - JSONObject q = new JSONObject(); - JSONObject queryJson = new JSONObject(); - List jsonList = new ArrayList(); - Double lat = query.getLat(); - Double lng = query.getLng(); - Integer radius = query.getRadius(); - JSONObject filter = new JSONObject(); - // 添加地理位置过滤器和排序 - if (lat != null && lng != null && radius != null) { - // 1. 设置地理位置参数 - JSONObject geoDistanceParam = new JSONObject(); - geoDistanceParam.put("lat", lat); - geoDistanceParam.put("lon", lng); + private JSONObject query(SeawaterQuery query) { + long time1 = System.currentTimeMillis(); + JSONObject reqBody = new JSONObject(); + JSONObject q = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + Double lat = query.getLat(); + Double lng = query.getLng(); + Integer radius = query.getRadius(); + JSONObject filter = new JSONObject(); + // 添加地理位置过滤器和排序 + if (lat != null && lng != null && radius != null) { + // 1. 设置地理位置参数 + JSONObject geoDistanceParam = new JSONObject(); + geoDistanceParam.put("lat", lat); + geoDistanceParam.put("lon", lng); - // 2. 设置 geo_distance 过滤器,限制结果在指定的半径范围内 + // 2. 设置 geo_distance 过滤器,限制结果在指定的半径范围内 - JSONObject geoDistance = new JSONObject(); - geoDistance.put("distance", radius + "m"); // 半径设置为 3000km - geoDistance.put("location", geoDistanceParam); // 使用给定的经纬度 - filter.put("geo_distance", geoDistance); + JSONObject geoDistance = new JSONObject(); + geoDistance.put("distance", radius + "m"); // 半径设置为 3000km + geoDistance.put("location", geoDistanceParam); // 使用给定的经纬度 + filter.put("geo_distance", geoDistance); - // 3. 构建查询体 + // 3. 构建查询体 // filter.put("filter", geoDistanceFilter); // jsonList.add(filter); // reqBody.put("query", filter); - // 4. 添加按距离排序的部分 - JSONObject geoDistanceSort = new JSONObject(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("order", "asc"); - jsonObject.put("location", geoDistanceParam); - jsonObject.put("unit", "m"); - jsonObject.put("distance_type", "arc"); - geoDistanceSort.put("_geo_distance", jsonObject); - // 5. 将排序部分添加到请求体 - List sortJsonList = new ArrayList(); - sortJsonList.add(geoDistanceSort); - reqBody.put("sort", sortJsonList); - } - if(StringUtils.isNotBlank(query.getId())) { - JSONObject param = new JSONObject(); - param.put("_id", query.getId()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getCat())) { - JSONObject param = new JSONObject(); - param.put("cat", query.getCat()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + // 4. 添加按距离排序的部分 + JSONObject geoDistanceSort = new JSONObject(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("order", "asc"); + jsonObject.put("location", geoDistanceParam); + jsonObject.put("unit", "m"); + jsonObject.put("distance_type", "arc"); + geoDistanceSort.put("_geo_distance", jsonObject); + // 5. 将排序部分添加到请求体 + List sortJsonList = new ArrayList(); + sortJsonList.add(geoDistanceSort); + reqBody.put("sort", sortJsonList); + } + if (StringUtils.isNotBlank(query.getId())) { + JSONObject param = new JSONObject(); + param.put("_id", query.getId()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getCat())) { + JSONObject param = new JSONObject(); + param.put("cat", query.getCat()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getDistrictName())) { - namesList.add(query.getDistrictName()); - } - if (query.getDistrictAlias() != null) { - namesList.addAll(query.getDistrictAlias()); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set namesList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getDistrictName())) { + namesList.add(query.getDistrictName()); + } + if (query.getDistrictAlias() != null) { + namesList.addAll(query.getDistrictAlias()); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getRegion())) { - regionsList.add(query.getRegion()); - } - if (query.getRegionAlias() != null) { - regionsList.addAll(query.getRegionAlias()); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getRegion())) { + regionsList.add(query.getRegion()); + } + if (query.getRegionAlias() != null) { + regionsList.addAll(query.getRegionAlias()); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getCityDisplay())){ - JSONObject param = new JSONObject(); - param.put("city", query.getCityDisplay()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getEstateType())) { - JSONObject param = new JSONObject(); - param.put("estate_type", query.getEstateType()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(query.getRoom() != null) { - JSONObject param = new JSONObject(); - param.put("room", query.getRoom()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getRootName())) { - JSONObject param = new JSONObject(); - param.put("root", query.getRootName()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(query.getCityDisplay())) { + JSONObject param = new JSONObject(); + param.put("city", query.getCityDisplay()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getEstateType())) { + JSONObject param = new JSONObject(); + param.put("estate_type", query.getEstateType()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (query.getRoom() != null) { + JSONObject param = new JSONObject(); + param.put("room", query.getRoom()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getRootName())) { + JSONObject param = new JSONObject(); + param.put("root", query.getRootName()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - if(query.getStartDate() != null || query.getEndDate() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartDate() != null){ - temp2.put("gte", query.getStartDate()); - } - if(query.getEndDate() != null){ - temp2.put("lte", query.getEndDate()); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartDate() != null || query.getEndDate() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartDate() != null) { + temp2.put("gte", query.getStartDate()); + } + if (query.getEndDate() != null) { + temp2.put("lte", query.getEndDate()); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartArea() != null || query.getEndArea() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartArea() != null){ - temp2.put("gte", query.getStartArea()); - } - if(query.getEndArea() != null){ - temp2.put("lte", query.getEndArea()); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartArea() != null || query.getEndArea() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartArea() != null) { + temp2.put("gte", query.getStartArea()); + } + if (query.getEndArea() != null) { + temp2.put("lte", query.getEndArea()); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartPrice() != null || query.getEndPrice() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartPrice() != null){ - temp2.put("gte", query.getStartPrice()); - } - if(query.getEndPrice() != null){ - temp2.put("lte", query.getEndPrice()); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartPrice() != null || query.getEndPrice() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartPrice() != null) { + temp2.put("gte", query.getStartPrice()); + } + if (query.getEndPrice() != null) { + temp2.put("lte", query.getEndPrice()); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getSortField())){ - JSONObject jsonOrder = new JSONObject(); - if(query.getOrder()){ - jsonOrder.put("order", "asc"); - }else{ - jsonOrder.put("order", "desc"); - } - JSONObject jsonSort = new JSONObject(); - jsonSort.put(query.getSortField(), jsonOrder); - List sortJsonList = new ArrayList(); - sortJsonList.add(jsonSort); - reqBody.put("sort", sortJsonList); - } + if (StringUtils.isNotBlank(query.getSortField())) { + JSONObject jsonOrder = new JSONObject(); + if (query.getOrder()) { + jsonOrder.put("order", "asc"); + } else { + jsonOrder.put("order", "desc"); + } + JSONObject jsonSort = new JSONObject(); + jsonSort.put(query.getSortField(), jsonOrder); + List sortJsonList = new ArrayList(); + sortJsonList.add(jsonSort); + reqBody.put("sort", sortJsonList); + } - if(query.getPager().getStartRow() >= 0){ - reqBody.put("from", query.getPager().getStartRow()); - } - if(query.getPager().getPageSize() >= 0){ - reqBody.put("size", query.getPager().getPageSize()); - } + if (query.getPager().getStartRow() >= 0) { + reqBody.put("from", query.getPager().getStartRow()); + } + if (query.getPager().getPageSize() >= 0) { + reqBody.put("size", query.getPager().getPageSize()); + } - if(query.getStatus() != null){ - JSONObject param = new JSONObject(); - param.put("status", query.getStatus()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (query.getStatus() != null) { + JSONObject param = new JSONObject(); + param.put("status", query.getStatus()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - queryJson.put("must", jsonList); - ArrayList filterList = new ArrayList(); - filterList.add(filter); - queryJson.put("filter", filterList); - q.put("bool", queryJson); - reqBody.put("query", q); - //用户名:密码 - Base64 token = new Base64(); - String authenticationEncoding = token.encodeAsString(new String(""+ES_USER+":"+ES_PASSWORD+"").getBytes()); - HttpRequest request = new HttpRequest(); - Map headers = new HashMap(); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", "Basic "+authenticationEncoding+""); - try { - String response = request.postWithBody("http://es.fangjia.com:9200/"+query.getTable()+"/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); - JSONObject json = JSONObject.fromObject(response); - long time2 = System.currentTimeMillis(); - System.out.println(time2-time1); - return json; - } catch (HttpRequestException e) { - e.printStackTrace(); - } - return null; - } + queryJson.put("must", jsonList); + ArrayList filterList = new ArrayList(); + if (filter.size() > 0) { + filterList.add(filter); + queryJson.put("filter", filterList); + } + q.put("bool", queryJson); + reqBody.put("query", q); + //用户名:密码 + Base64 token = new Base64(); + String authenticationEncoding = token.encodeAsString(new String("" + ES_USER + ":" + ES_PASSWORD + "").getBytes()); + HttpRequest request = new HttpRequest(); + Map headers = new HashMap(); + headers.put("Content-Type", "application/json"); + headers.put("Authorization", "Basic " + authenticationEncoding + ""); + try { + String response = request.postWithBody("http://es.fangjia.com:9200/" + query.getTable() + "/_search?rest_total_hits_as_int=true", reqBody, headers, "UTF-8"); + JSONObject json = JSONObject.fromObject(response); + long time2 = System.currentTimeMillis(); + System.out.println(time2 - time1); + return json; + } catch (HttpRequestException e) { + e.printStackTrace(); + } + return null; + } // private List queryList(String id,String category, String city, String region, String name, List alias, // List regionAlias, Integer startDate, Integer endDate, Double startArea, Double endArea, Integer startPrice, Integer endPrice, Integer room, String root,String sort, boolean order, int start, int limit,String table){ @@ -793,188 +795,188 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl i // return results; // } - private List queryList(SeawaterQuery query){ - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){ - return null; - } - JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); - List results = new ArrayList(); - for(int i=0 ;i < hits.size(); i++){ - JSONObject jsonObject = hits.getJSONObject(i); - results.add(jsonObject); - } - return results; - } + private List queryList(SeawaterQuery query) { + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) { + return null; + } + JSONArray hits = json.getJSONObject("hits").getJSONArray("hits"); + List results = new ArrayList(); + for (int i = 0; i < hits.size(); i++) { + JSONObject jsonObject = hits.getJSONObject(i); + results.add(jsonObject); + } + return results; + } - private int queryCount(String id,String category, String city, String region, String name, List alias, - List regionAlias, Integer startDate, Integer endDate, Integer room, String root,String sort, boolean order, int start, int limit,String table){ - SeawaterQuery query = new SeawaterQuery(); - query.setCat(category); - query.setCityDisplay(city); - query.setRegion(region); - query.setDistrictName(name); - query.setDistrictAlias(alias); - query.setRegionAlias(regionAlias); - query.setStartDate(startDate); - query.setEndDate(endDate); - query.setRoom(room); - query.setRootName(root); - query.setOrder(order); - Pager pager = new Pager(); - pager.setStartRow(start); - pager.setPageSize(limit); - query.setPager(pager); - query.setTable(table); - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){ + private int queryCount(String id, String category, String city, String region, String name, List alias, + List regionAlias, Integer startDate, Integer endDate, Integer room, String root, String sort, boolean order, int start, int limit, String table) { + SeawaterQuery query = new SeawaterQuery(); + query.setCat(category); + query.setCityDisplay(city); + query.setRegion(region); + query.setDistrictName(name); + query.setDistrictAlias(alias); + query.setRegionAlias(regionAlias); + query.setStartDate(startDate); + query.setEndDate(endDate); + query.setRoom(room); + query.setRootName(root); + query.setOrder(order); + Pager pager = new Pager(); + pager.setStartRow(start); + pager.setPageSize(limit); + query.setPager(pager); + query.setTable(table); + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")) { return 0; } return json.getJSONObject("hits").getInt("total"); - } + } - private int queryCount(SeawaterQuery query){ - JSONObject json = query(query); - if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")){ - return 0; - } - return json.getJSONObject("hits").getInt("total"); - } + private int queryCount(SeawaterQuery query) { + JSONObject json = query(query); + if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("total")) { + return 0; + } + return json.getJSONObject("hits").getInt("total"); + } - private JSONObject wrapQueryParams(SeawaterQuery query){ - JSONObject reqBody = new JSONObject(); - JSONObject q = new JSONObject(); - JSONObject queryJson = new JSONObject(); - List jsonList = new ArrayList(); - if(StringUtils.isNotBlank(query.getId())) { - JSONObject param = new JSONObject(); - param.put("_id", query.getId()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getCat())) { - JSONObject param = new JSONObject(); - param.put("cat", query.getCat()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + private JSONObject wrapQueryParams(SeawaterQuery query) { + JSONObject reqBody = new JSONObject(); + JSONObject q = new JSONObject(); + JSONObject queryJson = new JSONObject(); + List jsonList = new ArrayList(); + if (StringUtils.isNotBlank(query.getId())) { + JSONObject param = new JSONObject(); + param.put("_id", query.getId()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getCat())) { + JSONObject param = new JSONObject(); + param.put("cat", query.getCat()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - Set namesList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getDistrictName())) { - namesList.add(query.getDistrictName()); - } - if(namesList != null && namesList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("district_name", namesList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set namesList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getDistrictName())) { + namesList.add(query.getDistrictName()); + } + if (namesList != null && namesList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("district_name", namesList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - Set regionsList = new LinkedHashSet(); - if(StringUtils.isNotBlank(query.getRegion())) { - regionsList.add(query.getRegion()); - } - if (query.getRegionAlias() != null) { - regionsList.addAll(query.getRegionAlias()); - } - if(regionsList != null && regionsList.size() > 0){ - JSONObject param = new JSONObject(); - param.put("region", regionsList); - JSONObject temp = new JSONObject(); - temp.put("terms", param); - jsonList.add(temp); - } + Set regionsList = new LinkedHashSet(); + if (StringUtils.isNotBlank(query.getRegion())) { + regionsList.add(query.getRegion()); + } + if (query.getRegionAlias() != null) { + regionsList.addAll(query.getRegionAlias()); + } + if (regionsList != null && regionsList.size() > 0) { + JSONObject param = new JSONObject(); + param.put("region", regionsList); + JSONObject temp = new JSONObject(); + temp.put("terms", param); + jsonList.add(temp); + } - if(StringUtils.isNotBlank(query.getCityDisplay())){ - JSONObject param = new JSONObject(); - param.put("city", query.getCityDisplay()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getEstateType())) { - JSONObject param = new JSONObject(); - param.put("estate_type", query.getEstateType()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(query.getRoom() != null) { - JSONObject param = new JSONObject(); - param.put("room", query.getRoom()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } - if(StringUtils.isNotBlank(query.getRootName())) { - JSONObject param = new JSONObject(); - param.put("root", query.getRootName()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (StringUtils.isNotBlank(query.getCityDisplay())) { + JSONObject param = new JSONObject(); + param.put("city", query.getCityDisplay()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getEstateType())) { + JSONObject param = new JSONObject(); + param.put("estate_type", query.getEstateType()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (query.getRoom() != null) { + JSONObject param = new JSONObject(); + param.put("room", query.getRoom()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } + if (StringUtils.isNotBlank(query.getRootName())) { + JSONObject param = new JSONObject(); + param.put("root", query.getRootName()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - if(query.getStartDate() != null || query.getEndDate() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartDate() != null){ - temp2.put("gte", query.getStartDate()); - } - if(query.getEndDate() != null){ - temp2.put("lte", query.getEndDate()); - } - param.put("p_date", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartDate() != null || query.getEndDate() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartDate() != null) { + temp2.put("gte", query.getStartDate()); + } + if (query.getEndDate() != null) { + temp2.put("lte", query.getEndDate()); + } + param.put("p_date", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartArea() != null || query.getEndArea() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartArea() != null){ - temp2.put("gte", query.getStartArea()); - } - if(query.getEndArea() != null){ - temp2.put("lte", query.getEndArea()); - } - param.put("area", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartArea() != null || query.getEndArea() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartArea() != null) { + temp2.put("gte", query.getStartArea()); + } + if (query.getEndArea() != null) { + temp2.put("lte", query.getEndArea()); + } + param.put("area", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStartPrice() != null || query.getEndPrice() != null){ - JSONObject param = new JSONObject(); - JSONObject temp = new JSONObject(); - JSONObject temp2 = new JSONObject(); - if(query.getStartPrice() != null){ - temp2.put("gte", query.getStartPrice()); - } - if(query.getEndPrice() != null){ - temp2.put("lte", query.getEndPrice()); - } - param.put("avg_price", temp2); - temp.put("range", param); - jsonList.add(temp); - } + if (query.getStartPrice() != null || query.getEndPrice() != null) { + JSONObject param = new JSONObject(); + JSONObject temp = new JSONObject(); + JSONObject temp2 = new JSONObject(); + if (query.getStartPrice() != null) { + temp2.put("gte", query.getStartPrice()); + } + if (query.getEndPrice() != null) { + temp2.put("lte", query.getEndPrice()); + } + param.put("avg_price", temp2); + temp.put("range", param); + jsonList.add(temp); + } - if(query.getStatus() != null){ - JSONObject param = new JSONObject(); - param.put("status", query.getStatus()); - JSONObject temp = new JSONObject(); - temp.put("term", param); - jsonList.add(temp); - } + if (query.getStatus() != null) { + JSONObject param = new JSONObject(); + param.put("status", query.getStatus()); + JSONObject temp = new JSONObject(); + temp.put("term", param); + jsonList.add(temp); + } - queryJson.put("must", jsonList); - q.put("bool", queryJson); - reqBody.put("query", q); - return reqBody; - } + queryJson.put("must", jsonList); + q.put("bool", queryJson); + reqBody.put("query", q); + return reqBody; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/HouseController.java index 68e6d22d3..84994dbee 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 @@ -1150,11 +1150,11 @@ public class HouseController { public Object rentAction(final HouseSearchModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); - if (model.getSize()<0) { + if (model.getSize()!= null && model.getSize()<0) { mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); return mav; } - if (StringUtils.isNotBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { mav.setModel(BasicModel.buildBadRequestModel("城市(city),区域(district),小区名(name)为必填参数")); return mav; } From 2c1f3c043a81bca353348f75f1b8065e27a26686 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 16:25:31 +0800 Subject: [PATCH 158/230] update --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index d65f086bf..3dc4ffbca 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -361,7 +361,7 @@ class NewGaoDePoiBatch extends BaseBatch{ // if(!cityObj.city.contains("固原")){ // continue // } - def fileName = "/home/goojia/gj/poi/old_poi/${cityObj.city}.csv" + def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" } From 6c2b70c18f7520c521f1f8d74e5a471012c8cb11 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 19 Dec 2024 16:50:36 +0800 Subject: [PATCH 159/230] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/NewGaoDePoiBatch.groovy | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 3dc4ffbca..29c5560d4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -439,12 +439,17 @@ class NewGaoDePoiBatch extends BaseBatch{ def esValue = regionMap.get(key) if(esValue.township && ret.township){ if(esValue.name.contains(ret.name) || ret.name.contains(esValue.name)){//|| - def distance = GeoUtils.calculateDistance(ret.location.lon, ret.location.lat, esValue.location.lon, esValue.location.lat); - if(distance <100){ - simlarObj = esValue - println esValue.name +" "+ret.name+" "+distance - break; + if(ret.location && ret.location.lon){ + def distance = GeoUtils.calculateDistance(ret.location.lon, ret.location.lat, esValue.location.lon, esValue.location.lat); + if(distance <100){ + simlarObj = esValue + println esValue.name +" "+ret.name+" "+distance + break; + } + }else{ + println ret.data_id +" 无经纬度信息" } + } } } From db1208eac37ae8230c62a7d62e98a074bb041ed7 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 20 Dec 2024 11:33:10 +0800 Subject: [PATCH 160/230] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/DistrictController.java | 139 +++++++++++++++--- .../src/main/webapp/district/hidelist.ftl | 138 ++++++++++++++--- .../src/main/webapp/index.ftl | 2 +- 3 files changed, 244 insertions(+), 35 deletions(-) diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java index 23728998e..0e25c9471 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/DistrictController.java @@ -325,7 +325,85 @@ public class DistrictController { return model.redirectPermanently(model.getCityUrl() + "/ershoufang/" + URLEncoder.encode(model.getKeyword(), "UTF-8") + "--"); } - /*if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { +// if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { +// return model.redirectPermanently("http://www.fangjia.com"); +// } + +// Pager pager = model.getPager(20); +// pager.setMaxPage(FangjiaConfig.getConfig().getSearchListMaxPageNo()); +// +// // 小区列表支持新盘搜索 +// model.setCategory("district"); +// Object obj = FangjiaRudder.listMan(model.getKeyword()); +// if (obj != null) { +// return obj; +// } +// +// String city = ((ServerArea) FangjiaServerAreaContextHolder.getServerAreaDefault()).getDisplay(); +// Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, +// getCurrentParams(), 1); +// model.setMenu(menu); +// +// FacetQueryResult result; +// DistrictQueryBean queryBean = modelToBean(model); +// queryBean.setCity(city); +// +// // 老网站的URL中区域是带“区”的 +// if (StringUtils.isNotBlank(queryBean.getRegion())) { +// List gList = menu.getGroupList(); +// for (Group g : gList) { +// if (!"region".equals(g.getName())) { +// continue; +// } +// +// List iList = g.getItemList(); +// for (Item i : iList) { +// if (i.isSelected()) { +// queryBean.setRegion(i.getName()); +// break; +// } +// } +// break; +// } +// } +// +// if (StringUtils.isBlank(model.getKeyword())) { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, "bscore", false, false); +// } else { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, null, false, false); +// if (result.getNumberFound() <= 0) { +// result = districtService.findByQueryBeanWithFacet(menu, pager, queryBean, null, false, false, true); +// } +// } +// +// List districtList = districtService.processDistrictInfo(result.getEntityResults(), model.getKeyword()); +// model.setDistrictList(districtList); +// if (StringUtils.isNotBlank(model.getKeyword()) && districtList.size() <= 3) { +// Map parseMap = knowbaseService.parseKeyword(model.getKeyword()); +// if (parseMap.get("district_name") != null) { +// List otherDistrictList = otherCitiesDistrict(model.getKeyword(), model.getKeyword()); +// model.setOtherDistrictList(otherDistrictList); +// } +// } +// +// pager.setTotalRows(result.getNumberFound()); +// model.setPager(pager); +// +// model.setConditions(menuService.getConditions(((ServerArea) FangjiaServerAreaContextHolder.getServerAreaDefault()), +// MenuCategoryEnum.xiaoqu, getCurrentParams())); +// model.setConditionItems(menuService.getConditionItems(FangjiaServerAreaContextHolder.getServerAreaDefault(), +// MenuCategoryEnum.xiaoqu, getCurrentParams())); +// +//// */ +//// * gasm统计 +//// */ +// model.addGaMap(Gakey.rc, pager.getTotalRows()); +// +// feedFooter(model); +// return model; + } + public Object hidelistAction(HttpServletRequest request,DistrictModel model) throws Exception { + if (sensitiveWordService.isSensitiveWord(model.getKeyword())) { return model.redirectPermanently("http://www.fangjia.com"); } @@ -394,26 +472,12 @@ public class DistrictController { model.setConditionItems(menuService.getConditionItems(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, getCurrentParams())); - *//** - * gasm统计 - *//* + model.addGaMap(Gakey.rc, pager.getTotalRows()); feedFooter(model); - return model;*/ - } - public Object hidelistAction(HttpServletRequest request,DistrictModel model) throws Exception { - if(StringUtils.isNotBlank(model.getCityName())){ - List params = new ArrayList(); - params.add(new QueryParam("visible", 0)); - params.add(new QueryParam("city", model.getCityName())); - params.add(new QueryParam("category", "district")); - List districts = districtService.findAllByParams(params, 0, 0,new String[]{"city", "region", "name"}); - model.setDistricts(districts); - CacheUtils.putValue(CacheUtils.CachePolicyEnum.NEXT_MONTH, this.getClass(), "district-hide-list-crawl-"+model.getCityName(), (Serializable) districts); - } - return model; + } /** @@ -1764,6 +1828,47 @@ public class DistrictController { // return model; } + + /** + * 小区信息 + * + * @param model + * @return + */ + @SuppressWarnings("unchecked") + public Object seoInfoAction(DistrictModel model) { + + District district = districtService.findDistrictById(model.getId()); + if (district == null) + return model; + + model.setCityName(district.getCity()); + model.setDistrictName(district.getName()); + model.setDistrictAddress(district.getAddress()); + model.setRegion(district.getRegion()); + model.setId(district.getId()); + model.setType(String.valueOf(model.getType())); + + + DistrictStatBo districtStatBo = districtStatService.findDistrictStat(new DistrictKey(district.getCity(), district.getRegion(), district.getName())); + if (null == districtStatBo || null == districtStatBo.getDefaultDistrictStat()) { + return model; + } + + int districtAvgPrice = 0; + int villaAvgPrice = 0; + if (null != districtStatBo.getDistrictStat()) { + districtAvgPrice = districtStatBo.getDistrictStat().getAvgPrice(); + } + if (null != districtStatBo.getVillaDistrictStat()) { + villaAvgPrice = districtStatBo.getVillaDistrictStat().getAvgPrice(); + } + model.setDistrictAvgPrice((Integer) (districtAvgPrice / 100) * 100); + model.setVillaAvgPrice((Integer) (villaAvgPrice / 100) * 100); + model.setDistrictStatBo(districtStatBo); + return model; + } + private List getSubList(List fullList, int start, int pageSize, int total) { if (start >= total) { return Collections.emptyList(); diff --git a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl index 9963b48ae..e3de86858 100644 --- a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl +++ b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl @@ -1,21 +1,125 @@ <#ftl attributes={"content_type":"text/html; charset=UTF-8"}> <#compress> - - - - <#include "../jsconstants.ftl" /> - - - - + + + - -
- <#list districts! as dist> - ${dist.name!} - -
-<#include "/analytics.ftl" /> - - + <#assign fangjiaShareContent = "鎴夸环缃戯細 鎻愪緵${cityName!}灏忓尯鎴夸环鍙婂湪鍞埧婧愶紝杩樻湁灏忓尯鍛ㄨ竟閰嶅鍙婃柊闂昏瘎璁猴紒" /> + <#assign title="${cityName}"> + <#assign keywords="${cityName}"> + <#assign descr="${cityName}鎴夸环缃戜负鎮ㄦ彁渚涚儹闂ㄥ皬鍖烘悳绱㈡湇鍔�"> + <#assign addedKeywords="false"> + + <#if region?exists && region != ''> + <#assign keywords="${keywords}${region}"> + <#assign descr="${descr!''}${region!''}"> + <#assign title="${title!''}${region!''}"> + <#assign addedKeywords="true"> + + + <#if keyword?exists && keyword != ''> + <#assign keywords="${keywords}${keyword}"> + <#assign descr="${descr!''}${keyword!''}"> + <#assign title="${title!''}${keyword!''}"> + <#assign addedKeywords="true"> + + + <#assign title="${title}"> + <#assign keywords="${keywords}灏忓尯,鐑棬灏忓尯鎼滅储"> + <#assign descr="${descr}浜屾墜鎴�"> + + <#if block?exists && block != ''> + <#assign title="${title!''}${block!''}鏉垮潡"> + <#assign keywords="${keywords!''}${block!''}鏉垮潡"> + <#assign descr="${descr!''}${block!''}鏉垮潡"> + <#assign addedKeywords="true"> + + + <#assign title2="${cityName}灏忓尯淇℃伅"> + <#if (conditions?? && conditions?size gt 0)> + <#list conditions as c> + <#assign title2="${title2}${c}"> + <#if c_has_next> + <#assign title2="${title2}_"> + <#else> + <#assign title2="${title2}闄勮繎灏忓尯鎴夸环"> + + + <#else> + <#assign title2="${cityName}灏忓尯淇℃伅"> + + + <#assign PAGE_TITLE>銆�${title2}銆� + <#assign PAGE_DESCRIPTION>${title2!''}灏忓尯鎼滅储, 鎴夸环缃戝悓鏃舵彁渚�${cityName!''}灏忓尯鎴夸环,灏忓尯鍦ㄥ敭浜屾墜鎴挎埧婧�,鏂版埧鎴挎簮,绉熸埧鎴挎簮.浠ュ強灏忓尯閰嶅璁炬柦,灏忓尯鐩稿叧鏂伴椈绛夊唴瀹�. + <#assign PAGE_KEYWORDS>${keywords!''}锛屾埧浠风綉 + <#assign GA_PAGEVIEW_PATH = "/district/list/${fullQueryString}" /> + <#include "/header/head.ftl" /> + + + + + + + + + + + + <#include "../jsconstants.ftl" /> + + + + + <#include "/header/v6/_header.ftl"/> +
+ <#if pager.totalRows gt 0> +
+ <@d_pager action="hidelist" currentPage=pager.currentPage controller="district" totalPages=pager.totalPages theme="topSearch" anchor="pagelist"/> +
+ + + +
+ <#if pager.totalRows gt pager.pageSize> +
+ <@d_pager action="hidelist" currentPage=pager.currentPage controller="district" totalPages=pager.totalPages anchor="pagelist"/> +
+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/projects/fangjia-coresite/src/main/webapp/index.ftl b/projects/fangjia-coresite/src/main/webapp/index.ftl index 99dd2f6bd..356dea3ad 100644 --- a/projects/fangjia-coresite/src/main/webapp/index.ftl +++ b/projects/fangjia-coresite/src/main/webapp/index.ftl @@ -965,7 +965,7 @@ - + <#include "/header/v6/_footer.ftl"/> From f0d1afa7fac8d99bfeeff76f636e8b9093a0e246 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 20 Dec 2024 11:48:51 +0800 Subject: [PATCH 161/230] update --- .../fangjia/coresite/model/DistrictModel.java | 10 ++ .../src/main/webapp/district/seoInfo.ftl | 111 +++++++++++++++ .../houseReport/district_around_map2.ftl | 128 ++++++++++++++++++ .../main/webapp/style/fangjia/v6/seoInfo.css | 37 +++++ 4 files changed, 286 insertions(+) create mode 100644 projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl create mode 100644 projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl create mode 100644 projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java index 5ac69e8ef..2e5f579d3 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/DistrictModel.java @@ -140,6 +140,8 @@ public class DistrictModel extends BaseModel { private int allPicCount; private List districts; + private String type; + public boolean isHousePriceInfo() { return housePriceInfo; } @@ -787,4 +789,12 @@ public class DistrictModel extends BaseModel { public void setDistricts(List districts) { this.districts = districts; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl b/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl new file mode 100644 index 000000000..076a12008 --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/district/seoInfo.ftl @@ -0,0 +1,111 @@ + +<#compress> + + + + <#include "../jsconstants.ftl" /> + + + + + + + + + + + + + + + + +<#include "/header/v6/_header.ftl"/> + + +
+
+
+
+
+

+

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

+
+
+
  • 灏忓尯鍧囦环
  • 56565鍏�/銕�
+
  • 鐜瘮
  • 3.6
+
  • 鍚屾瘮
  • 12.3
+
+
+ + <#include "../houseReport/district_price.ftl"/> + + + <#include "../houseReport/district_around_map2.ftl"/> +
+
+
+<#include "/header/v6/_footer.ftl"/> + + + +<#----> +<#----> + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl b/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl new file mode 100644 index 000000000..4b1b758da --- /dev/null +++ b/projects/fangjia-coresite/src/main/webapp/houseReport/district_around_map2.ftl @@ -0,0 +1,128 @@ + + + + + +
+
灏忓尯鍛ㄨ竟閰嶅 +<#-- --> +
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css new file mode 100644 index 000000000..83c2d72fe --- /dev/null +++ b/projects/fangjia-static/src/main/webapp/style/fangjia/v6/seoInfo.css @@ -0,0 +1,37 @@ +@charset "utf-8"; +/* CSS Document */ +.main { width: 1200px;margin: auto; margin-top: 100px;overflow: hidden;position: relative;} +.main_left {margin: auto;} +.topic {padding: 40px 0;border-bottom: solid 1px #e5e5e5;} +.topic_top {font-size: 18px;margin-bottom: 20px;align-items: center;display: flex;float: left;} +.topic_top i {width: 30px;height: 36px;display: inline-flex;background: url(../../../images/fangjia/v6/4-2-13.png) no-repeat left bottom;margin-left: -10px;} +.overview01 .overview_left{margin-bottom: 80px;} +.overview01 .overview_left p { margin-bottom: 10px;width: 100%; text-align: justify;font-size: 20px;line-height: 30px;} +.overview01 .overview_left p label {color: #3c3f46;font-size: 24px;font-weight: 500;} +.overview01 .overview_left p i {width: 11px;height: 30px;background: url(../../../images/fangjia/v6/address.png) no-repeat center center;float: left;margin-right: 5px;} +.overview01 .overview_left p{font-size: 16px;} + +.price_div{display: flex;float: left;flex-direction: row;justify-content: flex-start;width: 1200px; margin: auto auto; padding-bottom: 10px;} +.price_div ul{width:25%;} +.price_div ul li{color: #878682;} +.price_div ul li .unit_price{color: #db4c3f;font-size: 32px;font-weight: bold;line-height: 50px;} +.price_div ul li .dw{color: #db4c3f;font-size: 16px;} +.price_div ul li .up{ color: #db4c3f;} +.price_div ul li .down{color:#00ae66;} +.price_div ul li .hb_tb{font-size: 22px;line-height: 50px;} +.price_div ul li .down i {background: url(../../../images/fangjia/v6/down.png) no-repeat left center;} +.price_div ul li .up i {background: url(../../../images/fangjia/v6/up.png) no-repeat left center;} + + +.districtMap{width:100%;height:400px;} +/* 鍦板浘鏍峰紡 */ +.mark-icon-box .mark-icon {width: 20px;height: 30px;display: block;cursor: pointer;font-size: 14px;color: #fff;font-weight: bold;text-align: center;line-height: 24px;background: url(../../../images/fangjia/v5/dw.png) no-repeat;} +.mark-icon-box { width: 24px; height: 30px; position: absolute; z-index: 98; } +.mark-icon-box .mark-icon:hover, .mark-icon-box .mark-icon-h { background: url(../../../images/fangjia/v5/dw_h.png) no-repeat ; } + +.mark-tip {font-size: 14px;position: absolute;z-index: 99;margin-top: -74px;margin-left: -20px;} +.mark-tip .title1 {line-height: 20px;color: #000;background: #fff;padding: 5px 40px 5px 15px;border-radius: 5px;box-shadow: 3px 3px 8px #888;height: 20px;} +.mark-tip .title1 span {display: inline-block;max-width: 170px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;margin-right: 25px;} +.mark-tip .title1 b { font-weight: normal; display: block; position: absolute; top: 5px; right: 10px; } +.mark-tip .icon { width: 21px; height:14px; background: url(../../../images/fangjia/v5/sj.png) no-repeat ; position: absolute; bottom: -14px; left: 20px; } + From 9bbe22212ab431f53d79d5b2f17287871ef36523 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 20 Dec 2024 13:24:01 +0800 Subject: [PATCH 162/230] css update --- .../fangjia-coresite/src/main/webapp/district/hidelist.ftl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl index e3de86858..7c88e857e 100644 --- a/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl +++ b/projects/fangjia-coresite/src/main/webapp/district/hidelist.ftl @@ -67,6 +67,9 @@ <#include "../jsconstants.ftl" /> - + +銆� +
diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index f9bc96179..8abcd7c2a 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -14,16 +14,25 @@ - + +銆� +
-
+
diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl index 7ba706719..286d93991 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl @@ -16,11 +16,20 @@ - + +銆� +
From 73076f0b2204cf2c36f50de6efd1496331a439da Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 20 Dec 2024 17:58:57 +0800 Subject: [PATCH 165/230] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=8A=E4=B8=80=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/district/districtDetail.ftl | 7 +++++++ .../src/main/webapp/report/downloadList.ftl | 15 ++++++++++++++- .../src/main/webapp/weiXinEvaluation/form.ftl | 7 +++++++ .../main/webapp/weiXinEvaluation/recordList.ftl | 17 ++++++++++++++--- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl index ad794d865..fd925c430 100644 --- a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl +++ b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl @@ -211,6 +211,13 @@ $(function(){initMap();}); + + if (typeof WeixinJSBridge !== "undefined") { + WeixinJSBridge.on('menu:back', function () { + window.history.back(); // 杩斿洖涓婁竴椤� + }); + } + diff --git a/projects/fangjia-open/src/main/webapp/report/downloadList.ftl b/projects/fangjia-open/src/main/webapp/report/downloadList.ftl index 55d2fbd97..f54286437 100644 --- a/projects/fangjia-open/src/main/webapp/report/downloadList.ftl +++ b/projects/fangjia-open/src/main/webapp/report/downloadList.ftl @@ -13,10 +13,23 @@ + -
+ +銆� + +
diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index 8abcd7c2a..1da5a0547 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -436,6 +436,13 @@ } }) }) + + if (typeof WeixinJSBridge !== "undefined") { + WeixinJSBridge.on('menu:back', function () { + window.history.back(); // 杩斿洖涓婁竴椤� + }); + } + diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl index 93cc7a993..cf6070a5c 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/recordList.ftl @@ -13,11 +13,22 @@ - + - + +銆� + -
+
From aa6ec4e50ae29a97b9ef54bd06f7d34cbde388e0 Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 20 Dec 2024 18:13:48 +0800 Subject: [PATCH 166/230] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=8A=E4=B8=80=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/webapp/district/districtDetail.ftl | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl index fd925c430..32a704887 100644 --- a/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl +++ b/projects/fangjia-open/src/main/webapp/district/districtDetail.ftl @@ -134,6 +134,7 @@ + From 0e723d4bbac94bedc30e0c9bb49783c8e630bed8 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Dec 2024 10:26:39 +0800 Subject: [PATCH 167/230] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=8A=A0?= =?UTF-8?q?=E8=AE=B0=E4=BD=8F=E5=AF=86=E7=A0=81=EF=BC=883=E5=A4=A9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/user/aiLoginPage.ftl | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl index 67948a07a..faf18a1c5 100644 --- a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -88,6 +88,47 @@ } return true; } + // 璁剧疆 Cookie 鍑芥暟 + function setLoginCookie(username, token) { + var expirationDate = new Date(); + expirationDate.setTime(expirationDate.getTime() + (3 * 24 * 60 * 60 * 1000)); // 3澶╁悗杩囨湡 + var expires = "expires=" + expirationDate.toUTCString(); + + // 灏嗙敤鎴蜂俊鎭紙鐢ㄦ埛鍚嶅拰 token锛夊瓨鍏� Cookie + document.cookie = "login_username=" + encodeURIComponent(username) + ";" + expires + ";path=/"; + document.cookie = "login_token=" + encodeURIComponent(token) + ";" + expires + ";path=/"; + } + + // 鑾峰彇 Cookie 涓殑鍊� + function getCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return decodeURIComponent(c.substring(nameEQ.length, c.length)); + } + return null; + } + + // 妫�鏌ョ櫥褰曠姸鎬� + function checkLoginStatus() { + var username = getCookie("login_username"); + var token = getCookie("login_token"); + + if (username && token) { + // 鑷姩鐧诲綍 + console.log("鑷姩鐧诲綍鐢ㄦ埛锛�" + username); + window.location.href = "reqCityChoicePage?type=gb"; + // 鍙互鍦ㄨ繖閲岀敤 token 楠岃瘉鐢ㄦ埛韬唤锛屾垨鑰呯洿鎺ヨ烦杞埌涓婚〉闈� + // 姣斿锛歸indow.location.href = 'dashboard.html'; + } else { + console.log("娌℃湁鐧诲綍淇℃伅锛岃烦杞埌鐧诲綍椤甸潰"); + // 濡傛灉娌℃湁鐧诲綍淇℃伅锛岃烦杞埌鐧诲綍椤甸潰 + // window.location.href = 'login.html'; + // window.location.href = "aiLoginPage"; + } + } $(".login_btn").click(function(){ var username = $("#username").val(); @@ -115,6 +156,8 @@ }); } }); + // 鍦ㄩ〉闈㈠姞杞芥椂妫�鏌ョ櫥褰曠姸鎬� + checkLoginStatus(); }); From 49160d7513eb49859427b020c64b9ea6c820317f Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Dec 2024 10:28:43 +0800 Subject: [PATCH 168/230] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=8A=A0?= =?UTF-8?q?=E8=AE=B0=E4=BD=8F=E5=AF=86=E7=A0=81=EF=BC=883=E5=A4=A9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl index faf18a1c5..600cf8f4b 100644 --- a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -119,7 +119,7 @@ if (username && token) { // 鑷姩鐧诲綍 console.log("鑷姩鐧诲綍鐢ㄦ埛锛�" + username); - window.location.href = "reqCityChoicePage?type=gb"; + window.location.href = "district/weXinList?type=gb"; // 鍙互鍦ㄨ繖閲岀敤 token 楠岃瘉鐢ㄦ埛韬唤锛屾垨鑰呯洿鎺ヨ烦杞埌涓婚〉闈� // 姣斿锛歸indow.location.href = 'dashboard.html'; } else { From 2845eaeb86011c7cbc862415ef6add59e8254a5e Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 23 Dec 2024 10:51:10 +0800 Subject: [PATCH 169/230] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=8A=A0?= =?UTF-8?q?=E8=AE=B0=E4=BD=8F=E5=AF=86=E7=A0=81=EF=BC=883=E5=A4=A9?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl index 600cf8f4b..cec747b40 100644 --- a/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl +++ b/projects/fangjia-open/src/main/webapp/user/aiLoginPage.ftl @@ -119,7 +119,7 @@ if (username && token) { // 鑷姩鐧诲綍 console.log("鑷姩鐧诲綍鐢ㄦ埛锛�" + username); - window.location.href = "district/weXinList?type=gb"; + window.location.href = "../district/weXinList?type=gb&cityName=涓婃捣"; // 鍙互鍦ㄨ繖閲岀敤 token 楠岃瘉鐢ㄦ埛韬唤锛屾垨鑰呯洿鎺ヨ烦杞埌涓婚〉闈� // 姣斿锛歸indow.location.href = 'dashboard.html'; } else { @@ -148,6 +148,7 @@ if(re.result == "fail"){ $.toast(re.msg); } else { + setLoginCookie(username, re.token); window.location.href = "reqCityChoicePage?type=gb"; } },error:function (data, status) { From d7ba02d699f618f9b442a02e6620842d12340113 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 23 Dec 2024 14:49:25 +0800 Subject: [PATCH 170/230] =?UTF-8?q?=E4=B8=8D=E5=9C=A8=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E6=88=90=E4=BA=A4=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/BigdataDealBatch.groovy index c65f09175..f6baf3541 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 @@ -71,8 +71,7 @@ class BigdataDealBatch extends BaseBatch{ for(def city : allCitys){ addDealPriceMatch(city); } - updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月 - +// updateCrawlTradeDate()//修改后抓取的成交,将时间改为本月 def rows = [] def headers = []//["城市ID","成交ID","城市名称","行政区ID","行政区名称","街道","门牌号","小区ID","小区名称","楼栋ID","楼栋编号","楼栋名称","单元ID","单元编号","单元名称","户ID","详细地址","建筑年代","权属","权属年限","期数","所在楼层","层类型","总楼层数","建筑类型","建筑结构","建筑面积","套内面积","户型","室","厅","厨","卫","房屋用途","室内结构","朝向","装修情况","评估编号","成交单价","成交总价","申报总价","评估总价","网签合同编号","交易日期","交易类型","出售付款方式","成交周期","是否有电梯","赠送面积(地面花园)","赠送面积(露台)","赠送面积(阳台)","赠送面积(飘窗)","赠送面积(阁楼)","赠送面积(车库)","赠送面积(地下室)","赠送面积(其他)","房源数据来源","中介公司ID","中介公司名称","备注","创建时间","更新时间","来源公司","成交金额","数据时间"] From 5a0529e1b76aa36752b0ef4eb7bdaf45e8419353 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 23 Dec 2024 18:10:40 +0800 Subject: [PATCH 171/230] =?UTF-8?q?poi=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/NewGaoDePoiBatch.groovy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 29c5560d4..046585431 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -46,8 +46,8 @@ class NewGaoDePoiBatch extends BaseBatch{ @Override void process(Object args) { -// run() - oldPoiMagre() + run() +// oldPoiMagre() } def run(){ @@ -323,7 +323,7 @@ class NewGaoDePoiBatch extends BaseBatch{ rows.each{map-> // def map = rows.get(key) - request.add(new IndexRequest("map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("gaode_map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); // 批量提交数据 if (request.numberOfActions() >= batchSize) { @@ -358,9 +358,9 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() for(def cityObj : cityList){ -// if(!cityObj.city.contains("固原")){ -// continue -// } + if(!cityObj.city.contains("五指山市")){ + continue + } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" From 4c6716694ed8dadb3f47edb7665f202ceaab2846 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 11:15:06 +0800 Subject: [PATCH 172/230] =?UTF-8?q?=E8=87=AA=E8=BA=AB=E6=88=BF=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/dal/seawater/model/Seawater.java | 2 +- .../open/controllers/HouseController.java | 138 ++++++- .../fangjia/open/model/BasicPageModel.java | 115 ++++++ .../open/model/DistrictFacilitysModel.java | 344 ++++++++++++++++++ .../fangjia/open/model/HouseSearchModel.java | 10 + 5 files changed, 599 insertions(+), 10 deletions(-) create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java create mode 100644 projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java index 225242e88..c553d2f46 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/seawater/model/Seawater.java @@ -234,7 +234,7 @@ public class Seawater implements SeawaterEntity { this.floor = floor; } - @Column(name = "floorInfo") + @Column(name = "floor_info") public String getFloorInfo() { return floorInfo; } 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 5c8ef119a..fba91b6eb 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 @@ -27,10 +27,7 @@ import com.fangjia.open.dto.UniversalDto; import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.BasicModel; -import com.fangjia.open.model.HousePublishModel; -import com.fangjia.open.model.HouseSearchModel; -import com.fangjia.open.model.RestfulModelAndView; +import com.fangjia.open.model.*; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.open.util.FileDao; import com.fangjia.open.ws.query.CollateralSampleQuery; @@ -1019,14 +1016,14 @@ public class HouseController { if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) { seawater.setTitle(name); } - if (cat.contains("office")){ + if (cat.contains("office")) { seawater.setLevel(house.getLevel()); } - if (cat.contains("shop")){ - if (StringUtils.isNotBlank(house.getEstateType()) && !"其他".equals(house.getEstateType())){ + if (cat.contains("shop")) { + if (StringUtils.isNotBlank(house.getEstateType()) && !"其他".equals(house.getEstateType())) { seawater.setShopType(house.getEstateType()); } - if (StringUtils.isNotBlank(house.getBusinessRange())){ + if (StringUtils.isNotBlank(house.getBusinessRange())) { seawater.setBusinessScope(house.getBusinessRange()); } } @@ -1147,10 +1144,11 @@ public class HouseController { mav.setViewType("rest"); return mav; } + public Object rentAction(final HouseSearchModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); - if (model.getSize()!= null && model.getSize()<0) { + if (model.getSize() != null && model.getSize() < 0) { mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); return mav; } @@ -1243,6 +1241,128 @@ public class HouseController { return mav; } + public Object resourcesAction(final HouseSearchModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getSize() != null && model.getSize() < 0) { + mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误")); + return mav; + } + if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) { + mav.setModel(BasicModel.buildBadRequestModel("城市(city),区域(district),小区名(name)为必填参数")); + return mav; + } + District property = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district"); + if (null == property) { + mav.setModel(BasicModel.buildBadRequestModel("未找到该小区")); + return mav; + } + // 没有输入时间范围,则是默认六个月的 + if (model.getStartTime() == null && model.getEndTime() == null) { + // 获取当前日期 + Calendar today = Calendar.getInstance(); + + // 复制一份当前日期,用于计算半年前的日期 + Calendar sixMonthsAgo = (Calendar) today.clone(); + + // 减去 6 个月 + sixMonthsAgo.add(Calendar.MONTH, -6); + + // 格式化日期为 yyyyMMdd + int todayInt = formatDate(today); + int sixMonthsAgoInt = formatDate(sixMonthsAgo); + model.setStartTime(sixMonthsAgoInt); + model.setEndTime(todayInt); + } + + List houses = null; + List houseList = new ArrayList(); + SeawaterQuery query = new SeawaterQuery(); + List catList = Arrays.asList("rent", "sell", "office_rent", "office_sell", "shop_sell", "shop_rent"); + if (!catList.contains(model.getCat())) { + model.setCat("rent"); + } + query.setCat(model.getCat()); + query.setStartDate(model.getStartTime()); + query.setEndDate(model.getEndTime()); + if (model.getSize() != null && model.getSize() != 0) { + query.setStartArea(model.getSize() * 0.9); + query.setEndArea(model.getSize() * 1.1); + } + query.setCityDisplay(model.getCity()); + query.setRegion(model.getDistrict()); + query.setDistrictName(model.getName()); + query.setDistrictAlias(property.getAlias()); + Pager pager = new Pager(); + // 没有查询数量,默认查前五个 + if (model.getPageIndex() == null) { + pager.setStartRow(0); + } else { + pager.setStartRow(model.getPageIndex()); + } + pager.setPageSize(model.getPageSize()); + query.setPager(pager); + query.setTable("latest_seawater"); + if (StringUtils.isNotBlank(model.getSortField())){ + query.setSortField(model.getSortField()); + }else { + query.setSortField("p_date"); + } + if ("asc".equals(model.getSortBy())) { + query.setOrder(true); + }else { + query.setOrder(false); + } + houses = seawaterDao.findSeawatersByQuery(query); + if (houses != null && !houses.isEmpty()) { + for (Seawater house : houses) { + Seawater seawater = new Seawater(); + seawater.setId(house.getId()); + seawater.setCity(house.getCity()); + seawater.setDistrict(house.getRegion()); + seawater.setAddress(house.getAddress()); + seawater.setName(house.getDistrictName()); + String name = house.getName(); + if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) { + seawater.setTitle(name); + } + seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea()); + seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); + seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); + seawater.setDirection(house.getDirection()); + seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); + seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); + seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); + seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); + seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); + seawater.setDecoration(house.getFitment()); + seawater.setFloorInfo(house.getFloorInfo()); + seawater.setRoot(house.getRoot()); + if (house.getpDate() != null && house.getpDate() > 10000000) { + String numberStr = String.valueOf(house.getpDate()); + // 拆分字符串并格式化 + String year = numberStr.substring(0, 4); // 前四位是年份 + String month = numberStr.substring(4, 6); // 中间两位是月份 + String day = numberStr.substring(6, 8); // 最后两位是日期 + String formattedDate = year + "-" + month + "-" + day; + seawater.setPublishDate(formattedDate); + } + houseList.add(seawater); + } + } + BasicPageModel pageModel = new BasicPageModel(200, "ok"); + pager.setPageSize(-1); + pager.setStartRow(-1); + query.setPager(pager); + long count = seawaterDao.findSeawatersCountByQuery(query); + pageModel.setTotal((int) count); + // 组装数据 + pageModel.setResult(houseList); + mav.setModel(pageModel); + mav.setViewType("rest"); + return mav; + } + Double sub6(Double a) { BigDecimal bd = new BigDecimal(a); BigDecimal bigDecimal = bd.setScale(6, BigDecimal.ROUND_DOWN); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java new file mode 100644 index 000000000..34512f434 --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/BasicPageModel.java @@ -0,0 +1,115 @@ +package com.fangjia.open.model; + +import com.fangjia.open.APIConstant; +import com.fangjia.open.HttpStatusCodeEnum; +import com.thoughtworks.xstream.annotations.XStreamAlias; +import org.sothis.web.mvc.ActionContext; + +@XStreamAlias("xml") +public class BasicPageModel { + + private int code; + + private String msg; + + private Object result; + + private String tid; + + private int total; + + public BasicPageModel(int code, String msg) { + super(); + this.code = code; + this.msg = msg; + } + + public BasicPageModel(HttpStatusCodeEnum status){ + this.code = status.getCode(); + this.msg = status.getMsg(); + } + + public static BasicPageModel buildOKModel() { + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.OK); + return model; + } + + public static BasicPageModel buildModel(int code, String msg){ + return new BasicPageModel( code, msg); + } + + public static BasicPageModel buildUnAuthorizedModel() { + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.UN_AUTHORIZED); + return model; + } + + public static BasicPageModel buildBadRequestModel(String msg){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.BAD_REQUEST); + model.setMsg(msg); + return model; + } + + public static BasicPageModel buildForbidModel(String msg){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.SERVER_FORBID); + model.setMsg(msg); + return model; + } + + + public static BasicPageModel buildServerErrorModel(){ + BasicPageModel model = new BasicPageModel(HttpStatusCodeEnum.SERVER_ERROR); + return model; + } + + public static void markNoDataRequest(){ + ActionContext.getContext().set(APIConstant.IS_RETURN_DATA, Boolean.FALSE); + } + + public BasicPageModel markNoData(){ + markNoDataRequest(); + return this; + } + + public int getCode() { + return code; + } + + public BasicPageModel setCode(int code) { + this.code = code; + return this; + } + + public String getMsg() { + return msg; + } + + public BasicPageModel setMsg(String msg) { + this.msg = msg; + return this; + } + + public Object getResult() { + return result; + } + + public BasicPageModel setResult(Object result) { + this.result = result; + return this; + } + + public void setTid(String tid) { + this.tid = tid; + } + + public String getTid() { + return tid; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java new file mode 100644 index 000000000..ddc05adec --- /dev/null +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java @@ -0,0 +1,344 @@ +package com.fangjia.open.model; + +import java.util.Date; +import java.util.List; + +/** + * 灏忓尯鍛ㄨ竟閰嶅 + */ +public class DistrictFacilitysModel { + private static final long serialVersionUID = -9200383212669643823L; + private String id; + private String city; + private String region; + private String districtName; + private List kindergarten; + private List primarySchool; + private List middleSchool; + private List university; + private List hospital; + private List shop; + private List supermarket; + private List foodShop; + private List bus; + private List metro; + private List bank; + private List atm; + private String innerFacilities; + private String carSite; + private String carSiteDes; + + private Double trafficScore; + private Double hospitalScore; + private Double shopScore; + private Double schoolScore; + private Double bankScore; + + private Date creationDate; + + private List positives; // 姝i潰 + private List negatives; // 璐熼潰 + private List appraisalNegative; // 璐熼潰 + private List appraisalPositive; // 姝i潰 + + /** + * 閺嶅洨顒峰妤�鍨� + */ + private Double traScore; + private Double virScore; + private Double aroScore; + private Double tradScore; + + private String imgUrl3D; + + private List school; + private List keySchool; + + public String getCity() { + return city; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getDistrictName() { + return districtName; + } + + public void setDistrictName(String districtName) { + this.districtName = districtName; + } + + public List getKindergarten() { + return kindergarten; + } + + public void setKindergarten(List kindergarten) { + this.kindergarten = kindergarten; + } + + public List getPrimarySchool() { + return primarySchool; + } + + public void setPrimarySchool(List primarySchool) { + this.primarySchool = primarySchool; + } + + public List getMiddleSchool() { + return middleSchool; + } + + public void setMiddleSchool(List middleSchool) { + this.middleSchool = middleSchool; + } + + public List getUniversity() { + return university; + } + + public void setUniversity(List university) { + this.university = university; + } + + public List getHospital() { + return hospital; + } + + public void setHospital(List hospital) { + this.hospital = hospital; + } + + public List getShop() { + return shop; + } + + public void setShop(List shop) { + this.shop = shop; + } + + public List getSupermarket() { + return supermarket; + } + + public void setSupermarket(List supermarket) { + this.supermarket = supermarket; + } + + public List getFoodShop() { + return foodShop; + } + + public void setFoodShop(List foodShop) { + this.foodShop = foodShop; + } + + public List getBus() { + return bus; + } + + public void setBus(List bus) { + this.bus = bus; + } + + public List getMetro() { + return metro; + } + + public void setMetro(List metro) { + this.metro = metro; + } + + public List getBank() { + return bank; + } + + public void setBank(List bank) { + this.bank = bank; + } + + public List getAtm() { + return atm; + } + + public void setAtm(List atm) { + this.atm = atm; + } + + public String getInnerFacilities() { + return innerFacilities; + } + + public void setInnerFacilities(String innerFacilities) { + this.innerFacilities = innerFacilities; + } + + public String getCarSite() { + return carSite; + } + + public void setCarSite(String carSite) { + this.carSite = carSite; + } + + public String getCarSiteDes() { + return carSiteDes; + } + + public void setCarSiteDes(String carSiteDes) { + this.carSiteDes = carSiteDes; + } + + public Double getTrafficScore() { + return trafficScore; + } + + public void setTrafficScore(Double trafficScore) { + this.trafficScore = trafficScore; + } + + public Double getHospitalScore() { + return hospitalScore; + } + + public void setHospitalScore(Double hospitalScore) { + this.hospitalScore = hospitalScore; + } + + public Double getShopScore() { + return shopScore; + } + + public void setShopScore(Double shopScore) { + this.shopScore = shopScore; + } + + public Double getSchoolScore() { + return schoolScore; + } + + public void setSchoolScore(Double schoolScore) { + this.schoolScore = schoolScore; + } + + public Double getBankScore() { + return bankScore; + } + + public void setBankScore(Double bankScore) { + this.bankScore = bankScore; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + public List getPositives() { + return positives; + } + + public void setPositives(List positives) { + this.positives = positives; + } + + public List getNegatives() { + return negatives; + } + + public void setNegatives(List negatives) { + this.negatives = negatives; + } + + public List getAppraisalNegative() { + return appraisalNegative; + } + + public void setAppraisalNegative(List appraisalNegative) { + this.appraisalNegative = appraisalNegative; + } + + public List getAppraisalPositive() { + return appraisalPositive; + } + + public void setAppraisalPositive(List appraisalPositive) { + this.appraisalPositive = appraisalPositive; + } + + public Double getTraScore() { + return traScore; + } + + public void setTraScore(Double traScore) { + this.traScore = traScore; + } + + public Double getVirScore() { + return virScore; + } + + public void setVirScore(Double virScore) { + this.virScore = virScore; + } + + public Double getAroScore() { + return aroScore; + } + + public void setAroScore(Double aroScore) { + this.aroScore = aroScore; + } + + public Double getTradScore() { + return tradScore; + } + + public void setTradScore(Double tradScore) { + this.tradScore = tradScore; + } + + public String getImgUrl3D() { + return imgUrl3D; + } + + public void setImgUrl3D(String imgUrl3D) { + this.imgUrl3D = imgUrl3D; + } + + public List getSchool() { + return school; + } + + public void setSchool(List school) { + this.school = school; + } + + public List getKeySchool() { + return keySchool; + } + + public void setKeySchool(List keySchool) { + this.keySchool = keySchool; + } +} diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index 987f6f3d2..8f695b729 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -25,6 +25,8 @@ public class HouseSearchModel extends SearchModel { private String houseType; private String district; + + private String cat; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -187,4 +189,12 @@ public class HouseSearchModel extends SearchModel { public void setDistrict(String district) { this.district = district; } + + public String getCat() { + return cat; + } + + public void setCat(String cat) { + this.cat = cat; + } } From 6ab477367b37815e90c9de2d2cc13f9ad32dbd62 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 11:17:59 +0800 Subject: [PATCH 173/230] =?UTF-8?q?=E8=87=AA=E8=BA=AB=E6=88=BF=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/model/DistrictFacilitysModel.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java index ddc05adec..ca5c12046 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/DistrictFacilitysModel.java @@ -4,7 +4,7 @@ import java.util.Date; import java.util.List; /** - * 灏忓尯鍛ㄨ竟閰嶅 + * 小区周边配套 */ public class DistrictFacilitysModel { private static final long serialVersionUID = -9200383212669643823L; @@ -36,13 +36,13 @@ public class DistrictFacilitysModel { private Date creationDate; - private List positives; // 姝i潰 - private List negatives; // 璐熼潰 - private List appraisalNegative; // 璐熼潰 - private List appraisalPositive; // 姝i潰 + private List positives; // 正面 + private List negatives; // 负面 + private List appraisalNegative; // 负面 + private List appraisalPositive; // 正面 /** - * 閺嶅洨顒峰妤�鍨� + * 鏍囩寰楀垎 */ private Double traScore; private Double virScore; From 63782f4ea2fbe59076338c444748a5f38acd1456 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 14:13:27 +0800 Subject: [PATCH 174/230] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/mongo/model/SeaweedImages.java | 8 +- .../open/controllers/DistrictController.java | 2103 +++++++++-------- 2 files changed, 1102 insertions(+), 1009 deletions(-) diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java index 33ff36050..33d6b6dee 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/model/SeaweedImages.java @@ -5,6 +5,7 @@ import com.fangjia.dal.MongoEntity; import javax.persistence.*; import java.util.Date; import java.util.List; +import java.util.Map; @Entity @Table(name = "fangjia_base.seaweed_images") @@ -15,7 +16,7 @@ public class SeaweedImages implements MongoEntity { private String city; private String district; - private List floorplanPics; + private Map> floorplanPics; private Date mDate; private String name; @@ -51,13 +52,12 @@ public class SeaweedImages implements MongoEntity { public void setDistrict(String district) { this.district = district; } - @Column(name = "floorplan_pics") - public List getFloorplanPics() { + public Map> getFloorplanPics() { return floorplanPics; } - public void setFloorplanPics(List floorplanPics) { + public void setFloorplanPics(Map> floorplanPics) { this.floorplanPics = floorplanPics; } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java index a35805605..ba7c22ede 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java @@ -10,8 +10,7 @@ import com.fangjia.core.util.DateUtil; import com.fangjia.core.util.HttpRequest; import com.fangjia.dal.mongo.model.*; import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto; -import com.fangjia.open.model.AvgPriceQueryModel; -import com.fangjia.open.model.BasicModel; +import com.fangjia.open.model.*; import com.fangjia.open.model.weixin.DistrictModel; import com.fangjia.open.util.CommonDtoUtils; import com.fangjia.service.datastore.RegionStatService; @@ -58,8 +57,6 @@ import com.fangjia.open.dto.NewDistrictDto; import com.fangjia.open.interceptors.AuthenticationBean; import com.fangjia.open.interceptors.Authority; import com.fangjia.open.interceptors.Role; -import com.fangjia.open.model.DistrictSearchModel; -import com.fangjia.open.model.RestfulModelAndView; import com.fangjia.service.api.AutoCompleteService; import com.fangjia.service.api.CategoryEnum; import com.fangjia.service.api.KnowbaseService; @@ -79,655 +76,655 @@ import com.fangjia.service.web.MenuService; /** * 小区接口 - * + * * @author velna - * */ @Authority(role = Role.USER) public class DistrictController { - private DistrictService districtService; - private MenuService menuService; - private DistrictStatService districtStatService; - private DistrictHouseService districtHouseService; - private AutoCompleteService autoCompleteService; - private KnowbaseService knowbaseService; - private ApiUserService apiUserService; - private ExtractDistrictService extractDistrictService; + private DistrictService districtService; + private MenuService menuService; + private DistrictStatService districtStatService; + private DistrictHouseService districtHouseService; + private AutoCompleteService autoCompleteService; + private KnowbaseService knowbaseService; + private ApiUserService apiUserService; + private ExtractDistrictService extractDistrictService; private RegionBlockService regionBlockService; private RegionStatService regionStatService; private RegionStatRentService regionStatRentService; - private DistrictFacilitysService districtFacilitysService; - private SeaweedImagesService seaweedImagesService; - + private DistrictFacilitysService districtFacilitysService; + private SeaweedImagesService seaweedImagesService; - public static final String[] COLUMNS = { "id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", - "householdCount", "address", "city", "region", "block", "alias", "lat", "lng", "lat2", "lng2", "finishBuildingDate", - "description", "kind", "carSite", "estateCharge", "cubagePercent", "virescencePercent", "estateCompany", "developer", - "facilities", "traffic", "loopLineInfo", "houseProperty", "buildStructure", "openDate", "sellAddress", "discount", - "fitmentMaterials", "floorInfo", "creationDate", "modificationDate" }; - public Object searchAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - @Param(name = "cat") String cat, @Param(name = "limit") int limit) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "所在城市必须输入")); - } + public static final String[] COLUMNS = {"id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", + "householdCount", "address", "city", "region", "block", "alias", "lat", "lng", "lat2", "lng2", "finishBuildingDate", + "description", "kind", "carSite", "estateCharge", "cubagePercent", "virescencePercent", "estateCompany", "developer", + "facilities", "traffic", "loopLineInfo", "houseProperty", "buildStructure", "openDate", "sellAddress", "discount", + "fitmentMaterials", "floorInfo", "creationDate", "modificationDate"}; - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键字必须输入")); - } + public Object searchAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + @Param(name = "cat") String cat, @Param(name = "limit") int limit) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "所在城市必须输入")); + } - List districts = this.districtService.searchByKeyword(cat, city, keyword, limit); + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键字必须输入")); + } - List> result = new ArrayList>(); + List districts = this.districtService.searchByKeyword(cat, city, keyword, limit); - for (District district : districts) { - Map resMap = new HashMap(); - resMap.put("_id", district.getId()); - resMap.put("city", district.getCity()); - resMap.put("region", district.getRegion()); - resMap.put("block", district.getBlock()); - resMap.put("districtName", district.getName()); - resMap.put("address", district.getAddress()); - resMap.put("category", district.getCategory()); - result.add(resMap); - } + List> result = new ArrayList>(); - mav.setModel(result); - return mav; - } + for (District district : districts) { + Map resMap = new HashMap(); + resMap.put("_id", district.getId()); + resMap.put("city", district.getCity()); + resMap.put("region", district.getRegion()); + resMap.put("block", district.getBlock()); + resMap.put("districtName", district.getName()); + resMap.put("address", district.getAddress()); + resMap.put("category", district.getCategory()); + result.add(resMap); + } - public Object fetchByCityAction(@Param(name = "city") String city, @Param(name = "cat") final String cat, - @Param(name = "skip") Integer skip, @Param(name = "limit") Integer limit, - @Param(name = "lastUpdateTime") Long lastUpdateTime) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } + mav.setModel(result); + return mav; + } - if (!"district".equals(cat) && !"new_district".equals(cat)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区类型必须输入正确")); - return mav; - } + public Object fetchByCityAction(@Param(name = "city") String city, @Param(name = "cat") final String cat, + @Param(name = "skip") Integer skip, @Param(name = "limit") Integer limit, + @Param(name = "lastUpdateTime") Long lastUpdateTime) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } - skip = null == skip ? 0 : skip; - limit = null == limit ? 20 : limit; - System.out.println(new Date().getTime()); + if (!"district".equals(cat) && !"new_district".equals(cat)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区类型必须输入正确")); + return mav; + } - if (skip < 0 || skip > 1000000 || limit < 0 || limit > 10000) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "请求数量参数不正确")); - return mav; - } + skip = null == skip ? 0 : skip; + limit = null == limit ? 20 : limit; + System.out.println(new Date().getTime()); - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("category", cat)); - params.add(new QueryParam("visible", 0)); - if (null != lastUpdateTime) { - params.add(new QueryParam("modificationDate", QueryParam.GREATER_THAN_OPERATOR, new Date(lastUpdateTime))); - } + if (skip < 0 || skip > 1000000 || limit < 0 || limit > 10000) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "请求数量参数不正确")); + return mav; + } - Pager pager = new Pager(limit); - pager.setStartRow(skip); - List districtLists = districtService.findDistrictList(pager, params, COLUMNS); + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("category", cat)); + params.add(new QueryParam("visible", 0)); + if (null != lastUpdateTime) { + params.add(new QueryParam("modificationDate", QueryParam.GREATER_THAN_OPERATOR, new Date(lastUpdateTime))); + } - List districtDtos = org.sothis.core.util.CollectionUtils.collect(districtLists, - new Closure() { - public DistrictDto execute(District obj) { - DistrictBo bo = new DistrictBo(obj); - DistrictDto ret = null; - if ("new_district".equals(cat)) { - ret = new NewDistrictDto(bo, true); - } else { - ret = new DistrictDto(bo, true); - } - ret.setAlias(obj.getAlias()); - return ret; - } - }); + Pager pager = new Pager(limit); + pager.setStartRow(skip); + List districtLists = districtService.findDistrictList(pager, params, COLUMNS); - mav.setModel(districtDtos); - return mav; - } + List districtDtos = org.sothis.core.util.CollectionUtils.collect(districtLists, + new Closure() { + public DistrictDto execute(District obj) { + DistrictBo bo = new DistrictBo(obj); + DistrictDto ret = null; + if ("new_district".equals(cat)) { + ret = new NewDistrictDto(bo, true); + } else { + ret = new DistrictDto(bo, true); + } + ret.setAlias(obj.getAlias()); + return ret; + } + }); - /** - * 根据城市和关键词取小区 - * - * @param city - * @param keyword - * @param request - * @return - */ - public Object fetchByKeywordAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); - return mav; - } - List districtNames = autoCompleteService.suggestDistrict(keyword, city, 10); - if (CollectionUtils.isNotEmpty(districtNames)) { - DistrictDto districtDto = null; - for (String districtName : districtNames) { - DistrictQueryBean queryBean = new DistrictQueryBean(); - queryBean.setCity(city); - queryBean.setCategory("district"); - queryBean.setName(districtName); - List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); - if (CollectionUtils.isNotEmpty(districtBos)) { - DistrictBo bo = districtBos.get(0); - if ("district".equals(bo.getCategory())) { - districtDto = new DistrictDto(bo, isSupportLatLng(request)); - } else { - districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); - } - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - break; - } - } - if (null != districtDto) { - mav.setModel(districtDto); - } - } - return mav; - } + mav.setModel(districtDtos); + return mav; + } - /** - * 根据关键词取小区 - * - * @param city - * @param keyword - * @param request - * @return - */ - public Object fetchSimpleAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, - HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(keyword)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); - return mav; - } + /** + * 根据城市和关键词取小区 + * + * @param city + * @param keyword + * @param request + * @return + */ + public Object fetchByKeywordAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); + return mav; + } + List districtNames = autoCompleteService.suggestDistrict(keyword, city, 10); + if (CollectionUtils.isNotEmpty(districtNames)) { + DistrictDto districtDto = null; + for (String districtName : districtNames) { + DistrictQueryBean queryBean = new DistrictQueryBean(); + queryBean.setCity(city); + queryBean.setCategory("district"); + queryBean.setName(districtName); + List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); + if (CollectionUtils.isNotEmpty(districtBos)) { + DistrictBo bo = districtBos.get(0); + if ("district".equals(bo.getCategory())) { + districtDto = new DistrictDto(bo, isSupportLatLng(request)); + } else { + districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); + } + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + break; + } + } + if (null != districtDto) { + mav.setModel(districtDto); + } + } + return mav; + } - ServerArea serverArea = ServerAreaData.getServerAreaByDisplayDefaultNull(city); - if (serverArea == null) { - serverArea = ServerAreaData.getServerAreaBySpellDefaultNull(city); - if (null == serverArea) { - serverArea = ServerAreaData.valueOfName(city); - } - } + /** + * 根据关键词取小区 + * + * @param city + * @param keyword + * @param request + * @return + */ + public Object fetchSimpleAction(@Param(name = "city") String city, @Param(name = "keyword") String keyword, + HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(keyword)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "关键词必须输入")); + return mav; + } - List districtNames = autoCompleteService.suggestDistrict(keyword, serverArea.getDisplay(), 10); - if (CollectionUtils.isNotEmpty(districtNames)) { - List> ret = new ArrayList>(10); - for (String districtName : districtNames) { - DistrictQueryBean queryBean = new DistrictQueryBean(); - queryBean.setCity(serverArea.getDisplay()); - queryBean.setCategory("district"); - queryBean.setName(districtName); - List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); - if (CollectionUtils.isNotEmpty(districtBos)) { - DistrictKey key = districtBos.get(0).getDistrictKey(); - Map info = new HashMap(3); - info.put("city", serverArea.getDisplay()); - info.put("region", key.getRegion()); - info.put("name", key.getName()); - ret.add(info); - } - } - if (ret.size() > 0) { - mav.setModel(ret); - } - } - return mav; - } + ServerArea serverArea = ServerAreaData.getServerAreaByDisplayDefaultNull(city); + if (serverArea == null) { + serverArea = ServerAreaData.getServerAreaBySpellDefaultNull(city); + if (null == serverArea) { + serverArea = ServerAreaData.valueOfName(city); + } + } - /** - * 小区搜索 - * - * @return - */ - public Object listAction(DistrictSearchModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } - Pager pager = new Pager(); - int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); - int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); - if (model.getPageSize() != null && model.getPageSize() > 0) { - pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); - } else { - pager.setPageSize(20); - } - if (model.getPageIndex() != null && model.getPageIndex() > 1) { - int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); - int startRow = (pageIndex - 1) * pager.getPageSize(); - pager.setStartRow(startRow); - } - // 是否输入半径查询,其他情况直接moedel查询即可 - if (isRadiusSearch(model)) { - Long lng = model.getLng(); - Long lat = model.getLat(); + List districtNames = autoCompleteService.suggestDistrict(keyword, serverArea.getDisplay(), 10); + if (CollectionUtils.isNotEmpty(districtNames)) { + List> ret = new ArrayList>(10); + for (String districtName : districtNames) { + DistrictQueryBean queryBean = new DistrictQueryBean(); + queryBean.setCity(serverArea.getDisplay()); + queryBean.setCategory("district"); + queryBean.setName(districtName); + List districtBos = this.districtService.findByCompactMode(queryBean.getQueryParams(), null, 0, 20); + if (CollectionUtils.isNotEmpty(districtBos)) { + DistrictKey key = districtBos.get(0).getDistrictKey(); + Map info = new HashMap(3); + info.put("city", serverArea.getDisplay()); + info.put("region", key.getRegion()); + info.put("name", key.getName()); + ret.add(info); + } + } + if (ret.size() > 0) { + mav.setModel(ret); + } + } + return mav; + } - model.setLng(lng); - model.setLat(lat); + /** + * 小区搜索 + * + * @return + */ + public Object listAction(DistrictSearchModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } + Pager pager = new Pager(); + int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); + int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); + } else { + pager.setPageSize(20); + } + if (model.getPageIndex() != null && model.getPageIndex() > 1) { + int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); + int startRow = (pageIndex - 1) * pager.getPageSize(); + pager.setStartRow(startRow); + } + // 是否输入半径查询,其他情况直接moedel查询即可 + if (isRadiusSearch(model)) { + Long lng = model.getLng(); + Long lat = model.getLat(); - Long lngMin = (lng - (model.getRadius() * 100000L)); - model.setLngMin(lngMin); - Long lngMax = (lng + (model.getRadius() * 100000L)); - model.setLngMax(lngMax); - Long latMin = (lat - (model.getRadius() * 100000L)); - model.setLatMin(latMin); - Long latMax = (lat + (model.getRadius() * 100000L)); - model.setLatMax(latMax); + model.setLng(lng); + model.setLat(lat); - model.setRegion(null); - model.setName(null); - } else if (model.getLatA() != null && model.getLatB() != null && model.getLngA() != null && model.getLngB() != null) { - Long lngMin = Math.min(model.getLngA(), model.getLngB()); - Long lngMax = Math.max(model.getLngA(), model.getLngB()); - Long latMin = Math.min(model.getLatA(), model.getLatB()); - Long latMax = Math.max(model.getLatA(), model.getLatB()); + Long lngMin = (lng - (model.getRadius() * 100000L)); + model.setLngMin(lngMin); + Long lngMax = (lng + (model.getRadius() * 100000L)); + model.setLngMax(lngMax); + Long latMin = (lat - (model.getRadius() * 100000L)); + model.setLatMin(latMin); + Long latMax = (lat + (model.getRadius() * 100000L)); + model.setLatMax(latMax); - model.setLngMin(lngMin); - model.setLngMax(lngMax); - model.setLatMin(latMin); - model.setLatMax(latMax); - } - Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, - getCurrentParams(), 1); - FacetQueryResult result; - if (StringUtils.isBlank(model.getKeyword())) { - result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), "bscore", - false, false); - } else { - result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), null, false, - false); - } - Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); - FacetQueryResult districtList = new FacetQueryResult(result.size()); - for (District district : result) { - DistrictBo districtBo = new DistrictBo(district); - districtBo.setStat(statMap.get(district.getDistrictKey())); - districtList.add(districtBo); - } - districtList.setNumberFound(result.getNumberFound()); + model.setRegion(null); + model.setName(null); + } else if (model.getLatA() != null && model.getLatB() != null && model.getLngA() != null && model.getLngB() != null) { + Long lngMin = Math.min(model.getLngA(), model.getLngB()); + Long lngMax = Math.max(model.getLngA(), model.getLngB()); + Long latMin = Math.min(model.getLatA(), model.getLatB()); + Long latMax = Math.max(model.getLatA(), model.getLatB()); - FacetQueryResult districtDtos = new FacetQueryResult(); - for (DistrictBo bo : districtList) { - DistrictDto districtDto = null; - if ("district".equals(bo.getCategory())) { - districtDto = new DistrictDto(bo, isSupportLatLng(request)); - } else { - districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); - } - if (StringUtils.isNotBlank(model.getHouseCountType())) { - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - if (CategoryEnum.sell.name().equals(model.getHouseCountType())) { - districtDto.setSellCount(dh.getSellCount()); - } else if (CategoryEnum.rent.name().equals(model.getHouseCountType())) { - districtDto.setRentCount(dh.getRentCount()); - } - } - } - // 若存在外景图则只考虑外景图 - List outPics = bo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "s", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDtos.add(districtDto); - } - districtDtos.setNumberFound(districtList.getNumberFound()); - mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); - return mav; - } + model.setLngMin(lngMin); + model.setLngMax(lngMax); + model.setLatMin(latMin); + model.setLatMax(latMax); + } + Menu menu = menuService.menuMaker(FangjiaServerAreaContextHolder.getServerAreaDefault(), MenuCategoryEnum.xiaoqu, + getCurrentParams(), 1); + FacetQueryResult result; + if (StringUtils.isBlank(model.getKeyword())) { + result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), "bscore", + false, false); + } else { + result = districtService.findByQueryBeanWithFacet(menu, pager, (DistrictQueryBean) model.getQueryBean(), null, false, + false); + } + Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); + FacetQueryResult districtList = new FacetQueryResult(result.size()); + for (District district : result) { + DistrictBo districtBo = new DistrictBo(district); + districtBo.setStat(statMap.get(district.getDistrictKey())); + districtList.add(districtBo); + } + districtList.setNumberFound(result.getNumberFound()); - private Map getCurrentParams() { - Map paramMap = ActionContext.getContext().getParameters(); - Map ret = new HashMap(); + FacetQueryResult districtDtos = new FacetQueryResult(); + for (DistrictBo bo : districtList) { + DistrictDto districtDto = null; + if ("district".equals(bo.getCategory())) { + districtDto = new DistrictDto(bo, isSupportLatLng(request)); + } else { + districtDto = new NewDistrictDto(bo, isSupportLatLng(request)); + } + if (StringUtils.isNotBlank(model.getHouseCountType())) { + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + if (CategoryEnum.sell.name().equals(model.getHouseCountType())) { + districtDto.setSellCount(dh.getSellCount()); + } else if (CategoryEnum.rent.name().equals(model.getHouseCountType())) { + districtDto.setRentCount(dh.getRentCount()); + } + } + } + // 若存在外景图则只考虑外景图 + List outPics = bo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "s", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDtos.add(districtDto); + } + districtDtos.setNumberFound(districtList.getNumberFound()); + mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); + return mav; + } - for (String key : paramMap.keySet()) { - Object[] obj = paramMap.get(key); - if (obj != null && obj.length > 0) { - ret.put(key, obj[0].toString()); - } - } - return ret; - } + private Map getCurrentParams() { + Map paramMap = ActionContext.getContext().getParameters(); + Map ret = new HashMap(); - /** - * 是否可以提供经纬度 - * - * @param request - * @return - */ - private boolean isSupportLatLng(HttpServletRequest request) { - AuthenticationBean bean = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); - if (null != bean) { - if (null != bean.auth) { - return bean.auth.isSupportLatLng(); - } - } - return false; - } + for (String key : paramMap.keySet()) { + Object[] obj = paramMap.get(key); + if (obj != null && obj.length > 0) { + ret.put(key, obj[0].toString()); + } + } + return ret; + } - /** - * 小区详情 - * - * @return - */ - public Object showAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); - return mav; - } else { - DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(city, region, name)); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); - return mav; - } - districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); - // 去除小区描述中的html标签 - districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); - DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 - List outPics = districtBo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "o", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" - + name + "-" + region); - mav.setModel(districtDto); - return mav; - } - } + /** + * 是否可以提供经纬度 + * + * @param request + * @return + */ + private boolean isSupportLatLng(HttpServletRequest request) { + AuthenticationBean bean = (AuthenticationBean) request.getAttribute(AuthenticationBean.ATTR_AUTHENTICATION_BEAN); + if (null != bean) { + if (null != bean.auth) { + return bean.auth.isSupportLatLng(); + } + } + return false; + } - /** - * 智能解析小区详情 - * - * @return - */ - public Object showDetailAction(DistrictSearchModel model, @Param(name = "city") String city, - @Param(name = "region") String region, @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); - return mav; - } - city = knowbaseService.matchingCityDefaultNull(city); - region = knowbaseService.matchingRegionDefaultNull(region, city); - if (null == city || null == region) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区所在城市或所在区域不存在")); - return mav; - } - District tempDistrict = null; - Map konwbase = knowbaseService.parseWord(name); - List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase - .get("district_name") : Collections.EMPTY_LIST; - if (CollectionUtils.isNotEmpty(districts)) { - for (Map district : districts) { - Map extra_data = (Map) district.get("extra_data"); - if (MapUtils.isNotEmpty(extra_data)) { - region = (String) extra_data.get("region"); - name = (String) district.get("value"); - String tempCity = (String) extra_data.get("city"); - if (null == city && tempCity != null) { - city = tempCity; - } else if (tempCity == null || (tempCity != null && !tempCity.equals(city))) { - continue; - } - District d = districtService.findDistrict(new DistrictKey(city, region, name), false); - if (null == d) { - continue; - } - tempDistrict = d; - break; - } - } - } - if (null == tempDistrict) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); - return mav; - } - DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(tempDistrict.getCity(), tempDistrict.getRegion(), - tempDistrict.getName())); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); - return mav; - } - districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); - // 去除小区描述中的html标签 - districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); - DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } + /** + * 小区详情 + * + * @return + */ + public Object showAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); + return mav; + } else { + DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(city, region, name)); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); + return mav; + } + districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); + // 去除小区描述中的html标签 + districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); + DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 + List outPics = districtBo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "o", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" + + name + "-" + region); + mav.setModel(districtDto); + return mav; + } + } - // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 - List outPics = districtBo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "o", "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" - + name + "-" + region); - mav.setModel(districtDto); - return mav; - } + /** + * 智能解析小区详情 + * + * @return + */ + public Object showDetailAction(DistrictSearchModel model, @Param(name = "city") String city, + @Param(name = "region") String region, @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); + return mav; + } + city = knowbaseService.matchingCityDefaultNull(city); + region = knowbaseService.matchingRegionDefaultNull(region, city); + if (null == city || null == region) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区所在城市或所在区域不存在")); + return mav; + } + District tempDistrict = null; + Map konwbase = knowbaseService.parseWord(name); + List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase + .get("district_name") : Collections.EMPTY_LIST; + if (CollectionUtils.isNotEmpty(districts)) { + for (Map district : districts) { + Map extra_data = (Map) district.get("extra_data"); + if (MapUtils.isNotEmpty(extra_data)) { + region = (String) extra_data.get("region"); + name = (String) district.get("value"); + String tempCity = (String) extra_data.get("city"); + if (null == city && tempCity != null) { + city = tempCity; + } else if (tempCity == null || (tempCity != null && !tempCity.equals(city))) { + continue; + } + District d = districtService.findDistrict(new DistrictKey(city, region, name), false); + if (null == d) { + continue; + } + tempDistrict = d; + break; + } + } + } + if (null == tempDistrict) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); + return mav; + } + DistrictBo districtBo = districtService.findByFullMode(new DistrictKey(tempDistrict.getCity(), tempDistrict.getRegion(), + tempDistrict.getName())); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在,请检查查询条件")); + return mav; + } + districtBo.setStat(this.districtStatService.findDistrictStat(districtBo.getDistrictKey())); + // 去除小区描述中的html标签 + districtBo.setDescription(DataUtil.removeSpecialString(districtBo.getDescription())); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(new DistrictKey(city, region, name)); + DistrictDto districtDto = new DistrictDto(districtBo, isSupportLatLng(request)); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } - public Object showListAction(DistrictSearchModel model, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(model.getCity())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); - return mav; - } - Pager pager = new Pager(); - int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); - int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); - if (model.getPageSize() != null && model.getPageSize() > 0) { - pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); - } else { - pager.setPageSize(20); - } - if (model.getPageIndex() != null && model.getPageIndex() > 1) { - int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); - int startRow = (pageIndex - 1) * pager.getPageSize(); - pager.setStartRow(startRow); - } - FacetQueryResult result; - if (StringUtils.isBlank(model.getKeyword())) { - result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); - } else { - result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); - } - Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); - FacetQueryResult districtList = new FacetQueryResult(result.size()); - for (District district : result) { - DistrictBo districtBo = new DistrictBo(district); - districtBo.setStat(statMap.get(district.getDistrictKey())); - districtList.add(districtBo); - } - districtList.setNumberFound(result.getNumberFound()); + // 若存在外景图则只考虑外景图,若无外景图则无图片,取前5张 + List outPics = districtBo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "o", "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "o", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setUrl("http://" + ServerAreaData.getServerAreaByDisplay(city).getSpell() + ".fangjia.com/xiaoqu-xinxi-" + + name + "-" + region); + mav.setModel(districtDto); + return mav; + } - FacetQueryResult districtDtos = new FacetQueryResult(); - for (DistrictBo bo : districtList) { - DistrictDto districtDto = new DistrictDto(bo, isSupportLatLng(request)); - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); - if (dh != null) { - districtDto.setSellCount(dh.getSellCount()); - districtDto.setRentCount(dh.getRentCount()); - } - // 若存在外景图则只考虑外景图 - List outPics = bo.getOutPics(); - if (CollectionUtils.isNotEmpty(outPics)) { - // 标志图取中间一张 - districtDto.setPic(outPics.get(outPics.size() / 2)); - if (outPics.size() <= 5) { - districtDto.setPics(outPics); - } else { - districtDto.setPics(outPics.subList(0, 5)); - } - // districtDto.setPic(model.getPicUrl() + - // DataUtil.encodePicUrl(districtDto.getPic(), "s", - // "district")); - // List picsNew = new ArrayList(); - // List pics = districtDto.getPics(); - // for (String url : pics) { - // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", - // "district"); - // picsNew.add(url); - // } - // districtDto.setPics(picsNew); - } - districtDto.setDescription(null); - districtDtos.add(districtDto); - } - districtDtos.setNumberFound(districtList.getNumberFound()); - mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); - return mav; - } + public Object showListAction(DistrictSearchModel model, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getCity())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市必须输入")); + return mav; + } + Pager pager = new Pager(); + int maxPageSize = OpenConfig.getConfig().getSearchListMaxPageSize(); + int maxPageIndex = OpenConfig.getConfig().getSearchListMaxPageNo(); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize() > maxPageSize ? maxPageSize : model.getPageSize()); + } else { + pager.setPageSize(20); + } + if (model.getPageIndex() != null && model.getPageIndex() > 1) { + int pageIndex = model.getPageIndex() > maxPageIndex ? maxPageIndex : model.getPageIndex(); + int startRow = (pageIndex - 1) * pager.getPageSize(); + pager.setStartRow(startRow); + } + FacetQueryResult result; + if (StringUtils.isBlank(model.getKeyword())) { + result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); + } else { + result = districtService.findByQueryBeanWithoutSrQuery(pager, (DistrictQueryBean) model.getQueryBean(), true); + } + Map statMap = districtStatService.findDistrictStat(districtService.getDistrictKeys(result)); + FacetQueryResult districtList = new FacetQueryResult(result.size()); + for (District district : result) { + DistrictBo districtBo = new DistrictBo(district); + districtBo.setStat(statMap.get(district.getDistrictKey())); + districtList.add(districtBo); + } + districtList.setNumberFound(result.getNumberFound()); + + FacetQueryResult districtDtos = new FacetQueryResult(); + for (DistrictBo bo : districtList) { + DistrictDto districtDto = new DistrictDto(bo, isSupportLatLng(request)); + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(bo.getDistrictKey()); + if (dh != null) { + districtDto.setSellCount(dh.getSellCount()); + districtDto.setRentCount(dh.getRentCount()); + } + // 若存在外景图则只考虑外景图 + List outPics = bo.getOutPics(); + if (CollectionUtils.isNotEmpty(outPics)) { + // 标志图取中间一张 + districtDto.setPic(outPics.get(outPics.size() / 2)); + if (outPics.size() <= 5) { + districtDto.setPics(outPics); + } else { + districtDto.setPics(outPics.subList(0, 5)); + } + // districtDto.setPic(model.getPicUrl() + + // DataUtil.encodePicUrl(districtDto.getPic(), "s", + // "district")); + // List picsNew = new ArrayList(); + // List pics = districtDto.getPics(); + // for (String url : pics) { + // url = model.getPicUrl() + DataUtil.encodePicUrl(url, "s", + // "district"); + // picsNew.add(url); + // } + // districtDto.setPics(picsNew); + } + districtDto.setDescription(null); + districtDtos.add(districtDto); + } + districtDtos.setNumberFound(districtList.getNumberFound()); + mav.setModel(new DistrictsDto(districtDtos, ((Number) districtDtos.getNumberFound()).longValue())); + return mav; + } /** * 小区均价查询接口 + * * @param model * @return */ - public Object avgPriceAction(AvgPriceQueryModel model){ + public Object avgPriceAction(AvgPriceQueryModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域)是必须参数")); return mav; } - if(!RegionData.isCity(model.getCity())){ - String city = RegionData.formatCity(model.getCity()); - if(null == city){ - mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); - return mav; - }else{ - model.setCity(city); - } - } + if (!RegionData.isCity(model.getCity())) { + String city = RegionData.formatCity(model.getCity()); + if (null == city) { + mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); + return mav; + } else { + model.setCity(city); + } + } String region = RegionData.formatRegion(model.getCity(), model.getDistrict()); model.setDistrict(region); - if(!RegionData.isRegion(model.getCity(), region)){ + if (!RegionData.isRegion(model.getCity(), region)) { mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); return mav; } - if(model.getPeriodCount() == null){ + if (model.getPeriodCount() == null) { model.setPeriodCount(1); } - if(model.getPeriodCount()< 1 || model.getPeriodCount()>156){ + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); return mav; } - if(StringUtils.isBlank(model.getPeriodType())){ + if (StringUtils.isBlank(model.getPeriodType())) { model.setPeriodType("weekly"); - }else{ - if(!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())){ + } else { + if (!"weekly".equals(model.getPeriodType()) && !"monthly".equals(model.getPeriodType())) { mav.setModel(BasicModel.buildBadRequestModel("periodModel值非法,合法值为:weekly,monthly")); return mav; } } Calendar calendar = Calendar.getInstance(); - if("weekly".equals(model.getPeriodType())){ - calendar.add(Calendar.DATE, -model.getPeriodCount().intValue()*7); - }else{ + if ("weekly".equals(model.getPeriodType())) { + calendar.add(Calendar.DATE, -model.getPeriodCount().intValue() * 7); + } else { calendar.add(Calendar.MONTH, -model.getPeriodCount().intValue()); } - List regionStats = regionStatService.findRegionBlockStat(model.getCity(),model.getDistrict(),null,calendar.getTime(),new Date(),model.getPeriodType()); - if(regionStats.size() > model.getPeriodCount()){ - regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(),regionStats.size()); + List regionStats = regionStatService.findRegionBlockStat(model.getCity(), model.getDistrict(), null, calendar.getTime(), new Date(), model.getPeriodType()); + if (regionStats.size() > model.getPeriodCount()) { + regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(), regionStats.size()); } - List> result = new ArrayList>(model.getPeriodCount()); + List> result = new ArrayList>(model.getPeriodCount()); for (RegionStat regionStat : regionStats) { - Map item = new LinkedHashMap(); + Map item = new LinkedHashMap(); item.put("city", regionStat.getCity()); item.put("district", regionStat.getRegion()); item.put("block", regionStat.getBlock()); item.put("avgPrice", String.valueOf(regionStat.getAvgPrice())); - if("monthly".equals(model.getPeriodType())){ + if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM")); - }else{ + } else { item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM-dd")); } item.put("changePercent", String.valueOf(regionStat.getMarkup() / 100d)); @@ -736,53 +733,55 @@ public class DistrictController { mav.setModel(BasicModel.buildOKModel().setResult(result)); return mav; } + /** * 区域均价查询接口 + * * @param model * @return */ - public Object rentAction(AvgPriceQueryModel model){ + public Object rentAction(AvgPriceQueryModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict())) { mav.setModel(BasicModel.buildBadRequestModel("参数缺失:city(城市),district(区域)是必须参数")); return mav; } - if(!RegionData.isCity(model.getCity())){ - String city = RegionData.formatCity(model.getCity()); - if(null == city){ - mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); - return mav; - }else{ - model.setCity(city); - } - } + if (!RegionData.isCity(model.getCity())) { + String city = RegionData.formatCity(model.getCity()); + if (null == city) { + mav.setModel(BasicModel.buildBadRequestModel("非法城市:" + model.getCity())); + return mav; + } else { + model.setCity(city); + } + } String region = RegionData.formatRegion(model.getCity(), model.getDistrict()); model.setDistrict(region); - if(!RegionData.isRegion(model.getCity(), region)){ + if (!RegionData.isRegion(model.getCity(), region)) { mav.setModel(BasicModel.buildBadRequestModel("没有找你输入的区域")); return mav; } - if (model.getHouseType() == null ||model.getHouseType() < 1) { + if (model.getHouseType() == null || model.getHouseType() < 1) { mav.setModel(BasicModel.buildBadRequestModel("房屋类型不合法")); return mav; } - if(model.getPeriodCount() == null){ + if (model.getPeriodCount() == null) { model.setPeriodCount(1); } - if(model.getPeriodCount() < 1 || model.getPeriodCount() > 72){ + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 72) { mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-72]")); return mav; } - List regionStats = regionStatRentService.findAllByDistrictKeyAndHouseType(model.getCity(),model.getDistrict(),model.getHouseType(),model.getPeriodCount()); - if(regionStats.size() > model.getPeriodCount()){ - regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(),regionStats.size()); + List regionStats = regionStatRentService.findAllByDistrictKeyAndHouseType(model.getCity(), model.getDistrict(), model.getHouseType(), model.getPeriodCount()); + if (regionStats.size() > model.getPeriodCount()) { + regionStats = regionStats.subList(regionStats.size() - model.getPeriodCount(), regionStats.size()); } - List> result = new ArrayList>(model.getPeriodCount()); + List> result = new ArrayList>(model.getPeriodCount()); for (RegionStatRent regionStat : regionStats) { - Map item = new LinkedHashMap(); + Map item = new LinkedHashMap(); item.put("city", regionStat.getCity()); item.put("district", regionStat.getRegion()); item.put("rent", regionStat.getAvgPrice()); @@ -868,423 +867,517 @@ public class DistrictController { // mav.setModel(map); // return mav; // } - - - /** - * 获取小区的均价Action - * - * @param city - * @param region - * @param name - * @return - */ - public Object curAvgPriceAction(@Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,所在区域,小区名为必填项")); - return mav; - } - DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(city, region, name)); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,区域,小区名")); - return mav; - } - - - String kind = ""; - if(StringUtils.isNotBlank(districtBo.getEstateType2())){ - if(districtBo.getEstateType2().indexOf(DistrictKindEnum.bieshu.getValue())!=-1){ - kind = DistrictKindEnum.bieshu.getValue(); - } - if(districtBo.getEstateType2().indexOf("住宅")!=-1||districtBo.getEstateType2().indexOf("小区")!=-1){ - if(kind.length()>1){ - kind = kind + ","; - } - kind = kind + DistrictKindEnum.gongyu.getValue(); - } - districtBo.setKind(kind); - - } - if (StringUtils.isEmpty(districtBo.getKind())) { - districtBo.setKind(DistrictKindEnum.gongyu.getValue()); - } - - - String[] kinds = districtBo.getKind().split(","); - - List districtStatList = null; - List villaStatList = null; - Date date = new Date(); - if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { - villaStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.bieshu.getValue(), date, 1); - if (kinds.length > 1) { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, 1); - } - } else { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, 1); - } - if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); - return mav; - } - - DistrictStat stat = null; - if(CollectionUtils.isNotEmpty(districtStatList)){ - stat = districtStatList.get(0); - } - if(CollectionUtils.isNotEmpty(villaStatList)){ - stat = villaStatList.get(0); - } - - Map map = new HashMap(1); - map.put("avgPrice", stat.getAvgPrice()); - map.put("weekendMarkup", stat.getWeekendMarkup()); - mav.setModel(map); - return mav; - } - - /** - * 获取小区的历史均价Action - * - * @param city - * @param region - * @param name - * @param weekCount - * @return - */ - public Object historyPriceAction(@Param(name = "city") String city, @Param(name = "name") String name, - @Param(name = "weekCount") Integer weekCount) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - int count = OfcChartUtils.YEAR_COUNT * 7; - if (null != weekCount && weekCount > 0) { - count = weekCount; - } - if (StringUtils.isBlank(name)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名为必填项")); - return mav; - } - District currentDistrict = null; - city = knowbaseService.matchingCityDefaultNull(city); - if (StringUtils.isBlank(city)) { - city = "上海"; - } - Map konwbase = knowbaseService.parseWord(name); - List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase - .get("district_name") : Collections.EMPTY_LIST; - if (CollectionUtils.isNotEmpty(districts)) { - for (Map district : districts) { - Map extra_data = (Map) district.get("extra_data"); - if (MapUtils.isNotEmpty(extra_data)) { - String region = (String) extra_data.get("region"); - name = (String) district.get("value"); - String tempCity = (String) extra_data.get("city"); - if (!city.equals(tempCity)) { - continue; - } - District d = districtService.findDistrict(new DistrictKey(city, region, name), false); - if (null == d) { - continue; - } - currentDistrict = d; - break; - } - } - } - - if (null == currentDistrict) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "未找到相关小区信息")); - return mav; - } - - // 解析出城市区域小区名楼栋号 - DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(currentDistrict.getCity(), currentDistrict - .getRegion(), currentDistrict.getName())); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,小区名")); - return mav; - } - if (StringUtils.isEmpty(districtBo.getKind())) { - districtBo.setKind(DistrictKindEnum.gongyu.getValue()); - } - String[] kinds = districtBo.getKind().split(","); - List districtStatList = null; - List villaStatList = null; - Date date = new Date(); - if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { - villaStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.bieshu.getValue(), date, count); - if (kinds.length > 1) { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, count); - } - } else { - districtStatList = this.districtStatService.findDistrictStat( - new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), - DistrictKindEnum.gongyu.getValue(), date, count); - } - if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); - return mav; - } - districtStatList = (List) OfcChartUtils.fixYDatas(date, districtStatList, count, null); - villaStatList = (List) OfcChartUtils.fixYDatas(date, villaStatList, count, null); - Map map = new HashMap(1); - map.put("stat", - DtoConverter.convertFromDistrictBoList(DataUtil.descCollection(districtStatList), - DataUtil.descCollection(villaStatList))); - mav.setModel(map); - return mav; - } - - /** - * 根据小区名等获取小区属性 - * - * @param uniqueCodes - * @param districtNames - * @param regionNames - * @param cityNames - * @return - */ - public Object fetchDistrictsPropertiesAction(@Param(name = "uniqueCodes") String[] uniqueCodes, - @Param(name = "districtNames") String[] districtNames, @Param(name = "regionNames") String[] regionNames, - @Param(name = "cityNames") String[] cityNames) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - if (uniqueCodes.length * districtNames.length * regionNames.length * cityNames.length == 0) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码、小区名、小区所在区域、小区所在城市必填")); - return mav; - } - if (uniqueCodes.length - districtNames.length + regionNames.length - cityNames.length != 0) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码数组、小区名数组、小区所在区域数组、小区所在城市数组数量必须相同")); - return mav; - } - - ArrayList keys = new ArrayList(1); - Map key_uniqueCode = new HashMap(1); - for (int i = 0; i < cityNames.length; i++) { - cityNames[i] = this.knowbaseService.matchingCity(cityNames[i]); - regionNames[i] = this.knowbaseService.matchingRegion(regionNames[i], cityNames[i]); - DistrictKey key = new DistrictKey(cityNames[i], regionNames[i], districtNames[i]); - keys.add(key); - key_uniqueCode.put(key, uniqueCodes[i]); - } - Map districtMap = this.districtService.findDistrictByKeyList(keys, false); - Map newDistrictMap = this.districtService.findDistrictByKeyList(keys, true, false); - - Map dtoMap = new HashMap(1); - for (DistrictKey key : districtMap.keySet()) { - District d = districtMap.get(key); - if (null != d) { - String uniqueCode = key_uniqueCode.get(key); - DistrictsPropertiesDto dto = new DistrictsPropertiesDto(); - dto.setUniqueCode(uniqueCode); - dto.setDistrictName(d.getName()); - if (null != newDistrictMap.get(key)) { - dto.setNewDistrict(true); - if (d.getStatus() == 5) { - dto.setOnSale(true); - } - if (StringUtils.isNotBlank(d.getDiscount())) { - dto.setDiscount(true); - } - } - if (null == dto.getOnSale()) { - DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(key); - if (dh != null && dh.getSellCount() != 0) { - dto.setOnSale(true); - } - } - if (StringUtils.isNotBlank(d.getVideoUrl())) { - dto.setVideo(true); - } - dtoMap.put(uniqueCode, dto); - } - } - mav.setModel(dtoMap); - return mav; - } - - private boolean isRadiusSearch(DistrictSearchModel model) { - return null != model.getRadius() && model.getRadius() > 0 && StringUtils.isNotBlank(model.getCity()) - && model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; - } - - public Object uploadAction(@Param(name = "token") String token, @Param(name = "data") String data) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - - Map ret = new HashMap(1); - ret.put("RESULT", 500); - - ApiUser apiUser = checkNewAuthorized(token); - if (null == apiUser) { - return mav; - } - - try { - JSONArray disJsonArr = JSONArray.fromObject(data); - for (int i = 0; i < disJsonArr.size(); i++) { - JSONObject disJsonObj = disJsonArr.getJSONObject(i); - ExtractDistrict dis = (ExtractDistrict) JSONObject.toBean(disJsonObj, ExtractDistrict.class); - dis.setSource("open_api"); - dis.setUserId((int) apiUser.getId()); - dis.setCreationDate(new Date()); - dis.setModificationDate(dis.getCreationDate()); - extractDistrictService.save(dis); - } - } catch (JSONException e) { - return mav; - } - - ret.put("RESULT", 200); - return mav; - } - - public Object facilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, - @Param(name = "name") String name, HttpServletRequest request) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); - return mav; - } else { - District districtBo = districtService.findDistrict(new DistrictKey(city, region, name), "district"); - if (null == districtBo) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); - return mav; - } - DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(districtBo); - mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); - } - return mav; - } - - /** - * 获取小区图片 - * - * @param districtModel - * @return - */ - public Object listPicAction(DistrictModel districtModel) { - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(districtModel.getId())) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); - return mav; - } - SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); - if (seaweedImages != null) { - mav.setModel(BasicModel.buildOKModel().setResult(seaweedImages.getOutPics())); - } else { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "图片数据不存在")); - } - return mav; - } - public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception{ - RestfulModelAndView mav = new RestfulModelAndView(); - mav.setViewType("rest"); - if (StringUtils.isBlank(address)) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "地址必须输入")); - return mav; - } else { - String cat = "district"; + /** + * 获取小区的均价Action + * + * @param city + * @param region + * @param name + * @return + */ + public Object curAvgPriceAction(@Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(city) || StringUtils.isBlank(region) || StringUtils.isBlank(name)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,所在区域,小区名为必填项")); + return mav; + } + DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(city, region, name)); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,区域,小区名")); + return mav; + } - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", city); - params.put("address", address); - params.put("category", "property"); - //新匹配接口 - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); - District property = null; - if (json != null && json.size() > 0) { - MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json); - property = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), cat); - if (null == property) { - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); - return mav; - } - DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(property); - mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); - }else{ - mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); - } - } - return mav; - } - - - /** - * 新版token验证 - * - * @param token - * @return - */ - private ApiUser checkNewAuthorized(String token) { - Map tokenMap = FangjiaApiUtil.parseToken(token); - if (tokenMap == null) { - return null; - } - // token验证后,拿取出的字段再去数据库验证一遍 - if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { - List params = new ArrayList(); - params.add(new QueryParam("ID", tokenMap.get("userid"))); - ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); - if (apiUser != null) { - if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { - return apiUser; - } - } - } - return null; - } - public void setDistrictService(DistrictService districtService) { - this.districtService = districtService; - } + String kind = ""; + if (StringUtils.isNotBlank(districtBo.getEstateType2())) { + if (districtBo.getEstateType2().indexOf(DistrictKindEnum.bieshu.getValue()) != -1) { + kind = DistrictKindEnum.bieshu.getValue(); + } + if (districtBo.getEstateType2().indexOf("住宅") != -1 || districtBo.getEstateType2().indexOf("小区") != -1) { + if (kind.length() > 1) { + kind = kind + ","; + } + kind = kind + DistrictKindEnum.gongyu.getValue(); + } + districtBo.setKind(kind); - public void setDistrictStatService(DistrictStatService districtStatService) { - this.districtStatService = districtStatService; - } + } + if (StringUtils.isEmpty(districtBo.getKind())) { + districtBo.setKind(DistrictKindEnum.gongyu.getValue()); + } - public void setDistrictHouseService(DistrictHouseService districtHouseService) { - this.districtHouseService = districtHouseService; - } - public void setAutoCompleteService(AutoCompleteService autoCompleteService) { - this.autoCompleteService = autoCompleteService; - } + String[] kinds = districtBo.getKind().split(","); - public void setMenuService(MenuService menuService) { - this.menuService = menuService; - } + List districtStatList = null; + List villaStatList = null; + Date date = new Date(); + if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { + villaStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.bieshu.getValue(), date, 1); + if (kinds.length > 1) { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, 1); + } + } else { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, 1); + } + if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); + return mav; + } - public void setKnowbaseService(KnowbaseService knowbaseService) { - this.knowbaseService = knowbaseService; - } + DistrictStat stat = null; + if (CollectionUtils.isNotEmpty(districtStatList)) { + stat = districtStatList.get(0); + } + if (CollectionUtils.isNotEmpty(villaStatList)) { + stat = villaStatList.get(0); + } - public void setApiUserService(ApiUserService apiUserService) { - this.apiUserService = apiUserService; - } + Map map = new HashMap(1); + map.put("avgPrice", stat.getAvgPrice()); + map.put("weekendMarkup", stat.getWeekendMarkup()); + mav.setModel(map); + return mav; + } - public void setExtractDistrictService(ExtractDistrictService extractDistrictService) { - this.extractDistrictService = extractDistrictService; - } + /** + * 获取小区的历史均价Action + * + * @param city + * @param region + * @param name + * @param weekCount + * @return + */ + public Object historyPriceAction(@Param(name = "city") String city, @Param(name = "name") String name, + @Param(name = "weekCount") Integer weekCount) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + int count = OfcChartUtils.YEAR_COUNT * 7; + if (null != weekCount && weekCount > 0) { + count = weekCount; + } + if (StringUtils.isBlank(name)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名为必填项")); + return mav; + } + District currentDistrict = null; + city = knowbaseService.matchingCityDefaultNull(city); + if (StringUtils.isBlank(city)) { + city = "上海"; + } + Map konwbase = knowbaseService.parseWord(name); + List> districts = (null != konwbase && null != konwbase.get("district_name")) ? (List>) konwbase + .get("district_name") : Collections.EMPTY_LIST; + if (CollectionUtils.isNotEmpty(districts)) { + for (Map district : districts) { + Map extra_data = (Map) district.get("extra_data"); + if (MapUtils.isNotEmpty(extra_data)) { + String region = (String) extra_data.get("region"); + name = (String) district.get("value"); + String tempCity = (String) extra_data.get("city"); + if (!city.equals(tempCity)) { + continue; + } + District d = districtService.findDistrict(new DistrictKey(city, region, name), false); + if (null == d) { + continue; + } + currentDistrict = d; + break; + } + } + } + + if (null == currentDistrict) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "未找到相关小区信息")); + return mav; + } + + // 解析出城市区域小区名楼栋号 + DistrictBo districtBo = this.districtService.findByFullMode(new DistrictKey(currentDistrict.getCity(), currentDistrict + .getRegion(), currentDistrict.getName())); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区不存在,请检查城市名,小区名")); + return mav; + } + if (StringUtils.isEmpty(districtBo.getKind())) { + districtBo.setKind(DistrictKindEnum.gongyu.getValue()); + } + String[] kinds = districtBo.getKind().split(","); + List districtStatList = null; + List villaStatList = null; + Date date = new Date(); + if (ArrayUtils.contains(kinds, DistrictKindEnum.bieshu.getValue())) { + villaStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.bieshu.getValue(), date, count); + if (kinds.length > 1) { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, count); + } + } else { + districtStatList = this.districtStatService.findDistrictStat( + new DistrictKey(districtBo.getCity(), districtBo.getRegion(), districtBo.getName()), + DistrictKindEnum.gongyu.getValue(), date, count); + } + if (CollectionUtils.isEmpty(districtStatList) && CollectionUtils.isEmpty(villaStatList)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "对应的小区无均价数据")); + return mav; + } + districtStatList = (List) OfcChartUtils.fixYDatas(date, districtStatList, count, null); + villaStatList = (List) OfcChartUtils.fixYDatas(date, villaStatList, count, null); + Map map = new HashMap(1); + map.put("stat", + DtoConverter.convertFromDistrictBoList(DataUtil.descCollection(districtStatList), + DataUtil.descCollection(villaStatList))); + mav.setModel(map); + return mav; + } + + /** + * 根据小区名等获取小区属性 + * + * @param uniqueCodes + * @param districtNames + * @param regionNames + * @param cityNames + * @return + */ + public Object fetchDistrictsPropertiesAction(@Param(name = "uniqueCodes") String[] uniqueCodes, + @Param(name = "districtNames") String[] districtNames, @Param(name = "regionNames") String[] regionNames, + @Param(name = "cityNames") String[] cityNames) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + if (uniqueCodes.length * districtNames.length * regionNames.length * cityNames.length == 0) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码、小区名、小区所在区域、小区所在城市必填")); + return mav; + } + if (uniqueCodes.length - districtNames.length + regionNames.length - cityNames.length != 0) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区唯一码数组、小区名数组、小区所在区域数组、小区所在城市数组数量必须相同")); + return mav; + } + + ArrayList keys = new ArrayList(1); + Map key_uniqueCode = new HashMap(1); + for (int i = 0; i < cityNames.length; i++) { + cityNames[i] = this.knowbaseService.matchingCity(cityNames[i]); + regionNames[i] = this.knowbaseService.matchingRegion(regionNames[i], cityNames[i]); + DistrictKey key = new DistrictKey(cityNames[i], regionNames[i], districtNames[i]); + keys.add(key); + key_uniqueCode.put(key, uniqueCodes[i]); + } + Map districtMap = this.districtService.findDistrictByKeyList(keys, false); + Map newDistrictMap = this.districtService.findDistrictByKeyList(keys, true, false); + + Map dtoMap = new HashMap(1); + for (DistrictKey key : districtMap.keySet()) { + District d = districtMap.get(key); + if (null != d) { + String uniqueCode = key_uniqueCode.get(key); + DistrictsPropertiesDto dto = new DistrictsPropertiesDto(); + dto.setUniqueCode(uniqueCode); + dto.setDistrictName(d.getName()); + if (null != newDistrictMap.get(key)) { + dto.setNewDistrict(true); + if (d.getStatus() == 5) { + dto.setOnSale(true); + } + if (StringUtils.isNotBlank(d.getDiscount())) { + dto.setDiscount(true); + } + } + if (null == dto.getOnSale()) { + DistrictHouse dh = this.districtHouseService.findDistrictHouseByDistrictKey(key); + if (dh != null && dh.getSellCount() != 0) { + dto.setOnSale(true); + } + } + if (StringUtils.isNotBlank(d.getVideoUrl())) { + dto.setVideo(true); + } + dtoMap.put(uniqueCode, dto); + } + } + mav.setModel(dtoMap); + return mav; + } + + private boolean isRadiusSearch(DistrictSearchModel model) { + return null != model.getRadius() && model.getRadius() > 0 && StringUtils.isNotBlank(model.getCity()) + && model.getLat() != null && model.getLng() != null && model.getLat() != 0 && model.getLng() != 0; + } + + public Object uploadAction(@Param(name = "token") String token, @Param(name = "data") String data) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + + Map ret = new HashMap(1); + ret.put("RESULT", 500); + + ApiUser apiUser = checkNewAuthorized(token); + if (null == apiUser) { + return mav; + } + + try { + JSONArray disJsonArr = JSONArray.fromObject(data); + for (int i = 0; i < disJsonArr.size(); i++) { + JSONObject disJsonObj = disJsonArr.getJSONObject(i); + ExtractDistrict dis = (ExtractDistrict) JSONObject.toBean(disJsonObj, ExtractDistrict.class); + dis.setSource("open_api"); + dis.setUserId((int) apiUser.getId()); + dis.setCreationDate(new Date()); + dis.setModificationDate(dis.getCreationDate()); + extractDistrictService.save(dis); + } + } catch (JSONException e) { + return mav; + } + + ret.put("RESULT", 200); + return mav; + } + + public Object facilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "region") String region, + @Param(name = "name") String name, HttpServletRequest request) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(name) || StringUtils.isBlank(city) || StringUtils.isBlank(region)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "小区所在城市,小区名,所在区域必必须输入")); + return mav; + } else { + District districtBo = districtService.findDistrict(new DistrictKey(city, region, name), "district"); + if (null == districtBo) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); + return mav; + } + DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(districtBo); + mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); + } + return mav; + } + + // 保存周边配套 + public Object saveFacilitiesAction(DistrictFacilitysModel model) { + model = processParam(model); + if (StringUtils.isNotBlank(model.getId())) { + Map data = new HashMap(); + data.put("kindergarten", model.getKindergarten()); + data.put("primarySchool", model.getPrimarySchool()); + data.put("middleSchool", model.getMiddleSchool()); + data.put("university", model.getUniversity()); + data.put("hospital", model.getHospital()); + data.put("shop", model.getShop()); + data.put("supermarket", model.getSupermarket()); + data.put("foodShop", model.getFoodShop()); + data.put("bus", model.getBus()); + data.put("bank", model.getBank()); + data.put("atm", model.getAtm()); + data.put("metro",model.getMetro()); + districtService.updateDistrictFacilitysById(data, model.getId()); + } else { + DistrictFacilitys districtFacilitys = CommonDtoUtils.transformV(DistrictFacilitys.class, model); + districtService.saveDistrictFacilitys(districtFacilitys); + } + return null; + } + + public static List convertToList(String value) { + List result = new ArrayList(); + + if (value != null && !value.isEmpty()) { + value = value.replaceAll("\\[", "").replaceAll("]", "").replaceAll(" ",""); + String[] splitValues = value.split(","); // 按逗号分割 + + // 遍历数组并过滤空字符串 + for (String str : splitValues) { + if (!str.isEmpty()) { // 只添加非空字符串 + result.add(str); + } + } + } + + return result.isEmpty() ? null : result; // 如果结果为空,则返回 null + } + + public static DistrictFacilitysModel processParam(DistrictFacilitysModel model) { + // 处理每个字段,确保只有非 null 字段才进行处理 + if (model.getKindergarten() != null) { + model.setKindergarten(convertToList(model.getKindergarten().toString())); + } + + if (model.getPrimarySchool() != null) { + model.setPrimarySchool(convertToList(model.getPrimarySchool().toString())); + } + + if (model.getMiddleSchool() != null) { + model.setMiddleSchool(convertToList(model.getMiddleSchool().toString())); + } + + if (model.getUniversity() != null) { + model.setUniversity(convertToList(model.getUniversity().toString())); + } + + if (model.getHospital() != null) { + model.setHospital(convertToList(model.getHospital().toString())); + } + + if (model.getShop() != null) { + model.setShop(convertToList(model.getShop().toString())); + } + + if (model.getSupermarket() != null) { + model.setSupermarket(convertToList(model.getSupermarket().toString())); + } + + if (model.getFoodShop() != null) { + model.setFoodShop(convertToList(model.getFoodShop().toString())); + } + + if (model.getBus() != null) { + model.setBus(convertToList(model.getBus().toString())); + } + + if (model.getBank() != null) { + model.setBank(convertToList(model.getBank().toString())); + } + + if (model.getAtm() != null) { + model.setAtm(convertToList(model.getAtm().toString())); + } + if (model.getMetro() != null) { + model.setMetro(convertToList(model.getMetro().toString())); + } + return model; + } + + /** + * 获取小区图片 + * + * @param districtModel + * @return + */ + public Object listPicAction(DistrictModel districtModel) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(districtModel.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); + return mav; + } + SeaweedImages seaweedImages = seaweedImagesService.findById(districtModel.getId()); + if (seaweedImages != null) { + mav.setModel(BasicModel.buildOKModel().setResult(seaweedImages)); + } else { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "图片数据不存在")); + } + return mav; + } + + + public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(address)) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "地址必须输入")); + return mav; + } else { + String cat = "district"; + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", city); + params.put("address", address); + params.put("category", "property"); + //新匹配接口 + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8"); + District property = null; + if (json != null && json.size() > 0) { + MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json); + property = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), cat); + if (null == property) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); + return mav; + } + DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(property); + mav.setModel(BasicModel.buildOKModel().setResult(facilitys)); + } else { + mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "小区数据不存在")); + } + } + return mav; + } + + + /** + * 新版token验证 + * + * @param token + * @return + */ + private ApiUser checkNewAuthorized(String token) { + Map tokenMap = FangjiaApiUtil.parseToken(token); + if (tokenMap == null) { + return null; + } + // token验证后,拿取出的字段再去数据库验证一遍 + if (StringUtils.isNotBlank(tokenMap.get("userid")) && !"null".equals(tokenMap.get("userid"))) { + List params = new ArrayList(); + params.add(new QueryParam("ID", tokenMap.get("userid"))); + ApiUser apiUser = apiUserService.findApiUserById(Long.parseLong(tokenMap.get("userid"))); + if (apiUser != null) { + if (tokenMap.get("appKey").equals(apiUser.getAppKey())) { + return apiUser; + } + } + } + return null; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setDistrictStatService(DistrictStatService districtStatService) { + this.districtStatService = districtStatService; + } + + public void setDistrictHouseService(DistrictHouseService districtHouseService) { + this.districtHouseService = districtHouseService; + } + + public void setAutoCompleteService(AutoCompleteService autoCompleteService) { + this.autoCompleteService = autoCompleteService; + } + + public void setMenuService(MenuService menuService) { + this.menuService = menuService; + } + + public void setKnowbaseService(KnowbaseService knowbaseService) { + this.knowbaseService = knowbaseService; + } + + public void setApiUserService(ApiUserService apiUserService) { + this.apiUserService = apiUserService; + } + + public void setExtractDistrictService(ExtractDistrictService extractDistrictService) { + this.extractDistrictService = extractDistrictService; + } public DistrictService getDistrictService() { return districtService; @@ -1310,11 +1403,11 @@ public class DistrictController { this.regionStatRentService = regionStatRentService; } - public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) { - this.districtFacilitysService = districtFacilitysService; - } + public void setDistrictFacilitysService(DistrictFacilitysService districtFacilitysService) { + this.districtFacilitysService = districtFacilitysService; + } - public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { - this.seaweedImagesService = seaweedImagesService; - } + public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { + this.seaweedImagesService = seaweedImagesService; + } } From 532c4b5230cc7111fecd70fd3a377b237babb1d8 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 25 Dec 2024 15:14:19 +0800 Subject: [PATCH 175/230] =?UTF-8?q?=E7=99=BE=E5=BA=A6=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0map=5Fpoi=5F2024=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 046585431..ad8c13d64 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -46,8 +46,8 @@ class NewGaoDePoiBatch extends BaseBatch{ @Override void process(Object args) { - run() -// oldPoiMagre() +// run() + oldPoiMagre() } def run(){ @@ -323,7 +323,7 @@ class NewGaoDePoiBatch extends BaseBatch{ rows.each{map-> // def map = rows.get(key) - request.add(new IndexRequest("gaode_map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("map_poi_2024", "_doc", map.data_id).source(map, XContentType.JSON)); // 批量提交数据 if (request.numberOfActions() >= batchSize) { From 667fae514ced67ec197841eb4930ebc71374a373 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 16:23:10 +0800 Subject: [PATCH 176/230] =?UTF-8?q?=E8=AF=84=E4=BC=B0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/fangjia-open/src/main/webapp/static/js/select.js | 2 +- .../fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl | 4 ++-- .../fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-open/src/main/webapp/static/js/select.js b/projects/fangjia-open/src/main/webapp/static/js/select.js index 6adecdba3..75c84511f 100644 --- a/projects/fangjia-open/src/main/webapp/static/js/select.js +++ b/projects/fangjia-open/src/main/webapp/static/js/select.js @@ -144,7 +144,7 @@ $(document).on('click', '.create-actions03', function () { label: true }, { - text: '鍏瘬', + text: '鏅�氫綇瀹�', bold: true, onClick: function () { $("a.create-actions03").empty().text(this.text).addClass("selected") diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl index 1da5a0547..8a35807f4 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/form.ftl @@ -92,9 +92,9 @@
-
寤虹瓚绫诲瀷锛�
+
鎴垮眿绫诲瀷锛�
-

璇烽�夋嫨寤虹瓚绫诲瀷

+

璇烽�夋嫨鎴垮眿绫诲瀷

diff --git a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl index 286d93991..821f5f2a7 100644 --- a/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl +++ b/projects/fangjia-open/src/main/webapp/weiXinEvaluation/report.ftl @@ -189,7 +189,7 @@ <#if evaluation?? && (fjtEvaluation.buildType)! == 3> 浣忓畢 <#elseif fjtEvaluation.buildType! == 8> - 鍏瘬 + 鏅�氫綇瀹� <#elseif fjtEvaluation.buildType! == 4> 鐙珛鍒 <#elseif fjtEvaluation.buildType! == 5> From 143ec1daff56fedf4e4118a145ea129d0cef827f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 25 Dec 2024 16:25:36 +0800 Subject: [PATCH 177/230] update --- .../fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index ad8c13d64..d62216fa2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -358,9 +358,9 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() for(def cityObj : cityList){ - if(!cityObj.city.contains("五指山市")){ - continue - } +// if(!cityObj.city.contains("攀枝花市")){ +// continue +// } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" @@ -463,7 +463,7 @@ class NewGaoDePoiBatch extends BaseBatch{ def findEsPoiByCity(city){ QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)) def map = new HashMap() - ElasticUtils89.executeQuery("192.168.0.89", "didata_map_poi", queryBuilder, { String id, Map d-> + ElasticUtils89.executeQuery("192.168.0.89", "map_poi_2024", queryBuilder, { String id, Map d-> def district = "" if(d.district){ district = d.district From 5a79ace9debccaae9d4aec786c11e638e65e4b20 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 25 Dec 2024 16:36:12 +0800 Subject: [PATCH 178/230] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=94=BE=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data_handle/AutoAddDistrictBatch.groovy | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy index 809fa216c..9d223e038 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AutoAddDistrictBatch.groovy @@ -35,22 +35,22 @@ class AutoAddDistrictBatch extends BaseBatch{ @Override void process(Object args) { -// //查找第三方匹配没有匹配上的小区 -// def citys = CommonDatautils.findAllCity() -// def list = [] -// list << ["城市", "区域", "名称", "成交量", "房源量", "百度地图", "百度类型","高德地图", "高德类型"] -// for(def c : citys){ -// def noMatchDatas = findNoMatchResult(c) -// println c +" 新旧算法未匹配的数据量:"+noMatchDatas.size() -// def rets = checkDatas(noMatchDatas.keySet()) -// list.addAll(rets) -// } + //查找第三方匹配没有匹配上的小区 + def citys = CommonDatautils.findAllCity() + def list = [] + list << ["城市", "区域", "名称", "成交量", "房源量", "百度地图", "百度类型","高德地图", "高德类型"] + for(def c : citys){ + def noMatchDatas = findNoMatchResult(c) + println c +" 新旧算法未匹配的数据量:"+noMatchDatas.size() + def rets = checkDatas(noMatchDatas.keySet()) + list.addAll(rets) + } def fileName = "/home/goojia/gj/add_dist_info.xlsx" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\add_dist_info_1.xlsx" } -// ExcelUtils.write(fileName, list, "待入库数据") + ExcelUtils.write(fileName, list, "待入库数据") check(fileName) From d84a66dbfb0b07b0e2ca9a5cc4c5c56c765ba79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 26 Dec 2024 10:12:22 +0800 Subject: [PATCH 179/230] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/WeiXinEvaluationController.java | 21 +++++++++++++++ .../open/model/weixin/EvaluationModel.java | 27 +++++++++++++++++++ .../service/util/EvaluateParamMap.java | 3 +++ 3 files changed, 51 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java index 716c2156f..2607ac3dc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/WeiXinEvaluationController.java @@ -763,6 +763,27 @@ public class WeiXinEvaluationController { } return model; } + + // 均价对比接口(房价通小程序用) + public Object otherSourcePlusAction(EvaluationModel model){ + + JsonModel jsonMmodel = new JsonModel(); + Map dataMap = new HashMap(); + if(StringUtils.isNotBlank(model.getCityName()) && StringUtils.isNotBlank(model.getRegion()) && StringUtils.isNotBlank(model.getName()) && model.getBuildType() != null){ + String category = getEnCategory(model.getBuildType()); + AverageStatistics averageStatistics = averageStatisticsService.findOneAverageStatictics(model.getCityName(), model.getName(), category); + + Integer tradeAvgPrice = dealPriceService.findDealPrices(model.getCityName(), model.getRegion(), model.getName(), DateUtil.getFirstDayOfMonth(new Date(), -6), DateUtil.getFirstDayOfMonth(new Date(), 0)); + //columnX = "['成交均价(近半年)','房价网挂牌均价','搜房挂牌均价','安居客挂牌均价']"; + dataMap.put("dealPrice", tradeAvgPrice); + dataMap.put("fjw", averageStatistics.getFangjiaPrice()); + dataMap.put("soufang", averageStatistics.getSoufangEsfPrice()); + dataMap.put("anjuke", averageStatistics.getAnjukeEsfPrice()); + } + jsonMmodel.setJsonModel(dataMap); + return jsonMmodel; + } + //均价对比 public Object otherSourceAction(EvaluationModel model){ diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java index cdf645a31..44cc2ca36 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/EvaluationModel.java @@ -57,6 +57,9 @@ public class EvaluationModel extends BaseModel{ private Map> reportFileMap; private UserTrades userTrades; private String address; + private Integer buildType; + private String name; + private String region; public void setId(String id) { @@ -326,4 +329,28 @@ public class EvaluationModel extends BaseModel{ public void setLoan(Integer loan) { this.loan = loan; } + + public Integer getBuildType() { + return buildType; + } + + public void setBuildType(Integer buildType) { + this.buildType = buildType; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java b/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java index 0bc28d9f5..2bc49ea24 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/util/EvaluateParamMap.java @@ -52,6 +52,9 @@ public class EvaluateParamMap { BUILD_TYPE_MAP.put("6", "联排别墅"); BUILD_TYPE_MAP.put("7", "叠加别墅"); BUILD_TYPE_MAP.put("8", "公寓"); + BUILD_TYPE_MAP.put("9","联列住宅"); + BUILD_TYPE_MAP.put("10","花园住宅"); + BUILD_TYPE_MAP.put("11","旧式里弄2"); HOUSE_PROPERTY_MAP.put("1","个人产权"); HOUSE_PROPERTY_MAP.put("2","集体产权"); From 278ce11890c62983893e87739e2482838e1d18ec Mon Sep 17 00:00:00 2001 From: majintao Date: Fri, 27 Dec 2024 11:02:03 +0800 Subject: [PATCH 180/230] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/DistrictController.java | 25 ++++++++++ .../open/model/weixin/DistrictModel.java | 40 +++++++++++++++ .../mongo/fangjia/SeaweedImagesService.java | 4 ++ .../fangjia/SeaweedImagesServiceImpl.java | 50 +++++++++++++++++++ 4 files changed, 119 insertions(+) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java index ba7c22ede..28559ace3 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/DistrictController.java @@ -1285,6 +1285,31 @@ public class DistrictController { } return mav; } + public Object deletePicAction(DistrictModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (StringUtils.isBlank(model.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); + return mav; + } + seaweedImagesService.deleteImage(model.getId(),model.getUrl(),model.getPicType(), model.getRoomType()); + mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "删除成功")); + return mav; + } + public Object addPicAction(DistrictModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + mav.setViewType("rest"); + if (model.getImageUrls()!=null){ + model.setImageUrls(convertToList(model.getImageUrls().toString())); + } + if (StringUtils.isBlank(model.getId())) { + mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); + return mav; + } + seaweedImagesService.addImage(model.getId(),model.getImageUrls(),model.getPicType(), model.getRoomType()); + mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "添加成功")); + return mav; + } public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java index 5f9c5a223..b3c210301 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/weixin/DistrictModel.java @@ -57,6 +57,15 @@ public class DistrictModel extends BaseModel { * 判断是不是友达 */ private boolean isYouDa; + //用于删除和新增 + // 图片url + private String url; + //房型图 或 外景图 + private String PicType; + //几室 + private String roomType; + + private List imageUrls; public Boolean getShowPrice() { return showPrice; @@ -241,4 +250,35 @@ public class DistrictModel extends BaseModel { // public void setBuildName(String buildName) { // this.buildName = buildName; // } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getRoomType() { + return roomType; + } + public void setRoomType(String roomType) { + this.roomType = roomType; + } + + public String getPicType() { + return PicType; + } + + public void setPicType(String picType) { + PicType = picType; + } + + public List getImageUrls() { + return imageUrls; + } + + public void setImageUrls(List imageUrls) { + this.imageUrls = imageUrls; + } } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java index 945437de1..ae7dd522d 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesService.java @@ -12,4 +12,8 @@ import java.util.Map; */ public interface SeaweedImagesService { public SeaweedImages findById(String id); + + public void deleteImage(String id, String url,String picType,String roomType); + public void addImage(String id, List urls,String picType,String roomType); + } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java index a58462040..37143cc5d 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java @@ -3,13 +3,63 @@ package com.fangjia.service.mongo.fangjia; import com.fangjia.dal.mongo.dao.SeaweedImagesDao; import com.fangjia.dal.mongo.model.SeaweedImages; +import java.util.List; +import java.util.Map; + public class SeaweedImagesServiceImpl implements SeaweedImagesService { private SeaweedImagesDao seaweedImagesDao; + @Override public SeaweedImages findById(String id) { return seaweedImagesDao.findById(id); } + @Override + public void deleteImage(String id, String url, String picType, String roomType) { + SeaweedImages seaweedImages = seaweedImagesDao.findById(id); + if ("floorplanPics".equals(picType)) { + Map> floorplanPics = seaweedImages.getFloorplanPics(); + List roomPicList = floorplanPics.get(roomType); + if (roomPicList!=null && !roomPicList.isEmpty()){ + roomPicList.remove(url); + floorplanPics.put(roomType,roomPicList); + seaweedImages.setFloorplanPics(floorplanPics); + } + } else if ("outPics".equals(picType)) { + List outPics = seaweedImages.getOutPics(); + if (outPics != null && !outPics.isEmpty()) { + outPics.remove(url); + seaweedImages.setOutPics(outPics); + } + } + seaweedImagesDao.update(seaweedImages); + } + + @Override + public void addImage(String id, List urls, String picType, String roomType) { + SeaweedImages seaweedImages = seaweedImagesDao.findById(id); + if ("floorplanPics".equals(picType)) { + Map> floorplanPics = seaweedImages.getFloorplanPics(); + List roomPicList = floorplanPics.get(roomType); + if (roomPicList!=null && !roomPicList.isEmpty()){ + roomPicList.addAll(urls); + floorplanPics.put(roomType,roomPicList); + }else { + floorplanPics.put(roomType,urls); + } + seaweedImages.setFloorplanPics(floorplanPics); + } else if ("outPics".equals(picType)) { + List outPics = seaweedImages.getOutPics(); + if (outPics != null && !outPics.isEmpty()) { + outPics.addAll(urls); + seaweedImages.setOutPics(outPics); + }else { + seaweedImages.setOutPics(urls); + } + } + seaweedImagesDao.update(seaweedImages); + } + public void setSeaweedImagesDao(SeaweedImagesDao seaweedImagesDao) { this.seaweedImagesDao = seaweedImagesDao; } From 3790007a0b518e09ebeffd8562d27d94cfb9ce47 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 27 Dec 2024 11:38:53 +0800 Subject: [PATCH 181/230] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index d62216fa2..8bef2fbe0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -358,7 +358,7 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() for(def cityObj : cityList){ -// if(!cityObj.city.contains("攀枝花市")){ +// if(!cityObj.city.contains("商洛市")){ // continue // } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" From 9ccae42cf1c30b2cb4f94043c82fa1c6cc4ecc7b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 27 Dec 2024 13:59:24 +0800 Subject: [PATCH 182/230] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ccbevaluation/ThirdPartyPriceBatch.groovy | 67 ++++++++++++++++++- .../thirdPriceCrawl/SynchDistrictPrice.groovy | 4 +- .../ThirdDataToGatherBatch.groovy | 2 +- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ThirdPartyPriceBatch.groovy index 98612d573..ffd743d5c 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 @@ -30,8 +30,11 @@ class ThirdPartyPriceBatch extends BaseBatch { static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - def sourceMap = ["诸葛找房":"01", "安居客":"02","房天下":"03","链家":"04","城市家居":"05","麦田":"06","贝壳":"07","淘房365":"08","中原":"09","兔博士":"10","Q房":"11","房探":"12", - "房多多":"13","我爱我家":"14","禧泰数据":"15","吉屋网":"16","乐居":"17","21世纪":"18","房产超市":"19","58同城":"20"] + def sourceMap = ["诸葛找房":"01", "安居客":"02","房天下":"03","链家":"04","城市家居":"05","麦田":"06","贝壳":"07", + "淘房365":"08","中原":"09","兔博士":"10","Q房":"11","房探":"12","房多多":"13","我爱我家":"14", + "禧泰数据":"15","吉屋网":"16","乐居":"17","21世纪":"18","房产超市":"19","58同城":"20", + "乐有家":"21","幸福里":"22","中国房价行情":"23","常州住房":"24" + ] def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl", "GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver") @@ -263,6 +266,30 @@ class ThirdPartyPriceBatch extends BaseBatch { if(third.get("csjj_esf_price")){ price_map.csjj_avg_price = third.get("csjj_esf_price") } + + if(third.get("leyoujia_esf_price")){ + price_map.leyoujia_avg_price = third.get("leyoujia_esf_price") + } + + if(third.get("c21_esf_price")){ + price_map.c21_avg_price = third.get("c21_esf_price") + } + + if(third.get("jiwu_esf_price")){ + price_map.jiwu_avg_price = third.get("jiwu_esf_price") + } + + if(third.get("xingfuli_esf_price")){ + price_map.xingfuli_avg_price = third.get("xingfuli_esf_price") + } + + if(third.get("zwfc_esf_price")){ + price_map.zwfc_avg_price = third.get("zwfc_esf_price") + } + + if(third.get("creprice_esf_price")){ + price_map.creprice_avg_price = third.get("creprice_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -313,6 +340,18 @@ class ThirdPartyPriceBatch extends BaseBatch { web = "房产超市" }else if(k=="csjj_avg_price"){ web = "城市居家" + }else if(k=="leyoujia_avg_price"){ + web = "乐有家" + }else if(k=="c21_avg_price"){ + web = "C21" + }else if(k=="jiwu_avg_price"){ + web = "吉屋网" + }else if(k=="xingfuli_avg_price"){ + web = "幸福里" + }else if(k=="creprice_avg_price"){ + web = "中国房价行情" + }else if(k=="zwfc_avg_price"){ + web = "常州住房" } ret << sourceMap.get(web) @@ -603,6 +642,30 @@ class ThirdPartyPriceBatch extends BaseBatch { if(!dataMap.get("csjj_esf_price") && db.get("csjj_esf_price") && db.get("csjj_esf_price")>3000){ dataMap.put("csjj_esf_price", db.get("csjj_esf_price")) } + + if(!dataMap.get("leyoujia_esf_price") && db.get("leyoujia_esf_price") && db.get("leyoujia_esf_price")>3000){ + dataMap.put("leyoujia_esf_price", db.get("leyoujia_esf_price")) + } + + if(!dataMap.get("c21_esf_price") && db.get("c21_esf_price") && db.get("c21_esf_price")>3000){ + dataMap.put("c21_esf_price", db.get("c21_esf_price")) + } + + if(!dataMap.get("jiwu_esf_price") && db.get("jiwu_esf_price") && db.get("jiwu_esf_price")>3000){ + dataMap.put("jiwu_esf_price", db.get("jiwu_esf_price")) + } + + if(!dataMap.get("xingfuli_esf_price") && db.get("xingfuli_esf_price") && db.get("xingfuli_esf_price")>3000){ + dataMap.put("xingfuli_esf_price", db.get("xingfuli_esf_price")) + } + + if(!dataMap.get("creprice_esf_price") && db.get("creprice_esf_price") && db.get("creprice_esf_price")>3000){ + dataMap.put("creprice_esf_price", db.get("creprice_esf_price")) + } + + if(!dataMap.get("zwfc_esf_price") && db.get("zwfc_esf_price") && db.get("zwfc_esf_price")>3000){ + dataMap.put("zwfc_esf_price", db.get("zwfc_esf_price")) + } // if(db.zhugezhaofang_esf_price || db.anjuke_esf_price ||db.soufang_esf_price || db.lianjia_esf_price || db.cityhouse_esf_price || db.maitian_esf_price || db.beike_esf_price || db.get("365house_esf_price") || db.zhongyuan_esf_price || db.tuboshi_esf_price || db.qfang_esf_price || db.fangtan_esf_price || db.fangduoduo_esf_price || db.get("5i5j_esf_price")){ // map.put(key, db) // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy index 5f07adb27..1b9e9e1e1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/SynchDistrictPrice.groovy @@ -27,7 +27,9 @@ class SynchDistrictPrice extends BaseBatch{ // "吉屋":"吉屋","365淘房":"365淘房","我爱我家":"我爱我家","诸葛找房APP":"诸葛找房","贝壳":"贝壳找房","链家":"链家","Q房":"Q房","麦田":"麦田", // "中原地产":"中原地产","安居客小程序":"安居客","搜房":"搜房","乐有家":"乐有家","C21":"C21","城市房产":"城市房产","兔博士PC端":"兔博士" // def esSources = ["搜房":"搜房"] - def esSources = ["我爱我家":"我爱我家","兔博士PC端":"兔博士","吉屋":"吉屋","贝壳找房":"贝壳找房","乐有家":"乐有家","365淘房":"365淘房","诸葛找房APP":"诸葛找房","链家":"链家","Q房":"Q房","麦田":"麦田","中原地产":"中原地产","安居客小程序":"安居客","搜房":"搜房","C21":"C21","城市房产小程序":"城市房产","幸福里APP":"幸福里", "中国房价行情":"中国房价行情","常州住房":"常州住房"] + def esSources = ["安居客小程序":"安居客","搜房":"搜房","诸葛找房APP":"诸葛找房","幸福里APP":"幸福里","吉屋":"吉屋","中国房价行情":"中国房价行情","贝壳找房":"贝壳找房", + "链家":"链家","C21":"C21","城市房产小程序":"城市房产","乐有家":"乐有家","我爱我家":"我爱我家","中原地产":"中原地产","兔博士PC端":"兔博士", + "365淘房":"365淘房","Q房":"Q房","麦田":"麦田","常州住房":"常州住房"] static main(args) { runBatch(new SynchDistrictPrice(), args); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy index aaf9d6380..d1fb7dc6f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/thirdPriceCrawl/ThirdDataToGatherBatch.groovy @@ -33,7 +33,7 @@ class ThirdDataToGatherBatch extends BaseBatch{ "链家":"lianjia_esf","兔博士":"tuboshi_esf","城市房产":"cityhouse_esf","贝壳找房":"beike_esf","Q房":"qfang_esf","Q房(新)":"qfang_new","中原地产(新)":"zhongyuan_new", "乐有家":"leyoujia_esf","乐有家(新)":"leyoujia_new","房探":"fangtan_esf","房多多":"fangdoudou_esf","小资家":"xiaozijia_esf","我爱我家":"5i5j_esf","麦田":"maitian_esf", "房途":"fangtoo_esf","C21":"c21_esf","乐居":"leju_esf","房产超市":"fccs_esf","58同城":"58tc_esf","365淘房":"365house_esf","吉屋":"jiwu_esf","幸福里":"xingfuli_esf", - "中国房价行情":"creprice_esf","常州住房":"zwfc_esf" + "中国房价行情":"creprice_esf","常州住房":"zwfc_esf", "房天下":"fang_esf" ] public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(2) From 37a0d75bc5ba3c20838bc5b0ce03a6fad9f94682 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 27 Dec 2024 15:49:18 +0800 Subject: [PATCH 183/230] =?UTF-8?q?=E5=86=85=E9=83=A8=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FjwThirdPartyPriceBatch.groovy | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy index f1925938e..892ebfea5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/fjwPriceBaseData/FjwThirdPartyPriceBatch.groovy @@ -32,8 +32,11 @@ class FjwThirdPartyPriceBatch extends BaseBatch { static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") DBCollection DIST_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "mongo.db.fangjia.com") - def sourceMap = ["诸葛找房":"01", "安居客":"02","房天下":"03","链家":"04","城市家居":"05","麦田":"06","贝壳":"07","淘房365":"08","中原":"09","兔博士":"10","Q房":"11","房探":"12", - "房多多":"13","我爱我家":"14","禧泰数据":"15","吉屋网":"16","乐居":"17","21世纪":"18","房产超市":"19","58同城":"20"] + def sourceMap = ["诸葛找房":"01", "安居客":"02","房天下":"03","链家":"04","城市家居":"05","麦田":"06","贝壳":"07", + "淘房365":"08","中原":"09","兔博士":"10","Q房":"11","房探":"12","房多多":"13","我爱我家":"14", + "禧泰数据":"15","吉屋网":"16","乐居":"17","21世纪":"18","房产超市":"19","58同城":"20", + "乐有家":"21","幸福里":"22","中国房价行情":"23","常州住房":"24" + ] def pgsqlInstance = Sql.newInstance("jdbc:postgresql://192.168.0.235:5433/fangjia?stringtype=unspecified", @@ -269,6 +272,33 @@ class FjwThirdPartyPriceBatch extends BaseBatch { if(third.get("fccs_esf_price")){ price_map.fccs_avg_price = third.get("fccs_esf_price") } + if(third.get("csjj_esf_price")){ + price_map.csjj_avg_price = third.get("csjj_esf_price") + } + + if(third.get("leyoujia_esf_price")){ + price_map.leyoujia_avg_price = third.get("leyoujia_esf_price") + } + + if(third.get("c21_esf_price")){ + price_map.c21_avg_price = third.get("c21_esf_price") + } + + if(third.get("jiwu_esf_price")){ + price_map.jiwu_avg_price = third.get("jiwu_esf_price") + } + + if(third.get("xingfuli_esf_price")){ + price_map.xingfuli_avg_price = third.get("xingfuli_esf_price") + } + + if(third.get("zwfc_esf_price")){ + price_map.zwfc_avg_price = third.get("zwfc_esf_price") + } + + if(third.get("creprice_esf_price")){ + price_map.creprice_avg_price = third.get("creprice_esf_price") + } dataMap.updatetime = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss") allRows << dataMap } @@ -317,6 +347,20 @@ class FjwThirdPartyPriceBatch extends BaseBatch { web = "我爱我家" }else if(k=="fccs_avg_price"){ web = "房产超市" + }else if(k=="csjj_avg_price"){ + web = "城市居家" + }else if(k=="leyoujia_avg_price"){ + web = "乐有家" + }else if(k=="c21_avg_price"){ + web = "C21" + }else if(k=="jiwu_avg_price"){ + web = "吉屋网" + }else if(k=="xingfuli_avg_price"){ + web = "幸福里" + }else if(k=="creprice_avg_price"){ + web = "中国房价行情" + }else if(k=="zwfc_avg_price"){ + web = "常州住房" } ret << sourceMap.get(web) @@ -470,6 +514,33 @@ class FjwThirdPartyPriceBatch extends BaseBatch { dataMap.put("fccs_esf_price", db.get("fccs_esf_price")) } + if(!dataMap.get("csjj_esf_price") && db.get("csjj_esf_price") && db.get("csjj_esf_price")>3000){ + dataMap.put("csjj_esf_price", db.get("csjj_esf_price")) + } + + if(!dataMap.get("leyoujia_esf_price") && db.get("leyoujia_esf_price") && db.get("leyoujia_esf_price")>3000){ + dataMap.put("leyoujia_esf_price", db.get("leyoujia_esf_price")) + } + + if(!dataMap.get("c21_esf_price") && db.get("c21_esf_price") && db.get("c21_esf_price")>3000){ + dataMap.put("c21_esf_price", db.get("c21_esf_price")) + } + + if(!dataMap.get("jiwu_esf_price") && db.get("jiwu_esf_price") && db.get("jiwu_esf_price")>3000){ + dataMap.put("jiwu_esf_price", db.get("jiwu_esf_price")) + } + + if(!dataMap.get("xingfuli_esf_price") && db.get("xingfuli_esf_price") && db.get("xingfuli_esf_price")>3000){ + dataMap.put("xingfuli_esf_price", db.get("xingfuli_esf_price")) + } + + if(!dataMap.get("creprice_esf_price") && db.get("creprice_esf_price") && db.get("creprice_esf_price")>3000){ + dataMap.put("creprice_esf_price", db.get("creprice_esf_price")) + } + + if(!dataMap.get("zwfc_esf_price") && db.get("zwfc_esf_price") && db.get("zwfc_esf_price")>3000){ + dataMap.put("zwfc_esf_price", db.get("zwfc_esf_price")) + } // if(db.zhugezhaofang_esf_price || db.anjuke_esf_price ||db.soufang_esf_price || db.lianjia_esf_price || db.cityhouse_esf_price || db.maitian_esf_price || db.beike_esf_price || db.get("365house_esf_price") || db.zhongyuan_esf_price || db.tuboshi_esf_price || db.qfang_esf_price || db.fangtan_esf_price || db.fangduoduo_esf_price || db.get("5i5j_esf_price")){ // map.put(key, db) // } From 140470bbc576ba7c2933d207d25a66c67c7de8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 16:09:03 +0800 Subject: [PATCH 184/230] =?UTF-8?q?500=E9=94=99=E8=AF=AF=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=9C=8D=E5=8A=A1=E5=8D=87=E7=BA=A7=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/exceptionhander/FangjiaOpenExceptionHandler.java | 2 +- .../fangjia/open/interceptors/AuthenticationInterceptor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 7848e9b25..3b2021dce 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -35,7 +35,7 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { context.getResponse().setStatus(500); context.getResponse().setCharacterEncoding("UTF-8"); context.getResponse().setContentType("application/json;charset=UTF-8"); - context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务器内部错误\"}"); + context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务升级中...\"}"); } public static String getLocalHostIP() { diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java index b3e60dcbd..c04cab406 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/interceptors/AuthenticationInterceptor.java @@ -111,7 +111,7 @@ public class AuthenticationInterceptor implements Interceptor { String ip = getLocalHostIP(); String token = "2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c"; try { - DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"服务器内部错误,请及时关注!"); + DingDingMessageUtil.sendTextMessage(token, "[OpenApi] "+ip+"Authentication error!"); } catch (Exception e1) { e1.printStackTrace(); } From e880ab201510a2571bbdf084d938034ccf26e640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 16:57:18 +0800 Subject: [PATCH 185/230] 503 --- .../src/main/java/com/fangjia/open/HttpStatusCodeEnum.java | 3 ++- .../open/exceptionhander/FangjiaOpenExceptionHandler.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java b/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java index 402218d72..a20704090 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/HttpStatusCodeEnum.java @@ -8,7 +8,8 @@ public enum HttpStatusCodeEnum { BAD_REQUEST_DECRYPT_ERROR(4002,"加密参数解密失败"), UN_AUTHORIZED(401,"请求未被授权"), SERVER_ERROR(500,"服务器内部错误"), - SERVER_FORBID(403,"请求频繁"); + SERVER_FORBID(403,"请求频繁"), + UPGRADE(503,"服务升级中"); private final int code; private final String msg; diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 3b2021dce..3948d69ca 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -32,10 +32,11 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { } catch (Exception e1) { e1.printStackTrace(); } - context.getResponse().setStatus(500); + // 临时改,后面还原 TODO + context.getResponse().setStatus(503); context.getResponse().setCharacterEncoding("UTF-8"); context.getResponse().setContentType("application/json;charset=UTF-8"); - context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务升级中...\"}"); + context.getResponse().getWriter().println("{\"code\":503, \"msg\":\"服务升级中\"}"); } public static String getLocalHostIP() { From 9dd5a962d1df24742c4c4f1b92469a98ed4afd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 17:23:32 +0800 Subject: [PATCH 186/230] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index adc9f45e3..34bc9be15 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -5879,7 +5879,8 @@ public class PropertyController { districtPriceMap.put("name", district.getName()); districtPriceMap.put("address", district.getAddress()); districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); - districtPriceMap.put("cal_date", model.getCalDate()); + //districtPriceMap.put("cal_date", model.getCalDate()); + districtPriceMap.put("unitPrice", (int)(evaluation.getTotalPrice() / evaluation.getArea())); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); return mav; } else { From f13137cb24d12a09e1a43cd5457ecc83880f16c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 27 Dec 2024 17:24:54 +0800 Subject: [PATCH 187/230] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 34bc9be15..45f930632 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -6,6 +6,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; +import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.Charset; import java.text.ParseException; @@ -5880,7 +5881,7 @@ public class PropertyController { districtPriceMap.put("address", district.getAddress()); districtPriceMap.put("totalPrice", evaluation.getTotalPrice()); //districtPriceMap.put("cal_date", model.getCalDate()); - districtPriceMap.put("unitPrice", (int)(evaluation.getTotalPrice() / evaluation.getArea())); + districtPriceMap.put("unitPrice", new BigDecimal(evaluation.getTotalPrice() / evaluation.getArea()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue()); mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap)); return mav; } else { From 0dc186a334742da684fc142b9d2b9ac50d0ce2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 30 Dec 2024 09:30:37 +0800 Subject: [PATCH 188/230] =?UTF-8?q?=E8=BF=98=E5=8E=9F500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/exceptionhander/FangjiaOpenExceptionHandler.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java index 3948d69ca..7848e9b25 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/exceptionhander/FangjiaOpenExceptionHandler.java @@ -32,11 +32,10 @@ public class FangjiaOpenExceptionHandler implements ExceptionHandler { } catch (Exception e1) { e1.printStackTrace(); } - // 临时改,后面还原 TODO - context.getResponse().setStatus(503); + context.getResponse().setStatus(500); context.getResponse().setCharacterEncoding("UTF-8"); context.getResponse().setContentType("application/json;charset=UTF-8"); - context.getResponse().getWriter().println("{\"code\":503, \"msg\":\"服务升级中\"}"); + context.getResponse().getWriter().println("{\"code\":500, \"msg\":\"服务器内部错误\"}"); } public static String getLocalHostIP() { From ca239765c99dd452bf5cc08555720ecae2f7de20 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 30 Dec 2024 10:43:18 +0800 Subject: [PATCH 189/230] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/NewGaoDePoiBatch.groovy | 11 +++++++---- .../gj/data_handle/ThirdPriceMappingBatch.groovy | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index 8bef2fbe0..fd631c5e0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -357,10 +357,12 @@ class NewGaoDePoiBatch extends BaseBatch{ def oldPoiMagre(){ def cityList = CommonDatautils.findFullNameCitys().reverse() + def index = 0 for(def cityObj : cityList){ -// if(!cityObj.city.contains("商洛市")){ -// continue -// } + index ++ + if(index <140){ + continue + } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\merge_poi\\${cityObj.city}.csv" @@ -369,9 +371,10 @@ class NewGaoDePoiBatch extends BaseBatch{ File file=new File(fileName); if(file.exists()){ def results = readCSV(fileName) - println cityObj.province+" " +cityObj.city+" "+results.size() + println "运行城市:"+cityObj.province+" " +cityObj.city+" "+results.size() if(results){ def megerMap = poiRepeat(cityObj.city, results) + println "待保存:" + cityObj.city +" "+megerMap.size() save(megerMap.values()) } }else{ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy index d1db63f64..7560c83ef 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/ThirdPriceMappingBatch.groovy @@ -40,7 +40,7 @@ class ThirdPriceMappingBatch extends BaseBatch{ @Override public void process(Object args) { // //将新增数据同步过来 - addNemCommunity() +// addNemCommunity() //// //接口进行匹配 match() From 2fc12021c97fa1b0a88e36d907415a4dfad51009 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 2 Jan 2025 13:23:46 +0800 Subject: [PATCH 190/230] =?UTF-8?q?/district/suggest=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/DistrictController.java | 57 ++++++++++--------- .../fangjia/service/api/AutoCompleteBo.java | 11 ++++ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index ed11d51ae..c254da4bf 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -46,7 +46,7 @@ public class DistrictController { private DistrictStatRentService districtStatRentService; private DistrictStatService districtStatService; private UserCityService userCityService; - private FjtUsersService fjtUsersService; + private FjtUsersService fjtUsersService; private SeaweedImagesService seaweedImagesService; @@ -59,14 +59,14 @@ public class DistrictController { * @param keyword * @return */ - public Object suggestAction( @Param(name = "city") String city, @Param(name = "cat") String cat, @Param(name = "keyword") String keyword, - @Param(name = "limit") Integer limit,@Param(name="lat")Double lat, @Param(name="lng")Double lng) { + public Object suggestAction(@Param(name = "city") String city, @Param(name = "cat") String cat, @Param(name = "keyword") String keyword, + @Param(name = "limit") Integer limit, @Param(name = "lat") Double lat, @Param(name = "lng") Double lng) { JsonModel model = new JsonModel(); if (limit == null || limit > 100 || limit <= 0) { limit = 10; } System.out.println(cat + "#" + city + "#" + keyword + "#" + limit + "#" + lng + "#" + lat); - List suggestList = getDistrictByKeyword(cat, city, keyword, limit, lng, lat); + List suggestList = getDistrictByKeyword(cat, city, keyword, limit, lng, lat); model.setJsonModel(suggestList); return model; } @@ -79,14 +79,14 @@ public class DistrictController { String login_user_type = CookieUtils.getCookieValue(request, "login_user_type"); //保存企业用户选择的城市,企业用户7天 - String weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id"); + String weiXinId = CookieUtils.getCookieValue(request, "we_chat_open_id"); // if(StringUtils.isBlank(login_user_type) || StringUtils.isBlank(weiXinId)){ // response.sendRedirect("/coming"); // return null; // } - if("b".equals(login_user_type) || "gb".equals(login_user_type)){ - CacheUtils.putValue(CachePolicyEnum.LONG, UsersInfoService.class, weiXinId + "_city_"+ login_user_type , model.getCityName()); - } + if ("b".equals(login_user_type) || "gb".equals(login_user_type)) { + CacheUtils.putValue(CachePolicyEnum.LONG, UsersInfoService.class, weiXinId + "_city_" + login_user_type, model.getCityName()); + } try { Long userId = Long.parseLong(CookieUtils.getCookieValue(request, "login_user_id")); if (userId != null) { @@ -118,14 +118,14 @@ public class DistrictController { BooleanQuery srQuery1 = new BooleanQuery(); BooleanQuery nameQuery = new BooleanQuery(); - // nameQuery.add(new TermQuery(new Term("district_name", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("alias_std", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("address", keyword)), BooleanClause.Occur.SHOULD); - // nameQuery.add(new TermQuery(new Term("addr_alias_std", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("district_name", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("alias_std", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("address", keyword)), BooleanClause.Occur.SHOULD); + // nameQuery.add(new TermQuery(new Term("addr_alias_std", keyword)), BooleanClause.Occur.SHOULD); nameQuery.add(new TermQuery(new Term("keyword", keyword)), BooleanClause.Occur.SHOULD); //nameQuery.add(new TermQuery(new Term("keyword_cjk", keyword)), BooleanClause.Occur.SHOULD);//这个重要,因seaweed不支持模糊搜索,当输入"中远两"需用此进行搜索 srQuery1.add(nameQuery, BooleanClause.Occur.SHOULD); - if(lat != null && lng != null && lat != 0 && lng != 0){ + if (lat != null && lng != null && lat != 0 && lng != 0) { Map geo = GeocodeUtils.geoconvBaiduToGoogle(lng, lat); SdQuery sdQuery = new SdQuery(); sdQuery.setPoint(geo.get("lat") + "," + geo.get("lng")); @@ -134,7 +134,7 @@ public class DistrictController { params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery)); } params.add(new QueryParam("$sr", new SrQuery(srQuery1))); - List districts = districtService.findAllByParams(params, 0, limit, new String[]{"region", "name", "address", "addrAlias","id"}); + List districts = districtService.findAllByParams(params, 0, limit, new String[]{"region", "name", "address", "addrAlias", "id", "alias"}); List ret = new ArrayList(districts.size()); for (District district : districts) { AutoCompleteBo bo = new AutoCompleteBo(); @@ -143,24 +143,27 @@ public class DistrictController { bo.setDesc(district.getAddress()); bo.setRegion(district.getRegion()); bo.setId(district.getId()); + if (!district.getAlias().isEmpty()) { + bo.setAlias(district.getAlias()); + } ret.add(bo); } return ret; } - public Object districtDetailAction(DistrictModel districtModel,HttpServletRequest request,HttpServletResponse response) { + public Object districtDetailAction(DistrictModel districtModel, HttpServletRequest request, HttpServletResponse response) { //id和name不能同时为空 - if(StringUtils.isBlank(districtModel.getId()) && (StringUtils.isBlank(districtModel.getCityName()) || StringUtils.isBlank(districtModel.getName()))) { + if (StringUtils.isBlank(districtModel.getId()) && (StringUtils.isBlank(districtModel.getCityName()) || StringUtils.isBlank(districtModel.getName()))) { districtModel.setMsg("参数错误"); return districtModel; } District district = null; - if(StringUtils.isNotBlank(districtModel.getId())) { + if (StringUtils.isNotBlank(districtModel.getId())) { district = districtService.findById(districtModel.getId()); - if(district != null) { + if (district != null) { districtModel.setCityName(district.getCity()); districtModel.setRegion(district.getRegion()); districtModel.setName(district.getName()); @@ -176,7 +179,6 @@ public class DistrictController { String userId = CookieUtils.getCookieValue(request, "login_user_id"); - //小区租金 List districtStatRentBos = districtStatRentService.findAllHouseTypeByDistrictStatRent(new DistrictKey(district)); //处理图片链接 @@ -195,8 +197,8 @@ public class DistrictController { districtModel.setDistrictStatBo(districtStatBo); districtModel.setDistrictStatRentBos(districtStatRentBos); - String city=request.getParameter("city"); - boolean is=true; + String city = request.getParameter("city"); + boolean is = true; if (null != districtStatBo && null != districtStatBo.getDefaultDistrictStat()) { double credit = districtStatBo.getDefaultDistrictStat().getCredit(); @@ -215,7 +217,7 @@ public class DistrictController { } else { is = true; } - if(!is){ + if (!is) { try { response.sendRedirect("wrongPrice"); } catch (Exception e) { @@ -225,7 +227,6 @@ public class DistrictController { } - private DistrictStatBo getDistrictStat(DistrictKey districtKey) { District district = districtService.findDistrict(districtKey, true); DistrictStatBo statBo = null; @@ -239,8 +240,8 @@ public class DistrictController { // 同比数据 if (statBo != null) { Date date = DateUtil.getThisWeekInLastYear(); - Date[] dateList = { DateUtil.getBeforeDay(date, 14), DateUtil.getBeforeDay(date, 7), DateUtil.getAfterDay(date, 7), - DateUtil.getAfterDay(date, 14), date }; + Date[] dateList = {DateUtil.getBeforeDay(date, 14), DateUtil.getBeforeDay(date, 7), DateUtil.getAfterDay(date, 7), + DateUtil.getAfterDay(date, 14), date}; DistrictStatBo yearPeriodStatBo = null; Integer markup = Integer.MAX_VALUE; @@ -330,9 +331,9 @@ public class DistrictController { this.userCityService = userCityService; } - public void setFjtUsersService(FjtUsersService fjtUsersService) { - this.fjtUsersService = fjtUsersService; - } + public void setFjtUsersService(FjtUsersService fjtUsersService) { + this.fjtUsersService = fjtUsersService; + } public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { this.seaweedImagesService = seaweedImagesService; diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java index 0b886ac78..3e8c53c6a 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java @@ -2,6 +2,8 @@ package com.fangjia.service.api; import com.fangjia.dal.mongo.model.PriceJiucuo; +import java.util.List; + public class AutoCompleteBo { private String val; private String desc; @@ -20,6 +22,8 @@ public class AutoCompleteBo { private Double lat; private Double lng; + private List alias; + /*** @Deprecated end ****/ public String getName() { @@ -133,4 +137,11 @@ public class AutoCompleteBo { public void setLng(Double lng) { this.lng = lng; } + public List getAlias() { + return alias; + } + + public void setAlias(List alias) { + this.alias = alias; + } } From 8b5fddd200da3dffa5c92443d857ce0dc4e8a3d9 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 2 Jan 2025 13:54:55 +0800 Subject: [PATCH 191/230] =?UTF-8?q?/district/suggest=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/weixin/DistrictController.java | 11 +++++++++-- .../java/com/fangjia/service/api/AutoCompleteBo.java | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java index c254da4bf..442e4b77a 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictController.java @@ -143,8 +143,15 @@ public class DistrictController { bo.setDesc(district.getAddress()); bo.setRegion(district.getRegion()); bo.setId(district.getId()); - if (!district.getAlias().isEmpty()) { - bo.setAlias(district.getAlias()); + if (!district.getName().contains(keyword)) { + if (district.getAlias() != null && !district.getAlias().isEmpty()) { + for (String alias : district.getAlias()) { + if (alias.contains(keyword)){ + bo.setAlias(alias); + break; + } + } + } } ret.add(bo); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java index 3e8c53c6a..9e714a4bb 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/api/AutoCompleteBo.java @@ -22,7 +22,7 @@ public class AutoCompleteBo { private Double lat; private Double lng; - private List alias; + private String alias; /*** @Deprecated end ****/ @@ -137,11 +137,12 @@ public class AutoCompleteBo { public void setLng(Double lng) { this.lng = lng; } - public List getAlias() { + + public String getAlias() { return alias; } - public void setAlias(List alias) { + public void setAlias(String alias) { this.alias = alias; } } From 1a4817c33896b2e7595301179e1a02e23519b49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 3 Jan 2025 17:40:28 +0800 Subject: [PATCH 192/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A6=86=E7=9B=96BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index 4800e992c..bc9ada616 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -747,11 +747,8 @@ public class ComprehensiveQueryController { districtPriceMap.put("city", district.getCity()); districtPriceMap.put("district", district.getRegion()); districtPriceMap.put("name", district.getName()); - if (evaluation.getAvgPrice2b() != null && evaluation.getAvgPrice2b() != 0) { - districtPriceMap.put("avgPrice", evaluation.getAvgPrice2b()); - } else { - districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); - } + // 估值中已经取过评估2B价格,且经过系数调整,不能在覆盖 + districtPriceMap.put("avgPrice", evaluation.getAvgPrice()); Long totalPrice = new BigDecimal((Integer)districtPriceMap.get("avgPrice")).multiply(new BigDecimal(evaluation.getArea())).longValue(); districtPriceMap.put("totalPrice", totalPrice); From 761f6221c15c3416cc5eefc684ea806de6d1a32f Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 6 Jan 2025 07:56:47 +0800 Subject: [PATCH 193/230] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=88=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dealPrice/SynchDealPriceToEs.groovy | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy new file mode 100644 index 000000000..7d06921dc --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -0,0 +1,83 @@ +package com.fangjia.script.dealPrice + +import com.fangjia.core.util.MongoUtils +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.ElasticUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.common.xcontent.XContentType + +class SynchDealPriceToEs { + static DBCollection dealPriceConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) + + static main(args) { + def task = new SynchDealPriceToEs() + task.run() + } + + def run(){ + def batchsize = 1000 + def dbcursor = dealPriceConn.find(new BasicDBObject()).batchSize(batchsize) + def ret = [] + def index = 0 + for(def d : dbcursor){ + ret << d + if(ret.size()>=2000){ + save(ret) + ret.clear() + index ++ + println index + } + } + + } + + + def save(rows){ + BulkRequest request = new BulkRequest(); + int batchSize = 500; + int processedCount = 0; + def client = ElasticUtils.getClient("192.168.0.206") + + for(def map : rows){ +// def map = rows.get(key) + def data_id = map._id.toString() + map.remove("_id") + request.add(new IndexRequest("deal_price", "_doc", data_id).source(map, XContentType.JSON)); + + // 批量提交数据 + if (request.numberOfActions() >= batchSize) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + print "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents "+new Date().format("yyyy-MM-dd HH:mm:ss") + } + + request = new BulkRequest(); + } + } + + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + } + + } + +} From 920b3969b98d0becd0d58b2ac2e28a53eafb5752 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 6 Jan 2025 10:21:32 +0800 Subject: [PATCH 194/230] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index fd631c5e0..a87c0b154 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -360,7 +360,7 @@ class NewGaoDePoiBatch extends BaseBatch{ def index = 0 for(def cityObj : cityList){ index ++ - if(index <140){ + if(index <291){ continue } def fileName = "/home/goojia/gj/poi/old_poi/merge_poi/${cityObj.city}.csv" From 96e13d215ff1ef5d6a2fd891ebd37f272d88bd21 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Mon, 6 Jan 2025 13:29:30 +0800 Subject: [PATCH 195/230] update --- .../dealPrice/SynchDealPriceToEs.groovy | 60 +++++++++++++++---- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 7d06921dc..13ea5e3de 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -3,8 +3,10 @@ package com.fangjia.script.dealPrice import com.fangjia.core.util.MongoUtils import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.util.ElasticUtils +import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject import com.mongodb.DBCollection +import com.mongodb.DBObject import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse import org.elasticsearch.action.index.IndexRequest @@ -21,23 +23,57 @@ class SynchDealPriceToEs { } def run(){ - def batchsize = 1000 - def dbcursor = dealPriceConn.find(new BasicDBObject()).batchSize(batchsize) - def ret = [] - def index = 0 - for(def d : dbcursor){ - ret << d - if(ret.size()>=2000){ - save(ret) - ret.clear() - index ++ - println index + def batchsize = 2000 + def citys = getCityCount() + citys.each{city,count-> + def dbcursor = dealPriceConn.find(new BasicDBObject("city", city)).batchSize(batchsize) + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) +// def index = 0 +// for(def d : dbcursor){ +// ret << d +// if(ret.size()>=2000){ +// save(ret) +// ret.clear() +// index ++ +// println index +// } +// } + } + } + + + def getCityCount(){ + + BasicDBObject match = null; + // 定义聚合管道,按 city 字段分组,并计算每个城市的数量 + DBObject groupFields = new BasicDBObject(); + +// match = new BasicDBObject('$match', new BasicDBObject("level", "城市")); + groupFields.put("_id", new BasicDBObject("city",'$city')) + + groupFields.put("count", new BasicDBObject('$sum', 1)); + DBObject group = new BasicDBObject('$group', groupFields); + + // 执行聚合查询 + AggregationOutput output = dealPriceConn.aggregate(Arrays.asList(group)); + def map = [:] + // 遍历结果 + for (DBObject result : output.results()) { + def obj = (DBObject ) result.get("_id"); + if(obj.get("city")) { + int count = (Integer) result.get("count"); + map.put(obj.get("city"), count) } } - + return map; } + def save(rows){ BulkRequest request = new BulkRequest(); int batchSize = 500; From a1243552838406daee482bdc7f2b42ef91ca6d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 13:54:38 +0800 Subject: [PATCH 196/230] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=94=B9=E4=B8=BA2B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/PropertyController.java | 4 +- .../service/district/DistrictStatService.java | 11 +++++ .../district/DistrictStatServiceImpl.java | 46 +++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index 45f930632..fcee9783d 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -752,7 +752,9 @@ public class PropertyController { districtInfoDto.setDistrict(district.getRegion()); districtInfoDto.setName(district.getName()); districtInfoDto.setAddress(district.getAddress()); - int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); + //int avgPrice = districtStatService.findLatestDistrictAvgPrice(new DistrictKey(district), null); + // 返回2B价格,小程序用,其他也改为2B + int avgPrice = districtStatService.findLatestDistrictAvgPrice2B(new DistrictKey(district), null); if (avgPrice != 0) { districtInfoDto.setAvgPrice(avgPrice); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java index a308e1a67..623a779b0 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatService.java @@ -295,6 +295,17 @@ public interface DistrictStatService { * @return */ public int findLatestDistrictAvgPrice(DistrictKey districtKey,Date weekend); + + /** + * 获得指定时间的小区均价2B + * + * @param districtKey + * @param weekend + * @return + */ + int findLatestDistrictAvgPrice2B(DistrictKey districtKey,Date weekend); + + /** diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index 242aac83e..9d7d57f50 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java @@ -1524,6 +1524,52 @@ public class DistrictStatServiceImpl implements DistrictStatService { return value; } + @Override + public int findLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend) { + if (weekend == null) { + weekend = DateUtil.getFirstDayOfWeek(new Date()); + } + String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_" + DateUtil.formatToYYMMDD(weekend); + Object obj = CacheUtils.getValue(this.getClass(), cacheKey); + if (obj != null) { + return (Integer)obj; + } + Integer value = doFindLatestDistrictAvgPrice2B(districtKey, weekend); + CacheUtils.putValue(CachePolicyEnum.LONG, this.getClass(), cacheKey, value); + return value; + } + + public Integer doFindLatestDistrictAvgPrice2B(DistrictKey districtKey, Date weekend){ + + DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); + if (statBo != null && statBo.getDefaultDistrictStat() != null) { + if (statBo.getDefaultDistrictStat().getAvg_price_2b() > 0) { + return statBo.getDefaultDistrictStat().getAvg_price_2b(); + } + if (statBo.getDefaultDistrictStat().getAvgPrice() > 0) { + return statBo.getDefaultDistrictStat().getAvgPrice(); + } + } + + double r = AveragerUtil.getFloatingRate(districtKey, weekend); + if (StringUtils.isNotBlank(districtKey.getCity()) && StringUtils.isNotBlank(districtKey.getRegion())) { + RegionStat regionStat = regionStatService.findRegionStat(districtKey.getCity(), districtKey.getRegion(), null); + if (regionStat != null) { + return (int) (regionStat.getAvgPrice() * r); + } + } + + if (StringUtils.isNotBlank(districtKey.getCity())) { + RegionStat regionStat = regionStatService.findRegionStat(districtKey.getCity(), null, null); + if (regionStat != null) { + return (int) (regionStat.getAvgPrice() * r); + } + } + + return 0; + + } + public Integer doFindLatestDistrictAvgPrice(DistrictKey districtKey, Date weekend){ DistrictStatBo statBo = districtStatService.findDistrictStat(districtKey); From ad5b9535d7839cf3187049b35dc26d7d18f8cc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 14:05:56 +0800 Subject: [PATCH 197/230] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=93=E5=AD=98key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/service/district/DistrictStatServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java index 9d7d57f50..9d2259bd7 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/district/DistrictStatServiceImpl.java @@ -1529,7 +1529,7 @@ public class DistrictStatServiceImpl implements DistrictStatService { if (weekend == null) { weekend = DateUtil.getFirstDayOfWeek(new Date()); } - String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_" + DateUtil.formatToYYMMDD(weekend); + String cacheKey = districtKey.getCity() + "_" + districtKey.getRegion() + "_" + districtKey.getName() + "_2B_" + DateUtil.formatToYYMMDD(weekend); Object obj = CacheUtils.getValue(this.getClass(), cacheKey); if (obj != null) { return (Integer)obj; From 423e22f54ba6d8d9c582b5b1f7a21f54195fc4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 14:22:50 +0800 Subject: [PATCH 198/230] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E8=B5=B0=E5=8A=BF=E6=94=B9=E4=B8=BA2B=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/weixin/DistrictTrendController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java index 3005fcf82..18c8f0bbe 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/weixin/DistrictTrendController.java @@ -559,7 +559,7 @@ public class DistrictTrendController { DistrictStat ds = districtStatMap.get(key); JSONArray ja = new JSONArray(); ja.put(DateUtil.getBeforeDay(ds.getWeekend(), -1).getTime()); - ja.put(ds.getAvgPrice()); + ja.put(ds.getAvg_price_2b()); districtJa.put(ja); } @@ -567,7 +567,7 @@ public class DistrictTrendController { DistrictStat ds = villaDistrictStatMap.get(key); JSONArray ja = new JSONArray(); ja.put(DateUtil.getBeforeDay(ds.getWeekend(), -1).getTime()); - ja.put(ds.getAvgPrice()); + ja.put(ds.getAvg_price_2b()); villaJa.put(ja); } From 9f5f3812c3413128762f1f29e5eceea0b7f067f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 6 Jan 2025 14:43:17 +0800 Subject: [PATCH 199/230] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E8=B5=B0=E5=8A=BF=E6=94=B9=E4=B8=BA2B=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fangjia/open/controllers/PropertyController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index fcee9783d..89ee1cfcf 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -2429,7 +2429,7 @@ public class PropertyController { item.put("city", districtStat.getCity()); item.put("district", districtStat.getRegion()); item.put("name", districtStat.getDistrictName()); - item.put("avgPrice", districtStat.getAvgPrice()); + item.put("avgPrice", districtStat.getAvg_price_2b()); if ("monthly".equals(model.getPeriodType())) { item.put("date", DateUtil.formatByPattern(districtStat.getWeekend(), "yyyy-MM")); } else { From e7054d75f18438894f9b6cee9abdc4864cb92f77 Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 6 Jan 2025 18:40:36 +0800 Subject: [PATCH 200/230] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/mongo/fangjia/SeaweedImagesServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java index 37143cc5d..e738c4d3b 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/SeaweedImagesServiceImpl.java @@ -3,6 +3,7 @@ package com.fangjia.service.mongo.fangjia; import com.fangjia.dal.mongo.dao.SeaweedImagesDao; import com.fangjia.dal.mongo.model.SeaweedImages; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,6 +41,9 @@ public class SeaweedImagesServiceImpl implements SeaweedImagesService { SeaweedImages seaweedImages = seaweedImagesDao.findById(id); if ("floorplanPics".equals(picType)) { Map> floorplanPics = seaweedImages.getFloorplanPics(); + if (floorplanPics==null){ + floorplanPics = new HashMap>(); + } List roomPicList = floorplanPics.get(roomType); if (roomPicList!=null && !roomPicList.isEmpty()){ roomPicList.addAll(urls); From 30736280a925d28fbf8cb252febe6d6afdec6a49 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 7 Jan 2025 11:02:29 +0800 Subject: [PATCH 201/230] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/dealPrice/SynchDealPriceToEs.groovy | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 13ea5e3de..355968064 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -2,6 +2,7 @@ package com.fangjia.script.dealPrice import com.fangjia.core.util.MongoUtils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject @@ -26,12 +27,17 @@ class SynchDealPriceToEs { def batchsize = 2000 def citys = getCityCount() citys.each{city,count-> - def dbcursor = dealPriceConn.find(new BasicDBObject("city", city)).batchSize(batchsize) - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) + for(def year = 1999;year<=2025;year++){ + def q = new BasicDBObject("city", city) + q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) + def dbcursor = dealPriceConn.find(q).batchSize(batchsize) + println city +" "+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) + } // def index = 0 // for(def d : dbcursor){ // ret << d From 82ef32206fd7e654fb668e244534bf97f6eab25a Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 7 Jan 2025 11:12:54 +0800 Subject: [PATCH 202/230] update --- .../dealPrice/SynchDealPriceToEs.groovy | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 355968064..f9f518cb8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -26,18 +26,21 @@ class SynchDealPriceToEs { def run(){ def batchsize = 2000 def citys = getCityCount() - citys.each{city,count-> - for(def year = 1999;year<=2025;year++){ - def q = new BasicDBObject("city", city) - q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) - def dbcursor = dealPriceConn.find(q).batchSize(batchsize) - println city +" "+ dbcursor.count() - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) - } + citys.each{city,count-> + if(city instanceof String){ + for(def year = 1999;year<=2025;year++){ + def q = new BasicDBObject("city", city) + q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) + def dbcursor = dealPriceConn.find(q).batchSize(batchsize) + println city +" "+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) + } + } + // def index = 0 // for(def d : dbcursor){ // ret << d From 6959b95aeb1579118b7f9be08487f3f75f890a29 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 7 Jan 2025 14:58:55 +0800 Subject: [PATCH 203/230] =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/HouseController.java | 12 ++++++++---- .../com/fangjia/open/model/HouseSearchModel.java | 12 ++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) 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 fba91b6eb..8870454dc 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 @@ -1000,7 +1000,11 @@ public class HouseController { query.setCityDisplay(model.getCity()); Pager pager = new Pager(); pager.setStartRow(0); - pager.setPageSize(5); + if (model.getPageSize() != null && model.getPageSize() > 0) { + pager.setPageSize(model.getPageSize()); + } else { + pager.setPageSize(5); + } query.setPager(pager); query.setTable("latest_seawater"); houses = seawaterDao.findSeawatersByQuery(query); @@ -1303,14 +1307,14 @@ public class HouseController { pager.setPageSize(model.getPageSize()); query.setPager(pager); query.setTable("latest_seawater"); - if (StringUtils.isNotBlank(model.getSortField())){ + if (StringUtils.isNotBlank(model.getSortField())) { query.setSortField(model.getSortField()); - }else { + } else { query.setSortField("p_date"); } if ("asc".equals(model.getSortBy())) { query.setOrder(true); - }else { + } else { query.setOrder(false); } houses = seawaterDao.findSeawatersByQuery(query); diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java index 8f695b729..39fefbbdc 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/model/HouseSearchModel.java @@ -27,6 +27,8 @@ public class HouseSearchModel extends SearchModel { private String district; private String cat; + + private Integer pageSize; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -197,4 +199,14 @@ public class HouseSearchModel extends SearchModel { public void setCat(String cat) { this.cat = cat; } + + @Override + public Integer getPageSize() { + return pageSize; + } + + @Override + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } } From 8539eadacace6d7dd15f1b06d2ace9c0f781c9b3 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 10 Jan 2025 13:58:12 +0800 Subject: [PATCH 204/230] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=89=88=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/webapp/evaluation/reportNew.ftl | 1 + .../src/main/webapp/user/login.ftl | 7 +- .../src/main/webapp/user/regSuccess.ftl | 12 +-- .../src/main/webapp/user/register.ftl | 76 +++++++++++++------ .../src/main/webapp/js/fangjia/v5/register.js | 4 +- 5 files changed, 68 insertions(+), 32 deletions(-) diff --git a/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl b/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl index 65a71bdff..34a2e10c4 100644 --- a/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl +++ b/projects/fangjia-coresite/src/main/webapp/evaluation/reportNew.ftl @@ -36,6 +36,7 @@ .adBoxLoan{width:100%;height:auto;background:none;border:solid 1px #f3f3f3;} .swiper-container{margin:0 1rem;margin-top:2rem;padding-bottom:1.5rem;top:0;} .swiper-container-horizontal > .swiper-pagination{bottom:0;} + .evaluation_content1 .error {top: 380px;} } @media (min-width:450px) and (max-width:600px) { .evaluation_inputInfo .cityChoice,.evaluation_inputInfo > div > div span{width:82%;} diff --git a/projects/fangjia-coresite/src/main/webapp/user/login.ftl b/projects/fangjia-coresite/src/main/webapp/user/login.ftl index ec4a9dc8b..254c8002f 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/login.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/login.ftl @@ -28,7 +28,7 @@ .main{width:768px;padding-top:0;} .main_left{width:768px;height: 650px;} .main_left div{padding-top: 140px;margin-left:30px;} - .main_left div p{text-align: left;} + .main_left div p{text-align: left; margin-top: 20px;} .main_left div p label{font-size: 42px;letter-spacing: 0px;} .main_left div p span{font-size: 30px;} .main_left div p small{display: none;} @@ -38,10 +38,10 @@ @media(max-device-width:414px){ .main_left{background:url(${staticUrl}/images/fangjia/v6/login-1.jpg);background-size: 100% 100%;background-repeat: no-repeat;background-position: center;} .main{width:414px;} - .main_left{width:414px;height: 450px;} + .main_left{width:414px;height: 200px;} .main_right{width:414px;height: 560px;} .main_left div {margin-left: 10px;margin-right: 70px;padding-top: 20px;} - .main_left div p label{font-size: 42px;letter-spacing: 0px;} + .main_left div p label{font-size: 22px;letter-spacing: 0px;} .main_left div p span {font-size: 27px;} .user00{width: 350px;height: 400px;margin-top: 30px;} .inputInfo {margin-bottom: 20px;} @@ -74,6 +74,7 @@ } .error {top: -20px;left: 106px;} + .main_left div {margin-top: 50px;} diff --git a/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl b/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl index 5e5d02187..cd9b74e06 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/regSuccess.ftl @@ -62,12 +62,12 @@ diff --git a/projects/fangjia-coresite/src/main/webapp/user/register.ftl b/projects/fangjia-coresite/src/main/webapp/user/register.ftl index 53127ca3a..6fce0e272 100644 --- a/projects/fangjia-coresite/src/main/webapp/user/register.ftl +++ b/projects/fangjia-coresite/src/main/webapp/user/register.ftl @@ -12,11 +12,11 @@ - + @@ -69,7 +99,7 @@
    -
  • 娆㈣繋娉ㄥ唽鎴夸环缃�
  • +
  • 娆㈣繋娉ㄥ唽鎴夸环缃�
@@ -99,7 +129,7 @@
- +
涓ゆ瀵嗙爜涓嶄竴鑷�
@@ -110,11 +140,13 @@ 鎴戝凡闃呰骞舵帴鍙�銆婄敤鎴峰崗璁��
- -
鎴�
- -

鑻ユ湁浠讳綍闂锛岃鑷寸數瀹㈡湇锛�400-188-3787

+
+ + +
鎴�
+ +

鑻ユ湁浠讳綍闂锛岃鑷寸數瀹㈡湇锛�400-188-3787

diff --git a/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js b/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js index 42db3b6a2..3457900c1 100644 --- a/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js +++ b/projects/fangjia-static/src/main/webapp/js/fangjia/v5/register.js @@ -239,7 +239,9 @@ $(function() { if(refererUrl.endWith("gujia/report")){ refererUrl = refererUrl+"?fangjia=true"; } - window.location.href = wwwUrl + "/user/register/success?backUrl="+refererUrl; + //鎴愬姛椤甸潰 + // window.location.href = wwwUrl + "/user/register/success?backUrl="+refererUrl; + window.location.href = refererUrl } else { if (re.msg == "杈撳叆鐨勯獙璇佺爜涓嶆纭紝璇烽噸鏂拌緭鍏�") { $(".smscode_err").html("鐭俊楠岃瘉鐮侀敊璇�"); From 450e00c2cb43f7343143a9f1ad53f277c7a5b085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 10:53:48 +0800 Subject: [PATCH 205/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComprehensiveQueryController.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index bc9ada616..cf62e6111 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -416,16 +416,18 @@ public class ComprehensiveQueryController { // 原周边POI DistrictFacilitys facilitys = districtFacilitysService.findByDistrict(district); - List hospitalList = facilitys.getHospital(); - List hospitals = new ArrayList(); - for (String hospital : hospitalList) { - if (hospital.endsWith("医院")){ - hospitals.add(hospital); + if (facilitys != null) { + List hospitalList = facilitys.getHospital(); + List hospitals = new ArrayList(); + for (String hospital : hospitalList) { + if (hospital.endsWith("医院")) { + hospitals.add(hospital); + } } + facilitys.setHospital(hospitals); + // 将周边POI数据放到结果集 + houseValueInformation.setSurroundingPoi(facilitys); } - facilitys.setHospital(hospitals); - // 将周边POI数据放到结果集 - houseValueInformation.setSurroundingPoi(facilitys); mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); return mav; } From 7953a15916bc4a1db0d54bcbaddd5ce9482b36a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 10:56:24 +0800 Subject: [PATCH 206/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/ComprehensiveQueryController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index cf62e6111..e181b8af2 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -425,9 +425,11 @@ public class ComprehensiveQueryController { } } facilitys.setHospital(hospitals); - // 将周边POI数据放到结果集 - houseValueInformation.setSurroundingPoi(facilitys); + } else { + facilitys = new DistrictFacilitys(); } + // 将周边POI数据放到结果集 + houseValueInformation.setSurroundingPoi(facilitys); mav.setModel(BasicModel.buildOKModel().setResult(houseValueInformation)); return mav; } From 5369465059adaedac4ab6c4fcff5d8f0887f0c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 12:10:50 +0800 Subject: [PATCH 207/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=A9=E4=B8=9A?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/ComprehensiveQueryController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java index e181b8af2..1088d4648 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/ComprehensiveQueryController.java @@ -245,7 +245,7 @@ public class ComprehensiveQueryController { Map communityAvgPriceParams = new HashMap(); communityAvgPriceParams.put("city", model.getCity()); communityAvgPriceParams.put("address", model.getAddress()); - communityAvgPriceParams.put("category", model.getCategory()); + communityAvgPriceParams.put("category", "district"); communityAvgPriceParams.put("useMap", "true"); communityAvgPriceParams.put("suggestName", String.valueOf(model.getName())); communityAvgPriceParams.put("preciseLevel", "strict"); From 774bef6b488df4be395ea9abd74e336eef82eb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 13 Jan 2025 12:12:29 +0800 Subject: [PATCH 208/230] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=A9=E4=B8=9A?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/open/controllers/AddrSvcController.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 0cb2d58f6..3ed1c5b08 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -719,12 +719,12 @@ public class AddrSvcController { } /** - * 涉农识别-新规则-上海银行 + * 对公涉农识别-新规则-上海银行 * * @param model * @return */ - public Object boscVillageIdentifyAction(AddressModel model) { + public Object boscEnterpriseVillageIdentifyAction(AddressModel model) { RestfulModelAndView mav = new RestfulModelAndView(); if (StringUtils.isBlank(model.getAddress())) { mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); @@ -737,13 +737,11 @@ public class AddrSvcController { params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); String address = model.getAddress(); params.put("address", address); - String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; - params.put("type", type); try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/shzxVillageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/boscEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception e) { try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/shzxVillageIdentify", params, "UTF-8"); + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/boscEnterpriseVillageIdentify", params, "UTF-8"); } catch (Exception ex) { ex.printStackTrace(); } From 00d777ccdcd297ecbee5e0830548fa57ddac237b Mon Sep 17 00:00:00 2001 From: majintao Date: Mon, 13 Jan 2025 15:23:22 +0800 Subject: [PATCH 209/230] =?UTF-8?q?=E4=B8=8A=E6=B5=B7=E9=93=B6=E8=A1=8C?= =?UTF-8?q?=E6=B6=89=E5=86=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open/controllers/AddrSvcController.java | 1232 +++++++++-------- 1 file changed, 653 insertions(+), 579 deletions(-) diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java index 3ed1c5b08..118cf497c 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/AddrSvcController.java @@ -44,10 +44,7 @@ import java.io.IOException; import java.net.Authenticator; import java.net.PasswordAuthentication; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 地址治理 @@ -752,9 +749,89 @@ public class AddrSvcController { int code = json.getInt("msgCode"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); - HashMap map = new HashMap(); + HashMap map = new LinkedHashMap(); //我们的结果 +// "province": "江苏省", +// "city": "苏州市", +// "district": "昆山市", +// "town": "玉山镇", +// "committee": "南星渎村委会", +// "provinceCode": "320000000000", +// "cityCode": "320500000000", +// "districtCode": "320583000000", +// "townCode": "320583100000", +// "committeeCode": "320583100222", +// "typeCode": "220", +// "typeName": "村庄", +// "verifyFlag": "非农", +// "addrVerify": "地址有效", +// "countyLevelCity": "是", +// "administrativeTowns": "否", +// "countyGov": "否", +// "devDistrict": "是", +// "devDistrictName": "昆山高新技术产业开发区", +// "devLevel": "国家级", +// "addrArea": "开发区", +// "countyGovTown": "昆山开发区" JSONObject result = json.getJSONObject("result"); + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("town")) { + map.put("town", result.getString("town")); + } + if (result.containsKey("committee")) { + map.put("committee", result.getString("committee")); + } + if (result.containsKey("provinceCode")) { + map.put("provinceCode", result.getString("provinceCode")); + } + if (result.containsKey("cityCode")) { + map.put("cityCode", result.getString("cityCode")); + } + if (result.containsKey("districtCode")) { + map.put("districtCode", result.getString("districtCode")); + } + if (result.containsKey("townCode")) { + map.put("townCode", result.getString("townCode")); + } + if (result.containsKey("committeeCode")) { + map.put("committeeCode", result.getString("committeeCode")); + } + if (result.containsKey("typeCode")) { + map.put("typeCode", result.getString("typeCode")); + } + if (result.containsKey("typeName")) { + map.put("typeName", result.getString("typeName")); + } + if (result.containsKey("verifyFlag")) { + map.put("verifyFlag", result.getString("verifyFlag")); + } + if (result.containsKey("addrVerify")) { + map.put("addrVerify", result.getString("addrVerify")); + } + if (result.containsKey("countyLevelCity")) { + map.put("countyLevelCity", result.getString("countyLevelCity")); + } + if (result.containsKey("administrativeTowns")) { + map.put("administrativeTowns", result.getString("administrativeTowns")); + } + if (result.containsKey("countyGov")) { + map.put("countyGov", result.getString("countyGov")); + } + if (result.containsKey("devDistrict")) { + map.put("devDistrict", result.getString("devDistrict")); + } + if (result.containsKey("devLevel")) { + map.put("devLevel", result.getString("devLevel")); + } + if (result.containsKey("addrArea")) { map.put("addrArea", result.getString("addrArea")); } @@ -764,9 +841,6 @@ public class AddrSvcController { if (result.containsKey("countyGovTown")) { map.put("countyGovTown", result.getString("countyGovTown")); } - if (result.containsKey("town")) { - map.put("town", result.getString("town")); - } basicModel.setResult(map); mav.setModel(basicModel); } else { @@ -999,276 +1073,60 @@ public class AddrSvcController { } /** - * 涉农识别-新规则-基础版本 - * - * @param model - * @return - */ - public Object villageIdentifyAction(AddressModel model){ + * 涉农识别-新规则-基础版本 + * + * @param model + * @return + */ + public Object villageIdentifyAction(AddressModel model) { - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getAddress())) { - mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); - return mav; - } - - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - String address = model.getAddress(); - params.put("address", address); - String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; - String villageType = "2".equals(model.getType()) ? "对公" : "对私"; - params.put("type", type); - params.put("showFullValue", "2"); - Pager pager = new Pager(1, 1); - List villageIdentifyList = villageIdentifyService.findByCityAndAddress(villageType, model.getCity(), model.getAddress(), pager); - VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null; - if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) { - Map resultMap = new HashMap(); - resultMap.put("province", villageResult.getProvince()); - resultMap.put("city", villageResult.getCity1()); - resultMap.put("district", villageResult.getDistrict()); - resultMap.put("town", villageResult.getTown()); - resultMap.put("committee", villageResult.getCommittee()); - resultMap.put("provinceCode", villageResult.getCityCode()); - resultMap.put("cityCode", villageResult.getCityCode()); - resultMap.put("districtCode", villageResult.getDistrictCode()); - resultMap.put("townCode", villageResult.getTownCode()); - resultMap.put("committeeCode", villageResult.getCommitteeCode()); - resultMap.put("typeCode", villageResult.getTypeCode()); - resultMap.put("typeName", villageResult.getTypeName()); - resultMap.put("verifyFlag", villageResult.getVerifyFlag()); - resultMap.put("addrVerify", villageResult.getAddrVerify()); - resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); - resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); - resultMap.put("countyGov", villageResult.getCountyGov()); - resultMap.put("devDistrict", villageResult.getDevDistrict()); - resultMap.put("devDistrictName", villageResult.getDevDistrictName()); - resultMap.put("devLevel", villageResult.getDevLevel()); - resultMap.put("addrArea", villageResult.getAddrArea()); - BasicModel basicModel = new BasicModel(200, "OK"); - basicModel.setResult(resultMap); - mav.setModel(basicModel); - } else { -// params.put("showTestValue", "2"); - Integer radius = model.getRadius(); - params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - //我们的结果 - JSONObject result = json.getJSONObject("result"); - //我们省级及以上有开发区,直接用我们的结果 - if (result.containsKey("devDistrictName")) { - basicModel.setResult(result); - } else if (!"2".equals(type)) { // 对私的不用齐梁 - basicModel.setResult(result); - } else { - try { - //如果是江苏省或者浙江省 调用齐梁的结果 - if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { - - //结果比较,如果涉农结果不一致 - //调用齐梁 type :1 对公 0 对私 - //我们 type :1 对私 2 对共 - String qltype = "2".equals(type) ? "1" : "0"; - Map map = senRequest(address, qltype); - // 涉农结果不一样 - if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { - // 齐梁县政府但是涉农为农,取我们的结果 扬中市三茅街道中华村永固河路1号 - if ("是".equals(map.get("countyGov")) && "农".equals(map.get("verifyFlag"))) { - basicModel.setResult(result); - mav.setModel(basicModel); - return mav; - } - //有市辖建制镇, 或者城市不一样 用我们 - if (result.containsKey("city")) { - if ("是".equals(result.get("administrativeTowns")) || (!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { - basicModel.setResult(result); - } else { - map.put("addrVerify", "地址有效"); - map.put("addrArea", addrArea(map, type)); - map.put("countyLevelCity", countyLevelCity(map)); - map.put("typeName", areaMap.get(map.get("typeCode"))); - basicModel.setResult(map); - } - } else { - map.put("addrVerify", "地址有效"); - map.put("addrArea", addrArea(map, type)); - map.put("countyLevelCity", countyLevelCity(map)); - map.put("typeName", areaMap.get(map.get("typeCode"))); - basicModel.setResult(map); - } - - } else { - basicModel.setResult(result); - } - - } else { - basicModel.setResult(result); - - } - - } catch (Exception e) { - e.printStackTrace(); - basicModel.setResult(result); - } - - } - - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - } + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); return mav; } - private static Map senRequest (String address, String type) throws IOException { - String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; - String proxyHost = "tunnel2.qg.net"; - int proxyPort = 14186; - final String proxyUsername = "113BBC06"; - final String proxyPassword = "3B2FBD05B0AF"; - String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}"; - String authKey = proxyUsername; - String password = proxyPassword; - String auth = authKey + ":" + password; - String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8"))); - - HttpHost proxy = new HttpHost(proxyHost, proxyPort); - DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); - CloseableHttpClient httpClient = HttpClients.custom() - .setRoutePlanner(routePlanner) - .build(); - HttpPost httpPost = new HttpPost(targetURL); - Authenticator.setDefault(new Authenticator() { - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()); - } - }); - httpPost.setHeader("Content-Type", "application/json"); - httpPost.setHeader("Accept", "*/*"); - httpPost.setHeader("Host", "146.56.217.44:9010"); - httpPost.setHeader("Proxy-Authorization", authHeader); - StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON); - httpPost.setEntity(stringEntity); - - CloseableHttpResponse httpResponse = null; - int retryCount = 2; // 设置重试次数 - int retryDelay = 10; // 设置重试延迟时间(毫秒) - boolean success = false; - for (int i = 0; i < retryCount; i++) { - try { - httpResponse = httpClient.execute(httpPost); - success = true; - break; - } catch (IOException e) { - System.err.println("代理请求失败,进行重试..."); - try { - Thread.sleep(retryDelay); - } catch (InterruptedException ex) { - Thread.currentThread().interrupt(); - } - } - } - - if (success) { - HttpEntity responseEntity = httpResponse.getEntity(); - String responseString = EntityUtils.toString(responseEntity); - - // 使用 Gson 解析 JSON 字符串 - Gson gson = new Gson(); - JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class); - - - // 创建 Map 存储各个值 - Map dataMap = new HashMap(); - - // 获取各个值并放入 Map -// dataMap.put("code", jsonObject.get("code").getAsString()); -// dataMap.put("msg", jsonObject.get("msg").getAsString()); - JsonElement dataElement = jsonObject.get("data"); - if (dataElement != null && !dataElement.isJsonNull() && dataElement.isJsonObject()) { - JsonObject data = dataElement.getAsJsonObject(); - // 在这里继续处理 data 对象 - - if (data != null && !data.isJsonNull()) { - -// dataMap.put("version", data.get("version").getAsString()); - dataMap.put("province", data.get("province").getAsString()); - dataMap.put("city", data.get("city").getAsString()); - dataMap.put("district", data.get("district").getAsString()); - dataMap.put("town", data.get("town").getAsString()); - dataMap.put("committee", data.get("village").getAsString()); - dataMap.put("provinceCode", data.get("provinceCode").getAsString()); - dataMap.put("cityCode", data.get("cityCode").getAsString()); - dataMap.put("districtCode", data.get("districtCode").getAsString()); - dataMap.put("townCode", data.get("townCode").getAsString()); - dataMap.put("committeeCode", data.get("villageCode").getAsString()); - dataMap.put("typeCode", data.get("areaCode").getAsString()); - dataMap.put("verifyFlag", "0".equals(data.get("farmer").getAsString()) ? "非农" : "农"); - dataMap.put("countyGov", "0".equals(data.get("isGovt").getAsString()) ? "否" : "是"); -// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空 - JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray(); - - if (indusParkList != null) { - JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class); - dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString()); - dataMap.put("devLevel", jsonObject1.get("indusParkLevel").getAsString()); - dataMap.put("devDistrict", "是"); - } - } - } - - httpResponse.close(); - return dataMap; - } else { - System.err.println("重试次数已用完,请求失败。"); - } - - httpClient.close(); - return null; - } - - /** - * 涉农识别-新规则-标准版 - * - * @param model - * @return - */ - public Object villageIdentifyStandardAction (AddressModel model){ - - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getAddress())) { - mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); - return mav; - } - - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("address", model.getAddress()); - params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null); - params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null); - params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + String address = model.getAddress(); + params.put("address", address); + String type = StringUtils.isNotBlank(model.getType()) ? model.getType() : null; + String villageType = "2".equals(model.getType()) ? "对公" : "对私"; + params.put("type", type); + params.put("showFullValue", "2"); + Pager pager = new Pager(1, 1); + List villageIdentifyList = villageIdentifyService.findByCityAndAddress(villageType, model.getCity(), model.getAddress(), pager); + VillageIdentify villageResult = CollectionUtils.isNotEmpty(villageIdentifyList) ? villageIdentifyList.get(0) : null; + if (villageResult != null && StringUtils.isNotBlank(villageResult.getVerifyFlag())) { + Map resultMap = new HashMap(); + resultMap.put("province", villageResult.getProvince()); + resultMap.put("city", villageResult.getCity1()); + resultMap.put("district", villageResult.getDistrict()); + resultMap.put("town", villageResult.getTown()); + resultMap.put("committee", villageResult.getCommittee()); + resultMap.put("provinceCode", villageResult.getCityCode()); + resultMap.put("cityCode", villageResult.getCityCode()); + resultMap.put("districtCode", villageResult.getDistrictCode()); + resultMap.put("townCode", villageResult.getTownCode()); + resultMap.put("committeeCode", villageResult.getCommitteeCode()); + resultMap.put("typeCode", villageResult.getTypeCode()); + resultMap.put("typeName", villageResult.getTypeName()); + resultMap.put("verifyFlag", villageResult.getVerifyFlag()); + resultMap.put("addrVerify", villageResult.getAddrVerify()); + resultMap.put("countyLevelCity", villageResult.getCountyLevelCity()); + resultMap.put("administrativeTowns", villageResult.getAdministrativeTowns()); + resultMap.put("countyGov", villageResult.getCountyGov()); + resultMap.put("devDistrict", villageResult.getDevDistrict()); + resultMap.put("devDistrictName", villageResult.getDevDistrictName()); + resultMap.put("devLevel", villageResult.getDevLevel()); + resultMap.put("addrArea", villageResult.getAddrArea()); + BasicModel basicModel = new BasicModel(200, "OK"); + basicModel.setResult(resultMap); + mav.setModel(basicModel); + } else { +// params.put("showTestValue", "2"); Integer radius = model.getRadius(); params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); try { @@ -1281,361 +1139,577 @@ public class AddrSvcController { } } + if (json != null) { int code = json.getInt("msgCode"); String msg = json.getString("msg"); BasicModel basicModel = new BasicModel(code, msg); if (json.containsKey("result")) { - basicModel.setResult(json.get("result")); + //我们的结果 + JSONObject result = json.getJSONObject("result"); + //我们省级及以上有开发区,直接用我们的结果 + if (result.containsKey("devDistrictName")) { + basicModel.setResult(result); + } else if (!"2".equals(type)) { // 对私的不用齐梁 + basicModel.setResult(result); + } else { + try { + //如果是江苏省或者浙江省 调用齐梁的结果 + if ("江苏省".equals(result.getString("province")) || "浙江省".equals(result.getString("province"))) { + + //结果比较,如果涉农结果不一致 + //调用齐梁 type :1 对公 0 对私 + //我们 type :1 对私 2 对共 + String qltype = "2".equals(type) ? "1" : "0"; + Map map = senRequest(address, qltype); + // 涉农结果不一样 + if (!map.get("verifyFlag").equals(result.get("verifyFlag"))) { + // 齐梁县政府但是涉农为农,取我们的结果 扬中市三茅街道中华村永固河路1号 + if ("是".equals(map.get("countyGov")) && "农".equals(map.get("verifyFlag"))) { + basicModel.setResult(result); + mav.setModel(basicModel); + return mav; + } + //有市辖建制镇, 或者城市不一样 用我们 + if (result.containsKey("city")) { + if ("是".equals(result.get("administrativeTowns")) || (!result.get("city").equals(map.get("city")) && StringUtils.isNotBlank(result.getString("city")))) { + basicModel.setResult(result); + } else { + map.put("addrVerify", "地址有效"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); + map.put("typeName", areaMap.get(map.get("typeCode"))); + basicModel.setResult(map); + } + } else { + map.put("addrVerify", "地址有效"); + map.put("addrArea", addrArea(map, type)); + map.put("countyLevelCity", countyLevelCity(map)); + map.put("typeName", areaMap.get(map.get("typeCode"))); + basicModel.setResult(map); + } + + } else { + basicModel.setResult(result); + } + + } else { + basicModel.setResult(result); + + } + + } catch (Exception e) { + e.printStackTrace(); + basicModel.setResult(result); + } + + } + } mav.setModel(basicModel); } else { mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } + } + return mav; + } + + private static Map senRequest(String address, String type) throws IOException { + String targetURL = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; + String proxyHost = "tunnel2.qg.net"; + int proxyPort = 14186; + final String proxyUsername = "113BBC06"; + final String proxyPassword = "3B2FBD05B0AF"; + String jsonData = "{\"address\":\"" + address + "\",\"type\":\"" + type + "\"}"; + String authKey = proxyUsername; + String password = proxyPassword; + String auth = authKey + ":" + password; + String authHeader = "Basic " + new BASE64Encoder().encode(auth.getBytes(Charset.forName("UTF-8"))); + + HttpHost proxy = new HttpHost(proxyHost, proxyPort); + DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); + CloseableHttpClient httpClient = HttpClients.custom() + .setRoutePlanner(routePlanner) + .build(); + HttpPost httpPost = new HttpPost(targetURL); + Authenticator.setDefault(new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()); + } + }); + httpPost.setHeader("Content-Type", "application/json"); + httpPost.setHeader("Accept", "*/*"); + httpPost.setHeader("Host", "146.56.217.44:9010"); + httpPost.setHeader("Proxy-Authorization", authHeader); + StringEntity stringEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON); + httpPost.setEntity(stringEntity); + + CloseableHttpResponse httpResponse = null; + int retryCount = 2; // 设置重试次数 + int retryDelay = 10; // 设置重试延迟时间(毫秒) + boolean success = false; + for (int i = 0; i < retryCount; i++) { + try { + httpResponse = httpClient.execute(httpPost); + success = true; + break; + } catch (IOException e) { + System.err.println("代理请求失败,进行重试..."); + try { + Thread.sleep(retryDelay); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + } + + if (success) { + HttpEntity responseEntity = httpResponse.getEntity(); + String responseString = EntityUtils.toString(responseEntity); + + // 使用 Gson 解析 JSON 字符串 + Gson gson = new Gson(); + JsonObject jsonObject = gson.fromJson(responseString, JsonObject.class); + + + // 创建 Map 存储各个值 + Map dataMap = new HashMap(); + + // 获取各个值并放入 Map +// dataMap.put("code", jsonObject.get("code").getAsString()); +// dataMap.put("msg", jsonObject.get("msg").getAsString()); + JsonElement dataElement = jsonObject.get("data"); + if (dataElement != null && !dataElement.isJsonNull() && dataElement.isJsonObject()) { + JsonObject data = dataElement.getAsJsonObject(); + // 在这里继续处理 data 对象 + + if (data != null && !data.isJsonNull()) { + +// dataMap.put("version", data.get("version").getAsString()); + dataMap.put("province", data.get("province").getAsString()); + dataMap.put("city", data.get("city").getAsString()); + dataMap.put("district", data.get("district").getAsString()); + dataMap.put("town", data.get("town").getAsString()); + dataMap.put("committee", data.get("village").getAsString()); + dataMap.put("provinceCode", data.get("provinceCode").getAsString()); + dataMap.put("cityCode", data.get("cityCode").getAsString()); + dataMap.put("districtCode", data.get("districtCode").getAsString()); + dataMap.put("townCode", data.get("townCode").getAsString()); + dataMap.put("committeeCode", data.get("villageCode").getAsString()); + dataMap.put("typeCode", data.get("areaCode").getAsString()); + dataMap.put("verifyFlag", "0".equals(data.get("farmer").getAsString()) ? "非农" : "农"); + dataMap.put("countyGov", "0".equals(data.get("isGovt").getAsString()) ? "否" : "是"); +// dataMap.put("govtAddr", data.get("govtAddr").isJsonNull() ? null : data.get("govtAddr").getAsString()); // 对于可能为 null 的值,需要判断是否为空 + JsonArray indusParkList = data.get("indusParkList").isJsonNull() ? null : data.get("indusParkList").getAsJsonArray(); + + if (indusParkList != null) { + JsonObject jsonObject1 = gson.fromJson(indusParkList.get(0), JsonObject.class); + dataMap.put("devDistrictName", jsonObject1.get("indusParkName").getAsString()); + dataMap.put("devLevel", jsonObject1.get("indusParkLevel").getAsString()); + dataMap.put("devDistrict", "是"); + } + } + } + + httpResponse.close(); + return dataMap; + } else { + System.err.println("重试次数已用完,请求失败。"); + } + + httpClient.close(); + return null; + } + + /** + * 涉农识别-新规则-标准版 + * + * @param model + * @return + */ + public Object villageIdentifyStandardAction(AddressModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getAddress())) { + mav.setModel(BasicModel.buildBadRequestModel("地址不能为空")); return mav; } - - /** - * 地址联想-PRO - * - * @param model - * @return - */ - @Deprecated - public Object addressAssociationAction (AddressModel model){ - - RestfulModelAndView mav = new RestfulModelAndView(); - if (StringUtils.isBlank(model.getKeywords()) && (StringUtils.isBlank(model.getLat()) && StringUtils.isBlank(model.getLng()))) { - mav.setModel(BasicModel.buildBadRequestModel("关键字或经纬度必填一个")); - return mav; + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("address", model.getAddress()); + params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null); + params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null); + params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null); + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + } catch (Exception e) { + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8"); + } catch (Exception ex) { + ex.printStackTrace(); } + } - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); - params.put("keywords", StringUtils.isNotBlank(model.getKeywords()) ? model.getKeywords() : null); - if (StringUtils.isNotBlank(model.getLng()) && StringUtils.isNotBlank(model.getLat())) { - params.put("lat", model.getLat()); - params.put("lng", model.getLng()); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + basicModel.setResult(json.get("result")); } - Integer radius = model.getRadius(); - params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + + /** + * 地址联想-PRO + * + * @param model + * @return + */ + @Deprecated + public Object addressAssociationAction(AddressModel model) { + + RestfulModelAndView mav = new RestfulModelAndView(); + if (StringUtils.isBlank(model.getKeywords()) && (StringUtils.isBlank(model.getLat()) && StringUtils.isBlank(model.getLng()))) { + mav.setModel(BasicModel.buildBadRequestModel("关键字或经纬度必填一个")); + return mav; + } + + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + params.put("keywords", StringUtils.isNotBlank(model.getKeywords()) ? model.getKeywords() : null); + if (StringUtils.isNotBlank(model.getLng()) && StringUtils.isNotBlank(model.getLat())) { + params.put("lat", model.getLat()); + params.put("lng", model.getLng()); + } + Integer radius = model.getRadius(); + params.put("radius", (radius != null && radius != 0) ? radius.toString() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/addressAssociation", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - basicModel.setResult(json.get("result")); - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - /** - * 市级行政区划查询接口 - * - * @param model - * @return - */ - public Object listCityAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + basicModel.setResult(json.get("result")); + } + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 市级行政区划查询接口 + * + * @param model + * @return + */ + public Object listCityAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listCity", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - list.add(map); - } - } - } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - /** - * 省级行政区划查询接口 - * - * @param model - * @return - */ - public Object listProvinceAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 省级行政区划查询接口 + * + * @param model + * @return + */ + public Object listProvinceAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listProvince", null, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - list.add(map); - } - } - } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - /** - * 区域级行政区划查询接口 - * - * @param model - * @return - */ - public Object listDistrictAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + /** + * 区域级行政区划查询接口 + * + * @param model + * @return + */ + public Object listDistrictAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listDistrict", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } - - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - if (result.containsKey("district")) { - map.put("district", result.getString("district")); - } - if (result.containsKey("tjjDistrictCode")) { - map.put("districtCode", result.getString("tjjDistrictCode")); - } - list.add(map); - } - } - } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); - } - return mav; } - public Object listTownshipAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); + } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("tjjDistrictCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } + list.add(map); + } + } + } + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + } + return mav; + } + + public Object listTownshipAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("district", StringUtils.isNotBlank(model.getDistrict()) ? model.getDistrict() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/listTownship", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } + } - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - List> list = new ArrayList>(); - if (json.containsKey("result")) { - JSONArray jsonArray = json.getJSONArray("result"); - if (jsonArray != null) { - for (Object o : jsonArray) { - JSONObject result = (JSONObject) o; - HashMap map = new HashMap(); - if (result.containsKey("id")) { - map.put("id", result.getString("id")); - } - if (result.containsKey("province")) { - map.put("province", result.getString("province")); - } - if (result.containsKey("tjjProvinceCode")) { - map.put("provinceCode", result.getString("tjjProvinceCode")); - } - if (result.containsKey("city")) { - map.put("city", result.getString("city")); - } - if (result.containsKey("tjjCityCode")) { - map.put("cityCode", result.getString("tjjCityCode")); - } - if (result.containsKey("district")) { - map.put("district", result.getString("district")); - } - if (result.containsKey("tjjDistrictCode")) { - map.put("districtCode", result.getString("tjjDistrictCode")); - } - if (result.containsKey("street")) { - map.put("street", result.getString("street")); - } - if (result.containsKey("tjjStreetCode")) { - map.put("streetCode", result.getString("tjjStreetCode")); - } - list.add(map); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + List> list = new ArrayList>(); + if (json.containsKey("result")) { + JSONArray jsonArray = json.getJSONArray("result"); + if (jsonArray != null) { + for (Object o : jsonArray) { + JSONObject result = (JSONObject) o; + HashMap map = new HashMap(); + if (result.containsKey("id")) { + map.put("id", result.getString("id")); } + if (result.containsKey("province")) { + map.put("province", result.getString("province")); + } + if (result.containsKey("tjjProvinceCode")) { + map.put("provinceCode", result.getString("tjjProvinceCode")); + } + if (result.containsKey("city")) { + map.put("city", result.getString("city")); + } + if (result.containsKey("tjjCityCode")) { + map.put("cityCode", result.getString("tjjCityCode")); + } + if (result.containsKey("district")) { + map.put("district", result.getString("district")); + } + if (result.containsKey("tjjDistrictCode")) { + map.put("districtCode", result.getString("tjjDistrictCode")); + } + if (result.containsKey("street")) { + map.put("street", result.getString("street")); + } + if (result.containsKey("tjjStreetCode")) { + map.put("streetCode", result.getString("tjjStreetCode")); + } + list.add(map); } } - basicModel.setResult(list); - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } - return mav; + basicModel.setResult(list); + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } + return mav; + } - public Object levelAction (AddressModel model){ - RestfulModelAndView mav = new RestfulModelAndView(); - HttpRequest request = new HttpRequest(); - JSONObject json = null; - Map params = new HashMap(); - params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); - params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); - params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + public Object levelAction(AddressModel model) { + RestfulModelAndView mav = new RestfulModelAndView(); + HttpRequest request = new HttpRequest(); + JSONObject json = null; + Map params = new HashMap(); + params.put("province", StringUtils.isNotBlank(model.getProvince()) ? model.getProvince() : null); + params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : null); + params.put("address", StringUtils.isNotBlank(model.getAddress()) ? model.getAddress() : null); + try { + json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); + } catch (Exception e) { try { json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); - } catch (Exception e) { - try { - json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/addrLevel", params, "UTF-8"); - } catch (Exception ex) { - ex.printStackTrace(); - } + } catch (Exception ex) { + ex.printStackTrace(); } + } - if (json != null) { - int code = json.getInt("msgCode"); - String msg = json.getString("msg"); - BasicModel basicModel = new BasicModel(code, msg); - if (json.containsKey("result")) { - JSONObject result = json.getJSONObject("result"); - basicModel.setResult(result); - } - mav.setModel(basicModel); - } else { - mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); + if (json != null) { + int code = json.getInt("msgCode"); + String msg = json.getString("msg"); + BasicModel basicModel = new BasicModel(code, msg); + if (json.containsKey("result")) { + JSONObject result = json.getJSONObject("result"); + basicModel.setResult(result); } - return mav; - } - - public void setDistrictStatService (DistrictStatService districtStatService){ - this.districtStatService = districtStatService; - } - - public void setDistrictService (DistrictService districtService){ - this.districtService = districtService; - } - - public void setVillageIdentifyService (VillageIdentifyService villageIdentifyService){ - this.villageIdentifyService = villageIdentifyService; + mav.setModel(basicModel); + } else { + mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中...")); } + return mav; } + + public void setDistrictStatService(DistrictStatService districtStatService) { + this.districtStatService = districtStatService; + } + + public void setDistrictService(DistrictService districtService) { + this.districtService = districtService; + } + + public void setVillageIdentifyService(VillageIdentifyService villageIdentifyService) { + this.villageIdentifyService = villageIdentifyService; + } +} From e0aa49ebc3646e12bb77e45944f1a5638ae72047 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 16 Jan 2025 17:29:08 +0800 Subject: [PATCH 210/230] update --- .../java/com/fangjia/core/util/GeoUtils.java | 3 + projects/fangjia-script/pom.xml | 6 + .../script/ccbevaluation/AddSzDealData.groovy | 2 +- .../script/commData/CommonDatautils.groovy | 4 +- .../fangjia/script/gj/ProxyHttpUtils.groovy | 62 +++++ .../gj/coresite/AddUrlToBaiduSpider.groovy | 48 ++++ .../gj/data_handle/AddDevShapeData.groovy | 202 ++++++++++++++ .../gj/data_handle/AddDistrictAddress.groovy | 159 +++++++++-- .../data_handle/AddDistrictShapeBatch.groovy | 2 +- .../script/gj/data_handle/DevProcess.groovy | 28 +- .../script/gj/data_handle/DevQlCheck.groovy | 113 ++++++++ .../gj/data_handle/DevUpdateTestBatch.groovy | 4 +- .../gj/data_handle/GXDdistrictMatch.groovy | 179 +++++++++--- .../gj/data_handle/NewGaoDePoiBatch.groovy | 5 +- .../gj/data_handle/PoiNineSplitBatch.groovy | 2 +- .../gj/data_handle/TownStandardBatch.groovy | 255 +++++++++++++++--- .../data_handle/TownshipStrandUpdate.groovy | 8 +- .../gj/district/DistrictFieldAddBatch.groovy | 43 ++- .../gj/district/FangjiaClientUtils.groovy | 28 ++ .../script/gj/meishubao/MsbPocTest.groovy | 28 +- .../fangjia/script/gj/poc/AddPriceTest.groovy | 44 +-- .../com/fangjia/script/util/GeoHelper.groovy | 161 ++++++++++- .../yinjihaun/amap/GaoDeApiUtils.groovy | 2 +- 23 files changed, 1237 insertions(+), 151 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java index bcb042e67..059a2bcb9 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java @@ -3,6 +3,7 @@ package com.fangjia.core.util; import java.util.HashMap; import java.util.Map; + public class GeoUtils { public static final String LAT ="lat"; @@ -258,6 +259,8 @@ public class GeoUtils { return ret; } + + public static void main(String[] args){ Map location = gps84ToGcj02(31.218024629574998,121.36562884455); System.out.println(location.toString()); diff --git a/projects/fangjia-script/pom.xml b/projects/fangjia-script/pom.xml index e639f76e3..2b61cb696 100644 --- a/projects/fangjia-script/pom.xml +++ b/projects/fangjia-script/pom.xml @@ -537,6 +537,12 @@ 1.70 + + org.locationtech.jts + jts-core + 1.18.2 + + diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy index 4473e1e49..dfd784e71 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/AddSzDealData.groovy @@ -8,7 +8,7 @@ import com.mongodb.DBCollection /** * 深圳公众号成交数据录入 */ -def datas = ExcelUtils.read("D:\\数据\\2024年10月深圳二手房成交.xlsx", 0, 1) +def datas = ExcelUtils.read("D:\\数据\\建行\\房产估值\\成交\\2024年11月深圳二手房成交.xlsx", 0, 1) def lineUrl = "mongodb://developer:G00IDCDEV12385@192.168.0.43:28017"; DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", lineUrl) 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 8e7863c2e..d77e63373 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 @@ -4209,7 +4209,7 @@ class CommonDatautils { static def findAllNewPoiDatas(city){ - String sql = "select pname,cityname,adname,name,address,location,type,id,parent from amap_poi_2024 where cityname='${city}'" + String sql = "select cityname,adname,name,address,location,type,id,parent from amap_poi_2024 where cityname='${city}'" def rets = [] def index= 0 ElasticUtils.executeSqlQuery(sql, { map-> @@ -4222,6 +4222,8 @@ class CommonDatautils { } + + static def findOneThirdNetWorkOffice(city, region, name){ String sql = "select location from office where city='${city}' and region='${region}' and name='${name}'" def map = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy new file mode 100644 index 000000000..72495191d --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/ProxyHttpUtils.groovy @@ -0,0 +1,62 @@ +package com.fangjia.script.gj + +import groovy.json.JsonOutput + +class ProxyHttpUtils { + + static String proxyHost = 'tunnel2.qg.net'; + static Integer proxyPort = 14186; + static String proxyUsername = '113BBC06'; + static String proxyPassword = '3B2FBD05B0AF'; + + static String getProxyResult(targetUrl, data){ + // 将 JSON 对象转换为字符串 + String jsonData = new JsonOutput().toJson(data); + // 创建代理对象 + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); + + // 创建 URL 对象 + URL url = new URL(targetUrl); + + // 创建连接对象 + URLConnection connection = url.openConnection(proxy); + + // 设置代理认证 + java.net.Authenticator.setDefault(new java.net.Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray()) + } + }) + + // 设置请求方法为 POST + connection.setRequestMethod("POST"); + + // 允许输出流 + connection.setDoOutput(true); + + // 设置请求头 + connection.setRequestProperty("Content-Type", "application/json"); + + // 发送请求参数 + OutputStream outputStream = connection.getOutputStream(); + outputStream.write(jsonData.getBytes("UTF-8")); + outputStream.flush(); + outputStream.close(); + + // 读取响应 + int responseCode = connection.getResponseCode() + if (responseCode == HttpURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + return response.toString(); + } else { + println "HTTP request failed with response code ${responseCode}"; + } + return null; + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy new file mode 100644 index 000000000..2b03fd2ae --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/coresite/AddUrlToBaiduSpider.groovy @@ -0,0 +1,48 @@ +package com.fangjia.script.gj.coresite + +import java.net.HttpURLConnection +import java.net.URL +import java.io.OutputStream + +// 目标服务器的URL +def targetUrlString = "http://data.zz.baidu.com/urls?site=sh.fangjia.com&token=UaKTemkcQ6I4YvSA" + +// 需要POST的URL数据 +def postData = "https://sh.fangjia.com/zoushi?cityName=%E4%B8%8A%E6%B5%B7&keyword=%E5%A4%A9%E5%B1%B1%E6%96%B0%E8%8B%91" + +// 创建URL对象 +URL url = new URL(targetUrlString) + +// 打开连接 +HttpURLConnection connection = (HttpURLConnection) url.openConnection() +connection.setDoOutput(true) // 表明我们将发送POST请求的输出数据 +connection.setRequestMethod("POST") // 设置请求方法为POST +connection.setRequestProperty("User-Agent", "curl/7.12.1") // 设置User-Agent,尽管这在实际应用中可能并非必需 +connection.setRequestProperty("Content-Type", "text/plain") // 设置内容类型,因为我们将发送纯文本数据 +connection.setRequestProperty("Content-Length", Integer.toString(postData.getBytes().length)) // 设置内容长度 + +// 发送POST数据 +//try (OutputStream os = connection.getOutputStream()) { +// byte[] input = postData.getBytes("utf-8") +// os.write(input, 0, input.length) +//} +outputStream = connection.getOutputStream(); +outputStream.write(postData.getBytes()); +outputStream.flush(); +outputStream.close(); + +// 获取响应码 +int responseCode = connection.getResponseCode() +println "POST Response Code :: $responseCode" + +// 可选:读取响应内容 +def reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8")) +StringBuilder response = new StringBuilder() +String responseLine +while ((responseLine = reader.readLine()) != null) { + response.append(responseLine.trim()) +} +println "Response Body :: ${response.toString()}" + +// 关闭连接 +connection.disconnect() \ No newline at end of file diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy new file mode 100644 index 000000000..4df41ffc4 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDevShapeData.groovy @@ -0,0 +1,202 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.util.BaiDuApiUtils +import com.fangjia.core.util.ExcelUtil +import com.fangjia.core.util.GeoUtils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import groovy.json.JsonSlurper +import groovy.io.FileType +import org.bson.types.ObjectId + +import java.util.regex.Pattern + +class AddDevShapeData { + + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + public static final def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; + DBCollection dev_mapping_CONN = MongoUtils.getCollectionByName2("fangjia", "dev_mapping", MONGO100_URL) + + def devAreaMap = [:] + + static main(args) { + def task = new AddDevShapeData(); + task.run() +// task.streetInfo() + } + + def run(){ + def directoryPath = 'D:\\数据\\数据建设\\开发区外包\\111开发区\\' + def dir = new File(directoryPath) + if (dir.isDirectory()) { +// dir.eachFileRecurse(FileType.FILES) { file -> +// process(file.absolutePath) +// } + addDevInfo("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx") + } else { + println "The specified path is not a directory." + } + } + + def addDevInfo(file){ + ExcelUtils.multiThreadingModify(file, {d-> +// if(!d['I']){ + def name = d['D'] + def q = new BasicDBObject() + q.put('_id',new ObjectId(d['A'])) + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(q) + if(obj){ + if(obj.operator){ + d['H'] = obj.operator + } + if(obj.operate_result){ + d['I'] = obj.operate_result + } + if(obj.m_date){ + d['P'] = DateUtils.formatDateByPattern(obj.m_date, "yyyy-MM-dd") + } + } +// } + devAreaMap.each {k,v-> + if(name.contains(k)){ + d['M'] = v.area_info + d['N'] = v.count + d['O'] = DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd") + } + } + }) + } + + def process(file){ + def retMap = getNewLocations(file) + if(retMap && retMap.gaode.size()>0){ + def q = new BasicDBObject() + q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+retMap.name+'.*$', Pattern.CASE_INSENSITIVE))) + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(q) + if(obj){ + for(def i=0;i0){ + obj.removeField("_id") + obj.put("create_time", new Date()) + obj.put("block", retMap.name+"-地块"+i) + obj.put("shape", resultMap) + obj.put("m_date", new Date()) + obj.put("bd_shape",bd_resultMap) + obj.put("operator", "外包") + obj.put( "operate_result" , "已处理") + DEVELOPMENT_ZONE_43_COLL.save(obj) + }else{ + udata.put("shape", resultMap) + udata.put("m_date", new Date()) + udata.put("bd_shape",bd_resultMap) + udata.put("operate_result" , "已处理") + udata.put("operator", "外包") + DEVELOPMENT_ZONE_43_COLL.update(q, new BasicDBObject('$set', udata), false, false) + } + } + } + } + } + + def getNewLocations(file){ + def jsonObj = readJson(file) + def features = jsonObj.features + def gaode_locations = [] + def baidu_locations = [] + def name = null + def areaMap = [:] + if(features && features.size()==1){ + name = features[0].properties.Name + def coordinates = features[0].geometry.coordinates + + def index = 0 + println name +" 有 "+coordinates.size()+" 块" + + areaMap.count = coordinates.size() + def areas = [] + if(name.contains("泉州经济技术开发区")){ + for(def pointList : coordinates){ + index ++ + def gaode_coordinates = [] + def bd_coordinates = [] + def points = null + if(pointList.size()>1){ + points = pointList + }else{ + points = pointList[0] + } + double area = com.fangjia.script.util.GeoHelper.calculateArea(points) + println name +" 地块"+index + "围栏面积是: ${area} 平方公里" + areas << area + def locationstr = "" + for(def arrs : points){ + def gaode_map = GeoUtils.gps84ToGcj02(arrs[1].toString().toDouble(), arrs[0].toString().toDouble()) + gaode_coordinates << [gaode_map.get("lng"), gaode_map.get("lat")] + + //此高德转百度 有偏差 + def bd_map = GeoUtils.gcj02ToBd09(gaode_map.get("lat"), gaode_map.get("lng")) +// bd_coordinates << [bd_map.get("lng"), bd_map.get("lat")] + // 高德转百度 通过接口有次数限制 +// def baidu = BaiDuApiUtils.geoconv(gaode_map.get("lng"), gaode_map.get("lat"), 3) +// bd_coordinates << [baidu.x, baidu.y] + + locationstr = arrs[0].toString()+","+arrs[1].toString() + def bdpoint = FangjiaClientUtils.convert(locationstr.substring(0, locationstr.length()), 6) + if(bdpoint){ + bd_coordinates << bdpoint + } + } + //整个一串一起传超过4029会报错 +// bd_coordinates = FangjiaClientUtils.convert(locationstr.substring(0, locationstr.length()-1), 6) + gaode_locations << gaode_coordinates + if(bd_coordinates){ + baidu_locations << bd_coordinates + }else{ + println name +" 转换有问题" + } + + } + areaMap.area_info = areas.join("\n") + } + + }else{ + println file +" 有多个" + } + + devAreaMap.put(name, areaMap) + def retMap = [:] + retMap.name = name + retMap.gaode = gaode_locations + retMap.baidu = baidu_locations + return retMap + } + + def readJson(def file){ + def jsonSlurper = new JsonSlurper() + def jsonFile = new File(file) + def jsonText = jsonFile.text + def jsonObj = jsonSlurper.parseText(jsonText) + return jsonObj + } + + def streetInfo(){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区外包\\所有开发区.xlsx", {d-> + def count = dev_mapping_CONN.count(new BasicDBObject("name", d['E']).append("type", "乡镇街道")) + d['L'] = count + }) + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy index d85eefdca..977423309 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictAddress.groovy @@ -23,19 +23,19 @@ import java.util.concurrent.atomic.AtomicLong //补充库中没有详细地址的小区 class AddDistrictAddress extends BaseBatch{ - def fullCityMap = CommonDatautils.queryFullNameCity() - def mcaDistMap = CommonDatautils.queryDistNameCityByMapping() - - DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) - public static final DBCollection seaweed_fence_coll = MongoUtils.getCollectionByName("fangjia_base", "seaweed_fence", "mongo.db.fangjia.com") - - - public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") - - def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; - DBCollection seaweed_fence100_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_fence", MONGO100_URL) - - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) +// def fullCityMap = CommonDatautils.queryFullNameCity() +// def mcaDistMap = CommonDatautils.queryDistNameCityByMapping() +// +// DBCollection BAIDU_POI_COLL = MongoUtils.getCollectionByName("crawl", "poi_wap_spider", "192.168.0.206",27020) +// public static final DBCollection seaweed_fence_coll = MongoUtils.getCollectionByName("fangjia_base", "seaweed_fence", "mongo.db.fangjia.com") +// +// +// public static final DBCollection administrative_mapping_coll = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") +// +// def MONGO100_URL = "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009"; +// DBCollection seaweed_fence100_CONN = MongoUtils.getCollectionByName2("fangjia", "seaweed_fence", MONGO100_URL) +// +// public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) static main(args) { runBatch(new AddDistrictAddress(), args) @@ -43,7 +43,16 @@ class AddDistrictAddress extends BaseBatch{ @Override public void process(Object args) { -// def citys = CommonDatautils.findAllCity() +// addNoAddressDist() //为不精确的地址通过地图补充地址 +// mapOtherAddress() //有精确地址的寻找其它地址 + +// addressSelect() + addrUpdateToDB() + } + + + def addNoAddressDist(){ + // def citys = CommonDatautils.findAllCity() // def index = 0 // def allrets = [] // for(def c : citys){ @@ -65,9 +74,95 @@ class AddDistrictAddress extends BaseBatch{ // allrets.clear() // } // } + updateDistAddr() + } - updateDistAddr() + def mapOtherAddress(){ + def citys = CommonDatautils.findAllCity() + def index = 0 + def allrets = [] + for(def c : citys){ + index ++ + def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "estate_type2", "address", "addr_alias"]) + def radInfoDists = haveRoadInfoDistricts(districts) + println c +" "+index +" 原始小区量:"+districts.size() +" 有详细地址量:"+radInfoDists.size() + radInfoDists = baiduMatch(c, radInfoDists) + radInfoDists = gaodeMatch(c, radInfoDists) + + def rets = [] + rets << ["id", "城市", "区域", "名称", "地址","地址别名", "百度原地址", "百度标准地址", "高德原地址", "高德标准地址"] + for(def d : radInfoDists){ + def addr_alias_str = ''; + if(d.addr_alias){ + addr_alias_str = d.addr_alias.join(" ") + } + rets << [d._id.toString(), d.city, d.region, d.name, d.address, addr_alias_str,d.baidu_old_addr?d.baidu_old_addr:'',d.baidu_address?d.baidu_address:'', d.gaode_old_addr?d.gaode_old_addr:'', d.gaode_addr?d.gaode_addr:""] + } + allrets.addAll(rets) + if(allrets.size()>50000){ + ExcelUtils.write("D:\\数据\\小区\\小区精确地址补充"+index+".xlsx", allrets, "补充地址") + allrets.clear() + } + } + } + + def addressSelect(){ + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\精确地址补充-all-2.xlsx",{d-> + if(d['G']){ + d['O'] = AddressUtil.formatAddress(d['B'], d['G']) + } + if(d['I']){ + d['P'] = AddressUtil.formatAddress(d['B'], d['I']) + } + }) + } + + def addrUpdateToDB(){ + def updateDist = 0 + def addAddrCount = 0 + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\精确地址补充-入库-2.xlsx",{d-> + def dist = CommonDatautils.findDistrictById(d['A']) + if(dist){ + def oldAddrAliasCount = 0 + if(dist.addr_alias){ + oldAddrAliasCount = dist.addr_alias.size() + } + def new_addr_alias = null + if(d['K'].contains("新增百度地址") || d['K'].contains("双地图新增")){ + new_addr_alias = getNewAddressAlias(d['L'], dist.address, dist.addr_alias) + } + if(d['K'].contains("新增高德地址") || d['K'].contains("双地图新增")){ + new_addr_alias = getNewAddressAlias(d['M'], dist.address, dist.addr_alias) + } + if(new_addr_alias){ + updateDist++ + println updateDist + addAddrCount = addAddrCount + new_addr_alias.size()-oldAddrAliasCount + + def udata = new BasicDBObject() + udata.put("addr_alias", new_addr_alias) + udata.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id', dist._id),new BasicDBObject('$set',udata)) + } + } + }) + println "修改小区数:"+updateDist + println "新增地址数:"+addAddrCount + } + + def getNewAddressAlias(new_addr, old_addr, dist_addr_alias){ + def arrs = new_addr.split(";") + def addr_alias = [] + if(dist_addr_alias){ + addr_alias = dist_addr_alias + } + for(def address : arrs){ + if(old_addr!=address && !addr_alias.contains(address)){ + addr_alias << address + } + } + return addr_alias } def updateDistAddr(){ @@ -108,6 +203,19 @@ class AddDistrictAddress extends BaseBatch{ return rets; } + def haveRoadInfoDistricts(districts){ + def rets = [] + for(def d : districts){ + if(d.address){ + def flag = DataHandleUtils.isStandardRoad(d.address) + if(flag){ + rets << d + } + } + } + return rets; + } + def baiduMatch(city,districts){ def data = fullCityMap.get(city) def fullCityName = null @@ -166,7 +274,8 @@ class AddDistrictAddress extends BaseBatch{ retMap.old_addr = temp_address } if(temp_address && DataHandleUtils.isStandardRoad(temp_address)){ - retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_address) +// retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_address) + retMap.new_addr = nineAddrSplit(fullCityName, temp_address) continue } } @@ -175,6 +284,21 @@ class AddDistrictAddress extends BaseBatch{ } + def nineAddrSplit(city, addr){ + def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(city, addr) + def address = "" + if (jsonObject) { + if (jsonObject.get("street") && jsonObject.get("street") != "null") { + address = jsonObject.get("street") + } + if (jsonObject.get("streetNumber") && jsonObject.get("streetNumber") != "null") { + address = address + jsonObject.get("streetNumber") + } + } + return address + } + + def findBaiduDatas(city, district, name){ def q = new BasicDBObject() q.put("city", city) @@ -250,7 +374,8 @@ class AddDistrictAddress extends BaseBatch{ if(temp_addr){ retMap.old_addr = temp_addr if(temp_addr && DataHandleUtils.isStandardRoad(temp_addr)){ - retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_addr ) +// retMap.new_addr = AddressUtil.formatAddress(fullCityName, temp_addr ) + retMap.new_addr = nineAddrSplit(fullCityName, temp_addr) continue } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy index 72d64ea09..796237eb0 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddDistrictShapeBatch.groovy @@ -57,7 +57,7 @@ class AddDistrictShapeBatch extends BaseBatch{ // // } - checkRangeCount() +// checkRangeCount() // synch100() } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index 521be8be2..a6503133c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -84,6 +84,7 @@ class DevProcess { // task.addQiDevResult() //获取齐梁数据结果 // task.updateDevShape()//修改开发区结构 + } @@ -439,30 +440,33 @@ class DevProcess { } def matchDev(){ - ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\新跑省份\\江苏省\\江苏省-齐梁待跑地址.xlsx",{d-> - if(!d['B'] && d['A']){ + ExcelUtils.multiThreadingModify("D:\\数据\\数据建设\\开发区\\高新区.xls",{d-> + if(!d['E'] && d['D']){ def q = new BasicDBObject() -// q.put("name", d['A']) -// q.put("city",d['G']) -// q.put('alias', new BasicDBObject('$in',[d['A']])) - def name = d['A'].replace('经济技术开发区','经济开发区') +// q.put("name", d['D']) + q.put("city",d['C']) +// q.put('alias', new BasicDBObject('$in',[d['D']])) + def name = d['D'] //.replace('经济技术开发区','经济开发区') q.put('name',new BasicDBObject('$regex', Pattern.compile('^.*'+name+'.*$', Pattern.CASE_INSENSITIVE))) //名称 模糊查询 def obj = development_zone_CONN.findOne(q) if(obj){ - d['I'] = "库中有开发区-相似2" + d['G'] = "相似" // d['K'] = obj.name // d['C'] = obj._id.toString() - d['B'] = obj.name -// if(obj.name == d['A']){ -// d['E'] = "相同" + d['E'] = obj.name +// if(obj.name == d['D']){ +// d['G'] = "相同" // }else{ -// d['E'] = "包含" +// d['G'] = "包含" // } + if(obj.shape){ + d['F'] = "是" + } // d['E'] = "别名" // d['F'] = obj.name } } - },1); + },0); } def calAddrDistince(){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy new file mode 100644 index 000000000..f37e917d2 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevQlCheck.groovy @@ -0,0 +1,113 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.util.ExcelUtil +import com.fangjia.script.gj.ProxyHttpUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import net.sf.json.JSONObject +import org.apache.commons.io.FileUtils + +class DevQlCheck { + + //http://146.56.217.44:8088/uams/index + String targetUrl = "http://146.56.217.44:9010/uams/farmer/all/v3/sign"; + DBCollection DEVELOPMENT_ZONE_43_COLL = MongoUtils.getCollectionByName("fangjia_base", "development_zone", "mongo.db.fangjia.com") + + static main(args) { + def task = new DevQlCheck() + task.run() + } + + def run(){ + def devName = "福建龙海经济开发区" + def obj = DEVELOPMENT_ZONE_43_COLL.findOne(new BasicDBObject("name",devName)) + def pois = readCSV("C:\\Users\\gaojuan\\Downloads\\漳州市POI.csv") + def devPois = [] + devPois << ["省", "城市", "区域", "名称", "地址", "类型", "经度", "纬度", "齐梁开发区"] + for(def poi : pois){ + def flag = InsidePolygon.isInArea(poi.lng.toString().toDouble(), poi.lat.toString().toDouble(), InsidePolygon.createPoint4(obj.shape.coordinates)) + if(flag){ + devPois << [poi.province, poi.city, poi.district, poi.name, poi.address, poi.cat, poi.lng, poi.lat] + } + } + println "共:"+devPois.size()+" 个" + ExcelUtils.write("D:\\数据\\数据建设\\开发区外包\\${devName}poi齐梁校验.xlsx", devPois, "齐梁开发区") + def index = 0 + ExcelUtils.modify("D:\\数据\\数据建设\\开发区外包\\${devName}poi齐梁校验.xlsx",{d-> + def address = d['B']+d['C']+d['D'] +// if(d['E']){ +// address = address + d['E'] +// } + Thread.sleep(3000) + def s = getQlResult(address) + d['I'] = s + index ++ + println index+" "+ s + }) + + + } + + def getQlResult(address){ + def params = [ + 'address': address, + 'type': '1' //1:对公 0:对私 + ] + try{ + def str = ProxyHttpUtils.getProxyResult(targetUrl, params); + println address +" "+ str + JSONObject result = JSONObject.fromObject(str) + if(result && result.code==20000){ + def data = result.data + if(data){ + def list = data.indusParkList + if(list && list!="null"){ + def s = "" + for(def r : list){ + s = s + r.indusParkName +"-"+r.indusParkLevel+"\n" + } + return s + } + } + } + }catch(Exception e){ + println address +" "+e.getMessage() + } + + return null + } + + + def readCSV(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + for(line in lines) { + if(line){ + String[] arrs = line.split("\\|@\\|") + def o = new BasicDBObject() + try{ + o.put("province", arrs[0]) + o.put("city", arrs[1]) + o.put("district", arrs[2]) + o.put("name", arrs[3]) + o.put("township", arrs[4]) + o.put("address", arrs[5]) + o.put("cat", arrs[6]) + o.put("lng", arrs[7]) + o.put("lat", arrs[8]) + o.put("data_source", arrs[9]) + rets << o + }catch(Exception e){ + println filename+" 文件异常" + } + + } + + } + return rets; + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy index aaf80284e..50ec412b8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevUpdateTestBatch.groovy @@ -32,7 +32,7 @@ class DevUpdateTestBatch { static main(args) { def task = new DevUpdateTestBatch() - def path = "D:\\数据\\开发区-园区.xlsx"//开发区-园区.xlsx + def path = "D:\\数据\\数据建设\\开发区\\开发区-园区.xlsx"//开发区-园区.xlsx // task.addDev(path) task.addDevAddress(path) // @@ -167,7 +167,7 @@ class DevUpdateTestBatch { println d['A'] +" 不存在" } } - },0) + },1) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy index ee54817e6..8a5fc6eec 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/GXDdistrictMatch.groovy @@ -1,12 +1,14 @@ package com.fangjia.script.gj.data_handle import com.fangjia.core.RegionData +import com.fangjia.core.util.BaiDuApiUtils import com.fangjia.script.ccbevaluation.CcbCommonUtils import com.fangjia.script.ccbevaluation.PgsqlCommUtils import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.EsSearchUtils import com.fangjia.script.gj.district.FangjiaClientUtils import com.fangjia.script.linxsh.util.AddressUtil +import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DbUtils import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils @@ -28,14 +30,24 @@ class GXDdistrictMatch { static main(args) { def task = new GXDdistrictMatch(); // task.run() - task.addOldMatch2() +// task.addOldMatch2() // task.runDb() +// task.hainanMatch() // task.updateDistStatus()//恢复name_cat不正常数据 // task.saveToDB() //保存新增小区 // task.restoreDist()//恢复小区status=0 // task.runMatch() + +// task.checkDist() + + task.addPrice() + + } + + def addPrice(){ + addPrice(row['K'],row['L'],row['M'], row['T'], DateUtils.parseFromTightByPattern('2023-10-01','yyyy-MM-dd'),DateUtils.parseFromTightByPattern('2023-10-25','yyyy-MM-dd')) } def addOldMatch(){ @@ -94,6 +106,46 @@ class GXDdistrictMatch { } + def hainanMatch(){ + def fileName = "D:\\数据\\小区\\海南未匹配地址-1.xlsx" + ExcelUtils.multiThreadingModify(fileName, { d -> + if(d['D'] && d['F'] ){// +// def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(null, d['I']) +// if(jsonObject){ +//// if(jsonObject.get("district") && jsonObject.get("district")!='null'){ +//// d['AO'] = jsonObject.get("district") +//// } +// if(jsonObject.get("province") && jsonObject.get("province")!="null"){ +// d['AP'] = jsonObject.get("province") +// } +// if(jsonObject.get("city") && jsonObject.get("city")!="null"){ +// d['AI'] = jsonObject.get("city") +// } +// } + def formatCity = RegionData.formatCity(d['F']) + def fullCityObj = fullCityMap.get(formatCity) + if(fullCityObj){ +// def fullRegion = regionCodeDataMap.get(d['A']+"#"+d['E']) + + def obj = findDatasByCityAndName(formatCity, d['D'].replaceAll('[·\\(\\)()]|·', '')) + if(obj){ + d['U'] = "楼盘抓取库" + d['V'] = obj.city + d['W'] = obj.region + d['X'] = obj.name + d['Y'] = obj.property_type + d['Z'] = obj.address + def loc = obj.location + if(loc){ + d['AA'] = loc.x + d['AB'] = loc.y + } + } + } + } + }) + } + def runDb(){ def fileName = "D:\\数据\\国信达\\国信达11城未匹配数据.xlsx" ExcelUtils.modify(fileName, { d -> @@ -238,43 +290,41 @@ class GXDdistrictMatch { def saveToDB(){ // def fileName = "D:\\数据\\国信达\\国信达11城未匹配数据.xlsx" - def fileName = "D:\\数据\\数据建设\\小区\\东莞未匹配成交数据.xlsx" + def fileName = "D:\\数据\\小区\\海南新增小区.xlsx" ExcelUtils.modify(fileName, { d -> - if(d['A']){ + if(d['A'] && d['C']){ def udata = new BasicDBObject() udata.put("city", d['A']) udata.put("region", d['B']) def name = d['C'].replaceAll('[·\\(\\)()]|·', '').replace("建设中", "") udata.put("name", name) - def alias = [] - if(d['G'] && name!=d['G']){ - alias << d['G'] - } +// def alias = [] +// if(d['G'] && name!=d['G']){ +// alias << d['G'] +// } // if(d['AI'] && !alias.contains(d['AI']) && d['AI']!=name){ // alias << d['AI'] // } - if(alias){ - udata.put("alias", alias) - } +// if(alias){ +// udata.put("alias", alias) +// } - def addr = AddressUtil.formatAddress(d['A'], d['D']) + def addr = AddressUtil.formatAddress(d['A'], d['E']) if(addr){ udata.put("address", addr) } - udata.put("status", "0") - udata.put("name_cat", "0") + udata.put("status", 0) + udata.put("name_cat", 0) udata.put("cat", "district") - udata.put("username", "高娟") +// udata.put("username", "高娟") def estateType2 = "普通住宅" def type = "" -// if(d['AH']){ -// type = d['AH'] -// }else{ -// type = d['Y'] -// } + if(d['D']){ + type = d['D'] + } if(type){ if(type.contains("别墅")){ estateType2 = "别墅" @@ -282,26 +332,50 @@ class GXDdistrictMatch { estateType2 = "商住" } } - udata.put("estateType2", estateType2) + udata.put("estate_type2", estateType2) + if(d['F']){ Long lng = d['F']*10000000000 - udata.put("lng", lng) - } - if(d['E']){ - Long lat = d['E'] * 10000000000 + Long lat = d['G'] * 10000000000 udata.put("lat", lat) - } - - def s = FangjiaClientUtils.saveOrUpdateDistrict(udata) - def opt = "add" - if(s && s=='成功'){ - saveOptLog(udata.city, udata.region, udata.name, opt) + udata.put("lng", lng) + // 高德转百度 + def baidu = BaiDuApiUtils.geoconv(d['F'].toString().toDouble(), d['G'].toString().toDouble(), 3) + def lng2 = baidu.x + def lat2 = baidu.y + if(lng2){ + Long lng2_new = lng2 *10000000000L + Long lat2_new = lat2 *10000000000L + udata.put("lng2", lng2_new) + udata.put("lat2", lat2_new) } } + udata.put("c_date", new Date()) + udata.put("m_date", new Date()) + def markMap = [:] + markMap.put("data_source", "机器入库") + udata.put("mark_map",markMap) +// udata.put("is_new", 0) + DbUtils.seaweed.save(udata) + saveOptLog(udata.city, udata.region, udata.name, "add") +// def s = FangjiaClientUtils.saveOrUpdateDistrict(udata) + println name +// def opt = "add" +// if(s && s=='成功'){ +// saveOptLog(udata.city, udata.region, udata.name, opt) +// } + } }) } + def checkDist(){ + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\海南未匹配地址-1.xlsx", { d -> + if(d['V'] && d['W'] && d['X']){ + matching(d['V'], d['W'], d, d['X'], null, null) + } + }) + } def match(city, region, d){ d = matching(city, region, d, d['C'].replaceAll('[·\\(\\)()]|·', ''), d['D'], "") @@ -391,7 +465,7 @@ class GXDdistrictMatch { if(rets && rets.size()>=1){ d = setRowValue(rets[0], d, "名称在地址中"+str) }else{ - if (d['D']) { + if (d['D'] && alias) { rets = CommonDatautils.findDistrictByAlias(city, region, alias.replaceAll('[·\\(\\)()]|·', ''), "district") if (rets) { if (rets.size() >= 1) { @@ -449,14 +523,14 @@ class GXDdistrictMatch { def setRowValue(dbo, d, remark){ if (dbo) { - d['V'] = dbo.city - d['W'] = dbo.region - d['X'] = dbo.name - d['Y'] = dbo.estate_type2 - d['Z'] = dbo.status - d['AA'] = dbo.name_cat - d['U'] = remark - d['AH'] = dbo.address +// d['V'] = dbo.city +// d['W'] = dbo.region +// d['X'] = dbo.name +// d['Y'] = dbo.estate_type2 + d['AK'] = dbo.status +// d['AA'] = dbo.name_cat + d['AJ'] = remark +// d['AH'] = dbo.address } return d; } @@ -510,6 +584,33 @@ class GXDdistrictMatch { return null; } + + def findDatasByCityAndName(def city, def name){ + def sql = "select * from community where city='${city}' and name='${name}'" + def rets = [] + ElasticUtils.executeSqlQuery(sql, { d-> + rets << d + println d.property_type + }) + + if(rets){ + def obj = null + for(def r : rets){ + if(r.property_type && (r.property_type.contains("住宅") || r.property_type.contains("别墅") || r.property_type.contains("公寓"))){ + obj = r + break + } + } + if(obj){ + return obj; + }else{ + return rets[0]; + } + + } + return null; + } + def saveOptLog(city, region, name, type){ def obj = new BasicDBObject(); obj.put("city",city); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy index a87c0b154..ea28d2c0b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/NewGaoDePoiBatch.groovy @@ -467,7 +467,7 @@ class NewGaoDePoiBatch extends BaseBatch{ QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("city", city)) def map = new HashMap() ElasticUtils89.executeQuery("192.168.0.89", "map_poi_2024", queryBuilder, { String id, Map d-> - def district = "" + def district = "嘉峪关市" if(d.district){ district = d.district } @@ -477,11 +477,12 @@ class NewGaoDePoiBatch extends BaseBatch{ } def o = new BasicDBObject() o.put("city", d.city) - o.put("district", d.district) + o.put("district", district) o.put("name", d.name) o.put("township", d.township) o.put("location", d.location) regionMap.put(d.name.replace("-","").replace("·",""), o) +// map.put(district, regionMap) map.put(district, regionMap) }) return map diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy index 21432c057..bf7a84c06 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/PoiNineSplitBatch.groovy @@ -6,7 +6,7 @@ import com.fangjia.script.util.ExcelUtils class PoiNineSplitBatch{ - static main(args) { + public static void main(args) { def task = new PoiNineSplitBatch() task.run() } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 4d3e00e32..41588517e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -3,7 +3,9 @@ package com.fangjia.script.gj.data_handle import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.looplineinfo.InsidePolygon import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import org.apache.commons.io.FileUtils import org.elasticsearch.action.bulk.BulkRequest @@ -12,6 +14,13 @@ import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType import org.elasticsearch.index.query.QueryBuilder import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + /** * 区域标准化 * 1.小区库乡镇街道标准化,包含小区,商铺,写字楼 @@ -22,6 +31,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def updateList = [] def addAliasList = [] @@ -38,7 +48,8 @@ class TownStandardBatch extends BaseBatch{ def TownStandard(){ // townStandardByCat("office") - townStandardByPoi() +// townStandardByPoi() + addTownByTownShape() } def townStandardByCat(def cat){ //"三明","龙岩","南平","漳州","福州","厦门","泉州","莆田","宁德", @@ -69,11 +80,15 @@ class TownStandardBatch extends BaseBatch{ updateList << ["数据ID", "城市","区域","乡镇街道","名称","状态", "修改"] addAliasList << ["城市","区域","乡镇街道", "新增别名"] - //浙江,江苏,安徽 - def citys = ['杭州','宁波','温州','嘉兴','台州','湖州','绍兴','金华','舟山','衢州','丽水']//CommonDatautils.findAllCity() + def runProvinces = ["福建省","浙江省","江苏省","安徽省","山东省","甘肃省"] + def citys = CommonDatautils.findAllCity() + def index = 0 for(def city : citys){ - + index++ def data = fullCityMap.get(city) +// if(runProvinces.contains(data.province)){ +// continue +// } def fullCityName = null if(data){ fullCityName = data.city @@ -95,11 +110,16 @@ class TownStandardBatch extends BaseBatch{ def rets = readPoiCsv(fileName) println city +" "+rets.size() if(set.size()>1){ - poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap) + poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap, data) }else{ // haveStreetProcess(city, set, cat) } } + if(updateList.size()>50000){ + ExcelUtils.write("D:\\数据\\乡镇街道待查数据-${index}.xlsx", updateList, "数据") + ExcelUtils.write("D:\\数据\\乡镇街道待查数据-需新增别名-${index}.xlsx", addAliasList, "数据") + updateList.clear() + } }else{ println fileName+" 文件没找到" } @@ -107,8 +127,7 @@ class TownStandardBatch extends BaseBatch{ println "没找到相应的全称:"+city } } - ExcelUtils.write("D:\\数据\\乡镇街道待查数据.xlsx", updateList, "数据") - ExcelUtils.write("D:\\数据\\乡镇街道待查数据-需新增别名.xlsx", addAliasList, "数据") + ExcelUtils.write("D:\\数据\\乡镇街道待查数据-最后.xlsx", updateList, "数据") } def haveRegionProcess(city, fullCityName, townMap, cat, shortRegionNameMap){ @@ -168,7 +187,7 @@ class TownStandardBatch extends BaseBatch{ } - def poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap){ + def poiHaveRegionProcess(fullCityName, townMap, rets, mzbRegionMap, data){ def results = [] if(fullCityName){ for(def d : rets){ @@ -221,21 +240,21 @@ class TownStandardBatch extends BaseBatch{ def m = [:] m.put(d.id, ["township":updateTown]) results << m -// if(results.size()%100==0){ -// updateByEs(results) -// results.clear() -// } - updateList << [d.id, d.city, d.district, d.name,d.township, d.status, updateTown] + if(results.size()%100==0){ + updateByEs(results) + results.clear() + } + updateList << [d.id, d.province, d.city, d.district, d.name,d.township, d.status, updateTown] // println d.city +" "+d.district+" "+d.name +" "+d.township+" 乡镇修改为:"+updateTown }else{ def m = [:] m.put(d.id, ["township":""]) -// results << m -// if(results.size()%100==0){ -// updateByEs(results) -// results.clear() -// } - updateList << [d.id, d.city, d.district, d.name, d.township, d.status, ""] + results << m + if(results.size()%100==0){ + updateByEs(results) + results.clear() + } + updateList << [d.id, d.province, d.city, d.district, d.name, d.township, d.status, ""] println d.city +" "+d.district+" "+d.name +" "+d.township+" 状态修改为:空值" } } @@ -244,10 +263,10 @@ class TownStandardBatch extends BaseBatch{ } } -// if(results.size()>0){ -// updateByEs(results) -// results.clear() -// } + if(results.size()>0){ + updateByEs(results) + results.clear() + } println fullCityName +" 处理完成" } @@ -322,18 +341,194 @@ class TownStandardBatch extends BaseBatch{ if(line){ String[] arrs = line.split("\\|@\\|") def o = new BasicDBObject() - o.put("city", arrs[0]) - o.put("district", arrs[1]) - o.put("name", arrs[2]) - o.put("township", arrs[3]) - o.put("status", arrs[4]) - o.put("id", arrs[5]) - rets << o + try{ + o.put("city", arrs[0]) + o.put("district", arrs[1]) + o.put("name", arrs[2]) + o.put("township", arrs[3]) + o.put("status", arrs[4]) + o.put("id", arrs[5]) + rets << o + }catch(Exception e){ + println arrs + } + } } return rets; } + def readCSV2(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + def index = 0 + for(line in lines) { + if(line && index>=1){ + String[] arrs = line.split(",") + def o = new BasicDBObject() + try{ + o.put("id", arrs[1]) + o.put("province", arrs[2]) + o.put("city", arrs[3]) + o.put("district", arrs[4]) + o.put("lng", arrs[5]) + o.put("lat", arrs[6]) + o.put("data_source", arrs[7]) + rets << o + }catch(Exception e){ + println arrs + } + } + index++ + } + return rets; + } + + def addTownByTownShape(){ + def i = 0 + def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式"] + while(i<50){ + def fileName = "/home/goojia/gj/new_poi/input/no_township_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\原始\\no_township_${i}.csv" + } + File file=new File(fileName); + if(file.exists()) { + def rets = readCSV2(fileName) + def rows = addTownshipBatch(rets) + if (CommonDatautils.isWindow()) { + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + }else{ + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + } + println fileName +" 运行完成" + }else{ + println fileName +" 不存在" + } + i++ + } + } + + def addTownshipBatch(def rets){ + def results = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(rets.size()) + for(def i=0;i= 1) { + addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) + results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source] + } + } + } catch (Exception e) { + e.printStackTrace() + } finally { + latch.countDown() + } + } + }); + } + latch.await() + return results + } + + def addTown(saveObj, townMap, location) { + //在poi本区域下通过乡镇街道围栏选出所在乡镇街道 + def towns = townMap.get(saveObj.district) + if (towns) { + for (def town : towns) { + if (town.shape && town.shape.coordinates) { + def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) + if (flag) { + saveObj.township = town.street + saveObj.town_source = "同区域" + break + } + } + } + } + //忽略poi中的区域 通过乡镇街道围栏选出所在乡镇街道 + if(!saveObj.township){ + def townNames = townMap.keySet() + for(def townName : townNames){ + towns = townMap.get(townName) + for (def town : towns) { + if (town.shape && town.shape.coordinates) { + def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) + if (flag) { + saveObj.township = town.street + saveObj.new_district = town.mzb_district_name + saveObj.town_source = "忽略区域" + break + } + } + } + if(saveObj.township){ + break; + } + } + } + //通过调取地图api接口获取乡镇街道 +// if(!saveObj.township){ +// def gaodeMap = getTownshipInfo(location.lon+","+location.lat) +// if(gaodeMap && gaodeMap.township){ +// saveObj.township = gaodeMap.township +// saveObj.new_district = gaodeMap.district +// saveObj.town_source = "高德API" +// } +// } + return saveObj + } + + + def getTownshipInfo(def glocation){ + def township = null + def district = null + def city = null + def format_addr = null + def stop = false + def count = 0 + while(!stop){ + if(glocation){ + def jsonObject = GaoDeApiUtils.geocode(glocation) + if(jsonObject && jsonObject.regeocode) { + def addressComponent = jsonObject.regeocode.addressComponent + if(addressComponent){ + township = addressComponent.township + district = addressComponent.district + city = addressComponent.city + format_addr = jsonObject.regeocode.formatted_address + + } + } + } + if(district || count>10){ + stop = true + }else{ + count ++ + Thread.sleep(3000) + print "." + } + } + + def map = [:] + map.city = city + map.district = district + map.township = township + map.format_addr = format_addr + return map; + } + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy index d99e249c9..bbe074507 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownshipStrandUpdate.groovy @@ -38,16 +38,16 @@ class TownshipStrandUpdate { static main(args) { def task = new TownshipStrandUpdate() -// task.process() -// task.updateTown() + task.process() + task.updateTown() // task.stat() - task.updateDiffRegionTown() +// task.updateDiffRegionTown() // task.cleanTown() // task.checkTownFromMongo() // task.updateTownMapping() // task.updateDevMapping() - println new Date().getTime() +// println new Date().getTime() // task.updateSpecCityTown() } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index 3b3aed61a..d6e73b168 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -67,7 +67,39 @@ class DistrictFieldAddBatch extends BaseBatch{ ] static main(args) { - runBatch(new DistrictFieldAddBatch(), args) +// runBatch(new DistrictFieldAddBatch(), args) + ExcelUtils.multiThreadingModify("D:\\数据\\小区\\上海别墅.xlsx",{d-> + def dist = CommonDatautils.findDistrict(d['B'], d['G'], d['C'], "district") +// if(dist){ +// d['L'] = dist.loudong_count +// d['M'] = dist.household_count +// d['Q'] = dist.estate_type2 +// } + def list = findEsDatasByCityAndName(d['B'], d['G'], d['C'], "搜房") + if(!list && dist){ + def alias = dist.alias + for(def name : alias){ + list = findEsDatasByCityAndName(d['B'], d['G'], name, "搜房") + if(list){ + d['Z'] = "别名" + } + } + }else{ + d['Z'] = "名称" + } + if(list){ + def obj = list[0] + if(obj.loudong_cnt){ + d['W'] = obj.loudong_cnt + } + + if(obj.households){ + d['X'] = obj.households + } + d['Y'] = obj.url + } + + }) } @Override @@ -361,6 +393,15 @@ class DistrictFieldAddBatch extends BaseBatch{ return list } + + static def findEsDatasByCityAndName(c, district, name, esWebSource){ + def list = [] + ElasticUtils.executeSqlQuery("select * from community where city='${c}' and source='${esWebSource}' and region='${district}' and name='${name}'", {r-> + list << r + }) + return list + } + def fieldUpdate(total,updateRets){ def countMap = [:] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 15e4cc80b..35179b3d9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -398,4 +398,32 @@ class FangjiaClientUtils { return jsonObj; } + + /** + * 经纬度转换 + * 1、高德转百度 2、高德转WGS84 3、百度转高德 4、WGS84转高德 5、百度转WGS84 6、WGS84转百度 + */ + public static def convert(String locationstr, type){ + def jsonObj = null + def content = null + def points = [] + try { + def url = "http://192.168.0.19:31080/FangJiaNlpService/convert?locations="+URLEncoder.encode(locationstr,"UTF-8")+"&coordsys=${type}" + + content = new HttpRequest().newGet(url, null, "utf-8") + jsonObj = JSONObject.fromObject(content) + if(jsonObj && jsonObj.locations){ + def locations = jsonObj.locations + for(def s : locations){ + def arrs = s.split(",") + points = [arrs[0].toString().toDouble(), arrs[1].toString().toDouble()] + } + } + return points + } catch (Exception e) { + println e.getMessage() + } + return null; + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy index 99b913307..3ea63b7e6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/meishubao/MsbPocTest.groovy @@ -13,18 +13,18 @@ class MsbPocTest { task.run(); } def run(){ - def inputfile = "D:\\数据\\建行\\房产估值\\_业务5月份系统反馈问题价格核查20240416-20240516 - 国信达0524.xlsx" + def inputfile = "D:\\数据\\建行\\房产估值\\房讯通10月价格核查_1126-FXT提交结果20241205.xlsx" // def inputfile = "D:\\数据\\美术宝\\美术宝测试数据(匹配V2).xlsx"//美术宝测试数据(匹配).xlsx // standard(inputfile) // match(inputfile) -// matchOld(inputfile) + matchOld(inputfile) // addPrice("D:\\数据\\美术宝\\美术宝测试数据(价格).xlsx") // test("D:\\数据\\美术宝\\test2.xlsx") // cityPrice() // mergeMatchPrice("D:\\数据\\美术宝\\美术宝-新接口价格.xlsx") - addCCBPrice(inputfile) +// addCCBPrice(inputfile) } def cityPrice(){ @@ -69,24 +69,24 @@ class MsbPocTest { def matchOld(path){ ExcelUtils.multiThreadingModify(path, { row -> - if(!row['Y'] && row['G']){ + if(!row['AD'] ){ def city = row['C'] def region = null //row['D'] - def name = row['E'] - def address = row['G'] + def name = null// row['E'] + def address = row['D'] println "[match] city:"+city+" region:"+region+" address:"+address def jsonObject = OpenApiClient.addressMatch(city, address, "property", false, region, name) if(jsonObject != null && jsonObject.precise!=-1) { - row['Y'] = jsonObject.get("id") - row['Z'] = jsonObject.get("city") - row['AA'] = jsonObject.get("district") - row['AB'] = jsonObject.get("name") - row['AC'] = jsonObject.get("propertyType") + row['AD'] = jsonObject.get("id") + row['AE'] = jsonObject.get("city") + row['AF'] = jsonObject.get("district") + row['AG'] = jsonObject.get("name") + row['AH'] = jsonObject.get("propertyType") // row['X'] = jsonObject.get("credit") } } - }) + },1) } @@ -114,7 +114,7 @@ class MsbPocTest { if(!row['Y']){ def city = row['C'] def region = null //row['B'] - def address = row['G'] //row['G']//row['F'] + def address = row['D'] //row['G']//row['F'] println "[match] city:"+city+" region:"+region+" address:"+address def jsonObject = FangjiaClientUtils.newMatch(city, address, "property", false) @@ -125,7 +125,7 @@ class MsbPocTest { row['AB'] = jsonObject.get("name") } } - }) + },1) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy index d314427a9..5cd666999 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/poc/AddPriceTest.groovy @@ -38,9 +38,9 @@ class AddPriceTest { task.run(); } def run(){ - def filePath = "D:\\数据\\建行\\房产估值\\202410测试偏差较大案例统计数据test.xlsx" - addGXDPrice(filePath) -// addCcbPrice(filePath) + def filePath = "D:\\数据\\价格\\惠州.xlsx" +// addGXDPrice(filePath) + addCcbPrice(filePath) // addThirdPrice(filePath) // addFjwPrice(filePath) // exportPkPrice() @@ -174,26 +174,28 @@ class AddPriceTest { def addCcbPrice(filepath){ def cityCodeDataMap = CcbCommonUtils.findCityCodeValue() ExcelUtils.multiThreadingModify(filepath,{ d-> - if(d['U']){ - def cityId = cityCodeDataMap.get(d['V']) - def map = findAvgPrice(d['U'], cityId) + if(d['A']){ + def cityId = cityCodeDataMap.get(d['B']) + def map = findAvgPrice(d['A'], cityId) if(map){ - d['H'] = map.avg_price - d['I'] = map.calc_type + d['I'] = map.avg_price + d['J'] = map.month +// d['H'] = map.calc_type // d['AM'] = map.credit_value } -// def newPriceMap = findNewFjwAvgPrice(d['U'], cityId) -// if(newPriceMap){ -// d['Q'] = newPriceMap.avg_price -// } + def newPriceMap = findNewFjwAvgPrice(d['A'], cityId) + if(newPriceMap){ + d['G'] = newPriceMap.avg_price + d['H'] = newPriceMap.month + } } }) } def findAvgPrice(def commid, def cityid){ - def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202409 order by gujiabds_clc_yrmo_val desc limit 1" + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from t_app_p9pha_plda.avm_community_base_price_gj_h where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc @@ -213,7 +215,7 @@ class AddPriceTest { def findNewFjwAvgPrice(def commid, def cityid){ - def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' and gujiabds_clc_yrmo_val=202409 order by gujiabds_clc_yrmo_val desc limit 1" + def sql = "SELECT gujia_bds_clc_avprc,gujia_bds_clmtd,gujiabds_clc_yrmo_val,gujia_bds_cfdc_dgr from price_stat.avm_community_base_price where urbn_id='${cityid}' and gujia_bds_id='${commid}' order by gujiabds_clc_yrmo_val desc limit 1" def map = [:] pgsqlInstance235.eachRow(sql, { r -> map.avg_price = r.gujia_bds_clc_avprc @@ -270,14 +272,14 @@ class AddPriceTest { def addGXDPrice(filepath){ ExcelUtils.multiThreadingModify(filepath, { d -> - if (!d['B']) { + if (!d['H']) { def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ def gxdPrice = findGXDPrice(dist.city, dist.region, dist.name) // def gxdPrice = findGXDPrice(d['D'], d['E'], d['C']) if(gxdPrice){ - d['B'] = gxdPrice.price - d['C'] = DateUtils.formatDateByPattern(gxdPrice.c_date, "yyyy-MM-dd") + d['H'] = gxdPrice.price + d['I'] = DateUtils.formatDateByPattern(gxdPrice.c_date, "yyyy-MM-dd") } } @@ -305,11 +307,11 @@ class AddPriceTest { ExcelUtils.multiThreadingModify(path,{d-> // if(!d['L']){ // if(d['J'] instanceof String){ - def dist = CommonDatautils.findDistrictById(d['AJ']) + def dist = CommonDatautils.findDistrictById(d['A']) if(dist){ // d['A'] = dist.city // d['B'] = dist.region - d['E'] = dist.name +// d['E'] = dist.name // d['D'] = dist.status // d['E'] = dist.name_cat // d['F'] = dist.estate_type2 @@ -318,9 +320,9 @@ class AddPriceTest { // d['N'] = dist.region def dbo = CommonDatautils.queryFirstDistrictPrice(dist.city, dist.region, dist.name) if(dbo){ - d['G'] = dbo.avg_price + d['E'] = dbo.avg_price_2b // d['X'] = dbo.cal_type -// d['E'] = dbo.avg_price_2b +// d['E'] = dbo.avg_price } } // } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy index cb59203cf..e04562271 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/GeoHelper.groovy @@ -1,4 +1,8 @@ package com.fangjia.script.util + + +import java.text.DecimalFormat + class GeoHelper { @@ -60,10 +64,159 @@ class GeoHelper { // return GetLatLon(a, distance, angle); // } // - public static void main(String[] args){ - GeoHelper.GetLatLon( 31.222361, 121.380462, 0.6, 0); - GetDistance(31.222361, 121.380462, 31.227757176233904, 121.380462); - } + public static haversine(lat1, lon1, lat2, lon2) { + def R = 6371; // 地球半径(公里) + def lat1Rad = lat1 * (Math.PI / 180); + def lat2Rad = lat2 * (Math.PI / 180); + def deltaLat = (lat2 - lat1) * (Math.PI / 180); + def deltaLon = (lon2 - lon1) * (Math.PI / 180); + + def a = Math.sin(deltaLat / 2) ** 2 + + Math.cos(lat1Rad) * Math.cos(lat2Rad) * + Math.sin(deltaLon / 2) ** 2; + + def c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + return R * c; // 返回距离(公里) + } + + public static calculateArea(coords) { + def area = 0; + def n = coords.size(); + + for (def i = 0; i < n; i++) { + def j = (i + 1) % n; + area += coords[i][0] * coords[j][1]; + area -= coords[j][0] * coords[i][1]; + } + area = Math.abs(area) / 2; // 平方度 + + // 转换为平方公里 + def conversionFactor = 111.32; // 大约每度经纬度的公里数(考虑到地球的曲率) + + def df = new DecimalFormat("#.000000") + return Double.parseDouble(df.format(area * conversionFactor * conversionFactor)) // 返回面积(平方公里) +// return area * conversionFactor * conversionFactor + } + + + public static void main(String[] args){ +// GeoHelper.GetLatLon( 31.222361, 121.380462, 0.6, 0); +// GetDistance(31.222361, 121.380462, 31.227757176233904, 121.380462); + + List> coordinates = [ + [ + 117.61878540582734, + 24.667331307258223 + ], + [ + 117.61400840589488, + 24.670008244935104 + ], + [ + 117.60936140565889, + 24.671837202755682 + ], + [ + 117.60834440585768, + 24.668667276729821 + ], + [ + 117.60696440583342, + 24.667256309201207 + ], + [ + 117.60517040553236, + 24.667762297657362 + ], + [ + 117.60272340547806, + 24.660100475272998 + ], + [ + 117.60254340555321, + 24.658630509428463 + ], + [ + 117.60206940590035, + 24.654781598282568 + ], + [ + 117.60254840557604, + 24.652731645907636 + ], + [ + 117.60346440599301, + 24.651555673447035 + ], + [ + 117.6070314057805, + 24.652578649754957 + ], + [ + 117.61605140571805, + 24.651939664372833 + ], + [ + 117.6156454058372, + 24.654165613124405 + ], + [ + 117.61559340595863, + 24.655023593107103 + ], + [ + 117.61535440558418, + 24.658990501065318 + ], + [ + 117.61662340528017, + 24.659352492642654 + ], + [ + 117.61678740531192, + 24.661365445721003 + ], + [ + 117.61472940542001, + 24.661623439403797 + ], + [ + 117.61462940586114, + 24.661837434759093 + ], + [ + 117.61470140583106, + 24.662665415879701 + ], + [ + 117.61487240553515, + 24.663165403873506 + ], + [ + 117.61522940591078, + 24.663494396452791 + ], + [ + 117.6157014059138, + 24.663523395394918 + ], + [ + 117.61627240565099, + 24.663438397829282 + ], + [ + 117.61693540544979, + 24.663181403867725 + ], + [ + 117.61878540582734, + 24.667331307258223 + ] + ] + + double area = calculateArea(coordinates) + println "The area of the polygon is: ${String.format("%.2f", area)} square kilometers" + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy index 65da1a7be..7c41bcc1c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy @@ -12,7 +12,7 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { - def static GAO_DE_AK = "c6fcd4bfbc40d73ee762b8115dca3390" //宝剑 + def static GAO_DE_AK = "dfc2245bac8a7b2d5b62e060e59d4eca" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995:dfc2245bac8a7b2d5b62e060e59d4eca /** From 34e2201f899b9919a8ca1e3343d4f1a13efa0a8a Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 16 Jan 2025 17:34:04 +0800 Subject: [PATCH 211/230] update --- .../com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy index e44d4424e..5cf2d132a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy @@ -7,6 +7,7 @@ import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.common.DataHandleUtils import com.fangjia.script.gj.ccb.FileUtils import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.looplineinfo.Point import com.fangjia.script.util.DateUtils import com.fangjia.script.util.MongoUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils @@ -17,7 +18,7 @@ import com.mongodb.DBCollection */ -@BatchOwner(Watcher.GaoJuan) +//@BatchOwner(Watcher.GaoJuan) class RelatedTaiWanBatch extends BaseBatch{ @@ -69,7 +70,9 @@ class RelatedTaiWanBatch extends BaseBatch{ if(r.lon && r.lat){ for(def m : zimaoqu_range_datas){ // def flag = InsidePolygon.isInArea(r.lon, r.lat, InsidePolygon.createPoint5(m.shape)) - def flag = InsidePolygon.isPtInPoly(r.lon, r.lat, InsidePolygon.createPoint5(m.shape)) + List> pointsList = InsidePolygon.createPoint4(m.shape) +// def flag = InsidePolygon.isPtInPoly(r.lon, r.lat, pointsList) + def flag = InsidePolygon.isInArea(r.lon, r.lat, pointsList) if(flag){ resKey = m.name break From 82ddcbc4ed3f47cc9d4d696d6b23977f12169c79 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 16 Jan 2025 17:59:59 +0800 Subject: [PATCH 212/230] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=88=90=E4=BA=A4?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dealPrice/SynchDealPriceToEs.groovy | 68 +++++++++++-------- .../gj/district/DistrictFieldAddBatch.groovy | 64 ++++++++--------- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index f9f518cb8..dba4650b9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -1,6 +1,9 @@ package com.fangjia.script.dealPrice import com.fangjia.core.util.MongoUtils +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils @@ -15,43 +18,52 @@ import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType -class SynchDealPriceToEs { +/** + * 成交同步206,按日同步 + */ +@BatchOwner(Watcher.GaoJuan) +class SynchDealPriceToEs extends BaseBatch{ static DBCollection dealPriceConn = MongoUtils.getCollectionByName("fangjia", "deal_price", "192.168.0.43",28017) static main(args) { - def task = new SynchDealPriceToEs() - task.run() + runBatch(new SynchDealPriceToEs(), args) + } + + + @Override + void process(Object args) { + run(); } def run(){ - def batchsize = 2000 - def citys = getCityCount() - citys.each{city,count-> - if(city instanceof String){ - for(def year = 1999;year<=2025;year++){ - def q = new BasicDBObject("city", city) - q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) - def dbcursor = dealPriceConn.find(q).batchSize(batchsize) - println city +" "+ dbcursor.count() - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) - } - } + def startDate = DateUtils.formatDateByPattern(new Date()-1, "yyyy-MM-dd") + def q = new BasicDBObject() + q.put("m_date", new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate))) + def dbcursor = dealPriceConn.find(q) + println DateUtils.formatDateByPattern(new Date(),"yyyy-MM-dd")+" 更新量:"+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) -// def index = 0 -// for(def d : dbcursor){ -// ret << d -// if(ret.size()>=2000){ +// def batchsize = 2000 +// def citys = getCityCount() +// citys.each{city,count-> +// if(city instanceof String){ +// for(def year = 1999;year<=2025;year++){ +// def q = new BasicDBObject("city", city) +// q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) +// def dbcursor = dealPriceConn.find(q).batchSize(batchsize) +// println city +" "+ dbcursor.count() +// def ret = [] +// for(def o : dbcursor){ +// ret << o +// } // save(ret) -// ret.clear() -// index ++ -// println index // } // } - } +// } } @@ -93,7 +105,7 @@ class SynchDealPriceToEs { // def map = rows.get(key) def data_id = map._id.toString() map.remove("_id") - request.add(new IndexRequest("deal_price", "_doc", data_id).source(map, XContentType.JSON)); + request.add(new IndexRequest("trades", "_doc", data_id).source(map, XContentType.JSON)); // 批量提交数据 if (request.numberOfActions() >= batchSize) { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index d6e73b168..e2625366c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -67,39 +67,39 @@ class DistrictFieldAddBatch extends BaseBatch{ ] static main(args) { -// runBatch(new DistrictFieldAddBatch(), args) - ExcelUtils.multiThreadingModify("D:\\数据\\小区\\上海别墅.xlsx",{d-> - def dist = CommonDatautils.findDistrict(d['B'], d['G'], d['C'], "district") -// if(dist){ -// d['L'] = dist.loudong_count -// d['M'] = dist.household_count -// d['Q'] = dist.estate_type2 + runBatch(new DistrictFieldAddBatch(), args) +// ExcelUtils.multiThreadingModify("D:\\数据\\小区\\上海别墅.xlsx",{d-> +// def dist = CommonDatautils.findDistrict(d['B'], d['G'], d['C'], "district") +//// if(dist){ +//// d['L'] = dist.loudong_count +//// d['M'] = dist.household_count +//// d['Q'] = dist.estate_type2 +//// } +// def list = findEsDatasByCityAndName(d['B'], d['G'], d['C'], "搜房") +// if(!list && dist){ +// def alias = dist.alias +// for(def name : alias){ +// list = findEsDatasByCityAndName(d['B'], d['G'], name, "搜房") +// if(list){ +// d['Z'] = "别名" +// } +// } +// }else{ +// d['Z'] = "名称" // } - def list = findEsDatasByCityAndName(d['B'], d['G'], d['C'], "搜房") - if(!list && dist){ - def alias = dist.alias - for(def name : alias){ - list = findEsDatasByCityAndName(d['B'], d['G'], name, "搜房") - if(list){ - d['Z'] = "别名" - } - } - }else{ - d['Z'] = "名称" - } - if(list){ - def obj = list[0] - if(obj.loudong_cnt){ - d['W'] = obj.loudong_cnt - } - - if(obj.households){ - d['X'] = obj.households - } - d['Y'] = obj.url - } - - }) +// if(list){ +// def obj = list[0] +// if(obj.loudong_cnt){ +// d['W'] = obj.loudong_cnt +// } +// +// if(obj.households){ +// d['X'] = obj.households +// } +// d['Y'] = obj.url +// } +// +// }) } @Override From a9cf819a653c942391738ea67e363419982a082a Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 11:23:34 +0800 Subject: [PATCH 213/230] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/commData/CommonDatautils.groovy | 13 +++- .../script/gj/es/EsMonthHouseStat.groovy | 76 ++++++++++++++++++- 2 files changed, 84 insertions(+), 5 deletions(-) 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 d77e63373..94a3445f5 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 @@ -5137,17 +5137,22 @@ class CommonDatautils { def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000).addOption(Bytes.QUERYOPTION_NOTIMEOUT) def townMap = [:] for(def d : dbcursor){ + def distName = null if(d.mzb_district_name){ - def list = townMap.get(d.mzb_district_name) + distName = d.mzb_district_name + }else{ + distName = d.district + } + if(distName){ + def list = townMap.get(distName) if(!list){ list = [] } list << d - townMap.put(d.mzb_district_name, list) + townMap.put(distName, list) } } - - println "[${city}] 乡镇街道 加载完成 "+new Date().format("yyyy-MM-dd HH:mm:ss") +// println "[${city}] 乡镇街道 加载完成 "+new Date().format("yyyy-MM-dd HH:mm:ss") return townMap } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy index 9be75aeb0..e07ac0739 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/es/EsMonthHouseStat.groovy @@ -26,7 +26,8 @@ class EsMonthHouseStat { // task.statHouseUpdateCount() // task.statDistHouse() - task.statRent() +// task.statRent() + task.statOfficeHouse() } def statRent(){ @@ -201,6 +202,51 @@ class EsMonthHouseStat { },0) } + def statOfficeHouse(){ + def citys = CommonDatautils.findAllCity() + def allLists = [] + allLists << ["城市", "近一年写字楼出售量", "写字楼量", "近一年出售房源量大于3的写字楼量", "大于3写字楼量占比"] + citys.each{c-> + def count = findHouseCountByCat(c, "office_sell",20240101, 20250201) + + def districts = CommonDatautils.findAllDistricts(c, "office", ["city", "region", "name", "alias"]); + def disthouseCount = 0 + for(def dist : districts){ + def alias = [] + if(dist.alias){ + if(!dist.alias.contains(dist.name)){ + dist.alias << dist.name + } + alias = dist.alias + }else{ + alias << dist.name + } + + def distCount = 0 + if(count){ + distCount = findHouseCountByCat(dist.city, dist.region, alias, 20240101, 20250201, "office_sell") + if(distCount && distCount>=3){ + disthouseCount++ + } + } +// println dist.city+" "+dist.region+" "+dist.name+" "+distCount + } + + println "disthouseCount:"+disthouseCount +// println districts.size() + def precent = 0 + if(districts){ + precent = DataHandleUtils.getDoubleRound(2, disthouseCount*100.0/districts.size()) + } + def row = [c , count, districts.size(), disthouseCount, precent+"%"] + println row + allLists << row + } + + ExcelUtils.write("D:\\数据\\写字楼\\全国写字楼情况占比统计.xlsx", allLists, "写字楼情况") + + } + def findHouseCount(def city, def region, def alias, def startDate, def endDate){ def aliasStr = null; @@ -219,6 +265,23 @@ class EsMonthHouseStat { return total } + def findHouseCountByCat(def city, def region, def alias, def startDate, def endDate, cat){ + def aliasStr = null; + def total = 0 + try{ + aliasStr = escapeExprSpecialWord(alias.join("','")) + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} and region='${region}' and district_name in ('${aliasStr}') " + + ElasticUtils.executeSqlQuery(sql,{data-> + total = data.c + }) + }catch(Exception e){ + e.printStackTrace() + } + + return total + } + /** * 转义字符串中的特殊字符 * 仅过滤Lucene regexps, 其他的勿用 @@ -240,6 +303,17 @@ class EsMonthHouseStat { } + def findHouseCountByCat(def city, def cat, def startDate, def endDate){ + + String sql = "select count(*) as c from latest_seawater where cat='${cat}' and city='${city}' and p_date >= ${startDate} and p_date<${endDate} " + def total = 0 + ElasticUtils.executeSqlQuery(sql,{ data-> + total = data.c + }) + return total + } + + From 02c5f23fbf9ebc0c713f4d46928c8ac89e9cc5ca Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 11:35:31 +0800 Subject: [PATCH 214/230] add --- .../gj/district/UpdateDistrictField.groovy | 413 ++++++++++++++++++ 1 file changed, 413 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy new file mode 100644 index 000000000..710eeacca --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy @@ -0,0 +1,413 @@ +package com.fangjia.script.gj.district + +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.gj.FiledStrand +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders + +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +/** + * 根据链家数据修改小区库中字段 + * 使用到中间映射表 + */ +@BatchOwner(Watcher.GaoJuan) +class UpdateDistrictField extends BaseBatch{ + + final DBCollection thirdSeaweedMappingColl = MongoUtils.getCollectionByName("fangjia_craw", "third_seaweed_mapping", "192.168.0.235", 27018) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + def fields = ["developer","estate_company","household_count","loudong_count","estate_charge","car_site_count"] + + def sources = ["链家", "我爱我家", "安居客"] + + def statMap = [:] + + static main(args) { + runBatch(new UpdateDistrictField(), args) + } + + @Override + void process(Object args) { + def sourceMap = [:] + sources.each {source-> + def valMap = findThirdMatchDist(source) + println source +" "+valMap.size() + if(valMap){ + sourceMap.put(source, valMap) + } + } + def margeResults = megerDatas(sourceMap) +// updateDB(margeResults) + } + + def megerDatas(sourceMap){ + def set = new HashSet() + sources.each {source-> + def valMap = sourceMap.get(source) + set.addAll(valMap.keySet()) + } + def lastValues = [] + set.each {id-> + + def dbObj = CommonDatautils.findDistrictById(id) + + def datas = [] + sources.each {source-> + def valMap = sourceMap.get(source) + def sourceEsObj = findCommunities(valMap.get(id)) + if(sourceEsObj){ + if(source == "链家"){ + sourceEsObj.source = "lianjia" + }else if(source == "我爱我家"){ + sourceEsObj.source = "wiwj" + }else if(source == "安居客"){ + sourceEsObj.source = "anjuke" + } + datas << sourceEsObj + } + } + if(dbObj && datas){ + def newValMap = getNewField2(datas, dbObj) + if(newValMap){ + newValMap.put("id", id) + lastValues << newValMap + } + } + } + + statMap.each {source,fieldMap-> + println source +" "+fieldMap.size() + fieldMap.each{f,v-> + println f+" "+ v + } + println "----------------------------------------" + } + return lastValues + } + + + def margeValue(lianjiaMap, wiwjMap, anjukeMap){ + def lianjisIds = lianjiaMap.keySet() + def wiwjIds = wiwjMap.keySet() + def anjukeIds = anjukeMap.keySet() + def set = new HashSet() + set.addAll(lianjisIds) + set.addAll(wiwjIds) + set.addAll(anjukeIds) + + def lastValues = [] + def lianjiaUpdateCount = 0 + def wiwjUpdateCount = 0 + def anjukeUpdateCount = 0 + def lianjiaCountMap = [:] + def wiwjCountMap = [:] + def anjukeCountMap = [:] + set.each {id-> + BasicDBObject newValMap = new BasicDBObject() + fields.each {field-> + def lianjiaValMap = lianjiaMap.get(id) + def wiwjValMap = wiwjMap.get(id) + def anjukeValMap = anjukeMap.get(id) + if(lianjiaValMap && lianjiaValMap.containsKey(field)){ + newValMap.put(field, lianjiaValMap.get(field)) + lianjiaUpdateCount++ + def count = lianjiaCountMap.get(field) + if(!count){ + lianjiaCountMap.put(field, 1) + }else{ + lianjiaCountMap.put(field, count + 1) + } + }else if(wiwjValMap && wiwjValMap.containsKey(field)){ + newValMap.put(field, wiwjValMap.get(field)) + wiwjUpdateCount++ + def count = wiwjCountMap.get(field) + if(!count){ + wiwjCountMap.put(field, 1) + }else{ + wiwjCountMap.put(field, count + 1) + } + }else if(anjukeValMap && anjukeValMap.containsKey(field)){ + newValMap.put(field, anjukeValMap.get(field)) + anjukeUpdateCount++ + def count = anjukeCountMap.get(field) + if(!count){ + anjukeCountMap.put(field, 1) + }else{ + anjukeCountMap.put(field, count + 1) + } + } + } + newValMap.put("id", id) + lastValues << newValMap + } + + lianjiaCountMap.each {k,v-> + println "[链家] "+k+" "+v + } + + wiwjCountMap.each {k,v-> + println "[我爱我家] "+k+" "+v + } + + anjukeCountMap.each {k,v-> + println "[安居客] "+k+" "+v + } + return lastValues + } + + def updateDB(margeResults){ + for(def mr : margeResults){ + def id = mr.get("id") + mr.remove("id") + mr.put("m_date", new Date()) + DbUtils.seaweed.update(new BasicDBObject('_id',new ObjectId(id)),new BasicDBObject('$set',mr)) + } + } + + def batchUpdateDist(source){ +// def rets = findThirdMatchDist(source) + println "[${source}] 符保条件小区量:"+rets.size() + def updateIndex = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(rets.size()) + def allUpdateList = new CopyOnWriteArrayList() + + def sourceMap = new ConcurrentHashMap() + + for(def i=0;i + def count = countMap.get(k) + if(!count){ + countMap.put(k, 1) + }else{ + countMap.put(k, count+1) + } + } + } + + countMap.each {k,v-> + println k +" 更新量:"+v + } + + println "---------------------------------------------------------" + return sourceMap + } + + def running(url, old_match_id){ + def esObj = findCommunities(url) + def dbObj = CommonDatautils.findDistrictById(old_match_id) + if(dbObj){ + def newValMap = getNewField(esObj, dbObj) + return newValMap + } + return null + } + + def getNewField(esObj, dbObj){ + BasicDBObject newValMap = new BasicDBObject() + esObj.each{field, esVal-> + def dbVal = dbObj.get(field) + def newVal = null + if(esVal && field=="developer" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + + } + if(esVal && field=="estate_company" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(esVal && field=="household_count" && esVal!=dbVal){ + newVal = FiledStrand.processHouseholdCount(esVal, dbObj.estate_type2) + } + + if(esVal && field=="loudong_count" && esVal!=dbVal){ + newVal = FiledStrand.processLoudongCount(esVal) + } + + if(esVal && field=="estate_charge" && esVal!=dbVal){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toDouble()!=dbVal){ + newVal = FiledStrand.processEstateCharge(dbObj.city, numVal, dbObj.estate_type2) + newVal = newVal.toString() + } + } + if(esVal && field=="car_site_count"){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toInteger()!=dbVal){ + newVal = FiledStrand.processCarSite(numVal) + } + } + if(newVal){ + newValMap.put(field, newVal) + } + + } + + return newValMap + } + + def getNewField2(esDatas, dbObj){ + BasicDBObject newValMap = new BasicDBObject() + def lastValueMap = [:] + def haveValueMap = [:] + fields.each{field-> + for(def esData : esDatas){ + def esVal = esData.get(field) + def dbVal = dbObj.get(field) + def newVal = null + if(haveValueMap.containsKey(field)){ + continue + }else{ + if(lastValueMap.containsKey(field)){ + continue + } + if(esVal){ + + if(field=="estate_charge" || field=="car_site_count") { + esVal = FiledStrand.getNumber(esVal) + } + if(dbVal && esVal.toString()==dbVal.toString()){ + haveValueMap.put(field, esVal) + }else{ + if(field=="developer" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(field=="estate_company" && esVal!=dbVal){ + newVal = FiledStrand.processCompany(esVal) + } + + if(field=="household_count" && esVal!=dbVal){ + newVal = FiledStrand.processHouseholdCount(esVal, dbObj.estate_type2) + } + + if(esVal && field=="loudong_count" && esVal!=dbVal){ + newVal = FiledStrand.processLoudongCount(esVal) + } + + if(field=="estate_charge" && esVal!=dbVal){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toDouble()!=dbVal){ + newVal = FiledStrand.processEstateCharge(dbObj.city, numVal, dbObj.estate_type2) + newVal = newVal.toString() + } + } + if(field=="car_site_count"){ + def numVal = FiledStrand.getNumber(esVal) + if(numVal && numVal.toString().toInteger()!=dbVal){ + newVal = FiledStrand.processCarSite(numVal) + } + } + } + } + if(newVal){ + lastValueMap.put(field, newVal) + + //以下为统计各网站各字段的更新情况 + def fieldStatMap = statMap.get(esData.source) + if(!fieldStatMap){ + fieldStatMap = [:] + statMap.put(esData.source, fieldStatMap) + } + def count = fieldStatMap.get(field) + if(!count){ + fieldStatMap.put(field, 1) + }else{ + fieldStatMap.put(field, count + 1) + } + } + } + } + } + return lastValueMap + } + + def findThirdMatchDist(source){ + def query = new BasicDBObject("source",source).append("old_match_way", 1) + def keys = new BasicDBObject() + keys.put("url", 1) + keys.put("old_match_id", 1) + keys.put("old_match_city", 1) + keys.put("old_match_district", 1) + keys.put("old_match_name", 1) + def idsMap = [:] + def dbcursor = thirdSeaweedMappingColl.find(query, keys) + for(def db : dbcursor){ + if(!db.old_match_id && db.old_match_name){ + def dbo = CommonDatautils.findDistrict(db.old_match_city, db.old_match_district, db.old_match_name, "district") + if(dbo){ + idsMap.put(dbo._id.toString(), db.url) + } + }else{ + idsMap.put(db.old_match_id, db.url) + } + + } + return idsMap + } + + static def findCommunities(url){ + if(!url){ + return null + } + QueryBuilder queryBuilder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("url", url)) + def rets = [] + def datas = null + try{ + datas = ElasticUtils.executeSimpleQuery("192.168.0.206", "community", queryBuilder); + }catch(Exception e){ + findCommunities(url) + } + def data = [:] + if(datas) { + for (int k = 0; k < datas.size(); k++) { + def d = datas[k]; + data.put("household_count", d.households) + data.put("loudong_count", d.loudong_cnt) + data.put("developer", d.developer) + data.put("estate_company", d.property_company) + data.put("estate_charge", d.property_fee) + data.put("car_site_count", d.parking_cnt) + } + } + return data; + } +} From 4906378a520c39762f8ac96060045de3af1c607b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 13:45:51 +0800 Subject: [PATCH 215/230] update --- .../com/fangjia/script/gj/FiledStrand.groovy | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy index a3c119bec..514dd9631 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/FiledStrand.groovy @@ -909,14 +909,18 @@ class FiledStrand { } static def getNumber(def input) { - Pattern pattern = Pattern.compile("\\d+(\\.\\d+)?"); - Matcher matcher = pattern.matcher(input); - List list = new ArrayList(); - while (matcher.find()) { - list.add(matcher.group()); - } - if(list.size()>0){ - return list.get(0); + try{ + Pattern pattern = Pattern.compile("\\d+(\\.\\d+)?"); + Matcher matcher = pattern.matcher(input); + List list = new ArrayList(); + while (matcher.find()) { + list.add(matcher.group()); + } + if(list.size()>0){ + return list.get(0); + } + }catch(Exception e){ + println input+" error" } return null; } From c717f3cf6ce6d64285d4ec43ceb1e6a1b202a007 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 7 Feb 2025 16:58:05 +0800 Subject: [PATCH 216/230] update --- .../gj/district/UpdateDistrictField.groovy | 241 +++++++++--------- .../gj/images/AddDistImagesBatch.groovy | 49 ++-- .../thirdPriceCrawl/DataStandardBatch.groovy | 1 + 3 files changed, 150 insertions(+), 141 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy index 710eeacca..f44d8bf4b 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/UpdateDistrictField.groovy @@ -52,7 +52,8 @@ class UpdateDistrictField extends BaseBatch{ } } def margeResults = megerDatas(sourceMap) -// updateDB(margeResults) + updateDB(margeResults) + println "修改完成 "+new Date().toString() } def megerDatas(sourceMap){ @@ -101,74 +102,74 @@ class UpdateDistrictField extends BaseBatch{ } - def margeValue(lianjiaMap, wiwjMap, anjukeMap){ - def lianjisIds = lianjiaMap.keySet() - def wiwjIds = wiwjMap.keySet() - def anjukeIds = anjukeMap.keySet() - def set = new HashSet() - set.addAll(lianjisIds) - set.addAll(wiwjIds) - set.addAll(anjukeIds) - - def lastValues = [] - def lianjiaUpdateCount = 0 - def wiwjUpdateCount = 0 - def anjukeUpdateCount = 0 - def lianjiaCountMap = [:] - def wiwjCountMap = [:] - def anjukeCountMap = [:] - set.each {id-> - BasicDBObject newValMap = new BasicDBObject() - fields.each {field-> - def lianjiaValMap = lianjiaMap.get(id) - def wiwjValMap = wiwjMap.get(id) - def anjukeValMap = anjukeMap.get(id) - if(lianjiaValMap && lianjiaValMap.containsKey(field)){ - newValMap.put(field, lianjiaValMap.get(field)) - lianjiaUpdateCount++ - def count = lianjiaCountMap.get(field) - if(!count){ - lianjiaCountMap.put(field, 1) - }else{ - lianjiaCountMap.put(field, count + 1) - } - }else if(wiwjValMap && wiwjValMap.containsKey(field)){ - newValMap.put(field, wiwjValMap.get(field)) - wiwjUpdateCount++ - def count = wiwjCountMap.get(field) - if(!count){ - wiwjCountMap.put(field, 1) - }else{ - wiwjCountMap.put(field, count + 1) - } - }else if(anjukeValMap && anjukeValMap.containsKey(field)){ - newValMap.put(field, anjukeValMap.get(field)) - anjukeUpdateCount++ - def count = anjukeCountMap.get(field) - if(!count){ - anjukeCountMap.put(field, 1) - }else{ - anjukeCountMap.put(field, count + 1) - } - } - } - newValMap.put("id", id) - lastValues << newValMap - } - - lianjiaCountMap.each {k,v-> - println "[链家] "+k+" "+v - } - - wiwjCountMap.each {k,v-> - println "[我爱我家] "+k+" "+v - } - - anjukeCountMap.each {k,v-> - println "[安居客] "+k+" "+v - } - return lastValues - } +// def margeValue(lianjiaMap, wiwjMap, anjukeMap){ +// def lianjisIds = lianjiaMap.keySet() +// def wiwjIds = wiwjMap.keySet() +// def anjukeIds = anjukeMap.keySet() +// def set = new HashSet() +// set.addAll(lianjisIds) +// set.addAll(wiwjIds) +// set.addAll(anjukeIds) +// +// def lastValues = [] +// def lianjiaUpdateCount = 0 +// def wiwjUpdateCount = 0 +// def anjukeUpdateCount = 0 +// def lianjiaCountMap = [:] +// def wiwjCountMap = [:] +// def anjukeCountMap = [:] +// set.each {id-> +// BasicDBObject newValMap = new BasicDBObject() +// fields.each {field-> +// def lianjiaValMap = lianjiaMap.get(id) +// def wiwjValMap = wiwjMap.get(id) +// def anjukeValMap = anjukeMap.get(id) +// if(lianjiaValMap && lianjiaValMap.containsKey(field)){ +// newValMap.put(field, lianjiaValMap.get(field)) +// lianjiaUpdateCount++ +// def count = lianjiaCountMap.get(field) +// if(!count){ +// lianjiaCountMap.put(field, 1) +// }else{ +// lianjiaCountMap.put(field, count + 1) +// } +// }else if(wiwjValMap && wiwjValMap.containsKey(field)){ +// newValMap.put(field, wiwjValMap.get(field)) +// wiwjUpdateCount++ +// def count = wiwjCountMap.get(field) +// if(!count){ +// wiwjCountMap.put(field, 1) +// }else{ +// wiwjCountMap.put(field, count + 1) +// } +// }else if(anjukeValMap && anjukeValMap.containsKey(field)){ +// newValMap.put(field, anjukeValMap.get(field)) +// anjukeUpdateCount++ +// def count = anjukeCountMap.get(field) +// if(!count){ +// anjukeCountMap.put(field, 1) +// }else{ +// anjukeCountMap.put(field, count + 1) +// } +// } +// } +// newValMap.put("id", id) +// lastValues << newValMap +// } +// +// lianjiaCountMap.each {k,v-> +// println "[链家] "+k+" "+v +// } +// +// wiwjCountMap.each {k,v-> +// println "[我爱我家] "+k+" "+v +// } +// +// anjukeCountMap.each {k,v-> +// println "[安居客] "+k+" "+v +// } +// return lastValues +// } def updateDB(margeResults){ for(def mr : margeResults){ @@ -179,57 +180,57 @@ class UpdateDistrictField extends BaseBatch{ } } - def batchUpdateDist(source){ -// def rets = findThirdMatchDist(source) - println "[${source}] 符保条件小区量:"+rets.size() - def updateIndex = new AtomicLong() - final CountDownLatch latch = new CountDownLatch(rets.size()) - def allUpdateList = new CopyOnWriteArrayList() - - def sourceMap = new ConcurrentHashMap() - - for(def i=0;i - def count = countMap.get(k) - if(!count){ - countMap.put(k, 1) - }else{ - countMap.put(k, count+1) - } - } - } - - countMap.each {k,v-> - println k +" 更新量:"+v - } - - println "---------------------------------------------------------" - return sourceMap - } +// def batchUpdateDist(source){ +//// def rets = findThirdMatchDist(source) +// println "[${source}] 符保条件小区量:"+rets.size() +// def updateIndex = new AtomicLong() +// final CountDownLatch latch = new CountDownLatch(rets.size()) +// def allUpdateList = new CopyOnWriteArrayList() +// +// def sourceMap = new ConcurrentHashMap() +// +// for(def i=0;i +// def count = countMap.get(k) +// if(!count){ +// countMap.put(k, 1) +// }else{ +// countMap.put(k, count+1) +// } +// } +// } +// +// countMap.each {k,v-> +// println k +" 更新量:"+v +// } +// +// println "---------------------------------------------------------" +// return sourceMap +// } def running(url, old_match_id){ def esObj = findCommunities(url) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy index 60824f8d5..4c710cb47 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/images/AddDistImagesBatch.groovy @@ -38,7 +38,7 @@ class AddDistImagesBatch extends BaseBatch{ @Override public void process(Object args) { - def mdate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(), -1), "yyyy-MM-dd") + def mdate = DateUtils.getFirstDayOfMonth(new Date(), -1) // def mdate = DateUtils.getFirstDayOfMonth(new Date(), -1) def citys = CommonUtils.findAllCity() citys.each {city-> @@ -48,7 +48,7 @@ class AddDistImagesBatch extends BaseBatch{ matchCommunitys(communitys) } -// statImgCount() + statImgCount() } def findAllEsData2(city, mdate){ QueryBuilder date_range = QueryBuilders.rangeQuery("m_date").from(mdate.getTime()).includeLower(true) @@ -105,40 +105,47 @@ class AddDistImagesBatch extends BaseBatch{ def total = communitys.size() for(def i=0;i Date: Tue, 11 Feb 2025 16:12:02 +0800 Subject: [PATCH 217/230] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=85=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/commData/CommonDatautils.groovy | 22 ++ .../data_handle/BusinessQuarterProcess.groovy | 268 ++++++++++++++++++ .../gj/district/DistrictFieldAddBatch.groovy | 103 ++++++- .../gj/images/AddDistImagesBatch.groovy | 6 +- 4 files changed, 382 insertions(+), 17 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy 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 94a3445f5..82cffedbd 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 @@ -103,6 +103,8 @@ class CommonDatautils { public static final DBCollection STATS_INDEX_COLL = MongoUtils.getCollectionByName("fangjia_stat", "stats_index", "mongo.db.fangjia.com") + public static final DBCollection bk_business_coll = MongoUtils.getCollectionByName("fangjia_base", "bk_business", "mongo.db.fangjia.com") + public static DSCollection getHouseDataStoreConnection(){ if(house_dataStoreConnection != null) { return house_dataStoreConnection @@ -4967,6 +4969,20 @@ class CommonDatautils { return regionMap } + static def queryRangeByCat(cat){ + def q = new BasicDBObject() + q.put("type",cat) + q.put("shape",new BasicDBObject('$exists', true)) + def keys = new BasicDBObject() + keys.put("city_short",1) + keys.put("district_short",1) + keys.put("city",1) + keys.put("district",1) + keys.put("mzb_district_name", 1) + keys.put("shape", 1) + return ADMINISTRATIVE_MAPPING_COLL.find(q,keys).toList() + } + static def queryAllRegionNameByCity(){ @@ -5522,4 +5538,10 @@ class CommonDatautils { return 0 } + static def findBusinessByCity(city){ + def q = new BasicDBObject() + q.put("short_city", city) + return bk_business_coll.find(q).toList() + } + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy new file mode 100644 index 000000000..f122be3c0 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/BusinessQuarterProcess.groovy @@ -0,0 +1,268 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.core.RegionData +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.district.FangjiaClientUtils +import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.lixue.util.DBUtils +import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ElasticUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import org.bson.types.ObjectId +import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest +import org.elasticsearch.action.update.UpdateRequest +import org.elasticsearch.client.RequestOptions +import org.elasticsearch.common.xcontent.XContentType + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +class BusinessQuarterProcess { + + def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() + def fullCityMap = CommonDatautils.queryFullNameCity() + DBCollection bk_map_bussiness_COLL = MongoUtils.getCollectionByName("crawl", "bk_map_sq", "192.168.0.206",27020) + + public static final DBCollection bk_business_coll = MongoUtils.getCollectionByName("fangjia_base", "bk_business", "mongo.db.fangjia.com") + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + + static main(args) { + def task = new BusinessQuarterProcess() + task.run() + } + def run(){ +// synchBusinessData() +// updateBusinessQuarter() +// addRegion() + synchBusinessToEs() + } + + def addRegion(){ + def list = CommonDatautils.queryRangeByCat("区域") + println list.size() + def dbcursor = bk_business_coll.find(new BasicDBObject("_id", new ObjectId("67a318893b75f388c80979f2"))) + for(def d : dbcursor){ + if(d.district){ + continue + } + for(def regionShape : list){ + if(d.short_city!=regionShape.city_short){ + continue + } + def flag = InsidePolygon.isInArea(d.location.lon, d.location.lat, InsidePolygon.createPoint4(regionShape.shape.coordinates)) + if(flag){ + def udata = new BasicDBObject() + udata.put("district", regionShape.mzb_district_name) + udata.put("short_district", regionShape.district_short) + bk_business_coll.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + break + } + } + } + } + + def synchBusinessData(){ + def datas = bk_map_bussiness_COLL.find(new BasicDBObject("type", null)).toList() + synchMongoProcess(datas) + + } + + def synchMongoProcess(datas){ + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(datas.size()) + for(def i=0;i=100){ +// updateByEs(rows) +// rows.clear() +// } + updateByEs(d, index) + } + } + + def updateByEs(row, index){ + BulkRequest request = new BulkRequest(); + def client = ElasticUtils89.getClient("192.168.0.89") + int processedCount = 0; + + def id = row.get("_id").toString() + def doc = [:] + doc.put("province",row.province) + doc.put("short_province",row.short_province) + doc.put("city",row.city) + doc.put("short_city",row.short_city) + doc.put("district",row.district) + doc.put("short_district",row.short_district) + doc.put("name", row.name) + doc.put("location", row.location) + doc.put("bd_location", row.bd_location) + doc.put("shape", row.shape) + doc.put("bd_shape", row.bd_shape) + + + request.add(new IndexRequest("bk_business", "_doc", id).source(doc, XContentType.JSON)); + if (request.numberOfActions() >= 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + println "[${index}] Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); +// println "Processed " + processedCount + " documents" + } + } + + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index e2625366c..83f747d21 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -18,6 +18,8 @@ import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.rabbitmq.client.impl.AMQImpl import org.bson.types.ObjectId +import org.elasticsearch.index.query.QueryBuilder +import org.elasticsearch.index.query.QueryBuilders import java.text.SimpleDateFormat import java.util.concurrent.CopyOnWriteArrayList @@ -39,7 +41,7 @@ class DistrictFieldAddBatch extends BaseBatch{ //"安居客":"安居客小程序","链家":"链家","幸福里":"幸福里","城市房产":"城市房产小程序","搜房":"搜房" // - def sourceMap = ["幸福里":"幸福里APP","城市房产":"城市房产小程序","安居客小程序":"安居客小程序","安居客移动端":"安居客移动端","贝壳找房":"贝壳找房","安居客-新房":"安居客-新房","安居客":"安居客","链家":"链家","贝壳找房-新房":"贝壳找房-新房","楼盘网-新房":"楼盘网-新房","禧泰":"中国房价行情","链家":"链家","搜房":"搜房","我爱我家":"我爱我家","诸葛找房":"诸葛找房APP","贝壳找房":"贝壳找房", + def sourceMap = ["贝壳找房":"贝壳找房","链家":"链家","贝壳找房-新房":"贝壳找房-新房","安居客":"安居客","幸福里":"幸福里","安居客小程序":"安居客小程序","城市房产":"城市房产小程序","安居客移动端":"安居客移动端","安居客-新房":"安居客-新房","楼盘网-新房":"楼盘网-新房","禧泰":"中国房价行情", "城市房产":"城市房产","搜房":"搜房","我爱我家":"我爱我家","诸葛找房":"诸葛找房", "乐有家":"乐有家","吉屋":"吉屋","C21":"C21","365淘房":"365淘房"] //key:穆融合表的来源 valve:es解析表的来源 @@ -61,6 +63,7 @@ class DistrictFieldAddBatch extends BaseBatch{ "car_site_count":"车位","car_site":"车位描述","property_life":"产权年限","address":"地址","build_structure":"建筑结构", "build_type":"建筑类型", "land_property":"权属类别","live_date":"入住时间","loop_line_info":"环线"] + final DBCollection thirdSeaweedMappingColl = MongoUtils.getCollectionByName("fangjia_craw", "third_seaweed_mapping", "192.168.0.235", 27018) final static def EMAILS = [ "gaojuan@fangjia.com" @@ -115,18 +118,12 @@ class DistrictFieldAddBatch extends BaseBatch{ headers << fieldsNameMap.get(it) } - headers << "抓取量" - headers << "匹配量" - headers << "0.9分以上量" - headers << "匹配率" - headers << "0.9以上匹配率" -// analysRets << headers - for(def c : citys){ def totalCount = CommonDatautils.findAllDistrictCount("district", c) if(totalCount){ // rh_analysRets = addFieldFromRonghe(c, totalCount, rh_analysRets)//融合 - analysRets = addFieldFromMatch(c, totalCount, analysRets)//匹配 +// analysRets = addFieldFromMatch(c, totalCount, analysRets)//匹配 + analysRets = addFieldFromMatchMapping(c, totalCount, analysRets)//新旧匹配中间表 } } println analysRets.toString() @@ -139,8 +136,10 @@ class DistrictFieldAddBatch extends BaseBatch{ sourceMap.each { seaweedmapSource, esWebSource -> def esRets = findEsDatas(c, esWebSource) + def matchRets1 = matchApi(esRets) def matchRets2 = selectRestByCredit(matchRets1) + println esWebSource +" 抓取量:"+esRets.size()+" 匹配量:"+matchRets1.size()+" 0.9分以上量:"+matchRets2.size() def updateRets = processFieldsFromMatch(c , matchRets2, esWebSource) @@ -172,6 +171,65 @@ class DistrictFieldAddBatch extends BaseBatch{ } + def addFieldFromMatchMapping(c, totalCount, analysRets){ + def fields = fieldsMap.keySet() as List + + sourceMap.each { seaweedmapSource, esWebSource -> + def esRets = findMatchSameDatas(c, esWebSource) + println esWebSource +" 新老算法匹配相同量:"+esRets.size() + + def updateRets = processFieldsFromMatch(c , esRets, esWebSource) + + def precentMap = fieldUpdate(totalCount, updateRets) + println c +" "+precentMap.toString() + updateDB(c, updateRets) + println "------------------------------------------------------------------------------" + + def analyRet = [] + analyRet << seaweedmapSource + analyRet << c + fields.each{key-> + analyRet << precentMap.get(key) + } + analyRet << esRets.size() + analysRets << analyRet + } + return analysRets; + + } + + + def findMatchSameDatas(c, esWebSource){ + def query = new BasicDBObject("city", c).append("source", esWebSource).append("match_id", new BasicDBObject('$exists', true)).append("old_match_id", new BasicDBObject('$exists',true)) + def siteDatas = thirdSeaweedMappingColl.find(query).toList() + def rows = new CopyOnWriteArrayList() + def totalCount = new AtomicLong() + final CountDownLatch latch = new CountDownLatch(siteDatas.size()) + for(def i=0;i Date: Wed, 12 Feb 2025 17:20:16 +0800 Subject: [PATCH 218/230] =?UTF-8?q?=E5=9C=B0=E5=9D=80=E5=88=AB=E5=90=8D?= =?UTF-8?q?=E8=B7=91=E4=B9=9D=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/AddrAlaisProcess.groovy | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy new file mode 100644 index 000000000..1cf20acc9 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -0,0 +1,86 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.common.DataHandleUtils +import com.fangjia.script.gj.ccb.FileUtils +import com.fangjia.script.util.ExcelUtils + +class AddrAlaisProcess { + + static main(args) { + def task = new AddrAlaisProcess() +// task.run() + task.nineApi() + } + + def nineApi(){ + def fileName = "/home/goojia/gj/district/addr_alias.xlsx" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化-测试.xlsx" + } + + ExcelUtils.multiThreadingModify(fileName, {d-> + def addrMap = nineAddrSplit(d['B'], d['E']) + def addrList = [] + if(addrMap && addrMap.address){ + d['G'] = addrMap.city + d['H'] = addrMap.address + addrList << addrMap.address + } + if(d['F']){ + def addrs = d['F'].split(",") + def addr_alias = [] + for(def addr : addrs){ + def map = nineAddrSplit(d['B'], addr) + if(map && map.address && DataHandleUtils.isStandardRoad(map.address)){ + if(!addrList.contains(map.address)){ + addrList << map.address + addr_alias << map.address + } + } + } + d['I'] = addr_alias.join(",") + } + }) + + } + + def nineAddrSplit(city, addr){ + def jsonObject = com.fangjia.script.gj.district.FangjiaClientUtils.formatNinelevel(city, addr) + def address = "" + def map = [:] + if (jsonObject) { + map.province = jsonObject.get("province") + map.city = jsonObject.get("city") + map.district = jsonObject.get("district") + if (jsonObject.get("street") && jsonObject.get("street") != "null") { + address = jsonObject.get("street") + } + if (jsonObject.get("streetNumber") && jsonObject.get("streetNumber") != "null") { + address = address + jsonObject.get("streetNumber") + } + map.address = address + } + return map + } + + def run(){ + def citys = CommonDatautils.findAllCity() + def rows = [] + citys.each{c-> + def districts = CommonDatautils.findAllDistricts(c, "district", ["city","region", "name","address", "addr_alias"]) + println c +" "+districts.size() + def num = 0 + for(def d : districts){ + num++ + def row = [num, d.city, d.region, d.name, d.address] + if(d.addr_alias){ + row << d.addr_alias.join(",") + } + rows << row + } + } +// ExcelUtils.write("D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.xlsx", rows, "小区") + FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\小区\\小区地址及地址别名标准化.bat", null, "utf-8", false, "#",""); + } +} From 683de63a610ed659d6a21da6eacf6a1465317e1b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Wed, 12 Feb 2025 18:09:51 +0800 Subject: [PATCH 219/230] update --- .../gj/district/DistrictFieldAddBatch.groovy | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index 83f747d21..5610ae238 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -119,6 +119,7 @@ class DistrictFieldAddBatch extends BaseBatch{ } for(def c : citys){ + def totalCount = CommonDatautils.findAllDistrictCount("district", c) if(totalCount){ // rh_analysRets = addFieldFromRonghe(c, totalCount, rh_analysRets)//融合 @@ -397,12 +398,16 @@ class DistrictFieldAddBatch extends BaseBatch{ newValues.put(seaweedfield, newVal) } if(seaweedfield == "lng"){ - def locationMap = FiledStrand.processLngAndLat(esVal) - if(locationMap){ - newValues.put("lat", locationMap.lat) - newValues.put("lng", locationMap.lng) - newValues.put("lat2", locationMap.lat2) - newValues.put("lng2", locationMap.lng2) + try{ + def locationMap = FiledStrand.processLngAndLat(esVal) + if(locationMap){ + newValues.put("lat", locationMap.lat) + newValues.put("lng", locationMap.lng) + newValues.put("lat2", locationMap.lat2) + newValues.put("lng2", locationMap.lng2) + } + }catch(Exception e){ + println esVal } } } From 8447b62637072b6cfc12f264b333747583cfe484 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 13 Feb 2025 09:47:30 +0800 Subject: [PATCH 220/230] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/AddrAlaisProcess.groovy | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy index 1cf20acc9..62d1f299e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddrAlaisProcess.groovy @@ -50,9 +50,21 @@ class AddrAlaisProcess { def address = "" def map = [:] if (jsonObject) { - map.province = jsonObject.get("province") - map.city = jsonObject.get("city") - map.district = jsonObject.get("district") + if (jsonObject.get("province") && jsonObject.get("province") != "null") { + map.province = jsonObject.get("province") + }else{ + map.province = "" + } + if (jsonObject.get("city") && jsonObject.get("city") != "null") { + map.city = jsonObject.get("city") + }else{ + map.city = "" + } + if (jsonObject.get("district") && jsonObject.get("district") != "null") { + map.district = jsonObject.get("district") + }else{ + map.district = "" + } if (jsonObject.get("street") && jsonObject.get("street") != "null") { address = jsonObject.get("street") } From 493e4c343306706bb055ed9483cf6a9dc7923d63 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 14 Feb 2025 17:56:48 +0800 Subject: [PATCH 221/230] update --- .../fangjia/script/gj/district/DistrictFieldAddBatch.groovy | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy index 5610ae238..8507f7d00 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictFieldAddBatch.groovy @@ -119,7 +119,7 @@ class DistrictFieldAddBatch extends BaseBatch{ } for(def c : citys){ - + def totalCount = CommonDatautils.findAllDistrictCount("district", c) if(totalCount){ // rh_analysRets = addFieldFromRonghe(c, totalCount, rh_analysRets)//融合 @@ -330,7 +330,9 @@ class DistrictFieldAddBatch extends BaseBatch{ def newVal = null if(seaweedfield == "estate_charge"){ newVal = FiledStrand.processEstateCharge(c, FiledStrand.getNumber(esVal), dist.estate_type2) - newVal = newVal.toString() + if(newVal) { + newVal = newVal.toString() + } } if(seaweedfield == "build_date" || seaweedfield == "live_date"){ newVal = FiledStrand.processFinishBuildingDate(esVal) From 26591c2d22510572f37c9eca73271aa66b5b3c30 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 11:44:45 +0800 Subject: [PATCH 222/230] =?UTF-8?q?=E8=B7=91=E9=AB=98=E5=BE=B7=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/TownStandardBatch.groovy | 246 ++++++++++++++---- .../fangjia/script/util/BaiduMapUtils.groovy | 42 ++- .../yinjihaun/amap/GaoDeApiUtils.groovy | 5 +- 3 files changed, 230 insertions(+), 63 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 41588517e..3fd7084d4 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -4,11 +4,16 @@ import com.fangjia.script.BaseBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.gj.xiamen.ElasticUtils89 import com.fangjia.script.looplineinfo.InsidePolygon +import com.fangjia.script.util.BaiduMapUtils +import com.fangjia.script.util.ElasticUtils import com.fangjia.script.util.ExcelUtils import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils import com.mongodb.BasicDBObject import org.apache.commons.io.FileUtils import org.elasticsearch.action.bulk.BulkRequest +import org.elasticsearch.action.bulk.BulkResponse +import org.elasticsearch.action.index.IndexRequest +import org.elasticsearch.action.support.WriteRequest import org.elasticsearch.action.update.UpdateRequest import org.elasticsearch.client.RequestOptions import org.elasticsearch.common.xcontent.XContentType @@ -31,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(100) def updateList = [] def addAliasList = [] @@ -49,7 +54,8 @@ class TownStandardBatch extends BaseBatch{ def TownStandard(){ // townStandardByCat("office") // townStandardByPoi() - addTownByTownShape() + addTownByTownShape()//为没有乡镇街道的poi,补充乡镇街道,忽略区域,并使用地图 +// updateTownData() } def townStandardByCat(def cat){ //"三明","龙岩","南平","漳州","福州","厦门","泉州","莆田","宁德", @@ -385,11 +391,41 @@ class TownStandardBatch extends BaseBatch{ return rets; } + def readCSV3(filename){ + def lines = FileUtils.readLines(new File(filename)) + def rets = []; + def index = 0 + for(line in lines) { + if(line && index>=1){ + String[] arrs = line.split(",") + if(arrs.size()>=10 && arrs[7] && arrs[9]=="同区域"){ + def o = new BasicDBObject() + try{ + o.put("id", arrs[0]) + o.put("township", arrs[7]) + if(arrs.size()>=9 && arrs[8]){ + o.put("district", arrs[8]) + } + if(arrs.size()>=10 && arrs[9]){ + o.put("way", arrs[9]) + } + rets << o + }catch(Exception e){ + println arrs + } + } + + } + index++ + } + return rets; + } + def addTownByTownShape(){ def i = 0 - def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式"] + def headers = ["_id","province","city","district","lng","lat","data_source","乡镇街道", "新区域", "方式", "标准乡镇"] while(i<50){ - def fileName = "/home/goojia/gj/new_poi/input/no_township_${i}.csv" + def fileName = "/home/goojia/gj/new_poi/input/map/no_township_${i}.csv" if (CommonDatautils.isWindow()) { fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\原始\\no_township_${i}.csv" } @@ -398,7 +434,7 @@ class TownStandardBatch extends BaseBatch{ def rets = readCSV2(fileName) def rows = addTownshipBatch(rets) if (CommonDatautils.isWindow()) { - com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); + com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果-地图\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); }else{ com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); } @@ -425,10 +461,10 @@ class TownStandardBatch extends BaseBatch{ def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() - if (set.size() >= 1) { +// if (set.size() >= 1) { addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) - results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source] - } + results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source, r.strand_town] +// } } } catch (Exception e) { e.printStackTrace() @@ -444,52 +480,87 @@ class TownStandardBatch extends BaseBatch{ def addTown(saveObj, townMap, location) { //在poi本区域下通过乡镇街道围栏选出所在乡镇街道 - def towns = townMap.get(saveObj.district) - if (towns) { - for (def town : towns) { - if (town.shape && town.shape.coordinates) { - def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) - if (flag) { - saveObj.township = town.street - saveObj.town_source = "同区域" - break - } - } - } - } +// def towns = townMap.get(saveObj.district) +// if (towns) { +// for (def town : towns) { +// if (town.shape && town.shape.coordinates) { +// def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) +// if (flag) { +// saveObj.township = town.street +// saveObj.town_source = "同区域" +// saveObj.strand_town = "是" +// break +// } +// } +// } +// } //忽略poi中的区域 通过乡镇街道围栏选出所在乡镇街道 +// if(!saveObj.township){ +// def townNames = townMap.keySet() +// for(def townName : townNames){ +// towns = townMap.get(townName) +// for (def town : towns) { +// if (town.shape && town.shape.coordinates) { +// def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) +// if (flag) { +// saveObj.township = town.street +// saveObj.new_district = town.mzb_district_name +// saveObj.town_source = "忽略区域" +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// break +// } +// } +// } +// if(saveObj.township){ +// break; +// } +// } +// } + //通过调取地图api接口获取乡镇街道 if(!saveObj.township){ - def townNames = townMap.keySet() - for(def townName : townNames){ - towns = townMap.get(townName) - for (def town : towns) { - if (town.shape && town.shape.coordinates) { - def flag = InsidePolygon.isInArea(location.lon, location.lat, InsidePolygon.createPoint4(town.shape.coordinates)) - if (flag) { - saveObj.township = town.street - saveObj.new_district = town.mzb_district_name - saveObj.town_source = "忽略区域" - break - } - } - } - if(saveObj.township){ - break; + def gaodeMap = getTownshipInfo(location.lon+","+location.lat) + if(gaodeMap && gaodeMap.township){ + saveObj.township = gaodeMap.township + saveObj.new_district = gaodeMap.district + saveObj.town_source = "高德API" + if(townMap.size()>=1){ + saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) } } } - //通过调取地图api接口获取乡镇街道 + +// //通过调取地图api接口获取乡镇街道 // if(!saveObj.township){ -// def gaodeMap = getTownshipInfo(location.lon+","+location.lat) -// if(gaodeMap && gaodeMap.township){ -// saveObj.township = gaodeMap.township -// saveObj.new_district = gaodeMap.district -// saveObj.town_source = "高德API" +// def gaodeMap = BaiduMapUtils.geocoding(location.lat+","+location.lon) +// if(gaodeMap && gaodeMap.addressComponent) { +// def addressComponent = gaodeMap.addressComponent +// if(addressComponent){ +// if(addressComponent.town){ +// saveObj.township = addressComponent.town +// saveObj.new_district = addressComponent.district +// saveObj.town_source = "百度API" +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// } +// } // } // } return saveObj } + def isStandTown(townMap, district, town){ + def towns = townMap.get(district) + def flag = "非" + if(towns){ + for(def t : towns){ + if(t.street == town){ + flag = "是" + break + } + } + } + return flag + } + def getTownshipInfo(def glocation){ def township = null @@ -498,9 +569,11 @@ class TownStandardBatch extends BaseBatch{ def format_addr = null def stop = false def count = 0 - while(!stop){ + def jsonObject = null +// while(!stop){ if(glocation){ - def jsonObject = GaoDeApiUtils.geocode(glocation) + jsonObject = GaoDeApiUtils.geocode(glocation) + if(jsonObject && jsonObject.regeocode) { def addressComponent = jsonObject.regeocode.addressComponent if(addressComponent){ @@ -512,14 +585,15 @@ class TownStandardBatch extends BaseBatch{ } } } - if(district || count>10){ - stop = true - }else{ - count ++ - Thread.sleep(3000) - print "." - } - } +// if(jsonObject.status==0 || count>3){ +// stop = true +// println "高德调用超3次" +// }else{ +// count ++ +// Thread.sleep(3000) +// print "." +// } +// } def map = [:] map.city = city @@ -529,6 +603,72 @@ class TownStandardBatch extends BaseBatch{ return map; } + def updateTownData(){ + def i = 0 + while(i<50) { + def fileName = "/home/goojia/gj/new_poi/output/no_township_result_${i}.csv" + if (CommonDatautils.isWindow()) { + fileName = "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果\\no_township_result_${i}.csv" + } + File file = new File(fileName); + if (file.exists()) { + def rets = readCSV3(fileName) + println file.getAbsoluteFile().getName() +" "+(rets.size()*100/200000)+"%"+" "+rets.size() +// if(rets){ +// updateToEs(rets) +// } + } + i++ + } + } + + + def updateToEs(rows){ + BulkRequest request = new BulkRequest(); + int batchSize = 1; + int processedCount = 0; + def client = ElasticUtils.getClient89("192.168.0.89") + for (int i = 0; i < rows.size(); i++) { + def map = rows[i] + if(map.containsKey("way")){ + map.remove("way") + } + request.add(new IndexRequest("map_poi_2024", "_doc", map.id).source(map, XContentType.JSON)); + if(i%1000==0){ + print "." + } + + // 批量提交数据 + if (request.numberOfActions() >= batchSize) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + print "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + + request = new BulkRequest(); + } + + } + + if (request.numberOfActions() > 0) { + request.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); + BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT); + if (bulkResponse.hasFailures()) { + // 处理错误 + println "Bulk request has failures: " + bulkResponse.buildFailureMessage() + } else { + processedCount += request.numberOfActions(); + println "Processed " + processedCount + " documents" + } + } + + println "结束时间 "+new Date() + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy index cb84af2c7..9a4003b7d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/BaiduMapUtils.groovy @@ -9,13 +9,8 @@ import net.sf.json.JSONObject class BaiduMapUtils { - private static String AK = "9E99D3540e4dafb7894f7b9fe27fa6b5"; - def static AKS = ["hj5KqPjaGA3uivtg8uS8XfAnj9X1kPMr","xjFg7DfDqvQleIZasM3ph8Zi2Lw8kgCg", - "4pb6fzrWIzvibDu8L1o8DGoY2h1wRIUq","ZzX6mRFfE5GKn4cpUp24Q3OyUIHnfQAR","79ac4ea49e7dedbf80b0ecd475d07784", - "9E99D3540e4dafb7894f7b9fe27fa6b5","W3M5uHfcrmlAdhQjf6v93LCI", "C8bb035aacf602551e829e4c64575224", - "B42b12d01f2dee712fd66c3e886158a4", "1a3cde429f38434f1811a75e1a90310c","W3M5uHfcrmlAdhQjf6v93LCI", - "C8bb035aacf602551e829e4c64575224", "B42b12d01f2dee712fd66c3e886158a4", - "1a3cde429f38434f1811a75e1a90310c","9E99D3540e4dafb7894f7b9fe27fa6b5"]; + private static String AK = "1a3cde429f38434f1811a75e1a90310c"; + def static AKS = ["1a3cde429f38434f1811a75e1a90310c","1a3cde429f38434f1811a75e1a90310c"]; public static boolean HAS_AVAILABLE_AK = true; static def getAddress(lng, lat) throws Exception{ @@ -83,8 +78,8 @@ class BaiduMapUtils { throw new RuntimeException("无可用百度AK"); } System.out.println("更换AK"); - for(int i = 0 ;i < AKS.length; i++){ - if(i == AKS.length - 1){ + for(int i = 0 ;i < AKS.size(); i++){ + if(i == AKS.size() - 1){ AK = AKS[0]; HAS_AVAILABLE_AK = false; throw new RuntimeException("无可用百度AK"); @@ -127,6 +122,35 @@ class BaiduMapUtils { return null } + + public static JSONObject geocoding(locationstr) { + String url = "https://api.map.baidu.com/reverse_geocoding/v3/?ak="+AK+"&output=json&coordtype=gcj02ll&location="+locationstr + boolean stop = false; + int recount = 0; + JSONObject jsonObj = null + while(!stop && recount<6) { + try{ + HttpRequest request = new HttpRequest(); + try{ + String result = request.get(url,null,"UTF-8"); + def json = JSONObject.fromObject(result); + if(json.getInt("status") >= 300){ + changeAK(); + recount++ + }else{ + jsonObj = json.result + } + }catch (Exception e){ + e.printStackTrace(); + } + }catch (Exception e){ + recount++; + println e.getMessage() + } + } + return jsonObj + } + public static def searchByBounds(key, min_lat, min_lng, max_lat, max_lng){ boolean stop = false; int recount = 0; diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy index 7c41bcc1c..30419ba47 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy @@ -12,7 +12,7 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { - def static GAO_DE_AK = "dfc2245bac8a7b2d5b62e060e59d4eca" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 + def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995:dfc2245bac8a7b2d5b62e060e59d4eca /** @@ -35,6 +35,9 @@ class GaoDeApiUtils { content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") } JSONObject jsonObj = JSONObject.fromObject(content) + if(jsonObj.status!=1){ + println jsonObj + } return jsonObj } From 9beb7b3f8163f88fe93d49d034f5e7e26737aa6c Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 12:24:31 +0800 Subject: [PATCH 223/230] update --- .../gj/data_handle/TownStandardBatch.groovy | 1 + .../script/looplineinfo/InPolygon.groovy | 132 ++++++++++++++++++ .../script/looplineinfo/InsidePolygon.groovy | 4 + .../yinjihaun/amap/GaoDeApiUtils.groovy | 2 +- 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 3fd7084d4..0034cdb20 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -432,6 +432,7 @@ class TownStandardBatch extends BaseBatch{ File file=new File(fileName); if(file.exists()) { def rets = readCSV2(fileName) + println i +" "+ rets.size() def rows = addTownshipBatch(rets) if (CommonDatautils.isWindow()) { com.fangjia.script.gj.ccb.FileUtils.batchCreateFileByCustomSuffix(rows, "D:\\数据\\数据建设\\乡镇街道\\待补充乡镇街道\\结果-地图\\no_township_result_${i}.csv", headers, "utf-8", false, ',', ''); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy new file mode 100644 index 000000000..4d79373ca --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InPolygon.groovy @@ -0,0 +1,132 @@ +package com.fangjia.script.looplineinfo + +import com.fangjia.script.common.DataHandleUtils + +import java.awt.geom.Point2D; + +class InPolygon { + + + public static List> createPoint(def pointList){ + List> alllist = new ArrayList<>(); + for(def pointArr : pointList){ + List list = new ArrayList<>(); + for(def arr : pointArr){ + double x = DataHandleUtils.getDoubleRound(6, arr[0]); + double y = DataHandleUtils.getDoubleRound(6, arr[1]); + Point2D.Double point = new Point2D.Double(x,y); + list.add(point); + } + alllist << list + } + return alllist + } + + public static def isInArea(Point2D.Double point, List> pointList){ + def flag = false; + for(List pointArr : pointList){ + flag = isPtInPoly(point, pointArr) + if(flag){ + break; + } + } + return flag; + } + + /** + * 判断点是否在多边形内 + *

+ * 整个算法的思路为:作点平行于y轴的射线,这样就可以直接比较交点是否大于点(x,y)中y的值,可以简化判断。 + * + * @param point 检测点 + * @param pts 多边形的顶点 + * @return 点在多边形内返回true, 否则返回false + */ + public static boolean isPtInPoly(Point2D.Double point, List pts) { + int polygonSidesCount = pts.size(); + //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true + boolean boundOrVertex = true; + // 射线与多边形相交的次数 + int intersectCount = 0; + //浮点类型计算时候与0比较时候的容差 + double precision = 2e-10; + // 相邻两点 + Point2D.Double p1, p2; + // 当前点 + Point2D.Double p = point; + // 线段起点 + p1 = pts.get(0); + for (int i = 1; i <= polygonSidesCount; ++i) { + //按照点录入的顺序依次检查相邻两点组成的线段和当前的点的关系。 + if (p.equals(p1)) { + //如果当前点就是多边形的顶点之一,直接返回。 + return boundOrVertex; + } + // 线段终点 + p2 = pts.get(i % polygonSidesCount); + if (p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)) { + //点在x轴上的映射,明显超出了线段在x轴上的投影。此时冲着上做射线,肯定没有交点,直接跳过。 + p1 = p2; + continue; + } + if (p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)) { + // 当前点在线段于x轴上的投影内 + if (p.y <= Math.max(p1.y, p2.y)) { + //当前点的 y 坐标小于 线段对y轴投影的最大值 + if (p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)) { + // 若线段同样是平行于y轴,则可以断定,当前点,在多边形的这条垂直于x轴的边上。 + return boundOrVertex; + } + if (p1.y == p2.y) { + // 若线段为平行于x轴的水平线 + if (p1.y == p.y) { + //当前点正好位于该水平线上,直接返回该点位于多边形的一条边上。 + return boundOrVertex; + } else { + //如果当前点在水平线以下,增加一个交点。 + ++intersectCount; + } + } else { + // 如果不是水平线,则用两点式求当前点的x带入多边形线段的直线方程后,对应的y的坐标 + double xInSideLineFormulaResultY = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y; + if (Math.abs(p.y - xInSideLineFormulaResultY) < precision) { + // 误差允许范围内,改点就在线段上,则表明,该点位于多边形的一个边上。 + return boundOrVertex; + } + + if (p.y < xInSideLineFormulaResultY) { + // 如果线段上取得的y比当前点的y要大,当前做向上的射线,肯定交于上方的一个点。 + ++intersectCount; + } + } + } + } else { + // 当前点不在线段投影到x轴的区间中 + if (p.x == p2.x && p.y <= p2.y) { + // 但恰好位于线段终点的x坐标对应的平行于y轴上的线上的低于终点y的一点 + // 此时检查下一点能否将其x边界包含。 + Point2D.Double p3 = pts.get((i + 1) % polygonSidesCount); + if (p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)) { + // 若当前点的x坐标位于 p1和p3组成的线段关于x轴的投影中,则记为该点的射线只穿过端点一次。 + ++intersectCount; + } else { + // 若当前点的x坐标不能包含在p1和p3组成的线段关于x轴的投影中,则点射线通过的两条线段组成了一个弯折的部分, + // 此时我们记射线穿过该端点两次 + intersectCount += 2; + } + // 此判断的核心思路是由点在两条线段的内部还是外部去思考得出的 + } + } + // 进行下一个线段的判断 + p1 = p2; + } + if (intersectCount % 2 == 0) { + //偶数在多边形外 + return false; + } else { + //奇数在多边形内 + return true; + } + } + +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy index 58a13a34d..25f5c45ed 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/looplineinfo/InsidePolygon.groovy @@ -324,4 +324,8 @@ class InsidePolygon { } return name; } + + + + } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy index 30419ba47..f4801828f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy @@ -35,7 +35,7 @@ class GaoDeApiUtils { content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") } JSONObject jsonObj = JSONObject.fromObject(content) - if(jsonObj.status!=1){ + if(jsonObj.status!="1"){ println jsonObj } return jsonObj From b1819a64701bdab75740fe5bcb08cb599047b240 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 13:13:42 +0800 Subject: [PATCH 224/230] =?UTF-8?q?=E5=85=88=E4=B8=8D=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=B9=A1=E9=95=87=E6=98=AF=E5=90=A6=E6=A0=87=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/TownStandardBatch.groovy | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 0034cdb20..d8ee85b0c 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -459,7 +459,7 @@ class TownStandardBatch extends BaseBatch{ totalCount.addAndGet(1) def rMap = regionFullNameMap.get(r.city) if (rMap) { - def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) + def townMap = null//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() // if (set.size() >= 1) { @@ -524,9 +524,10 @@ class TownStandardBatch extends BaseBatch{ saveObj.township = gaodeMap.township saveObj.new_district = gaodeMap.district saveObj.town_source = "高德API" - if(townMap.size()>=1){ - saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) - } + saveObj.strand_town = "" +// if(townMap.size()>=1){ +// saveObj.strand_town = isStandTown(townMap, saveObj.new_district, saveObj.township) +// } } } From b519a64b9c3d7fffc7d67221763b998075b6ba25 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Thu, 20 Feb 2025 13:46:01 +0800 Subject: [PATCH 225/230] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E9=99=8D?= =?UTF-8?q?=E4=BD=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/TownStandardBatch.groovy | 2 +- .../yinjihaun/amap/GaoDeApiUtils.groovy | 30 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index d8ee85b0c..0feaa0b5e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(100) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def updateList = [] def addAliasList = [] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy index f4801828f..60dc4ddb2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy @@ -12,6 +12,7 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { + //94c74c60e102972a8d17b7b75d7403be def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995:dfc2245bac8a7b2d5b62e060e59d4eca @@ -29,15 +30,28 @@ class GaoDeApiUtils { params.put("location", location) params.put("extensions","all") String content - try { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") - } catch (Exception e) { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") - } - JSONObject jsonObj = JSONObject.fromObject(content) - if(jsonObj.status!="1"){ - println jsonObj + def stop = true + JSONObject jsonObj = null + def errorCount = 1 + while (stop){ + try { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } catch (Exception e) { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } + jsonObj = JSONObject.fromObject(content) + if(jsonObj.status!="1"){ + println jsonObj + errorCount ++ + Thread.sleep(3000) + if(errorCount>3){ + stop = false + } + }else{ + stop = false + } } + return jsonObj } From b5efda084a10d95ebba0cb497957508fdbac7f8b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 11:18:04 +0800 Subject: [PATCH 226/230] =?UTF-8?q?=E7=A9=BA=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/gj/data_handle/TownStandardBatch.groovy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 0feaa0b5e..3ace39f53 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5) def updateList = [] def addAliasList = [] @@ -380,7 +380,12 @@ class TownStandardBatch extends BaseBatch{ o.put("district", arrs[4]) o.put("lng", arrs[5]) o.put("lat", arrs[6]) - o.put("data_source", arrs[7]) + if(arrs[7]){ + o.put("data_source", arrs[7]) + }else{ + o.put("data_source", "") + } + rets << o }catch(Exception e){ println arrs @@ -459,7 +464,7 @@ class TownStandardBatch extends BaseBatch{ totalCount.addAndGet(1) def rMap = regionFullNameMap.get(r.city) if (rMap) { - def townMap = null//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) +// def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() // if (set.size() >= 1) { From 50481d224b2184e73756953f39d6799d94041a0b Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 19:50:21 +0800 Subject: [PATCH 227/230] update --- .../script/gj/data_handle/TownStandardBatch.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 3ace39f53..79569b74a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -380,12 +380,12 @@ class TownStandardBatch extends BaseBatch{ o.put("district", arrs[4]) o.put("lng", arrs[5]) o.put("lat", arrs[6]) - if(arrs[7]){ - o.put("data_source", arrs[7]) + println arrs.size() + if(arrs.size()<=7){ + o.put("data_source","") }else{ - o.put("data_source", "") + o.put("data_source", arrs[7]) } - rets << o }catch(Exception e){ println arrs From e1228c538a81a4b1970261117ddba7b0e17622de Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 20:00:22 +0800 Subject: [PATCH 228/230] update --- .../fangjia/script/gj/data_handle/TownStandardBatch.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index 79569b74a..a614c04e5 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) def updateList = [] def addAliasList = [] @@ -464,8 +464,8 @@ class TownStandardBatch extends BaseBatch{ totalCount.addAndGet(1) def rMap = regionFullNameMap.get(r.city) if (rMap) { -// def townMap = CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) - def set = rMap.keySet() + def townMap = [:]//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) +// def set = rMap.keySet() println totalCount.get() +" "+r.city + " " + set.size() // if (set.size() >= 1) { addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) From ad8cf3b8f5c5a8b8782bd7713697e0aea37144c4 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sat, 22 Feb 2025 20:07:04 +0800 Subject: [PATCH 229/230] update --- .../com/fangjia/script/gj/data_handle/TownStandardBatch.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index a614c04e5..69c368290 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -380,7 +380,6 @@ class TownStandardBatch extends BaseBatch{ o.put("district", arrs[4]) o.put("lng", arrs[5]) o.put("lat", arrs[6]) - println arrs.size() if(arrs.size()<=7){ o.put("data_source","") }else{ @@ -466,7 +465,7 @@ class TownStandardBatch extends BaseBatch{ if (rMap) { def townMap = [:]//CommonDatautils.queryTownByCity(r.city, ["city", "district", "mzb_district_name", "street", "alias", "shape"]) // def set = rMap.keySet() - println totalCount.get() +" "+r.city + " " + set.size() + println totalCount.get() +" "+r.city + " " // if (set.size() >= 1) { addTown(r, townMap, ["lon":r.lng.toString().toDouble(), "lat":r.lat.toString().toDouble()]) results << [r.id, r.province, r.city, r.district, r.lng, r.lat, r.data_source, r.township, r.new_district, r.town_source, r.strand_town] From c241012fe0af2bd98354de45f7937f36a82312fc Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 28 Feb 2025 18:50:34 +0800 Subject: [PATCH 230/230] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=8F=91=E9=82=AE?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/dataAna/CityInfoAnaBatch.groovy | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy index d008b0f48..8511662a1 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dataAna/CityInfoAnaBatch.groovy @@ -343,21 +343,21 @@ class CityInfoAnaBatch extends BaseBatch { def totalDbhouseloudongCount = HOUSE_LOUDONG_CONN.count(findObj) datas << ['', totalDistrictCount, totalLoudongCount, df.format(totalLoudongCount * 1.0/ totalDistrictCount), totalFanghaoCount, df.format(totalFanghaoCount * 1.0/ totalDistrictCount), totalDbLoudongCount, totalDbhouseloudongCount] - ExcelUtils.write(fileName, datas, resultTitle) - String id = ObjectId.get().toString() - BasicDBObject file = new BasicDBObject() - file.put("t", "upload") - file.put("content_type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") - file.put("c_date", new Date()) - file.put("_id", idGenerator(id, "o")) - file.put("data", new File(fileName).getBytes()) - fsDB.save(file) - def href = DataUtil.encodePicUrl(id, "o", "upload") - href = "点击下载附件" - receivers.each {receiver-> - jms.sendMail(receiver, resultTitle, href) - } - new File(fileName).deleteOnExit() +// ExcelUtils.write(fileName, datas, resultTitle) +// String id = ObjectId.get().toString() +// BasicDBObject file = new BasicDBObject() +// file.put("t", "upload") +// file.put("content_type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") +// file.put("c_date", new Date()) +// file.put("_id", idGenerator(id, "o")) +// file.put("data", new File(fileName).getBytes()) +// fsDB.save(file) +// def href = DataUtil.encodePicUrl(id, "o", "upload") +// href = "点击下载附件" +// receivers.each {receiver-> +// jms.sendMail(receiver, resultTitle, href) +// } +// new File(fileName).deleteOnExit() } private String idGenerator(String url, String size) {