案件流程节点排序接口

This commit is contained in:
gy b
2024-01-09 15:15:34 +08:00
parent af565db9d6
commit 801714c888
@@ -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<MsCaseFlow> 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;