张涛 1 year ago
parent
commit
6284856a78

+ 2
- 2
application/src/main/java/com/lyg/application/DTO/ErrorDto.java View File

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

+ 0
- 3
application/src/main/java/com/lyg/application/controller/TaIncompatibleController.java View File

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

+ 49
- 3
application/src/main/java/com/lyg/application/controller/TaRotationController.java View File

@@ -4,8 +4,10 @@ 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 com.lyg.application.DTO.ErrorDto;
7 8
 import com.lyg.application.entity.TaRotation;
8 9
 import com.lyg.application.service.TaRotationService;
10
+import com.lyg.application.util.CreateResponse;
9 11
 import com.lyg.application.util.Rule;
10 12
 import com.lyg.common.util.StringUtil;
11 13
 import com.lyg.framework.accesslimit.AccessLimit;
@@ -19,6 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired;
19 21
 import org.springframework.validation.annotation.Validated;
20 22
 import org.springframework.web.bind.annotation.*;
21 23
 
24
+import java.util.ArrayList;
25
+import java.util.List;
26
+
22 27
 /**
23 28
  * 轮岗列表;(ta_rotation)表控制层
24 29
  *
@@ -55,7 +60,7 @@ public class TaRotationController extends BaseController {
55 60
 
56 61
         Boolean b = checkAuth() == null || checkAuth() == taRotation.getCreateUser();
57 62
         if (b) {
58
-           return SaResult.data(taRotationService.getById(id));
63
+            return SaResult.data(taRotationService.getById(id));
59 64
         }
60 65
         return SaResult.error("无权限");
61 66
 
@@ -120,7 +125,26 @@ public class TaRotationController extends BaseController {
120 125
     public SaResult add(@ApiParam("对象实体") @Validated @RequestBody TaRotation taRotation) throws Exception {
121 126
         taRotationService.save(taRotation);
122 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,7 +163,29 @@ public class TaRotationController extends BaseController {
139 163
         taRotation.setRotationId(id);
140 164
         taRotationService.updateById(taRotation);
141 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 View File

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

+ 0
- 1
application/src/main/java/com/lyg/application/entity/TaRotation.java View File

@@ -36,7 +36,6 @@ public class TaRotation implements Serializable, Cloneable {
36 36
     private String sort;
37 37
 
38 38
     @ExcelProperty(index = 1)
39
-    @NotBlank(message = "总行部门不能为空")
40 39
     @ApiModelProperty(name = "总行部门/一级分行", notes = "")
41 40
     private String headOfficeOrg;
42 41
 

+ 2
- 1
application/src/main/java/com/lyg/application/mapper/TaIncompatibleMapper.java View File

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
6 6
 import org.apache.ibatis.annotations.Param;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Map;
9 10
 
10 11
 /**
11 12
  * 不相容;(ta_incompatible)表数据库访问层
@@ -16,7 +17,7 @@ import java.util.List;
16 17
 @Mapper
17 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 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 View File

@@ -122,10 +122,10 @@ public class TaRotationServiceImpl extends BaseServiceImpl<TaRotationMapper, TaR
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 130
         return entity;
131 131
     }

+ 24
- 0
application/src/main/java/com/lyg/application/util/CreateResponse.java View File

@@ -0,0 +1,24 @@
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 View File

@@ -79,7 +79,7 @@ public class MessageHandle {
79 79
         // 使用描述性强的常量代替硬编码值
80 80
         stringBuilder.append(tmp); // 假设warningTmp或promptTmp已经定义且包含插入点
81 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 83
         stringBuilder.insert(insertPos, item.getEmployeeName());
84 84
         taMessage.setContentSent(stringBuilder.toString());
85 85
         taMessage.setSourceName(sourceName);
@@ -120,7 +120,7 @@ public class MessageHandle {
120 120
         // 使用描述性强的常量代替硬编码值
121 121
         stringBuilder.append(tmp); // 假设warningTmp或promptTmp已经定义且包含插入点
122 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 124
         stringBuilder.insert(insertPos, item.getEmployeeName());
125 125
         taMessage.setContentSent(stringBuilder.toString());
126 126
         taMessage.setSourceName(sourceName);

+ 32
- 15
application/src/main/java/com/lyg/application/util/Rule.java View File

@@ -1,6 +1,7 @@
1 1
 package com.lyg.application.util;
2 2
 
3 3
 
4
+import cn.dev33.satoken.util.SaResult;
4 5
 import com.lyg.application.DTO.ErrorDto;
5 6
 import com.lyg.application.entity.TaIncompatible;
6 7
 import com.lyg.application.entity.TaRotation;
@@ -25,7 +26,7 @@ public class Rule {
25 26
     TaIncompatibleMapper taIncompatibleMapper;
26 27
     @Autowired
27 28
     TaRotationMapper taRotationMapper;
28
-
29
+    private static final String COMPATIBLE_TEXT = "根据不相容设置这两个岗位是相容的";
29 30
 
30 31
     //这是在controller中使用的
31 32
     public Object taRotationRule(TaRotation taRotation) {
@@ -39,32 +40,48 @@ public class Rule {
39 40
             LocalDate newDate = LocalDate.now();
40 41
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
41 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 45
             params.put("primaryPost", taRotation.getCounterImpPositions());
45 46
             params.put("targetPost", taRotation.getCounterImpPostRotation());
46 47
             params.put("passTime", passTime);
47 48
 
48
-
49 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 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 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 87
         return result;
@@ -73,8 +90,8 @@ public class Rule {
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,7 +119,7 @@ public class Rule {
102 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 124
             return repelList;
108 125
         }

+ 8
- 7
application/src/main/java/com/lyg/application/util/RuleDetail.java View File

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

+ 1
- 1
application/src/main/resources/mapper/TaIncompatibleMapper.xml View File

@@ -8,7 +8,7 @@
8 8
         FROM
9 9
         TA_INCOMPATIBLE i
10 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 12
         AND i.DELETED=0 AND i.Rule=#{regularRule}
13 13
     </select>
14 14
 

+ 1
- 1
common/src/main/java/com/lyg/common/Constants.java View File

@@ -14,7 +14,7 @@ public class Constants {
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 20
     public final static String MONTH_RULE = "monthRules";