<?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.reptileclient.jlifeapp.dao.jz.JzEventHistoryMapper">
    <resultMap id="BaseResultMap" type="com.reptileclient.jlifeapp.entity.jz.JzEventHistory">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="dbname" property="dbname" jdbcType="VARCHAR"/>
        <result column="eventname" property="eventname" jdbcType="VARCHAR"/>
        <result column="issuccess" property="issuccess" jdbcType="INTEGER"/>
        <result column="errormessage" property="errormessage" jdbcType="VARCHAR"/>
        <result column="starttime" property="starttime" jdbcType="TIMESTAMP"/>
        <result column="duration" property="duration" jdbcType="INTEGER"/>
        <result column="endtime" property="endtime" jdbcType="TIMESTAMP"/>
        <result column="randno" property="randno" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, dbname, eventname, issuccess, errormessage, starttime, duration, endtime,randno
    </sql>
    <select id="selectByToday" resultMap="BaseResultMap">
        select dbname, eventname, issuccess, errormessage, starttime, duration, endtime
        from jz_event_history
        where starttime >=date_add(current_date(),interval -1 day)
          and eventname!='执行预采任务'
          and eventname!='每日增量etl客户信息'
          and (eventname not like 'sp_etl_campaign%' or (eventname like 'sp_etl_campaign%' and issuccess=0))
        union all
        select '',job_name,if(status=0,1,0),job_message,create_time,0,create_time from jzlife_portal.sys_job_log
          where create_time >=current_date() group by job_name,`status`
    </select>

</mapper>
