新火炬后端单体项目初始化代码
Lius
7 天以前 904727f59b7e10a291ce7d1576e33192a619f2f2
MDC设备树和设备权限改造
已添加7个文件
已修改17个文件
759 ■■■■■ 文件已修改
src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/service/IFactoryService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/entity/FactoryEquipment.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/mapper/FactoryEquipmentMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/mapper/xml/FactoryEquipmentMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/model/FactoryTreeModel.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/service/IFactoryEquipmentService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/service/impl/FactoryEquipmentServiceImpl.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java 189 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/util/FindsEquipmentFactoryUtil.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/controller/SysUserController.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java
@@ -3,6 +3,7 @@
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.base.entity.Factory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -14,4 +15,9 @@
 */
public interface FactoryMapper extends BaseMapper<Factory> {
    /**
     * æ ¹æ®id下级产线
     */
    @Select("SELECT * FROM base_factory where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}")
    List<Factory> queryFacByPid(@Param("parentId") String parentId);
}
src/main/java/org/jeecg/modules/base/mapper/UserFactoryMapper.java
@@ -14,4 +14,8 @@
 */
public interface UserFactoryMapper extends BaseMapper<UserFactory> {
    /**
     * æ ¹æ®æŒ‡å®šç”¨æˆ·id查询产线id集合
     */
    List<String> queryFactoryIdsByUserId(@Param("userId") String userId);
}
src/main/java/org/jeecg/modules/base/mapper/xml/UserFactoryMapper.xml
@@ -2,4 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.base.mapper.UserFactoryMapper">
    <select id="queryFactoryIdsByUserId" resultType="java.lang.String">
        SELECT factory_id FROM base_user_factory WHERE user_id = #{userId}
    </select>
</mapper>
src/main/java/org/jeecg/modules/base/service/IFactoryService.java
@@ -38,4 +38,9 @@
     * æŸ¥è¯¢æ‰€æœ‰factoryId信息,并分节点进行显示
     */
    List<FactoryIdModel> queryFactoryIdTreeList();
    /**
     * èŽ·å–ä¸‹çº§äº§çº¿
     */
    List<Factory> queryFacByPid(String pid);
}
src/main/java/org/jeecg/modules/base/service/IUserFactoryService.java
@@ -18,4 +18,9 @@
     * æ ¹æ®æŒ‡å®šç”¨æˆ·id查询产线信息
     */
    List<FactoryIdModel> queryFactoryIdsOfUser(String userId);
    /**
     * æ ¹æ®æŒ‡å®šç”¨æˆ·id查询产线id集合
     */
    List<String> queryFactoryIdsByUserId(String userId);
}
src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java
@@ -24,6 +24,7 @@
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@@ -159,6 +160,14 @@
    }
    /**
     * æ ¹æ®id查询下级产线
     */
    @Override
    public List<Factory> queryFacByPid(String pid) {
        return this.baseMapper.queryFacByPid(pid);
    }
    /**
     * æ‰“å¼€ çˆ¶èŠ‚ç‚¹ åŠ ä»¥ä¸Šçš„mdc标记
     * @param parentId
     */
src/main/java/org/jeecg/modules/base/service/impl/UserFactoryServiceImpl.java
@@ -13,6 +13,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@@ -56,4 +57,12 @@
        }
        return null;
    }
    /**
     * æ ¹æ®æŒ‡å®šç”¨æˆ·id查询产线id集合
     */
    @Override
    public List<String> queryFactoryIdsByUserId(String userId) {
        return this.baseMapper.queryFactoryIdsByUserId(userId);
    }
}
src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
@@ -13,10 +13,12 @@
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.base.model.FactoryIdModel;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor;
import org.jeecg.modules.mdc.model.MdcEquipmentTree;
import org.jeecg.modules.mdc.model.ProductionIdModel;
import org.jeecg.modules.mdc.service.IFactoryEquipmentService;
import org.jeecg.modules.mdc.service.IMdcEquipmentDepartService;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService;
@@ -55,7 +57,10 @@
    private IMdcEquipmentDepartService mdcEquipmentDepartService;
    @Resource
    private IMdcProductionEquipmentService mdcProductionEquipmentService;
    private IFactoryEquipmentService factoryEquipmentService;
