|
|
|
<?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="yq.system.mapper.MineFaceMapper">
|
|
|
|
|
|
|
|
<resultMap type="MineFace" id="MineFaceResult">
|
|
|
|
<result property="id" column="id" />
|
|
|
|
<result property="deptId" column="dept_id" />
|
|
|
|
<result property="deptName" column="dept_name" />
|
|
|
|
<result property="faceName" column="face_name" />
|
|
|
|
<result property="age" column="age" />
|
|
|
|
<result property="birthDate" column="birth_date" />
|
|
|
|
<result property="facePhone" column="face_phone" />
|
|
|
|
<result property="faceUrl" column="face_url" />
|
|
|
|
<result property="isWork" column="is_work" />
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
<result property="useTime" column="use_time" />
|
|
|
|
<result property="faceByte" column="face_byte" />
|
|
|
|
<result property="bpHigh" column="bp_high" />
|
|
|
|
<result property="bpLow" column="bp_low" />
|
|
|
|
<result property="br" column="br" />
|
|
|
|
<result property="hr" column="hr" />
|
|
|
|
<result property="hrv" column="hrv" />
|
|
|
|
<result property="temperature" column="temperature" />
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<sql id="selectMineFaceVo">
|
|
|
|
select mf.id, mf.face_name, mf.birth_date,
|
|
|
|
CASE
|
|
|
|
WHEN LENGTH(birth_date) = 15 THEN
|
|
|
|
-- 15位身份证号,提取出生年份、月份、日期并计算年龄
|
|
|
|
FLOOR(DATEDIFF(CURDATE(), STR_TO_DATE(CONCAT('19', SUBSTRING(birth_date, 7, 6)), '%Y%m%d')) / 365.25)
|
|
|
|
WHEN LENGTH(birth_date) = 18 THEN
|
|
|
|
-- 18位身份证号,提取出生年份、月份、日期并计算年龄
|
|
|
|
FLOOR(DATEDIFF(CURDATE(), STR_TO_DATE(SUBSTRING(birth_date, 7, 8), '%Y%m%d')) / 365.25)
|
|
|
|
ELSE
|
|
|
|
NULL
|
|
|
|
END AS age,
|
|
|
|
mf.face_phone, mf.face_url,
|
|
|
|
mf.is_work, mf.remark, mf.create_time,mf.use_time,mf.dept_id,d.dept_name,
|
|
|
|
mf.bp_high,
|
|
|
|
mf.bp_low,
|
|
|
|
mf.br,
|
|
|
|
mf.hr,
|
|
|
|
mf.hrv,
|
|
|
|
mf.spo2,
|
|
|
|
mf.hd,
|
|
|
|
mf.temperature
|
|
|
|
from mine_face mf
|
|
|
|
inner join sys_dept d on mf.dept_id = d.dept_id
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="selectMineFaceList" parameterType="MineFace" resultMap="MineFaceResult">
|
|
|
|
<include refid="selectMineFaceVo"/>
|
|
|
|
<where>
|
|
|
|
<if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if>
|
|
|
|
<if test="age != null "> and mf.age = #{age}</if>
|
|
|
|
<if test="deptId != null "> and d.dept_id =#{deptId}</if>
|
|
|
|
<if test="facePhone != null and facePhone != ''"> and mf.face_phone = #{facePhone}</if>
|
|
|
|
<if test="faceUrl != null and faceUrl != ''"> and mf.face_url = #{faceUrl}</if>
|
|
|
|
<if test="isWork != null "> and mf.is_work = #{isWork}</if>
|
|
|
|
<if test="deptIdStr != null "> and d.dept_id in (#{deptIdStr})</if>
|
|
|
|
</where>
|
|
|
|
order by d.dept_name desc
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectMineFaceById" parameterType="Long" resultMap="MineFaceResult">
|
|
|
|
<include refid="selectMineFaceVo"/>
|
|
|
|
where mf.id = #{id}
|
|
|
|
</select>
|
|
|
|
<select id="selectMineFaceByList" resultMap="MineFaceResult">
|
|
|
|
SELECT
|
|
|
|
mf.id,
|
|
|
|
mf.face_name,
|
|
|
|
FLOOR(TIMESTAMPDIFF(MONTH,mf.birth_date , SYSDATE()) / 12) AS age,
|
|
|
|
mf.face_byte,
|
|
|
|
mf.face_url,
|
|
|
|
mf.face_phone,
|
|
|
|
mf.remark,
|
|
|
|
d.dept_id,d.dept_name
|
|
|
|
FROM
|
|
|
|
mine_face mf
|
|
|
|
inner join sys_dept d on mf.dept_id = d.dept_id
|
|
|
|
WHERE mf.face_byte is not null
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<insert id="insertMineFace" parameterType="MineFace">
|
|
|
|
insert into mine_face
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="id != null">id,</if>
|
|
|
|
<if test="faceName != null">face_name,</if>
|
|
|
|
<if test="birthDate != null">birth_date,</if>
|
|
|
|
<if test="facePhone != null">face_phone,</if>
|
|
|
|
<if test="faceUrl != null">face_url,</if>
|
|
|
|
<if test="isWork != null">is_work,</if>
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
<if test="useTime != null">use_time,</if>
|
|
|
|
<if test="faceByte != null">face_byte,</if>
|
|
|
|
<if test="deptId != null">dept_id,</if>
|
|
|
|
</trim>
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="id != null">#{id},</if>
|
|
|
|
<if test="faceName != null">#{faceName},</if>
|
|
|
|
<if test="birthDate != null">#{birthDate},</if>
|
|
|
|
<if test="facePhone != null">#{facePhone},</if>
|
|
|
|
<if test="faceUrl != null">#{faceUrl},</if>
|
|
|
|
<if test="isWork != null">#{isWork},</if>
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
<if test="useTime != null">#{useTime},</if>
|
|
|
|
<if test="faceByte != null">#{faceByte},</if>
|
|
|
|
<if test="deptId != null">#{deptId},</if>
|
|
|
|
</trim>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<update id="updateMineFace" parameterType="MineFace">
|
|
|
|
update mine_face
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
<if test="faceName != null">face_name = #{faceName},</if>
|
|
|
|
<if test="birthDate != null">birth_date = #{birthDate},</if>
|
|
|
|
<if test="facePhone != null">face_phone = #{facePhone},</if>
|
|
|
|
<if test="faceUrl != null">face_url = #{faceUrl},</if>
|
|
|
|
<if test="isWork != null">is_work = #{isWork},</if>
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
<if test="deptId != null">dept_id = #{deptId},</if>
|
|
|
|
<if test="useTime != null">use_time=#{useTime},</if>
|
|
|
|
<if test="faceByte != null">face_byte = #{faceByte},</if>
|
|
|
|
</trim>
|
|
|
|
where id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="updateByMineFace" parameterType="MineFace">
|
|
|
|
update mine_face
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
<if test="bpHigh != null">bp_high = #{bpHigh},</if>
|
|
|
|
<if test="bpLow != null">bp_low = #{bpLow},</if>
|
|
|
|
<if test="br != null">br = #{br},</if>
|
|
|
|
<if test="hr != null">hr = #{hr},</if>
|
|
|
|
<if test="hrv != null">hrv = #{hrv},</if>
|
|
|
|
<if test="hd != null "> hd = #{hd},</if>
|
|
|
|
<if test="spo2 != null "> spo2 = #{spo2},</if>
|
|
|
|
<if test="temperature != null">temperature = #{temperature},</if>
|
|
|
|
</trim>
|
|
|
|
where id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteMineFaceById" parameterType="Long">
|
|
|
|
delete from mine_face where id = #{id}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="deleteMineFaceByIds" parameterType="String">
|
|
|
|
delete from mine_face where id in
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
</mapper>
|