package com.common.mapper;

import com.common.entity.AlarmVisitProcesslog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AlarmVisitProcesslogMapper {

    /**
     * 插入处理记录
     */
    @Insert("INSERT INTO alarm_visit_processlog (" +
            "batch_no, log_count, start_time, end_time, remark" +
            ") VALUES (" +
            "#{batchNo}, #{logCount}, #{startTime}, #{endTime}, #{remark}" +
            ")")
    void insert(AlarmVisitProcesslog processlog);

    /**
     * 查询当天最大批次序号
     */
    @Select("SELECT COALESCE(MAX(batch_no), '') FROM alarm_visit_processlog " +
            "WHERE batch_no LIKE CONCAT(#{todayPrefix}, '%')")
    String getTodayMaxBatchNo(String todayPrefix);
}
