|
@@ -17,8 +17,17 @@ import cn.hutool.core.collection.CollStreamUtil;
|
17
|
17
|
import cn.hutool.core.util.ObjectUtil;
|
18
|
18
|
import cn.hutool.core.util.StrUtil;
|
19
|
19
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
20
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
21
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
22
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
20
|
23
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
21
|
24
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
25
|
+import com.unis.lawEnforcementSupervision.modular.lesJointInspectionTaskItem.entity.LesJointInspectionTaskItem;
|
|
26
|
+import com.unis.lawEnforcementSupervision.modular.lesJointInspectionTaskItem.mapper.LesJointInspectionTaskItemMapper;
|
|
27
|
+import com.unis.policy.info.modular.auditRecord.entity.AuditRecord;
|
|
28
|
+import com.unis.policy.info.modular.auditRecord.mapper.AuditRecordMapper;
|
|
29
|
+import com.unis.policy.info.modular.auditRequest.entity.AuditRequest;
|
|
30
|
+import com.unis.policy.info.modular.auditRequest.mapper.AuditRequestMapper;
|
22
|
31
|
import org.springframework.stereotype.Service;
|
23
|
32
|
import org.springframework.transaction.annotation.Transactional;
|
24
|
33
|
import com.unis.common.enums.CommonSortOrderEnum;
|
|
@@ -32,28 +41,49 @@ import com.unis.lawEnforcementSupervision.modular.lesJointInspectionTask.param.L
|
32
|
41
|
import com.unis.lawEnforcementSupervision.modular.lesJointInspectionTask.param.LesJointInspectionTaskPageParam;
|
33
|
42
|
import com.unis.lawEnforcementSupervision.modular.lesJointInspectionTask.service.LesJointInspectionTaskService;
|
34
|
43
|
|
|
44
|
+import javax.annotation.Resource;
|
35
|
45
|
import java.util.List;
|
36
|
46
|
|
37
|
47
|
/**
|
38
|
48
|
* 联合检查-联合检查任务Service接口实现类
|
39
|
49
|
*
|
40
|
50
|
* @author QSHan
|
41
|
|
- * @date 2024/06/25 17:13
|
|
51
|
+ * @date 2024/06/25 17:13
|
42
|
52
|
**/
|
43
|
53
|
@Service
|
44
|
54
|
public class LesJointInspectionTaskServiceImpl extends ServiceImpl<LesJointInspectionTaskMapper, LesJointInspectionTask> implements LesJointInspectionTaskService {
|
|
55
|
+ @Resource
|
|
56
|
+ private LesJointInspectionTaskItemMapper lesJointInspectionTaskItemMapper;
|
|
57
|
+ @Resource
|
|
58
|
+ private LesJointInspectionTaskMapper lesJointInspectionTaskMapper;
|
|
59
|
+ // 流程主表
|
|
60
|
+ @Resource
|
|
61
|
+ private AuditRequestMapper auditRequestMapper;
|
|
62
|
+ // 流程记录
|
|
63
|
+ @Resource
|
|
64
|
+ private AuditRecordMapper auditRecordMapper;
|
45
|
65
|
|
46
|
66
|
@Override
|
47
|
67
|
public Page<LesJointInspectionTask> page(LesJointInspectionTaskPageParam lesJointInspectionTaskPageParam) {
|
48
|
68
|
QueryWrapper<LesJointInspectionTask> queryWrapper = new QueryWrapper<>();
|
49
|
|
- if(ObjectUtil.isAllNotEmpty(lesJointInspectionTaskPageParam.getSortField(), lesJointInspectionTaskPageParam.getSortOrder())) {
|
|
69
|
+ // 检查任务名称
|
|
70
|
+ if (StringUtils.isNotEmpty(lesJointInspectionTaskPageParam.getInspectionTaskName())) {
|
|
71
|
+ queryWrapper.lambda().like(LesJointInspectionTask::getInspectionTaskName, lesJointInspectionTaskPageParam.getInspectionTaskName());
|
|
72
|
+ }
|
|
73
|
+ // 检查任务审核,查询状态非0的数据(状态 0:保存状态;1:发布(申请中);2:审核通过;3:驳回)
|
|
74
|
+ if (ObjectUtils.isNotEmpty(lesJointInspectionTaskPageParam.getStatus())) {
|
|
75
|
+ if (0 != lesJointInspectionTaskPageParam.getStatus()) {
|
|
76
|
+ queryWrapper.lambda().ne(LesJointInspectionTask::getStatus, 0);
|
|
77
|
+ }
|
|
78
|
+ }
|
|
79
|
+ if (ObjectUtil.isAllNotEmpty(lesJointInspectionTaskPageParam.getSortField(), lesJointInspectionTaskPageParam.getSortOrder())) {
|
50
|
80
|
CommonSortOrderEnum.validate(lesJointInspectionTaskPageParam.getSortOrder());
|
51
|
81
|
queryWrapper.orderBy(true, lesJointInspectionTaskPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
|
52
|
82
|
StrUtil.toUnderlineCase(lesJointInspectionTaskPageParam.getSortField()));
|
53
|
83
|
} else {
|
54
|
|
- queryWrapper.lambda().orderByAsc(LesJointInspectionTask::getId);
|
|
84
|
+ queryWrapper.lambda().orderByDesc(LesJointInspectionTask::getId);
|
55
|
85
|
}
|
56
|
|
- return this.page(CommonPageRequest.defaultPage(), queryWrapper);
|
|
86
|
+ return lesJointInspectionTaskMapper.pageList(CommonPageRequest.defaultPage(), queryWrapper);
|
57
|
87
|
}
|
58
|
88
|
|
59
|
89
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -61,6 +91,12 @@ public class LesJointInspectionTaskServiceImpl extends ServiceImpl<LesJointInspe
|
61
|
91
|
public void add(LesJointInspectionTaskAddParam lesJointInspectionTaskAddParam) {
|
62
|
92
|
LesJointInspectionTask lesJointInspectionTask = BeanUtil.toBean(lesJointInspectionTaskAddParam, LesJointInspectionTask.class);
|
63
|
93
|
this.save(lesJointInspectionTask);
|
|
94
|
+ if (CollectionUtils.isNotEmpty(lesJointInspectionTaskAddParam.getItems())) {
|
|
95
|
+ // 保存子表关联数据
|
|
96
|
+ this.insertChild(lesJointInspectionTask);
|
|
97
|
+ }
|
|
98
|
+ // 添加审批
|
|
99
|
+ this.audit(lesJointInspectionTask);
|
64
|
100
|
}
|
65
|
101
|
|
66
|
102
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -69,6 +105,14 @@ public class LesJointInspectionTaskServiceImpl extends ServiceImpl<LesJointInspe
|
69
|
105
|
LesJointInspectionTask lesJointInspectionTask = this.queryEntity(lesJointInspectionTaskEditParam.getId());
|
70
|
106
|
BeanUtil.copyProperties(lesJointInspectionTaskEditParam, lesJointInspectionTask);
|
71
|
107
|
this.updateById(lesJointInspectionTask);
|
|
108
|
+ if (CollectionUtils.isNotEmpty(lesJointInspectionTask.getItems())) {
|
|
109
|
+ // 先删除
|
|
110
|
+ this.deleteChild(lesJointInspectionTask.getId());
|
|
111
|
+ // 在新增
|
|
112
|
+ this.insertChild(lesJointInspectionTask);
|
|
113
|
+ }
|
|
114
|
+ // 添加审批
|
|
115
|
+ this.audit(lesJointInspectionTask);
|
72
|
116
|
}
|
73
|
117
|
|
74
|
118
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -76,19 +120,116 @@ public class LesJointInspectionTaskServiceImpl extends ServiceImpl<LesJointInspe
|
76
|
120
|
public void delete(List<LesJointInspectionTaskIdParam> lesJointInspectionTaskIdParamList) {
|
77
|
121
|
// 执行删除
|
78
|
122
|
this.removeByIds(CollStreamUtil.toList(lesJointInspectionTaskIdParamList, LesJointInspectionTaskIdParam::getId));
|
|
123
|
+ // 删除子表关联数据
|
|
124
|
+ lesJointInspectionTaskIdParamList.forEach(ids -> this.deleteChild(ids.getId()));
|
79
|
125
|
}
|
80
|
126
|
|
81
|
127
|
@Override
|
82
|
128
|
public LesJointInspectionTask detail(LesJointInspectionTaskIdParam lesJointInspectionTaskIdParam) {
|
83
|
|
- return this.queryEntity(lesJointInspectionTaskIdParam.getId());
|
|
129
|
+ LesJointInspectionTask lesJointInspectionTask = this.queryEntity(lesJointInspectionTaskIdParam.getId());
|
|
130
|
+ // 查询子表关联数据
|
|
131
|
+ List<LesJointInspectionTaskItem> items = lesJointInspectionTaskItemMapper.selectList(this.queryObject(lesJointInspectionTask.getId()));
|
|
132
|
+ if (CollectionUtils.isNotEmpty(items)) {
|
|
133
|
+ lesJointInspectionTask.setItems(items);
|
|
134
|
+ }
|
|
135
|
+ // 查询审批意见
|
|
136
|
+ QueryWrapper<AuditRequest> wrapper = new QueryWrapper<>();
|
|
137
|
+ wrapper.lambda().eq(AuditRequest::getRequestId, lesJointInspectionTask.getId());
|
|
138
|
+ wrapper.lambda().eq(AuditRequest::getType, 12);
|
|
139
|
+ wrapper.lambda().eq(AuditRequest::getStep, 12);
|
|
140
|
+ AuditRequest request = auditRequestMapper.selectOne(wrapper);
|
|
141
|
+ if (ObjectUtils.isNotEmpty(request)) {
|
|
142
|
+ lesJointInspectionTask.setAuditAdvice(request.getAuditAdvice());
|
|
143
|
+ }
|
|
144
|
+ return lesJointInspectionTask;
|
84
|
145
|
}
|
85
|
146
|
|
86
|
147
|
@Override
|
87
|
148
|
public LesJointInspectionTask queryEntity(String id) {
|
88
|
149
|
LesJointInspectionTask lesJointInspectionTask = this.getById(id);
|
89
|
|
- if(ObjectUtil.isEmpty(lesJointInspectionTask)) {
|
|
150
|
+ if (ObjectUtil.isEmpty(lesJointInspectionTask)) {
|
90
|
151
|
throw new CommonException("联合检查-联合检查任务不存在,id值为:{}", id);
|
91
|
152
|
}
|
92
|
153
|
return lesJointInspectionTask;
|
93
|
154
|
}
|
|
155
|
+
|
|
156
|
+ // 新增关联主表数据
|
|
157
|
+ private void insertChild(LesJointInspectionTask lesJointInspectionTask) {
|
|
158
|
+ lesJointInspectionTask.getItems().forEach(item -> {
|
|
159
|
+ item.setLesJointInspectionTaskId(lesJointInspectionTask.getId());
|
|
160
|
+ // 保存子表关联数据
|
|
161
|
+ lesJointInspectionTaskItemMapper.insert(item);
|
|
162
|
+ });
|
|
163
|
+ }
|
|
164
|
+
|
|
165
|
+ // 删除关联主表数据
|
|
166
|
+ private void deleteChild(String lesJointInspectionTaskId) {
|
|
167
|
+ lesJointInspectionTaskItemMapper.delete(this.queryObject(lesJointInspectionTaskId));
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ // 条件对象
|
|
171
|
+ private QueryWrapper<LesJointInspectionTaskItem> queryObject(String lesJointInspectionTaskId) {
|
|
172
|
+ QueryWrapper<LesJointInspectionTaskItem> wrapper = new QueryWrapper<>();
|
|
173
|
+ wrapper.lambda().eq(LesJointInspectionTaskItem::getLesJointInspectionTaskId, lesJointInspectionTaskId);
|
|
174
|
+ return wrapper;
|
|
175
|
+ }
|
|
176
|
+
|
|
177
|
+ // 流程
|
|
178
|
+ private void audit(LesJointInspectionTask lesJointInspectionTask) {
|
|
179
|
+ // 状态 0:保存状态;1:发布(申请中);2:审核通过;3:驳回
|
|
180
|
+ Integer status = lesJointInspectionTask.getStatus();
|
|
181
|
+ if (1 == status) {
|
|
182
|
+ // 添加审批(状态 0:待审核;1:已审核;2:驳回)
|
|
183
|
+ AuditRequest request = this.addAuditRequest(lesJointInspectionTask);
|
|
184
|
+ // 添加审批流程记录
|
|
185
|
+ this.addAuditRecord(lesJointInspectionTask, request.getId(), 0);
|
|
186
|
+ } else if (2 == status) {
|
|
187
|
+ this.editAuditRequest(lesJointInspectionTask, 1);
|
|
188
|
+ } else if (3 == status) {
|
|
189
|
+ this.editAuditRequest(lesJointInspectionTask, 2);
|
|
190
|
+ }
|
|
191
|
+ }
|
|
192
|
+
|
|
193
|
+ // 新增流程主表关联数据
|
|
194
|
+ private AuditRequest addAuditRequest(LesJointInspectionTask lesJointInspectionTask) {
|
|
195
|
+ AuditRequest request = new AuditRequest();
|
|
196
|
+ request.setType(12);
|
|
197
|
+ request.setStep(12);
|
|
198
|
+ request.setRequestId(lesJointInspectionTask.getId());
|
|
199
|
+ // 状态 0:待审核;1:已审核;2:驳回
|
|
200
|
+ request.setAuditStatus(0);
|
|
201
|
+ request.setAuditAdvice(lesJointInspectionTask.getAuditAdvice());
|
|
202
|
+ request.setAuditUserId(lesJointInspectionTask.getAuditUserId());
|
|
203
|
+ auditRequestMapper.insert(request);
|
|
204
|
+ return request;
|
|
205
|
+ }
|
|
206
|
+
|
|
207
|
+ // 增加一条流程记录
|
|
208
|
+ private void addAuditRecord(LesJointInspectionTask lesJointInspectionTask, String requestId, Integer status) {
|
|
209
|
+ AuditRecord record = new AuditRecord();
|
|
210
|
+ record.setAuditRequestId(requestId);
|
|
211
|
+ record.setType(12);
|
|
212
|
+ record.setStep(12);
|
|
213
|
+ record.setRequestId(lesJointInspectionTask.getId());
|
|
214
|
+ // 状态 0:待审核;1:已审核;2:驳回
|
|
215
|
+ record.setAuditStatus(status);
|
|
216
|
+ record.setAuditAdvice(lesJointInspectionTask.getAuditAdvice());
|
|
217
|
+ record.setAuditUserId(lesJointInspectionTask.getAuditUserId());
|
|
218
|
+ auditRecordMapper.insert(record);
|
|
219
|
+ }
|
|
220
|
+
|
|
221
|
+ // 更新流程主表关联数据
|
|
222
|
+ private void editAuditRequest(LesJointInspectionTask lesJointInspectionTask, Integer status) {
|
|
223
|
+ QueryWrapper<AuditRequest> wrapper = new QueryWrapper<>();
|
|
224
|
+ wrapper.lambda().eq(AuditRequest::getRequestId, lesJointInspectionTask.getId());
|
|
225
|
+ AuditRequest request = new AuditRequest();
|
|
226
|
+ // 状态 0:待审核;1:已审核;2:驳回
|
|
227
|
+ request.setAuditStatus(status);
|
|
228
|
+ request.setAuditAdvice(lesJointInspectionTask.getAuditAdvice());
|
|
229
|
+ request.setAuditUserId(lesJointInspectionTask.getAuditUserId());
|
|
230
|
+ auditRequestMapper.update(request, wrapper);
|
|
231
|
+
|
|
232
|
+ // 新增流程记录
|
|
233
|
+ this.addAuditRecord(lesJointInspectionTask, lesJointInspectionTask.getId(), status);
|
|
234
|
+ }
|
94
|
235
|
}
|