Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
b3b7b61e
提交
b3b7b61e
authored
4月 10, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加批量删除标签的接口
上级
0ab2861d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
114 行增加
和
34 行删除
+114
-34
InformationController.java
...m/zzsn/event/controller/common/InformationController.java
+22
-2
InformationService.java
src/main/java/com/zzsn/event/service/InformationService.java
+16
-2
InformationServiceImpl.java
...a/com/zzsn/event/service/impl/InformationServiceImpl.java
+72
-30
InfoDataSearchCondition.java
src/main/java/com/zzsn/event/vo/InfoDataSearchCondition.java
+4
-0
没有找到文件。
src/main/java/com/zzsn/event/controller/common/InformationController.java
浏览文件 @
b3b7b61e
...
...
@@ -249,7 +249,7 @@ public class InformationController {
}
/**
* 保存为数据集
* 保存为数据集
(实为打标签)
*
* @param searchCondition 筛选条件
* @author lkg
...
...
@@ -265,7 +265,27 @@ public class InformationController {
return
Result
.
FAIL
(
"专题id不能为空"
);
}
CompletableFuture
.
runAsync
(()
->
informationService
.
saveAsDataSet
(
searchCondition
));
return
Result
.
OK
(
"数据集保存中。。。"
);
return
Result
.
OK
(
"数据集保存中,请稍后查看"
);
}
/**
* 批量删除标签
*
* @param searchCondition 筛选条件
* @author lkg
* @date 2024/5/6
*/
@PostMapping
(
"/batchDeleteLabel"
)
public
Result
<?>
batchDeleteLabel
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
String
dataSetId
=
searchCondition
.
getRemoveRelationId
();
if
(
StringUtils
.
isEmpty
(
dataSetId
))
{
return
Result
.
FAIL
(
"待删除标签id不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
searchCondition
.
getSubjectId
()))
{
return
Result
.
FAIL
(
"专题id不能为空"
);
}
CompletableFuture
.
runAsync
(()
->
informationService
.
removeLabels
(
searchCondition
));
return
Result
.
OK
(
"标签删除中,请稍后查看"
);
}
...
...
src/main/java/com/zzsn/event/service/InformationService.java
浏览文件 @
b3b7b61e
...
...
@@ -39,6 +39,7 @@ public interface InformationService {
* @date 2024/5/6
*/
IPage
<
DisplayInfo
>
subjectPageList
(
InfoDataSearchCondition
subjectInfo
);
/**
* 专题库资讯分页列表
*
...
...
@@ -47,6 +48,7 @@ public interface InformationService {
* @date 2024/5/6
*/
IPage
<
SpecialInformation
>
subjectPageListForDataDetail
(
InfoDataSearchCondition
subjectInfo
);
/**
* 资讯分页列表(根据标签分类分组)
*/
...
...
@@ -62,6 +64,15 @@ public interface InformationService {
void
saveAsDataSet
(
InfoDataSearchCondition
searchCondition
);
/**
* 批量删除标签
*
* @param searchCondition 筛选条件
* @author lkg
* @date 2025/4/10
*/
void
removeLabels
(
InfoDataSearchCondition
searchCondition
);
/**
* 资讯详情
*
* @param type 类别(1-采集库;2-专题库)
...
...
@@ -127,11 +138,11 @@ public interface InformationService {
* 资讯绑定标签
*
* @param dataBindLabelFrom 绑定参数
* @param boundList 专题绑定的标签(数据字典)集合
* @param boundList
专题绑定的标签(数据字典)集合
* @author lkg
* @date 2025/3/31
*/
void
modifyLabel
(
DataBindLabelFrom
dataBindLabelFrom
,
List
<
DictVO
>
boundList
);
void
modifyLabel
(
DataBindLabelFrom
dataBindLabelFrom
,
List
<
DictVO
>
boundList
);
/**
* 审核
...
...
@@ -207,6 +218,7 @@ public interface InformationService {
/**
* 批量导入数据到发布库
*
* @author lkg
* @date 2025/2/5
*/
...
...
@@ -214,6 +226,7 @@ public interface InformationService {
/**
* 批量导入数据到发布库-研究中心
*
* @author lkg
* @date 2025/2/5
*/
...
...
@@ -228,6 +241,7 @@ public interface InformationService {
* @date 2025/2/20
*/
void
removeByCondition
(
String
subjectId
,
List
<
String
>
themeIds
);
/**
* 新增专题下的数据-研究中心
*
...
...
src/main/java/com/zzsn/event/service/impl/InformationServiceImpl.java
浏览文件 @
b3b7b61e
...
...
@@ -225,7 +225,7 @@ public class InformationServiceImpl implements InformationService {
List
<
LabelModelVo
>
modelVoList
=
modelMap
.
get
(
info
.
getSubjectId
());
formatLabel
(
modelVoList
,
info
);
try
{
try
{
//多个主题的保留分数最高的
List
<
Label
>
listLabel
=
info
.
getLabels
();
// 使用流操作找到score最大的Label
...
...
@@ -235,33 +235,33 @@ public class InformationServiceImpl implements InformationService {
.
max
(
Comparator
.
comparingDouble
(
Label:
:
getStatus
));
List
<
Label
>
maxLabelList
=
maxLabel
.
map
(
Collections:
:
singletonList
).
orElse
(
Collections
.
emptyList
());
info
.
setLabels
(
maxLabelList
);
}
catch
(
Exception
e
)
{
log
.
error
(
"处理得分最高标签异常"
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"处理得分最高标签异常"
,
e
);
}
dataList
.
add
(
info
);
}
Map
<
String
,
List
<
DisplayInfo
>>
mapList
=
groupedByLabelMark
(
dataList
,
searchCondition
);
Map
<
String
,
List
<
DisplayInfo
>>
mapList
=
groupedByLabelMark
(
dataList
,
searchCondition
);
mapList
.
forEach
((
relationName
,
displayInfos
)
->
{
List
<
DisplayInfo
>
listN
=
new
ArrayList
<>();
Integer
num
=
0
;
for
(
DisplayInfo
obj
:
displayInfos
)
{
DisplayInfo
copy
=
new
DisplayInfo
();
BeanUtils
.
copyProperties
(
obj
,
copy
);
BeanUtils
.
copyProperties
(
obj
,
copy
);
num
++;
copy
.
setIndex
(
num
+
"."
);
// copy.setTitle(StringUtils.isNotEmpty(copy.getTitle())?copy.getTitle() + "。":"");
listN
.
add
(
copy
);
}
HashMap
map
=
new
HashMap
();
map
.
put
(
"relationName"
,
relationName
);
map
.
put
(
"infoList"
,
listN
);
map
.
put
(
"relationName"
,
relationName
);
map
.
put
(
"infoList"
,
listN
);
list
.
add
(
map
);
});
}
else
{
}
else
{
//不加标签获取列表数据
searchCondition
.
setLabelMark
(
null
);
//中外智库专栏-数据需排序
if
(
StringUtils
.
isNotBlank
(
searchCondition
.
getSubjectId
())
&&
searchCondition
.
getSubjectId
().
equals
(
subjectId
))
{
if
(
StringUtils
.
isNotBlank
(
searchCondition
.
getSubjectId
())
&&
searchCondition
.
getSubjectId
().
equals
(
subjectId
))
{
searchCondition
.
setColumn
(
"yqgzzk"
);
}
specialInformationIPage
=
esService
.
pageListByCondition
(
searchCondition
,
subjectIdList
);
...
...
@@ -285,30 +285,30 @@ public class InformationServiceImpl implements InformationService {
dataList
.
add
(
info
);
}
//中外智库专栏-数据需过滤
if
(
StringUtils
.
isNotBlank
(
searchCondition
.
getSubjectId
())
&&
searchCondition
.
getSubjectId
().
equals
(
subjectId
))
{
if
(
StringUtils
.
isNotBlank
(
searchCondition
.
getSubjectId
())
&&
searchCondition
.
getSubjectId
().
equals
(
subjectId
))
{
ArrayList
<
DisplayInfo
>
saveList
=
new
ArrayList
<>(
list
.
size
());
List
<
String
>
titles
=
new
ArrayList
<>(
list
.
size
());
for
(
DisplayInfo
s:
dataList
)
{
for
(
DisplayInfo
s
:
dataList
)
{
String
title
=
s
.
getTitle
().
trim
();
int
tem
=
0
;
for
(
String
t:
titles
)
{
for
(
String
t
:
titles
)
{
double
simforcatl
=
SimilarityUtil
.
simforcatl
(
title
,
t
);
if
(
simforcatl
>
0.83
)
{
log
.
info
(
"getArticleNode 获取文章列表中标题为[{}],和标题为[{}],的相似度大于80%过滤后者"
,
title
,
t
);
tem
=
1
;
if
(
simforcatl
>
0.83
)
{
log
.
info
(
"getArticleNode 获取文章列表中标题为[{}],和标题为[{}],的相似度大于80%过滤后者"
,
title
,
t
);
tem
=
1
;
break
;
}
}
if
(
tem
==
0
)
{
if
(
tem
==
0
)
{
titles
.
add
(
title
);
}
else
{
}
else
{
continue
;
}
saveList
.
add
(
s
);
}
for
(
DisplayInfo
info:
saveList
)
{
if
(
StringUtils
.
isNotBlank
(
info
.
getSubtitle
()))
{
info
.
setTitle
(
info
.
getSubtitle
()
+
info
.
getTitle
());
for
(
DisplayInfo
info
:
saveList
)
{
if
(
StringUtils
.
isNotBlank
(
info
.
getSubtitle
()))
{
info
.
setTitle
(
info
.
getSubtitle
()
+
info
.
getTitle
());
}
}
return
Result
.
OK
(
saveList
);
...
...
@@ -322,7 +322,7 @@ public class InformationServiceImpl implements InformationService {
return
Result
.
OK
(
list
);
}
public
Map
<
String
,
List
<
DisplayInfo
>>
groupedByLabelMark
(
List
<
DisplayInfo
>
dataList
,
InfoDataSearchCondition
searchCondition
)
{
public
Map
<
String
,
List
<
DisplayInfo
>>
groupedByLabelMark
(
List
<
DisplayInfo
>
dataList
,
InfoDataSearchCondition
searchCondition
)
{
// 使用 Stream API 对 dataList 进行分组
Map
<
String
,
List
<
DisplayInfo
>>
groupedByLabelMark
=
dataList
.
stream
()
// 将每个 DisplayInfo 对象映射到一个或多个 labelMark
...
...
@@ -341,6 +341,7 @@ public class InformationServiceImpl implements InformationService {
Collectors
.
mapping
(
AbstractMap
.
SimpleEntry
::
getValue
,
Collectors
.
toList
())));
return
groupedByLabelMark
;
}
@Override
public
DisplayInfo
queryInfo
(
Integer
type
,
String
index
,
String
id
)
{
DisplayInfo
info
=
(
DisplayInfo
)
esOpUtil
.
getInfoById
(
index
,
id
,
DisplayInfo
.
class
);
...
...
@@ -389,20 +390,37 @@ public class InformationServiceImpl implements InformationService {
dataSet
.
setRelationId
(
dataSetId
);
Map
<
String
,
List
<
SpecialInformation
>>
map
=
new
HashMap
<>();
List
<
SpecialInformation
>
informationList
=
this
.
informationAllList
(
searchCondition
);
formatUpdateMap
(
map
,
informationList
,
dataSet
);
formatUpdateMap
(
map
,
informationList
,
dataSet
);
map
.
forEach
((
k
,
v
)
->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
}
@Override
public
void
removeLabels
(
InfoDataSearchCondition
searchCondition
)
{
String
[]
fetchFields
=
new
String
[]{
"id"
,
"labels"
};
searchCondition
.
setFetchFields
(
fetchFields
);
List
<
Label
>
removeLabels
=
new
ArrayList
<>();
String
removeRelationId
=
searchCondition
.
getRemoveRelationId
();
for
(
String
relationId
:
removeRelationId
.
split
(
","
))
{
Label
dataSet
=
new
Label
();
dataSet
.
setRelationId
(
relationId
);
removeLabels
.
add
(
dataSet
);
}
Map
<
String
,
List
<
SpecialInformation
>>
map
=
new
HashMap
<>();
List
<
SpecialInformation
>
informationList
=
this
.
informationAllList
(
searchCondition
);
formatUpdateMap
(
map
,
informationList
,
removeLabels
);
map
.
forEach
((
k
,
v
)
->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
}
/**
* 格式化数据
*
* @param map 待更新的数据map集合
* @param map
待更新的数据map集合
* @param informationList 查询到的数据集合
* @param dataSet 数据集标签信息
* @param dataSet
数据集标签信息
* @author lkg
* @date 2025/2/28
*/
private
void
formatUpdateMap
(
Map
<
String
,
List
<
SpecialInformation
>>
map
,
List
<
SpecialInformation
>
informationList
,
Label
dataSet
)
{
private
void
formatUpdateMap
(
Map
<
String
,
List
<
SpecialInformation
>>
map
,
List
<
SpecialInformation
>
informationList
,
Label
dataSet
)
{
for
(
SpecialInformation
information
:
informationList
)
{
String
index
=
information
.
getDbIndex
();
List
<
Label
>
labels
=
information
.
getLabels
();
...
...
@@ -425,6 +443,30 @@ public class InformationServiceImpl implements InformationService {
}
}
private
void
formatUpdateMap
(
Map
<
String
,
List
<
SpecialInformation
>>
map
,
List
<
SpecialInformation
>
informationList
,
List
<
Label
>
removeLabels
)
{
for
(
SpecialInformation
information
:
informationList
)
{
String
index
=
information
.
getDbIndex
();
List
<
Label
>
newLabels
=
new
ArrayList
<>();
List
<
Label
>
labels
=
information
.
getLabels
();
if
(
CollectionUtils
.
isNotEmpty
(
labels
))
{
for
(
Label
label
:
labels
)
{
boolean
present
=
removeLabels
.
stream
().
anyMatch
(
e
->
e
.
getRelationId
().
equals
(
label
.
getRelationId
()));
if
(!
present
)
{
newLabels
.
add
(
label
);
}
}
}
information
.
setLabels
(
newLabels
);
if
(
map
.
containsKey
(
index
))
{
map
.
get
(
index
).
add
(
information
);
}
else
{
List
<
SpecialInformation
>
list
=
new
ArrayList
<>();
list
.
add
(
information
);
map
.
put
(
index
,
list
);
}
}
}
@Override
public
List
<
List
<
String
>>
statisticsExportList
(
String
subjectId
,
String
startDate
,
String
endDate
)
{
List
<
String
>
subjectIdList
=
new
ArrayList
<>();
...
...
@@ -610,7 +652,7 @@ public class InformationServiceImpl implements InformationService {
}
@Override
public
void
modifyLabel
(
DataBindLabelFrom
dataBindLabelFrom
,
List
<
DictVO
>
boundList
)
{
public
void
modifyLabel
(
DataBindLabelFrom
dataBindLabelFrom
,
List
<
DictVO
>
boundList
)
{
DisplayInfo
info
=
(
DisplayInfo
)
esOpUtil
.
getInfoById
(
dataBindLabelFrom
.
getIndex
(),
dataBindLabelFrom
.
getId
(),
DisplayInfo
.
class
);
if
(
info
!=
null
)
{
List
<
Label
>
newLabels
=
new
ArrayList
<>();
...
...
@@ -1039,7 +1081,7 @@ public class InformationServiceImpl implements InformationService {
}
if
(
CollectionUtils
.
isNotEmpty
(
dataList
))
{
Map
<
String
,
List
<
SpecialInformation
>>
updateMap
=
removeList
.
stream
().
collect
(
Collectors
.
groupingBy
(
SpecialInformation:
:
getDbIndex
));
updateMap
.
forEach
((
k
,
v
)
->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
updateMap
.
forEach
((
k
,
v
)
->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
}
//python 去重接口
pythonUtil
.
clearDuplicateHistory
(
themeIds
);
...
...
@@ -1055,15 +1097,15 @@ public class InformationServiceImpl implements InformationService {
if
(
CollectionUtils
.
isNotEmpty
(
dateList
))
{
List
<
String
>
redisCacheList
=
new
ArrayList
<>();
for
(
String
date
:
dateList
)
{
if
(
themeIds
!=
null
&&
!
themeIds
.
isEmpty
())
{
if
(
themeIds
!=
null
&&
!
themeIds
.
isEmpty
())
{
//2025-01-21:123,123,123
String
dateStr
=
date
+
":"
+
StringUtils
.
join
(
","
,
themeIds
);
redisCacheList
.
add
(
dateStr
);
}
else
{
}
else
{
redisCacheList
.
add
(
date
);
}
}
redisUtil
.
rpushMultipleValues
(
Constants
.
HISTORY_SUBJECT_DATE_QUEUE
+
subject
.
getSubjectCode
(),
redisCacheList
.
toArray
(
new
String
[
0
]));
redisUtil
.
rpushMultipleValues
(
Constants
.
HISTORY_SUBJECT_DATE_QUEUE
+
subject
.
getSubjectCode
(),
redisCacheList
.
toArray
(
new
String
[
0
]));
}
}
...
...
src/main/java/com/zzsn/event/vo/InfoDataSearchCondition.java
浏览文件 @
b3b7b61e
...
...
@@ -97,6 +97,10 @@ public class InfoDataSearchCondition {
//数据集id,保存数据集时使用-研究中心
private
String
dataSetId
;
//待删除的标签id(多个用逗号隔开)-研究中心
private
String
removeRelationId
;
//关键词信息;推荐信息源时使用-研究中心
private
List
<
String
>
wordsList
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论