| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.GovMonitorPoint; |
| | | import com.moral.api.mapper.GovMonitorPointMapper; |
| | | import com.moral.api.service.GovMonitorPointService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.RegionCodeUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class GovMonitorPointServiceImpl extends ServiceImpl<GovMonitorPointMapper, GovMonitorPoint> implements GovMonitorPointService { |
| | | |
| | | @Autowired |
| | | GovMonitorPointMapper govMonitorPointMapper; |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | | public List<GovMonitorPoint> queryGovMonitorPointAndDataByRegionCode(Integer regionCode) { |
| | | String regionCodeStr = RegionCodeUtils.regionCodeConvertToName(regionCode); |
| | | QueryWrapper<GovMonitorPoint> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq(regionCodeStr,regionCode); |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | wrapper.select("guid","name","longitude","latitude","station_level"); |
| | | List<GovMonitorPoint> govMonitorPoints = govMonitorPointMapper.selectList(wrapper); |
| | | for (GovMonitorPoint govMonitorPoint : govMonitorPoints) { |
| | | Object data = redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, govMonitorPoint.getGuid()); |
| | | if(data!=null) |
| | | govMonitorPoint.setData(String.valueOf(data)); |
| | | } |
| | | return govMonitorPoints; |
| | | } |
| | | } |