还是需要进行改造,把es_receiver字段修改成1000,可以接收更多用“,”分开的用户串,这样可以进行多人处理,同时需要修改发送代码。
@Slf4j public class WebMsgSendMsgHandle implements ISendMsgHandle { @Override public void SendMsg(String es_receiver, String es_title, String es_content, String es_fromuser) { log.info("WebMsgSendMsgHandle 发websocket消息"); ISysBaseAPI sysBaseAPI = (ISysBaseAPI) SpringContextUtils.getBean(ISysBaseAPI.class); List<String> userlist = Arrays.asList(es_receiver.split(",")); for(String user : userlist) { MessageDTO messagedto = new MessageDTO(); messagedto.setContent(es_content); messagedto.setCategory("1"); //放到通知通告了 messagedto.setFromUser(es_fromuser); messagedto.setTitle(es_title); messagedto.setToUser(user); sysBaseAPI.sendSysAnnouncement(messagedto); } } }
同时对于修改日程需要考虑各种情况,所以需要修改
@Override @Transactional(rollbackFor=Exception.class) public boolean updateSchedule(OaSchedule oaSchedule) { String msgId = oaSchedule.getMsgId(); String sendStatus = iEstarThirdService.getMsgSendStatus(msgId); if (oaSchedule.getRemind() != 0) {//有消息提醒 if (iEstarThirdService.getMsgRecord(msgId)) {//原来有消息记录 if(StringUtils.equals(sendStatus,"0")) {//还没发送消息,可以更新 updateScheduleById(oaSchedule); SysMessageVo sysMessageVo= new SysMessageVo(); sysMessageVo.setId(msgId); sysMessageVo.setEsContent(oaSchedule.getContent()); sysMessageVo.setEsTitle(oaSchedule.getTitle()); sysMessageVo.setEsReceiver(oaSchedule.getTaker()); sysMessageVo.setEsType(oaSchedule.getRemindType()); String reminddate = DateUtil.getPreTime(DateUtil.getDateString(oaSchedule.getStartTime(), "yyyy-MM-dd HH:mm:ss") ,String.valueOf(0-oaSchedule.getRemind())); sysMessageVo.setEsSendTime(DateUtil.stringToDate(reminddate)); iEstarThirdService.updateSysMessage(sysMessageVo); return true; } else {//已经发送消息了就不再更新了 return false; } }else {//原来没有就插入 updateScheduleById(oaSchedule); SysMessageVo sysMessageVo= new SysMessageVo(); sysMessageVo.setEsContent(oaSchedule.getContent()); sysMessageVo.setEsTitle(oaSchedule.getTitle()); sysMessageVo.setEsReceiver(oaSchedule.getTaker()); sysMessageVo.setEsType(oaSchedule.getRemindType()); String reminddate = DateUtil.getPreTime(DateUtil.getDateString(oaSchedule.getStartTime(), "yyyy-MM-dd HH:mm:ss") ,String.valueOf(0-oaSchedule.getRemind())); sysMessageVo.setEsSendTime(DateUtil.stringToDate(reminddate)); sysMessageVo.setEsSendStatus("0"); //SendMsgStatusEnum.WAIT.getCode() sysMessageVo.setEsSendNum(0); String sysMsgId = iEstarThirdService.saveSysMessage(sysMessageVo); oaSchedule.setMsgId(sysMsgId); oaScheduleService.updateById(oaSchedule); return true; } } else { updateScheduleById(oaSchedule); return true; } } void updateScheduleById(OaSchedule oaSchedule) { SysUser loginUser = iEstarThirdService.getLoginUser(); String userId = loginUser.getUsername(); if(StringUtils.isEmpty(oaSchedule.getTaker())){ oaSchedule.setTaker(userId); } if(StringUtils.isEmpty(oaSchedule.getOwner())){ oaSchedule.setOwner(userId); } oaScheduleService.updateById(oaSchedule); }
这样多人发送也能成功发送
更多功能看演示系统
gitee源代码地址
后端代码: https://gitee.com/nbacheng/nbcio-boot
前端代码:https://gitee.com/nbacheng/nbcio-vue.git
在线演示(包括H5) : http://122.227.135.243:9888