wang-hao-jie
2022-08-25 57dcc73636bb7d8dce89c808eb8cc988a7512264
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?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.ruoyi.station.mapper.MjHeadsUsersMapper">
    
    <resultMap type="MjHeadsUsers" id="MjHeadsUsersResult">
        <result property="id"    column="id"    />
        <result property="orderId"    column="order_id"    />
        <result property="userId"    column="user_id"    />
        <result property="headId"    column="head_id"    />
        <result property="headType"    column="head_type"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="authorizeType"    column="authorize_type"    />
        <result property="authorizeName"    column="authorize_name"    />
        <result property="authorizeStatus"    column="authorize_status"    />
        <result property="authorizeResult"    column="authorize_result"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="mainUser"    column="main_user"    />
    </resultMap>
 
    <sql id="selectMjHeadsUsersVo">
        select id, order_id, user_id, head_id, head_type, start_time, end_time, authorize_type, authorize_name, authorize_status, authorize_result, create_time, update_time, create_by, update_by, del_flag, main_user from mj_heads_users
    </sql>
 
    <select id="selectMjHeadsUsersList" parameterType="MjHeadsUsers" resultMap="MjHeadsUsersResult">
        <include refid="selectMjHeadsUsersVo"/>
        <where>  
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="headId != null  and headId != ''"> and head_id = #{headId}</if>
            <if test="headType != null "> and head_type = #{headType}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="authorizeType != null "> and authorize_type = #{authorizeType}</if>
            <if test="authorizeName != null  and authorizeName != ''"> and authorize_name like concat('%', #{authorizeName}, '%')</if>
            <if test="authorizeStatus != null "> and authorize_status = #{authorizeStatus}</if>
            <if test="authorizeResult != null "> and authorize_result = #{authorizeResult}</if>
            <if test="mainUser != null "> and main_user = #{mainUser}</if>
        </where>
    </select>
 
    <select id="selectMjHeadsUsersList2" parameterType="MjHeadsUsers" resultMap="MjHeadsUsersResult">
        select order_id,authorize_name,authorize_type from mj_heads_users
        <where>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="headId != null  and headId != ''"> and head_id = #{headId}</if>
            <if test="headType != null "> and head_type = #{headType}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="authorizeType != null "> and authorize_type = #{authorizeType}</if>
            <if test="authorizeName != null  and authorizeName != ''"> and authorize_name like concat('%', #{authorizeName}, '%')</if>
            <if test="authorizeStatus != null "> and authorize_status = #{authorizeStatus}</if>
            <if test="authorizeResult != null "> and authorize_result = #{authorizeResult}</if>
            <if test="mainUser != null "> and main_user = #{mainUser}</if>
        </where>
 
        GROUP BY order_id,authorize_name,authorize_type
    </select>
    
    <select id="selectMjHeadsUsersById" parameterType="String" resultMap="MjHeadsUsersResult">
        <include refid="selectMjHeadsUsersVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMjHeadsUsers" parameterType="MjHeadsUsers">
        insert into mj_heads_users
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="orderId != null">order_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="headId != null">head_id,</if>
            <if test="headType != null">head_type,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="authorizeType != null">authorize_type,</if>
            <if test="authorizeName != null">authorize_name,</if>
            <if test="authorizeStatus != null">authorize_status,</if>
            <if test="authorizeResult != null">authorize_result,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="mainUser != null">main_user,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="headId != null">#{headId},</if>
            <if test="headType != null">#{headType},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="authorizeType != null">#{authorizeType},</if>
            <if test="authorizeName != null">#{authorizeName},</if>
            <if test="authorizeStatus != null">#{authorizeStatus},</if>
            <if test="authorizeResult != null">#{authorizeResult},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="mainUser != null">#{mainUser},</if>
         </trim>
    </insert>
 
    <update id="updateMjHeadsUsers" parameterType="MjHeadsUsers">
        update mj_heads_users
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="headId != null">head_id = #{headId},</if>
            <if test="headType != null">head_type = #{headType},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="authorizeType != null">authorize_type = #{authorizeType},</if>
            <if test="authorizeName != null">authorize_name = #{authorizeName},</if>
            <if test="authorizeStatus != null">authorize_status = #{authorizeStatus},</if>
            <if test="authorizeResult != null">authorize_result = #{authorizeResult},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="mainUser != null">main_user = #{mainUser},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteMjHeadsUsersById" parameterType="String">
        delete from mj_heads_users where id = #{id}
    </delete>
 
    <delete id="deleteMjHeadsUsersByIds" parameterType="String">
        delete from mj_heads_users where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <update id="updateStartTimeAndEndTime" parameterType="MjWorkOrder">
        update mj_heads_users
        <trim prefix="SET" suffixOverrides=",">
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
        </trim>
        where order_id = #{id}
    </update>
 
    <delete id="deleteByEndTime" parameterType="MjWorkOrder">
        delete from mj_heads_users where authorize_type=1 and head_type=0 and end_time &lt;= #{endTime}
    </delete>
 
    <select id="selectMjHeadsUsersListByWorking" resultMap="MjHeadsUsersResult">
        <include refid="selectMjHeadsUsersVo"/>
        <where>
            authorize_result=0 and head_type=1 and authorize_type=1 and DATE_FORMAT(start_time,'%y%m%d %H%i%s') &lt;= DATE_FORMAT(NOW(),'%y%m%d %H%i%s') and DATE_FORMAT(end_time,'%y%m%d %H%i%s') > DATE_FORMAT(NOW(),'%y%m%d %H%i%s')
        </where>
    </select>
 
    <select id="selectMjHeadsUsersListByUnWorking" resultMap="MjHeadsUsersResult">
        <include refid="selectMjHeadsUsersVo"/>
        <where>
            head_type=1 and authorize_type=1 and DATE_FORMAT(end_time,'%y%m%d %H%i%s') &lt;= DATE_FORMAT(NOW(),'%y%m%d %H%i%s')
        </where>
    </select>
 
    <select id="getAuthorizeType" resultMap="MjHeadsUsersResult">
        <include refid="selectMjHeadsUsersVo"/>
        where head_id = #{id}
    </select>
 
    <select id="getUserId" resultType="java.lang.Long">
        select user_id from mj_heads_users where order_id = #{orderId}
    </select>
</mapper>