张涛 1年前
父节点
当前提交
2f56341dcb
共有 23 个文件被更改,包括 395 次插入196 次删除
  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 查看文件

1
-package com.lyg.application.dao;
2
-
3
-import com.lyg.application.entity.TaRotation;
1
+package com.lyg.application.Listener;
4
 
2
 
5
 import java.util.List;
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 查看文件

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

+ 69
- 0
application/src/main/java/com/lyg/application/Listener/TaRotationListener.java 查看文件

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 查看文件

5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.lyg.application.entity.TaIncompatible;
7
 import com.lyg.application.entity.TaIncompatible;
8
-import com.lyg.application.entity.TaRotation;
9
 import com.lyg.application.service.TaIncompatibleService;
8
 import com.lyg.application.service.TaIncompatibleService;
10
 import com.lyg.application.util.Rule;
9
 import com.lyg.application.util.Rule;
11
 import com.lyg.common.util.StringUtil;
10
 import com.lyg.common.util.StringUtil;
20
 import org.springframework.web.bind.annotation.*;
19
 import org.springframework.web.bind.annotation.*;
21
 
20
 
22
 import java.util.Hashtable;
21
 import java.util.Hashtable;
23
-import java.util.List;
24
 import java.util.Map;
22
 import java.util.Map;
25
 
23
 
26
 /**
24
 /**
130
 
128
 
131
 
129
 
132
     /**
130
     /**
133
-     * 分页查询
131
+     *
134
      */
132
      */
135
     @OpLog(module = "不相容规则查询", action = "")
133
     @OpLog(module = "不相容规则查询", action = "")
136
     @AccessLimit()
134
     @AccessLimit()
146
 
144
 
147
         Map<String, String> params = new Hashtable<>();
145
         Map<String, String> params = new Hashtable<>();
148
 
146
 
149
-
150
         if (oldOrgCode != null && newOrgCode != null && primaryPost != null && targetPost != null && passTime != null) {
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
         return SaResult.error("请输入岗位或机构号");
159
         return SaResult.error("请输入岗位或机构号");
182
 
160
 

+ 67
- 47
application/src/main/java/com/lyg/application/controller/TaRotationController.java 查看文件

4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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
 import com.lyg.common.util.StringUtil;
10
 import com.lyg.common.util.StringUtil;
11
+import com.lyg.framework.accesslimit.AccessLimit;
10
 import com.lyg.framework.log.OpLog;
12
 import com.lyg.framework.log.OpLog;
11
 import com.lyg.system.controller.BaseController;
13
 import com.lyg.system.controller.BaseController;
12
-import com.lyg.framework.accesslimit.AccessLimit;
14
+import com.lyg.system.mapper.SysOrgMapper;
13
 import io.swagger.annotations.Api;
15
 import io.swagger.annotations.Api;
14
 import io.swagger.annotations.ApiOperation;
16
 import io.swagger.annotations.ApiOperation;
15
 import io.swagger.annotations.ApiParam;
17
 import io.swagger.annotations.ApiParam;
16
 import org.springframework.beans.factory.annotation.Autowired;
18
 import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.validation.annotation.Validated;
19
 import org.springframework.validation.annotation.Validated;
18
 import org.springframework.web.bind.annotation.*;
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
  * 轮岗列表;(ta_rotation)表控制层
23
  * 轮岗列表;(ta_rotation)表控制层
24
+ *
24
  * @author : http://njyunzhi.com
25
  * @author : http://njyunzhi.com
25
  * @date : 2024-3-6
26
  * @date : 2024-3-6
26
  */
27
  */
28
 @RestController
29
 @RestController
29
 @RequestMapping("/")
30
 @RequestMapping("/")
30
 public class TaRotationController extends BaseController {
31
 public class TaRotationController extends BaseController {
31
-    
32
+
32
     @Autowired
33
     @Autowired
33
     private TaRotationService taRotationService;
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
      * @param id 主键
45
      * @param id 主键
39
      * @return 实例对象
46
      * @return 实例对象
45
     public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
52
     public SaResult queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
46
         return SaResult.data(taRotationService.getById(id));
53
         return SaResult.data(taRotationService.getById(id));
47
     }
54
     }
48
-    
49
-    /** 
55
+
56
+    /**
50
      * 分页查询
57
      * 分页查询
51
      *
58
      *
52
-     * @param pageNum 当前页码
59
+     * @param pageNum  当前页码
53
      * @param pageSize 每页条数
60
      * @param pageSize 每页条数
54
      * @return 查询结果
61
      * @return 查询结果
55
      */
62
      */
57
     @AccessLimit()
64
     @AccessLimit()
58
     @ApiOperation("分页查询")
65
     @ApiOperation("分页查询")
59
     @GetMapping("/taRotation")
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
     ) throws Exception {
81
     ) throws Exception {
75
-        
82
+
76
         IPage<TaRotation> pg = new Page<>(pageNum, pageSize);
83
         IPage<TaRotation> pg = new Page<>(pageNum, pageSize);
77
         QueryWrapper<TaRotation> queryWrapper = new QueryWrapper<>();
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
         queryWrapper.orderByAsc(StringUtil.isNotEmpty(sortAsc), StringUtil.humpToLine(sortAsc));
94
         queryWrapper.orderByAsc(StringUtil.isNotEmpty(sortAsc), StringUtil.humpToLine(sortAsc));
88
         queryWrapper.orderByDesc(StringUtil.isNotEmpty(sortDesc), StringUtil.humpToLine(sortDesc));
95
         queryWrapper.orderByDesc(StringUtil.isNotEmpty(sortDesc), StringUtil.humpToLine(sortDesc));
89
         IPage<TaRotation> result = taRotationService.page(pg, queryWrapper);
96
         IPage<TaRotation> result = taRotationService.page(pg, queryWrapper);
90
-        
97
+
91
         return SaResult.data(result);
98
         return SaResult.data(result);
92
     }