//    @Resource
//    private IMdcProductionEquipmentService mdcProductionEquipmentService;
    /**
     * åˆ†é¡µåˆ—表查询
@@ -244,7 +249,7 @@
    public Result<MdcEquipment> add(@RequestBody MdcEquipment mdcEquipment) {
        Result<MdcEquipment> result = new Result<>();
        String selectedDeparts = mdcEquipment.getSelectedDeparts();
        String selectedProduction = mdcEquipment.getSelectedProduction();
        String selectedProduction = mdcEquipment.getSelectedFactory();
        mdcEquipment.setEquipmentStatus(CommonConstant.STATUS_NORMAL);
        try {
            mdcEquipmentService.saveMdcEquipment(mdcEquipment, selectedDeparts, selectedProduction);
@@ -367,11 +372,11 @@
     */
    @AutoLog(value = "设备表-查询指定设备和产线关联的数据")
    @ApiOperation(value = "设备表-查询指定设备和产线关联的数据", notes = "设备表-查询指定设备和产线关联的数据")
    @GetMapping(value = "/equipmentProductionList")
    public Result<List<ProductionIdModel>> getEquipmentProductionList(@RequestParam(name = "equipmentId", required = true) String equipmentId) {
        Result<List<ProductionIdModel>> result = new Result<>();
    @GetMapping(value = "/equipmentFactoryList")
    public Result<List<FactoryIdModel>> equipmentFactoryList(@RequestParam(name = "equipmentId", required = true) String equipmentId) {
        Result<List<FactoryIdModel>> result = new Result<>();
        try {
            List<ProductionIdModel> proIdModelList = this.mdcProductionEquipmentService.queryProductionIdsOfEquipment(equipmentId);
            List<FactoryIdModel> proIdModelList = this.factoryEquipmentService.queryFactoryIdsOfEquipment(equipmentId);
            if (proIdModelList != null && !proIdModelList.isEmpty()) {
                result.setSuccess(true);
                result.setMessage("查找成功");
@@ -388,6 +393,33 @@
            return result;
        }
    }
//    /**
//     * æŸ¥è¯¢æŒ‡å®šè®¾å¤‡å’Œäº§çº¿å…³è”的数据
//     */
//    @AutoLog(value = "设备表-查询指定设备和产线关联的数据")
//    @ApiOperation(value = "设备表-查询指定设备和产线关联的数据", notes = "设备表-查询指定设备和产线关联的数据")
//    @GetMapping(value = "/equipmentProductionList")
//    public Result<List<ProductionIdModel>> getEquipmentProductionList(@RequestParam(name = "equipmentId", required = true) String equipmentId) {
//        Result<List<ProductionIdModel>> result = new Result<>();
//        try {
//            List<ProductionIdModel> proIdModelList = this.mdcProductionEquipmentService.queryProductionIdsOfEquipment(equipmentId);
//            if (proIdModelList != null && !proIdModelList.isEmpty()) {
//                result.setSuccess(true);
//                result.setMessage("查找成功");
//                result.setResult(proIdModelList);
//            } else {
//                result.setSuccess(false);
//                result.setMessage("查找失败");
//            }
//            return result;
//        } catch (Exception e) {
//            log.error(e.getMessage(), e);
//            result.setSuccess(false);
//            result.setMessage("查找过程中出现了异常: " + e.getMessage());
//            return result;
//        }
//    }
    /**
     * åŠ è½½éƒ¨é—¨è®¾å¤‡æ ‘
@@ -430,6 +462,26 @@
    }
    /**
     * åŠ è½½äº§çº¿è®¾å¤‡æ ‘
     */
    @AutoLog(value = "设备表-加载产线设备树")
    @ApiOperation(value = "设备表-加载产线设备树", notes = "设备表-加载产线设备树")
    @GetMapping(value = "/queryTreeListByFactory")
    public Result<List<MdcEquipmentTree>> queryTreeListByFactory() {
        Result<List<MdcEquipmentTree>> result = new Result<>();
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        try {
            List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId);
            result.setSuccess(true);
            result.setResult(mdcEquipmentTreeList);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return result;
    }
    /**
     * å¯¼å‡ºexcel
     *
     * @param request
src/main/java/org/jeecg/modules/mdc/entity/FactoryEquipment.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
package org.jeecg.modules.mdc.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
 * äº§çº¿è®¾å¤‡
 *
 * @author: LiuS
 * @create: 2023-03-24 15:54
 */
@Data
@TableName("base_equipment_factory")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "base_equipment_factory对象", description = "产线设备表")
public class FactoryEquipment implements Serializable {
    private static final long serialVersionUID = 1684188898785392096L;
    /**
     * ä¸»é”®id
     */
    @TableId(type = IdType.ASSIGN_ID)
    private String id;
    /**
     * äº§çº¿id
     */
    private String factoryId;
    /**
     * è®¾å¤‡id
     */
    private String equipmentId;
    public FactoryEquipment(String id, String factoryId, String equipmentId) {
        super();
        this.id = id;
        this.factoryId = factoryId;
        this.equipmentId = equipmentId;
    }
    public FactoryEquipment(String id, String factoryId) {
        this.equipmentId = id;
        this.factoryId = factoryId;
    }
}
src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java
@@ -172,7 +172,7 @@
    @TableField(exist = false)
    @ApiModelProperty(value = "选择的产线id集合")
    private String selectedProduction;
    private String selectedFactory;
    // å…³è”产线(非数据库字段)
    private transient String productionId;
src/main/java/org/jeecg/modules/mdc/mapper/FactoryEquipmentMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package org.jeecg.modules.mdc.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.mdc.entity.FactoryEquipment;
/**
 * äº§çº¿è®¾å¤‡mapper接口
 *
 * @author: LiuS
 * @create: 2023-03-24 16:00
 */
public interface FactoryEquipmentMapper extends BaseMapper<FactoryEquipment> {
}
src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
@@ -144,4 +144,9 @@
    List<String> getEquIdsByProIds(@Param("proIds") List<String> proIds);
    List<MdcEquipment> getEquipmentList(@Param("allProductionIds") List<String> allProductionIds);
    List<MdcEquipment> queryByFactoryId(@Param("factoryId") String factoryId);
    List<String> queryIdsByFactorys(@Param("allFactoryIds") List<String> allFactoryIds);
}
src/main/java/org/jeecg/modules/mdc/mapper/xml/FactoryEquipmentMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mdc.mapper.FactoryEquipmentMapper">
</mapper>
src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
@@ -12,7 +12,7 @@
    <!--查询设备的所属产线名称信息-->
    <select id="getProNamesByEquipmentIds" resultType="org.jeecg.modules.mdc.vo.MdcEquipmentProVo">
        SELECT p.production_name, pe.equipment_id FROM mdc_production_equipment pe, mdc_production p WHERE p.id = pe.production_id AND pe.equipment_id IN
        SELECT f.factory_name, bef.equipment_id FROM base_equipment_factory bef, base_factory f WHERE f.id = bef.factory_id AND bef.equipment_id IN
        <foreach collection="equipmentIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
