package com.tofly.qualitycontrol.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.qualitycontrol.dto.OrderDto;
import com.tofly.qualitycontrol.dto.OrderReportDto;
import com.tofly.qualitycontrol.dto.ReportOrderDto;
import com.tofly.qualitycontrol.entity.CertificationOrder;
import com.tofly.qualitycontrol.entity.RectifyOrder;
import com.tofly.qualitycontrol.vo.BusinessMonitorVO_L;
import com.tofly.qualitycontrol.vo.RectifyOrderListVo;
import com.tofly.qualitycontrol.vo.RectifySummaryVo;
import com.tofly.qualitycontrol.vo.ReportSummaryVo;
import org.apache.ibatis.annotations.Param;

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

/**
 * @author B
 */
public interface RectifyOrderMapper extends BaseMapper<RectifyOrder> {

	/**
	 * 业务监控分页和模糊查询
	 *
	 * @param startDate
	 * @param endDate
	 * @param number
	 * @param currentProcess
	 * @param orderExceptionStatus
	 * @param page
	 * @return com.baomidou.mybatisplus.core.metadata.IPage<com.tofly.qualitycontrol.vo.BusinessMonitorVO_L>
	 **/
	IPage<BusinessMonitorVO_L> getBusinessMonitorList(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("number") String number, @Param("currentProcess") String currentProcess, @Param("orderExceptionStatus") Integer orderExceptionStatus, @Param("page") Page<CertificationOrder> page);

    List<ReportSummaryVo> getIssueSummary(@Param("dto") OrderDto dto, @Param("userId") Long userId, @Param("ratio") Integer ratio,@Param("departmentId") Long departmentId);

	List<ReportSummaryVo> getRectifySummary(@Param("dto") OrderDto dto, @Param("userId") Long userId, @Param("ratio") Integer ratio,@Param("departmentId") Long departmentId);

    List<ReportSummaryVo> getAuditSummary(@Param("dto")OrderDto dto, @Param("userId") Long userId,@Param("ratio") Integer ratio, @Param("departmentId") Long departmentId);

    List<ReportSummaryVo> getVerifySummary(@Param("dto")OrderDto dto, @Param("userId") Long userId,@Param("ratio") Integer ratio, @Param("departmentId") Long departmentId);

	List<ReportSummaryVo> getValidateSummary(@Param("dto")OrderDto dto, @Param("userId") Long userId,@Param("ratio") Integer ratio, @Param("departmentId") Long departmentId);

    Page<RectifyOrderListVo> loadRectifyIssueList(@Param("dto") ReportOrderDto dto, @Param("userId") Long userId, @Param("departmentId") Long departmentId, @Param("ratio") Integer ratio, Page page);

	Page<RectifyOrderListVo> loadRectifyResultList(@Param("dto")ReportOrderDto dto, @Param("userId") Long userId, @Param("departmentId") Long departmentId, @Param("ratio") Integer ratio, Page page);

	Page<RectifyOrderListVo> loadRectifyAuditList(@Param("dto")ReportOrderDto dto, @Param("userId") Long userId, @Param("departmentId") Long departmentId, Page page);

	Page<RectifyOrderListVo> loadRectifyVerifyList(@Param("dto")ReportOrderDto dto, @Param("userId") Long userId, @Param("departmentId") Long departmentId, @Param("ratio") Integer ratio, Page page);

	Page<RectifyOrderListVo> loadRectifyValidateList(@Param("dto")ReportOrderDto dto, @Param("userId") Long userId, @Param("departmentId") Long departmentId, Page page);

    List<RectifySummaryVo> loadOrderRectifySummary(@Param("dto")OrderReportDto dto);

    List<Map<String, Object>> loadEconomyBenefit(@Param("dto")OrderReportDto dto);

    Long maxAuditNum(@Param("code") String code,@Param("process") Long process,@Param("state") Long state);

    Long getDeptIdByUser(@Param("userId") Long userId);

    Long getAuditUser(@Param("code") String code,@Param("process") Long process);

    Long maxAuditLevel(@Param("code") String code,@Param("process") Long process);

    Long getMaxId(@Param("tableName") String tableName);

	/**
	 * 获取当前审核等级
	 * @param code
	 * @param process
	 * @return
	 */
    Long getNowLevel(@Param("code") String code,@Param("process") Long process);

    Long getNowAuditUser(@Param("code") String code,@Param("process") Long process,@Param("level") Long level);
}
