package cn.com.taiji.track.mapper;

import cn.com.taiji.track.dto.BeidouShipLocationDTO;
import cn.com.taiji.track.entity.BeidouLocationEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenfangchao
 * @title: GeoServerMapper
 * @projectName ax-geoserver-project
 * @description: TODO
 * @date 2022/8/16 7:54 PM
 */
@Mapper
public interface BeidouLocationMapper extends BaseMapper<BeidouLocationEntity> {
    @Select("SELECT\n" +
            "\tl.*,\n" +
            "\ts.is_online,\n" +
            "\ts.is_inport,\n" +
            "\ts.is_anchor,\n" +
            "\tIFNULL( d.dispose_type, 0 ) AS dispose_type,\n" +
            "\tIFNULL( dept.xw_dept_id, '' ) AS xw_dept_id,\n" +
            "\tIFNULL( l.ship_name, ship_id ) AS ship_name \n" +
            "FROM\n" +
            "\tax_beidou_ship_location l\n" +
            "\tLEFT JOIN ax_beidou_ship_status s ON s.device_id = l.device_id\n" +
            "\tLEFT JOIN ax_beidou_ship_dispose d ON d.devide_no = l.device_id\n" +
            "\tLEFT JOIN ax_beidou_ship_archives a ON a.devide_no = l.device_id\n" +
            "\tLEFT JOIN ax_beidou_dept dept ON dept.pscbh = a.police_station_id \n" +
            "ORDER BY\n" +
            "\tdevice_id,\n" +
            "\tlocation_time")
    List<BeidouShipLocationDTO> listLocation();
}

