Browse Source

人员定位模拟数据

konghl 4 years ago
parent
commit
c3ad790c7c

+ 14 - 22
ebc-sea-platform/src/main/java/com/ai/ipu/server/controller/ReceiveSubscribeController.java

@ -13,7 +13,6 @@ import com.ai.ipu.data.JMap;
13 13
import com.ai.ipu.data.impl.JsonMap;
14 14
import com.ai.ipu.server.service.interfaces.ReceiveSubscribeService;
15 15
import com.ai.ipu.server.util.EbcConstant;
16
import com.ai.ipu.server.util.JingPingSendDateUtil;
17 16
import com.alibaba.fastjson.JSON;
18 17
import com.alibaba.fastjson.JSONObject;
19 18
@ -77,33 +76,26 @@ public class ReceiveSubscribeController {
77 76
		dataMap.put("latitude",detailInfo.getJSONObject("latitude").getString("value"));//纬度
78 77
		dataMap.put("newDate",detailInfo.getJSONObject("msgDate").getString("value"));//最新定位时间
79 78
		
80
		String topic="";
81
		switch (detailInfo.getJSONObject("alarmType").getString("value")) {
82
		case "1": //自动报警
83
			dataMap.put("alarmType",EbcConstant.location_status_autosos);//报警类型
84
			dataMap.put("alarmTypeZH",EbcConstant.location_status_autosos_ZH);//报警类型
85
			topic=JingPingSendDateUtil.topic_alarm;
79
		//报警类型
80
		switch (detailInfo.getJSONObject("alarmType").getIntValue("value")) {
81
		case 1: //自动报警
82
			dataMap.put("locationStatus",EbcConstant.location_status_autosos);//报警类型
83
			dataMap.put("alarmType",EbcConstant.alarm_type_autosos);//报警类型
86 84
			break;
87
		case "2": //手动报警
88
			dataMap.put("alarmType",EbcConstant.location_status_jogsos);//报警类型
89
			dataMap.put("alarmTypeZH",EbcConstant.location_status_jogsos_ZH);//报警类型
90
			topic=JingPingSendDateUtil.topic_alarm;
85
		case 2: //手动报警
86
			dataMap.put("locationStatus",EbcConstant.location_status_jogsos);//报警类型
87
			dataMap.put("alarmType",EbcConstant.alarm_type_jogsos);//报警类型
91 88
			break;
92
		case "4": //离线
93
			dataMap.put("alarmType",EbcConstant.location_status_offline);//报警类型
94
			dataMap.put("alarmTypeZH",EbcConstant.location_status_offline_ZH);//报警类型
95
			topic=JingPingSendDateUtil.topic_offline;
89
		case 4: //离线
90
			dataMap.put("locationStatus",EbcConstant.location_status_offline);//报警类型
91
			dataMap.put("alarmType",EbcConstant.alarm_type_offline);//报警类型
96 92
			break;
97 93
		default:
98
			break;
94
			logger.error("告警消息的内容错误,消息为:" +msg);
95
			return msg;
99 96
		}
100 97
		
101
		//推送镜屏
102
		String jingpingData=JSON.toJSONString(dataMap);
103
		logger.debug("推送镜屏数据:" +jingpingData);
104
		JingPingSendDateUtil.sendData(topic,jingpingData);
105
		
106
		//保存报警数据
98
		//分析并推送报警数据
107 99
		receiveSubscribeService.receiveIotAlarmData(dataMap);
108 100
		
109 101
		return msg;

+ 19 - 19
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/impl/DeviceManageDaoImpl.java

@ -135,8 +135,8 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
135 135
	}
136 136
137 137
	@Override
138
	public Map<String, Object> queryAssociatUser(JMap params) throws Exception {
139
		List<Map<String, Object>> userAndDeviceList = dao.selectByCond(userAndDevicetableName, params);
138
	public Map<String, Object> queryOneBindDeviceInfo(Map<String, Object> dataMap) throws Exception {
139
		List<Map<String, Object>> userAndDeviceList = dao.selectByCond(userAndDevicetableName, dataMap);
140 140
		if (userAndDeviceList.isEmpty()) {
141 141
			return null;
142 142
		} else {
@ -200,9 +200,9 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
200 200
		map1.put("locationStatus", EbcConstant.location_status_normal);//状态: 0定位
201 201
		map1.put("deviceId", "999571");//终端ID
202 202
		map1.put("deviceNo", "999571");//终端编号
203
		map1.put("longitude", "123.7709438548");//经度
204
		map1.put("latitude", "31.58477450849");//纬度
205
		map1.put("newDate", "2020-10-26 10:12:24");//最新定位时间
203
		map1.put("longitude", "123.7709439");//经度
204
		map1.put("latitude", "31.5847745");//纬度
205
		map1.put("newDate", "2020-10-27 13:14:15");//最新定位时间
206 206
		list.add(map1);
207 207
208 208
		Map<String, Object> map2=new HashMap<String, Object>();
@ -210,8 +210,8 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
210 210
		map2.put("locationStatus", EbcConstant.location_status_normal);//状态: 0定位
211 211
		map2.put("deviceId", "981489");//终端ID
212 212
		map2.put("deviceNo", "981489");//终端编号
213
		map2.put("longitude", "126.422192652");//经度
214
		map2.put("latitude", "32.045333123");//纬度
213
		map2.put("longitude", "125.4221927");//经度
214
		map2.put("latitude", "32.0453331");//纬度
215 215
		map2.put("newDate", "2020-10-26 11:22:33");//最新定位时间
216 216
		list.add(map2);
217 217
		
@ -220,8 +220,8 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
220 220
		map3.put("locationStatus", EbcConstant.location_status_normal);//状态: 0定位
221 221
		map3.put("deviceId", "981453");//终端ID
222 222
		map3.put("deviceNo", "981453");//终端编号
223
		map3.put("longitude", "127.422192652");//经度
224
		map3.put("latitude", "34.045333123");//纬度
223
		map3.put("longitude", "122.0221926");//经度
224
		map3.put("latitude", "33.5453331");//纬度
225 225
		map3.put("newDate", "2020-10-27 12:31:45");//最新定位时间
226 226
		list.add(map3);
227 227
		
@ -230,9 +230,9 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
230 230
		map4.put("locationStatus", EbcConstant.location_status_normal);//状态: 0定位
231 231
		map4.put("deviceId", "23125");//终端ID
232 232
		map4.put("deviceNo", "23125");//终端编号
233
		map4.put("longitude", "125.822192652");//经度
234
		map4.put("latitude", "33.345333123");//纬度
235
		map4.put("newDate", "2020-10-27 09:18:13");//最新定位时间
233
		map4.put("longitude", "125.3221927");//经度
234
		map4.put("latitude", "33.3453331");//纬度
235
		map4.put("newDate", "2020-10-27 13:40:40");//最新定位时间
236 236
		list.add(map4);
237 237
		
238 238
		Map<String, Object> map5=new HashMap<String, Object>();
@ -240,8 +240,8 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
240 240
		map5.put("locationStatus", EbcConstant.location_status_normal);//状态: 0定位
241 241
		map5.put("deviceId", "23126");//终端ID
242 242
		map5.put("deviceNo", "23126");//终端编号
243
		map5.put("longitude", "126.922192652");//经度
244
		map5.put("latitude", "32.945333123");//纬度
243
		map5.put("longitude", "125.4221927");//经度
244
		map5.put("latitude", "32.9453331");//纬度
245 245
		map5.put("newDate", "2020-10-27 18:20:30");//最新定位时间
246 246
		list.add(map5);
247 247
		
@ -250,9 +250,9 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
250 250
		map6.put("locationStatus", EbcConstant.location_status_exclusion);//状态:3违规(禁区)
251 251
		map6.put("deviceId", "23128");//终端ID
252 252
		map6.put("deviceNo", "23128");//终端编号
253
		map6.put("longitude", "127.422192652");//经度
254
		map6.put("latitude", "33.045333123");//纬度
255
		map6.put("newDate", "2020-10-25 14:28:38");//最新定位时间
253
		map6.put("longitude", "124.5309335");//经度
254
		map6.put("latitude", "33.7753425");//纬度
255
		map6.put("newDate", "2020-10-27 14:28:38");//最新定位时间
256 256
		list.add(map6);
257 257
		
258 258
		Map<String, Object> map7=new HashMap<String, Object>();
@ -260,8 +260,8 @@ public class DeviceManageDaoImpl extends AbstractBizDao implements DeviceManageD
260 260
		map7.put("locationStatus", EbcConstant.location_status_offline);//状态:1离线
261 261
		map7.put("deviceId", "23129");//终端ID
262 262
		map7.put("deviceNo", "23129");//终端编号
263
		map7.put("longitude", "121.422192652");//经度
264
		map7.put("latitude", "31.045333123");//纬度
263
		map7.put("longitude", "122.4221927");//经度
264
		map7.put("latitude", "32.6453331");//纬度
265 265
		map7.put("newDate", "2020-10-27 14:15:22");//最新定位时间
266 266
		list.add(map7);
267 267

+ 1 - 1
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/impl/MapTagManageDaoImpl.java

@ -106,7 +106,7 @@ public class MapTagManageDaoImpl extends AbstractBizDao implements MapTagManageD
106 106
		params.put("mapTagShape", "POLYGON ((" + params.getString("mapTagShape") + "))");
107 107
108 108
		params.put("residenceTimeLength",
109
				params.get("residenceTimeLength") == null ? null : params.get("residenceTimeLength"));
109
				params.get("residenceTimeLength") == null ? 0 : params.getInt("residenceTimeLength"));
110 110
		params.put("mapTagContent", params.get("mapTagContent") == null ? null : params.get("mapTagContent"));
111 111
		params.put("remarks", params.get("remarks") == null ? null : params.get("remarks"));
112 112

+ 2 - 0
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/impl/RescueDaoImpl.java

@ -11,6 +11,7 @@ import com.ai.ipu.common.date.TimeUtil;
11 11
import com.ai.ipu.data.JMap;
12 12
import com.ai.ipu.database.dao.impl.AbstractBizDao;
13 13
import com.ai.ipu.server.dao.interfaces.RescueDao;
14
import com.ai.ipu.server.util.EbcConstant;
14 15
15 16
@Component
16 17
public class RescueDaoImpl extends AbstractBizDao implements RescueDao {
@ -36,6 +37,7 @@ public class RescueDaoImpl extends AbstractBizDao implements RescueDao {
36 37
		sql.append(" FROM LR_RESCUE_LOG l ");
37 38
		sql.append(" WHERE 1=1 ");
38 39
		sql.append(" AND RESCUERS_DATE IS NULL ");//TODO 救援时间为空
40
		sql.append(" AND ALARM_TYPE <> '").append(EbcConstant.alarm_type_offline).append("' ");//不属于离线告警
39 41
		sql.append(" AND DEVICE_ID = #{deviceId} ");
40 42
		dataMap.put("deviceId", params.get("deviceId"));
41 43
		

+ 7 - 1
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/interfaces/DeviceManageDao.java

@ -59,7 +59,13 @@ public interface DeviceManageDao {
59 59
60 60
	List<Map<String, Object>> queryAssociatBoatInfo(JMap params) throws Exception;
61 61
62
	Map<String, Object> queryAssociatUser(JMap params) throws Exception;
62
	/**
63
	 * 查询单个终端绑定信息
64
	 * @param params
65
	 * @return
66
	 * @throws Exception
67
	 */
68
	Map<String, Object> queryOneBindDeviceInfo(Map<String, Object> dataMap) throws Exception;
63 69
64 70
	int bindDevice(Map params, String type) throws Exception;
65 71

+ 3 - 3
ebc-sea-platform/src/main/java/com/ai/ipu/server/enums/ProductEnums.java

@ -11,11 +11,11 @@ import java.util.Map;
11 11
 */
12 12
public enum ProductEnums {
13 13
	// 船舶
14
	ship("003", "船舶", 1),
14
	ship("001", "船舶", 1),
15 15
	// 风机
16
	fan("001", "风机", 2),
16
	fan("002", "风机", 2),
17 17
	// 升压站
18
	booster("002", "升压站", 2),
18
	booster("003", "升压站", 2),
19 19
	// 测风塔
20 20
	anemometer("004", "测风塔", 2);
21 21

+ 3 - 1
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/impl/DeviceManageServiceImpl.java

@ -161,7 +161,9 @@ public class DeviceManageServiceImpl implements DeviceManageService {
161 161
	@Override
162 162
	public Map<String, Object> verifyUserOrBoatAssociatInfo(JMap params) throws Exception {
163 163
		// 查询用户与终端关联表,如果有数据返回,无数据返回空
164
		Map<String, Object> userAndDeviceMap = deviceManageDao.queryAssociatUser(params);
164
		Map<String, Object> dataMap=new HashMap<String, Object>();
165
		dataMap.put("PARTY_CODE", params.get("PARTY_CODE"));
166
		Map<String, Object> userAndDeviceMap = deviceManageDao.queryOneBindDeviceInfo(dataMap);
165 167
		return userAndDeviceMap;
166 168
	}
167 169

+ 150 - 113
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/impl/ReceiveSubscribeServiceImpl.java

@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
17 17
import com.ai.ipu.basic.log.ILogger;
18 18
import com.ai.ipu.basic.log.IpuLoggerFactory;
19 19
import com.ai.ipu.data.JMap;
20
import com.ai.ipu.database.conn.SqlSessionManager;
20 21
import com.ai.ipu.server.dao.interfaces.AreaInOutRecordDao;
21 22
import com.ai.ipu.server.dao.interfaces.DeviceManageDao;
22 23
import com.ai.ipu.server.dao.interfaces.MapTagManageDao;
@ -42,71 +43,94 @@ public class ReceiveSubscribeServiceImpl implements ReceiveSubscribeService {
42 43
	@Autowired
43 44
	AreaInOutRecordDao areaInOutRecordDao;
44 45
45
	//private ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
46
	private ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
46 47
47 48
	@Override
48 49
	public void receiveIotLocationData(JMap dataMap) {
49
		executeReceiveIotLocationData(dataMap);
50
		
51
		/*cachedThreadPool.execute(new Runnable() {
50
		cachedThreadPool.execute(new Runnable() {
52 51
			@Override
53 52
			public void run() {
54
				logger.debug("启动定位信息新线程:" + Thread.currentThread().getName());
55
				executeReceiveIotLocationData(dataMap);
53
				try {
54
					logger.debug("启动定位信息新线程:" + Thread.currentThread().getName());
55
					executeReceiveIotLocationData(dataMap);
56
57
					logger.debug("数据库连接全量提交");
58
					SqlSessionManager.commitAll();
59
				} catch (Exception ex) {
60
					logger.error(ex.getMessage());
61
					logger.debug("数据库连接全量回滚");
62
					SqlSessionManager.rollbackAll();
63
				} finally {
64
					logger.debug("数据库连接全量回收");
65
					SqlSessionManager.closeAll();
66
				}
67
56 68
			}
57
		});*/
69
		});
58 70
	}
59 71
60 72
	@Override
61 73
	public void receiveIotAlarmData(JMap dataMap) {
62
		executeReceiveIotAlarmData(dataMap);
63
		
64
		/*cachedThreadPool.execute(new Runnable() {
74
		cachedThreadPool.execute(new Runnable() {
65 75
			@Override
66 76
			public void run() {
67
				logger.debug("启动报警信息新线程:" + Thread.currentThread().getName());
68
				executeReceiveIotAlarmData(dataMap);
77
				try {
78
					logger.debug("启动报警信息新线程:" + Thread.currentThread().getName());
79
					executeReceiveIotAlarmData(dataMap);
80
81
					logger.debug("数据库连接全量提交");
82
					SqlSessionManager.commitAll();
83
				} catch (Exception ex) {
84
					logger.error(ex.getMessage());
85
					logger.debug("数据库连接全量回滚");
86
					SqlSessionManager.rollbackAll();
87
				} finally {
88
					logger.debug("数据库连接全量回收");
89
					SqlSessionManager.closeAll();
90
				}
69 91
			}
70
		});*/
92
		});
71 93
	}
72 94
73 95
	/**
74 96
	 * 处理定位数据
75 97
	 * @param dataMap
98
	 * @throws Exception 
76 99
	 */
77
	private void executeReceiveIotLocationData(JMap params) {
78
		try {
79
			// 1、查询是否为需救援的人员
80
			Map<String, Object> alarmMap = rescueDao.queryNoCloseRescueLog(params);
81
82
			// 当前已为报警信息
83
			if (alarmMap != null) {
84
				logger.info("定位信息为已报警人员:" + alarmMap.get("MAP_TAG_NAME"));
85
				// 执行对应方法
86
				beforeAlarmLocationData(params, alarmMap);
87
				// 报警人员不再进行围栏计算
88
				return;
89
			}
100
	private void executeReceiveIotLocationData(JMap params) throws Exception {
101
		// 1、获取人员信息
102
		Map<String, Object> dataMap=new HashMap<String, Object>();
103
		dataMap.put("DEVICE_ID", params.get("deviceId"));
104
		Map<String, Object> deviceAndUser = deviceManageDao.queryOneBindDeviceInfo(dataMap);
105
		params.put("userName", deviceAndUser.get("PARTY_NAME"));
106
107
		// 2、查询是否为需救援的人员
108
		Map<String, Object> alarmMap = rescueDao.queryNoCloseRescueLog(params);
109
110
		// 当前已为报警信息
111
		if (alarmMap != null && !alarmMap.isEmpty()) {
112
			logger.info("定位信息为已报警人员:" + alarmMap.get("MAP_TAG_NAME"));
113
			// 执行对应方法
114
			beforeAlarmLocationData(params, alarmMap);
115
			// 报警人员不再进行围栏计算
116
			return;
117
		}
90 118
91
			logger.debug("定位信息不是报警人员");
92
			// 2、查询人员当前是否在围栏内
93
			JMap currentAreaInfoJMap = mapTagManageDao.getInAreaInfo(params.getString("longitude"),
94
					params.getString("latitude"));
95
96
			// 3、查询人员之前所在围栏信息
97
			List<Map<String, Object>> beforeAreaMapList = areaInOutRecordDao.getBeforeAreaInfo(params);
98
99
			// 4、判断当前是否在围栏内
100
			if (currentAreaInfoJMap.getInt("mapTagNum") == 0) {
101
				logger.debug("定位信息不在围栏内");
102
				currentNotInArea(params, beforeAreaMapList);
103
			} else {
104
				logger.debug("定位信息在围栏内,围栏数量:" + currentAreaInfoJMap.getInt("mapTagNum"));
105
				currentInArea(params, currentAreaInfoJMap, beforeAreaMapList);
106
			}
119
		logger.debug("定位信息不是报警人员");
120
		// 3、查询人员当前是否在围栏内
121
		JMap currentAreaInfoJMap = mapTagManageDao.getInAreaInfo(params.getString("longitude"),
122
				params.getString("latitude"));
123
124
		// 4、查询人员之前所在围栏信息
125
		List<Map<String, Object>> beforeAreaMapList = areaInOutRecordDao.getBeforeAreaInfo(params);
107 126
108
		} catch (Exception ex) {
109
			logger.error(ex.getMessage());
127
		// 5、判断当前是否在围栏内
128
		if (currentAreaInfoJMap.getInt("mapTagNum") == 0) {
129
			logger.debug("定位信息不在围栏内");
130
			currentNotInArea(params, beforeAreaMapList);
131
		} else {
132
			logger.debug("定位信息在围栏内,围栏数量:" + currentAreaInfoJMap.getInt("mapTagNum"));
133
			currentInArea(params, currentAreaInfoJMap, beforeAreaMapList);
110 134
		}
111 135
	}
112 136
@ -118,19 +142,11 @@ public class ReceiveSubscribeServiceImpl implements ReceiveSubscribeService {
118 142
	 * @throws ParseException 
119 143
	 */
120 144
	private void beforeAlarmLocationData(JMap params, Map<String, Object> alarmMap) throws Exception {
121
		String newDate = params.getString("newDate");// 当前定位时间
122 145
		String alarmDate = String.valueOf(alarmMap.get("CALLER_DATE"));// 求救时间
123 146
		params.put("alarmDate", alarmDate);
124 147
125 148
		// 计算持续时长
126
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
127
		long newDateLong = simpleDateFormat.parse(newDate).getTime();
128
		long alarmDateLong = simpleDateFormat.parse(alarmDate).getTime();
129
		long alarmLong = newDateLong - alarmDateLong;
130
			BigDecimal alarmLongBigDecimal = new BigDecimal(alarmLong);
131
			// 单位为分,四舍五入不保留小数
132
			alarmLongBigDecimal = alarmLongBigDecimal.divide(new BigDecimal("60000L"), 0, BigDecimal.ROUND_HALF_UP);
133
			params.put("alarmLong", alarmLongBigDecimal.intValue());
149
		params.put("alarmLong", JingPingSendDateUtil.getBetweenMinuteValue(alarmDate, params.getString("newDate")));
134 150
135 151
		// 推送镜屏
136 152
		String jingpingData = JSON.toJSONString(params);
@ -243,10 +259,11 @@ public class ReceiveSubscribeServiceImpl implements ReceiveSubscribeService {
243 259
	 */
244 260
	private void currentInAreaSendData(JMap params, List<Map<String, Object>> currentAreaInfoList)
245 261
			throws ParseException {
246
		// 获得用于推送镜屏的围栏信息
262
247 263
		int maxMapTagGrade = 0; // 围栏优先级(电子围栏5>定点3>考勤1、作业1)
248 264
		long minInAreaLong = System.currentTimeMillis();// 进入围栏最早的时间戳
249
		int mapTagIndex = 0;// 围栏的索引
265
		Map<String, Object> sendDataAreaInfo = null;// 用于推送镜屏的围栏信息
266
250 267
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
251 268
252 269
		for (int i = 0; i < currentAreaInfoList.size(); i++) {
@ -273,44 +290,39 @@ public class ReceiveSubscribeServiceImpl implements ReceiveSubscribeService {
273 290
						.getTime();
274 291
				if (inAreaLong < minInAreaLong) {
275 292
					minInAreaLong = inAreaLong;
276
					mapTagIndex = i;
293
					sendDataAreaInfo = currentAreaInfoList.get(i);
277 294
				}
278 295
			} else if (mapTagGrade > maxMapTagGrade) {
279 296
				maxMapTagGrade = mapTagGrade;
280 297
				minInAreaLong = simpleDateFormat.parse(String.valueOf(currentAreaInfoList.get(i).get("inAreaDate")))
281 298
						.getTime();
282
				mapTagIndex = i;
299
				sendDataAreaInfo = currentAreaInfoList.get(i);
283 300
			}
284 301
		}
285 302
286 303
		if (maxMapTagGrade == 5) {
287 304
			logger.info("镜屏推送进入电子围栏的信息");
288 305
			// 进入电子围栏(禁区),需显示进入时间
289
			params.put("inDate", currentAreaInfoList.get(mapTagIndex).get("inAreaDate"));
306
			params.put("inDate", sendDataAreaInfo.get("inAreaDate"));
290 307
			params.put("locationStatus", EbcConstant.location_status_exclusion);
291 308
292 309
		} else if (maxMapTagGrade == 3) {
293 310
			// 进入定点(限时),需计算是否超时
294
			String newDate = params.getString("newDate");// 当前定位时间
295
			long newDateLong = simpleDateFormat.parse(newDate).getTime();
296
			long fixedLong = newDateLong - minInAreaLong;
297
			if (fixedLong>=60000L) {
298
				BigDecimal fixedLongBigDecimal = new BigDecimal(fixedLong);
299
				// 单位为分,四舍五入不保留小数
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
}

+ 6 - 9
ebc-sea-platform/src/main/java/com/ai/ipu/server/util/EbcConstant.java

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

+ 31 - 10
ebc-sea-platform/src/main/java/com/ai/ipu/server/util/JingPingSendDateUtil.java

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