99
     }
93
-    
94
-    /** 
100
+
101
+    /**
95
      * 新增数据
102
      * 新增数据
96
      *
103
      *
97
      * @param taRotation 实例对象
104
      * @param taRotation 实例对象
102
     @ApiOperation("新增数据")
109
     @ApiOperation("新增数据")
103
     @PostMapping("/taRotation")
110
     @PostMapping("/taRotation")
104
     public SaResult add(@ApiParam("对象实体") @Validated @RequestBody TaRotation taRotation) throws Exception {
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
         taRotationService.save(taRotation);
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
      * @param taRotation 实例对象
130
      * @param taRotation 实例对象
117
     @ApiOperation("更新数据")
135
     @ApiOperation("更新数据")
118
     @PutMapping("/taRotation/{id}")
136
     @PutMapping("/taRotation/{id}")
119
     public SaResult edit(@ApiParam("对象实体") @Validated @RequestBody TaRotation taRotation,
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
         taRotation.setRotationId(id);
139
         taRotation.setRotationId(id);
122
         taRotationService.updateById(taRotation);
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
      * @param id 主键
149
      * @param id 主键
133
     @AccessLimit()
153
     @AccessLimit()
134
     @ApiOperation("通过主键删除数据")
154
     @ApiOperation("通过主键删除数据")
135
     @DeleteMapping("/taRotation/{id}")
155
     @DeleteMapping("/taRotation/{id}")
136
-    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id){
156
+    public SaResult deleteById(@ApiParam("对象ID") @PathVariable String id) {
137
         taRotationService.removeById(id);
157
         taRotationService.removeById(id);
138
         return SaResult.data("success");
158
         return SaResult.data("success");
139
     }
159
     }

+ 11
- 16
application/src/main/java/com/lyg/application/controller/UploadController.java 查看文件

2
 
2
 
3
 import cn.dev33.satoken.util.SaResult;
3
 import cn.dev33.satoken.util.SaResult;
4
 import com.alibaba.excel.EasyExcel;
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
 import com.lyg.application.entity.TaMandatoryLeave;
7
 import com.lyg.application.entity.TaMandatoryLeave;
7
 import com.lyg.application.entity.TaRotation;
8
 import com.lyg.application.entity.TaRotation;
9
+import com.lyg.application.service.TaMandatoryLeaveService;
8
 import com.lyg.application.service.TaRotationService;
10
 import com.lyg.application.service.TaRotationService;
9
 import com.lyg.application.service.impl.TaMandatoryLeaveServiceImpl;
11
 import com.lyg.application.service.impl.TaMandatoryLeaveServiceImpl;
10
 import com.lyg.application.service.impl.TaRotationServiceImpl;
12
 import com.lyg.application.service.impl.TaRotationServiceImpl;
14
 import io.swagger.annotations.ApiOperation;
16
 import io.swagger.annotations.ApiOperation;
15
 import io.swagger.annotations.ApiParam;
17
 import io.swagger.annotations.ApiParam;
16
 import org.springframework.beans.factory.annotation.Autowired;
18
 import org.springframework.beans.factory.annotation.Autowired;
17
-import org.springframework.scheduling.annotation.Scheduled;
18
 import org.springframework.web.bind.annotation.*;
19
 import org.springframework.web.bind.annotation.*;
19
 import org.springframework.web.multipart.MultipartFile;
20
 import org.springframework.web.multipart.MultipartFile;
20
 
21
 
41
 
42
 
42
     @Autowired
43
     @Autowired
43
     private TaRotationServiceImpl taRotationServiceImpl;
44
     private TaRotationServiceImpl taRotationServiceImpl;
45
+    @Autowired
46
+    private TaMandatoryLeaveService taMandatoryLeaveService;
44
 
47
 
45
     @Autowired
48
     @Autowired
46
     private TaMandatoryLeaveServiceImpl taMandatoryLeaveServiceImpl;
49
     private TaMandatoryLeaveServiceImpl taMandatoryLeaveServiceImpl;
57
         try {
60
         try {
58
 
61
 
59
             InputStream inputStream = file.getInputStream();
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
             StringBuilder errorMessageBuilder = new StringBuilder();
67
             StringBuilder errorMessageBuilder = new StringBuilder();
65
 
68
 
66
-            for (String errorMessage : errorMessages) {
69
+            for (Object errorMessage : errorMessages) {
67
                 errorMessageBuilder.append(errorMessage).append("\n");
70
                 errorMessageBuilder.append(errorMessage).append("\n");
68
             }
71
             }
69
 
72
 
90
         try {
93
         try {
91
 
94
 
92
             InputStream inputStream = file.getInputStream();
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
             List<String> errorMessages = taMandatoryLeaveServiceImpl.getErrorMessages();
99
             List<String> errorMessages = taMandatoryLeaveServiceImpl.getErrorMessages();
97
             StringBuilder errorMessageBuilder = new StringBuilder();
100
             StringBuilder errorMessageBuilder = new StringBuilder();
112
     }
115
     }
113
 
116
 
114
 
117
 
115
-
116
-
117
 //
118
 //
118
 //    @AccessLimit()
119
 //    @AccessLimit()
119
 //    @ApiOperation("提示/预警")
120
 //    @ApiOperation("提示/预警")
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 查看文件

1
 package com.lyg.application.mapper;
1
 package com.lyg.application.mapper;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.application.entity.TaIncompatible;
4
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Param;
6
 import org.apache.ibatis.annotations.Param;
6
-import com.lyg.application.entity.TaIncompatible;
7
 
7
 
8
 import java.util.List;
8
 import java.util.List;
9
 
9
 
10
 /**
10
 /**
11
  * 不相容;(ta_incompatible)表数据库访问层
11
  * 不相容;(ta_incompatible)表数据库访问层
12
+ *
12
  * @author : http://njyunzhi.com
13
  * @author : http://njyunzhi.com
13
  * @date : 2024-3-6
14
  * @date : 2024-3-6
14
  */
15
  */
15
 @Mapper
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 查看文件

16
 public interface TaIncompatibleService extends IBaseService<TaIncompatible> {
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 查看文件

2
 
2
 
3
 import com.baomidou.mybatisplus.extension.service.IService;
3
 import com.baomidou.mybatisplus.extension.service.IService;
4
 import com.lyg.application.entity.TaMandatoryLeave;
4
 import com.lyg.application.entity.TaMandatoryLeave;
5
+import com.lyg.application.entity.TaRotation;
5
 import com.lyg.system.service.IBaseService;
6
 import com.lyg.system.service.IBaseService;
6
 
7
 
7
- /**
8
+import java.util.List;
9
+
10
+/**
8
  * 强制休假表;(ta_mandatory_leave)表服务接口
11
  * 强制休假表;(ta_mandatory_leave)表服务接口
9
  * @author : http://njyunzhi.com
12
  * @author : http://njyunzhi.com
10
  * @date : 2024-3-6
13
  * @date : 2024-3-6
11
  */
14
  */
12
 public interface TaMandatoryLeaveService extends IBaseService<TaMandatoryLeave> {
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 查看文件

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

+ 32
- 38
application/src/main/java/com/lyg/application/service/impl/TaIncompatibleServiceImpl.java 查看文件

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 查看文件

1
 package com.lyg.application.service.impl;
1
 package com.lyg.application.service.impl;
2
 
2
 
3
-import com.lyg.application.dao.EntityHandler;
4
 import com.lyg.application.entity.TaMandatoryLeave;
3
 import com.lyg.application.entity.TaMandatoryLeave;
5
 import com.lyg.application.mapper.TaMandatoryLeaveMapper;
4
 import com.lyg.application.mapper.TaMandatoryLeaveMapper;
6
 import com.lyg.application.service.TaMandatoryLeaveService;
5
 import com.lyg.application.service.TaMandatoryLeaveService;
6
+import com.lyg.system.mapper.SysPositionMapper;
7
 import com.lyg.system.service.SysOrgService;
7
 import com.lyg.system.service.SysOrgService;
8
 import com.lyg.system.service.SysPositionService;
8
 import com.lyg.system.service.SysPositionService;
9
 import com.lyg.system.service.impl.BaseServiceImpl;
9
 import com.lyg.system.service.impl.BaseServiceImpl;
21
  * @date : 2024-3-6
21
  * @date : 2024-3-6
22
  */
22
  */
23
 @Service
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
     private final List<String> errorMessages = new ArrayList<>();
25
     private final List<String> errorMessages = new ArrayList<>();
26
     @Autowired
26
     @Autowired
27
     private SysOrgService sysOrgService;
27
     private SysOrgService sysOrgService;
28
     @Autowired
28
     @Autowired
29
     private SysPositionService sysPositionService;
29
     private SysPositionService sysPositionService;
30
+    @Autowired
31
+    private SysPositionMapper sysPositionMapper;
30
 
32
 
31
     @Override
33
     @Override
32
     public TaMandatoryLeave handleEntity(TaMandatoryLeave entity, Integer index) throws Exception {
34
     public TaMandatoryLeave handleEntity(TaMandatoryLeave entity, Integer index) throws Exception {
36
 
38
 
37
         String orgCode = entity.getOrgNum();//单位机构号
39
         String orgCode = entity.getOrgNum();//单位机构号
38
         String orgName = entity.getOrgName().replaceAll("\n", "");//单位机构名
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
         LocalDate durationOfEmployment = entity.getStartTimeVacation();
49
         LocalDate durationOfEmployment = entity.getStartTimeVacation();
41
         LocalDate vacationDeadline = entity.getVacationDeadline();
50
         LocalDate vacationDeadline = entity.getVacationDeadline();
42
 
51
 
52
+
43
         Long count = sysOrgService.countBy("org_id", orgCode, true);
53
         Long count = sysOrgService.countBy("org_id", orgCode, true);
44
         if (count == 0 || orgCode.isEmpty()) {
54
         if (count == 0 || orgCode.isEmpty()) {
45
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构号 " + orgCode);
55
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构号 " + orgCode);

+ 43
- 14
application/src/main/java/com/lyg/application/service/impl/TaRotationServiceImpl.java 查看文件

1
 package com.lyg.application.service.impl;
1
 package com.lyg.application.service.impl;
2
 
2
 
3
-import com.lyg.application.dao.EntityHandler;
4
 import com.lyg.application.entity.TaRotation;
3
 import com.lyg.application.entity.TaRotation;
5
 import com.lyg.application.mapper.TaRotationMapper;
4
 import com.lyg.application.mapper.TaRotationMapper;
6
 import com.lyg.application.service.TaRotationService;
5
 import com.lyg.application.service.TaRotationService;
6
+import com.lyg.application.util.Rule;
7
+import com.lyg.system.mapper.SysPositionMapper;
7
 import com.lyg.system.service.SysOrgService;
8
 import com.lyg.system.service.SysOrgService;
8
 import com.lyg.system.service.SysPositionService;
9
 import com.lyg.system.service.SysPositionService;
9
 import com.lyg.system.service.impl.BaseServiceImpl;
10
 import com.lyg.system.service.impl.BaseServiceImpl;
22
  */
23
  */
23
 @Service
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
     @Autowired
31
     @Autowired
29
     private SysOrgService sysOrgService;
32
     private SysOrgService sysOrgService;
30
     @Autowired
33
     @Autowired
31
     private SysPositionService sysPositionService;
34
     private SysPositionService sysPositionService;
35
+    @Autowired
36
+    private SysPositionMapper sysPositionMapper;
32
 
37
 
33
-    @Override
34
     public TaRotation handleEntity(TaRotation entity, Integer index) throws Exception {
38
     public TaRotation handleEntity(TaRotation entity, Integer index) throws Exception {
35
 //校验验证
39
 //校验验证
36
         System.out.println("******************************entity**************************************");
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
         String orgCode = entity.getSpecificOrgNum();//单位机构号
47
         String orgCode = entity.getSpecificOrgNum();//单位机构号
40
         String orgName = entity.getSpecificOrgName().replaceAll("\n", "");//单位机构名
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
         LocalDate durationOfEmployment = entity.getDurationOfEmployment();
54
         LocalDate durationOfEmployment = entity.getDurationOfEmployment();
43
         LocalDate rotationExeTime = entity.getRotationExeTime();
55
         LocalDate rotationExeTime = entity.getRotationExeTime();
44
         LocalDate rotationDeadline = entity.getRotationDeadline();
56
         LocalDate rotationDeadline = entity.getRotationDeadline();
45
         LocalDate planRotationDate = entity.getPlanRotationDate();
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
         Long count = sysOrgService.countBy("org_id", orgCode, true);
68
         Long count = sysOrgService.countBy("org_id", orgCode, true);
48
-        if (count == 0||orgCode.isEmpty()) {
69
+        if (count == 0 || orgCode.isEmpty()) {
49
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构号 " + orgCode);
70
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构号 " + orgCode);
50
         }
71
         }
51
 
72
 
52
         count = sysOrgService.countBy("name", orgName, true);
73
         count = sysOrgService.countBy("name", orgName, true);
53
-        if (count == 0||orgName.isEmpty()) {
74
+        if (count == 0) {
54
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构名字 " + orgName);
75
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此机构名字 " + orgName);
55
         }
76
         }
56
 
77
 
57
         count = sysPositionService.countBy("name", rotationName, true);
78
         count = sysPositionService.countBy("name", rotationName, true);
58
-        if (count == 0||rotationName.isEmpty()) {
79
+        if (count == 0 || rotationName.isEmpty()) {
59
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此岗位 " + rotationName);
80
             errorMessages.add("第 " + index + " 行处理发生错误: " + "没有此岗位 " + rotationName);
60
         }
81
         }
61
 
82
 
71
         if (planRotationDate == null) {
92
         if (planRotationDate == null) {
72
             errorMessages.add("第 " + index + " 行时间错误:计划轮岗日期 " + planRotationDate);
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
         return entity;
102
         return entity;
75
     }
103
     }
76
 
104
 
105
+
77
     //    @Transactional(rollbackFor = Exception.class)
106
     //    @Transactional(rollbackFor = Exception.class)
78
-    @Override
79
     public void saveEntityBatch(List<TaRotation> entityList) {
107
     public void saveEntityBatch(List<TaRotation> entityList) {
80
         // 实现逻辑:保存批量实体
108
         // 实现逻辑:保存批量实体
81
         System.out.println("******************************entityList**************************************");
109
         System.out.println("******************************entityList**************************************");
82
         System.out.println(entityList);
110
         System.out.println(entityList);
83
         for (TaRotation taRotation : entityList) {
111
         for (TaRotation taRotation : entityList) {
112
+
113
+
84
             baseMapper.insert(taRotation);
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 查看文件

1
 package com.lyg.application.util;
1
 package com.lyg.application.util;
2
 
2
 
3
 
3
 
4
+import cn.dev33.satoken.util.SaResult;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
 import com.lyg.application.entity.TaIncompatible;
6
 import com.lyg.application.entity.TaIncompatible;
6
 import com.lyg.application.entity.TaRotation;
7
 import com.lyg.application.entity.TaRotation;
7
 import com.lyg.application.mapper.TaIncompatibleMapper;
8
 import com.lyg.application.mapper.TaIncompatibleMapper;
8
 import com.lyg.application.mapper.TaRotationMapper;
9
 import com.lyg.application.mapper.TaRotationMapper;
9
-import com.lyg.application.service.TaIncompatibleService;
10
+import com.lyg.common.Constants;
10
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.stereotype.Component;
12
 import org.springframework.stereotype.Component;
12
 
13
 
13
 import java.time.LocalDate;
14
 import java.time.LocalDate;
14
 import java.time.format.DateTimeFormatter;
15
 import java.time.format.DateTimeFormatter;
15
 import java.util.ArrayList;
16
 import java.util.ArrayList;
17
+import java.util.Hashtable;
16
 import java.util.List;
18
 import java.util.List;
17
 import java.util.Map;
19
 import java.util.Map;
18
 
20
 
19
 @Component
21
 @Component
20
 public class Rule {
22
 public class Rule {
21
 
23
 
22
-    @Autowired
23
-    TaIncompatibleService taIncompatibleService;
24
-
25
 
24
 
26
     @Autowired
25
     @Autowired
27
     TaIncompatibleMapper taIncompatibleMapper;
26
     TaIncompatibleMapper taIncompatibleMapper;
28
     @Autowired
27
     @Autowired
29
     TaRotationMapper taRotationMapper;
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
     public List<TaIncompatible> regularRules(String primaryPost, String targetPost) {
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
 
105
 
40
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
106
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
41
 
107
 
42
-        QueryWrapper<TaRotation> queryWrapper = new QueryWrapper<>();
43
         String primaryPost = params.get("primaryPost");
108
         String primaryPost = params.get("primaryPost");
44
         String targetPost = params.get("targetPost");
109
         String targetPost = params.get("targetPost");
45
         String passTime = params.get("passTime");
110
         String passTime = params.get("passTime");
46
         LocalDate newDate = LocalDate.parse(passTime, formatter).minusMonths(3);
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
         if (oldPostList.size() == 0 && newPostList.size() == 0) {
116
         if (oldPostList.size() == 0 && newPostList.size() == 0) {
52
             return repelList;
117
             return repelList;
53
         } else {
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
             repelList = taRotationMapper.selectRepel(orgList, targetList, newDate);
126
             repelList = taRotationMapper.selectRepel(orgList, targetList, newDate);
64
         }
129
         }
65
     }
130
     }
66
 }
131
 }
132
+

+ 3
- 3
application/src/main/resources/mapper/TaIncompatibleMapper.xml 查看文件

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

+ 1
- 0
application/src/main/resources/mapper/TaRotationMapper.xml 查看文件

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

+ 7
- 0
common/src/main/java/com/lyg/common/Constants.java 查看文件

12
     // 东海特殊规则
12
     // 东海特殊规则
13
     public final static String SPECIAL_RULE_DH = "donghai";
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 查看文件

60
     public SaResult list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
60
     public SaResult list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61
                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
61
                             @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
62
                          @ApiParam("岗位名字") @RequestParam(value ="name", required = false) String name,
62
                          @ApiParam("岗位名字") @RequestParam(value ="name", required = false) String name,
63
-
64
                          @ApiParam("正序排列") @RequestParam(value ="sortAsc", required = false) String sortAsc,
63
                          @ApiParam("正序排列") @RequestParam(value ="sortAsc", required = false) String sortAsc,
65
                          @ApiParam("倒序排列") @RequestParam(value ="sortDesc", defaultValue = "create_date") String sortDesc) throws Exception {
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 查看文件

25
 
25
 
26
     long changeOrgCode(@Param("from") String from, @Param("to") String to);
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 查看文件

1
 package com.lyg.system.mapper;
1
 package com.lyg.system.mapper;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.system.entity.SysPosition;
4
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Param;
6
 import org.apache.ibatis.annotations.Param;
6
-import com.lyg.system.entity.SysPosition;
7
 
7
 
8
- /**
8
+/**
9
  * 岗位表;(sys_position)表数据库访问层
9
  * 岗位表;(sys_position)表数据库访问层
10
+ *
10
  * @author : http://njyunzhi.com
11
  * @author : http://njyunzhi.com
11
  * @date : 2024-3-6
12
  * @date : 2024-3-6
12
  */
13
  */
13
 @Mapper
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 查看文件

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

+ 8
- 0
system/src/main/resources/mapper/SysOrgMapper.xml 查看文件

34
         FROM
34
         FROM
35
         sys_org
35
         sys_org
36
     </select>
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
 </mapper>
45
 </mapper>

+ 9
- 1
system/src/main/resources/mapper/SysPositionMapper.xml 查看文件

2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
 
3
 
4
 <mapper namespace="com.lyg.system.mapper.SysPositionMapper">
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
 </mapper>
14
 </mapper>