移风店镇项目初始化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

247 lines
8.0 KiB

<?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.IcVaccineDao">
<select id="getMyNatList" resultType="com.epmet.dto.result.MyNatListResultDTO">
SELECT
id icNatId,
user_id userId,
user_type userType,
`name` `name`,
mobile mobile,
id_card idCard,
nat_time natTime,
nat_result natResult,
nat_address natAddress,
file_name fileName,
attachment_url attachmentUrl,
created_time reportTime
FROM
ic_nat
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND (
CREATED_BY = #{userId}
<if test='null != idCard and "" != idCard'>
OR id_card = #{idCard}
</if>
)
ORDER BY nat_time DESC
</select>
<select id="getIcVaccineList" resultType="com.epmet.dto.result.IcVaccineListResultDTO">
SELECT
a.IC_VACCINE_ID AS vaccineId,
a.agency_id,
a.user_type,
a.is_local_resi_user isLocalResiUser,
b.`name`,
b.mobile,
b.id_card,
b.INOCULATE_TIME,
b.INOCULATE_ADDRESS,
b.MANUFACTURER,
b.user_id
FROM ic_vaccine_relation a
INNER JOIN ic_vaccine b ON a.IC_VACCINE_ID = b.ID AND b.DEL_FLAG = '0'
WHERE a.DEL_FLAG = '0'
AND a.customer_id = #{customerId}
AND a.pids like concat('%', #{agencyId}, '%')
<if test='null != name and "" != name'>
AND b.name like concat('%', #{name}, '%')
</if>
<if test='null != mobile and "" != mobile'>
AND b.mobile = #{mobile}
</if>
<if test='null != idCard and "" != idCard'>
AND b.id_card = #{idCard}
</if>
<if test='null != startTime and "" != startTime'>
AND b.INOCULATE_TIME <![CDATA[ >= ]]> #{startTime}
</if>
<if test='null != endTime and "" != endTime'>
AND b.INOCULATE_TIME <![CDATA[ <= ]]> #{endTime}
</if>
<if test='isResiUser != null and isResiUser != ""'>
AND a.is_local_resi_user = #{isResiUser}
</if>
ORDER BY b.INOCULATE_TIME DESC, b.id ASC
</select>
<select id="getCustomerIcVaccineList" resultType="com.epmet.dto.result.IcVaccineListResultDTO">
SELECT
id vaccineId,
is_resi_user isResiUser,
user_id userId,
user_type userType,
`name` `name`,
mobile mobile,
id_card idCard,
INOCULATE_TIME ,
INOCULATE_ADDRESS,
MANUFACTURER
FROM ic_vaccine
WHERE del_flag = '0'
AND customer_id = #{customerId}
<if test='null != name and "" != name'>
AND name like concat('%', #{name}, '%')
</if>
<if test='null != mobile and "" != mobile'>
AND mobile = #{mobile}
</if>
<if test='null != idCard and "" != idCard'>
AND id_card = #{idCard}
</if>
<if test='null != startTime and "" != startTime'>
AND INOCULATE_TIME <![CDATA[ >= ]]> #{startTime}
</if>
<if test='null != endTime and "" != endTime'>
AND INOCULATE_TIME <![CDATA[ <= ]]> #{endTime}
</if>
ORDER BY INOCULATE_TIME DESC, id ASC
</select>
<select id="getNatDTO" resultType="com.epmet.dto.IcNatDTO">
SELECT
id,
user_id,
user_type,
`name`,
mobile,
id_card,
nat_time,
nat_result,
nat_address
FROM
ic_nat
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND id_card = #{idCard}
AND DATE_FORMAT(nat_time, '%Y-%m-%d %h:%i') = DATE_FORMAT(#{natTime}, '%Y-%m-%d %h:%i')
<if test='null != natResult and "" != natResult'>
AND nat_result = #{natResult}
</if>
<if test='null != icNatId and "" != icNatId'>
AND id != #{icNatId}
</if>
LIMIT 1
</select>
<select id="getVaccineDTO" resultType="com.epmet.dto.IcVaccineDTO">
SELECT
id,
is_resi_user,
user_type,
`name`,
mobile,
id_card,
is_resi_user,
inoculate_time,
inoculate_time,
manufacturer
FROM
ic_vaccine
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND id_card = #{idCard}
AND DATE_FORMAT(inoculate_time, '%Y-%m-%d %h:%i') = DATE_FORMAT(#{inoculateTime}, '%Y-%m-%d %h:%i')
<if test='null != icVaccineId and "" != icVaccineId'>
AND id != #{icVaccineId}
</if>
LIMIT 1
</select>
<delete id="delById">
DELETE FROM ic_vaccine WHERE id = #{icVaccineId}
</delete>
<update id="updateIsResiFlag">
UPDATE ic_nat m,
(
SELECT if(DEL_FLAG,0,1) resiFlag, ID_CARD FROM ic_resi_user
WHERE
1=1
<if test="icResiUserId != null and icResiUserId != ''">
AND ID = #{icResiUserId}
</if>
AND CUSTOMER_ID = #{customerId}
AND DEL_FLAG = '0'
) t
SET m.IS_RESI_USER = t.resiFlag
WHERE
m.ID_CARD = t.ID_CARD
AND m.DEL_FLAG = '0'
</update>
<select id="getVaccineListByIdCard" resultType="com.epmet.entity.IcVaccineEntity">
select
*
from ic_vaccine
where DEL_FLAG = '0'
and ID_CARD = #{idCard}
and DATE_FORMAT( INOCULATE_TIME, '%Y-%m-%d' ) = #{time}
</select>
<select id="initVaccineLocal" resultType="com.epmet.dto.result.RelationAndNatResultDTO">
SELECT
r.id AS relationId,
i.id AS natId,
i.id_card,
r.pids AS staffAgencyIdPath
FROM ic_vaccine_relation r
INNER JOIN ic_vaccine i ON i.ID = r.ic_vaccine_id AND i.del_flag = 0
WHERE r.del_flag = 0
AND r.user_type = 'import'
</select>
<update id="updateRelation">
UPDATE ic_vaccine_relation
<trim prefix="set" suffixOverrides=",">
<trim prefix="is_local_resi_user =(case" suffix="end),">
<foreach collection="list" item="l">
when ID = #{l.relationId} then #{l.isLocalResiUser}
</foreach>
</trim>
updated_time = NOW()
</trim>
WHERE ID IN(
<foreach collection="list" item="l" separator=",">
#{l.relationId}
</foreach>)
</update>
<update id="updateRelationOther">
UPDATE ic_vaccine_relation a
INNER JOIN ic_vaccine b ON a.ic_vaccine_id = b.id
set a.is_local_resi_user = #{isLocalResiUser},
a.updated_time = NOW()
where a.user_type != 'import'
<if test="isLocalResiUser == '1'">
and b.USER_ID is not null
and b.USER_ID != ''
</if>
<if test="isLocalResiUser == '0'">
and (b.USER_ID is null or b.USER_ID ='')
</if>
</update>
<!-- 根据 身份证 查询库里存在的 -->
<select id="getExistVaccine" resultType="com.epmet.dto.YTVaccineListDTO">
SELECT
ID_CARD,
INOCULATE_TIME
FROM ic_vaccine
WHERE DEL_FLAG = '0'
and ID_CARD IN
<foreach collection="list" item="v" separator="," open="(" close=")">
#{v.cardno}
</foreach>
<!--AND (-->
<!-- <foreach collection="list" item="l" separator=" OR ">-->
<!-- (ID_CARD = #{l.cardno} AND INOCULATE_TIME = #{l.inoculateDate})-->
<!-- </foreach>-->
<!-- )-->
</select>
</mapper>