dcs 3 月之前
父节点
当前提交
ae1dbd31be
共有 17 个文件被更改,包括 416 次插入0 次删除
  1. 6 0
      virgo.api/src/main/java/com/bosshand/virgo/api/operate/controller/OperateFlowDataController.java
  2. 3 0
      virgo.api/src/main/java/com/bosshand/virgo/api/operate/dao/OperateFlowDataDao.java
  3. 11 0
      virgo.api/src/main/java/com/bosshand/virgo/api/operate/service/OperateFlowDataService.java
  4. 46 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/controller/TestCont.java
  5. 15 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/DeviceLiveDataDao.java
  6. 15 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/DeviceLiveDataHistoryDao.java
  7. 18 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/DeviceSensorDao.java
  8. 2 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/GiveAlarmDao.java
  9. 72 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/model/DeviceLiveData.java
  10. 47 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/model/DeviceLiveDataHistory.java
  11. 56 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/model/DeviceSensor.java
  12. 39 0
      virgo.api/src/main/java/com/bosshand/virgo/api/test/service/TestService.java
  13. 22 0
      virgo.api/src/main/resources/mapper/DeviceLiveDataHistoryMapper.xml
  14. 23 0
      virgo.api/src/main/resources/mapper/DeviceLiveDataMapper.xml
  15. 30 0
      virgo.api/src/main/resources/mapper/DeviceSensorMapper.xml
  16. 4 0
      virgo.api/src/main/resources/mapper/GiveAlarmMapper.xml
  17. 7 0
      virgo.api/src/main/resources/mapper/OperateFlowDataMapper.xml

+ 6 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/controller/OperateFlowDataController.java

@@ -107,4 +107,10 @@ public class OperateFlowDataController {
         operateFlowDataService.delete(id);
         return Response.ok();
     }
+
+    @ApiOperation("设备看板-全生命周期")
+    @RequestMapping(value = "/count/{deviceId}", method = RequestMethod.GET)
+    public Response deviceCount(@PathVariable long deviceId) {
+        return Response.ok(operateFlowDataService.deviceCount(deviceId));
+    }
 }

+ 3 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/dao/OperateFlowDataDao.java

@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface OperateFlowDataDao {
@@ -27,4 +28,6 @@ public interface OperateFlowDataDao {
                                  @Param(value = "startDate") String startDate,
                                  @Param(value = "endDate") String endDate);
 
+    Map<String, Object> deviceCount(long deviceId, int type);
+
 }

+ 11 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/service/OperateFlowDataService.java

@@ -8,7 +8,9 @@ import com.bosshand.virgo.core.utils.ContextUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class OperateFlowDataService {
@@ -50,4 +52,13 @@ public class OperateFlowDataService {
         return JSON.toJSONString(operateFlowDataDao.census(projectId, startDate, endDate));
     }
 
+    public Map<Integer, Object> deviceCount(long deviceId) {
+        Map<Integer, Object> map = new HashMap<>();
+        for (int type = 1; type < 6; type++) {
+            map.put(type, operateFlowDataDao.deviceCount(deviceId, type));
+        }
+        return map;
+    }
+
+
 }

+ 46 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/controller/TestCont.java

@@ -160,6 +160,12 @@ public class TestCont {
         return Response.ok(testService.save(data));
     }
 
+    @ApiOperation("根据deviceId报警获取")
+    @RequestMapping(value = "/giveAlarm/{deviceId}", method = RequestMethod.GET)
+    public Response getGiveAlarmByDeviceId(@PathVariable long deviceId) {
+        return Response.ok(testService.getGiveAlarmByDeviceId(deviceId));
+    }
+
     //---------------------------------------------------------------------------------------------
 
     @ApiOperation("设备统计获取")
@@ -174,6 +180,46 @@ public class TestCont {
         return Response.ok(testService.save(data));
     }
 
