diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java index 30a73fa2f..36af6dfbc 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/EvaluationController.java @@ -28,6 +28,9 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.fangjia.dal.mongo.model.*; +import com.fangjia.service.datastore.*; +import com.fangjia.service.mongo.fangjia.*; import net.sf.json.JSONObject; import org.apache.commons.codec.digest.DigestUtils; @@ -105,19 +108,6 @@ import com.fangjia.dal.mongo.fangjia.model.LoanLeads; import com.fangjia.dal.mongo.fangjia.model.LoanProduct; import com.fangjia.dal.mongo.fangjia.model.LoanProductTag; import com.fangjia.dal.mongo.fangjia.model.ServerArea; -import com.fangjia.dal.mongo.model.AddressMatchLog; -import com.fangjia.dal.mongo.model.CityNewPrice; -import com.fangjia.dal.mongo.model.DistrictSellStat; -import com.fangjia.dal.mongo.model.DistrictStat; -import com.fangjia.dal.mongo.model.Evaluation; -import com.fangjia.dal.mongo.model.FangjiaCommonLog; -import com.fangjia.dal.mongo.model.HouseLoudong; -import com.fangjia.dal.mongo.model.HousePrice; -import com.fangjia.dal.mongo.model.InputUserInfo; -import com.fangjia.dal.mongo.model.IpCount; -import com.fangjia.dal.mongo.model.RegionStat; -import com.fangjia.dal.mongo.model.SnapData; -import com.fangjia.dal.mongo.model.ThirdIpCount; import com.fangjia.dal.mongo.model.bkoff.AdLog; import com.fangjia.dal.mongo.model.bkoff.Advertisement; import com.fangjia.dal.mongo.pds.model.AlgorithmRule; @@ -145,16 +135,6 @@ import com.fangjia.service.chart.generator.ChartGenerator; import com.fangjia.service.chart.ofc.bean.OfcStyleConfig; import com.fangjia.service.common.CookieName; import com.fangjia.service.cpc.CpcService; -import com.fangjia.service.datastore.DistrictDto; -import com.fangjia.service.datastore.DistrictSellStatService; -import com.fangjia.service.datastore.DistrictService; -import com.fangjia.service.datastore.EvaluationService; -import com.fangjia.service.datastore.HouseService; -import com.fangjia.service.datastore.IpCountService; -import com.fangjia.service.datastore.RegionStatService; -import com.fangjia.service.datastore.ReportDistrictInfoService; -import com.fangjia.service.datastore.SchoolService; -import com.fangjia.service.datastore.ThirdIpCountService; import com.fangjia.service.datastore.bean.DistrictQueryBean; import com.fangjia.service.datastore.bean.EvaluationBeforeLoanBean; import com.fangjia.service.datastore.bean.HousePicEnum; @@ -173,13 +153,6 @@ import com.fangjia.service.fangjia.LoanProductService; import com.fangjia.service.fangjia.LoanProductTagService; import com.fangjia.service.fsh.CityNewPriceService; import com.fangjia.service.menu.MenuCategoryEnum; -import com.fangjia.service.mongo.fangjia.AddressMatchLogService; -import com.fangjia.service.mongo.fangjia.CopyrightConfigService; -import com.fangjia.service.mongo.fangjia.FangjiaCommonLogService; -import com.fangjia.service.mongo.fangjia.InputUserInfoService; -import com.fangjia.service.mongo.fangjia.MetroService; -import com.fangjia.service.mongo.fangjia.ServerAreaService; -import com.fangjia.service.mongo.fangjia.SnapDataService; import com.fangjia.service.news.NewsService; import com.fangjia.service.pds.AlgorithmRuleService; import com.fangjia.service.pds.DistrictHouseNumberService; @@ -212,6 +185,8 @@ public class EvaluationController { private SnapDataService snapDataService; private HouseService houseService; private RegionStatService regionStatService; + private CitySellStatService citySellStatService; + private RegionSellStatService regionSellStatService; private MenuService menuService; private CpcService cpcService; private DistrictStatRentService districtStatRentService; @@ -3626,23 +3601,34 @@ public Object checkUserAction(EvaluationModel model, HttpServletRequest req, Htt private Map buildStatJson(String city, String region, String block, Date startDate) { List regionStatList = null; + List citySellStats = null; + List regionSellStats = null; Map oprions = new HashMap(); Date currentDate = new Date(); if (city != null && region != null) { - regionStatList = regionStatService.findRegionStat(city, region, null, startDate, currentDate); + regionSellStats = regionSellStatService.findRegionSellStat(city, region, Integer.parseInt(DateUtil.formatByPattern(startDate, "yyyyMM")), Integer.parseInt(DateUtil.formatByPattern(currentDate, "yyyyMM"))); oprions.put("name", region); } else if (city != null) { - regionStatList = regionStatService.findRegionStat(city, null, null, startDate, currentDate); + citySellStats = citySellStatService.findCitySellStat(city, Integer.parseInt(DateUtil.formatByPattern(startDate, "yyyyMM")), Integer.parseInt(DateUtil.formatByPattern(currentDate, "yyyyMM"))); oprions.put("name", city); } - if (regionStatList == null) { - return null; - } Map map = new HashMap(); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM"); - for (RegionStat re : regionStatList) { - map.put(format.format(DateUtil.getBeforeDay(re.getWeekend(), -1)),re.getAvgPrice()); + if (CollectionUtils.isNotEmpty(regionStatList)) { + for (RegionStat re : regionStatList) { + map.put(format.format(DateUtil.getBeforeDay(re.getWeekend(), -1)), re.getAvgPrice()); + } + } + if (CollectionUtils.isNotEmpty(citySellStats)) { + for (CitySellStat re : citySellStats) { + map.put(re.getDate().toString().substring(0, 4) + "." + re.getDate().toString().substring(4, 6), re.getAvgPrice()); + } + } + if (CollectionUtils.isNotEmpty(regionSellStats)) { + for (RegionSellStat re : regionSellStats) { + map.put(re.getDate().toString().substring(0, 4) + "." + re.getDate().toString().substring(4, 6), re.getAvgPrice()); + } } return map; } @@ -4749,5 +4735,12 @@ public Object checkUserAction(EvaluationModel model, HttpServletRequest req, Htt public void setIpCountService(IpCountService ipCountService) { this.ipCountService = ipCountService; } - + + public void setCitySellStatService(CitySellStatService citySellStatService) { + this.citySellStatService = citySellStatService; + } + + public void setRegionSellStatService(RegionSellStatService regionSellStatService) { + this.regionSellStatService = regionSellStatService; + } } diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java index 6351025d3..34543d7be 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/controllers/TrendController.java @@ -14,8 +14,12 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; +import com.fangjia.core.City; import com.fangjia.coresite.model.*; +import com.fangjia.dal.mongo.model.*; import com.fangjia.service.bo.*; +import com.fangjia.service.datastore.*; +import com.fangjia.service.mongo.fangjia.RegionSellStatService; import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; @@ -39,21 +43,9 @@ import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.common.FangjiaServerAreaContextHolder; import com.fangjia.dal.datastore.model.News; import com.fangjia.dal.mongo.fangjia.model.ServerArea; -import com.fangjia.dal.mongo.model.CityTradeStat; -import com.fangjia.dal.mongo.model.DistrictNewPrice; -import com.fangjia.dal.mongo.model.DistrictSellStat; -import com.fangjia.dal.mongo.model.DistrictStat; -import com.fangjia.dal.mongo.model.DistrictTradeStat; -import com.fangjia.dal.mongo.model.RegionBlock; -import com.fangjia.dal.mongo.model.RegionStat; import com.fangjia.dal.seaweed.model.District; -import com.fangjia.service.datastore.DistrictSellStatService; -import com.fangjia.service.datastore.DistrictService; -import com.fangjia.service.datastore.HouseService; -import com.fangjia.service.datastore.RegionStatService; import com.fangjia.service.datastore.bean.HousePicEnum; import com.fangjia.service.datastore.bean.HouseQueryBean; -import com.fangjia.service.datastore.EvaluationService; import com.fangjia.service.district.DistrictStatService; import com.fangjia.service.district.TradeStatService; import com.fangjia.service.fsh.DistrictNewPriceService; @@ -82,6 +74,9 @@ public class TrendController { private static int QUARTER_WEEK = 13; private final static Logger LOGGER = LoggerFactory.getLogger(TrendController.class); + private CitySellStatService citySellStatService; + private RegionSellStatService regionSellStatService; + public Object trendChartAction(TrendModel model, HttpServletRequest request) { TrendView trendView = TrendViewFactory.getInstance().create(model); if (trendView != null) { @@ -171,7 +166,9 @@ public class TrendController { model.setRegionItems(getRegionItems(model)); model.setBlockItems(getRegionBlocks(model)); - model.setCityStatInfoBos(findCitysAvgPrice(10)); + + List citySellStats = citySellStatService.getAllWithMonths(city, 2); + model.setCityStatInfoBos(findCitysAvgPricePlus(city,citySellStats.get(0).getDate(), 10)); model.setDefaultCityName(city); TrendView trendView = TrendViewFactory.getInstance().create(model); if (trendView == null) { @@ -182,15 +179,15 @@ public class TrendController { //DistrictStatBo statBo = getDistrictStat(new DistrictKey(trendView.getCityName(), trendView.getRegion(), trendView.getDistrictName())); DistrictStatBo statBo = getNearestDistrictStat(new DistrictKey(trendView.getCityName(), trendView.getRegion(), trendView.getDistrictName())); model.setDistrictStatBo(statBo); - } else if (trendView.getType().equals(ViewType.region) || trendView.getType().equals(ViewType.block)) { + } else if (trendView.getType().equals(ViewType.region)) { //RegionStatBo regionStat = getRegionBlockStat(trendView.getCityName(), trendView.getRegion(), trendView.getBlock()); - RegionStatBo regionStat = getNearestRegionStat(trendView.getCityName(), trendView.getRegion(), trendView.getBlock()); - model.setRegionStatBo(regionStat); + RegionSellStatBo regionSellStatBo = getNearestRegionSellStat(trendView.getCityName(), trendView.getRegion()); + model.setRegionSellStatBo(regionSellStatBo); model.setRegion(trendView.getRegion()); } else if (trendView.getType().equals(ViewType.city)) { //RegionStatBo regionStat = getRegionBlockStat(trendView.getCityName(), null, null); - RegionStatBo regionStat = getNearestRegionStat(trendView.getCityName(), null, null); - model.setRegionStatBo(regionStat); + CitySellStatBo citySellStat = getNearestCitySellStat(trendView.getCityName()); + model.setCitySellStatBo(citySellStat); } @@ -275,6 +272,30 @@ public class TrendController { return Collections.EMPTY_LIST; } + private List findCitysAvgPricePlus(String city, Integer startDate, int limit){ + List cityStatInfoBos = new ArrayList(); + List citySellStats = citySellStatService.findCityOrderByAvgPrice(null, startDate, limit); + for(int i=0;i buildStatJson(String city, String region, String block, int weeks) { List regionStatList = null; + List citySellStatList = null; + List regionSellStatList = null; Map oprions = new HashMap(); Date currentDate = new Date(); if (city != null && region != null && block != null) { regionStatList = regionStatService.findRegionStat(city, region, block, currentDate, weeks); oprions.put("name", block + "板块"); } else if (city != null && region != null) { - regionStatList = regionStatService.findRegionStat(city, region, null, currentDate, weeks); + //regionStatList = regionStatService.findRegionStat(city, region, null, currentDate, weeks); + int month = weeks / 4; + regionSellStatList = regionSellStatService.getAllWithMonths(city, region, month); oprions.put("name", region); } else if (city != null) { - regionStatList = regionStatService.findRegionStat(city, null, null, currentDate, weeks); + //regionStatList = regionStatService.findRegionStat(city, null, null, currentDate, weeks); + int month = weeks / 4; + citySellStatList = citySellStatService.getAllWithMonths(city, month); oprions.put("name", city); } List ret = new ArrayList(); - if (regionStatList == null) { - return null; - } - JSONArray splineJa = new JSONArray(); - for (RegionStat re : regionStatList) { - JSONArray ja = new JSONArray(); - ja.put(DateUtil.getBeforeDay(re.getWeekend(), -1).getTime()); - ja.put(re.getAvgPrice()); - splineJa.put(ja); + if (CollectionUtils.isNotEmpty(regionStatList)) { + for (RegionStat re : regionStatList) { + JSONArray ja = new JSONArray(); + ja.put(DateUtil.getBeforeDay(re.getWeekend(), -1).getTime()); + ja.put(re.getAvgPrice()); + splineJa.put(ja); + } + } else if (CollectionUtils.isNotEmpty(citySellStatList)) { + for (int i = citySellStatList.size() - 1; i >= 0; i--) { + CitySellStat re = citySellStatList.get(i); + JSONArray ja = new JSONArray(); + ja.put(DateUtil.getBeforeDay(DateUtil.parseDate(re.getDate().toString(), "yyyyMM"), -1).getTime()); + ja.put(re.getAvgPrice()); + splineJa.put(ja); + } + } else if (CollectionUtils.isNotEmpty(regionSellStatList)) { + for (int i = regionSellStatList.size() - 1; i >= 0; i--) { + RegionSellStat re = regionSellStatList.get(i); + JSONArray ja = new JSONArray(); + ja.put(DateUtil.getBeforeDay(DateUtil.parseDate(re.getDate().toString(), "yyyyMM"), -1).getTime()); + ja.put(re.getAvgPrice()); + splineJa.put(ja); + } } if (splineJa.length() > 0) { @@ -826,6 +867,64 @@ public class TrendController { seriesOptions.addAll(data); } } + private CitySellStatBo getNearestCitySellStat(String city) { + CitySellStatBo ret = null; + List citySellStats = null; + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtils.addMonths(new Date(), -3), "yyyyMM")); + citySellStats = citySellStatService.findNearCityStat(city, startDate, 2); + if(citySellStats!=null && citySellStats.size()>0){ + CitySellStatBo bo = new CitySellStatBo(); + if(citySellStats.size()==2){ + bo.setAvgPrice(citySellStats.get(0).getAvgPrice()); + bo.setLastTimeAvgPrice(citySellStats.get(1).getAvgPrice()); + int monthMarkup = (citySellStats.get(0).getAvgPrice()-citySellStats.get(1).getAvgPrice())*10000/citySellStats.get(1).getAvgPrice(); + bo.setMonthMarkup(monthMarkup); + + }else{ + bo.setAvgPrice(citySellStats.get(0).getAvgPrice()); + } + + CitySellStat rs = citySellStatService.findStartStat(city); + if(rs!=null){ + bo.setStartDate(rs.getDate() / 100); + } + return bo; + } + return null; + } + + /** + * 区域均价 + * + * @param city + * @return + */ + private RegionSellStatBo getNearestRegionSellStat(String city, String region) { + RegionSellStatBo ret = null; + List regionSellStats = null; + Integer startDate = Integer.valueOf(DateUtil.formatByPattern(DateUtils.addMonths(new Date(), -3), "yyyyMM")); + regionSellStats = regionSellStatService.findNearCityStat(city, region, startDate, 2); + if(regionSellStats!=null && regionSellStats.size()>0){ + RegionSellStatBo bo = new RegionSellStatBo(); + if(regionSellStats.size()==2){ + bo.setAvgPrice(regionSellStats.get(0).getAvgPrice()); + bo.setLastTimeAvgPrice(regionSellStats.get(1).getAvgPrice()); + int monthMarkup = (regionSellStats.get(0).getAvgPrice()-regionSellStats.get(1).getAvgPrice())*10000/regionSellStats.get(1).getAvgPrice(); + bo.setMonthMarkup(monthMarkup); + + }else{ + bo.setAvgPrice(regionSellStats.get(0).getAvgPrice()); + } + + RegionSellStat rs = regionSellStatService.findStartStat(city, region); + if(rs!=null){ + bo.setStartDate(rs.getDate() / 100); + } + return bo; + } + return null; + } + private RegionStatBo getNearestRegionStat(String city, String region, String block){ RegionStatBo ret = null; @@ -1284,4 +1383,11 @@ public class TrendController { this.evaluationService = evaluationService; } + public void setCitySellStatService(CitySellStatService citySellStatService) { + this.citySellStatService = citySellStatService; + } + + public void setRegionSellStatService(RegionSellStatService regionSellStatService) { + this.regionSellStatService = regionSellStatService; + } } diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java index 0f6a0fde9..1e9c64f0f 100644 --- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java +++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/TrendModel.java @@ -31,6 +31,8 @@ public class TrendModel extends BaseModel implements TrendViewModel { private String trendDesc; private DistrictStatBo districtStatBo; private RegionStatBo regionStatBo; + private CitySellStatBo citySellStatBo; + private RegionSellStatBo regionSellStatBo; private String affectKeyword; private int chartWidth; private int chartHeight; @@ -330,4 +332,20 @@ public class TrendModel extends BaseModel implements TrendViewModel { public void setCityStatInfoBos(List cityStatInfoBos) { this.cityStatInfoBos = cityStatInfoBos; } + + public CitySellStatBo getCitySellStatBo() { + return citySellStatBo; + } + + public void setCitySellStatBo(CitySellStatBo citySellStatBo) { + this.citySellStatBo = citySellStatBo; + } + + public RegionSellStatBo getRegionSellStatBo() { + return regionSellStatBo; + } + + public void setRegionSellStatBo(RegionSellStatBo regionSellStatBo) { + this.regionSellStatBo = regionSellStatBo; + } } diff --git a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl index c3fbbf0d3..aaec999b2 100644 --- a/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl +++ b/projects/fangjia-coresite/src/main/webapp/trend/trend.ftl @@ -104,21 +104,34 @@
- <#if districtStatBo?? || regionStatBo??> + <#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??>

${affectValue}鎴夸骇鍧囦环璧板娍

-

<#if districtStatBo??>${districtStatBo.startYear!}<#else><#if regionStatBo?? && regionStatBo.startDate??>${regionStatBo.startDate?string('yyyy')}-${.now?string('yyyy')} | 鍛ㄥ害 | 鍏�/銕� | 鏁版嵁鏉ユ簮锛氭埧浠风綉

+

+ <#if districtStatBo??>${districtStatBo.startYear!} + <#elseif citySellStatBo?? && citySellStatBo.startDate??>${citySellStatBo.startDate} + <#elseif regionSellStatBo?? && regionSellStatBo.startDate??>${regionSellStatBo.startDate} + + -${.now?string('yyyy')} | 鍛ㄥ害 | 鍏�/銕� | 鏁版嵁鏉ユ簮锛氭埧浠风綉

${descWord}

- <#if districtStatBo?? || regionStatBo??> + <#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??> <#if count??>
${count!}
<#if districtStatBo??>
<#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>鏆傛棤
<#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>鏆傛棤
${(districtStatBo.districtStat.weekendMarkup/100)?string('0.00')}%
+ <#elseif citySellStatBo??> +
${citySellStatBo.lastTimeAvgPrice!}
+
${citySellStatBo.avgPrice!}
+
${(citySellStatBo.monthMarkup/100)?string('0.00')}%
+ <#elseif regionSellStatBo??> +
${regionSellStatBo.lastTimeAvgPrice!}
+
${regionSellStatBo.avgPrice!}
+
${(regionSellStatBo.monthMarkup/100)?string('0.00')}%
<#elseif regionStatBo??>
${regionStatBo.lastTimeAvgPrice!}
${regionStatBo.avgPrice!}
@@ -145,21 +158,21 @@
- <#if blockItems?? && blockItems?size gt 0> - <#if block??>${block!}<#else>鏉垮潡 - - - +<#-- <#if blockItems?? && blockItems?size gt 0>--> +<#-- <#if block??>${block!}<#else>鏉垮潡--> +<#-- --> +<#-- --> +<#-- -->
- <#if districtStatBo?? || regionStatBo??> + <#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??>
  • 涓嬭浇
  • 鎵撳嵃
  • @@ -181,7 +194,7 @@
    - <#if districtStatBo?? || regionStatBo??> + <#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??> <#else>
    @@ -478,7 +491,7 @@ var down_pic_temp = 0; $(document).ready(function(){ //璧板娍鍥� - <#if districtStatBo?? || regionStatBo??> + <#if districtStatBo?? || regionStatBo?? || citySellStatBo?? || regionSellStatBo??> <#if type??> <#if type == '4' || type == 'quarter'> var url = Constants.cityUrl + '/trend/quarterData?defaultCityName=${cityName}&districtName=${districtName!}®ion=${region!}&block=${block!}&keyword=${keyword!}'; diff --git a/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl b/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl index e9b882a94..7b54d3b4c 100644 --- a/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl +++ b/projects/fangjia-coresite/src/main/webapp/yinLianEvaluation/index.ftl @@ -103,12 +103,12 @@
    <#if districtStatBo?? || regionStatBo??> <#if districtStatBo??> -
    <#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>鏆傛棤
    -
    <#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>鏆傛棤
    +
    <#if districtStatBo.lastTimeDistrictStat??>${districtStatBo.lastTimeDistrictStat.avgPrice}<#else>鏆傛棤
    +
    <#if districtStatBo.districtStat??>${districtStatBo.districtStat.avgPrice}<#else>鏆傛棤
    ${(districtStatBo.districtStat.weekendMarkup/100)?string('0.00')}%
    <#elseif regionStatBo??> -
    ${regionStatBo.lastTimeAvgPrice!}
    -
    ${regionStatBo.avgPrice!}
    +
    ${regionStatBo.lastTimeAvgPrice!}
    +
    ${regionStatBo.avgPrice!}
    ${(regionStatBo.weekendMarkup/100)?string('0.00')}%
    diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDao.java index d726b3806..c6ade6b04 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDao.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDao.java @@ -2,9 +2,16 @@ package com.fangjia.dal.mongo.dao; import com.fangjia.dal.MongoDao; import com.fangjia.dal.mongo.model.CitySellStat; +import com.fangjia.dal.mongo.model.RegionStat; + +import java.util.Date; +import java.util.List; /** * Created by hubingliang on 2016/12/8. */ public interface CitySellStatDao extends MongoDao { + + List findCitySellStat(String city, Integer startDate, Integer endDate); + } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDaoImpl.java index f09616ce9..56eb779a2 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/CitySellStatDaoImpl.java @@ -1,10 +1,33 @@ package com.fangjia.dal.mongo.dao; import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SortParam; import com.fangjia.dal.mongo.model.CitySellStat; +import com.fangjia.dal.mongo.model.RegionStat; +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * Created by hubingliang on 2016/12/8. */ public class CitySellStatDaoImpl extends MongoDaoImpl implements CitySellStatDao { + + @Override + public List findCitySellStat(String city, Integer startDate, Integer endDate) { + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + if (startDate!=null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + + List sortParms = new ArrayList(1); + sortParms.add(new SortParam("date", true)); + List statList = findAllByParams(params, sortParms); + return statList; + } } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDao.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDao.java index 65c0123ef..87a77e9a2 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDao.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDao.java @@ -1,8 +1,13 @@ package com.fangjia.dal.mongo.dao; import com.fangjia.dal.MongoDao; +import com.fangjia.dal.mongo.model.CitySellStat; import com.fangjia.dal.mongo.model.RegionSellStat; +import java.util.List; + public interface RegionSellStatDao extends MongoDao { + List findRegionSellStat(String city, String region, Integer startDate, Integer endDate); + } diff --git a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDaoImpl.java b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDaoImpl.java index 389c4e30d..940c9b9da 100644 --- a/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDaoImpl.java +++ b/projects/fangjia-dal/src/main/java/com/fangjia/dal/mongo/dao/RegionSellStatDaoImpl.java @@ -1,9 +1,31 @@ package com.fangjia.dal.mongo.dao; import com.fangjia.dal.MongoDaoImpl; +import com.fangjia.dal.QueryParam; +import com.fangjia.dal.SortParam; +import com.fangjia.dal.mongo.model.CitySellStat; import com.fangjia.dal.mongo.model.RegionSellStat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class RegionSellStatDaoImpl extends MongoDaoImpl implements RegionSellStatDao { + @Override + public List findRegionSellStat(String city, String region, Integer startDate, Integer endDate) { + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("region", region)); + params.add(new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate)); + if (startDate!=null) { + params.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + } + + List sortParms = new ArrayList(1); + sortParms.add(new SortParam("date", true)); + List statList = findAllByParams(params, sortParms); + return statList; + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CityController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CityController.java index 8612308d7..e39e0958f 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CityController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/CityController.java @@ -452,18 +452,18 @@ public class CityController { * * @return */ - public Object avgPrice2Action(@Param(name = "city") String city, @Param(name = "periodCount") Integer periodCount,@Param(name = "periodType") String periodType) { + public Object avgPrice2Action(@Param(name = "city") String city, @Param(name = "periodCount") Integer periodCount) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); if (StringUtils.isBlank(city)) { mav.setModel(BasicModel.buildBadRequestModel("city不能为null")); return mav; } - if(!RegionData.isCity(city)){ + if (!RegionData.isCity(city)) { String formatCity = RegionData.formatCity(city); - if(StringUtils.isNotBlank(formatCity)){ + if (StringUtils.isNotBlank(formatCity)) { city = formatCity; - }else{ + } else { mav.setModel(BasicModel.buildBadRequestModel("city非法")); return mav; } @@ -473,57 +473,41 @@ public class CityController { mav.setModel(BasicModel.buildBadRequestModel("city非法")); return mav; } - if(null == periodCount || 0 == periodCount){ - periodCount = 1; - } - if(periodCount < 1 || periodCount>156){ - mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); - return mav; - } - - if(StringUtils.isBlank(periodType)){ - periodType = "weekly"; - }else{ - if(!"weekly".equals(periodType) && !"monthly".equals(periodType)){ - mav.setModel(BasicModel.buildBadRequestModel("periodModel值非法,合法值为:weekly,monthly")); - return mav; - } - } - - Calendar calendar = Calendar.getInstance(); - if("weekly".equals(periodType)){ - calendar.add(Calendar.DATE, -periodCount*7); - }else{ - calendar.add(Calendar.MONTH, -periodCount); - } - - List regionStats = regionStatService.findRegionBlockStat(city,null,null,calendar.getTime(),new Date(),periodType); - - if (CollectionUtils.isEmpty(regionStats)) { + if (null == periodCount || 0 == periodCount) { + periodCount = 1; + } + if (periodCount < 1 || periodCount > 36) { + mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-36]")); + return mav; + } + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -periodCount); + + int year = calendar.get(Calendar.YEAR); + int month = calendar.get(Calendar.MONTH) + 1; // 注意:月份从 0 开始,需要加 1 + int montyInt = year * 100 + month; + List cityStats = citySellStatService.findNearCityStat(city, montyInt, periodCount); + if (CollectionUtils.isEmpty(cityStats)) { mav.setModel(new HttpCode(OpenHttpCodeEnum.TARGET_DATA_NOT_EXIST, "该城市没有均价数据")); return mav; } - if(regionStats.size() > periodCount){ - regionStats = regionStats.subList(regionStats.size() - periodCount,regionStats.size()); - } - List> result = new ArrayList>(periodCount); - for (RegionStat regionStat : regionStats) { - Map item = new LinkedHashMap(); - item.put("city", regionStat.getCity()); - item.put("avgPrice", String.valueOf(regionStat.getAvgPrice())); - if("monthly".equals(periodType)){ - item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM")); - }else{ - item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM-dd")); - } - item.put("changePercent", String.valueOf(regionStat.getMarkup() / 100d)); - result.add(item); - } - mav.setModel(BasicModel.buildOKModel().setResult(result)); + if (cityStats.size() > periodCount) { + cityStats = cityStats.subList(cityStats.size() - periodCount, cityStats.size()); + } + List> result = new ArrayList>(periodCount); + for (CitySellStat cityStat : cityStats) { + Map item = new LinkedHashMap(); + item.put("city", cityStat.getCity()); + item.put("avgPrice", String.valueOf(cityStat.getAvgPrice())); + item.put("date", cityStat.getDate() / 100 + "-" + String.format("%02d", cityStat.getDate() % 100)); + item.put("changePercent", String.format("%.2f", cityStat.getMom() * 100)); + result.add(item); + } + mav.setModel(BasicModel.buildOKModel().setResult(result)); return mav; } - /** * 城市均价范围Action * 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 28559ace3..826ee47c4 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 @@ -17,10 +17,8 @@ import com.fangjia.service.datastore.RegionStatService; import com.fangjia.service.district.DistrictFacilitysService; import com.fangjia.service.district.DistrictStatRentService; import com.fangjia.service.district.RegionStatRentService; -import com.fangjia.service.mongo.fangjia.AverageAnalyService; -import com.fangjia.service.mongo.fangjia.RegionBlockService; +import com.fangjia.service.mongo.fangjia.*; -import com.fangjia.service.mongo.fangjia.SeaweedImagesService; import net.sf.json.JSONArray; import net.sf.json.JSONException; import net.sf.json.JSONObject; @@ -69,7 +67,6 @@ import com.fangjia.service.index.BoostQueryPolicy; import com.fangjia.service.menu.Menu; import com.fangjia.service.menu.MenuCategoryEnum; import com.fangjia.service.mongo.bkoff.ExtractDistrictService; -import com.fangjia.service.mongo.fangjia.DistrictHouseService; import com.fangjia.service.open.DistrictBo; import com.fangjia.service.sql.ApiUserService; import com.fangjia.service.web.MenuService; @@ -94,6 +91,7 @@ public class DistrictController { private RegionStatRentService regionStatRentService; private DistrictFacilitysService districtFacilitysService; private SeaweedImagesService seaweedImagesService; + private RegionStatTrendService regionStatTrendService; public static final String[] COLUMNS = {"id", "name", "estateType", "buildType", "licence", "buildArea", "allArea", @@ -692,42 +690,30 @@ public class DistrictController { if (model.getPeriodCount() == null) { model.setPeriodCount(1); } - if (model.getPeriodCount() < 1 || model.getPeriodCount() > 156) { - mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-156]")); + if (model.getPeriodCount() < 1 || model.getPeriodCount() > 36) { + mav.setModel(BasicModel.buildBadRequestModel("periodCount值不合法,取值范围是:[1-36]")); return mav; } - if (StringUtils.isBlank(model.getPeriodType())) { - model.setPeriodType("weekly"); - } 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 { - 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()); + calendar.add(Calendar.MONTH, -model.getPeriodCount()); + + int year = calendar.get(Calendar.YEAR); + int month = calendar.get(Calendar.MONTH) + 1; // 注意:月份从 0 开始,需要加 1 + int montyInt = year * 100 + month; + List datas = regionStatTrendService.getAllWithMonths(model.getCity(), region, model.getPeriodCount()); + + if (datas.size() > model.getPeriodCount()) { + datas = datas.subList(datas.size() - model.getPeriodCount(), datas.size()); } List> result = new ArrayList>(model.getPeriodCount()); - for (RegionStat regionStat : regionStats) { + for (RegionStatTrend regionStat : datas) { 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())) { - item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM")); - } else { - item.put("date", DateUtil.formatByPattern(regionStat.getWeekend(), "yyyy-MM-dd")); - } - item.put("changePercent", String.valueOf(regionStat.getMarkup() / 100d)); + item.put("date", regionStat.getDate() / 100 + "-" + String.format("%02d", regionStat.getDate() % 100)); + item.put("changePercent", String.format("%.2f", regionStat.getMom() * 100)); result.add(item); } mav.setModel(BasicModel.buildOKModel().setResult(result)); @@ -1186,7 +1172,7 @@ public class DistrictController { data.put("bus", model.getBus()); data.put("bank", model.getBank()); data.put("atm", model.getAtm()); - data.put("metro",model.getMetro()); + data.put("metro", model.getMetro()); districtService.updateDistrictFacilitysById(data, model.getId()); } else { DistrictFacilitys districtFacilitys = CommonDtoUtils.transformV(DistrictFacilitys.class, model); @@ -1199,7 +1185,7 @@ public class DistrictController { List result = new ArrayList(); if (value != null && !value.isEmpty()) { - value = value.replaceAll("\\[", "").replaceAll("]", "").replaceAll(" ",""); + value = value.replaceAll("\\[", "").replaceAll("]", "").replaceAll(" ", ""); String[] splitValues = value.split(","); // 按逗号分割 // 遍历数组并过滤空字符串 @@ -1285,6 +1271,7 @@ public class DistrictController { } return mav; } + public Object deletePicAction(DistrictModel model) { RestfulModelAndView mav = new RestfulModelAndView(); mav.setViewType("rest"); @@ -1292,21 +1279,22 @@ public class DistrictController { mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入")); return mav; } - seaweedImagesService.deleteImage(model.getId(),model.getUrl(),model.getPicType(), model.getRoomType()); + 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){ + 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()); + seaweedImagesService.addImage(model.getId(), model.getImageUrls(), model.getPicType(), model.getRoomType()); mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "添加成功")); return mav; } @@ -1435,4 +1423,8 @@ public class DistrictController { public void setSeaweedImagesService(SeaweedImagesService seaweedImagesService) { this.seaweedImagesService = seaweedImagesService; } + + public void setRegionStatTrendService(RegionStatTrendService regionStatTrendService) { + this.regionStatTrendService = regionStatTrendService; + } } 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 945ab4e5b..cb41460ae 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 @@ -1017,6 +1017,10 @@ public class HouseController { } else { pager.setPageSize(5); } + if (model.getPrice() != null) { + query.setStartPrice((int) (model.getPrice() * 0.9)); + query.setEndPrice((int) (model.getPrice() * 1.1)); + } query.setPager(pager); query.setSortField("p_date"); query.setOrder(false); 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 e2b80dddd..74e1af29d 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 @@ -107,7 +107,9 @@ public class DistrictController { } List params = new ArrayList(); - params.add(new QueryParam("city", city)); + if (StringUtils.isNotBlank(city)) { + params.add(new QueryParam("city", city)); + } params.add(new QueryParam("category", cat)); params.add(new QueryParam("visible", 0)); params.add(new QueryParam("$srByStr", String.format("keyword:%s^6.0 OR keyword_cjk:%s", keyword, keyword))); 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 39fefbbdc..dc5b5eae0 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 @@ -29,6 +29,8 @@ public class HouseSearchModel extends SearchModel { private String cat; private Integer pageSize; + + private Double price; @Override public QueryBean getQueryBean() { HouseQueryBean queryBean = new HouseQueryBean(); @@ -209,4 +211,12 @@ public class HouseSearchModel extends SearchModel { public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy index ddb9616bd..5c6e27c8a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchAdministrativeMappingDataBatch.groovy @@ -37,7 +37,9 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ //删除旧的,再同步新的 ADMINISTRATIVE_MAPPING_COLL_100.remove(new BasicDBObject()) - def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(new BasicDBObject()).batchSize(1000) + def q = new BasicDBObject() +// q.put("shape.type","MultiPolygon") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q).batchSize(1000) def datas = [] def retMap = [:] for(def d : dbcursor){ @@ -59,6 +61,7 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ def synchToEs(retMap, host, indexName){ QueryBuilder queryBuilder = QueryBuilders.boolQuery() +// queryBuilder.must(QueryBuilders.termQuery("street", "喀拉玛盖镇")) def oldIds = new CopyOnWriteArrayList() ElasticUtils89.queryUpdate(host, indexName, queryBuilder, { String id, doc-> @@ -69,11 +72,11 @@ class SynchAdministrativeMappingDataBatch extends BaseBatch{ if(!["id","_id","c_date","m_date","polyline_source","operator","city_simple_pinyin","prefecture_level_city"].contains(k)){ def val = doc.get(k) if(val!=v){ - if(k!="shape" || (k=="shape" && v.type!="MultiPolygon")){ +// if(k!="shape" || (k=="shape" && v.type!="MultiPolygon")){ println k +" 修改 "+id updateFieldCount++ doc.put(k,v) - } +// } } } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy index ea5a16f8e..7cc322652 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/SynchDevDataBatch.groovy @@ -35,7 +35,8 @@ class SynchDevDataBatch extends BaseBatch{ } def synchDevTo100(){ - def dbcursor = DEVELOPMENT_ZONE_43_COLL.find() + def q = new BasicDBObject() + def dbcursor = DEVELOPMENT_ZONE_43_COLL.find(q) def rets = [] def devMap = [:] for(def r : dbcursor){ @@ -87,7 +88,7 @@ class SynchDevDataBatch extends BaseBatch{ QueryBuilder queryBuilder = QueryBuilders.boolQuery() def oldIds = new CopyOnWriteArrayList() - ElasticUtils89.executeQuery(host, indexName, queryBuilder, { String id, doc-> + ElasticUtils89.queryUpdate(host, indexName, queryBuilder, { String id, doc-> oldIds << id def mongoObj = devMap.get(id) def updateFieldCount = 0 diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy index b0c2ea3f8..939778156 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SeaweedDataSynch.groovy @@ -343,7 +343,7 @@ class SeaweedDataSynch extends BaseBatch{ map.region = distData.district area_code = distData.mca_district_code }else{ - if(["东莞市","中山市","济源市","仙桃市","潜江市","天门市","神农架林区","五指山市","琼海市","文昌市","万宁市","东方市","定安县","屯昌县","澄迈县","临高县","白沙黎族自治县","昌江黎族自治县","乐东黎族自治县","陵水黎族自治县","保亭黎族苗族自治县","琼中黎族苗族自治县","五指山市","琼海市","文昌市","万宁市","东方市","定安县","屯昌县","澄迈县","临高县","白沙黎族自治县","昌江黎族自治县","乐东黎族自治县","陵水黎族自治县","保亭黎族苗族自治县","琼中黎族苗族自治县","石河子市","阿拉尔市","图木舒克市","五家渠市","北屯市","铁门关市","双河市","可克达拉市","昆玉市","胡杨河市","新星市","白杨市","嘉峪关市"].contains(map.city)){ + if(["东莞市","中山市","济源市","仙桃市","潜江市","天门市","神农架林区","五指山市","琼海市","文昌市","万宁市","东方市","定安县","屯昌县","澄迈县","临高县","白沙黎族自治县","昌江黎族自治县","乐东黎族自治县","陵水黎族自治县","保亭黎族苗族自治县","琼中黎族苗族自治县","五指山市","琼海市","文昌市","万宁市","东方市","定安县","屯昌县","澄迈县","临高县","白沙黎族自治县","昌江黎族自治县","乐东黎族自治县","陵水黎族自治县","保亭黎族苗族自治县","琼中黎族苗族自治县","石河子市","阿拉尔市","图木舒克市","五家渠市","北屯市","铁门关市","双河市","可克达拉市","昆玉市","胡杨河市","新星市","白杨市","嘉峪关市","儋州市"].contains(map.city)){ map.region = map.city } // map.region = dist.region diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy index 39b9e53d2..9bb1b003a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/util/DingDingMessageUtil.groovy @@ -30,6 +30,28 @@ class DingDingMessageUtil { } } + static void sendTextMessageAndAt(String access_token, String msg, String atMobile) throws Exception { + HttpRequest request = new HttpRequest(); + HttpPost httppost = new HttpPost("https://oapi.dingtalk.com/robot/send?access_token=" + access_token); + httppost.addHeader("Content-Type", "application/json; charset=utf-8"); + + // 创建消息体,只包含一个手机号 + String textMsg = "{ " + + "\"msgtype\": \"text\", " + + "\"text\": {\"content\": \"" + msg + "\"}, " + + "\"at\": {\"atMobiles\": [\"" + atMobile + "\"]}" + // 只 @ 一个手机号 + "}"; + + StringEntity se = new StringEntity(textMsg, "utf-8"); + httppost.setEntity(se); + HttpResponse response = request.getHttpClient().execute(httppost); + + if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { + String result = EntityUtils.toString(response.getEntity(), "utf-8"); + System.out.println("消息发送结果:" + result); + } + } + static void sendMarkdownMessage(String access_token, String title, String msg){ HttpRequest request = new HttpRequest() JSONObject requestBody = new JSONObject() diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/bo/CitySellStatBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/CitySellStatBo.java new file mode 100644 index 000000000..5c5121057 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/CitySellStatBo.java @@ -0,0 +1,101 @@ +package com.fangjia.service.bo; + +import java.io.Serializable; +import java.util.Date; + +public class CitySellStatBo implements Serializable { + private static final long serialVersionUID = -5310665233447971693L; + private String city; + private String region; + private String block; + private int avgPrice; + private int weekendMarkup; + // 年同比涨跌 + private Integer yearMarkup; + // 月环比涨跌 + private Integer monthMarkup; + private int month; + + private int lastTimeAvgPrice; + private Integer startDate; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getBlock() { + return block; + } + + public void setBlock(String block) { + this.block = block; + } + + public int getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(int avgPrice) { + this.avgPrice = avgPrice; + } + + public int getWeekendMarkup() { + return weekendMarkup; + } + + public void setWeekendMarkup(int weekendMarkup) { + this.weekendMarkup = weekendMarkup; + } + + public Integer getYearMarkup() { + return yearMarkup; + } + + public void setYearMarkup(Integer yearMarkup) { + this.yearMarkup = yearMarkup; + } + + public Integer getMonthMarkup() { + return monthMarkup; + } + + public void setMonthMarkup(Integer monthMarkup) { + this.monthMarkup = monthMarkup; + } + + public int getMonth() { + return month; + } + + public void setMonth(int month) { + this.month = month; + } + + public int getLastTimeAvgPrice() { + return lastTimeAvgPrice; + } + + public void setLastTimeAvgPrice(int lastTimeAvgPrice) { + this.lastTimeAvgPrice = lastTimeAvgPrice; + } + + public Integer getStartDate() { + return startDate; + } + + public void setStartDate(Integer startDate) { + this.startDate = startDate; + } +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/bo/RegionSellStatBo.java b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/RegionSellStatBo.java new file mode 100644 index 000000000..1f6e9a520 --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/bo/RegionSellStatBo.java @@ -0,0 +1,104 @@ +package com.fangjia.service.bo; + +import java.io.Serializable; +import java.util.Date; + +public class RegionSellStatBo implements Serializable { + private static final long serialVersionUID = -5310665233447971693L; + private String city; + private String region; + private String block; + private int avgPrice; + private int weekendMarkup; + // 年同比涨跌 + private Integer yearMarkup; + // 月环比涨跌 + private Integer monthMarkup; + private int month; + + private int lastTimeAvgPrice; + private Integer startDate; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getBlock() { + return block; + } + + public void setBlock(String block) { + this.block = block; + } + + public int getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(int avgPrice) { + this.avgPrice = avgPrice; + } + + public int getWeekendMarkup() { + return weekendMarkup; + } + + public void setWeekendMarkup(int weekendMarkup) { + this.weekendMarkup = weekendMarkup; + } + + public Integer getYearMarkup() { + return yearMarkup; + } + + public void setYearMarkup(Integer yearMarkup) { + this.yearMarkup = yearMarkup; + } + + public Integer getMonthMarkup() { + return monthMarkup; + } + + public void setMonthMarkup(Integer monthMarkup) { + this.monthMarkup = monthMarkup; + } + + public int getMonth() { + return month; + } + + public void setMonth(int month) { + this.month = month; + } + + public int getLastTimeAvgPrice() { + return lastTimeAvgPrice; + } + + public void setLastTimeAvgPrice(int lastTimeAvgPrice) { + this.lastTimeAvgPrice = lastTimeAvgPrice; + } + + public Integer getStartDate() { + return startDate; + } + + public void setStartDate(Integer startDate) { + this.startDate = startDate; + } + + + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java index 08a2582de..7967206ac 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatService.java @@ -2,7 +2,9 @@ package com.fangjia.service.datastore; import com.fangjia.dal.mongo.model.CitySellStat; import com.fangjia.dal.mongo.model.DistrictSellStat; +import com.fangjia.dal.mongo.model.RegionStat; +import java.util.Date; import java.util.List; /** @@ -32,4 +34,18 @@ public interface CitySellStatService { * @return */ CitySellStat findCitySellStatByCity(String city); + + List findNearCityStat(String city, Integer startDate, int count); + + /** + * 查询均价开始的最早时间 + * @param city + * @return + */ + CitySellStat findStartStat(String city); + + List findCityOrderByAvgPrice(final String city, final Integer startDate, final int count) ; + + List findCitySellStat(String city, Integer startDate, Integer endDate); + } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java index 8e329b935..77a7fad14 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/CitySellStatServiceImpl.java @@ -1,12 +1,6 @@ package com.fangjia.service.datastore; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import com.fangjia.core.util.CacheUtils; import com.fangjia.core.util.DateUtil; @@ -16,9 +10,12 @@ import com.fangjia.dal.SortParam; import com.fangjia.dal.common.DistrictKey; import com.fangjia.dal.mongo.dao.CitySellStatDao; import com.fangjia.dal.mongo.model.CitySellStat; +import com.fangjia.dal.mongo.model.RegionStat; +import com.fangjia.dal.mongo.model.StatFlag; import com.fangjia.service.bo.DistrictStatBo; import com.google.common.collect.ImmutableList; +import org.apache.commons.lang.StringUtils; import org.sothis.core.util.Closure; /** @@ -108,4 +105,60 @@ public class CitySellStatServiceImpl implements CitySellStatService { }); } + @Override + public List findNearCityStat(final String city, final Integer startDate, final int count) { + return CacheUtils.getValue(this.getClass(), "findNearCityStat",city+"_"+startDate, CachePolicyEnum.LONG, + new Closure, String>() { + @Override + public List execute(String input) { + List q = new ArrayList(5); + q.add(new QueryParam("city", city)); + q.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + + List s = new ArrayList(); + s.add(new SortParam("date", false)); + return citySellStatDao.findAllByParams(q, s, count); + } + }); + } + + @Override + public CitySellStat findStartStat(final String city) { + return CacheUtils.getValue(this.getClass(), "findStartStat",city, CachePolicyEnum.LONG, + new Closure() { + @Override + public CitySellStat execute(String input) { + List q = new ArrayList(5); + q.add(new QueryParam("city", city)); + + List s = new ArrayList(); + s.add(new SortParam("date", true)); + return citySellStatDao.findFirstByParams(q, s); + } + }); + } + + @Override + public List findCityOrderByAvgPrice(final String city, final Integer startDate, final int count) { + List q = new ArrayList(); + if (StringUtils.isNotBlank(city)) { + q.add(new QueryParam("city", city)); + } + q.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + + List s = new ArrayList(); + s.add(new SortParam("avgPrice", false)); + return citySellStatDao.findAllByParams(q, s, count); + } + + @Override + public List findCitySellStat(final String city, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), city, String.valueOf(endDate + startDate), + CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return citySellStatDao.findCitySellStat(city, startDate, endDate); + } + }); + } + } 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 8cdd9018a..406afdada 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 @@ -187,7 +187,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { BooleanQuery nameQuery = new BooleanQuery(); int c = 0; for (String n : names) { - if (StringUtils.isNotBlank(name)) { + if (StringUtils.isNotBlank(n)) { if (name.indexOf("(") > -1 || name.indexOf(")") > -1 || name.indexOf("(") > -1 || name.indexOf(")") > -1 | name.indexOf("[") > -1 || name.indexOf("]") > -1 || name.indexOf("-") > -1 || name.indexOf("{") > -1 || name.indexOf("}") > -1 || name.indexOf("{") > -1 || name.indexOf("}") > -1 || name.indexOf(":") > -1) { @@ -200,9 +200,11 @@ public class CzbankSampleServiceImpl implements CzbankSampleService { break; } } - BooleanQuery srQuery = new BooleanQuery(); - srQuery.add(nameQuery, BooleanClause.Occur.MUST); - houseQuery.add(new QueryParam("$sr", new SrQuery(srQuery))); + if (!nameQuery.clauses().isEmpty()) { + BooleanQuery srQuery = new BooleanQuery(); + srQuery.add(nameQuery, BooleanClause.Occur.MUST); + houseQuery.add(new QueryParam("$sr", new SrQuery(srQuery))); + } List houseSortParams = new ArrayList(); houseSortParams.add(new SortParam("publishDate", false)); houseQuery.add(new QueryParam("category", "shop_sell")); diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RegionSellService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RegionSellService.java new file mode 100644 index 000000000..80f2e360b --- /dev/null +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/datastore/RegionSellService.java @@ -0,0 +1,14 @@ +package com.fangjia.service.datastore; + +import com.fangjia.dal.mongo.model.RegionStat; +import com.fangjia.service.bo.AvgUpdateBo; +import com.fangjia.service.bo.RegionStatBo; +import org.sothis.core.util.Pager; + +import java.util.Date; +import java.util.List; + +public interface RegionSellService { + + +} diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java index 8033d7603..708a8bcca 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatService.java @@ -1,14 +1,38 @@ package com.fangjia.service.mongo.fangjia; +import java.util.Date; import java.util.List; +import com.fangjia.dal.mongo.model.CitySellStat; import com.fangjia.dal.mongo.model.RegionSellStat; +import com.fangjia.dal.mongo.model.RegionStat; public interface RegionSellStatService { - - RegionSellStat findNewestRegionPrice(); - - List findAllRegionPriceByCity(String city, Integer date, String sortField, Boolean sortWay); - RegionSellStat findNewestRegionPrice(String city, String region); + /** + * 获取过去 monCount 个月的数据(不包含本月数据) + * @param city + * @param region + * @param monthCount + * @return + */ + List getAllWithMonths(String city, String region, int monthCount); + + List findNearCityStat(String city, final String region, Integer startDate, int count); + + /** + * 查询均价开始的最早时间 + * @param city + * @return + */ + RegionSellStat findStartStat(String city, final String region); + + RegionSellStat findNewestRegionPrice(); + + List findAllRegionPriceByCity(String city, Integer date, String sortField, Boolean sortWay); + + RegionSellStat findNewestRegionPrice(String city, String region); + + + List findRegionSellStat(final String city, final String region, final Integer startDate, final Integer endDate); } diff --git a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java index 082b5e520..3d3632cf6 100644 --- a/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java +++ b/projects/fangjia-service/src/main/java/com/fangjia/service/mongo/fangjia/RegionSellStatServiceImpl.java @@ -1,65 +1,137 @@ package com.fangjia.service.mongo.fangjia; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import com.fangjia.core.util.CacheUtils; +import com.fangjia.core.util.DateUtil; +import com.fangjia.dal.mongo.model.*; +import com.google.common.collect.ImmutableList; import org.apache.commons.lang.StringUtils; import com.fangjia.dal.QueryParam; import com.fangjia.dal.SortParam; import com.fangjia.dal.mongo.dao.RegionSellStatDao; import com.fangjia.dal.mongo.model.RegionSellStat; +import org.sothis.core.util.Closure; public class RegionSellStatServiceImpl implements RegionSellStatService { - - private RegionSellStatDao regionSellStatDao; - public RegionSellStatDao getRegionSellStatDao() { - return regionSellStatDao; - } + private RegionSellStatDao regionSellStatDao; - public void setRegionSellStatDao(RegionSellStatDao regionSellStatDao) { - this.regionSellStatDao = regionSellStatDao; - } + @Override + public RegionSellStat findNewestRegionPrice() { + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + return regionSellStatDao.findFirstByParams(null, sortParams); + } - @Override - public RegionSellStat findNewestRegionPrice() { - List sortParams = new ArrayList(); - sortParams.add(new SortParam("date", false)); - return regionSellStatDao.findFirstByParams(null, sortParams); - } + @Override + public List findAllRegionPriceByCity(String city, + Integer date, String sortField, Boolean sortWay) { + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("date", date)); - @Override - public List findAllRegionPriceByCity(String city, - Integer date, String sortField, Boolean sortWay) { - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("date", date)); - - List sortParams = new ArrayList(); - if(StringUtils.isNotBlank(sortField)){ - sortParams.add(new SortParam(sortField, sortWay)); - }else{ - sortParams.add(new SortParam("mom", false)); - } - - - return regionSellStatDao.findAllByParams(params, sortParams); - } - - @Override - public RegionSellStat findNewestRegionPrice(String city, String region) { - List params = new ArrayList(); - params.add(new QueryParam("city", city)); - params.add(new QueryParam("region", region)); - - List sortParams = new ArrayList(); - sortParams.add(new SortParam("date", false)); - return regionSellStatDao.findFirstByParams(params, sortParams); - } + List sortParams = new ArrayList(); + if(StringUtils.isNotBlank(sortField)){ + sortParams.add(new SortParam(sortField, sortWay)); + }else{ + sortParams.add(new SortParam("mom", false)); + } - - + return regionSellStatDao.findAllByParams(params, sortParams); + } + @Override + public RegionSellStat findNewestRegionPrice(String city, String region) { + List params = new ArrayList(); + params.add(new QueryParam("city", city)); + params.add(new QueryParam("region", region)); + + List sortParams = new ArrayList(); + sortParams.add(new SortParam("date", false)); + return regionSellStatDao.findFirstByParams(params, sortParams); + } + + + + @Override + public List getAllWithMonths(final String city, final String region, final int monthCount) { + return CacheUtils.getValue(this.getClass(), "getAllWithMonths",city+"_"+monthCount, CacheUtils.CachePolicyEnum.LONG, + new Closure, String>() { + @Override + public List execute(String input) { + System.out.println("getAllWithMonths"); + Date now = new Date(); + Date lastMonth = DateUtil.getBeforeDate(now, -1); + Date monthInLastYear = DateUtil.getBeforeDate(now, -1 * monthCount); + int lastMonthNum = DateUtil.getYear(lastMonth) * 100 + DateUtil.getMonth(lastMonth); + int monthInLastYearNum = DateUtil.getYear(monthInLastYear) * 100 + DateUtil.getMonth(monthInLastYear); + + List queryParams = ImmutableList.of( + new QueryParam("city", city), + new QueryParam("region", region), + new QueryParam("date", QueryParam.LESS_THAN_EQUAL_OPERATOR, lastMonthNum), + new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, monthInLastYearNum) + ); + List sortParams = ImmutableList.of( + new SortParam("date", false) + ); + return regionSellStatDao.findAllByParams(queryParams, sortParams); + } + }); + + } + + @Override + public List findNearCityStat(final String city, final String region, final Integer startDate, final int count) { + return CacheUtils.getValue(this.getClass(), "findNearRegionStat",city+"_"+startDate, CacheUtils.CachePolicyEnum.LONG, + new Closure, String>() { + @Override + public List execute(String input) { + List q = new ArrayList(5); + q.add(new QueryParam("city", city)); + q.add(new QueryParam("region", region)); + q.add(new QueryParam("date", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate)); + + List s = new ArrayList(); + s.add(new SortParam("date", false)); + return regionSellStatDao.findAllByParams(q, s, count); + } + }); + } + + @Override + public RegionSellStat findStartStat(final String city, final String region) { + return CacheUtils.getValue(this.getClass(), "findStartStat",city, CacheUtils.CachePolicyEnum.LONG, + new Closure() { + @Override + public RegionSellStat execute(String input) { + List q = new ArrayList(5); + q.add(new QueryParam("city", city)); + q.add(new QueryParam("region", region)); + + List s = new ArrayList(); + s.add(new SortParam("date", true)); + return regionSellStatDao.findFirstByParams(q, s); + } + }); + } + + @Override + public List findRegionSellStat(final String city, final String region, final Integer startDate, final Integer endDate) { + return CacheUtils.getValue(this.getClass(), city, String.valueOf(endDate + startDate), + CacheUtils.CachePolicyEnum.MIDDLE, new Closure, String>() { + public List execute(String input) { + return regionSellStatDao.findRegionSellStat(city, region, startDate, endDate); + } + }); + } + + public void setRegionSellStatDao(RegionSellStatDao regionSellStatDao) { + this.regionSellStatDao = regionSellStatDao; + } }