<?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.`NAME`,
a.MOBILE,
a.ID_CARD,
a.REMARK,
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 (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 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 != vaccinationCount' >
HAVING vaccinationCount = #{vaccinationCount}
</if>
ORDER BY a.CREATED_TIME DESC
</select>
<!-- 核酸检测关注名单 -->
<select id= "natList" resultType= "com.epmet.dto.result.VaccinationListResultDTO" >
SELECT
a.`NAME`,
a.MOBILE,
a.ID_CARD,
a.REMARK,
a.REASON,
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
WHERE a.DEL_FLAG = 0
AND a.ORG_ID = #{orgId}
AND 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>
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>
</mapper>