<?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.boman.web.core.mapper.VaccineInfoMapper">
    
    <resultMap type="com.boman.domain.VaccineInfoOperation" id="VaccineInfoResult">
        <result property="id"    column="id"    />
        <result property="villageTowns"    column="village_towns" />
        <result property="village"    column="village"    />
        <result property="villagerGroup"    column="villager_group" />
        <result property="age"    column="age" />
        <result property="houseType"    column="house_type"  />
        <result property="domicile"    column="domicile"   />
        <result property="province"    column="province"  />
        <result property="city"    column="city"  />
        <result property="region"    column="region"  />
        <result property="vaccineName"    column="vaccine_name"  />
        <result property="residenceTown"    column="residence_town"  />
        <result property="residenceVillage"    column="residence_village"  />
        <result property="userName"    column="user_name"  />
        <result property="gender"    column="gender"  />
        <result property="idCard"    column="id_card"  />
        <result property="phoneNum"    column="phone_num"  />
        <result property="keyIndustries"    column="key_industries" />
        <result property="isVaccination"    column="is_vaccination"  />
        <result property="contraindication"    column="contraindication"    />
        <result property="suspend"    column="suspend"    />
        <result property="shouldBe"    column="should_be"    />
        <result property="other"    column="other"    />
        <result property="remark"    column="remark"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="code"    column="code"    />
        <result property="birthday"    column="birthday"    />
        <result property="workUnit"    column="work_unit"    />
        <result property="crowdClassification"    column="crowd_classification"    />
        <result property="manufacturer"    column="manufacturer"    />
        <result property="nowIn"    column="now_in"    />
        <result property="url"    column="url"    />
        <result property="jici"     column="jici"      />
        <result property="suspendUrl"    column="suspend_url"    />
        <result property="otherUrl"    column="other_url"    />
        <result property="shouldSlow"    column="should_slow"    />
        <result property="vaccinationTime"    column="vaccination_time"    />
        <result property="progress"    column="progress"    />
        <result property="deptId"    column="dept_id"    />
        <result property="rlr"    column="rlr"    />
        <result property="yhzgx"    column="yhzgx"    />
        <result property="deleteReason"    column="delete_reason"    />
        <collection  property="vaccineInfoUserList"   javaType="java.util.List"        resultMap="VaccineInfoUser" />
    </resultMap>

    <resultMap id="VaccineInfoUser" type="com.boman.domain.VaccineInfoUser">
        <id     property="id"       column="id_user"        />
        <result property="idCard"     column="id_card_user"      />
        <result property="vaccineName"      column="vaccine_name_user"       />
        <result property="jici"     column="jici_user"      />
        <result property="vaccinationTime"    column="vaccination_time_user"    />
        <result property="vaccinationPlace"    column="vaccination_place_user"    />
        <result property="progress"    column="progress_user"    />
        <result property="url"    column="url_user"    />
        <result property="status"    column="status_user"    />
    </resultMap>

    <sql id="selectVaccineInfoVo">
        select vi.id, vi.village_towns, vi.village, vi.villager_group,vi.age, vi.house_type, vi.domicile, vi.province, vi.city,
        vi.region, vi.user_name, vi.gender, vi.id_card, vi.phone_num, vi.key_industries, vi.is_vaccination, vi.vaccine_name, vi.jici,
        vi.vaccination_time, vi.vaccination_place, vi.contraindication, vi.suspend,vi.suspend_url,vi.other_url,vi.vaccination_time,
        vi.should_be, vi.other, vi.progress, vi.remark, vi.status, vi.create_by, vi.create_time, vi.update_by, vi.update_time,
               vi.is_del,vi.code,vi.birthday,vi.work_unit,vi.crowd_classification,vi.manufacturer,vi.now_in,vi.url,vi.dept_id,
               vi.residence_town as residenceTown, vi.residence_village as residenceVillage,
               viu.id as id_user,viu.id_card as id_card_user,viu.vaccine_name as vaccine_name_user,viu.jici as jici_user,viu.vaccination_time as vaccination_time_user,
               viu.vaccination_place as vaccination_place_user,viu.progress as progress_user,viu.status as status_user,viu.url as url_user
               from vaccine_info vi left join vaccine_info_user viu
               on vi.id_card = viu.id_card and viu.is_del = 'N'
    </sql>

    <select id="selectVaccineInfoList"  resultMap="VaccineInfoResult">
        select vi.id, vi.village_towns, vi.village, vi.villager_group,vi.age, vi.house_type, vi.domicile, vi.province, vi.city,vi.should_slow,
        vi.region, vi.user_name, vi.gender, vi.id_card, vi.phone_num, vi.key_industries, vi.is_vaccination, vi.vaccine_name, vi.jici,
        vi.vaccination_time, vi.vaccination_place, vi.contraindication, vi.suspend,vi.suspend_url,vi.other_url,vi.vaccination_time,
        vi.should_be, vi.other, vi.progress, vi.remark, vi.status, vi.create_by, vi.create_time, vi.update_by, vi.update_time,
        vi.is_del,vi.code,vi.birthday,vi.work_unit,vi.crowd_classification,vi.manufacturer,vi.now_in,vi.url,vi.dept_id from vaccine_info vi
        <where>
            vi.is_del = 'N'
            <if test="villageTowns != null  and villageTowns != ''">
                and vi.village_towns = #{villageTowns}
            </if>
            <if test="village != null  and village != ''"> and vi.village = #{village}</if>
            <if test="villagerGroup != null  and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
            <if test="houseType != null  and houseType != ''"> and vi.house_type = #{houseType}</if>
            <if test="domicile != null  and domicile != ''"> and vi.domicile = #{domicile}</if>
            <if test="province != null  and province != ''"> and vi.province = #{province}</if>
            <if test="city != null  and city != ''"> and vi.city = #{city}</if>
            <if test="jici != null  and jici != ''"> and vi.jici &lt;= #{jici}</if>
            <if test="vaccineName != null  and vaccineName != ''"> and vi.vaccine_name like concat('%', #{vaccineName}, '%')</if>
            <if test="vaccinationTime != null "> and DATE_FORMAT(vi.vaccination_time,'%Y-%m-%d') = DATE_FORMAT(#{vaccinationTime},'%Y-%m-%d')</if>
            <if test="region != null  and region != ''"> and vi.region = #{region}</if>
            <if test="userName != null  and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>
            <if test="gender != null  and gender != ''"> and vi.gender = #{gender}</if>
            <if test="idCard != null  and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
            <if test="phoneNum != null  and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
            <if test="keyIndustries != null  and keyIndustries != ''"> and vi.key_industries = #{keyIndustries}</if>
            <if test="isVaccination != null  and isVaccination != ''"> and vi.is_vaccination = #{isVaccination}</if>
            <if test="params.startAge != null  and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
            <if test="params.endAge != null  and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>
            <if test="contraindication != null  and contraindication != ''"> and vi.contraindication = #{contraindication}</if>
            <if test="suspend != null  and suspend != ''"> and vi.suspend = #{suspend}</if>
            <if test="shouldBe != null  and shouldBe != ''"> and vi.should_be = #{shouldBe}</if>
            <if test="other != null  and other != ''"> and vi.other = #{other}</if>
            <if test="status != null  and status != ''"> and vi.status = #{status}</if>
            <if test="code != null  and code != ''"> and vi.code = #{code}</if>
            <if test="birthday != null  and birthday != ''"> and vi.birthday = #{birthday}</if>
            <if test="workUnit != null  and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
            <if test="crowdClassification != null  and crowdClassification != ''"> and vi.crowd_classification = #{crowdClassification}</if>
            <if test="manufacturer != null  and manufacturer != ''"> and vi.manufacturer = #{manufacturer}</if>
            <if test="nowIn != null  and nowIn != ''"> and vi.now_in = #{nowIn}</if>
            <if test="shouldSlow != null and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
            <if test="createTime != null and createTime != ''"> and vi.create_time &gt;= #{startTime}</if>
            <if test="endTime != null and endTime != ''"> and vi.create_time &lt;= #{endTime}</if>
            <if test="shouldSlow != null  and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
            <if test="idCardS != null  and idCardS.size() > 0">
             and vi.id_card in
            <foreach item="idCard" collection="idCardS" open="(" separator="," close=")">
                #{idCard}
            </foreach>
            </if>
            <if test="deptIdList != null  and deptIdList.size() > 0">
                and vi.dept_id in
                <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
        </where>
        order by vi.create_time DESC ,vi.vaccination_time DESC
    </select>

    <select id="listByXz"  resultMap="VaccineInfoResult">
        select vi.id, vi.create_time, vi.update_time, vi.is_del, vi.update_by, vi.user_name, vi.phone_num, vi.id_card
             , vi.gender, vi.province, vi.city, vi.region, vi.now_in, vi.house_type, vi.update_by, vi.code
        from vaccine_info vi
        where vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}
        <if test="userName != null  and userName != ''">
            and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
        </if>
        <if test="villageTowns != null  and villageTowns != ''">
            and vi.village_towns = #{villageTowns}
        </if>
        <if test="village != null  and village != ''"> and vi.village = #{village}</if>
        <if test="villagerGroup != null  and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
        <if test="houseType != null  and houseType != ''"> and vi.house_type = #{houseType}</if>
        <if test="domicile != null  and domicile != ''"> and vi.domicile = #{domicile}</if>
        <if test="province != null  and province != ''"> and vi.province = #{province}</if>
        <if test="city != null  and city != ''"> and vi.city = #{city}</if>
        <if test="jici != null  and jici != ''"> and vi.jici &lt;= #{jici}</if>
        <if test="vaccineName != null  and vaccineName != ''"> and vi.vaccine_name like concat('%', #{vaccineName}, '%')</if>
        <if test="vaccinationTime != null "> and DATE_FORMAT(vi.vaccination_time,'%Y-%m-%d') = DATE_FORMAT(#{vaccinationTime},'%Y-%m-%d')</if>
        <if test="region != null  and region != ''"> and vi.region = #{region}</if>
<!--        <if test="userName != null  and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>-->
        <if test="gender != null  and gender != ''"> and vi.gender = #{gender}</if>
        <if test="idCard != null  and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
        <if test="phoneNum != null  and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
        <if test="keyIndustries != null  and keyIndustries != ''"> and vi.key_industries = #{keyIndustries}</if>
        <if test="isVaccination != null  and isVaccination != ''"> and vi.is_vaccination = #{isVaccination}</if>
        <if test="params.startAge != null  and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
        <if test="params.endAge != null  and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>
        <if test="contraindication != null  and contraindication != ''"> and vi.contraindication = #{contraindication}</if>
        <if test="suspend != null  and suspend != ''"> and vi.suspend = #{suspend}</if>
        <if test="shouldBe != null  and shouldBe != ''"> and vi.should_be = #{shouldBe}</if>
        <if test="other != null  and other != ''"> and vi.other = #{other}</if>
        <if test="status != null  and status != ''"> and vi.status = #{status}</if>
        <if test="code != null  and code != ''"> and vi.code = #{code}</if>
        <if test="birthday != null  and birthday != ''"> and vi.birthday = #{birthday}</if>
        <if test="workUnit != null  and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
        <if test="crowdClassification != null  and crowdClassification != ''"> and vi.crowd_classification = #{crowdClassification}</if>
        <if test="manufacturer != null  and manufacturer != ''"> and vi.manufacturer = #{manufacturer}</if>
        <if test="nowIn != null  and nowIn != ''"> and vi.now_in = #{nowIn}</if>
        <if test="shouldSlow != null and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="createTime != null and createTime != ''"> and vi.create_time &gt;= #{startTime}</if>
        <if test="endTime != null and endTime != ''"> and vi.create_time &lt;= #{endTime}</if>
        <if test="shouldSlow != null  and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="idCardS != null  and idCardS.size() > 0">
            and vi.id_card in
            <foreach item="idCard" collection="idCardS" open="(" separator="," close=")">
                #{idCard}
            </foreach>
        </if>

        <if test="deptIdList != null  and deptIdList.size() > 0">
            and vi.dept_id in
            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                #{deptId}
            </foreach>
        </if>
    </select>

    <select id="countByXz" resultType="int">
        select count(1)
        from vaccine_info vi
        where vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}
        <if test="villageTowns != null  and villageTowns != ''">
            and vi.village_towns = #{villageTowns}
        </if>
        <if test="village != null  and village != ''"> and vi.village = #{village}</if>
        <if test="villagerGroup != null  and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
        <if test="houseType != null  and houseType != ''"> and vi.house_type = #{houseType}</if>
        <if test="domicile != null  and domicile != ''"> and vi.domicile = #{domicile}</if>
        <if test="province != null  and province != ''"> and vi.province = #{province}</if>
        <if test="city != null  and city != ''"> and vi.city = #{city}</if>
        <if test="jici != null  and jici != ''"> and vi.jici &lt;= #{jici}</if>
        <if test="vaccineName != null  and vaccineName != ''"> and vi.vaccine_name like concat('%', #{vaccineName}, '%')</if>
        <if test="vaccinationTime != null "> and DATE_FORMAT(vi.vaccination_time,'%Y-%m-%d') = DATE_FORMAT(#{vaccinationTime},'%Y-%m-%d')</if>
        <if test="region != null  and region != ''"> and vi.region = #{region}</if>
        <if test="userName != null  and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>
        <if test="gender != null  and gender != ''"> and vi.gender = #{gender}</if>
        <if test="idCard != null  and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
        <if test="phoneNum != null  and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
        <if test="keyIndustries != null  and keyIndustries != ''"> and vi.key_industries = #{keyIndustries}</if>
        <if test="isVaccination != null  and isVaccination != ''"> and vi.is_vaccination = #{isVaccination}</if>
        <if test="params.startAge != null  and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
        <if test="params.endAge != null  and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>
        <if test="contraindication != null  and contraindication != ''"> and vi.contraindication = #{contraindication}</if>
        <if test="suspend != null  and suspend != ''"> and vi.suspend = #{suspend}</if>
        <if test="shouldBe != null  and shouldBe != ''"> and vi.should_be = #{shouldBe}</if>
        <if test="other != null  and other != ''"> and vi.other = #{other}</if>
        <if test="status != null  and status != ''"> and vi.status = #{status}</if>
        <if test="code != null  and code != ''"> and vi.code = #{code}</if>
        <if test="birthday != null  and birthday != ''"> and vi.birthday = #{birthday}</if>
        <if test="workUnit != null  and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
        <if test="crowdClassification != null  and crowdClassification != ''"> and vi.crowd_classification = #{crowdClassification}</if>
        <if test="manufacturer != null  and manufacturer != ''"> and vi.manufacturer = #{manufacturer}</if>
        <if test="nowIn != null  and nowIn != ''"> and vi.now_in = #{nowIn}</if>
        <if test="shouldSlow != null and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="createTime != null and createTime != ''"> and vi.create_time &gt;= #{startTime}</if>
        <if test="endTime != null and endTime != ''"> and vi.create_time &lt;= #{endTime}</if>
        <if test="shouldSlow != null  and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="idCardS != null  and idCardS.size() > 0">
            and vi.id_card in
            <foreach item="idCard" collection="idCardS" open="(" separator="," close=")">
                #{idCard}
            </foreach>
        </if>
        <if test="deptIdList != null  and deptIdList.size() > 0">
            and vi.dept_id in
            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                #{deptId}
            </foreach>
        </if>
    </select>

    <select id="listByJs" resultMap="VaccineInfoResult">
        select vi.id, vi.create_time, vi.update_time, vi.is_del, vi.update_by, vi.user_name, vi.phone_num, vi.id_card
        , vi.gender, vi.province, vi.city, vi.region, vi.now_in, vi.house_type, vi.update_by, vi.code
        from vaccine_info vi
        where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
        <if test="userName != null  and userName != ''">
            and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
        </if>
          <if test="villageTowns != null  and villageTowns != ''">
            and vi.village_towns = #{villageTowns}
        </if>
        <if test="village != null  and village != ''"> and vi.village = #{village}</if>
        <if test="villagerGroup != null  and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
        <if test="houseType != null  and houseType != ''"> and vi.house_type = #{houseType}</if>
        <if test="domicile != null  and domicile != ''"> and vi.domicile = #{domicile}</if>
        <if test="province != null  and province != ''"> and vi.province = #{province}</if>
        <if test="city != null  and city != ''"> and vi.city = #{city}</if>
        <if test="jici != null  and jici != ''"> and vi.jici &lt;= #{jici}</if>
        <if test="vaccineName != null  and vaccineName != ''"> and vi.vaccine_name like concat('%', #{vaccineName}, '%')</if>
        <if test="vaccinationTime != null "> and DATE_FORMAT(vi.vaccination_time,'%Y-%m-%d') = DATE_FORMAT(#{vaccinationTime},'%Y-%m-%d')</if>
        <if test="region != null  and region != ''"> and vi.region = #{region}</if>
        <!--<if test="userName != null  and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>-->
        <if test="gender != null  and gender != ''"> and vi.gender = #{gender}</if>
        <if test="idCard != null  and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
        <if test="phoneNum != null  and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
        <if test="keyIndustries != null  and keyIndustries != ''"> and vi.key_industries = #{keyIndustries}</if>
        <if test="isVaccination != null  and isVaccination != ''"> and vi.is_vaccination = #{isVaccination}</if>
        <if test="params.startAge != null  and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
        <if test="params.endAge != null  and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>
        <if test="contraindication != null  and contraindication != ''"> and vi.contraindication = #{contraindication}</if>
        <if test="suspend != null  and suspend != ''"> and vi.suspend = #{suspend}</if>
        <if test="shouldBe != null  and shouldBe != ''"> and vi.should_be = #{shouldBe}</if>
        <if test="other != null  and other != ''"> and vi.other = #{other}</if>
        <if test="status != null  and status != ''"> and vi.status = #{status}</if>
        <if test="code != null  and code != ''"> and vi.code = #{code}</if>
        <if test="birthday != null  and birthday != ''"> and vi.birthday = #{birthday}</if>
        <if test="workUnit != null  and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
        <if test="crowdClassification != null  and crowdClassification != ''"> and vi.crowd_classification = #{crowdClassification}</if>
        <if test="manufacturer != null  and manufacturer != ''"> and vi.manufacturer = #{manufacturer}</if>
        <if test="nowIn != null  and nowIn != ''"> and vi.now_in = #{nowIn}</if>
        <if test="shouldSlow != null and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="createTime != null and createTime != ''"> and vi.create_time &gt;= #{startTime}</if>
        <if test="endTime != null and endTime != ''"> and vi.create_time &lt;= #{endTime}</if>
        <if test="shouldSlow != null  and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="idCardS != null  and idCardS.size() > 0">
            and vi.id_card in
            <foreach item="idCard" collection="idCardS" open="(" separator="," close=")">
                #{idCard}
            </foreach>
        </if>
        <if test="deptIdList != null  and deptIdList.size() > 0">
            and vi.dept_id in
            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                #{deptId}
            </foreach>
        </if>
    </select>

    <select id="countByJs" resultType="int">
        select count(1)
        from vaccine_info vi
        where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
        <if test="villageTowns != null  and villageTowns != ''">
            and vi.village_towns = #{villageTowns}
        </if>
        <if test="village != null  and village != ''"> and vi.village = #{village}</if>
        <if test="villagerGroup != null  and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
        <if test="houseType != null  and houseType != ''"> and vi.house_type = #{houseType}</if>
        <if test="domicile != null  and domicile != ''"> and vi.domicile = #{domicile}</if>
        <if test="province != null  and province != ''"> and vi.province = #{province}</if>
        <if test="city != null  and city != ''"> and vi.city = #{city}</if>
        <if test="jici != null  and jici != ''"> and vi.jici &lt;= #{jici}</if>
        <if test="vaccineName != null  and vaccineName != ''"> and vi.vaccine_name like concat('%', #{vaccineName}, '%')</if>
        <if test="vaccinationTime != null "> and DATE_FORMAT(vi.vaccination_time,'%Y-%m-%d') = DATE_FORMAT(#{vaccinationTime},'%Y-%m-%d')</if>
        <if test="region != null  and region != ''"> and vi.region = #{region}</if>
        <if test="userName != null  and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>
        <if test="gender != null  and gender != ''"> and vi.gender = #{gender}</if>
        <if test="idCard != null  and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
        <if test="phoneNum != null  and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
        <if test="keyIndustries != null  and keyIndustries != ''"> and vi.key_industries = #{keyIndustries}</if>
        <if test="isVaccination != null  and isVaccination != ''"> and vi.is_vaccination = #{isVaccination}</if>
        <if test="params.startAge != null  and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
        <if test="params.endAge != null  and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>
        <if test="contraindication != null  and contraindication != ''"> and vi.contraindication = #{contraindication}</if>
        <if test="suspend != null  and suspend != ''"> and vi.suspend = #{suspend}</if>
        <if test="shouldBe != null  and shouldBe != ''"> and vi.should_be = #{shouldBe}</if>
        <if test="other != null  and other != ''"> and vi.other = #{other}</if>
        <if test="status != null  and status != ''"> and vi.status = #{status}</if>
        <if test="code != null  and code != ''"> and vi.code = #{code}</if>
        <if test="birthday != null  and birthday != ''"> and vi.birthday = #{birthday}</if>
        <if test="workUnit != null  and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
        <if test="crowdClassification != null  and crowdClassification != ''"> and vi.crowd_classification = #{crowdClassification}</if>
        <if test="manufacturer != null  and manufacturer != ''"> and vi.manufacturer = #{manufacturer}</if>
        <if test="nowIn != null  and nowIn != ''"> and vi.now_in = #{nowIn}</if>
        <if test="shouldSlow != null and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="createTime != null and createTime != ''"> and vi.create_time &gt;= #{startTime}</if>
        <if test="endTime != null and endTime != ''"> and vi.create_time &lt;= #{endTime}</if>
        <if test="shouldSlow != null  and shouldSlow != ''"> and vi.should_slow = #{shouldSlow}</if>
        <if test="idCardS != null  and idCardS.size() > 0">
            and vi.id_card in
            <foreach item="idCard" collection="idCardS" open="(" separator="," close=")">
                #{idCard}
            </foreach>
        </if>
        <if test="deptIdList != null  and deptIdList.size() > 0">
            and vi.dept_id in
            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                #{deptId}
            </foreach>
        </if>
    </select>

    <select id="countCzrk" resultType="int">
        select count(vi.id)
        from vaccine_info vi
        where vi.is_del = 'N'
        <!-- 已认领 -->
        <if test="ryrl == true">and (vi.village_towns is not null or vi.village_towns != '')</if>

        <if test="deptIdList != null  and deptIdList.size() > 0">
            and vi.dept_id in
            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                #{deptId}
            </foreach>
        </if>
    </select>

    <select id="countIdCard" resultType="int">
        select count(vi.id) from vaccine_info vi where vi.is_del = 'N' and id_card = #{idCard}
    </select>

    <select id="listByCode" resultMap="VaccineInfoResult">
        select vi.id, vi.user_name, vi.phone_num, vi.id_card, vi.gender, vi.province, vi.city, vi.region, vi.now_in
        , vi.house_type, vi.update_by, vi.code, vi.rlr, vi.yhzgx
        from vaccine_info vi
        <!--把户主放第一位-->
        where vi.is_del = 'N' and code = #{code} order by house_type desc;
    </select>

    <select id="listByRlry" resultMap="VaccineInfoResult">
        select vi.id, vi.user_name, vi.phone_num, vi.id_card, vi.gender, vi.province, vi.city, vi.region, vi.now_in
               , vi.house_type, vi.update_by, vi.code, vi.rlr, vi.update_time, vi.delete_reason, vi.domicile
        from vaccine_info vi
        <where>
            vi.is_del = #{isDel}
            <!-- 已认领 -->
            <if test="ryrl == true">and (vi.village_towns is not null or vi.village_towns != '')</if>
            <!-- 未认领 -->
            <if test="ryrl == false">and (vi.village_towns is null or vi.village_towns = '')</if>


            <if test="villageTowns != null  and villageTowns != ''">and vi.village_towns = #{villageTowns}</if>
            <if test="village != null  and village != ''">and vi.village = #{village}</if>
            <if test="houseType != null  and houseType != ''">and vi.house_type = #{houseType}</if>
            <if test="domicile != null  and domicile != ''">and vi.domicile = #{domicile}</if>
            <if test="province != null  and province != ''">and vi.province = #{province}</if>
            <if test="city != null  and city != ''">and vi.city = #{city}</if>
            <if test="jici != null  and jici != ''">and vi.jici &lt;= #{jici}</if>
            <if test="vaccineName != null  and vaccineName != ''">and vi.vaccine_name like concat('%', #{vaccineName},
                '%')
            </if>
            <if test="vaccinationTime != null ">and DATE_FORMAT(vi.vaccination_time,'%Y-%m-%d') =
                DATE_FORMAT(#{vaccinationTime},'%Y-%m-%d')
            </if>
            <if test="region != null  and region != ''">and vi.region = #{region}</if>
            <!--小程序，一个搜索框既可以搜索姓名，也可以搜索身份证-->
            <if test="userName != null  and userName != ''">
                and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
            </if>
            <if test="gender != null  and gender != ''">and vi.gender = #{gender}</if>
            <if test="idCard != null  and idCard != ''">and vi.id_card like concat('%', #{idCard}, '%')</if>
            <if test="phoneNum != null  and phoneNum != ''">and vi.phone_num = #{phoneNum}</if>
            <if test="keyIndustries != null  and keyIndustries != ''">and vi.key_industries = #{keyIndustries}</if>
            <if test="isVaccination != null  and isVaccination != ''">and vi.is_vaccination = #{isVaccination}</if>
            <if test="params.startAge != null  and params.startAge != ''">and vi.age &gt;= #{params.startAge}</if>
            <if test="params.endAge != null  and params.endAge != ''">and vi.age &lt;= #{params.endAge}</if>
            <if test="contraindication != null  and contraindication != ''">and vi.contraindication = #{contraindication}</if>
            <if test="suspend != null  and suspend != ''">and vi.suspend = #{suspend}</if>
            <if test="shouldBe != null  and shouldBe != ''">and vi.should_be = #{shouldBe}</if>
            <if test="other != null  and other != ''">and vi.other = #{other}</if>
            <if test="status != null  and status != ''">and vi.status = #{status}</if>
            <if test="code != null  and code != ''">and vi.code = #{code}</if>
            <if test="birthday != null  and birthday != ''">and vi.birthday = #{birthday}</if>
            <if test="workUnit != null  and workUnit != ''">and vi.work_unit = #{workUnit}</if>
            <if test="crowdClassification != null  and crowdClassification != ''">and vi.crowd_classification =
                #{crowdClassification}
            </if>
            <if test="manufacturer != null  and manufacturer != ''">and vi.manufacturer = #{manufacturer}</if>
            <if test="nowIn != null  and nowIn != ''">and vi.now_in = #{nowIn}</if>
            <if test="shouldSlow != null  and shouldSlow != ''">and vi.should_slow = #{shouldSlow}</if>
            <if test="idCardS != null  and idCardS.size() > 0">
                and vi.id_card in
                <foreach item="idCard" collection="idCardS" open="(" separator="," close=")">
                    #{idCard}
                </foreach>
            </if>
            <if test="deptIdList != null  and deptIdList.size() > 0">
                and vi.dept_id in
                <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
        </where>
        order by vi.create_time DESC ,vi.vaccination_time DESC
    </select>

    <select id="stsByYrl" resultType="int">
        select count(vi.id)
        from vaccine_info vi
        where vi.is_del = 'N'
        <!-- 已认领 -->
        and (vi.village_towns is not null or vi.village_towns != '')
        <if test="userName != null  and userName != ''">
            and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
        </if>
        <if test="deptIdList != null  and deptIdList.size() > 0">
            and vi.dept_id in
            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                #{deptId}
            </foreach>
        </if>
    </select>

    <select id="stsByWrl" resultType="int">
        select count(vi.id)
        from vaccine_info vi
        where vi.is_del = 'N'
        <!-- 未认领 -->
        and (vi.village_towns is null or vi.village_towns = '')
        <if test="userName != null  and userName != ''">
            and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
        </if>
        <if test="deptIdList != null  and deptIdList.size() > 0">
            and vi.dept_id in
            <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
                #{deptId}
            </foreach>
        </if>
    </select>

    <update id="deleteCzrk">
        update vaccine_info
        set is_del        = 'Y'
          , delete_reason = #{deleteReason}
          , update_by     = #{updateBy}
          , update_time   = sysdate()
        where id = #{id}
    </update>

    <update id="reduction">
        update vaccine_info
        set is_del        = 'N'
          , update_by     = #{updateBy}
          , update_time   = sysdate()
        where id = #{id}
    </update>

    <select id="selectVaccineInfoListByPage" parameterType="Integer" resultMap="VaccineInfoResult">
        select * from vaccine_info limit   #{startNum}, #{endNum}
    </select>

    <select id="selectVaccineInfoListById" parameterType="Integer" resultMap="VaccineInfoResult">
        select * from vaccine_info where id > #{id}
    </select>

    <select id="handleData" resultMap="VaccineInfoResult">
        SELECT (DATE_FORMAT(substring(t.id_card, 7, 8), "%Y-%m-%d")) AS birthday
            , ((YEAR(now())) - (YEAR(substring(t.id_card, 7, 8)))) AS age
            , id AS id
        FROM vaccine_info t where age is null or age = 0 or age = ''
    </select>

    <select id="getHouseType" resultType="com.alibaba.fastjson.JSONObject">
        SELECT zjhm idCard, hh code, yhzgx yhzgx FROM std_ga_hjrkxx
    </select>

    <update id="setHouseType">
        update vaccine_info set code = #{code}, yhzgx = #{yhzgx}, house_type = #{houseType} where id_card = #{idCard}
    </update>

    <select id="selectVaccineInfoById" parameterType="Long" resultMap="VaccineInfoResult">
        <include refid="selectVaccineInfoVo"/>
        where vi.id = #{id} and vi.is_del = 'N'
        order by viu.vaccination_time
    </select>

    <select id="selectVaccineInfoByIdCard" parameterType="String" resultMap="VaccineInfoResult">
        <include refid="selectVaccineInfoVo"/>
        where vi.id_card = #{idCard} and vi.is_del = 'N'
        order by viu.vaccination_time
    </select>

    <select id="selectVaccineInfoByIds" parameterType="Long" resultMap="VaccineInfoResult">
        <include refid="selectVaccineInfoVo"/>
        where vi.id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
        and vi.is_del = 'N'
    </select>
        
    <insert id="insertVaccineInfo"  useGeneratedKeys="true" keyProperty="id">
        insert into vaccine_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="villageTowns != null">village_towns,</if>
            <if test="village != null">village,</if>
            <if test="villagerGroup != null">villager_group,</if>
            <if test="houseType != null">house_type,</if>
            <if test="domicile != null">domicile,</if>
            <if test="province != null">province,</if>
            <if test="city != null">city,</if>
            <if test="region != null and region != ''">region,</if>
            <if test="userName != null">user_name,</if>
            <if test="gender != null">gender,</if>
            <if test="idCard != null">id_card,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="keyIndustries != null">key_industries,</if>
            <if test="isVaccination != null">is_vaccination,</if>
            <if test="vaccineName != null">vaccine_name,</if>
            <if test="jici != null">jici,</if>
            <if test="vaccinationTime != null">vaccination_time,</if>
            <if test="vaccinationPlace != null">vaccination_place,</if>
            <if test="contraindication != null">contraindication,</if>
            <if test="suspend != null">suspend,</if>
            <if test="shouldBe != null">should_be,</if>
            <if test="other != null">other,</if>
            <if test="progress != null">progress,</if>
            <if test="remark != null">remark,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null and isDel != ''">is_del,</if>
            <if test="code != null and code != ''">code,</if>
            <if test="birthday != null and birthday != ''">birthday,</if>
            <if test="workUnit != null and workUnit != ''">work_unit,</if>
            <if test="crowdClassification != null and crowdClassification != ''">crowd_classification,</if>
            <if test="manufacturer != null and manufacturer != ''">manufacturer,</if>
            <if test="nowIn != null and nowIn != ''">now_in,</if>
            <if test="url != null and url != ''">url,</if>
            <if test="shouldSlow != null and shouldSlow != ''">should_slow,</if>
            <if test="suspendUrl != null and suspendUrl != ''">suspend_url,</if>
            <if test="otherUrl != null and otherUrl != ''">other_url,</if>
            <if test="age != null and age != ''">age,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deleteReason != null">delete_reason,</if>
            create_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="villageTowns != null">#{villageTowns},</if>
            <if test="village != null">#{village},</if>
            <if test="villagerGroup != null">#{villagerGroup},</if>
            <if test="houseType != null">#{houseType},</if>
            <if test="domicile != null">#{domicile},</if>
            <if test="province != null">#{province},</if>
            <if test="city != null">#{city},</if>
            <if test="region != null and region != ''">#{region},</if>
            <if test="userName != null">#{userName},</if>
            <if test="gender != null">#{gender},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="keyIndustries != null">#{keyIndustries},</if>
            <if test="isVaccination != null">#{isVaccination},</if>
            <if test="vaccineName != null">#{vaccineName},</if>
            <if test="jici != null">#{jici},</if>
            <if test="vaccinationTime != null">#{vaccinationTime},</if>
            <if test="vaccinationPlace != null">#{vaccinationPlace},</if>
            <if test="contraindication != null">#{contraindication},</if>
            <if test="suspend != null">#{suspend},</if>
            <if test="shouldBe != null">#{shouldBe},</if>
            <if test="other != null">#{other},</if>
            <if test="progress != null">#{progress},</if>
            <if test="remark != null">#{remark},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null and isDel != ''">#{isDel},</if>
            <if test="code != null and code != ''">#{code},</if>
            <if test="birthday != null and birthday != ''">#{birthday},</if>
            <if test="workUnit != null and workUnit != ''">#{workUnit},</if>
            <if test="crowdClassification != null and crowdClassification != ''">#{crowdClassification},</if>
            <if test="manufacturer != null and manufacturer != ''">#{manufacturer},</if>
            <if test="nowIn != null and nowIn != ''">#{nowIn},</if>
            <if test="url != null and url != ''">#{url},</if>
            <if test="shouldSlow != null and shouldSlow != ''">#{shouldSlow},</if>
            <if test="suspendUrl != null and suspendUrl != ''">#{suspendUrl},</if>
            <if test="otherUrl != null and otherUrl != ''">#{otherUrl},</if>
            <if test="age != null and age != ''">#{age},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deleteReason != null">#{deleteReason},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateVaccineInfo" >
        update vaccine_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="villageTowns != null">village_towns = #{villageTowns},</if>
            <if test="village != null">village = #{village},</if>
            <if test="villagerGroup != null">villager_group = #{villagerGroup},</if>
            <if test="houseType != null">house_type = #{houseType},</if>
            <if test="domicile != null">domicile = #{domicile},</if>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="region != null and region != ''">region = #{region},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="keyIndustries != null">key_industries = #{keyIndustries},</if>
            <if test="isVaccination != null">is_vaccination = #{isVaccination},</if>
            <if test="vaccineName != null">vaccine_name = #{vaccineName},</if>
            <if test="jici != null">jici = #{jici},</if>
            <if test="vaccinationTime != null">vaccination_time = #{vaccinationTime},</if>
            <if test="vaccinationPlace != null">vaccination_place = #{vaccinationPlace},</if>
            <if test="contraindication != null">contraindication = #{contraindication},</if>
            <if test="suspend != null">suspend = #{suspend},</if>
            <if test="shouldBe != null">should_be = #{shouldBe},</if>
            <if test="other != null">other = #{other},</if>
            <if test="progress != null">progress = #{progress},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = sysdate(),</if>
            <if test="isDel != null and isDel != ''">is_del = #{isDel},</if>
            <if test="code != null and code != ''">code = #{code},</if>
            <if test="birthday != null and birthday != ''">birthday = #{birthday},</if>
            <if test="workUnit != null and workUnit != ''">work_unit = #{workUnit},</if>
            <if test="crowdClassification != null and crowdClassification != ''">crowd_classification = #{crowdClassification},</if>
            <if test="manufacturer != null and manufacturer != ''">manufacturer = #{manufacturer},</if>
            <if test="nowIn != null and nowIn != ''">now_in = #{nowIn},</if>
            <if test="url != null and url != ''">url = #{url},</if>
            <if test="shouldSlow != null and shouldSlow != ''">should_slow = #{shouldSlow},</if>
            <if test="suspendUrl != null and suspendUrl != ''">suspend_url = #{suspendUrl},</if>
            <if test="otherUrl != null and otherUrl != ''">other_url = #{otherUrl},</if>
            <if test="age != null and age != ''">age = #{age},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="rlr != null and rlr != ''">rlr = #{rlr},</if>
            <if test="deleteReason != null and deleteReason != ''">delete_reason = #{deleteReason},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateAgeBirthday" >
        update vaccine_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="age != null and age != ''">age = #{age},</if>
            <if test="birthday != null and birthday != ''">birthday = #{birthday},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="update" >
        update vaccine_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="villageTowns != null">village_towns = #{villageTowns},</if>
            <if test="village != null">village = #{village},</if>
            <if test="villagerGroup != null">villager_group = #{villagerGroup},</if>
            <if test="houseType != null">house_type = #{houseType},</if>
            <if test="domicile != null">domicile = #{domicile},</if>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="region != null and region != ''">region = #{region},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="gender != null">gender = #{gender},</if>
<!--            <if SysRegion="idCard != null">id_card = #{idCard},</if>-->
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="keyIndustries != null">key_industries = #{keyIndustries},</if>
            <if test="isVaccination != null">is_vaccination = #{isVaccination},</if>
            <if test="vaccineName != null">vaccine_name = #{vaccineName},</if>
            <if test="jici != null">jici = #{jici},</if>
            <if test="vaccinationTime != null">vaccination_time = #{vaccinationTime},</if>
            <if test="vaccinationPlace != null">vaccination_place = #{vaccinationPlace},</if>
            <if test="contraindication != null">contraindication = #{contraindication},</if>
            <if test="suspend != null">suspend = #{suspend},</if>
            <if test="shouldBe != null">should_be = #{shouldBe},</if>
            <if test="other != null">other = #{other},</if>
            <if test="progress != null">progress = #{progress},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null and isDel != ''">is_del = #{isDel},</if>
            <if test="code != null and code != ''">code = #{code},</if>
            <if test="birthday != null and birthday != ''">birthday = #{birthday},</if>
            <if test="workUnit != null and workUnit != ''">work_unit = #{workUnit},</if>
            <if test="crowdClassification != null and crowdClassification != ''">crowd_classification = #{crowdClassification},</if>
            <if test="manufacturer != null and manufacturer != ''">manufacturer = #{manufacturer},</if>
            <if test="nowIn != null and nowIn != ''">now_in = #{nowIn},</if>
            <if test="url != null and url != ''">url = #{url},</if>
            <if test="shouldSlow != null and shouldSlow != ''">should_slow = #{shouldSlow},</if>
            <if test="suspendUrl != null and suspendUrl != ''">suspend_url = #{suspendUrl},</if>
            <if test="otherUrl != null and otherUrl != ''">other_url = #{otherUrl},</if>
            <if test="age != null and age != ''">age = #{age},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
        </trim>
        where code = #{code} or (id_card like concat('%', #{idCard}, '%') and user_name like concat('%', #{userName}, '%'))
    </update>

    <delete id="deleteVaccineInfoById" parameterType="Long">
        update  vaccine_info set is_del = 'Y' where id = #{id}
    </delete>

    <delete id="deleteVaccineInfoByIds" parameterType="String">
        update  vaccine_info set is_del = 'Y' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>


    <select id="findHjInfo"  resultMap="VaccineInfoResult">
        select id, user_name ,gender, birthday,age,code from vaccine_info
        <where>
            is_del = 'N'
         <if test="idCard != null and idCard != '' "> and id_card = #{idCard}</if>
        </where>
        limit 1
    </select>

    <select id="selectSysDictDataByDictLabel" parameterType="string" resultType="String">
        select dict_value  from sys_dict_data where dict_label = #{vaccineName} and  status = '0'
    </select>

    <select id="listByTotalTaskCnt" resultMap="VaccineInfoResult">
        SELECT id_card, village_towns, vaccination_time, age, jici, vaccine_name
        FROM vaccine_info
        WHERE age > 18
    </select>

    <select id="getByIdCard" resultMap="VaccineInfoResult">
        select * from vaccine_info where id_card = #{idCard} limit 1;
    </select>
    <!--    AND (-->
<!--    contraindication IS NULL-->
<!--    OR suspend IS NULL-->
<!--    OR other IS NULL-->
<!--    );-->

</mapper>