package com.zcxk.order.service;


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.Param;

import java.text.ParseException;
import java.util.List;
import java.util.Map;


public interface WorkOrderManageService {
    /**
     * 新增数据
     *
     * @param workOrderManage 实例对象
     * @return 影响行数
     */
    int insertSelective(WorkOrderManage workOrderManage);
    /**
     * APP运维管理待处理
     */
    List<WorkOrderManageDto> selectAppTodo();
    /**
     * APP运维管理全部查询
     */
    List<WorkOrderManageDto> selectAppAll();
    /**
     * 按id查询工单
     */
    WorkOrderManage selectByPrimaryKey(Integer id);
    /**
     * 更新工单
     */
    int updateByPrimaryKey(WorkOrderManage workOrderManage);
    /**
     * 按id查询工单和详情
     */
    List<WorkOrderManageDto> selectOrderDetail(Integer id);

    /**
     * 批量插入工单信息（报警生成的）
     */
    Integer batchInsertByAlarms(List<WorkOrderManageByAlarmDto> workOrderManages);

    Integer batchDeleteByAlarms(List<Long> deviceIds);

    List<WorkOrderManageByAlarmDto> findWorkOrderByDeviceIds(List<Long> deviceIds);

    void updateByAlarms(List<WorkOrderManageByAlarmDto> workOrderManages);

    int updateByPrimaryKeySelective(WorkOrderManage record);


    /**
     * 批量删除
     */
    Integer batchDelete(@Param("ids") List<Integer> ids);

    /**
     * 分页查询
     */
    Page<WorkOrderManageDto> selectPage(IPage<WorkOrderManageDto> page, @Param("order") WorkOrderManageDto workOrderManageDto);


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

    /**
     * 事件列表
     */
    Page<WorkOrderManageDto> findEventListPage(IPage<WorkOrderManageDto> page, @Param("order") WorkOrderManageDto workOrderManageDto);
    /**
     * 根据orderPid查询
     */
    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);


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


    List<Map<String,Object>> eventMonthStatistics(@Param("order") WorkOrderManageDto workOrderManageDto) throws ParseException;

    List<Map<String,Object>> eventYearStatistics(@Param("order") WorkOrderManageDto workOrderManageDto) throws ParseException;
    /**
     * 待处理权限
     */
    int selectPendingPower(Map<String,Object> map);
    /**
     * 综合展示-查询工单执行情况
     */
    List<WorkOrderManageDto> selectOrderStatus(WorkOrderManageDto workOrderManageDto);

    List<WorkOrderManageDto> selectMaintainOrder(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(WorkOrderManageDto workOrderManageDto,List<String> list) throws ParseException;

    /**
     * 判单次数年统计
     */
    List<Map<String,Object>> dispatchTimesYearStatistics( WorkOrderManageDto workOrderManageDto,List<String> list) throws ParseException;


    /**
    * @Author lihui
    * @Description 查询个人工单信息
    * @Date 9:13 2021/5/13
    * @Param [page, userId, startTime, endTime]
    * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.zcxk.order.dto.WorkOrderManageDto>
    **/
    Page<WorkOrderManageDto> selectByTime(IPage<WorkOrderManageDto> page, String tenantId, Integer userId, String startTime, String endTime);

    /**
    * @Author lihui
    * @Description 查询工单工作流
    * @Date 16:40 2021/5/14
    * @Param [id]
    * @return com.zcxk.order.dto.WorkOrderManageDto
    **/
    WorkOrderManageDto findWorkFlowById(Integer id);
}