+    //---------------------------------------------------------------------------------------------
+
+    @ApiOperation("设备传感器统计获取")
+    @RequestMapping(value = "/deviceSensor/count/{deviceId}", method = RequestMethod.GET)
+    public Response getDeviceSensorCount(@PathVariable long deviceId) {
+        return Response.ok(testService.getDeviceSensorCount(deviceId));
+    }
+
+    @ApiOperation("设备传感器获取")
+    @RequestMapping(value = "/deviceSensor/{deviceId}", method = RequestMethod.GET)
+    public Response getDeviceSensor(@PathVariable long deviceId) {
+        return Response.ok(testService.getDeviceSensor(deviceId));
+    }
+
+    @ApiOperation("设备传感器保存")
+    @RequestMapping(value = "/deviceSensor/save", method = RequestMethod.POST)
+    public Response save(@RequestBody DeviceSensor data) {
+        return Response.ok(testService.save(data));
+    }
+
+    //---------------------------------------------------------------------------------------------
+
+    @ApiOperation("设备传感器实时数据获取")
+    @RequestMapping(value = "/deviceLiveData/{deviceId}", method = RequestMethod.GET)
+    public Response getDeviceLiveData(@PathVariable long deviceId) {
+        return Response.ok(testService.getDeviceLiveData(deviceId));
+    }
+
+    @ApiOperation("设备传感器历史数据走势")
+    @RequestMapping(value = "/deviceLiveData/history/{deviceId}", method = RequestMethod.GET)
+    public Response getDeviceLiveDataHistory(@PathVariable long deviceId) {
+        return Response.ok(testService.getDeviceLiveDataHistory(deviceId));
+    }
+
+    @ApiOperation("设备传感器实时数据保存")
+    @RequestMapping(value = "/deviceLiveData/save", method = RequestMethod.POST)
+    public Response save(@RequestBody DeviceLiveData data) {
+        return Response.ok(testService.save(data));
+    }
+
     //-----------------------------------------------------------------------------------------------
 
     @ApiOperation("车辆通行记录获取")

+ 15 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/DeviceLiveDataDao.java

@@ -0,0 +1,15 @@
+package com.bosshand.virgo.api.test.dao;
+
+import com.bosshand.virgo.api.test.model.DeviceLiveData;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface DeviceLiveDataDao {
+
+    List<DeviceLiveData> get(long deviceId);
+
+    void save(DeviceLiveData deviceLiveData);
+
+}

+ 15 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/DeviceLiveDataHistoryDao.java

@@ -0,0 +1,15 @@
+package com.bosshand.virgo.api.test.dao;
+
+import com.bosshand.virgo.api.test.model.DeviceLiveDataHistory;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface DeviceLiveDataHistoryDao {
+
+    List<DeviceLiveDataHistory> get(long deviceId);
+
+    void save(DeviceLiveDataHistory deviceLiveDataHistory);
+
+}

+ 18 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/DeviceSensorDao.java

@@ -0,0 +1,18 @@
+package com.bosshand.virgo.api.test.dao;
+
+import com.bosshand.virgo.api.test.model.DeviceSensor;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface DeviceSensorDao {
+
+    List<DeviceSensor> get(long deviceId);
+
+    void save(DeviceSensor deviceSensor);
+
+    Map<String, Object> getCount(long deviceId);
+
+}

+ 2 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/dao/GiveAlarmDao.java

