| | |
| | | package com.moral.service.impl; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import com.moral.common.exception.BusinessException; |
| | | import com.moral.common.util.ReportTimeFormat; |
| | | import com.moral.entity.Organization; |
| | | import com.moral.entity.charts.TimePeriod; |
| | | import com.moral.entity.charts.TimeUnits; |
| | | import com.moral.mapper.HangzhouAqiMapper; |
| | | import com.moral.mapper.OrganizationMapper; |
| | | import com.moral.service.HangzhouAqiService; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Auther: fengxiang |
| | |
| | | * @param orgId |
| | | * @return 返回长度为24的数组,查不到的数据设置为0 |
| | | */ |
| | | @Override |
| | | public List<Map> queryAqi24Hours(Integer orgId) { |
| | | List<Map> aqi24HoursValues = new ArrayList<>(24); |
| | | @SuppressWarnings("serial") |
| | | @Override |
| | | public List<Map<String, Object>> queryAqi24Hours(Integer orgId) { |
| | | List<Map<String, Object>> aqi24HoursValues = new ArrayList<>(24); |
| | | /* |
| | | Date now = ReportTimeFormat.getFormatDate(ReportTimeFormat.HOUR_FORMAT); |
| | | Date start = ReportTimeFormat.dateCalc(now, TimeUnits.HOUR,-24); |
| | | Date end = ReportTimeFormat.dateCalc(now, TimeUnits.MILLISECOND,-1);; |
| | |
| | | aqiItem.put("aqi",aqiValue); |
| | | aqi24HoursValues.add(aqiItem); |
| | | } |
| | | */ |
| | | Organization organization = organizationMapper.selectByPrimaryKey(orgId); |
| | | |
| | | Map<String, Object> parameters = new HashMap<String, Object>(){{ |
| | | put("end", LocalDateTime.now()); |
| | | put("cityCode", organization.getAreaCode()); |
| | | }}; |
| | | aqi24HoursValues = hangzhouAqiMapper.getAqisByOrganizationId(parameters); |
| | | if (ObjectUtils.isEmpty(aqi24HoursValues)) { |
| | | parameters.put("cityCode", organization.getCityCode()); |
| | | aqi24HoursValues = hangzhouAqiMapper.getAqisByOrganizationId(parameters); |
| | | } |
| | | Collections.reverse(aqi24HoursValues); |
| | | return aqi24HoursValues; |
| | | } |
| | | private Integer getCode(Integer orgId,boolean isGetCityCode) |