/*
 * Author: wangjian
 * 生成mapper
 */
package com.tofly.gpsboot.mapper.maintain;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.pojo.statement.vo.MaintenanceLogLedgerVo;
import com.tofly.pojo.statement.vo.MaintenanceTypeStatisticsVo;
import com.tofly.pojo.maintain.Repairorder;
import com.tofly.pojo.maintain.Repairtype;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 维修类型信息表
 *
 * @author admin
 * @date Tue Apr 06 00:00:00 CST 2021
 */
public interface RepairtypeMapper extends BaseMapper<Repairtype> {
    /**
     * 获取维修类型统计
     * @param page
     * @param queryWrapper
     * @return
     */
    @Select("select p.ID orderId,p.ADDRESS address,p.ORDER_CODE orderCode,p.OVER_TIME overTime,p.PHONE mobile,p.CREATE_TIME generatedTime, " +
            "p.TYPE_ID typeId,t.NAME typeName  " +
            "from TF_YWPN_REPAIRORDER_W p LEFT JOIN TF_YWPN_REPAIRTYPE_D t on p.TYPE_ID = t.ID " +
            "${ew.customSqlSegment} " +
            "order by overTime DESC")
    Page<MaintenanceLogLedgerVo> getPageMaintenanceTypeStatisticsInfo(Page<MaintenanceTypeStatisticsVo> page, @Param(Constants.WRAPPER) QueryWrapper<Repairorder> queryWrapper);

    /**
     * 判断当前维修类型是否允许删除
     *
     * @return
     */
    @Select("select  count(*) " +
            "from TF_YWPN_REPAIRTYPE_D p LEFT JOIN TF_YWPN_REPAIRGOODS_W t1 on p.ID = t1.MATERIAL_TYPE " +
            "LEFT JOIN TF_YWPN_REPAIRORDER_W t2 on p.ID = t2.TYPE_ID " +
            "LEFT JOIN TF_YWPN_REPAIRPLANDETAIL_W t3 on p.ID = t3.TYPE_ID " +
            "${ew.customSqlSegment} ")
    Integer isDelete(@Param(Constants.WRAPPER) QueryWrapper<Repairorder> queryWrapper);

    @Select("SELECT id " +
            "FROM " +
            "tf_smpn_user_x")
    List<Long> getUserIdList();
}
