|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.moral.api.config.mybatis.MybatisPlusConfig; | 
|---|
|  |  |  | import com.moral.api.entity.*; | 
|---|
|  |  |  | import com.moral.api.mapper.DeviceMapper; | 
|---|
|  |  |  | import com.moral.api.mapper.HistoryFiveMinutelyMapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.moral.api.mapper.HistoryHourlyMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.moral.constant.SeparateTableType; | 
|---|
|  |  |  | import com.moral.util.DateUtils; | 
|---|
|  |  |  | import com.moral.util.MybatisPLUSUtils; | 
|---|
|  |  |  | import com.moral.util.RegionCodeUtils; | 
|---|
|  |  |  | import io.lettuce.core.GeoCoordinates; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | HistoryHourlyMapper historyHourlyMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | DeviceService deviceService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | DeviceMapper deviceMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<DeviceAndFiveMinuteDataDTO> queryDeviceAndFiveMinuteData(QueryDeviceAndFiveMinuteDataForm form) { | 
|---|
|  |  |  | 
|---|
|  |  |  | Integer organizationId = form.getOrganizationId(); | 
|---|
|  |  |  | Integer regionCode = form.getRegionCode(); | 
|---|
|  |  |  | String sensorCode = form.getSensorCode(); | 
|---|
|  |  |  | Map<String, Object> params = new HashMap<>(); | 
|---|
|  |  |  | String region = null; | 
|---|
|  |  |  | if (regionCode != null && organizationId!=24) { | 
|---|
|  |  |  | region = RegionCodeUtils.regionCodeConvertToName(regionCode); | 
|---|
|  |  |  | params.put("region",region); | 
|---|
|  |  |  | params.put("regionCode",regionCode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | params.put("organizationId",organizationId); | 
|---|
|  |  |  | //查询组织在对应地区下的站点以及设备 | 
|---|
|  |  |  | List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(new MonitorPointQueryForm(organizationId, regionCode)); | 
|---|
|  |  |  | /*List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(new MonitorPointQueryForm(organizationId, regionCode)); | 
|---|
|  |  |  | List<Device> devices = new ArrayList<>(); | 
|---|
|  |  |  | for (MonitorPoint monitorPoint : monitorPoints) { | 
|---|
|  |  |  | List<Device> monitorPointDevices = monitorPoint.getDevices(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | //查询所有设备对应的数据 | 
|---|
|  |  |  | List<Device> devices = deviceMapper.deviceList(organizationId,regionCode,region); | 
|---|
|  |  |  | List<DeviceAndFiveMinuteDataDTO> dtos = new ArrayList<>(); | 
|---|
|  |  |  | if (form.getChooseTime().equals("true")) { | 
|---|
|  |  |  | String time = form.getTime(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return dtos; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //List<Map<String, Object>> sensorValuess = (List<Map<String, Object>>) redisTemplate.opsForValue().multiGet(Arrays.asList("data_five_minutes:p5dnd7a0245400","data_five_minutes:p5dnd7a0245412")); | 
|---|
|  |  |  | for (Device device : devices) { | 
|---|
|  |  |  | DeviceAndFiveMinuteDataDTO dto = new DeviceAndFiveMinuteDataDTO(); | 
|---|
|  |  |  | String mac = device.getMac(); | 
|---|
|  |  |  | Map<String, Object> sensorValues = queryLastDataByMac(mac); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String dbDataStr = JSON.toJSONString(sensorValues); | 
|---|
|  |  |  | sensorValues = JSON.parseObject(dbDataStr, HashMap.class); | 
|---|
|  |  |  | Map<String, Object> sensorValue = new HashMap<>(); | 
|---|