提交 61026bc9 作者: 925993793@qq.com

新版事件分析功能开发:大模型配置、ppt导出等

上级 2b32b387
......@@ -16,6 +16,7 @@ public class Constants {
public static final String SUBJECT_ANALYSIS_PRE = "SUBJECT_ANALYSIS::";
//传播路径
public static final String PROPAGATION_KEY = "PROPAGATION_PATH::";
public static final String CO_OCCURRENCE = "CO_OCCURRENCE::";
public static String[] FETCH_FIELDS_STATISTIC = {"id", "subjectId","title","origin", "publishDate", "sourceAddress"};
public static String[] FETCH_FIELDS_DATA = {"id", "subjectId", "title", "content", "publishDate", "origin", "sourceAddress"};
......
package com.zzsn.event.controller;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -35,7 +34,6 @@ import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.CompletableFuture;
......@@ -311,7 +309,7 @@ public class EventManageController {
/**
* 1.7 发布
* 发布
*
* @return
*/
......@@ -325,6 +323,20 @@ public class EventManageController {
return Result.OK();
}
/**
* 审核公开状态
*
* @param event 参数
* @author lkg
* @date 2025/7/22
*/
@PostMapping(value = "/checkFacePublic")
public Result<?> checkFacePublic(@RequestBody Event event) {
eventService.update(Wrappers.<Event>lambdaUpdate().eq(Event::getId, event.getId())
.set(Event::getFacePublic, event.getFacePublic()));
return Result.OK();
}
/**
......
......@@ -22,14 +22,12 @@ import com.zzsn.event.service.*;
import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......
......@@ -11,11 +11,9 @@ import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.KeyWords;
import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.EventSimpleService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IKeyWordsService;
import com.zzsn.event.service.InformationService;
import com.zzsn.event.service.*;
import com.zzsn.event.service.impl.ConfigurationMessageService;
import com.zzsn.event.util.*;
import com.zzsn.event.util.user.UserUtil;
......@@ -37,6 +35,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* 事件
......@@ -72,6 +71,8 @@ public class EventDataController {
private EsOpUtil esOpUtil;
@Autowired
private ObsUtil obsUtil;
@Autowired
private SysDictItemService dictItemService;
@Value("${translate.url:}")
private String TRANSLATE_URL;
......@@ -415,6 +416,14 @@ public class EventDataController {
}
@GetMapping("/labelList")
public Result<?> labelList(){
List<SysDictItem> dictItemList = dictItemService.listByDictCode("eventView");
List<SysDictItem> collect = dictItemList.stream().filter(e -> !e.getItemText().equals("无观点")).collect(Collectors.toList());
return Result.OK(collect);
}
/**
* 事件资讯分页列表
*
......@@ -441,8 +450,7 @@ public class EventDataController {
@RequestParam(name = "column", defaultValue = "publishDate") String column,
@RequestParam(name = "order", defaultValue = "desc") String order,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest request) {
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
UserVo currentUser = UserUtil.getLoginUser();
String username = currentUser.getUsername();
List<String> subjectIdList = new ArrayList<>();
......
package com.zzsn.event.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 事件大模型信息配置表
* @TableName event_llm_config
*/
@Data
@TableName("event_llm_config")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class EventLlmConfig implements Serializable {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 事件id
*/
private String eventId;
/**
* 栏目编码
*/
private Integer columnCode;
/**
* 栏目名称
*/
private String columnName;
/**
* 大模型
*/
private String llmName;
/**
* 角色
*/
private String llmRole;
/**
* 提示词
*/
private String llmPrompt;
/**
* 资讯筛选条件
*/
private String articleCondition;
/**
* 是否默认(1-是;0-否)
*/
private Integer ynDefault;
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}
......@@ -33,6 +33,10 @@ public enum AnalysisColumnEnum {
FOREIGN_SIMILAR_EVENT(11,"各国类似事件","array", 1),
//GENERATE_OUTLINE(12,"生成大纲","array", 1),
//GENERATE_PPT(13,"生成ppt","array", 1),
;
//栏目编码
......@@ -76,4 +80,13 @@ public enum AnalysisColumnEnum {
}
return list;
}
public static AnalysisColumnEnum getByCode(Integer code) {
for (AnalysisColumnEnum value : AnalysisColumnEnum.values()) {
if (value.code.equals(code)) {
return value;
}
}
return null;
}
}
package com.zzsn.event.llm;
import cn.hutool.http.HttpException;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -41,6 +46,18 @@ public class LlmServiceImpl implements LlmService {
@Value("${model.qwen.apiKey:}")
private String QWEN_APIKEY;
@Value("${model.deepseek.url:}")
private String DEEP_SEEK_URL;
@Value("${model.deepseek.api-key:}")
private String DEEP_SEEK_APIKEY;
@Value("${model.doubao.url:}")
private String DOU_BAO_URL;
@Value("${model.doubao.api-key:}")
private String DOU_BAO_APIKEY;
@Value("${model.doubao.default-model:}")
private String DOU_BAO_MODEL;
@Override
public String model(String model, String system, String content) {
if (StringUtils.isNotEmpty(model)) {
......@@ -48,6 +65,10 @@ public class LlmServiceImpl implements LlmService {
return glmModel(model.replace("glm:", ""), system, content);
} else if (model.startsWith("qwen")) {
return qwenModel(model.replace("qwen:", ""), system, content);
} else if (model.startsWith("deepseek")) {
return deepSeekModel(system, content);
} else if (model.startsWith("doubao")) {
return douBaoModel(system, content);
}
}
//默认调用模型
......@@ -120,7 +141,65 @@ public class LlmServiceImpl implements LlmService {
return "";
}
public String glmPost(String urlstr, JSONObject jsonObject) {
public String deepSeekModel(String system, String content) {
try {
Map<String, Object> params = new HashMap<>();
params.put("model", "deepseek-chat");
params.put("stream", false);
Message systemMsg = Message.builder()
.role(Role.SYSTEM.getValue())
.content(system)
.build();
Message userMsg = Message.builder()
.role(Role.USER.getValue())
.content(content)
.build();
List<Message> messages = Arrays.asList(systemMsg, userMsg);
params.put("messages", messages);
HttpResponse execute = HttpUtil.createPost(DEEP_SEEK_URL)
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + DEEP_SEEK_APIKEY)
.body(JSONUtil.toJsonStr(params))
.execute();
return execute.body();
} catch (HttpException e) {
log.error("deepseek error:{}", e.getMessage(), e);
}
return null;
}
public String douBaoModel(String system, String content) {
try {
Map<String, Object> params = new HashMap<>();
params.put("model", DOU_BAO_MODEL);
Message systemMsg = Message.builder()
.role(Role.SYSTEM.getValue())
.content(system)
.build();
Message userMsg = Message.builder()
.role(Role.USER.getValue())
.content(content)
.build();
List<Message> messages = Arrays.asList(systemMsg, userMsg);
params.put("messages", messages);
HttpResponse execute = HttpUtil.createPost(DOU_BAO_URL)
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + DOU_BAO_APIKEY)
.body(JSONUtil.toJsonStr(params))
.execute();
String body = execute.body();
JSONObject jsonObject = JSONObject.parseObject(body);
JSONArray choices = jsonObject.getJSONArray("choices");
JSONObject choice = choices.getJSONObject(0);
JSONObject message = choice.getJSONObject("message");
return message.getString("content");
} catch (HttpException e) {
log.error("doubao error:{}", e.getMessage(), e);
}
return null;
}
private String glmPost(String urlstr, JSONObject jsonObject) {
String responseStr = null;
try {
URL url = new URL(urlstr);
......
package com.zzsn.event.mapper;
import com.zzsn.event.entity.EventLlmConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lenovo
* @description 针对表【event_llm_config(事件大模型信息配置表)】的数据库操作Mapper
* @createDate 2025-07-21 14:17:40
* @Entity com.zzsn.event.entity.EventLlmConfig
*/
@Mapper
public interface EventLlmConfigMapper extends BaseMapper<EventLlmConfig> {
}
......@@ -352,7 +352,6 @@
order by t1.publish_date desc
</otherwise>
</choose>
limit #{offset}, #{pageSize}
</select>
......
package com.zzsn.event.service;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.zzsn.event.entity.EventLlmConfig;
import com.zzsn.event.entity.SubjectAnalysis;
import com.zzsn.event.vo.CoOccurrenceVO;
import com.zzsn.event.vo.CountVO;
......@@ -53,9 +55,9 @@ public interface AnalysisService {
/**
* 关键词时间趋势
*
* @param eventId 事件id
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/9
*/
......@@ -64,9 +66,9 @@ public interface AnalysisService {
/**
* 关键词共现
*
* @param eventId 事件id
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/9
*/
......@@ -81,88 +83,34 @@ public interface AnalysisService {
PropagationPathVo propagationPath(String eventId);
/**
* 影响评估
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/17
*/
Object impactAssessment(String eventId,String startTime,String endTime);
/**
* 决策建议
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/17
*/
Object measureSuggest(String eventId,String startTime,String endTime);
/**
* 知识词条
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/17
*/
Object knowledgeEntry(String eventId,String startTime,String endTime);
/**
* 企业案例
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/17
*/
Object enterpriseCase(String eventId,String startTime,String endTime);
/**
* 各国政策
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/17
*/
Object countryPolicy(String eventId,String startTime,String endTime);
/**
* 本国类似事件
* 利用大模型生成的结果
*
* @param eventId 事件id
* @param eventName 事件名称
* @param startTime 开始时间
* @param endTime 结束时间
* @param endTime 结束时间
* @param llmConfig 模型配置信息
* @author lkg
* @date 2025/7/17
*/
Object domesticSimilarEvent(String eventId,String startTime,String endTime);
String llmResult(String eventName, String startTime, String endTime, EventLlmConfig llmConfig);
String llmResult(String eventId, String startTime, String endTime, Integer columnCode);
/**
* 各国类似事件
* 重新生成
*
* @param eventId 事件id
* @param startTime 开始时间
* @param endTime 结束时间
* @author lkg
* @date 2025/7/17
* @date 2025/7/7
*/
Object foreignSimilarEvent(String eventId,String startTime,String endTime);
void regenerate(String eventId);
/**
* 重新生成
* 导出ppt
*
* @param eventId 事件id
* @param content 导出内容
* @author lkg
* @date 2025/7/7
* @date 2025/7/19
*/
void regenerate(String eventId);
String exportPPT(String eventId, JSONArray content);
}
package com.zzsn.event.service;
import com.zzsn.event.entity.EventLlmConfig;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @author lenovo
* @description 针对表【event_llm_config(事件大模型信息配置表)】的数据库操作Service
* @createDate 2025-07-21 14:17:40
*/
public interface EventLlmConfigService extends IService<EventLlmConfig> {
List<EventLlmConfig> getConfigList(String eventId);
EventLlmConfig getConfig(String eventId,Integer columnCode);
}
package com.zzsn.event.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.EventLlmConfig;
import com.zzsn.event.service.EventLlmConfigService;
import com.zzsn.event.mapper.EventLlmConfigMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author lenovo
* @description 针对表【event_llm_config(事件大模型信息配置表)】的数据库操作Service实现
* @createDate 2025-07-21 14:17:40
*/
@Service
public class EventLlmConfigServiceImpl extends ServiceImpl<EventLlmConfigMapper, EventLlmConfig> implements EventLlmConfigService{
@Override
public List<EventLlmConfig> getConfigList(String eventId) {
LambdaQueryWrapper<EventLlmConfig> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(EventLlmConfig::getEventId, eventId).orderByAsc(EventLlmConfig::getColumnCode);
List<EventLlmConfig> configList = this.list(queryWrapper);
if (CollectionUtils.isEmpty(configList)) {
LambdaQueryWrapper<EventLlmConfig> query = Wrappers.lambdaQuery();
query.eq(EventLlmConfig::getYnDefault, 1).orderByAsc(EventLlmConfig::getColumnCode);
configList = this.list(query);
}
return configList;
}
@Override
public EventLlmConfig getConfig(String eventId, Integer columnCode) {
LambdaQueryWrapper<EventLlmConfig> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(EventLlmConfig::getEventId, eventId).eq(EventLlmConfig::getColumnCode, columnCode);
EventLlmConfig config = this.getOne(queryWrapper);
if (ObjectUtils.isNull(config)) {
LambdaQueryWrapper<EventLlmConfig> query = Wrappers.lambdaQuery();
query.eq(EventLlmConfig::getYnDefault, 1).eq(EventLlmConfig::getColumnCode, columnCode);
config = this.getOne(query);
}
return config;
}
}
......@@ -64,7 +64,7 @@ public class AnalysisTask {
* @author lkg
* @date 2025/7/9
*/
@Scheduled(cron = "0 0 0/3 * * ?")
//@Scheduled(cron = "0 0 0/3 * * ?")
public void eventContext() {
Date today = new Date();
Date disableDate = DateUtil.addDate(today, -1);
......
package com.zzsn.event.task;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.service.AnalysisService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.vo.CoOccurrenceVO;
import com.zzsn.event.vo.SubjectKafkaVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 热词共现数据缓存
*
* @author lkg
* @date 2025/7/22
*/
@Slf4j
@Component
public class CoOccurrenceTask {
@Autowired
private IEventService eventService;
@Autowired
private RedisUtil redisUtil;
@Autowired
private AnalysisService analysisService;
/**
* 定时缓存热词共现关系数据
* 每天凌晨1点执行一次
*/
@Scheduled(cron = "0 0 1 * * ?")
public void propagationPath() {
Date today = new Date();
Date deadlineDate = DateUtil.addDate(today, -1);
List<SubjectKafkaVo> events = eventService.eventSubjectList();
for (SubjectKafkaVo event : events) {
CompletableFuture.runAsync(() -> {
String eventId = event.getId();
String key = Constants.SUBJECT_ANALYSIS_PRE + Constants.CO_OCCURRENCE + eventId;
Date timeDisable = event.getTimeDisable();
if (timeDisable != null && deadlineDate.compareTo(timeDisable) > 0) {
Object cacheObject = redisUtil.get(key);
if (cacheObject == null) {
List<CoOccurrenceVO> occurrenceList = analysisService.coOccurrence(eventId, null, null);
if (CollectionUtils.isNotEmpty(occurrenceList)) {
redisUtil.set(key, occurrenceList);
log.info("专题-{},热词共现关系数据【永久】缓存成功!", event.getSubjectName());
}
}
} else {
List<CoOccurrenceVO> occurrenceList = analysisService.coOccurrence(eventId, null, null);
if (CollectionUtils.isNotEmpty(occurrenceList)) {
redisUtil.set(key, occurrenceList, 3600 * 24);
log.info("专题-{},热词共现关系数据缓存成功!", event.getSubjectName());
}
}
});
}
}
}
package com.zzsn.event.util.ppt;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class ApiAuthAlgorithm {
/**
* Gets the signature for the given appId and secret.
*
* @param appId The appId used as a key for the signature.
* @param apiSecret The secret key used for the signature.
* @param ts The timestamp.
* @return The generated signature.
*/
public static String getSignature(String appId, String apiSecret, long ts) {
try {
String auth = md5(appId + ts);
return hmacSHA1Encrypt(auth, apiSecret);
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
// Log the exception for debugging
e.printStackTrace();
return null;
}
}
/**
* HMAC SHA1 encryption.
*
* @param encryptText The text to be encrypted.
* @param encryptKey The encryption key.
* @return The encrypted string.
* @throws NoSuchAlgorithmException If the algorithm is not available.
* @throws InvalidKeyException If the key is invalid.
*/
private static String hmacSHA1Encrypt(String encryptText, String encryptKey)
throws NoSuchAlgorithmException, InvalidKeyException {
SecretKeySpec keySpec = new SecretKeySpec(
encryptKey.getBytes(StandardCharsets.UTF_8), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(keySpec);
byte[] result = mac.doFinal(encryptText.getBytes(StandardCharsets.UTF_8));
return Base64.encodeBase64String(result);
}
/**
* Generates MD5 hash of the given text.
*
* @param text The text to be hashed.
* @return The MD5 hash of the text.
* @throws NoSuchAlgorithmException If the MD5 algorithm is not available.
*/
private static String md5(String text) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(text.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%02x", b));
}
return sb.toString();
}
}
package com.zzsn.event.util.ppt;
import lombok.Data;
@Data
public class CreateResponse {
private boolean flag;
private int code;
private String desc;
private Integer count;
private Data data;
@lombok.Data
public static class Data {
private String sid;
private String coverImgSrc;
private String title;
private String subTitle;
private String outline;
}
}
package com.zzsn.event.util.ppt;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* ppt工具类
*
* @author lkg
* @date 2025/7/19
*/
@Slf4j
public class PPTUtil {
//讯飞-智能PPT
public static final String baseUrl = "https://zwapi.xfyun.cn/api/ppt/v2";
//默认模板id
public static final String templateId = "20240807EA3CB30";
private final static OkHttpClient client = new OkHttpClient().newBuilder()
.connectionPool(new ConnectionPool(100, 5, TimeUnit.MINUTES))
.readTimeout(60 * 10, TimeUnit.SECONDS)
.build();
/**
* 生成大纲
*
* @param appId 应用id
* @param timestamp 时间戳
* @param signature 签名
* @param query 大模型提问
* @author lkg
* @date 2025/7/19
*/
public static CreateResponse createOutline(String appId, String timestamp, String signature, String query) {
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
builder.addFormDataPart("query", query);
RequestBody requestBody = builder.build();
Request request = new Request.Builder().url(baseUrl + "/createOutline")
.addHeader("appId", appId)
.addHeader("timestamp", timestamp)
.addHeader("signature", signature)
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
String string = Objects.requireNonNull(response.body()).string();
return JSONObject.parseObject(string, CreateResponse.class);
} else {
log.info("PPT大纲生成异常:{}", Objects.requireNonNull(response.body()).string());
return null;
}
} catch (IOException e) {
log.info("PPT生成进度查询异常:{}", e.getMessage());
}
return null;
}
/**
* 根据大纲生成ppt
*
* @param appId 应用id
* @param timestamp 时间戳
* @param signature 签名
* @param query 大模型提问
* @param outline ppt大纲
* @author lkg
* @date 2025/7/19
*/
public static CreateResponse createByOutline(String appId, String timestamp, String signature, String query, String outline) {
JSONObject jsonObject = new JSONObject();
JSONObject outlineJson = JSONObject.parseObject(outline);
jsonObject.put("outline", outlineJson);
jsonObject.put("query", query);
jsonObject.put("templateId", templateId);
RequestBody requestBody = RequestBody.create(jsonObject.toString(), MediaType.get("application/json; charset=utf-8"));
Request request = new Request.Builder()
.url(baseUrl + "/createPptByOutline")
.addHeader("appId", appId)
.addHeader("timestamp", timestamp)
.addHeader("signature", signature)
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
String string = Objects.requireNonNull(response.body()).string();
return JSONObject.parseObject(string, CreateResponse.class);
} else {
log.info("PPT生成异常:{}", Objects.requireNonNull(response.body()).string());
return null;
}
} catch (IOException e) {
log.info("PPT生成进度查询异常:{}", e.getMessage());
}
return null;
}
/**
* 查看ppt生成进度
*
* @param appId 应用id
* @param timestamp 时间戳
* @param signature 签名
* @param sid 请求大纲唯一id
* @author lkg
* @date 2025/7/19
*/
public static ProgressResponse checkProgress(String appId, String timestamp, String signature, String sid) {
String url = baseUrl + "/progress?sid=" + sid;
Request request = new Request.Builder()
.url(url)
.addHeader("appId", appId)
.addHeader("timestamp", timestamp)
.addHeader("signature", signature)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
String string = Objects.requireNonNull(response.body()).string();
return JSON.parseObject(string,ProgressResponse.class);
} else {
log.info("PPT生成进度查询异常:{}", Objects.requireNonNull(response.body()).string());
return null;
}
} catch (IOException e) {
log.info("PPT生成进度查询异常:{}", e.getMessage());
}
return null;
}
}
package com.zzsn.event.util.ppt;
import lombok.Data;
@Data
public class ProgressResponse {
private boolean flag;
private int code;
private String desc;
private Integer count;
private Data data;
@lombok.Data
public static class Data {
private String pptStatus;
private String aiImageStatus;
private String cardNoteStatus;
private String pptUrl;
private String errMsg;
private Integer totalPages;
private Integer donePages;
}
}
......@@ -155,7 +155,7 @@ python:
hot-crawler: http://139.9.144.106:5000/data?option=OPTION
jeecg:
shiro:
excludeUrls: info/subjectPageListGroupByLabel,/subject/simple/queryInfoNoSign,/subject/manage/visiblePageListNoSign
excludeUrls: info/subjectPageListGroupByLabel,/subject/simple/**,/subject/manage/visiblePageListNoSign,/test/**
kafka:
topic:
subject:
......@@ -184,4 +184,14 @@ model:
url: https://open.bigmodel.cn/api/paas/v4/chat/completions
authorization: Bearer 3262d41a17a9490a8528eaf52a2be6a0.LNbHPCRmnzFgPHRp
cookie: acw_tc=2760822c17247248406261468e6c541507ba9035f95078363549469047ee74
qwen:
apiKey: sk-01ee9a6efa394178993a950b768e3753
deepseek:
url: https://api.deepseek.com/v1/chat/completions
# api-key: sk-0e374c2ff9a147a2822c36d1c971fda1
api-key: sk-656a8ec451dc47aaad3dacf24fe36f20
doubao:
url: https://ark.cn-beijing.volces.com/api/v3/chat/completions
api-key: ab54c534-4f3c-41b9-9b27-132cb7954b6f
default-model: doubao-1-5-pro-32k-250115 # Doubao-1.5-pro-32k # 收费
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论