| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.time.Instant;
|
| | | import java.time.LocalDate;
|
| | | import java.time.LocalDateTime;
|
| | |
| | | import com.moral.entity.Sensor;
|
| | | import com.moral.mapper.DeviceMapper;
|
| | | import com.moral.mapper.HistoryMapper;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.mapper.OrganizationRelationMapper;
|
| | | import com.moral.mapper.SensorMapper;
|
| | | import com.moral.mapper.SensorUnitMapper;
|
| | |
| | |
|
| | | @Resource
|
| | | private OrganizationRelationMapper organizationRelationMapper;
|
| | | |
| | | @Resource
|
| | | private MonitorPointMapper monitorPointMapper;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getAllSensorAverageByDevice(Map<String, Object> parameters) throws Exception {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getMointorPointRankByOrganizationId(Map<String, Object> parameters) {
|
| | | public List<Map<String, Object>> getMointorPointRankByOrganizationId(Map<String, Object> parameters) {
|
| | | //获取组织id
|
| | | String organizationId = parameters.get("organization_id").toString();
|
| | | //声明一个集合存放要查询站点数据的组织id
|
| | |
| | | for(int i=0;i<10;i++) {
|
| | | if(!parentIdList.isEmpty()) {
|
| | | //或去该组织下的子组织
|
| | | System.out.println("parentIdList:"+parentIdList);
|
| | | List<Map<String, Object>> childIdList = organizationRelationMapper.getChildIdByParentId(parentIdList);
|
| | | //清空父组织id集合
|
| | | parentIdList.clear();
|
| | | System.out.println("childIdList:"+childIdList);
|
| | | //将子组织id放入到集合中
|
| | | for (Map<String, Object> map : childIdList) {
|
| | | organizationIdList.add(map.get("child_id"));
|
| | |
| | | }
|
| | | System.out.println(organizationIdList);
|
| | |
|
| | | return null;
|
| | | //根据组织id获取站点id
|
| | | List<Map<String, Object>> monitorPointIdListMap = monitorPointMapper.getIdByOrganizationId(organizationIdList);
|
| | | //将List<Map<String, Object>>装换为List<Object>
|
| | | List<Object> monitorPointIdList = new ArrayList<>();
|
| | | for (Map<String, Object> map : monitorPointIdListMap) {
|
| | | monitorPointIdList.add(map.get("id"));
|
| | | }
|
| | | |
| | | //通过站点id获取设备因子的排名
|
| | | //获取系统当前时间
|
| | | Calendar rightNow = Calendar.getInstance();
|
| | | //获取五分钟前的时间
|
| | | Calendar beforeTime = Calendar.getInstance();
|
| | | beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间
|
| | | Date beforeD = beforeTime.getTime();
|
| | | Date end = rightNow.getTime();
|
| | | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(end);
|
| | | String before5Time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(beforeD); // 前五分钟时间
|
| | | |
| | | String sensor = parameters.get("sensor").toString();
|
| | | List<Map<String, Object>> result = historyMapper.getAVGSensorRankByMonitorPointIdList(sensor, monitorPointIdList, before5Time, endTime);
|
| | | return result;
|
| | | }
|
| | | }
|