|
@@ -250,6 +250,8 @@ public class MonitoringServiceImpl implements IMonitoringService {
|
250
|
250
|
|
251
|
251
|
/**
|
252
|
252
|
* tp_equipment 表
|
|
253
|
+ * url_id 是可视对讲视频流id配置
|
|
254
|
+ * uuid_id 是可视对讲视设备
|
253
|
255
|
* op_user_uuid 是监控的Token,
|
254
|
256
|
* unit_uuids 是token的有效时间
|
255
|
257
|
* appkey 是视频流的appKey
|
|
@@ -261,42 +263,52 @@ public class MonitoringServiceImpl implements IMonitoringService {
|
261
|
263
|
*
|
262
|
264
|
*/
|
263
|
265
|
|
264
|
|
- List<TpEquipment> tpEquipments = tpEquipmentMapper.selectByCommunityIdAndUnitId(userElement.getCommunityId(), userElement.getUnitId(), 5);
|
|
266
|
+ List<TpEquipment> tpEquipments = tpEquipmentMapper.selectByCommunityIdAndUnitId(userElement.getCommunityId(), userElement.getUnitId(), 3);
|
265
|
267
|
if (CollectionUtils.isEmpty(tpEquipments)) {
|
266
|
268
|
String address = toCommunities.getCommunityName() + tpUnit.getPhaseName() + tpUnit.getBuildingName() + tpUnit.getName();
|
267
|
269
|
responseBean.addError("系统未配置单元门口机设备!", address, null);
|
268
|
270
|
return responseBean;
|
269
|
271
|
}
|
270
|
|
- TpEquipment tpEquipment = tpEquipments.get(0);
|
271
|
|
- TpConfiguration tpConfiguration = tpConfigurationMapper.selectByPrimaryKey(tpEquipment.getUuidId());
|
272
|
|
-
|
273
|
|
- // 判断视频流地址,是否过期
|
274
|
|
- if (StringUtils.isBlank(tpEquipment.getOpUserUuid()) || System.currentTimeMillis() >= Long.valueOf(tpEquipment.getUnitUuids())) {
|
275
|
|
- // 开始更新视频Token
|
276
|
|
- Map<String,Object> queryMap = new HashMap<>();
|
277
|
|
- queryMap.put("appKey", tpEquipment.getAppkey());
|
278
|
|
- queryMap.put("appSecret", tpEquipment.getSecret());
|
279
|
|
- try {
|
280
|
|
- String result = OkHttpRequestUtils.doPost(yinShiProperties.getVideoTokenUrl(), queryMap);
|
281
|
|
- JSONObject jsonObject = JSONObject.parseObject(result).getJSONObject("data");
|
282
|
|
- tpEquipment.setOpUserUuid(jsonObject.getString("accessToken"));
|
283
|
|
- tpEquipment.setUnitUuids(String.valueOf(jsonObject.getLong("expireTime")));
|
284
|
|
- tpEquipmentMapper.updateByPrimaryKeySelective(tpEquipment);
|
285
|
|
- } catch (Exception e) {
|
286
|
|
- throw new WisdomException("获取视频Token失败!");
|
|
272
|
+
|
|
273
|
+ List<Map<String,Object>> resultMap = tpEquipments.stream().map(e -> {
|
|
274
|
+ // 获取视频地址
|
|
275
|
+ TpConfiguration tpConfiguration = tpConfigurationMapper.selectByPrimaryKey(e.getUrlId());
|
|
276
|
+ // 判断视频流地址,是否过期
|
|
277
|
+ if (StringUtils.isBlank(e.getOpUserUuid()) || System.currentTimeMillis() >= Long.valueOf(e.getUnitUuids())) {
|
|
278
|
+ // 开始更新视频Token
|
|
279
|
+ Map<String,Object> queryMap = new HashMap<>();
|
|
280
|
+ queryMap.put("appKey", e.getAppkey());
|
|
281
|
+ queryMap.put("appSecret", e.getSecret());
|
|
282
|
+ try {
|
|
283
|
+ String result = OkHttpRequestUtils.doPost(yinShiProperties.getVideoTokenUrl(), queryMap);
|
|
284
|
+ JSONObject jsonObject = JSONObject.parseObject(result).getJSONObject("data");
|
|
285
|
+ String accessToken = jsonObject.getString("accessToken");
|
|
286
|
+ String expireTime = String.valueOf(jsonObject.getLong("expireTime"));
|
|
287
|
+ // 根据小区更新所有的门口机的萤石云 token, token有效期
|
|
288
|
+ tpEquipmentMapper.updateYinShiYunByCommunityId(userElement.getCommunityId(), accessToken, expireTime);
|
|
289
|
+ } catch (Exception exception) {
|
|
290
|
+ throw new WisdomException("获取视频Token失败!");
|
|
291
|
+ }
|
|
292
|
+
|
287
|
293
|
}
|
288
|
294
|
|
289
|
|
- }
|
|
295
|
+ Map<String,Object> map = new HashMap<>();
|
|
296
|
+ map.put("equipmentsId", e.getId());
|
|
297
|
+ // 流程视频流地址
|
|
298
|
+ map.put("url", tpConfiguration.getConfigurationValue());
|
|
299
|
+ // 高清视频流地址
|
|
300
|
+ map.put("url_high", tpConfiguration.getKey());
|
|
301
|
+ map.put("address", toCommunities.getCommunityName() + tpUnit.getPhaseName() + tpUnit.getBuildingName() + tpUnit.getName());
|
|
302
|
+ // 门口机位置(可视对讲) ,例如:东门
|
|
303
|
+ map.put("displayName", tpConfiguration.getDisplayName());
|
|
304
|
+ map.put("token", e.getOpUserUuid());
|
|
305
|
+
|
|
306
|
+ return map;
|
|
307
|
+
|
|
308
|
+ }).collect(Collectors.toList());
|
290
|
309
|
|
291
|
310
|
|
292
|
|
- Map<String,Object> map = new HashMap<>();
|
293
|
|
- // 流程视频流地址
|
294
|
|
- map.put("url", tpConfiguration.getConfigurationValue());
|
295
|
|
- // 高清视频流地址
|
296
|
|
- map.put("url_high", tpConfiguration.getKey());
|
297
|
|
- map.put("address", toCommunities.getCommunityName() + tpUnit.getPhaseName() + tpUnit.getBuildingName() + tpUnit.getName());
|
298
|
|
- map.put("token", tpEquipment.getOpUserUuid());
|
299
|
|
- responseBean.addSuccess(map);
|
|
311
|
+ responseBean.addSuccess(resultMap);
|
300
|
312
|
|
301
|
313
|
// 记录 单元门监控查看
|
302
|
314
|
TaRemotelyMonitor taRemotelyMonitor = new TaRemotelyMonitor();
|