356 lines
12 KiB
XML
356 lines
12 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.keyteenagers.IKeyTeenagersDao">
|
|
|
|
<resultMap id="keyTeenagersDTO" type="com.cm.population.pojo.dtos.keyteenagers.KeyTeenagersDTO">
|
|
<id column="key_teenagers_id" property="keyTeenagersId"/>
|
|
<result column="id_card_number" property="idCardNumber"/>
|
|
<result column="relationship_with_guardian" property="relationshipWithGuardian"/>
|
|
<result column="relationship_with_guardian_name" property="relationshipWithGuardianName"/>
|
|
<result column="family_situation" property="familySituation"/>
|
|
<result column="person_type" property="personType"/>
|
|
<result column="guardian_card" property="guardianCard"/>
|
|
<result column="helping_situation" property="helpingSituation"/>
|
|
<result column="crime_situation" property="crimeSituation"/>
|
|
<result column="helper_name" property="helperName"/>
|
|
<result column="helping_method" property="helpingMethod"/>
|
|
<result column="guardian_name" property="guardianName"/>
|
|
<result column="is_crime" property="isCrime"/>
|
|
<result column="helper_phone" property="helperPhone"/>
|
|
<result column="base_id" property="baseId"/>
|
|
<result column="guardian_address" property="guardianAddress"/>
|
|
<result column="guardian_phone" property="guardianPhone"/>
|
|
<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="saveKeyTeenagers" parameterType="map" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT IGNORE INTO gen_key_teenagers(
|
|
key_teenagers_id,
|
|
relationship_with_guardian,
|
|
family_situation,
|
|
person_type,
|
|
guardian_card,
|
|
helping_situation,
|
|
crime_situation,
|
|
helper_name,
|
|
helping_method,
|
|
guardian_name,
|
|
is_crime,
|
|
helper_phone,
|
|
base_id,
|
|
guardian_address,
|
|
guardian_phone,
|
|
creator,
|
|
gmt_create,
|
|
modifier,
|
|
gmt_modified,
|
|
is_delete
|
|
) SELECT
|
|
#{keyTeenagersId},
|
|
#{relationshipWithGuardian},
|
|
#{familySituation},
|
|
#{personType},
|
|
#{guardianCard},
|
|
#{helpingSituation},
|
|
#{crimeSituation},
|
|
#{helperName},
|
|
#{helpingMethod},
|
|
#{guardianName},
|
|
#{isCrime},
|
|
#{helperPhone},
|
|
#{baseId},
|
|
#{guardianAddress},
|
|
#{guardianPhone},
|
|
#{creator},
|
|
#{gmtCreate},
|
|
#{modifier},
|
|
#{gmtModified},
|
|
#{isDelete}
|
|
FROM
|
|
DUAL
|
|
WHERE
|
|
NOT EXISTS (
|
|
SELECT
|
|
*
|
|
FROM
|
|
gen_key_teenagers
|
|
WHERE
|
|
base_id = #{baseId}
|
|
AND is_delete = 0
|
|
)
|
|
</insert>
|
|
|
|
<!-- 批量新增重点青少年 -->
|
|
<insert id="saveKeyTeenagersList" parameterType="java.util.List">
|
|
INSERT IGNORE INTO gen_key_teenagers(
|
|
key_teenagers_id,
|
|
relationship_with_guardian,
|
|
family_situation,
|
|
person_type,
|
|
guardian_card,
|
|
helping_situation,
|
|
crime_situation,
|
|
helper_name,
|
|
helping_method,
|
|
guardian_name,
|
|
is_crime,
|
|
helper_phone,
|
|
base_id,
|
|
guardian_address,
|
|
guardian_phone,
|
|
creator,
|
|
gmt_create,
|
|
modifier,
|
|
gmt_modified,
|
|
is_delete
|
|
)
|
|
<foreach collection="list" index="index" item="item" separator="union all">
|
|
SELECT
|
|
#{item.keyTeenagersId},
|
|
#{item.relationshipWithGuardian},
|
|
#{item.familySituation},
|
|
#{item.personType},
|
|
#{item.guardianCard},
|
|
#{item.helpingSituation},
|
|
#{item.crimeSituation},
|
|
#{item.helperName},
|
|
#{item.helpingMethod},
|
|
#{item.guardianName},
|
|
#{item.isCrime},
|
|
#{item.helperPhone},
|
|
#{item.baseId},
|
|
#{item.guardianAddress},
|
|
#{item.guardianPhone},
|
|
#{item.creator},
|
|
#{item.gmtCreate},
|
|
#{item.modifier},
|
|
#{item.gmtModified},
|
|
#{item.isDelete}
|
|
FROM
|
|
DUAL
|
|
WHERE
|
|
NOT EXISTS (
|
|
SELECT
|
|
*
|
|
FROM
|
|
gen_key_teenagers
|
|
WHERE
|
|
base_id = #{item.baseId}
|
|
AND is_delete = 0
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 删除重点青少年 -->
|
|
<update id="removeKeyTeenagers" parameterType="map">
|
|
UPDATE
|
|
gen_key_teenagers
|
|
SET
|
|
is_delete = 1,
|
|
modifier = #{modifier},
|
|
gmt_modified = #{gmtModified}
|
|
WHERE
|
|
key_teenagers_id IN
|
|
<foreach collection="keyTeenagersIds" index="index" open="(" separator="," close=")">
|
|
#{keyTeenagersIds[${index}]}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 删除重点青少年(物理) -->
|
|
<update id="deleteKeyTeenagers" parameterType="map">
|
|
DELETE FROM
|
|
gen_key_teenagers
|
|
WHERE
|
|
key_teenagers_id IN
|
|
<foreach collection="keyTeenagersIds" index="index" open="(" separator="," close=")">
|
|
#{keyTeenagersIds[${index}]}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 修改重点青少年 -->
|
|
<update id="updateKeyTeenagers" parameterType="map">
|
|
UPDATE
|
|
gen_key_teenagers
|
|
SET
|
|
<if test="relationshipWithGuardian != null and relationshipWithGuardian != ''">
|
|
relationship_with_guardian = #{relationshipWithGuardian},
|
|
</if>
|
|
<if test="familySituation != null and familySituation != ''">
|
|
family_situation = #{familySituation},
|
|
</if>
|
|
<if test="personType != null and personType != ''">
|
|
person_type = #{personType},
|
|
</if>
|
|
<if test="guardianCard != null and guardianCard != ''">
|
|
guardian_card = #{guardianCard},
|
|
</if>
|
|
<if test="helpingSituation != null and helpingSituation != ''">
|
|
helping_situation = #{helpingSituation},
|
|
</if>
|
|
<if test="crimeSituation != null and crimeSituation != ''">
|
|
crime_situation = #{crimeSituation},
|
|
</if>
|
|
<if test="helperName != null and helperName != ''">
|
|
helper_name = #{helperName},
|
|
</if>
|
|
<if test="helpingMethod != null and helpingMethod != ''">
|
|
helping_method = #{helpingMethod},
|
|
</if>
|
|
<if test="guardianName != null and guardianName != ''">
|
|
guardian_name = #{guardianName},
|
|
</if>
|
|
<if test="isCrime != null and isCrime != ''">
|
|
is_crime = #{isCrime},
|
|
</if>
|
|
<if test="helperPhone != null and helperPhone != ''">
|
|
helper_phone = #{helperPhone},
|
|
</if>
|
|
<if test="baseId != null and baseId != ''">
|
|
base_id = #{baseId},
|
|
</if>
|
|
<if test="guardianAddress != null and guardianAddress != ''">
|
|
guardian_address = #{guardianAddress},
|
|
</if>
|
|
<if test="guardianPhone != null and guardianPhone != ''">
|
|
guardian_phone = #{guardianPhone},
|
|
</if>
|
|
modifier = #{modifier},
|
|
gmt_modified = #{gmtModified}
|
|
WHERE
|
|
key_teenagers_id = #{keyTeenagersId}
|
|
</update>
|
|
|
|
<!-- 重点青少年详情 -->
|
|
<select id="getKeyTeenagers" parameterType="map" resultMap="keyTeenagersDTO">
|
|
SELECT
|
|
t1.relationship_with_guardian,
|
|
t1.family_situation,
|
|
t1.person_type,
|
|
t1.guardian_card,
|
|
t1.helping_situation,
|
|
t1.crime_situation,
|
|
t1.helper_name,
|
|
t1.helping_method,
|
|
t1.guardian_name,
|
|
t1.is_crime,
|
|
t1.helper_phone,
|
|
t1.base_id,
|
|
t1.guardian_address,
|
|
t1.guardian_phone,
|
|
t1.key_teenagers_id,
|
|
t2.id_card_number
|
|
FROM
|
|
gen_key_teenagers 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="keyTeenagersId != null and keyTeenagersId != ''">
|
|
AND
|
|
t1.key_teenagers_id = #{keyTeenagersId}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 重点青少年列表 -->
|
|
<select id="listKeyTeenagers" parameterType="map" resultMap="keyTeenagersDTO">
|
|
SELECT
|
|
t1.relationship_with_guardian,
|
|
t1.family_situation,
|
|
t1.person_type,
|
|
t1.guardian_card,
|
|
t1.helping_situation,
|
|
t1.crime_situation,
|
|
t1.helper_name,
|
|
t1.helping_method,
|
|
t1.guardian_name,
|
|
t1.is_crime,
|
|
t1.helper_phone,
|
|
t1.base_id,
|
|
t1.guardian_address,
|
|
t1.guardian_phone,
|
|
t1.key_teenagers_id,
|
|
t2.full_name,
|
|
t2.gender,
|
|
t2.telephone,
|
|
t2.native_place,
|
|
t2.current_residence
|
|
FROM
|
|
gen_key_teenagers 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.helper_name LIKE CONCAT('%', #{keywords}, '%')
|
|
OR
|
|
t1.guardian_name 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.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''">
|
|
AND
|
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
|
</if>
|
|
<if test="keyTeenagersIds != null and keyTeenagersIds.size > 0">
|
|
AND
|
|
t1.key_teenagers_id IN
|
|
<foreach collection="keyTeenagersIds" index="index" open="(" separator="," close=")">
|
|
#{keyTeenagersIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 重点青少年统计 -->
|
|
<select id="countKeyTeenagers" parameterType="map" resultType="Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
gen_key_teenagers t1
|
|
WHERE
|
|
t1.is_delete = 0
|
|
</select>
|
|
|
|
<!-- 重点青少年详情 -->
|
|
<select id="hasMsg" parameterType="map" resultMap="keyTeenagersDTO">
|
|
SELECT
|
|
t1.relationship_with_guardian,
|
|
t1.family_situation,
|
|
t1.person_type,
|
|
t1.guardian_card,
|
|
t1.helping_situation,
|
|
t1.crime_situation,
|
|
t1.helper_name,
|
|
t1.helping_method,
|
|
t1.guardian_name,
|
|
t1.is_crime,
|
|
t1.helper_phone,
|
|
t1.base_id,
|
|
t1.guardian_address,
|
|
t1.guardian_phone,
|
|
t1.key_teenagers_id,
|
|
t2.id_card_number
|
|
FROM
|
|
gen_key_teenagers 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> |