| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.moral.api.entity.CityAqiDaily; |
| | | import com.moral.api.entity.CityAqiMonthly; |
| | | import com.moral.api.mapper.CityAqiMonthlyMapper; |
| | |
| | | //结束时间,本月1号 |
| | | Date end = DateUtils.addMonths(start, 1); |
| | | |
| | | //如果是1号,先删除上月数据再统计 |
| | | //不是1号,统计的是本月累计值,先删除本月数据 |
| | | int day = DateUtils.getDay(new Date()); |
| | | UpdateWrapper<CityAqiMonthly> cityAqiMonthlyUpdateWrapper = new UpdateWrapper<>(); |
| | | if (day == 1) { |
| | | cityAqiMonthlyUpdateWrapper.eq("time", start); |
| | | } else { |
| | | start = end; |
| | | end = DateUtils.addMonths(start, 1); |
| | | lastLastMonth = DateUtils.addMonths(start, -1); |
| | | cityAqiMonthlyUpdateWrapper.eq("time", start); |
| | | } |
| | | cityAqiMonthlyMapper.delete(cityAqiMonthlyUpdateWrapper); |
| | | |
| | | |
| | | //获取所有城市aqi小时数据 |
| | | QueryWrapper<CityAqiDaily> wrapper = new QueryWrapper<>(); |
| | |
| | | |
| | | List<CityAqiMonthly> cityAqiMonthlyList = new ArrayList<>(); |
| | | |
| | | Date finalStart = start; |
| | | data.forEach((cityCode, value) -> { |
| | | CityAqiMonthly cityAqiMonthly = new CityAqiMonthly(); |
| | | Map<String, Object> jsonMap = new HashMap<>(); |
| | | cityAqiMonthly.setCityCode(Integer.parseInt(cityCode)); |
| | | cityAqiMonthly.setTime(start); |
| | | cityAqiMonthly.setTime(finalStart); |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | List<Map<String, Object>> temp = new ArrayList<>(); |