<?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.css.simulation.resource.server.infra.db.mysql.mapper.HomePageMapper" >

    <select id="selectRunTaskChart" parameterType="java.util.Map" resultType="api.common.pojo.vo.home.LineChartVO">
        select
          COUNT(id) as num,
          DATE(run_start_time) as toDate
        FROM simulation_manual_project_task
        WHERE run_start_time >= #{dateBegin,jdbcType=VARCHAR}
        and create_user_id = #{createUserId,jdbcType=VARCHAR}
        GROUP BY DATE(run_start_time)
        ORDER BY toDate ASC
    </select>

    <select id="selectRunProjectChart" parameterType="java.util.Map" resultType="api.common.pojo.vo.home.LineChartVO">
        SELECT COUNT(1)           as num,
               DATE(t.finish_time) as toDate
        FROM (SELECT finish_time
              FROM simulation_manual_project
              WHERE finish_time >= #{dateBegin,jdbcType=VARCHAR}
                and create_user_id = #{createUserId,jdbcType=VARCHAR} and is_deleted = '0'
              UNION ALL
              SELECT finish_time
              FROM simulation_automatic_subproject
              WHERE finish_time >= #{dateBegin,jdbcType=VARCHAR}
                and create_user_id = #{createUserId,jdbcType=VARCHAR} and is_deleted = '0')
                 as t
        GROUP BY DATE(t.finish_time)
        ORDER BY toDate ASC
    </select>

</mapper>
