浏览代码

Merge remote-tracking branch 'origin/master'

wangchao 4 年之前
父节点
当前提交
993f22008d
共有 17 个文件被更改,包括 502 次插入327 次删除
  1. 1 1
      ebc-sea-platform/src/main/java/com/ai/ipu/server/controller/RescueController.java
  2. 14 2
      ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/impl/RescueDaoImpl.java
  3. 12 4
      ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/interfaces/RescueDao.java
  4. 81 84
      ebc-sea-platform/src/main/java/com/ai/ipu/server/enums/UserEnums.java
  5. 88 70
      ebc-sea-platform/src/main/java/com/ai/ipu/server/service/impl/DeviceManageServiceImpl.java
  6. 98 60
      ebc-sea-platform/src/main/java/com/ai/ipu/server/service/impl/RescueServiceImpl.java
  7. 1 1
      ebc-sea-platform/src/main/java/com/ai/ipu/server/service/interfaces/RescueService.java
  8. 42 12
      ebc-sea-platform/src/main/java/com/ai/ipu/server/service/iotdata/ManageIotNoCloseAlarmData.java
  9. 44 24
      ebc-sea-platform/src/main/java/com/ai/ipu/server/util/DateUtil.java
  10. 6 6
      ebc-sea-platform/src/main/java/com/ai/ipu/server/util/EbcConstant.java
  11. 16 15
      ebc-sea-platform/src/main/java/com/ai/ipu/server/util/HttpServiceUtil.java
  12. 82 38
      ebc-sea-platform/src/main/java/com/ai/ipu/server/util/NorthboundInterfaceUtil.java
  13. 3 0
      ebc-sea-platform/src/main/resources/dev/application-gis.properties
  14. 5 2
      ebc-sea-platform/src/main/resources/dev/application-iot.properties
  15. 3 0
      ebc-sea-platform/src/main/resources/pro/application-gis.properties
  16. 3 8
      ebc-sea-platform/src/main/resources/sql/ipu/RescueDao.xml
  17. 3 0
      ebc-sea-platform/src/main/resources/test/application-gis.properties

+ 1 - 1
ebc-sea-platform/src/main/java/com/ai/ipu/server/controller/RescueController.java

