فهرست منبع

update from 0719

wucl 1 سال پیش
والد
کامیت
d6ba877860
25فایلهای تغییر یافته به همراه703 افزوده شده و 423 حذف شده
  1. 1 0
      src/main/java/com/leeroa/dydb/datasource/loanorder/service/impl/DataLoanOrderServiceImpl.java
  2. 103 84
      src/main/java/com/leeroa/dydb/datasource/localimport/service/impl/CommunityImportServiceImpl.java
  3. 21 12
      src/main/java/com/leeroa/dydb/datasource/qiyu/service/impl/DataQiYuDealServiceImpl.java
  4. 20 12
      src/main/java/com/leeroa/dydb/datasource/qiyu/service/impl/DataQiYuUpServiceImpl.java
  5. 4 0
      src/main/java/com/leeroa/dydb/datasource/utils/HouseUtils.java
  6. 31 10
      src/main/java/com/leeroa/dydb/datasource/utils/SpiderUtils.java
  7. 1 0
      src/main/java/com/leeroa/dydb/price/dao/CommunityPriceDao.java
  8. 18 2
      src/main/java/com/leeroa/dydb/price/dao/impl/CommunityPriceDaoImpl.java
  9. 2 0
      src/main/java/com/leeroa/dydb/price/dao/impl/CommunityQueryDaoImpl.java
  10. 3 1
      src/main/java/com/leeroa/dydb/price/schedule/CommunityPriceSchedule.java
  11. 8 6
      src/main/java/com/leeroa/dydb/price/service/CommunityPriceService.java
  12. 4 1
      src/main/java/com/leeroa/dydb/price/service/impl/CommunityPriceInitServiceImpl.java
  13. 200 165
      src/main/java/com/leeroa/dydb/price/service/impl/CommunityPriceServiceImpl.java
  14. 22 0
      src/main/java/com/leeroa/dydb/price/web/CommunityPriceCtrl.java
  15. 69 69
      src/main/java/com/leeroa/dydb/utils/baidu/BaiduMapUtils.java
  16. 121 41
      src/main/java/com/leeroa/dydb/zhaoshang/service/impl/QueryLogServiceImpl.java
  17. 7 2
      src/main/webapp/app/dydb/datasource/dataQiYuDeal/dataQiYuDeal_list.js
  18. 3 2
      src/main/webapp/app/dydb/datasource/dataQiYuDeal/dataQiYuDeal_list.jsp
  19. 7 2
      src/main/webapp/app/dydb/datasource/dataQiYuUp/dataQiYuUp_list.js
  20. 2 1
      src/main/webapp/app/dydb/datasource/dataQiYuUp/dataQiYuUp_list.jsp
  21. 3 0
      src/main/webapp/app/dydb/price/communityPrice/communityPrice.js
  22. 30 1
      src/main/webapp/app/dydb/price/communityPrice/communityPrice_list.js
  23. 21 10
      src/main/webapp/app/dydb/price/communityPrice/communityPrice_list.jsp
  24. 2 1
      src/main/webapp/app/dydb/price/communityQuery/communityQuery_list.js
  25. 0 1
      src/main/webapp/app/dydb/price/communityQuery/communityQuery_list.jsp

+ 1 - 0
src/main/java/com/leeroa/dydb/datasource/loanorder/service/impl/DataLoanOrderServiceImpl.java

@@ -266,6 +266,7 @@ public class DataLoanOrderServiceImpl implements DataLoanOrderService, BeanWrapC
                     // 根据小区名称,更新小区的坐落地址
                     CommunityPrice cp = (CommunityPrice) session.createCriteria(CommunityPrice.class)
                             .add(Restrictions.eq("houses", houseName))