@@ -11,6 +11,8 @@ public interface GiveAlarmDao {
 
     List<GiveAlarm> get(GiveAlarm b);
 
+    List<GiveAlarm> getDeviceId(long deviceId);
+
     void save(GiveAlarm b);
 
     Map<String, Object> projectCount(long projectId);

+ 72 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/model/DeviceLiveData.java

@@ -0,0 +1,72 @@
+package com.bosshand.virgo.api.test.model;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+/**
+ * 设备实时数据
+ */
+public class DeviceLiveData {
+
+    private long id;
+
+    /**
+     * 设备id
+     */
+    private long deviceId;
+
+    /**
+     * 传感器id
+     */
+    private long deviceSensorId;
+
+    /**
+     * 时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private String date;
+
+    /**
+     * 数据
+     */
+    private String data;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getDeviceId() {
+        return deviceId;
+    }
+
+    public void setDeviceId(long deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public long getDeviceSensorId() {
+        return deviceSensorId;
+    }
+
+    public void setDeviceSensorId(long deviceSensorId) {
+        this.deviceSensorId = deviceSensorId;
+    }
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+}

+ 47 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/model/DeviceLiveDataHistory.java

@@ -0,0 +1,47 @@
+package com.bosshand.virgo.api.test.model;
+
+/**
+ *  历史走势
+ */
+public class DeviceLiveDataHistory {
+
+    private long id;
+
+    private long deviceId;
+
+    private String dataKay;
+
+    private String dataValue;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getDeviceId() {
+        return deviceId;
+    }
+
+    public void setDeviceId(long deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public String getDataKay() {
+        return dataKay;
+    }
+
+    public void setDataKay(String dataKay) {
+        this.dataKay = dataKay;
+    }
+
+    public String getDataValue() {
+        return dataValue;
+    }
+
+    public void setDataValue(String dataValue) {
+        this.dataValue = dataValue;
+    }
+}

+ 56 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/model/DeviceSensor.java

@@ -0,0 +1,56 @@
+package com.bosshand.virgo.api.test.model;
+
+/**
+ * 设备传感器
+ */
+public class DeviceSensor {
+
+    private long id;
+
+    /**
+     * 设备id
+     */
+    private long deviceId;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 状态
+     */
+    private Integer state;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getDeviceId() {
+        return deviceId;
+    }
+
+    public void setDeviceId(long deviceId) {
+        this.deviceId = deviceId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getState() {
+        return state;
+    }
+
+    public void setState(Integer state) {
+        this.state = state;
+    }
+}

+ 39 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/test/service/TestService.java

@@ -86,6 +86,15 @@ public class TestService {
     @Autowired
     PowerDistributionMachineDao powerDistributionMachineDao;
 
+    @Autowired
+    DeviceSensorDao deviceSensorDao;
+
+    @Autowired
+    DeviceLiveDataDao deviceLiveDataDao;
+
+    @Autowired
+    DeviceLiveDataHistoryDao deviceLiveDataHistoryDao;
+
     private static Logger logger = LoggerFactory.getLogger(TestService.class);
 
     public List<AccessControl> get(AccessControl data) {
@@ -162,6 +171,10 @@ public class TestService {
         return data;
     }
 
+    public List<GiveAlarm> getGiveAlarmByDeviceId(long deviceId) {
+        return giveAlarmdao.getDeviceId(deviceId);
+    }
+
     public List<DeviceCount> get(DeviceCount data) {
         return deviceCountDao.get(data);
     }
@@ -171,6 +184,32 @@ public class TestService {
         return data;
     }
 
+    public List<DeviceSensor> getDeviceSensor(long deviceId) {
+        return deviceSensorDao.get(deviceId);
+    }
+
+    public DeviceSensor save(DeviceSensor data) {
+        deviceSensorDao.save(data);
+        return data;
+    }
+
+    public Map<String, Object> getDeviceSensorCount(long deviceId) {
+        return deviceSensorDao.getCount(deviceId);
+    }
+
+    public List<DeviceLiveData> getDeviceLiveData(long deviceId) {
+        return deviceLiveDataDao.get(deviceId);
+    }
+
+    public List<DeviceLiveDataHistory> getDeviceLiveDataHistory(long deviceId) {
+        return deviceLiveDataHistoryDao.get(deviceId);
+    }
+
+    public DeviceLiveData save(DeviceLiveData data) {
+        deviceLiveDataDao.save(data);
+        return data;
+    }
+
     public List<Vehicle> get(Vehicle data) {
         return vehicledao.get(data);
     }

+ 22 - 0
virgo.api/src/main/resources/mapper/DeviceLiveDataHistoryMapper.xml

@@ -0,0 +1,22 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.api.test.dao.DeviceLiveDataHistoryDao">
+
+    <resultMap type="com.bosshand.virgo.api.test.model.DeviceLiveDataHistory" id="result" >
+        <id column="id" property="id"/>
+        <result column="deviceId" property="deviceId"/>
+        <result column="dataKay" property="dataKay"/>
+        <result column="dataValue" property="dataValue"/>
+    </resultMap>
+
+    <select id="get" resultMap="result">
+        SELECT * FROM test_v where deviceId = #{deviceId}
+    </select>
+
+    <insert id="save" parameterType="com.bosshand.virgo.api.test.model.DeviceLiveDataHistory" useGeneratedKeys="true" keyProperty="id">
+        INSERT into test_v(deviceId, dataKay, dataValue) values (#{deviceId}, #{dataKay}, #{dataValue})
+    </insert>
+
+</mapper>

+ 23 - 0
virgo.api/src/main/resources/mapper/DeviceLiveDataMapper.xml

@@ -0,0 +1,23 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.api.test.dao.DeviceLiveDataDao">
+
+    <resultMap type="com.bosshand.virgo.api.test.model.DeviceLiveData" id="result" >
+        <id column="id" property="id"/>
+        <result column="deviceId" property="deviceId"/>
+        <result column="deviceSensorId" property="deviceSensorId"/>
+        <result column="date" property="date"/>
+        <result column="data" property="data"/>
+    </resultMap>
+
+    <select id="get" resultMap="result">
+        SELECT * FROM test_u where deviceId = #{deviceId} order by date desc
+    </select>
+
+    <insert id="save" parameterType="com.bosshand.virgo.api.test.model.DeviceLiveData" useGeneratedKeys="true" keyProperty="id">
+        INSERT into test_u(deviceId, deviceSensorId, date, data) values (#{deviceId}, #{deviceSensorId}, now(), #{data})
+    </insert>
+
+</mapper>

+ 30 - 0
virgo.api/src/main/resources/mapper/DeviceSensorMapper.xml

@@ -0,0 +1,30 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.api.test.dao.DeviceSensorDao">
+
+    <resultMap type="com.bosshand.virgo.api.test.model.DeviceSensor" id="result" >
+        <id column="id" property="id"/>
+        <result column="deviceId" property="deviceId"/>
+        <result column="name" property="name"/>
+        <result column="state" property="state"/>
+    </resultMap>
+
+    <select id="get" resultMap="result">
+        SELECT * FROM test_t where deviceId = #{deviceId}
+    </select>
+
+    <insert id="save" parameterType="com.bosshand.virgo.api.test.model.DeviceSensor" useGeneratedKeys="true" keyProperty="id">
+        INSERT into test_t(deviceId, name, state) values (#{deviceId}, #{name}, #{state})
+    </insert>
+
+    <select id="getCount" resultType="map">
+        SELECT COUNT(`id`) as totalNumber,
+               COUNT(if(`state`=1,true,null)) as openNumber,
+               COUNT(if(`state`=2,true,null)) as faultNumber
+        FROM test_t WHERE deviceId = #{deviceId}
+    </select>
+
+
+</mapper>

+ 4 - 0
virgo.api/src/main/resources/mapper/GiveAlarmMapper.xml

@@ -20,6 +20,10 @@
         <result column="state" property="state"/>
     </resultMap>
 
+    <select id="getDeviceId" resultMap="BResult">
+        SELECT * FROM test_b where deviceId = #{deviceId} order by date desc
+    </select>
+
     <select id="get" resultMap="BResult">
         SELECT * FROM test_b
         <where>

+ 7 - 0
virgo.api/src/main/resources/mapper/OperateFlowDataMapper.xml

@@ -213,4 +213,11 @@
         WHERE id=#{id}
     </update>
 
+    <select id="projectCount" resultType="map">
+        SELECT COUNT(if(`state`=3,true,null)) as eligibleNumber,
+               COUNT(if(`state`!=3,true,null)) as correctionNumber
+        FROM  operate_flow_data WHERE deviceId = #{deviceId} and type = #{type}
+    </select>
+
+
 </mapper>