@@ -402,4 +402,29 @@
        </where>
    </select>
    <select id="queryByFactoryId" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
        SELECT
            me.*
        FROM
            base_equipment_factory bef,
            mdc_equipment me
        WHERE
            bef.equipment_id = me.id
          AND bef.factory_id = #{ factoryId }
        ORDER BY me.equipment_id
    </select>
    <select id="queryIdsByFactorys" resultType="java.lang.String">
        SELECT
            me.equipment_id
        FROM
            mdc_equipment me
            LEFT JOIN base_equipment_factory bef ON me.id = bef.equipment_id
        WHERE
            bef.factory_id IN
        <foreach collection="allFactoryIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
</mapper>
src/main/java/org/jeecg/modules/mdc/model/FactoryTreeModel.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,112 @@
package org.jeecg.modules.mdc.model;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.modules.base.entity.Factory;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * @author: LiuS
 * @create: 2023-03-23 14:16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "产线表树结构数据实体", description = "产线表")
public class FactoryTreeModel implements Serializable {
    private static final long serialVersionUID = -1309711609760828658L;
    /**
     * å¯¹åº”MdcProduction中的id字段,前端数据树中的key
     */
    private String key;
    /**
     * å¯¹åº”MdcProduction中的id字段,前端数据树中的value
     */
    private String value;
    /**
     * å¯¹åº”depart_name字段,前端数据树中的title
     */
    private String title;
    private boolean isLeaf;
    /**
     * ç±»åž‹
     */
    private Integer type;
    //以下所有字段均与MdcProduction相同
    private String id;
    private String createBy;
    private Date createTime;
    private String updateBy;
    private Date updateTime;
    private Integer delFlag;
    private String factoryName;
    private String factoryCode;
    private String parentId;
    private String factoryStatus;
    private String factoryCategory;
    private Integer sorter;
    private String address;
    private String mdcFlag;
    private String remark;
    /**
     * äº§çº¿è´Ÿè´£äººids
     */
    private String directorUserIds;
    private List<FactoryTreeModel> children = new ArrayList<>();
    public FactoryTreeModel() {
    }
    /**
     * å°†MdcProduction对象转换成MdcProductionTreeModel对象
     *
     * @param factory
     */
    public FactoryTreeModel(Factory factory) {
        this.key = factory.getId();
        this.value = factory.getId();
        this.title = factory.getFactoryName();
        this.id = factory.getId();
        this.parentId = factory.getParentId();
        this.factoryName = factory.getFactoryName();
        this.sorter = factory.getSorter();
        this.factoryCode = factory.getFactoryCode();
        this.address = factory.getAddress();
        this.delFlag = factory.getDelFlag();
        this.createBy = factory.getCreateBy();
        this.createTime = factory.getCreateTime();
        this.updateBy = factory.getUpdateBy();
        this.updateTime = factory.getUpdateTime();
        this.mdcFlag = factory.getMdcFlag();
    }
}
src/main/java/org/jeecg/modules/mdc/model/MdcEquipmentTree.java
@@ -122,5 +122,18 @@
        return this;
    }
    /**
     * å°†mdcProductionTreeModel的部分数据放在该对象当中
     * @param treeModel
     * @return
     */
    public MdcEquipmentTree convertByFactory(FactoryTreeModel treeModel) {
        this.key = treeModel.getId();
        this.value = treeModel.getId();
        this.title = treeModel.getFactoryName();
        this.type = treeModel.getType();
        return this;
    }
}
src/main/java/org/jeecg/modules/mdc/service/IFactoryEquipmentService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,30 @@
package org.jeecg.modules.mdc.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.model.FactoryIdModel;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.FactoryEquipment;
import java.util.List;
/**
 * @author: LiuS
 * @create: 2023-03-28 10:30
 */
