改造估值也城市均价

This commit is contained in:
沈健
2025-06-13 15:13:00 +08:00
parent 89f03f5301
commit 28eed814f7
5 changed files with 62 additions and 30 deletions
@@ -28,6 +28,8 @@ 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 net.sf.json.JSONObject;
import org.apache.commons.codec.digest.DigestUtils;
@@ -105,19 +107,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 +134,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;
@@ -212,6 +191,7 @@ public class EvaluationController {
private SnapDataService snapDataService;
private HouseService houseService;
private RegionStatService regionStatService;
private CitySellStatService citySellStatService;
private MenuService menuService;
private CpcService cpcService;
private DistrictStatRentService districtStatRentService;
@@ -3626,23 +3606,28 @@ public Object checkUserAction(EvaluationModel model, HttpServletRequest req, Htt
private Map<String,Integer> buildStatJson(String city, String region, String block, Date startDate) {
List<RegionStat> regionStatList = null;
List<CitySellStat> citySellStats = null;
Map<String, String> oprions = new HashMap<String, String>();
Date currentDate = new Date();
if (city != null && region != null) {
regionStatList = regionStatService.findRegionStat(city, region, null, startDate, currentDate);
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<String,Integer> map = new HashMap<String,Integer>();
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());
}
}
return map;
}
@@ -4749,5 +4734,8 @@ public Object checkUserAction(EvaluationModel model, HttpServletRequest req, Htt
public void setIpCountService(IpCountService ipCountService) {
this.ipCountService = ipCountService;
}
public void setCitySellStatService(CitySellStatService citySellStatService) {
this.citySellStatService = citySellStatService;
}
}
@@ -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<CitySellStat> {
List<CitySellStat> findCitySellStat(String city, Integer startDate, Integer endDate);
}
@@ -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<CitySellStat> implements CitySellStatDao {
@Override
public List<CitySellStat> findCitySellStat(String city, Integer startDate, Integer endDate) {
List<QueryParam> params = new ArrayList<QueryParam>();
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<SortParam> sortParms = new ArrayList<SortParam>(1);
sortParms.add(new SortParam("date", true));
List<CitySellStat> statList = findAllByParams(params, sortParms);
return statList;
}
}
@@ -45,4 +45,7 @@ public interface CitySellStatService {
CitySellStat findStartStat(String city);
List<CitySellStat> findCityOrderByAvgPrice(final String city, final Integer startDate, final int count) ;
List<CitySellStat> findCitySellStat(String city, Integer startDate, Integer endDate);
}
@@ -11,6 +11,7 @@ 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;
@@ -150,4 +151,14 @@ public class CitySellStatServiceImpl implements CitySellStatService {
return citySellStatDao.findAllByParams(q, s, count);
}
@Override
public List<CitySellStat> findCitySellStat(final String city, final Integer startDate, final Integer endDate) {
return CacheUtils.getValue(this.getClass(), city, String.valueOf(endDate + startDate),
CachePolicyEnum.MIDDLE, new Closure<List<CitySellStat>, String>() {
public List<CitySellStat> execute(String input) {
return citySellStatDao.findCitySellStat(city, startDate, endDate);
}
});
}
}