| | |
| | | @Resource
|
| | | SensorService sensorService;
|
| | | @Resource
|
| | | SensorUnitService sensorUnitService;
|
| | | @Resource
|
| | | MonitorPointService monitorPointService;
|
| | | @Resource
|
| | | DeviceVersionService deviceVersionService;
|
| | |
| | | return model;
|
| | | }
|
| | | }
|
| | | |
| | | /*@GetMapping("getSensor")
|
| | | @ApiOperation(value = "返回单位", notes = "返回单位")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "mac", value = "设备MN号", required = true, paramType = "query", dataType = "String")
|
| | | })
|
| | | public ResultBean<Map<String, Object>> getSensor(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | String mac = (String) parameters.get("mac");
|
| | | //System.out.println("ScreenController-----getSensor-----mac:"+mac);
|
| | | Map<String, Object> map = sensorUnitService.getSensorByMac(mac);
|
| | | System.out.println("ScreenController-----getSensor-----map:"+map);
|
| | | return new ResultBean<Map<String, Object>>(map);
|
| | | }*/
|
| | | |
| | | @GetMapping("getSensorByMonitorPointId")
|
| | | @ApiOperation(value = "返回单位", notes = "返回单位")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "monitor_point_id", value = "监测站点id", required = true, paramType = "query", dataType = "String")
|
| | | })
|
| | | public ResultBean<Map<String, Object>> getSensorByMonitorPointId(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | String monitor_point_id = (String) parameters.get("monitor_point_id");
|
| | | System.out.println("ScreenController-----getSensorByMonitorPointId-----monitor_point_id:"+monitor_point_id);
|
| | | 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预测")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "monitorPoint", value = "监控站id", required = true, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "mac", value = "设备mac", required = false, paramType = "query", dataType = "String"),
|
| | | @ApiImplicitParam(name = "sensorKey", value = "传感器key,如有多个用逗号分隔", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间,天(格式:2018-03-06)", required = true, paramType = "query", dataType = "String"), |
| | | })
|
| | | public ResultBean<List<Map<String, Object>>> AIForecast (HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | ParameterUtils.getTimeType4Time(parameters);
|
| | | String monitor_point_id = (String) parameters.get("monitorPoint");
|
| | | parameters.put("monitorPointId", parameters.remove("monitorPoint"));
|
| | | Object sensorKey = parameters.remove("sensorKey");
|
| | | parameters.put("sensors", Arrays.asList(sensorKey));
|
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
|
| | | |
| | | //获取单位信息
|
| | | 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));
|
| | | }
|
| | | |
| | | return null;
|
| | | //return new ResultBean<List<Map<String, Object>>>(result);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.moral.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.moral.common.mapper.BaseMapper; |
| | | import com.moral.entity.SensorUnit; |
| | | |
| | | public interface SensorUnitMapper extends BaseMapper<SensorUnit> { |
| | | |
| | | List<Map<String, Object>> getSensorsByDeviceMac(@Param("mac")String mac); |
| | | |
| | | List<Map<String, Object>> getSensorsByMonitPointId(@Param("id")String id); |
| | | |
| | | } |
| | |
| | | void remove(Integer id); |
| | | |
| | | Map<Integer,List<SensorUnit>> queryGroupSensorBySids(List<Integer> sensorIds); |
| | | |
| | | Map<String, Object> getSensorByMac(String mac); |
| | | |
| | | Map<String, Object> getSensorsByMonitPointId(String id); |
| | | |
| | | } |
| | |
| | | } |
| | | return resultListMap; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getSensorByMac(String mac) { |
| | | System.out.println("SensorUnitServiceImpl-----getSensorByMac-----mac:"+mac); |
| | | List<Map<String, Object>> list = sensorUnitMapper.getSensorsByDeviceMac(mac); |
| | | System.out.println("SensorUnitServiceImpl----getSensorByMac----list:"+list); |
| | | if (list!=null && !list.isEmpty()) { |
| | | Map<String, Object> sensorUnitMap = new HashMap<>(); |
| | | for(Map<String, Object> sensorMap : list) { |
| | | String sensor_key = (String) sensorMap.get("sensor_key"); |
| | | System.out.println("SensorUnitServiceImpl----getSensorByMac----sensor_key:"+sensor_key); |
| | | String name = (String) sensorMap.get("name"); |
| | | System.out.println("SensorUnitServiceImpl----getSensorByMac----name:"+name); |
| | | sensorUnitMap.put(sensor_key, name); |
| | | } |
| | | System.out.println(sensorUnitMap); |
| | | return sensorUnitMap; |
| | | } else { |
| | | Map<String, Object> sensorUnitMap = null; |
| | | return sensorUnitMap; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public 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> sensorUnitMap = new HashMap<>(); |
| | | for(Map<String, Object> sensorMap : list) { |
| | | 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, name); |
| | | } |
| | | System.out.println(sensorUnitMap); |
| | | return sensorUnitMap; |
| | | } else { |
| | | Map<String, Object> sensorUnitMap = null; |
| | | return sensorUnitMap; |
| | | } |
| | | } |
| | | } |
| | |
| | | <sql id="Base_Column_List" > |
| | | id, sensor_id, name, rules, is_delete, create_time, update_time |
| | | </sql> |
| | | |
| | | <select id="getSensorsByDeviceMac" resultType="java.util.Map"> |
| | | SELECT d.mac,s.sensor_key,su.id,su.sensor_id,su.name,su.rules |
| | | FROM device d, device_version_sensor dvs, sensor_unit su, sensor s |
| | | WHERE d.device_version_id = dvs.device_version_id |
| | | AND dvs.sensor_id = su.sensor_id |
| | | AND d.device_version_id = dvs.device_version_id |
| | | AND su.sensor_id = s.id |
| | | AND su.is_delete=0 |
| | | AND d.mac = #{mac} |
| | | </select> |
| | | |
| | | <select id="getSensorsByMonitPointId" resultType="java.util.Map"> |
| | | SELECT mp.id,s.sensor_key,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 |
| | | AND osu.sensor_unit_id = su.id |
| | | AND su.sensor_id = s.id |
| | | AND su.is_delete=0 |
| | | AND mp.id = #{id} |
| | | </select> |
| | | </mapper> |