|
|
@@ -3,8 +3,7 @@ package com.ruoyi.system.service.flow;
|
|
3
|
3
|
import com.github.pagehelper.PageHelper;
|
|
4
|
4
|
import com.github.pagehelper.PageInfo;
|
|
5
|
5
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
6
|
|
-import com.ruoyi.common.utils.PageUtils;
|
|
7
|
|
-import com.ruoyi.system.domain.SysOperLog;
|
|
|
6
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
8
|
7
|
import com.ruoyi.system.domain.entity.flow.MsCaseFlow;
|
|
9
|
8
|
import com.ruoyi.system.domain.entity.flow.MsCaseFlowRoleRelated;
|
|
10
|
9
|
import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
|
|
|
@@ -12,6 +11,8 @@ import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
|
|
12
|
11
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
|
13
|
12
|
import com.ruoyi.system.mapper.flow.MsCaseFlowMapper;
|
|
14
|
13
|
import com.ruoyi.system.mapper.flow.MsCaseFlowRoleRelatedMapper;
|
|
|
14
|
+import com.ruoyi.system.util.NewStringUtil;
|
|
|
15
|
+import com.ruoyi.system.util.TableDataUtil;
|
|
15
|
16
|
import org.springframework.beans.BeanUtils;
|
|
16
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
17
|
18
|
import org.springframework.stereotype.Service;
|
|
|
@@ -23,10 +24,6 @@ import java.util.List;
|
|
23
|
24
|
import java.util.Map;
|
|
24
|
25
|
import java.util.stream.Collectors;
|
|
25
|
26
|
|
|
26
|
|
-import static com.deepoove.poi.data.NumberingRenderData.build;
|
|
27
|
|
-import static com.ruoyi.common.utils.PageUtils.startPage;
|
|
28
|
|
-import static jdk.nashorn.internal.runtime.Debug.id;
|
|
29
|
|
-
|
|
30
|
27
|
@Service
|
|
31
|
28
|
public class CaseFlowServiceImpl implements CaseFlowService {
|
|
32
|
29
|
@Autowired
|
|
|
@@ -48,10 +45,13 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
|
48
|
45
|
if (caseFlowSearchVO.getId() != null) {
|
|
49
|
46
|
return msCaseFlowMapper.selectByPrimaryKey(caseFlowSearchVO.getId());
|
|
50
|
47
|
} else if (caseFlowSearchVO == null) {
|
|
|
48
|
+ //查询所有案件流程节点信息
|
|
51
|
49
|
return msCaseFlowMapper.selectAll();
|
|
52
|
50
|
} else if (caseFlowSearchVO.getPageNum() == null || caseFlowSearchVO.getPageSize() == null) {
|
|
|
51
|
+ //查询所有案件流程节点信息
|
|
53
|
52
|
return msCaseFlowMapper.selectAll();
|
|
54
|
53
|
} else {
|
|
|
54
|
+ //分页查询案件流程节点信息
|
|
55
|
55
|
Map<Integer, List<SysRole>> sysRoleMap = queryRoleByFlowId(null);
|
|
56
|
56
|
Example example = new Example(MsCaseFlow.class);
|
|
57
|
57
|
example.setOrderByClause(" sort DESC ");
|
|
|
@@ -62,23 +62,26 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
|
62
|
62
|
PageHelper.startPage(caseFlowSearchVO.getPageNum(), caseFlowSearchVO.getPageSize());
|
|
63
|
63
|
List<MsCaseFlow> msCaseFlows = msCaseFlowMapper.selectByExample(example);
|
|
64
|
64
|
PageInfo<MsCaseFlow> pageInfo = new PageInfo<>(msCaseFlows);
|
|
65
|
|
- PageInfo<MsCaseFlowVO> newpageInfo = new PageInfo<>();
|
|
66
|
|
- BeanUtils.copyProperties(pageInfo, newpageInfo);
|
|
|
65
|
+ long total = pageInfo.getTotal();
|
|
67
|
66
|
List<MsCaseFlowVO> list = new ArrayList<>();
|
|
68
|
67
|
for (int i = 0; i < msCaseFlows.size(); i++) {
|
|
69
|
68
|
MsCaseFlow msCaseFlow = msCaseFlows.get(i);
|
|
70
|
69
|
MsCaseFlowVO temp = new MsCaseFlowVO();
|
|
71
|
70
|
BeanUtils.copyProperties(msCaseFlow, temp);
|
|
72
|
71
|
//关联的角色
|
|
73
|
|
- List<String> roleNames = new ArrayList<>();
|
|
|
72
|
+ StringBuilder roleNames = new StringBuilder();
|
|
|
73
|
+ List<Long> roleIds = new ArrayList<>();
|
|
74
|
74
|
if (sysRoleMap.containsKey(msCaseFlow.getId())) {
|
|
75
|
75
|
List<SysRole> sysRoles = sysRoleMap.get(msCaseFlow.getId());
|
|
76
|
|
- roleNames = sysRoles
|
|
77
|
|
- .stream()
|
|
78
|
|
- .map(sysRole -> sysRole.getRoleName())
|
|
79
|
|
- .collect(Collectors.toList());
|
|
80
|
|
- temp.setRoleNames(roleNames.toString());
|
|
|
76
|
+ sysRoles.stream().forEach(item -> {
|
|
|
77
|
+ roleNames.append(item.getRoleName()).append(",");
|
|
|
78
|
+ });
|
|
|
79
|
+ temp.setRoleNames(NewStringUtil.stringListToStringBuilder(sysRoles.stream().map(SysRole::getRoleName).collect(Collectors.toList()), ","));
|
|
|
80
|
+ roleIds.addAll(sysRoles.stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
|
|
81
|
+ } else {
|
|
|
82
|
+ temp.setRoleNames("");
|
|
81
|
83
|
}
|
|
|
84
|
+ temp.setRoleIds(roleIds);
|
|
82
|
85
|
//驳回节点
|
|
83
|
86
|
if (msCaseFlow.getBackFlowId() != null) {
|
|
84
|
87
|
MsCaseFlow msCaseFlow1 = msCaseFlowMapper.selectByPrimaryKey(msCaseFlow.getBackFlowId());
|
|
|
@@ -86,7 +89,8 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
|
86
|
89
|
}
|
|
87
|
90
|
list.add(temp);
|
|
88
|
91
|
}
|
|
89
|
|
- return list;
|
|
|
92
|
+ TableDataInfo tableDataInfo = TableDataUtil.rebuildTableDataInfo(list, total);
|
|
|
93
|
+ return tableDataInfo;
|
|
90
|
94
|
}
|
|
91
|
95
|
}
|
|
92
|
96
|
|
|
|
@@ -126,8 +130,68 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
|
126
|
130
|
* @return
|
|
127
|
131
|
*/
|
|
128
|
132
|
@Override
|
|
129
|
|
- public Boolean addCaseFlow(MsCaseFlowVO caseFlowVO) {
|
|
130
|
|
- return null;
|
|
|
133
|
+ public Boolean saveCaseFlow(MsCaseFlowVO caseFlowVO) {
|
|
|
134
|
+ if (caseFlowVO.getId() != null) {
|
|
|
135
|
+ //更新案件流程信息
|
|
|
136
|
+ MsCaseFlow msCaseFlow = new MsCaseFlow();
|
|
|
137
|
+ BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
|
|
|
138
|
+ int i = msCaseFlowMapper.updateByPrimaryKey(msCaseFlow);
|
|
|
139
|
+ if (i > 0) {
|
|
|
140
|
+ //更新流程节点和角色之间的关系
|
|
|
141
|
+ updateFlowRoleByFlowId(caseFlowVO.getId(), caseFlowVO.getRoleIds());
|
|
|
142
|
+ return true;
|
|
|
143
|
+ }
|
|
|
144
|
+ } else {
|
|
|
145
|
+ int sort = 1;
|
|
|
146
|
+ Example example = new Example(MsCaseFlow.class);
|
|
|
147
|
+ example.setOrderByClause("sort DESC limit 1");
|
|
|
148
|
+ Example.Criteria criteria = example.createCriteria();
|
|
|
149
|
+ List<MsCaseFlow> msCaseFlows = msCaseFlowMapper.selectByExample(example);
|
|
|
150
|
+ if (msCaseFlows != null && msCaseFlows.size() > 0) {
|
|
|
151
|
+ sort = msCaseFlows.get(0).getSort() + 1;
|
|
|
152
|
+ }
|
|
|
153
|
+ //新增案件流程信息
|
|
|
154
|
+ MsCaseFlow msCaseFlow = new MsCaseFlow();
|
|
|
155
|
+ BeanUtils.copyProperties(caseFlowVO, msCaseFlow);
|
|
|
156
|
+ msCaseFlow.setSort(sort);
|
|
|
157
|
+ int insert = msCaseFlowMapper.insert(msCaseFlow);
|
|
|
158
|
+ if (insert > 0) {
|
|
|
159
|
+ //更新流程节点和角色之间的关系
|
|
|
160
|
+ updateFlowRoleByFlowId(caseFlowVO.getId(), caseFlowVO.getRoleIds());
|
|
|
161
|
+ return true;
|
|
|
162
|
+ }
|
|
|
163
|
+ }
|
|
|
164
|
+ return false;
|
|
|
165
|
+ }
|
|
|
166
|
+
|
|
|
167
|
+ /**
|
|
|
168
|
+ * 更新流程节点和角色之间的关系
|
|
|
169
|
+ *
|
|
|
170
|
+ * @param id
|
|
|
171
|
+ * @param roleIds
|
|
|
172
|
+ */
|
|
|
173
|
+ private void updateFlowRoleByFlowId(Integer id, List<Long> roleIds) {
|
|
|
174
|
+ if (roleIds != null && roleIds.size() > 0) {
|
|
|
175
|
+ //删除流程节点和角色之间的关系
|
|
|
176
|
+ deleteFlowRoleByFlowId(id);
|
|
|
177
|
+ for (int i = 0; i < roleIds.size(); i++) {
|
|
|
178
|
+ MsCaseFlowRoleRelated msCaseFlowRoleRelated = new MsCaseFlowRoleRelated();
|
|
|
179
|
+ msCaseFlowRoleRelated.setFlowId(id);
|
|
|
180
|
+ msCaseFlowRoleRelated.setRoleid(roleIds.get(i));
|
|
|
181
|
+ msCaseFlowRoleRelatedMapper.insertSelective(msCaseFlowRoleRelated);
|
|
|
182
|
+ }
|
|
|
183
|
+ }
|
|
|
184
|
+ }
|
|
|
185
|
+
|
|
|
186
|
+ /**
|
|
|
187
|
+ * 删除流程节点和角色之间的关系
|
|
|
188
|
+ *
|
|
|
189
|
+ * @param id
|
|
|
190
|
+ */
|
|
|
191
|
+ private void deleteFlowRoleByFlowId(Integer id) {
|
|
|
192
|
+ if (id != null) {
|
|
|
193
|
+ msCaseFlowRoleRelatedMapper.deleteByExample(new Example(MsCaseFlowRoleRelated.class).createCriteria().andEqualTo("flowId", id));
|
|
|
194
|
+ }
|
|
131
|
195
|
}
|
|
132
|
196
|
|
|
133
|
197
|
/**
|
|
|
@@ -138,7 +202,16 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
|
138
|
202
|
*/
|
|
139
|
203
|
@Override
|
|
140
|
204
|
public Boolean deleteCaseFlow(MsCaseFlowVO caseFlowVO) {
|
|
141
|
|
- return null;
|
|
|
205
|
+ if (caseFlowVO.getId() != null) {
|
|
|
206
|
+ //删除案件流程信息
|
|
|
207
|
+ int i = msCaseFlowMapper.deleteByPrimaryKey(caseFlowVO.getId());
|
|
|
208
|
+ if (i > 0) {
|
|
|
209
|
+ //删除流程节点和角色之间的关系
|
|
|
210
|
+ deleteFlowRoleByFlowId(caseFlowVO.getId());
|
|
|
211
|
+ return true;
|
|
|
212
|
+ }
|
|
|
213
|
+ }
|
|
|
214
|
+ return false;
|
|
142
|
215
|
}
|
|
143
|
216
|
|
|
144
|
217
|
/**
|
|
|
@@ -148,7 +221,17 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
|
148
|
221
|
* @return
|
|
149
|
222
|
*/
|
|
150
|
223
|
@Override
|
|
151
|
|
- public Boolean sortCaseFlow(MsCaseFlowVO caseFlowVO) {
|
|
152
|
|
- return null;
|
|
|
224
|
+ public Boolean sortCaseFlow(MsCaseFlowSearchVO caseFlowVO) {
|
|
|
225
|
+ if (caseFlowVO != null && caseFlowVO.getId() != null && caseFlowVO.getSortType() != null) {
|
|
|
226
|
+ if (caseFlowVO.getSortType() == 0) {
|
|
|
227
|
+ //降序
|
|
|
228
|
+
|
|
|
229
|
+ return true;
|
|
|
230
|
+ } else if (caseFlowVO.getSortType() == 1) {
|
|
|
231
|
+ //升序
|
|
|
232
|
+ return true;
|
|
|
233
|
+ }
|
|
|
234
|
+ }
|
|
|
235
|
+ return false;
|
|
153
|
236
|
}
|
|
154
|
237
|
}
|