提交 b3c4febe 作者: 925993793@qq.com

【fix】已入库资讯导出逻辑修改以及其他bug修改

上级 b7bd8c2f
......@@ -7,11 +7,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.obs.services.model.PutObjectResult;
import com.zzsn.event.config.FreeMarkerConfiguration;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.ClbFileOperationLog;
import com.zzsn.event.entity.Event;
import com.zzsn.event.entity.FileDownloadCenter;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.entity.*;
import com.zzsn.event.es.EsService;
import com.zzsn.event.exception.FileExportException;
import com.zzsn.event.service.*;
import com.zzsn.event.util.*;
import com.zzsn.event.util.user.UserUtil;
......@@ -31,6 +29,8 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
......@@ -75,6 +75,10 @@ public class FileController {
private CommonService commonService;
@Autowired
private IClbFileOperationLogService clbFileOperationLogService;
@Autowired
private ISubjectTypeService subjectTypeService;
@Autowired
private ISubjectTypeMapService subjectTypeMapService;
/**
* 专题关联信息源采集量统计-导出excel(专题列表页)
......@@ -226,11 +230,13 @@ public class FileController {
} catch (Exception e) {
e.printStackTrace();
}
} else {
} else if (count < 100000){
//获取当前登录用户
UserVo userVo = UserUtil.getLoginUser();
String subjectName;
Integer category = searchCondition.getCategory();
String isSubject = searchCondition.getIsSubject();
if (isSubject.equals("1")) {
if (category == 1) {
Subject subject = subjectService.getById(subjectId);
subjectName = subject.getSubjectName();
......@@ -238,6 +244,10 @@ public class FileController {
Event event = eventService.getById(subjectId);
subjectName = event.getEventName();
}
} else {
SubjectType subjectType = subjectTypeService.getById(subjectId);
subjectName = subjectType.getTypeName();
}
FileDownloadCenter fileDownloadCenter = new FileDownloadCenter();
fileDownloadCenter.setRelationId(subjectId);
String name = fileDownloadCenterService.getNoRepeatName(subjectName + "-已入库信息", userVo.getUsername());
......@@ -265,12 +275,17 @@ public class FileController {
}
fileDownloadCenterService.update(updateWrapper);
});
} else {
throw new FileExportException("导出数据量超出100000,请联系技术人员");
}
} else {
throw new FileExportException("数据量为0,无法导出");
}
}
/**
* 专题资讯导入模板下载-研究中心
*
......@@ -391,11 +406,30 @@ public class FileController {
byte[] bytes = null;
try {
String[] arr = new String[]{"得分", "标题", "标题译文", "摘要", "摘要译文", "正文", "正文译文", "作者", "来源", "发布时间", "网址", "专题库类型", "命中词"};
List<String> subjectIds = new ArrayList<>();
subjectIds.add(searchCondition.getSubjectId());
List<LabelModelVo> labelTypeVos = commonService.subjectModelBindLabels(subjectIds);
List<String> headers = Arrays.asList(arr);
List<String> subjectIdList = new ArrayList<>();
//判断是否是专题
if ("1".equals(searchCondition.getIsSubject())) {
if (StringUtils.isNotEmpty(searchCondition.getSubjectId())) {
subjectIdList.add(searchCondition.getSubjectId());
}
} else {
//该id其实是专题类别id
//查询类别id的所有明细id
Integer category = searchCondition.getCategory();
String subjectTypeId = searchCondition.getSubjectId();
List<String> typeIds = subjectTypeService.belowIdList(subjectTypeId, category);
if (category == 1) {
subjectIdList = subjectTypeMapService.selectSubjectByTypeIds(typeIds);
} else if (category == 2) {
subjectIdList = subjectTypeMapService.selectEventByTypeIds(typeIds);
}
}
List<LabelModelVo> labelTypeVos = commonService.subjectModelBindLabels(subjectIdList);
if (subjectIdList.size() == 1) {
//动态补充表头
List<String> headers = supplyHeaders(arr, labelTypeVos);
headers = supplyHeaders(arr, labelTypeVos);
}
SXSSFWorkbook workbook = new SXSSFWorkbook();
for (int i = 1; ; i++) {
searchCondition.setPageNo(i);
......@@ -404,7 +438,7 @@ public class FileController {
if (CollectionUtils.isEmpty(informationList)) {
break;
}
List<List<String>> rows = formatData(informationList, labelTypeVos);
List<List<String>> rows = formatData(informationList, labelTypeVos,subjectIdList);
BigExcelExportUtil.exportExcelData(workbook, i - 1, headers, rows, "sheet" + i);
log.info("第【{}】个sheet页写入成功", i);
}
......@@ -429,7 +463,7 @@ public class FileController {
return headers;
}
private List<List<String>> formatData(List<SpecialInformation> informationList, List<LabelModelVo> labelTypeVos) {
private List<List<String>> formatData(List<SpecialInformation> informationList, List<LabelModelVo> labelTypeVos,List<String> subjectIdList) {
List<List<String>> list = new ArrayList<>();
for (SpecialInformation info : informationList) {
List<String> data = new ArrayList<>();
......@@ -515,8 +549,7 @@ public class FileController {
} else {
data.add(" ");
}
//标签处理
if (CollectionUtils.isNotEmpty(labelTypeVos)) {
if (subjectIdList.size() == 1 && (CollectionUtils.isNotEmpty(labelTypeVos))) {
List<Label> relationLabels = info.getLabels();
Map<String, List<Label>> map = new HashMap<>(labelTypeVos.size());
for (LabelModelVo labelTypeVo : labelTypeVos) {
......@@ -569,6 +602,7 @@ public class FileController {
data.add(sb.substring(1));
}
}
}
list.add(data);
}
......
......@@ -99,7 +99,7 @@ public class SubjectManageController {
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired
private PythonUtil pythonUtil;
@Autowired
@Autowired(required = false)
private RemoteModelService remoteModelService;
@Autowired
private ConfigurationMessageService configurationMessageService;
......
......@@ -222,6 +222,9 @@ public class InformationController {
if (StringUtils.isEmpty(searchCondition.getSubjectId())) {
return Result.FAIL("专题id/专题分类id不能为空");
}
if (searchCondition.getCategory() == null) {
return Result.FAIL("专题类型不能为空");
}
UserVo userVo = UserUtil.getLoginUser();
return informationService.subjectPageListGroupByLabel(userVo, searchCondition);
}
......
......@@ -1089,9 +1089,25 @@ public class EsService {
searchSourceBuilder.trackTotalHits(true);
searchSourceBuilder.size(0);
//创建查询对象
List<String> subjectIds = new ArrayList<>();
subjectIds.add(searchCondition.getSubjectId());
BoolQueryBuilder boolQuery = buildQuery(searchCondition, subjectIds);
List<String> subjectIdList = new ArrayList<>();
//判断是否是专题
if ("1".equals(searchCondition.getIsSubject())) {
if (StringUtils.isNotEmpty(searchCondition.getSubjectId())) {
subjectIdList.add(searchCondition.getSubjectId());
}
} else {
//该id其实是专题类别id
//查询类别id的所有明细id
Integer category = searchCondition.getCategory();
String subjectTypeId = searchCondition.getSubjectId();
List<String> typeIds = subjectTypeService.belowIdList(subjectTypeId, category);
if (category == 1) {
subjectIdList = subjectTypeMapService.selectSubjectByTypeIds(typeIds);
} else if (category == 2) {
subjectIdList = subjectTypeMapService.selectEventByTypeIds(typeIds);
}
}
BoolQueryBuilder boolQuery = buildQuery(searchCondition, subjectIdList);
searchSourceBuilder.query(boolQuery);
searchRequest.source(searchSourceBuilder);
try {
......@@ -1163,9 +1179,25 @@ public class EsService {
}
searchSourceBuilder.size(pageSize);
searchSourceBuilder.from((pageNo - 1) * pageSize);
List<String> subjectIds = new ArrayList<>();
subjectIds.add(searchCondition.getSubjectId());
boolQuery = buildQuery(searchCondition, subjectIds);
List<String> subjectIdList = new ArrayList<>();
//判断是否是专题
if ("1".equals(searchCondition.getIsSubject())) {
if (StringUtils.isNotEmpty(searchCondition.getSubjectId())) {
subjectIdList.add(searchCondition.getSubjectId());
}
} else {
//该id其实是专题类别id
//查询类别id的所有明细id
Integer category = searchCondition.getCategory();
String subjectTypeId = searchCondition.getSubjectId();
List<String> typeIds = subjectTypeService.belowIdList(subjectTypeId, category);
if (category == 1) {
subjectIdList = subjectTypeMapService.selectSubjectByTypeIds(typeIds);
} else if (category == 2) {
subjectIdList = subjectTypeMapService.selectEventByTypeIds(typeIds);
}
}
boolQuery = buildQuery(searchCondition, subjectIdList);
}
searchSourceBuilder.query(boolQuery);
searchRequest.source(searchSourceBuilder);
......
package com.zzsn.event.exception;
import com.zzsn.event.constant.Result;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 异常拦截
*
* @author lkg
* @date 2025/2/28
*/
@RestControllerAdvice
public class CustomExceptionHandler {
@ExceptionHandler(FileExportException.class)
public ResponseEntity<Object> handleFileExportException(FileExportException ex) {
return new ResponseEntity<>(Result.FAIL(ex.getMessage()), HttpStatus.valueOf(ex.getStatusCode()));
}
}
package com.zzsn.event.exception;
import lombok.Data;
/**
* 文件导出异常
*
* @author lkg
* @date 2025/2/28
*/
@Data
public class FileExportException extends RuntimeException{
private int statusCode = 500;
public FileExportException(String message) {
super(message);
}
}
......@@ -876,11 +876,13 @@ public class InformationServiceImpl implements InformationService {
}
for (SpecialInformation specialInformation : informationList) {
List<Label> labels = specialInformation.getLabels();
if (labels.size() == 1) {
List<Label> collect = labels.stream().filter(e -> "thematic_information_column".equals(e.getLabelMark())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
if (collect.size() == 1) {
removeList.add(specialInformation);
} else {
List<Label> newLabels = new ArrayList<>();
for (Label label : labels) {
for (Label label : collect) {
String labelRelationId = label.getRelationId();
if (!themeIds.contains(labelRelationId)) {
newLabels.add(label);
......@@ -889,6 +891,9 @@ public class InformationServiceImpl implements InformationService {
specialInformation.setLabels(newLabels);
dataList.add(specialInformation);
}
} else {
removeList.add(specialInformation);
}
}
}
if (CollectionUtils.isNotEmpty(removeList)) {
......
......@@ -80,7 +80,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
private CodeGenerateUtil codeGenerateUtil;
@Autowired
private PythonUtil pythonUtil;
@Autowired
@Autowired(required = false)
private RemoteModelService remoteModelService;
@Value("${clb.subject.default.processing.advanceMonth}")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论