package com.elephant.framework.galaxy.aroad.module.emergency.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elephant.framework.galaxy.aroad.module.emergency.dto.CarCoordinateDto;
import com.elephant.framework.galaxy.aroad.module.emergency.dto.TeamEquipmentInfoDto;
import com.elephant.framework.galaxy.aroad.module.emergency.entity.EmergencyCar;
import com.elephant.framework.galaxy.aroad.module.emergency.mapper.EmergencyCarMapper;
import com.elephant.framework.galaxy.aroad.module.emergency.service.EmergencyCarService;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 应急处置车辆
 *
 * @author songwenjie
 * @date 2019-03-21 14:50:26
 */
@Service
public class EmergencyCarServiceImpl extends ServiceImpl<EmergencyCarMapper, EmergencyCar> implements EmergencyCarService {

    public IPage<EmergencyCar> getEmergencyCarPage(Page<EmergencyCar> page, @Param("text") String text) {
        return baseMapper.getEmergencyCarPage(page, text);
    }

    /**
     * @Description: 通过id获取应急队伍的坐标信息
     * @Param: []
     * @return: java.util.List<com.elephant.framework.galaxy.aroad.module.emergency.dto.CarCoordinateDto>
     * @Author: songwenjie
     * @Date: 2019/4/2
     */
    @Cacheable(value = "carCoordinates")
    public List<CarCoordinateDto> getCoordinates(String teamIds) {
        List<String> teamIdList = Arrays.asList(teamIds.split(","));
        return baseMapper.getCoordinates(teamIdList);
    }

    /**
     * @Description: 获取队伍列表
     * @Param:
     * @return:
     * @Author: XingYuyang
     * @Date: 2019-04-15 10:11:13
     */
    @Cacheable(value = "getTeamsC")
    public List<TeamEquipmentInfoDto> getTeams() {
        return baseMapper.getTeams();
    }
}
