From f4d4d29368ccacb807f93e2033cd4a643a3ddade Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 30 三月 2026 10:20:28 +0800
Subject: [PATCH] yys 1.修改bug
---
src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java | 83 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java
index 1f6dd1b..4aa7cdb 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java
@@ -9,6 +9,7 @@
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.dto.ProductProcessDto;
+import com.ruoyi.production.dto.SysDeptAndUserDto;
import com.ruoyi.production.mapper.ProcessRouteItemMapper;
import com.ruoyi.production.mapper.ProductProcessMapper;
import com.ruoyi.production.mapper.ProductProcessRouteItemMapper;
@@ -16,12 +17,18 @@
import com.ruoyi.production.pojo.ProductProcess;
import com.ruoyi.production.pojo.ProductProcessRouteItem;
import com.ruoyi.production.service.ProductProcessService;
+import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.mapper.SysDeptMapper;
+import com.ruoyi.project.system.mapper.SysUserDeptMapper;
+import com.ruoyi.project.system.mapper.SysUserMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
+import java.util.ArrayList;
import java.util.List;
@Service
@@ -32,6 +39,13 @@
private ProcessRouteItemMapper processRouteItemMapper;
@Autowired
private ProductProcessRouteItemMapper productProcessRouteItemMapper;
+
+ @Autowired
+ private SysDeptMapper sysDeptMapper;
+ @Autowired
+ private SysUserDeptMapper sysUserDeptMapper;
+ @Autowired
+ private SysUserMapper sysUserMapper;
@Override
public IPage<ProductProcessDto> listPage(Page page, ProductProcessDto productProcessDto) {
@@ -51,7 +65,7 @@
productProcessMapper.updateById(productProcess);
return AjaxResult.success();
}
- return AjaxResult.error();
+ return AjaxResult.success();
}
@Override
@@ -62,11 +76,19 @@
if(CollectionUtils.isEmpty(productProcessList)){
return AjaxResult.warn("妯℃澘閿欒鎴栧鍏ユ暟鎹负绌�");
}
+ productProcessList.forEach(productProcess -> {
+ if (ObjectUtils.isEmpty(productProcess)) {
+ throw new RuntimeException("浣跨敤妯℃澘杩涜瀵煎叆");
+ }
+ if (ObjectUtils.isEmpty(productProcess.getName())) {
+ throw new RuntimeException("宸ュ簭鍚嶇О涓嶈兘涓虹┖");
+ }
+ });
this.saveOrUpdateBatch(productProcessList);
return AjaxResult.success(true);
}catch (Exception e){
e.printStackTrace();
- return AjaxResult.error("瀵煎叆澶辫触");
+ return AjaxResult.error(e.getMessage());
}
}
@@ -81,4 +103,61 @@
productProcessMapper.deleteBatchIds(ids);
return null;
}
+
+ public List<SysDeptAndUserDto> listDeptUserTree() {
+ return buildDeptUserTree();
+ }
+
+
+ /**
+ * 鏋勫缓瀹屾暣鐨勯儴闂�-鐢ㄦ埛鏍戝舰缁撴瀯
+ */
+ public List<SysDeptAndUserDto> buildDeptUserTree() {
+ // 1. 鏌ヨ鎵�鏈夋牴閮ㄩ棬锛坧arent_id = 0锛�
+ List<SysDeptAndUserDto> rootDeptList = sysDeptMapper.selectChildrenDeptByParentId(0L);
+
+ // 2. 閫掑綊鏋勫缓姣忎釜鏍归儴闂ㄧ殑瀛愯妭鐐癸紝骞舵寕杞界敤鎴�
+ for (SysDeptAndUserDto rootDept : rootDeptList) {
+ buildChildrenDept(rootDept);
+ loadDeptUser(rootDept);
+ }
+
+ return rootDeptList;
+ }
+
+ /**
+ * 閫掑綊鏋勫缓瀛愰儴闂�
+ */
+ private void buildChildrenDept(SysDeptAndUserDto parentDept) {
+ // 鏌ヨ褰撳墠閮ㄩ棬鐨勫瓙閮ㄩ棬
+ List<SysDeptAndUserDto> childrenDept = sysDeptMapper.selectChildrenDeptByParentId(parentDept.getDeptId());
+ if (childrenDept == null || childrenDept.isEmpty()) {
+ parentDept.setChildrenList(new ArrayList<>());
+ return;
+ }
+
+ // 涓烘瘡涓瓙閮ㄩ棬閫掑綊鏋勫缓涓嬬骇锛屽苟鎸傝浇鐢ㄦ埛
+ for (SysDeptAndUserDto childDept : childrenDept) {
+ buildChildrenDept(childDept);
+ loadDeptUser(childDept);
+ }
+
+ parentDept.setChildrenList(childrenDept);
+ }
+
+ /**
+ * 涓洪儴闂ㄥ姞杞藉叧鑱旂殑鐢ㄦ埛
+ */
+ private void loadDeptUser(SysDeptAndUserDto dept) {
+ // 鏌ヨ閮ㄩ棬鍏宠仈鐨勭敤鎴稩D
+ List<Long> userIdList = sysUserDeptMapper.selectUserIdByDeptId(dept.getDeptId());
+ if (userIdList == null || userIdList.isEmpty()) {
+ dept.setUserList(new ArrayList<>());
+ return;
+ }
+
+ // 鏍规嵁鐢ㄦ埛ID鏌ヨ鐢ㄦ埛淇℃伅
+ List<SysUser> userList = sysUserMapper.selectUserListByIds(userIdList);
+ dept.setUserList(userList);
+ }
}
--
Gitblit v1.9.3