提交 6d6dff7d 作者: 925993793@qq.com

定制专题采集推送逻辑优化、导出pdf方法

上级 c01035b0
......@@ -10,6 +10,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.obs.services.model.PutObjectResult;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.*;
......@@ -17,28 +18,30 @@ import com.zzsn.event.enums.AnalysisColumnEnum;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.*;
import com.zzsn.event.util.CalculateUtil;
import com.zzsn.event.util.DocUtil;
import com.zzsn.event.util.ObsUtil;
import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.CoOccurrenceVO;
import com.zzsn.event.vo.CountVO;
import com.zzsn.event.vo.EventViewVO;
import com.zzsn.event.vo.es.Doc;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
......@@ -78,6 +81,8 @@ public class EventAnalysisController {
private CommonService commonService;
@Autowired
private IEventService eventService;
@Autowired
private ObsUtil obsUtil;
/**
......@@ -786,6 +791,52 @@ public class EventAnalysisController {
/**
* 导出PDF
*
* @param request
* @param response
* @author lkg
* @date 2025/8/19
*/
@PostMapping(value = "/exportPDF", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public void exportPdf(HttpServletRequest request,HttpServletResponse response) {
try {
InputStream inputStream = request.getInputStream();
String content = DocUtil.convertDocStream2Html(inputStream);
byte[] pdfBytes = DocUtil.convertDocHtml2Pdf(content);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(pdfBytes);
try {
OutputStream outs = response.getOutputStream();
bos = new BufferedOutputStream(outs);
bis = new BufferedInputStream(byteInputStream);
int i;
while ((i = bis.read(pdfBytes)) != -1) {
bos.write(pdfBytes, 0, i);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bos != null) {
bos.flush();
bos.close();
}
if (bis != null) {
bis.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 导出ppt
*
* @param params 参数
......
......@@ -241,7 +241,7 @@ public class EventManageController {
}
try {
configurationMessageService.bindInfoSourceSend(event.getId());
configurationMessageService.bindKeyWordsSend(event.getId());
configurationMessageService.bindKeyWordsSend(event.getId(),null);
configurationMessageService.subjectEnterpriseSourceSync(event.getId());
configurationMessageService.subjectPolicySourceSync(event.getId());
} catch (Exception e) {
......
......@@ -438,7 +438,7 @@ public class SubjectManageController {
if (subject.getStatus() == 1) {
kafkaTemplate.send(SUBJECT_MODEL_KAFKA_CHANNEL, byId.getSubjectCode());
configurationMessageService.bindInfoSourceSend(subject.getId());
configurationMessageService.bindKeyWordsSend(subject.getId());
configurationMessageService.bindKeyWordsSend(subject.getId(),null);
configurationMessageService.subjectEnterpriseSourceSync(subject.getId());
configurationMessageService.subjectPolicySourceSync(subject.getId());
}
......@@ -472,7 +472,7 @@ public class SubjectManageController {
log.info("专题状态同步采集{},index:{},total:{}", subject.getSubjectName(), i, list.size());
if (subject.getStatus() != null && subject.getStatus() == 1) {
configurationMessageService.bindInfoSourceSend(subject.getId());
configurationMessageService.bindKeyWordsSend(subject.getId());
configurationMessageService.bindKeyWordsSend(subject.getId(),null);
caiJiCenterHttpService.subjectStatusEdit(subject.getStatus(), subject.getId());
configurationMessageService.subjectEnterpriseSourceSync(subject.getId());
log.info("专题配置信息同步采集成功:{}", subject.getSubjectName());
......@@ -669,7 +669,7 @@ public class SubjectManageController {
public Result<?> keyWordsBindScope(@RequestBody SubjectKeywordsMap subjectKeywordsMap) {
subjectKeywordsMapService.updateById(subjectKeywordsMap);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectKeywordsMap.getSubjectId());
configurationMessageService.bindKeyWordsSend(subjectKeywordsMap.getSubjectId(),null);
return Result.OK();
}
......
package com.zzsn.event.controller.common;
import cn.hutool.core.bean.BeanException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.EventAnalysisVersion;
import com.zzsn.event.entity.EventAnalysisVersionRecord;
import com.zzsn.event.entity.EventLlmConfig;
import com.zzsn.event.enums.AnalysisColumnEnum;
import com.zzsn.event.service.*;
import com.zzsn.event.util.DateUtil;
import com.zzsn.event.service.AnalysisService;
import com.zzsn.event.service.EventAnalysisVersionRecordService;
import com.zzsn.event.service.EventLlmConfigService;
import com.zzsn.event.service.IEventService;
import com.zzsn.event.vo.EventLlmConfigModifyVO;
import com.zzsn.event.vo.EventVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 大模型配置
......@@ -40,8 +33,6 @@ public class LLmConfigController {
@Autowired
private AnalysisService analysisService;
@Autowired
private EventAnalysisVersionService eventAnalysisVersionService;
@Autowired
private EventAnalysisVersionRecordService eventAnalysisVersionRecordService;
@Autowired
private IEventService eventService;
......@@ -85,7 +76,6 @@ public class LLmConfigController {
if (StringUtils.isEmpty(versionId)) {
return Result.FAIL("请选择要修改的版本");
}
try {
EventLlmConfig eventLlmConfig = new EventLlmConfig();
BeanUtils.copyProperties(eventLlmConfigModifyVO, eventLlmConfig);
llmConfigService.modifySingle(eventLlmConfig);
......@@ -102,14 +92,7 @@ public class LLmConfigController {
log.info("未找到对应的事件栏目【{}】", eventLlmConfig.getColumnCode());
}
//更新返回结果
String finalLlmResult = llmResult;
CompletableFuture.runAsync(() ->{
eventAnalysisVersionRecordService.modify(versionId, analysisColumnEnum, finalLlmResult);
});
} catch (Exception e) {
log.info("事件栏目【{}】,结果更新失败", eventLlmConfigModifyVO.getColumnCode());
e.printStackTrace();
}
eventAnalysisVersionRecordService.modify(versionId, analysisColumnEnum, llmResult);
return Result.OK(llmResult);
}
}
......@@ -272,7 +272,7 @@ public class ExternalController {
* @author lkg
* @date 2025/8/12
*/
@GetMapping("/pushToCaiji")
//@GetMapping("/pushToCaiji")
public Result<?> pushToCaiji(@RequestParam String subjectId) {
SubjectInfoVO subjectInfoVO = new SubjectInfoVO();
SubjectDetailVO subjectDetailVO = subjectSimpleService.queryInfo(subjectId);
......@@ -336,7 +336,7 @@ public class ExternalController {
* @author lkg
* @date 2025/8/16
*/
@GetMapping("/getGatherSummary")
//@GetMapping("/getGatherSummary")
public Result<?> getGatherSummary(@RequestParam String subjectId) {
return Result.OK(redisUtil.get("GATHER_SUMMARY::" + subjectId));
}
......
......@@ -9,9 +9,12 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.entity.*;
import com.zzsn.event.enums.BindTypeEnum;
import com.zzsn.event.external.entity.ExternalSubjectInfoSourceMap;
import com.zzsn.event.external.service.ExternalSubjectInfoSourceMapService;
import com.zzsn.event.feign.api.RemoteModelService;
import com.zzsn.event.mapper.SubjectAdditionMapper;
import com.zzsn.event.service.*;
......@@ -127,7 +130,10 @@ public class ConfigurationMessageService {
@Autowired(required = false)
private RemoteModelService remoteModelService;
public void bindKeyWordsSend(String subjectId) {
@Autowired
private ExternalSubjectInfoSourceMapService externalSubjectInfoSourceMapService;
public void bindKeyWordsSend(String subjectId,Integer type) {
try {
remoteModelService.delSubjectCache(subjectId);
} catch (Exception e) {
......@@ -144,10 +150,10 @@ public class ConfigurationMessageService {
String keyWordsParam;
if (CollectionUtil.isEmpty(keyWordsPages)) {
log.info("专题未绑定采集词组,通知采集清空");
keyWordsParam = getKeyWordsParam(byId, null, new ArrayList<>());
keyWordsParam = getKeyWordsParam(byId, null, new ArrayList<>(),type);
}else {
List<KeyWords> keyWords = keyWordsService.listByIds(keyWordsPages.stream().map(KeyWordsPage::getId).collect(Collectors.toList()));
keyWordsParam = getKeyWordsParam(byId, null, keyWords);
keyWordsParam = getKeyWordsParam(byId, null, keyWords,type);
}
String post = caiJiCenterHttpService.allKeyWordsBindUrl(keyWordsParam);
......@@ -415,7 +421,7 @@ public class ConfigurationMessageService {
return param;
}
private String getKeyWordsParam(Subject subject ,Integer option,List<KeyWords> keyWords) {
private String getKeyWordsParam(Subject subject ,Integer option,List<KeyWords> keyWords,Integer type) {
Map<String,Object> param = new HashMap<>();
List<Map<String,Object>> kw = new ArrayList<>();
param.put("subjectSign",subject.getId());
......@@ -423,6 +429,7 @@ public class ConfigurationMessageService {
param.put("customerSign",caiJiCenterHttpService.getProjectCode());
param.put("customerName",caiJiCenterHttpService.getProjectName());
param.put("mode",option);
param.put("type",type);
if (ObjectUtil.isNotNull(subject.getTimeEnable())) {
param.put("startTime", DateUtil.format(subject.getTimeEnable(),"yyyy-MM-dd HH:mm:ss"));
}else {
......@@ -446,6 +453,13 @@ public class ConfigurationMessageService {
kw.add(map);
});
param.put("keywordList",kw);
if (type != null && type == 1) {
LambdaQueryWrapper<ExternalSubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ExternalSubjectInfoSourceMap::getSubjectId, subject.getId())
.eq(ExternalSubjectInfoSourceMap::getType, 1);
List<ExternalSubjectInfoSourceMap> sourceList = externalSubjectInfoSourceMapService.list(queryWrapper);
param.put("sourceList",sourceList);
}
return JSONUtil.toJsonStr(param);
}
......
......@@ -588,7 +588,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
subjectKeywordsMapService.saveBatch(mapList);
}
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectPage.getId());
configurationMessageService.bindKeyWordsSend(subjectPage.getId(),null);
}
@Override
......@@ -609,7 +609,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}*/
}
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectPage.getId());
configurationMessageService.bindKeyWordsSend(subjectPage.getId(),null);
}
@Override
......
......@@ -121,7 +121,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
scoreModel.setData(defaultConfig);
scoreModelService.save(scoreModel);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId);
configurationMessageService.bindKeyWordsSend(subjectId,null);
//默认绑定tpu流程
List<ClbModelArrangeSubjectMap> tpuList = new ArrayList<>();
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
......@@ -151,7 +151,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectId, subject.getSubjectName(), keywords);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectId);
configurationMessageService.bindKeyWordsSend(subjectId,1);
//默认绑定tpu流程
ClbModelArrangeSubjectMap tpu = new ClbModelArrangeSubjectMap();
tpu.setSubjectId(subject.getId());
......@@ -376,7 +376,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId());
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId(),null);
}
}
......@@ -391,7 +391,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
if (CollectionUtils.isNotEmpty(keywords)) {
modifyKeyword(subjectSimpleVO.getId(), subjectSimpleVO.getSubjectName(), keywords);
//同步配置到采集
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId());
configurationMessageService.bindKeyWordsSend(subjectSimpleVO.getId(),1);
}
}
......
......@@ -105,4 +105,19 @@ public class DocUtil {
doc.save(dataByteArrayOutputStream, SaveFormat.DOCX);
return dataByteArrayOutputStream.getData();
}
public static byte[] convertDocHtml2Pdf(String content) throws Exception {
getLicense();
if (SystemUtils.IS_OS_LINUX) {
FontSettings fontSettings = new FontSettings();
//true 表示递归查询子文件夹
fontSettings.setFontsFolder(fontsPath, true);
}
Document doc = new Document();
DataByteArrayOutputStream dataByteArrayOutputStream = new DataByteArrayOutputStream();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml(content);
doc.save(dataByteArrayOutputStream, SaveFormat.PDF);
return dataByteArrayOutputStream.getData();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论