dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
1
2
|
package cn.fw.morax.server.task;
|
e3e0c571
姜超
feature(*): 定时任务添...
|
3
|
import cn.fw.common.cache.locker.DistributedLocker;
|
b05ea76a
姜超
feature(*): 定时任务日志打印
|
4
|
import cn.fw.morax.common.constant.TimeTaskConstant;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
5
6
7
|
import cn.fw.morax.common.utils.PublicUtil;
import cn.fw.morax.domain.db.kpi.KpiGroup;
import cn.fw.morax.domain.db.kpi.KpiGroupUser;
|
8fb407fa
姜超
fix(kpigroupuser)...
|
8
|
import cn.fw.morax.domain.enums.KpiIgnoreCauseEnum;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
9
10
|
import cn.fw.morax.service.biz.kpi.KpiGroupBizService;
import cn.fw.morax.service.biz.kpi.KpiGroupUserBizService;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
11
|
import cn.fw.morax.service.data.kpi.KpiGroupUserService;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
12
|
import cn.hutool.core.date.StopWatch;
|
3349b957
姜超
fix(kpiReportServ...
|
13
|
import com.alibaba.fastjson.JSON;
|
5f57db6b
姜超
fix(*): 薪酬编码修改、绩效...
|
14
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
15
|
import com.google.common.collect.Lists;
|
d2feb148
姜超
feature(*): 绩效组人员...
|
16
|
import com.google.common.collect.Maps;
|
7d59a85e
姜超
feature(*): redis...
|
17
|
import lombok.Getter;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
18
19
|
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
|
e3e0c571
姜超
feature(*): 定时任务添...
|
20
|
import org.redisson.api.RLock;
|
7d59a85e
姜超
feature(*): redis...
|
21
|
import org.springframework.beans.factory.annotation.Value;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
22
23
24
25
26
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
|
e990aa6f
姜超
fix(*): 绩效、薪酬定时任务...
|
27
|
import java.time.LocalDate;
|
3349b957
姜超
fix(kpiReportServ...
|
28
|
import java.util.*;
|
985e8807
姜超
feature(*): 修改绩效人...
|
29
|
import java.util.concurrent.TimeUnit;
|
e3e0c571
姜超
feature(*): 定时任务添...
|
30
|
import java.util.concurrent.locks.Lock;
|
5f57db6b
姜超
fix(*): 薪酬编码修改、绩效...
|
31
|
import java.util.stream.Collectors;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
32
33
34
35
36
37
38
39
40
41
42
|
/**
* @author : jiangchao
* @className : KpiGroupStatusTask
* @description : 绩效组人员定时器
* @date : 2022-04-07 15:29
*/
@Component
@Slf4j
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = "task", name = "switch", havingValue = "on")
|
d2feb148
姜超
feature(*): 绩效组人员...
|
43
|
public class KpiGroupUserTask {
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
44
|
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
45
46
47
|
private final KpiGroupUserBizService kpiGroupUserBizService;
private final KpiGroupUserService kpiGroupUserService;
private final KpiGroupBizService kpiGroupBizService;
|
e3e0c571
姜超
feature(*): 定时任务添...
|
48
49
|
private final DistributedLocker distributedLocker;
|
7d59a85e
姜超
feature(*): redis...
|
50
51
52
|
@Value("${spring.cache.custom.global-prefix}:kpi:group:user")
@Getter
private String kpiGroupUserDistKey;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
53
|
/**
|
98350563
姜超
fix(*): 修改corn表达式...
|
54
|
* 每天凌晨30分执行(人事角色、岗位调整在5点执行)
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
55
56
57
58
|
* 1. 将待生效数据改为生效中
* 2. 将之前的配置设置为失效
* 3. 处理重复数据,合并、拆分门店的绩效组配置需要把其他的重复配置失效
*/
|
b05ea76a
姜超
feature(*): 定时任务日志打印
|
59
|
@Scheduled(cron = TimeTaskConstant.KPI_GROUP_USER)
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
60
61
|
@Transactional(rollbackFor = Exception.class)
public void processKpiUser() {
|
7d59a85e
姜超
feature(*): redis...
|
62
|
Lock lock = distributedLocker.lock(getKpiGroupUserDistKey());
|
e3e0c571
姜超
feature(*): 定时任务添...
|
63
64
|
if (((RLock) lock).isLocked()) {
try {
|
b05ea76a
姜超
feature(*): 定时任务日志打印
|
65
|
log.info("定时任务【绩效组人员更新】开始执行");
|
e3e0c571
姜超
feature(*): 定时任务添...
|
66
67
68
|
StopWatch stopWatch = new StopWatch();
stopWatch.start("绩效组人员更新,查询人事系统人员状态");
//查询员工
|
5f57db6b
姜超
fix(*): 薪酬编码修改、绩效...
|
69
70
|
LocalDate yesterday = LocalDate.now().minusDays(1);
List<KpiGroupUser> kpiGroupUsersForSave = this.queryKpiStaff(yesterday);
|
e3e0c571
姜超
feature(*): 定时任务添...
|
71
72
73
74
75
76
|
stopWatch.stop();
if (PublicUtil.isEmpty(kpiGroupUsersForSave)) {
log.info(stopWatch.prettyPrint());
return;
}
stopWatch.start("绩效组人员保存,保存条数:"+ kpiGroupUsersForSave.size());
|
5f57db6b
姜超
fix(*): 薪酬编码修改、绩效...
|
77
78
79
80
81
82
83
84
|
//逻辑删除今天已保存人员,保存人员
Set<Long> kpiGroupIds = kpiGroupUsersForSave.stream().map(KpiGroupUser::getKpiGroupId).collect(Collectors.toSet());
kpiGroupUserService.update(Wrappers.<KpiGroupUser>lambdaUpdate()
.in(KpiGroupUser::getKpiGroupId, kpiGroupIds)
.eq(KpiGroupUser::getDataDate, yesterday)
.eq(KpiGroupUser::getYn, Boolean.TRUE)
.set(KpiGroupUser::getYn, Boolean.FALSE)
);
|
e3e0c571
姜超
feature(*): 定时任务添...
|
85
86
87
88
89
90
91
92
|
kpiGroupUserService.saveBatch(kpiGroupUsersForSave);
stopWatch.stop();
log.info(stopWatch.prettyPrint(TimeUnit.SECONDS));
} catch (Exception e){
log.error(e.getMessage(), e);
} finally {
lock.unlock();
}
|
4b07306b
姜超
feature(*): 星级特殊调整申请
|
93
|
}
|
4b07306b
姜超
feature(*): 星级特殊调整申请
|
94
95
96
97
98
99
|
}
/**
* 查询绩效员工
* @return
*/
|
5f57db6b
姜超
fix(*): 薪酬编码修改、绩效...
|
100
|
private List<KpiGroupUser> queryKpiStaff(LocalDate yesterday) {
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
101
|
Map<Long, List<KpiGroup>> postKpis = kpiGroupBizService.postEffectKpis();
|
3349b957
姜超
fix(kpiReportServ...
|
102
103
104
|
if (! postKpis.isEmpty()) {
log.info("需要生成绩效组人员的绩效组:{}", postKpis);
}
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
105
|
Long postId = null;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
106
|
List<KpiGroup> kpiGroups = null;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
107
108
|
List<KpiGroupUser> kpiGroupUsers = null;
List<KpiGroupUser> kpiGroupUsersForSave = Lists.newArrayListWithCapacity(300);
|
8fb407fa
姜超
fix(kpigroupuser)...
|
109
|
KpiIgnoreCauseEnum filterEnum = KpiIgnoreCauseEnum.PROBATION;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
110
111
112
|
for (Map.Entry<Long, List<KpiGroup>> entry : postKpis.entrySet()) {
postId = entry.getKey();
kpiGroups = entry.getValue();
|
8fb407fa
姜超
fix(kpigroupuser)...
|
113
|
kpiGroupUsers = kpiGroupUserBizService.fetchBuildKpiUser(postId, kpiGroups, yesterday).stream()
|
43fb9eed
姜超
feature(*): 薪酬详情查询修改
|
114
|
// .filter(user -> (PublicUtil.isEmpty(user.getIgnoreCause()) || (! filterEnum.equals(user.getIgnoreCause()))))
|
8fb407fa
姜超
fix(kpigroupuser)...
|
115
|
.collect(Collectors.toList());
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
116
117
118
|
kpiGroupUsersForSave.addAll(kpiGroupUsers);
}
|
4b07306b
姜超
feature(*): 星级特殊调整申请
|
119
|
return kpiGroupUsersForSave;
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
120
121
|
}
|
dc2eb3fa
姜超
feature(*): 绩效组人员查看
|
122
|
}
|