lyh
2025-04-11 2cf1565485060fd56e1f1f1cffbba7a4d70d42a6
优化dnc,设备结构树查询,优化原有代码
已修改19个文件
445 ■■■■ 文件已修改
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/DeviceInfoController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/ComponentInfo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/PartsInfo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/request/DocInfoUploadRequest.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/response/PartsInfoCode.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IDevicePermissionService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProcessSpecVersionService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceCharactersServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceManagementServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DevicePermissionServiceImpl.java 235 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/DeviceInfoController.java
@@ -3,17 +3,15 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.entity.DeviceInfo;
import org.jeecg.modules.dnc.response.*;
import org.jeecg.modules.dnc.service.IDeviceInfoService;
import org.jeecg.modules.dnc.service.IDevicePermissionService;
import org.jeecg.modules.mdc.model.MdcEquipmentTree;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.dnc.entity.DeviceInfo;
import org.jeecg.modules.dnc.service.IDeviceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -171,10 +169,8 @@
    @GetMapping(value = "/queryTreeListByProduction")
    public Result<List<MdcEquipmentTree>> queryTreeListByProduction() {
        Result<List<MdcEquipmentTree>> result = new Result<>();
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        try {
            List<MdcEquipmentTree> mdcEquipmentTreeList = devicePermissionService.DncLoadTreeListByProduction(userId);
            List<MdcEquipmentTree> mdcEquipmentTreeList = devicePermissionService.DncLoadTreeListByProduction();
            result.setSuccess(true);
            result.setResult(mdcEquipmentTreeList);
        } catch (Exception e) {
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/ComponentInfo.java
@@ -46,7 +46,7 @@
    @TableField(value = "process_type")
    private Integer processType;
    @TableField(value = "structure_type")
    private Integer structureType;
    private String structureType;
    @TableField(value = "component_code")
    private String componentCode;
    @TableField(value = "component_status")
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/entity/PartsInfo.java
@@ -42,7 +42,7 @@
    @TableField(value = "process_type")
    private Integer processType;
    @TableField(value = "structure_type")
    private Integer structureType;
    private String structureType;
    @TableField(value = "parts_code")
    private String partsCode;
    @TableField(value = "parts_status")
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/request/DocInfoUploadRequest.java
@@ -9,6 +9,4 @@
    private String attributionId;
    private Integer attributionType;
    private String docClassCode;
    /**是否进入审签流程*/
    private Boolean isApprove = true;
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/response/PartsInfoCode.java
@@ -19,8 +19,9 @@
    PROCESSSPECVERSION_NOT_EXIST(false,25211,"工艺规程不存在!"),
    PROCESSSPECVERSION_IS_EXIST(false,25212,"工艺规程已存在!"),
    PROCESSSPECVERSION_CODE_NONE(false,25213,"请输入工艺规程版本号!"),
    PROCESSSPECVERSION_PROCESS_EXIST(false,25214,"工艺规程版本有关联的工序信息!"),
    PARTS_USER_NONE(false,25215,"零件无法清空用户权限,请至少保留一位可操作用户!");
    PROCESSSPECVERSION_NONE(false,25214,"请输入工艺规程版本名称!"),
    PROCESSSPECVERSION_PROCESS_EXIST(false,25215,"工艺规程版本有关联的工序信息!"),
    PARTS_USER_NONE(false,25216,"零件无法清空用户权限,请至少保留一位可操作用户!");
    //操作代码
    @ApiModelProperty(value = "操作是否成功", example = "true", required = true)
@@ -32,7 +33,7 @@
    //提示信息
    @ApiModelProperty(value = "操作提示", example = "操作过于频繁!", required = true)
    String message;
    private PartsInfoCode(boolean success, int code, String message){
    PartsInfoCode(boolean success, int code, String message){
        this.success = success;
        this.code = code;
        this.message = message;
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IDevicePermissionService.java
@@ -56,5 +56,5 @@
    /**
     * 加载产线设备树
     */
    List<MdcEquipmentTree> DncLoadTreeListByProduction(String userId);
    List<MdcEquipmentTree> DncLoadTreeListByProduction();
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/IProcessSpecVersionService.java
@@ -54,7 +54,7 @@
     * @param processSpecVersionCode
     * @return
     */
    ProcessSpecVersion getByCode(String processSpecVersionCode);
    ProcessSpecVersion getByCode(String partId,String processSpecVersionCode);
    /**
     * 根据零件id获取
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceCharactersServiceImpl.java
@@ -5,15 +5,19 @@
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.entity.DeviceCharacters;
import org.jeecg.modules.dnc.exception.ExceptionCast;
import org.jeecg.modules.dnc.mapper.DeviceCharactersMapper;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.QueryPageResponseResult;
import org.jeecg.modules.dnc.request.DeviceCharactersRequest;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.service.IDeviceCharactersService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
public class DeviceCharactersServiceImpl extends ServiceImpl<DeviceCharactersMapper, DeviceCharacters> implements IDeviceCharactersService {
@@ -24,6 +28,8 @@
            ExceptionCast.cast(CommonCode.INVALID_PAGE);
        }
        IPage<DeviceCharacters> pageData = new Page<>(page, size);
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<String> productIdList = Arrays.asList(user.getProductionIds().split(","));
        LambdaQueryChainWrapper<DeviceCharacters> lambdaQuery = super.lambdaQuery();
        if(deviceCharactersRequest != null) {
            lambdaQuery.like(StrUtil.isNotEmpty(deviceCharactersRequest.getDeviceNo()),DeviceCharacters::getDeviceNo, deviceCharactersRequest.getDeviceNo());
@@ -33,6 +39,7 @@
            lambdaQuery.ge(StrUtil.isNotEmpty(deviceCharactersRequest.getStartTime()),DeviceCharacters::getCreateTime,deviceCharactersRequest.getStartTime());
            lambdaQuery.le(StrUtil.isNotEmpty(deviceCharactersRequest.getEndTime()),DeviceCharacters::getCreateTime,deviceCharactersRequest.getEndTime());
        }
        lambdaQuery.in(DeviceCharacters::getDepartId, productIdList);
        lambdaQuery.orderByDesc(DeviceCharacters::getCreateTime);
        IPage<DeviceCharacters> userIPage = lambdaQuery.page(pageData);
        return Result.ok(userIPage);
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DeviceManagementServiceImpl.java
@@ -5,7 +5,9 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.entity.DeviceManagement;
import org.jeecg.modules.dnc.entity.DeviceType;
import org.jeecg.modules.dnc.exception.ExceptionCast;
@@ -143,10 +145,13 @@
     */
    @Override
    public Result<?> query(DeviceManagement deviceManagement, Integer pageNo, Integer pageSize){
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<String> productIdList = Arrays.asList(user.getProductionIds().split(","));
        QueryWrapper<DeviceManagement> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotEmpty(deviceManagement.getProductionId()),"production_id",deviceManagement.getProductionId());
        queryWrapper.like(StrUtil.isNotEmpty(deviceManagement.getDeviceManagementName()),"device_management_name",deviceManagement.getDeviceManagementName());
        queryWrapper.like(StrUtil.isNotEmpty(deviceManagement.getDeviceManagementCode()),"device_management_code",deviceManagement.getDeviceManagementCode());
        queryWrapper.in("production_id",productIdList);
        queryWrapper.orderByDesc("create_time");
        Page<DeviceManagement> page = new Page<>(pageNo, pageSize);
        IPage<DeviceManagement> pageList = super.page(page, queryWrapper);
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DevicePermissionServiceImpl.java
@@ -5,7 +5,9 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.entity.DevicePermission;
import org.jeecg.modules.dnc.mapper.DevicePermissionMapper;
import org.jeecg.modules.dnc.service.IDevicePermissionService;
@@ -24,10 +26,10 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
public class DevicePermissionServiceImpl extends ServiceImpl<DevicePermissionMapper, DevicePermission> implements IDevicePermissionService {
@@ -92,80 +94,181 @@
    /**
     * 加载产线设备树
     * * 加载产线设备树
     */
    @Override
    public List<MdcEquipmentTree> DncLoadTreeListByProduction(String userId){
        //获取所有产线数据
        List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder));
        //根据用户id获取拥有的产线信息集合
        List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId);
        List<String> allProductionIds = new ArrayList<>();
        //找到所有产线id的上级id
        if (productionIds != null && !productionIds.isEmpty()) {
            for (String productionId : productionIds) {
                this.getAllProductionIds(productionList, productionId, allProductionIds);
            }
        }
        //过滤产线数据
        List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList());
        //组装产线设备树
        List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list);
        //填充设备数据
        FillEquipmentByProduction(treeList,userId);
    public List<MdcEquipmentTree> DncLoadTreeListByProduction() {
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        // 获取所有有效产线并建立快速查询映射
        Map<String, MdcProduction> productionMap = getValidProductions();
        // 获取用户权限相关的所有产线ID(包含层级祖先)
        Set<String> authorizedProductionIds = getAuthorizedProductionIds(user.getId(), productionMap);
        // 构建产线树结构
        List<MdcEquipmentTree> treeList = buildProductionTree(new ArrayList<>(authorizedProductionIds), productionMap);
        // 批量填充设备数据
        fillEquipmentData(treeList, user);
        return treeList;
    }
    /**
     * 获取所有的产线id(包含所有上级)
     */
    private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) {
        if (!allProductionIds.contains(productionId)) {
            allProductionIds.add(productionId);
        }
        for (MdcProduction mdcProduction : productionList) {
            if (StringUtils.isEmpty(mdcProduction.getParentId())) {
                continue;
            }
            if (productionId.equals(mdcProduction.getId())) {
                if (!allProductionIds.contains(mdcProduction.getParentId())) {
                    allProductionIds.add(mdcProduction.getParentId());
                    getAllProductionIds(productionList, mdcProduction.getParentId(), allProductionIds);
                }
            }
     * 获取所有有效产线并建立ID映射
    */
    private Map<String, MdcProduction> getValidProductions() {
        List<MdcProduction> productions = mdcProductionService.list(
                new LambdaQueryWrapper<MdcProduction>()
                        .eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0)
                        .orderByAsc(MdcProduction::getProductionOrder)
        );
        return productions.stream().collect(Collectors.toMap(MdcProduction::getId, Function.identity()));
    }
    /**
     * 获取用户权限相关的所有产线ID(包含层级祖先)
    */
    private Set<String> getAuthorizedProductionIds(String userId, Map<String, MdcProduction> productionMap) {
        Set<String> result = new HashSet<>();
        // 获取直接关联的产线ID
        List<String> directProductionIds = Optional.ofNullable(mdcUserProductionService.queryProductionIdsByUserId(userId))
                .orElse(Collections.emptyList());
        // 递归收集所有层级ID
        directProductionIds.forEach(id -> collectHierarchyIds(id, productionMap, result));
        return result;
    }
    /**
    * 递归收集层级ID(包含自身及所有祖先)
    */
    private void collectHierarchyIds(String productionId, Map<String, MdcProduction> productionMap, Set<String> collector) {
        if (collector.contains(productionId)) return;
        MdcProduction current = productionMap.get(productionId);
        if (current == null) return;
        collector.add(productionId);
        if (StringUtils.isNotBlank(current.getParentId())) {
            collectHierarchyIds(current.getParentId(), productionMap, collector);
        }
    }
    /**
     * 产线设备树填充设备数据
     */
    private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList,String userId) {
        //获取已分配权限设备数据
        List<String> deviceIds=super.list(new QueryWrapper<DevicePermission>().eq("user_id",userId)).stream().map(DevicePermission::getDeviceId).collect(Collectors.toList());
        if (!deviceIds.isEmpty()){
            for (MdcEquipmentTree mdcEquipmentTree : treeList) {
                List<MdcEquipment> equipmentList = mdcEquipmentMapper.queryByProductionIdAndType(mdcEquipmentTree.getKey(),deviceIds);
                if (equipmentList != null && !equipmentList.isEmpty()) {
                    for (MdcEquipment mdcEquipment : equipmentList) {
                        if (mdcEquipment.getCreateBy()!=null&& !mdcEquipment.getCreateBy().isEmpty()){
                            mdcEquipment.setCreateBy(sysUserService.getUserByName(mdcEquipment.getCreateBy()).getRealname());
                        }
                        if (mdcEquipment.getUpdateBy()!=null&& !mdcEquipment.getUpdateBy().isEmpty()){
                            mdcEquipment.setUpdateBy(sysUserService.getUserByName(mdcEquipment.getUpdateBy()).getRealname());
                        }
                        MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment);
                        tree.setParentId(mdcEquipmentTree.getKey());
                        tree.setEntity(mdcEquipment);
                        tree.setType(2);
                        mdcEquipmentTree.getChildren().add(tree);
                    }
                    mdcEquipmentTree.setLeaf(false);
                }
                if (!mdcEquipmentTree.getChildren().isEmpty()) {
                    FillEquipmentByProduction(mdcEquipmentTree.getChildren(),userId);
                }
            }
     构建产线树结构
    */
    private List<MdcEquipmentTree> buildProductionTree(List<String> productionIds, Map<String, MdcProduction> productionMap) {
        List<MdcProduction> filteredProductions = new ArrayList<>();
        productionIds.forEach(id -> {
        MdcProduction production = productionMap.get(id);
        if (production != null) {
            filteredProductions.add(production);
        }
        });
        return FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(filteredProductions);
    }
    /**
    * 批量填充设备数据
    */
    private void fillEquipmentData(List<MdcEquipmentTree> treeList, LoginUser user) {
        // 获取用户设备权限
        Set<String> deviceIds = getAuthorizedDeviceIds(user.getId());
        if (deviceIds.isEmpty()) return;
        // 批量获取所有相关设备
        Map<String, List<MdcEquipment>> equipmentMap = getEquipmentMap(user, deviceIds);
        // 批量获取用户信息
        Map<String, String> userRealNameMap = getUserRealNameMapping(equipmentMap.values());
        // 填充设备数据到树节点
        populateEquipmentNodes(treeList, equipmentMap, userRealNameMap);
    }
/**
        * 获取授权设备ID集合
 */
    private Set<String> getAuthorizedDeviceIds(String userId) {
        return super.list(new QueryWrapper<DevicePermission>().select("device_id").eq("user_id", userId))
                .stream()
                .map(DevicePermission::getDeviceId)
                .collect(Collectors.toSet());
    }
    /**
     * 批量获取设备数据并按产线分组
    */
    private Map<String, List<MdcEquipment>> getEquipmentMap(LoginUser user, Set<String> deviceIds) {
        List<String> productionIds=Arrays.asList(user.getProductionIds().split(","));
        return mdcEquipmentMapper.queryByDepartIdsAndType(productionIds, new ArrayList<>(deviceIds))
                .stream()
                .collect(Collectors.groupingBy(MdcEquipment::getProductionId));
    }
    /*** 批量获取用户真实姓名映射
    */
    private Map<String, String> getUserRealNameMapping(Collection<List<MdcEquipment>> equipmentLists) {
        Set<String> userNames = equipmentLists.stream()
                .flatMap(List::stream)
                .flatMap(e -> Stream.of(e.getCreateBy(), e.getUpdateBy()))
                .filter(StringUtils::isNotBlank)
                .collect(Collectors.toSet());
        return sysUserService.getUserRealNamesByUserNames(new ArrayList<>(userNames));
    }
    /**
     * 填充设备节点数据
    */
    private void populateEquipmentNodes(List<MdcEquipmentTree> nodes,
                                        Map<String, List<MdcEquipment>> equipmentMap,
                                        Map<String, String> userRealNameMap) {
        for (MdcEquipmentTree node : nodes) {
            if (!isProductionNode(node)) continue;
            List<MdcEquipment> equipments = equipmentMap.getOrDefault(node.getKey(), Collections.emptyList());
            List<MdcEquipmentTree> equipmentNodes = convertToEquipmentNodes(equipments, userRealNameMap, node.getKey());
            node.getChildren().addAll(equipmentNodes);
            node.setLeaf(equipmentNodes.isEmpty());
            // 递归处理子节点
            populateEquipmentNodes(node.getChildren(), equipmentMap, userRealNameMap);
        }
    }
/**
        * 转换设备数据为树节点
 */
    private List<MdcEquipmentTree> convertToEquipmentNodes(List<MdcEquipment> equipments,
                                                           Map<String, String> userRealNameMap,
                                                           String parentId) {
        return equipments.stream().map(e -> {
            // 更新用户显示名称
            Optional.ofNullable(e.getCreateBy()).ifPresent(name ->
                    e.setCreateBy(userRealNameMap.getOrDefault(name, name)));
            Optional.ofNullable(e.getUpdateBy()).ifPresent(name ->
                    e.setUpdateBy(userRealNameMap.getOrDefault(name, name)));
            MdcEquipmentTree node = new MdcEquipmentTree().convert(e);
            node.setParentId(parentId);
            node.setEntity(e);
            node.setType(2); // 设备节点类型
            return node;
        }).collect(Collectors.toList());
    }
/**
        * 判断是否为产线节点(根据业务逻辑定义)
            */
    private boolean isProductionNode(MdcEquipmentTree node) {
        return node.getType() == 1; // 假设类型1表示产线节点
    }
}
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java
@@ -90,7 +90,7 @@
        if(ProcessSpecVersion == null)
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionName()))
            ExceptionCast.cast(PartsInfoCode.PARTS_NAME_NONE);
            ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_NONE);
        if(!ValidateUtil.validateString(ProcessSpecVersion.getProductId()))
            ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE);
        if(!ValidateUtil.validateString(ProcessSpecVersion.getComponentId()))
