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
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}
AND a.ATTENTION_TYPE = #{attentionType}
<iftest='null != name and "" != name'>
AND a.`NAME` LIKE CONCAT('%',#{name},'%')
</if>
@ -42,6 +47,18 @@
<iftest='null != mobile and "" != mobile'>
AND a.ID_CARD LIKE CONCAT('%',#{idCard},'%')
</if>
<iftest='null != villageId and "" != villageId'>
AND b.village_id = #{villageId}
</if>
<iftest='null != buildId and "" != buildId'>
AND b.build_id = #{buildId}
</if>
<iftest='null != unitId and "" != unitId'>
AND b.unit_id = #{unitId}
</if>
<iftest='null != homeId and "" != homeId'>
AND b.home_id = #{homeId}
</if>
<iftest=' null != vaccinationCount'>
HAVING vaccinationCount = #{vaccinationCount}
</if>
@ -56,11 +73,16 @@
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