mitao
3 天以前 6365012e69b76d2a7804f5a462745f09a5fa0105
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/OaNotificationController.java
@@ -8,7 +8,7 @@
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.TDept;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.model.OaNotifationUser;
import com.ruoyi.system.model.OaNotificationUser;
import com.ruoyi.system.model.OaNotification;
import com.ruoyi.system.query.NotificationListQuery;
import com.ruoyi.system.service.*;
@@ -63,8 +63,8 @@
        List<String> notificationIds = Arrays.asList(ids.split(","));
        // 删除后 将已发送的消息通知一并删除
        oaNotificationService.removeBatchByIds(notificationIds);
        oaNotifationUserService.remove(new LambdaQueryWrapper<OaNotifationUser>()
                .in(OaNotifationUser::getNotificationId,notificationIds));
        oaNotifationUserService.remove(new LambdaQueryWrapper<OaNotificationUser>()
                .in(OaNotificationUser::getNotificationId,notificationIds));
        return R.ok();
    }
    @Log(title = "消息通知-新增消息", businessType = BusinessType.INSERT)
@@ -72,28 +72,28 @@
    @PostMapping(value = "/add")
    public R<Boolean> add( @RequestBody OaNotification dto) {
        oaNotificationService.save(dto);
        ArrayList<OaNotifationUser> oaNotifationUsers = new ArrayList<>();
        ArrayList<OaNotificationUser> oaNotificationUsers = new ArrayList<>();
        // 发送消息通知
        if (dto.getType()){
            // 指定人员发送
            Arrays.asList(dto.getUserIds().split(","))
                    .forEach(userId -> {
                        OaNotifationUser oaNotifationUser = new OaNotifationUser();
                        oaNotifationUser.setUserId(Integer.parseInt(userId));
                        oaNotifationUser.setNotificationId(dto.getId());
                        oaNotifationUsers.add(oaNotifationUser);
                        OaNotificationUser oaNotificationUser = new OaNotificationUser();
                        oaNotificationUser.setUserId(Integer.parseInt(userId));
                        oaNotificationUser.setNotificationId(dto.getId());
                        oaNotificationUsers.add(oaNotificationUser);
                    });
        }else{
            // 所有人发送
            List<SysUser> sysUsers = sysUserService.selectAllList();
            sysUsers.forEach(sysUser -> {
                OaNotifationUser oaNotifationUser = new OaNotifationUser();
                oaNotifationUser.setUserId(sysUser.getUserId().intValue());
                oaNotifationUser.setNotificationId(dto.getId());
                oaNotifationUsers.add(oaNotifationUser);
                OaNotificationUser oaNotificationUser = new OaNotificationUser();
                oaNotificationUser.setUserId(sysUser.getUserId().intValue());
                oaNotificationUser.setNotificationId(dto.getId());
                oaNotificationUsers.add(oaNotificationUser);
            });
        }
        oaNotifationUserService.saveBatch(oaNotifationUsers);
        oaNotifationUserService.saveBatch(oaNotificationUsers);
        return R.ok();
    }
    @ApiOperation(value = "消息通知详情")
@@ -105,7 +105,7 @@
        StringBuilder deptName = new StringBuilder();
        List<TDept> tDepts = deptService.list();
        List<SysUser> sysUsers = sysUserService.selectAllList();
        List<OaNotifationUser> notifationUsers = oaNotifationUserService.lambdaQuery().eq(OaNotifationUser::getNotificationId, id)
        List<OaNotificationUser> notifationUsers = oaNotifationUserService.lambdaQuery().eq(OaNotificationUser::getNotificationId, id)
                .list();
        Map<Integer, String> deptMap = tDepts.stream().collect(Collectors.toMap(TDept::getId, TDept::getDeptName));
        Map<Long, SysUser> userMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, e->e));
@@ -149,7 +149,7 @@
        }
        List<NotificationUserDetailVO> notificationUserDetailVOS = new ArrayList<>();
        for (OaNotifationUser notifationUser : notifationUsers) {
        for (OaNotificationUser notifationUser : notifationUsers) {
            NotificationUserDetailVO notificationUserDetailVO = new NotificationUserDetailVO();
            BeanUtils.copyProperties(notifationUser, notificationUserDetailVO);
            SysUser sysUser = userMap.get(notifationUser.getUserId().longValue());