From 571ec3d3aef0ab51cc4e95f816082fbe0dc68456 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 08 四月 2025 18:11:09 +0800
Subject: [PATCH] 修改任务彻底实现,查询表单数据不使用任务上的流程变量,单独去查流程变量
---
system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java | 148 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 122 insertions(+), 26 deletions(-)
diff --git a/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java b/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java
index a54ad3f..5283434 100644
--- a/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java
+++ b/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java
@@ -1,9 +1,12 @@
package com.ycl.system.service.impl;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
+
+import com.ycl.common.base.Result;
+import com.ycl.common.core.domain.StringTreeSelect;
+import com.ycl.system.domain.base.BaseSelect;
+import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ycl.common.annotation.DataScope;
@@ -27,13 +30,12 @@
* @author ycl
*/
@Service
+@RequiredArgsConstructor
public class SysDeptServiceImpl implements ISysDeptService
{
- @Autowired
- private SysDeptMapper deptMapper;
- @Autowired
- private SysRoleMapper roleMapper;
+ private final SysDeptMapper deptMapper;
+ private final SysRoleMapper roleMapper;
/**
* 鏌ヨ閮ㄩ棬绠$悊鏁版嵁
@@ -48,6 +50,11 @@
return deptMapper.selectDeptList(dept);
}
+ @Override
+ public List<SysDept> selectDeptListNoAuth(SysDept dept) {
+ return deptMapper.selectDeptListNoAuth(dept);
+ }
+
/**
* 鏌ヨ閮ㄩ棬鏍戠粨鏋勪俊鎭�
*
@@ -59,6 +66,48 @@
{
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts);
+ }
+
+ @Override
+ public List<TreeSelect> deptTreeNoDataAuth(SysDept dept) {
+ List<SysDept> depts = deptMapper.selectDeptList(dept);;
+ return buildDeptTreeSelect(depts);
+ }
+
+ @Override
+ public List<StringTreeSelect> flowDeptTree(SysDept dept) {
+ List<SysDept> depts = deptMapper.selectDeptList(dept);
+ List<StringTreeSelect> list = depts.stream().map(item -> {
+ StringTreeSelect d = new StringTreeSelect();
+ d.setId("dept:" + item.getDeptId());
+ d.setLabel(item.getDeptName());
+ d.setParentId("dept:" + item.getParentId());
+ return d;
+ }).collect(Collectors.toList());
+
+
+ Map<String, StringTreeSelect> nodeMap = new HashMap<>();
+ // 灏嗘墍鏈夎妭鐐规斁鍏ap涓紝鏂逛究鍚庣画鏌ユ壘
+ for (StringTreeSelect node : list) {
+ nodeMap.put(node.getId(), node);
+ }
+ List<StringTreeSelect> treeList = new ArrayList<>();
+ // 鏋勫缓鏍戠粨鏋�
+ for (StringTreeSelect node : list) {
+ StringTreeSelect root = null;
+ if ("dept:0".equals(node.getParentId()) || node.getParentId().isEmpty()) {
+ // 鏍硅妭鐐�
+ root = node;
+ treeList.add(root);
+ } else {
+ // 鎵惧埌鐖惰妭鐐癸紝骞跺皢褰撳墠鑺傜偣娣诲姞鍒扮埗鑺傜偣鐨刢hildren鍒楄〃涓�
+ StringTreeSelect parentNode = nodeMap.get(node.getParentId());
+ if (parentNode != null) {
+ parentNode.getChildren().add(node);
+ }
+ }
+ }
+ return treeList;
}
/**
@@ -87,6 +136,8 @@
}
return returnList;
}
+
+
/**
* 鏋勫缓鍓嶇鎵�闇�瑕佷笅鎷夋爲缁撴瀯
@@ -124,6 +175,11 @@
public SysDept selectDeptById(Long deptId)
{
return deptMapper.selectDeptById(deptId);
+ }
+
+ @Override
+ public List<SysDept> selectDeptByIds(List<Long> deptIds) {
+ return deptMapper.selectDeptByIds(deptIds);
}
/**
@@ -211,13 +267,18 @@
@Override
public int insertDept(SysDept dept)
{
- SysDept info = deptMapper.selectDeptById(dept.getParentId());
- // 濡傛灉鐖惰妭鐐逛笉涓烘甯哥姸鎬�,鍒欎笉鍏佽鏂板瀛愯妭鐐�
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
- {
- throw new ServiceException("閮ㄩ棬鍋滅敤锛屼笉鍏佽鏂板");
+ if (Objects.nonNull(dept.getParentId())) {
+ SysDept info = deptMapper.selectDeptById(dept.getParentId());
+ // 濡傛灉鐖惰妭鐐逛笉涓烘甯哥姸鎬�,鍒欎笉鍏佽鏂板瀛愯妭鐐�
+ if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
+ {
+ throw new ServiceException("涓婄骇閮ㄩ棬宸插仠鐢紝涓嶅厑璁告柊澧炰笅绾ч儴闂�");
+ }
+ dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
+ } else {
+ dept.setParentId(0L);
+ dept.setAncestors("");
}
- dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
}
@@ -230,22 +291,23 @@
@Override
public int updateDept(SysDept dept)
{
- SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
- if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
- {
- String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
- String oldAncestors = oldDept.getAncestors();
- dept.setAncestors(newAncestors);
- updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+ if (Objects.isNull(oldDept)) {
+ throw new RuntimeException("淇敼閮ㄩ棬琚垹闄ゆ垨涓嶅瓨鍦�");
+ }
+ if (Objects.nonNull(dept.getParentId())) {
+ SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
+ if (Objects.nonNull(newParentDept)) {
+ String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
+ String oldAncestors = oldDept.getAncestors();
+ dept.setAncestors(newAncestors);
+ updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+ }
+ } else {
+ dept.setParentId(0L);
+ dept.setAncestors("");
}
int result = deptMapper.updateDept(dept);
- if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
- && !StringUtils.equals("0", dept.getAncestors()))
- {
- // 濡傛灉璇ラ儴闂ㄦ槸鍚敤鐘舵�侊紝鍒欏惎鐢ㄨ閮ㄩ棬鐨勬墍鏈変笂绾ч儴闂�
- updateParentDeptStatusNormal(dept);
- }
return result;
}
@@ -335,4 +397,38 @@
{
return getChildList(list, t).size() > 0;
}
+
+ /**
+ * 閮ㄩ棬涓嬫媺鍒楄〃
+ * @return
+ */
+ @Override
+ public Result all(SysDept dept) {
+ List<BaseSelect> vos = deptMapper.selectDeptList(dept).stream().map(sysDept -> {
+ BaseSelect baseSelect = new BaseSelect();
+ baseSelect.setId(Integer.parseInt(sysDept.getDeptId() + ""));
+ baseSelect.setValue(sysDept.getDeptName());
+ return baseSelect;
+ }
+ ).collect(Collectors.toList());
+ return Result.ok().data(vos);
+ }
+
+
+ @Override
+ public List<StringTreeSelect> flowableAll() {
+ List<StringTreeSelect> list = deptMapper.selectDeptList(new SysDept()).stream().map(sysDept -> {
+ StringTreeSelect stringTreeSelect = new StringTreeSelect();
+ stringTreeSelect.setId("dept:" + sysDept.getDeptId());
+ stringTreeSelect.setLabel(sysDept.getDeptName());
+ return stringTreeSelect;
+ }).collect(Collectors.toList());
+ return list;
+ }
+
+
+ @Override
+ public List<Long> getChildIds(Long deptId) {
+ return deptMapper.getChildIds(deptId);
+ }
}
--
Gitblit v1.8.0