zxl
2025-03-21 1f2697051a87a7ca54734ccbf04a4bc8b0110907
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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="com.ycl.mapper.ProjectEngineeringMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.domain.vo.ProjectEngineeringVO">
        <id column="id" property="id"/>
        <result column="project_info_id" property="projectInfoId" />
        <result column="projectInfoName" property="projectInfoName" />
        <result column="project_name" property="projectName" />
        <result column="project_type" property="projectType" />
        <result column="investment_amount" property="investmentAmount" />
        <result column="status" property="status" />
        <result column="unit" property="unit" />
        <result column="department" property="department" />
        <result column="parent_id" property="parent" />
        <result column="year" property="year" />
        <result column="unit_name" property="unitName" />
        <result column="department_name" property="departmentName" />
        <result column="build_content" property="buildContent"/>
        <collection property="children" ofType="com.ycl.domain.vo.ProjectEngineeringVO" select="getProjectEngineering" column="id"></collection>
 
    </resultMap>
 
 
 
    <select id="getProjectEngineering" parameterType="String" resultMap="com.ycl.mapper.ProjectEngineeringMapper.BaseResultMap">
        SELECT  TPE.project_info_id,
                TPE.project_name,
                TPE.project_type,
                TPE.investment_amount,
                TPE.status,
                TPE.id,
                TPE.unit,
                TPE.department,
                TPE.parent_id,
                TPE.year,
                TPE.build_content,
            (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TPE.unit) AS unit_name,
                (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TPE.department) AS department_name
        FROM t_project_engineering TPE
                          INNER JOIN t_project_info TPI ON TPI.id = TPE.project_info_id AND TPI.deleted = 0
        WHERE TPE.parent_id = #{id} and TPE.deleted = 0 ORDER BY TPE.gmt_create
    </select>
 
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TPE.project_info_id,
            TPE.project_name,
            TPE.project_type,
            TPE.investment_amount,
            TPE.status,
            TPE.id,
            TPE.unit,
            TPE.department,
            TPE.parent_id,
            TPE.year,
            TPE.build_content
        FROM
            t_project_engineering TPE
        WHERE
            TPE.id = #{id} AND TPE.deleted = 0
    </select>
 
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            TPE.project_info_id,
            TPE.project_type,
            TPE.investment_amount,
            TPE.status,
            TPE.id,
            TPE.unit,
            TPE.department,
            TPE.parent_id,
            TPE.year,
            TPI.project_name,
            TPE.build_content,
            (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TPE.unit) AS unit_name,
            (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TPE.department) AS department_name
        FROM
            t_project_engineering TPE
                Left JOIN t_project_info TPI ON TPI.id = TPE.project_info_id AND TPI.deleted = 0
        WHERE
            TPE.deleted = 0 AND TPE.parent_id = '0'
            <if test="query.projectName != null and query.projectName != ''">
                AND TPE.project_name LIKE concat('%', #{query.projectName}, '%')
            </if>
            <if test="query.projectInfoId != null">
                AND TPE.project_info_id = #{query.projectInfoId}
            </if>
            <if test="query.status != null and query.status != ''">
                AND TPE.status = #{query.status}
            </if>
            <if test="query.projectType != null and query.projectType != ''">
                AND TPE.project_type = #{query.projectType}
            </if>
        ORDER BY TPE.gmt_create DESC
 
    </select>
 
</mapper>