<?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.ssj.mapper.load.data.LoadDataMapper">
    <resultMap id="FeedbackDTOResultMap" type="com.ssj.service.conch.teacher.library.dto.FeedbackDTO">
        <id column="push_id" property="pushId"/>
        <result column="suggest" property="suggest"/>
        <result column="push_time" property="pushTime"/>
        <result column="vip_id" property="vipId"/>
        <collection property="homeworkPictureList" ofType="String">
            <constructor>
                <arg column="file_key"/>
            </constructor>
        </collection>
    </resultMap>

    <select id="findFeedbackHistory" resultMap="FeedbackDTOResultMap">
        select push.*, scon_homework_picture.file_key
        from (select id        push_id,
        vip_id,
        suggest,
        push_time push_time
        from zyb_student_push
        where
        push_time >= #{beginDate} and    #{endDate} >  push_time
             and type > 0
        ) push
        left join scon_homework_picture
        on push.vip_id = scon_homework_picture.vip_id
        and to_days(push.push_time) = to_days(scon_homework_picture.create_time)
        and scon_homework_picture.is_delete = 0
        order by push.push_time desc, field(scon_homework_picture.subject, '语文', '数学', '英语')
    </select>


    <select id="findWeeklyReportBeginDateAndEndDate"
            resultType="com.ssj.bean.sys.homework.domain.StudentWeeklyReport">
        select * from scon_student_weekly_report where  create_time >= #{beginDate} and    #{endDate} >  create_time
    </select>


    <select id="findMonthHomeworkCount" resultType="com.ssj.bean.sys.homework.domain.HomeworkCount">
        select *
        from scon_homework_count
        where  create_time >= #{beginDate} and    #{endDate} >  create_time
    </select>

    <select id="findWeeklyReportHistory"
            resultType="com.ssj.service.conch.parents.v2.dto.StudentWeeklyReportDTO">
        select vip_id,
               group_concat(subject)              subject_str,
               group_concat(accuracy_rate)        accuracy_rate_str,
               sum(total_knowledge_num)           total_knowledge_num,
               sum(master_well_knowledge_num)     master_well_knowledge_num,
               sum(master_infirmly_knowledge_num) master_infirmly_knowledge_num,
               sum(not_mastered_knowledge_num)    not_mastered_knowledge_num,
               begin_date begin_time,
               end_date end_time
        from scon_student_weekly_report
        where  create_time >= #{beginDate} and    #{endDate} >  create_time
        group by vip_id, begin_date
        order by begin_date desc
    </select>

    <select id="findMonthlyReportHistory" resultType="com.ssj.service.conch.parents.v2.dto.MonthlyReportDTO">
        select accuracy_rate learning_score,
               homework_month,
               transcended_student_proportion,
               increased_score
        from scon_homework_count
        where data_type = 2
          and create_time >= #{beginDate}
          and #{endDate} >  create_time
        order by homework_month desc
    </select>


</mapper>