Browse Source

清单审核

csg6 10 months ago
parent
commit
c8fd467b42

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -7,7 +7,7 @@ ruoyi:
7 7
   # 版权年份
8 8
   copyrightYear: 2023
9 9
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
10
-  profile: c:/ruoyi/uploadPath
10
+  profile: c:/gnhz/uploadPath
11 11
   # 获取ip地址开关
12 12
   addressEnabled: false
13 13
   # 验证码类型 math 数字计算 char 字符验证

+ 33 - 2
ruoyi-common/src/main/java/com/ruoyi/common/constant/PostListEnum.java

@@ -5,13 +5,24 @@ package com.ruoyi.common.constant;
5 5
  */
6 6
 public enum PostListEnum {
7 7
 
8
-//    状态:1-待审核;2-审核中;3-通过;4-驳回;
8
+    //    状态:1-待审核;2-审核中;3-通过;4-驳回;
9 9
     STATUS_WAIT("待审核", 1),
10 10
     STATUS_ING("审核中", 2),
11 11
     STATUS_PASS("通过;", 3),
12
-    STATUS_BACK("驳回;", 4);
12
+    STATUS_BACK("驳回;", 4),
13 13
 
14 14
 
15
+//    1-业务职责(人力资源部)
16
+//    2-党建及党风廉政建设职责(党建工作部)
17
+//    3-安全环保职责(健康安全环保中心)
18
+//    4-合规保密职责(内控法务部&办公室)
19
+//    5-任职资格与能力素质要求(不需要审核)
20
+
21
+    TYPE_ONE("业务职责(人力资源部)", 1),
22
+    TYPE_TWO("党建及党风廉政建设职责(党建工作部)", 2),
23
+    TYPE_THREE("安全环保职责(健康安全环保中心)", 3),
24
+    TYPE_FOUR("合规保密职责(内控法务部&办公室)", 4),
25
+    TYPE_FIVE("任职资格与能力素质要求(不需要审核)", 5);
15 26
 
16 27
     private String name;
17 28
     private Integer value;
@@ -36,4 +47,24 @@ public enum PostListEnum {
36 47
     public void setValue(Integer value) {
37 48
         this.value = value;
38 49
     }
50
+
51
+    public static String getTypeView(int type) {
52
+        switch (type) {
53
+            case 1:
54
+                return "业务职责";
55
+            case 2:
56
+                return "党建及党风廉政建设职责";
57
+            case 3:
58
+                return "安全环保职责";
59
+            case 4:
60
+                return "合规保密职责";
61
+            case 5:
62
+                return "任职资格与能力素质要求";
63
+            default:
64
+                return "Other";
65
+
66
+        }
67
+    }
68
+
69
+
39 70
 }

+ 11 - 8
ruoyi-common/src/main/java/com/ruoyi/common/enums/DeptCode.java

@@ -2,26 +2,29 @@ package com.ruoyi.common.enums;
2 2
 
3 3
 public enum DeptCode {
4 4
 
5
-    DEPT_HR("10010712", "人力资源部"),
6
-    DEPT_ICFA("50007343", "内控法务部");
5
+    DEPT_HR("10001", "人力资源部"),
6
+
7
+    DEPT_PARTY("10002", "党建工作部"),
8
+
9
+    DEPT_HSE("10003", "健康安全环保中心"),
10
+
11
+    DEPT_ICFA("10004", "内控法务部"),
12
+    DEPT_OFFICE("10005", "办公室");
7 13
 
8 14
 
9 15
     private final String code;
10 16
     private final String info;
11 17
 
12
-    DeptCode(String code, String info)
13
-    {
18
+    DeptCode(String code, String info) {
14 19
         this.code = code;
15 20
         this.info = info;
16 21
     }
17 22
 
18
-    public String getCode()
19
-    {
23
+    public String getCode() {
20 24
         return code;
21 25
     }
22 26
 
23
-    public String getInfo()
24
-    {
27
+    public String getInfo() {
25 28
         return info;
26 29
     }
27 30
 }

+ 74 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/controller/PostListController.java

@@ -4,9 +4,15 @@ import java.util.*;
4 4
 import javax.servlet.http.HttpServletResponse;
5 5
 
6 6
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
7
+import com.ruoyi.common.constant.PostListEnum;
8
+import com.ruoyi.common.enums.DeptCode;
9
+import com.ruoyi.common.exception.base.BaseException;
10
+import com.ruoyi.common.utils.SecurityUtils;
7 11
 import com.ruoyi.postCheck.domain.PostCheckedItems;
8 12
 import com.ruoyi.postCheck.domain.PostListInfo;
9 13
 import com.ruoyi.postCheck.domain.tools.PostCheckListType;
14
+import com.ruoyi.postCheck.domain.tools.PostListApproveTypeUser;
15
+import com.ruoyi.system.service.ISysPostService;
10 16
 import org.springframework.security.access.prepost.PreAuthorize;
11 17
 import org.springframework.beans.factory.annotation.Autowired;
12 18
 import org.springframework.util.CollectionUtils;
@@ -44,6 +50,9 @@ public class PostListController extends BaseController {
44 50
     @Autowired
45 51
     private IPostListService postListService;
46 52
 
53
+    @Autowired
54
+    private ISysPostService sysPostService;
55
+
47 56
     /**
48 57
      * 查询岗位责任制清单列表
49 58
      */
@@ -137,6 +146,71 @@ public class PostListController extends BaseController {
137 146
     }
138 147
 
139 148
 
149
+    @ApiOperation("岗位责任制清单审核权限用户列表")
150
+    @GetMapping("/approveTypeUserList")
151
+    public AjaxResult approveTypeUserList() {
152
+        /*
153
+        [
154
+            {
155
+                "type" :1 // 1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求
156
+                "userList" : [111111, 222222, 33333] // 用户权限列表
157
+            },
158
+            {
159
+                "type" :2 // 1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求
160
+                "userList" : [111111, 222222, 33333] // 用户权限列表
161
+            },
162
+            {
163
+                "type" :3 // 1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求
164
+                "userList" : [111111, 222222, 33333] // 用户权限列表
165
+            },
166
+            {
167
+                "type" :4 // 1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求
168
+                "userList" : [111111, 222222, 33333] // 用户权限列表
169
+            }
170
+        ]
171
+         */
172
+
173
+//        Map<Integer, List<Long>> typeMap = new HashMap<>();
174
+//        typeMap.put(PostListEnum.TYPE_ONE.getValue(), sysPostService.userHaveAuthorityList(DeptCode.DEPT_HR.getCode()));
175
+//        typeMap.put(PostListEnum.TYPE_TWO.getValue(), sysPostService.userHaveAuthorityList(DeptCode.DEPT_PARTY.getCode()));
176
+//        typeMap.put(PostListEnum.TYPE_THREE.getValue(), sysPostService.userHaveAuthorityList(DeptCode.DEPT_HSE.getCode()));
177
+
178
+//        List<Long> userHaveAuthorityList = sysPostService.userHaveAuthorityList(DeptCode.DEPT_ICFA.getCode());
179
+//        List<Long> userHaveAuthorityListV2 = sysPostService.userHaveAuthorityList(DeptCode.DEPT_OFFICE.getCode());
180
+//        userHaveAuthorityList.addAll(userHaveAuthorityListV2);
181
+//        typeMap.put(PostListEnum.TYPE_FOUR.getValue(), userHaveAuthorityList);
182
+
183
+        List<PostListApproveTypeUser> typeUserList = new ArrayList<>();
184
+        PostListApproveTypeUser data1 = new PostListApproveTypeUser(PostListEnum.TYPE_ONE.getValue(), sysPostService.userHaveAuthorityList(DeptCode.DEPT_HR.getCode()));
185
+        PostListApproveTypeUser data2 = new PostListApproveTypeUser(PostListEnum.TYPE_TWO.getValue(), sysPostService.userHaveAuthorityList(DeptCode.DEPT_PARTY.getCode()));
186
+        PostListApproveTypeUser data3 = new PostListApproveTypeUser(PostListEnum.TYPE_THREE.getValue(), sysPostService.userHaveAuthorityList(DeptCode.DEPT_HSE.getCode()));
187
+        List<Long> userHaveAuthorityList = sysPostService.userHaveAuthorityList(DeptCode.DEPT_ICFA.getCode());
188
+        List<Long> userHaveAuthorityListV2 = sysPostService.userHaveAuthorityList(DeptCode.DEPT_OFFICE.getCode());
189
+        userHaveAuthorityList.addAll(userHaveAuthorityListV2);
190
+        PostListApproveTypeUser data4 = new PostListApproveTypeUser(PostListEnum.TYPE_FOUR.getValue(), userHaveAuthorityList);
191
+        typeUserList.add(data1);
192
+        typeUserList.add(data2);
193
+        typeUserList.add(data3);
194
+        typeUserList.add(data4);
195
+
196
+        return success(typeUserList);
197
+    }
198
+
199
+
200
+    @ApiOperation("岗位责任制清单审核")
201
+    @ApiImplicitParams({
202
+            @ApiImplicitParam(name = "type", value = "审核的类型(1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求)", dataType = "String", dataTypeClass = String.class),
203
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "String", dataTypeClass = String.class),
204
+            @ApiImplicitParam(name = "status", value = "状态:3-通过;4-驳回;", dataType = "String", dataTypeClass = String.class),
205
+            @ApiImplicitParam(name = "reason", value = "未通过理由(驳回时必选)", dataType = "String", dataTypeClass = String.class),
206
+    })
207
+    @Log(title = "岗位责任制清单审核", businessType = BusinessType.UPDATE)
208
+    @PutMapping("/approve")
209
+    public AjaxResult approve(Integer type, Long id, Integer status, String reason) {
210
+        return toAjax(postListService.approve(type, id, status, reason));
211
+    }
212
+
213
+
140 214
     @ApiOperation("1、检查项目下拉框(不需要参数)")
141 215
     @GetMapping("/typeList")
142 216
     public AjaxResult typeList(PostCheckListType postCheckListType) {

+ 4 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/domain/PostList.java

@@ -126,4 +126,8 @@ public class PostList extends BaseEntity
126 126
     @TableField(exist = false)
127 127
     private List<PostListInfo> children = new ArrayList<>();
128 128
 
129
+    @ApiModelProperty("未通过理由:明细表的值")
130
+    @TableField(exist = false)
131
+    private String reason;
132
+
129 133
 }

+ 14 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/domain/PostListInfo.java

@@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
11 11
 import lombok.Data;
12 12
 import lombok.EqualsAndHashCode;
13 13
 
14
+import java.util.Date;
15
+
14 16
 /**
15 17
  * 岗检责任制清单明细对象 post_list_info
16 18
  *
@@ -31,6 +33,11 @@ public class PostListInfo extends BaseEntity
31 33
     @Excel(name = "分区域审核-状态:1-待审核;3-通过;4-驳回;")
32 34
     private Integer status;
33 35
 
36
+    @ApiModelProperty("状态更新时间")
37
+    @TableField(value = "status_time")
38
+    @Excel(name = "状态更新时间")
39
+    private Date statusTime;
40
+
34 41
     @ApiModelProperty("审核人ID")
35 42
     @TableField(value = "status_by_user_id")
36 43
     @Excel(name = "审核人ID")
@@ -41,6 +48,11 @@ public class PostListInfo extends BaseEntity
41 48
     @Excel(name = "审核人姓名")
42 49
     private String statusByUserName;
43 50
 
51
+    @ApiModelProperty("未通过理由")
52
+    @TableField(value = "reason")
53
+    @Excel(name = "未通过理由")
54
+    private String reason;
55
+
44 56
     @ApiModelProperty("岗位责任制清单表ID")
45 57
     @TableField(value = "post_list_id")
46 58
     @Excel(name = "岗位责任制清单表ID", readConverterExp = "多=")
@@ -96,4 +108,6 @@ public class PostListInfo extends BaseEntity
96 108
     @Excel(name = "创建者用户ID")
97 109
     private Long createUserId;
98 110
 
111
+
112
+
99 113
 }

+ 23 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/domain/tools/PostListApproveTypeUser.java

@@ -0,0 +1,23 @@
1
+package com.ruoyi.postCheck.domain.tools;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+
7
+import java.util.ArrayList;
8
+import java.util.List;
9
+
10
+@ApiModel(value = "岗位责任制清单审核权限用户")
11
+@Data
12
+public class PostListApproveTypeUser {
13
+    @ApiModelProperty("1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求")
14
+    private Integer type;
15
+
16
+    @ApiModelProperty("拥有审核权限的用户数组")
17
+    private List<Long> userList = new ArrayList<>();
18
+
19
+    public PostListApproveTypeUser(Integer type, List<Long> userList) {
20
+        this.type = type;
21
+        this.userList = userList;
22
+    }
23
+}

+ 13 - 0
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/service/IPostListService.java

@@ -5,6 +5,9 @@ import java.util.List;
5 5
 import com.ruoyi.postCheck.domain.PostCheckedItems;
6 6
 import com.ruoyi.postCheck.domain.PostList;
7 7
 import com.baomidou.mybatisplus.extension.service.IService;
8
+import io.swagger.annotations.ApiImplicitParam;
9
+import io.swagger.annotations.ApiImplicitParams;
10
+import io.swagger.annotations.ApiOperation;
8 11
 
9 12
 /**
10 13
  * 岗检责任制清单Service接口
@@ -70,4 +73,14 @@ public interface IPostListService extends IService<PostList>
70 73
      * @return
71 74
      */
72 75
     List<PostCheckedItems> contentListByType(Long deptId, Long postId, Integer type);
76
+
77
+    /**
78
+     * 岗位责任制清单审核
79
+     * @param type 审核的类型(1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求)
80
+     * @param id 主键ID
81
+     * @param status 状态:3-通过;4-驳回;
82
+     * @param reason 未通过理由(驳回时必选)
83
+     * @return
84
+     */
85
+    int approve(Integer type, Long id, Integer status, String reason);
73 86
 }

+ 192 - 15
ruoyi-postcheck/src/main/java/com/ruoyi/postCheck/service/impl/PostListServiceImpl.java

@@ -1,21 +1,25 @@
1 1
 package com.ruoyi.postCheck.service.impl;
2 2
 
3
-import java.util.Date;
4
-import java.util.List;
3
+import java.util.*;
5 4
 
6 5
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
7 6
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
7
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
8
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
8 9
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
10
+import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
9 11
 import com.ruoyi.common.constant.PostListEnum;
12
+import com.ruoyi.common.enums.DeptCode;
13
+import com.ruoyi.common.exception.base.BaseException;
10 14
 import com.ruoyi.common.utils.DateUtils;
11 15
 import com.ruoyi.common.utils.SecurityUtils;
12 16
 import com.ruoyi.postCheck.domain.PostCheckedItems;
17
+import com.ruoyi.postCheck.mapper.PostListInfoMapper;
13 18
 import com.ruoyi.postCheck.service.IPostListInfoService;
19
+import com.ruoyi.system.service.ISysPostService;
14 20
 import org.springframework.beans.factory.annotation.Autowired;
15 21
 import org.springframework.stereotype.Service;
16 22
 
17
-import java.util.ArrayList;
18
-import java.util.Map;
19 23
 import java.util.stream.Collectors;
20 24
 
21 25
 import com.ruoyi.common.utils.StringUtils;
@@ -37,10 +41,15 @@ import org.springframework.util.CollectionUtils;
37 41
 public class PostListServiceImpl extends ServiceImpl<PostListMapper, PostList> implements IPostListService {
38 42
     @Autowired
39 43
     private PostListMapper postListMapper;
44
+    @Autowired
45
+    private PostListInfoMapper postListInfoMapper;
40 46
 
41 47
     @Autowired
42 48
     private IPostListInfoService postListInfoService;
43 49
 
50
+    @Autowired
51
+    private ISysPostService sysPostService;
52
+
44 53
     /**
45 54
      * 查询岗检责任制清单
46 55
      *
@@ -100,18 +109,29 @@ public class PostListServiceImpl extends ServiceImpl<PostListMapper, PostList> i
100 109
         //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
101 110
 //        if (postList.getId() == null)
102 111
         postList.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
103
-
104 112
         postList.setCreateDefault();
105 113
         postList.setCreationDate(new Date());//编制时间
106 114
         postList.setRevisionDate(new Date());//修订时间
107 115
         postList.setStatus(PostListEnum.STATUS_WAIT.getValue());//待审核
108
-
109
-//        String isConfidential = postList.getIsConfidential();
110
-//        System.out.println("isConfidential = " + isConfidential);
111
-
112 116
         int rows = postListMapper.insertPostList(postList);
117
+
113 118
         //新增责任制清单明细
114 119
         insertPostListInfo(postList);
120
+
121
+        //TODO 更新业务职责的状态=待审核:只要部门修改数据,人力资源都需要重新审核单据
122
+        //1、按区域类型+主表id批量更新明细表状态、审核人、审核时间、未通过理由
123
+        LambdaUpdateWrapper<PostListInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
124
+        //条件
125
+        lambdaUpdateWrapper.eq(PostListInfo::getPostListId, postList.getId());
126
+        lambdaUpdateWrapper.eq(PostListInfo::getType, PostListEnum.TYPE_ONE.getValue());
127
+        //参数
128
+        lambdaUpdateWrapper.set(PostListInfo::getStatus, PostListEnum.STATUS_WAIT.getValue());
129
+        lambdaUpdateWrapper.set(PostListInfo::getStatusTime, null);
130
+        lambdaUpdateWrapper.set(PostListInfo::getStatusByUserId, null);
131
+        lambdaUpdateWrapper.set(PostListInfo::getStatusByUserName, null);
132
+        lambdaUpdateWrapper.set(PostListInfo::getReason, null);
133
+        postListInfoMapper.update(null, lambdaUpdateWrapper);
134
+
115 135
         return rows;
116 136
     }
117 137
 
@@ -127,11 +147,40 @@ public class PostListServiceImpl extends ServiceImpl<PostListMapper, PostList> i
127 147
         postList.setUpdateDefault();
128 148
         //TODO 待改造,不可以将全部删除完,哪个部门修改了删除那个部门的,其他部门的不能删除。
129 149
         //删除明细
130
-        postListMapper.deletePostListInfoByPostListId(postList.getId());
150
+//        postListMapper.deletePostListInfoByPostListId(postList.getId());
151
+        //删除明细:按类型只删除本次包含的主要职责
152
+        List<PostListInfo> children = postList.getChildren();
153
+        Map<Integer, List<PostListInfo>> typeMapList = children.stream().collect(Collectors.groupingBy(PostListInfo::getType));
154
+        Set<Integer> typeList = typeMapList.keySet();
155
+        if (CollectionUtils.isEmpty(typeList)) {
156
+            throw new BaseException("请至少设置一项“主要职责”!");
157
+        }
158
+        LambdaQueryWrapper<PostListInfo> deleteWrapper = new LambdaQueryWrapper<>();
159
+        deleteWrapper.eq(PostListInfo::getPostListId, postList.getId());
160
+        deleteWrapper.in(PostListInfo::getType, typeList);
161
+        postListInfoMapper.delete(deleteWrapper);
162
+
131 163
         //重新添加
132 164
         insertPostListInfo(postList);
133 165
 
134
-        return postListMapper.updatePostList(postList);
166
+        postList.setStatus(PostListEnum.STATUS_WAIT.getValue());
167
+        int updateCount = postListMapper.updatePostList(postList);
168
+
169
+        //TODO 更新业务职责的状态=待审核:只要部门修改数据,人力资源都需要重新审核单据
170
+        //1、按区域类型+主表id批量更新明细表状态、审核人、审核时间、未通过理由
171
+        LambdaUpdateWrapper<PostListInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
172
+        //条件
173
+        lambdaUpdateWrapper.eq(PostListInfo::getPostListId, postList.getId());
174
+        lambdaUpdateWrapper.eq(PostListInfo::getType, PostListEnum.TYPE_ONE.getValue());
175
+        //参数
176
+        lambdaUpdateWrapper.set(PostListInfo::getStatus, PostListEnum.STATUS_WAIT.getValue());
177
+        lambdaUpdateWrapper.set(PostListInfo::getStatusTime, null);
178
+        lambdaUpdateWrapper.set(PostListInfo::getStatusByUserId, null);
179
+        lambdaUpdateWrapper.set(PostListInfo::getStatusByUserName, null);
180
+        lambdaUpdateWrapper.set(PostListInfo::getReason, null);
181
+        postListInfoMapper.update(null, lambdaUpdateWrapper);
182
+
183
+        return updateCount;
135 184
     }
136 185
 
137 186
     /**
@@ -168,20 +217,34 @@ public class PostListServiceImpl extends ServiceImpl<PostListMapper, PostList> i
168 217
     public void insertPostListInfo(PostList postList) {
169 218
         List<PostListInfo> children = postList.getChildren();
170 219
         Long id = postList.getId();
171
-        if (StringUtils.isNotNull(children)) {
220
+        if (!CollectionUtils.isEmpty(children)) {
172 221
             List<PostListInfo> list = new ArrayList<>();
173 222
             for (PostListInfo postListInfo : children) {
223
+                Integer type = postListInfo.getType();
174 224
                 //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
175 225
 //                if (postListInfo.getId() == null)
176 226
                 postListInfo.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
177
-
178
-                postListInfo.setCreateDefault();
179 227
                 postListInfo.setPostListId(id);
180 228
 
229
+                postListInfo.setCreateDefault();
181 230
                 postListInfo.setCreateUserId(SecurityUtils.getUserId());//创建者ID
182
-                postListInfo.setStatus(PostListEnum.STATUS_WAIT.getValue());//状态,可能需要重新设计,五大部门按类型区分状态
231
+                //自动审核:任职资格与能力素质要求
232
+                if (type == PostListEnum.TYPE_FIVE.getValue()) {
233
+                    postListInfo.setStatus(PostListEnum.STATUS_PASS.getValue());//状态,可能需要重新设计,五大部门按类型区分状态
234
+                    postListInfo.setStatusByUserId(SecurityUtils.getUserId());
235
+                    postListInfo.setStatusByUserName(SecurityUtils.getLoginUser().getUser().getNickName());
236
+                    postListInfo.setReason("Auto");
237
+                }
238
+                //其他都是待审核
239
+                else {
240
+                    postListInfo.setStatus(PostListEnum.STATUS_WAIT.getValue());//状态,可能需要重新设计,五大部门按类型区分状态
241
+                }
183 242
 
184 243
                 list.add(postListInfo);
244
+                //非业务职责修改时将业务职责设置为待审核
245
+//                if (postListInfo.getType() != PostListEnum.TYPE_ONE.getValue()) {
246
+//
247
+//                }
185 248
             }
186 249
             if (list.size() > 0) {
187 250
                 postListMapper.batchPostListInfo(list);
@@ -201,4 +264,118 @@ public class PostListServiceImpl extends ServiceImpl<PostListMapper, PostList> i
201 264
 
202 265
         return postListMapper.contentListByType(deptId, postId, type);
203 266
     }
267
+
268
+    /**
269
+     * 岗位责任制清单审核
270
+     *
271
+     * @param type   审核的类型(1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求)
272
+     * @param id     主键ID
273
+     * @param status 状态:3-通过;4-驳回;
274
+     * @param reason 未通过理由(驳回时必选)
275
+     * @return
276
+     */
277
+    @Override
278
+    public int approve(Integer type, Long id, Integer status, String reason) {
279
+        if (type == null || id == null || status == null) {
280
+            throw new BaseException("参数不全,请检查!");
281
+        }
282
+        if (status == PostListEnum.STATUS_BACK.getValue() && StringUtils.isBlank(reason)) {
283
+            throw new BaseException("请填写未通过理由!");
284
+        }
285
+
286
+        if (status == PostListEnum.STATUS_PASS.getValue() && status == PostListEnum.STATUS_BACK.getValue()) {
287
+            throw new BaseException("状态错误,请检查!");
288
+        }
289
+
290
+        //1、判断权限
291
+        //1-业务职责(人力资源部)
292
+        if (type == PostListEnum.TYPE_ONE.getValue()) {
293
+            List<Long> userHaveAuthorityList = sysPostService.userHaveAuthorityList(DeptCode.DEPT_HR.getCode());
294
+            if (!userHaveAuthorityList.contains(SecurityUtils.getUserId())) {
295
+                throw new BaseException("当前账号无权限,请检查!【" + type + "】");
296
+            }
297
+
298
+        }
299
+        //2-党建及党风廉政建设职责(党建工作部)
300
+        else if (type == PostListEnum.TYPE_TWO.getValue()) {
301
+            List<Long> userHaveAuthorityList = sysPostService.userHaveAuthorityList(DeptCode.DEPT_PARTY.getCode());
302
+            if (!userHaveAuthorityList.contains(SecurityUtils.getUserId())) {
303
+                throw new BaseException("当前账号无权限,请检查!【" + type + "】");
304
+            }
305
+        }
306
+        //3-安全环保职责(健康安全环保中心)
307
+        else if (type == PostListEnum.TYPE_THREE.getValue()) {
308
+            List<Long> userHaveAuthorityList = sysPostService.userHaveAuthorityList(DeptCode.DEPT_HSE.getCode());
309
+            if (!userHaveAuthorityList.contains(SecurityUtils.getUserId())) {
310
+                throw new BaseException("当前账号无权限,请检查!【" + type + "】");
311
+            }
312
+        }
313
+        //4-合规保密职责(内控法务部&办公室)
314
+        else if (type == PostListEnum.TYPE_FOUR.getValue()) {
315
+            List<Long> userHaveAuthorityList = sysPostService.userHaveAuthorityList(DeptCode.DEPT_ICFA.getCode());
316
+            List<Long> userHaveAuthorityListV2 = sysPostService.userHaveAuthorityList(DeptCode.DEPT_OFFICE.getCode());
317
+            userHaveAuthorityList.addAll(userHaveAuthorityListV2);
318
+
319
+            if (!userHaveAuthorityList.contains(SecurityUtils.getUserId())) {
320
+                throw new BaseException("当前账号无权限,请检查!【" + type + "】");
321
+            }
322
+        }
323
+        //不需要审核,新增修改时自动审核的
324
+        //5-任职资格与能力素质要求(不需要审核)
325
+//        else if (type == PostListEnum.TYPE_ONE.getValue()) {
326
+//
327
+//        }
328
+        else {
329
+            throw new BaseException("类型错误,请检查!");
330
+        }
331
+
332
+
333
+        //2、判断人力资源最后审核
334
+        if (type == PostListEnum.TYPE_ONE.getValue()) {
335
+            //查询其他类型待审核的记录
336
+            LambdaQueryWrapper<PostListInfo> queryWrapper = new LambdaQueryWrapper<>();
337
+            queryWrapper.eq(PostListInfo::getPostListId, id);
338
+            queryWrapper.ne(PostListInfo::getType, PostListEnum.TYPE_ONE.getValue());//类型(1-业务职责;2-党建及党风廉政建设职责;3-安全环保职责;4-合规保密职;5-任职资格与能力素质要求)
339
+            queryWrapper.ne(PostListInfo::getStatus, PostListEnum.STATUS_WAIT.getValue());//分区域审核-状态:1-待审核;3-通过;4-驳回;
340
+
341
+            List<PostListInfo> postListInfoList = postListInfoMapper.selectList(queryWrapper);
342
+            if (!CollectionUtils.isEmpty(postListInfoList)) {
343
+                Set<Integer> typeSet = postListInfoList.stream().map(t -> t.getType()).collect(Collectors.toSet());
344
+                String typeView = "";
345
+                for (Integer typeIng : typeSet) {
346
+                    typeView += PostListEnum.getTypeView(typeIng) + ";";
347
+                }
348
+                throw new BaseException("以下部门还未审核,请检查!" + typeView);
349
+            }
350
+        }
351
+
352
+
353
+        //1、按区域类型+主表id批量更新明细表状态、审核人、审核时间、未通过理由
354
+        LambdaUpdateWrapper<PostListInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
355
+        //条件
356
+        lambdaUpdateWrapper.eq(PostListInfo::getPostListId, id);
357
+        lambdaUpdateWrapper.eq(PostListInfo::getType, type);
358
+        //参数
359
+        lambdaUpdateWrapper.set(PostListInfo::getStatus, status);
360
+        lambdaUpdateWrapper.set(PostListInfo::getStatusTime, new Date());
361
+
362
+        //通过-参数
363
+        if (status == PostListEnum.STATUS_PASS.getValue()) {
364
+            lambdaUpdateWrapper.set(PostListInfo::getStatusByUserId, SecurityUtils.getUserId());
365
+            lambdaUpdateWrapper.set(PostListInfo::getStatusByUserName, SecurityUtils.getLoginUser().getUser().getNickName());
366
+            lambdaUpdateWrapper.set(PostListInfo::getReason, null);
367
+        }
368
+        //驳回-参数
369
+        else if (status == PostListEnum.STATUS_BACK.getValue()) {
370
+            lambdaUpdateWrapper.set(PostListInfo::getStatusByUserId, null);
371
+            lambdaUpdateWrapper.set(PostListInfo::getStatusByUserName, null);
372
+            lambdaUpdateWrapper.set(PostListInfo::getReason, reason);
373
+        }
374
+        int updateCount = postListInfoMapper.update(null, lambdaUpdateWrapper);
375
+        if (updateCount == 0) {
376
+            throw new BaseException("更新状态失败,请稍后重试!");
377
+        }
378
+
379
+        return updateCount;
380
+    }
204 381
 }

+ 32 - 3
ruoyi-postcheck/src/main/resources/mapper/postCheck/PostListInfoMapper.xml

@@ -26,19 +26,42 @@
26 26
         <result property="updateTime"    column="update_time"    />
27 27
         <result property="updateBy"    column="update_by"    />
28 28
         <result property="createUserId"    column="create_user_id"    />
29
+        <result property="statusTime"    column="status_time"    />
30
+        <result property="reason"    column="reason"    />
29 31
     </resultMap>
30 32
 
31 33
     <sql id="selectPostListInfoVo">
32 34
         select
33
-            id, status, status_by_user_id, status_by_user_name, post_list_id, type, sequence_project, level_one, level_two, level_three, level_four, level_five, work_standard,
34
-            requirement, remark, del_flag, create_time, create_by, update_time, update_by, create_user_id
35
-        from post_list_info
35
+            t1.id,
36
+            t1.status,
37
+            t1.status_time,
38
+            t1.reason,
39
+            t1.status_by_user_id,
40
+            t1.status_by_user_name,
41
+            t1.post_list_id,
42
+            t1.type,
43
+            t1.sequence_project,
44
+            t1.level_one,
45
+            t1.level_two,
46
+            t1.level_three,
47
+            t1.level_four,
48
+            t1.level_five,
49
+            t1.work_standard,
50
+            t1.requirement, remark,
51
+            t1.del_flag,
52
+            t1.create_time,
53
+            t1.create_by,
54
+            t1.update_time,
55
+            t1.update_by,
56
+            t1.create_user_id
57
+        from post_list_info t1
36 58
     </sql>
37 59
 
38 60
     <select id="selectPostListInfoList" parameterType="PostListInfo" resultMap="PostListInfoResult">
39 61
         <include refid="selectPostListInfoVo"/>
40 62
         <where>
41 63
             <if test="status != null "> and status = #{status}</if>
64
+            <if test="reason != null  and reason != ''"> and reason like concat('%', #{reason}, '%')</if>
42 65
             <if test="statusByUserId != null "> and status_by_user_id = #{statusByUserId}</if>
43 66
             <if test="statusByUserName != null  and statusByUserName != ''"> and status_by_user_name like concat('%', #{statusByUserName}, '%')</if>
44 67
             <if test="postListId != null "> and post_list_id = #{postListId}</if>
@@ -66,6 +89,8 @@
66 89
         <trim prefix="(" suffix=")" suffixOverrides=",">
67 90
             <if test="id != null">id,</if>
68 91
             <if test="status != null">status,</if>
92
+            <if test="statusTime != null">status_time,</if>
93
+            <if test="reason != null">reason,</if>
69 94
             <if test="statusByUserId != null">status_by_user_id,</if>
70 95
             <if test="statusByUserName != null">status_by_user_name,</if>
71 96
             <if test="postListId != null">post_list_id,</if>
@@ -89,6 +114,8 @@
89 114
         <trim prefix="values (" suffix=")" suffixOverrides=",">
90 115
             <if test="id != null">#{id},</if>
91 116
             <if test="status != null">#{status},</if>
117
+            <if test="statusTime != null">#{statusTime},</if>
118
+            <if test="reason != null">#{reason},</if>
92 119
             <if test="statusByUserId != null">#{statusByUserId},</if>
93 120
             <if test="statusByUserName != null">#{statusByUserName},</if>
94 121
             <if test="postListId != null">#{postListId},</if>
@@ -115,6 +142,8 @@
115 142
         update post_list_info
116 143
         <trim prefix="SET" suffixOverrides=",">
117 144
             <if test="status != null">status = #{status},</if>
145
+            <if test="statusTime != null">status_time = #{statusTime},</if>
146
+            <if test="reason != null">reason = #{reason},</if>
118 147
             <if test="statusByUserId != null">status_by_user_id = #{statusByUserId},</if>
119 148
             <if test="statusByUserName != null">status_by_user_name = #{statusByUserName},</if>
120 149
             <if test="postListId != null">post_list_id = #{postListId},</if>

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java

@@ -100,4 +100,6 @@ public interface SysPostMapper {
100 100
     public SysPost checkPostCodeUnique(String postCode);
101 101
 
102 102
     List<UserPostAuthority> userPostAuthorityList(@Param("deptId") Long deptId, @Param("postLevel") Integer postLevel);
103
+
104
+    List<UserPostAuthority> userHaveAuthorityList(@Param("deptCode") String deptCode, @Param("postLevel") Integer postLevel);
103 105
 }

+ 15 - 5
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java

@@ -10,8 +10,7 @@ import com.ruoyi.system.domain.UserPostAuthority;
10 10
  *
11 11
  * @author ruoyi
12 12
  */
13
-public interface ISysPostService
14
-{
13
+public interface ISysPostService {
15 14
     /**
16 15
      * 查询岗位信息集合
17 16
      *
@@ -102,16 +101,27 @@ public interface ISysPostService
102 101
 
103 102
     /**
104 103
      * 查询部门经理级别岗位下的人员列表
105
-     * @param deptId 部门ID
104
+     *
105
+     * @param deptId    部门ID
106 106
      * @param postLevel 岗位级别:0-不设置;1-经理;
107 107
      * @return
108 108
      */
109
-    List<UserPostAuthority> userPostAuthorityList(Long deptId,Integer postLevel);
109
+    List<UserPostAuthority> userPostAuthorityList(Long deptId, Integer postLevel);
110 110
 
111 111
     /**
112 112
      * 当前登录用户是否为部门经理级别
113
+     *
113 114
      * @param deptId 部门ID
114 115
      * @return
115 116
      */
116
-   boolean userHaveAuthority(Long deptId);
117
+    boolean userHaveAuthority(Long deptId);
118
+
119
+
120
+    /**
121
+     * 根据部门编码查询经理级别岗位下的用户列表
122
+     *
123
+     * @param deptCode 部门编码
124
+     * @return
125
+     */
126
+    List<Long> userHaveAuthorityList(String deptCode);
117 127
 }

+ 18 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java

@@ -1,5 +1,6 @@
1 1
 package com.ruoyi.system.service.impl;
2 2
 
3
+import java.util.ArrayList;
3 4
 import java.util.List;
4 5
 import java.util.stream.Collectors;
5 6
 
@@ -203,4 +204,21 @@ public class SysPostServiceImpl implements ISysPostService {
203 204
         }
204 205
         return false;
205 206
     }
207
+
208
+    /**
209
+     * 根据部门编码查询经理级别岗位下的用户列表
210
+     *
211
+     * @param deptCode 部门编码
212
+     * @return
213
+     */
214
+    @Override
215
+    public List<Long> userHaveAuthorityList(String deptCode) {
216
+        // 判断岗位是否在权限范围内
217
+        List<UserPostAuthority> userPostAuthorityList = postMapper.userHaveAuthorityList(deptCode, PostLevelEnum.SET_MANAGER.getValue());
218
+        if (CollectionUtils.isEmpty(userPostAuthorityList)) {
219
+            return new ArrayList<>();
220
+        }
221
+        List<Long> haveAuthorityUserList = userPostAuthorityList.stream().map(t -> t.getUserId()).collect(Collectors.toList());
222
+        return haveAuthorityUserList;
223
+    }
206 224
 }

+ 18 - 0
ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml

@@ -158,4 +158,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
158 158
 		</if>
159 159
 	</select>
160 160
 
161
+
162
+	<select id="userHaveAuthorityList"  resultType="UserPostAuthority">
163
+		SELECT
164
+			su."user_id" as userId,
165
+			su."user_name" as userName,
166
+			su."nick_name" as nickName,
167
+			sp."post_id" as postId,
168
+			sp."post_code" as postCode,
169
+			sp."post_name" as postName,
170
+			sp."post_level" as postLevel
171
+		FROM sys_post sp
172
+		INNER JOIN "sys_dept" sd ON  sd."dept_id" = sp."dept_id"
173
+		INNER JOIN "sys_user_post" sup ON sup."post_id" = sp."post_id"
174
+		INNER JOIN "public"."sys_users" su  ON su."user_id"  = sup."user_id"
175
+		WHERE sd."dept_code" = #{deptCode}
176
+		AND sp."post_level" = #{postLevel}
177
+	</select>
178
+
161 179
 </mapper>