|  | @@ -78,71 +78,64 @@ public class WebsocketNoticeLogServiceImpl extends ServiceImpl<WebsocketNoticeLo
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void noticeAlarm(IotDeviceInfo deviceInfo,IotAlarmData iotAlarmData) {
 | 
	
		
			
				|  |  | -        QueryWrapper<CoreNoticeRuleItem> wrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | -        wrapper.lambda()
 | 
	
		
			
				|  |  | -                .eq(CoreNoticeRuleItem::getOrgId, deviceInfo.getOrgId())
 | 
	
		
			
				|  |  | -                .eq(CoreNoticeRuleItem::getProductType, deviceInfo.getDeviceProduct())
 | 
	
		
			
				|  |  | -                .eq(CoreNoticeRuleItem::getIsDeleted, 0);
 | 
	
		
			
				|  |  | -        List<CoreNoticeRuleItem> itemList = coreNoticeRuleItemService.list(wrapper);
 | 
	
		
			
				|  |  | -        /**
 | 
	
		
			
				|  |  | -         * 通知人员:
 | 
	
		
			
				|  |  | -         * 1.角色为空,有具体人员->发送到该机构下具体人员
 | 
	
		
			
				|  |  | -         * 2.角色不为空,无具体人员->发送到该机构下这些角色下所有人员
 | 
	
		
			
				|  |  | -         * 3.角色不为空,有具体人员->某个角色无对应人员时,发送到该角色下所有人员,某个角色有对应人员时,只发送对应人员
 | 
	
		
			
				|  |  | -         */
 | 
	
		
			
				|  |  | -        if (itemList != null && itemList.size() > 0) {
 | 
	
		
			
				|  |  | -            HashSet<Long> userSet = new HashSet<>();
 | 
	
		
			
				|  |  | -            for (CoreNoticeRuleItem item : itemList) {
 | 
	
		
			
				|  |  | -                //根据角色查询人员
 | 
	
		
			
				|  |  | -                if(ObjectUtil.isNotEmpty(item.getRoleIds())){
 | 
	
		
			
				|  |  | -                    String[] roles = item.getRoleIds().split(",");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    List<String> roleList = Arrays.asList(roles);
 | 
	
		
			
				|  |  | -                    List<Long> roleUserIdList = coreNoticeRuleItemService.getUserIdsByRoleIds(roleList, deviceInfo.getOrgId());
 | 
	
		
			
				|  |  | -                    if (roleUserIdList != null && roleUserIdList.size() > 0) {
 | 
	
		
			
				|  |  | -                        userSet.addAll(roleUserIdList);
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            List<CoreNoticeRuleItem> itemList = coreNoticeRuleItemService.getByOrgIdAndProductType(deviceInfo.getOrgId(),deviceInfo.getDeviceProduct());
 | 
	
		
			
				|  |  | +            /**
 | 
	
		
			
				|  |  | +             * 通知人员:
 | 
	
		
			
				|  |  | +             * 1.角色为空,有具体人员->发送到该机构下具体人员
 | 
	
		
			
				|  |  | +             * 2.角色不为空,无具体人员->发送到该机构下这些角色下所有人员
 | 
	
		
			
				|  |  | +             * 3.对上述两种人员进行去重,就是需要发送消息的人员
 | 
	
		
			
				|  |  | +             */
 | 
	
		
			
				|  |  | +            if (itemList != null && itemList.size() > 0) {
 | 
	
		
			
				|  |  | +                HashSet<Long> userSet = new HashSet<>();
 | 
	
		
			
				|  |  | +                for (CoreNoticeRuleItem item : itemList) {
 | 
	
		
			
				|  |  | +                    //根据角色查询人员
 | 
	
		
			
				|  |  | +                    if(item.getRoleId() != null){
 | 
	
		
			
				|  |  | +                        List<Long> roleUserIdList = coreNoticeRuleItemService.getUserIdsByRoleId(item.getRoleId(), deviceInfo.getOrgId());
 | 
	
		
			
				|  |  | +                        if (roleUserIdList != null && roleUserIdList.size() > 0) {
 | 
	
		
			
				|  |  | +                            userSet.addAll(roleUserIdList);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                //根据人员id查询该机构下人员
 | 
	
		
			
				|  |  | -                if(ObjectUtil.isNotEmpty(item.getUserIds())){
 | 
	
		
			
				|  |  | -                    String[] userIds = item.getUserIds().split(",");
 | 
	
		
			
				|  |  | -                    List<String> userList = Arrays.asList(userIds);
 | 
	
		
			
				|  |  | -                    List<Long> userIdList = coreNoticeRuleItemService.handleByOrgIdAndUserIds(userList, deviceInfo.getOrgId());
 | 
	
		
			
				|  |  | -                    if (userIdList != null && userIdList.size() > 0) {
 | 
	
		
			
				|  |  | -                        userSet.addAll(userIdList);
 | 
	
		
			
				|  |  | +                    //根据人员id查询该机构下人员
 | 
	
		
			
				|  |  | +                    if(ObjectUtil.isNotEmpty(item.getUserIds())){
 | 
	
		
			
				|  |  | +                        String[] userIds = item.getUserIds().split(",");
 | 
	
		
			
				|  |  | +                        for (String userId : userIds) {
 | 
	
		
			
				|  |  | +                            userSet.add(Long.valueOf(userId));
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if(!userSet.isEmpty()){
 | 
	
		
			
				|  |  | -                Long orgId = deviceInfo.getOrgId();
 | 
	
		
			
				|  |  | -                WebSocketNoticeVo noticeVo = new WebSocketNoticeVo();
 | 
	
		
			
				|  |  | -                noticeVo.setIotAlarmDataId(iotAlarmData.getId());
 | 
	
		
			
				|  |  | -                noticeVo.setAlarmTime(iotAlarmData.getTime());
 | 
	
		
			
				|  |  | -                noticeVo.setAlarmContent(iotAlarmData.getContent());
 | 
	
		
			
				|  |  | -                noticeVo.setAlarmValue(iotAlarmData.getAlarmValue());
 | 
	
		
			
				|  |  | -                noticeVo.setDeviceName(deviceInfo.getDeviceName());
 | 
	
		
			
				|  |  | -                noticeVo.setProductType(deviceInfo.getDeviceProduct());
 | 
	
		
			
				|  |  | -                String productTypeName = ObjectUtil.isNotEmpty(BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceType()))
 | 
	
		
			
				|  |  | -                        ? BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceType()) : BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceProduct());
 | 
	
		
			
				|  |  | -                noticeVo.setProductTypeName(productTypeName);
 | 
	
		
			
				|  |  | -                noticeVo.setIsDo(0);
 | 
	
		
			
				|  |  | -                noticeVo.setOrgId(orgId);
 | 
	
		
			
				|  |  | -                SysOrg sysOrg = orgService.selectOrgById(orgId, SecurityConstants.INNER);
 | 
	
		
			
				|  |  | -                if (null != sysOrg) {
 | 
	
		
			
				|  |  | -                    noticeVo.setOrgName(sysOrg.getShortName());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                List<WebSocketSendVo> list = new ArrayList<>();
 | 
	
		
			
				|  |  | -                for (Long userId : userSet) {
 | 
	
		
			
				|  |  | -                    WebSocketSendVo sendVo = new WebSocketSendVo();
 | 
	
		
			
				|  |  | -                    sendVo.setUserId(userId);
 | 
	
		
			
				|  |  | -                    sendVo.setOrgId(orgId);
 | 
	
		
			
				|  |  | -                    sendVo.setContent(noticeVo);
 | 
	
		
			
				|  |  | -                    list.add(sendVo);
 | 
	
		
			
				|  |  | +                if(!userSet.isEmpty()){
 | 
	
		
			
				|  |  | +                    Long orgId = deviceInfo.getOrgId();
 | 
	
		
			
				|  |  | +                    WebSocketNoticeVo noticeVo = new WebSocketNoticeVo();
 | 
	
		
			
				|  |  | +                    noticeVo.setIotAlarmDataId(iotAlarmData.getId());
 | 
	
		
			
				|  |  | +                    noticeVo.setAlarmTime(iotAlarmData.getTime());
 | 
	
		
			
				|  |  | +                    noticeVo.setAlarmContent(iotAlarmData.getContent());
 | 
	
		
			
				|  |  | +                    noticeVo.setAlarmValue(iotAlarmData.getAlarmValue());
 | 
	
		
			
				|  |  | +                    noticeVo.setDeviceName(deviceInfo.getDeviceName());
 | 
	
		
			
				|  |  | +                    noticeVo.setProductType(deviceInfo.getDeviceProduct());
 | 
	
		
			
				|  |  | +                    String productTypeName = ObjectUtil.isNotEmpty(BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceType()))
 | 
	
		
			
				|  |  | +                            ? BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceType()) : BaseDeviceTypeEnum.getDescByCode(deviceInfo.getDeviceProduct());
 | 
	
		
			
				|  |  | +                    noticeVo.setProductTypeName(productTypeName);
 | 
	
		
			
				|  |  | +                    noticeVo.setIsDo(0);
 | 
	
		
			
				|  |  | +                    noticeVo.setOrgId(orgId);
 | 
	
		
			
				|  |  | +                    SysOrg sysOrg = orgService.selectOrgById(orgId, SecurityConstants.INNER);
 | 
	
		
			
				|  |  | +                    if (null != sysOrg) {
 | 
	
		
			
				|  |  | +                        noticeVo.setOrgName(sysOrg.getShortName());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    List<WebSocketSendVo> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +                    for (Long userId : userSet) {
 | 
	
		
			
				|  |  | +                        WebSocketSendVo sendVo = new WebSocketSendVo();
 | 
	
		
			
				|  |  | +                        sendVo.setUserId(userId);
 | 
	
		
			
				|  |  | +                        sendVo.setOrgId(orgId);
 | 
	
		
			
				|  |  | +                        sendVo.setContent(noticeVo);
 | 
	
		
			
				|  |  | +                        list.add(sendVo);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    //调用system接口发送通知
 | 
	
		
			
				|  |  | +                    websocketSendService.sendMessages(list);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                //调用system接口发送通知
 | 
	
		
			
				|  |  | -                websocketSendService.sendMessages(list);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +        }catch (Exception e){
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |