|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 { | 
|---|
|  |  |  | 
|---|
|  |  |  | historyAqi.setGuid(guid); | 
|---|
|  |  |  | historyAqi.setTime(DateUtils.addHours(time, -1)); | 
|---|
|  |  |  | //存入数据库 | 
|---|
|  |  |  | historyAqi.setJson(JSONObject.toJSONString(map)); | 
|---|
|  |  |  | historyAqi.setValue(JSONObject.toJSONString(map)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | historyAqis.add(historyAqi); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //aqi数据存入redis | 
|---|
|  |  |  | redisTemplate.opsForHash().put(RedisConstants.AQI_DATA, guid, value); | 
|---|
|  |  |  | //                historyAqiMapper.insert(historyAqi); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(historyAqis)){ | 
|---|
|  |  |  | XxlJobHelper.log("数据不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //存入数据库 | 
|---|
|  |  |  | historyAqiMapper.insertHistoryAqi(historyAqis); | 
|---|
|  |  |  | } | 
|---|