<?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.tsi.api.server.mybatis.TsiDatabaseMapper">

    <select id="getAlarmConfig" parameterType="java.util.HashMap" resultType="com.tsi.api.server.mybatis.vo.AlarmConfigVo">
        <![CDATA[
        select a.alarm_code as alarmCode, a.desc,
               a.value, a.useyn
        from tb_tsc_alarm_config a
        ]]>
    </select>
    <insert id="insertAlarmOccrHs" parameterType="com.tsi.api.server.mybatis.vo.AlarmOccrVo">
    <![CDATA[
        insert into tb_tsc_alarm_hs(occr_dt, alarm_code, alarm_target, alarm_value)
        values(STR_TO_DATE(#{vo.eventDt},'%Y%m%d%H%i%S'), #{vo.alarmCode}, #{vo.alarmTarget}, #{vo.alarmValue})
        ]]>
    </insert>

    <update id="updateProcessStatusStart" parameterType="com.tsi.api.server.mybatis.vo.ProcessStateVo">
    <![CDATA[
        update tb_tsc_process
        set process_state = 1,
            update_tm = NOW(),
            start_tm = NOW()
        where process_id = #{stts.processId}
        ]]>
    </update>
    <update id="updateProcessStatusStop" parameterType="com.tsi.api.server.mybatis.vo.ProcessStateVo">
    <![CDATA[
        update tb_tsc_process
        set process_state = 0,
            update_tm = NOW(),
            end_tm = NOW()
        where process_id = #{stts.processId}
        ]]>
    </update>
    <update id="updateProcessStatusRun" parameterType="com.tsi.api.server.mybatis.vo.ProcessStateVo">
    <![CDATA[
        update tb_tsc_process
        set process_state = 1,
            update_tm = NOW()
        where process_id = #{stts.processId}
        ]]>
    </update>

</mapper>
