|
@@ -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
|
}
|