luohairen
2024-11-27 dd9cb79f149f2eaebccdf19efd35f77f5a9e52ae
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?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.ProjectPlanExamineRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.domain.vo.ProjectPlanExamineRecordVO">
        <result column="project_plan_record_id" property="projectPlanRecordId" />
        <result column="project_plan_info_id" property="projectPlanInfoId" />
        <result column="department_user_id" property="departmentUserId" />
        <result column="manager_user_id" property="managerUserId" />
        <result column="department_examine" property="departmentExamine" />
        <result column="department_approval" property="departmentApproval" />
        <result column="department_approval_reply" property="departmentApprovalReply" />
        <result column="manage_examine" property="manageExamine" />
        <result column="manage_approval" property="manageApproval" />
        <result column="manage_approval_reply" property="manageApprovalReply" />
        <result column="event_type" property="eventType" />
        <result column="delay_start_time" property="delayStartTime" />
        <result column="delay_end_time" property="delayEndTime" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_update" property="gmtUpdate" />
    </resultMap>
 
    <resultMap id="selectInfoResultMap" type="com.ycl.domain.vo.DepartmentApprovalResponseVO">
        <id property="id" column="id" />
        <result property="title" column="title" />
        <result property="departmentExamine" column="department_examine" />
        <result property="departmentApproval" column="department_approval" />
        <result property="departmentApprovalReply" column="department_approval_reply" />
        <result property="manageExamine" column="manage_examine" />
        <result property="manageApproval" column="manage_approval" />
        <result property="manageApprovalReply" column="manage_approval_reply" />
        <result property="gmtCreate" column="gmt_create" />
    </resultMap>
 
    <insert id="insertOne">
        insert into t_project_plan_examine_record (
            project_plan_record_id,
            project_plan_info_id,
            department_user_id,
            manager_user_id,
            department_examine,
            department_approval,
            department_approval_reply,
            manage_examine,
            manage_approval,
            manage_approval_reply,
            event_type,
            delay_start_time,
            delay_end_time,
            gmt_create,
            gmt_update
        ) values (
            #{projectPlanRecordId},
            #{projectPlanInfoId},
            #{departmentUserId},
            #{managerUserId},
            #{departmentExamine},
            #{departmentApproval},
            #{departmentApprovalReply},
            #{manageExamine},
            #{manageApproval},
            #{manageApprovalReply},
            #{eventType},
            #{delayStartTime},
            #{delayEndTime},
            #{gmtCreate},
            #{gmtUpdate}
        )
    </insert>
 
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TPPER.project_plan_record_id,
            TPPER.department_user_id,
            TPPER.manager_user_id,
            TPPER.department_examine,
            TPPER.department_approval,
            TPPER.department_approval_reply,
            TPPER.manage_examine,
            TPPER.manage_approval,
            TPPER.manage_approval_reply,
            TPPER.event_type,
            TPPER.delay_start_time,
            TPPER.delay_end_time,
            TPPER.gmt_create_time,
            TPPER.gmt_update_time,
            TPPER.id
        FROM
            t_project_plan_examine_record TPPER
        WHERE
            TPPER.id = #{id} AND TPPER.deleted = 0
    </select>
 
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            TPPER.project_plan_record_id,
            TPPER.department_user_id,
            TPPER.manager_user_id,
            TPPER.department_examine,
            TPPER.department_approval,
            TPPER.department_approval_reply,
            TPPER.manage_examine,
            TPPER.manage_approval,
            TPPER.manage_approval_reply,
            TPPER.event_type,
            TPPER.delay_start_time,
            TPPER.delay_end_time,
            TPPER.gmt_create_time,
            TPPER.gmt_update_time,
            TPPER.id
        FROM
            t_project_plan_examine_record TPPER
        WHERE
            TPPER.deleted = 0
    </select>
    <select id="selectInfo" resultType="com.ycl.domain.vo.DepartmentApprovalResponseVO">
        SELECT
            ranked.id,
            (SELECT title FROM t_project_plan_info WHERE id = ranked.project_plan_info_id) as title,
            ranked.department_examine,
            ranked.department_approval,
            ranked.department_approval_reply,
            ranked.manage_examine,
            ranked.manage_approval,
            ranked.manage_approval_reply,
            ranked.gmt_create
        FROM (
                 SELECT
                     *,
                     ROW_NUMBER() OVER (PARTITION BY project_plan_info_id ORDER BY gmt_update DESC) AS rn
                 FROM t_project_plan_examine_record AS pper
                 WHERE project_plan_record_id = #{projectPlanRecordId}
             ) AS ranked
        WHERE rn = 1;
    </select>
 
    <select id="getPlanLog" resultType="com.ycl.domain.vo.DepartmentApprovalResponseVO">
        SELECT
            pper.id,
            (SELECT title FROM t_project_plan_info WHERE id = pper.project_plan_info_id) as title,
            pper.department_examine,
            pper.department_approval,
            pper.department_approval_reply,
            pper.manage_examine,
            pper.manage_approval,
            pper.manage_approval_reply,
            pper.gmt_create
        FROM t_project_plan_examine_record AS pper
        WHERE
            pper.project_plan_record_id = #{projectPlanRecordId}
        ORDER BY gmt_update DESC
    </select>
 
</mapper>