...
|
...
|
@@ -382,20 +382,31 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
logger.warn("doVirtualPraise config is empty,praiseType ={},commonConfig={},specialConfig={},timeConfig={},",praiseType,commonConfig,specialConfig,timeConfig);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
String[] commonStrategy = StringUtils.split(commonConfig, ",");
|
|
|
String [] specialStrategy = StringUtils.split(specialConfig, ",");
|
|
|
//普通用户的点赞策略(线性函数)
|
|
|
int start = Integer.valueOf(commonStrategy[0]);//起始(0,start)
|
|
|
int end = Integer.valueOf(commonStrategy[1]);//终结(timeConfig,end)
|
|
|
int min = Integer.valueOf(commonStrategy[0]);//起始(0,start)
|
|
|
int max = Integer.valueOf(commonStrategy[1]);//终结(timeConfig,end)
|
|
|
//重点用户的点赞策略(线性函数)
|
|
|
int startSpecial = Integer.valueOf(specialStrategy[0]);//起始点(0,startSpecial)
|
|
|
int endSpecial = Integer.valueOf(specialStrategy[1]);//终结(timeConfig,endSpecial)
|
|
|
//两个坐标点 --线性函数 y=kx + b
|
|
|
// double k = ((end - start)*1d) / (timeConfig * 1d);
|
|
|
int specialMin = Integer.valueOf(specialStrategy[0]);//起始点(0,startSpecial)
|
|
|
int specialMax = Integer.valueOf(specialStrategy[1]);//终结(timeConfig,endSpecial)
|
|
|
|
|
|
//根据当前批次需要点赞的文章数量, 取合适的点赞区间 如 min = 10 max = 50 list.size =70 则 区间取 10 - 35
|
|
|
int articleNum = articleList.size() / 2;
|
|
|
if(articleNum < max && articleNum> min){
|
|
|
max = articleNum;
|
|
|
}else if(articleNum <= min ){
|
|
|
max = min+ articleNum;
|
|
|
}
|
|
|
|
|
|
if(articleNum < specialMax && articleNum> specialMin){
|
|
|
specialMax = articleNum;
|
|
|
}else if(articleNum <= min ){
|
|
|
specialMax = specialMin+ articleNum;
|
|
|
}
|
|
|
|
|
|
double k = timeConfig;
|
|
|
double b = start;
|
|
|
double kSpecial = timeConfig;
|
|
|
double bSpecial = startSpecial;
|
|
|
|
|
|
//3)基础数据--原有的点赞(正常的点赞--排除; 取消的点赞--不要发站内信)
|
|
|
Map<Integer,List<Integer>> articlePraiseMap = new HashMap<>();
|
...
|
...
|
@@ -436,9 +447,9 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
}
|
|
|
Set<Integer> randomUidList;
|
|
|
if(authorType == GrassUserTypeEnum.COMMON.getValue() && specialAuthors.contains(authorUid)){//有货的用户,并且是重点用户,采用的线性函数有所不同
|
|
|
randomUidList = getPraiseUids(tempList, kSpecial, bSpecial, time, end);
|
|
|
randomUidList = getPraiseUids(tempList,k, specialMin, specialMax, time);
|
|
|
}else{
|
|
|
randomUidList = getPraiseUids(tempList, k, b, time, end);
|
|
|
randomUidList = getPraiseUids(tempList, k, min, max, time);
|
|
|
}
|
|
|
if(CollectionUtils.isEmpty(randomUidList)){
|
|
|
article.setPraiseCount(0);//新增加的点赞数是0
|
...
|
...
|
@@ -490,18 +501,17 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
|
|
|
//随着时间的推移,增加的点赞数 逐步减少--》y= kx + b
|
|
|
//x 是距离当前的时间(分钟为单位,比小时更精确)
|
|
|
private Set<Integer> getPraiseUids(List<Integer> virtualList,double timeConfig,double start, double x , int end ) {
|
|
|
private Set<Integer> getPraiseUids(List<Integer> virtualList,double timeConfig,int min, int max, double x) {
|
|
|
if(virtualList.isEmpty()){//没有可选的马甲粉丝
|
|
|
return new HashSet<>();
|
|
|
}
|
|
|
//数量--随着时间的推移,线性的
|
|
|
// double numDouble = k * x + b + new Random().nextInt(5);
|
|
|
//使用对数函数模型
|
|
|
double y = x==0? 1/timeConfig : x/timeConfig;
|
|
|
//需要随机可以加随机数
|
|
|
double numDouble= start + new Random().nextInt(5);
|
|
|
int bound = max-min == 0 ? 1 : max-min;
|
|
|
double numDouble= new Random().nextInt(bound) + min;
|
|
|
double m = log(y,1/timeConfig) * numDouble ;
|
|
|
double num = Math.ceil(m) > end ? Math.ceil(m) : end;
|
|
|
double num = Math.ceil(m);
|
|
|
|
|
|
int addnum = new Double(num).intValue();//需要增加的点
|
|
|
int totalVitual = virtualList.size();
|
...
|
...
|
|