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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?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.MjVisitLogMapper">
 
    <resultMap type="MjVisitLog" id="MjVisitLogResult">
        <result property="id"    column="id"    />
        <result property="userName"    column="user_name"    />
        <result property="organizationId"    column="organization_id"    />
        <result property="organizationName"    column="organization_name"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="jobNumber"    column="Job_number"    />
        <result property="workOrderId"    column="work_order_id"    />
        <result property="workOrderName"    column="work_order_name"    />
        <result property="doorId"    column="door_id"    />
        <result property="doorName"    column="door_name"    />
        <result property="ipOrOther"    column="ip_or_other"    />
        <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="sort"    column="sort"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="expandStatus"    column="expand_status"    />
        <result property="expandStatus1"    column="expand_status1"    />
        <result property="areaName"    column="area_name"    />
        <result property="direction"    column="direction"    />
    </resultMap>
 
    <sql id="selectMjVisitLogVo">
        select id, user_name, organization_id, organization_name, dept_id, dept_name, Job_number, work_order_id, work_order_name, door_id, door_name, ip_or_other, create_time, update_time, create_by, update_by, sort, del_flag, expand_status, expand_status1,area_name,direction from mj_visit_log
    </sql>
 
    <select id="selectMjVisitLogList3" parameterType="MjVisitLog" resultMap="MjVisitLogResult">
        <include refid="selectMjVisitLogVo"/>
        <where>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="organizationId != null  and organizationId != ''"> and organization_id = #{organizationId}</if>
            <if test="organizationName != null  and organizationName != ''"> and organization_name like concat('%', #{organizationName}, '%')</if>
            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="jobNumber != null  and jobNumber != ''"> and Job_number like concat('%', #{userName}, '%')</if>
            <if test="workOrderId != null  and workOrderId != ''"> and work_order_id = #{workOrderId}</if>
            <if test="workOrderName != null  and workOrderName != ''"> and work_order_name like concat('%', #{workOrderName}, '%')</if>
            <if test="doorId != null  and doorId != ''"> and door_id = #{doorId}</if>
            <if test="doorName != null  and doorName != ''"> and door_name like concat('%', #{doorName}, '%')</if>
            <if test="ipOrOther != null  and ipOrOther != ''"> and ip_or_other = #{ipOrOther}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="expandStatus != null "> and expand_status = #{expandStatus}</if>
            <if test="expandStatus1 != null "> and expand_status1 = #{expandStatus1}</if>
            <if test="areaName != null "> and area_name like concat('%', #{areaName}, '%')</if>
            <if test="direction != null "> and direction = #{direction}</if>
            and del_flag=1
        </where>
        order by create_time desc
    </select>
 
    <select id="selectMjVisitLogList" parameterType="MjVisitLog" resultMap="MjVisitLogResult">
        <include refid="selectMjVisitLogVo"/>
        <where>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="organizationId != null  and organizationId != ''"> and organization_id = #{organizationId}</if>
            <if test="organizationName != null  and organizationName != ''"> and organization_name like concat('%', #{organizationName}, '%')</if>
            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="jobNumber != null  and jobNumber != ''"> and Job_number = #{jobNumber}</if>
            <if test="workOrderId != null  and workOrderId != ''"> and work_order_id = #{workOrderId}</if>
            <if test="workOrderName != null  and workOrderName != ''"> and work_order_name like concat('%', #{workOrderName}, '%')</if>
            <if test="doorId != null  and doorId != ''"> and door_id = #{doorId}</if>
            <if test="doorName != null  and doorName != ''"> and door_name like concat('%', #{doorName}, '%')</if>
            <if test="ipOrOther != null  and ipOrOther != ''"> and ip_or_other = #{ipOrOther}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="expandStatus != null "> and expand_status = #{expandStatus}</if>
            <if test="expandStatus1 != null "> and expand_status1 = #{expandStatus1}</if>
            <if test="areaName != null "> and area_name like concat('%', #{areaName}, '%')</if>
            <if test="direction != null "> and direction = #{direction}</if>
            and del_flag=0
        </where>
         order by create_time desc
    </select>
    <!--and DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(create_time)-->
 
    <select id="selectMjVisitLogById" parameterType="String" resultMap="MjVisitLogResult">
        <include refid="selectMjVisitLogVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertMjVisitLog" parameterType="MjVisitLog">
        insert into mj_visit_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userName != null">user_name,</if>
            <if test="organizationId != null">organization_id,</if>
            <if test="organizationName != null">organization_name,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="jobNumber != null">Job_number,</if>
            <if test="workOrderId != null">work_order_id,</if>
            <if test="workOrderName != null">work_order_name,</if>
            <if test="doorId != null">door_id,</if>
            <if test="doorName != null">door_name,</if>
            <if test="ipOrOther != null">ip_or_other,</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="sort != null">sort,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="expandStatus != null">expand_status,</if>
            <if test="expandStatus1 != null">expand_status1,</if>
            <if test="areaName != null">area_name,</if>
            <if test="direction != null">direction,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userName != null">#{userName},</if>
            <if test="organizationId != null">#{organizationId},</if>
            <if test="organizationName != null">#{organizationName},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="jobNumber != null">#{jobNumber},</if>
            <if test="workOrderId != null">#{workOrderId},</if>
            <if test="workOrderName != null">#{workOrderName},</if>
            <if test="doorId != null">#{doorId},</if>
            <if test="doorName != null">#{doorName},</if>
            <if test="ipOrOther != null">#{ipOrOther},</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="sort != null">#{sort},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="expandStatus != null">#{expandStatus},</if>
            <if test="expandStatus1 != null">#{expandStatus1},</if>
            <if test="areaName != null">#{areaName},</if>
            <if test="direction != null">#{direction},</if>
         </trim>
    </insert>
 
    <update id="updateMjVisitLog" parameterType="MjVisitLog">
        update mj_visit_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="userName != null">user_name = #{userName},</if>
            <if test="organizationId != null">organization_id = #{organizationId},</if>
            <if test="organizationName != null">organization_name = #{organizationName},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="jobNumber != null">Job_number = #{jobNumber},</if>
            <if test="workOrderId != null">work_order_id = #{workOrderId},</if>
            <if test="workOrderName != null">work_order_name = #{workOrderName},</if>
            <if test="doorId != null">door_id = #{doorId},</if>
            <if test="doorName != null">door_name = #{doorName},</if>
            <if test="ipOrOther != null">ip_or_other = #{ipOrOther},</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="sort != null">sort = #{sort},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="expandStatus != null">expand_status = #{expandStatus},</if>
            <if test="expandStatus1 != null">expand_status1 = #{expandStatus1},</if>
            <if test="areaName != null">area_name = #{areaName},</if>
            <if test="direction != null">direction = #{direction},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteMjVisitLogById" parameterType="String">
        delete from mj_visit_log where id = #{id}
    </delete>
 
    <delete id="delete7days" parameterType="String">
        delete from mj_visit_log where create_time &lt; NOW() - INTERVAL 7 DAY
    </delete>
 
 
    <delete id="deleteMjVisitLogByIds" parameterType="String">
        delete from mj_visit_log where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectVisitLogCount" resultType="Integer">
        select count(1) from mj_visit_log where del_flag = 0
    </select>
 
    <select id="selectVisitOrder" resultType="com.ruoyi.station.domain.MjWorkOrder">
        select workOrder.id id,workOrder.start_time startTime,workOrder.end_time endTime,workOrder.open_mode openMode, log.expand_status expandStatus from mj_visit_log log
        left join mj_work_order workOrder on workOrder.id = log.work_order_id
        where log.del_flag = 0
    </select>
 
    <select id="selectVisitLog" resultType="com.ruoyi.station.domain.MjVisitLog">
        select log.id id,log.work_order_name workOrderName,log.user_name userName,head.direction direction,log.create_time createTime,log.expand_status expandStatus from mj_visit_log log
        left join mj_fingerprint_read_head head on head.ip_or_other = log.ip_or_other
        group by log.create_time
        order by log.create_time desc
    </select>
 
    <select id="selectVisitLogByCondition" parameterType="Map" resultType="com.ruoyi.station.domain.MjVisitLog">
        select log.id id,log.work_order_name workOrderName,log.user_name userName,head.direction direction,log.create_time createTime,
        log.dept_name deptName, detail.area_name areaName, head.door_name doorName from mj_visit_log log
        left join mj_fingerprint_read_head head on head.ip_or_other = log.ip_or_other
        left join mj_order_detail detail on detail.order_id = log.work_order_id
        <where>
            <if test="direction != null"> and head.direction = #{direction}</if>
            <if test="userName != null  and userName != ''"> and log.user_name like concat('%', #{userName}, '%')</if>
            <if test="deptName != null  and deptName != ''"> and log.dept_name like concat('%', #{deptName}, '%')</if>
            <if test="workOrderName != null  and workOrderName != ''"> and log.work_order_name like concat('%', #{workOrderName}, '%')</if>
            <if test="areaName != null  and areaName != ''"> and detail.area_name like concat('%', #{areaName}, '%')</if>
            <if test="doorName != null  and doorName != ''"> and head.door_name like concat('%', #{doorName}, '%')</if>
            <if test="startTime != null "> and date_format(#{startTime},'%y%m%d %H%i%s') &lt;= date_format(log.create_time,'%y%m%d %H%i%s')</if>
            <if test="endTime != null "> and date_format(#{endTime},'%y%m%d %H%i%s') >= date_format(log.create_time,'%y%m%d %H%i%s')</if>
        </where>
        order by log.create_time desc
    </select>
 
</mapper>