|
|
|
|
@ -26,6 +26,7 @@ import org.springframework.stereotype.Component; |
|
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
@ -45,6 +46,18 @@ public class ExternalUtils { |
|
|
|
|
@Autowired |
|
|
|
|
QueueUtils queueUtils; |
|
|
|
|
|
|
|
|
|
private List<Map> hosts = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
private List<Map> mapList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
public List<Map> getHosts() { |
|
|
|
|
return hosts; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<Map> getMapList() { |
|
|
|
|
return mapList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取物联网平台token |
|
|
|
|
*/ |
|
|
|
|
@ -143,20 +156,6 @@ public class ExternalUtils { |
|
|
|
|
* 更新设备状态 |
|
|
|
|
*/ |
|
|
|
|
public void updateStatus() { |
|
|
|
|
List<Map> hosts = null; |
|
|
|
|
List<Map> mapList = null; |
|
|
|
|
try { |
|
|
|
|
// 报警主机信息
|
|
|
|
|
hosts = getList(0, 0, null, null, "105", null); |
|
|
|
|
|
|
|
|
|
// 子系统、防区信息
|
|
|
|
|
mapList = getList(0, 0, null, null, "100", null); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("获取设备信息失败!"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 遍历设备列表更新设备状态信息
|
|
|
|
|
if (CollectionUtils.isNotEmpty(hosts)) { |
|
|
|
|
for (Map hostMap : hosts) { |
|
|
|
|
String tags = JSON.toJSONString(hostMap.get("tags")).replace("\\", ""); |
|
|
|
|
@ -166,7 +165,7 @@ public class ExternalUtils { |
|
|
|
|
String mac = tagMap.get("mac").toString(); // 自定义mac
|
|
|
|
|
|
|
|
|
|
// 认证
|
|
|
|
|
String renzheng = null; |
|
|
|
|
String renzheng = ""; |
|
|
|
|
try { |
|
|
|
|
String rzUrl = "http://" + Alarm.ipMap.get(number) + ":" + Alarm.portMap.get(number) + "/ISAPI/System/deviceInfo"; |
|
|
|
|
renzheng = HTTPClientUtil.statusRz(rzUrl, HTTPClientUtil.client); |
|
|
|
|
@ -180,6 +179,7 @@ public class ExternalUtils { |
|
|
|
|
String status = "http://" + Alarm.ipMap.get(number) + ":" + Alarm.portMap.get(number) + "/ISAPI/SecurityCP/status/host?format=json"; |
|
|
|
|
String statusData = HTTPClientUtil.doGet(status, HTTPClientUtil.client); |
|
|
|
|
|
|
|
|
|
// log.info("statusData" + status + "===" + statusData);
|
|
|
|
|
Map statusMap = JSONObject.parseObject(statusData, Map.class); |
|
|
|
|
Map alarmHostStatus = JSONObject.parseObject(statusMap.get("AlarmHostStatus").toString(), Map.class); |
|
|
|
|
Map communiStatus = JSONObject.parseObject(alarmHostStatus.get("CommuniStatus").toString(), Map.class); |
|
|
|
|
@ -210,7 +210,7 @@ public class ExternalUtils { |
|
|
|
|
String type = tagsMap.get("type").toString(); |
|
|
|
|
|
|
|
|
|
// 防区号/子系统号
|
|
|
|
|
int sCIDCode = Integer.parseInt(tagsMap.get("buildingNo").toString()); |
|
|
|
|
// log.info("该设备信息:" + tagsMap);
|
|
|
|
|
|
|
|
|
|
// 设备真实状态
|
|
|
|
|
int fqStatus = 0; |
|
|
|
|
@ -218,6 +218,7 @@ public class ExternalUtils { |
|
|
|
|
|
|
|
|
|
if ("2".equals(type)) { |
|
|
|
|
presence = 1; |
|
|
|
|
int sCIDCode = Integer.parseInt(tagsMap.get("sectorNo").toString()); |
|
|
|
|
List<Map> zones = zoneList.stream().filter(zone -> Integer.parseInt(JSONObject.parseObject(zone.get("Zone").toString(), Map.class).get("id").toString()) == sCIDCode - 1).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(zones)) { |
|
|
|
|
@ -247,11 +248,6 @@ public class ExternalUtils { |
|
|
|
|
byAlarmInStatus = 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 上报防区报警状态
|
|
|
|
|
// updateById(id, 7, byAlarmInStatus, type);
|
|
|
|
|
// test1(id, 7, byAlarmInStatus, 2);
|
|
|
|
|
// test1(id, 7, 1, 2);
|
|
|
|
|
|
|
|
|
|
// 撤防-6 布防-5 旁路-7
|
|
|
|
|
if (byAlarmInFaultStatus == 0) { |
|
|
|
|
if (bySetupAlarmStatus == 1) { |
|
|
|
|
@ -267,7 +263,7 @@ public class ExternalUtils { |
|
|
|
|
} |
|
|
|
|
} else if ("3".equals(type)) { |
|
|
|
|
presence = 2; |
|
|
|
|
List<Map> subSyss = subSysList.stream().filter(sys -> Integer.parseInt(JSONObject.parseObject(sys.get("SubSys").toString(), Map.class).get("id").toString()) == sCIDCode).collect(Collectors.toList()); |
|
|
|
|
List<Map> subSyss = subSysList.stream().filter(sys -> Integer.parseInt(JSONObject.parseObject(sys.get("SubSys").toString(), Map.class).get("id").toString()) == 1).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtils.isNotEmpty(subSyss)) { |
|
|
|
|
Map sysMap = subSyss.get(0); |
|
|
|
|
Map subSys = JSONObject.parseObject(sysMap.get("SubSys").toString(), Map.class); |
|
|
|
|
@ -281,7 +277,6 @@ public class ExternalUtils { |
|
|
|
|
|
|
|
|
|
// 海信iot
|
|
|
|
|
updateById(id, fqStatus, presence, type); |
|
|
|
|
// test(id, fqStatus, presence, type);
|
|
|
|
|
|
|
|
|
|
if (fqStatus == state) { |
|
|
|
|
continue; |
|
|
|
|
@ -292,6 +287,9 @@ public class ExternalUtils { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 刷新内存数据
|
|
|
|
|
refresh(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -356,14 +354,13 @@ public class ExternalUtils { |
|
|
|
|
if (queueUtils == null) { |
|
|
|
|
queueUtils = SpringUtil.getBean(QueueUtils.class); |
|
|
|
|
} |
|
|
|
|
byte[] byteValue = DataTrans.intToBytesBigEndian(pntTypeValue); |
|
|
|
|
byte[] byteValue = DataTrans.shortToBytesBigEndian((short) pntTypeValue); |
|
|
|
|
ByteString byteString = ByteString.copyFrom(byteValue); |
|
|
|
|
Point point = Point.newBuilder() |
|
|
|
|
.setData(byteString) |
|
|
|
|
.setId(id) |
|
|
|
|
.setDevType(devType) |
|
|
|
|
.setPntType(pntType) |
|
|
|
|
// .setPntTypeValue(pntTypeValue)
|
|
|
|
|
.build(); |
|
|
|
|
boolean b = queueUtils.saveQueueDataStatus(point); |
|
|
|
|
} |
|
|
|
|
@ -390,8 +387,6 @@ public class ExternalUtils { |
|
|
|
|
|
|
|
|
|
private Map device(String token, int id, int status) { |
|
|
|
|
String url = ParamCache.getValue(IOT_PLATFORM_URL) + "bizDevice"; |
|
|
|
|
// String url = "http://171.16.8.58:8080/prod-api/api/bizDevice";
|
|
|
|
|
// String url = "http://182.139.182.190:60032/prod-api/api/bizDevice";
|
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8")); |
|
|
|
|
headers.setBearerAuth(token); |
|
|
|
|
@ -408,76 +403,87 @@ public class ExternalUtils { |
|
|
|
|
return JSONObject.parseObject(exchange.getBody(), Map.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 刷新内存中报警主机、子系统、防区信息 |
|
|
|
|
*/ |
|
|
|
|
public void refresh() { |
|
|
|
|
// 报警主机信息
|
|
|
|
|
hosts = getList(1, 20, null, null, "105", null); |
|
|
|
|
|
|
|
|
|
// 子系统、防区信息
|
|
|
|
|
mapList = getList(1, 100, null, null, "100", null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 和iot联调测试专用接口 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @param byBypassStatus |
|
|
|
|
*/ |
|
|
|
|
public void test(String id, int byBypassStatus, int presence, String type) { |
|
|
|
|
|
|
|
|
|
int pntType = 6; |
|
|
|
|
int pntTypeValue = 0; |
|
|
|
|
|
|
|
|
|
// 离线状态
|
|
|
|
|
if (presence == 0) { |
|
|
|
|
int typeInt = "1".equals(type) ? 2 : 3; |
|
|
|
|
test1(id, pntType, pntTypeValue, typeInt); |
|
|
|
|
} |
|
|
|
|
// 子系统
|
|
|
|
|
else if (presence == 2) { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
test1(id, pntType, pntTypeValue, 3); |
|
|
|
|
|
|
|
|
|
pntType = 10; |
|
|
|
|
pntTypeValue = byBypassStatus == 5 ? 0 : 1; |
|
|
|
|
test1(id, pntType, pntTypeValue, 3); |
|
|
|
|
} |
|
|
|
|
// 防区 撤防-6 布防-5 旁路-7
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
test1(id, pntType, pntTypeValue, 2); |
|
|
|
|
|
|
|
|
|
pntType = 9; |
|
|
|
|
// 故障
|
|
|
|
|
if (byBypassStatus == 4) { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
test1(id, pntType, pntTypeValue, 2); |
|
|
|
|
} |
|
|
|
|
// 未故障
|
|
|
|
|
else { |
|
|
|
|
pntTypeValue = 0; |
|
|
|
|
test1(id, pntType, pntTypeValue, 2); |
|
|
|
|
|
|
|
|
|
pntType = 8; |
|
|
|
|
if (byBypassStatus == 5) { |
|
|
|
|
pntTypeValue = 1; |
|
|
|
|
} else if (byBypassStatus == 6) { |
|
|
|
|
pntTypeValue = 0; |
|
|
|
|
} else if (byBypassStatus == 7) { |
|
|
|
|
pntTypeValue = 2; |
|
|
|
|
} |
|
|
|
|
test1(id, pntType, pntTypeValue, 2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void test1(String id, int pntType, int pntTypeValue, int devType) { |
|
|
|
|
String url = "http://152.136.119.150:81/alarmInformation/hikRemote"; |
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8")); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("id_", id); |
|
|
|
|
map.put("devType_", devType); |
|
|
|
|
map.put("pntType_", pntType); |
|
|
|
|
map.put("pntTypeValue_", pntTypeValue); |
|
|
|
|
String content = JSON.toJSONString(map); |
|
|
|
|
|
|
|
|
|
HttpEntity<String> httpEntity = new HttpEntity<>(content, headers); |
|
|
|
|
|
|
|
|
|
// 发送post请求,并输出结果
|
|
|
|
|
R r = restTemplate.postForObject(url, httpEntity, R.class); |
|
|
|
|
// System.out.println("调用远程服务器接口成功!!:" + r);
|
|
|
|
|
} |
|
|
|
|
// public void test(String id, int byBypassStatus, int presence, String type) {
|
|
|
|
|
//
|
|
|
|
|
// int pntType = 6;
|
|
|
|
|
// int pntTypeValue = 0;
|
|
|
|
|
//
|
|
|
|
|
// // 离线状态
|
|
|
|
|
// if (presence == 0) {
|
|
|
|
|
// int typeInt = "1".equals(type) ? 2 : 3;
|
|
|
|
|
// test1(id, pntType, pntTypeValue, typeInt);
|
|
|
|
|
// }
|
|
|
|
|
// // 子系统
|
|
|
|
|
// else if (presence == 2) {
|
|
|
|
|
// pntTypeValue = 1;
|
|
|
|
|
// test1(id, pntType, pntTypeValue, 3);
|
|
|
|
|
//
|
|
|
|
|
// pntType = 10;
|
|
|
|
|
// pntTypeValue = byBypassStatus == 5 ? 0 : 1;
|
|
|
|
|
// test1(id, pntType, pntTypeValue, 3);
|
|
|
|
|
// }
|
|
|
|
|
// // 防区 撤防-6 布防-5 旁路-7
|
|
|
|
|
// else {
|
|
|
|
|
// pntTypeValue = 1;
|
|
|
|
|
// test1(id, pntType, pntTypeValue, 2);
|
|
|
|
|
//
|
|
|
|
|
// pntType = 9;
|
|
|
|
|
// // 故障
|
|
|
|
|
// if (byBypassStatus == 4) {
|
|
|
|
|
// pntTypeValue = 1;
|
|
|
|
|
// test1(id, pntType, pntTypeValue, 2);
|
|
|
|
|
// }
|
|
|
|
|
// // 未故障
|
|
|
|
|
// else {
|
|
|
|
|
// pntTypeValue = 0;
|
|
|
|
|
// test1(id, pntType, pntTypeValue, 2);
|
|
|
|
|
//
|
|
|
|
|
// pntType = 8;
|
|
|
|
|
// if (byBypassStatus == 5) {
|
|
|
|
|
// pntTypeValue = 1;
|
|
|
|
|
// } else if (byBypassStatus == 6) {
|
|
|
|
|
// pntTypeValue = 0;
|
|
|
|
|
// } else if (byBypassStatus == 7) {
|
|
|
|
|
// pntTypeValue = 2;
|
|
|
|
|
// }
|
|
|
|
|
// test1(id, pntType, pntTypeValue, 2);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public void test1(String id, int pntType, int pntTypeValue, int devType) {
|
|
|
|
|
// String url = "http://152.136.119.150:81/alarmInformation/hikRemote";
|
|
|
|
|
// HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
// headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
|
|
|
//
|
|
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
|
|
// map.put("id_", id);
|
|
|
|
|
// map.put("devType_", devType);
|
|
|
|
|
// map.put("pntType_", pntType);
|
|
|
|
|
// map.put("pntTypeValue_", pntTypeValue);
|
|
|
|
|
// String content = JSON.toJSONString(map);
|
|
|
|
|
//
|
|
|
|
|
// HttpEntity<String> httpEntity = new HttpEntity<>(content, headers);
|
|
|
|
|
//
|
|
|
|
|
// // 发送post请求,并输出结果
|
|
|
|
|
// R r = restTemplate.postForObject(url, httpEntity, R.class);
|
|
|
|
|
//// System.out.println("调用远程服务器接口成功!!:" + r);
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|