<?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.ruoyi.project.benyi.mapper.ByChildMapper">

    <resultMap type="ByChild" id="ByChildResult">
        <result property="id" column="id"/>
        <result property="schoolid" column="schoolid"/>
        <result property="classid" column="classid"/>
        <result property="name" column="name"/>
        <result property="enName" column="en_name"/>
        <result property="infantName" column="infant_name"/>
        <result property="phone" column="phone"/>
        <result property="xb" column="xb"/>
        <result property="mz" column="mz"/>
        <result property="zjhm" column="zjhm"/>
        <result property="csrq" column="csrq"/>
        <result property="birthProvince" column="birth_province"/>
        <result property="birthProvincename" column="birth_provincename"/>
        <result property="birthCity" column="birth_city"/>
        <result property="birthCityname" column="birth_cityname"/>
        <result property="birthArea" column="birth_area"/>
        <result property="birthAreaname" column="birth_areaname"/>
        <result property="registeredProvince" column="registered_province"/>
        <result property="registeredProvincename" column="registered_provincename"/>
        <result property="registeredCity" column="registered_city"/>
        <result property="registeredCityname" column="registered_cityname"/>
        <result property="registeredArea" column="registered_area"/>
        <result property="registeredAreaname" column="registered_areaname"/>
        <result property="addrProvince" column="addr_province"/>
        <result property="addrProvincename" column="addr_provincename"/>
        <result property="addrCity" column="addr_city"/>
        <result property="addrCityname" column="addr_cityname"/>
        <result property="addrArea" column="addr_area"/>
        <result property="addrAreaname" column="addr_areaname"/>
        <result property="addrDetail" column="addr_detail"/>
        <result property="everSchool" column="ever_school"/>
        <result property="learnEnglish" column="learn_english"/>
        <result property="source" column="source"/>
        <result property="status" column="status"/>
        <result property="enterDate" column="enter_date"/>
        <result property="outDate" column="out_date"/>
        <result property="firstLanguage" column="first_language"/>
        <result property="seconderLanguage" column="seconder_language"/>
        <result property="otherLanguage" column="other_language"/>
        <result property="createuserid" column="createuserid"/>
        <result property="createTime" column="create_time"/>
        <result property="month" column="month"/>
        <result property="day1" column="day1"/>
        <result property="day2" column="day2"/>
        <result property="day3" column="day3"/>
        <result property="day4" column="day4"/>
        <result property="day5" column="day5"/>
        <result property="day6" column="day6"/>
        <result property="day7" column="day7"/>
        <result property="day8" column="day8"/>
        <result property="day9" column="day9"/>
        <result property="day10" column="day10"/>
        <result property="day11" column="day11"/>
        <result property="day12" column="day12"/>
        <result property="day13" column="day13"/>
        <result property="day14" column="day14"/>
        <result property="day15" column="day15"/>
        <result property="day16" column="day16"/>
        <result property="day17" column="day17"/>
        <result property="day18" column="day18"/>
        <result property="day19" column="day19"/>
        <result property="day20" column="day20"/>
        <result property="day21" column="day21"/>
        <result property="day22" column="day22"/>
        <result property="day23" column="day23"/>
        <result property="day24" column="day24"/>
        <result property="day25" column="day25"/>
        <result property="day26" column="day26"/>
        <result property="day27" column="day27"/>
        <result property="day28" column="day28"/>
        <result property="day29" column="day29"/>
        <result property="day30" column="day30"/>
        <result property="day31" column="day31"/>
        <result property="bjmc" column="bjmc"/>
        <result property="zbjsmc" column="zbjsmc"/>
        <association property="byChildContactpeople"    column="childid" javaType="ByChildContactpeople" resultMap="ByChildContactpeopleResult" />
    </resultMap>

    <resultMap type="ByChildContactpeople" id="ByChildContactpeopleResult">
        <result property="id" column="id"/>
        <result property="childid" column="childid"/>
        <result property="schoolid" column="schoolid"/>
        <result property="classid" column="classid"/>
        <result property="fathername" column="fathername"/>
        <result property="fphone" column="fphone"/>
        <result property="foffphone" column="foffphone"/>
        <result property="mothername" column="mothername"/>
        <result property="mphone" column="mphone"/>
        <result property="moffphone" column="moffphone"/>
        <result property="grandfathername" column="grandfathername"/>
        <result property="gfgx" column="gfgx"/>
        <result property="gfphone" column="gfphone"/>
        <result property="gfoffphone" column="gfoffphone"/>
        <result property="gfaddress" column="gfaddress"/>
        <result property="grandmothername" column="grandmothername"/>
        <result property="gmgx" column="gmgx"/>
        <result property="gmphone" column="gmphone"/>
        <result property="gmaddress" column="gmaddress"/>
        <result property="gmoffphone" column="gmoffphone"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectByChildVo">
        select c.id, c.schoolid, c.classid, c.name, c.en_name, c.infant_name, c.phone, c.xb, c.mz, c.zjhm, c.csrq, c.birth_province, c.birth_provincename, c.birth_city, c.birth_cityname, c.birth_area, c.birth_areaname, c.registered_province, c.registered_provincename, c.registered_city, c.registered_cityname, c.registered_area, c.registered_areaname, c.addr_province, c.addr_provincename, c.addr_city, c.addr_cityname, c.addr_area, c.addr_areaname, c.addr_detail, c.ever_school, c.learn_english, c.source, c.status, c.enter_date, c.out_date, c.first_language, c.seconder_language, c.other_language, c.createuserid, c.create_time, p.fathername, p.mothername,
        p.childid, p.fphone, p.foffphone, p.mphone, p.moffphone, p.grandfathername, p.gfgx, p.gfphone, p.gfoffphone, p.gfaddress, p.grandmothername, p.gmgx, p.gmphone, p.gmaddress, p.gmoffphone, p.create_time,a.bjmc,(select nick_name from sys_user where user_id=a.zbjs) as zbjsmc
        from by_child c
        left join by_child_contactpeople p on c.id=p.childid
        left join by_class a on c.classid=a.bjbh
    </sql>

    <select id="selectByChildList" parameterType="ByChild" resultMap="ByChildResult">
        <include refid="selectByChildVo"/>
        <where>
            <if test="schoolid != null ">and schoolid = #{schoolid}</if>
            <if test="classid != null  and classid != ''">and classid = #{classid}</if>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="enName != null  and enName != ''">and en_name like concat('%', #{enName}, '%')</if>
            <if test="infantName != null  and infantName != ''">and infant_name like concat('%', #{infantName}, '%')
            </if>
            <if test="phone != null  and phone != ''">and phone = #{phone}</if>
            <if test="xb != null  and xb != ''">and xb = #{xb}</if>
            <if test="mz != null  and mz != ''">and mz = #{mz}</if>
            <if test="zjhm != null  and zjhm != ''">and zjhm = #{zjhm}</if>
            <if test="csrq != null ">and csrq = #{csrq}</if>
            <if test="birthProvince != null  and birthProvince != ''">and birth_province = #{birthProvince}</if>
            <if test="birthProvincename != null  and birthProvincename != ''">and birth_provincename like concat('%',
                #{birthProvincename}, '%')
            </if>
            <if test="birthCity != null  and birthCity != ''">and birth_city = #{birthCity}</if>
            <if test="birthCityname != null  and birthCityname != ''">and birth_cityname like concat('%',
                #{birthCityname}, '%')
            </if>
            <if test="birthArea != null  and birthArea != ''">and birth_area = #{birthArea}</if>
            <if test="birthAreaname != null  and birthAreaname != ''">and birth_areaname like concat('%',
                #{birthAreaname}, '%')
            </if>
            <if test="registeredProvince != null  and registeredProvince != ''">and registered_province =
                #{registeredProvince}
            </if>
            <if test="registeredProvincename != null  and registeredProvincename != ''">and registered_provincename like
                concat('%', #{registeredProvincename}, '%')
            </if>
            <if test="registeredCity != null  and registeredCity != ''">and registered_city = #{registeredCity}</if>
            <if test="registeredCityname != null  and registeredCityname != ''">and registered_cityname like concat('%',
                #{registeredCityname}, '%')
            </if>
            <if test="registeredArea != null  and registeredArea != ''">and registered_area = #{registeredArea}</if>
            <if test="registeredAreaname != null  and registeredAreaname != ''">and registered_areaname like concat('%',
                #{registeredAreaname}, '%')
            </if>
            <if test="addrProvince != null  and addrProvince != ''">and addr_province = #{addrProvince}</if>
            <if test="addrProvincename != null  and addrProvincename != ''">and addr_provincename like concat('%',
                #{addrProvincename}, '%')
            </if>
            <if test="addrCity != null  and addrCity != ''">and addr_city = #{addrCity}</if>
            <if test="addrCityname != null  and addrCityname != ''">and addr_cityname like concat('%', #{addrCityname},
                '%')
            </if>
            <if test="addrArea != null  and addrArea != ''">and addr_area = #{addrArea}</if>
            <if test="addrAreaname != null  and addrAreaname != ''">and addr_areaname like concat('%', #{addrAreaname},
                '%')
            </if>
            <if test="addrDetail != null  and addrDetail != ''">and addr_detail = #{addrDetail}</if>
            <if test="everSchool != null  and everSchool != ''">and ever_school = #{everSchool}</if>
            <if test="learnEnglish != null  and learnEnglish != ''">and learn_english = #{learnEnglish}</if>
            <if test="source != null  and source != ''">and source = #{source}</if>
            <if test="status != null  and status != ''">and status = #{status}</if>
            <if test="enterDate != null ">and enter_date = #{enterDate}</if>
            <if test="outDate != null ">and out_date = #{outDate}</if>
            <if test="firstLanguage != null  and firstLanguage != ''">and first_language = #{firstLanguage}</if>
            <if test="seconderLanguage != null  and seconderLanguage != ''">and seconder_language =
                #{seconderLanguage}
            </if>
            <if test="otherLanguage != null  and otherLanguage != ''">and other_language = #{otherLanguage}</if>
            <if test="createuserid != null ">and createuserid = #{createuserid}</if>
        </where>
    </select>

    <select id="selectByCheckList" parameterType="ByChild" resultMap="ByChildResult">
        select a.* from by_child a
        where id not in (select childid from by_child_checkin_detail where to_days(create_time) = to_days(now()))
        <if test="schoolid != null ">and schoolid = #{schoolid}</if>
        <if test="classid != null  and classid != ''">and classid = #{classid}</if>
        <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
        <if test="enName != null  and enName != ''">and en_name like concat('%', #{enName}, '%')</if>
        <if test="infantName != null  and infantName != ''">and infant_name like concat('%', #{infantName}, '%')
        </if>
        <if test="phone != null  and phone != ''">and phone = #{phone}</if>
        <if test="xb != null  and xb != ''">and xb = #{xb}</if>
        <if test="mz != null  and mz != ''">and mz = #{mz}</if>
        <if test="zjhm != null  and zjhm != ''">and zjhm = #{zjhm}</if>
        <if test="csrq != null ">and csrq = #{csrq}</if>
        <if test="birthProvince != null  and birthProvince != ''">and birth_province = #{birthProvince}</if>
        <if test="birthProvincename != null  and birthProvincename != ''">and birth_provincename like concat('%',
            #{birthProvincename}, '%')
        </if>
        <if test="birthCity != null  and birthCity != ''">and birth_city = #{birthCity}</if>
        <if test="birthCityname != null  and birthCityname != ''">and birth_cityname like concat('%',
            #{birthCityname}, '%')
        </if>
        <if test="birthArea != null  and birthArea != ''">and birth_area = #{birthArea}</if>
        <if test="birthAreaname != null  and birthAreaname != ''">and birth_areaname like concat('%',
            #{birthAreaname}, '%')
        </if>
        <if test="registeredProvince != null  and registeredProvince != ''">and registered_province =
            #{registeredProvince}
        </if>
        <if test="registeredProvincename != null  and registeredProvincename != ''">and registered_provincename like
            concat('%', #{registeredProvincename}, '%')
        </if>
        <if test="registeredCity != null  and registeredCity != ''">and registered_city = #{registeredCity}</if>
        <if test="registeredCityname != null  and registeredCityname != ''">and registered_cityname like concat('%',
            #{registeredCityname}, '%')
        </if>
        <if test="registeredArea != null  and registeredArea != ''">and registered_area = #{registeredArea}</if>
        <if test="registeredAreaname != null  and registeredAreaname != ''">and registered_areaname like concat('%',
            #{registeredAreaname}, '%')
        </if>
        <if test="addrProvince != null  and addrProvince != ''">and addr_province = #{addrProvince}</if>
        <if test="addrProvincename != null  and addrProvincename != ''">and addr_provincename like concat('%',
            #{addrProvincename}, '%')
        </if>
        <if test="addrCity != null  and addrCity != ''">and addr_city = #{addrCity}</if>
        <if test="addrCityname != null  and addrCityname != ''">and addr_cityname like concat('%', #{addrCityname},
            '%')
        </if>
        <if test="addrArea != null  and addrArea != ''">and addr_area = #{addrArea}</if>
        <if test="addrAreaname != null  and addrAreaname != ''">and addr_areaname like concat('%', #{addrAreaname},
            '%')
        </if>
        <if test="addrDetail != null  and addrDetail != ''">and addr_detail = #{addrDetail}</if>
        <if test="everSchool != null  and everSchool != ''">and ever_school = #{everSchool}</if>
        <if test="learnEnglish != null  and learnEnglish != ''">and learn_english = #{learnEnglish}</if>
        <if test="source != null  and source != ''">and source = #{source}</if>
        <if test="status != null  and status != ''">and status = #{status}</if>
        <if test="enterDate != null ">and enter_date = #{enterDate}</if>
        <if test="outDate != null ">and out_date = #{outDate}</if>
        <if test="firstLanguage != null  and firstLanguage != ''">and first_language = #{firstLanguage}</if>
        <if test="seconderLanguage != null  and seconderLanguage != ''">and seconder_language =
            #{seconderLanguage}
        </if>
        <if test="otherLanguage != null  and otherLanguage != ''">and other_language = #{otherLanguage}</if>
        <if test="createuserid != null ">and createuserid = #{createuserid}</if>
    </select>

    <select id="selectByChildById" parameterType="Long" resultMap="ByChildResult">
        <include refid="selectByChildVo"/>
        where c.id = #{id}
    </select>

    <insert id="insertByChild" parameterType="ByChild" useGeneratedKeys="true" keyProperty="id">
        insert into by_child
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="schoolid != null ">schoolid,</if>
            <if test="classid != null  and classid != ''">classid,</if>
            <if test="name != null  and name != ''">name,</if>
            <if test="enName != null  and enName != ''">en_name,</if>
            <if test="infantName != null  and infantName != ''">infant_name,</if>
            <if test="phone != null  and phone != ''">phone,</if>
            <if test="xb != null  and xb != ''">xb,</if>
            <if test="mz != null  and mz != ''">mz,</if>
            <if test="zjhm != null  and zjhm != ''">zjhm,</if>
            <if test="csrq != null ">csrq,</if>
            <if test="birthProvince != null  and birthProvince != ''">birth_province,</if>
            <if test="birthProvincename != null  and birthProvincename != ''">birth_provincename,</if>
            <if test="birthCity != null  and birthCity != ''">birth_city,</if>
            <if test="birthCityname != null  and birthCityname != ''">birth_cityname,</if>
            <if test="birthArea != null  and birthArea != ''">birth_area,</if>
            <if test="birthAreaname != null  and birthAreaname != ''">birth_areaname,</if>
            <if test="registeredProvince != null  and registeredProvince != ''">registered_province,</if>
            <if test="registeredProvincename != null  and registeredProvincename != ''">registered_provincename,</if>
            <if test="registeredCity != null  and registeredCity != ''">registered_city,</if>
            <if test="registeredCityname != null  and registeredCityname != ''">registered_cityname,</if>
            <if test="registeredArea != null  and registeredArea != ''">registered_area,</if>
            <if test="registeredAreaname != null  and registeredAreaname != ''">registered_areaname,</if>
            <if test="addrProvince != null  and addrProvince != ''">addr_province,</if>
            <if test="addrProvincename != null  and addrProvincename != ''">addr_provincename,</if>
            <if test="addrCity != null  and addrCity != ''">addr_city,</if>
            <if test="addrCityname != null  and addrCityname != ''">addr_cityname,</if>
            <if test="addrArea != null  and addrArea != ''">addr_area,</if>
            <if test="addrAreaname != null  and addrAreaname != ''">addr_areaname,</if>
            <if test="addrDetail != null  and addrDetail != ''">addr_detail,</if>
            <if test="everSchool != null  and everSchool != ''">ever_school,</if>
            <if test="learnEnglish != null  and learnEnglish != ''">learn_english,</if>
            <if test="source != null  and source != ''">source,</if>
            <if test="status != null  and status != ''">status,</if>
            <if test="enterDate != null ">enter_date,</if>
            <if test="outDate != null ">out_date,</if>
            <if test="firstLanguage != null  and firstLanguage != ''">first_language,</if>
            <if test="seconderLanguage != null  and seconderLanguage != ''">seconder_language,</if>
            <if test="otherLanguage != null  and otherLanguage != ''">other_language,</if>
            <if test="createuserid != null ">createuserid,</if>
            <if test="createTime != null ">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="schoolid != null ">#{schoolid},</if>
            <if test="classid != null  and classid != ''">#{classid},</if>
            <if test="name != null  and name != ''">#{name},</if>
            <if test="enName != null  and enName != ''">#{enName},</if>
            <if test="infantName != null  and infantName != ''">#{infantName},</if>
            <if test="phone != null  and phone != ''">#{phone},</if>
            <if test="xb != null  and xb != ''">#{xb},</if>
            <if test="mz != null  and mz != ''">#{mz},</if>
            <if test="zjhm != null  and zjhm != ''">#{zjhm},</if>
            <if test="csrq != null ">#{csrq},</if>
            <if test="birthProvince != null  and birthProvince != ''">#{birthProvince},</if>
            <if test="birthProvincename != null  and birthProvincename != ''">#{birthProvincename},</if>
            <if test="birthCity != null  and birthCity != ''">#{birthCity},</if>
            <if test="birthCityname != null  and birthCityname != ''">#{birthCityname},</if>
            <if test="birthArea != null  and birthArea != ''">#{birthArea},</if>
            <if test="birthAreaname != null  and birthAreaname != ''">#{birthAreaname},</if>
            <if test="registeredProvince != null  and registeredProvince != ''">#{registeredProvince},</if>
            <if test="registeredProvincename != null  and registeredProvincename != ''">#{registeredProvincename},</if>
            <if test="registeredCity != null  and registeredCity != ''">#{registeredCity},</if>
            <if test="registeredCityname != null  and registeredCityname != ''">#{registeredCityname},</if>
            <if test="registeredArea != null  and registeredArea != ''">#{registeredArea},</if>
            <if test="registeredAreaname != null  and registeredAreaname != ''">#{registeredAreaname},</if>
            <if test="addrProvince != null  and addrProvince != ''">#{addrProvince},</if>
            <if test="addrProvincename != null  and addrProvincename != ''">#{addrProvincename},</if>
            <if test="addrCity != null  and addrCity != ''">#{addrCity},</if>
            <if test="addrCityname != null  and addrCityname != ''">#{addrCityname},</if>
            <if test="addrArea != null  and addrArea != ''">#{addrArea},</if>
            <if test="addrAreaname != null  and addrAreaname != ''">#{addrAreaname},</if>
            <if test="addrDetail != null  and addrDetail != ''">#{addrDetail},</if>
            <if test="everSchool != null  and everSchool != ''">#{everSchool},</if>
            <if test="learnEnglish != null  and learnEnglish != ''">#{learnEnglish},</if>
            <if test="source != null  and source != ''">#{source},</if>
            <if test="status != null  and status != ''">#{status},</if>
            <if test="enterDate != null ">#{enterDate},</if>
            <if test="outDate != null ">#{outDate},</if>
            <if test="firstLanguage != null  and firstLanguage != ''">#{firstLanguage},</if>
            <if test="seconderLanguage != null  and seconderLanguage != ''">#{seconderLanguage},</if>
            <if test="otherLanguage != null  and otherLanguage != ''">#{otherLanguage},</if>
            <if test="createuserid != null ">#{createuserid},</if>
            <if test="createTime != null ">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateByChild" parameterType="ByChild">
        update by_child
        <trim prefix="SET" suffixOverrides=",">
            <if test="schoolid != null ">schoolid = #{schoolid},</if>
            <if test="classid != null  and classid != ''">classid = #{classid},</if>
            <if test="name != null  and name != ''">name = #{name},</if>
            <if test="enName != null  and enName != ''">en_name = #{enName},</if>
            <if test="infantName != null  and infantName != ''">infant_name = #{infantName},</if>
            <if test="phone != null  and phone != ''">phone = #{phone},</if>
            <if test="xb != null  and xb != ''">xb = #{xb},</if>
            <if test="mz != null  and mz != ''">mz = #{mz},</if>
            <if test="zjhm != null  and zjhm != ''">zjhm = #{zjhm},</if>
            <if test="csrq != null ">csrq = #{csrq},</if>
            <if test="birthProvince != null  and birthProvince != ''">birth_province = #{birthProvince},</if>
            <if test="birthProvincename != null  and birthProvincename != ''">birth_provincename =
                #{birthProvincename},
            </if>
            <if test="birthCity != null  and birthCity != ''">birth_city = #{birthCity},</if>
            <if test="birthCityname != null  and birthCityname != ''">birth_cityname = #{birthCityname},</if>
            <if test="birthArea != null  and birthArea != ''">birth_area = #{birthArea},</if>
            <if test="birthAreaname != null  and birthAreaname != ''">birth_areaname = #{birthAreaname},</if>
            <if test="registeredProvince != null  and registeredProvince != ''">registered_province =
                #{registeredProvince},
            </if>
            <if test="registeredProvincename != null  and registeredProvincename != ''">registered_provincename =
                #{registeredProvincename},
            </if>
            <if test="registeredCity != null  and registeredCity != ''">registered_city = #{registeredCity},</if>
            <if test="registeredCityname != null  and registeredCityname != ''">registered_cityname =
                #{registeredCityname},
            </if>
            <if test="registeredArea != null  and registeredArea != ''">registered_area = #{registeredArea},</if>
            <if test="registeredAreaname != null  and registeredAreaname != ''">registered_areaname =
                #{registeredAreaname},
            </if>
            <if test="addrProvince != null  and addrProvince != ''">addr_province = #{addrProvince},</if>
            <if test="addrProvincename != null  and addrProvincename != ''">addr_provincename = #{addrProvincename},
            </if>
            <if test="addrCity != null  and addrCity != ''">addr_city = #{addrCity},</if>
            <if test="addrCityname != null  and addrCityname != ''">addr_cityname = #{addrCityname},</if>
            <if test="addrArea != null  and addrArea != ''">addr_area = #{addrArea},</if>
            <if test="addrAreaname != null  and addrAreaname != ''">addr_areaname = #{addrAreaname},</if>
            <if test="addrDetail != null  and addrDetail != ''">addr_detail = #{addrDetail},</if>
            <if test="everSchool != null  and everSchool != ''">ever_school = #{everSchool},</if>
            <if test="learnEnglish != null  and learnEnglish != ''">learn_english = #{learnEnglish},</if>
            <if test="source != null  and source != ''">source = #{source},</if>
            <if test="status != null  and status != ''">status = #{status},</if>
            <if test="enterDate != null ">enter_date = #{enterDate},</if>
            <if test="outDate != null ">out_date = #{outDate},</if>
            <if test="firstLanguage != null  and firstLanguage != ''">first_language = #{firstLanguage},</if>
            <if test="seconderLanguage != null  and seconderLanguage != ''">seconder_language = #{seconderLanguage},
            </if>
            <if test="otherLanguage != null  and otherLanguage != ''">other_language = #{otherLanguage},</if>
            <if test="createuserid != null ">createuserid = #{createuserid},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteByChildById" parameterType="Long">
        delete from by_child where id = #{id}
    </delete>

    <delete id="deleteByChildByIds" parameterType="String">
        delete from by_child where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="selectststicstClassList" parameterType="ByChild"
            resultMap="ByChildResult">
        select c.id, c.classid, c.name,
        (select bjmc from by_class where bjbh=c.classid) as bjmc,
        (select nick_name from sys_user where user_id in (select zbjs from by_class where bjbh=c.classid)) as zbjsmc,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-1')) as day1,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-2')) as day2,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-3')) as day3,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-4')) as day4,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-5')) as day5,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-6')) as day6,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-7')) as day7,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-8')) as day8,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-9')) as day9,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-10')) as day10,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-11')) as day11,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-12')) as day12,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-13')) as day13,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-14')) as day14,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-15')) as day15,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-16')) as day16,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-17')) as day17,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-18')) as day18,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-19')) as day19,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-20')) as day20,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-21')) as day21,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-22')) as day22,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-23')) as day23,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-24')) as day24,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-25')) as day25,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-26')) as day26,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-27')) as day27,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-28')) as day28,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-29')) as day29,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-30')) as day30,
        (select  (select dict_label from sys_dict_data
        where dict_type='sys_dm_cqzt' and dict_value= type)
        from by_child_checkin_detail where childid=c.id
        and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-31')) as day31
        from by_child c
        where c.status = '0'
       and c.classid = #{classid}
        <!-- 数据范围过滤 -->
        -- ${dataScope}
        union all
        select '',classid, '小计','','',
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-01') and classid=#{classid}) / count(*)*100),decimal), '%') as day1,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-02') and classid=#{classid}) / count(*)*100),decimal), '%') as day2,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-03') and classid=#{classid}) / count(*)*100),decimal), '%') as day3,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-04') and classid=#{classid}) / count(*)*100),decimal), '%') as day4,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-05') and classid=#{classid}) / count(*)*100),decimal), '%') as day5,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-06') and classid=#{classid}) / count(*)*100),decimal), '%') as day6,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-07') and classid=#{classid}) / count(*)*100),decimal), '%') as day7,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-08') and classid=#{classid}) / count(*)*100),decimal), '%') as day8,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-09') and classid=#{classid}) / count(*)*100),decimal), '%') as day9,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-10') and classid=#{classid}) / count(*)*100),decimal), '%') as day10,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-11') and classid=#{classid}) / count(*)*100),decimal), '%') as day11,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-12') and classid=#{classid}) / count(*)*100),decimal), '%') as day12,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-13') and classid=#{classid}) / count(*)*100),decimal), '%') as day13,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-14') and classid=#{classid}) / count(*)*100),decimal), '%') as day14,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-15') and classid=#{classid}) / count(*)*100),decimal), '%') as day15,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-16') and classid=#{classid}) / count(*)*100),decimal), '%') as day16,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-17') and classid=#{classid}) / count(*)*100),decimal), '%') as day17,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-18') and classid=#{classid}) / count(*)*100),decimal), '%') as day18,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-19') and classid=#{classid}) / count(*)*100),decimal), '%') as day19,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-20') and classid=#{classid}) / count(*)*100),decimal), '%') as day20,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-21') and classid=#{classid}) / count(*)*100),decimal), '%') as day21,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-22') and classid=#{classid}) / count(*)*100),decimal), '%') as day22,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-23') and classid=#{classid}) / count(*)*100),decimal), '%') as day23,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-24') and classid=#{classid}) / count(*)*100),decimal), '%') as day24,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-25') and classid=#{classid}) / count(*)*100),decimal), '%') as day25,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-26') and classid=#{classid}) / count(*)*100),decimal), '%') as day26,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-27') and classid=#{classid}) / count(*)*100),decimal), '%') as day27,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-28') and classid=#{classid}) / count(*)*100),decimal), '%') as day28,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-29') and classid=#{classid}) / count(*)*100),decimal), '%') as day29,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-30') and classid=#{classid}) / count(*)*100),decimal), '%') as day30,
        CONCAT(convert(((select count(*) from by_child_checkin_detail where
        type='01' and date_format(create_time,'%Y-%m-%d')=concat(#{month},'-31') and classid=#{classid}) / count(*)*100),decimal), '%') as day31
        from by_child c
        where c.status = '0'
        and c.classid = #{classid}
        <!-- 数据范围过滤 -->
         -- ${dataScope}
    </select>

</mapper>