You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
7.8 KiB

6 months ago
<?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.MineHealthMapper">
5 months ago
<resultMap type="mineHealth" id="MineHealthResult">
6 months ago
<result property="id" column="id" />
<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" />
<result property="isWork" column="is_work" />
<result property="createTime" column="create_time" />
<result property="faceName" column="face_name" />
6 months ago
<result property="facePhone" column="face_phone" />
5 months ago
<result property="deptId" column="dept_id" />
5 months ago
<result property="warningId" column="warning_id" />
<result property="userName" column="user_name" />
<result property="userId" column="user_id" />
5 months ago
<result property="deptName" column="dept_name" />
6 months ago
<result property="age" column="age" />
6 months ago
</resultMap>
<sql id="selectMineHealthVo">
SELECT
mh.id,
mh.bp_high,
mh.bp_low,
mh.br,
mh.hr,
mh.hrv,
mh.temperature,
mh.is_work,
mh.create_time,
5 months ago
mh.user_id,
5 months ago
mh.user_name,
5 months ago
mh.warning_id,
6 months ago
mf.face_name,
6 months ago
mf.face_phone ,
5 months ago
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.dept_id,
d.dept_name
6 months ago
FROM
mine_health mh
INNER JOIN mine_face mf
on mf.id =mh.face_id
5 months ago
inner join sys_dept d
on d.dept_id =mf.dept_id
6 months ago
</sql>
6 months ago
<select id="selectMineHealthList" parameterType="mineHealthVo" resultMap="MineHealthResult">
6 months ago
<include refid="selectMineHealthVo"/>
<where>
<if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
<if test="deptId != null "> and d.dept_id = #{deptId}</if>
6 months ago
<if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if>
<if test="bpHigh != null "> and mh.bp_high = #{bpHigh}</if>
<if test="bpLow != null "> and mh.bp_low = #{bpLow}</if>
<if test="br != null "> and mh.br = #{br}</if>
<if test="hr != null "> and mh.hr = #{hr}</if>
<if test="hrv != null "> and mh.hrv = #{hrv}</if>
5 months ago
<if test="userId != null "> and mh.user_id = #{userId}</if>
5 months ago
<if test="userName != null and userName != ''"> and mh.user_name like concat('%', #{userName}, '%')</if>
5 months ago
<if test="warningId != null "> and mh.waring_id = #{warningId}</if>
6 months ago
<if test="temperature != null and temperature != ''"> and mh.temperature = #{temperature}</if>
<if test="isWork != null "> and mf.is_work = #{isWork}</if>
</where>
5 months ago
order by mh.user_id,mh.create_time desc
6 months ago
</select>
<select id="selectMineHealthById" parameterType="Long" resultMap="MineHealthResult">
<include refid="selectMineHealthVo"/>
where mh.id = #{id}
</select>
5 months ago
<select id="selectMineHealthByList" resultMap="MineHealthResult">
<include refid="selectMineHealthVo"/>
<where>
<if test="mineGroupName != null and mineGroupName != ''"> and mg.mine_group_name like concat('%', #{mineGroupName}, '%')</if>
<if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if>
<if test="bpHigh != null "> and mh.bp_high = #{bpHigh}</if>
<if test="bpLow != null "> and mh.bp_low = #{bpLow}</if>
<if test="br != null "> and mh.br = #{br}</if>
<if test="hr != null "> and mh.hr = #{hr}</if>
<if test="hrv != null "> and mh.hrv = #{hrv}</if>
<if test="userId != null "> and mh.user_id = #{userId}</if>
5 months ago
<if test="userName != null "> and mh.user_name = #{userName}</if>
5 months ago
<if test="warningId != null "> and mh.waring_id = #{warningId}</if>
<if test="temperature != null and temperature != ''"> and mh.temperature = #{temperature}</if>
<if test="isWork != null "> and mf.is_work = #{isWork}</if>
</where>
</select>
6 months ago
<insert id="insertMineHealth" parameterType="MineHealth" useGeneratedKeys="true" keyProperty="id">
insert into mine_health
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bpHigh != null">bp_high,</if>
<if test="bpLow != null">bp_low,</if>
<if test="br != null">br,</if>
<if test="hr != null">hr,</if>
5 months ago
<if test="userId != null "> user_id,</if>
5 months ago
<if test="userName != null "> user_name,</if>
6 months ago
<if test="faceId != null">face_id,</if>
5 months ago
<if test="warningId != null">warning_id,</if>
6 months ago
<if test="hrv != null">hrv,</if>
<if test="temperature != null">temperature,</if>
<if test="isWork != null">is_work,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bpHigh != null">#{bpHigh},</if>
<if test="bpLow != null">#{bpLow},</if>
<if test="br != null">#{br},</if>
<if test="hr != null">#{hr},</if>
5 months ago
<if test="userId != null "> #{userId},</if>
5 months ago
<if test="userName != null ">#{userName},</if>
5 months ago
<if test="faceId != null">#{faceId},</if>
<if test="warningId != null">#{warningId},</if>
6 months ago
<if test="hrv != null">#{hrv},</if>
<if test="temperature != null">#{temperature},</if>
<if test="isWork != null">#{isWork},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateMineHealth" parameterType="MineHealth">
update mine_health
<trim prefix="SET" suffixOverrides=",">
<if test="faceId != null">face_id=#{faceId}</if>
<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="temperature != null">temperature = #{temperature},</if>
<if test="isWork != null">is_work = #{isWork},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMineHealthById" parameterType="Long">
delete from mine_health where id = #{id}
</delete>
<delete id="deleteMineHealthByIds" parameterType="String">
delete from mine_health where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>