|
@@ -0,0 +1,72 @@
|
|
|
+package com.rongwei.safecommon.utils;
|
|
|
+
|
|
|
+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 com.rongwei.safecommon.fegin.CXCommonFeginClient;
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * CXCommonUtils class
|
|
|
+ *
|
|
|
+ * @author XH
|
|
|
+ * @date 2023/12/15
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class CXCommonUtils {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(CXCommonUtils.class.getName());
|
|
|
+ @Autowired
|
|
|
+ private RedisService autoRedisService;
|
|
|
+ @Autowired
|
|
|
+ private CXCommonFeginClient autoCommonFeginClient;
|
|
|
+ private static RedisService redisService;
|
|
|
+
|
|
|
+ private static CXCommonFeginClient commonFeginClient;
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void info(){
|
|
|
+ redisService = autoRedisService;
|
|
|
+ commonFeginClient = autoCommonFeginClient;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送通知信息
|
|
|
+ */
|
|
|
+ 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) {
|
|
|
+ if (recipientIds == null || recipientIds.isEmpty()) {
|
|
|
+ log.debug("接收人ID为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SysNotifyAnnounceVo sysNotifyAnnounceVo = new SysNotifyAnnounceVo();
|
|
|
+ sysNotifyAnnounceVo.setId(SecurityUtil.getUUID());
|
|
|
+ sysNotifyAnnounceVo.setSenderid("8672bf72ab274bec83052868ae336b38");
|
|
|
+ sysNotifyAnnounceVo.setNotifytype("notify");
|
|
|
+ sysNotifyAnnounceVo.setNotifystatus("3");
|
|
|
+ sysNotifyAnnounceVo.setNotifytitle(title);
|
|
|
+ sysNotifyAnnounceVo.setNotifycontent(content);
|
|
|
+ sysNotifyAnnounceVo.setRemark(remark);
|
|
|
+ // 特殊处理
|
|
|
+ if (StringUtils.isNotBlank(roption)) {
|
|
|
+ sysNotifyAnnounceVo.setRoption(roption);
|
|
|
+ }
|
|
|
+ sysNotifyAnnounceVo.setUserid(recipientIds.stream().distinct().collect(Collectors.joining(",")));
|
|
|
+ log.debug("开始通过fegin发送消息通知: {}", sysNotifyAnnounceVo);
|
|
|
+ commonFeginClient.sendNotify(sysNotifyAnnounceVo);
|
|
|
+ }
|
|
|
+}
|