public interface IFactoryEquipmentService extends IService<FactoryEquipment> {
    /**
     * æ ¹æ®æŒ‡å®šè®¾å¤‡id查询产线信息
     */
    List<FactoryIdModel> queryFactoryIdsOfEquipment(String equipmentId);
    /**
     * æ ¹æ®æŒ‡å®šäº§çº¿id查询设备信息
     */
    List<MdcEquipment> queryEquipmentsOfFactory(String factoryId);
    /**
     * æ ¹æ®æŒ‡å®šäº§çº¿ids查询设备信息
     */
    List<MdcEquipment> queryEquipmentsOfFactorys(List<String> factoryIds);
}
src/main/java/org/jeecg/modules/mdc/service/impl/FactoryEquipmentServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,87 @@
package org.jeecg.modules.mdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.Factory;
import org.jeecg.modules.base.model.FactoryIdModel;
import org.jeecg.modules.base.service.IFactoryService;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.FactoryEquipment;
import org.jeecg.modules.mdc.mapper.FactoryEquipmentMapper;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.IFactoryEquipmentService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @author: LiuS
 * @create: 2023-03-28 10:31
 */
@Service
public class FactoryEquipmentServiceImpl extends ServiceImpl<FactoryEquipmentMapper, FactoryEquipment> implements IFactoryEquipmentService {
    @Resource
    private IFactoryService mdcFactoryService;
    @Resource
    private IMdcEquipmentService mdcEquipmentService;
    /**
     * æ ¹æ®è®¾å¤‡id查询产线信息
     */
    @Override
    public List<FactoryIdModel> queryFactoryIdsOfEquipment(String equipmentId) {
        LambdaQueryWrapper<FactoryEquipment> queryEquipmentFac = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<Factory> queryFac = new LambdaQueryWrapper<>();
        try {
            queryEquipmentFac.eq(FactoryEquipment::getEquipmentId, equipmentId);
            List<String> facIdList = new ArrayList<>();
            List<FactoryIdModel> facIdModelList = new ArrayList<>();
            List<FactoryEquipment> equipmentProList = this.list(queryEquipmentFac);
            if (equipmentProList != null && !equipmentProList.isEmpty()) {
                for (FactoryEquipment factoryEquipment : equipmentProList) {
                    facIdList.add(factoryEquipment.getFactoryId());
                }
                queryFac.in(Factory::getId, facIdList);
                List<Factory> proList = mdcFactoryService.list(queryFac);
                if (proList != null && !proList.isEmpty()) {
                    for (Factory mdcFactory : proList) {
                        facIdModelList.add(new FactoryIdModel().convertByUserFactory(mdcFactory));
                    }
                }
                return facIdModelList;
            }
        } catch (Exception e) {
            e.fillInStackTrace();
        }
        return null;
    }
    /**
     * æ ¹æ®æŒ‡å®šäº§çº¿id查询设备信息
     */
    @Override
    public List<MdcEquipment> queryEquipmentsOfFactory(String factoryId){
        List<String> equipmentIds = this.list(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getFactoryId, factoryId))
                .stream().map(FactoryEquipment::getEquipmentId).collect(Collectors.toList());
        if (!equipmentIds.isEmpty()) {
            return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds));
        }
        return null;
    }
    /**
     * æ ¹æ®æŒ‡å®šäº§çº¿ids查询设备信息
     */
    @Override
    public List<MdcEquipment> queryEquipmentsOfFactorys(List<String> factoryIds){
        List<String> equipmentIds = this.list(new LambdaQueryWrapper<FactoryEquipment>()
                .in(FactoryEquipment::getFactoryId, factoryIds)).stream().map(FactoryEquipment::getEquipmentId).collect(Collectors.toList());
        if (!equipmentIds.isEmpty()) {
            return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds));
        }
        return null;
    }
}
src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -15,24 +15,23 @@
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.base.entity.Factory;
import org.jeecg.modules.base.service.IFactoryService;
import org.jeecg.modules.base.service.IUserFactoryService;
import org.jeecg.modules.base.service.impl.FactoryServiceImpl;
import org.jeecg.modules.mdc.dto.MdcEquDepDto;
import org.jeecg.modules.mdc.dto.MdcEquProDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
import org.jeecg.modules.mdc.entity.*;
import org.jeecg.modules.mdc.mapper.MdcEquipmentDepartMapper;
import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper;
import org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper;
import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper;
import org.jeecg.modules.mdc.mapper.*;
import org.jeecg.modules.mdc.model.MdcEquipmentTree;
import org.jeecg.modules.mdc.service.*;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.util.DncCopyEquipment;
import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil;
import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil;
import org.jeecg.modules.mdc.util.*;
import org.jeecg.modules.mdc.vo.*;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.service.*;
import org.jeecg.modules.system.util.FindsFactorysChildrenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
@@ -91,6 +90,15 @@
    @Autowired
    private IEquipmentService equipmentService;
    @Autowired
    private IFactoryService factoryService;
    @Autowired
    private IUserFactoryService userFactoryService;
    @Autowired
    private FactoryEquipmentMapper factoryEquipmentMapper;
    @Override
    public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) {
@@ -104,7 +112,7 @@
    public Map<String, String> getProNamesByEquipmentIds(List<String> equipmentIds) {
        List<MdcEquipmentProVo> list = this.baseMapper.getProNamesByEquipmentIds(equipmentIds);
        Map<String, String> res = new HashMap(5);
        list.forEach(item -> res.merge(item.getEquipmentId(), item.getProductionName(), (a, b) -> a + "," + b));
        list.forEach(item -> res.merge(item.getEquipmentId(), item.getFactoryName(), (a, b) -> a + "," + b));
        return res;
    }
@@ -125,8 +133,8 @@
        if (oConvertUtils.isNotEmpty(selectedProduction)) {
            String[] arr = selectedProduction.split(",");
            for (String productionId : arr) {
                MdcProductionEquipment mdcProductionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId);
                mdcProductionEquipmentMapper.insert(mdcProductionEquipment);
                FactoryEquipment mdcProductionEquipment = new FactoryEquipment(mdcEquipment.getId(), productionId);
                factoryEquipmentMapper.insert(mdcProductionEquipment);
            }
        }
    }
