|
@@ -2,11 +2,15 @@ package com.jpsoft.smart.modules.base.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
import com.jpsoft.smart.modules.base.entity.AlarmInfo;
|
|
import com.jpsoft.smart.modules.base.entity.AlarmInfo;
|
|
|
|
+import com.jpsoft.smart.modules.base.entity.OwnerInfo;
|
|
import com.jpsoft.smart.modules.base.service.AlarmInfoService;
|
|
import com.jpsoft.smart.modules.base.service.AlarmInfoService;
|
|
|
|
+import com.jpsoft.smart.modules.base.service.OwnerInfoService;
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
import com.jpsoft.smart.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.smart.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
|
|
+import com.jpsoft.smart.modules.wechat.entity.AccessControl;
|
|
|
|
+import com.jpsoft.smart.modules.wechat.service.IAccessControlService;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -23,6 +27,10 @@ public class AlarmInfoController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private AlarmInfoService alarmInfoService;
|
|
private AlarmInfoService alarmInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OwnerInfoService ownerInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IAccessControlService accessControlService;
|
|
|
|
|
|
@PostMapping("alarmNotify")
|
|
@PostMapping("alarmNotify")
|
|
public MessageResult<String> alarmNotify(String message){
|
|
public MessageResult<String> alarmNotify(String message){
|
|
@@ -35,10 +43,21 @@ public class AlarmInfoController {
|
|
//alarmInfo.setCreateBy(subject);
|
|
//alarmInfo.setCreateBy(subject);
|
|
alarmInfo.setIsRead(false);
|
|
alarmInfo.setIsRead(false);
|
|
//2019-12-07 11:04:04.322 INFO 11000 --- [nio-8080-exec-5] c.j.s.m.b.c.AlarmInfoController : 周界入侵,目标ID:13974,区域范围:(0.327,0.698)(0.674,0.936)(0.67,0.985)(0.352,0.973)
|
|
//2019-12-07 11:04:04.322 INFO 11000 --- [nio-8080-exec-5] c.j.s.m.b.c.AlarmInfoController : 周界入侵,目标ID:13974,区域范围:(0.327,0.698)(0.674,0.936)(0.67,0.985)(0.352,0.973)
|
|
- int index = message.indexOf("周界入侵");
|
|
|
|
- if(index > 0){
|
|
|
|
- message = message.substring(index,message.length());
|
|
|
|
|
|
+
|
|
|
|
+ int zjIndex = message.indexOf("周界入侵");
|
|
|
|
+ int bjIndex = message.indexOf("报警主机CID报告");
|
|
|
|
+ if(zjIndex >= 0){
|
|
|
|
+ message = message.substring(zjIndex,message.length());
|
|
|
|
+ }else if(bjIndex >= 0){
|
|
|
|
+ int index = message.indexOf("报告类型");
|
|
|
|
+ if(index >= 0) {
|
|
|
|
+ message = "报警主机CID报告," + message.substring(index, message.length());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
alarmInfo.setMessage(message);
|
|
alarmInfo.setMessage(message);
|
|
alarmInfo.setType("2");
|
|
alarmInfo.setType("2");
|
|
alarmInfo.setCreateTime(new Date());
|
|
alarmInfo.setCreateTime(new Date());
|
|
@@ -282,18 +301,46 @@ public class AlarmInfoController {
|
|
msgResult.setData(alarmInfo.getMessage());
|
|
msgResult.setData(alarmInfo.getMessage());
|
|
|
|
|
|
String content = alarmInfo.getMessage();
|
|
String content = alarmInfo.getMessage();
|
|
- int index = content.lastIndexOf(":");
|
|
|
|
- if(index > 0){
|
|
|
|
- content = content.substring(index+1,content.length());
|
|
|
|
|
|
+
|
|
|
|
+ //报警主机CID报告,sCIDCode:1401,sCIDDescribe:����,报告类型:6,防区号:65535,报警触发时间:2019-12-17 10:21:36
|
|
|
|
+ //周界入侵,目标ID:761,区域范围:(0.327,0.698)(0.674,0.936)(0.67,0.985)(0.352,0.973)
|
|
|
|
+ int zjIndex = content.indexOf("区域范围");
|
|
|
|
+ int cidIndex = content.indexOf("报警主机CID报告");
|
|
|
|
+ if(zjIndex >= 0){
|
|
|
|
+ //周界入侵
|
|
|
|
+// int index = content.lastIndexOf(":");
|
|
|
|
+// if(index >= 0){
|
|
|
|
+// content = content.substring(index+1,content.length());
|
|
|
|
+// }
|
|
|
|
+ content = content;
|
|
|
|
+ }else if(cidIndex >= 0){
|
|
|
|
+ //报警主机CID报告
|
|
|
|
+ int startIndex = content.lastIndexOf("报告类型");
|
|
|
|
+ int endIndex = content.lastIndexOf("报警触发时间");
|
|
|
|
+ if(startIndex >= 0){
|
|
|
|
+ content = content.substring(0,endIndex-1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
//发送通知
|
|
//发送通知
|
|
- String openId = "oHjCawgwCGen5k1-hAsimdEX5lZo";
|
|
|
|
- boolean result = WechatMessageUtil.sendAlarmNoticeMessage("周界入侵警报", content, openId, "","8dpP8XM1XaiiIByXiuAeFIZeNjEow1AleG_h8O2xyVA","wx7e70eb62a8459869","909d17e353268da57c4f18cc09798049");
|
|
|
|
- if(result) {
|
|
|
|
- //修改阅读状态
|
|
|
|
- alarmInfo.setIsRead(true);
|
|
|
|
- alarmInfoService.update(alarmInfo);
|
|
|
|
|
|
+ //String openId = "oHjCawgwCGen5k1-hAsimdEX5lZo";
|
|
|
|
+ String openId = "";
|
|
|
|
+ List<OwnerInfo> lstOwner = ownerInfoService.list();
|
|
|
|
+ for(OwnerInfo owner : lstOwner) {
|
|
|
|
+ AccessControl accessControl = accessControlService.findByOwnerId(owner.getId());
|
|
|
|
+ if(accessControl != null){
|
|
|
|
+ openId = accessControl.getOpenId();
|
|
|
|
+ boolean result = WechatMessageUtil.sendAlarmNoticeMessage("周界入侵警报", content, openId, "","8dpP8XM1XaiiIByXiuAeFIZeNjEow1AleG_h8O2xyVA","wx7e70eb62a8459869","909d17e353268da57c4f18cc09798049");
|
|
|
|
+ if(result) {
|
|
|
|
+ //修改阅读状态
|
|
|
|
+ alarmInfo.setIsRead(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ alarmInfoService.update(alarmInfo);
|
|
|
|
+
|
|
}
|
|
}
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|