Browse Source

群发消息,群内@所有人功能开发

luolinsong 2 weeks ago
parent
commit
d5352a9436

+ 18 - 0
fs-ipad-task/src/main/java/com/fs/app/service/IpadSendServer.java

@@ -29,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -171,6 +172,19 @@ public class IpadSendServer {
         }
     }
 
+    public void sendTxtAtMsg(BaseVo vo) {
+        WxSendTextAtMsgTwoDTO dto = new WxSendTextAtMsgTwoDTO();
+        List<WxSendTextAtMsgTwoDTO.Contentva> contentvaList = new ArrayList<>();
+        WxSendTextAtMsgTwoDTO.Contentva contentva = new WxSendTextAtMsgTwoDTO.Contentva();
+        contentva.setMsgtype(5);
+        contentva.setVid(0);
+        contentvaList.add(contentva);
+        dto.setContentva(contentvaList);
+        dto.setBase(vo);
+        dto.setSend_userid(ipadSendUtils.userIds(vo));
+       ipadSendUtils.sendTxtAtMsgVo(dto, vo.getServerId());
+    }
+
     public void sendVoice(BaseVo vo, QwSopCourseFinishTempSetting.Setting content) {
         if (StringUtils.isEmpty(content.getVoiceUrl()) || StringUtils.isEmpty(content.getVoiceDuration())) {
             log.debug("语音未生成无法发送,转文字发送:{}", vo);
@@ -375,6 +389,10 @@ public class IpadSendServer {
                     // 语音
                     sendWxVideo(vo, content);
                     break;
+                case "99":
+                    // 群发
+                    sendTxtAtMsg(vo);
+                    break;
                 default:
                     // 未知类型,记录警告
                     log.error("SOP_LOG_ID:{}错误的发送类型: {}", qwSopLogs.getId(), content.getContentType());

+ 8 - 1
fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopLogsTaskServiceImpl.java

@@ -652,6 +652,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
             content.setVideoId(e.getVideoId());
             content.setCourseType(e.getCourseType());
             content.setAiTouch(e.getAiTouch());
+            content.setIsAtAll(e.getIsAtAll());
             return content;
         }).sorted(Comparator.comparing(e -> LocalTime.parse(e.getTime() + ":00"))).peek(e -> e.setIndex(i.getAndIncrement())).collect(Collectors.toList());
     }
@@ -929,7 +930,13 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
             log.error("Cloned content settings are empty, skipping.");
             return;
         }
