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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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/181] =?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 0defcebdafd2d68b3198184317ba717b6ffa7143 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 19 Dec 2024 15:25:35 +0800 Subject: [PATCH 144/181] =?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 145/181] =?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 db1208eac37ae8230c62a7d62e98a074bb041ed7 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Fri, 20 Dec 2024 11:33:10 +0800 Subject: [PATCH 146/181] =?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 147/181] 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 148/181] 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 151/181] =?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 152/181] =?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 153/181] =?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 154/181] =?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 155/181] =?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 4c6716694ed8dadb3f47edb7665f202ceaab2846 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 11:15:06 +0800 Subject: [PATCH 156/181] =?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 157/181] =?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 158/181] =?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 667fae514ced67ec197841eb4930ebc71374a373 Mon Sep 17 00:00:00 2001 From: majintao Date: Wed, 25 Dec 2024 16:23:10 +0800 Subject: [PATCH 159/181] =?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 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 160/181] =?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 161/181] =?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 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 162/181] =?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 163/181] 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 164/181] =?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 165/181] =?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 166/181] =?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 2fc12021c97fa1b0a88e36d907415a4dfad51009 Mon Sep 17 00:00:00 2001 From: majintao Date: Thu, 2 Jan 2025 13:23:46 +0800 Subject: [PATCH 167/181] =?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 168/181] =?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 169/181] =?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 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 170/181] =?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 171/181] =?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 172/181] =?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 173/181] =?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 174/181] =?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 6959b95aeb1579118b7f9be08487f3f75f890a29 Mon Sep 17 00:00:00 2001 From: majintao Date: Tue, 7 Jan 2025 14:58:55 +0800 Subject: [PATCH 175/181] =?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 176/181] =?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 177/181] =?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 178/181] =?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 179/181] =?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 180/181] =?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 181/181] =?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; + } +}