提交 5ad50710 作者: 925993793@qq.com

研究中心对接bug修改

上级 6713a62d
......@@ -799,10 +799,11 @@ public class SubjectManageController {
* @date 2025/1/9
*/
@PostMapping("/removeDirectInfoSource")
public Result<?> removeDirectInfoSource(@RequestBody JSONObject params){
String subjectId = params.get("subjectId").toString();
String webSiteName = params.get("webSiteName").toString();
String status = params.get("status").toString();
public Result<?> removeDirectInfoSource(@RequestBody List<JSONObject> params){
for (JSONObject param : params) {
String subjectId = param.get("subjectId").toString();
String webSiteName = param.get("webSiteName").toString();
String status = param.get("status").toString();
if ("1".equals(status)) {
List<InfoSource> infoSources = infoSourceService.directSourceColumnList(webSiteName);
List<String> sourceIds = infoSources.stream().map(InfoSource::getId).collect(Collectors.toList());
......@@ -810,6 +811,7 @@ public class SubjectManageController {
} else if ("0".equals(status)) {
subjectInfoSourceMiddleMapService.remove(new LambdaQueryWrapper<SubjectInfoSourceMiddleMap>().eq(SubjectInfoSourceMiddleMap::getSubjectId, subjectId).eq(SubjectInfoSourceMiddleMap::getInfoSourceName, webSiteName));
}
}
return Result.OK();
}
......
package com.zzsn.event.controller.common;
import cn.hutool.core.util.ObjectUtil;
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.InfoSource;
import com.zzsn.event.entity.Subject;
......@@ -15,6 +17,7 @@ import com.zzsn.event.vo.*;
import com.zzsn.event.vo.es.Label;
import com.zzsn.event.vo.es.SpecialInformation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -52,7 +55,7 @@ public class StatisticalAnalysisController {
* @author lkg
* @date 2024/12/26
*/
@GetMapping("overview")
@PostMapping("overview")
public Result<OverviewAnalysisVO> overviewAnalysis(@RequestBody InfoDataSearchCondition searchCondition) {
OverviewAnalysisVO overviewAnalysisVO = new OverviewAnalysisVO();
Subject subject = subjectService.getById(searchCondition.getSubjectId());
......@@ -114,7 +117,7 @@ public class StatisticalAnalysisController {
format = "yyyy-MM";
} else if ("day".equalsIgnoreCase(groupType)) {
format = "yyyy-MM-dd";
} else if ("hout".equalsIgnoreCase(groupType)) {
} else if ("hour".equalsIgnoreCase(groupType)) {
format = "HH:00:00";
}
if (format != null) {
......@@ -171,13 +174,13 @@ public class StatisticalAnalysisController {
public Result<?> dataSource(@RequestBody InfoDataSearchCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
List<Label> bindLabelList = bindLabelList(searchCondition.getSubjectId());
Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(Label::getRelationId, label -> label));
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
List<String> includeValues = new ArrayList<>();
bindLabelList.forEach(e -> includeValues.add(e.getRelationId()));
searchCondition.setIncludeValues(includeValues.toArray(new String[0]));
dataList = esService.groupByInfoSourceTag(searchCondition);
} else {
Map<String, Label> labelMap = bindLabelList.stream().collect(Collectors.toMap(Label::getRelationId, label -> label));
String[] fetchFields = new String[]{"id", "labels"};
searchCondition.setFetchFields(fetchFields);
List<SpecialInformation> specialInformationList = esService.informationList(searchCondition);
......@@ -185,10 +188,35 @@ public class StatisticalAnalysisController {
for (Map.Entry<String, List<SpecialInformation>> entry : map.entrySet()) {
CountVO countVO = new CountVO();
String key = entry.getKey();
countVO.setName(labelMap.get(key).getRelationName());
countVO.setName(key);
countVO.setValue((long) entry.getValue().size());
}
}
if (CollectionUtils.isNotEmpty(dataList)) {
for (CountVO countVO : dataList) {
String name = countVO.getName();
Label label = labelMap.get(name);
if (label != null) {
countVO.setName(label.getRelationName());
labelMap.remove(name);
}
}
if (MapUtils.isNotEmpty(labelMap)) {
dataList.addAll(labelMap.values().stream().map(e -> {
CountVO countVO = new CountVO();
countVO.setName(e.getRelationName());
countVO.setValue(0L);
return countVO;
}).collect(Collectors.toList()));
}
} else {
for (Label label : bindLabelList) {
CountVO countVO = new CountVO();
countVO.setName(label.getRelationName());
countVO.setValue(0L);
dataList.add(countVO);
}
}
return Result.OK(dataList);
}
......@@ -202,7 +230,11 @@ public class StatisticalAnalysisController {
@PostMapping("/infoSource/dataCount/top")
public Result<?> infoSourceDataCountTop(@RequestBody InfoDataSearchCondition searchCondition) {
List<CountVO> dataList = new ArrayList<>();
List<String> sourceIdList = searchCondition.getSourceIdList();
if (CollectionUtils.isEmpty(searchCondition.getIds()) && searchCondition.getNum() == null) {
if (CollectionUtils.isNotEmpty(sourceIdList)) {
searchCondition.setIncludeValues(sourceIdList.toArray(new String[0]));
}
dataList = esService.groupBySourceId(searchCondition);
} else {
String[] fetchFields = new String[]{"id", "sid"};
......@@ -211,8 +243,11 @@ public class StatisticalAnalysisController {
Map<String, List<SpecialInformation>> map = informationList.stream()
.collect(Collectors.groupingBy(SpecialInformation::getSid));
for (Map.Entry<String, List<SpecialInformation>> entry : map.entrySet()) {
CountVO countVO = new CountVO();
String sid = entry.getKey();
if (CollectionUtils.isNotEmpty(sourceIdList) && (!sourceIdList.contains(sid))) {
continue;
}
CountVO countVO = new CountVO();
countVO.setName(sid);
countVO.setValue((long) entry.getValue().size());
dataList.add(countVO);
......@@ -220,12 +255,16 @@ public class StatisticalAnalysisController {
}
if (CollectionUtils.isNotEmpty(dataList)) {
List<String> sidList = dataList.stream().map(CountVO::getName).collect(Collectors.toList());
List<InfoSource> infoSources = infoSourceService.listByIds(sidList);
LambdaQueryWrapper<InfoSource> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(InfoSource::getId, InfoSource::getSiteName).in(InfoSource::getId, sidList);
List<InfoSource> infoSources = infoSourceService.list(queryWrapper);
Map<String, InfoSource> sourceMap = infoSources.stream().collect(Collectors.toMap(InfoSource::getId, infoSource -> infoSource));
for (CountVO countVO : dataList) {
String sid = countVO.getName();
InfoSource infoSource = sourceMap.get(sid);
countVO.setName(infoSource.getWebSiteName());
if (infoSource != null) {
countVO.setName(infoSource.getSiteName());
}
}
}
return Result.OK(dataList);
......@@ -240,15 +279,32 @@ public class StatisticalAnalysisController {
* @date 2024/12/30
*/
private void changeKey(List<CountVO> dataList, String dictCode) {
if (CollectionUtils.isNotEmpty(dataList)) {
List<SysDictItem> dictItemList = sysDictItemService.listByDictCode(dictCode);
if (CollectionUtils.isNotEmpty(dataList)) {
Map<String, List<SysDictItem>> map = dictItemList.stream().collect(Collectors.groupingBy(SysDictItem::getItemValue));
for (CountVO countVO : dataList) {
List<SysDictItem> sysDictItemList = map.get(countVO.getName());
String name = countVO.getName();
List<SysDictItem> sysDictItemList = map.get(name);
if (CollectionUtils.isNotEmpty(sysDictItemList)) {
countVO.setName(sysDictItemList.get(0).getItemText());
map.remove(name);
}
}
if (MapUtils.isNotEmpty(map)) {
dataList.addAll(map.values().stream().map(e -> {
CountVO countVO = new CountVO();
countVO.setName(e.get(0).getItemText());
countVO.setValue(0L);
return countVO;
}).collect(Collectors.toList()));
}
} else {
for (SysDictItem sysDictItem : dictItemList) {
CountVO countVO = new CountVO();
countVO.setName(sysDictItem.getItemText());
countVO.setValue(0L);
dataList.add(countVO);
}
}
}
......@@ -264,12 +320,12 @@ public class StatisticalAnalysisController {
List<InfoSourceLabelVO> infoSourceLabelInfos = clbLabelService.bindInfoSourceLabelInfo(subjectId);
if (ObjectUtil.isNotEmpty(infoSourceLabelInfos)) {
for (InfoSourceLabelVO infoSourceLabel : infoSourceLabelInfos) {
String labelCode = infoSourceLabel.getLabelCode();
List<InfoSourceLabelItemVO> infoSourceLabelItemList = infoSourceLabel.getInfoSourceLabelItemList();
for (InfoSourceLabelItemVO infoSourceLabelItem : infoSourceLabelItemList) {
Label label = new Label();
label.setRelationName(infoSourceLabelItem.getLabelItemName());
label.setRelationId(labelCode + "_" +infoSourceLabelItem.getLabelItemCode());
label.setRelationId(infoSourceLabelItem.getLabelItemCode());
labels.add(label);
}
}
}
......
......@@ -1477,7 +1477,7 @@ public class EsService {
if ("year".equalsIgnoreCase(groupType)) {
aggregationBuilder = AggregationBuilders.dateHistogram("groupYear")
.field("publishDate")
.calendarInterval(DateHistogramInterval.MONTH)
.calendarInterval(DateHistogramInterval.YEAR)
.format("yyyy");
}
if ("month".equalsIgnoreCase(groupType)) {
......@@ -1648,6 +1648,9 @@ public class EsService {
searchSourceBuilder.query(boolQuery);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(groupName);
aggregationBuilder.field(field);
if (!Objects.isNull(searchCondition.getIncludeValues()) || !Objects.isNull(searchCondition.getExcludeValues())) {
aggregationBuilder.includeExclude(new IncludeExclude(searchCondition.getIncludeValues(), searchCondition.getExcludeValues()));
}
Integer size = searchCondition.getPageSize();
if (size != null) {
aggregationBuilder.size(size);
......
......@@ -12,18 +12,10 @@
</resultMap>
<select id="bindInfoSourceLabelInfo" resultMap="labelMap">
select label.label_code, label.label_name, item.label_item_code, item.label_item_name
from subject_info_source_map m on s.id = m.subject_id
left join clb_label label
on m.source_id = label.label_code
left join clb_label_item item on label.id = item.label_id
where m.subject_id = #{subjectId} and m.type = 6
union
select label.label_code, label.label_name, item.label_item_code, item.label_item_name
from subject_info_source_map m on s.id = m.subject_id
left join clb_label_item item
on m.source_id = item.label_item_code
left join clb_label label on item.label_id = label.id
where m.subject_id = #{subjectId} and m.type = 7
from subject_info_source_map m
inner join clb_label_item item on m.source_item_id = item.label_item_code
inner join clb_label label on item.label_id = label.id
where m.subject_id = #{subjectId} and m.type = 12
</select>
<select id="labelInfoByType" resultMap="labelMap">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论