From 227eff61120aaca63e068035d745d86452e6499a Mon Sep 17 00:00:00 2001
From: hsy <1029150275@qq.com>
Date: 星期一, 17 八月 2026 09:35:12 +0800
Subject: [PATCH] feat(mes): 优化生产订单与排产任务列表显示,新增启停工及校验逻辑 1. 生产订单列表展示优化 (WorkOrder)   - 新增「生产状态」列,全局注册 `ORDER_PRODUCTION_STATUS` 常量并绑定系统动态字典。   - 彻底重构「工序生产进度」单元格显示:弃用臃肿的 Steps 组件,改为极简横向布局(彩色状态圆点 + 进度百分比),解决表格行高被强行撑开及内容截断问题,支持横向滚动。   - 优化「完成进度」列宽及展示样式,将百分比数值外置同行显示,更加直观。 2. 排产任务列表改造 (Task)   - 顶部表头重构,由单一标题重构为「全部 / 未完成 / 已完成」的 Tabs 标签页切换结构。   - 重写数据过滤逻辑,剥离写死的 status 查询,改为使用 `scheduleStatus` 字段动态响应 Tabs 切换 (0: 未完成, 1: 已完成)。 3. 工单业务逻辑增强与状态流转   - 落实「工单查询逻辑设计方案」,优化底层的工单条件检索逻辑。   - 实现「添加工单启停功能」与「停工状态」,支持工单在执行过程中的暂停与恢复业务流转。   - 强化容错与防呆设计:操作「完成订单」时增加前置校验 `handleCheckFinish`,若生产状态为未完成,强制弹出二次确认 Modal,避免误操作。 # 相关讨论/参考方案 # - 添加工单启停功能 # - 停工状态功能设计方案 # - 工单查询逻辑设计方案 # - 工单完成进度显示优化

---
 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java |   85 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 1 deletions(-)

diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
index 6086474..79da07a 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
@@ -2,11 +2,15 @@
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptImportExcelVO;
+import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptImportRespVO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
 import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
@@ -27,7 +31,7 @@
 /**
  * 閮ㄩ棬 Service 瀹炵幇绫�
  *
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
  */
 @Service
 @Validated
@@ -235,4 +239,83 @@
         });
     }
 
+    @Override
+    public DeptImportRespVO importDeptList(List<DeptImportExcelVO> importDepts, boolean isUpdateSupport) {
+        if (CollUtil.isEmpty(importDepts)) {
+            throw exception(DEPT_IMPORT_LIST_IS_EMPTY);
+        }
+        DeptImportRespVO respVO = DeptImportRespVO.builder().createDeptNames(new ArrayList<>())
+                .updateDeptNames(new ArrayList<>()).failureDeptNames(new LinkedHashMap<>()).build();
+
+        // 1. 鍒濆鍖栫幇鏈夌殑鍏ㄨ矾寰勪笌閮ㄩ棬ID鏄犲皠
+        List<DeptDO> allDepts = getDeptList(new DeptListReqVO());
+        Map<Long, DeptDO> idDeptMap = cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap(allDepts, DeptDO::getId);
+        Map<String, Long> fullPathDeptIdMap = new HashMap<>();
+        for (DeptDO dept : allDepts) {
+            fullPathDeptIdMap.put(getFullPath(dept, idDeptMap), dept.getId());
+        }
+
+        // 2. 灏嗗鍏ョ殑閮ㄩ棬鎸夌収鐖堕儴闂ㄨ矾寰勬繁搴︽帓搴忥紝纭繚鍏堝鐞嗙埗閮ㄩ棬
+        importDepts.sort(Comparator.comparingInt(dept -> StrUtil.isEmpty(dept.getParentPath()) ? 0 : dept.getParentPath().split("/").length));
+
+        // 3. 閬嶅巻瀵煎叆
+        for (DeptImportExcelVO importDept : importDepts) {
+            // 3.1 鑾峰彇鐖堕儴闂� ID
+            Long parentId = DeptDO.PARENT_ID_ROOT;
+            if (StrUtil.isNotEmpty(importDept.getParentPath())) {
+                parentId = fullPathDeptIdMap.get(importDept.getParentPath());
+                if (parentId == null) {
+                    respVO.getFailureDeptNames().put(importDept.getName(), "涓婄骇閮ㄩ棬涓嶅瓨鍦�: " + importDept.getParentPath());
+                    continue;
+                }
+            }
+
+            // 3.2 鏍¢獙閮ㄩ棬鍚嶇О鏄惁鍞竴
+            try {
+                validateDeptNameUnique(null, parentId, importDept.getName());
+            } catch (ServiceException ex) {
+                if (!isUpdateSupport) {
+                    respVO.getFailureDeptNames().put(importDept.getName(), ex.getMessage());
+                    continue;
+                }
+                // 鏀寔鏇存柊锛屾墽琛屾洿鏂�
+                DeptDO existDept = deptMapper.selectByParentIdAndName(parentId, importDept.getName());
+                DeptDO updateDept = BeanUtils.toBean(importDept, DeptDO.class);
+                updateDept.setId(existDept.getId());
+                updateDept.setParentId(parentId);
+                deptMapper.updateById(updateDept);
+                respVO.getUpdateDeptNames().add(importDept.getName());
+                
+                String myFullPath = StrUtil.isEmpty(importDept.getParentPath()) ? importDept.getName() : importDept.getParentPath() + "/" + importDept.getName();
+                fullPathDeptIdMap.put(myFullPath, existDept.getId());
+                continue;
+            }
+
+            // 3.3 鏂板閮ㄩ棬
+            DeptDO newDept = BeanUtils.toBean(importDept, DeptDO.class);
+            newDept.setParentId(parentId);
+            deptMapper.insert(newDept);
+            respVO.getCreateDeptNames().add(importDept.getName());
+            
+            // 鏇存柊缂撳瓨锛屼緵鍚庣画瀛愰儴闂ㄤ娇鐢�
+            String myFullPath = StrUtil.isEmpty(importDept.getParentPath()) ? importDept.getName() : importDept.getParentPath() + "/" + importDept.getName();
+            fullPathDeptIdMap.put(myFullPath, newDept.getId());
+        }
+
+        return respVO;
+    }
+
+    private String getFullPath(DeptDO dept, Map<Long, DeptDO> idDeptMap) {
+        StringBuilder path = new StringBuilder(dept.getName());
+        Long parentId = dept.getParentId();
+        while (parentId != null && !DeptDO.PARENT_ID_ROOT.equals(parentId)) {
+            DeptDO parent = idDeptMap.get(parentId);
+            if (parent == null) {
+                break;
+            }
+            path.insert(0, parent.getName() + "/");
+            parentId = parent.getParentId();
+        }
+        return path.toString();
+    }
 }

--
Gitblit v1.9.3