btxtgxq-system-population/target/classes/mybatis/mapper/aids/aids-mapper.xml
2021-03-22 14:45:21 +08:00

233 lines
8.1 KiB
XML

<?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.cm.population.dao.aids.IAidsDao">
<resultMap id="aidsDTO" type="com.cm.population.pojo.dtos.aids.AidsDTO">
<id column="aids_id" property="aidsId"/>
<result column="id_card_number" property="idCardNumber"/>
<result column="infection_route" property="infectionRoute"/>
<result column="infection_route_dictionary_name" property="infectionRouteDictionaryName"/>
<result column="help_user_name" property="helpUserName"/>
<result column="case_category" property="caseCategory"/>
<result column="case_category_dictionary_name" property="caseCategoryDictionaryName"/>
<result column="treatment_info" property="treatmentInfo"/>
<result column="treatment_org" property="treatmentOrg"/>
<result column="help_info" property="helpInfo"/>
<result column="attention_type" property="attentionType"/>
<result column="attention_type_dictionary_name" property="attentionTypeDictionaryName"/>
<result column="has_crime_his" property="hasCrimeHis"/>
<result column="has_crime_his_dictionary_name" property="hasCrimeHisDictionaryName"/>
<result column="crime_info" property="crimeInfo"/>
<result column="help_user_phone" property="helpUserPhone"/>
<result column="full_name" property="fullName"/>
<result column="gender" property="gender"/>
<result column="telephone" property="telephone"/>
<result column="native_place" property="nativePlace"/>
<result column="current_residence" property="currentResidence"/>
</resultMap>
<!-- 新增特殊人群-艾滋病危险人员 -->
<insert id="saveAids" parameterType="map">
INSERT INTO gen_aids(
aids_id,
id_card_number,
infection_route,
help_user_name,
case_category,
treatment_info,
treatment_org,
help_info,
attention_type,
has_crime_his,
crime_info,
help_user_phone,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{aidsId},
#{idCardNumber},
#{infectionRoute},
#{helpUserName},
#{caseCategory},
#{treatmentInfo},
#{treatmentOrg},
#{helpInfo},
#{attentionType},
#{hasCrimeHis},
#{crimeInfo},
#{helpUserPhone},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除特殊人群-艾滋病危险人员 -->
<update id="removeAids" parameterType="map">
UPDATE
gen_aids
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
aids_id IN
<foreach collection="aidsIds" index="index" open="(" separator="," close=")">
#{aidsIds[${index}]}
</foreach>
</update>
<!-- 删除特殊人群-艾滋病危险人员(物理) -->
<update id="deleteAids" parameterType="map">
DELETE FROM
gen_aids
WHERE
aids_id IN
<foreach collection="aidsIds" index="index" open="(" separator="," close=")">
#{aidsIds[${index}]}
</foreach>
</update>
<!-- 修改特殊人群-艾滋病危险人员 -->
<update id="updateAids" parameterType="map">
UPDATE
gen_aids
SET
<if test="infectionRoute != null and infectionRoute != ''">
infection_route = #{infectionRoute},
</if>
<if test="idCardNumber != null and idCardNumber != ''">
id_card_number = #{idCardNumber},
</if>
<if test="helpUserName != null and helpUserName != ''">
help_user_name = #{helpUserName},
</if>
<if test="caseCategory != null and caseCategory != ''">
case_category = #{caseCategory},
</if>
<if test="treatmentInfo != null and treatmentInfo != ''">
treatment_info = #{treatmentInfo},
</if>
<if test="treatmentOrg != null and treatmentOrg != ''">
treatment_org = #{treatmentOrg},
</if>
<if test="helpInfo != null and helpInfo != ''">
help_info = #{helpInfo},
</if>
<if test="attentionType != null and attentionType != ''">
attention_type = #{attentionType},
</if>
<if test="hasCrimeHis != null and hasCrimeHis != ''">
has_crime_his = #{hasCrimeHis},
</if>
<if test="crimeInfo != null and crimeInfo != ''">
crime_info = #{crimeInfo},
</if>
<if test="helpUserPhone != null and helpUserPhone != ''">
help_user_phone = #{helpUserPhone},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
aids_id = #{aidsId}
</update>
<!-- 特殊人群-艾滋病危险人员详情 -->
<select id="getAids" parameterType="map" resultMap="aidsDTO">
SELECT
t1.infection_route,
t1.help_user_name,
t1.case_category,
t1.treatment_info,
t1.treatment_org,
t1.help_info,
t1.attention_type,
t1.has_crime_his,
t1.crime_info,
t1.help_user_phone,
t1.aids_id,
t1.id_card_number,
t2.full_name,
t2.gender,
t2.telephone
FROM
gen_aids t1
LEFT JOIN gen_base_population_info t2 ON t1.id_card_number = t2.id_card_number
WHERE
t1.is_delete = 0
AND t2.is_delete = 0
<if test="aidsId != null and aidsId != ''">
AND t1.aids_id = #{aidsId}
</if>
<if test="idCardNumber != null and idCardNumber != ''">
AND t1.id_card_number = #{idCardNumber}
</if>
</select>
<!-- 特殊人群-艾滋病危险人员列表 -->
<select id="listAids" parameterType="map" resultMap="aidsDTO">
SELECT
t1.infection_route,
t1.help_user_name,
t1.case_category,
t1.treatment_info,
t1.treatment_org,
t1.help_info,
t1.attention_type,
t1.has_crime_his,
t1.crime_info,
t1.help_user_phone,
t1.aids_id,
t1.id_card_number,
t2.full_name,
t2.gender,
t2.telephone,
t2.native_place,
CONCAT(t2.current_residence,t2.current_residence_addr) current_residence
FROM
gen_aids t1
LEFT JOIN gen_base_population_info t2 ON t1.id_card_number = t2.id_card_number
WHERE
t1.is_delete = 0
AND t2.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.id_card_number LIKE CONCAT('%', #{keywords}, '%')
OR
t2.full_name LIKE CONCAT('%', #{keywords}, '%')
<!-- 这里添加其他条件 -->
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="aidsIds != null and aidsIds.size > 0">
AND
t1.aids_id IN
<foreach collection="aidsIds" index="index" open="(" separator="," close=")">
#{aidsIds[${index}]}
</foreach>
</if>
</select>
<!-- 特殊人群-艾滋病危险人员统计 -->
<select id="countAids" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
gen_aids t1
WHERE
t1.is_delete = 0
</select>
</mapper>