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

288 lines
9.9 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.floatingpopulation.IFloatingPopulationDao">
<resultMap id="floatingPopulationDTO" type="com.cm.population.pojo.dtos.floatingpopulation.FloatingPopulationDTO">
<id column="floating_population_id" property="floatingPopulationId"/>
<id column="base_id" property="baseId"/>
<result column="card_expire_date" property="cardExpireDate"/>
<result column="residence_type" property="residenceType"/>
<result column="register_date" property="registerDate"/>
<result column="registration_type" property="registrationType"/>
<result column="key_of_follow" property="keyOfFollow"/>
<result column="card_number" property="cardNumber"/>
<result column="inflow_reason" property="inflowReason"/>
<result column="id_card_number" property="idCardNumber"/>
<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="saveFloatingPopulation" parameterType="map" useGeneratedKeys="true" keyProperty="id">
INSERT IGNORE INTO gen_floating_population(
floating_population_id,
base_id,
card_expire_date,
residence_type,
register_date,
registration_type,
key_of_follow,
card_number,
inflow_reason,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) SELECT
#{floatingPopulationId},
#{baseId},
#{cardExpireDate},
#{residenceType},
#{registerDate},
#{registrationType},
#{keyOfFollow},
#{cardNumber},
#{inflowReason},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
FROM
DUAL
WHERE
NOT EXISTS (
SELECT
*
FROM
gen_floating_population
WHERE
base_id = #{baseId}
AND is_delete = 0
)
</insert>
<!-- 批量新增流动人口 -->
<insert id="saveFloatingPopulationList" parameterType="java.util.List">
INSERT IGNORE INTO gen_floating_population(
floating_population_id,
base_id,
card_expire_date,
residence_type,
register_date,
registration_type,
key_of_follow,
card_number,
inflow_reason,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
)
<foreach collection="list" index="index" item="item" separator="union all">
SELECT
#{item.floatingPopulationId},
#{item.baseId},
#{item.cardExpireDate},
#{item.residenceType},
#{item.registerDate},
#{item.registrationType},
#{item.keyOfFollow},
#{item.cardNumber},
#{item.inflowReason},
#{item.creator},
#{item.gmtCreate},
#{item.modifier},
#{item.gmtModified},
#{item.isDelete}
FROM
DUAL
WHERE
NOT EXISTS (
SELECT
*
FROM
gen_floating_population
WHERE
base_id = #{item.baseId}
AND is_delete = 0
)
</foreach>
</insert>
<!-- 删除流动人口 -->
<update id="removeFloatingPopulation" parameterType="map">
UPDATE
gen_floating_population
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
floating_population_id IN
<foreach collection="floatingPopulationIds" index="index" open="(" separator="," close=")">
#{floatingPopulationIds[${index}]}
</foreach>
</update>
<!-- 删除流动人口(物理) -->
<update id="deleteFloatingPopulation" parameterType="map">
DELETE FROM
gen_floating_population
WHERE
floating_population_id IN
<foreach collection="floatingPopulationIds" index="index" open="(" separator="," close=")">
#{floatingPopulationIds[${index}]}
</foreach>
</update>
<!-- 修改流动人口 -->
<update id="updateFloatingPopulation" parameterType="map">
UPDATE
gen_floating_population
SET
<if test="baseId != null and baseId != ''">
base_id = #{baseId},
</if>
<if test="cardExpireDate != null and cardExpireDate != ''">
card_expire_date = #{cardExpireDate},
</if>
<if test="residenceType != null and residenceType != ''">
residence_type = #{residenceType},
</if>
<if test="registerDate != null and registerDate != ''">
register_date = #{registerDate},
</if>
<if test="registrationType != null and registrationType != ''">
registration_type = #{registrationType},
</if>
<if test="keyOfFollow != null and keyOfFollow != ''">
key_of_follow = #{keyOfFollow},
</if>
<if test="cardNumber != null and cardNumber != ''">
card_number = #{cardNumber},
</if>
<if test="inflowReason != null and inflowReason != ''">
inflow_reason = #{inflowReason},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
floating_population_id = #{floatingPopulationId}
</update>
<!-- 流动人口详情 -->
<select id="getFloatingPopulation" parameterType="map" resultMap="floatingPopulationDTO">
SELECT
t1.card_expire_date,
t1.residence_type,
t1.register_date,
t1.registration_type,
t1.key_of_follow,
t1.card_number,
t1.inflow_reason,
t1.floating_population_id,
t1.base_id,
t2.id_card_number
FROM
gen_floating_population t1
LEFT JOIN gen_base_population_info t2 ON t1.base_id = t2.base_population_info_id AND t2.is_delete = 0
WHERE
t1.is_delete = 0
<if test="floatingPopulationId != null and floatingPopulationId != ''">
AND
t1.floating_population_id = #{floatingPopulationId}
</if>
</select>
<!-- 流动人口列表 -->
<select id="listFloatingPopulation" parameterType="map" resultMap="floatingPopulationDTO">
SELECT
t1.card_expire_date,
t1.residence_type,
t1.register_date,
t1.registration_type,
t1.key_of_follow,
t1.card_number,
t1.inflow_reason,
t1.floating_population_id,
t1.base_id,
t2.id_card_number,
t2.full_name,
t2.gender,
t2.telephone,
t2.native_place,
t2.current_residence
FROM
gen_floating_population t1
LEFT JOIN gen_base_population_info t2 ON t1.base_id = t2.base_population_info_id AND t2.is_delete = 0
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.card_number LIKE CONCAT('%', #{keywords}, '%')
OR
t2.id_card_number LIKE CONCAT('%', #{keywords}, '%')
OR
<!-- 全名 -->
t2.full_name LIKE CONCAT('%', #{keywords}, '%')
OR
<!-- 曾用名 -->
t2.name_used_before LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.register_date, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.card_expire_date, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="floatingPopulationIds != null and floatingPopulationIds.size > 0">
AND
t1.floating_population_id IN
<foreach collection="floatingPopulationIds" index="index" open="(" separator="," close=")">
#{floatingPopulationIds[${index}]}
</foreach>
</if>
</select>
<!-- 流动人口统计 -->
<select id="countFloatingPopulation" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
gen_floating_population t1
WHERE
t1.is_delete = 0
</select>
<!-- 通过身份证号码查询信息是否存在 -->
<select id="hasMsg" parameterType="map" resultMap="floatingPopulationDTO">
SELECT
t1.card_expire_date,
t1.residence_type,
t1.register_date,
t1.registration_type,
t1.key_of_follow,
t1.card_number,
t1.inflow_reason,
t1.floating_population_id,
t1.base_id,
t2.id_card_number
FROM
gen_floating_population t1
LEFT JOIN gen_base_population_info t2 ON t1.base_id = t2.base_population_info_id AND t2.is_delete = 0
WHERE
t1.is_delete = 0
AND t2.id_card_number = #{idCardNumber}
LIMIT 0, 1
</select>
</mapper>