@@ -152,17 +160,17 @@
            }
        }
        //step.3 ä¿®æ”¹äº§çº¿
        String productions = mdcEquipment.getSelectedProduction();
        String productions = mdcEquipment.getSelectedFactory();
        String[] array = {};
        if (oConvertUtils.isNotEmpty(productions)) {
            array = productions.split(",");
        }
        //先删后加
        mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, mdcEquipment.getId()));
        factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getEquipmentId, mdcEquipment.getId()));
        if (oConvertUtils.isNotEmpty(productions)) {
            for (String productionId : array) {
                MdcProductionEquipment productionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId);
                mdcProductionEquipmentMapper.insert(productionEquipment);
                FactoryEquipment productionEquipment = new FactoryEquipment(mdcEquipment.getId(), productionId);
                factoryEquipmentMapper.insert(productionEquipment);
            }
        }
    }
@@ -176,7 +184,7 @@
        // 2. åˆ é™¤è®¾å¤‡éƒ¨é—¨å…³ç³»
        line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getEquipmentId, id));
        // 3. åˆ é™¤è®¾å¤‡äº§çº¿å…³ç³»
        line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, id));
        line += factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().eq(FactoryEquipment::getEquipmentId, id));
        return line != 0;
    }
@@ -189,7 +197,7 @@
        // 2. åˆ é™¤è®¾å¤‡éƒ¨é—¨å…³ç³»
        line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().in(MdcEquipmentDepart::getEquipmentId, equipmentIds));
        // 3. åˆ é™¤è®¾å¤‡äº§çº¿å…³ç³»
        line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getEquipmentId, equipmentIds));
        line += factoryEquipmentMapper.delete(new LambdaQueryWrapper<FactoryEquipment>().in(FactoryEquipment::getEquipmentId, equipmentIds));
        return line != 0;
    }
