-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe242e9
commit 15ef97f
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.easy.custom.tools; | ||
|
||
import org.joda.time.DateTime; | ||
import org.joda.time.Years; | ||
|
||
/** | ||
* Created by qindongliang on 2016/5/17. | ||
*/ | ||
public class ScoreTools { | ||
|
||
|
||
/*** | ||
* | ||
* @param time 传入当前计算的日期毫秒数 | ||
* @param maxYears 设置加权因子的最大年份上限 | ||
* @return 该日期的一个动态加权评分 | ||
*/ | ||
public static float getYearScore(long time,int maxYears){ | ||
if(time==0){//没有日期的数据,不做加权操作 | ||
return 1; | ||
} | ||
DateTime now=new DateTime(); | ||
DateTime varTime=new DateTime(time); | ||
int year= Years.yearsBetween(varTime,now).getYears(); | ||
float score=1; | ||
if(year>0&&year<=maxYears){ | ||
return year*score; | ||
}else if(year>maxYears){ //超过上限者,统一按上限值乘以1.5倍算 | ||
return score*maxYears*1.5f; | ||
} | ||
return score; | ||
|
||
} | ||
|
||
|
||
/*** | ||
* | ||
* @param money 传入需要计算的注册资金 | ||
* @param maxTimes 设置加权因子的最大倍数上限 | ||
* @param money_base 注册资金基数 | ||
* @return 该资金的一个动态评分值 | ||
*/ | ||
public static float getMoneyScore(Double money,int maxTimes,int money_base){ | ||
if(money==0){//没有注册资金的数据,不做加权操作 | ||
return 1; | ||
} | ||
int mtimes=(int)(money/money_base); | ||
float score=1; | ||
if(mtimes>0&&mtimes<=maxTimes){ | ||
return mtimes*score; | ||
}else if(mtimes>maxTimes){//超过上限者,统一按上限值乘以1.5倍算 | ||
return score*maxTimes*1.5f; | ||
} | ||
return score; | ||
|
||
} | ||
|
||
|
||
|
||
} |