package cn.com.ty.lift.business.maintenance.dao.mapper;

import cn.com.ty.lift.business.common.CommonRequest;
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
import cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenanceCount;
import cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenanceTask;
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenancePlanRequest;
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceRecordRequest;
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtPlanRequest;
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenanceAppResponse;
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenancePlanResponse;
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtPlanResponse;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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

/**
 * MyBatis Mapper 接口 - 表：maintenance_plan
 * @author bieao
 * @since 2019-12-12 11:27:30
 */
public interface MaintenancePlanMapper extends BaseMapper<MaintenancePlan> {

    IPage<MaintenancePlanResponse> findByCondition(IPage<MaintenancePlanResponse> page, @Param("request") MaintenancePlanRequest request);

    /**
     * @param request 用户id和维保状态
     * @return RestResponse 保养任务列表
     * @description 根据用户id和维保状态查询保养任务列表
     * @date 2020/4/24 5:03 下午
     */
    IPage<MaintenanceAppResponse> findPlanByWorkerId(IPage<MaintenancePlanResponse> page, @Param("request") MaintenanceRecordRequest request);

    /**
     * @param request 用户id
     * @return RestResponse 保养任务列表
     * @description 根据用户id查询保养任务列表
     * @date 2020/4/24 5:03 下午
     */
    List<MaintenanceCount> countPlanByWorkerId(@Param("request") MaintenanceRecordRequest request);

    IPage<MtPlanResponse> pagePlanByCondition(IPage<MtPlanResponse> page, @Param("cond") MtPlanRequest request);

    long countPlanByCondition(@Param("cond") MtPlanRequest request);

    List<MaintenancePlan> queryPlanListByIds(@Param("paramMap") Map<String, Object> paramMap);

    List<MaintenanceTask> queryMaintenanceTask();

    List<Map<String, String>> exportList(@Param("exportList") List<String> ids);

    long countWaitingMaintenanceByUser(@Param("request") CommonRequest request);

    @Select("SELECT count FROM maintenance_plan WHERE id = #{planId}")
    Long getCountByPlanId(Long planId);

}