@@ -293,23 +301,84 @@
    @Override
    public List<MdcEquipmentTree> loadTreeListByProduction(String userId) {
        //获取所有产线数据
        List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1).orderByAsc(MdcProduction::getProductionOrder));
        List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(Factory::getSorter));
        //根据用户id获取拥有的产线信息集合
        List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId);
        List<String> allProductionIds = new ArrayList<>();
        List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId);
        List<String> allFactoryIds = new ArrayList<>();
        //找到所有产线id的上级id
        if (productionIds != null && !productionIds.isEmpty()) {
            for (String productionId : productionIds) {
                this.getAllProductionIds(productionList, productionId, allProductionIds);
        if (factoryIds != null && !factoryIds.isEmpty()) {
            for (String factoryId : factoryIds) {
                this.getAllFactoryIds(factoryList, factoryId, allFactoryIds);
            }
        }
        //过滤产线数据
        List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList());
        List<Factory> list = factoryList.stream().filter((Factory factory) -> allFactoryIds.contains(factory.getId())).collect(Collectors.toList());
        //组装产线设备树
        List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list);
        List<MdcEquipmentTree> treeList = FindsEquipmentFactoryUtil.wrapEquipmentFactoryTreeList(list);
        //填充设备数据
        FillEquipmentByProduction(treeList);
        FillEquipmentByFactory(treeList);
