业务职务积分更新表字段

五院杭州中心
liangcheng 5 days ago
parent cd3efde9a5
commit 9d95997dd2

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

Loading…
Cancel
Save