fix:五院杭州中心 业务职务积分库更新需求变更处理
This commit is contained in:
parent
7092bde9fa
commit
ed0934ba8d
|
|
@ -2,6 +2,7 @@ package weaver.interfaces.wysecond;
|
||||||
|
|
||||||
import com.engine.wysecond.entity.PostionPoints;
|
import com.engine.wysecond.entity.PostionPoints;
|
||||||
import com.weaver.general.Util;
|
import com.weaver.general.Util;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import weaver.common.DateUtil;
|
import weaver.common.DateUtil;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
import weaver.interfaces.schedule.BaseCronJob;
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
@ -25,8 +26,10 @@ public class PostionPointsUpdateCron extends BaseCronJob {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
RecordSet rs = new RecordSet();
|
RecordSet rs = new RecordSet();
|
||||||
|
String year = DateUtil.getYear();
|
||||||
|
|
||||||
List<PostionPoints> pointsList = new ArrayList<>();
|
List<PostionPoints> pointsList = new ArrayList<>();
|
||||||
rs.executeQuery("select id,xm,zwdzlx,rbywzwcjqssj,rbywzwcjnx,rbywzwcjljjf from uf_ywzwxx");
|
rs.executeQuery("select id,xm,zwdzlx,rbywzwcjqssj,rbywzwcjnx,rbywzwcjljjf,nd from uf_ywzwxx");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
pointsList.add(PostionPoints.builder()
|
pointsList.add(PostionPoints.builder()
|
||||||
.id(Util.getIntValue(rs.getString("id")))
|
.id(Util.getIntValue(rs.getString("id")))
|
||||||
|
|
@ -35,12 +38,12 @@ public class PostionPointsUpdateCron extends BaseCronJob {
|
||||||
.jobStartDate(Util.null2String(rs.getString("rbywzwcjqssj")))
|
.jobStartDate(Util.null2String(rs.getString("rbywzwcjqssj")))
|
||||||
.jobYears(Util.null2String(rs.getString("rbywzwcjnx")))
|
.jobYears(Util.null2String(rs.getString("rbywzwcjnx")))
|
||||||
.points(Util.getIntValue(rs.getString("rbywzwcjljjf"),0))
|
.points(Util.getIntValue(rs.getString("rbywzwcjljjf"),0))
|
||||||
|
.year(Util.getIntValue("nd"))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<PostionPoints> checkList = new ArrayList<>();
|
List<PostionPoints> checkList = new ArrayList<>();
|
||||||
String year = DateUtil.getYear();
|
|
||||||
rs.executeQuery("select id,xm,nd,ndjxkhjl from uf_ndjxkhdjtzzxld where nd = ?",year);
|
rs.executeQuery("select id,xm,nd,ndjxkhjl from uf_ndjxkhdjtzzxld where nd = ?",year);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
checkList.add(PostionPoints.builder()
|
checkList.add(PostionPoints.builder()
|
||||||
|
|
@ -51,78 +54,82 @@ public class PostionPointsUpdateCron extends BaseCronJob {
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 处理考核结果表数据,按xm分组,筛选最新记录
|
|
||||||
Map<Integer, PostionPoints> resultMap = checkList.stream()
|
|
||||||
.collect(Collectors.groupingBy(
|
|
||||||
PostionPoints::getResourceId,
|
|
||||||
Collectors.collectingAndThen(
|
|
||||||
Collectors.maxBy(
|
|
||||||
Comparator.comparingInt(PostionPoints::getYear)
|
|
||||||
.thenComparingInt(PostionPoints::getId)
|
|
||||||
.reversed()
|
|
||||||
),
|
|
||||||
optional -> optional.orElse(null)
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
//合并
|
|
||||||
pointsList.forEach(point -> {
|
|
||||||
PostionPoints matchedPoint = resultMap.get(point.getResourceId());
|
|
||||||
if (matchedPoint != null) {
|
|
||||||
point.setYear(matchedPoint.getYear());
|
|
||||||
point.setCheckResult(matchedPoint.getCheckResult());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
//积分统计 任职年限计算
|
//积分统计 任职年限计算
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
// 获取当前日期
|
// 获取当前日期
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
|
|
||||||
for (PostionPoints point : pointsList) {
|
if (CollectionUtils.isNotEmpty(pointsList)) {
|
||||||
if (point.getJobStartDate() == null || point.getJobStartDate().isEmpty()) {
|
//1.业务职务信息分组
|
||||||
continue;
|
Map<Integer, List<PostionPoints>> listMap = pointsList.stream()
|
||||||
}
|
.collect(Collectors.groupingBy(PostionPoints::getResourceId));
|
||||||
try {
|
|
||||||
// 计算任职年限
|
|
||||||
Date startDate = sdf.parse(point.getJobStartDate());
|
|
||||||
long diffInMillis = currentDate.getTime() - startDate.getTime();
|
|
||||||
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 获取额外积分
|
listMap.forEach((xm, postionPoints) -> {
|
||||||
int extraPoints;
|
List<PostionPoints> sortedList = postionPoints.stream()
|
||||||
Integer checkResult = point.getCheckResult();
|
.sorted(Comparator.comparingInt(PostionPoints::getId).reversed())
|
||||||
if (checkResult == null) {
|
.collect(Collectors.toList());
|
||||||
extraPoints = 0;
|
|
||||||
} else {
|
PostionPoints maxIdRecord = sortedList.isEmpty() ? null : sortedList.get(0);
|
||||||
switch (checkResult) {
|
PostionPoints secondMaxIdRecord = sortedList.size() >= 2 ? sortedList.get(1) : null;
|
||||||
case 0: extraPoints = 3; break;
|
|
||||||
case 1: extraPoints = 2; break;
|
if (maxIdRecord == null || maxIdRecord.getJobStartDate() == null || maxIdRecord.getJobStartDate().isEmpty()) {
|
||||||
case 2: extraPoints = 1; break;
|
return;
|
||||||
default: extraPoints = 0; break;
|
}
|
||||||
|
|
||||||
|
//只处理最新数据
|
||||||
|
//1.根据xm和年度匹配绩效考核最新数据
|
||||||
|
List<PostionPoints> filteredList = checkList.stream()
|
||||||
|
.filter(p -> Objects.equals(p.getResourceId(), maxIdRecord.getResourceId()) && Objects.equals(p.getYear(), maxIdRecord.getYear()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
//维护默认值
|
||||||
|
int extraPoints = 0;
|
||||||
|
if (secondMaxIdRecord != null) {
|
||||||
|
extraPoints = secondMaxIdRecord.getPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
int resultPoint = 0;
|
||||||
|
if (CollectionUtils.isNotEmpty(filteredList)) {
|
||||||
|
PostionPoints maxInFiltered = filteredList.stream()
|
||||||
|
.max(Comparator.comparingInt(PostionPoints::getId))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (maxInFiltered != null) {
|
||||||
|
// 根据 checkResult 获取额外积分
|
||||||
|
Integer checkResult = maxInFiltered.getCheckResult();
|
||||||
|
switch (checkResult) {
|
||||||
|
case 0: resultPoint = 3; break;
|
||||||
|
case 1: resultPoint = 2; break;
|
||||||
|
case 2: resultPoint = 1; break;
|
||||||
|
default: resultPoint = 0; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (point.getChangeType() == 1 || point.getChangeType() == 2) {
|
//计算业务积分
|
||||||
point.setPoints(point.getPoints() + extraPoints);
|
if (maxIdRecord.getChangeType() == 1 || maxIdRecord.getChangeType() == 2) {
|
||||||
|
//调整类型是降职和平调
|
||||||
|
maxIdRecord.setPoints(resultPoint + extraPoints);
|
||||||
}else {
|
}else {
|
||||||
point.setPoints(extraPoints);
|
maxIdRecord.setPoints(resultPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.executeUpdate("update uf_ywzwxx set rbywzwcjnx = ?,rbywzwcjljjf = ? where id = ?",point.getJobYears(),point.getPoints(),point.getId());
|
// 计算任职年限
|
||||||
} catch (ParseException e) {
|
Date startDate = null;
|
||||||
e.printStackTrace();
|
try {
|
||||||
}
|
startDate = sdf.parse(maxIdRecord.getJobStartDate());
|
||||||
|
long diffInMillis = currentDate.getTime() - startDate.getTime();
|
||||||
|
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);
|
||||||
|
maxIdRecord.setJobYears(years.toString());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
rs.writeLog("PostionPointsUpdateCron:日期格式解析异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.executeUpdate("update uf_ywzwxx set rbywzwcjnx = ?,rbywzwcjljjf = ? where id = ?",maxIdRecord.getJobYears(),maxIdRecord.getPoints(),maxIdRecord.getId());
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue