张涛 1年前
父节点
当前提交
6284856a78

+ 2
- 2
application/src/main/java/com/lyg/application/DTO/ErrorDto.java 查看文件

5
 
5
 
6
 @Data
6
 @Data
7
 public class ErrorDto {
7
 public class ErrorDto {
8
-    private String regularRules;//普通规则 提示
8
+    private String rules;//普通规则 提示
9
     private String primaryPost; //原来的岗位
9
     private String primaryPost; //原来的岗位
10
     private String targetPost;// 轮岗之后的岗位
10
     private String targetPost;// 轮岗之后的岗位
11
 
11
 
12
 
12
 
13
-    private String monthRules;//三个月规则 提示
13
+//    private String monthRules;//三个月规则 提示
14
     private  String employeeNum;//员工工号
14
     private  String employeeNum;//员工工号
15
     private  String employeeName;//员工姓名
15
     private  String employeeName;//员工姓名
16
 
16
 

+ 0
- 3
application/src/main/java/com/lyg/application/controller/TaIncompatibleController.java 查看文件

12
 import com.lyg.framework.accesslimit.AccessLimit;
12
 import com.lyg.framework.accesslimit.AccessLimit;
13
 import com.lyg.framework.log.OpLog;
13
 import com.lyg.framework.log.OpLog;
14
 import com.lyg.system.controller.BaseController;
14
 import com.lyg.system.controller.BaseController;
15
-import com.lyg.system.entity.SysUser;
16
 import io.swagger.annotations.Api;
15
 import io.swagger.annotations.Api;
17
 import io.swagger.annotations.ApiOperation;
16
 import io.swagger.annotations.ApiOperation;
18
 import io.swagger.annotations.ApiParam;
17
 import io.swagger.annotations.ApiParam;
148
             @ApiParam("原岗位") @RequestParam(value = "primaryPost", required = false) String primaryPost,
147
             @ApiParam("原岗位") @RequestParam(value = "primaryPost", required = false) String primaryPost,
149
             @ApiParam("目标机构/网点") @RequestParam(value = "newOrgCode", required = false) String newOrgCode,
148
             @ApiParam("目标机构/网点") @RequestParam(value = "newOrgCode", required = false) String newOrgCode,
150
             @ApiParam("目标岗位") @RequestParam(value = "targetPost", required = false) String targetPost) throws Exception {
149
             @ApiParam("目标岗位") @RequestParam(value = "targetPost", required = false) String targetPost) throws Exception {
151
-
152
-
153
         Map<String, String> params = new Hashtable<>();
150
         Map<String, String> params = new Hashtable<>();
154
 
151
 
155
         if (oldOrgCode != null && newOrgCode != null && primaryPost != null && targetPost != null && passTime != null) {
152
         if (oldOrgCode != null && newOrgCode != null && primaryPost != null && targetPost != null && passTime != null) {

+ 49
- 3
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 com.lyg.application.DTO.ErrorDto;
7
 import com.lyg.application.entity.TaRotation;
8
 import com.lyg.application.entity.TaRotation;
8
 import com.lyg.application.service.TaRotationService;
9
 import com.lyg.application.service.TaRotationService;
10
+import com.lyg.application.util.CreateResponse;
9
 import com.lyg.application.util.Rule;
11
 import com.lyg.application.util.Rule;
10
 import com.lyg.common.util.StringUtil;
12
 import com.lyg.common.util.StringUtil;
11
 import com.lyg.framework.accesslimit.AccessLimit;
13
 import com.lyg.framework.accesslimit.AccessLimit;
19
 import org.springframework.validation.annotation.Validated;
21
 import org.springframework.validation.annotation.Validated;
20
 import org.springframework.web.bind.annotation.*;
22
 import org.springframework.web.bind.annotation.*;
21
 
23
 
24
+import java.util.ArrayList;
25
+import java.util.List;
26
+
22
 /**
27
 /**
23
  * 轮岗列表;(ta_rotation)表控制层
28
  * 轮岗列表;(ta_rotation)表控制层
24
  *
29
  *
55
 
60
 
56
         Boolean b = checkAuth() == null || checkAuth() == taRotation.getCreateUser();
61
         Boolean b = checkAuth() == null || checkAuth() == taRotation.getCreateUser();
57
         if (b) {
62
         if (b) {
58
-           return SaResult.data(taRotationService.getById(id));
63
+            return SaResult.data(taRotationService.getById(id));
59
         }
64
         }
60
         return SaResult.error("无权限");
65
         return SaResult.error("无权限");
61
 
66
 
120
     public SaResult add(@ApiParam("对象实体") @Validated @RequestBody TaRotation taRotation) throws Exception {
125
     public SaResult add(@ApiParam("对象实体") @Validated @RequestBody TaRotation taRotation) throws Exception {
121
         taRotationService.save(taRotation);
126
         taRotationService.save(taRotation);
122
         Object result = rule.taRotationRule(taRotation);
127
         Object result = rule.taRotationRule(taRotation);
123
-        return SaResult.data(result);
128
+
129
+//        LocalDate localDate = LocalDate.now();
130
+//        DateTimeFormatter ft = DateTimeFormatter.ofPattern("yyyy-MM-dd");
131
+//        String oldOrgCode = taRotation.getSpecificOrgNum();
132
+//        String newOrgCode = taRotation.getOrgNumJobRotation();
133
+//        String primaryPost = taRotation.getCounterImpPositions();
134
+//        String targetPost = taRotation.getCounterImpPostRotation();
135
+//        String passTime = localDate.format(ft);
136
+//        if (oldOrgCode != null && newOrgCode != null && primaryPost != null && targetPost != null && passTime != null) {
137
+//
138
+//            Map<String, String> params = new HashMap<>();
139
+//            params.put("oldOrgCode", oldOrgCode);
140
+//            params.put("newOrgCode", newOrgCode);
141
+//            params.put("primaryPost", primaryPost);
142
+//            params.put("targetPost", targetPost);
143
+//            params.put("passTime", passTime);
144
+//
145
+//            List<ErrorDto> result = rule.siftRule(params);
146
+//        }
147
+        return (SaResult) result;
124
     }
148
     }
125
 
149
 
126
     /**
150
     /**
139
         taRotation.setRotationId(id);
163
         taRotation.setRotationId(id);
140
         taRotationService.updateById(taRotation);
164
         taRotationService.updateById(taRotation);
141
         Object result = rule.taRotationRule(taRotation);
165
         Object result = rule.taRotationRule(taRotation);
142
-        return SaResult.data(result);
166
+//        boolean isAllCompatible = true;
167
+//        if (result instanceof List) {
168
+//            ArrayList<ErrorDto> resultList = (ArrayList<ErrorDto>) rule.taRotationRule(taRotation);
169
+//            for (ErrorDto errorDto : resultList) {
170
+//                String regularRuleMessage = errorDto.getRegularRules();
171
+//                String monthRules = errorDto.getMonthRules();
172
+//                if (regularRuleMessage != null||monthRules != null) {
173
+//                    // 判断并添加相容/不相容信息到消息中
174
+//                    if (regularRuleMessage.contains("是不相容的")|| monthRules.contains("是不相容的")) {
175
+//                        isAllCompatible = true;
176
+//                    } else if (regularRuleMessage.contains("是相容的")|| monthRules.contains("是相容的")) {
177
+//                        isAllCompatible = false;
178
+//                    }
179
+//                }
180
+//            }
181
+//        } else if (result instanceof TaRotation) {
182
+//
183
+//        }
184
+
185
+
186
+// 设置规则的 id(假设 You
187
+
188
+        return (SaResult) result;
143
 
189
 
144
     }
190
     }
145
 
191
 

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

120
 
120
 
121
 
121
 
122
     @AccessLimit()
122
     @AccessLimit()
123
-    @Scheduled(cron = "0 0 8 * * *")
123
+//    @Scheduled(cron = "0 0 8 * * *")
124
     @GetMapping("/as/holiday")
124
     @GetMapping("/as/holiday")
125
     public void promptWarning() throws Exception {
125
     public void promptWarning() throws Exception {
126
 
126
 
127
         taRotationService.selectGetWaring();
127
         taRotationService.selectGetWaring();
128
+//        taMandatoryLeaveService.selectGetPrompt();
128
 
129
 
129
     }
130
     }
130
 
131
 

+ 0
- 1
application/src/main/java/com/lyg/application/entity/TaRotation.java 查看文件

36
     private String sort;
36
     private String sort;
37
 
37
 
38
     @ExcelProperty(index = 1)
38
     @ExcelProperty(index = 1)
39
-    @NotBlank(message = "总行部门不能为空")
40
     @ApiModelProperty(name = "总行部门/一级分行", notes = "")
39
     @ApiModelProperty(name = "总行部门/一级分行", notes = "")
41
     private String headOfficeOrg;
40
     private String headOfficeOrg;
42
 
41
 

+ 2
- 1
application/src/main/java/com/lyg/application/mapper/TaIncompatibleMapper.java 查看文件

6
 import org.apache.ibatis.annotations.Param;
6
 import org.apache.ibatis.annotations.Param;
7
 
7
 
8
 import java.util.List;
8
 import java.util.List;
9
+import java.util.Map;
9
 
10
 
10
 /**
11
 /**
11
  * 不相容;(ta_incompatible)表数据库访问层
12
  * 不相容;(ta_incompatible)表数据库访问层
16
 @Mapper
17
 @Mapper
17
 public interface TaIncompatibleMapper extends BaseMapper<TaIncompatible> {
18
 public interface TaIncompatibleMapper extends BaseMapper<TaIncompatible> {
18
 
19
 
19
-    List<TaIncompatible> getRegularRules(@Param("oldOrgName") String oldOrgName, @Param("newOrgName") String newOrgName, @Param("regularRule") String regularRule);
20
+    List<TaIncompatible> getRegularRules(@Param("params") Map<String, String> params, @Param("regularRule") String regularRule);
20
 
21
 
21
     List<String> getMonthRulesPrimary(@Param("primaryPost") String primaryPost, @Param("monthRule") String monthRule);
22
     List<String> getMonthRulesPrimary(@Param("primaryPost") String primaryPost, @Param("monthRule") String monthRule);
22
 
23
 

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

122
         }
122
         }
123
 
123
 
124
 
124
 
125
-        if (orgName != null && specificNameOrgRotation != null && rotationName != null && counterImpPostRotation != null) {
126
-            Object result = rule.taRotationRule(entity);
127
-            errorMessages.add(result);
128
-        }
125
+//        if (orgName != null && specificNameOrgRotation != null && rotationName != null && counterImpPostRotation != null) {
126
+//            Object result = rule.taRotationRule(entity);
127
+//            errorMessages.add(result);
128
+//        }
129
 
129
 
130
         return entity;
130
         return entity;
131
     }
131
     }

+ 24
- 0
application/src/main/java/com/lyg/application/util/CreateResponse.java 查看文件

1
+package com.lyg.application.util;
2
+
3
+import cn.dev33.satoken.util.SaResult;
4
+import org.springframework.stereotype.Component;
5
+
6
+@Component
7
+public class CreateResponse {
8
+
9
+
10
+    public static SaResult createResponse(int code, Object data, String msg) {
11
+        // 创建一个SaResult实例
12
+        SaResult result = new SaResult();
13
+
14
+        // 设置code和msg
15
+        result.setCode(code);
16
+        result.setMsg(msg);
17
+
18
+        // 设置数据内容
19
+        result.setData(data);
20
+
21
+        // 返回包含了msg、code和data的结果对象
22
+        return result;
23
+    }
24
+}

+ 2
- 2
application/src/main/java/com/lyg/application/util/MessageHandle.java 查看文件

79
         // 使用描述性强的常量代替硬编码值
79
         // 使用描述性强的常量代替硬编码值
80
         stringBuilder.append(tmp); // 假设warningTmp或promptTmp已经定义且包含插入点
80
         stringBuilder.append(tmp); // 假设warningTmp或promptTmp已经定义且包含插入点
81
         stringBuilder.insert(Constants.numI, item.getEmployeeNum());
81
         stringBuilder.insert(Constants.numI, item.getEmployeeNum());
82
-        int insertPos = Constants.numI + item.getEmployeeNum().length() + Constants.nameI;
82
+        int insertPos = item.getEmployeeNum().length() + Constants.nameI;
83
         stringBuilder.insert(insertPos, item.getEmployeeName());
83
         stringBuilder.insert(insertPos, item.getEmployeeName());
84
         taMessage.setContentSent(stringBuilder.toString());
84
         taMessage.setContentSent(stringBuilder.toString());
85
         taMessage.setSourceName(sourceName);
85
         taMessage.setSourceName(sourceName);
120
         // 使用描述性强的常量代替硬编码值
120
         // 使用描述性强的常量代替硬编码值
121
         stringBuilder.append(tmp); // 假设warningTmp或promptTmp已经定义且包含插入点
121
         stringBuilder.append(tmp); // 假设warningTmp或promptTmp已经定义且包含插入点
122
         stringBuilder.insert(Constants.numI, item.getEmployeeNum());
122
         stringBuilder.insert(Constants.numI, item.getEmployeeNum());
123
-        int insertPos = Constants.numI + item.getEmployeeNum().length() + Constants.nameI;
123
+        int insertPos = item.getEmployeeNum().length() + Constants.nameI;
124
         stringBuilder.insert(insertPos, item.getEmployeeName());
124
         stringBuilder.insert(insertPos, item.getEmployeeName());
125
         taMessage.setContentSent(stringBuilder.toString());
125
         taMessage.setContentSent(stringBuilder.toString());
126
         taMessage.setSourceName(sourceName);
126
         taMessage.setSourceName(sourceName);

+ 32
- 15
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.lyg.application.DTO.ErrorDto;
5
 import com.lyg.application.DTO.ErrorDto;
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;
25
     TaIncompatibleMapper taIncompatibleMapper;
26
     TaIncompatibleMapper taIncompatibleMapper;
26
     @Autowired
27
     @Autowired
27
     TaRotationMapper taRotationMapper;
28
     TaRotationMapper taRotationMapper;
28
-
29
+    private static final String COMPATIBLE_TEXT = "根据不相容设置这两个岗位是相容的";
29
 
30
 
30
     //这是在controller中使用的
31
     //这是在controller中使用的
31
     public Object taRotationRule(TaRotation taRotation) {
32
     public Object taRotationRule(TaRotation taRotation) {
39
             LocalDate newDate = LocalDate.now();
40
             LocalDate newDate = LocalDate.now();
40
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
41
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
41
             String passTime = newDate.format(formatter);
42
             String passTime = newDate.format(formatter);
42
-            params.put("oldOrgCode", taRotation.getSpecificOrgName());
43
-            params.put("newOrgCode", taRotation.getSpecificNameOrgRotation());
43
+            params.put("oldOrgCode", taRotation.getSpecificOrgNum());
44
+            params.put("newOrgCode", taRotation.getOrgNumJobRotation());
44
             params.put("primaryPost", taRotation.getCounterImpPositions());
45
             params.put("primaryPost", taRotation.getCounterImpPositions());
45
             params.put("targetPost", taRotation.getCounterImpPostRotation());
46
             params.put("targetPost", taRotation.getCounterImpPostRotation());
46
             params.put("passTime", passTime);
47
             params.put("passTime", passTime);
47
 
48
 
48
-
49
             List<ErrorDto> result = siftRule(params);
49
             List<ErrorDto> result = siftRule(params);
50
+            boolean isRulesCompatible = true;
51
+            if (!result.isEmpty()) {
52
+                isRulesCompatible = result.stream()
53
+                        .allMatch(error -> error.getRules() != null && error.getRules().contains(COMPATIBLE_TEXT));
54
+
55
+
56
+            }
57
+
58
+            String message = (isRulesCompatible  ? "不相容" : "相容";
59
+
60
+
61
+                int statusCode = 200; // HTTP状态码
62
+                // 自定义消息
63
+                SaResult response = CreateResponse.createResponse(statusCode, result, message);
64
+
65
+                return response;
50
 
66
 
51
-            return result;
52
         }
67
         }
53
-        return taRotation;
68
+        return SaResult.data(taRotation);
54
     }
69
     }
55
 
70
 
56
 
71
 
57
     public List<ErrorDto> siftRule(Map<String, String> params) {
72
     public List<ErrorDto> siftRule(Map<String, String> params) {
58
-        String primaryPost = params.get("primaryPost");
59
-        String targetPost = params.get("targetPost");
60
-
73
+        List<TaIncompatible> taIncompatibleList = new ArrayList<>();
74
+        if (params.get("oldOrgCode").equals(params.get("newOrgCode"))) {
75
+//        普通规则
76
+            taIncompatibleList = regularRules(params);
77
+        }
78
+//        三个月规则
61
         List<TaRotation> repelList = getMonthRules(params);
79
         List<TaRotation> repelList = getMonthRules(params);
62
 
80
 
63
-        List<TaIncompatible> taIncompatibleList = regularRules(primaryPost, targetPost);
64
 
81
 
65
-        RuleDetail ruleDetail=new RuleDetail();
82
+        RuleDetail ruleDetail = new RuleDetail();
66
 
83
 
67
-        List<ErrorDto> result = ruleDetail.planRuleType(taIncompatibleList,repelList);
84
+        List<ErrorDto> result = ruleDetail.planRuleType(taIncompatibleList, repelList);
68
 
85
 
69
 
86
 
70
         return result;
87
         return result;
73
     }
90
     }
74
 
91
 
75
 
92
 
76
-    public List<TaIncompatible> regularRules(String primaryPost, String targetPost) {
77
-        return taIncompatibleMapper.getRegularRules(primaryPost, targetPost, Constants.REGULAR_RULE);
93
+    public List<TaIncompatible> regularRules(Map<String, String> params) {
94
+        return taIncompatibleMapper.getRegularRules(params, Constants.REGULAR_RULE);
78
 
95
 
79
     }
96
     }
80
 
97
 
102
             targetList.add(targetPost);
119
             targetList.add(targetPost);
103
 
120
 
104
             //拿到数据 不相容轮岗数据
121
             //拿到数据 不相容轮岗数据
105
-            repelList = taRotationMapper.selectRepel(orgList, targetList, newDate,params);
122
+            repelList = taRotationMapper.selectRepel(orgList, targetList, newDate, params);
106
 
123
 
107
             return repelList;
124
             return repelList;
108
         }
125
         }

+ 8
- 7
application/src/main/java/com/lyg/application/util/RuleDetail.java 查看文件

12
 
12
 
13
     public List<ErrorDto> planRuleType(List<TaIncompatible> taIncompatibleList, List<TaRotation> repelList) {
13
     public List<ErrorDto> planRuleType(List<TaIncompatible> taIncompatibleList, List<TaRotation> repelList) {
14
 
14
 
15
-        ErrorDto errorDto = new ErrorDto();
16
         List<ErrorDto> result = new ArrayList<>();
15
         List<ErrorDto> result = new ArrayList<>();
17
 
16
 
18
         //普通规则
17
         //普通规则
19
         // 处理 taIncompatibleList
18
         // 处理 taIncompatibleList
20
-        if (taIncompatibleList.size() != 0) {
19
+//        if (taIncompatibleList.size() != 0) {
21
             result.addAll(processTaIncompatibleList(taIncompatibleList));
20
             result.addAll(processTaIncompatibleList(taIncompatibleList));
22
-        }
21
+//        }
23
 
22
 
24
 
23
 
25
         // 处理 repelList
24
         // 处理 repelList
26
-        if (repelList.size() != 0) {
25
+//        if (repelList.size() != 0) {
27
             result.addAll(processTaRotationList(repelList));
26
             result.addAll(processTaRotationList(repelList));
28
-        }
27
+//        }
29
         return result;
28
         return result;
30
 
29
 
31
 
30
 
37
 
36
 
38
         // 当列表为空,直接添加一个具有默认信息的 ErrorDto
37
         // 当列表为空,直接添加一个具有默认信息的 ErrorDto
39
         if (repelList.isEmpty()) {
38
         if (repelList.isEmpty()) {
40
-            errorDto.setMonthRules("根据不相容设置这两个岗位是相容的");
39
+            errorDto.setRules("根据不相容设置这两个岗位是相容的");
41
             resultList.add(errorDto);
40
             resultList.add(errorDto);
42
             return resultList;
41
             return resultList;
43
         }
42
         }
46
         for (TaRotation item : repelList) {
45
         for (TaRotation item : repelList) {
47
             ErrorDto dto = new ErrorDto();
46
             ErrorDto dto = new ErrorDto();
48
             // 设置属性
47
             // 设置属性
48
+            dto.setRules("根据不相容设置这两个岗位是不相容的");
49
             dto.setCounterImpPositions(item.getCounterImpPositions());
49
             dto.setCounterImpPositions(item.getCounterImpPositions());
50
             dto.setCounterImpPost(item.getCounterImpPostRotation());
50
             dto.setCounterImpPost(item.getCounterImpPostRotation());
51
             dto.setSpecificOrgName(item.getSpecificOrgName());
51
             dto.setSpecificOrgName(item.getSpecificOrgName());
68
 
68
 
69
         // 当列表为空,直接添加一个具有默认信息的 ErrorDto
69
         // 当列表为空,直接添加一个具有默认信息的 ErrorDto
70
         if (taIncompatibleList.isEmpty()) {
70
         if (taIncompatibleList.isEmpty()) {
71
-            errorDto.setRegularRules("根据不相容设置这两个岗位是相容的");
71
+            errorDto.setRules("根据不相容设置这两个岗位是相容的");
72
             resultList.add(errorDto);
72
             resultList.add(errorDto);
73
             return resultList;
73
             return resultList;
74
         }
74
         }
76
         // 对每个 item 进行处理,创建新的 ErrorDto 实例
76
         // 对每个 item 进行处理,创建新的 ErrorDto 实例
77
         for (TaIncompatible item : taIncompatibleList) {
77
         for (TaIncompatible item : taIncompatibleList) {
78
             ErrorDto dto = new ErrorDto();
78
             ErrorDto dto = new ErrorDto();
79
+            dto.setRules("根据不相容设置这两个岗位是不相容的");
79
             dto.setPrimaryPost(item.getPrimaryPost());
80
             dto.setPrimaryPost(item.getPrimaryPost());
80
             dto.setTargetPost(item.getTargetPost());
81
             dto.setTargetPost(item.getTargetPost());
81
             resultList.add(dto);
82
             resultList.add(dto);

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

8
         FROM
8
         FROM
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=#{params.primaryPost} AND i.TARGET_POST=#{params.targetPost}
12
         AND i.DELETED=0 AND i.Rule=#{regularRule}
12
         AND i.DELETED=0 AND i.Rule=#{regularRule}
13
     </select>
13
     </select>
14
 
14
 

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

14
 
14
 
15
 
15
 
16
     //普通规则
16
     //普通规则
17
-    public final static String REGULAR_RULE = "regularRule";
17
+    public final static String REGULAR_RULE = "regularRules";
18
 
18
 
19
     //三个月规则
19
     //三个月规则
20
     public final static String MONTH_RULE = "monthRules";
20
     public final static String MONTH_RULE = "monthRules";