...
|
...
|
@@ -384,9 +384,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
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);
|
|
|
// double k = ((end - start)*1d) / (timeConfig * 1d);
|
|
|
double k = timeConfig;
|
|
|
double b = start;
|
|
|
double kSpecial = ((endSpecial - startSpecial)*1d) / (timeConfig * 1d);
|
|
|
double kSpecial = timeConfig;
|
|
|
double bSpecial = startSpecial;
|
|
|
|
|
|
//3)基础数据--原有的点赞(正常的点赞--排除; 取消的点赞--不要发站内信)
|
...
|
...
|
@@ -428,9 +429,9 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
}
|
|
|
Set<Integer> randomUidList;
|
|
|
if(authorType == GrassUserTypeEnum.COMMON.getValue() && specialAuthors.contains(authorUid)){//有货的用户,并且是重点用户,采用的线性函数有所不同
|
|
|
randomUidList = getPraiseUids(tempList, kSpecial, bSpecial, time);
|
|
|
randomUidList = getPraiseUids(tempList, kSpecial, bSpecial, time, end);
|
|
|
}else{
|
|
|
randomUidList = getPraiseUids(tempList, k, b, time);
|
|
|
randomUidList = getPraiseUids(tempList, k, b, time, end);
|
|
|
}
|
|
|
if(CollectionUtils.isEmpty(randomUidList)){
|
|
|
article.setPraiseCount(0);//新增加的点赞数是0
|
...
|
...
|
@@ -482,20 +483,25 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
|
|
|
//随着时间的推移,增加的点赞数 逐步减少--》y= kx + b
|
|
|
//x 是距离当前的时间(分钟为单位,比小时更精确)
|
|
|
private Set<Integer> getPraiseUids(List<Integer> virtualList,double k,double b, double x ) {
|
|
|
private Set<Integer> getPraiseUids(List<Integer> virtualList,double timeConfig,double start, double x , int end ) {
|
|
|
if(virtualList.isEmpty()){//没有可选的马甲粉丝
|
|
|
return new HashSet<>();
|
|
|
}
|
|
|
//数量--随着时间的推移,线性的
|
|
|
double numDouble = k * x + b + new Random().nextInt(5);
|
|
|
int num = new Double(numDouble).intValue();//需要增加的点
|
|
|
// double numDouble = k * x + b + new Random().nextInt(5);
|
|
|
//使用对数函数模型
|
|
|
double numDouble= new Random().nextInt((int)start-end) + start ;
|
|
|
double m = log(x/timeConfig,1/timeConfig) * numDouble ;
|
|
|
double num = Math.ceil(m) > end ? Math.ceil(m) : end;
|
|
|
|
|
|
int addnum = new Double(num).intValue();//需要增加的点
|
|
|
int totalVitual = virtualList.size();
|
|
|
Set<Integer> set = new HashSet<>();
|
|
|
if(totalVitual <= num){
|
|
|
if(totalVitual <= addnum){
|
|
|
set = virtualList.stream().collect(Collectors.toSet());
|
|
|
return set;
|
|
|
}
|
|
|
for(int i = 0 ; i < num; i++){
|
|
|
for(int i = 0 ; i < addnum; i++){
|
|
|
int index = getRandom(0, virtualList.size() - 1);
|
|
|
Integer uid = virtualList.get(index);//随机得到的粉丝uid
|
|
|
virtualList.remove(uid);
|
...
|
...
|
@@ -504,6 +510,10 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
return set;
|
|
|
}
|
|
|
|
|
|
private double log(double value, double base) {
|
|
|
return Math.log(value) / Math.log(base);
|
|
|
}
|
|
|
|
|
|
private void sendAddPariseMessage(List<GrassArticlePraise> pariseDetail) {
|
|
|
if(CollectionUtils.isEmpty(pariseDetail)){
|
|
|
return;
|
...
|
...
|
|