<?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.lyms.platform.permission.dao.master.MeasureDataInfoMapper">
<resultMap type="com.lyms.platform.pojo.MeasureDataInfoModel" id="measureDataInfoModelMap">
<result column="id" property="id"/>
<result column="measure_user_id" property="measureUserId"/>
<result column="value_one" property="valueOne"/>
<result column="value_two" property="valueTwo"/>
<result column="value_three" property="valueThree"/>
<result column="value_type" property="valueType"/>
<result column="record_count" property="recordCount"/>
<result column="created" property="created"/>
<result column="modified" property="modified"/>
<result column="today_count" property="todayCount"/>
<result column="remark_value" property="remarkValue"/>
</resultMap>
<resultMap type="com.lyms.platform.pojo.MeasureDataInfoModel" id="measureDataInfoModelMapList">
<id property="id" column="id"/>
<result column="measure_user_id" property="measureUserId"/>
<result column="value_one" property="valueOne"/>
<result column="value_two" property="valueTwo"/>
<result column="value_three" property="valueThree"/>
<result column="value_type" property="valueType"/>
<result column="record_count" property="recordCount"/>
<result column="created" property="created"/>
<result column="modified" property="modified"/>
<result column="today_count" property="todayCount"/>
<result column="record_content" property="recordContent"/>
<result column="remark_value" property="remarkValue"/>
<association property="measureUserInfoModel" javaType="com.lyms.platform.pojo.MeasureUserInfoModel">
<result column="user_name" property="userName"/>
<result column="cert_type" property="certType"/>
<result column="cert_no" property="certNo"/>
<result column="age" property="age"/>
<result column="phone" property="phone"/>
<result column="sex" property="sex"/>
<result column="vc_card_no" property="vcCardNo"/>
<result column="hospital_id" property="hospitalId"/>
<result column="created" property="created"/>
<result column="modified" property="modified"/>
<result column="zy_no" property="zyNo"/>
<result column="visit_id" property="visitId"/>
<result column="patient_id" property="patientId"/>
<result column="address" property="address"/>
<result column="face" property="face"/>
<result column="finger" property="finger"/>
</association>
</resultMap>
<insert id="addMeasureDataInfo" parameterType="com.lyms.platform.pojo.MeasureDataInfoModel" >
INSERT INTO measure_data_info(measure_user_id,
value_one,value_two,value_three,value_type
,record_count,created,modified,today_count,remark_value,record_content)
VALUES (#{measureUserId},#{valueOne}
,#{valueTwo},#{valueThree},#{valueType},#{recordCount},#{created},#{modified},#{todayCount},#{remarkValue},#{recordContent})
</insert>
<select id="queryMeasureDataInfoList" parameterType="com.lyms.platform.query.MeasureDataInfoQuery"
resultMap="measureDataInfoModelMap">
SELECT id,measure_user_id,
value_one,value_two,value_three,value_type
,record_count,created,modified,today_count,remark_value,record_content
FROM measure_data_info
<include refid="queryMeasureDataInfoCondition"/>
<include refid="orderAndLimit"/>
</select>
<select id="queryMeasureList" parameterType="com.lyms.platform.query.MeasureDataInfoQuery"
resultMap="measureDataInfoModelMapList">
SELECT
m.id,
m.measure_user_id,
m.value_one,m.value_two,m.value_three,m.value_type,
m.record_count,m.created,m.modified,
m.today_count,m.remark_value,
m.record_content,
u.user_name,u.cert_type,
u.cert_no,u.age,u.phone,u.sex,u.vc_card_no,
u.hospital_id,u.patient_id,u.address,u.face,u.finger
FROM measure_data_info m
LEFT JOIN
measure_user_info u ON m.measure_user_id = u.id
WHERE 1 = 1
<if test="id != null and id >= 0">
and m.id = #{id,jdbcType=INTEGER}
</if>
<if test="valueOne != null and valueOne != ''">
and m.value_one = #{valueOne,jdbcType=VARCHAR}
</if>
<if test="valueTwo != null and valueTwo != ''">
and m.value_two = #{valueTwo,jdbcType=VARCHAR}
</if>
<if test="valueThree != null and valueThree != ''">
and m.value_three = #{valueThree,jdbcType=VARCHAR}
</if>
<if test="valueType != null and valueType > 0">
and m.value_type = #{valueType,jdbcType=INTEGER}
</if>
<if test="created != null">
AND date_format(m.created,'%Y-%m-%d') = #{created}
</if>
<if test="recordCount != null and recordCount >= 0">
and m.record_count = #{m.recordCount,jdbcType=INTEGER}
</if>
<if test="modified != null">
AND date_format(m.modified,'%Y-%m-%d') = #{modified}
</if>
<if test="createdTimeStart != null">
AND m.created >= date_format(#{createdTimeStart},'%Y-%m-%d')
</if>
<if test="createdTimeEnd != null">
AND <![CDATA[ m.created < date_format(#{createdTimeEnd},'%Y-%m-%d') ]]>
</if>
<if test="modifiedTimeStart != null">
AND m.modified >= date_format(#{modifiedTimeStart},'%Y-%m-%d')
</if>
<if test="modifiedTimeEnd != null">
AND <![CDATA[ m.modified < date_format(#{modifiedTimeEnd},'%Y-%m-%d') ]]>
</if>
<if test="todayCount != null and todayCount > 0">
m.today_count = #{todayCount,jdbcType=INTEGER},
</if>
<if test="queryNo != null and queryNo != ''">
and (u.phone = #{queryNo,jdbcType=VARCHAR} or u.cert_no = #{queryNo,jdbcType=VARCHAR}
or u.user_name = #{queryNo,jdbcType=VARCHAR})
</if>
<if test="hospitalId != null and hospitalId != ''">
and u.hospital_id = #{hospitalId,jdbcType=VARCHAR}
</if>
<if test="hospitalIds != null and hospitalIds.size() > 0">
and u.hospital_id in
<foreach collection="hospitalIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="address != null and address != ''">
and u.address = #{address,jdbcType=VARCHAR}
</if>
<if test="face != null and face != ''">
and u.face = #{face,jdbcType=VARCHAR}
</if>
<if test="finger != null and finger != ''">
and u.finger = #{finger,jdbcType=VARCHAR}
</if>
<if test="userName != null">
and u.user_name = #{userName,jdbcType=VARCHAR}
</if>
<if test="certType != null and certType != ''">
and u.cert_type = #{certType,jdbcType=VARCHAR}
</if>
<if test="certNo != null and certNo != ''">
and u.cert_no = #{certNo,jdbcType=VARCHAR}
</if>
<if test="age != null and age != ''">
and u.age = #{age,jdbcType=VARCHAR}
</if>
<if test="phone != null and phone != ''">
and u.phone = #{phone,jdbcType=VARCHAR}
</if>
<if test="sex != null">
and u.sex = #{sex,jdbcType=INTEGER}
</if>
<if test="vcCardNo != null and vcCardNo != ''">
and u.vc_card_no = #{vcCardNo,jdbcType=VARCHAR}
</if>
<if test="zyNo != null and zyNo != ''">
and u.zy_no = #{zyNo,jdbcType=VARCHAR}
</if>
<if test="visitId != null and visitId != ''">
and u.visit_id = #{visitId,jdbcType=VARCHAR}
</if>
<if test="patientId != null and patientId != ''">
and u.patient_id = #{valueOne,jdbcType=VARCHAR}
</if>
order by m.created desc
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</select>
<select id="queryMeasureDataInfoListCount" parameterType="com.lyms.platform.query.MeasureDataInfoQuery" resultType="int">
SELECT count(id) FROM measure_data_info
<include refid="queryMeasureDataInfoCondition"/>
</select>
<update id="updateMeasureDataInfo" parameterType="com.lyms.platform.pojo.MeasureDataInfoModel" >
UPDATE
measure_data_info
<set>
<if test="id != null and id >= 0">
id = #{id,jdbcType=INTEGER},
</if>
<if test="measureUserId != null">
measure_user_id = #{measureUserId},
</if>
<if test="valueOne != null and valueOne != ''">
value_one = #{valueOne,jdbcType=VARCHAR},
</if>
<if test="valueTwo != null and valueTwo != ''">
value_two = #{valueTwo,jdbcType=VARCHAR},
</if>
<if test="valueThree != null and valueThree != ''">
value_three = #{valueThree,jdbcType=VARCHAR},
</if>
<if test="valueType != null and valueType > 0">
value_type = #{valueType,jdbcType=INTEGER},
</if>
<if test="recordCount != null and recordCount >= 0">
record_count = #{recordCount,jdbcType=INTEGER},
</if>
<if test="recordContent != null">
record_content = #{recordContent,jdbcType=VARCHAR},
</if>
<if test="created != null">
created = #{created},
</if>
<if test="modified != null">
modified = #{modified},
</if>
<if test="todayCount != null and todayCount > 0">
today_count = #{todayCount,jdbcType=INTEGER},
</if>
<if test="remarkValue != null and remarkValue != ''">
remark_value = #{remarkValue,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>
<sql id="queryMeasureDataInfoCondition">
<where>
1 = 1
<if test="id != null and id >= 0">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="valueOne != null and valueOne != ''">
and value_one = #{valueOne,jdbcType=VARCHAR}
</if>
<if test="valueTwo != null and valueTwo != ''">
and value_two = #{valueTwo,jdbcType=VARCHAR}
</if>
<if test="valueThree != null and valueThree != ''">
and value_three = #{valueThree,jdbcType=VARCHAR}
</if>
<if test="valueType != null and valueType > 0">
and value_type = #{valueType,jdbcType=INTEGER}
</if>
<if test="created != null">
AND date_format(created,'%Y-%m-%d') = #{created}
</if>
<if test="recordCount != null and recordCount >= 0">
and record_count = #{recordCount,jdbcType=INTEGER}
</if>
<if test="measureUserId != null and measureUserId >= 0">
and measure_user_id = #{measureUserId,jdbcType=INTEGER}
</if>
<if test="recordContent != null">
and record_content = #{recordContent,jdbcType=VARCHAR}
</if>
<if test="createdTimeStart != null">
AND created >= date_format(#{createdTimeStart},'%Y-%m-%d')
</if>
<if test="createdTimeEnd != null">
AND <![CDATA[ created < date_format(#{createdTimeEnd},'%Y-%m-%d') ]]>
</if>
<if test="modifiedTimeStart != null">
AND modified >= date_format(#{modifiedTimeStart},'%Y-%m-%d')
</if>
<if test="modifiedTimeEnd != null">
AND <![CDATA[ modified < date_format(#{modifiedTimeEnd},'%Y-%m-%d') ]]>
</if>
<if test="todayCount != null and todayCount > 0">
today_count = #{todayCount,jdbcType=INTEGER},
</if>
</where>
</sql>
</mapper>