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
|
}
|