@ -35,7 +35,7 @@ public class RescueController {
35 35
	public JMap queryCurrentRescueLocationInfo(JMap params) throws Exception {
36 36
		JMap result = new JsonMap();
37 37
38
		List<Map<String, String>> resultList = rescueService.queryCurrentRescueLocationInfo(params);
38
		List<Map<String, Map<String, String>>> resultList = rescueService.queryCurrentRescueLocationInfo(params);
39 39
		result.put("dataList", resultList);
40 40
		return result;
41 41
	}

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

@ -72,9 +72,9 @@ public class RescueDaoImpl extends AbstractBizDao implements RescueDao {
72 72
	}
73 73
74 74
	@Override
75
	public List<Map<String, Object>> queryNoCloseRescueLog(List<String> deviceIdsList) throws Exception {
75
	public List<Map<String, Object>> queryNoCloseRescueLog(String deviceId) throws Exception {
76 76
		Map<String, Object> dataMap = new HashMap<String, Object>();
77
		dataMap.put("deviceIdsList", deviceIdsList);// 设备ID
77
		dataMap.put("deviceId", deviceId);// 设备ID
78 78
		dataMap.put("offlineType", EbcConstant.alarm_type_offline_ZH);// 不属于离线告警
79 79
		dataMap.put("alarmDataStatus", EbcConstant.data_status_valid);// 数据状态
80 80
@ -127,4 +127,16 @@ public class RescueDaoImpl extends AbstractBizDao implements RescueDao {
127 127
		dataMap.put("LOG_ID", params.getString("alarmLogId"));
128 128
		return dao.delete("LR_RESCUE_LOG", dataMap) > 0;
129 129
	}
130
	
131
	@Override
132
	public List<Map<String, Object>> queryListRescuerInfo(JMap params, int pageNum, int pageSize) throws Exception {
133
		StringBuilder sql = new StringBuilder();
134
		
135
		sql.append(" SELECT RESCUERS_ID ID,PARTY_CODE CODE ,PARTY_NAME NAME  ");
136
		sql.append(" FROM LR_RESCUERS ");
137
		sql.append(" WHERE DATA_STATUS ='").append(EbcConstant.data_status_valid).append("' ");
138
		
139
		return dao.executeSelect(sql.toString(), pageNum, pageSize);
140
	}
141
	
130 142
}

+ 12 - 4
ebc-sea-platform/src/main/java/com/ai/ipu/server/dao/interfaces/RescueDao.java

@ -19,11 +19,11 @@ public interface RescueDao {
19 19
20 20
	/**
21 21
	 * 根据终端ID获取未关闭的报警救援日志
22
	 * @param deviceIdsList
22
	 * @param deviceId
23 23
	 * @return
24 24
	 * @throws Exception
25 25
	 */
26
	List<Map<String, Object>> queryNoCloseRescueLog(List<String> deviceIdsList) throws Exception;
26
	List<Map<String, Object>> queryNoCloseRescueLog(String deviceId) throws Exception;
27 27
28 28
	/**
29 29
	 * 查询单个报警救援日志
@ -41,8 +41,6 @@ public interface RescueDao {
41 41
	 */
42 42
	String addRescueLog(Map<String, Object> dataMap) throws Exception;
43 43
44
	
45
	
46 44
	/**
47 45
	 * 修改报警救援日志
48 46
	 * @param dataMap
@ -59,4 +57,14 @@ public interface RescueDao {
59 57
	 */
60 58
	boolean deleteRescueLog(JMap params) throws Exception;
61 59
	
60
	/**
61
	 * 获取救援者的下拉列表
62
	 * @param params
63
	 * @param pageNum 当前页数
64
	 * @param pageSize 每页条数
65
	 * @return
66
	 * @throws Exception
67
	 */
68
	List<Map<String, Object>> queryListRescuerInfo(JMap params, int pageNum, int pageSize) throws Exception;
69
	
62 70
}

+ 81 - 84
ebc-sea-platform/src/main/java/com/ai/ipu/server/enums/UserEnums.java

@ -1,17 +1,12 @@
1 1
package com.ai.ipu.server.enums;
2 2
3
import java.lang.reflect.InvocationTargetException;
4 3
import java.util.ArrayList;
5 4
import java.util.HashMap;
6 5
import java.util.List;
7
import java.lang.reflect.Field;
8
import java.lang.reflect.Method;
9 6
import java.util.Map;
10 7
11
import org.springframework.util.ReflectionUtils;
12
13 8
public enum UserEnums {
14
	//工人
9
	// 工人
15 10
	oneUser(1, "张三", "1111", 1, 1, "zhangsan", "经理"), 
16 11
	twoUser(2, "李四", "2222", 1, 1, "lisi", "员工"),
17 12
	threeUser(3, "王五", "3333", 1, 1, "wangwu", "员工"), 
@ -21,14 +16,14 @@ public enum UserEnums {
21 16
	sevenUser(7, "吴九", "7777", 1, 1, "wujiu", "员工"), 
22 17
	eightUser(8, "郑十", "8888", 1, 1, "zhengshi", "员工"),
23 18
	nineUser(0, "刘一", "9999", 1, 1, "liuyi", "员工"),
24
	//救援者
25
	oneRescuer(0, "童一", "1001", 2, 1, "tongyi", "员工"),
26
	twoRescuer(0, "童二", "1002", 2, 1, "tonger", "员工"),
27
	threeRescuer(0, "童三", "1003", 2, 1, "tongsan", "员工"),
28
	fourRescuer(0, "童四", "1004", 2, 1, "tongsi", "员工"),
29
	fiveRescuer(0, "童五", "1005", 2, 1, "tongwu", "员工"),
30
	sixRescuer(0, "童六", "1006", 2, 1, "tongliu", "员工");
31
	
19
	// 救援者
20
	oneRescuer(1, "童一", "1001", 2, 1, "tongyi", "员工"), 
21
	twoRescuer(2, "童二", "1002", 2, 1, "tonger", "员工"),
22
	threeRescuer(3, "童三", "1003", 2, 1, "tongsan", "员工"),
23
	fourRescuer(4, "童四", "1004", 2, 1, "tongsi", "员工"),
24
	fiveRescuer(5, "童五", "1005", 2, 1, "tongwu", "员工"), 
25
	sixRescuer(6, "童六", "1006", 2, 1, "tongliu", "员工");
26
32 27
	public int id; // id
33 28
	public String userName;// 姓名
34 29
	public String employeeNo;// 员工编号
@ -41,8 +36,8 @@ public enum UserEnums {
41 36
42 37
	}
43 38
44
	private UserEnums(int id, String userName, String employeeNo, int department, int employeeType,
45
			String employeeCode, String duty) {
39
	private UserEnums(int id, String userName, String employeeNo, int department, int employeeType, String employeeCode,
40
			String duty) {
46 41
		this.id = id;
47 42
		this.userName = userName;
48 43
		this.employeeNo = employeeNo;
@ -93,7 +88,7 @@ public enum UserEnums {
93 88
		}
94 89
		return null;
95 90
	}
96
	
91
97 92
	/**
98 93
	 * 根据员工编号返回枚举值
99 94
	 * @param id
@ -109,79 +104,81 @@ public enum UserEnums {
109 104
	}
110 105
111 106
	/**
112
	 * 根据序号获取枚举数组中的值,序号必须从0开始
113
	 * @param id
114
	 * @return
115
	 * @throws IllegalAccessException
116
	 * @throws IllegalArgumentException
117
	 * @throws InvocationTargetException
118
	 * @throws InstantiationException
119
	 */
107
			* 根据序号获取枚举数组中的值,序号必须从0开始
108
			* @param id
109
			* @return
110
			* @throws IllegalAccessException
111
			* @throws IllegalArgumentException
112
			* @throws InvocationTargetException
113
			* @throws InstantiationException
114
			*/
115
	/*
120 116
	public static <T> List<T> getEumByKey(int id)
121
			throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
122
		List<String> enumList = getEumValueList();
123
		List<T> enumList1 = new ArrayList<T>();
124
		for (UserEnums testEnums : UserEnums.values()) {
125
			if (testEnums.getId() == id) {
126
				Class<?> clazz = testEnums.getClass();
127
				// 获取所有常量
128
				Object object = clazz.getEnumConstants()[id];
129
				Field[] filedFields = clazz.getFields();
130
				for (Field field : filedFields) {
131
					field.setAccessible(true);
132
					Object sssObject = field.get(object);
133
					if (enumList.contains(field.getName())) {
134
						continue;
135
					} else {
136
						if (sssObject != null)
137
							enumList1.add((T) sssObject);
138
					}
117
		throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
118
	List<String> enumList = getEumValueList();
119
	List<T> enumList1 = new ArrayList<T>();
120
	for (UserEnums testEnums : UserEnums.values()) {
121
		if (testEnums.getId() == id) {
122
			Class<?> clazz = testEnums.getClass();
123
			// 获取所有常量
124
			Object object = clazz.getEnumConstants()[id];
125
			Field[] filedFields = clazz.getFields();
126
			for (Field field : filedFields) {
127
				field.setAccessible(true);
128
				Object sssObject = field.get(object);
129
				if (enumList.contains(field.getName())) {
130
					continue;
131
				} else {
132
					if (sssObject != null)
133
						enumList1.add((T) sssObject);
139 134
				}
140
				return enumList1;
141 135
			}
136
			return enumList1;
142 137
		}
143
		return null;
144 138
	}
145
146
	/**
147
	 * 获取枚举值常量列表
148
	 * @param
149
	 * @return
150
	 */
139
	return null;
140
	}
141
	
142
	*//**
143
		* 获取枚举值常量列表
144
		* @param
145
		* @return
146
		*/
147
	/*
151 148
	public static List<String> getEumValueList() {
152
		List<String> list = new ArrayList<String>();
153
		for (Object object : UserEnums.values()) {
154
			list.add(object.toString());
155
		}
156
		return list;
149
	List<String> list = new ArrayList<String>();
150
	for (Object object : UserEnums.values()) {
151
		list.add(object.toString());
157 152
	}
158
159
	/**
160
	 * 传入方法名称  values是值 ,field是 字段mingcheng
161
	 * @param <T>
162
	 * @param enumType
163
	 * @param value
164
	 * @param field
165
	 * @return
166
	 * @throws Exception
167
	 */
168
	public static <T extends Enum<T>> T getEnumOnValue(Class<T> enumType, String value, String field) throws Exception {
169
170
		for (Object obj : enumType.getEnumConstants()) {
171
			Method m = obj.getClass().getDeclaredMethod("values", null);
172
			Object[] results = (Object[]) m.invoke(obj, null);
173
			for (Object result : results) {
174
				Field codeField = result.getClass().getDeclaredField(field);
175
				ReflectionUtils.makeAccessible(codeField);
176
				String fileValue = String.valueOf(ReflectionUtils.getField(codeField, result));
177
				if (fileValue.equals(value)) {
178
					return (T) result;
153
	return list;
154
	}
155
	
156
	*//**
157
		* 传入方法名称  values是值 ,field是 字段mingcheng
158
		* @param <T>
159
		* @param enumType
160
		* @param value
161
		* @param field
162
		* @return
163
		* @throws Exception
164
		*//*
165
			public static <T extends Enum<T>> T getEnumOnValue(Class<T> enumType, String value, String field) throws Exception {
166
			
167
			for (Object obj : enumType.getEnumConstants()) {
168
				Method m = obj.getClass().getDeclaredMethod("values", null);
169
				Object[] results = (Object[]) m.invoke(obj, null);
170
				for (Object result : results) {
171
					Field codeField = result.getClass().getDeclaredField(field);
172
					ReflectionUtils.makeAccessible(codeField);
173
					String fileValue = String.valueOf(ReflectionUtils.getField(codeField, result));
174
					if (fileValue.equals(value)) {
175
						return (T) result;
176
					}
177
			
179 178
				}
180
181 179
			}
182
		}
183
		return null;
184
	}
180
			return null;
181
			}*/
185 182
186 183
	/**
187 184
	 * 获取所有的用户放到list里
@ -205,7 +202,7 @@ public enum UserEnums {
205 202
		}
206 203
		return list;
207 204
	}
208
	
205
209 206
	/**
210 207
	 * 按部门获取所有的用户放到list里
211 208
	 *
@ -215,7 +212,7 @@ public enum UserEnums {
215 212
	public static List<Map<String, Object>> getUserListByDepy(int department) {
216 213
		ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
217 214
		for (UserEnums userEnum : UserEnums.values()) {
218
			if (department==userEnum.getDepartment()) {
215
			if (department == userEnum.getDepartment()) {
219 216
				Map<String, Object> userMap = new HashMap<String, Object>();
220 217
				userMap.put("id", userEnum.getId());
221 218
				userMap.put("userName", userEnum.getUserName());
@ -229,5 +226,5 @@ public enum UserEnums {
229 226
		}
230 227
		return list;
231 228
	}
232
	
229
233 230
}

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

@ -63,10 +63,10 @@ public class DeviceManageServiceImpl implements DeviceManageService {
63 63
			}
64 64
65 65
			if (bindDeviceBoolean) {
66
				//只查询绑定的终端:包含
66
				// 只查询绑定的终端:包含
67 67
				paramsMap.put("resourceIdList", deviceIds.toString());
68 68
			} else if (unBindDeviceBoolean) {
69
				//只查询不绑定的终端:不包含
69
				// 只查询不绑定的终端:不包含
70 70
				paramsMap.put("notIn", deviceIds.toString());
71 71
			}
72 72
		}
@ -208,8 +208,13 @@ public class DeviceManageServiceImpl implements DeviceManageService {
208 208
		// 获取终端当前位置信息
209 209
		List<Map<String, String>> list = deviceManageDao.queryCurrentDeviceLocationInfo(deviceIdsList);
210 210
211
		if (list.isEmpty()) {
212
			logger.info("未查询到设备位置信息");
213
			return new ArrayList();
214
		}
215
211 216
		// 查询当前所有未关闭的求救信息
212
		List<Map<String, Object>> alarmMapList = rescueDao.queryNoCloseRescueLog(deviceIdsList);
217
		List<Map<String, Object>> alarmMapList = rescueDao.queryNoCloseRescueLog(null);
213 218
214 219
		// 查询人员所在围栏信息
215 220
		List<String> mapTagTypeList = new ArrayList<String>();
@ -223,71 +228,83 @@ public class DeviceManageServiceImpl implements DeviceManageService {
223 228
		for (Map<String, String> map : list) {
224 229
			String deviceId = map.get("deviceId");
225 230
			map.put("locationStatus", EbcConstant.location_status_normal);// 定位状态
226
			
231
227 232
			boolean flag = true;
228
			
233
229 234
			// 人员名称
230 235
			for (Map<String, Object> bindDeviceMap : bindUserDeviceList) {
231 236
				if (deviceId.equals(String.valueOf(bindDeviceMap.get("DEVICE_ID")))) {
232 237
					map.put("userName", String.valueOf(bindDeviceMap.get("NAME")));
238
					map.put("userCode", String.valueOf(bindDeviceMap.get("CODE")));
233 239
					break;
234 240
				}
235 241
			}
236
			
237
			//离线信息
238
			if (map.get("alarmType")!=null&&EbcConstant.alarm_type_offline_beidou==Integer.parseInt(String.valueOf(map.get("alarmType")))) {
239
				map.put("locationStatus",EbcConstant.location_status_offline);//定位状态
240
				map.put("alarmType",EbcConstant.alarm_type_offline_ZH);//报警类型
242
243
			// 离线信息
244
			if (map.get("alarmType") != null && EbcConstant.alarm_type_offline_beidou == Integer
245
					.parseInt(String.valueOf(map.get("alarmType")))) {
246
				map.put("locationStatus", EbcConstant.location_status_offline);// 定位状态
247
				map.put("alarmType", EbcConstant.alarm_type_offline_ZH);// 报警类型
241 248
				flag = false;
242 249
			}
243
			
250
244 251
			// 求救信息
245
			if (alarmMapList != null && flag) {
252
			if (flag && alarmMapList != null && !alarmMapList.isEmpty()) {
246 253
				for (int i = 0; i < alarmMapList.size() && flag; i++) {
247 254
					Map<String, Object> alarmMap = alarmMapList.get(i);
255
					
256
					// 判断是救援者还是求救者
248 257
					if (deviceId.equals(String.valueOf(alarmMap.get("DEVICE_ID")))) {
249
						// 求救时间
250
						String alarmDate = String.valueOf(alarmMap.get("CALLER_DATE"));
251
						map.put("alarmDate", DateUtil.formatStrDate(alarmDate));
258
							// 求救
259
							// 求救时间
260
							String alarmDate = String.valueOf(alarmMap.get("CALLER_DATE"));
261
							map.put("alarmDate", DateUtil.formatStrDate(alarmDate));
262
263
							// 计算求救时长
264
							int alarmLong = DateUtil.getDifferenceMinute(alarmDate, map.get("newDate"));
265
							map.put("alarmLong", String.valueOf(alarmLong));
266
267
							if (alarmMap.get("RESCUERS_ID") == null) {
268
								// 未指派救援人员
269
								map.put("isNewAlarm", EbcConstant.alarm_status_needassign);
270
							} else {
271
								// 已指派救援人员
272
								map.put("isNewAlarm", EbcConstant.alarm_status_needclose);
273
								// map.put("rescuerDeviceId", String.valueOf(alarmMap.get("RESCUER_DEVICE_ID")));//救援者的设备ID
274
							}
252 275
253
						// 计算求救时长
254
						int alarmLong = DateUtil.getDifferenceMinute(alarmDate, map.get("newDate"));
255
						map.put("alarmLong", String.valueOf(alarmLong));
256
						
257
						if (alarmMap.get("RESCUERS_ID")==null) {
258
							//未指派救援人员
259
							params.put("isNewAlarm", EbcConstant.alarm_status_needassign);
260
						}else {
261
							//已指派救援人员
262
							params.put("isNewAlarm", EbcConstant.alarm_status_needclose);
263
						}
264
						
265
						//求救记录ID
266
						params.put("alarmLogId", alarmMap.get("LOG_ID"));
267
268
						//定位状态
269
						switch (String.valueOf(alarmMap.get("ALARM_TYPE"))) {
270
						case EbcConstant.alarm_type_autosos_ZH:
271
							//自动报警
272
							map.put("locationStatus",EbcConstant.location_status_autosos);
273
							map.put("alarmType",EbcConstant.alarm_type_autosos_ZH);
274
							break;
275
						case EbcConstant.alarm_type_jogsos_ZH:
276
							//手动报警
277
							map.put("locationStatus",EbcConstant.location_status_jogsos);
278
							map.put("alarmType",EbcConstant.alarm_type_jogsos_ZH);
279
							break;
280
						default:
281
							break;
282
						}
276
							// 求救记录ID
277
							map.put("alarmLogId", String.valueOf(alarmMap.get("LOG_ID")));
278
279
							// 定位状态
280
							switch (String.valueOf(alarmMap.get("ALARM_TYPE"))) {
281
							case EbcConstant.alarm_type_autosos_ZH:
282
								// 自动报警
283
								map.put("locationStatus", EbcConstant.location_status_autosos);
284
								map.put("alarmType", EbcConstant.alarm_type_autosos_ZH);
285
								break;
286
							case EbcConstant.alarm_type_jogsos_ZH:
287
								// 手动报警
288
								map.put("locationStatus", EbcConstant.location_status_jogsos);
289
								map.put("alarmType", EbcConstant.alarm_type_jogsos_ZH);
290
								break;
291
							default:
292
								break;
293
							}
294
295
						flag = false;
283 296
						
297
					}else if(deviceId.equals(String.valueOf(alarmMap.get("RESCUER_DEVICE_ID")))){
298
						// 救援者
299
						map.put("locationStatus", EbcConstant.location_status_rescuer);// 定位状态
300
						// map.put("alarmDeviceId", String.valueOf(alarmMap.get("DEVICE_ID"))); // 求救者的设备ID
284 301
						flag = false;
285 302
					}
286 303
				}
287 304
			}
288 305
289 306
			// 违规信息
290
			if (areaViolationMapList != null && flag) {
307
			if (flag && areaViolationMapList != null && !areaViolationMapList.isEmpty()) {
291 308
				int maxMapTagGrade = 0; // 围栏优先级(电子围栏5>定点3>考勤1、作业1)
292 309
				long minInAreaLong = System.currentTimeMillis();// 进入围栏最早的时间戳
293 310
				Map<String, Object> areaInfoMap = null;// 用于计算时间的围栏信息
@ -331,7 +348,8 @@ public class DeviceManageServiceImpl implements DeviceManageService {
331 348
332 349
				} else if (maxMapTagGrade == 3) {
333 350
					// 进入定点(限时),需计算是否超时
334
					int fixedLong = DateUtil.getDifferenceMinute(String.valueOf(areaInfoMap.get("IN_DATE")), map.get("newDate"));
351
					int fixedLong = DateUtil.getDifferenceMinute(String.valueOf(areaInfoMap.get("IN_DATE")),
352
							map.get("newDate"));
335 353
336 354
					if (fixedLong > 0) {
337 355
						// 围栏要求定点时间
@ -350,35 +368,35 @@ public class DeviceManageServiceImpl implements DeviceManageService {
350 368
351 369
		return list;
352 370
	}
353
	
371
354 372
	@Override
355 373
	public JMap queryOneDeviceLocationInfo(JMap params, int pageNum, int pageSize) throws Exception {
356
		JMap resultJMap=new JsonMap();
357
		String beginTime=null;//开始时间
358
		String endTime=null;//结束时间
359
		
360
		//时间段类型
374
		JMap resultJMap = new JsonMap();
375
		String beginTime = null;// 开始时间
376
		String endTime = null;// 结束时间
377
378
		// 时间段类型
361 379
		switch (params.getString("timeType")) {
362 380
		case EbcConstant.locus_time_interval_tenMinute:
363
			//10分钟
364
			endTime=TimeUtil.getSysTime();
365
			beginTime=DateUtil.dateAddMinute(endTime, -10);
381
			// 10分钟
382
			endTime = TimeUtil.getSysTime();
383
			beginTime = DateUtil.dateAddMinute(endTime, -10);
366 384
			break;
367 385
		case EbcConstant.locus_time_interval_oneHour:
368
			//1小时
369
			endTime=TimeUtil.getSysTime();
370
			beginTime=DateUtil.dateAddHour(endTime, -1);
386
			// 1小时
387
			endTime = TimeUtil.getSysTime();
388
			beginTime = DateUtil.dateAddHour(endTime, -1);
371 389
			break;
372 390
		case EbcConstant.locus_time_interval_oneDay:
373
			//1天
374
			endTime=TimeUtil.getSysTime();
375
			beginTime=DateUtil.dateAddDay(endTime, -1);
391
			// 1天
392
			endTime = TimeUtil.getSysTime();
393
			beginTime = DateUtil.dateAddDay(endTime, -1);
376 394
			break;
377 395
		case EbcConstant.locus_time_interval_custom:
378
			//自定义
379
			beginTime=params.getString("beginTime");
380
			endTime=params.getString("endTime");
381
			if (beginTime==null||"".equals(beginTime)||endTime==null||"".equals(endTime)) {
396
			// 自定义
397
			beginTime = params.getString("beginTime");
398
			endTime = params.getString("endTime");
399
			if (beginTime == null || "".equals(beginTime) || endTime == null || "".equals(endTime)) {
382 400
				resultJMap.put("result", false);
383 401
				resultJMap.put("errMsg", "日期不能为空");
384 402
				return resultJMap;
@ -389,13 +407,13 @@ public class DeviceManageServiceImpl implements DeviceManageService {
389 407
			resultJMap.put("errMsg", "时间段无效");
390 408
			return resultJMap;
391 409
		}
392
		
410
393 411
		Map<String, String> paramsMap = new HashMap<String, String>();
394
		paramsMap.put("resourceId", params.getString("deviceId"));//终端ID
412
		paramsMap.put("resourceId", params.getString("deviceId"));// 终端ID
395 413
		paramsMap.put("startTime", beginTime);
396 414
		paramsMap.put("endTime", endTime);
397
		
398
		resultJMap= deviceManageDao.queryOneDeviceLocationInfo(paramsMap, pageNum, pageSize);
415
416
		resultJMap = deviceManageDao.queryOneDeviceLocationInfo(paramsMap, pageNum, pageSize);
399 417
		return resultJMap;
400 418
	}
401 419

+ 98 - 60
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/impl/RescueServiceImpl.java

@ -5,6 +5,10 @@ import java.util.HashMap;
5 5
import java.util.List;
6 6
import java.util.Map;
7 7
8
import javax.websocket.Session;
9
10
import org.slf4j.Logger;
11
import org.slf4j.LoggerFactory;
8 12
import org.springframework.beans.factory.annotation.Autowired;
9 13
import org.springframework.stereotype.Service;
10 14
@ -18,19 +22,19 @@ import com.ai.ipu.server.util.EbcConstant;
18 22
19 23
@Service
20 24
public class RescueServiceImpl implements RescueService {
25
	Logger logger = LoggerFactory.getLogger(RescueServiceImpl.class);
21 26
22 27
	@Autowired
23 28
	RescueDao rescueDao;
24
	
29
25 30
	@Autowired
26 31
	DeviceManageDao deviceManageDao;
27 32
28 33
	@Override
29 34
	public List<Map<String, Object>> queryListRescuerInfo(JMap params, int pageNum, int pageSize) throws Exception {
30
		// TODO 调用uspa接口获取人员信息 暂时用枚举(救援的部门为2)
31
		return UserEnums.getUserListByDepy(2);
35
		return rescueDao.queryListRescuerInfo(params, pageNum, pageSize);
32 36
	}
33
	
37
34 38
	@Override
35 39
	public boolean assignRescuer(JMap params) throws Exception {
36 40
		// 修改最后定位时间
@ -51,8 +55,7 @@ public class RescueServiceImpl implements RescueService {
51 55
52 56
	@Override
53 57
	public JMap queryPageRescueLog(JMap params, int pageNum, int pageSize) throws Exception {
54
		//TODO 计算求救时间、按时间查询
55
		
58
		// TODO 计算求救时间、按时间查询
56 59
		
57 60
		return rescueDao.queryPageRescueLog(params, pageNum, pageSize);
58 61
	}
@ -63,91 +66,126 @@ public class RescueServiceImpl implements RescueService {
63 66
	}
64 67
65 68
	@Override
66
	public List<Map<String, String>> queryCurrentRescueLocationInfo(JMap params) throws Exception {
69
	public List<Map<String, Map<String, String>>> queryCurrentRescueLocationInfo(JMap params) throws Exception {
67 70
		// 查询当前所有未关闭的求救信息
68 71
		List<Map<String, Object>> alarmMapList = rescueDao.queryNoCloseRescueLog(null);
69
		
72
73
		if (alarmMapList == null || alarmMapList.isEmpty()) {
74
			logger.info("未查询到未关闭的求救信息");
75
			return new ArrayList();
76
		}
77
70 78
		List<String> deviceIdsList = new ArrayList<String>();
71 79
		for (int i = 0; i < alarmMapList.size(); i++) {
72 80
			deviceIdsList.add(String.valueOf(alarmMapList.get(i).get("DEVICE_ID")));
73
			if (alarmMapList.get(i).get("RESCUER_DEVICE_ID")!=null) {
81
			if (alarmMapList.get(i).get("RESCUER_DEVICE_ID") != null) {
74 82
				deviceIdsList.add(String.valueOf(alarmMapList.get(i).get("RESCUER_DEVICE_ID")));
75 83
			}
76 84
		}
77
		
85
78 86
		// 获取终端当前位置信息
79
		List<Map<String, String>> list = deviceManageDao.queryCurrentDeviceLocationInfo(deviceIdsList);
87
		List<Map<String, String>> deviceList = deviceManageDao.queryCurrentDeviceLocationInfo(deviceIdsList);
88
89
		if (deviceList.isEmpty()) {
90
			logger.info("未查询到设备位置信息");
91
			return new ArrayList();
92
		}
80 93
81 94
		// 拼接返回数据
82
		for (Map<String, String> map : list) {
83
			String deviceId = map.get("deviceId");
84
			boolean flag=true; //是否为救援人员
85
			
86
			for (int i = 0; i < alarmMapList.size()&&flag; i++) {
87
				Map<String, Object> alarmMap = alarmMapList.get(i);
88
				if (deviceId.equals(String.valueOf(alarmMap.get("DEVICE_ID")))) {
89
					//拼接报警人员的信息
90
					//员工姓名
91
					map.put("userName", String.valueOf(alarmMap.get("PARTY_NAME")));
92
					
95
		List<Map<String, Map<String, String>>> resultList = new ArrayList<Map<String, Map<String, String>>>();
96
		for (Map<String, Object> alarmMap : alarmMapList) {
97
			Map<String, Map<String, String>> resultDataMap = new HashMap<String, Map<String, String>>();
98
99
			String alarmDeviceId = String.valueOf(alarmMap.get("DEVICE_ID"));// 求救者的设备ID
100
			String rescuerDeviceId = null;// 救援者的设备ID
101
102
			// 求救者的设备ID
103
			int countBreakLoop = 0; // 统计需跳出循环的数量
104
			int sumBreakLoop = 1; // 跳出循环的总数量
105
			if (alarmMap.get("RESCUERS_ID") != null) {
106
				// 有救援者
107
				rescuerDeviceId = String.valueOf(alarmMap.get("RESCUER_DEVICE_ID"));
108
				sumBreakLoop = 2;
109
			}
110
111
			for (Map<String, String> deviceMap : deviceList) {
112
				String deviceId = deviceMap.get("deviceId");
113
				if (deviceId.equals(alarmDeviceId)) {
114
					// 求救者
115
					// 员工姓名
116
					deviceMap.put("userName", String.valueOf(alarmMap.get("PARTY_NAME")));// 员工姓名
117
					deviceMap.put("userCode", String.valueOf(alarmMap.get("PARTY_CODE")));// 员工编号
118
93 119
					// 求救时间
94 120
					String alarmDate = String.valueOf(alarmMap.get("CALLER_DATE"));
95
					map.put("alarmDate", DateUtil.formatStrDate(alarmDate));
121
					deviceMap.put("alarmDate", DateUtil.formatStrDate(alarmDate));
96 122
97 123
					// 计算求救时长
98
					int alarmLong = DateUtil.getDifferenceMinute(alarmDate, map.get("newDate"));
99
					map.put("alarmLong", String.valueOf(alarmLong));
100
					
101
					if (alarmMap.get("RESCUERS_ID")==null) {
102
						//未指派救援人员
103
						map.put("isNewAlarm", EbcConstant.alarm_status_needassign);
104
					}else {
105
						//已指派救援人员
106
						map.put("isNewAlarm", EbcConstant.alarm_status_needclose);
107
						map.put("rescuerDeviceId", String.valueOf(alarmMap.get("RESCUER_DEVICE_ID")));
124
					int alarmLong = DateUtil.getDifferenceMinute(alarmDate, deviceMap.get("newDate"));
125
					deviceMap.put("alarmLong", String.valueOf(alarmLong));
126
127
					if (alarmMap.get("RESCUERS_ID") == null) {
128
						// 未指派救援人员
129
						deviceMap.put("isNewAlarm", EbcConstant.alarm_status_needassign);
130
					} else {
131
						// 已指派救援人员
132
						deviceMap.put("isNewAlarm", EbcConstant.alarm_status_needclose);
133
						deviceMap.put("rescuerDeviceId", String.valueOf(alarmMap.get("RESCUER_DEVICE_ID")));// 救援者的设备ID
108 134
					}
109
					
110
					//求救记录ID
111
					map.put("alarmLogId", String.valueOf(alarmMap.get("LOG_ID")));
112 135
113
					//定位状态
136
					// 求救记录ID
137
					deviceMap.put("alarmLogId", String.valueOf(alarmMap.get("LOG_ID")));
138
139
					// 定位状态
114 140
					switch (String.valueOf(alarmMap.get("ALARM_TYPE"))) {
115 141
					case EbcConstant.alarm_type_autosos_ZH:
116
						//自动报警
117
						map.put("locationStatus",EbcConstant.location_status_autosos);//定位状态
118
						map.put("alarmType",EbcConstant.alarm_type_autosos_ZH);
142
						// 自动报警
143
						deviceMap.put("locationStatus", EbcConstant.location_status_autosos);// 定位状态
144
						deviceMap.put("alarmType", EbcConstant.alarm_type_autosos_ZH);
119 145
						break;
120 146
					case EbcConstant.alarm_type_jogsos_ZH:
121
						//手动报警
122
						map.put("locationStatus",EbcConstant.location_status_jogsos);//定位状态
123
						map.put("alarmType",EbcConstant.alarm_type_jogsos_ZH);
147
						// 手动报警
148
						deviceMap.put("locationStatus", EbcConstant.location_status_jogsos);// 定位状态
149
						deviceMap.put("alarmType", EbcConstant.alarm_type_jogsos_ZH);
124 150
						break;
125 151
					default:
126 152
						break;
127 153
					}
128
					
129
					break;
130
					
131
				}else if (deviceId.equals(String.valueOf(alarmMap.get("RESCUER_DEVICE_ID")))) {
132
					//拼接救援人员的信息
133
					map.put("locationStatus",EbcConstant.location_status_rescuer);//定位状态
134
					map.put("userName", String.valueOf(alarmMap.get("RESCUER_NAME")));//员工姓名
135
					break;
136
					
154
155
					resultDataMap.put("alarm", deviceMap);
156
					countBreakLoop++;
157
					if (countBreakLoop == sumBreakLoop) {
158
						// 求救者和救援者的信息都已找到,结束设备位置的循环
159
						break;
160
					}
161
162
				} else if (rescuerDeviceId != null && deviceId.equals(rescuerDeviceId)) {
163
					// 救援者
164
					deviceMap.put("locationStatus", EbcConstant.location_status_rescuer);// 定位状态
165
					deviceMap.put("userName", String.valueOf(alarmMap.get("RESCUER_NAME")));// 员工姓名
166
					deviceMap.put("userCode", String.valueOf(alarmMap.get("RESCUER_CODE")));// 员工编号
167
					deviceMap.put("alarmLogId", String.valueOf(alarmMap.get("LOG_ID")));// 求救记录ID
168
					deviceMap.put("alarmDeviceId", String.valueOf(alarmMap.get("DEVICE_ID")));// 求救者的设备ID
169
170
					resultDataMap.put("rescuer", deviceMap);
171
					countBreakLoop++;
172
					if (countBreakLoop == sumBreakLoop) {
173
						// 求救者和救援者的信息都已找到,结束设备位置的循环
174
						break;
175
					}
137 176
				}
177
138 178
			}
179
			resultList.add(resultDataMap);
139 180
		}
140
		
141
		return list;
181
182
		return resultList;
142 183
	}
143
	
184
144 185
	@Override
145 186
	public JMap queryOneRescuePlayback(JMap params, int pageNum, int pageSize) {
146
		//TODO
147
		
148
		
149
		
150
		
187
		// TODO
188
151 189
		return null;
152 190
	}
153 191

+ 1 - 1
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/interfaces/RescueService.java

@ -43,7 +43,7 @@ public interface RescueService {
43 43
	 * @param params
44 44
	 * @return
45 45
	 */
46
	List<Map<String, String>> queryCurrentRescueLocationInfo(JMap params) throws Exception;
46
	List<Map<String, Map<String, String>>> queryCurrentRescueLocationInfo(JMap params) throws Exception;
47 47
48 48
	/**
49 49
	 * 获取救援者的下拉列表

+ 42 - 12
ebc-sea-platform/src/main/java/com/ai/ipu/server/service/iotdata/ManageIotNoCloseAlarmData.java

@ -26,26 +26,55 @@ public class ManageIotNoCloseAlarmData {
26 26
27 27
	public boolean executeReceiveIotData(JMap params) throws Exception {
28 28
		// 查询是否为未被救援的人员
29
		List<String> deviceIdsList = new ArrayList<String>();
30
		deviceIdsList.add(params.getString("deviceId"));
31
		List<Map<String, Object>> alarmList = rescueDao.queryNoCloseRescueLog(deviceIdsList);
29
		List<Map<String, Object>> alarmList = rescueDao.queryNoCloseRescueLog(params.getString("deviceId"));
32 30
33 31
		if (alarmList == null || alarmList.isEmpty()) {
34 32
			return false;
35 33
		}
36 34
37
		logger.info("定位信息为已报警人员: " + params.get("userName"));
38
39
		// 推送镜屏
40
		sendMirrorData(params, alarmList.get(0));
41
42
		// 修改最后定位时间
43
		updateLastLocationRecord(params, alarmList.get(0));
35
		//判断是救援者还是求救者
36
		if (params.getString("userCode").equals(String.valueOf(alarmList.get(0).get("RESCUER_CODE")))) {
37
			//救援者
38
			logger.info("定位信息为救援人员: " + params.getString("userName"));
39
			
40
			// 推送镜屏
41
			sendRescuerMirrorData(params, alarmList.get(0));
42
			
43
		}else {
44
			//求救者
45
			logger.info("定位信息为已求救的人员: " + params.getString("userName"));
46
			
47
			// 推送镜屏
48
			sendAlarmMirrorData(params, alarmList.get(0));
49
50
			// 修改最后定位时间
51
			updateLastLocationRecord(params, alarmList.get(0));
52
		}
44 53
45 54
		return true;
46 55
	}
47 56
48
	private void sendMirrorData(JMap params, Map<String, Object> alarmMap) throws ParseException {
57
	/**
58
	 * 推送救援者的镜屏信息
59
	 * @param params
60
	 * @param alarmMap
61
	 * @throws ParseException
62
	 */
63
	private void sendRescuerMirrorData(JMap params, Map<String, Object> alarmMap) throws ParseException {
64
		params.put("locationStatus", EbcConstant.location_status_rescuer);// 定位状态
65
		params.put("alarmDeviceId", String.valueOf(alarmMap.get("DEVICE_ID"))); //求救者的设备ID
66
		
67
		// 推送镜屏
68
		MirrorSendDateUtil.sendData(MirrorSendDateUtil.topic_personnel, params);
69
	}
70
	
71
	/**
72
	 * 推送求救者的镜屏信息
73
	 * @param params
74
	 * @param alarmMap
75
	 * @throws ParseException
76
	 */
77
	private void sendAlarmMirrorData(JMap params, Map<String, Object> alarmMap) throws ParseException {
49 78
		// 求救时间
50 79
		String alarmDate = String.valueOf(alarmMap.get("CALLER_DATE"));
51 80
		params.put("alarmDate", DateUtil.formatStrDate(alarmDate));
@ -59,7 +88,7 @@ public class ManageIotNoCloseAlarmData {
59 88
		if (EbcConstant.alarm_type_jogsos_ZH.equals(alarmType)) {
60 89
			params.put("locationStatus", EbcConstant.location_status_jogsos);// 定位状态
61 90
		} else if (EbcConstant.alarm_type_autosos_ZH.equals(alarmType)) {
62
			params.put("locationStatus", EbcConstant.location_status_autosos);// 报警类型
91
			params.put("locationStatus", EbcConstant.location_status_autosos);// 定位状态
63 92
		}
64 93
65 94
		if (alarmMap.get("RESCUERS_ID")==null) {
@ -68,6 +97,7 @@ public class ManageIotNoCloseAlarmData {
68 97
		}else {
69 98
			//已指派救援人员
70 99
			params.put("isNewAlarm", EbcConstant.alarm_status_needclose);
100
			params.put("rescuerDeviceId", String.valueOf(alarmMap.get("RESCUER_DEVICE_ID"))); //救援者的设备ID
71 101
		}
72 102
		
73 103
		//求救记录ID

+ 44 - 24
ebc-sea-platform/src/main/java/com/ai/ipu/server/util/DateUtil.java

@ -37,58 +37,64 @@ public class DateUtil {
37 37
	 * @param dateStr
38 38
	 * @param amount
39 39
	 * @return yyyy-MM-dd HH:mm:ss
40
	 * @throws ParseException 
40 41
	 */
41
	public static String dateAddYear(String dateStr, int amount) {
42
	public static String dateAddYear(String dateStr, int amount) throws ParseException {
42 43
		return dateAdd(dateStr, Calendar.YEAR, amount, NORM_DATETIME_PATTERN);
43 44
	}
44
	
45
45 46
	/**
46 47
	 * 在原日期加月数
47 48
	 * @param dateStr
48 49
	 * @param amount
49 50
	 * @return yyyy-MM-dd HH:mm:ss
51
	 * @throws ParseException 
50 52
	 */
51
	public static String dateAddMonth(String dateStr, int amount) {
53
	public static String dateAddMonth(String dateStr, int amount) throws ParseException {
52 54
		return dateAdd(dateStr, Calendar.MONTH, amount, NORM_DATETIME_PATTERN);
53 55
	}
54
	
56
55 57
	/**
56 58
	 * 在原日期加天数
57 59
	 * @param dateStr
58 60
	 * @param amount
59 61
	 * @return yyyy-MM-dd HH:mm:ss
62
	 * @throws ParseException 
60 63
	 */
61
	public static String dateAddDay(String dateStr, int amount) {
64
	public static String dateAddDay(String dateStr, int amount) throws ParseException {
62 65
		return dateAdd(dateStr, Calendar.DATE, amount, NORM_DATETIME_PATTERN);
63 66
	}
64
	
67
65 68
	/**
66 69
	 * 在原日期加小时数
67 70
	 * @param dateStr
68 71
	 * @param amount
69 72
	 * @return yyyy-MM-dd HH:mm:ss
73
	 * @throws ParseException 
70 74
	 */
71
	public static String dateAddHour(String dateStr, int amount) {
75
	public static String dateAddHour(String dateStr, int amount) throws ParseException {
72 76
		return dateAdd(dateStr, Calendar.HOUR, amount, NORM_DATETIME_PATTERN);
73 77
	}
74
	
78
75 79
	/**
76 80
	 * 在原日期加分钟数
77 81
	 * @param dateStr
78 82
	 * @param amount
79 83
	 * @return yyyy-MM-dd HH:mm:ss
84
	 * @throws ParseException 
80 85
	 */
81
	public static String dateAddMinute(String dateStr, int amount) {
86
	public static String dateAddMinute(String dateStr, int amount) throws ParseException {
82 87
		return dateAdd(dateStr, Calendar.MINUTE, amount, NORM_DATETIME_PATTERN);
83 88
	}
84
	
89
85 90
	/**
86 91
	 * 在原日期加秒数
87 92
	 * @param dateStr
88 93
	 * @param amount
89 94
	 * @return yyyy-MM-dd HH:mm:ss
95
	 * @throws ParseException 
90 96
	 */
91
	public static String dateAddSecond(String dateStr, int amount) {
97
	public static String dateAddSecond(String dateStr, int amount) throws ParseException {
92 98
		return dateAdd(dateStr, Calendar.SECOND, amount, NORM_DATETIME_PATTERN);
93 99
	}
94 100
@ -99,8 +105,9 @@ public class DateUtil {
99 105
	 * @param amount 间隔长度
100 106
	 * @param pattern 返回日期格式
101 107
	 * @return
108
	 * @throws ParseException 
102 109
	 */
103
	public static String dateAdd(String dateStr, int field, int amount, String pattern) {
110
	public static String dateAdd(String dateStr, int field, int amount, String pattern) throws ParseException {
104 111
		Date date = convertDate(dateStr);
105 112
		Date newDate = dateAdd(date, field, amount);
106 113
		return formatDate(newDate, pattern);
@ -125,8 +132,9 @@ public class DateUtil {
125 132
	 * @param field Calendar中的时间类型
126 133
	 * @param amount 间隔长度
127 134
	 * @return
135
	 * @throws ParseException 
128 136
	 */
129
	public static Date dateAdd(String dateStr, int field, int amount) {
137
	public static Date dateAdd(String dateStr, int field, int amount) throws ParseException {
130 138
		Date date = convertDate(dateStr);
131 139
		return dateAdd(date, field, amount);
132 140
	}
@ -149,9 +157,22 @@ public class DateUtil {
149 157
	 * 比较日期大小
150 158
	 * @param dateStr0
151 159
	 * @param dateStr1
152
	 * @return
160
	 * @return dateStr0<dateStr1 ? -1 : (dateStr0==dateStr1 ? 0 : 1)
161
	 * @throws ParseException 
153 162
	 */
154
	public static int compareDate(String dateStr0, String dateStr1) {
163
	public static int compareDate(String dateStr0, String dateStr1) throws ParseException {
164
		if (dateStr0 == null || "".equals(dateStr0)) {
165
			if (dateStr1 == null || "".equals(dateStr1)) {
166
				return 0;
167
			} else {
168
				return -1;
169
			}
170
		}
171
172
		if (dateStr1 == null || "".equals(dateStr1)) {
173
			return 1;
174
		}
175
155 176
		Date date1 = convertDate(dateStr0);
156 177
		Date date2 = convertDate(dateStr1);
157 178
		int result = date1.compareTo(date2);
@ -162,8 +183,9 @@ public class DateUtil {
162 183
	 * 格式化字符串时间
163 184
	 * @param date
164 185
	 * @return yyyy-MM-dd HH:mm:ss
186
	 * @throws ParseException 
165 187
	 */
166
	public static String formatStrDate(String dateStr) {
188
	public static String formatStrDate(String dateStr) throws ParseException {
167 189
		Date date = convertDate(dateStr);
168 190
		return formatDate(date, DateUtil.NORM_DATETIME_PATTERN);
169 191
	}
@ -196,11 +218,13 @@ public class DateUtil {
196 218
	 * 字符串转时间
197 219
	 * @param dateStr
198 220
	 * @return
221
	 * @throws ParseException 
199 222
	 */
200
	public static Date convertDate(String dateStr) {
223
	public static Date convertDate(String dateStr) throws ParseException {
201 224
		if (dateStr == null || "".equals(dateStr)) {
202 225
			return null;
203 226
		}
227
204 228
		String pattern = TimeUtil.getTimestampFormat(dateStr);
205 229
		return convertDate(dateStr, pattern);
206 230
	}
@ -210,8 +234,9 @@ public class DateUtil {
210 234
	 * @param dateStr
211 235
	 * @param pattern
212 236
	 * @return
237
	 * @throws ParseException 
213 238
	 */
214
	public static Date convertDate(String dateStr, String pattern) {
239
	public static Date convertDate(String dateStr, String pattern) throws ParseException {
215 240
		if (dateStr == null || "".equals(dateStr)) {
216 241
			return null;
217 242
		}
@ -221,12 +246,7 @@ public class DateUtil {
221 246
		}
222 247
223 248
		SimpleDateFormat formatter = new SimpleDateFormat(pattern);
224
		Date date = null;
225
		try {
226
			date = formatter.parse(dateStr);
227
		} catch (ParseException e) {
228
			e.printStackTrace();
229
		}
249
		Date date = formatter.parse(dateStr);
230 250
		return date;
231 251
	}
232 252

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

@ -72,21 +72,21 @@ public class EbcConstant {
72 72
	// 人员定位状态:救援人员
73 73
	public static final String location_status_rescuer = "6";
74 74
75
	// 告警类型:SOS(手动)
76
	public static final int alarm_type_jogsos_beidou = 2;
77
78 75
	// 告警类型:SOS(自动)
79 76
	public static final int alarm_type_autosos_beidou = 1;
77
	
78
	// 告警类型:SOS(手动)
79
	public static final int alarm_type_jogsos_beidou = 2;
80 80
81 81
	// 告警类型:离线
82 82
	public static final int alarm_type_offline_beidou = 4;
83 83
84
	// 告警类型:SOS(手动)
85
	public static final String alarm_type_jogsos_ZH = "手动告警";
86
87 84
	// 告警类型:SOS(自动)
88 85
	public static final String alarm_type_autosos_ZH = "落水告警";
89 86
87
	// 告警类型:SOS(手动)
88
	public static final String alarm_type_jogsos_ZH = "手动告警";
89
90 90
	// 告警类型:离线
91 91
	public static final String alarm_type_offline_ZH = "离线告警";
92 92

+ 16 - 15
ebc-sea-platform/src/main/java/com/ai/ipu/server/util/HttpServiceUtil.java

@ -189,21 +189,20 @@ public class HttpServiceUtil {
189 189
190 190
	public static String sendGet(String url, Charset encoding) {
191 191
		HttpClient httpClient = HttpClients.createDefault();
192
		String resp = "";
193 192
		HttpGet httpGet = new HttpGet(url);
194 193
		httpGet.addHeader(HTTP.CONTENT_TYPE, HTTP_CONTENT_TYPE_JSON);
195 194
		CloseableHttpResponse response = null;
196 195
		try {
197 196
			response = (CloseableHttpResponse) httpClient.execute(httpGet);
198
		} catch (IOException e) {
199
			log.error("请求错误");
197
		} catch (Exception e) {
198
			log.error("sendGet Exception: " + e.getMessage());
199
			return "{}";
200 200
		}
201 201
		return responseEx(httpClient, response, encoding);
202 202
	}
203 203
204 204
	public static String sendPost(String url, Map<String, Object> paramsMap, Charset encoding) {
205 205
		HttpClient httpClient = HttpClients.createDefault();
206
		String resp = "";
207 206
		HttpPost httpPost = new HttpPost(url);
208 207
		httpPost.addHeader(HTTP.CONTENT_TYPE, HTTP_CONTENT_TYPE_JSON);
209 208
		if (paramsMap != null && paramsMap.size() > 0) {
@ -213,8 +212,9 @@ public class HttpServiceUtil {
213 212
		CloseableHttpResponse response = null;
214 213
		try {
215 214
			response = (CloseableHttpResponse) httpClient.execute(httpPost);
216
		} catch (IOException e) {
217
			log.error("sendPost Exception: ", e.getMessage());
215
		} catch (Exception e) {
216
			log.error("sendPost Exception: " + e.getMessage());
217
			return "{}";
218 218
		}
219 219
		return responseEx(httpClient, response, encoding);
220 220
	}
@ -222,7 +222,6 @@ public class HttpServiceUtil {
222 222
	public static String sendPost(String url, Map<String, Object> paramsMap, Charset encoding,
223 223
			Map<String, String> headerMap) {
224 224
		HttpClient httpClient = HttpClients.createDefault();
225
		String resp = "";
226 225
		HttpPost httpPost = new HttpPost(url);
227 226
228 227
		Iterator<String> iter = headerMap.keySet().iterator();
@ -236,15 +235,16 @@ public class HttpServiceUtil {
236 235
237 236
		httpPost.addHeader(HTTP.CONTENT_TYPE, HTTP_CONTENT_TYPE_JSON);
238 237
		if (paramsMap != null && paramsMap.size() > 0) {
239
			log.debug("调用北向接口:url= "+url+",参数= "+JSONObject.toJSONString(paramsMap));
238
			log.debug("调用北向接口:url= " + url + ",参数= " + JSONObject.toJSONString(paramsMap));
240 239
			StringEntity se = new StringEntity(JSONObject.toJSONString(paramsMap), encoding);
241 240
			httpPost.setEntity(se);
242 241
		}
243 242
		CloseableHttpResponse response = null;
244 243
		try {
245 244
			response = (CloseableHttpResponse) httpClient.execute(httpPost);
246
		} catch (IOException e) {
247
			log.error("sendPost Exception: ", e.getMessage());
245
		} catch (Exception e) {
246
			log.error("sendPost Exception: " + e.getMessage());
247
			return "{}";
248 248
		}
249 249
		return responseEx(httpClient, response, encoding);
250 250
	}
@ -261,8 +261,9 @@ public class HttpServiceUtil {
261 261
		CloseableHttpResponse response = null;
262 262
		try {
263 263
			response = (CloseableHttpResponse) httpClient.execute(httpPut);
264
		} catch (IOException e) {
265
			log.error("请求错误");
264
		} catch (Exception e) {
265
			log.error("sendPut Exception: " + e.getMessage());
266
			return "{}";
266 267
		}
267 268
268 269
		return responseEx(httpClient, response, encoding);
@ -275,13 +276,13 @@ public class HttpServiceUtil {
275 276
				resp = EntityUtils.toString(response.getEntity(), encoding);
276 277
			}
277 278
		} catch (Exception e) {
278
			log.error(e.getMessage(), e);
279
			log.error("responseEx Exception: " + e.getMessage());
279 280
		} finally {
280 281
			if (response != null) {
281 282
				try {
282 283
					response.close();
283
				} catch (IOException e) {
284
					log.error(e.getMessage(), e);
284
				} catch (Exception e) {
285
					log.error("responseEx Exception: " + e.getMessage());
285 286
				}
286 287
			}
287 288
		}

+ 82 - 38
ebc-sea-platform/src/main/java/com/ai/ipu/server/util/NorthboundInterfaceUtil.java

@ -25,16 +25,16 @@ public class NorthboundInterfaceUtil {
25 25
26 26
	@Value("${aap.iot.userCode}")
27 27
	private String userCode;
28
	
28
29 29
	@Value("${aap.iot.passWord}")
30 30
	private String passWord;
31
	
31
32 32
	@Value("${url.iot.login}")
33 33
	private String iotLoginUrl;
34
	
34
35 35
	@Value("${url.iot.service}")
36 36
	private String iotServiceUrl;
37
	
37
38 38
	// 定义静态存储map空间存放sign与sessionId
39 39
	private volatile static Map<String, String> cacheMap = new ConcurrentHashMap<String, String>();// 缓存map
40 40
@ -71,18 +71,25 @@ public class NorthboundInterfaceUtil {
71 71
		// 调用北向服务的接口
72 72
		logger.debug("GET调用北向接口");
73 73
74
		boolean loginFlag = true;
75
74 76
		// 1.在缓存中获取sessionId与sign
75 77
		Map<String, String> mapCache = getMapCache();
76 78
		if (mapCache.isEmpty() || mapCache.get("sign") == null || mapCache.get("session_id") == null) {
77 79
			// 2.如果没有调用登录接口从新获取
78
			iotLogin();
80
			loginFlag = iotLogin();
81
		}
82
83
		if (!loginFlag) {
84
			logger.debug("调用北向接口登录失败");
85
			return new HashMap<String, String>();
79 86
		}
80 87
81 88
		// 3.调用北向服务接口
82 89
		// (1)设置字符集
83 90
		Charset charset = Charset.forName("utf-8");
84 91
		// (2)调用接口
85
		String resultJson = HttpServiceUtil.sendGet(iotServiceUrl+url, charset);
92
		String resultJson = HttpServiceUtil.sendGet(iotServiceUrl + url, charset);
86 93
		// (3)将参数转为Map<String,String>【将返回值统一为String】
87 94
		Map<String, String> resultMap = JSON.parseObject(resultJson, Map.class);
88 95
@ -93,15 +100,31 @@ public class NorthboundInterfaceUtil {
93 100
			// (1)清除缓存
94 101
			clear();
95 102
			// (2)重新登录
96
			iotLogin();
97
			// (3)再次调用接口
98
			String fianlresultJson = HttpServiceUtil.sendGet(iotServiceUrl+url, charset);
99
			// (4)获取返回值
100
			resultMap = JSON.parseObject(fianlresultJson, Map.class);
103
			loginFlag = iotLogin();
104
105
			if (!loginFlag) {
106
				logger.debug("再次调用北向接口登录失败");
107
				return new HashMap<String, String>();
108
			}
109
110
			try {
111
				// (3)再次调用接口
112
				String fianlresultJson = HttpServiceUtil.sendGet(iotServiceUrl + url, charset);
113
				// (4)获取返回值
114
				resultMap = JSON.parseObject(fianlresultJson, Map.class);
115
			} catch (Exception e) {
116
				logger.error("再次调用北向接口失败: " + e.getMessage());
117
				return new HashMap<String, String>();
118
			}
119
120
			if (resultMap == null) {
121
				logger.error("再次调用北向接口返回值为空");
122
				return new HashMap<String, String>();
123
			}
101 124
		}
102 125
103 126
		// 5.判断是否调用成功
104
		if ("0".equals(resultMap.get("resultCode"))) {
127
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
105 128
			logger.info("调用北向接口成功");
106 129
		} else {
107 130
			logger.info("调用北向接口失败");
@ -122,11 +145,18 @@ public class NorthboundInterfaceUtil {
122 145
		// 调用北向服务的接口
123 146
		logger.debug("POSt调用北向接口");
124 147
148
		boolean loginFlag = true;
149
125 150
		// 1.在缓存中获取sessionId与sign
126 151
		Map<String, String> mapCache = getMapCache();
127 152
		if (mapCache.isEmpty() || mapCache.get("sign") == null || mapCache.get("session_id") == null) {
128 153
			// 2.如果没有调用登录接口从新获取
129
			iotLogin();
154
			loginFlag = iotLogin();
155
		}
156
157
		if (!loginFlag) {
158
			logger.debug("调用北向接口登录失败");
159
			return new HashMap<String, String>();
130 160
		}
131 161
132 162
		// 3.调用北向服务接口
@ -136,34 +166,52 @@ public class NorthboundInterfaceUtil {
136 166
		Map<String, String> resultMap = null;
137 167
		try {
138 168
			// (2)调用接口
139
			String resultJson = HttpServiceUtil.sendPost(iotServiceUrl+url, paramsMap, charset, getMapCache());
169
			String resultJson = HttpServiceUtil.sendPost(iotServiceUrl + url, paramsMap, charset, getMapCache());
140 170
			// (3)将参数转为Map<String,String>【将返回值统一为String】
141 171
			resultMap = JSON.parseObject(resultJson, Map.class);
142 172
		} catch (Exception e) {
143 173
			logger.error("调用北向接口失败: " + e.getMessage());
174
			return new HashMap<String, String>();
144 175
		}
145 176
146 177
		if (resultMap == null) {
147
			logger.info("调用北向接口失败");
178
			logger.error("调用北向接口返回值为空");
148 179
			return new HashMap<String, String>();
149 180
		}
150 181
151 182
		// 4.登录超时,需重新登录
152 183
		if ("登录超时".equals(resultMap.get("resultMsg"))) {
153
			logger.info("调用北向接口失败,需重新登录");
184
			logger.info("调用北向接口登录超时,需重新登录");
154 185
			// 4.调用不成功可能是登录过期
155 186
			// (1)清除缓存
156 187
			clear();
157 188
			// (2)重新登录
158
			iotLogin();
159
			// (3)再次调用接口
160
			String fianlresultJson = HttpServiceUtil.sendPost(iotServiceUrl+url, paramsMap, charset, getMapCache());
161
			// (4)获取返回值
162
			resultMap = JSON.parseObject(fianlresultJson, Map.class);
189
			loginFlag = iotLogin();
190
191
			if (!loginFlag) {
192
				logger.debug("再次调用北向接口登录失败");
193
				return new HashMap<String, String>();
194
			}
195
196
			try {
197
				// (3)再次调用接口
198
				String fianlresultJson = HttpServiceUtil.sendPost(iotServiceUrl + url, paramsMap, charset,
199
						getMapCache());
200
				// (4)获取返回值
201
				resultMap = JSON.parseObject(fianlresultJson, Map.class);
202
			} catch (Exception e) {
203
				logger.error("再次调用北向接口失败: " + e.getMessage());
204
				return new HashMap<String, String>();
205
			}
206
207
			if (resultMap == null) {
208
				logger.error("再次调用北向接口返回值为空");
209
				return new HashMap<String, String>();
210
			}
163 211
		}
164 212
165 213
		// 5.判断是否调用成功
166
		if ("0".equals(resultMap.get("resultCode"))) {
214
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
167 215
			logger.info("调用北向接口成功");
168 216
		} else {
169 217
			logger.info("调用北向接口失败");
@ -177,7 +225,7 @@ public class NorthboundInterfaceUtil {
177 225
	 * 
178 226
	 * @return
179 227
	 */
180
	private Map<String, String> iotLogin() {
228
	private boolean iotLogin() {
181 229
		logger.debug("登录北向接口");
182 230
183 231
		// 调用登录接口获取sessionId与sign
@ -188,30 +236,26 @@ public class NorthboundInterfaceUtil {
188 236
		// 设置字符集
189 237
		Charset charset = Charset.forName("utf-8");
190 238
191
		Map mapType = null;
239
		Map loginResultMap = null;
192 240
		try {
193 241
			// 调用登录接口
194 242
			String loginResult = HttpServiceUtil.sendPost(iotLoginUrl, loginParamMap, charset);
195
			mapType = JSON.parseObject(loginResult, Map.class);
243
			loginResultMap = JSON.parseObject(loginResult, Map.class);
196 244
		} catch (Exception e) {
197 245
			logger.error("登录北向接口失败: " + e.getMessage());
246
			return false;
198 247
		}
199 248
200
		if (mapType != null) {
201
			Map result = (Map) mapType.get("result");
202
203
			if ("0".equals(String.valueOf(mapType.get("resultCode")))) {
204
				logger.info("登录北向接口成功");
205
				// 将数据存到缓存中
206
				setMapCache(result);
207
			} else {
208
				logger.info("登录北向接口失败");
209
			}
249
		if (loginResultMap != null && NorthboundInterfaceConstant.resultCode_succeed
250
				.equals(String.valueOf(loginResultMap.get("resultCode")))) {
251
			logger.info("登录北向接口成功");
252
			Map result = (Map) loginResultMap.get("result");
253
			// 将数据存到缓存中
254
			setMapCache(result);
255
			return true;
210 256
		} else {
211 257
			logger.info("登录北向接口失败");
258
			return false;
212 259
		}
213
214
		return cacheMap;
215 260
	}
216
217 261
}

+ 3 - 0
ebc-sea-platform/src/main/resources/dev/application-gis.properties

@ -8,5 +8,8 @@ url.gis.token=http://192.168.74.189:9999/gisIntf/account/gettoken
8 8
#\u6d77\u56fe\u4e2d\u5fc3\u5750\u6807
9 9
seaMap.centre.longitude=123.396036
10 10
seaMap.centre.latitude=31.560302
11
11 12
#\u6d77\u56fe\u663e\u793a\u6bd4\u4f8b\u5c3a
13
# 5-->300km,6-->200km,7-->100km,8-->50km,9-->20km,10-->10km,11-->5km
14
# 12-->2km,13-->1km,14-->500m,15-->300m,16-->200m,17-->100m,18-->50m
12 15
seaMap.scale=11

+ 5 - 2
ebc-sea-platform/src/main/resources/dev/application-iot.properties

@ -3,6 +3,9 @@ aap.iot.userCode=IOT_ADMIN
3 3
aap.iot.passWord=123456
4 4
5 5
#iot\u7684\u5317\u5411\u63a5\u53e3\u6ce8\u518c\u5730\u5740
6
url.iot.login=http://60.205.219.67:8300/sso/login
6
#url.iot.login=http://60.205.219.67:8300/sso/login
7
url.iot.login=http://47.105.130.83:8083/sso/login
8
7 9
#iot\u7684\u5317\u5411\u63a5\u53e3\u7edf\u4e00\u5730\u5740
8
url.iot.service=http://60.205.219.67:8300/dmp/terminalNorthApi/
10
#url.iot.service=http://60.205.219.67:8300/dmp/terminalNorthApi/
11
url.iot.service=http://47.105.130.83:8083/dmp/terminalNorthApi/

+ 3 - 0
ebc-sea-platform/src/main/resources/pro/application-gis.properties

@ -8,5 +8,8 @@ url.gis.token=http://192.168.74.189:9999/gisIntf/account/gettoken
8 8
#\u6d77\u56fe\u4e2d\u5fc3\u5750\u6807
9 9
seaMap.centre.longitude=123.396036
10 10
seaMap.centre.latitude=31.560302
11
11 12
#\u6d77\u56fe\u663e\u793a\u6bd4\u4f8b\u5c3a
13
# 5-->300km,6-->200km,7-->100km,8-->50km,9-->20km,10-->10km,11-->5km
14
# 12-->2km,13-->1km,14-->500m,15-->300m,16-->200m,17-->100m,18-->50m
12 15
seaMap.scale=11

+ 3 - 8
ebc-sea-platform/src/main/resources/sql/ipu/RescueDao.xml

@ -17,14 +17,9 @@
17 17
	        AND l.ALARM_TYPE <> #{offlineType}
18 18
	        AND l.DATA_STATUS = #{alarmDataStatus}
19 19
	        
20
	        <if test="deviceIdsList != null">
21
		        AND l.DEVICE_ID IN (
22
				
23
	    		<foreach collection="deviceIdsList" item="item" separator=",">
24
	        		#{item}
25
	    		</foreach>
26
	    		
27
	    		)
20
	        <if test="deviceId != null">
21
		        AND ( l.DEVICE_ID = #{deviceId}
22
		        OR t.DEVICE_ID = #{deviceId} )
28 23
    		</if>
29 24
    		
30 25
	        </where>

+ 3 - 0
ebc-sea-platform/src/main/resources/test/application-gis.properties

@ -8,5 +8,8 @@ url.gis.token=http://192.168.74.189:9999/gisIntf/account/gettoken
8 8
#\u6d77\u56fe\u4e2d\u5fc3\u5750\u6807
9 9
seaMap.centre.longitude=123.396036
10 10
seaMap.centre.latitude=31.560302
11
11 12
#\u6d77\u56fe\u663e\u793a\u6bd4\u4f8b\u5c3a
13
# 5-->300km,6-->200km,7-->100km,8-->50km,9-->20km,10-->10km,11-->5km
14
# 12-->2km,13-->1km,14-->500m,15-->300m,16-->200m,17-->100m,18-->50m
12 15
seaMap.scale=11