|
@@ -0,0 +1,66 @@
|
|
1
|
+package com.lyg.application.util;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
5
|
+import com.lyg.application.entity.TaIncompatible;
|
|
6
|
+import com.lyg.application.entity.TaRotation;
|
|
7
|
+import com.lyg.application.mapper.TaIncompatibleMapper;
|
|
8
|
+import com.lyg.application.mapper.TaRotationMapper;
|
|
9
|
+import com.lyg.application.service.TaIncompatibleService;
|
|
10
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
11
|
+import org.springframework.stereotype.Component;
|
|
12
|
+
|
|
13
|
+import java.time.LocalDate;
|
|
14
|
+import java.time.format.DateTimeFormatter;
|
|
15
|
+import java.util.ArrayList;
|
|
16
|
+import java.util.List;
|
|
17
|
+import java.util.Map;
|
|
18
|
+
|
|
19
|
+@Component
|
|
20
|
+public class Rule {
|
|
21
|
+
|
|
22
|
+ @Autowired
|
|
23
|
+ TaIncompatibleService taIncompatibleService;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+ @Autowired
|
|
27
|
+ TaIncompatibleMapper taIncompatibleMapper;
|
|
28
|
+ @Autowired
|
|
29
|
+ TaRotationMapper taRotationMapper;
|
|
30
|
+
|
|
31
|
+ public List<TaIncompatible> regularRules(String primaryPost, String targetPost) {
|
|
32
|
+ return taIncompatibleService.getRegularRules(primaryPost, targetPost);
|
|
33
|
+
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+ public List<TaRotation> getMonthRules(Map<String, String> params) {
|
|
38
|
+ List<TaRotation> repelList = new ArrayList<>();
|
|
39
|
+
|
|
40
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
41
|
+
|
|
42
|
+ QueryWrapper<TaRotation> queryWrapper = new QueryWrapper<>();
|
|
43
|
+ String primaryPost = params.get("primaryPost");
|
|
44
|
+ String targetPost = params.get("targetPost");
|
|
45
|
+ String passTime = params.get("passTime");
|
|
46
|
+ LocalDate newDate = LocalDate.parse(passTime, formatter).minusMonths(3);
|
|
47
|
+
|
|
48
|
+ List<String> oldPostList = taIncompatibleMapper.getMonthRulesPrimary(primaryPost);//原来岗位+目标不相容岗位
|
|
49
|
+ List<String> newPostList = taIncompatibleMapper.getMonthRulesTarget(targetPost);//目标岗位+原来不相容岗位
|
|
50
|
+
|
|
51
|
+ if (oldPostList.size() == 0 && newPostList.size() == 0) {
|
|
52
|
+ return repelList;
|
|
53
|
+ } else {
|
|
54
|
+ List<String> orgList = newPostList;//原来岗位 不相容的
|
|
55
|
+ orgList.add(orgList.size() - 1, primaryPost);
|
|
56
|
+
|
|
57
|
+ List<String> targetList = oldPostList;//目标岗位 不相容的
|
|
58
|
+ targetList.add(targetList.size() - 1, targetPost);
|
|
59
|
+
|
|
60
|
+ // 拿到数据 不相容轮岗数据
|
|
61
|
+ repelList = taRotationMapper.selectRepel(orgList, targetList, newDate);
|
|
62
|
+
|
|
63
|
+ return repelList;
|
|
64
|
+ }
|
|
65
|
+ }
|
|
66
|
+}
|