|  |  |  | 
|---|
|  |  |  | @GetMapping("rtd-config") | 
|---|
|  |  |  | public ResultBean<Map<String,Object>> getRealTimeDevicetConfig(Integer orgId){ | 
|---|
|  |  |  | Map<String,Object> resultMap = new HashMap(); | 
|---|
|  |  |  | resultMap.put("deviceVersions",""); | 
|---|
|  |  |  | resultMap.put("sensors",""); | 
|---|
|  |  |  | resultMap.put("rtdLayout",""); | 
|---|
|  |  |  | resultMap.put("deviceVersions",new ArrayList<>()); | 
|---|
|  |  |  | resultMap.put("sensorCombs", new ArrayList<>()); | 
|---|
|  |  |  | resultMap.put("sensors", new ArrayList<>()); | 
|---|
|  |  |  | resultMap.put("rtdLayout", new HashMap<>()); | 
|---|
|  |  |  | // 获取当前组织所含设备版本数组 | 
|---|
|  |  |  | List<DeviceVersion> deviceVersionList = deviceVersionService.queryByOrgId(orgId); | 
|---|
|  |  |  | // 获取第一个version 下所有传感器 | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<Integer,List<SensorUnit>> resultListMap = new HashMap<>(); | 
|---|
|  |  |  | for(Integer sensorId: sensorIds) { | 
|---|
|  |  |  | sensorUnitQuery.setSensorId(sensorId); | 
|---|
|  |  |  | sensorUnitQuery.setIsDelete(false); | 
|---|
|  |  |  | List<SensorUnit> sensorUnitList = sensorUnitMapper.select(sensorUnitQuery); | 
|---|
|  |  |  | if(sensorUnitList!=null&&sensorUnitList.size()>0){ | 
|---|
|  |  |  | resultListMap.put(sensorId,sensorUnitList); | 
|---|
|  |  |  | 
|---|
|  |  |  | device dev | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | dev.monitor_point_id IN | 
|---|
|  |  |  | ( SELECT id FROM monitor_point mpt WHERE mpt.organization_id = #{orgId,jdbcType=INTEGER} ) | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | SELECT id FROM monitor_point mpt | 
|---|
|  |  |  | WHERE mpt.organization_id = #{orgId,jdbcType=INTEGER} | 
|---|
|  |  |  | or EXISTS ( | 
|---|
|  |  |  | SELECT * from dictionary_data where dict_data_key = 'auth_config_super_org' and dict_data_value = #{orgId,jdbcType=INTEGER} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | order by dvn.create_time desc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | 
|---|
|  |  |  | select * from sensor sen where sen.id in | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | select DISTINCT sensor_id from device_version_sensor dvs | 
|---|
|  |  |  | where dvs.device_version_id in ( | 
|---|
|  |  |  | where dvs.device_version_id | 
|---|
|  |  |  | in ( | 
|---|
|  |  |  | select DISTINCT device_version_id from device dev where | 
|---|
|  |  |  | EXISTS (select * from monitor_point mpt where | 
|---|
|  |  |  | mpt.organization_id = #{organizationId,jdbcType=INTEGER} and mpt.id = dev.monitor_point_id | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) order by sen.id asc | 
|---|
|  |  |  | OR EXISTS  ( | 
|---|
|  |  |  | SELECT * from dictionary_data | 
|---|
|  |  |  | where dict_data_key = 'auth_config_super_org' and dict_data_value = #{organizationId,jdbcType=INTEGER} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | order by sen.id asc | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|