|
@@ -0,0 +1,90 @@
|
|
|
+package com.rongwei.bscommon.sys.utils;
|
|
|
+
|
|
|
+import com.rongwei.bscommon.sys.feign.KnowledgeCommonFeginClient;
|
|
|
+import com.rongwei.commonservice.serial.service.SysSerialNumberService;
|
|
|
+import com.rongwei.commonservice.service.RedisService;
|
|
|
+import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
+import com.rongwei.rwcommonentity.commonservers.vo.SysNotifyAnnounceVo;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class KnowledgeSystemUtils {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(KnowledgeSystemUtils.class.getName());
|
|
|
+ @Autowired
|
|
|
+ private RedisService autoRedisService;
|
|
|
+ @Autowired
|
|
|
+ private KnowledgeCommonFeginClient autoKnowledgeCommonFeginClient;
|
|
|
+ @Autowired
|
|
|
+ private SysSerialNumberService autoSysSerialNumberService;
|
|
|
+
|
|
|
+ private static SysSerialNumberService sysSerialNumberService;
|
|
|
+
|
|
|
+ private static RedisService redisService;
|
|
|
+
|
|
|
+ private static KnowledgeCommonFeginClient knowledgeCommonFeginClient;
|
|
|
+ public static final String DEFAULT_NOTIFY_STATUS = "3";
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void info() {
|
|
|
+ redisService = autoRedisService;
|
|
|
+ knowledgeCommonFeginClient = autoKnowledgeCommonFeginClient;
|
|
|
+ sysSerialNumberService = autoSysSerialNumberService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送通知信息
|
|
|
+ */
|
|
|
+ public static void sendNotify(String title, String content, String remark, List<String> recipientIds) {
|
|
|
+ sendNotify(title, content, remark, recipientIds, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送通知信息
|
|
|
+ */
|
|
|
+ public static void sendNotify(String title, String content, String remark,
|
|
|
+ List<String> recipientIds, String roption) {
|
|
|
+ sendNotify(title, content, remark, recipientIds, roption, DEFAULT_NOTIFY_STATUS);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送通知信息
|
|
|
+ * @param title 标题
|
|
|
+ * @param content 内容
|
|
|
+ * @param remark 备注
|
|
|
+ * @param recipientIds 接收人
|
|
|
+ * @param roption 主键ID
|
|
|
+ * @param notifyStatus 通知类型
|
|
|
+ */
|
|
|
+ public static void sendNotify(String title, String content, String remark,
|
|
|
+ List<String> recipientIds, String roption, String notifyStatus) {
|
|
|
+ if (recipientIds == null || recipientIds.isEmpty()) {
|
|
|
+ log.debug("接收人ID为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SysNotifyAnnounceVo sysNotifyAnnounceVo = new SysNotifyAnnounceVo();
|
|
|
+ sysNotifyAnnounceVo.setId(SecurityUtil.getUUID());
|
|
|
+ sysNotifyAnnounceVo.setSenderid("8672bf72ab274bec83052868ae336b38");
|
|
|
+ sysNotifyAnnounceVo.setNotifytype(notifyStatus);
|
|
|
+ sysNotifyAnnounceVo.setNotifystatus(DEFAULT_NOTIFY_STATUS);
|
|
|
+ sysNotifyAnnounceVo.setNotifytitle(title);
|
|
|
+ sysNotifyAnnounceVo.setNotifycontent(content.replace("null"," "));
|
|
|
+ sysNotifyAnnounceVo.setRemark(remark);
|
|
|
+ // 特殊处理
|
|
|
+ if (StringUtils.isNotBlank(roption)) {
|
|
|
+ sysNotifyAnnounceVo.setRoption(roption);
|
|
|
+ }
|
|
|
+ sysNotifyAnnounceVo.setUserid(recipientIds.stream().distinct().collect(Collectors.joining(",")));
|
|
|
+ log.debug("开始通过fegin发送消息通知: {}", sysNotifyAnnounceVo);
|
|
|
+ knowledgeCommonFeginClient.sendNotify(sysNotifyAnnounceVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|