|
|
@@ -223,13 +223,49 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
|
223
|
223
|
@Override
|
|
224
|
224
|
public Boolean sortCaseFlow(MsCaseFlowSearchVO caseFlowVO) {
|
|
225
|
225
|
if (caseFlowVO != null && caseFlowVO.getId() != null && caseFlowVO.getSortType() != null) {
|
|
|
226
|
+ //升序查询所有案件流程信息
|
|
|
227
|
+ Example example = new Example(MsCaseFlow.class);
|
|
|
228
|
+ example.setOrderByClause(" sort ASC");
|
|
|
229
|
+ List<MsCaseFlow> msCaseFlows = msCaseFlowMapper.selectByExample(example);
|
|
|
230
|
+ if (msCaseFlows == null || msCaseFlows.size() == 0 || msCaseFlows.size() == 1) {
|
|
|
231
|
+ return false;
|
|
|
232
|
+ }
|
|
|
233
|
+ //查找出要调整顺序的这行数据在集合的下标是多少
|
|
|
234
|
+ int currentIndex = 0;
|
|
|
235
|
+ for (int i = 0; i < msCaseFlows.size(); i++) {
|
|
|
236
|
+ if (msCaseFlows.get(i).getId().equals(caseFlowVO.getId())) {
|
|
|
237
|
+ currentIndex = i;
|
|
|
238
|
+ break;
|
|
|
239
|
+ }
|
|
|
240
|
+ }
|
|
226
|
241
|
if (caseFlowVO.getSortType() == 0) {
|
|
227
|
|
- //降序
|
|
228
|
|
-
|
|
229
|
|
- return true;
|
|
|
242
|
+ //降序(序号加1)
|
|
|
243
|
+ if (currentIndex == msCaseFlows.size() - 1) {
|
|
|
244
|
+ return false;
|
|
|
245
|
+ } else {
|
|
|
246
|
+ int nextIndex = currentIndex + 1;
|
|
|
247
|
+ MsCaseFlow current = msCaseFlows.get(currentIndex);
|
|
|
248
|
+ current.setSort(current.getSort() + 1);
|
|
|
249
|
+ MsCaseFlow next = msCaseFlows.get(nextIndex);
|
|
|
250
|
+ next.setSort(next.getSort() - 1);
|
|
|
251
|
+ msCaseFlowMapper.updateByPrimaryKeySelective(current);
|
|
|
252
|
+ msCaseFlowMapper.updateByPrimaryKeySelective(next);
|
|
|
253
|
+ return true;
|
|
|
254
|
+ }
|
|
230
|
255
|
} else if (caseFlowVO.getSortType() == 1) {
|
|
231
|
|
- //升序
|
|
232
|
|
- return true;
|
|
|
256
|
+ //升序(序号减1)
|
|
|
257
|
+ if (currentIndex == 0) {
|
|
|
258
|
+ return false;
|
|
|
259
|
+ } else {
|
|
|
260
|
+ int lastIndex = currentIndex - 1;
|
|
|
261
|
+ MsCaseFlow current = msCaseFlows.get(currentIndex);
|
|
|
262
|
+ current.setSort(current.getSort() - 1);
|
|
|
263
|
+ MsCaseFlow last = msCaseFlows.get(lastIndex);
|
|
|
264
|
+ last.setSort(last.getSort() + 1);
|
|
|
265
|
+ msCaseFlowMapper.updateByPrimaryKeySelective(current);
|
|
|
266
|
+ msCaseFlowMapper.updateByPrimaryKeySelective(last);
|
|
|
267
|
+ return true;
|
|
|
268
|
+ }
|
|
233
|
269
|
}
|
|
234
|
270
|
}
|
|
235
|
271
|
return false;
|