|
|
@@ -9,6 +9,7 @@ import com.xunmei.common.core.domain.notice.CoreNoticeRuleItem;
|
|
|
import com.xunmei.common.core.domain.notice.WebsocketNoticeLog;
|
|
|
import com.xunmei.common.core.enums.iot.BaseDeviceTypeEnum;
|
|
|
import com.xunmei.common.core.vo.notice.WebSocketNoticeVo;
|
|
|
+import com.xunmei.host.enums.AlarmHostProductToFsuProductEnum;
|
|
|
import com.xunmei.host.notice.mapper.WebsocketNoticeLogMapper;
|
|
|
import com.xunmei.host.notice.service.ICoreNoticeRuleItemService;
|
|
|
import com.xunmei.host.notice.service.IWebsocketNoticeLogService;
|
|
|
@@ -16,12 +17,13 @@ import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.RemoteWebsocketSendService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.domain.iot.IotDeviceInfo;
|
|
|
+import com.xunmei.system.api.util.LogUtils;
|
|
|
import com.xunmei.system.api.vo.WebSocketSendVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -77,9 +79,20 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void noticeAlarm(IotDeviceInfo deviceInfo,IotAlarmData iotAlarmData) {
|
|
|
+ public void noticeAlarm(IotDeviceInfo deviceInfo,IotAlarmData iotAlarmData,boolean alarmHost) {
|
|
|
try {
|
|
|
- List<CoreNoticeRuleItem> itemList = coreNoticeRuleItemService.getByOrgIdAndProductType(deviceInfo.getOrgId(),deviceInfo.getDeviceProduct());
|
|
|
+ String productType = deviceInfo.getDeviceProduct();
|
|
|
+ //是报警主机的传感器时,需要转换类型
|
|
|
+ if (alarmHost){
|
|
|
+ String fsuProductType = AlarmHostProductToFsuProductEnum.getFsuProductType(productType);
|
|
|
+ if (ObjectUtil.isEmpty(fsuProductType)){
|
|
|
+ LogUtils.SMS_NOTICE_LOG.error("报警主机设备类型转换fsu设备类型为空,设备类型:{}",productType);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ productType = fsuProductType;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CoreNoticeRuleItem> itemList = coreNoticeRuleItemService.getByOrgIdAndProductType(deviceInfo.getOrgId(),productType);
|
|
|
/**
|
|
|
* 通知人员:
|
|
|
* 1.角色为空,有具体人员->发送到该机构下具体人员
|
|
|
@@ -88,12 +101,20 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
|
|
|
*/
|
|
|
if (itemList != null && itemList.size() > 0) {
|
|
|
HashSet<Long> userSet = new HashSet<>();
|
|
|
+ HashSet<Long> sendSmsUserSet = new HashSet<>();
|
|
|
+ HashMap<Long, Long> hashMap = new HashMap<>();
|
|
|
for (CoreNoticeRuleItem item : itemList) {
|
|
|
//根据角色查询人员
|
|
|
if(item.getRoleId() != null){
|
|
|
- List<Long> roleUserIdList = coreNoticeRuleItemService.getUserIdsByRoleId(item.getRoleId(), deviceInfo.getOrgId());
|
|
|
+ List<Long> roleUserIdList = coreNoticeRuleItemService.getUserIdsByRoleId(item.getRoleId(), item.getOrgId());
|
|
|
if (roleUserIdList != null && roleUserIdList.size() > 0) {
|
|
|
userSet.addAll(roleUserIdList);
|
|
|
+ if (item.getSendSms() == 1){
|
|
|
+ sendSmsUserSet.addAll(roleUserIdList);
|
|
|
+ }
|
|
|
+ for (Long userId : roleUserIdList) {
|
|
|
+ hashMap.put(userId, item.getOrgId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//根据人员id查询该机构下人员
|
|
|
@@ -101,11 +122,14 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
|
|
|
String[] userIds = item.getUserIds().split(",");
|
|
|
for (String userId : userIds) {
|
|
|
userSet.add(Long.valueOf(userId));
|
|
|
+ hashMap.put(Long.valueOf(userId), item.getOrgId());
|
|
|
+ if (item.getSendSms() == 1){
|
|
|
+ sendSmsUserSet.add(Long.valueOf(userId));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(!userSet.isEmpty()){
|
|
|
- Long orgId = deviceInfo.getOrgId();
|
|
|
WebSocketNoticeVo noticeVo = new WebSocketNoticeVo();
|
|
|
noticeVo.setIotAlarmDataId(iotAlarmData.getId());
|
|
|
noticeVo.setAlarmTime(iotAlarmData.getTime());
|
|
|
@@ -117,8 +141,8 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
|
|
|
? BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceType()) : BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceProduct());
|
|
|
noticeVo.setProductTypeName(productTypeName);
|
|
|
noticeVo.setIsDo(0);
|
|
|
- noticeVo.setOrgId(orgId);
|
|
|
- SysOrg sysOrg = orgService.selectOrgById(orgId, SecurityConstants.INNER);
|
|
|
+ noticeVo.setOrgId(deviceInfo.getOrgId());
|
|
|
+ SysOrg sysOrg = orgService.selectOrgById(deviceInfo.getOrgId(), SecurityConstants.INNER);
|
|
|
if (null != sysOrg) {
|
|
|
noticeVo.setOrgName(sysOrg.getShortName());
|
|
|
}
|
|
|
@@ -126,7 +150,8 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
|
|
|
for (Long userId : userSet) {
|
|
|
WebSocketSendVo sendVo = new WebSocketSendVo();
|
|
|
sendVo.setUserId(userId);
|
|
|
- sendVo.setOrgId(orgId);
|
|
|
+ //通知机构
|
|
|
+ sendVo.setOrgId(hashMap.get(userId));
|
|
|
sendVo.setContent(noticeVo);
|
|
|
list.add(sendVo);
|
|
|
}
|