<?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.epmet.dao.IcEpidemicSpecialAttentionDao" >
<!-- 取消关注 -->
<update id= "cancelAttention" >
UPDATE ic_epidemic_special_attention
SET UPDATED_TIME = NOW(),
IS_ATTENTION = 0,
del_flag = 1
WHERE del_flag = 0
AND attention_type = #{attentionType}
AND id_card IN (
<foreach collection= "list" item= "l" separator= "," >
#{l}
</foreach>
)
</update>
<!-- 疫苗接种关注名单 -->
<select id= "vaccinationList" resultType= "com.epmet.dto.result.VaccinationListResultDTO" >
SELECT a.id,
a.`NAME`,
a.MOBILE,
a.ID_CARD,
a.reason,
a.REMARK,
b.VILLAGE_ID,
b.BUILD_ID,
b.UNIT_ID,
b.HOME_ID,
IFNULL((SELECT DATE_FORMAT(CREATED_TIME,'%Y-%m-%d %H:%i:%s') FROM ic_notice WHERE DEL_FLAG = '0' AND ORIGIN = #{attentionType} AND ID_CARD = a.ID_CARD ORDER BY CREATED_TIME DESC LIMIT 1),'') AS lastInformTime,
IFNULL(v.vaccinationCount,0) AS vaccinationCount
FROM ic_epidemic_special_attention a
LEFT JOIN ic_resi_user b ON a.id_card = b.id_card AND b.del_flag = '0'
LEFT JOIN (SELECT id_card ,count(1) AS vaccinationCount FROM ic_vaccine WHERE DEL_FLAG = 0 GROUP BY ID_CARD) v ON (v.ID_CARD = a.ID_CARD)
WHERE a.DEL_FLAG = 0
AND a.ORG_ID = #{orgId}
AND a.ATTENTION_TYPE = #{attentionType}
<if test= 'null != name and "" != name' >
AND a.`NAME` LIKE CONCAT('%',#{name},'%')
</if>
<if test= 'null != mobile and "" != mobile' >
AND a.MOBILE LIKE CONCAT('%',#{mobile},'%')
</if>
<if test= 'null != mobile and "" != mobile' >
AND a.ID_CARD LIKE CONCAT('%',#{idCard},'%')
</if>
<if test= 'null != villageId and "" != villageId' >
AND b.village_id = #{villageId}
</if>
<if test= 'null != buildId and "" != buildId' >
AND b.build_id = #{buildId}
</if>
<if test= 'null != unitId and "" != unitId' >
AND b.unit_id = #{unitId}
</if>
<if test= 'null != homeId and "" != homeId' >
AND b.home_id = #{homeId}
</if>
<if test= ' null != vaccinationCount' >
HAVING vaccinationCount = #{vaccinationCount}
</if>
ORDER BY a.CREATED_TIME DESC
</select>
<!-- 核酸检测关注名单 -->
<select id= "natList" resultType= "com.epmet.dto.result.VaccinationListResultDTO" >
SELECT a.id,
a.`NAME`,
a.MOBILE,
a.ID_CARD,
a.REMARK,
a.REASON,
b.VILLAGE_ID,
b.BUILD_ID,
b.UNIT_ID,
b.HOME_ID,
IFNULL((SELECT DATE_FORMAT(CREATED_TIME,'%Y-%m-%d %H:%i:%s') FROM ic_notice WHERE DEL_FLAG = '0' AND ORIGIN = #{attentionType} AND ID_CARD = a.ID_CARD ORDER BY CREATED_TIME DESC LIMIT 1),'') AS lastInformTime
FROM ic_epidemic_special_attention a
LEFT JOIN ic_resi_user b ON a.id_card = b.id_card AND b.del_flag = '0'
WHERE a.DEL_FLAG = 0
AND a.ORG_ID = #{orgId}
AND a.ATTENTION_TYPE = #{attentionType}
<if test= 'null != name and "" != name' >
AND a.`NAME` LIKE CONCAT('%',#{name},'%')
</if>
<if test= 'null != mobile and "" != mobile' >
AND a.MOBILE LIKE CONCAT('%',#{mobile},'%')
</if>
<if test= 'null != mobile and "" != mobile' >
AND a.ID_CARD LIKE CONCAT('%',#{idCard},'%')
</if>
<if test= 'null != reason and "" != reason' >
AND a.REASON LIKE CONCAT('%',#{reason},'%')
</if>
<if test= 'null != remark and "" != remark' >
AND a.REMARK LIKE CONCAT('%',#{remark},'%')
</if>
<if test= 'null != villageId and "" != villageId' >
AND b.village_id = #{villageId}
</if>
<if test= 'null != buildId and "" != buildId' >
AND b.build_id = #{buildId}
</if>
<if test= 'null != unitId and "" != unitId' >
AND b.unit_id = #{unitId}
</if>
<if test= 'null != homeId and "" != homeId' >
AND b.home_id = #{homeId}
</if>
ORDER BY a.CREATED_TIME DESC
</select>
<!-- 查询已经存在的关注 -->
<select id= "getExistList" resultType= "java.lang.String" >
SELECT
ID_CARD
FROM ic_epidemic_special_attention
WHERE DEL_FLAG = 0
AND ATTENTION_TYPE = #{attentionType}
AND ID_CARD IN (
<foreach collection= "list" item= "l" separator= "," >
#{l}
</foreach>
)
</select>
<select id= "getIdCardList" parameterType= "map" resultType= "java.lang.String" >
SELECT
DISTINCT
ID_CARD
FROM
ic_epidemic_special_attention
WHERE
DEL_FLAG = 0
AND IS_ATTENTION = '1'
AND ATTENTION_TYPE = #{attentionType}
AND CUSTOMER_ID=#{customerId}
AND ID_CARD IN (
<foreach collection= "idCardSet" item= "idCard" separator= "," >
#{idCard}
</foreach>
)
</select>
<!-- 关注详情 -->
<select id= "nat" resultType= "com.epmet.dto.result.VaccinationListResultDTO" >
SELECT
a.`NAME`,
a.MOBILE,
a.ID_CARD,
a.REMARK,
a.REASON
FROM ic_epidemic_special_attention a
WHERE a.ID = #{id}
</select>
</mapper>