+26
@@ -0,0 +1,26 @@
|
||||
package com.fangjia.job.common.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class DataUtil {
|
||||
|
||||
public static double getDoubleRound(int scale, double dSource) {
|
||||
BigDecimal deSource = new BigDecimal(dSource);
|
||||
return deSource.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 求最大公约数
|
||||
* @param m
|
||||
* @param n
|
||||
* @return
|
||||
*/
|
||||
public static int divisor(int m,int n) {
|
||||
if (m % n == 0) {
|
||||
return n;
|
||||
} else {
|
||||
return divisor(n,m % n);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+40
-1
@@ -1,7 +1,10 @@
|
||||
package com.fangjia.job.common.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@@ -56,7 +59,43 @@ public class DateUtilCustom {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取近几天的时间范围
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, String> getLatelyDate(int days) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
DateTime dt = new DateTime();
|
||||
// 昨天
|
||||
DateTime yesterday = dt.minusDays(days);
|
||||
String start = yesterday.toString("yyyy-MM-dd") + " 00:00:00";
|
||||
String end = dt.toString("yyyy-MM-dd") + " 00:00:00";
|
||||
map.put("start", start);
|
||||
map.put("end", end);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日期格式化
|
||||
* @param date
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
public static String formatByPattern(Date date, String pattern) {
|
||||
if (date == null)
|
||||
return "";
|
||||
String result = "";
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat(pattern);
|
||||
result = format.format(date);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
getTopMonth();
|
||||
System.err.println(JsonUtils.toJson(getLatelyDate(3)));
|
||||
}
|
||||
}
|
||||
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
package com.fangjia.job.fsh.document;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
/**
|
||||
* 理财和贷款潜客统计
|
||||
* @author yinjihuan
|
||||
*/
|
||||
@Document(collection="customer_stat")
|
||||
public class CustomerStat {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 企业编号
|
||||
*/
|
||||
@Field(value="eid")
|
||||
private Long eid;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Field(value="uid")
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
@Field(value="city")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 区域
|
||||
*/
|
||||
@Field(value="region")
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* 房产总数量
|
||||
*/
|
||||
@Field(value="h_count")
|
||||
private Long houseCount;
|
||||
|
||||
/**
|
||||
* 房产总价格(万元)
|
||||
*/
|
||||
@Field(value="h_price")
|
||||
private Double housePrice;
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
@Field(value="level")
|
||||
private int level;
|
||||
|
||||
/**
|
||||
* 类型 1理财或者2贷款
|
||||
*/
|
||||
@Field(value="type")
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Field(value="c_date")
|
||||
private Date createDate;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getEid() {
|
||||
return eid;
|
||||
}
|
||||
|
||||
public void setEid(Long eid) {
|
||||
this.eid = eid;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
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 Long getHouseCount() {
|
||||
return houseCount;
|
||||
}
|
||||
|
||||
public void setHouseCount(Long houseCount) {
|
||||
this.houseCount = houseCount;
|
||||
}
|
||||
|
||||
public Double getHousePrice() {
|
||||
return housePrice;
|
||||
}
|
||||
|
||||
public void setHousePrice(Double housePrice) {
|
||||
this.housePrice = housePrice;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
}
|
||||
+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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.fangjia.job.fsh.document;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
/**
|
||||
* 页面访问统计
|
||||
* @author yinjihuan
|
||||
*/
|
||||
@Document(collection="page_stat")
|
||||
public class PageStat {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 企业编号
|
||||
*/
|
||||
@Field(value="eid")
|
||||
private Long eid;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
@Field(value="city")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 页面地址
|
||||
*/
|
||||
@Field(value="uri")
|
||||
private String uri;
|
||||
|
||||
@Field(value="uv")
|
||||
private Long uv;
|
||||
|
||||
@Field(value="pv")
|
||||
private Long pv;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Field(value="c_date")
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 格式化的时间,分组用
|
||||
*/
|
||||
@Field(value="f_date")
|
||||
private String formatDate;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getEid() {
|
||||
return eid;
|
||||
}
|
||||
|
||||
public void setEid(Long eid) {
|
||||
this.eid = eid;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public Long getUv() {
|
||||
return uv;
|
||||
}
|
||||
|
||||
public void setUv(Long uv) {
|
||||
this.uv = uv;
|
||||
}
|
||||
|
||||
public Long getPv() {
|
||||
return pv;
|
||||
}
|
||||
|
||||
public void setPv(Long pv) {
|
||||
this.pv = pv;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public String getFormatDate() {
|
||||
return formatDate;
|
||||
}
|
||||
|
||||
public void setFormatDate(String formatDate) {
|
||||
this.formatDate = formatDate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.fangjia.job.fsh.document;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
+42
-1
@@ -1,9 +1,11 @@
|
||||
package com.fangjia.job.fsh.job;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,6 +17,7 @@ import com.fangjia.job.common.util.DateUtilCustom;
|
||||
import com.fangjia.job.common.util.DingDingMessageUtil;
|
||||
import com.fangjia.job.fsh.document.EnterpriseStat;
|
||||
import com.fangjia.job.fsh.document.HouseStatus;
|
||||
import com.fangjia.job.fsh.document.PageStat;
|
||||
import com.fangjia.job.fsh.po.Enterprise;
|
||||
import com.fangjia.job.fsh.service.AdVisitLogService;
|
||||
import com.fangjia.job.fsh.service.EnterpriseProductUserService;
|
||||
@@ -22,6 +25,7 @@ import com.fangjia.job.fsh.service.EnterpriseService;
|
||||
import com.fangjia.job.fsh.service.EnterpriseStatService;
|
||||
import com.fangjia.job.fsh.service.HouseInfoService;
|
||||
import com.fangjia.job.fsh.service.LoanApplyService;
|
||||
import com.fangjia.job.fsh.service.PageStatService;
|
||||
import com.fangjia.job.fsh.service.VisitLogService;
|
||||
|
||||
/**
|
||||
@@ -54,6 +58,9 @@ public class EnterpriseStatJob implements SimpleJob {
|
||||
@Autowired
|
||||
private HouseInfoService houseInfoService;
|
||||
|
||||
@Autowired
|
||||
private PageStatService pageStatService;
|
||||
|
||||
@Override
|
||||
public void execute(ShardingContext shardingContext) {
|
||||
logger.info("开始执行EnterpriseStatJob");
|
||||
@@ -70,6 +77,10 @@ public class EnterpriseStatJob implements SimpleJob {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//按天统计某企业访问不同城市不同页面的pv及uv
|
||||
processPageStat();
|
||||
|
||||
logger.info("EnterpriseStatJob执行结束");
|
||||
}
|
||||
|
||||
@@ -116,7 +127,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);
|
||||
@@ -137,4 +149,33 @@ public class EnterpriseStatJob implements SimpleJob {
|
||||
enterpriseStatService.save(stat);
|
||||
}
|
||||
|
||||
|
||||
private void processPageStat(){
|
||||
|
||||
Date date = new Date();
|
||||
String fDate = DateUtilCustom.formatByPattern(date, "yyyy-MM-dd");
|
||||
//删除老数据
|
||||
pageStatService.deleteByParams(fDate);
|
||||
|
||||
Map<String, String> dateMap = DateUtilCustom.getYesterday();
|
||||
String start = dateMap.get("start");
|
||||
String end = dateMap.get("end");
|
||||
List<Map<String, Object>> result = visitLogService.queryPvList(start, end);
|
||||
if(result.size() > 0){
|
||||
List<PageStat> list = new ArrayList<PageStat>();
|
||||
for(Map<String, Object> m : result){
|
||||
PageStat stat = new PageStat();
|
||||
stat.setCity((String) m.get("city"));
|
||||
stat.setEid((Long) m.get("eid"));
|
||||
stat.setUri((String) m.get("uri"));
|
||||
stat.setPv((Long) m.get("pv"));
|
||||
stat.setUv((Long) m.get("uv"));
|
||||
stat.setCreateDate(date);
|
||||
stat.setFormatDate(fDate);
|
||||
list.add(stat);
|
||||
}
|
||||
pageStatService.saveAll(list);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,13 +10,21 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.cxytiandi.jdbc.util.PageBean;
|
||||
import com.dangdang.ddframe.job.api.ShardingContext;
|
||||
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||
import com.fangjia.job.common.util.DataUtil;
|
||||
import com.fangjia.job.common.util.DingDingMessageUtil;
|
||||
import com.fangjia.job.fsh.document.UserStat;
|
||||
import com.fangjia.job.fsh.po.EnterpriseProductUser;
|
||||
import com.fangjia.job.fsh.po.FinancialCustomersConfig;
|
||||
import com.fangjia.job.fsh.po.LoanCustomersConfig;
|
||||
import com.fangjia.job.fsh.po.PotentialCustomersFilterConfig;
|
||||
import com.fangjia.job.fsh.service.CustomerStatService;
|
||||
import com.fangjia.job.fsh.service.EnterpriseProductUserService;
|
||||
import com.fangjia.job.fsh.service.FinancialCustomersConfigService;
|
||||
import com.fangjia.job.fsh.service.HouseInfoService;
|
||||
import com.fangjia.job.fsh.service.HouseSubstitutionService;
|
||||
import com.fangjia.job.fsh.service.LoanApplyService;
|
||||
import com.fangjia.job.fsh.service.LoanCustomersConfigService;
|
||||
import com.fangjia.job.fsh.service.PotentialCustomersFilterConfigService;
|
||||
import com.fangjia.job.fsh.service.UserStatService;
|
||||
|
||||
/**
|
||||
@@ -42,9 +50,29 @@ public class UserStatJob implements SimpleJob {
|
||||
@Autowired
|
||||
private LoanApplyService loanApplyService;
|
||||
|
||||
@Autowired
|
||||
private CustomerStatService customerStatService;
|
||||
|
||||
@Autowired
|
||||
private PotentialCustomersFilterConfigService potentialCustomersFilterConfigService;
|
||||
|
||||
@Autowired
|
||||
private FinancialCustomersConfigService financialCustomersConfigService;
|
||||
|
||||
@Autowired
|
||||
private LoanCustomersConfigService loanCustomersConfigService;
|
||||
|
||||
@Override
|
||||
public void execute(ShardingContext shardingContext) {
|
||||
logger.info("开始执行UserStatJob");
|
||||
// 理财潜客过滤条件
|
||||
PotentialCustomersFilterConfig financiaFilterConfig = potentialCustomersFilterConfigService.get(1);
|
||||
// 贷款潜客过滤条件
|
||||
PotentialCustomersFilterConfig loanFilterConfig = potentialCustomersFilterConfigService.get(2);
|
||||
// 理财潜客分析条件
|
||||
List<FinancialCustomersConfig> financialCustomersList = financialCustomersConfigService.queryAll();
|
||||
// 贷款潜客分析条件
|
||||
List<LoanCustomersConfig> LoanCustomersConfigList = loanCustomersConfigService.queryAll();
|
||||
long total = enterpriseProductUserService.queryCount();
|
||||
int pages = PageBean.calcPages(total, 1000);
|
||||
for (int i = 1; i <= pages; i++) {
|
||||
@@ -52,6 +80,9 @@ public class UserStatJob implements SimpleJob {
|
||||
for (EnterpriseProductUser user : users) {
|
||||
try {
|
||||
processStat(user);
|
||||
|
||||
// 理财和贷款潜客统计
|
||||
customerStatService.customerStat(user, financiaFilterConfig, loanFilterConfig, financialCustomersList, LoanCustomersConfigList);
|
||||
} catch (Exception e) {
|
||||
logger.error("用户维度统计任务异常", e);
|
||||
DingDingMessageUtil.sendTextMessage("用户维度统计任务异常:" + e.getMessage());
|
||||
@@ -74,7 +105,8 @@ public class UserStatJob implements SimpleJob {
|
||||
stat.setRegion(user.getRegion());
|
||||
}
|
||||
stat.setHouseCount(houseInfoService.queryCountByEidAndUid(eid, uid));
|
||||
stat.setHousePrice(houseInfoService.querySumMoneyByEidAndUid(eid, uid));
|
||||
Double totalPrice = houseInfoService.querySumMoneyByEidAndUid(eid, uid);
|
||||
stat.setHousePrice(totalPrice > 0 ? DataUtil.getDoubleRound(2, totalPrice) : totalPrice);
|
||||
stat.setSubstitutionCount(houseSubstitutionService.queryCount(eid, uid));
|
||||
stat.setSubstitutionMaxPrice(houseSubstitutionService.queryMaxBudget(eid, uid));
|
||||
stat.setLoanEvalCount(loanApplyService.queryUserCountByType(eid, uid, 2));
|
||||
|
||||
@@ -32,7 +32,7 @@ public class AdVisitLog implements Serializable {
|
||||
@Field(value="adid", desc="广告ID")
|
||||
private Long adid;
|
||||
|
||||
@Field(value="ad_position", desc="AdvertisementPositionEnum-广告位(0:我的房产-投资收益-底部, 1:我的房产-均价排名-底部, 2:我的房产-租售比-底部,3:我的房产-流动性评级-底部, 4:我的房产-均价相似小区-底部, 5:我的房产-位置及周边-底部, 6:以房换钱, 7:以房换房-小区位置及周边-底部)")
|
||||
@Field(value="ad_position", desc="广告位(0:房产分析/出租管理-租金回报率, 1:房产分析/出租管理-出租状态, 2:出售分析-增长率收益,3:出售分析-挂牌建议, 4:置换建议-小区详情-顶部描述)")
|
||||
private int adPosition = -1;
|
||||
|
||||
public int getAdPosition() {
|
||||
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
package com.fangjia.job.fsh.po;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.cxytiandi.jdbc.annotation.AutoId;
|
||||
import com.cxytiandi.jdbc.annotation.Field;
|
||||
import com.cxytiandi.jdbc.annotation.TableName;
|
||||
|
||||
@TableName(value = "financial_customers_config", author = "yinjihuan", desc = "理财潜在客户设置表")
|
||||
public class FinancialCustomersConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1463438428120590218L;
|
||||
|
||||
@AutoId
|
||||
@Field(value="id", desc="ID")
|
||||
private Long id;
|
||||
|
||||
@Field(value="star_level", desc="星级(1就代表1星)")
|
||||
private int starLevel;
|
||||
|
||||
@Field(value="analy_time", desc="分析时间(近N天)")
|
||||
private int analyTime;
|
||||
|
||||
@Field(value="ad_click_rate", desc="理财广告点击率(大于%之多少)")
|
||||
private int adClickRate;
|
||||
|
||||
@Field(value="house_count_rank", desc="房产数量排名(大于N套)")
|
||||
private int houseCountRank;
|
||||
|
||||
@Field(value="house_price_rank", desc="房产价值排名(大于%之多少)")
|
||||
private int housePriceRank;
|
||||
|
||||
@Field(value="house_analy_pv", desc="房产分析PV(大于多少)")
|
||||
private int houseAnalyPv;
|
||||
|
||||
@Field(value="sale_analy_pv", desc="出售分析PV(大于多少)")
|
||||
private int saleAnalyPv;
|
||||
|
||||
@Field(value="rent_manager_pv", desc="出租管理PV(大于多少)")
|
||||
private int rentManagerPv;
|
||||
|
||||
@Field(value="modify_time", desc="修改时间")
|
||||
private Date modifyTime;
|
||||
|
||||
@Field(value="modify_user", desc="修改用户ID")
|
||||
private Long modifyUser;
|
||||
|
||||
@Field(value="house_level", desc="房产评级(1:豪宅级、2:公寓级、3:平房级、4:草屋级、5:山洞级)")
|
||||
private int houseLevel;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getStarLevel() {
|
||||
return starLevel;
|
||||
}
|
||||
|
||||
public void setStarLevel(int starLevel) {
|
||||
this.starLevel = starLevel;
|
||||
}
|
||||
|
||||
public int getAnalyTime() {
|
||||
return analyTime;
|
||||
}
|
||||
|
||||
public void setAnalyTime(int analyTime) {
|
||||
this.analyTime = analyTime;
|
||||
}
|
||||
|
||||
public int getAdClickRate() {
|
||||
return adClickRate;
|
||||
}
|
||||
|
||||
public void setAdClickRate(int adClickRate) {
|
||||
this.adClickRate = adClickRate;
|
||||
}
|
||||
|
||||
public int getHouseCountRank() {
|
||||
return houseCountRank;
|
||||
}
|
||||
|
||||
public void setHouseCountRank(int houseCountRank) {
|
||||
this.houseCountRank = houseCountRank;
|
||||
}
|
||||
|
||||
public int getHousePriceRank() {
|
||||
return housePriceRank;
|
||||
}
|
||||
|
||||
public void setHousePriceRank(int housePriceRank) {
|
||||
this.housePriceRank = housePriceRank;
|
||||
}
|
||||
|
||||
public int getHouseAnalyPv() {
|
||||
return houseAnalyPv;
|
||||
}
|
||||
|
||||
public void setHouseAnalyPv(int houseAnalyPv) {
|
||||
this.houseAnalyPv = houseAnalyPv;
|
||||
}
|
||||
|
||||
public int getSaleAnalyPv() {
|
||||
return saleAnalyPv;
|
||||
}
|
||||
|
||||
public void setSaleAnalyPv(int saleAnalyPv) {
|
||||
this.saleAnalyPv = saleAnalyPv;
|
||||
}
|
||||
|
||||
public int getRentManagerPv() {
|
||||
return rentManagerPv;
|
||||
}
|
||||
|
||||
public void setRentManagerPv(int rentManagerPv) {
|
||||
this.rentManagerPv = rentManagerPv;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Long getModifyUser() {
|
||||
return modifyUser;
|
||||
}
|
||||
|
||||
public void setModifyUser(Long modifyUser) {
|
||||
this.modifyUser = modifyUser;
|
||||
}
|
||||
|
||||
public int getHouseLevel() {
|
||||
return houseLevel;
|
||||
}
|
||||
|
||||
public void setHouseLevel(int houseLevel) {
|
||||
this.houseLevel = houseLevel;
|
||||
}
|
||||
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package com.fangjia.job.fsh.po;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.cxytiandi.jdbc.annotation.AutoId;
|
||||
import com.cxytiandi.jdbc.annotation.Field;
|
||||
import com.cxytiandi.jdbc.annotation.TableName;
|
||||
|
||||
@TableName(value = "loan_customers_config", author = "yinjihuan", desc = "贷款潜在客户设置表")
|
||||
public class LoanCustomersConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -300390333187645627L;
|
||||
|
||||
@AutoId
|
||||
@Field(value="id", desc="ID")
|
||||
private Long id;
|
||||
|
||||
@Field(value="analy_time", desc="分析时间(近N天)")
|
||||
private int analyTime;
|
||||
|
||||
@Field(value="ad_click_rate", desc="贷款广告点击率(大于%之多少)")
|
||||
private int adClickRate;
|
||||
|
||||
@Field(value="loan_eval_count", desc="贷款评估次数(大于多少次)")
|
||||
private int loanEvalCount;
|
||||
|
||||
@Field(value="loan_eval_pv", desc="贷款评估PV(大于多少次)")
|
||||
private int loanEvalPv;
|
||||
|
||||
@Field(value="loan_apply_pv", desc="贷款申请PV(大于多少次)")
|
||||
private int loanApplyPv;
|
||||
|
||||
@Field(value="loan_index_page_pv", desc="我要贷款首页PV(大于多少)")
|
||||
private int loanIndexPagePv;
|
||||
|
||||
@Field(value="sub_index_page_pv", desc="我要置换首页PV(大于多少)")
|
||||
private int subIndexPagePv;
|
||||
|
||||
@Field(value="rent_manager_pv", desc="出租管理PV(大于多少)")
|
||||
private int rentManagerPv;
|
||||
|
||||
@Field(value="sale_analy_pv", desc="出售分析PV(大于多少)")
|
||||
private int saleAnalyPv;
|
||||
|
||||
@Field(value="star_level", desc="星级(1就代表1星)")
|
||||
private int starLevel;
|
||||
|
||||
@Field(value="modify_time", desc="修改时间")
|
||||
private Date modifyTime;
|
||||
|
||||
@Field(value="modify_user", desc="修改用户ID")
|
||||
private Long modifyUser;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getAnalyTime() {
|
||||
return analyTime;
|
||||
}
|
||||
|
||||
public void setAnalyTime(int analyTime) {
|
||||
this.analyTime = analyTime;
|
||||
}
|
||||
|
||||
public int getAdClickRate() {
|
||||
return adClickRate;
|
||||
}
|
||||
|
||||
public void setAdClickRate(int adClickRate) {
|
||||
this.adClickRate = adClickRate;
|
||||
}
|
||||
|
||||
public int getLoanEvalCount() {
|
||||
return loanEvalCount;
|
||||
}
|
||||
|
||||
public void setLoanEvalCount(int loanEvalCount) {
|
||||
this.loanEvalCount = loanEvalCount;
|
||||
}
|
||||
|
||||
public int getLoanEvalPv() {
|
||||
return loanEvalPv;
|
||||
}
|
||||
|
||||
public void setLoanEvalPv(int loanEvalPv) {
|
||||
this.loanEvalPv = loanEvalPv;
|
||||
}
|
||||
|
||||
public int getLoanApplyPv() {
|
||||
return loanApplyPv;
|
||||
}
|
||||
|
||||
public void setLoanApplyPv(int loanApplyPv) {
|
||||
this.loanApplyPv = loanApplyPv;
|
||||
}
|
||||
|
||||
public int getLoanIndexPagePv() {
|
||||
return loanIndexPagePv;
|
||||
}
|
||||
|
||||
public void setLoanIndexPagePv(int loanIndexPagePv) {
|
||||
this.loanIndexPagePv = loanIndexPagePv;
|
||||
}
|
||||
|
||||
public int getSubIndexPagePv() {
|
||||
return subIndexPagePv;
|
||||
}
|
||||
|
||||
public void setSubIndexPagePv(int subIndexPagePv) {
|
||||
this.subIndexPagePv = subIndexPagePv;
|
||||
}
|
||||
|
||||
public int getRentManagerPv() {
|
||||
return rentManagerPv;
|
||||
}
|
||||
|
||||
public void setRentManagerPv(int rentManagerPv) {
|
||||
this.rentManagerPv = rentManagerPv;
|
||||
}
|
||||
|
||||
public int getSaleAnalyPv() {
|
||||
return saleAnalyPv;
|
||||
}
|
||||
|
||||
public void setSaleAnalyPv(int saleAnalyPv) {
|
||||
this.saleAnalyPv = saleAnalyPv;
|
||||
}
|
||||
|
||||
public int getStarLevel() {
|
||||
return starLevel;
|
||||
}
|
||||
|
||||
public void setStarLevel(int starLevel) {
|
||||
this.starLevel = starLevel;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Long getModifyUser() {
|
||||
return modifyUser;
|
||||
}
|
||||
|
||||
public void setModifyUser(Long modifyUser) {
|
||||
this.modifyUser = modifyUser;
|
||||
}
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.fangjia.job.fsh.po;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.cxytiandi.jdbc.annotation.AutoId;
|
||||
import com.cxytiandi.jdbc.annotation.Field;
|
||||
import com.cxytiandi.jdbc.annotation.TableName;
|
||||
|
||||
@TableName(value = "potential_customers_filter_config", author = "yinjihuan", desc = "贷款理财潜在客户过滤条件设置表")
|
||||
public class PotentialCustomersFilterConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 395735765985199357L;
|
||||
|
||||
@AutoId
|
||||
@Field(value="id", desc="ID")
|
||||
private Long id;
|
||||
|
||||
@Field(value="analy_time", desc="分析时间(近多少天)")
|
||||
private int analyTime;
|
||||
|
||||
@Field(value="all_page_visit", desc="所有页面浏览(访问较频繁),大于多少次")
|
||||
private int allPageVisit;
|
||||
|
||||
@Field(value="house_count", desc="房产数量,含删除(大于多少套)")
|
||||
private int houseCount;
|
||||
|
||||
@Field(value="type", desc="类型(1:理财潜客设置 2:贷款潜客设置)")
|
||||
private int type;
|
||||
|
||||
@Field(value="modify_time", desc="修改时间")
|
||||
private Date modifyTime;
|
||||
|
||||
@Field(value="modify_user", desc="修改用户ID")
|
||||
private Long modifyUser;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getAnalyTime() {
|
||||
return analyTime;
|
||||
}
|
||||
|
||||
public void setAnalyTime(int analyTime) {
|
||||
this.analyTime = analyTime;
|
||||
}
|
||||
|
||||
public int getAllPageVisit() {
|
||||
return allPageVisit;
|
||||
}
|
||||
|
||||
public void setAllPageVisit(int allPageVisit) {
|
||||
this.allPageVisit = allPageVisit;
|
||||
}
|
||||
|
||||
public int getHouseCount() {
|
||||
return houseCount;
|
||||
}
|
||||
|
||||
public void setHouseCount(int houseCount) {
|
||||
this.houseCount = houseCount;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Long getModifyUser() {
|
||||
return modifyUser;
|
||||
}
|
||||
|
||||
public void setModifyUser(Long modifyUser) {
|
||||
this.modifyUser = modifyUser;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,9 @@ public class VisitLog implements Serializable {
|
||||
@Field(value="ip", desc="用户IP")
|
||||
private String ip;
|
||||
|
||||
@Field(value="city", desc="根据IP定位的城市")
|
||||
private String city;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -91,6 +94,15 @@ public class VisitLog implements Serializable {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
|
||||
public static Orders[] id_orders = new Orders[] { new Orders("id", Orders.OrderyType.DESC)};
|
||||
|
||||
public static String[] query_params = new String[] { "eid", "uid" };
|
||||
|
||||
+13
@@ -1,5 +1,7 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AdVisitLogService {
|
||||
|
||||
/**
|
||||
@@ -20,4 +22,15 @@ public interface AdVisitLogService {
|
||||
*/
|
||||
long queryUvCount(Long eid, String start, String end);
|
||||
|
||||
/**
|
||||
* 查询用户的广告点击次数
|
||||
* @param eid 企业ID
|
||||
* @param uid 用户ID
|
||||
* @param adPositions 广告位集合
|
||||
* @param start 开始时间
|
||||
* @param end 结束时间
|
||||
* @return
|
||||
*/
|
||||
long queryPvCount(Long eid, String uid, List<Integer> adPositions, String start, String end);
|
||||
|
||||
}
|
||||
|
||||
+25
@@ -1,5 +1,9 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.fsh.po.AdVisitLog;
|
||||
@@ -18,5 +22,26 @@ public class AdVisitLogServiceImpl extends EntityService<AdVisitLog> implements
|
||||
String sql = "select count(distinct(uid)) from ad_visit_log where eid = ? and visit_time between ? and ?";
|
||||
return super.count(sql, new Object[] { eid, start, end });
|
||||
}
|
||||
|
||||
@Override
|
||||
public long queryPvCount(Long eid, String uid, List<Integer> adPositions, String start, String end) {
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
StringBuilder sql = new StringBuilder("select count(id) from ad_visit_log where eid = ? and uid = ?");
|
||||
params.add(eid);
|
||||
params.add(uid);
|
||||
sql.append(" and ad_position in (");
|
||||
for (Integer poi : adPositions) {
|
||||
sql.append("?,");
|
||||
params.add(poi);
|
||||
}
|
||||
sql.delete(sql.length() - 1, sql.length());
|
||||
sql.append(")");
|
||||
if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) {
|
||||
sql.append(" and visit_time between ? and ?");
|
||||
params.add(start);
|
||||
params.add(end);
|
||||
}
|
||||
return super.count(sql.toString(), params.toArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.job.fsh.po.EnterpriseProductUser;
|
||||
import com.fangjia.job.fsh.po.FinancialCustomersConfig;
|
||||
import com.fangjia.job.fsh.po.LoanCustomersConfig;
|
||||
import com.fangjia.job.fsh.po.PotentialCustomersFilterConfig;
|
||||
|
||||
public interface CustomerStatService {
|
||||
|
||||
/**
|
||||
* 删除潜在客户统计信息
|
||||
* @param eid
|
||||
* @param uid
|
||||
*/
|
||||
void removeCustomerStat(Long eid, String uid);
|
||||
|
||||
/**
|
||||
* 理财和贷款潜客统计
|
||||
* @param user 用户信息
|
||||
* @param financiaFilterConfig 理财潜客过滤条件
|
||||
* @param loanFilterConfig 贷款潜客过滤条件
|
||||
* @param financialCustomersList 理财潜客分析条件
|
||||
* @param loanCustomersConfigList 贷款潜客分析条件
|
||||
*/
|
||||
void customerStat(EnterpriseProductUser user,
|
||||
PotentialCustomersFilterConfig financiaFilterConfig,
|
||||
PotentialCustomersFilterConfig loanFilterConfig,
|
||||
List<FinancialCustomersConfig> financialCustomersList,
|
||||
List<LoanCustomersConfig> loanCustomersConfigList);
|
||||
|
||||
}
|
||||
+446
@@ -0,0 +1,446 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fangjia.job.common.util.DateUtilCustom;
|
||||
import com.fangjia.job.fsh.document.CustomerStat;
|
||||
import com.fangjia.job.fsh.po.EnterpriseProductUser;
|
||||
import com.fangjia.job.fsh.po.FinancialCustomersConfig;
|
||||
import com.fangjia.job.fsh.po.HouseInfo;
|
||||
import com.fangjia.job.fsh.po.LoanCustomersConfig;
|
||||
import com.fangjia.job.fsh.po.PotentialCustomersFilterConfig;
|
||||
|
||||
@Service
|
||||
public class CustomerStatServiceImpl implements CustomerStatService {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Autowired
|
||||
private VisitLogService visitLogService;
|
||||
|
||||
@Autowired
|
||||
private HouseInfoService houseInfoService;
|
||||
|
||||
@Autowired
|
||||
private AdVisitLogService adVisitLogService;
|
||||
|
||||
@Autowired
|
||||
private EnterpriseProductUserService enterpriseProductUserService;
|
||||
|
||||
@Autowired
|
||||
private LoanApplyService loanApplyService;
|
||||
|
||||
@Override
|
||||
public void removeCustomerStat(Long eid, String uid) {
|
||||
Query query = Query.query(Criteria.where("eid").is(eid).and("uid").is(uid));
|
||||
mongoTemplate.remove(query, CustomerStat.class);
|
||||
}
|
||||
|
||||
/*
|
||||
分析逻辑:
|
||||
先过滤
|
||||
|
||||
从5星开始分析,如果满足了5星就这个用户就跳过了,否则接着分析4星,以此类推
|
||||
|
||||
理财潜客设置:
|
||||
分析时间:下面条件的筛选时间
|
||||
理财广告点击率:多个广告位的点击次数/页面的pv +分析时间
|
||||
房产数量排名:所有的有效房产数量
|
||||
房产价值排名:所有的有效房产数量总价值 这个企业下的用户的总价值排名 自己的总价值的排名/总人数
|
||||
房产分析PV:房产分析结果页面的pv /fsh/result +分析时间
|
||||
出售分析PV: 出售分析结果页面pv saleAnalysis/analysisDetail +分析时间
|
||||
出租管理PV: 出租管理结果页面pv /rent/index +分析时间
|
||||
房产评级,就是用户房产等级最高的一个
|
||||
|
||||
过滤条件:
|
||||
(访问较频繁)所有页面浏览 改成次数 +分析时间
|
||||
房产数量(含删除) 套数
|
||||
|
||||
贷款潜客设置:
|
||||
|
||||
贷款广告点击率:多个广告位的点击次数/页面的pv +分析时间
|
||||
贷款评估次数
|
||||
贷款评估PV /myLoan/loanStep /myLoan/result +分析时间
|
||||
贷款申请PV /myLoan/info /myLoan/applyResult +分析时间
|
||||
我要贷款首页PV /myLoan/index +分析时间
|
||||
我要置换首页PV changeHouse/index +分析时间
|
||||
出租管理PV /rent/index +分析时间
|
||||
出售管理PV /saleAnalysis/analysisDetail +分析时间
|
||||
*/
|
||||
@Override
|
||||
public void customerStat(EnterpriseProductUser user, PotentialCustomersFilterConfig financiaFilterConfig,
|
||||
PotentialCustomersFilterConfig loanFilterConfig, List<FinancialCustomersConfig> financialCustomersList,
|
||||
List<LoanCustomersConfig> loanCustomersConfigList) {
|
||||
Long eid = user.getEid();
|
||||
String uid = user.getUid();
|
||||
// 删除之前这个用户的统计数据,每天都是最新的
|
||||
this.removeCustomerStat(eid, uid);
|
||||
|
||||
long hosueCount = 0;
|
||||
Double housePrice = 0.0;
|
||||
int level = this.getFinanciaCustomerLevel(eid, uid, financiaFilterConfig, financialCustomersList);
|
||||
if (level > 0) {
|
||||
CustomerStat stat = new CustomerStat();
|
||||
stat.setEid(eid);
|
||||
stat.setUid(uid);
|
||||
stat.setCity(user.getCity());
|
||||
stat.setRegion(user.getRegion());
|
||||
hosueCount = houseInfoService.queryCountByEidAndUid(eid, uid);
|
||||
stat.setHouseCount(hosueCount);
|
||||
housePrice = houseInfoService.querySumMoneyByEidAndUid(eid, uid);
|
||||
stat.setHousePrice(housePrice);
|
||||
stat.setCreateDate(new Date());
|
||||
stat.setType(1);
|
||||
stat.setLevel(level);
|
||||
mongoTemplate.save(stat);
|
||||
}
|
||||
|
||||
int levelLoan = getLoanCustomerLevel(eid, uid, loanFilterConfig, loanCustomersConfigList);
|
||||
if (levelLoan > 0) {
|
||||
CustomerStat stat = new CustomerStat();
|
||||
stat.setEid(eid);
|
||||
stat.setUid(uid);
|
||||
stat.setCity(user.getCity());
|
||||
stat.setRegion(user.getRegion());
|
||||
// 理财级别有的情况下就用上面已经查询好的数据,避免重复查询
|
||||
if (level > 0) {
|
||||
stat.setHouseCount(hosueCount);
|
||||
stat.setHousePrice(housePrice);
|
||||
} else {
|
||||
stat.setHouseCount(houseInfoService.queryCountByEidAndUid(eid, uid));
|
||||
stat.setHousePrice(houseInfoService.querySumMoneyByEidAndUid(eid, uid));
|
||||
}
|
||||
stat.setCreateDate(new Date());
|
||||
stat.setType(2);
|
||||
stat.setLevel(levelLoan);
|
||||
mongoTemplate.save(stat);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否要进行过滤
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @param financiaFilterConfig
|
||||
* @return 1 不需要 0 需要
|
||||
*/
|
||||
private int filter(Long eid, String uid, PotentialCustomersFilterConfig financiaFilterConfig) {
|
||||
// 有过滤条件才做过滤
|
||||
if (financiaFilterConfig != null) {
|
||||
// 配置了最近分析时间才需要根据时间去查询PV
|
||||
String start = "";
|
||||
String end = "";
|
||||
if (financiaFilterConfig.getAnalyTime() > 0) {
|
||||
Map<String, String> timeMap = DateUtilCustom.getLatelyDate(financiaFilterConfig.getAnalyTime());
|
||||
start = timeMap.get("start");
|
||||
end = timeMap.get("end");
|
||||
}
|
||||
|
||||
// 判断是否超过指定浏览次数,浏览次数是所有页面的PV
|
||||
if (financiaFilterConfig.getAllPageVisit() > 0) {
|
||||
long pv = visitLogService.queryPvCountByUser(eid, uid, start, end);
|
||||
if (pv > financiaFilterConfig.getAllPageVisit()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断房产数量(含删除)的套数
|
||||
if (financiaFilterConfig.getHouseCount() > 0) {
|
||||
long houseCount = houseInfoService.queryAllCountByEidAndUid(eid, uid);
|
||||
if (houseCount > financiaFilterConfig.getHouseCount()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 贷款潜在客户分析
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @param loanFilterConfig
|
||||
* @param financialCustomersList
|
||||
* @return
|
||||
*/
|
||||
private int getLoanCustomerLevel(Long eid, String uid, PotentialCustomersFilterConfig loanFilterConfig,
|
||||
List<LoanCustomersConfig> loanCustomersConfigList) {
|
||||
|
||||
if (filter(eid, uid, loanFilterConfig) == 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 从5星开始分析,满足条件则继续下个用户的分析,不满足则继续4星的分析,以此类推
|
||||
for (int i = 5; i >= 1; i--) {
|
||||
LoanCustomersConfig config = getLoanCustomersConfig(i, loanCustomersConfigList);
|
||||
if (config == null) {
|
||||
continue;
|
||||
}
|
||||
// 配置了最近分析时间才需要根据时间去查询PV
|
||||
String start = "";
|
||||
String end = "";
|
||||
if (config.getAnalyTime() > 0) {
|
||||
Map<String, String> timeMap = DateUtilCustom.getLatelyDate(config.getAnalyTime());
|
||||
start = timeMap.get("start");
|
||||
end = timeMap.get("end");
|
||||
}
|
||||
|
||||
// 判断贷款评估PV
|
||||
if (config.getLoanEvalPv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/loanStep", "/myLoan/result"), start, end);
|
||||
if (count <= config.getLoanEvalPv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断贷款申请PV
|
||||
if (config.getLoanApplyPv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/info", "/myLoan/applyResult"), start, end);
|
||||
if (count <= config.getLoanApplyPv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断我要贷款首页PV
|
||||
if (config.getLoanIndexPagePv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/myLoan/index"), start, end);
|
||||
if (count <= config.getLoanIndexPagePv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断我要置换首页PV
|
||||
if (config.getSubIndexPagePv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/changeHouse/index"), start, end);
|
||||
if (count <= config.getSubIndexPagePv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断出租管理PV
|
||||
if (config.getRentManagerPv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/rent/index"), start, end);
|
||||
if (count <= config.getRentManagerPv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断出售分析PV
|
||||
if (config.getSaleAnalyPv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/saleAnalysis/analysisDetail"), start, end);
|
||||
if (count <= config.getSaleAnalyPv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断贷款评估次数
|
||||
if (config.getLoanEvalCount() > 0) {
|
||||
long count = loanApplyService.queryCountByType(eid, uid, 2, start, end);
|
||||
if (count <= config.getLoanEvalCount()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断用户贷款广告点击率
|
||||
if (config.getAdClickRate() > 0) {
|
||||
double adClickRate = getLoanAdClickRate(eid, uid, start, end);
|
||||
if (adClickRate <= config.getAdClickRate()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getFinanciaCustomerLevel(Long eid, String uid, PotentialCustomersFilterConfig financiaFilterConfig,
|
||||
List<FinancialCustomersConfig> financialCustomersList) {
|
||||
|
||||
if (filter(eid, uid, financiaFilterConfig) == 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 从5星开始分析,满足条件则继续下个用户的分析,不满足则继续4星的分析,以此类推
|
||||
for (int i = 5; i >= 1; i--) {
|
||||
FinancialCustomersConfig config = getFinancialCustomersConfig(i, financialCustomersList);
|
||||
if (config == null) {
|
||||
continue;
|
||||
}
|
||||
// 配置了最近分析时间才需要根据时间去查询PV
|
||||
String start = "";
|
||||
String end = "";
|
||||
if (config.getAnalyTime() > 0) {
|
||||
Map<String, String> timeMap = DateUtilCustom.getLatelyDate(config.getAnalyTime());
|
||||
start = timeMap.get("start");
|
||||
end = timeMap.get("end");
|
||||
}
|
||||
|
||||
// 判断房产分析PV
|
||||
if (config.getHouseAnalyPv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/fsh/result"), start, end);
|
||||
if (count <= config.getHouseAnalyPv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断出售分析PV
|
||||
if (config.getSaleAnalyPv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/saleAnalysis/analysisDetail"), start, end);
|
||||
if (count <= config.getSaleAnalyPv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断出租管理PV
|
||||
if (config.getRentManagerPv() > 0) {
|
||||
long count = visitLogService.queryPvCountByUser(eid, uid, Arrays.asList("/rent/index"), start, end);
|
||||
if (count <= config.getRentManagerPv()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断房产数量
|
||||
if (config.getHouseCountRank() > 0) {
|
||||
long count = houseInfoService.queryCountByEidAndUid(eid, uid);
|
||||
if (count <= config.getHouseCountRank()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断房产评级
|
||||
if (config.getHouseLevel() > 0) {
|
||||
HouseInfo houseInfo = houseInfoService.findHighLevelHouseInfo(eid, uid);
|
||||
if (houseInfo == null) {
|
||||
continue;
|
||||
}
|
||||
if (houseInfo.getLevel() != config.getHouseLevel()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断房产价值排名
|
||||
if (config.getHousePriceRank() > 0) {
|
||||
if (this.getHousePriceLevel(eid, uid) <= config.getHousePriceRank()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 判断用户理财广告点击率
|
||||
if (config.getAdClickRate() > 0) {
|
||||
double adClickRate = getFinancialAdClickRate(eid, uid, start, end);
|
||||
if (adClickRate <= config.getAdClickRate()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户房产价值排名<br>
|
||||
* 所有的有效房产数量总价值 这个企业下的用户的总价值排名 = 自己的总价值的排名/总人数
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
private double getHousePriceLevel(Long eid, String uid) {
|
||||
// 企业下的用户数量
|
||||
long enterpriseUserCount = enterpriseProductUserService.queryUserCount(eid);
|
||||
long level = houseInfoService.queryHouseTotalPriceLevel(eid, uid);
|
||||
if (enterpriseUserCount == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
double rate = new BigDecimal((double)level/enterpriseUserCount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
|
||||
return rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户理财广告点击率<br>
|
||||
* 点击率=广告点击次数/广告位页面PV
|
||||
* 广告位:
|
||||
* 1、房产分析/出租管理-租金回报率
|
||||
* 2、房产分析/出租管理-出租状态
|
||||
* 3、出售分析-增长率收益
|
||||
* 4、出售分析-挂牌建议
|
||||
*
|
||||
* 页面:
|
||||
* 1、房产分析 /fsh/result
|
||||
* 2、出租管理 /rent/index
|
||||
* 3、出售分析 /saleAnalysis/analysisDetail
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
private double getFinancialAdClickRate(Long eid, String uid, String start, String end) {
|
||||
long adClickCount = adVisitLogService.queryPvCount(eid, uid, Arrays.asList(0, 1, 2, 3), start, end);
|
||||
List<String> uriList = Arrays.asList("/fsh/result", "/saleAnalysis/analysisDetail", "/rent/index");
|
||||
long pvCount = visitLogService.queryPvCountByUser(eid, uid, uriList, start, end);
|
||||
if (pvCount == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
double rate = new BigDecimal((double)adClickCount/pvCount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
|
||||
return rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 贷款广告点击率
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
private double getLoanAdClickRate(Long eid, String uid, String start, String end) {
|
||||
long adClickCount = adVisitLogService.queryPvCount(eid, uid, Arrays.asList(4), start, end);
|
||||
List<String> uriList = Arrays.asList("/changeHouse/details");
|
||||
long pvCount = visitLogService.queryPvCountByUser(eid, uid, uriList, start, end);
|
||||
if (pvCount == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
double rate = new BigDecimal((double)adClickCount/pvCount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
|
||||
return rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取星级对应的理财客户分析条件
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
private FinancialCustomersConfig getFinancialCustomersConfig(int level, List<FinancialCustomersConfig> financialCustomersList) {
|
||||
for (FinancialCustomersConfig config : financialCustomersList) {
|
||||
if (level == config.getStarLevel()) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取星级对应贷款客户分析条件
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
private LoanCustomersConfig getLoanCustomersConfig(int level, List<LoanCustomersConfig> loanCustomersConfigList) {
|
||||
for (LoanCustomersConfig config : loanCustomersConfigList) {
|
||||
if (level == config.getStarLevel()) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.fangjia.job.fsh.po.FinancialCustomersConfig;
|
||||
|
||||
public interface FinancialCustomersConfigService {
|
||||
|
||||
List<FinancialCustomersConfig> queryAll();
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.fsh.po.FinancialCustomersConfig;
|
||||
|
||||
@Service
|
||||
public class FinancialCustomersConfigServiceImpl extends EntityService<FinancialCustomersConfig> implements FinancialCustomersConfigService {
|
||||
|
||||
@Override
|
||||
public List<FinancialCustomersConfig> queryAll() {
|
||||
return super.list();
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -1,5 +1,9 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.fangjia.job.fsh.po.HouseInfo;
|
||||
|
||||
public interface HouseInfoService {
|
||||
|
||||
/**
|
||||
@@ -50,6 +54,14 @@ public interface HouseInfoService {
|
||||
*/
|
||||
long queryCountByEidAndUid(Long eid, String uid);
|
||||
|
||||
/**
|
||||
* 查询企业下用户的房产数量(包含删除)
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
long queryAllCountByEidAndUid(Long eid, String uid);
|
||||
|
||||
/**
|
||||
* 查询企业下用户的房产总价值
|
||||
* @param eid
|
||||
@@ -58,4 +70,33 @@ public interface HouseInfoService {
|
||||
*/
|
||||
Double querySumMoneyByEidAndUid(Long eid, String uid);
|
||||
|
||||
/**
|
||||
* 分组统计企业下的各城市对应的房产数量Top
|
||||
* @param eid
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
Map<String, Long> queryHouseCountGroupByCity(Long eid, int limit);
|
||||
|
||||
/**
|
||||
* 用户所有有效房产总价值排名
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
long queryHouseTotalPriceLevel(Long eid, String uid);
|
||||
|
||||
/**
|
||||
* 查询用户有效房产总价值
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
Long queryUserHouseTotalPrice(Long eid, String uid);
|
||||
|
||||
/**
|
||||
* 查找最高等级的房产信息
|
||||
*/
|
||||
HouseInfo findHighLevelHouseInfo(Long eid, String uid);
|
||||
|
||||
}
|
||||
|
||||
+53
@@ -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,52 @@ 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long queryAllCountByEidAndUid(Long eid, String uid) {
|
||||
return super.count(new String[] { "eid", "uid" }, new Object[] { eid, uid });
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用户分组查询出总价值,降序排序,然后根据当前用户自己的总价值,查询在它之上的有多少位,来算出排名
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public long queryHouseTotalPriceLevel(Long eid, String uid) {
|
||||
Long totalPrice = this.queryUserHouseTotalPrice(eid, uid);
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("select count(*) from");
|
||||
sql.append(" (select uid,SUM(total_price) as total_price from house_info where eid = ? and remove_status = 0 GROUP BY uid ORDER BY total_price desc ) as t");
|
||||
sql.append(" where t.total_price >= ?");
|
||||
return super.count(sql.toString(), new Object[] { eid, totalPrice });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long queryUserHouseTotalPrice(Long eid, String uid) {
|
||||
String sql = "select sum(total_price) from house_info where eid = ? and uid = ? and remove_status = 0";
|
||||
Long sum = super.getJdbcTemplate().queryForObject(sql, Long.class, new Object[] { eid, uid });
|
||||
if (sum == null) {
|
||||
return 0L;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HouseInfo findHighLevelHouseInfo(Long eid, String uid) {
|
||||
return super.getByParams(new String[] { "level" }, new String[] { "eid", "uid" ,"remove_status"},
|
||||
new Object[] { eid, uid, 0 }, HouseInfo.level_orders);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -20,6 +20,16 @@ public interface LoanApplyService {
|
||||
*/
|
||||
long queryCountByType(Long eid, int type, String start, String end);
|
||||
|
||||
/**
|
||||
* 查询次数
|
||||
* @param eid
|
||||
* @param type 1:贷款申请 2:贷款评估
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
long queryCountByType(Long eid, String uid, int type, String start, String end);
|
||||
|
||||
/**
|
||||
* 贷款申请金额
|
||||
* @param eid
|
||||
|
||||
+21
@@ -1,6 +1,11 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.fsh.po.LoanApply;
|
||||
|
||||
@@ -42,5 +47,21 @@ public class LoanApplyServiceImpl extends EntityService<LoanApply> implements Lo
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long queryCountByType(Long eid, String uid, int type, String start, String end) {
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("select count(id) from loan_apply where eid = ? and uid = ? and type = ?");
|
||||
params.add(eid);
|
||||
params.add(uid);
|
||||
params.add(type);
|
||||
if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) {
|
||||
sql.append(" and add_time between ? and ?");
|
||||
params.add(start);
|
||||
params.add(end);
|
||||
}
|
||||
return super.count(sql.toString(), params.toArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.job.fsh.po.LoanCustomersConfig;
|
||||
|
||||
public interface LoanCustomersConfigService {
|
||||
|
||||
List<LoanCustomersConfig> queryAll();
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.fsh.po.LoanCustomersConfig;
|
||||
|
||||
@Service
|
||||
public class LoanCustomersConfigServiceImpl extends EntityService<LoanCustomersConfig> implements LoanCustomersConfigService {
|
||||
|
||||
@Override
|
||||
public List<LoanCustomersConfig> queryAll() {
|
||||
return super.list();
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fangjia.job.fsh.document.PageStat;
|
||||
|
||||
public interface PageStatService {
|
||||
|
||||
/**
|
||||
* 保存页面统计信息
|
||||
* @param stat
|
||||
*/
|
||||
void saveAll(List<PageStat> pageStats);
|
||||
|
||||
/**
|
||||
* 删除某天的统计
|
||||
* @param formateDate
|
||||
*/
|
||||
void deleteByParams(String formateDate);
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fangjia.job.fsh.document.PageStat;
|
||||
|
||||
@Service
|
||||
public class PageStatServiceImpl implements PageStatService{
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public void saveAll(List<PageStat> pageStats) {
|
||||
mongoTemplate.insertAll(pageStats);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByParams(String formateDate) {
|
||||
Query query = Query.query(Criteria.where("formatDate").is(formateDate));
|
||||
mongoTemplate.remove(query, PageStat.class);
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import com.fangjia.job.fsh.po.PotentialCustomersFilterConfig;
|
||||
|
||||
public interface PotentialCustomersFilterConfigService {
|
||||
|
||||
/**
|
||||
* 获取潜在客户分析过滤参数
|
||||
* @param type 类型(1:理财潜客设置 2:贷款潜客设置)
|
||||
* @return
|
||||
*/
|
||||
PotentialCustomersFilterConfig get(int type);
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.fsh.po.PotentialCustomersFilterConfig;
|
||||
|
||||
@Service
|
||||
public class PotentialCustomersFilterConfigServiceImpl extends EntityService<PotentialCustomersFilterConfig> implements PotentialCustomersFilterConfigService {
|
||||
|
||||
@Override
|
||||
public PotentialCustomersFilterConfig get(int type) {
|
||||
return super.getById("type", type);
|
||||
}
|
||||
|
||||
}
|
||||
+30
@@ -1,5 +1,8 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface VisitLogService {
|
||||
|
||||
/**
|
||||
@@ -40,4 +43,31 @@ public interface VisitLogService {
|
||||
*/
|
||||
long queryUvCount(Long eid, String start, String end);
|
||||
|
||||
/**
|
||||
* 查询用户的所有页面的PV
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
long queryPvCountByUser(Long eid, String uid, String start, String end);
|
||||
|
||||
/**
|
||||
* 查询用户的指定页面的PV
|
||||
* @param eid
|
||||
* @param uid
|
||||
* @param uriList
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
long queryPvCountByUser(Long eid, String uid, List<String> uriList, String start, String end);
|
||||
|
||||
/**
|
||||
* 查询某企业访问页面城市的pv
|
||||
* @param eid
|
||||
* @param start
|
||||
* @param end
|
||||
*/
|
||||
List<Map<String, Object>> queryPvList(String start, String end);
|
||||
|
||||
}
|
||||
|
||||
+50
@@ -1,6 +1,12 @@
|
||||
package com.fangjia.job.fsh.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.fsh.po.VisitLog;
|
||||
|
||||
@@ -31,4 +37,48 @@ public class VisitLogServiceImpl extends EntityService<VisitLog> implements Visi
|
||||
return super.count(sql.toString(), new Object[] {eid, start, end});
|
||||
}
|
||||
|
||||
@Override
|
||||
public long queryPvCountByUser(Long eid, String uid, String start, String end) {
|
||||
StringBuilder sql = new StringBuilder("select count(id) from visit_log where eid = ? and uid = ?");
|
||||
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
params.add(eid);
|
||||
params.add(uid);
|
||||
|
||||
if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) {
|
||||
sql.append(" and visit_time between ? and ?");
|
||||
params.add(start);
|
||||
params.add(end);
|
||||
}
|
||||
return super.count(sql.toString(), params.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long queryPvCountByUser(Long eid, String uid, List<String> uriList, String start, String end) {
|
||||
List<Object> params = new ArrayList<Object>();
|
||||
StringBuilder sql = new StringBuilder("select count(id) from visit_log where eid = ? and uid = ?");
|
||||
params.add(eid);
|
||||
params.add(uid);
|
||||
sql.append(" and uri in (");
|
||||
for (String uri : uriList) {
|
||||
sql.append("?,");
|
||||
params.add(uri);
|
||||
}
|
||||
sql.delete(sql.length() - 1, sql.length());
|
||||
sql.append(")");
|
||||
if (StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) {
|
||||
sql.append(" and visit_time between ? and ?");
|
||||
params.add(start);
|
||||
params.add(end);
|
||||
}
|
||||
return super.count(sql.toString(), params.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> queryPvList(String start, String end) {
|
||||
String sql = "SELECT eid,city, uri,COUNT(uri) as pv,COUNT(DISTINCT(ip)) as uv FROM visit_log WHERE visit_time BETWEEN ? AND ? GROUP BY eid,city,uri";
|
||||
List<Map<String, Object>> list = super.getJdbcTemplate().queryForPage(0, Integer.MAX_VALUE, sql, new Object[] {start, end});
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,4 +12,5 @@ spring.datasource.log.driver-class-name=com.mysql.jdbc.Driver
|
||||
|
||||
fsh.url=http://192.168.0.251:8084
|
||||
|
||||
zk.server-lists=192.168.10.47:2181
|
||||
zk.server-lists=192.168.10.47:2181
|
||||
zk.namespace=fangjia-job-fsh-test
|
||||
@@ -5,9 +5,15 @@ spring.datasource.username=sa
|
||||
spring.datasource.password=G00jia
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
|
||||
spring.datasource.log.url=jdbc:mysql://192.168.0.41:4306/batch_log
|
||||
spring.datasource.log.username=root
|
||||
spring.datasource.log.password=Ga041243
|
||||
#spring.datasource.log.url=jdbc:mysql://192.168.0.41:4306/batch_log
|
||||
#spring.datasource.log.username=root
|
||||
#spring.datasource.log.password=Ga041243
|
||||
#spring.datasource.log.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.log.url=jdbc:mysql://192.168.0.132:4306/batch_log
|
||||
spring.datasource.log.username=sa
|
||||
spring.datasource.log.password=G00jia
|
||||
spring.datasource.log.driver-class-name=com.mysql.jdbc.Driver
|
||||
fsh.url=http://fsh.fangjia.com
|
||||
|
||||
fsh.url=http://fsh.fangjia.com
|
||||
zk.server-lists=192.168.10.47:2181
|
||||
zk.namespace=fangjia-job-fsh
|
||||
@@ -12,4 +12,5 @@ spring.datasource.log.driver-class-name=com.mysql.jdbc.Driver
|
||||
|
||||
fsh.url=http://192.168.0.251:8084
|
||||
|
||||
zk.server-lists=192.168.10.47:2181
|
||||
zk.server-lists=192.168.10.47:2181
|
||||
zk.namespace=fangjia-job-fsh-test
|
||||
@@ -1 +1 @@
|
||||
spring.profiles.active=test
|
||||
spring.profiles.active=dev
|
||||
@@ -37,7 +37,7 @@
|
||||
<property name="dataSource" ref="dataSource"></property>
|
||||
</bean>
|
||||
|
||||
<reg:zookeeper id="regCenter" server-lists="${zk.server-lists}" namespace="fangjia-job-fsh"
|
||||
<reg:zookeeper id="regCenter" server-lists="${zk.server-lists}" namespace="${zk.namespace}"
|
||||
base-sleep-time-milliseconds="1000" max-sleep-time-milliseconds="3000" max-retries="3" />
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user