spdm消息通知

This commit is contained in:
2025-12-03 10:54:59 +08:00
parent ce48739ee2
commit 1f86cb9268
16 changed files with 146 additions and 5 deletions

View File

@@ -89,6 +89,11 @@ public interface ServiceNameConstants {
*/
String STEP_SERVICE = "honeycom-step-biz";
/**
* 消息模块
*/
String MSG_SERVICE = "honeycom-msg-biz";
/**
* spdm中转模块
*/

View File

@@ -73,6 +73,12 @@
<groupId>com.honeycombis</groupId>
<artifactId>honeycom-common-log</artifactId>
</dependency>
<dependency>
<groupId>com.honeycombis</groupId>
<artifactId>honeycom-msg-api</artifactId>
<version>5.4.0</version>
<scope>compile</scope>
</dependency>
<!--选配: mybatis 依赖 -->
<dependency>
<groupId>com.baomidou</groupId>

View File

@@ -15,6 +15,7 @@ import com.honeycombis.honeycom.admin.api.feign.RemoteDeptService;
import com.honeycombis.honeycom.admin.api.utils.DataUtil;
import com.honeycombis.honeycom.common.core.constant.SecurityConstants;
import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.common.data.tenant.TenantContextHolder;
import com.honeycombis.honeycom.common.security.service.HoneycomUser;
import com.honeycombis.honeycom.common.security.util.SecurityUtils;
import com.honeycombis.honeycom.flow.task.api.feign.RemoteFlowEngineService;
@@ -25,8 +26,11 @@ import com.honeycombis.honeycom.flow.task.dto.*;
import com.honeycombis.honeycom.flow.task.entity.*;
import com.honeycombis.honeycom.flow.task.entity.Process;
import com.honeycombis.honeycom.flow.task.service.*;
import com.honeycombis.honeycom.msg.api.dto.MessageOpenApiDTO;
import com.honeycombis.honeycom.msg.api.feign.RemoteMessageService;
import com.honeycombis.honeycom.user.feign.HoneycomUserServiceFeign;
import com.honeycombis.honeycom.user.vo.SysUserVO;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@@ -64,6 +68,9 @@ public class RemoteServiceImpl implements IRemoteService {
private final RemoteSpdmService remoteSpdmService;
@Resource
private RemoteMessageService remoteMessageService;
private final IProcessNodeDataService iProcessNodeDataService;
@@ -385,7 +392,16 @@ public class RemoteServiceImpl implements IRemoteService {
*/
@Override
public R startAssignUser(ProcessNodeRecordAssignUserParamDto processNodeRecordAssignUserParamDto) {
return processNodeRecordAssignUserService.addAssignUser(processNodeRecordAssignUserParamDto);
processNodeRecordAssignUserService.addAssignUser(processNodeRecordAssignUserParamDto);
// 审批消息通知
Process process = processService.getByFlowId(processNodeRecordAssignUserParamDto.getFlowId());
MessageOpenApiDTO messageOpenApiDTO = new MessageOpenApiDTO();
messageOpenApiDTO.setTitle("审批消息通知");
messageOpenApiDTO.setContent("收到一条" + process.getName() + "审批任务代办,请前往任务中心-代办任务-流程任务审批");
messageOpenApiDTO.setStaffCode(String.valueOf(processNodeRecordAssignUserParamDto.getUserId()));
messageOpenApiDTO.setTenantCode(String.valueOf(TenantContextHolder.getTenantId()));
remoteMessageService.pushMessage(messageOpenApiDTO);
return R.ok();
}
/**

View File

@@ -33,8 +33,9 @@ public class MsgConfigDefaultData {
list.add(new MessageConfigAddDto(MsgConfigKeyType.MSG_CONFIG_KEY_MILESTONE_POSTPONE.getCode(),2,"里程碑延期通知","{%里程碑名称%}里程碑已延期,请点击查看详情",MsgRoleType.MSG_ROLE_PROJECT_MEMBERS.getCode(),2,"0,1","里程碑计划时间结束已到但关联任务仍未完成触发一条消息","1/DAY"));
list.add(new MessageConfigAddDto(MsgConfigKeyType.MSG_CONFIG_KEY_INVITE.getCode(),2,"邀请通知","{%租户名称%}邀请您加入",MsgRoleType.MSG_ROLE_INVITEES.getCode(),0,"0,1","点击发送邀请后受邀人接受一条消息",""));
list.add(new MessageConfigAddDto(MsgConfigKeyType.MSG_CONFIG_KEY_ORGANIZATIONAL_MESSAGES.getCode(),2,"组织消息","{%员工名称%}加入了{%部门名称%}",MsgRoleType.MSG_ROLE_ROLE_ADMIN.getCode(),0,"0,1","受邀人点击同意加入邀请公司后租户管理员收到一条消息",""));
list.add(new MessageConfigAddDto(MsgConfigKeyType.MSG_CONFIG_KEY_OPEN_API.getCode(),2,"消息标题","消息内容",MsgRoleType.MSG_ROLE_PROJECT_MEMBERS.getCode(),0,"0,1","第三方api调用发送消息",""));
list.add(new MessageConfigAddDto(MsgConfigKeyType.MSG_CONFIG_KEY_OPEN_API.getCode(),2,"消息标题","消息内容",MsgRoleType.MSG_ROLE_PROJECT_MEMBERS.getCode(),0,"0,1","第三方api调用发送消息",""))
;
return list;
}
}

View File

@@ -54,7 +54,8 @@ public enum MsgConfigKeyType {
MSG_CONFIG_KEY_INVITE("INVITE", "邀请", 4),
MSG_CONFIG_KEY_ORGANIZATIONAL_MESSAGES("ORGANIZATIONAL_MESSAGES", "组织消息", 4),
MSG_CONFIG_KEY_OPEN_API("OPEN_API_MESSAGE", "对外开放消息模板", 99),
MSG_CONFIG_KEY_ADD_NOTIFY("ADD_NOTIFY", "新增通知", 0);
MSG_CONFIG_KEY_ADD_NOTIFY("ADD_NOTIFY", "新增通知", 0),
MSG_CONFIG_KEY_APPROVE_NOTICE("APPROVE_NOTICE", "审批消息通知", 0);
private final String code;

View File

@@ -30,4 +30,7 @@ public class MessageListUserQueryDto {
*/
@Schema(description="是否已读0未读1已读2忽略")
private Integer isRead;
@Schema(description="消息标题")
private Integer msgTitle;
}

View File

@@ -17,4 +17,7 @@ public class MessageOpenApiDTO {
@Schema(description = "消息内容")
private String content;
@Schema(description = "业务id")
private String businessId;
}

View File

@@ -4,6 +4,7 @@ import com.honeycombis.honeycom.common.core.constant.SecurityConstants;
import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.msg.api.dto.MessageDeleteParamDTO;
import com.honeycombis.honeycom.msg.api.dto.MessageListBusinessAddDto;
import com.honeycombis.honeycom.msg.api.dto.MessageOpenApiDTO;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
@@ -31,4 +32,8 @@ public interface RemoteMessageService {
@PostMapping("/message/list/deleteMessageByParam" )
R<Boolean> deleteMessageByParam(@RequestBody MessageDeleteParamDTO messageDeleteParamDTO, @RequestHeader(SecurityConstants.FROM) String from);
@Operation(summary = "提供给外围系统发布消息通知", description = "提供给外围系统发布消息通知")
@PostMapping(value = "/openapi/push")
R<Object> pushMessage(@RequestBody MessageOpenApiDTO dto);
}

View File

@@ -4,6 +4,7 @@ import com.honeycombis.honeycom.common.core.exception.ErrorType;
import com.honeycombis.honeycom.common.core.exception.HoneycomException;
import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.common.log.annotation.SysLog;
import com.honeycombis.honeycom.common.security.annotation.Inner;
import com.honeycombis.honeycom.msg.api.dto.MessageListBusinessAddDto;
import com.honeycombis.honeycom.msg.api.dto.MessageOpenApiDTO;
import com.honeycombis.honeycom.msg.service.MessageListService;
@@ -34,6 +35,7 @@ public class MessageApiController {
@Operation(summary = "发布新消息", description = "发布新消息")
@SysLog("发布新消息")
@PostMapping(value = "/push")
@Inner(value = false)
public R<Object> addByConfigKey(@RequestBody MessageOpenApiDTO dto) {
if (StringUtils.isBlank(dto.getStaffCode())) {
log.error("用户ID不能为空");

View File

@@ -107,6 +107,7 @@ public class MessageListItemServiceImpl extends ServiceImpl<MessageListItemMappe
wrapper.lt(MessageListItemEntity::getSendTime, LocalDateTime.now());
wrapper.eq(Objects.nonNull(query.getMsgType()), MessageListItemEntity::getMsgType, query.getMsgType());
wrapper.eq(Objects.nonNull(query.getMsgCategory()), MessageListItemEntity::getMsgCategory, query.getMsgCategory());
wrapper.eq(Objects.nonNull(query.getMsgTitle()), MessageListItemEntity::getMsgTitle, query.getMsgTitle());
wrapper.and(a->a.eq(MessageListItemEntity::getTenantId, TenantContextHolder.getTenantId()).or().isNull(MessageListItemEntity::getTenantId));
// 已读未读查询条件过滤
wrapper.eq(Objects.nonNull(query.getIsRead()), MessageListItemEntity::getIsRead, query.getIsRead());

View File

@@ -357,6 +357,7 @@ public class MessageListServiceImpl extends ServiceImpl<MessageListMapper, Messa
messageListEntity.setStatus(MsgReleaseType.MSG_RELEASE_TYPE_READY_RELEASE.getCode());
messageListEntity.setMsgCategory(MsgConfigKeyType.getCategory(messageConfig.getConfigKey()));
messageListEntity.setSendTime(LocalDateTime.now());
messageListEntity.setBusinessId(dto.getBusinessId());
if (!this.save(messageListEntity)) {
log.error("新增消息列表:消息新增失败!");
throw new HoneycomException(MsgErrorType.MESSAGE_ADD_ERROR.getCode());

View File

@@ -61,6 +61,11 @@
<artifactId>honeycom-user-api</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>com.honeycombis</groupId>
<artifactId>honeycom-msg-api</artifactId>
<version>5.4.0</version>
</dependency>
<!--必备: 操作数据源相关-->
<!-- <dependency>-->
<!-- <groupId>com.honeycombis</groupId>-->

View File

@@ -21,8 +21,6 @@ package com.honeycombis.honeycom.spdm.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@@ -0,0 +1,56 @@
/*
*
* Copyright (c) 2018-2025, honeycom All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: honeycom
*
*/
package com.honeycombis.honeycom.spdm.controller;
import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.msg.api.dto.MessageOpenApiDTO;
import com.honeycombis.honeycom.spdm.dto.*;
import com.honeycombis.honeycom.spdm.feign.RemoteMsgServiceFeign;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@RestController
@AllArgsConstructor
@RequestMapping("/spdm-msg")
@Tag(description = "spdm", name = "提供给SPDM的流程模块")
@Slf4j
public class SpdmMsgController {
@Resource
private RemoteMsgServiceFeign remoteMsgServiceFeign;
@Operation(summary = "发起流程")
@PostMapping(value = "/sendMessage")
public R sendMessage(@RequestBody MessageDto messageDto) {
MessageOpenApiDTO messageOpenApiDTO = new MessageOpenApiDTO();
messageOpenApiDTO.setTitle(messageDto.getTitle());
messageOpenApiDTO.setContent(messageDto.getContent());
messageOpenApiDTO.setStaffCode(messageDto.getUserId());
messageOpenApiDTO.setTenantCode(messageDto.getTenantId());
return remoteMsgServiceFeign.pushMessage(messageOpenApiDTO, messageDto.getTenantId());
}
}

View File

@@ -0,0 +1,19 @@
package com.honeycombis.honeycom.spdm.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class MessageDto {
@Schema(description = "租户代码")
private String tenantId;
@Schema(description = "员工工号")
private String userId;
@Schema(description = "消息标题")
private String title;
@Schema(description = "消息内容")
private String content;
}

View File

@@ -0,0 +1,19 @@
package com.honeycombis.honeycom.spdm.feign;
import com.honeycombis.honeycom.common.core.constant.CommonConstants;
import com.honeycombis.honeycom.common.core.constant.ServiceNameConstants;
import com.honeycombis.honeycom.common.core.util.R;
import com.honeycombis.honeycom.common.feign.config.FeignConfig;
import com.honeycombis.honeycom.msg.api.dto.MessageOpenApiDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@FeignClient(contextId = "remoteMsgService", value = ServiceNameConstants.MSG_SERVICE, configuration = FeignConfig.class)
public interface RemoteMsgServiceFeign {
@PostMapping(value = "/openapi/push")
R<Object> pushMessage(@RequestBody MessageOpenApiDTO dto, @RequestHeader(CommonConstants.TENANT_ID) String tenantId);
}