业务职务积分更新表字段
This commit is contained in:
parent
cd3efde9a5
commit
9d95997dd2
|
|
@ -6,6 +6,8 @@ import weaver.common.DateUtil;
|
|||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
|
@ -49,6 +51,7 @@ public class PostionPointsUpdateCron extends BaseCronJob {
|
|||
.build());
|
||||
}
|
||||
|
||||
|
||||
// 处理考核结果表数据,按xm分组,筛选最新记录
|
||||
Map<Integer, PostionPoints> resultMap = checkList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
|
|
@ -64,18 +67,12 @@ public class PostionPointsUpdateCron extends BaseCronJob {
|
|||
));
|
||||
|
||||
//合并
|
||||
pointsList.removeIf(point -> {
|
||||
pointsList.forEach(point -> {
|
||||
PostionPoints matchedPoint = resultMap.get(point.getResourceId());
|
||||
if (matchedPoint == null) {
|
||||
return true; // 如果在 resultMap 中找不到对应元素,返回 true 表示移除该元素
|
||||
}
|
||||
if (matchedPoint.getYear() != null) {
|
||||
if (matchedPoint != null) {
|
||||
point.setYear(matchedPoint.getYear());
|
||||
}
|
||||
if (matchedPoint.getCheckResult() != null) {
|
||||
point.setCheckResult(matchedPoint.getCheckResult());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -85,35 +82,36 @@ public class PostionPointsUpdateCron extends BaseCronJob {
|
|||
Date currentDate = new Date();
|
||||
|
||||
for (PostionPoints point : pointsList) {
|
||||
if (point.getJobStartDate() == null || point.getJobStartDate().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// 计算任职年限
|
||||
Date startDate = sdf.parse(point.getJobStartDate());
|
||||
long diffInMillis = currentDate.getTime() - startDate.getTime();
|
||||
long diffInDays = diffInMillis / (1000 * 60 * 60 * 24);
|
||||
double years = (double) diffInDays / 365;
|
||||
point.setJobYears(String.format("%.2f", years));
|
||||
BigDecimal millisPerDay = BigDecimal.valueOf(1000 * 60 * 60 * 24);
|
||||
BigDecimal diffDays = BigDecimal.valueOf(diffInMillis).divide(millisPerDay, 10, RoundingMode.HALF_UP);
|
||||
BigDecimal years = diffDays.divide(BigDecimal.valueOf(365), 2, RoundingMode.HALF_UP);
|
||||
point.setJobYears(years.toString());
|
||||
|
||||
// 根据 checkResult 获取额外积分
|
||||
int extraPoints;
|
||||
switch (point.getCheckResult()) {
|
||||
case 0:
|
||||
extraPoints = 3;
|
||||
break;
|
||||
case 1:
|
||||
extraPoints = 2;
|
||||
break;
|
||||
case 2:
|
||||
extraPoints = 1;
|
||||
break;
|
||||
default:
|
||||
extraPoints = 0;
|
||||
break;
|
||||
Integer checkResult = point.getCheckResult();
|
||||
if (checkResult == null) {
|
||||
extraPoints = 0;
|
||||
} else {
|
||||
switch (checkResult) {
|
||||
case 0: extraPoints = 3; break;
|
||||
case 1: extraPoints = 2; break;
|
||||
case 2: extraPoints = 1; break;
|
||||
default: extraPoints = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (point.getChangeType() == 0) {
|
||||
point.setPoints(extraPoints);
|
||||
} else if (point.getChangeType() == 1 || point.getChangeType() == 2) {
|
||||
if (point.getChangeType() == 1 || point.getChangeType() == 2) {
|
||||
point.setPoints(point.getPoints() + extraPoints);
|
||||
}else {
|
||||
point.setPoints(extraPoints);
|
||||
}
|
||||
|
||||
rs.executeUpdate("update uf_ywzwxx set rbywzwcjnx = ?,rbywzwcjljjf = ? where id = ?",point.getJobYears(),point.getPoints(),point.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue