// 单位为分,四舍五入不保留小数
300
|
|
long fixedMinute = fixedLongBigDecimal.divide(new BigDecimal("60000L"), 0, BigDecimal.ROUND_HALF_UP)
|
301
|
|
.longValue();
|
|
311
|
int fixedLong = JingPingSendDateUtil.getBetweenMinuteValue(
|
|
312
|
String.valueOf(sendDataAreaInfo.get("inAreaDate")), params.getString("newDate"));
|
|
313
|
|
|
314
|
if (fixedLong > 0) {
|
302
|
315
|
// 围栏要求定点时间
|
303
|
|
long residenceTimeLength = Long
|
304
|
|
.getLong(String.valueOf(currentAreaInfoList.get(mapTagIndex).get("RESIDENCE_TIME_LENGTH")));
|
|
316
|
int residenceTimeLength = Integer
|
|
317
|
.getInteger(String.valueOf(sendDataAreaInfo.get("RESIDENCE_TIME_LENGTH")));
|
305
|
318
|
|
306
|
|
if (residenceTimeLength <= fixedMinute) {
|
|
319
|
if (residenceTimeLength <= fixedLong) {
|
307
|
320
|
// 已超时
|
308
|
|
logger.info("镜屏推送进入定点的信息");
|
|
321
|
logger.info("镜屏推送进入定点(限时)的信息");
|
309
|
322
|
params.put("locationStatus", EbcConstant.location_status_overtime);
|
310
|
323
|
}
|
311
|
|
|
312
|
|
params.put("fixedLong", fixedMinute);
|
313
|
324
|
}
|
|
325
|
params.put("fixedLong", fixedLong);
|
314
|
326
|
}
|
315
|
327
|
|
316
|
328
|
String jingpingData = JSON.toJSONString(params);
|
|
@ -321,52 +333,77 @@ public class ReceiveSubscribeServiceImpl implements ReceiveSubscribeService {
|
321
|
333
|
/**
|
322
|
334
|
* 处理报警数据
|
323
|
335
|
* @param dataMap
|
|
336
|
* @throws Exception
|
324
|
337
|
*/
|
325
|
|
private void executeReceiveIotAlarmData(JMap params) {
|
326
|
|
try {
|
327
|
|
// 1、获取人员信息
|
328
|
|
Map<String, Object> deviceAndUser = deviceManageDao.queryAssociatUser(params);
|
329
|
|
|
330
|
|
// 2、获取围栏信息
|
331
|
|
JMap currentAreaInfoJMap = mapTagManageDao.getInAreaInfo(params.getString("longitude"),
|
332
|
|
params.getString("latitude"));
|
333
|
|
|
334
|
|
// 拼接添加数据
|
335
|
|
Map<String, Object> dataMap = new HashMap<String, Object>();
|
336
|
|
dataMap.put("CALLER_ID", deviceAndUser.get("PARTY_CODE")); // 报警人员标识
|
337
|
|
dataMap.put("DEVICE_ID", params.get("deviceId")); // 终端标识
|
338
|
|
dataMap.put("PARTY_TYPE", deviceAndUser.get("PARTY_TYPE")); // 参与人类型
|
339
|
|
dataMap.put("PARTY_CODE", deviceAndUser.get("PARTY_CODE")); // 参与人业务编码
|
340
|
|
dataMap.put("PARTY_NAME", deviceAndUser.get("PARTY_NAME")); // 参与人名称
|
341
|
|
dataMap.put("ALARM_TYPE", params.get("alarmTypeZH")); // 告警类型
|
342
|
|
dataMap.put("LONGITUDE", params.get("longitude")); // 报警经度
|
343
|
|
dataMap.put("LATITUDE", params.get("latitude")); // 报警纬度
|
344
|
|
dataMap.put("CALLER_DATE", params.get("msgDate")); // 报警时间
|
345
|
|
|
346
|
|
// 报警位置
|
347
|
|
if (currentAreaInfoJMap.getInt("mapTagNum") > 0) {
|
348
|
|
// 当前所在围栏列表
|
349
|
|
List<Map<String, Object>> currentAreaInfoList = (List<Map<String, Object>>) currentAreaInfoJMap
|
350
|
|
.get("resultList");
|
351
|
|
|
352
|
|
StringBuffer mapTagName = new StringBuffer(
|
353
|
|
String.valueOf(currentAreaInfoList.get(0).get("MAP_TAG_NAME")));
|
354
|
|
for (int i = 1; i < currentAreaInfoList.size(); i++) {
|
355
|
|
mapTagName.append(",").append(String.valueOf(currentAreaInfoList.get(i).get("MAP_TAG_NAME")));
|
356
|
|
}
|
|
338
|
private void executeReceiveIotAlarmData(JMap params) throws Exception {
|
|
339
|
// 1、获取人员信息
|
|
340
|
Map<String, Object> dataMap=new HashMap<String, Object>();
|
|
341
|
dataMap.put("DEVICE_ID", params.get("deviceId"));
|
|
342
|
Map<String, Object> deviceAndUser = deviceManageDao.queryOneBindDeviceInfo(dataMap);
|
|
343
|
params.put("userName", deviceAndUser.get("PARTY_NAME"));
|
|
344
|
|
|
345
|
// 2、查询是否为需救援的人员
|
|
346
|
Map<String, Object> alarmMap = rescueDao.queryNoCloseRescueLog(params);
|
|
347
|
|
|
348
|
// 3、判断是否存在未救援的报警信息
|
|
349
|
if (alarmMap == null || alarmMap.isEmpty()) {
|
|
350
|
logger.debug("新增报警信息");
|
|
351
|
params.put("isNewAlarm", "1");
|
|
352
|
// 保存报警数据
|
|
353
|
saveAlarmData(params, deviceAndUser);
|
|
354
|
} else {
|
|
355
|
params.put("isNewAlarm", "0");
|
|
356
|
logger.debug("报警信息未处理");
|
|
357
|
}
|
357
|
358
|
|
358
|
|
dataMap.put("CALLER_LOCATION", mapTagName.toString());
|
359
|
|
} else {
|
360
|
|
dataMap.put("CALLER_LOCATION", "");
|
361
|
|
}
|
|
359
|
// 4、推送镜屏
|
|
360
|
String jingpingData = JSON.toJSONString(params);
|
|
361
|
logger.debug("推送镜屏数据:" + jingpingData);
|
|
362
|
JingPingSendDateUtil.sendData(JingPingSendDateUtil.topic_personnel, jingpingData);
|
|
363
|
}
|
362
|
364
|
|
363
|
|
// 3、保存报警数据
|
364
|
|
logger.debug("记录告警日志");
|
365
|
|
rescueDao.addRescueLog(dataMap);
|
|
365
|
/**
|
|
366
|
* 保存报警数据
|
|
367
|
* @param params
|
|
368
|
* @param deviceAndUser
|
|
369
|
* @throws Exception
|
|
370
|
*/
|
|
371
|
private void saveAlarmData(JMap params, Map<String, Object> deviceAndUser) throws Exception {
|
|
372
|
// 1、获取围栏信息
|
|
373
|
JMap currentAreaInfoJMap = mapTagManageDao.getInAreaInfo(params.getString("longitude"),
|
|
374
|
params.getString("latitude"));
|
|
375
|
|
|
376
|
// 2、拼接添加数据
|
|
377
|
Map<String, Object> dataMap = new HashMap<String, Object>();
|
|
378
|
dataMap.put("CALLER_ID", deviceAndUser.get("PARTY_CODE")); // 报警人员标识
|
|
379
|
dataMap.put("DEVICE_ID", params.get("deviceId")); // 终端标识
|
|
380
|
dataMap.put("PARTY_TYPE", deviceAndUser.get("PARTY_TYPE")); // 参与人类型
|
|
381
|
dataMap.put("PARTY_CODE", deviceAndUser.get("PARTY_CODE")); // 参与人业务编码
|
|
382
|
dataMap.put("PARTY_NAME", deviceAndUser.get("PARTY_NAME")); // 参与人名称
|
|
383
|
dataMap.put("ALARM_TYPE", params.get("alarmType")); // 告警类型
|
|
384
|
dataMap.put("LONGITUDE", params.get("longitude")); // 报警经度
|
|
385
|
dataMap.put("LATITUDE", params.get("latitude")); // 报警纬度
|
|
386
|
dataMap.put("CALLER_DATE", params.get("msgDate")); // 报警时间
|
|
387
|
|
|
388
|
// 报警位置
|
|
389
|
if (currentAreaInfoJMap.getInt("mapTagNum") > 0) {
|
|
390
|
// 当前所在围栏列表
|
|
391
|
List<Map<String, Object>> currentAreaInfoList = (List<Map<String, Object>>) currentAreaInfoJMap
|
|
392
|
.get("resultList");
|
|
393
|
|
|
394
|
StringBuffer mapTagName = new StringBuffer(String.valueOf(currentAreaInfoList.get(0).get("MAP_TAG_NAME")));
|
|
395
|
for (int i = 1; i < currentAreaInfoList.size(); i++) {
|
|
396
|
mapTagName.append(",").append(String.valueOf(currentAreaInfoList.get(i).get("MAP_TAG_NAME")));
|
|
397
|
}
|
366
|
398
|
|
367
|
|
} catch (Exception e) {
|
368
|
|
logger.error("记录告警日志失败");
|
|
399
|
dataMap.put("CALLER_LOCATION", mapTagName.toString());
|
|
400
|
} else {
|
|
401
|
dataMap.put("CALLER_LOCATION", "");
|
369
|
402
|
}
|
|
403
|
|
|
404
|
// 3、保存报警数据
|
|
405
|
logger.debug("记录告警日志");
|
|
406
|
rescueDao.addRescueLog(dataMap);
|
370
|
407
|
}
|
371
|
408
|
|
372
|
409
|
}
|
|
@ -63,16 +63,13 @@ public class EbcConstant {
|
63
|
63
|
//人员状态:救援人员
|
64
|
64
|
public static final String location_status_rescuers="6";
|
65
|
65
|
|
66
|
|
//人员状态:离线
|
67
|
|
public static final String location_status_offline_ZH="离线告警";
|
|
66
|
//告警类型:离线
|
|
67
|
public static final String alarm_type_offline="离线告警";
|
68
|
68
|
|
69
|
|
//人员状态:违规
|
70
|
|
public static final String location_status_exclusion_ZH="违规告警";
|
|
69
|
//告警类型:SOS(手动)
|
|
70
|
public static final String alarm_type_jogsos="手动告警";
|
71
|
71
|
|
72
|
|
//人员状态:SOS(手动)
|
73
|
|
public static final String location_status_jogsos_ZH="手动告警";
|
74
|
|
|
75
|
|
//人员状态:SOS(自动)
|
76
|
|
public static final String location_status_autosos_ZH="落水告警";
|
|
72
|
//告警类型:SOS(自动)
|
|
73
|
public static final String alarm_type_autosos="落水告警";
|
77
|
74
|
|
78
|
75
|
}
|
|
@ -1,5 +1,9 @@
|
1
|
1
|
package com.ai.ipu.server.util;
|
2
|
2
|
|
|
3
|
import java.math.BigDecimal;
|
|
4
|
import java.text.ParseException;
|
|
5
|
import java.text.SimpleDateFormat;
|
|
6
|
|
3
|
7
|
import com.ai.ipu.server.connect.ps.EventChannelTool;
|
4
|
8
|
import com.ai.ipu.server.connect.ps.EventChannelTool.PublisherEvent;
|
5
|
9
|
import com.ai.ipu.server.connect.ps.ISubscriber;
|
|
@ -11,18 +15,12 @@ import com.ai.ipu.server.connect.ps.impl.Publisher;
|
11
|
15
|
* 2020-10-21
|
12
|
16
|
*/
|
13
|
17
|
public class JingPingSendDateUtil {
|
14
|
|
|
15
|
|
// 人员定位topic(正常)
|
16
|
|
public static final String topic_personnel = "personnel";
|
17
|
18
|
|
18
|
|
// 救援定位topic(SOS)
|
19
|
|
public static final String topic_alarm = "alarm";
|
20
|
|
|
21
|
|
// 离线topic(离线)
|
22
|
|
public static final String topic_offline = "offline";
|
|
19
|
// 人员定位topic
|
|
20
|
public static final String topic_personnel = "personnel";
|
23
|
21
|
|
24
|
|
// 违规topic(违规)
|
25
|
|
public static final String topic_violation = "violation";
|
|
22
|
// 救援定位topic
|
|
23
|
//public static final String topic_alarm = "alarm";
|
26
|
24
|
|
27
|
25
|
public static void sendData(String topic, String msg) {
|
28
|
26
|
if (!EventChannelTool.isExistSubscriber(topic)) {
|
|
@ -41,4 +39,27 @@ public class JingPingSendDateUtil {
|
41
|
39
|
publisher.publish(topic, publisherEvent);
|
42
|
40
|
}
|
43
|
41
|
|
|
42
|
/**
|
|
43
|
* 计算两个时间相隔的分钟数(endDate-beginDate)
|
|
44
|
* @param beginDate
|
|
45
|
* @param endDate
|
|
46
|
* @return
|
|
47
|
* @throws ParseException
|
|
48
|
*/
|
|
49
|
public static int getBetweenMinuteValue(String beginDate, String endDate) throws ParseException {
|
|
50
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
51
|
long endDateLong = simpleDateFormat.parse(endDate).getTime();
|
|
52
|
long beginDateLong = simpleDateFormat.parse(beginDate).getTime();
|
|
53
|
long alarmLong = endDateLong - beginDateLong;
|
|
54
|
if (alarmLong>0) {
|
|
55
|
BigDecimal alarmLongBigDecimal = new BigDecimal(alarmLong);
|
|
56
|
// 单位为分,四舍五入不保留小数
|
|
57
|
alarmLongBigDecimal = alarmLongBigDecimal.divide(new BigDecimal("60000L"), 0, BigDecimal.ROUND_HALF_UP);
|
|
58
|
return alarmLongBigDecimal.intValue();
|
|
59
|
}else {
|
|
60
|
return 0;
|
|
61
|
}
|
|
62
|
|
|
63
|
}
|
|
64
|
|
44
|
65
|
}
|