|  |  |  | 
|---|
|  |  |  | return new ResultBean<Map<String, Object>>(map); | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("getSensorByMonitorPointId") | 
|---|
|  |  |  | /*@GetMapping("getSensorByMonitorPointId") | 
|---|
|  |  |  | @ApiOperation(value = "返回单位", notes = "返回单位") | 
|---|
|  |  |  | @ApiImplicitParams(value = { | 
|---|
|  |  |  | @ApiImplicitParam(name = "monitor_point_id", value = "监测站点id", required = true, paramType = "query", dataType = "String") | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, Object> map = sensorUnitService.getSensorsByMonitPointId(monitor_point_id); | 
|---|
|  |  |  | System.out.println("ScreenController-----getSensorByMonitorPointId-----map:"+map); | 
|---|
|  |  |  | return new ResultBean<Map<String, Object>>(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("AIForecast") | 
|---|
|  |  |  | @ApiOperation(value = "AI预测", notes = "AI预测") | 
|---|
|  |  |  | 
|---|
|  |  |  | Object sensorKey = parameters.remove("sensorKey"); | 
|---|
|  |  |  | parameters.put("sensors", Arrays.asList(sensorKey)); | 
|---|
|  |  |  | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters); | 
|---|
|  |  |  | System.out.println("ScreenController-----AIForecast-----list:"+list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取单位信息 | 
|---|
|  |  |  | Map<String, Object> sensorMap = sensorUnitService.getSensorsByMonitPointId(monitor_point_id); | 
|---|
|  |  |  | Map<String, Map<String, Object>> sensorMap = sensorUnitService.getSensorsByMonitPointId(monitor_point_id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (Map<String, Object> map : list) { | 
|---|
|  |  |  | String time = map.get("time").toString(); | 
|---|
|  |  |  | time = time.substring(time.length() - 2); | 
|---|
|  |  |  | map.put("time", Integer.valueOf(time)); | 
|---|
|  |  |  | map.put("value", map.remove(sensorKey)); | 
|---|
|  |  |  | if(sensorMap!=null && !sensorMap.isEmpty()) { | 
|---|
|  |  |  | for (Map<String, Object> map : list) { | 
|---|
|  |  |  | String time = map.get("time").toString(); | 
|---|
|  |  |  | time = time.substring(time.length() - 2); | 
|---|
|  |  |  | map.put("time", Integer.valueOf(time)); | 
|---|
|  |  |  | map.put("value", map.remove(sensorKey)); | 
|---|
|  |  |  | String sensor = map.get("sensorKey").toString(); | 
|---|
|  |  |  | if(sensorMap.get(sensor)!=null) { | 
|---|
|  |  |  | map.put("unit", sensorMap.get("unit")); | 
|---|
|  |  |  | map.put("name", sensorMap.get("name")); | 
|---|
|  |  |  | map.put("rules", sensorMap.get("rules")); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | map.put("unit", null); | 
|---|
|  |  |  | map.put("name", null); | 
|---|
|  |  |  | map.put("rules", null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | for (Map<String, Object> map : list) { | 
|---|
|  |  |  | String time = map.get("time").toString(); | 
|---|
|  |  |  | time = time.substring(time.length() - 2); | 
|---|
|  |  |  | map.put("time", Integer.valueOf(time)); | 
|---|
|  |  |  | map.put("value", map.remove(sensorKey)); | 
|---|
|  |  |  | map.put("unit", null); | 
|---|
|  |  |  | map.put("name", null); | 
|---|
|  |  |  | map.put("rules", null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | //return new ResultBean<List<Map<String, Object>>>(result); | 
|---|
|  |  |  | //return null; | 
|---|
|  |  |  | return new ResultBean<List<Map<String, Object>>>(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> getSensorByMac(String mac); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> getSensorsByMonitPointId(String id); | 
|---|
|  |  |  | //Map<String, Object> getSensorsByMonitPointId(String id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Map<String, Object>> getSensorsByMonitPointId(String id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | /*@Override | 
|---|
|  |  |  | public Map<String, Object> getSensorsByMonitPointId(String id) { | 
|---|
|  |  |  | System.out.println("SensorUnitServiceImpl-----getSensorsByMonitPointId-----id:"+id); | 
|---|
|  |  |  | List<Map<String, Object>> list = sensorUnitMapper.getSensorsByMonitPointId(id); | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, Object> sensorUnitMap =  null; | 
|---|
|  |  |  | return sensorUnitMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Map<String, Map<String, Object>> getSensorsByMonitPointId(String id) { | 
|---|
|  |  |  | System.out.println("SensorUnitServiceImpl-----getSensorsByMonitPointId-----id:"+id); | 
|---|
|  |  |  | List<Map<String, Object>> list = sensorUnitMapper.getSensorsByMonitPointId(id); | 
|---|
|  |  |  | System.out.println("SensorUnitServiceImpl----getSensorsByMonitPointId----list:"+list); | 
|---|
|  |  |  | if (list!=null && !list.isEmpty()) { | 
|---|
|  |  |  | Map<String, Object> innerMap = new HashMap<>(); | 
|---|
|  |  |  | Map<String, Map<String, Object>> sensorUnitMap = new HashMap<>(); | 
|---|
|  |  |  | for(Map<String, Object> sensorMap : list) { | 
|---|
|  |  |  | innerMap.put("unit", sensorMap.get("unit")); | 
|---|
|  |  |  | innerMap.put("name", sensorMap.get("name")); | 
|---|
|  |  |  | innerMap.put("rules", sensorMap.get("rules")); | 
|---|
|  |  |  | String sensor_key = (String) sensorMap.get("sensor_key"); | 
|---|
|  |  |  | System.out.println("SensorUnitServiceImpl----getSensorsByMonitPointId----sensor_key:"+sensor_key); | 
|---|
|  |  |  | String name = (String) sensorMap.get("name"); | 
|---|
|  |  |  | System.out.println("SensorUnitServiceImpl----getSensorsByMonitPointId----name:"+name); | 
|---|
|  |  |  | sensorUnitMap.put(sensor_key, innerMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | System.out.println(sensorUnitMap); | 
|---|
|  |  |  | return sensorUnitMap; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Map<String, Map<String, Object>> sensorUnitMap =  null; | 
|---|
|  |  |  | return sensorUnitMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getSensorsByMonitPointId" resultType="java.util.Map"> | 
|---|
|  |  |  | SELECT mp.id,s.sensor_key,su.id,su.sensor_id,su.name,su.rules | 
|---|
|  |  |  | SELECT mp.id,s.sensor_key,s.unit,su.id,su.sensor_id,su.name,su.rules | 
|---|
|  |  |  | FROM monitor_point mp,organization org,organization_sensor_unit osu,sensor_unit su, sensor s | 
|---|
|  |  |  | WHERE mp.organization_id = org.id | 
|---|
|  |  |  | AND org.id = osu.organization_id | 
|---|