xw 21 часов назад
Родитель
Сommit
88c6c5500e

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

@@ -1,6 +1,7 @@
 package com.fs.app.service;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fs.common.core.redis.RedisCache;
@@ -204,6 +205,52 @@ public class IpadSendServer {
         }
     }
 
+    /**
+     * 个微 SOP 的 contentJson 中每条消息可能来自 {@link com.fs.sop.domain.QwSopTempContent},
+     * 业务字段在 {@code content} 嵌套 JSON 里;未合并时 fileUrl/fileName 为空,
+     * 发送文件会退回用 URL 路径名(如 1775377962733.xlsx)作为展示名。
+     */
+    private void applyNestedContentIfPresent(QwSopCourseFinishTempSetting.Setting content) {
+        if (content == null || StringUtils.isEmpty(content.getContent())) {
+            return;
+        }
+        try {
+            JSONObject inner = JSON.parseObject(content.getContent());
+            if (inner == null || inner.isEmpty()) {
+                return;
+            }
+            if (StringUtils.isEmpty(content.getFileUrl()) && StringUtils.isNotEmpty(inner.getString("fileUrl"))) {
+                content.setFileUrl(inner.getString("fileUrl"));
+            }
+            if (StringUtils.isEmpty(content.getFileName())) {
+                String fn = inner.getString("fileName");
+                if (StringUtils.isEmpty(fn)) {
+                    fn = inner.getString("value");
+                }
+                if (StringUtils.isNotEmpty(fn)) {
+                    content.setFileName(fn);
+                }
+            }
+            if (StringUtils.isEmpty(content.getImgUrl()) && StringUtils.isNotEmpty(inner.getString("imgUrl"))) {
+                content.setImgUrl(inner.getString("imgUrl"));
+            }
+            if (StringUtils.isEmpty(content.getVideoUrl()) && StringUtils.isNotEmpty(inner.getString("videoUrl"))) {
+                content.setVideoUrl(inner.getString("videoUrl"));
+            }
+            if (StringUtils.isEmpty(content.getVoiceUrl()) && StringUtils.isNotEmpty(inner.getString("voiceUrl"))) {
+                content.setVoiceUrl(inner.getString("voiceUrl"));
+            }
+            if (StringUtils.isEmpty(content.getValue()) && StringUtils.isNotEmpty(inner.getString("value"))) {
+                content.setValue(inner.getString("value"));
+            }
+            if (StringUtils.isEmpty(content.getContentType()) && inner.get("contentType") != null) {
+                content.setContentType(String.valueOf(inner.get("contentType")));
+            }
+        } catch (Exception e) {
+            log.warn("applyNestedContentIfPresent parse failed: {}", e.getMessage());
+        }
+    }
+
     private void sendFile(BaseVo vo, QwSopCourseFinishTempSetting.Setting content) {
         FileVo fileVo = FileVo.builder()
                 .url(content.getFileUrl())
@@ -685,6 +732,7 @@ public class IpadSendServer {
         vo.setQwUserId(qwUser.getId());
         try {
             content.setSendStatus(1);
+            applyNestedContentIfPresent(content);
             // 如果是群公告,使用SendNotice接口
             if (qwSopLogs.getSendType() == 21 && "11".equals(content.getContentType())) {
                 sendNotice(vo, content);

+ 6 - 0
fs-service/src/main/java/com/fs/qw/vo/QwSopCourseFinishTempSetting.java

@@ -140,6 +140,12 @@ public class QwSopCourseFinishTempSetting implements Serializable,Cloneable{
 
         private String articleUrl;
 
+        /**
+         * 模板表 qw_sop_temp_content 中存储的整段 JSON 字符串(个微 SOP 生成日志时会原样带入)。
+         * 真实 fileUrl、展示用文件名等多在该嵌套串中,发送前需合并到本对象扁平字段。
+         */
+        private String content;
+
         @Override
         public Setting clone() {
             try {