|
@@ -30,6 +30,8 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
+import static com.zd.common.core.constant.Constants.MAP_INIT_SIZE;
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
public class SendSginAccessLogService {
|
|
public class SendSginAccessLogService {
|
|
|
|
|
|
|
@@ -123,7 +125,7 @@ public class SendSginAccessLogService {
|
|
|
String loudspeakerIp1 = algorithmYml.getLoudspeakerIp1();
|
|
String loudspeakerIp1 = algorithmYml.getLoudspeakerIp1();
|
|
|
String loudspeakerIp2 = algorithmYml.getLoudspeakerIp2();
|
|
String loudspeakerIp2 = algorithmYml.getLoudspeakerIp2();
|
|
|
R deviceList = remoteSpeakService.getDeviceList(1, 10, 5L);
|
|
R deviceList = remoteSpeakService.getDeviceList(1, 10, 5L);
|
|
|
- if (deviceList.getCode() == 200) {
|
|
|
|
|
|
|
+ if (deviceList.getCode() == HttpStatus.SUCCESS) {
|
|
|
List<Map<String, Object>> mapList = (List<Map<String, Object>>) deviceList.getData();
|
|
List<Map<String, Object>> mapList = (List<Map<String, Object>>) deviceList.getData();
|
|
|
for (Map<String, Object> map : mapList) {
|
|
for (Map<String, Object> map : mapList) {
|
|
|
if (StringUtils.isNotNull(map.get("deviceSn")) && StringUtils.isNotNull(map.get("port"))) {
|
|
if (StringUtils.isNotNull(map.get("deviceSn")) && StringUtils.isNotNull(map.get("port"))) {
|
|
@@ -152,22 +154,16 @@ public class SendSginAccessLogService {
|
|
|
* 发送火焰警报
|
|
* 发送火焰警报
|
|
|
*/
|
|
*/
|
|
|
public R<Object> sendAlarm(VideoRequestData videoRequestData) {
|
|
public R<Object> sendAlarm(VideoRequestData videoRequestData) {
|
|
|
- Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>(MAP_INIT_SIZE);
|
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
Integer aid = videoRequestData.getAid();
|
|
Integer aid = videoRequestData.getAid();
|
|
|
Map<Integer, AlgorithmYml.AlarmConfig> alarmConfigMap = algorithmYml.getAlarmConfigMap();
|
|
Map<Integer, AlgorithmYml.AlarmConfig> alarmConfigMap = algorithmYml.getAlarmConfigMap();
|
|
|
if (alarmConfigMap.containsKey(aid)) {
|
|
if (alarmConfigMap.containsKey(aid)) {
|
|
|
AlgorithmYml.AlarmConfig alarmConfig = alarmConfigMap.get(aid);
|
|
AlgorithmYml.AlarmConfig alarmConfig = alarmConfigMap.get(aid);
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>(MAP_INIT_SIZE);
|
|
|
params.put("hardwareNum", videoRequestData.getCid());
|
|
params.put("hardwareNum", videoRequestData.getCid());
|
|
|
params.put("val", videoRequestData.getStatus());
|
|
params.put("val", videoRequestData.getStatus());
|
|
|
- params.put("funNum", alarmConfig.getFunNum());
|
|
|
|
|
- params.put("describe", alarmConfig.getDescribe());
|
|
|
|
|
- maps.add(params);
|
|
|
|
|
- requestMap.put("functionStatuses", maps);
|
|
|
|
|
- ParameterizedTypeReference<R<Object>> reference = new ParameterizedTypeReference<R<Object>>() {
|
|
|
|
|
- };
|
|
|
|
|
- return send(requestMap, algorithmYml.getTargetUrl() + "laboratory/plan/triggerRiskPlan", HttpMethod.POST, reference);
|
|
|
|
|
|
|
+ return getParams(requestMap, maps, alarmConfig, params);
|
|
|
}
|
|
}
|
|
|
return R.fail("未找到算法");
|
|
return R.fail("未找到算法");
|
|
|
}
|
|
}
|
|
@@ -176,32 +172,36 @@ public class SendSginAccessLogService {
|
|
|
* 发送火焰警报
|
|
* 发送火焰警报
|
|
|
*/
|
|
*/
|
|
|
public R<Object> send(FireProperties properties) {
|
|
public R<Object> send(FireProperties properties) {
|
|
|
- Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>(MAP_INIT_SIZE);
|
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
Integer aid = properties.getAlgoId();
|
|
Integer aid = properties.getAlgoId();
|
|
|
Map<Integer, AlgorithmYml.AlarmConfig> alarmConfigMap = algorithmYml.getAlarmConfigMap();
|
|
Map<Integer, AlgorithmYml.AlarmConfig> alarmConfigMap = algorithmYml.getAlarmConfigMap();
|
|
|
if (alarmConfigMap.containsKey(aid)) {
|
|
if (alarmConfigMap.containsKey(aid)) {
|
|
|
AlgorithmYml.AlarmConfig alarmConfig = alarmConfigMap.get(aid);
|
|
AlgorithmYml.AlarmConfig alarmConfig = alarmConfigMap.get(aid);
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>(MAP_INIT_SIZE);
|
|
|
params.put("hardwareNum", properties.getHardwareNum());
|
|
params.put("hardwareNum", properties.getHardwareNum());
|
|
|
params.put("subId", properties.getLabId());
|
|
params.put("subId", properties.getLabId());
|
|
|
params.put("val", 1);
|
|
params.put("val", 1);
|
|
|
- params.put("funNum", alarmConfig.getFunNum());
|
|
|
|
|
- params.put("describe", alarmConfig.getDescribe());
|
|
|
|
|
- maps.add(params);
|
|
|
|
|
- requestMap.put("functionStatuses", maps);
|
|
|
|
|
- ParameterizedTypeReference<R<Object>> reference = new ParameterizedTypeReference<R<Object>>() {
|
|
|
|
|
- };
|
|
|
|
|
- return send(requestMap, algorithmYml.getTargetUrl() + "laboratory/plan/triggerRiskPlan", HttpMethod.POST, reference);
|
|
|
|
|
|
|
+ return getParams(requestMap, maps, alarmConfig, params);
|
|
|
}
|
|
}
|
|
|
return R.fail("未找到算法");
|
|
return R.fail("未找到算法");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private R<Object> getParams(Map<String, Object> requestMap, List<Map<String, Object>> maps, AlgorithmYml.AlarmConfig alarmConfig, Map<String, Object> params) {
|
|
|
|
|
+ params.put("funNum", alarmConfig.getFunNum());
|
|
|
|
|
+ params.put("describe", alarmConfig.getDescribe());
|
|
|
|
|
+ maps.add(params);
|
|
|
|
|
+ requestMap.put("functionStatuses", maps);
|
|
|
|
|
+ ParameterizedTypeReference<R<Object>> reference = new ParameterizedTypeReference<R<Object>>() {
|
|
|
|
|
+ };
|
|
|
|
|
+ return send(requestMap, algorithmYml.getTargetUrl() + "laboratory/plan/triggerRiskPlan", HttpMethod.POST, reference);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private <T> R<T> send(Map<String, Object> params, String url, HttpMethod method, ParameterizedTypeReference<R<T>> reference) {
|
|
private <T> R<T> send(Map<String, Object> params, String url, HttpMethod method, ParameterizedTypeReference<R<T>> reference) {
|
|
|
HttpEntity<Map<String, Object>> requestEntity = getMapHttpEntity(params);
|
|
HttpEntity<Map<String, Object>> requestEntity = getMapHttpEntity(params);
|
|
|
ResponseEntity<R<T>> exchange = restTemplateLocal.exchange(url, method, requestEntity, reference);
|
|
ResponseEntity<R<T>> exchange = restTemplateLocal.exchange(url, method, requestEntity, reference);
|
|
|
R<T> body = exchange.getBody();
|
|
R<T> body = exchange.getBody();
|
|
|
- if (body != null && body.getCode() == 401) {
|
|
|
|
|
|
|
+ if (body != null && body.getCode() == HttpStatus.UNAUTHORIZED) {
|
|
|
requestEntity = getMapHttpEntityLogin(params);
|
|
requestEntity = getMapHttpEntityLogin(params);
|
|
|
exchange = restTemplateLocal.exchange(url, method, requestEntity, reference);
|
|
exchange = restTemplateLocal.exchange(url, method, requestEntity, reference);
|
|
|
|
|
|