Преглед на файлове

feat:MQTT双屏版数据增加返回电梯继续信息返回至电梯屏APK应用

lihao16 преди 3 месеца
родител
ревизия
e8d7516487

+ 18 - 0
elevator-admin/src/main/java/com/inspur/idm/api/IElevatorService.java

@@ -0,0 +1,18 @@
+package com.inspur.idm.api;
+
+import com.inspur.idm.media.vo.elevator.ElevatorInfoVO;
+
+/**
+ * 获取电梯信息
+ * @author lihao16
+ */
+public interface IElevatorService {
+
+    /**
+     * 根据电梯ID获取电梯信息
+     * @param elevatorId
+     * @return
+     */
+    ElevatorInfoVO getElevatorInfoById(String elevatorId);
+
+}

+ 23 - 0
elevator-admin/src/main/java/com/inspur/idm/media/dubbo/ElevatorServiceImpl.java

@@ -0,0 +1,23 @@
+package com.inspur.idm.media.dubbo;
+
+import com.inspur.idm.api.IElevatorService;
+import com.inspur.idm.media.service.ElevatorInfoService;
+import com.inspur.idm.media.vo.elevator.ElevatorInfoVO;
+import org.apache.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 描述:
+ * @author lihao16
+ */
+@Service(protocol = "dubbo")
+public class ElevatorServiceImpl implements IElevatorService {
+
+    @Autowired
+    private ElevatorInfoService elevatorInfoService;
+
+    @Override
+    public ElevatorInfoVO getElevatorInfoById(String elevatorId) {
+        return elevatorInfoService.getElevatorInfoById(elevatorId);
+    }
+}

+ 7 - 0
elevator-data-collect/src/main/java/com/inspur/elevator_data_collect/dao/DeviceStatisticsDayInfoDao.java

@@ -25,4 +25,11 @@ public interface DeviceStatisticsDayInfoDao {
      * @return
      */
     String selectScreenSnByCameraId(String cameraId);
+
+    /**
+     * 查询指定设备关联的电梯ID
+     * @param deviceId
+     * @return
+     */
+    String selectElevatorIdByDeviceId(String deviceId);
 }

+ 7 - 0
elevator-data-collect/src/main/java/com/inspur/elevator_data_collect/domain/DeviceStatisticsDayInfo.java

@@ -52,4 +52,11 @@ public class DeviceStatisticsDayInfo implements Serializable {
      */
     private Integer elevatorStatus;
 
+    private String elevatorName;
+
+    private String cityName;
+
+    private String estateName;
+
+    private String elevatorId;
 }

+ 18 - 0
elevator-data-collect/src/main/java/com/inspur/elevator_data_collect/domain/ElevatorInfoVO.java

@@ -0,0 +1,18 @@
+package com.inspur.elevator_data_collect.domain;
+
+import lombok.Data;
+
+/**
+ * 描述:电梯信息
+ * @author lihao16
+ */
+@Data
+public class ElevatorInfoVO {
+
+    private String elevatorName;
+
+    private String cityName;
+
+    private String estateName;
+
+}

+ 16 - 0
elevator-data-collect/src/main/java/com/inspur/elevator_data_collect/service/WriteMongoService.java

@@ -4,9 +4,12 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.inspur.elevator_data_collect.dao.DeviceStatisticsDayInfoDao;
 import com.inspur.elevator_data_collect.domain.DeviceStatisticsDayInfo;
+import com.inspur.elevator_data_collect.domain.ElevatorInfoVO;
 import com.inspur.elevator_data_collect.mqtt.MqttGateway;
+import com.inspur.idm.api.IElevatorService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.dubbo.config.annotation.Reference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -37,6 +40,9 @@ public class WriteMongoService {
     @Autowired
     private MqttGateway mqttGateway;
 
+    @Reference
+    private IElevatorService elevatorService;
+
     /**
      * 统计信息缓存key
      */
@@ -108,6 +114,16 @@ public class WriteMongoService {
         }
         DeviceStatisticsDayInfo deviceStatisticsDayInfo = deviceStatisticsDayInfoDao.selectSumStatisticsInfo(deviceId);
         if (null != deviceStatisticsDayInfo) {
+            String elevatorId = deviceStatisticsDayInfoDao.selectElevatorIdByDeviceId(deviceId);
+            if (StringUtils.isNotBlank(elevatorId)) {
+                deviceStatisticsDayInfo.setElevatorId(elevatorId);
+                ElevatorInfoVO elevatorInfoVO = elevatorService.getElevatorInfoById(elevatorId);
+                if (null != elevatorInfoVO) {
+                    deviceStatisticsDayInfo.setElevatorName(elevatorInfoVO.getElevatorName());
+                    deviceStatisticsDayInfo.setCityName(elevatorInfoVO.getCityName());
+                    deviceStatisticsDayInfo.setEstateName(elevatorInfoVO.getEstateName());
+                }
+            }
             jsonResult = (JSONObject) JSON.toJSON(deviceStatisticsDayInfo);
             // 为防止缓存穿透,设置缓存时间为随机60-120分钟
             long randomTime = (long) (Math.random() * 60 + 60);

+ 16 - 0
elevator-data-collect/src/main/java/com/inspur/idm/api/IElevatorService.java

@@ -0,0 +1,16 @@
+package com.inspur.idm.api;
+
+import com.inspur.elevator_data_collect.domain.ElevatorInfoVO;
+
+/**
+ * 获取电梯信息
+ * @author lihao16
+ */
+public interface IElevatorService {
+    /**
+     * 根据电梯ID获取电梯信息
+     * @param elevatorId
+     * @return
+     */
+    ElevatorInfoVO getElevatorInfoById(String elevatorId);
+}

+ 4 - 0
elevator-data-collect/src/main/resources/mapper/DeviceStatisticsDayInfoDao.xml

@@ -35,4 +35,8 @@
             elevator_id = (SELECT elevator_id FROM ele_device_info WHERE device_id = #{cameraId})
         LIMIT 1
     </select>
+
+    <select id="selectElevatorIdByDeviceId" parameterType="java.lang.String" resultType="java.lang.String">
+        SELECT elevator_id FROM ele_device_info WHERE device_id = #{deviceId}
+    </select>
 </mapper>