房产top统计
This commit is contained in:
+15
@@ -1,6 +1,7 @@
|
||||
package com.fangjia.job.fsh.document;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
@@ -178,6 +179,12 @@ public class EnterpriseStat {
|
||||
@Field(value="m_date")
|
||||
private Date modifyDate;
|
||||
|
||||
/**
|
||||
* 城市房产数量TOP 10 key:上海 value:1000
|
||||
*/
|
||||
@Field(value="city_house_top")
|
||||
private Map<String, Long> cityHouseTop;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -402,4 +409,12 @@ public class EnterpriseStat {
|
||||
this.modifyDate = modifyDate;
|
||||
}
|
||||
|
||||
public Map<String, Long> getCityHouseTop() {
|
||||
return cityHouseTop;
|
||||
}
|
||||
|
||||
public void setCityHouseTop(Map<String, Long> cityHouseTop) {
|
||||
this.cityHouseTop = cityHouseTop;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -116,7 +116,8 @@ public class EnterpriseStatJob implements SimpleJob {
|
||||
stat.setTerdayAddHousePrice(houseInfoService.queryHouseSumMoney(eid, start, end));
|
||||
stat.setHouseCount(houseInfoService.queryHouseAllCount(eid));
|
||||
stat.setHouseTotalPrice(houseInfoService.queryHouseAllSumMoney(eid));
|
||||
|
||||
stat.setCityHouseTop(houseInfoService.queryHouseCountGroupByCity(eid, 10));
|
||||
|
||||
if (stat.getTotalUserCount() > 0) {
|
||||
double avgHouseCount = stat.getHouseCount() / stat.getTotalUserCount();
|
||||
stat.setAvgHouseCount(avgHouseCount);
|
||||
|
||||
+10
@@ -1,5 +1,7 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface HouseInfoService {
|
||||
|
||||
/**
|
||||
@@ -58,4 +60,12 @@ public interface HouseInfoService {
|
||||
*/
|
||||
Double querySumMoneyByEidAndUid(Long eid, String uid);
|
||||
|
||||
/**
|
||||
* 分组统计企业下的各城市对应的房产数量Top
|
||||
* @param eid
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
Map<String, Long> queryHouseCountGroupByCity(Long eid, int limit);
|
||||
|
||||
}
|
||||
|
||||
+16
@@ -1,6 +1,11 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.fsh.po.HouseInfo;
|
||||
|
||||
@@ -60,4 +65,15 @@ public class HouseInfoServiceImpl extends EntityService<HouseInfo> implements Ho
|
||||
return sum / 10000.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Long> queryHouseCountGroupByCity(Long eid, int limit) {
|
||||
Map<String, Long> result = new TreeMap<String, Long>();
|
||||
String sql = "select city,count(id) as count from house_info where eid = ? GROUP BY city ORDER BY count desc LIMIT ?";
|
||||
List<Map<String, Object>> list = super.getJdbcTemplate().queryForList(sql, new Object[] { eid, limit });
|
||||
for (Map<String, Object> map : list) {
|
||||
result.put(map.get("city").toString(), Long.parseLong(map.get("count").toString()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user