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.MaterialCoordinateDto;
import com.elephant.framework.galaxy.aroad.module.emergency.dto.TeamEquipmentInfoDto;
import com.elephant.framework.galaxy.aroad.module.emergency.entity.EmergencyMaterial;
import com.elephant.framework.galaxy.aroad.module.emergency.mapper.EmergencyMaterialMapper;
import com.elephant.framework.galaxy.aroad.module.emergency.service.EmergencyMaterialService;
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;
import java.util.Map;

/**
 * 应急处置物资
 *
 * @author songwenjie
 * @date 2019-03-21 14:50:12
 */
@Service
public class EmergencyMaterialServiceImpl extends ServiceImpl<EmergencyMaterialMapper, EmergencyMaterial> implements EmergencyMaterialService {
    public IPage<EmergencyMaterial> getEmergencyMaterialPage(Page<EmergencyMaterial> page, @Param("text") String text) {
        return baseMapper.getEmergencyMaterialPage(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 = "materialCoordinates")
    public List<MaterialCoordinateDto> 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 = "getTeamsM")
    public List<TeamEquipmentInfoDto> getTeams() {
        return baseMapper.getTeams();
    }

    @Override
    /**
     * @Description: 应急资源全部经纬度
     * @Author: xuyanqi
     * @Date: 2019-5-8 09：10
     */
    public List<Map<String,Object>> getLngLat(){
        return baseMapper.queryLngLat();
    }

    @Override
    public List<EmergencyMaterial> getByIds(List<String> idList) {
        return baseMapper.selectBatchIds(idList);
    }

}
