package com.zcxk.order.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zcxk.order.dto.StatisticsDto;
import com.zcxk.order.dto.WorkOrderManageByAlarmDto;
import com.zcxk.order.dto.WorkOrderManageDto;
import com.zcxk.order.entity.WorkOrderManage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
public interface WorkOrderManageMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(WorkOrderManage record);

    int insertSelective(WorkOrderManage record);

    WorkOrderManage selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(WorkOrderManage record);

    int updateByPrimaryKey(WorkOrderManage record);

    Integer batchDelete(@Param("ids") List<Integer> ids);

    List<WorkOrderManageDto> selectAppTodo( @Param("userId")Integer userId,@Param("tenantId")String tenantId);

    List<WorkOrderManageDto> selectAppAll( @Param("userId")Integer userId,@Param("tenantId")String tenantId);

    List<WorkOrderManageDto> selectOrderDetail(Integer id);

    int batchInsertByAlarms(@Param("workOrderManages")List<WorkOrderManageByAlarmDto> workOrderManages);

    int batchDeleteByAlarms(@Param("deviceIds")List<Long> deviceIds);

    List<WorkOrderManageByAlarmDto> findWorkOrderByDeviceIds(@Param("deviceIds")List<Long> deviceIds);

    int updateByAlarms(@Param("workOrderManage")WorkOrderManageByAlarmDto workOrderManage);

    Page<WorkOrderManageDto> findEventListPage(IPage<WorkOrderManageDto> page, @Param("order") WorkOrderManageDto workOrderManageDto);

    Page<WorkOrderManageDto> findPage(IPage<WorkOrderManageDto> page, @Param("order") WorkOrderManageDto workOrderManageDto);

    Map<String,Object> workOrderStatistics(@Param("order") WorkOrderManageDto workOrderManageDto);

    Page<WorkOrderManageDto> findByNo(IPage<WorkOrderManageDto> page, @Param("order") WorkOrderManageDto workOrderManageDto);

    List<WorkOrderManageDto> selectMaintainOrder(@Param("order") WorkOrderManageDto workOrderManageDto);

    List<WorkOrderManage> selectByPId(Map<String,Object> map);

    Map<String,Object> selectOrderUserStatus(@Param("userId") String userId);

    Map<String,Object> selectPlanUserStatus(@Param("userId") String userId);

    Map<String,Object> selectMaintainUserStatus(@Param("userId") String userId);


    /**
     * 事件月报统计
     */
    List<Map<String,Object>> eventMonthStatistics(@Param("order") WorkOrderManageDto workOrderManageDto);

    /**
     *事件年统计
     */
    List<Map<String,Object>> eventYearStatistics(@Param("order") WorkOrderManageDto workOrderManageDto);

    /**
     * 上报统计
     */
    List<StatisticsDto> reportStatistics(@Param("order") WorkOrderManageDto workOrderManageDto);


    /**
     * 工单状态统计
     */
    List<StatisticsDto> orderStatusStatistics(@Param("order") WorkOrderManageDto workOrderManageDto);


    /**
     * 工单类型统计
     */
    List<StatisticsDto> orderTypeStatistics(@Param("order") WorkOrderManageDto workOrderManageDto);

    /**
     * 工单时长统计
     */
    List<StatisticsDto> orderDurationStatistics(@Param("order") WorkOrderManageDto workOrderManageDto);


    /**
     * 派单次数月统计
     */
    List<Map<String,Object>> dispatchTimesMonthStatistics(@Param("order") WorkOrderManageDto workOrderManageDto, @Param("list") List<String> list);

    /**
     * 派单次数年统计
     */
    List<Map<String,Object>> dispatchTimesYearStatistics(@Param("order") WorkOrderManageDto workOrderManageDto, @Param("list") List<String> list);

    /**
     * 待处理权限
     */
    int selectPendingPower(Map<String,Object> map);

    List<WorkOrderManageDto> selectOrderStatus(WorkOrderManageDto workOrderManageDto);

    Page<WorkOrderManageDto> selectByTime( IPage<WorkOrderManageDto> page, @Param("userId")Integer userId, @Param("tenantId")String tenantId ,
                                           @Param("startTime")String startTime, @Param("endTime")String endTime);


    WorkOrderManageDto findWorkFlowById(Integer id);



}