package com.yfd.platform.modules.patroltask.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfd.platform.modules.patroltask.domain.Task;
import org.apache.ibatis.annotations.Insert;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 巡视任务表 Mapper 接口
 * </p>
 *
 *
 * @since 2023-04-08
 */
public interface TaskMapper extends BaseMapper<Task> {

    Page<Map<String, Object>> getTaskList(Page<Map<String, Object>> page,String stationId, String startDate, String endDate,
                                          String type, String taskName, String enable, String taskType,
                                          String taskTodoType);

    @Insert("<script> " +
            "insert into iis_task " +
            "(task_id, station_code, station_name, type, task_code, task_name, task_type, task_todo_type, priority, " +
            "device_level, device_list, fixed_start_time, cycle_month, cycle_week, cycle_execute_time, " +
            "cycle_start_time, cycle_end_time, interval_number, " +
            "interval_type, interval_execute_time, interval_start_time, interval_end_time, invalid_start_time, " +
            "invalid_end_time, isenable, cron_value, creatorcode, creator, " +
            "create_time, task_number_total, datastatus, lastmodifier, lastmodifydate, custom1, custom2,custom3," +
            "is_report,control_num) " +
            "values " +
            "<foreach collection='taskList' index='index' item='item' separator=','> " +
            "(#{item.taskId}, #{item.stationCode}, #{item.stationName}, #{item.type}, #{item.taskCode}, " +
            "#{item.taskName}, #{item.taskType}, #{item.taskTodoType},#{item.priority}," +
            "#{item.deviceLevel}, #{item.deviceList}, #{item.fixedStartTime}, #{item.cycleMonth}, #{item.cycleWeek}, " +
            "#{item.cycleExecuteTime}, #{item.cycleStartTime}, #{item.cycleEndTime}, #{item.intervalNumber}, " +
            "#{item.intervalType}, #{item.intervalExecuteTime}, #{item.intervalStartTime}, #{item.intervalEndTime}, " +
            "#{item.invalidStartTime}, " +
            "#{item.invalidEndTime}, #{item.isenable}, #{item.cronValue},#{item.creatorcode}, " +
            "#{item.creator},#{item.createTime}, #{item.taskNumberTotal}, #{item.datastatus}, #{item.lastmodifier}, " +
            "#{item.lastmodifydate}, " +
            "#{item.custom1}, #{item.custom2}, #{item.custom3}, #{item.isReport}, #{item.controlNum}) " +
            "</foreach> " +
            "ON DUPLICATE KEY UPDATE " +
            "station_code=VALUES(station_code), " +
            "station_name=VALUES(station_name), " +
            "type=VALUES(type), " +
            "task_code=VALUES(task_code), " +
            "task_name=VALUES(task_name), " +
            "task_type=VALUES(task_type), " +
            "task_todo_type=VALUES(task_todo_type), " +
            "priority=VALUES(priority), " +
            "device_level=VALUES(device_level), " +
            "device_list=VALUES(device_list), " +
            "fixed_start_time=VALUES(fixed_start_time), " +
            "cycle_month=VALUES(cycle_month), " +
            "cycle_week=VALUES(cycle_week), " +
            "cycle_execute_time=VALUES(cycle_execute_time), " +
            "cycle_start_time=VALUES(cycle_start_time), " +
            "cycle_end_time=VALUES(cycle_end_time), " +
            "interval_number=VALUES(interval_number), " +
            "interval_type=VALUES(interval_type), " +
            "interval_execute_time=VALUES(interval_execute_time), " +
            "interval_start_time=VALUES(interval_start_time), " +
            "interval_end_time=VALUES(interval_end_time), " +
            "invalid_start_time=VALUES(invalid_start_time), " +
            "invalid_end_time=VALUES(invalid_end_time), " +
            "isenable=VALUES(isenable), " +
            "cron_value=VALUES(cron_value), " +
            "creatorcode=VALUES(creatorcode), " +
            "creator=VALUES(creator), " +
            "create_time=VALUES(create_time), " +
            "task_number_total=VALUES(task_number_total), " +
            "datastatus=VALUES(datastatus), " +
            "lastmodifier=VALUES(lastmodifier), " +
            "lastmodifydate=VALUES(lastmodifydate)," +
            "custom1=VALUES(custom1)," +
            "custom2=VALUES(custom2)," +
            "custom3=VALUES(custom3)," +
            "is_report=VALUES(is_report)," +
            "control_num=VALUES(control_num)" +
            "</script>")
    void batchAdd(List<Task> taskList);
}
