From 801714c8882a4e72bfb1377f9704272a9f6b4688 Mon Sep 17 00:00:00 2001 From: gy b Date: Tue, 9 Jan 2024 15:15:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BB=B6=E6=B5=81=E7=A8=8B=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=8E=92=E5=BA=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/flow/CaseFlowServiceImpl.java | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java index 2bc0181..7c16bf0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java @@ -223,13 +223,49 @@ public class CaseFlowServiceImpl implements CaseFlowService { @Override public Boolean sortCaseFlow(MsCaseFlowSearchVO caseFlowVO) { if (caseFlowVO != null && caseFlowVO.getId() != null && caseFlowVO.getSortType() != null) { + //升序查询所有案件流程信息 + Example example = new Example(MsCaseFlow.class); + example.setOrderByClause(" sort ASC"); + List msCaseFlows = msCaseFlowMapper.selectByExample(example); + if (msCaseFlows == null || msCaseFlows.size() == 0 || msCaseFlows.size() == 1) { + return false; + } + //查找出要调整顺序的这行数据在集合的下标是多少 + int currentIndex = 0; + for (int i = 0; i < msCaseFlows.size(); i++) { + if (msCaseFlows.get(i).getId().equals(caseFlowVO.getId())) { + currentIndex = i; + break; + } + } if (caseFlowVO.getSortType() == 0) { - //降序 - - return true; + //降序(序号加1) + if (currentIndex == msCaseFlows.size() - 1) { + return false; + } else { + int nextIndex = currentIndex + 1; + MsCaseFlow current = msCaseFlows.get(currentIndex); + current.setSort(current.getSort() + 1); + MsCaseFlow next = msCaseFlows.get(nextIndex); + next.setSort(next.getSort() - 1); + msCaseFlowMapper.updateByPrimaryKeySelective(current); + msCaseFlowMapper.updateByPrimaryKeySelective(next); + return true; + } } else if (caseFlowVO.getSortType() == 1) { - //升序 - return true; + //升序(序号减1) + if (currentIndex == 0) { + return false; + } else { + int lastIndex = currentIndex - 1; + MsCaseFlow current = msCaseFlows.get(currentIndex); + current.setSort(current.getSort() - 1); + MsCaseFlow last = msCaseFlows.get(lastIndex); + last.setSort(last.getSort() + 1); + msCaseFlowMapper.updateByPrimaryKeySelective(current); + msCaseFlowMapper.updateByPrimaryKeySelective(last); + return true; + } } } return false;