| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.HistoryMonthlyMapper; |
| | | import com.moral.api.mapper.OrganizationMapper; |
| | | |
| | | import com.moral.api.pojo.dto.dataDisplay.MonitorPointDataDisplayDTO; |
| | | import com.moral.api.pojo.dto.dataDisplay.SensorComparisonDisplayDTO; |
| | | import com.moral.api.pojo.form.dataDisplay.MonitorPointDataDisplayForm; |
| | | import com.moral.api.pojo.form.dataDisplay.SensorComparisonDisplayForm; |
| | | |
| | | import com.moral.api.service.*; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.SeparateTableType; |
| | | import com.moral.pojo.AQI; |
| | | import com.moral.util.*; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.moral.util.DateUtils.dateToDateString; |
| | | |
| | | /** |
| | | * @ClassName DataDisplayServiceImpl |
| | |
| | | * @Version TODO |
| | | **/ |
| | | @Service |
| | | @Slf4j |
| | | public class DataDisplayServiceImpl implements DataDisplayService { |
| | | |
| | | @Autowired |
| | |
| | | HistoryWeeklyService historyWeeklyService; |
| | | @Autowired |
| | | HistoryMonthlyService historyMonthlyService; |
| | | @Autowired |
| | | OrganizationMapper organizationMapper; |
| | | |
| | | @Autowired |
| | | DeviceMapper deviceMapper; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 热力图 |
| | | * @param code |
| | | * @param startTime |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ArrayList<Map<String, Object>> getHeatMapData(String code, String startTime, String type,String form) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("start",startTime); |
| | | map.put("type","$."+ type); |
| | | map.put("sensorCode","count"); |
| | | map.put("regionCode",null); |
| | | map.put("region",null); |
| | | |
| | | //获取用户信息 |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | | Integer organizationId = (Integer) orgInfo.get("id"); |
| | | //大账号 |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | if (organizationId==24){ |
| | | LambdaQueryWrapper<Organization> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Organization::getIsDelete,Constants.NOT_DELETE); |
| | | wrapper.eq(Organization::getCityCode,code); |
| | | List<Organization> organizations = organizationMapper.selectList(wrapper); |
| | | List<Integer> collect = organizations.stream().map(organization -> organization.getId()).collect(Collectors.toList()); |
| | | list.addAll(collect); |
| | | }else { |
| | | list.add(organizationId); |
| | | } |
| | | |
| | | ArrayList<Map<String, Object>> rsHeatMap = new ArrayList<>(); |
| | | // ArrayList<HeatMapDTO> rsHeatMap = new ArrayList<>(); |
| | | |
| | | if (form.equals("hour")){ //小时 |
| | | Date date1 = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_EN); |
| | | List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(date1, date1, SeparateTableType.MONTH); |
| | | // for (Integer integer : list) { |
| | | map.put("organizationIds",list); |
| | | map.put("tableName",tableNames.get(0)); |
| | | List<Map<String, Object>> heatMap = deviceMapper.getHeatMap(map); |
| | | // List<HeatMapDTO> heatMap = deviceMapper.getHeatMap(map); |
| | | rsHeatMap.addAll(heatMap); |
| | | // } |
| | | |
| | | }else { //天 |
| | | // for (Integer integer : list) { |
| | | map.put("organizationIds",list); |
| | | List<Map<String, Object>> heatMap = deviceMapper.getHeatMap(map); |
| | | // List<HeatMapDTO> heatMap = deviceMapper.getHeatMap(map); |
| | | rsHeatMap.addAll(heatMap); |
| | | // } |
| | | } |
| | | |
| | | //除去为空数据 |
| | | ArrayList<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | for (Map<String, Object> map1 : rsHeatMap) { |
| | | boolean hasEmptyValue = false; |
| | | for (Object value : map1.values()) { |
| | | if (value == null) { |
| | | hasEmptyValue = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!hasEmptyValue) { |
| | | filteredList.add(map1); |
| | | } |
| | | } |
| | | log.info(filteredList.size()+""); |
| | | return filteredList; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 根据时间进行排序 |
| | | * @Param: [timeValueMap, reportType] |
| | | * @return: java.util.Map<java.lang.String , java.lang.String> |