@@ -99,7 +99,7 @@
            ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE);
        if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionCode()))
            ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_CODE_NONE);
        ProcessSpecVersion en = getByCode(ProcessSpecVersion.getProcessSpecVersionCode());
        ProcessSpecVersion en = getByCode(ProcessSpecVersion.getPartsId(),ProcessSpecVersion.getProcessSpecVersionCode());
        if(en != null)
            ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST);
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -243,9 +243,11 @@
    }
    @Override
    public ProcessSpecVersion getByCode(String processSpecVersionCode) {
    public ProcessSpecVersion getByCode(String partId,String processSpecVersionCode) {
        if(ValidateUtil.validateString(processSpecVersionCode)) {
            List<ProcessSpecVersion> list = super.lambdaQuery().eq(ProcessSpecVersion::getProcessSpecVersionCode, processSpecVersionCode).list();
            List<ProcessSpecVersion> list = super.lambdaQuery()
                    .eq(ProcessSpecVersion::getPartsId, partId)
                    .eq(ProcessSpecVersion::getProcessSpecVersionCode, processSpecVersionCode).list();
            if(list == null || list.isEmpty())
                return null;
            return list.get(0);
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductMixServiceImpl.java
@@ -19,6 +19,10 @@
    @Autowired
    private IPermissionStreamNewService permissionStreamNewService;
    /**
     * 默认结构树查询
     * @return
     */
    @Override
    public List<ProductMix> getTree() {
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java
@@ -186,4 +186,7 @@
    @Dict(dicCode = "mdc_staff_team")
    @ApiModelProperty(value = "配送小组")
    private String teamCode;
    // 关联产线(非数据库字段)
    private transient String productionId;
}
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
@@ -64,6 +64,11 @@
    List<MdcEquipment> queryByProductionIdAndType(@Param("productionId") String productionId, @Param("deviceIds") List<String> deviceIds);
    /**
     * 根据部门ids、已分配权限数据 查询设备
     */
    List<MdcEquipment> queryByDepartIdsAndType(@Param("productionIds") List<String> productionIds, @Param("deviceIds") List<String> deviceIds);
    /**
     * 查找设备监控信息
     */
    List<MdcEquipmentMonitor> checkStatusFromEquipmentIds(@Param("equipmentIds") List<String> equipmentIds);
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
@@ -279,7 +279,8 @@
    <select id="queryByProductionIdAndType" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
        me.*
        me.*,
        mpe.production_id
        FROM
        mdc_production_equipment mpe,
        mdc_equipment me
@@ -339,5 +340,22 @@
            #{equipmentType}
        </foreach>
    </select>
    <select id="queryByDepartIdsAndType" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            e.*,
        ep.production_id
        FROM
        mdc_equipment e
        INNER JOIN mdc_production_equipment ep ON e.id = ep.equipment_id
        WHERE
        ep.production_id IN
        <foreach collection='productionIds' item='id' open='(' separator=',' close=')'>
            #{id}
        </foreach>
        AND e.id IN
        <foreach collection='deviceIds' item='deviceId' open='(' separator=',' close=')'>
            #{deviceId}
        </foreach>
    </select>
</mapper>
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java
@@ -27,7 +27,7 @@
     * @param username
     * @return
     */
    public SysUser getUserByName(@Param("username") String username);
    SysUser getUserByName(@Param("username") String username);
    /**
     *  根据部门Id查询用户信息
@@ -62,28 +62,28 @@
     * @return
     */
    IPage<SysUser> getUserByRoleId(Page page, @Param("roleId") String roleId, @Param("username") String username);
    /**
     * 根据用户名设置部门ID
     * @param username
     * @param orgCode
     */
    void updateUserDepart(@Param("username") String username,@Param("orgCode") String orgCode);
    /**
     * 根据手机号查询用户信息
     * @param phone
     * @return
     */
    public SysUser getUserByPhone(@Param("phone") String phone);
    SysUser getUserByPhone(@Param("phone") String phone);
    /**
     * 根据邮箱查询用户信息
     * @param email
     * @return
     */
    public SysUser getUserByEmail(@Param("email")String email);
    SysUser getUserByEmail(@Param("email") String email);
    /**
     * 根据 orgCode 查询用户,包括子部门下的用户
@@ -150,7 +150,7 @@
     */
    @Deprecated
    int updateNullByEmptyString(@Param("fieldName") String fieldName);
    /**
     *  根据部门Ids,查询部门下用户信息
     * @param departIds
@@ -183,4 +183,9 @@
     * 根据角色编码和设备编号查询用户
     */
    List<SysUser> getEquipmentAdmin(@Param("roleCode") String roleCode, @Param("equipmentId") String equipmentId);
    /** 根据用户名批量查询
     * @param userNames 用户名列表(需确保非空)
     */
    List<SysUser> selectUsersByNames(@Param("userNames") List<String> userNames);
}
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
@@ -45,7 +45,7 @@
            and username = #{username}
        </if>
    </select>
    <!--  修改用户部门code -->
    <update id="updateUserDepart">
        UPDATE sys_user SET org_code = #{orgCode} where username = #{username}
@@ -55,7 +55,7 @@
    <select id="getUserByPhone"  resultType="org.jeecg.modules.system.entity.SysUser">
        select * from  sys_user  where phone = #{phone} and del_flag = 0
    </select>
    <!-- 根据邮箱查询用户信息 -->
    <select id="getUserByEmail" resultType="org.jeecg.modules.system.entity.SysUser">
    select * from  sys_user  where email = #{email} and del_flag = 0
@@ -217,4 +217,15 @@
        WHERE
            t3.role_code = #{roleCode} AND equipment_ids LIKE concat(concat('%',#{equipmentId}),'%')
    </select>
</mapper>
    <select id="selectUsersByNames" resultType="org.jeecg.modules.system.entity.SysUser">
        SELECT
        username,
        realname
        FROM sys_user
        WHERE
        username IN
        <foreach item="name" collection="userNames" open="(" separator="," close=")">
            #{name}
        </foreach>
    </select>
</mapper>
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
@@ -37,7 +37,7 @@
     * @param confirmpassword
     * @return
     */
    public Result<?> resetPassword(String username, String oldpassword, String newpassword, String confirmpassword);
    Result<?> resetPassword(String username, String oldpassword, String newpassword, String confirmpassword);
    /**
     * 修改密码
@@ -45,50 +45,50 @@
     * @param sysUser
     * @return
     */
    public Result<?> changePassword(SysUser sysUser);
    Result<?> changePassword(SysUser sysUser);
    /**
     * 删除用户
     * @param userId
     * @return
     */
    public boolean deleteUser(String userId);
    boolean deleteUser(String userId);
    /**
     * 批量删除用户
     * @param userIds
     * @return
     */
    public boolean deleteBatchUsers(String userIds);
    boolean deleteBatchUsers(String userIds);
    /**
     * 根据用户名查询
     * @param username 用户名
     * @return SysUser
     */
    public SysUser getUserByName(String username);
    SysUser getUserByName(String username);
    /**
     * 添加用户和用户角色关系
     * @param user
     * @param roles
     */
    public void addUserWithRole(SysUser user,String roles);
    void addUserWithRole(SysUser user, String roles);
    /**
     * 修改用户和用户角色关系
     * @param user
     * @param roles
     */
    public void editUserWithRole(SysUser user,String roles);
    void editUserWithRole(SysUser user, String roles);
    /**
     * 获取用户的授权角色
     * @param username
     * @return
     */
    public List<String> getRole(String username);
    List<String> getRole(String username);
    /**
     * 获取根据登录用户的角色获取动态首页
@@ -97,15 +97,15 @@
     * @param version 前端UI版本
     * @return
     */
    public SysRoleIndex getDynamicIndexByUserRole(String username,String version);
    SysRoleIndex getDynamicIndexByUserRole(String username, String version);
    /**
      * 查询用户信息包括 部门信息
     * @param username
     * @return
     */
    @Deprecated
    public SysUserCacheInfo getCacheUser(String username);
    SysUserCacheInfo getCacheUser(String username);
    /**
     * 根据部门Id查询
@@ -114,7 +114,7 @@
     * @param username 用户账户名称
     * @return
     */
    public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
    IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
    /**
     * 根据部门Ids查询
@@ -123,14 +123,14 @@
     * @param username 用户账户名称
     * @return
     */
    public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username);
    IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username);
    /**
     * 根据 userIds查询,查询用户所属部门的名称(多个部门名逗号隔开)
     * @param userIds
     * @return
     */
    public Map<String,String> getDepNamesByUserIds(List<String> userIds);
    Map<String,String> getDepNamesByUserIds(List<String> userIds);
    /**
     * 根据部门 Id 和 QueryWrapper 查询
@@ -161,7 +161,7 @@
     * @param username 用户账户名称
     * @return
     */
    public IPage<SysUser> getUserByRoleId(Page<SysUser> page,String roleId, String username);
    IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username);
    /**
     * 通过用户名获取用户角色集合
@@ -178,20 +178,20 @@
     * @return 权限集合
     */
    Set<String> getUserPermissionsSet(String username);
    /**
     * 根据用户名设置部门ID
     * @param username
     * @param orgCode
     */
    void updateUserDepart(String username,String orgCode);
    /**
     * 根据手机号获取用户名和密码
     * @param phone 手机号
     * @return SysUser
     */
    public SysUser getUserByPhone(String phone);
    SysUser getUserByPhone(String phone);
    /**
@@ -199,7 +199,7 @@
     * @param email 邮箱
     * @return SysUser
     */
    public SysUser getUserByEmail(String email);
    SysUser getUserByEmail(String email);
    /**
@@ -215,7 +215,7 @@
     * @param departs
     */
    void editUserWithDepart(SysUser user, String departs);
    /**
       * 校验用户是否有效
     * @param sysUser
@@ -316,7 +316,7 @@
     * @param
     * @return
     */
    public List<SysUser> getAllUsersByRoleId(String roleId);
    List<SysUser> getAllUsersByRoleId(String roleId);
    List<String> getUserByRoleCode(String roleCode);
