btxtgxq-system-population/src/main/resources/mybatis/mapper/addicts/addicts-mapper.xml
2020-12-01 14:40:46 +08:00

240 lines
8.3 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.addicts.IAddictsDao">
<resultMap id="addictsDTO" type="com.cm.population.pojo.dtos.addicts.AddictsDTO">
<id column="addicts_id" property="addictsId"/>
<result column="control_info" property="controlInfo"/>
<result column="crime_info" property="crimeInfo"/>
<result column="discovery_date" property="discoveryDate"/>
<result column="help_user_phone" property="helpUserPhone"/>
<result column="id_card_number" property="idCardNumber"/>
<result column="control_user_name" property="controlUserName"/>
<result column="has_crime_his" property="hasCrimeHis"/>
<result column="has_crime_his_dictionary_name" property="hasCrimeHisDictionaryName"/>
<result column="drug_result" property="drugResult"/>
<result column="drug_result_dictionary_name" property="drugResultDictionaryName"/>
<result column="help_user_name" property="helpUserName"/>
<result column="control_user_phone" property="controlUserPhone"/>
<result column="help_info" property="helpInfo"/>
<result column="drug_reason" property="drugReason"/>
<result column="drug_reason_dictionary_name" property="drugReasonDictionaryName"/>
<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="saveAddicts" parameterType="map">
INSERT INTO gen_addicts(
addicts_id,
control_info,
crime_info,
discovery_date,
help_user_phone,
id_card_number,
control_user_name,
has_crime_his,
drug_result,
help_user_name,
control_user_phone,
help_info,
drug_reason,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{addictsId},
#{controlInfo},
#{crimeInfo},
#{discoveryDate},
#{helpUserPhone},
#{idCardNumber},
#{controlUserName},
#{hasCrimeHis},
#{drugResult},
#{helpUserName},
#{controlUserPhone},
#{helpInfo},
#{drugReason},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除特殊人群-吸毒人员 -->
<update id="removeAddicts" parameterType="map">
UPDATE
gen_addicts
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
addicts_id IN
<foreach collection="addictsIds" index="index" open="(" separator="," close=")">
#{addictsIds[${index}]}
</foreach>
</update>
<!-- 删除特殊人群-吸毒人员(物理) -->
<update id="deleteAddicts" parameterType="map">
DELETE FROM
gen_addicts
WHERE
addicts_id IN
<foreach collection="addictsIds" index="index" open="(" separator="," close=")">
#{addictsIds[${index}]}
</foreach>
</update>
<!-- 修改特殊人群-吸毒人员 -->
<update id="updateAddicts" parameterType="map">
UPDATE
gen_addicts
SET
<if test="controlInfo != null and controlInfo != ''">
control_info = #{controlInfo},
</if>
<if test="crimeInfo != null and crimeInfo != ''">
crime_info = #{crimeInfo},
</if>
<if test="discoveryDate != null and discoveryDate != ''">
discovery_date = #{discoveryDate},
</if>
<if test="helpUserPhone != null and helpUserPhone != ''">
help_user_phone = #{helpUserPhone},
</if>
<if test="idCardNumber != null and idCardNumber != ''">
id_card_number = #{idCardNumber},
</if>
<if test="controlUserName != null and controlUserName != ''">
control_user_name = #{controlUserName},
</if>
<if test="hasCrimeHis != null and hasCrimeHis != ''">
has_crime_his = #{hasCrimeHis},
</if>
<if test="drugResult != null and drugResult != ''">
drug_result = #{drugResult},
</if>
<if test="helpUserName != null and helpUserName != ''">
help_user_name = #{helpUserName},
</if>
<if test="controlUserPhone != null and controlUserPhone != ''">
control_user_phone = #{controlUserPhone},
</if>
<if test="helpInfo != null and helpInfo != ''">
help_info = #{helpInfo},
</if>
<if test="drugReason != null and drugReason != ''">
drug_reason = #{drugReason},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
addicts_id = #{addictsId}
</update>
<!-- 特殊人群-吸毒人员详情 -->
<select id="getAddicts" parameterType="map" resultMap="addictsDTO">
SELECT
t1.control_info,
t1.crime_info,
t1.discovery_date,
t1.help_user_phone,
t1.id_card_number,
t1.control_user_name,
t1.has_crime_his,
t1.drug_result,
t1.help_user_name,
t1.control_user_phone,
t1.help_info,
t1.drug_reason,
t1.addicts_id,
t2.full_name,
t2.gender,
t2.telephone
FROM
gen_addicts 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="addictsId != null and addictsId != ''">
AND t1.addicts_id = #{addictsId}
</if>
<if test="idCardNumber != null and idCardNumber != ''">
AND t1.id_card_number = #{idCardNumber}
</if>
</select>
<!-- 特殊人群-吸毒人员列表 -->
<select id="listAddicts" parameterType="map" resultMap="addictsDTO">
SELECT
t1.control_info,
t1.crime_info,
t1.discovery_date,
t1.help_user_phone,
t1.id_card_number,
t1.control_user_name,
t1.has_crime_his,
t1.drug_result,
t1.help_user_name,
t1.control_user_phone,
t1.help_info,
t1.drug_reason,
t1.addicts_id,
t2.full_name,
t2.gender,
t2.telephone,
t2.native_place,
CONCAT(t2.current_residence,t2.current_residence_addr) current_residence
FROM
gen_addicts 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="addictsIds != null and addictsIds.size > 0">
AND
t1.addicts_id IN
<foreach collection="addictsIds" index="index" open="(" separator="," close=")">
#{addictsIds[${index}]}
</foreach>
</if>
</select>
<!-- 特殊人群-吸毒人员统计 -->
<select id="countAddicts" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
gen_addicts t1
WHERE
t1.is_delete = 0
</select>
</mapper>