/*
 * Author: Zev
 * 生成mapper
 */
package com.tofly.gpsboot.mapper.trouble;

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.dto.StatementDto;
import com.tofly.pojo.statement.vo.TroubleRecordLedgerVo;
import com.tofly.pojo.trouble.Trouble;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 隐患上报信息表
 *
 * @author admin
 * @date Thu Mar 18 00:00:00 CST 2021
 */
public interface TroubleMapper extends BaseMapper<Trouble> {
    @Select("select p.PIPE_NAME pipeName, p.LOCATION location, p.ADDRESS address,p.TYPE_ID troubleTypeId,v.name troubleTypeName, m.id rangeId,m.name rangeName,p.NOTES note, p.CREATE_TIME troubleTime,p.ISBUILD isBuild, " +
            "p.SUGGEST suggest,t.AUDIT_RESULT isSuggest,t.AUDIT_TIME auditTime,t.NOTES eliminateTroubleNotes,p.SUBMIT_USER submitUserid,p.SUBMIT_TIME submitTime " +
            "from TF_YWPN_TROUBLE_W p LEFT JOIN TF_YWPN_TOUBLECLEAR_W t on p.ID = t.TOUBLE_ID " +
            "LEFT JOIN TF_YWPN_TOUBLETYPE_D v on v.ID = p.TYPE_ID " +
            "LEFT JOIN TF_YWPN_TOUBLERANGE_D m on m.ID = p.TOUBLE_RANGE_ID " +
            "${ew.customSqlSegment} " +
            "order by troubleTime DESC")
    Page<TroubleRecordLedgerVo> searchWeeklyPage(Page<TroubleRecordLedgerVo> page, @Param(Constants.WRAPPER) QueryWrapper<StatementDto> queryWrapper);
}
