lyh
2025-02-25 ed9f1d757d6d3486dd69a726454eb69c3c9bc538
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?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.system.mapper.MdcProductionMapper">
 
    <!--递归查询所有子节点-->
    <select id="recursionChildren" resultType="java.lang.String">
        WITH temp ( id ) AS (
            SELECT
                id
            FROM
                mdc_production
            WHERE
                id = #{ productionId } UNION ALL
            SELECT
                a.id
            FROM
                mdc_production a
                    INNER JOIN temp ON a.parent_id = temp.id
        ) SELECT
            *
        FROM
            temp
    </select>
 
    <!--根据用户id和车间id获取用户拥有的车间id-->
    <select id="findFirstProduction" resultType="java.lang.String">
        SELECT TOP 1 t2.id FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id WHERE t1.user_id = #{ userId } AND t2.parent_id = #{productionId}
    </select>
 
    <!--根据用户id查询用户工段权限-->
    <select id="findThreeProductionId" resultType="java.lang.String">
        SELECT TOP 1 t2.id id FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id WHERE t1.user_id = #{userId} AND t2.org_type = '3'
    </select>
    <select id="findAllProductionId" resultType="org.jeecg.modules.system.entity.MdcProduction">
        SELECT
            t1.*
        FROM
            mdc_production t1
                LEFT JOIN mdc_user_production t2 ON t1.id = t2.pro_id
                LEFT JOIN sys_user t3 on t3.ID=t2.user_id
        WHERE
            t3.id = #{userId}
          AND t1.org_type = '3'
    </select>
</mapper>