+                            .add(Restrictions.eq("cityName", "成都市"))
                             .setMaxResults(1)
                             .uniqueResult();
                     if (cp == null) {

+ 103 - 84
src/main/java/com/leeroa/dydb/datasource/localimport/service/impl/CommunityImportServiceImpl.java

@@ -20,9 +20,12 @@ import com.leeroa.dydb.datasource.localimport.vo.CommunityImportVo;
 import com.leeroa.dydb.datasource.utils.HouseUtils;
 import com.leeroa.dydb.price.domain.BuildingsPrice;
 import com.leeroa.dydb.price.domain.CommunityPrice;
+import com.leeroa.dydb.price.domain.CommunityQuery;
 import com.leeroa.dydb.price.dto.EvaluateDTO;
 import com.leeroa.dydb.price.enums.HousePriceEnum;
 import com.leeroa.dydb.utils.DoubleUtils;
+import com.leeroa.dydb.zhaoshang.domain.QueryLog;
+import com.leeroa.dydb.zhaoshang.service.QueryLogService;
 import com.michael.core.beans.BeanWrapBuilder;
 import com.michael.core.beans.BeanWrapCallback;
 import com.michael.core.hibernate.HibernateUtils;
@@ -52,6 +55,7 @@ import org.springframework.util.Assert;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
@@ -64,6 +68,9 @@ public class CommunityImportServiceImpl implements CommunityImportService, BeanW
     @Resource
     private CommunityImportDao housePriceDao;
 
+    @Resource
+    private QueryLogService queryLogService;
+
 
     private LoadingCache<String, CommunityImport> housePriceLoadingCache = CacheBuilder.newBuilder().maximumSize(20000)
             .expireAfterAccess(1, TimeUnit.HOURS)
@@ -298,94 +305,106 @@ public class CommunityImportServiceImpl implements CommunityImportService, BeanW
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public Map<String, Object> evaluate(EvaluateDTO dto) {
-        String name = dto.getName();
-        Map<String, Object> data = new HashMap<>();
-        data.put("price", 0d);
-        data.put("money", 0d);
-        Assert.hasText(name, "小区名称不能为空!");
-        final Session session = HibernateUtils.getSession();
-        // 先获取小区信息
-        CommunityPrice communityPrice = (CommunityPrice) session.createCriteria(CommunityPrice.class)
-                .add(Restrictions.eq("houses", name))
-                .setMaxResults(1)
-                .uniqueResult();
-        if (communityPrice == null) {
-            return data;
-        }
-
-        double avgPrice = communityPrice.getPrice();
-
-        double rate = 1.0;
-        // 基准面积--这里面积配置,调整为具体的面积,不再是比例
-        double areaRate = dto.getArea();
-        IndexWeightDetail detail = IndexWeightUtils.getIndex(HousePriceEnum.AREA.name(), areaRate + "");
-        Assert.notNull(detail, "未获取到适合配置的权重[" + HousePriceEnum.AREA.name() + "]!" + areaRate);
-        String areaValue = detail.getValues();
-        Assert.isTrue(RegUtils.isDouble(areaValue), "不合法的配置[" + HousePriceEnum.AREA.name() + "],必须是数字!");
-        rate = Double.parseDouble(areaValue) * rate;
-
-        // 楼层
-        final String floor = dto.getFloor();
-        if (StringUtils.isNotEmpty(floor)) {
-            IndexWeightDetail floorDetail = IndexWeightUtils.getIndex(HousePriceEnum.FLOOR.name(), floor);
-            Assert.notNull(floorDetail, "未获取到适合配置的权重[" + HousePriceEnum.FLOOR.name() + "]!" + floor);
-            String floorValue = floorDetail.getValues();
-            Assert.isTrue(RegUtils.isDouble(floorValue), "不合法的配置[" + HousePriceEnum.FLOOR.name() + "],必须是数字!");
-            rate = Double.parseDouble(floorValue) * rate;
-            log.info("小区价格评估,楼层系数:{}", floorValue);
-        }
-
-
-        // 装修
-        final String decoration = dto.getDecoration();
-        if (StringUtils.isNotEmpty(decoration)) {
-            IndexWeightDetail decorationDetail = IndexWeightUtils.getIndex(HousePriceEnum.DECORATION.name(), decoration);
-            Assert.notNull(decorationDetail, "未获取到适合配置的权重[" + HousePriceEnum.DECORATION.name() + "]!" + decoration);
-            String decorationValue = decorationDetail.getValues();
-            Assert.isTrue(RegUtils.isDouble(decorationValue), "不合法的配置[" + HousePriceEnum.DECORATION.name() + "],必须是数字!");
-            rate = Double.parseDouble(decorationValue) * rate;
-            log.info("小区价格评估,装修系数:{}", decorationValue);
-        }
-
-        // 临路
-        final String road = dto.getRoad();
-        if (StringUtils.isNotEmpty(road)) {
-            IndexWeightDetail roadDetail = IndexWeightUtils.getIndex(HousePriceEnum.ROAD.name(), road);
-            Assert.notNull(roadDetail, "未获取到适合配置的权重[" + HousePriceEnum.ROAD.name() + "]!" + road);
-            String roadValue = roadDetail.getValues();
-            Assert.isTrue(RegUtils.isDouble(roadValue), "不合法的配置[" + HousePriceEnum.ROAD.name() + "],必须是数字!");
-            rate = Double.parseDouble(roadValue) * rate;
-            log.info("小区价格评估,临路系数:{}", roadValue);
-        }
-
-        // 是否顶层或1层
-        boolean isFloorOrTop = IntegerUtils.nullEqual(dto.getNowFloor(), 1) || IntegerUtils.nullEqual(dto.getNowFloor(), dto.getMaxFloor());
-        if (isFloorOrTop) {
-            boolean garden = BooleanUtils.isTrue(dto.getGarden());
-            IndexWeightDetail gardenWeight = IndexWeightUtils.getIndex(HousePriceEnum.GARDEN.name(), garden ? "带花园" : "不带花园");
-            Assert.notNull(gardenWeight, "未获取到适合配置的权重[" + HousePriceEnum.GARDEN.name() + "]!" + road);
-            String value = gardenWeight.getValues();
-            Assert.isTrue(RegUtils.isDouble(value), "不合法的配置[" + HousePriceEnum.GARDEN.name() + "],必须是数字!");
-            rate = Double.parseDouble(value) * rate;
-            log.info("小区价格评估,花园系数:{}", value);
-        }
-
-        // 获得浮动比例
-        IndexWeightDetail dynamicRate = IndexWeightUtils.getIndex("其他配置", "浮动比例");
-        if (dynamicRate != null) {
-            String rateValue = dynamicRate.getValues();
-            Assert.isTrue(RegUtils.isDouble(rateValue), "不合法的配置[浮动比例],必须是数字!");
-            rate = rate * 0.01d * Double.parseDouble(rateValue);
-            log.info("小区价格评估,浮动比例系数:{}", rateValue);
-        }
-
-        data.put("price", DoubleUtils.multiply(avgPrice, rate));
-        data.put("money", DoubleUtils.divide(dto.getArea() * avgPrice * rate, 10000d));
+        QueryLog queryLog = new QueryLog();
+        queryLog.setAddress(dto.getName());
+        queryLog.setBuildingArea(String.valueOf(dto.getArea()));
+        Map<String,Object> data = new HashMap<>();
+        CommunityQuery communityQuery = queryLogService.queryByZhaoShang(queryLog);
+        data.put("price", new BigDecimal(communityQuery.getPrice()).setScale(0,1).toPlainString());
+        data.put("money", new BigDecimal(communityQuery.getMoney()).setScale(0,1).toPlainString());
         return data;
     }
 
+//    @Override
+//    @SuppressWarnings("unchecked")
+//    public Map<String, Object> evaluate(EvaluateDTO dto) {
+//        String name = dto.getName();
+//        Map<String, Object> data = new HashMap<>();
+//        data.put("price", 0d);
+//        data.put("money", 0d);
+//        Assert.hasText(name, "小区名称不能为空!");
+//        final Session session = HibernateUtils.getSession();
+//        // 先获取小区信息
+//        CommunityPrice communityPrice = (CommunityPrice) session.createCriteria(CommunityPrice.class)
+//                .add(Restrictions.eq("houses", name))
+//                .setMaxResults(1)
+//                .uniqueResult();
+//        if (communityPrice == null) {
+//            return data;
+//        }
+//
+//        double avgPrice = communityPrice.getPrice();
+//
+//        double rate = 1.0;
+//        // 基准面积--这里面积配置,调整为具体的面积,不再是比例
+//        double areaRate = dto.getArea();
+//        IndexWeightDetail detail = IndexWeightUtils.getIndex(HousePriceEnum.AREA.name(), areaRate + "");
+//        Assert.notNull(detail, "未获取到适合配置的权重[" + HousePriceEnum.AREA.name() + "]!" + areaRate);
+//        String areaValue = detail.getValues();
+//        Assert.isTrue(RegUtils.isDouble(areaValue), "不合法的配置[" + HousePriceEnum.AREA.name() + "],必须是数字!");
+//        rate = Double.parseDouble(areaValue) * rate;
+//
+//        // 楼层
+//        final String floor = dto.getFloor();
+//        if (StringUtils.isNotEmpty(floor)) {
+//            IndexWeightDetail floorDetail = IndexWeightUtils.getIndex(HousePriceEnum.FLOOR.name(), floor);
+//            Assert.notNull(floorDetail, "未获取到适合配置的权重[" + HousePriceEnum.FLOOR.name() + "]!" + floor);
+//            String floorValue = floorDetail.getValues();
+//            Assert.isTrue(RegUtils.isDouble(floorValue), "不合法的配置[" + HousePriceEnum.FLOOR.name() + "],必须是数字!");
+//            rate = Double.parseDouble(floorValue) * rate;
+//            log.info("小区价格评估,楼层系数:{}", floorValue);
+//        }
+//
+//
+//        // 装修
+//        final String decoration = dto.getDecoration();
+//        if (StringUtils.isNotEmpty(decoration)) {
+//            IndexWeightDetail decorationDetail = IndexWeightUtils.getIndex(HousePriceEnum.DECORATION.name(), decoration);
+//            Assert.notNull(decorationDetail, "未获取到适合配置的权重[" + HousePriceEnum.DECORATION.name() + "]!" + decoration);
+//            String decorationValue = decorationDetail.getValues();
+//            Assert.isTrue(RegUtils.isDouble(decorationValue), "不合法的配置[" + HousePriceEnum.DECORATION.name() + "],必须是数字!");
+//            rate = Double.parseDouble(decorationValue) * rate;
+//            log.info("小区价格评估,装修系数:{}", decorationValue);
+//        }
+//
+//        // 临路
+//        final String road = dto.getRoad();
+//        if (StringUtils.isNotEmpty(road)) {
+//            IndexWeightDetail roadDetail = IndexWeightUtils.getIndex(HousePriceEnum.ROAD.name(), road);
+//            Assert.notNull(roadDetail, "未获取到适合配置的权重[" + HousePriceEnum.ROAD.name() + "]!" + road);
+//            String roadValue = roadDetail.getValues();
+//            Assert.isTrue(RegUtils.isDouble(roadValue), "不合法的配置[" + HousePriceEnum.ROAD.name() + "],必须是数字!");
+//            rate = Double.parseDouble(roadValue) * rate;
+//            log.info("小区价格评估,临路系数:{}", roadValue);
+//        }
+//
+//        // 是否顶层或1层
+//        boolean isFloorOrTop = IntegerUtils.nullEqual(dto.getNowFloor(), 1) || IntegerUtils.nullEqual(dto.getNowFloor(), dto.getMaxFloor());
+//        if (isFloorOrTop) {
+//            boolean garden = BooleanUtils.isTrue(dto.getGarden());
+//            IndexWeightDetail gardenWeight = IndexWeightUtils.getIndex(HousePriceEnum.GARDEN.name(), garden ? "带花园" : "不带花园");
+//            Assert.notNull(gardenWeight, "未获取到适合配置的权重[" + HousePriceEnum.GARDEN.name() + "]!" + road);
+//            String value = gardenWeight.getValues();
+//            Assert.isTrue(RegUtils.isDouble(value), "不合法的配置[" + HousePriceEnum.GARDEN.name() + "],必须是数字!");
+//            rate = Double.parseDouble(value) * rate;
+//            log.info("小区价格评估,花园系数:{}", value);
+//        }
+//
+//        // 获得浮动比例
+//        IndexWeightDetail dynamicRate = IndexWeightUtils.getIndex("其他配置", "浮动比例");
+//        if (dynamicRate != null) {
+//            String rateValue = dynamicRate.getValues();
+//            Assert.isTrue(RegUtils.isDouble(rateValue), "不合法的配置[浮动比例],必须是数字!");
+//            rate = rate * 0.01d * Double.parseDouble(rateValue);
+//            log.info("小区价格评估,浮动比例系数:{}", rateValue);
+//        }
+//
+//        data.put("price", DoubleUtils.multiply(avgPrice, rate));
+//        data.put("money", DoubleUtils.divide(dto.getArea() * avgPrice * rate, 10000d));
+//        return data;
+//    }
+
 
     @Override
     @SuppressWarnings("unchecked")

+ 21 - 12
src/main/java/com/leeroa/dydb/datasource/qiyu/service/impl/DataQiYuDealServiceImpl.java

@@ -78,6 +78,8 @@ public class DataQiYuDealServiceImpl implements DataQiYuDealService, BeanWrapCal
             cp.setBuildArea(dataQiYuDeal.getBuildArea());
             cp.setLongitude(dataQiYuDeal.getLongitude());
             cp.setLatitude(dataQiYuDeal.getLatitude());
+            cp.setCityName(dataQiYuDeal.getCityName());
+            cp.setAreaName(dataQiYuDeal.getAreaName());
             if (dataQiYuDeal.getBuildYear() != null) {
                 cp.setBuildYear(dataQiYuDeal.getBuildYear().toString());
             }
@@ -112,6 +114,9 @@ public class DataQiYuDealServiceImpl implements DataQiYuDealService, BeanWrapCal
     @Override
     public PageVo pageQuery(DataQiYuDealBo bo) {
         PageVo vo = new PageVo();
+        if ("全部".equals(bo.getCityName())){
+            bo.setCityName(null);
+        }
         Long total = dataQiYuDealDao.getTotal(bo);
         vo.setTotal(total);
         if (total == null || total == 0) {
@@ -190,21 +195,25 @@ public class DataQiYuDealServiceImpl implements DataQiYuDealService, BeanWrapCal
                 if (StringUtils.isEmpty(dataQiYuDeal.getHouses())) {
                     return;
                 }
-                // 如果数据不符合规范,则跳过
-                if (!HouseUtils.check(dto.getPrice(), dto.getBuildArea())) {
-                    log.info("{}. 小区[{}]的价格或面积不满足导入条件,本次跳过!{}-{}", context.getRowIndex(), dto.getHouses(), dto.getPrice(), dto.getBuildArea());
-                    return;
-                }
                 String dt = dto.getDealDateStr();
-                if (StringUtils.isEmpty(dt)) {
-                    log.info("{}. 小区[{}]的成交日期不满足导入条件,本次跳过!", context.getRowIndex(), dto.getHouses());
-                    return;
-                }
                 DateTime upDate = DateUtil.parse(dt);
-                if (upDate == null) {
-                    log.info("{}. 小区[{}]的成交日期不满足导入条件,本次跳过!{}", context.getRowIndex(), dto.getHouses(), dt);
-                    return;
+                if (dto.getCityName().contains("成都")){
+                    // 如果数据不符合规范,则跳过
+                    if (!HouseUtils.check(dto.getPrice(), dto.getBuildArea())) {
+                        log.info("{}. 小区[{}]的价格或面积不满足导入条件,本次跳过!{}-{}", context.getRowIndex(), dto.getHouses(), dto.getPrice(), dto.getBuildArea());
+                        return;
+                    }
+
+                    if (StringUtils.isEmpty(dt)) {
+                        log.info("{}. 小区[{}]的成交日期不满足导入条件,本次跳过!", context.getRowIndex(), dto.getHouses());
+                        return;
+                    }
+                    if (upDate == null) {
+                        log.info("{}. 小区[{}]的成交日期不满足导入条件,本次跳过!{}", context.getRowIndex(), dto.getHouses(), dt);
+                        return;
+                    }
                 }
+
                 dataQiYuDeal.setDealDate(upDate.toJdkDate());
                 // 处理区的名称
                 dataQiYuDeal.setAreaName(HouseUtils.formatArea(dataQiYuDeal.getAreaName()));

+ 20 - 12
src/main/java/com/leeroa/dydb/datasource/qiyu/service/impl/DataQiYuUpServiceImpl.java

@@ -79,6 +79,8 @@ public class DataQiYuUpServiceImpl implements DataQiYuUpService, BeanWrapCallbac
             cp.setBuildArea(dataQiYuUp.getBuildArea());
             cp.setLongitude(dataQiYuUp.getLongitude());
             cp.setLatitude(dataQiYuUp.getLatitude());
+            cp.setCityName(dataQiYuUp.getCityName());
+            cp.setAreaName(dataQiYuUp.getAreaName());
             if (dataQiYuUp.getBuildYear() != null) {
                 cp.setBuildYear(dataQiYuUp.getBuildYear().toString());
             }
@@ -114,6 +116,9 @@ public class DataQiYuUpServiceImpl implements DataQiYuUpService, BeanWrapCallbac
     @Override
     public PageVo pageQuery(DataQiYuUpBo bo) {
         PageVo vo = new PageVo();
+        if ("全部".equals(bo.getCityName())){
+            bo.setCityName(null);
+        }
         Long total = dataQiYuUpDao.getTotal(bo);
         vo.setTotal(total);
         if (total == null || total == 0) {
@@ -192,21 +197,24 @@ public class DataQiYuUpServiceImpl implements DataQiYuUpService, BeanWrapCallbac
                 if (StringUtils.isEmpty(dataQiYuUp.getHouses())) {
                     return;
                 }
-                // 如果数据不符合规范,则跳过
-                if (!HouseUtils.check(dto.getPrice(), dto.getBuildArea())) {
-                    log.info("{}. 小区[{}]的价格或面积不满足导入条件,本次跳过!{}-{}", context.getRowIndex(), dto.getHouses(), dto.getPrice(), dto.getBuildArea());
-                    return;
-                }
                 String dt = dto.getUpDateStr();
-                if (StringUtils.isEmpty(dt)) {
-                    log.info("{}. 小区[{}]的挂牌日期不满足导入条件,本次跳过!", context.getRowIndex(), dto.getHouses());
-                    return;
-                }
                 DateTime upDate = DateUtil.parse(dt);
-                if (upDate == null) {
-                    log.info("{}. 小区[{}]的挂牌日期不满足导入条件,本次跳过!{}", context.getRowIndex(), dto.getHouses(), dt);
-                    return;
+                // 如果数据不符合规范,则跳过
+                if (dto.getCityName().contains("成都")){
+                    if (!HouseUtils.check(dto.getPrice(), dto.getBuildArea())) {
+                        log.info("{}. 小区[{}]的价格或面积不满足导入条件,本次跳过!{}-{}", context.getRowIndex(), dto.getHouses(), dto.getPrice(), dto.getBuildArea());
+                        return;
+                    }
+                    if (StringUtils.isEmpty(dt)) {
+                        log.info("{}. 小区[{}]的挂牌日期不满足导入条件,本次跳过!", context.getRowIndex(), dto.getHouses());
+                        return;
+                    }
+                    if (upDate == null) {
+                        log.info("{}. 小区[{}]的挂牌日期不满足导入条件,本次跳过!{}", context.getRowIndex(), dto.getHouses(), dt);
+                        return;
+                    }
                 }
+
                 // 处理区的名称
                 dataQiYuUp.setAreaName(HouseUtils.formatArea(dataQiYuUp.getAreaName()));
                 dataQiYuUp.setUpDate(upDate.toJdkDate());

+ 4 - 0
src/main/java/com/leeroa/dydb/datasource/utils/HouseUtils.java

@@ -145,6 +145,7 @@ public class HouseUtils {
         return null;
     }
 
+
     public static String getArea(String address) {
         if (address == null) {
             return null;
@@ -292,6 +293,7 @@ public class HouseUtils {
         return Optional.empty();
     }
 
+
     /**
      * 从地址中直接获取小区名称,需要地址中包含"区"
      *
@@ -456,6 +458,8 @@ public class HouseUtils {
         return null;
     }
 
+
+
     private static String removeRepeat(String text) {
         int length = text.length();
         if (length % 2 == 0) {

+ 31 - 10
src/main/java/com/leeroa/dydb/datasource/utils/SpiderUtils.java

@@ -2,8 +2,11 @@ package com.leeroa.dydb.datasource.utils;
 
 import com.michael.utils.gson.GsonUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
 import org.apache.http.client.fluent.Request;
 import org.apache.http.entity.StringEntity;
+import org.apache.http.util.EntityUtils;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -19,21 +22,29 @@ public class SpiderUtils {
     private static final String spider_json = "http://spider.leeroa.com/spider/json";
 
     public static String html(String url,String homeLinkCookie) {
-        Map<String, String> headers = new HashMap<>();
+        Map<String,Object> obj = SignUtils.signMap(url);
+        Map<String,Object> headers = new HashMap<>();
+        headers.put("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36");
         headers.put("Cookie",homeLinkCookie);
-        String json = GsonUtils.toJson(SignUtils.signMap(url,headers));
+        obj.put("headers",headers);
+        String json = GsonUtils.toJson(obj);
         for (int i = 0; i < 5; i++) {
             try {
                 log.info("spider request {} => {}", i + 1, url);
-                return Request.Post(spider_html)
+                HttpResponse response = Request.Post(spider_html)
                         .body(new StringEntity(json, StandardCharsets.UTF_8))
                         .addHeader("Content-Type", "application/json")
                         .addHeader("Connection", "keep-alive")
                         .addHeader("Accept", "*/*")
                         .addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36")
                         .execute()
-                        .returnContent()
-                        .asString(StandardCharsets.UTF_8);
+                        .returnResponse();
+                StatusLine statusLine = response.getStatusLine();
+                if (statusLine.getStatusCode() != 200){
+                    return null;
+                }
+                String html = EntityUtils.toString(response.getEntity());
+                return html;
             } catch (IOException e) {
 //                log.info("spider exception - {} : {}", i + 1, e.getMessage());
             }
@@ -42,19 +53,28 @@ public class SpiderUtils {
     }
 
     public static String html(String url) {
-        String json = GsonUtils.toJson(SignUtils.signMap(url));
+        Map<String,Object> obj = SignUtils.signMap(url);
+        Map<String,Object> headers = new HashMap<>();
+        headers.put("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36");
+        obj.put("headers",headers);
+        String json = GsonUtils.toJson(obj);
         for (int i = 0; i < 5; i++) {
             try {
                 log.info("spider request {} => {}", i + 1, url);
-                return Request.Post(spider_html)
+                HttpResponse response = Request.Post(spider_html)
                         .body(new StringEntity(json, StandardCharsets.UTF_8))
                         .addHeader("Content-Type", "application/json")
                         .addHeader("Connection", "keep-alive")
                         .addHeader("Accept", "*/*")
                         .addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36")
                         .execute()
-                        .returnContent()
-                        .asString(StandardCharsets.UTF_8);
+                        .returnResponse();
+                StatusLine statusLine = response.getStatusLine();
+                if (statusLine.getStatusCode() != 200){
+                    return null;
+                }
+                String html = EntityUtils.toString(response.getEntity());
+                return html;
             } catch (IOException e) {
 //                log.info("spider exception - {} : {}", i + 1, e.getMessage());
             }
@@ -62,6 +82,7 @@ public class SpiderUtils {
         return null;
     }
     public static void main(String[] args) throws IOException {
-        System.out.println(html("https://cd.lianjia.com/ershoufang/pg" + 2 + "co32/",""));
+        String html = html("https://cd.lianjia.com/ershoufang/pg1co32/");
+        System.out.println(html);
     }
 }

+ 1 - 0
src/main/java/com/leeroa/dydb/price/dao/CommunityPriceDao.java

@@ -39,4 +39,5 @@ public interface CommunityPriceDao {
      */
     void delete(CommunityPrice communityPrice);
 
+
 }

+ 18 - 2
src/main/java/com/leeroa/dydb/price/dao/impl/CommunityPriceDaoImpl.java

@@ -4,9 +4,14 @@ import com.leeroa.dydb.price.bo.CommunityPriceBo;
 import com.leeroa.dydb.price.domain.CommunityPrice;
 import com.leeroa.dydb.price.dao.CommunityPriceDao;
 import com.michael.core.hibernate.HibernateDaoHelper;
+import com.michael.core.hibernate.HibernateUtils;
 import com.michael.core.hibernate.criteria.CriteriaUtils;
 import com.michael.utils.string.StringUtils;
 import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.criterion.MatchMode;
 import org.hibernate.criterion.Restrictions;
 import org.springframework.stereotype.Repository;
 import org.springframework.util.Assert;
@@ -77,8 +82,19 @@ public class CommunityPriceDaoImpl extends HibernateDaoHelper implements Communi
     private void initCriteria(Criteria criteria, CommunityPriceBo bo) {
         Assert.notNull(criteria, "criteria must not be null!");
         if (bo != null){
-            CriteriaUtils.addCondition(criteria, bo);
+            if (StringUtils.isNotEmpty(bo.getCityName()) && !"全部".equals(bo.getCityName())){
+                criteria.add(Restrictions.like("cityName",bo.getCityName(), MatchMode.ANYWHERE));
+            }
+            if (StringUtils.isNotEmpty(bo.getKeywords())){
+                criteria.add(Restrictions.or(
+                        Restrictions.like("houses",bo.getKeywords(), MatchMode.ANYWHERE),
+                                Restrictions.like("address",bo.getKeywords(),MatchMode.ANYWHERE))
+                      );
+            }
+            if (StringUtils.isNotEmpty(bo.getAreaName())){
+                criteria.add(Restrictions.like("areaName",bo.getAreaName(), MatchMode.ANYWHERE));
+            }
+            //CriteriaUtils.addCondition(criteria, bo);
         }
     }
-
 }

+ 2 - 0
src/main/java/com/leeroa/dydb/price/dao/impl/CommunityQueryDaoImpl.java

@@ -6,6 +6,7 @@ import com.leeroa.dydb.price.domain.CommunityQuery;
 import com.michael.core.hibernate.HibernateDaoHelper;
 import com.michael.core.hibernate.criteria.CriteriaUtils;
 import org.hibernate.Criteria;
+import org.hibernate.criterion.Order;
 import org.springframework.stereotype.Repository;
 import org.springframework.util.Assert;
 
@@ -32,6 +33,7 @@ public class CommunityQueryDaoImpl extends HibernateDaoHelper implements Communi
     @SuppressWarnings("unchecked")
     public List<CommunityQuery> pageQuery(CommunityQueryBo bo) {
         Criteria criteria = createPagerCriteria(CommunityQuery.class);
+        criteria.addOrder(Order.desc("createdDatetime"));
         initCriteria(criteria, bo);
         return criteria.list();
     }

+ 3 - 1
src/main/java/com/leeroa/dydb/price/schedule/CommunityPriceSchedule.java

@@ -25,7 +25,6 @@ public class CommunityPriceSchedule {
      * 日常重新计算各个小区的价格
      */
     @Scheduled(cron = "0 0 4 * * ?")
-//    @Scheduled(cron = "*/5 * * * * ?")
     public void dailyInit() throws MessagingException {
 
         try {
@@ -36,6 +35,9 @@ public class CommunityPriceSchedule {
             // 重置小区价格数据
             communityPriceService.dailyInit();
 
+            //更新小区地址
+           // communityPriceService.updateAddressByAMap();
+
             // 重新缓存:因为已经更新了数据。所以这里需要重新缓存
             CommunityPriceCache.getInstance().reloadAllCommunityPrice();
 

+ 8 - 6
src/main/java/com/leeroa/dydb/price/service/CommunityPriceService.java

@@ -114,10 +114,12 @@ public interface CommunityPriceService {
 
     CommunityPrice findByName(String houses);
 
-    /**
-     * 查询指定小区的所有地址的集合
-     * @param houses 小区名称
-     * @return
-     */
-    AddressVO getAddressByName(String houses);
+//    /**
+//     * 查询指定小区的所有地址的集合
+//     * @param houses 小区名称
+//     * @return
+//     */
+//    AddressVO getAddressByName(String houses);
+
+    void updateAddressByAMap();
 }

+ 4 - 1
src/main/java/com/leeroa/dydb/price/service/impl/CommunityPriceInitServiceImpl.java

@@ -57,6 +57,7 @@ public class CommunityPriceInitServiceImpl implements CommunityPriceInitService
             List<CommunityPrice> communityPriceList = session.createCriteria(CommunityPrice.class)
                     .setFirstResult(batch * i)
                     .setMaxResults(batch)
+                    .add(Restrictions.eq("cityName","成都市"))
                     .addOrder(Order.asc("houses"))
                     .list();
             communityPriceList.forEach(k -> {
@@ -93,6 +94,7 @@ public class CommunityPriceInitServiceImpl implements CommunityPriceInitService
         for (int i = 0; i < times; i++) {
             List<CommunityPrice> communityPriceList = session.createCriteria(CommunityPrice.class)
                     .add(Restrictions.isNotNull("houses"))
+                    .add(Restrictions.eq("cityName","成都市"))
                     .setFirstResult(batch * i)
                     .setMaxResults(batch)
                     .addOrder(Order.asc("houses"))
@@ -100,7 +102,8 @@ public class CommunityPriceInitServiceImpl implements CommunityPriceInitService
             communityPriceList.forEach(k -> {
                 // 从几个渠道获取地址
                 String houseName = k.getHouses();
-                AddressVO vo = communityPriceService.getAddressByName(houseName);
+                //AddressVO vo = communityPriceService.getAddressByName(houseName);
+                AddressVO vo = new AddressVO();
                 if (vo == null || vo.getAddress() == null) {
                     return;
                 }

+ 200 - 165
src/main/java/com/leeroa/dydb/price/service/impl/CommunityPriceServiceImpl.java

@@ -1,9 +1,8 @@
 package com.leeroa.dydb.price.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.leeroa.base.log.LogHelper;
 import com.leeroa.base.parameter.service.ParameterContainer;
-import com.leeroa.base.utils.sql.TemplateUtils;
-import com.leeroa.cache.ConfigCache;
 import com.leeroa.core.index.domain.IndexWeightDetail;
 import com.leeroa.core.index.utils.IndexWeightUtils;
 import com.leeroa.core.index.utils.RegUtils;
@@ -23,19 +22,17 @@ import com.leeroa.dydb.price.domain.CommunityPrice;
 import com.leeroa.dydb.price.domain.CommunityPriceHistory;
 import com.leeroa.dydb.price.domain.ViewHousePrice;
 import com.leeroa.dydb.price.service.CommunityPriceService;
-import com.leeroa.dydb.price.vo.AddressVO;
 import com.leeroa.dydb.price.vo.CommunityPriceVo;
 import com.leeroa.dydb.price.vo.DataSourcePriceVO;
 import com.leeroa.dydb.price.vo.PriceTempVO;
 import com.leeroa.dydb.utils.DoubleUtils;
 import com.leeroa.dydb.utils.PriceUtils;
-import com.leeroa.dydb.utils.baidu.*;
+import com.leeroa.dydb.utils.amap.AMapTask;
 import com.michael.core.beans.BeanWrapBuilder;
 import com.michael.core.beans.BeanWrapCallback;
 import com.michael.core.hibernate.HibernateUtils;
 import com.michael.core.hibernate.validator.ValidatorUtils;
 import com.michael.core.pager.PageVo;
-import com.michael.utils.collection.CollectionUtils;
 import com.michael.utils.date.DateUtils;
 import com.michael.utils.number.IntegerUtils;
 import com.michael.utils.string.StringUtils;
@@ -53,6 +50,7 @@ import org.springframework.util.Assert;
 import javax.annotation.Resource;
 import java.math.BigInteger;
 import java.util.*;
+import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -175,92 +173,92 @@ public class CommunityPriceServiceImpl implements CommunityPriceService, BeanWra
 
     @Override
     public void batchInitBaiduInfo(List<CommunityPrice> data) {
-        final int total = data.size();
-        LogHelper.info("%s-->批量更新所有小区的地址信息 ---------- %s", Thread.currentThread().getName(), total);
-        final Session session = HibernateUtils.getSession();
-        final int batch = 30;
-        int index = 0;
-        for (CommunityPrice datum : data) {
-            index++;
-
-            // 如果有经纬度,但是没有地址(说明数据来源于链家)则从百度获取地址
-            String longitude = datum.getLongitude();
-            if (StringUtils.isNotEmpty(longitude) && StringUtils.isEmpty(datum.getAddress())) {
-                BaiduResponseData baiduData = BaiduMapUtils.getByXY(datum.getLongitude(), datum.getLatitude());
-                if (baiduData != null && 0 == baiduData.getStatus()) {
-                    BaiduResult result = baiduData.getResult();
-                    BaiduXY xy = result.getLocation();
-                    if (xy != null && StringUtils.isNotEmpty(xy.getLng())) {
-                        datum.setLongitude(xy.getLng());
-                    }
-                    if (xy != null && StringUtils.isNotEmpty(xy.getLat())) {
-                        datum.setLatitude(xy.getLat());
-                    }
-                    if (StringUtils.isNotEmpty(result.getAddress())) {
-                        datum.setAddress(result.getAddress());
-                    }
-                    BaiduData foo = result.getDetail();
-                    if (StringUtils.isNotEmpty(datum.getBizName()) && StringUtils.isNotEmpty(result.getBizNames())) {
-                        datum.setBizName(result.getBizNames().split(",")[0]);
-                    }
-                    if (StringUtils.isEmpty(datum.getProvinceName())) {
-                        datum.setProvinceName(foo.getProvince());
-                    }
-                    if (StringUtils.isEmpty(datum.getCityName())) {
-                        datum.setCityName(foo.getCity());
-                    }
-                    if (StringUtils.isEmpty(datum.getAreaName())) {
-                        datum.setAreaName(StringUtils.emptyDefault(foo.getDistrict(), foo.getTown()));
-                    }
-                }
-            }
-
-            // 如果地址依旧为空,则通过小区名称来查询
-            if (StringUtils.isEmpty(datum.getAddress())) {
-                BaiduResponseData baiduData = BaiduMapUtils.get(datum.getHouses());
-                if (StringUtils.equals(baiduData.getMessage(), "ok")) {
-                    // 成功解析数据
-                    if (CollectionUtils.isNotEmpty(baiduData.getResults())) {
-                        BaiduData bd = baiduData.getResults().get(0);
-                        datum.setBaiduName(bd.getName());
-                        //更新省市区街道
-                        if (StringUtils.isNotEmpty(datum.getProvinceName())) {
-                            datum.setProvinceName(HouseUtils.formatProvince(bd.getProvince()));
-                        }
-                        if (StringUtils.isNotEmpty(datum.getCityName())) {
-                            datum.setCityName(bd.getCity());
-                        }
-                        if (StringUtils.isNotEmpty(datum.getAreaName())) {
-                            datum.setAreaName(bd.getArea());
-                        }
-                        if (StringUtils.isNotEmpty(datum.getAddress())) {
-                            datum.setAddress(bd.getAddress());
-                        }
-                        if (StringUtils.isEmpty(datum.getLongitude()) && bd.getLocation() != null) {
-                            BaiduXY xy = bd.getLocation();
-                            datum.setLatitude(xy.getLat());
-                            datum.setLongitude(xy.getLng());
-                        }
-                        // 如果使用严谨模式,则名称必须一致才可以。等待手动确认
-                        if (!bd.getName().equals(datum.getHouses())) {
-                            String name1 = bd.getName().replaceAll("\\s+", "").replaceAll("([\\w东西南北]+区)?([一二三四五六七八九]期)?(·-_)?", "");
-                            String name2 = datum.getHouses().replaceAll("\\s+", "").replaceAll("([\\w东西南北]+区)?([一二三四五六七八九]期)?(·-_)?", "");
-                        }
-                    }
-                    datum.setMapType("baidu");
-                    session.update(datum);
-                }
-            }
-
-            if (index % batch == 0) {
-                LogHelper.info("%s-->批量更新所有小区的地址信息 ---- %s/%s ---", Thread.currentThread().getName(), index, total);
-                session.flush();
-                session.clear();
-            }
-        }
-        session.flush();
-        session.clear();
-        LogHelper.info("%s-->批量更新所有小区的地址信息 ---------- OK!!!", Thread.currentThread().getName());
+//        final int total = data.size();
+//        LogHelper.info("%s-->批量更新所有小区的地址信息 ---------- %s", Thread.currentThread().getName(), total);
+//        final Session session = HibernateUtils.getSession();
+//        final int batch = 30;
+//        int index = 0;
+//        for (CommunityPrice datum : data) {
+//            index++;
+//
+//            // 如果有经纬度,但是没有地址(说明数据来源于链家)则从百度获取地址
+//            String longitude = datum.getLongitude();
+//            if (StringUtils.isNotEmpty(longitude) && StringUtils.isEmpty(datum.getAddress())) {
+//                BaiduResponseData baiduData = BaiduMapUtils.getByXY(datum.getLongitude(), datum.getLatitude());
+//                if (baiduData != null && 0 == baiduData.getStatus()) {
+//                    BaiduResult result = baiduData.getResult();
+//                    BaiduXY xy = result.getLocation();
+//                    if (xy != null && StringUtils.isNotEmpty(xy.getLng())) {
+//                        datum.setLongitude(xy.getLng());
+//                    }
+//                    if (xy != null && StringUtils.isNotEmpty(xy.getLat())) {
+//                        datum.setLatitude(xy.getLat());
+//                    }
+//                    if (StringUtils.isNotEmpty(result.getAddress())) {
+//                        datum.setAddress(result.getAddress());
+//                    }
+//                    BaiduData foo = result.getDetail();
+//                    if (StringUtils.isNotEmpty(datum.getBizName()) && StringUtils.isNotEmpty(result.getBizNames())) {
+//                        datum.setBizName(result.getBizNames().split(",")[0]);
+//                    }
+//                    if (StringUtils.isEmpty(datum.getProvinceName())) {
+//                        datum.setProvinceName(foo.getProvince());
+//                    }
+//                    if (StringUtils.isEmpty(datum.getCityName())) {
+//                        datum.setCityName(foo.getCity());
+//                    }
+//                    if (StringUtils.isEmpty(datum.getAreaName())) {
+//                        datum.setAreaName(StringUtils.emptyDefault(foo.getDistrict(), foo.getTown()));
+//                    }
+//                }
+//            }
+//
+//            // 如果地址依旧为空,则通过小区名称来查询
+//            if (StringUtils.isEmpty(datum.getAddress())) {
+//                BaiduResponseData baiduData = BaiduMapUtils.get(datum.getHouses());
+//                if (StringUtils.equals(baiduData.getMessage(), "ok")) {
+//                    // 成功解析数据
+//                    if (CollectionUtils.isNotEmpty(baiduData.getResults())) {
+//                        BaiduData bd = baiduData.getResults().get(0);
+//                        datum.setBaiduName(bd.getName());
+//                        //更新省市区街道
+//                        if (StringUtils.isNotEmpty(datum.getProvinceName())) {
+//                            datum.setProvinceName(HouseUtils.formatProvince(bd.getProvince()));
+//                        }
+//                        if (StringUtils.isNotEmpty(datum.getCityName())) {
+//                            datum.setCityName(bd.getCity());
+//                        }
+//                        if (StringUtils.isNotEmpty(datum.getAreaName())) {
+//                            datum.setAreaName(bd.getArea());
+//                        }
+//                        if (StringUtils.isNotEmpty(datum.getAddress())) {
+//                            datum.setAddress(bd.getAddress());
+//                        }
+//                        if (StringUtils.isEmpty(datum.getLongitude()) && bd.getLocation() != null) {
+//                            BaiduXY xy = bd.getLocation();
+//                            datum.setLatitude(xy.getLat());
+//                            datum.setLongitude(xy.getLng());
+//                        }
+//                        // 如果使用严谨模式,则名称必须一致才可以。等待手动确认
+//                        if (!bd.getName().equals(datum.getHouses())) {
+//                            String name1 = bd.getName().replaceAll("\\s+", "").replaceAll("([\\w东西南北]+区)?([一二三四五六七八九]期)?(·-_)?", "");
+//                            String name2 = datum.getHouses().replaceAll("\\s+", "").replaceAll("([\\w东西南北]+区)?([一二三四五六七八九]期)?(·-_)?", "");
+//                        }
+//                    }
+//                    datum.setMapType("baidu");
+//                    session.update(datum);
+//                }
+//            }
+//
+//            if (index % batch == 0) {
+//                LogHelper.info("%s-->批量更新所有小区的地址信息 ---- %s/%s ---", Thread.currentThread().getName(), index, total);
+//                session.flush();
+//                session.clear();
+//            }
+//        }
+//        session.flush();
+//        session.clear();
+//        LogHelper.info("%s-->批量更新所有小区的地址信息 ---------- OK!!!", Thread.currentThread().getName());
     }
 
 
@@ -320,11 +318,11 @@ public class CommunityPriceServiceImpl implements CommunityPriceService, BeanWra
         communityPrice.setPriceUpdateTime(new Date());
 
         // 判断地址是否发生了变化
-        AddressVO vo = getAddressByName(communityPrice.getHouses());
-        if (vo != null && StringUtils.notEquals(vo.getAddress(), communityPrice.getAddress())) {
-            log.info("小区地址位置发生变化 - {} : {} -> {}", communityPrice.getHouses(), communityPrice.getAddress(), vo.getAddress());
-            communityPrice.setAddress(vo.getAddress());
-        }
+//        AddressVO vo = getAddressByName(communityPrice.getHouses());
+//        if (vo != null && StringUtils.notEquals(vo.getAddress(), communityPrice.getAddress())) {
+//            log.info("小区地址位置发生变化 - {} : {} -> {}", communityPrice.getHouses(), communityPrice.getAddress(), vo.getAddress());
+//            communityPrice.setAddress(vo.getAddress());
+//        }
 
         // 判断价格是否改变,如果改变了,则保存历史记录
         if (DoubleUtils.notEquals(newAvgPrice, communityPrice.getPrice())) {
@@ -405,6 +403,7 @@ public class CommunityPriceServiceImpl implements CommunityPriceService, BeanWra
         return time;
     }
 
+
     @SuppressWarnings("unchecked")
     private void loadAllDataSourceHouse(Set<String> houseSet, Date time, Date lastPriceDate) {
 
@@ -492,7 +491,7 @@ public class CommunityPriceServiceImpl implements CommunityPriceService, BeanWra
     public void deleteRepeatCommunity() {
         final Session session = HibernateUtils.getSession();
         // 获取所有名称重复的数据
-        String sql = "select houses,count(distinct  id) as total,max(createdDatetime) as createdDatetime\n" +
+        String sql = "select houses,count(distinct  id) as total,max(id) as maxId\n" +
                 "from db_price_community where houses is not null \n" +
                 "group by houses having total > 1";
         List<Map<String, Object>> data = SQLUtils.listMap(sql, null);
@@ -500,10 +499,10 @@ public class CommunityPriceServiceImpl implements CommunityPriceService, BeanWra
         log.info("开始删除重复的小区...共有 {} 个小区符合条件!", data.size());
         data.forEach(k -> {
             String houseName = k.get("houses").toString();
-            Date maxDate = (Date) k.get("createdDatetime");
-            long total = session.createSQLQuery("delete from db_price_community where houses=:houses and createdDatetime<:createdDatetime")
+            String maxId = k.get("maxId").toString();
+            long total = session.createSQLQuery("delete from db_price_community where houses=:houses and id !=:maxId")
                     .setParameter("houses", houseName)
-                    .setParameter("createdDatetime", maxDate)
+                    .setParameter("maxId", maxId)
                     .executeUpdate();
             log.info("删除重复的小区:{},共计 {} 条!", houseName, total);
             count.add(BigInteger.valueOf(total));
@@ -557,76 +556,112 @@ public class CommunityPriceServiceImpl implements CommunityPriceService, BeanWra
                 .uniqueResult();
     }
 
+   // @Override
+//    public AddressVO getAddressByName(String houses) {
+//        if (StringUtils.isEmpty(houses)) {
+//            return null;
+//        }
+//        Map<String, Object> params = new HashMap<>();
+//        params.put("houses", houses);
+//        String sql = TemplateUtils.getTemplate("fmt/query_address.fmt", params, ConfigCache.isDebug());
+//        List<Map<String, Object>> data = com.leeroa.base.utils.sql.SQLUtils.listMap(sql, params);
+//        if (data == null || data.isEmpty()) {
+//            return null;
+//        }
+//        Set<String> addressSet = new HashSet<>();
+//        AddressVO vo = new AddressVO();
+//        for (Map<String, Object> map : data) {
+//            String address = (String) map.get("address");
+//            if (address == null) {
+//                break;
+//            }
+//            // 解析街道
+//            String[] addressArray = address.split("[,,/;;]");
+//            for (String fooAddress : addressArray) {
+//                // 获取到地址
+//                if (vo.getProvince() == null) {
+//                    String province = HouseUtils.getProvince(address);
+//                    vo.setProvince(province);
+//                }
+//                if (vo.getCity() == null) {
+//                    String city = HouseUtils.getCity(address);
+//                    vo.setCity(city);
+//                }
+//                if (vo.getArea() == null) {
+//                    String area = HouseUtils.getArea(address);
+//                    if (HouseUtils.AREA_CHENGDU.contains(area)) {
+//                        vo.setArea(area);
+//                    }
+//                }
+//                String street = HouseUtils.getStreet(fooAddress);
+//                // 如果没有解析出地址,则跳过
+//                if (StringUtils.isEmpty(street)) {
+//                    continue;
+//                }
+//                addressSet.add(street);
+//            }
+//        }
+//        StringBuilder builder = new StringBuilder("");
+//        for (String fooAddress : addressSet) {
+//            String street = HouseUtils.getStreet(fooAddress);
+//            // 如果没有解析出地址,则跳过
+//            if (StringUtils.isEmpty(street)) {
+//                continue;
+//            }
+//            // 如果地址中已经包含,则跳过
+//            if (builder.indexOf(street) != -1) {
+//                continue;
+//            }
+//            // 如果是当前门牌号包含了之前的地址,则直接替换。
+//            if (street.contains(builder.toString())) {
+//                builder.delete(0, builder.length());
+//                builder.append(",").append(street);
+//                continue;
+//            }
+//            // 追加
+//            builder.append(",").append(street);
+//        }
+//        if (builder.length() > 0) {
+//            String newAddress = builder.substring(1);
+//            vo.setAddress(newAddress);
+//        }
+//        return vo;
+//    }
+
+
     @Override
-    public AddressVO getAddressByName(String houses) {
-        if (StringUtils.isEmpty(houses)) {
-            return null;
-        }
-        Map<String, Object> params = new HashMap<>();
-        params.put("houses", houses);
-        String sql = TemplateUtils.getTemplate("fmt/query_address.fmt", params, ConfigCache.isDebug());
-        List<Map<String, Object>> data = com.leeroa.base.utils.sql.SQLUtils.listMap(sql, params);
-        if (data == null || data.isEmpty()) {
-            return null;
-        }
-        Set<String> addressSet = new HashSet<>();
-        AddressVO vo = new AddressVO();
-        for (Map<String, Object> map : data) {
-            String address = (String) map.get("address");
-            if (address == null) {
-                break;
-            }
-            // 解析街道
-            String[] addressArray = address.split("[,,/;;]");
-            for (String fooAddress : addressArray) {
-                // 获取到地址
-                if (vo.getProvince() == null) {
-                    String province = HouseUtils.getProvince(address);
-                    vo.setProvince(province);
-                }
-                if (vo.getCity() == null) {
-                    String city = HouseUtils.getCity(address);
-                    vo.setCity(city);
-                }
-                if (vo.getArea() == null) {
-                    String area = HouseUtils.getArea(address);
-                    if (HouseUtils.AREA_CHENGDU.contains(area)) {
-                        vo.setArea(area);
+    public void updateAddressByAMap() {
+        List<Map<String, Object>> maps = SQLUtils.listMap("select id,cityName,houses,address from db_price_community where " +
+                "address is null and cityName is not null and houses is not null", null);
+        if (CollectionUtil.isNotEmpty(maps)){
+            final Session session = HibernateUtils.getSession();
+            ExecutorService executorService = Executors.newFixedThreadPool(10);
+            for(Map<String,Object> x : maps){
+                String id = x.get("id").toString();
+                String cityName = x.get("cityName").toString();
+                String houses = x.get("houses").toString();
+                AMapTask task = new AMapTask(cityName,houses);
+                Future<List<String>> future = executorService.submit(task);
+                try {
+                    List<String> result = future.get();
+                    if (CollectionUtil.isNotEmpty(result)){
+                        String xAddresses = org.apache.commons.lang.StringUtils.strip(result.toString(), "[]");
+                        session.createSQLQuery("update db_price_community set address = :address where id = :id")
+                                .setParameter("address",xAddresses)
+                                .setParameter("id",id).executeUpdate();
+                        log.info("更新{},{}小区=====>地址:成功", cityName,houses);
                     }
+                    if (result==null){
+                        LogHelper.info("高德API接口返回异常,中止请求。");
+                        break;
+                    }
+                } catch (InterruptedException | ExecutionException e) {
+                    // 异常处理
+                    e.printStackTrace();
                 }
-                String street = HouseUtils.getStreet(fooAddress);
-                // 如果没有解析出地址,则跳过
-                if (StringUtils.isEmpty(street)) {
-                    continue;
-                }
-                addressSet.add(street);
             }
+            executorService.shutdown();
         }
-        StringBuilder builder = new StringBuilder("");
-        for (String fooAddress : addressSet) {
-            String street = HouseUtils.getStreet(fooAddress);
-            // 如果没有解析出地址,则跳过
-            if (StringUtils.isEmpty(street)) {
-                continue;
-            }
-            // 如果地址中已经包含,则跳过
-            if (builder.indexOf(street) != -1) {
-                continue;
-            }
-            // 如果是当前门牌号包含了之前的地址,则直接替换。
-            if (street.contains(builder.toString())) {
-                builder.delete(0, builder.length());
-                builder.append(",").append(street);
-                continue;
-            }
-            // 追加
-            builder.append(",").append(street);
-        }
-        if (builder.length() > 0) {
-            String newAddress = builder.substring(1);
-            vo.setAddress(newAddress);
-        }
-        return vo;
     }
 
     @Override

+ 22 - 0
src/main/java/com/leeroa/dydb/price/web/CommunityPriceCtrl.java

@@ -6,6 +6,9 @@ import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.leeroa.base.utils.DownloadResponseWrapper;
 import com.leeroa.base.utils.export.ExcelUtils;
+import com.leeroa.dydb.datasource.lianjia.bo.DataLianjiaCodeBo;
+import com.leeroa.dydb.datasource.lianjia.domain.DataLianjiaCode;
+import com.leeroa.dydb.datasource.lianjia.service.DataLianjiaCodeService;
 import com.leeroa.dydb.price.bo.CommunityPriceBo;
 import com.leeroa.dydb.price.cache.CommunityPriceCache;
 import com.leeroa.dydb.price.domain.CommunityPrice;
@@ -51,6 +54,9 @@ public class CommunityPriceCtrl extends BaseController {
     @Resource
     private ZhaoShangCheckService zhaoShangCheckService;
 
+    @Resource
+    private DataLianjiaCodeService dataLianjiaCodeService;
+
     @RequestMapping(value = {""}, method = RequestMethod.GET)
     public String toList() {
         return "dydb/price/communityPrice/communityPrice_list";
@@ -186,4 +192,20 @@ public class CommunityPriceCtrl extends BaseController {
         zhaoShangCheckService.check(attachmentId, response.getOutputStream());
     }
 
+    // 更新地址信息
+    @RequestMapping(value = "/updateAddress", method = RequestMethod.GET)
+    public void updateAddress(HttpServletRequest request, HttpServletResponse response) throws IOException, MessagingException {
+        communityPriceService.updateAddressByAMap();
+    }
+
+    // 获取成都的所有区域信息
+    @RequestMapping("/citymap")
+    @ResponseBody
+    public void queryCityMap(HttpServletRequest request, HttpServletResponse response) {
+        //GsonUtils.printData(response, LianjiaUtils.getCityMap());
+        DataLianjiaCodeBo bo = GsonUtils.wrapDataToEntity(request, DataLianjiaCodeBo.class);
+        List<DataLianjiaCode> cityMap = dataLianjiaCodeService.queryCityMap(bo);
+        GsonUtils.printData(response, cityMap);
+    }
+
 }

+ 69 - 69
src/main/java/com/leeroa/dydb/utils/baidu/BaiduMapUtils.java

@@ -30,75 +30,75 @@ public class BaiduMapUtils {
      */
     private static LoadingCache<String, BaiduResponseData> cache;
 
-    static {
-        cache = CacheBuilder.newBuilder().maximumSize(50000)
-                .expireAfterAccess(2, TimeUnit.HOURS)
-                .build(new CacheLoader<String, BaiduResponseData>() {
-                    @Override
-                    public BaiduResponseData load(String houseName) {
-                        BaiduResponseData baiduData = null;
-                        // 现从现有的小区价格表中加载。如果没有,则从百度进行加载
-                        CommunityPrice cp = CommunityPriceCache.getInstance().getCommunityPrice(houseName);
-                        if (cp != null && StringUtils.isNotEmpty(cp.getLatitude())) {
-                            baiduData = new BaiduResponseData();
-                            baiduData.setMessage("ok");
-                            baiduData.setStatus(0);
-                            final BaiduData bd = new BaiduData();
-                            bd.setProvince(cp.getProvinceName());
-                            bd.setCity(cp.getCityName());
-                            bd.setArea(cp.getAreaName());
-                            bd.setName(cp.getHouses());
-                            bd.setAddress(cp.getAddress());
-                            bd.setXY(cp.getLatitude(), cp.getLongitude());
-                            baiduData.addResult(bd);
-                            return baiduData;
-                        }
-                        String url = "http://api.map.baidu.com/place/v2/search?query=%s&region=成都tag=房地产&output=json&ak=" + ConfigCache.get("map.baidu.ak");
-
-                        // 为了防止出现请求超时的情况,遍历5次。只要一次成功即可。
-                        int index = 0;
-                        while (baiduData == null && index < 5) {
-                            index++;
-                            try {
-                                final String finalURL = String.format(url, houseName);
-                                LogHelper.info("百度地图获取地址信息:%s", houseName);
-                                String json = Request.Get(finalURL).execute().returnContent().toString();
-                                baiduData = GsonUtils.fromJson(json, BaiduResponseData.class);
-                                if ("ok".equalsIgnoreCase(baiduData.getMessage()) && CollectionUtils.isEmpty(baiduData.getResults())) {
-                                    // 如果查询地址里包含了xx号这种,去掉后缀再查询一次
-                                    if (houseName.matches(".+\\d+号.*")) {
-                                        houseName = houseName.replaceAll("\\d+号.*", "");
-                                        continue;
-                                    }
-                                }
-                                if ("ok".equalsIgnoreCase(baiduData.getMessage()) && CollectionUtils.isNotEmpty(baiduData.getResults())) {
-                                    BaiduData data = baiduData.getResults().get(0);
-                                    if (StringUtils.isEmpty(data.getAddress())) {
-                                        LogHelper.info("未正确获取到楼盘信息:%s\r\n%s", houseName, json);
-                                    }
-                                    // 如果获取到的经纬度中包含-,则表示是错误地址。不作为结果
-                                    if (data.getLocation() != null) {
-                                        if (data.getLocation().getLat().startsWith("-") || data.getLocation().getLng().startsWith("-")) {
-                                            data.setLocation(null);
-                                        }
-                                    }
-                                    // 如果结果中没有城市和区域,并且查询地址是xxx号或者数字结尾,则将address设置为行政区域名称
-                                    if (StringUtils.isEmpty(data.getCity()) && StringUtils.isEmpty(data.getArea()) && StringUtils.isNotEmpty(data.getAddress()) && houseName.matches(".+\\d+(号)?")) {
-                                        data.setCity("成都");
-                                        data.setArea(data.getAddress());
-                                        data.setAddress(houseName);
-                                    }
-                                }
-
-                                break;
-                            } catch (Exception e) {
-                                LogHelper.warn("百度地图获取地址信息失败:" + e.getMessage());
-                            }
-                        }
-                        return baiduData;
-                    }
-                });
-    }
+//    static {
+//        cache = CacheBuilder.newBuilder().maximumSize(50000)
+//                .expireAfterAccess(2, TimeUnit.HOURS)
+//                .build(new CacheLoader<String, BaiduResponseData>() {
+//                    @Override
+//                    public BaiduResponseData load(String houseName) {
+//                        BaiduResponseData baiduData = null;
+//                        // 现从现有的小区价格表中加载。如果没有,则从百度进行加载
+//                        CommunityPrice cp = CommunityPriceCache.getInstance().getCommunityPrice(houseName);
+//                        if (cp != null && StringUtils.isNotEmpty(cp.getLatitude())) {
+//                            baiduData = new BaiduResponseData();
+//                            baiduData.setMessage("ok");
+//                            baiduData.setStatus(0);
+//                            final BaiduData bd = new BaiduData();
+//                            bd.setProvince(cp.getProvinceName());
+//                            bd.setCity(cp.getCityName());
+//                            bd.setArea(cp.getAreaName());
+//                            bd.setName(cp.getHouses());
+//                            bd.setAddress(cp.getAddress());
+//                            bd.setXY(cp.getLatitude(), cp.getLongitude());
+//                            baiduData.addResult(bd);
+//                            return baiduData;
+//                        }
+//                        String url = "http://api.map.baidu.com/place/v2/search?query=%s&region=成都tag=房地产&output=json&ak=" + ConfigCache.get("map.baidu.ak");
+//
+//                        // 为了防止出现请求超时的情况,遍历5次。只要一次成功即可。
+//                        int index = 0;
+//                        while (baiduData == null && index < 5) {
+//                            index++;
+//                            try {
+//                                final String finalURL = String.format(url, houseName);
+//                                LogHelper.info("百度地图获取地址信息:%s", houseName);
+//                                String json = Request.Get(finalURL).execute().returnContent().toString();
+//                                baiduData = GsonUtils.fromJson(json, BaiduResponseData.class);
+//                                if ("ok".equalsIgnoreCase(baiduData.getMessage()) && CollectionUtils.isEmpty(baiduData.getResults())) {
+//                                    // 如果查询地址里包含了xx号这种,去掉后缀再查询一次
+//                                    if (houseName.matches(".+\\d+号.*")) {
+//                                        houseName = houseName.replaceAll("\\d+号.*", "");
+//                                        continue;
+//                                    }
+//                                }
+//                                if ("ok".equalsIgnoreCase(baiduData.getMessage()) && CollectionUtils.isNotEmpty(baiduData.getResults())) {
+//                                    BaiduData data = baiduData.getResults().get(0);
+//                                    if (StringUtils.isEmpty(data.getAddress())) {
+//                                        LogHelper.info("未正确获取到楼盘信息:%s\r\n%s", houseName, json);
+//                                    }
+//                                    // 如果获取到的经纬度中包含-,则表示是错误地址。不作为结果
+//                                    if (data.getLocation() != null) {
+//                                        if (data.getLocation().getLat().startsWith("-") || data.getLocation().getLng().startsWith("-")) {
+//                                            data.setLocation(null);
+//                                        }
+//                                    }
+//                                    // 如果结果中没有城市和区域,并且查询地址是xxx号或者数字结尾,则将address设置为行政区域名称
+//                                    if (StringUtils.isEmpty(data.getCity()) && StringUtils.isEmpty(data.getArea()) && StringUtils.isNotEmpty(data.getAddress()) && houseName.matches(".+\\d+(号)?")) {
+//                                        data.setCity("成都");
+//                                        data.setArea(data.getAddress());
+//                                        data.setAddress(houseName);
+//                                    }
+//                                }
+//
+//                                break;
+//                            } catch (Exception e) {
+//                                LogHelper.warn("百度地图获取地址信息失败:" + e.getMessage());
+//                            }
+//                        }
+//                        return baiduData;
+//                    }
+//                });
+//    }
 
 
     public static void clear() {

+ 121 - 41
src/main/java/com/leeroa/dydb/zhaoshang/service/impl/QueryLogServiceImpl.java

@@ -123,26 +123,39 @@ public class QueryLogServiceImpl implements QueryLogService, BeanWrapCallback<Qu
 
         String areaName = HouseUtils.getArea(address);
         // 这里不考虑非成都城区的情况
-        if (areaName != null && !HouseUtils.AREA_CHENGDU.contains(areaName)) {
-            areaName = null;
-        }
+//        if (areaName != null && !HouseUtils.AREA_CHENGDU.contains(areaName)) {
+//            areaName = null;
+//        }
         // 获得街道号
-        String streetName = HouseUtils.getStreet(address);
-        String houseName = null;
-        // 如果没有解析到街道,则直接尝试解析小区名称。
-        if (streetName == null) {
-            houseName = HouseUtils.getHouseName(address);
-            if (houseName != null) {
-                return houseName;
-            }
+//        String streetName = HouseUtils.getStreet(address);
+//        String houseName = null;
+//        // 如果没有解析到街道,则直接尝试解析小区名称。
+//        if (streetName == null) {
+//            houseName = HouseUtils.getHouseName(address);
+//            if (houseName != null) {
+//                return houseName;
+//            }
+//        }
+//        // 这里表示没有解析出来街道,也没有解析出来小区名称
+//        if (streetName == null) {
+//            log.warn("地址解析失败:{}", address);
+//            return null;
+//        }
+        //先解析小区名称
+        String houseName =HouseUtils.getHouseName(address);
+        String streetName = null;
+        // 如果没有小区名称。再解析地址
+        if (houseName != null && !"".equals(houseName)) {
+            return houseName;
         }
-        // 这里表示没有解析出来街道,也没有解析出来小区名称
+
+        streetName = HouseUtils.getStreet(address);
         if (streetName == null) {
             log.warn("地址解析失败:{}", address);
             return null;
         }
 
-        // 查询价值库中的地址。并给定区域(如果有)
+                // 查询价值库中的地址。并给定区域(如果有)
         Criteria cpCriteria = session.createCriteria(CommunityPrice.class)
                 .setProjection(Projections.property("houses"))
                 .add(Restrictions.like("address", streetName, MatchMode.ANYWHERE));
@@ -238,22 +251,23 @@ public class QueryLogServiceImpl implements QueryLogService, BeanWrapCallback<Qu
 
         // 获取城市,如果不是成都市的,则返回
         String cityName = HouseUtils.getCity(address);
-        if (cityName != null && !cityName.contains("成都")) {
-            log.info("招商查询,非成都地区,直接返回:{}", address);
-            cq.setStatus("N");
-            cq.setHouseName("");
-            cq.setRemark(CommunityQuery.ERROR_TYPE_NOT_LOCAL);
-            return cq;
-        }
+//        if (cityName != null && !cityName.contains("成都")) {
+//            log.info("招商查询,非成都地区,直接返回:{}", address);
+//            cq.setStatus("N");
+//            cq.setRemark(CommunityQu
+//            cq.setHouseName("");ery.ERROR_TYPE_NOT_LOCAL);
+//            return cq;
+
+ //       }
         // 获取区县,如果不是成都市的,也返回
         String areaName = HouseUtils.getArea(address);
-        if (StringUtils.isNotEmpty(areaName) && HouseUtils.AREA_OTHER.contains(areaName)) {
-            log.info("招商查询,非成都地区,直接返回:{}", address);
-            cq.setStatus("N");
-            cq.setHouseName("");
-            cq.setRemark(CommunityQuery.ERROR_TYPE_NOT_LOCAL);
-            return cq;
-        }
+//        if (StringUtils.isNotEmpty(areaName) && HouseUtils.AREA_OTHER.contains(areaName)) {
+//            log.info("招商查询,非成都地区,直接返回:{}", address);
+//            cq.setStatus("N");
+//            cq.setHouseName("");
+//            cq.setRemark(CommunityQuery.ERROR_TYPE_NOT_LOCAL);
+//            return cq;
+//        }
 
         // 如果没有传递小区名称,则通过地址查询一次个贷数据
         if (StringUtils.isEmpty(houseName)) {
@@ -279,8 +293,6 @@ public class QueryLogServiceImpl implements QueryLogService, BeanWrapCallback<Qu
             }
             // 调用价格系数进行一次处理
             price = getRatePrice(price);
-            cq.setProvinceName("四川省");
-            cq.setCityName("成都市");
             cq.setAreaName(HouseUtils.getChengDuArea(address));
             cq.setHouseName(road);
             cq.setCommunityName(road);
@@ -305,11 +317,24 @@ public class QueryLogServiceImpl implements QueryLogService, BeanWrapCallback<Qu
         // 根据小区名称获取小区的数据
         CommunityPrice communityPrice = null;
         while (true) {
-            communityPrice = (CommunityPrice) session.createCriteria(CommunityPrice.class)
-                    .add(Restrictions.eq("houses", houseName))
-                    .addOrder(Order.desc("priceUpdateTime"))
-                    .setMaxResults(1)
-                    .uniqueResult();
+//            communityPrice = (CommunityPrice) session.createCriteria(CommunityPrice.class)
+//                    .add(Restrictions.eq("houses", houseName))
+//                    .add(Restrictions.eq("cityName",cityName))
+//                    .add(Restrictions.eq("areaName",areaName))
+//                    .addOrder(Order.desc("priceUpdateTime"))
+//                    .setMaxResults(1)
+//                    .uniqueResult();
+            Criteria criteria = session.createCriteria(CommunityPrice.class);
+            criteria.add(Restrictions.eq("houses", houseName));
+            if (StringUtils.isNotEmpty(cityName)){
+                criteria.add(Restrictions.eq("cityName",cityName));
+            }
+            if (StringUtils.isNotEmpty(areaName)){
+                criteria.add(Restrictions.eq("areaName",areaName));
+            }
+            criteria.addOrder(Order.desc("priceUpdateTime"));
+            criteria.setMaxResults(1);
+            communityPrice = (CommunityPrice) criteria.uniqueResult();
             if (communityPrice != null) {
                 break;
             }
@@ -324,11 +349,26 @@ public class QueryLogServiceImpl implements QueryLogService, BeanWrapCallback<Qu
             }
 
             // 为了提高命中率,按照名称再模糊匹配一次
-            communityPrice = (CommunityPrice) session.createCriteria(CommunityPrice.class)
-                    .add(Restrictions.like("houses", houseName, MatchMode.START))
-                    .setMaxResults(1)
-                    .addOrder(Order.asc("houses"))
-                    .uniqueResult();
+//            communityPrice = (CommunityPrice) session.createCriteria(CommunityPrice.class)
+//                    .add(Restrictions.like("houses", houseName, MatchMode.START))
+//                    .add(Restrictions.eq("cityName",cityName))
+//                    .add(Restrictions.eq("areaName",areaName))
+//                    .setMaxResults(1)
+//                    .addOrder(Order.asc("houses"))
+//                    .uniqueResult();
+
+            Criteria criteria1 = session.createCriteria(CommunityPrice.class);
+            criteria1.add(Restrictions.like("houses", houseName, MatchMode.START));
+            if (StringUtils.isNotEmpty(cityName)){
+                criteria1.add(Restrictions.eq("cityName",cityName));
+            }
+            if (StringUtils.isNotEmpty(areaName)){
+                criteria1.add(Restrictions.eq("areaName",areaName));
+            }
+            criteria1.addOrder(Order.desc("priceUpdateTime"));
+            criteria1.setMaxResults(1);
+            communityPrice = (CommunityPrice) criteria1.uniqueResult();
+
             cq.setRemark(CommunityQuery.MATCH_TYPE_LIKE);
             break;
         }
@@ -407,8 +447,48 @@ public class QueryLogServiceImpl implements QueryLogService, BeanWrapCallback<Qu
             // 总套数
             cq.setTotalHouse(communityPrice.getHouseQuantity());
         } else {
-            cq.setRemark(CommunityQuery.ERROR_TYPE_NO_DATA);
-            cq.setStatus("N");
+//            cq.setRemark(CommunityQuery.ERROR_TYPE_NO_DATA);
+//            cq.setStatus("N");
+            //再通过地址模糊匹配
+//            communityPrice = (CommunityPrice) session.createCriteria(CommunityPrice.class)
+//                    .add(Restrictions.like("address", houseName))
+//                    .add(Restrictions.eq("cityName",cityName))
+//                    .add(Restrictions.eq("areaName",areaName))
+//                    .addOrder(Order.desc("priceUpdateTime"))
+//                    .setMaxResults(1)
+//                    .uniqueResult();
+
+            Criteria criteria = session.createCriteria(CommunityPrice.class);
+            criteria.add(Restrictions.like("address", houseName,MatchMode.ANYWHERE));
+            if (StringUtils.isNotEmpty(cityName)){
+                criteria.add(Restrictions.eq("cityName",cityName));
+            }
+            if (StringUtils.isNotEmpty(areaName)){
+                criteria.add(Restrictions.eq("areaName",areaName));
+            }
+            criteria.addOrder(Order.desc("priceUpdateTime"));
+            criteria.setMaxResults(1);
+            communityPrice = (CommunityPrice) criteria.uniqueResult();
+
+            if (communityPrice == null){
+                cq.setRemark(CommunityQuery.ERROR_TYPE_NO_DATA);
+                cq.setStatus("N");
+            }else {
+                houseName = communityPrice.getHouses();
+                cq.setCommunityName(houseName);
+                cq.setHouseName(houseName);
+                cq.setAreaName(communityPrice.getAreaName());
+                cq.setCityName(communityPrice.getCityName());
+                Double price = getRatePrice(communityPrice.getPrice());
+                cq.setPrice(price);
+                cq.setMinPrice(price);
+                cq.setMaxPrice(price);
+                cq.setBuildArea(area);
+                cq.setMoney(price * area);
+                cq.setMngPrice(communityPrice.getMngPrice());
+                // 总套数
+                cq.setTotalHouse(communityPrice.getHouseQuantity());
+            }
         }
 
         cq.setAddress(address);

+ 7 - 2
src/main/webapp/app/dydb/datasource/dataQiYuDeal/dataQiYuDeal_list.js

@@ -13,12 +13,13 @@
             orderBy : '-dealDate,houses'
         };
 
-        $scope.condition = angular.extend({cityName:'成都'}, defaults);
+        $scope.condition = angular.extend({}, defaults);
 
         $scope.fetch = {page: 1, endPage: 100};
         // 加载城市信息
         $scope.citys = [];
         DataQiYuDealService.getCityMap({parentId: '0'},function (o) {
+            $scope.citys.push({name: '全部', value: null, code: '全部'});
             angular.forEach(o.data, function (data) {
                 $scope.citys.push({name: data.name, value: data.id, code: data.name});
             });
@@ -27,7 +28,7 @@
         $scope.cityChange = function(){
             $scope.areas = [];
             $scope.condition.areaName = undefined;
-            if ($scope.condition.cityName) {
+            if ($scope.condition.cityName && $scope.condition.cityName!='全部') {
                 angular.forEach($scope.citys, function (o) {
                     if (o.code.indexOf($scope.condition.cityName) === 0) {
                         // 获取code
@@ -42,6 +43,10 @@
             $scope.query();
         }
 
+        $scope.areaChange = function(){
+            $scope.query();
+        }
+
         //加载行政区域信息
         $scope.areas = [];
         DataQiYuDealService.getCityMap({parentId: '1780490511923245056'},function (o) {

+ 3 - 2
src/main/webapp/app/dydb/datasource/dataQiYuDeal/dataQiYuDeal_list.jsp

@@ -31,7 +31,7 @@ String contextPath = request.getContextPath();
                             <div class="form-label w80">
                                 <label>城市</label>
                             </div>
-                            <select class="w120" ng-model="condition.cityCode"
+                            <select class="w120" ng-model="condition.cityName"
                                     ng-options="foo.code as foo.name for foo in citys"
                                     ng-change="cityChange();"> </select>
                         </div>
@@ -40,7 +40,8 @@ String contextPath = request.getContextPath();
                                 <label>行政区</label>
                             </div>
                             <select class="w120" ng-model="condition.areaName"
-                                    ng-options="foo.name as foo.name for foo in areas">
+                                    ng-options="foo.name as foo.name for foo in areas"
+                                    ng-change="areaChange();">
                             </select>
                         </div>
                         <div class="item w400">

+ 7 - 2
src/main/webapp/app/dydb/datasource/dataQiYuUp/dataQiYuUp_list.js

@@ -13,12 +13,13 @@
             orderBy : '-upDate,houses'
         };
 
-        $scope.condition = angular.extend({cityName:'成都'}, defaults);
+        $scope.condition = angular.extend({}, defaults);
 
         $scope.fetch = {page: 1, endPage: 100};
         // 加载城市信息
         $scope.citys = [];
         DataQiYuUpService.getCityMap({parentId: '0'},function (o) {
+            $scope.citys.push({name: '全部', value: null, code: '全部'});
             angular.forEach(o.data, function (data) {
                 $scope.citys.push({name: data.name, value: data.id, code: data.name});
             });
@@ -27,7 +28,7 @@
         $scope.cityChange = function(){
             $scope.areas = [];
             $scope.condition.areaName = undefined;
-            if ($scope.condition.cityName) {
+            if ($scope.condition.cityName && $scope.condition.cityName!='全部') {
                 angular.forEach($scope.citys, function (o) {
                     if (o.code.indexOf($scope.condition.cityName) === 0) {
                         // 获取code
@@ -42,6 +43,10 @@
             $scope.query();
         }
 
+        $scope.areaChange = function(){
+            $scope.query();
+        }
+
         //加载行政区域信息
         $scope.areas = [];
         DataQiYuUpService.getCityMap({parentId: '1780490511923245056'},function (o) {

+ 2 - 1
src/main/webapp/app/dydb/datasource/dataQiYuUp/dataQiYuUp_list.jsp

@@ -40,7 +40,8 @@
                                 <label>行政区</label>
                             </div>
                             <select class="w120" ng-model="condition.areaName"
-                                    ng-options="foo.name as foo.name for foo in areas">
+                                    ng-options="foo.name as foo.name for foo in areas"
+                                    ng-change="areaChange();">
                             </select>
                         </div>
                         <div class="item w400">

+ 3 - 0
src/main/webapp/app/dydb/price/communityPrice/communityPrice.js

@@ -24,6 +24,9 @@
             // 不带分页的列表查询
             query: {method: 'POST', params: {method: 'query'}, isArray: false},
 
+            // 获得行政区域数据
+            getCityMap: {method: 'GET', params: {method: 'citymap',parentId:'@parentId'}, isArray: false},
+
             // 导入数据
             importData: {method: 'POST', params: {method: 'import'}, isArray: false},
 

+ 30 - 1
src/main/webapp/app/dydb/price/communityPrice/communityPrice_list.js

@@ -12,9 +12,38 @@
         var defaults = {
             orderBy: 'areaName,houses,price'
         };
-
         $scope.condition = angular.extend({}, defaults);
 
+        // 加载城市信息
+        $scope.citys = [];
+        CommunityPriceService.getCityMap({parentId: '0'},function (o) {
+            $scope.citys.push({name: '全部', value: null, code: '全部'});
+            angular.forEach(o.data, function (data) {
+                $scope.citys.push({name: data.name, value: data.id, code: data.name});
+            });
+        });
+
+        $scope.cityChange = function(){
+            $scope.areas = [];
+            $scope.condition.areaName = undefined;
+            if ($scope.condition.cityName && $scope.condition.cityName!='全部') {
+                angular.forEach($scope.citys, function (o) {
+                    if (o.code.indexOf($scope.condition.cityName) === 0) {
+                        // 获取code
+                        CommunityPriceService.getCityMap({parentId: o.value}, function (bizData) {
+                            angular.forEach(bizData.data, function (data) {
+                                $scope.areas.push({name: data.name, value: data.id, code: data.name});
+                            });
+                        });
+                    }
+                });
+            }
+            $scope.query();
+        }
+
+        $scope.areaChange = function(){
+            $scope.query();
+        }
         $scope.status = [
             {name: '全部'},
             {name: '有效', value: true},

+ 21 - 10
src/main/webapp/app/dydb/price/communityPrice/communityPrice_list.jsp

@@ -38,16 +38,27 @@
                         </div>
                         <div class="item w200">
                             <div class="form-label w80">
-                                <label>行政区</label>
+                                <label>城市</label>
                             </div>
-                            <input type="text" class="w120" ng-model="condition.areaName"/>
+                            <select class="w120" ng-model="condition.cityName"
+                                    ng-options="foo.code as foo.name for foo in citys"
+                                    ng-change="cityChange();"> </select>
                         </div>
                         <div class="item w200">
                             <div class="form-label w80">
-                                <label>商圈</label>
+                                <label>行政区</label>
                             </div>
-                            <input type="text" class="w120" ng-model="condition.bizName"/>
+                            <select class="w120" ng-model="condition.areaName"
+                                    ng-options="foo.name as foo.name for foo in areas"
+                                    ng-change="areaChange();">
+                            </select>
                         </div>
+<%--                        <div class="item w200">--%>
+<%--                            <div class="form-label w80">--%>
+<%--                                <label>商圈</label>--%>
+<%--                            </div>--%>
+<%--                            <input type="text" class="w120" ng-model="condition.bizName"/>--%>
+<%--                        </div>--%>
                         <div class="item w200">
                             <div class="form-label w80">
                                 <label>是否有效</label>
@@ -94,7 +105,9 @@
                                          anyone-selected="anyone"></div>
                                 </td>
                                 <td style="width: 20px;">序号</td>
-                                <td style="width: 80px">省市区</td>
+                                <td style="width: 80px">省份</td>
+                                <td style="width: 80px">城市</td>
+                                <td style="width: 80px">行政区</td>
                                 <td style="text-align: left">小区名称</td>
                                 <td style="text-align: left">小区地址</td>
                                 <td style="width: 120px">平均单价(元)</td>
@@ -112,11 +125,9 @@
                                 ng-class="{red:!foo.status}">
                                 <td><input type="checkbox" ng-model="foo.isSelected"/></td>
                                 <td bo-text="pager.start+$index+1"></td>
-                                <td>
-                                    <span bo-text="foo.provinceName"></span> -
-                                    <span bo-text="foo.cityName"></span> -
-                                    <span bo-text="foo.areaName"></span>
-                                </td>
+                                <td style="text-align: left" bo-text="foo.provinceName"></td>
+                                <td style="text-align: left" bo-text="foo.cityName"></td>
+                                <td style="text-align: left" bo-text="foo.areaName"></td>
                                 <td style="text-align: left" bo-text="foo.houses"></td>
                                 <td bo-text="foo.address" style="text-align: left"></td>
                                 <td bo-text="foo.price|number:0"></td>

+ 2 - 1
src/main/webapp/app/dydb/price/communityQuery/communityQuery_list.js

@@ -13,7 +13,7 @@
             orderBy: '-createdDatetime'
         };
 
-        $scope.condition = angular.extend({cityName:'成都'}, defaults);
+        // $scope.condition = angular.extend({cityName:'全部'}, defaults);
 
         $scope.remarks = [
             {name: '全部'},
@@ -31,6 +31,7 @@
             angular.forEach(o.data, function (data) {
                 $scope.citys.push({name: data.name, value: data.id, code: data.name});
             });
+            $scope.citys.push({name:'全部', value: data.id, code: data.name});
         });
 
         $scope.cityChange = function(){

+ 0 - 1
src/main/webapp/app/dydb/price/communityQuery/communityQuery_list.jsp

@@ -141,7 +141,6 @@
                                 <td bo-text="foo.CTYCOD_DSP"></td>
                                 <td bo-text="foo.DISCOD_DSP"></td>
                                 <td bo-text="foo.UNIT_PRICE|number:0"></td>
-                                <td bo-text="foo.UNIT_PRICE|number:0"></td>
                                 <td bo-text="foo.BUILD_AREA|number:2"></td>
                                 <td bo-text="foo.TOTAL_PRICE|number:2"></td>
                                 <td bo-text="foo.AVG_UNIT_PRICE|number:2"></td>