2023年12月20日09:31:06

main
litao 2 years ago
parent b05a741798
commit 80a61baea9
  1. 19
      src/main/java/org/springblade/hospital/agent/service/HikAgentService.java
  2. 9
      src/main/java/org/springblade/hospital/agent/utils/QueueUtils.java
  3. 42
      src/main/java/org/springblade/hospital/controller/AIoTRequestDemo.java
  4. 10
      src/main/java/org/springblade/hospital/controller/AlarmInformationController.java
  5. 18
      src/main/java/org/springblade/hospital/controller/AppDataController.java
  6. 49
      src/main/java/org/springblade/hospital/hik/alarm/Alarm.java
  7. 6
      src/main/java/org/springblade/hospital/hik/alarm/AlarmDataParse.java
  8. 170
      src/main/java/org/springblade/hospital/newalarm/communicationCom/HTTPClientUtil.java
  9. 2
      src/main/java/org/springblade/hospital/service/impl/AppDataServiceImpl.java
  10. 17
      src/main/java/org/springblade/hospital/utils/CornJobUtil.java
  11. 192
      src/main/java/org/springblade/hospital/utils/ExternalUtils.java

@ -112,10 +112,11 @@ public class HikAgentService extends AgentGrpc.AgentImplBase {
ChannStatus channStatus = ChannStatus.newBuilder().setId(80).setOnline(true).build(); ChannStatus channStatus = ChannStatus.newBuilder().setId(80).setOnline(true).build();
initResponseObserver.onNext(Heartbeat.newBuilder().setAgentId(agentId) initResponseObserver.onNext(Heartbeat.newBuilder().setAgentId(agentId)
.setStatus("online").setCurrentTime(new Date().getTime()).addAllChannStatus(Arrays.asList(channStatus)).build()); .setStatus("online").setCurrentTime(new Date().getTime()).addAllChannStatus(Arrays.asList(channStatus)).build());
log.debug("sendHeartBeat 已发送"); // log.debug("sendHeartBeat 已发送");
Thread.sleep(10000); Thread.sleep(10000);
} catch (Exception e) { } catch (Exception e) {
log.error("sendHeartBeat 异常:{}", e.getMessage()); e.getMessage();
// log.error("sendHeartBeat 异常:{}", e.getMessage());
} }
} }
} }
@ -124,7 +125,6 @@ public class HikAgentService extends AgentGrpc.AgentImplBase {
private void execGetDataFromDevice() { private void execGetDataFromDevice() {
while (true) { while (true) {
try { try {
// Collection<Point> pointsAlarm = MemoryCache.POINT_MAP_SPF.values(); // Collection<Point> pointsAlarm = MemoryCache.POINT_MAP_SPF.values();
// log.info("execGetDataFromDevice pointsSPF.size()" + pointsAlarm.size() + "|||||当前线程:" + Thread.currentThread().getId()); // log.info("execGetDataFromDevice pointsSPF.size()" + pointsAlarm.size() + "|||||当前线程:" + Thread.currentThread().getId());
// if (CollectionUtils.isNotEmpty(pointsAlarm)) { // if (CollectionUtils.isNotEmpty(pointsAlarm)) {
@ -158,7 +158,7 @@ public class HikAgentService extends AgentGrpc.AgentImplBase {
// queueUtils.saveQueueDataStatus(point); // queueUtils.saveQueueDataStatus(point);
Thread.sleep(20000); Thread.sleep(20000);
} catch (Exception e) { } catch (Exception e) {
log.error("execGetDataFromDevice 从map获取数据异常:{}", e.getMessage()); // log.error("execGetDataFromDevice 从map获取数据异常:{}", e.getMessage());
} }
} }
@ -181,7 +181,12 @@ public class HikAgentService extends AgentGrpc.AgentImplBase {
int page = request.getPage(); int page = request.getPage();
int pagesize = request.getPagesize(); int pagesize = request.getPagesize();
int devType = request.getDevType(); int devType = request.getDevType();
int total = 0;
if (devType == 2) {
total = 61;
} else if (devType == 3) {
total = 19;
}
List<Map> list = externalUtils.getList(page, pagesize, null, String.valueOf(devType), "100", null); List<Map> list = externalUtils.getList(page, pagesize, null, String.valueOf(devType), "100", null);
log.info("list======" + list); log.info("list======" + list);
@ -204,7 +209,7 @@ public class HikAgentService extends AgentGrpc.AgentImplBase {
}); });
log.info("total {}", list.size()); log.info("total {}", list.size());
responseObserver.onNext(ListResponse.newBuilder().setTotal(list.size()).setIsPointList(false).addAllItems(items).build()); responseObserver.onNext(ListResponse.newBuilder().setTotal(total).setIsPointList(false).addAllItems(items).build());
responseObserver.onCompleted(); responseObserver.onCompleted();
} else { } else {
responseObserver.onError(new Throwable("获取服务列表数据失败")); responseObserver.onError(new Throwable("获取服务列表数据失败"));
@ -251,7 +256,7 @@ public class HikAgentService extends AgentGrpc.AgentImplBase {
@Override @Override
public void setDevice(SetDeviceRequest request, StreamObserver<CommonResult> responseObserver) { public void setDevice(SetDeviceRequest request, StreamObserver<CommonResult> responseObserver) {
log.info("HikAgentService_setDevice来到了grpc服务端{}", request); // log.info("HikAgentService_setDevice来到了grpc服务端{}", request);
responseObserver.onNext(CommonResult.newBuilder().build()); responseObserver.onNext(CommonResult.newBuilder().build());
responseObserver.onCompleted(); responseObserver.onCompleted();
} }

@ -5,9 +5,6 @@ import com.hisense.device.agent.grpc.DataResponse;
import com.hisense.device.agent.grpc.Point; import com.hisense.device.agent.grpc.Point;
import io.grpc.stub.StreamObserver; import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.hospital.agent.service.HikAgentService;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
@ -149,12 +146,10 @@ public class QueueUtils {
sendMessage(list); sendMessage(list);
// responseObserver.onNext(DataResponse.newBuilder().addAllPoints(list).build()); // responseObserver.onNext(DataResponse.newBuilder().addAllPoints(list).build());
log.info("消费到的状态数据是:{}", point); // log.info("消费到的状态数据是:{}", point);
} catch (Exception e) { } catch (Exception e) {
log.error("缓存队列单条消费异常:{}", e.getMessage()); log.error("缓存队列单条消费异常:{}", e.getMessage());
} }
} }
@ -167,7 +162,7 @@ public class QueueUtils {
/*注意:stream流 不能并行调用 ,否则前端解析错误*/ /*注意:stream流 不能并行调用 ,否则前端解析错误*/
private synchronized void sendMessage(List list){ private synchronized void sendMessage(List list){
log.info("sendMessage 当前线程:{}",Thread.currentThread().getName()); // log.info("sendMessage 当前线程:{}",Thread.currentThread().getName());
responseObserver.onNext(DataResponse.newBuilder().addAllPoints(list).build()); responseObserver.onNext(DataResponse.newBuilder().addAllPoints(list).build());
} }

@ -2,10 +2,12 @@ package org.springblade.hospital.controller;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springblade.hospital.newalarm.communicationCom.HTTPClientUtil;
import javax.crypto.Mac; import javax.crypto.Mac;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
@ -25,24 +27,28 @@ public class AIoTRequestDemo {
Security.addProvider(new BouncyCastleProvider()); Security.addProvider(new BouncyCastleProvider());
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) {
LinkedHashMap<String, List<String>> parameters = new LinkedHashMap<>(); // LinkedHashMap<String, List<String>> parameters = new LinkedHashMap<>();
parameters.put("lang", Lists.newArrayList("zh_CN")); // parameters.put("lang", Lists.newArrayList("zh_CN"));
String appKey = "9aON8USr"; // String appKey = "9aON8USr";
String appSecret = "VHc1CBWM0YS204rydm+wWxkQrqJSVyXAAgFRktVpOF4="; // String appSecret = "VHc1CBWM0YS204rydm+wWxkQrqJSVyXAAgFRktVpOF4=";
String nonce = "123456"; // String nonce = "123456";
String timestampStr = "123456789"; // String timestampStr = "123456789";
String correctSignature = "RdYq6cvBpeF84HO8iQErRF6Aq9XdE2fDx5w4qjDWfrg="; // String correctSignature = "RdYq6cvBpeF84HO8iQErRF6Aq9XdE2fDx5w4qjDWfrg=";
String signature = renderSignature( // String signature = renderSignature(
"/report/data/device", // "/report/data/device",
parameters, // parameters,
nonce, // nonce,
timestampStr, // timestampStr,
"", // "",
appKey, // appKey,
appSecret // appSecret
); // );
System.out.println(signature.equals(correctSignature)); // System.out.println(signature.equals(correctSignature));
HttpClient client = new HttpClient();
String rzUrl = "http://" + "171.16.170.81" + ":" + "80" + "/ISAPI/System/deviceInfo";
String renzheng = HTTPClientUtil.renzheng(rzUrl, client);
log.info("登录信息:" + renzheng);
} }
/* 封装逻辑 /* 封装逻辑

@ -139,9 +139,13 @@ public class AlarmInformationController extends BladeController {
*/ */
@PostMapping("/clear") @PostMapping("/clear")
public R clear(@RequestBody AlarmInformation alarmInformation) { public R clear(@RequestBody AlarmInformation alarmInformation) {
Alarm.xiaojing(alarmInformation.getHostSerialNumber(), alarmInformation.getSystemNum(), alarmInformation.getDeviceId()); boolean xjcg = false;
alarmInformation.setIsClear(1); boolean xiaojing = Alarm.xiaojing(alarmInformation.getHostSerialNumber(), alarmInformation.getSystemNum(), alarmInformation.getDeviceId());
return R.status(alarmInformationService.updateById(alarmInformation)); if (xiaojing) {
alarmInformation.setIsClear(1);
xjcg = alarmInformationService.updateById(alarmInformation);
}
return R.status(xjcg);
} }
/** /**

@ -151,7 +151,7 @@ public class AppDataController extends BladeController {
sha256_HMAC.init(secret_key); sha256_HMAC.init(secret_key);
String signature = Base64.encodeBase64String(sha256_HMAC.doFinal(message.getBytes())); String signature = Base64.encodeBase64String(sha256_HMAC.doFinal(message.getBytes()));
String content = JSON.toJSONString(alarm); String content = JSON.toJSONString(alarm);
System.out.println("body请求数据:" + content); log.info("body请求数据:" + content);
// 请求头参数 // 请求头参数
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
@ -166,14 +166,14 @@ public class AppDataController extends BladeController {
// 发送post请求,并输出结果 // 发送post请求,并输出结果
response = restTemplate.postForObject(url, httpEntity, String.class); response = restTemplate.postForObject(url, httpEntity, String.class);
System.out.println("最终发送url:" + url); // System.out.println("最终发送url:" + url);
System.out.println("鉴权url:" + message); // System.out.println("鉴权url:" + message);
System.out.println("appKey:" + appKey); // System.out.println("appKey:" + appKey);
System.out.println("appSecret:" + appSecret); // System.out.println("appSecret:" + appSecret);
System.out.println("nonce:" + nonce); // System.out.println("nonce:" + nonce);
System.out.println("timestamp:" + timestamp); // System.out.println("timestamp:" + timestamp);
System.out.println("signature:" + signature); // System.out.println("signature:" + signature);
System.out.println("fhxx:" + response); log.info("fhxx:" + response);
return R.data(response); return R.data(response);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

@ -46,7 +46,7 @@ public class Alarm implements CommandLineRunner {
static FMSGCallBack_V31 fMSFCallBack_V31 = null; static FMSGCallBack_V31 fMSFCallBack_V31 = null;
static FMSGCallBack fMSFCallBack; static FMSGCallBack fMSFCallBack;
static Map<String, Integer> numMap; static Map<String, Integer> numMap;
// static Map<String, HttpClient> clientMap = new HashMap<>(); // static Map<String, HttpClient> clientMap = new HashMap<>();
public static Map<String, String> ipMap; public static Map<String, String> ipMap;
public static Map<String, String> portMap; public static Map<String, String> portMap;
public static Map<String, String> macMap; public static Map<String, String> macMap;
@ -318,11 +318,9 @@ public class Alarm implements CommandLineRunner {
.setPntType(11) .setPntType(11)
.build(); .build();
queueUtils.saveQueueDataStatus(sysPoint); queueUtils.saveQueueDataStatus(sysPoint);
// 获取该报警主机全部防区状态信息 // 获取该报警主机全部防区状态信息
String status = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/status/zones?format=json"; String status = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/status/zones?format=json";
String statusData = HTTPClientUtil.doGet(status, HTTPClientUtil.client); String statusData = HTTPClientUtil.doGet(status, HTTPClientUtil.client);
System.out.println("statusData:" + statusData);
// 解析状态信息 // 解析状态信息
Map statusMap = JSONObject.parseObject(statusData, Map.class); Map statusMap = JSONObject.parseObject(statusData, Map.class);
@ -332,7 +330,7 @@ public class Alarm implements CommandLineRunner {
// 过滤只剩该子系统下正在报警的防区 // 过滤只剩该子系统下正在报警的防区
List<Map> zones = zoneList.stream().filter(zone -> (boolean) JSONObject.parseObject(zone.get("Zone").toString(), Map.class).get("alarm") && String.valueOf(num).equals(JSONObject.parseObject(zone.get("Zone").toString(), Map.class).get("id").toString())).collect(Collectors.toList()); List<Map> zones = zoneList.stream().filter(zone -> (boolean) JSONObject.parseObject(zone.get("Zone").toString(), Map.class).get("alarm") && String.valueOf(num).equals(JSONObject.parseObject(zone.get("Zone").toString(), Map.class).get("id").toString())).collect(Collectors.toList());
System.out.println("zones数量:" + zones); log.info("zones数量:" + zones);
if (CollectionUtils.isNotEmpty(zones)) { if (CollectionUtils.isNotEmpty(zones)) {
for (Map zoneMap : zones) { for (Map zoneMap : zones) {
Map zone = JSONObject.parseObject(zoneMap.get("Zone").toString(), Map.class); Map zone = JSONObject.parseObject(zoneMap.get("Zone").toString(), Map.class);
@ -354,7 +352,7 @@ public class Alarm implements CommandLineRunner {
// 下发消警指令 // 下发消警指令
String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/clearAlarm/" + num; String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/clearAlarm/" + num;
String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client); String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client);
System.out.println("respx:" + respx); log.info("respx:" + respx);
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@ -381,7 +379,7 @@ public class Alarm implements CommandLineRunner {
if (renzheng.contains(hostSerialNumber)) { if (renzheng.contains(hostSerialNumber)) {
String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/arm/" + num + "?ways=away&format=json"; String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/arm/" + num + "?ways=away&format=json";
String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client); String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client);
System.out.println(respx); log.info("respx:" + respx);
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@ -408,7 +406,7 @@ public class Alarm implements CommandLineRunner {
if (renzheng.contains(hostSerialNumber)) { if (renzheng.contains(hostSerialNumber)) {
String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/disarm/" + num; String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/disarm/" + num;
String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client); String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client);
System.out.println(respx); log.info("respx:" + respx);
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@ -467,7 +465,7 @@ public class Alarm implements CommandLineRunner {
if (renzheng.contains(hostSerialNumber)) { if (renzheng.contains(hostSerialNumber)) {
String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/bypass/" + num; String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/bypass/" + num;
String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client); String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client);
System.out.println(respx); log.info("respx:" + respx);
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@ -497,7 +495,7 @@ public class Alarm implements CommandLineRunner {
if (renzheng.contains(hostSerialNumber)) { if (renzheng.contains(hostSerialNumber)) {
String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/bypassRecover/" + num; String xjUrl = "http://" + ipMap.get(hostSerialNumber) + ":" + portMap.get(hostSerialNumber) + "/ISAPI/SecurityCP/control/bypassRecover/" + num;
String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client); String respx = HTTPClientUtil.doPut(xjUrl, "", HTTPClientUtil.client);
System.out.println(respx); log.info("respx:" + respx);
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
@ -535,7 +533,7 @@ public class Alarm implements CommandLineRunner {
List<Thread> threadList = new ArrayList<>(); List<Thread> threadList = new ArrayList<>();
ScheduledFuture<?> scheduledFuture = scheduled.scheduleAtFixedRate(() -> { ScheduledFuture<?> scheduledFuture = scheduled.scheduleAtFixedRate(() -> {
// log.info("我执行了1"); // log.info("我执行了1");
List<Map> list = externalUtils.getList(0, 0, null, null, "105", null); List<Map> list = externalUtils.getList(1, 20, null, null, "105", null);
log.info("获取报警主机列表数量为:" + list.size()); log.info("获取报警主机列表数量为:" + list.size());
if (list.size() != size.get()) { if (list.size() != size.get()) {
size.set(list.size()); size.set(list.size());
@ -546,23 +544,23 @@ public class Alarm implements CommandLineRunner {
} }
threadList.clear(); threadList.clear();
// 51服务器使用:物联网平台获取的报警主机列表 // 51服务器使用:物联网平台获取的报警主机列表
// getList(list, threadList); getList(list, threadList);
// 52服务器使用:不需要监听,只获取设备信息:ip、端口号、mac // 52服务器使用:不需要监听,只获取设备信息:ip、端口号、mac
for (Map map : list) { // for (Map map : list) {
String s = JSON.toJSONString(map.get("tags")).replace("\\", ""); // String s = JSON.toJSONString(map.get("tags")).replace("\\", "");
s = s.substring(1, s.length() - 1); // s = s.substring(1, s.length() - 1);
Map tagsMap = JSONObject.parseObject(s, Map.class); // Map tagsMap = JSONObject.parseObject(s, Map.class);
//
// 报警主机信息 // // 报警主机信息
String number = tagsMap.get("hostNumber").toString();//序列号 // String number = tagsMap.get("hostNumber").toString();//序列号
String ip = tagsMap.get("ip").toString(); // String ip = tagsMap.get("ip").toString();
String port = tagsMap.get("port").toString(); // String port = tagsMap.get("port").toString();
String mac = tagsMap.get("mac").toString(); // String mac = tagsMap.get("mac").toString();
ipMap.put(number, ip); // ipMap.put(number, ip);
portMap.put(number, port); // portMap.put(number, port);
macMap.put(mac, number); // macMap.put(mac, number);
} // }
} }
}, 0, 1, TimeUnit.DAYS); }, 0, 1, TimeUnit.DAYS);
} catch (Exception e) { } catch (Exception e) {
@ -690,6 +688,7 @@ public class Alarm implements CommandLineRunner {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
// 登录认证 // 登录认证
String rzUrl = "http://" + ip + ":" + port + "/ISAPI/System/deviceInfo"; String rzUrl = "http://" + ip + ":" + port + "/ISAPI/System/deviceInfo";
log.info("rzUrl:" + rzUrl);
String renzheng = HTTPClientUtil.renzheng(rzUrl, client); String renzheng = HTTPClientUtil.renzheng(rzUrl, client);
log.info("登录信息:" + renzheng); log.info("登录信息:" + renzheng);

@ -314,9 +314,9 @@ public class AlarmDataParse {
externalUtils = SpringUtil.getBean(ExternalUtils.class); externalUtils = SpringUtil.getBean(ExternalUtils.class);
} }
if (sum > 0) { if (sum > 0) {
list = externalUtils.getList(0, 0, "sector_" + sum, null, "100", sSerialNumber); list = externalUtils.getList(1, 100, "sector_" + sum, null, "100", sSerialNumber);
} else { } else {
list = externalUtils.getList(0, 0, "sys_" + bySubSysNo, null, "100", sSerialNumber); list = externalUtils.getList(1, 100, "sys_" + bySubSysNo, null, "100", sSerialNumber);
} }
} }
System.out.println("【CID事件】" + "触发时间:" + TriggerTime + "CID事件号:" + sCIDCode + "CID事件名:" + sCIDDescribe + "子系统号:" + System.out.println("【CID事件】" + "触发时间:" + TriggerTime + "CID事件号:" + sCIDCode + "CID事件名:" + sCIDDescribe + "子系统号:" +
@ -370,7 +370,7 @@ public class AlarmDataParse {
queueUtils = SpringUtil.getBean(QueueUtils.class); queueUtils = SpringUtil.getBean(QueueUtils.class);
} }
List<Map> hostList = externalUtils.getList(0, 0, null, null, "105", sSerialNumber); List<Map> hostList = externalUtils.getList(1, 20, null, null, "105", sSerialNumber);
Map hostMap = hostList.get(0); Map hostMap = hostList.get(0);
String s = JSON.toJSONString(hostMap.get("tags")).replace("\\", ""); String s = JSON.toJSONString(hostMap.get("tags")).replace("\\", "");
s = s.substring(1, s.length() - 1); s = s.substring(1, s.length() - 1);

@ -3,9 +3,9 @@ package org.springblade.hospital.newalarm.communicationCom;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import com.hisense.device.agent.grpc.Point; import com.hisense.device.agent.grpc.Point;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.UsernamePasswordCredentials;
@ -14,8 +14,6 @@ import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.methods.PutMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.common.cache.DictBizCache; import org.springblade.common.cache.DictBizCache;
import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.hospital.agent.utils.DataTrans; import org.springblade.hospital.agent.utils.DataTrans;
@ -24,18 +22,17 @@ import org.springblade.hospital.entity.AlarmInformation;
import org.springblade.hospital.service.IAlarmInformationService; import org.springblade.hospital.service.IAlarmInformationService;
import org.springblade.hospital.utils.ExternalUtils; import org.springblade.hospital.utils.ExternalUtils;
import org.springblade.hospital.websocket.WebSocketServer; import org.springblade.hospital.websocket.WebSocketServer;
import org.springframework.scheduling.annotation.Async; import org.springblade.modules.system.service.IDictBizService;
import org.springframework.stereotype.Component;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@Slf4j @Slf4j
public class HTTPClientUtil { public class HTTPClientUtil {
@ -49,7 +46,7 @@ public class HTTPClientUtil {
public static String renzheng(String rzUrl, HttpClient client) { public static String renzheng(String rzUrl, HttpClient client) {
// 设置用户名和密码 // 设置用户名和密码
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("admin", "hao12345"); UsernamePasswordCredentials creds = new UsernamePasswordCredentials("admin", "qlyy123456");
client.getState().setCredentials(AuthScope.ANY, creds); client.getState().setCredentials(AuthScope.ANY, creds);
GetMethod method = new GetMethod(rzUrl); GetMethod method = new GetMethod(rzUrl);
method.setDoAuthentication(true); method.setDoAuthentication(true);
@ -77,7 +74,7 @@ public class HTTPClientUtil {
public static String statusRz(String rzUrl, HttpClient client) throws IOException { public static String statusRz(String rzUrl, HttpClient client) throws IOException {
// 设置用户名和密码 // 设置用户名和密码
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("admin", "hao12345"); UsernamePasswordCredentials creds = new UsernamePasswordCredentials("admin", "qlyy123456");
client.getState().setCredentials(AuthScope.ANY, creds); client.getState().setCredentials(AuthScope.ANY, creds);
GetMethod method = new GetMethod(rzUrl); GetMethod method = new GetMethod(rzUrl);
method.setDoAuthentication(true); method.setDoAuthentication(true);
@ -179,64 +176,72 @@ public class HTTPClientUtil {
// system子系统号 // system子系统号
int system = Integer.parseInt(cidMap.get("system").toString()); int system = Integer.parseInt(cidMap.get("system").toString());
// zone防区号 // zone防区号
List<Map> mapList = externalUtils.getMapList();
if (cidMap.get("zone") != null) { if (cidMap.get("zone") != null) {
zone = Integer.parseInt(cidMap.get("zone").toString()) + 1; zone = Integer.parseInt(cidMap.get("zone").toString()) + 1;
list = externalUtils.getList(0, 0, mac + "_sector_" + zone, null, "100", sSerialNumber); int finalZone = zone;
list = mapList.stream().filter(map -> JSON.toJSONString(map.get("tags")).contains(mac + "_sector_" + finalZone)).collect(Collectors.toList());
// list = externalUtils.getList(1, 100, mac + "_sector_" + zone, null, "100", sSerialNumber);
} else { } else {
list = externalUtils.getList(0, 0, mac + "_sys_" + system, null, "100", sSerialNumber); list = mapList.stream().filter(map -> JSON.toJSONString(map.get("tags")).contains(mac + "_sys_" + system)).collect(Collectors.toList());
// list = externalUtils.getList(1, 100, mac + "_sys_" + system, null, "100", sSerialNumber);
} }
} }
// 事件信息入本地库 // 事件信息入本地库
//SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss+08:00");
if (alarmInformationService == null) { if (alarmInformationService == null) {
alarmInformationService = SpringUtil.getBean(IAlarmInformationService.class); alarmInformationService = SpringUtil.getBean(IAlarmInformationService.class);
} }
String sCIDCode = cidMap.get("code").toString(); String sCIDCode = cidMap.get("code").toString();
String alarmMessageType = DictBizCache.getValue("alarm_message_type", sCIDCode);
AlarmInformation alarmInformation = new AlarmInformation(); AlarmInformation alarmInformation = new AlarmInformation();
alarmInformation.setReportTime(new Date()); if (StringUtils.isNotBlank(alarmMessageType)) {
alarmInformation.setType(sCIDCode); alarmInformation.setReportTime(new Date());
alarmInformation.setContent(DictBizCache.getValue("alarm_message_type", sCIDCode)); alarmInformation.setType(sCIDCode);
if (cidMap.get("system") != null) { alarmInformation.setContent(alarmMessageType);
alarmInformation.setSystemNum(Integer.parseInt(cidMap.get("system").toString())); if (cidMap.get("system") != null) {
} alarmInformation.setSystemNum(Integer.parseInt(cidMap.get("system").toString()));
alarmInformation.setHostSerialNumber(sSerialNumber);
alarmInformation.setHostIp(resMap.get("ipAddress").toString());
alarmInformation.setAlarmType(1);
if (CollectionUtils.isNotEmpty(list)) {
Map map = list.get(0);
alarmInformation.setDeviceName(map.get("name").toString());
alarmInformation.setDeviceType(Integer.parseInt(String.valueOf(map.get("pid"))));
String s = JSON.toJSONString(map.get("tags")).replace("\\", "");
s = s.substring(1, s.length() - 1);
Map tagsMap = JSONObject.parseObject(s, Map.class);
alarmInformation.setFloorNo(tagsMap.get("floorNo").toString());
alarmInformation.setBuildId(tagsMap.get("buildingNo").toString());
if (tagsMap.get("coordinate") != null) {
String coordinate = tagsMap.get("coordinate").toString();
alarmInformation.setLatidute(coordinate.split("-")[0]);
alarmInformation.setLongidute(coordinate.split("-")[1]);
} }
alarmInformation.setDeviceId(tagsMap.get("pmac").toString()); alarmInformation.setHostSerialNumber(sSerialNumber);
Map bizProduct = JSONObject.parseObject(JSON.toJSONString(map.get("bizProduct")), Map.class); alarmInformation.setHostIp(resMap.get("ipAddress").toString());
alarmInformation.setProductName(bizProduct.get("name").toString()); alarmInformation.setAlarmType(1);
if (tagsMap.get("cameraCode") != null) {
alarmInformation.setCameraCode(tagsMap.get("cameraCode").toString()); if (CollectionUtils.isNotEmpty(list)) {
} Map map = list.get(0);
alarmInformation.setDeviceName(map.get("name").toString());
// 主动修改设备状态-物联网平台 alarmInformation.setDeviceType(Integer.parseInt(String.valueOf(map.get("pid"))));
if ("3973".equals(sCIDCode)) { String s = JSON.toJSONString(map.get("tags")).replace("\\", "");
externalUtils.bizDevice(Integer.parseInt(String.valueOf(map.get("id"))), 5); s = s.substring(1, s.length() - 1);
} else if ("1973".equals(sCIDCode) || "3570".equals(sCIDCode)) { Map tagsMap = JSONObject.parseObject(s, Map.class);
externalUtils.bizDevice(Integer.parseInt(String.valueOf(map.get("id"))), 6); alarmInformation.setFloorNo(tagsMap.get("floorNo").toString());
} else if ("1570".equals(sCIDCode)) { alarmInformation.setBuildId(tagsMap.get("buildingNo").toString());
externalUtils.bizDevice(Integer.parseInt(String.valueOf(map.get("id"))), 7); if (tagsMap.get("coordinate") != null) {
String coordinate = tagsMap.get("coordinate").toString();
alarmInformation.setLatidute(coordinate.split("-")[0]);
alarmInformation.setLongidute(coordinate.split("-")[1]);
}
alarmInformation.setDeviceId(tagsMap.get("pmac").toString());
Map bizProduct = JSONObject.parseObject(JSON.toJSONString(map.get("bizProduct")), Map.class);
alarmInformation.setProductName(bizProduct.get("name").toString());
if (tagsMap.get("cameraCode") != null) {
alarmInformation.setCameraCode(DictBizCache.getValue("hikvision_camera", map.get("name").toString()));
}
// 主动修改设备状态-物联网平台
if ("3401".equals(sCIDCode)) {
// 布防
externalUtils.bizDevice(Integer.parseInt(String.valueOf(map.get("id"))), 5);
} else if ("1401".equals(sCIDCode) || "3570".equals(sCIDCode)) {
// 撤防
externalUtils.bizDevice(Integer.parseInt(String.valueOf(map.get("id"))), 6);
} else if ("1570".equals(sCIDCode)) {
// 旁路
externalUtils.bizDevice(Integer.parseInt(String.valueOf(map.get("id"))), 7);
}
} }
alarmInformationService.save(alarmInformation);
} }
boolean save = alarmInformationService.save(alarmInformation);
// 只保留“即时报警”、“设备防拆报警” // 只保留“即时报警”、“设备防拆报警”
if ("1103".equals(sCIDCode) || "1137".equals(sCIDCode)) { if ("1103".equals(sCIDCode) || "1137".equals(sCIDCode)) {
// 上报海信iot平台 // 上报海信iot平台
@ -244,50 +249,29 @@ public class HTTPClientUtil {
queueUtils = SpringUtil.getBean(QueueUtils.class); queueUtils = SpringUtil.getBean(QueueUtils.class);
} }
List<Map> hostList = externalUtils.getList(0, 0, null, null, "105", sSerialNumber); List<Map> hostList = externalUtils.getHosts();
Map hostMap = hostList.get(0); if (CollectionUtils.isNotEmpty(hostList)) {
String s = JSON.toJSONString(hostMap.get("tags")).replace("\\", ""); Map hostMap = hostList.get(0);
s = s.substring(1, s.length() - 1); String s = JSON.toJSONString(hostMap.get("tags")).replace("\\", "");
Map tagsMap = JSONObject.parseObject(s, Map.class); s = s.substring(1, s.length() - 1);
Map tagsMap = JSONObject.parseObject(s, Map.class);
byte[] byteValue = DataTrans.shortToBytesBigEndian((short) 1);
ByteString byteString = ByteString.copyFrom(byteValue); byte[] byteValue = DataTrans.shortToBytesBigEndian((short) 1);
Point point = Point.newBuilder() ByteString byteString = ByteString.copyFrom(byteValue);
.setData(byteString) Point point = Point.newBuilder()
.setId(tagsMap.get("mac").toString() + "_sector_" + zone) .setData(byteString)
.setDevType(2) .setId(tagsMap.get("mac").toString() + "_sector_" + zone)
.setPntType(7) .setDevType(2)
.build(); .setPntType(7)
boolean b = queueUtils.saveQueueDataStatus(point); .build();
System.out.println("===" + b); boolean b = queueUtils.saveQueueDataStatus(point);
System.out.println("===" + b);
// 报警信息发送到远程服务器
// if (restTemplate == null) { JSONObject jsonObject = new JSONObject();
// restTemplate = SpringUtil.getBean(RestTemplate.class); jsonObject.put("message", JSONObject.toJSONString(alarmInformation));
// } WebSocketServer.sendInfo(jsonObject);
// 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_", tagsMap.get("mac").toString() + "_sector_" + Integer.sum(strCIDalarm.wDefenceNo, 1));
// map.put("devType_", 2);
// map.put("pntType_", 7);
// map.put("pntTypeValue_", 1);
// 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);
// webSocket推送给客户端消息
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", JSONObject.toJSONString(alarmInformation));
WebSocketServer.sendInfo(jsonObject);
} }
} }
// System.out.println("接收到的数据:" + resMap); // System.out.println("接收到的数据:" + resMap);
} }

@ -77,7 +77,7 @@ public class AppDataServiceImpl extends BaseServiceImpl<AppDataMapper, AppData>
BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream()); BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream());
String link = bladeFile.getLink(); String link = bladeFile.getLink();
Attach attach = new Attach(); Attach attach = new Attach();
attach.setLink("http://192.169.9.252:1883/hospital/" + bladeFile.getName()); attach.setLink("http://171.16.8.53:1883/hospital/" + bladeFile.getName());
attach.setOriginalName(file.getOriginalFilename()); attach.setOriginalName(file.getOriginalFilename());
attach.setName(bladeFile.getName()); attach.setName(bladeFile.getName());
attachService.save(attach); attachService.save(attach);

@ -37,18 +37,27 @@ public class CornJobUtil {
/** /**
* 定时更新设备状态每1分钟执行一次 * 定时更新设备状态每1分钟执行一次
*/ */
// @Async @Async
// @Scheduled(initialDelay = 5000, fixedRate = 60000) @Scheduled(initialDelay = 5000, fixedRate = 60000)
public void updateStatus() { public void updateStatus() {
log.info("定时1分钟获取1次设备状态"); log.info("定时1分钟获取1次设备状态");
externalUtils.updateStatus(); externalUtils.updateStatus();
} }
/**
* 每天凌晨1点执行任务刷新内存设备信息
*/
@Async
@Scheduled(cron = "0 0 1 * * ?")
public void refresh() {
externalUtils.refresh();
}
/** /**
* 定时布撤防每3分钟执行一次 * 定时布撤防每3分钟执行一次
*/ */
// @Async @Async
// @Scheduled(initialDelay = 6000, fixedRate = 180000) @Scheduled(initialDelay = 6000, fixedRate = 180000)
public void task() { public void task() {
// System.out.println("定时任务执行了2"); // System.out.println("定时任务执行了2");
List<CornJob> jobs = cornJobService.list(Wrappers.<CornJob>lambdaQuery().eq(CornJob::getStatus, 1).eq(CornJob::getIsRegular, 1)); List<CornJob> jobs = cornJobService.list(Wrappers.<CornJob>lambdaQuery().eq(CornJob::getStatus, 1).eq(CornJob::getIsRegular, 1));

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

Loading…
Cancel
Save