-
+        log.info("测试数据:{}",content.getIsAtAll());
+        //如果是@所有人,就添加
+        if (1 == content.getIsAtAll()) {
+            QwSopTempSetting.Content.Setting atMsg = new QwSopTempSetting.Content.Setting();
+            atMsg.setContentType("99");
+            settings.add(atMsg);
+        }
         // 顺序处理每个 Setting,避免过多的并行导致线程开销
         for (QwSopTempSetting.Content.Setting setting : settings) {
             switch (setting.getContentType()) {

+ 7 - 1
fs-service/src/main/java/com/fs/ipad/IpadSendUtils.java

@@ -197,7 +197,7 @@ public class IpadSendUtils {
      * @param vo 调用接口参数
      * @return 返回的userid
      */
-    private Long userIds(BaseVo vo){
+    public Long userIds(BaseVo vo){
         if(vo.isRoom()){
             return chatIds(vo);
         }
@@ -406,4 +406,10 @@ public class IpadSendUtils {
         log.info("发送返回数据:{}", result);
         if(result.getErrcode() != 0) throw new BaseException("发送消息错误:" + result.getErrmsg());
     }
+
+    public void sendTxtAtMsgVo(WxSendTextAtMsgTwoDTO dto, Long serverId){
+        WxWorkResponseDTO<WxSendTextAtMsgVo> result = wxWorkService.sendTextAtMsgTwo(dto, serverId);
+        log.info("发送@所有人返回数据:{}", result);
+        if(result.getErrcode() != 0) throw new BaseException("发送@所有人消息错误:" + result.getErrmsg());
+    }
 }

+ 31 - 0
fs-service/src/main/java/com/fs/ipad/vo/WxSendTextAtMsgVo.java

@@ -0,0 +1,31 @@
+package com.fs.ipad.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+
+@Data
+public class WxSendTextAtMsgVo {
+
+    private Long receiver;
+    private Long sender;
+    private List<atList> at_list;
+    private String sender_name;
+    private Long room_conversation_id;
+    private Integer is_room;
+    private Integer sendtime;
+    private Long msg_id;
+    private Long server_id;
+    private Long msgtype;
+    private String content;
+
+    @Data
+    public class atList {
+        private Long user_id;
+        private String nikeName;
+
+    }
+}
+
+

+ 1 - 1
fs-service/src/main/java/com/fs/qw/vo/QwSopTempSetting.java

@@ -44,7 +44,7 @@ public class QwSopTempSetting implements Serializable{
         private String addTag;
 
         private String delTag;
-
+        private Integer isAtAll;
         @Override
         public Content clone() {
             try {

+ 2 - 0
fs-service/src/main/java/com/fs/sop/domain/QwSopTempRules.java

@@ -80,4 +80,6 @@ public class QwSopTempRules{
     private Integer dayNum;
     @TableField(exist = false)
     private FsUserCourseVideoRedPackage red;
+    /**是否@所有人  1是0否**/
+    private Integer isAtAll;
 }

+ 46 - 0
fs-service/src/main/java/com/fs/wxwork/dto/WxSendTextAtMsgTwoDTO.java

@@ -0,0 +1,46 @@
+package com.fs.wxwork.dto;
+
+import com.fs.ipad.vo.BaseVo;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class WxSendTextAtMsgTwoDTO extends BaseVo {
+    /**
+     * 消息的唯一标识符 (UUID)
+     */
+    private String uuid;
+
+    /**
+     * 要发送的人或群id
+     */
+    private Long send_userid;
+
+    /**
+     * 发送者用户 ID
+     */
+    private List<Contentva> contentva;
+    /**
+     * 是否为群组消息
+     * <p>
+     * true: 群组消息; false: 单聊消息
+     * </p>
+     */
+    private Boolean isRoom;
+
+    @Data
+    public static class Contentva {
+        private Integer msgtype;
+        private String content;
+        /**
+         * "msgtype":5,//@类型
+         * "vid":0 //填0就是所有人
+         * <p>
+         * "msgtype":5, //就是@人的类型
+         * "vid":788130xx38 //@人id
+         */
+        private Integer vid;
+    }
+
+}

+ 6 - 0
fs-service/src/main/java/com/fs/wxwork/service/WxWorkServiceNew.java

@@ -9,6 +9,7 @@ import com.fs.ipad.param.WxSendAtMsgParam;
 import com.fs.ipad.vo.WxGetSessionRoomListVo;
 import com.fs.ipad.vo.WxRoomUserListVo;
 import com.fs.ipad.vo.WxSendAtMsgVo;
+import com.fs.ipad.vo.WxSendTextAtMsgVo;
 import com.fs.qw.domain.QwIpadServer;
 import com.fs.qw.service.IQwIpadServerService;
 import com.fs.wxwork.dto.*;
@@ -221,4 +222,9 @@ public class WxWorkServiceNew {
         String url = getUrl(serverId) + "/SendTextAtMsg";
         return WxWorkHttpUtil.postWithType(url, param, new TypeReference<WxWorkResponseDTO<WxSendAtMsgVo>>() {});
     }
+
+    public WxWorkResponseDTO<WxSendTextAtMsgVo> sendTextAtMsgTwo(WxSendTextAtMsgTwoDTO param, Long serverId) {
+        String url = getUrl(serverId) + "/SendTextAtMsgTwo";
+        return WxWorkHttpUtil.postWithType(url, param, new TypeReference<WxWorkResponseDTO<WxSendTextAtMsgVo>>() {});
+    }
 }