cjl
2023-07-26 0ce061d9ed37a6c25fff70e4734fa8cc8747237c
screen-job/src/main/java/com/moral/api/service/impl/HistoryAqiServiceImpl.java
@@ -11,6 +11,7 @@
import com.moral.constant.Constants;
import com.moral.constant.RedisConstants;
import com.moral.util.DateUtils;
import com.xxl.job.core.context.XxlJobHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -72,6 +73,7 @@
        List<GovMonitorPoint> govMonitorPoints = govMonitorPointService.list(queryWrapper);
        Date time = DateUtils.dataToTimeStampTime(new Date(), DateUtils.yyyy_MM_dd_HH_EN);
        String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
//        String timeStr = DateUtils.dateToDateString(DateUtils.addHours(time, -1), DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
        List<HistoryAqi> historyAqis = new ArrayList<>();
@@ -96,8 +98,7 @@
                historyAqi.setGuid(guid);
                historyAqi.setTime(DateUtils.addHours(time, -1));
                //存入数据库
//                historyAqi.setValue(JSONObject.toJSONString(map));
               historyAqi.setJson(JSONObject.toJSONString(map));
                historyAqi.setValue(JSONObject.toJSONString(map));
                historyAqis.add(historyAqi);
@@ -132,8 +133,13 @@
                    value.put(Constants.SENSOR_CODE_O3, o3);
                }
                //aqi数据存入redis
                redisTemplate.opsForHash().put(RedisConstants.AQI_DATA, guid, value);
//                historyAqiMapper.insert(historyAqi);
            }else {
                ResponseEntity<String> response;
                try {
@@ -151,7 +157,7 @@
                historyAqi.setGuid(guid);
                historyAqi.setTime(DateUtils.addHours(time, -1));
                //存入数据库
                historyAqi.setJson(JSONObject.toJSONString(map));
                historyAqi.setValue(JSONObject.toJSONString(map));
                historyAqis.add(historyAqi);
@@ -188,9 +194,14 @@
                //aqi数据存入redis
                redisTemplate.opsForHash().put(RedisConstants.AQI_DATA, guid, value);
//                historyAqiMapper.insert(historyAqi);
            }
        }
        if (ObjectUtils.isEmpty(historyAqis)){
            XxlJobHelper.log("数据不存在");
        }
        //存入数据库
        historyAqiMapper.insertHistoryAqi(historyAqis);
    }