Search in sources :

Example 1 with SysAnnouncement

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;
}
Also used : SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) Result(org.jeecg.common.api.vo.Result)

Example 2 with SysAnnouncement

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;
}
Also used : SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) JSONObject(com.alibaba.fastjson.JSONObject) Date(java.util.Date) IOException(java.io.IOException) Result(org.jeecg.common.api.vo.Result)

Example 3 with SysAnnouncement

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;
}
Also used : SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) Result(org.jeecg.common.api.vo.Result)

Example 4 with SysAnnouncement

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;
}
Also used : SysAnnouncementSend(org.jeecg.modules.system.entity.SysAnnouncementSend) SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) HashMap(java.util.HashMap) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) LoginUser(org.jeecg.common.system.vo.LoginUser) Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) JSONObject(com.alibaba.fastjson.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with SysAnnouncement

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);
}
Also used : SysAnnouncement(org.jeecg.modules.system.entity.SysAnnouncement) Date(java.util.Date)

Aggregations

SysAnnouncement (org.jeecg.modules.system.entity.SysAnnouncement)36 Result (org.jeecg.common.api.vo.Result)24 IOException (java.io.IOException)12 JSONObject (com.alibaba.fastjson.JSONObject)9 Date (java.util.Date)9 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 LoginUser (org.jeecg.common.system.vo.LoginUser)6 IPage (com.baomidou.mybatisplus.core.metadata.IPage)3 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)3 SysAnnouncementSend (org.jeecg.modules.system.entity.SysAnnouncementSend)3 ExportParams (org.jeecgframework.poi.excel.entity.ExportParams)3 ImportParams (org.jeecgframework.poi.excel.entity.ImportParams)3 JeecgEntityExcelView (org.jeecgframework.poi.excel.view.JeecgEntityExcelView)3 MultipartFile (org.springframework.web.multipart.MultipartFile)3 MultipartHttpServletRequest (org.springframework.web.multipart.MultipartHttpServletRequest)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3