@@ -330,4 +330,11 @@
     * @return
     */
    List<UserSelector> selectOperatorList(String equipmentCode, String productionId, String positionCode);
    /**
     * 根据用户名批量获取真实姓名映射
     * @param userNames 用户名列表
     * @return 用户名->真实姓名的映射(不存在时值为null)
     */
    Map<String, String> getUserRealNamesByUserNames(List<String> userNames);
}
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
@@ -762,4 +763,35 @@
        List<UserSelector> collect = sysUsers.stream().map(user -> new UserSelector(user.getId(), user.getUsername(), user.getRealname())).collect(Collectors.toList());
        return collect;
    }
    /**
     * 根据用户名批量获取真实姓名映射
     * @param userNames 用户名列表
     * @return 用户名->真实姓名的映射(不存在时值为null)
     */
    @Override
    public Map<String, String> getUserRealNamesByUserNames(List<String> userNames) {
        if (CollectionUtils.isEmpty(userNames)) {
            return Collections.emptyMap();
        }
        // 去重并过滤空值
        Set<String> uniqueNames = userNames.stream()
                .filter(StringUtils::isNotBlank)
                .collect(Collectors.toSet());
        if (uniqueNames.isEmpty()) {
            return Collections.emptyMap();
        }
        // 批量查询(自动处理IN语句分片)
        List<SysUser> users = userMapper.selectUsersByNames(new ArrayList<>(uniqueNames));
        // 构建映射关系
        return users.stream()
                .collect(Collectors.toMap(
                        SysUser::getUsername,
                        SysUser::getRealname,
                        (existing, replacement) -> existing // 重复键处理
                ));
    }
}