kaiyu
2021-09-24 8e9a6b3013b877faa78bff87954dabe873e4eac7
screen-api/src/main/java/com/moral/api/service/impl/GovMonitorPointServiceImpl.java
@@ -1,10 +1,18 @@
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>
@@ -17,4 +25,24 @@
@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;
    }
}