//        //获取所有产线数据
//        List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1).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);
        return treeList;
    }
    /**
     * äº§çº¿è®¾å¤‡æ ‘填充设备数据
     */
    private void FillEquipmentByFactory(List<MdcEquipmentTree> treeList) {
        for (MdcEquipmentTree mdcEquipmentTree : treeList) {
            List<MdcEquipment> equipmentList = this.baseMapper.queryByFactoryId(mdcEquipmentTree.getKey());
            if (equipmentList != null && !equipmentList.isEmpty()) {
                for (MdcEquipment mdcEquipment : equipmentList) {
                    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()) {
                FillEquipmentByFactory(mdcEquipmentTree.getChildren());
            }
        }
    }
    /**
     * èŽ·å–æ‰€æœ‰çš„äº§çº¿id(包含所有上级)
     */
    private void getAllFactoryIds(List<Factory> factoryList, String factoryId, List<String> allFactoryIds) {
        if (!allFactoryIds.contains(factoryId)) {
            allFactoryIds.add(factoryId);
        }
        for (Factory factory : factoryList) {
            if (StringUtils.isEmpty(factory.getParentId())) {
                continue;
            }
            if (factoryId.equals(factory.getId())) {
                if (!allFactoryIds.contains(factory.getParentId())) {
                    allFactoryIds.add(factory.getParentId());
                    getAllFactoryIds(factoryList, factory.getParentId(), allFactoryIds);
                }
            }
        }
    }
    /**
@@ -513,30 +582,74 @@
    @Override
    public List<String> getEquipmentIdsProduction(String userId, String key) {
        //获取所有产线数据
        List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder));
        List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0).orderByAsc(Factory::getSorter));
        //根据用户id获取拥有的产线信息集合
        List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId);
        List<String> allProductionIds = new ArrayList<>();
        List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId);
        List<String> allFactoryIds = new ArrayList<>();
        //找到所有产线id的上级id
        if (productionIds != null && !productionIds.isEmpty()) {
            for (String productionId : productionIds) {
                this.getAllProductionIds(productionList, productionId, allProductionIds);
        if (factoryIds != null && !factoryIds.isEmpty()) {
            for (String productionId : factoryIds) {
                this.getAllFactoryIds(factoryList, productionId, allFactoryIds);
            }
        }
        //根据产线集合查找所有设备id
        if (allProductionIds.isEmpty()) {
        if (allFactoryIds.isEmpty()) {
            return null;
        }
        List<String> equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIds);
        List<String> equipmentIds = this.baseMapper.queryIdsByFactorys(allFactoryIds);
        if (StringUtils.isNotEmpty(key)) {
            //key不为空,查询所有下级产线id
            List<String> partProduction = this.findAllProductions(key);
            partProduction.add(key);
            List<String> partFactory = this.findAllFactorys(key);
            partFactory.add(key);
            //过滤无权限产线id
            List<String> allProductionIdsByKey = partProduction.stream().filter(allProductionIds::contains).collect(Collectors.toList());
            equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIdsByKey);
            List<String> allFactoryIdsByKey = partFactory.stream().filter(allFactoryIds::contains).collect(Collectors.toList());
            equipmentIds = this.baseMapper.queryIdsByFactorys(allFactoryIdsByKey);
        }
        return equipmentIds;
        //获取所有产线数据
//        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);
//            }
//        }
//        //根据产线集合查找所有设备id
//        if (allProductionIds.isEmpty()) {
//            return null;
//        }
//        List<String> equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIds);
//        if (StringUtils.isNotEmpty(key)) {
//            //key不为空,查询所有下级产线id
//            List<String> partProduction = this.findAllProductions(key);
//            partProduction.add(key);
//            //过滤无权限产线id
//            List<String> allProductionIdsByKey = partProduction.stream().filter(allProductionIds::contains).collect(Collectors.toList());
//            equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIdsByKey);
//        }
//        return equipmentIds;
//
    }
    /**
     * æ ¹æ®çˆ¶çº§id递归查询所有下级id集合
     */
    private List<String> findAllFactorys(String key) {
        List<String> factoryIds = new ArrayList<>();
        List<Factory> factorys = factoryService.queryFacByPid(key);
        if (factorys != null && !factorys.isEmpty()) {
            List<String> ids = factorys.stream().map(Factory::getId).collect(Collectors.toList());
            factoryIds.addAll(ids);
            for (Factory factory : factorys) {
                List<String> allFactorys = findAllFactorys(factory.getId());
                factoryIds.addAll(allFactorys);
            }
        }
        return factoryIds;
    }
    /**
src/main/java/org/jeecg/modules/mdc/util/FindsEquipmentFactoryUtil.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,80 @@
package org.jeecg.modules.mdc.util;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.base.entity.Factory;
import org.jeecg.modules.mdc.model.MdcEquipmentTree;
import org.jeecg.modules.mdc.model.FactoryTreeModel;
import org.jeecg.modules.mdc.model.MdcProductionTreeModel;
import java.util.ArrayList;
import java.util.List;
/**
 * äº§çº¿è®¾å¤‡æ ‘
 * @author: LiuS
 * @create: 2023-04-03 15:59
 */
public class FindsEquipmentFactoryUtil {
    /**
     * èŽ·å– MdcEquipmentTree
     */
    public static List<MdcEquipmentTree> wrapEquipmentFactoryTreeList(List<Factory> recordList) {
        List<MdcEquipmentTree> idList = new ArrayList<>();
        List<FactoryTreeModel> records = new ArrayList<>();
        for (Factory factory : recordList) {
            records.add(new FactoryTreeModel(factory));
        }
        getChildren(records, idList);
        setEmptyChildrenAsNull(idList);
        return idList;
    }
    /**
     * è¯¥æ–¹æ³•是找到并封装顶级父类的节点到TreeList集合
     */
    private static void getChildren(List<FactoryTreeModel> recordList, List<MdcEquipmentTree> idList) {
        List<FactoryTreeModel> treeList = new ArrayList<>();
        for (FactoryTreeModel factoryTreeModel : recordList) {
            if (oConvertUtils.isEmpty(factoryTreeModel.getParentId())) {
                factoryTreeModel.setType(1);
                treeList.add(factoryTreeModel);
                idList.add(new MdcEquipmentTree().convertByFactory(factoryTreeModel));
            }
        }
        getGrandChildren(treeList, recordList, idList);
    }
    /**
     *该方法是找到顶级父类下的所有子节点集合并封装到TreeList集合
     */
    private static void getGrandChildren(List<FactoryTreeModel> treeList, List<FactoryTreeModel> recordList, List<MdcEquipmentTree> idList) {
        for (int i = 0; i < treeList.size(); i++) {
            FactoryTreeModel model = treeList.get(i);
            MdcEquipmentTree mdcEquipmentTree = idList.get(i);
            for (int i1 = 0; i1 < recordList.size(); i1++) {
                FactoryTreeModel m = recordList.get(i1);
                if (m.getParentId() != null && m.getParentId().equals(model.getId())) {
                    model.getChildren().add(m);
                    m.setType(1);
                    mdcEquipmentTree.getChildren().add(new MdcEquipmentTree().convertByFactory(m));
                }
            }
            getGrandChildren(treeList.get(i).getChildren(), recordList, idList.get(i).getChildren());
        }
    }
    /**
     * è¯¥æ–¹æ³•是将子节点为空的List集合设置为Null值
     */
    private static void setEmptyChildrenAsNull(List<MdcEquipmentTree> idList) {
        for (MdcEquipmentTree mdcEquipmentTree : idList) {
            if (mdcEquipmentTree.getChildren().isEmpty()) {
                mdcEquipmentTree.setLeaf(true);
            } else {
                setEmptyChildrenAsNull(mdcEquipmentTree.getChildren());
                mdcEquipmentTree.setLeaf(false);
            }
        }
    }
}
src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentProVo.java
@@ -9,5 +9,5 @@
@Data
public class MdcEquipmentProVo {
    private String equipmentId;
    private String productionName;
    private String factoryName;
}
src/main/java/org/jeecg/modules/system/controller/SysUserController.java
@@ -253,7 +253,7 @@
        Result<SysUser> result = new Result<SysUser>();
        String selectedRoles = jsonObject.getString("selectedroles");
        String selectedDeparts = jsonObject.getString("selecteddeparts");
        String selectedProductions = jsonObject.getString("selectedProduction");
        String selectedProductions = jsonObject.getString("selectedFactorys");
        try {
            SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
            user.setCreateTime(new Date());//设置创建时间
@@ -295,7 +295,7 @@
                user.setPassword(sysUser.getPassword());
                String roles = jsonObject.getString("selectedroles");
                String departs = jsonObject.getString("selecteddeparts");
                String productions = jsonObject.getString("selectedProduction");
                String productions = jsonObject.getString("selectedFactorys");
                if (oConvertUtils.isEmpty(departs)) {
                    //vue3.0前端只传递了departIds
                    departs = user.getDepartIds();
@@ -476,17 +476,17 @@
    }
    @AutoLog(value = "用户表-查询指定用户和产线关联的数据")
    @ApiOperation(value = "用户表-查询指定用户和产线关联的数据", notes = "用户表-查询指定用户和产线关联的数据")
    @GetMapping(value = "/userProductionList")
    public Result<List<ProductionIdModel>> getUserProductionsList(@RequestParam(name = "userId", required = true) String userId) {
        Result<List<ProductionIdModel>> result = new Result<>();
    @AutoLog(value = "用户表-查询指定用户和工厂建模关联的数据")
    @ApiOperation(value = "用户表-查询指定用户和工厂建模关联的数据", notes = "用户表-查询指定用户和工厂建模关联的数据")
    @GetMapping(value = "/userFactorysList")
    public Result<List<FactoryIdModel>> getUserFactorysList(@RequestParam(name = "userId", required = true) String userId) {
        Result<List<FactoryIdModel>> result = new Result<>();
        try {
            List<ProductionIdModel> proIdModelList = this.userProductionService.queryProductionIdsOfUser(userId);
            if (proIdModelList != null && !proIdModelList.isEmpty()) {
            List<FactoryIdModel> facIdModelList = this.userFactoryService.queryFactoryIdsOfUser(userId);
            if (facIdModelList != null && !facIdModelList.isEmpty()) {
                result.setSuccess(true);
                result.setMessage("查找成功");
                result.setResult(proIdModelList);
                result.setResult(facIdModelList);
            } else {
                result.setSuccess(false);
                result.setMessage("查找失败");
src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
@@ -185,7 +185,7 @@
    <!-- æŸ¥è¯¢ç”¨æˆ·çš„æ‰€å±žäº§çº¿åç§°ä¿¡æ¯ -->
    <select id="getProNamesByUserIds" resultType="org.jeecg.modules.system.vo.MdcUserProVo">
        SELECT p.production_name, up.user_id FROM mdc_user_production up, mdc_production p WHERE p.id = up.pro_id AND up.user_id IN
        SELECT p.factory_name productionName, up.user_id FROM base_user_factory up, base_factory p WHERE p.id = up.factory_id AND up.user_id IN
        <foreach collection="userIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
@@ -522,7 +522,7 @@
        // 2. åˆ é™¤ç”¨æˆ·éƒ¨é—¨å…³ç³»
        line += sysUserDepartMapper.delete(new LambdaQueryWrapper<SysUserDepart>().in(SysUserDepart::getUserId, userIds));
        // 3. åˆ é™¤ç”¨æˆ·äº§çº¿å…³ç³»
        line += mdcUserProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getUserId, userIds));
        line += userFactoryMapper.delete(new LambdaQueryWrapper<UserFactory>().in(UserFactory::getUserId, userIds));
        //3. åˆ é™¤ç”¨æˆ·è§’色关系
        line += sysUserRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, userIds));
        //4.同步删除第三方App的用户
@@ -592,8 +592,8 @@
        if (oConvertUtils.isNotEmpty(selectedProductions)) {
            arr = selectedProductions.split(",");
            for (String productionId : arr) {
                MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId);
                mdcUserProductionMapper.insert(mdcUserProduction);
                UserFactory mdcUserProduction = new UserFactory(productionId, user.getId());
                userFactoryMapper.insert(mdcUserProduction);
            }
        }
        //step.5 ä¿å­˜è®¾å¤‡æƒé™
@@ -661,13 +661,14 @@
            array = productions.split(",");
        }
        //先删后加
        mdcUserProductionMapper.delete(new QueryWrapper<MdcUserProduction>().lambda().eq(MdcUserProduction::getUserId, user.getId()));
        userFactoryMapper.delete(new QueryWrapper<UserFactory>().lambda().eq(UserFactory::getUserId, user.getId()));
        if (oConvertUtils.isNotEmpty(productions)) {
            for (String productionId : array) {
                MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId);
                mdcUserProductionMapper.insert(mdcUserProduction);
                UserFactory mdcUserProduction = new UserFactory(productionId, user.getId());
                userFactoryMapper.insert(mdcUserProduction);
            }
        }
        //step.5 ä¿®æ”¹è®¾å¤‡æƒé™
        //先删后加
//        dncDevicePermissionMapper.delete(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getUserId, user.getId()));