use of org.jeecg.modules.system.entity.SysAnnouncement in project jeecg-boot by jeecgboot.
the class SysAnnouncementController method delete.
/**
* 通过id删除
* @param id
* @return
*/
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public Result<SysAnnouncement> delete(@RequestParam(name = "id", required = true) String id) {
Result<SysAnnouncement> result = new Result<SysAnnouncement>();
SysAnnouncement sysAnnouncement = sysAnnouncementService.getById(id);
if (sysAnnouncement == null) {
result.error500("未找到对应实体");
} else {
sysAnnouncement.setDelFlag(CommonConstant.DEL_FLAG_1.toString());
boolean ok = sysAnnouncementService.updateById(sysAnnouncement);
if (ok) {
result.success("删除成功!");
}
}
return result;
}
use of org.jeecg.modules.system.entity.SysAnnouncement in project jeecg-boot by jeecgboot.
the class SysAnnouncementController method doReleaseData.
/**
* 更新发布操作
* @param id
* @return
*/
@RequestMapping(value = "/doReleaseData", method = RequestMethod.GET)
public Result<SysAnnouncement> doReleaseData(@RequestParam(name = "id", required = true) String id, HttpServletRequest request) {
Result<SysAnnouncement> result = new Result<SysAnnouncement>();
SysAnnouncement sysAnnouncement = sysAnnouncementService.getById(id);
if (sysAnnouncement == null) {
result.error500("未找到对应实体");
} else {
// 发布中
sysAnnouncement.setSendStatus(CommonSendStatus.PUBLISHED_STATUS_1);
sysAnnouncement.setSendTime(new Date());
String currentUserName = JwtUtil.getUserNameByToken(request);
sysAnnouncement.setSender(currentUserName);
boolean ok = sysAnnouncementService.updateById(sysAnnouncement);
if (ok) {
result.success("该系统通知发布成功");
if (sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_ALL)) {
JSONObject obj = new JSONObject();
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendMessage(obj.toJSONString());
} else {
// 2.插入用户通告阅读标记表记录
String userId = sysAnnouncement.getUserIds();
String[] userIds = userId.substring(0, (userId.length() - 1)).split(",");
String anntId = sysAnnouncement.getId();
Date refDate = new Date();
JSONObject obj = new JSONObject();
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendMessage(userIds, obj.toJSONString());
}
try {
// 同步企业微信、钉钉的消息通知
Response<String> dtResponse = dingtalkService.sendActionCardMessage(sysAnnouncement, true);
wechatEnterpriseService.sendTextCardMessage(sysAnnouncement, true);
if (dtResponse != null && dtResponse.isSuccess()) {
String taskId = dtResponse.getResult();
sysAnnouncement.setDtTaskId(taskId);
sysAnnouncementService.updateById(sysAnnouncement);
}
} catch (Exception e) {
log.error("同步发送第三方APP消息失败:", e);
}
}
}
return result;
}
use of org.jeecg.modules.system.entity.SysAnnouncement in project jeecg-boot by jeecgboot.
the class SysAnnouncementController method deleteBatch.
/**
* 批量删除
* @param ids
* @return
*/
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<SysAnnouncement> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
Result<SysAnnouncement> result = new Result<SysAnnouncement>();
if (ids == null || "".equals(ids.trim())) {
result.error500("参数不识别!");
} else {
String[] id = ids.split(",");
for (int i = 0; i < id.length; i++) {
SysAnnouncement announcement = sysAnnouncementService.getById(id[i]);
announcement.setDelFlag(CommonConstant.DEL_FLAG_1.toString());
sysAnnouncementService.updateById(announcement);
}
result.success("删除成功!");
}
return result;
}
use of org.jeecg.modules.system.entity.SysAnnouncement in project jeecg-boot by jeecgboot.
the class SysAnnouncementController method listByUser.
/**
* @功能:补充用户数据,并返回系统消息
* @return
*/
@RequestMapping(value = "/listByUser", method = RequestMethod.GET)
public Result<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
// 1.将系统消息补充到用户通告阅读标记表中
LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>();
// 全部人员
querySaWrapper.eq(SysAnnouncement::getMsgType, CommonConstant.MSG_TYPE_ALL);
// 未删除
querySaWrapper.eq(SysAnnouncement::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
// 已发布
querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND);
// 新注册用户不看结束通知
querySaWrapper.ge(SysAnnouncement::getEndTime, sysUser.getCreateTime());
// update-begin--Author:liusq Date:20210108 for:[JT-424] 【开源issue】bug处理--------------------
querySaWrapper.notInSql(SysAnnouncement::getId, "select annt_id from sys_announcement_send where user_id='" + userId + "'");
// update-begin--Author:liusq Date:20210108 for: [JT-424] 【开源issue】bug处理--------------------
List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper);
if (announcements.size() > 0) {
for (int i = 0; i < announcements.size(); i++) {
// update-begin--Author:wangshuai Date:20200803 for: 通知公告消息重复LOWCOD-759--------------------
// 因为websocket没有判断是否存在这个用户,要是判断会出现问题,故在此判断逻辑
LambdaQueryWrapper<SysAnnouncementSend> query = new LambdaQueryWrapper<>();
query.eq(SysAnnouncementSend::getAnntId, announcements.get(i).getId());
query.eq(SysAnnouncementSend::getUserId, userId);
SysAnnouncementSend one = sysAnnouncementSendService.getOne(query);
if (null == one) {
log.info("listByUser接口新增了SysAnnouncementSend:pageSize{}:" + pageSize);
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
announcementSend.setAnntId(announcements.get(i).getId());
announcementSend.setUserId(userId);
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
sysAnnouncementSendService.save(announcementSend);
log.info("announcementSend.toString()", announcementSend.toString());
}
// update-end--Author:wangshuai Date:20200803 for: 通知公告消息重复LOWCOD-759------------
}
}
// 2.查询用户未读的系统消息
Page<SysAnnouncement> anntMsgList = new Page<SysAnnouncement>(0, pageSize);
// 通知公告消息
anntMsgList = sysAnnouncementService.querySysCementPageByUserId(anntMsgList, userId, "1");
Page<SysAnnouncement> sysMsgList = new Page<SysAnnouncement>(0, pageSize);
// 系统消息
sysMsgList = sysAnnouncementService.querySysCementPageByUserId(sysMsgList, userId, "2");
Map<String, Object> sysMsgMap = new HashMap<String, Object>();
sysMsgMap.put("sysMsgList", sysMsgList.getRecords());
sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal());
sysMsgMap.put("anntMsgList", anntMsgList.getRecords());
sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal());
result.setSuccess(true);
result.setResult(sysMsgMap);
return result;
}
use of org.jeecg.modules.system.entity.SysAnnouncement in project jeecg-boot by jeecgboot.
the class SysAnnouncementServiceImpl method saveSysAnnouncement.
// @功能:流程执行完成保存消息通知
@Override
public void saveSysAnnouncement(String title, String msgContent) {
SysAnnouncement announcement = new SysAnnouncement();
announcement.setTitile(title);
announcement.setMsgContent(msgContent);
announcement.setSender("JEECG BOOT");
announcement.setPriority(CommonConstant.PRIORITY_L);
announcement.setMsgType(CommonConstant.MSG_TYPE_ALL);
announcement.setSendStatus(CommonConstant.HAS_SEND);
announcement.setSendTime(new Date());
announcement.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
sysAnnouncementMapper.insert(announcement);
}
Aggregations