张涛 1 jaar geleden
bovenliggende
commit
2f56341dcb
23 gewijzigde bestanden met toevoegingen van 395 en 196 verwijderingen
  1. 1
    3
      application/src/main/java/com/lyg/application/Listener/EntityHandler.java
  2. 13
    9
      application/src/main/java/com/lyg/application/Listener/TaMandatoryLeaveListener.java
  3. 69
    0
      application/src/main/java/com/lyg/application/Listener/TaRotationListener.java
  4. 10
    32
      application/src/main/java/com/lyg/application/controller/TaIncompatibleController.java
  5. 67
    47
      application/src/main/java/com/lyg/application/controller/TaRotationController.java
  6. 11
    16
      application/src/main/java/com/lyg/application/controller/UploadController.java
  7. 8
    5
      application/src/main/java/com/lyg/application/mapper/TaIncompatibleMapper.java
  8. 1
    2
      application/src/main/java/com/lyg/application/service/TaIncompatibleService.java
  9. 6
    2
      application/src/main/java/com/lyg/application/service/TaMandatoryLeaveService.java
  10. 3
    1
      application/src/main/java/com/lyg/application/service/TaRotationService.java
  11. 32
    38
      application/src/main/java/com/lyg/application/service/impl/TaIncompatibleServiceImpl.java
  12. 13
    3
      application/src/main/java/com/lyg/application/service/impl/TaMandatoryLeaveServiceImpl.java
  13. 43
    14
      application/src/main/java/com/lyg/application/service/impl/TaRotationServiceImpl.java
  14. 78
    12
      application/src/main/java/com/lyg/application/util/Rule.java
  15. 3
    3
      application/src/main/resources/mapper/TaIncompatibleMapper.xml
  16. 1
    0
      application/src/main/resources/mapper/TaRotationMapper.xml
  17. 7
    0
      common/src/main/java/com/lyg/common/Constants.java
  18. 0
    1
      system/src/main/java/com/lyg/system/controller/SysPositionController.java
  19. 1
    0
      system/src/main/java/com/lyg/system/mapper/SysOrgMapper.java
  20. 7
    4
      system/src/main/java/com/lyg/system/mapper/SysPositionMapper.java
  21. 4
    3
      system/src/main/java/com/lyg/system/service/SysPositionService.java
  22. 8
    0
      system/src/main/resources/mapper/SysOrgMapper.xml
  23. 9
    1
      system/src/main/resources/mapper/SysPositionMapper.xml

application/src/main/java/com/lyg/application/dao/EntityHandler.java → application/src/main/java/com/lyg/application/Listener/EntityHandler.java Bestand weergeven

@@ -1,6 +1,4 @@
1
-package com.lyg.application.dao;
2
-
3
-import com.lyg.application.entity.TaRotation;
1
+package com.lyg.application.Listener;
4 2
 
5 3
 import java.util.List;
6 4
 

application/src/main/java/com/lyg/application/dao/UploadDataListener.java → application/src/main/java/com/lyg/application/Listener/TaMandatoryLeaveListener.java Bestand weergeven

@@ -1,7 +1,9 @@
1
-package com.lyg.application.dao;
1
+package com.lyg.application.Listener;
2 2
 
3 3
 import com.alibaba.excel.context.AnalysisContext;
4 4
 import com.alibaba.excel.read.listener.ReadListener;
5
+import com.lyg.application.entity.TaMandatoryLeave;
6
+import com.lyg.application.service.TaMandatoryLeaveService;
5 7
 import lombok.SneakyThrows;
6 8
 import lombok.extern.slf4j.Slf4j;
7 9
 
@@ -9,28 +11,30 @@ import java.util.ArrayList;
9 11
 import java.util.List;
10 12
 
11 13
 @Slf4j
12
-public class UploadDataListener<T> implements ReadListener<T> {
14
+public class TaMandatoryLeaveListener implements ReadListener<TaMandatoryLeave> {
13 15
 
14 16
 
15 17
     private static final int BATCH_COUNT = 10;
16 18
     final List<String> errorMessages = new ArrayList<>();
17
-    private final List<T> dataList = new ArrayList<>();
18
-    private final EntityHandler<T> entityHandler;
19
+    private final List<TaMandatoryLeave> dataList = new ArrayList<>();
19 20
 
20
-    public UploadDataListener(EntityHandler<T> entityHandler) {
21
-        this.entityHandler = entityHandler;
21
+    private final TaMandatoryLeaveService taMandatoryLeaveService;
22
+
23
+    public TaMandatoryLeaveListener(TaMandatoryLeaveService taMandatoryLeaveService) {
24
+        this.taMandatoryLeaveService = taMandatoryLeaveService;
22 25
     }
23 26
 
27
+
24 28
     @SneakyThrows
25 29
     @Override
26
-    public void invoke(T data, AnalysisContext context) {
30
+    public void invoke(TaMandatoryLeave data, AnalysisContext context) {
27 31
         log.info("解析到一条数据: {}", data);
28 32
         if (data == null) {
29 33
             throw new RuntimeException("excel读取失败");
30 34
         }
31 35
         Integer index = context.readRowHolder().getRowIndex() + 1;
32 36
 
33
-        T processedData = entityHandler.handleEntity(data, index);
37
+        TaMandatoryLeave processedData = taMandatoryLeaveService.handleEntity(data, index);
34 38
         if (processedData != null) {
35 39
             dataList.add(processedData);
36 40
             if (dataList.size() >= BATCH_COUNT) {
@@ -58,7 +62,7 @@ public class UploadDataListener<T> implements ReadListener<T> {
58 62
         log.info("正在读取 {} 条数据", dataList.size());
59 63
 //        log.info("错误信息列表: {}", errorMessages);
60 64
         if (!dataList.isEmpty()) { // 只有当数据列表不为空且没有错误信息时才保存数据
61
-            entityHandler.saveEntityBatch(dataList);
65
+            taMandatoryLeaveService.saveEntityBatch(dataList);
62 66
             dataList.clear();
63 67
         }
64 68
     }

+ 69
- 0
application/src/main/java/com/lyg/application/Listener/TaRotationListener.java Bestand weergeven

@@ -0,0 +1,69 @@
1
+package com.lyg.application.Listener;
2
+
3
+import com.alibaba.excel.context.AnalysisContext;
4
+import com.alibaba.excel.read.listener.ReadListener;
5
+import com.lyg.application.entity.TaRotation;
6
+import com.lyg.application.service.TaRotationService;
7
+import com.lyg.application.util.Rule;
8
+import lombok.SneakyThrows;
9
+import lombok.extern.slf4j.Slf4j;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+
12
+import java.util.ArrayList;
13
+import java.util.List;
14
+
15
+@Slf4j
16
+public class TaRotationListener implements ReadListener<TaRotation> {
17
+
18
+
19
+    private static final int BATCH_COUNT = 10;
20
+    final List<String> errorMessages = new ArrayList<>();
21
+    private final List<TaRotation> dataList = new ArrayList<>();
22
+
23
+    private final TaRotationService taRotationService;
24
+
25
+    public TaRotationListener(TaRotationService taRotationService) {
26
+        this.taRotationService = taRotationService;
27
+    }
28
+
29
+
30
+    @SneakyThrows
31
+    @Override
32
+    public void invoke(TaRotation data, AnalysisContext context) {
33
+        log.info("解析到一条数据: {}", data);
34
+        if (data == null) {
35
+            throw new RuntimeException("excel读取失败");
36
+        }
37
+        Integer index = context.readRowHolder().getRowIndex() + 1;
38
+
39
+        TaRotation processedData = taRotationService.handleEntity(data, index);
40
+        if (processedData != null) {
41
+            dataList.add(processedData);
42
+            if (dataList.size() >= BATCH_COUNT) {
43
+                saveData();
44
+            }
45
+        }
46
+    }
47
+
48
+    @Override
49
+    public void doAfterAllAnalysed(AnalysisContext context) {
50
+        saveData();
51
+        log.info("所有数据解析完成!");
52
+    }
53
+//    public List<String> getErrorMessages() {
54
+//        return errorMessages;
55
+//    }
56
+
57
+//    public List<T> getDataList() {
58
+//        return dataList;
59
+//    }
60
+
61
+    public void saveData() {
62
+        log.info("正在读取 {} 条数据", dataList.size());
63
+//        log.info("错误信息列表: {}", errorMessages);
64
+        if (!dataList.isEmpty()) { // 只有当数据列表不为空且没有错误信息时才保存数据
65
+            taRotationService.saveEntityBatch(dataList);
66
+            dataList.clear();
67
+        }
68
+    }
69
+}

+ 10
- 32
application/src/main/java/com/lyg/application/controller/TaIncompatibleController.java Bestand weergeven

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 7
 import com.lyg.application.entity.TaIncompatible;
8
-import com.lyg.application.entity.TaRotation;
9 8
 import com.lyg.application.service.TaIncompatibleService;
10 9
 import com.lyg.application.util.Rule;
11 10
 import com.lyg.common.util.StringUtil;
@@ -20,7 +19,6 @@ import org.springframework.validation.annotation.Validated;
20 19
 import org.springframework.web.bind.annotation.*;
21 20
 
22 21
 import java.util.Hashtable;
23
-import java.util.List;
24 22
 import java.util.Map;
25 23
 
26 24
 /**
@@ -130,7 +128,7 @@ public class TaIncompatibleController extends BaseController {
130 128
 
131 129
 
132 130
     /**
133
-     * 分页查询
131
+     *
134 132
      */
135 133
     @OpLog(module = "不相容规则查询", action = "")
136 134
     @AccessLimit()
@@ -146,37 +144,17 @@ public class TaIncompatibleController extends BaseController {
146 144
 
147 145
         Map<String, String> params = new Hashtable<>();
148 146
 
149
-
150 147
         if (oldOrgCode != null && newOrgCode != null && primaryPost != null && targetPost != null && passTime != null) {
148
+            params.put("oldOrgCode", oldOrgCode);
149
+            params.put("newOrgCode", newOrgCode);
150
+            params.put("primaryPost", primaryPost);
151
+            params.put("targetPost", targetPost);
152
+            params.put("passTime", passTime);
153
+
154
+            Object result = rule.siftRule(params);
155
+
156
+            return SaResult.data(result);
151 157
 
152
-            //普通规则
153
-            if (oldOrgCode.equals(newOrgCode)) {
154
-                List<TaIncompatible> taIncompatibleList = rule.regularRules(primaryPost, targetPost);
155
-
156
-//                List<TaIncompatible> taIncompatibleList = taIncompatibleService.getRegularRules(, );
157
-
158
-                if (taIncompatibleList.size() == 0) {
159
-                    return SaResult.data("普通规则:根据不相容设置这两个岗位是相容的");
160
-                } else {
161
-                    return SaResult.data(taIncompatibleList);
162
-                }
163
-
164
-            } else {
165
-                params.put("oldOrgCode", oldOrgCode);
166
-                params.put("newOrgCode", newOrgCode);
167
-                params.put("primaryPost", primaryPost);
168
-                params.put("targetPost", targetPost);
169
-                params.put("passTime", passTime);
170
-                //三个月规则
171
-                List<TaRotation> repelList =rule.getMonthRules(params);
172
-//                List<TaRotation> repelList = taIncompatibleService.getMonthRules(params);
173
-                if (repelList.size() == 0) {
174
-                    return SaResult.data("三个月规则: 这是两个岗位是相容的");
175
-                } else {
176
-                    return SaResult.data(repelList);
177
-                }
178
-
179
-            }
180 158
         }
181 159
         return SaResult.error("请输入岗位或机构号");
182 160
 

+ 67
- 47
application/src/main/java/com/lyg/application/controller/TaRotationController.java Bestand weergeven

@@ -4,23 +4,24 @@ import cn.dev33.satoken.util.SaResult;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
-import java.util.List;
8
-import com.lyg.common.Constants;
7
+import com.lyg.application.entity.TaRotation;
8
+import com.lyg.application.service.TaRotationService;
9
+import com.lyg.application.util.Rule;
9 10
 import com.lyg.common.util.StringUtil;
11
+import com.lyg.framework.accesslimit.AccessLimit;
10 12
 import com.lyg.framework.log.OpLog;
11 13
 import com.lyg.system.controller.BaseController;
12
-import com.lyg.framework.accesslimit.AccessLimit;
14
+import com.lyg.system.mapper.SysOrgMapper;
13 15
 import io.swagger.annotations.Api;
14 16
 import io.swagger.annotations.ApiOperation;
15 17
 import io.swagger.annotations.ApiParam;
16 18
 import org.springframework.beans.factory.annotation.Autowired;
17 19
 import org.springframework.validation.annotation.Validated;
18 20
 import org.springframework.web.bind.annotation.*;
19
-import com.lyg.application.entity.TaRotation;
20
-import com.lyg.application.service.TaRotationService;
21 21
 
22
- /**
22
+/**
23 23
  * 轮岗列表;(ta_rotation)表控制层
24
+ *
24 25
  * @author : http://njyunzhi.com
25 26
  * @date : 2024-3-6
26 27
  */
@@ -28,12 +29,18 @@ import com.lyg.application.service.TaRotationService;
28 29
 @RestController
29 30
 @RequestMapping("/")
30 31
 public class TaRotationController extends BaseController {
31
-    
32
+
32 33
     @Autowired
33 34
     private TaRotationService taRotationService;
34
-    
35
-    /** 
36
-     * 通过ID查询单条数据 
35
+    @Autowired
36
+    private Rule rule;
37
+
38
+    @Autowired
39
+    private SysOrgMapper sysOrgMapper;
40
+
41
+
42
+    /**
43
+     * 通过ID查询单条数据
37 44
      *
38 45
      * @param id 主键
39 46
      * @return 实例对象
@@ -45,11 +52,11 @@ public class TaRotationController extends BaseController {
45 52
     public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
46 53
         return SaResult.data(taRotationService.getById(id));
47 54
     }
48
-    
49
-    /** 
55
+
56
+    /**
50 57
      * 分页查询
51 58
      *
52
-     * @param pageNum 当前页码
59
+     * @param pageNum  当前页码
53 60
      * @param pageSize 每页条数
54 61
      * @return 查询结果
55 62
      */
@@ -57,41 +64,41 @@ public class TaRotationController extends BaseController {
57 64
     @AccessLimit()
58 65
     @ApiOperation("分页查询")
59 66
     @GetMapping("/taRotation")
60
-    public SaResult list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
62
-                         @ApiParam("总行部门/一级分行") @RequestParam(value ="headOfficeOrg",required = false) String headOfficeOrg,
63
-                         @ApiParam("员工工号") @RequestParam(value ="employeeNum",required = false) String employeeNum,
64
-                         @ApiParam("员工姓名") @RequestParam(value ="employeeName",required = false) String employeeName,
65
-                         @ApiParam("具体单位机构号") @RequestParam(value ="specificOrgNum",required = false) String specificOrgNum,
66
-                         @ApiParam("所在单位具体名称") @RequestParam(value ="specificOrgName",required = false) String specificOrgName,
67
-                         @ApiParam("对应机构层次") @RequestParam(value ="counterInstitutionsLevel",required = false) String counterInstitutionsLevel,
68
-                         @ApiParam("对应重要岗位") @RequestParam(value ="counterImpPositions",required = false) String counterImpPositions,
69
-                         @ApiParam("对应总行条线") @RequestParam(value ="counterHeadOfficeLine",required = false) String counterHeadOfficeLine,
70
-
71
-
72
-                         @ApiParam("正序排列") @RequestParam(value ="sortAsc", defaultValue = "create_date") String sortAsc,
73
-                         @ApiParam("倒序排列") @RequestParam(value ="sortDesc",required = false) String sortDesc
67
+    public SaResult list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
68
+                         @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
69
+                         @ApiParam("总行部门/一级分行") @RequestParam(value = "headOfficeOrg", required = false) String headOfficeOrg,
70
+                         @ApiParam("员工工号") @RequestParam(value = "employeeNum", required = false) String employeeNum,
71
+                         @ApiParam("员工姓名") @RequestParam(value = "employeeName", required = false) String employeeName,
72
+                         @ApiParam("具体单位机构号") @RequestParam(value = "specificOrgNum", required = false) String specificOrgNum,
73
+                         @ApiParam("所在单位具体名称") @RequestParam(value = "specificOrgName", required = false) String specificOrgName,
74
+                         @ApiParam("对应机构层次") @RequestParam(value = "counterInstitutionsLevel", required = false) String counterInstitutionsLevel,
75
+                         @ApiParam("对应重要岗位") @RequestParam(value = "counterImpPositions", required = false) String counterImpPositions,
76
+                         @ApiParam("对应总行条线") @RequestParam(value = "counterHeadOfficeLine", required = false) String counterHeadOfficeLine,
77
+
78
+
79
+                         @ApiParam("正序排列") @RequestParam(value = "sortAsc", defaultValue = "create_date") String sortAsc,
80
+                         @ApiParam("倒序排列") @RequestParam(value = "sortDesc", required = false) String sortDesc
74 81
     ) throws Exception {
75
-        
82
+
76 83
         IPage<TaRotation> pg = new Page<>(pageNum, pageSize);
77 84
         QueryWrapper<TaRotation> queryWrapper = new QueryWrapper<>();
78
-        queryWrapper.like(StringUtil.isNotEmpty(headOfficeOrg),"head_office_org",headOfficeOrg);
79
-        queryWrapper.eq(StringUtil.isNotEmpty(employeeNum),"employee_num",employeeNum);
80
-        queryWrapper.like(StringUtil.isNotEmpty(employeeName),"employee_name",employeeName);
81
-        queryWrapper.eq(StringUtil.isNotEmpty(specificOrgNum),"specific_org_num",specificOrgNum);
82
-        queryWrapper.like(StringUtil.isNotEmpty(specificOrgName),"specific_org_name",specificOrgName);
83
-        queryWrapper.like(StringUtil.isNotEmpty(counterInstitutionsLevel),"counter_institutions_level",counterInstitutionsLevel);
84
-        queryWrapper.like(StringUtil.isNotEmpty(counterImpPositions),"counter_imp_positions",counterImpPositions);
85
-        queryWrapper.like(StringUtil.isNotEmpty(counterHeadOfficeLine),"counter_head_office_line",counterHeadOfficeLine);
85
+        queryWrapper.like(StringUtil.isNotEmpty(headOfficeOrg), "head_office_org", headOfficeOrg);
86
+        queryWrapper.eq(StringUtil.isNotEmpty(employeeNum), "employee_num", employeeNum);
87
+        queryWrapper.like(StringUtil.isNotEmpty(employeeName), "employee_name", employeeName);
88
+        queryWrapper.eq(StringUtil.isNotEmpty(specificOrgNum), "specific_org_num", specificOrgNum);
89
+        queryWrapper.like(StringUtil.isNotEmpty(specificOrgName), "specific_org_name", specificOrgName);
90
+        queryWrapper.like(StringUtil.isNotEmpty(counterInstitutionsLevel), "counter_institutions_level", counterInstitutionsLevel);
91
+        queryWrapper.like(StringUtil.isNotEmpty(counterImpPositions), "counter_imp_positions", counterImpPositions);
92
+        queryWrapper.like(StringUtil.isNotEmpty(counterHeadOfficeLine), "counter_head_office_line", counterHeadOfficeLine);
86 93
 
87 94
         queryWrapper.orderByAsc(StringUtil.isNotEmpty(sortAsc), StringUtil.humpToLine(sortAsc));
88 95
         queryWrapper.orderByDesc(StringUtil.isNotEmpty(sortDesc), StringUtil.humpToLine(sortDesc));
89 96
         IPage<TaRotation> result = taRotationService.page(pg, queryWrapper);
90
-        
97
+
91 98
         return SaResult.data(result);
92 99
     }
93
-    
94
-    /** 
100
+
101
+    /**
95 102
      * 新增数据
96 103
      *
97 104
      * @param taRotation 实例对象
@@ -102,11 +109,22 @@ public class TaRotationController extends BaseController {
102 109
     @ApiOperation("新增数据")
103 110
     @PostMapping("/taRotation")
104 111
     public SaResult add(@ApiParam("对象实体") @Validated @RequestBody TaRotation taRotation) throws Exception {
112
+
113
+
114
+        String specificOrgNum = taRotation.getSpecificOrgName();//轮岗前具体单位名称 传来的是orgId
115
+//        String specificOrgNum = taRotation.getSpecificOrgNum();//轮岗前单位号
116
+        String specificNameOrgRotation = taRotation.getSpecificNameOrgRotation();//轮岗后具体单位名称
117
+        String orgNumJobRotation = taRotation.getOrgNumJobRotation();//轮岗后单位号
118
+        String specificOrgName = sysOrgMapper.getOrgId(specificOrgNum);
119
+        taRotation.setSpecificOrgNum(specificOrgName);
120
+        taRotation.setSpecificOrgName();
105 121
         taRotationService.save(taRotation);
106
-        return SaResult.data(taRotation);
122
+        Object result = rule.taRotationRule(taRotation);
123
+
124
+        return SaResult.data(result);
107 125
     }
108
-    
109
-    /** 
126
+
127
+    /**
110 128
      * 更新数据
111 129
      *
112 130
      * @param taRotation 实例对象
@@ -117,13 +135,15 @@ public class TaRotationController extends BaseController {
117 135
     @ApiOperation("更新数据")
118 136
     @PutMapping("/taRotation/{id}")
119 137
     public SaResult edit(@ApiParam("对象实体") @Validated @RequestBody TaRotation taRotation,
120
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
138
+                         @ApiParam("对象ID") @PathVariable String id) throws Exception {
121 139
         taRotation.setRotationId(id);
122 140
         taRotationService.updateById(taRotation);
123
-        return SaResult.data(taRotation);
141
+        Object result = rule.taRotationRule(taRotation);
142
+        return SaResult.data(result);
143
+
124 144
     }
125
-    
126
-    /** 
145
+
146
+    /**
127 147
      * 通过主键删除数据
128 148
      *
129 149
      * @param id 主键
@@ -133,7 +153,7 @@ public class TaRotationController extends BaseController {
133 153
     @AccessLimit()
134 154
     @ApiOperation("通过主键删除数据")
135 155
     @DeleteMapping("/taRotation/{id}")
136
-    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id){
156
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id) {
137 157
         taRotationService.removeById(id);
138 158
         return SaResult.data("success");
139 159
     }

+ 11
- 16
application/src/main/java/com/lyg/application/controller/UploadController.java Bestand weergeven

@@ -2,9 +2,11 @@ package com.lyg.application.controller;
2 2
 
3 3
 import cn.dev33.satoken.util.SaResult;
4 4
 import com.alibaba.excel.EasyExcel;
5
-import com.lyg.application.dao.UploadDataListener;
5
+import com.lyg.application.Listener.TaMandatoryLeaveListener;
6
+import com.lyg.application.Listener.TaRotationListener;
6 7
 import com.lyg.application.entity.TaMandatoryLeave;
7 8
 import com.lyg.application.entity.TaRotation;
9
+import com.lyg.application.service.TaMandatoryLeaveService;
8 10
 import com.lyg.application.service.TaRotationService;
9 11
 import com.lyg.application.service.impl.TaMandatoryLeaveServiceImpl;
10 12
 import com.lyg.application.service.impl.TaRotationServiceImpl;
@@ -14,7 +16,6 @@ import io.swagger.annotations.Api;
14 16
 import io.swagger.annotations.ApiOperation;
15 17
 import io.swagger.annotations.ApiParam;
16 18
 import org.springframework.beans.factory.annotation.Autowired;
17
-import org.springframework.scheduling.annotation.Scheduled;
18 19
 import org.springframework.web.bind.annotation.*;
19 20
 import org.springframework.web.multipart.MultipartFile;
20 21
 
@@ -41,6 +42,8 @@ public class UploadController extends BaseController {
41 42
 
42 43
     @Autowired
43 44
     private TaRotationServiceImpl taRotationServiceImpl;
45
+    @Autowired
46
+    private TaMandatoryLeaveService taMandatoryLeaveService;
44 47
 
45 48
     @Autowired
46 49
     private TaMandatoryLeaveServiceImpl taMandatoryLeaveServiceImpl;
@@ -57,13 +60,13 @@ public class UploadController extends BaseController {
57 60
         try {
58 61
 
59 62
             InputStream inputStream = file.getInputStream();
60
-            UploadDataListener<TaRotation> uploadDataListener = new UploadDataListener<>(taRotationServiceImpl);
61
-            EasyExcel.read(inputStream, TaRotation.class, uploadDataListener).sheet().headRowNumber(4).doRead();
63
+            TaRotationListener taRotationListener = new TaRotationListener(taRotationService);
64
+            EasyExcel.read(inputStream, TaRotation.class, taRotationListener).sheet().headRowNumber(4).doRead();
62 65
 
63
-            List<String> errorMessages = taRotationServiceImpl.getErrorMessages();
66
+            List<Object> errorMessages = taRotationServiceImpl.getErrorMessages();
64 67
             StringBuilder errorMessageBuilder = new StringBuilder();
65 68
 
66
-            for (String errorMessage : errorMessages) {
69
+            for (Object errorMessage : errorMessages) {
67 70
                 errorMessageBuilder.append(errorMessage).append("\n");
68 71
             }
69 72
 
@@ -90,8 +93,8 @@ public class UploadController extends BaseController {
90 93
         try {
91 94
 
92 95
             InputStream inputStream = file.getInputStream();
93
-            UploadDataListener<TaMandatoryLeave> uploadDataListener = new UploadDataListener<>(taMandatoryLeaveServiceImpl);
94
-            EasyExcel.read(inputStream, TaMandatoryLeave.class, uploadDataListener).sheet().headRowNumber(4).doRead();
96
+            TaMandatoryLeaveListener taMandatoryLeaveListener = new TaMandatoryLeaveListener(taMandatoryLeaveService);
97
+            EasyExcel.read(inputStream, TaMandatoryLeave.class, taMandatoryLeaveListener).sheet().headRowNumber(4).doRead();
95 98
 
96 99
             List<String> errorMessages = taMandatoryLeaveServiceImpl.getErrorMessages();
97 100
             StringBuilder errorMessageBuilder = new StringBuilder();
@@ -112,8 +115,6 @@ public class UploadController extends BaseController {
112 115
     }
113 116
 
114 117
 
115
-
116
-
117 118
 //
118 119
 //    @AccessLimit()
119 120
 //    @ApiOperation("提示/预警")
@@ -128,10 +129,4 @@ public class UploadController extends BaseController {
128 129
 //    }
129 130
 
130 131
 
131
-
132
-
133
-
134
-
135
-
136
-
137 132
 }

+ 8
- 5
application/src/main/java/com/lyg/application/mapper/TaIncompatibleMapper.java Bestand weergeven

@@ -1,23 +1,26 @@
1 1
 package com.lyg.application.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.application.entity.TaIncompatible;
4 5
 import org.apache.ibatis.annotations.Mapper;
5 6
 import org.apache.ibatis.annotations.Param;
6
-import com.lyg.application.entity.TaIncompatible;
7 7
 
8 8
 import java.util.List;
9 9
 
10 10
 /**
11 11
  * 不相容;(ta_incompatible)表数据库访问层
12
+ *
12 13
  * @author : http://njyunzhi.com
13 14
  * @date : 2024-3-6
14 15
  */
15 16
 @Mapper
16
-public interface TaIncompatibleMapper  extends BaseMapper<TaIncompatible>{
17
+public interface TaIncompatibleMapper extends BaseMapper<TaIncompatible> {
18
+
19
+    List<TaIncompatible> getRegularRules(@Param("oldOrgName") String oldOrgName, @Param("newOrgName") String newOrgName, @Param("regularRule") String regularRule);
20
+
21
+    List<String> getMonthRulesPrimary(@Param("primaryPost") String primaryPost, @Param("monthRule") String monthRule);
17 22
 
18
-     List<TaIncompatible> getRegularRules(@Param("oldOrgName") String oldOrgName, @Param("newOrgName") String newOrgName);
23
+    List<String> getMonthRulesTarget(@Param("targetPost") String targetPost, @Param("monthRule") String monthRule);
19 24
 
20
-    List<String> getMonthRulesPrimary(@Param("primaryPost") String primaryPost);
21 25
 
22
-    List<String> getMonthRulesTarget(@Param("targetPost") String targetPost);
23 26
 }

+ 1
- 2
application/src/main/java/com/lyg/application/service/TaIncompatibleService.java Bestand weergeven

@@ -16,7 +16,6 @@ import java.util.Map;
16 16
 public interface TaIncompatibleService extends IBaseService<TaIncompatible> {
17 17
 
18 18
 
19
-    List<TaIncompatible> getRegularRules(String primaryPost, String targetPost);
20 19
 
21
-    List<TaRotation> getMonthRules(Map<String, String> params);
20
+//    List<TaRotation> getMonthRules(Map<String, String> params);
22 21
 }

+ 6
- 2
application/src/main/java/com/lyg/application/service/TaMandatoryLeaveService.java Bestand weergeven

@@ -2,13 +2,17 @@ package com.lyg.application.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.lyg.application.entity.TaMandatoryLeave;
5
+import com.lyg.application.entity.TaRotation;
5 6
 import com.lyg.system.service.IBaseService;
6 7
 
7
- /**
8
+import java.util.List;
9
+
10
+/**
8 11
  * 强制休假表;(ta_mandatory_leave)表服务接口
9 12
  * @author : http://njyunzhi.com
10 13
  * @date : 2024-3-6
11 14
  */
12 15
 public interface TaMandatoryLeaveService extends IBaseService<TaMandatoryLeave> {
13
-    
16
+ TaMandatoryLeave handleEntity(TaMandatoryLeave entity, Integer index) throws Exception;
17
+ void saveEntityBatch(List<TaMandatoryLeave> entityList);
14 18
 }

+ 3
- 1
application/src/main/java/com/lyg/application/service/TaRotationService.java Bestand weergeven

@@ -1,8 +1,8 @@
1 1
 package com.lyg.application.service;
2 2
 
3
+import cn.dev33.satoken.util.SaResult;
3 4
 import com.lyg.application.entity.TaRotation;
4 5
 import com.lyg.system.service.IBaseService;
5
-import org.apache.poi.ss.formula.functions.T;
6 6
 
7 7
 import java.util.List;
8 8
 
@@ -13,6 +13,8 @@ import java.util.List;
13 13
  * @date : 2024-3-6
14 14
  */
15 15
 public interface TaRotationService extends IBaseService<TaRotation> {
16
+    TaRotation handleEntity(TaRotation entity,Integer index) throws Exception;
17
+    void saveEntityBatch(List<TaRotation> entityList);
16 18
 
17 19
 //
18 20
 //    void handleEntity(List<T> entityList) throws Exception;

+ 32
- 38
application/src/main/java/com/lyg/application/service/impl/TaIncompatibleServiceImpl.java Bestand weergeven

@@ -37,42 +37,36 @@ public class TaIncompatibleServiceImpl extends BaseServiceImpl<TaIncompatibleMap
37 37
 //    }
38 38
 
39 39
 
40
-    @SneakyThrows
41
-    @Override
42
-    public List<TaIncompatible> getRegularRules(String oldOrgName, String newOrgName) {
43
-        return baseMapper.getRegularRules(oldOrgName, newOrgName);
44
-
45
-    }
46
-
47
-    @Override
48
-    public List<TaRotation> getMonthRules(Map<String, String> params) {
49
-        List<TaRotation> repelList = new ArrayList<>();
50
-
51
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
52
-
53
-        QueryWrapper<TaRotation> queryWrapper = new QueryWrapper<>();
54
-        String primaryPost = params.get("primaryPost");
55
-        String targetPost = params.get("targetPost");
56
-        String passTime = params.get("passTime");
57
-        LocalDate newDate = LocalDate.parse(passTime, formatter).minusMonths(3);
58
-
59
-        List<String> oldPostList = baseMapper.getMonthRulesPrimary(primaryPost);//原来岗位+目标不相容岗位
60
-        List<String> newPostList = baseMapper.getMonthRulesTarget(targetPost);//目标岗位+原来不相容岗位
61
-
62
-        if (oldPostList.size() == 0 && newPostList.size() == 0) {
63
-            return repelList;
64
-        } else {
65
-            List<String> orgList = newPostList;//原来岗位 不相容的
66
-            orgList.add(orgList.size() - 1, primaryPost);
67
-
68
-            List<String> targetList = oldPostList;//目标岗位 不相容的
69
-            targetList.add(targetList.size() - 1, targetPost);
70
-
71
-            //                拿到数据 不相容轮岗数据
72
-            repelList = taRotationMapper.selectRepel(orgList, targetList,newDate);
73
-
74
-            return repelList;
75
-        }
76
-
77
-    }
40
+//
41
+//
42
+//    @Override
43
+//    public List<TaRotation> getMonthRules(Map<String, String> params) {
44
+//        List<TaRotation> repelList = new ArrayList<>();
45
+//
46
+//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
47
+//
48
+//        QueryWrapper<TaRotation> queryWrapper = new QueryWrapper<>();
49
+//        String primaryPost = params.get("primaryPost");
50
+//        String targetPost = params.get("targetPost");
51
+//        String passTime = params.get("passTime");
52
+//        LocalDate newDate = LocalDate.parse(passTime, formatter).minusMonths(3);
53
+//
54
+//        List<String> oldPostList = baseMapper.getMonthRulesPrimary(primaryPost);//原来岗位+目标不相容岗位
55
+//        List<String> newPostList = baseMapper.getMonthRulesTarget(targetPost);//目标岗位+原来不相容岗位
56
+//
57
+//        if (oldPostList.size() == 0 && newPostList.size() == 0) {
58
+//            return repelList;
59
+//        } else {
60
+//            List<String> orgList = newPostList;//原来岗位 不相容的
61
+//            orgList.add(orgList.size() - 1, primaryPost);
62
+//
63
+//            List<String> targetList = oldPostList;//目标岗位 不相容的
64
+//            targetList.add(targetList.size() - 1, targetPost);
65
+//
66
+//            //                拿到数据 不相容轮岗数据
67
+//            repelList = taRotationMapper.selectRepel(orgList, targetList,newDate);
68
+//
69
+//            return repelList;
70
+//        }
71
+//    }
78 72
 }

+ 13
- 3
application/src/main/java/com/lyg/application/service/impl/TaMandatoryLeaveServiceImpl.java Bestand weergeven

@@ -1,9 +1,9 @@
1 1
 package com.lyg.application.service.impl;
2 2
 
3
-import com.lyg.application.dao.EntityHandler;
4 3
 import com.lyg.application.entity.TaMandatoryLeave;
5 4
 import com.lyg.application.mapper.TaMandatoryLeaveMapper;
6 5
 import com.lyg.application.service.TaMandatoryLeaveService;
6
+import com.lyg.system.mapper.SysPositionMapper;
7 7
 import com.lyg.system.service.SysOrgService;
8 8
 import com.lyg.system.service.SysPositionService;
9 9
 import com.lyg.system.service.impl.BaseServiceImpl;
@@ -21,12 +21,14 @@ import java.util.List;
21 21
  * @date : 2024-3-6
22 22
  */
23 23
 @Service
24
-public class TaMandatoryLeaveServiceImpl extends BaseServiceImpl<TaMandatoryLeaveMapper, TaMandatoryLeave> implements TaMandatoryLeaveService, EntityHandler<TaMandatoryLeave> {
24
+public class TaMandatoryLeaveServiceImpl extends BaseServiceImpl<TaMandatoryLeaveMapper, TaMandatoryLeave> implements TaMandatoryLeaveService {
25 25
     private final List<String> errorMessages = new ArrayList<>();
26 26
     @Autowired
27 27
     private SysOrgService sysOrgService;
28 28
     @Autowired
29 29
     private SysPositionService sysPositionService;
30
+    @Autowired
31
+    private SysPositionMapper sysPositionMapper;
30 32
 
31 33
     @Override
32 34
     public TaMandatoryLeave handleEntity(TaMandatoryLeave entity, Integer index) throws Exception {
@@ -36,10 +38,18 @@ public class TaMandatoryLeaveServiceImpl extends BaseServiceImpl<TaMandatoryLeav
36 38
 
37 39
         String orgCode = entity.getOrgNum();//单位机构号
38 40
         String orgName = entity.getOrgName().replaceAll("\n", "");//单位机构名
39
-        String counterImpPost = entity.getCounterImpPost().replaceAll("\n", "");//岗位名
41
+
42
+        String counterImpPost = null;
43
+        if (entity.getCounterImpPost() != null) {
44
+            counterImpPost = entity.getCounterImpPost().replaceAll("\n", "");//岗位名
45
+            //        轮岗之前岗位名  获取id
46
+            String rotationId = sysPositionMapper.getPostId(counterImpPost);
47
+            entity.setCounterImpPost(rotationId);
48
+        }
40 49
         LocalDate durationOfEmployment = entity.getStartTimeVacation();
41 50
         LocalDate vacationDeadline = entity.getVacationDeadline();
42 51
 
52
+
43 53
         Long count = sysOrgService.countBy("org_id", orgCode, true);
44 54
         if (count == 0 || orgCode.isEmpty()) {
45 55
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构号 " + orgCode);

+ 43
- 14
application/src/main/java/com/lyg/application/service/impl/TaRotationServiceImpl.java Bestand weergeven

@@ -1,9 +1,10 @@
1 1
 package com.lyg.application.service.impl;
2 2
 
3
-import com.lyg.application.dao.EntityHandler;
4 3
 import com.lyg.application.entity.TaRotation;
5 4
 import com.lyg.application.mapper.TaRotationMapper;
6 5
 import com.lyg.application.service.TaRotationService;
6
+import com.lyg.application.util.Rule;
7
+import com.lyg.system.mapper.SysPositionMapper;
7 8
 import com.lyg.system.service.SysOrgService;
8 9
 import com.lyg.system.service.SysPositionService;
9 10
 import com.lyg.system.service.impl.BaseServiceImpl;
@@ -22,40 +23,60 @@ import java.util.List;
22 23
  */
23 24
 @Service
24 25
 
25
-public class TaRotationServiceImpl extends BaseServiceImpl<TaRotationMapper, TaRotation> implements TaRotationService, EntityHandler<TaRotation> {
26
+public class TaRotationServiceImpl extends BaseServiceImpl<TaRotationMapper, TaRotation> implements TaRotationService {
26 27
 
27
-    private final List<String> errorMessages = new ArrayList<>();
28
+    private final List<Object> errorMessages = new ArrayList<>();
29
+    @Autowired
30
+    Rule rule;
28 31
     @Autowired
29 32
     private SysOrgService sysOrgService;
30 33
     @Autowired
31 34
     private SysPositionService sysPositionService;
35
+    @Autowired
36
+    private SysPositionMapper sysPositionMapper;
32 37
 
33
-    @Override
34 38
     public TaRotation handleEntity(TaRotation entity, Integer index) throws Exception {
35 39
 //校验验证
36 40
         System.out.println("******************************entity**************************************");
37
-        System.out.println(entity);
41
+//        System.out.println(entity);
42
+
43
+        String specificNameOrgRotation = entity.getSpecificNameOrgRotation();
44
+        String counterImpPostRotation = entity.getCounterImpPostRotation();
45
+
38 46
 
39 47
         String orgCode = entity.getSpecificOrgNum();//单位机构号
40 48
         String orgName = entity.getSpecificOrgName().replaceAll("\n", "");//单位机构名
41
-        String rotationName = entity.getCounterImpPositions().replaceAll("\n", "");//岗位名
49
+        String rotationName = entity.getCounterImpPositions().replaceAll("\n", "");//轮岗之前岗位名
50
+        String impPostRotation = null;
51
+        if (entity.getCounterImpPostRotation() != null) {
52
+            impPostRotation = entity.getCounterImpPostRotation().replaceAll("\n", "");//轮岗之后岗位名
53
+        }
42 54
         LocalDate durationOfEmployment = entity.getDurationOfEmployment();
43 55
         LocalDate rotationExeTime = entity.getRotationExeTime();
44 56
         LocalDate rotationDeadline = entity.getRotationDeadline();
45 57
         LocalDate planRotationDate = entity.getPlanRotationDate();
58
+//        轮岗之前岗位名  获取id
59
+        String rotationId = sysPositionMapper.getPostId(rotationName);
60
+        entity.setCounterImpPositions(rotationId);
61
+        if(impPostRotation!=null){
62
+        //   轮岗之后岗位名  获取id
63
+        String impPostRotationId = sysPositionMapper.getPostId(impPostRotation);
64
+        entity.setCounterImpPostRotation(impPostRotationId);
65
+        }
66
+
46 67
 
47 68
         Long count = sysOrgService.countBy("org_id", orgCode, true);
48
-        if (count == 0||orgCode.isEmpty()) {
69
+        if (count == 0 || orgCode.isEmpty()) {
49 70
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构号 " + orgCode);
50 71
         }
51 72
 
52 73
         count = sysOrgService.countBy("name", orgName, true);
53
-        if (count == 0||orgName.isEmpty()) {
74
+        if (count == 0) {
54 75
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构名字 " + orgName);
55 76
         }
56 77
 
57 78
         count = sysPositionService.countBy("name", rotationName, true);
58
-        if (count == 0||rotationName.isEmpty()) {
79
+        if (count == 0 || rotationName.isEmpty()) {
59 80
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此岗位 " + rotationName);
60 81
         }
61 82
 
@@ -71,25 +92,33 @@ public class TaRotationServiceImpl extends BaseServiceImpl<TaRotationMapper, TaR
71 92
         if (planRotationDate == null) {
72 93
             errorMessages.add("第 " + index + " 行时间错误:计划轮岗日期 " + planRotationDate);
73 94
         }
95
+
96
+
97
+        if (orgName != null && specificNameOrgRotation != null && rotationName != null && counterImpPostRotation != null) {
98
+            Object result = rule.taRotationRule(entity);
99
+            errorMessages.add(result);
100
+        }
101
+
74 102
         return entity;
75 103
     }
76 104
 
105
+
77 106
     //    @Transactional(rollbackFor = Exception.class)
78
-    @Override
79 107
     public void saveEntityBatch(List<TaRotation> entityList) {
80 108
         // 实现逻辑:保存批量实体
81 109
         System.out.println("******************************entityList**************************************");
82 110
         System.out.println(entityList);
83 111
         for (TaRotation taRotation : entityList) {
112
+
113
+
84 114
             baseMapper.insert(taRotation);
115
+
85 116
         }
86 117
     }
87 118
 
88 119
 
89
-    public List<String> getErrorMessages() {
90
-
91
-            return errorMessages;
92
-
120
+    public List<Object> getErrorMessages() {
121
+        return errorMessages;
93 122
     }
94 123
 }
95 124
 

+ 78
- 12
application/src/main/java/com/lyg/application/util/Rule.java Bestand weergeven

@@ -1,35 +1,101 @@
1 1
 package com.lyg.application.util;
2 2
 
3 3
 
4
+import cn.dev33.satoken.util.SaResult;
4 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 6
 import com.lyg.application.entity.TaIncompatible;
6 7
 import com.lyg.application.entity.TaRotation;
7 8
 import com.lyg.application.mapper.TaIncompatibleMapper;
8 9
 import com.lyg.application.mapper.TaRotationMapper;
9
-import com.lyg.application.service.TaIncompatibleService;
10
+import com.lyg.common.Constants;
10 11
 import org.springframework.beans.factory.annotation.Autowired;
11 12
 import org.springframework.stereotype.Component;
12 13
 
13 14
 import java.time.LocalDate;
14 15
 import java.time.format.DateTimeFormatter;
15 16
 import java.util.ArrayList;
17
+import java.util.Hashtable;
16 18
 import java.util.List;
17 19
 import java.util.Map;
18 20
 
19 21
 @Component
20 22
 public class Rule {
21 23
 
22
-    @Autowired
23
-    TaIncompatibleService taIncompatibleService;
24
-
25 24
 
26 25
     @Autowired
27 26
     TaIncompatibleMapper taIncompatibleMapper;
28 27
     @Autowired
29 28
     TaRotationMapper taRotationMapper;
30 29
 
30
+
31
+    //这是在controller中使用的
32
+    public Object taRotationRule(TaRotation taRotation) {
33
+        Map<String, String> params = new Hashtable<>();
34
+        String specificOrgName = taRotation.getSpecificOrgName();
35
+        String specificNameOrgRotation = taRotation.getSpecificNameOrgRotation();
36
+        String counterImpPositions = taRotation.getCounterImpPositions();
37
+        String counterImpPostRotation = taRotation.getCounterImpPostRotation();
38
+
39
+        if (specificOrgName != null && specificNameOrgRotation != null && counterImpPositions != null && counterImpPostRotation != null) {
40
+            LocalDate newDate = LocalDate.now();
41
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
42
+            String passTime = newDate.format(formatter);
43
+            params.put("oldOrgCode", taRotation.getSpecificOrgName());
44
+            params.put("newOrgCode", taRotation.getSpecificNameOrgRotation());
45
+            params.put("primaryPost", taRotation.getCounterImpPositions());
46
+            params.put("targetPost", taRotation.getCounterImpPostRotation());
47
+            params.put("passTime", passTime);
48
+
49
+
50
+            Object result = siftRule(params);
51
+
52
+            return result;
53
+        }
54
+        return taRotation;
55
+    }
56
+
57
+
58
+    public Object siftRule(Map<String, String> params) {
59
+        String oldOrgCode = params.get("oldOrgCode");
60
+        String newOrgCode = params.get("newOrgCode");
61
+        String primaryPost = params.get("primaryPost");
62
+        String targetPost = params.get("targetPost");
63
+        String passTime = params.get("passTime");
64
+
65
+        //普通规则
66
+        if (oldOrgCode.equals(newOrgCode)) {
67
+            List<TaIncompatible> taIncompatibleList = regularRules(primaryPost, targetPost);
68
+
69
+//                List<TaIncompatible> taIncompatibleList = taIncompatibleService.getRegularRules(, );
70
+
71
+            if (taIncompatibleList.size() == 0) {
72
+                return "普通规则:根据不相容设置这两个岗位是相容的";
73
+            } else {
74
+                return taIncompatibleList;
75
+            }
76
+
77
+        } else {
78
+            params.put("oldOrgCode", oldOrgCode);
79
+            params.put("newOrgCode", newOrgCode);
80
+            params.put("primaryPost", primaryPost);
81
+            params.put("targetPost", targetPost);
82
+            params.put("passTime", passTime);
83
+            //三个月规则
84
+            List<TaRotation> repelList = getMonthRules(params);
85
+//                List<TaRotation> repelList = taIncompatibleService.getMonthRules(params);
86
+            if (repelList.size() == 0) {
87
+                return "三个月规则: 这是两个岗位是相容的";
88
+            } else {
89
+                return repelList;
90
+            }
91
+
92
+        }
93
+
94
+    }
95
+
96
+
31 97
     public List<TaIncompatible> regularRules(String primaryPost, String targetPost) {
32
-        return taIncompatibleService.getRegularRules(primaryPost, targetPost);
98
+        return taIncompatibleMapper.getRegularRules(primaryPost, targetPost, Constants.REGULAR_RULE);
33 99
 
34 100
     }
35 101
 
@@ -39,23 +105,22 @@ public class Rule {
39 105
 
40 106
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
41 107
 
42
-        QueryWrapper<TaRotation> queryWrapper = new QueryWrapper<>();
43 108
         String primaryPost = params.get("primaryPost");
44 109
         String targetPost = params.get("targetPost");
45 110
         String passTime = params.get("passTime");
46 111
         LocalDate newDate = LocalDate.parse(passTime, formatter).minusMonths(3);
47 112
 
48
-        List<String> oldPostList = taIncompatibleMapper.getMonthRulesPrimary(primaryPost);//原来岗位+目标不相容岗位
49
-        List<String> newPostList = taIncompatibleMapper.getMonthRulesTarget(targetPost);//目标岗位+原来不相容岗位
113
+        List<String> oldPostList = taIncompatibleMapper.getMonthRulesPrimary(primaryPost, Constants.MONTH_RULE);
114
+        List<String> newPostList = taIncompatibleMapper.getMonthRulesTarget(targetPost, Constants.MONTH_RULE);
50 115
 
51 116
         if (oldPostList.size() == 0 && newPostList.size() == 0) {
52 117
             return repelList;
53 118
         } else {
54
-            List<String> orgList = newPostList;//原来岗位 不相容的
55
-            orgList.add(orgList.size() - 1, primaryPost);
119
+            List<String> orgList = newPostList;//原来岗位+目标不相容岗位
120
+            orgList.add(primaryPost);
56 121
 
57
-            List<String> targetList = oldPostList;//目标岗位 不相容的
58
-            targetList.add(targetList.size() - 1, targetPost);
122
+            List<String> targetList = oldPostList;//目标岗位+原来不相容岗位
123
+            targetList.add(targetPost);
59 124
 
60 125
             //                拿到数据 不相容轮岗数据
61 126
             repelList = taRotationMapper.selectRepel(orgList, targetList, newDate);
@@ -64,3 +129,4 @@ public class Rule {
64 129
         }
65 130
     }
66 131
 }
132
+

+ 3
- 3
application/src/main/resources/mapper/TaIncompatibleMapper.xml Bestand weergeven

@@ -9,7 +9,7 @@
9 9
         TA_INCOMPATIBLE i
10 10
         WHERE
11 11
         i.PRIMARY_POST=#{oldOrgName} AND i.TARGET_POST=#{newOrgName}
12
-        AND i.DELETED=0 AND i.Rule='regularRules'
12
+        AND i.DELETED=0 AND i.Rule=#{regularRule}
13 13
     </select>
14 14
 
15 15
     <select id="getMonthRulesPrimary" resultType="java.lang.String">
@@ -19,7 +19,7 @@
19 19
         and
20 20
         i.DELETED=0
21 21
         and
22
-        i.RULE='monthRules'
22
+        i.RULE=#{monthRule}
23 23
     </select>
24 24
 
25 25
 
@@ -30,6 +30,6 @@
30 30
         and
31 31
         i.DELETED=0
32 32
         and
33
-        i.RULE='monthRules'
33
+        i.RULE=#{monthRule}
34 34
     </select>
35 35
 </mapper>

+ 1
- 0
application/src/main/resources/mapper/TaRotationMapper.xml Bestand weergeven

@@ -7,6 +7,7 @@
7 7
         FROM TA_ROTATION r
8 8
         WHERE
9 9
         r.rotation_exe_time IS NOT NULL
10
+        AND r.specific_org_num != r.org_num_job_rotation
10 11
         and r.rotation_exe_time &lt;=#{newDate}
11 12
         and r.counter_imp_positions IN
12 13
         <foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">

+ 7
- 0
common/src/main/java/com/lyg/common/Constants.java Bestand weergeven

@@ -12,4 +12,11 @@ public class Constants {
12 12
     // 东海特殊规则
13 13
     public final static String SPECIAL_RULE_DH = "donghai";
14 14
 
15
+
16
+    //普通规则
17
+    public final static String REGULAR_RULE = "regularRule";
18
+
19
+    //三个月规则
20
+    public final static String MONTH_RULE = "monthRules";
21
+
15 22
 }

+ 0
- 1
system/src/main/java/com/lyg/system/controller/SysPositionController.java Bestand weergeven

@@ -60,7 +60,6 @@ public class SysPositionController extends BaseController {
60 60
     public SaResult list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61 61
                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
62 62
                          @ApiParam("岗位名字") @RequestParam(value ="name", required = false) String name,
63
-
64 63
                          @ApiParam("正序排列") @RequestParam(value ="sortAsc", required = false) String sortAsc,
65 64
                          @ApiParam("倒序排列") @RequestParam(value ="sortDesc", defaultValue = "create_date") String sortDesc) throws Exception {
66 65
         

+ 1
- 0
system/src/main/java/com/lyg/system/mapper/SysOrgMapper.java Bestand weergeven

@@ -25,4 +25,5 @@ public interface SysOrgMapper extends BaseMapper<SysOrg> {
25 25
 
26 26
     long changeOrgCode(@Param("from") String from, @Param("to") String to);
27 27
 
28
+    String getOrgId(@Param("orgName") String orgName);
28 29
 }

+ 7
- 4
system/src/main/java/com/lyg/system/mapper/SysPositionMapper.java Bestand weergeven

@@ -1,16 +1,19 @@
1 1
 package com.lyg.system.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysPosition;
4 5
 import org.apache.ibatis.annotations.Mapper;
5 6
 import org.apache.ibatis.annotations.Param;
6
-import com.lyg.system.entity.SysPosition;
7 7
 
8
- /**
8
+/**
9 9
  * 岗位表;(sys_position)表数据库访问层
10
+ *
10 11
  * @author : http://njyunzhi.com
11 12
  * @date : 2024-3-6
12 13
  */
13 14
 @Mapper
14
-public interface SysPositionMapper  extends BaseMapper<SysPosition>{
15
-    
15
+public interface SysPositionMapper extends BaseMapper<SysPosition> {
16
+
17
+    String getPostId(@Param("postName") String postName);
18
+
16 19
 }

+ 4
- 3
system/src/main/java/com/lyg/system/service/SysPositionService.java Bestand weergeven

@@ -3,12 +3,13 @@ package com.lyg.system.service;
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.lyg.system.entity.SysPosition;
5 5
 import com.lyg.system.service.IBaseService;
6
+import org.apache.ibatis.annotations.Param;
6 7
 
7
- /**
8
+/**
8 9
  * 岗位表;(sys_position)表服务接口
9 10
  * @author : http://njyunzhi.com
10 11
  * @date : 2024-3-6
11 12
  */
12 13
 public interface SysPositionService extends IBaseService<SysPosition> {
13
-    
14
-}
14
+
15
+ }

+ 8
- 0
system/src/main/resources/mapper/SysOrgMapper.xml Bestand weergeven

@@ -34,4 +34,12 @@
34 34
         FROM
35 35
         sys_org
36 36
     </select>
37
+    <select id="getOrgId" resultType="java.lang.String">
38
+        SELECT
39
+        o.name
40
+        FROM
41
+        SYS_ORG o
42
+        WHERE
43
+        o.ORG_ID = #{orgName}
44
+    </select>
37 45
 </mapper>

+ 9
- 1
system/src/main/resources/mapper/SysPositionMapper.xml Bestand weergeven

@@ -2,5 +2,13 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 
4 4
 <mapper namespace="com.lyg.system.mapper.SysPositionMapper">
5
-    
5
+
6
+    <select id="getPostId" resultType="java.lang.String">
7
+        SELECT
8
+        p.POSITION_ID
9
+        FROM
10
+        SYS_POSITION p
11
+        WHERE
12
+        p.name = #{postName}
13
+    </select>
6 14
 </mapper>