Selaa lähdekoodia

file整合bs-common,统一发送通知,之后走websocket推送app消息

sucheng 1 vuosi sitten
vanhempi
commit
1c59e97167

+ 5 - 3
bs-common/src/main/java/com/rongwei/safecommon/fegin/CXCommonFeginClient.java

@@ -3,12 +3,11 @@ package com.rongwei.safecommon.fegin;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.vo.MailDo;
 import com.rongwei.rwcommonentity.commonservers.vo.SysNotifyAnnounceVo;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
 import org.springframework.scheduling.annotation.Async;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 @FeignClient(value = "rw-common-server",fallback = CXHysitx.class,contextId = "commonFeign")
@@ -19,4 +18,7 @@ public interface CXCommonFeginClient {
 
     @PostMapping("/mail/sendHtmlMail")
     R sendHtmlMail(@RequestBody MailDo Mail);
+
+    @PostMapping("ws/socket/push/app")
+    R pushToWeb(@RequestParam String cid, @RequestParam(required = false) String message);
 }

+ 6 - 0
bs-common/src/main/java/com/rongwei/safecommon/fegin/CXHysitx.java

@@ -28,4 +28,10 @@ public class CXHysitx implements CXCommonFeginClient {
         log.error("邮件发送失败,数据为{}",mailDo);
         return R.error();
     }
+
+    @Override
+    public R pushToWeb(String cid, String message) {
+        log.error("发送websocket通知失败!通知内容为:{}", message);
+        return R.error();
+    }
 }

+ 8 - 0
bs-common/src/main/java/com/rongwei/safecommon/utils/CXCommonUtils.java

@@ -1,5 +1,6 @@
 package com.rongwei.safecommon.utils;
 
+import com.alibaba.fastjson.JSONObject;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
 import com.rongwei.commonservice.service.RedisService;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
@@ -102,6 +103,13 @@ public class CXCommonUtils {
         sysNotifyAnnounceVo.setUserid(recipientIds.stream().distinct().collect(Collectors.joining(",")));
         log.debug("开始通过fegin发送消息通知: {}", sysNotifyAnnounceVo);
         commonFeginClient.sendNotify(sysNotifyAnnounceVo);
+
+        //推送websocket消息给app
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("title", title);
+        jsonObject.put("content", content);
+        jsonObject.put("userIds", recipientIds);
+        commonFeginClient.pushToWeb("app", jsonObject.toJSONString());
     }
 
 

+ 3 - 1
cx-file/cx-file-common/src/main/java/com/rongwei/bscommon/sys/utils/FileSystemUtils.java

@@ -6,6 +6,7 @@ import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.rwcommonentity.commonservers.vo.SysNotifyAnnounceVo;
+import com.rongwei.safecommon.utils.CXCommonUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -86,7 +87,8 @@ public class FileSystemUtils {
 //        sysNotifyAnnounceVo.setCreatedate(new Date());
         sysNotifyAnnounceVo.setUserid(recipientIds.stream().distinct().collect(Collectors.joining(",")));
         log.debug("开始通过fegin发送消息通知: {}", sysNotifyAnnounceVo);
-        commonFeginClient.sendNotify(sysNotifyAnnounceVo);
+        CXCommonUtils.sendNotify(sysNotifyAnnounceVo.getTitle(), sysNotifyAnnounceVo.getNotifycontent(), sysNotifyAnnounceVo.getRemark(), recipientIds, sysNotifyAnnounceVo.getRoption(), sysNotifyAnnounceVo.getNotifystatus());
+//        commonFeginClient.sendNotify(sysNotifyAnnounceVo);
     }
 
 

+ 7 - 0
cx-file/cx-file-server/src/main/java/com/rongwei/BusinessServerApplication.java

@@ -1,10 +1,13 @@
 package com.rongwei;
 
+import com.rongwei.safecommon.config.BsMetaObjectHandler;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
 import org.springframework.scheduling.annotation.EnableAsync;
 
 @EnableAsync
@@ -12,6 +15,10 @@ import org.springframework.scheduling.annotation.EnableAsync;
 @EnableDiscoveryClient
 @EnableFeignClients
 @MapperScan("com.rongwei.*.*.dao")
+//排除bean,防止bs-common中的BsMetaObjectHandler和rw-common-config中的重复
+@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = BsMetaObjectHandler.class)})
+
+
 public class BusinessServerApplication {
 
     public static void main(String[] args) {

+ 5 - 0
cx-file/pom.xml

@@ -57,6 +57,11 @@
             <artifactId>aspose-words</artifactId>
             <version>21.1</version>
         </dependency>
+        <dependency>
+            <groupId>com.rongwei</groupId>
+            <artifactId>bs-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
     <repositories>