Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
dba7f4fd
提交
dba7f4fd
authored
1月 14, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
专题创建逻辑完善、接口补充以及bug修改
上级
2975571f
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
378 行增加
和
47 行删除
+378
-47
SubjectManageController.java
...va/com/zzsn/event/controller/SubjectManageController.java
+0
-2
SubjectSimpleController.java
...va/com/zzsn/event/controller/SubjectSimpleController.java
+71
-4
InformationController.java
...m/zzsn/event/controller/common/InformationController.java
+5
-2
EsService.java
src/main/java/com/zzsn/event/es/EsService.java
+2
-2
SubjectMapper.java
src/main/java/com/zzsn/event/mapper/SubjectMapper.java
+10
-1
LabelEntityMapper.xml
...main/java/com/zzsn/event/mapper/xml/LabelEntityMapper.xml
+1
-1
SubjectMapper.xml
src/main/java/com/zzsn/event/mapper/xml/SubjectMapper.xml
+30
-0
SubjectSimpleService.java
...ain/java/com/zzsn/event/service/SubjectSimpleService.java
+68
-0
InformationServiceImpl.java
...a/com/zzsn/event/service/impl/InformationServiceImpl.java
+10
-18
SubjectServiceImpl.java
.../java/com/zzsn/event/service/impl/SubjectServiceImpl.java
+21
-11
SubjectSimpleServiceImpl.java
...com/zzsn/event/service/impl/SubjectSimpleServiceImpl.java
+124
-5
EsOpUtil.java
src/main/java/com/zzsn/event/util/EsOpUtil.java
+33
-0
SubjectDetailVO.java
src/main/java/com/zzsn/event/vo/SubjectDetailVO.java
+2
-0
SpecialInformation.java
src/main/java/com/zzsn/event/vo/es/SpecialInformation.java
+1
-1
没有找到文件。
src/main/java/com/zzsn/event/controller/SubjectManageController.java
浏览文件 @
dba7f4fd
...
...
@@ -128,8 +128,6 @@ public class SubjectManageController {
public
Result
<?>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
UserVo
loginUser
=
AuthUtil
.
getLoginUser
();
subjectCondition
.
setUsername
(
loginUser
.
getUsername
());
Page
<
SubjectPage
>
pageList
=
subjectService
.
researchCenterPageList
(
subjectCondition
,
pageNo
,
pageSize
);
return
Result
.
OK
(
pageList
);
}
...
...
src/main/java/com/zzsn/event/controller/SubjectSimpleController.java
浏览文件 @
dba7f4fd
package
com
.
zzsn
.
event
.
controller
;
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.Subject
;
import
com.zzsn.event.es.EsService
;
import
com.zzsn.event.service.SubjectService
;
import
com.zzsn.event.service.SubjectSimpleService
;
import
com.zzsn.event.vo.
SearchWordVO
;
import
com.zzsn.event.vo.
InfoDataSearchCondition
;
import
com.zzsn.event.vo.SubjectDetailVO
;
import
com.zzsn.event.vo.SubjectSimpleVO
;
import
com.zzsn.event.vo.es.SpecialInformation
;
import
com.zzsn.event.xxljob.service.IXxlJobInfoService
;
import
lombok.extern.slf4j.Slf4j
;
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.concurrent.CompletableFuture
;
/**
* 专题管理流程简化版
...
...
@@ -30,6 +38,8 @@ public class SubjectSimpleController {
private
SubjectService
subjectService
;
@Autowired
private
IXxlJobInfoService
xxlJobInfoService
;
@Autowired
private
EsService
esService
;
/**
* 创建专题
...
...
@@ -68,9 +78,66 @@ public class SubjectSimpleController {
*/
@GetMapping
(
"/queryInfo"
)
public
Result
<?>
queryInfo
(
@RequestParam
String
subjectId
){
SubjectDetailVO
subjectDetailVO
=
subjectService
.
queryInfo
(
subjectId
);
List
<
SearchWordVO
>
list
=
subjectSimpleService
.
subjectBindWordInfo
(
subjectId
);
subjectDetailVO
.
setKeywords
(
list
);
SubjectDetailVO
subjectDetailVO
=
subjectSimpleService
.
queryInfo
(
subjectId
);
return
Result
.
OK
(
subjectDetailVO
);
}
/**
* 删除专题
*
* @param subjectId 专题id
* @return
*/
@GetMapping
(
value
=
"/removeSubject"
)
public
Result
<?>
removeSubject
(
@RequestParam
String
subjectId
)
{
subjectSimpleService
.
removeSubject
(
subjectId
);
CompletableFuture
.
runAsync
(()
->
{
//删除xxljob里面的信息
LambdaQueryWrapper
<
Subject
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
Subject:
:
getId
,
subjectId
);
Subject
subject
=
subjectService
.
getOne
(
queryWrapper
);
xxlJobInfoService
.
deleteByInfosourceCode
(
subject
.
getSubjectCode
());
});
return
Result
.
OK
();
}
/**
* 批量添加至精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
@PostMapping
(
"/selected"
)
public
Result
<?>
selected
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
subjectSimpleService
.
selected
(
searchCondition
);
return
Result
.
OK
();
}
/**
* 批量移除精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
@PostMapping
(
"/removeSelected"
)
public
Result
<?>
removeSelected
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
subjectSimpleService
.
removeSelected
(
searchCondition
);
return
Result
.
OK
();
}
/**
* 批量删除
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
@PostMapping
(
"/batchRemove"
)
public
Result
<?>
batchRemove
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
subjectSimpleService
.
batchRemove
(
searchCondition
);
return
Result
.
OK
();
}
}
src/main/java/com/zzsn/event/controller/common/InformationController.java
浏览文件 @
dba7f4fd
...
...
@@ -77,7 +77,7 @@ public class InformationController {
* @date 2024/12/24
*/
@GetMapping
(
"/listBeInStorage"
)
public
Result
<?>
listBeInStorage
(
@RequestParam
()
String
subjectId
,
@RequestParam
()
String
ids
)
{
public
Result
<?>
listBeInStorage
(
@RequestParam
String
subjectId
,
@RequestParam
String
ids
)
{
List
<
String
>
list
=
esService
.
listBeInStorage
(
subjectId
,
ids
);
return
Result
.
OK
(
list
);
}
...
...
@@ -146,7 +146,7 @@ public class InformationController {
/**
* 专题下模型绑定的标签信息
* 专题下模型绑定的标签信息
-筛选条件
*
* @param subjectId 专题id
* @author lkg
...
...
@@ -199,6 +199,9 @@ public class InformationController {
*/
@PostMapping
(
"/subjectPageList"
)
public
Result
<?>
subjectPageList
(
@RequestBody
InfoDataSearchCondition
searchCondition
)
{
if
(
StringUtils
.
isEmpty
(
searchCondition
.
getSubjectId
()))
{
return
Result
.
FAIL
(
"专题id不能为空"
);
}
UserVo
userVo
=
AuthUtil
.
getLoginUser
();
IPage
<
DisplayInfo
>
pageList
=
informationService
.
subjectPageList
(
userVo
,
searchCondition
);
return
Result
.
OK
(
pageList
);
...
...
src/main/java/com/zzsn/event/es/EsService.java
浏览文件 @
dba7f4fd
...
...
@@ -767,7 +767,7 @@ public class EsService {
for
(
SearchHit
hit
:
searchHits
)
{
String
queryInfo
=
hit
.
getSourceAsString
();
SpecialInformation
info
=
JSONUtil
.
toBean
(
queryInfo
,
SpecialInformation
.
class
);
info
.
setIndex
(
hit
.
getIndex
());
info
.
set
Db
Index
(
hit
.
getIndex
());
list
.
add
(
info
);
}
IPage
<
SpecialInformation
>
pageData
=
new
Page
<>(
pageNo
,
pageSize
,
searchResponse
.
getHits
().
getTotalHits
().
value
);
...
...
@@ -1174,7 +1174,7 @@ public class EsService {
String
queryInfo
=
hit
.
getSourceAsString
();
SpecialInformation
info
=
JSON
.
parseObject
(
queryInfo
,
SpecialInformation
.
class
);
info
.
setPublishDate
(
EsDateUtil
.
esFieldDateMapping
(
info
.
getPublishDate
()));
info
.
setIndex
(
hit
.
getIndex
());
info
.
set
Db
Index
(
hit
.
getIndex
());
dataList
.
add
(
info
);
}
}
catch
(
IOException
e
)
{
...
...
src/main/java/com/zzsn/event/mapper/SubjectMapper.java
浏览文件 @
dba7f4fd
...
...
@@ -29,7 +29,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
Page
<
SubjectPage
>
pageList
(
@Param
(
"subjectCondition"
)
SubjectCondition
subjectCondition
,
Page
<
SubjectPage
>
page
);
/**
* 专题分页列表-研究中心
* 专题分页列表
(个人)
-研究中心
*
* @param subjectCondition 查询条件
* @param page 分页参数
...
...
@@ -37,6 +37,15 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @date 2024/12/18
*/
Page
<
SubjectPage
>
researchCenterPageList
(
@Param
(
"subjectCondition"
)
SubjectCondition
subjectCondition
,
Page
<
SubjectPage
>
page
);
/**
* 专题分页列表(公开)-研究中心
*
* @param subjectCondition 查询条件
* @param page 分页参数
* @author lkg
* @date 2025/1/14
*/
Page
<
SubjectPage
>
researchCenterFacePageList
(
@Param
(
"subjectCondition"
)
SubjectCondition
subjectCondition
,
Page
<
SubjectPage
>
page
);
/**
* 获取专题详情(包含样例文章信息)
...
...
src/main/java/com/zzsn/event/mapper/xml/LabelEntityMapper.xml
浏览文件 @
dba7f4fd
...
...
@@ -43,7 +43,7 @@
select id,name_cn as name,pid,top_id,'region_out' as labelMark,'region_label' as labelType from sys_base_region
</select>
<select
id=
"industryList"
resultType=
"com.zzsn.event.vo.LabelTypeVO"
>
select id,name_cn as name,pid,
top_id,
'standard-industry' as labelMark,'industry_label' as labelType from sys_base_industry
select id,name_cn as name,pid,'standard-industry' as labelMark,'industry_label' as labelType from sys_base_industry
</select>
<select
id=
"queryCustomLabel"
resultType=
"com.zzsn.event.vo.SysLabelVo"
>
...
...
src/main/java/com/zzsn/event/mapper/xml/SubjectMapper.xml
浏览文件 @
dba7f4fd
...
...
@@ -112,9 +112,38 @@
</if>
order by d.create_time desc
</select>
<select
id=
"researchCenterFacePageList"
resultType=
"com.zzsn.event.vo.SubjectPage"
>
SELECT d.id,
d.subject_name,
d.remark,
d.create_time,
d.status,
c.type_name as subjectTypeName
from subject d
LEFT JOIN subject_type_map b ON b.subject_id = d.id
LEFT JOIN subject_type c ON b.type_id = c.id
where face_public = 1
<if
test=
"subjectCondition.id !=null and subjectCondition.id !=''"
>
and d.id =#{subjectCondition.id}
</if>
<if
test=
"subjectCondition.subjectName!=null and subjectCondition.subjectName != ''"
>
and d.subject_name like CONCAT('%',#{subjectCondition.subjectName},'%')
</if>
<if
test=
"subjectCondition.startTime != null and subjectCondition.startTime != ''"
>
and d.create_time >= #{subjectCondition.startTime}
</if>
<if
test=
"subjectCondition.endTime != null and subjectCondition.endTime != ''"
>
and d.create_time
<![CDATA[ <= ]]>
#{subjectCondition.endTime}
</if>
<if
test=
"subjectCondition.status!=null"
>
and d.status = #{subjectCondition.status}
</if>
order by d.create_time desc
</select>
<resultMap
id=
"SubjectDetailVOMap"
type=
"com.zzsn.event.vo.SubjectDetailVO"
>
<result
column=
"subject_name"
property=
"subjectName"
/>
<result
column=
"subjectTypeId"
property=
"subjectTypeId"
/>
<result
column=
"subjectTypeName"
property=
"subjectTypeName"
/>
<result
column=
"remark"
property=
"remark"
/>
<result
column=
"data_source"
property=
"dataSource"
/>
...
...
@@ -138,6 +167,7 @@
s.data_source,
s.face_public,
s.library,
c.id as subjectTypeId,
c.type_name as subjectTypeName,
f.id,
f.file_name,
...
...
src/main/java/com/zzsn/event/service/SubjectSimpleService.java
浏览文件 @
dba7f4fd
package
com
.
zzsn
.
event
.
service
;
import
com.zzsn.event.entity.Subject
;
import
com.zzsn.event.vo.InfoDataSearchCondition
;
import
com.zzsn.event.vo.SearchWordVO
;
import
com.zzsn.event.vo.SubjectDetailVO
;
import
com.zzsn.event.vo.SubjectSimpleVO
;
import
java.util.List
;
...
...
@@ -14,9 +16,75 @@ import java.util.List;
*/
public
interface
SubjectSimpleService
{
/**
* 新增专题
*
* @param subjectSimpleVO 参数
* @author lkg
* @date 2025/1/14
*/
Subject
createSubject
(
SubjectSimpleVO
subjectSimpleVO
);
/**
* 编辑专题
*
* @param subjectSimpleVO 参数
* @author lkg
* @date 2025/1/14
*/
void
editSubject
(
SubjectSimpleVO
subjectSimpleVO
);
/**
* 专题绑定关键词信息
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/14
*/
List
<
SearchWordVO
>
subjectBindWordInfo
(
String
subjectId
);
/**
* 专题详情(包含样例文章以及关键词)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/14
*/
SubjectDetailVO
queryInfo
(
String
subjectId
);
/**
* 删除专题
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/14
*/
void
removeSubject
(
String
subjectId
);
/**
* 批量添加至精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
void
selected
(
InfoDataSearchCondition
searchCondition
);
/**
* 批量移除精选
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
void
removeSelected
(
InfoDataSearchCondition
searchCondition
);
/**
* 批量删除
*
* @param searchCondition 检索条件
* @author lkg
* @date 2025/1/14
*/
void
batchRemove
(
InfoDataSearchCondition
searchCondition
);
}
src/main/java/com/zzsn/event/service/impl/InformationServiceImpl.java
浏览文件 @
dba7f4fd
...
...
@@ -174,8 +174,7 @@ public class InformationServiceImpl implements InformationService {
Label
dataSet
=
new
Label
();
String
dataSetId
=
searchCondition
.
getDataSetId
();
dataSet
.
setRelationId
(
dataSetId
);
//totalMap结构 index >> id >> updateField
Map
<
String
,
Map
<
String
,
Map
<
String
,
Object
>>>
totalMap
=
new
HashMap
<>();
Map
<
String
,
List
<
SpecialInformation
>>
map
=
new
HashMap
<>();
for
(
int
i
=
1
;
;
i
++)
{
searchCondition
.
setPageNo
(
i
);
List
<
SpecialInformation
>
informationList
=
esService
.
informationList
(
searchCondition
);
...
...
@@ -184,8 +183,7 @@ public class InformationServiceImpl implements InformationService {
break
;
}
for
(
SpecialInformation
information
:
informationList
)
{
String
id
=
information
.
getId
();
String
index
=
information
.
getIndex
();
String
index
=
information
.
getDbIndex
();
List
<
Label
>
labels
=
information
.
getLabels
();
if
(
CollectionUtils
.
isNotEmpty
(
labels
))
{
boolean
present
=
labels
.
stream
().
anyMatch
(
label
->
label
.
getRelationId
().
equals
(
dataSetId
));
...
...
@@ -195,23 +193,17 @@ public class InformationServiceImpl implements InformationService {
}
else
{
labels
.
add
(
dataSet
);
}
Map
<
String
,
Object
>
updateField
=
new
HashMap
<>();
updateField
.
put
(
"labels"
,
labels
);
if
(
totalMap
.
containsKey
(
index
))
{
totalMap
.
get
(
index
).
put
(
id
,
updateField
);
information
.
setLabels
(
labels
);
if
(
map
.
containsKey
(
index
))
{
map
.
get
(
index
).
add
(
information
);
}
else
{
//updateFields结构 id >> updateField
Map
<
String
,
Map
<
String
,
Object
>>
updateFields
=
new
HashMap
<>();
updateFields
.
put
(
id
,
updateField
);
totalMap
.
put
(
index
,
updateFields
);
List
<
SpecialInformation
>
list
=
new
ArrayList
<>();
list
.
add
(
information
);
map
.
put
(
index
,
list
);
}
}
}
for
(
Map
.
Entry
<
String
,
Map
<
String
,
Map
<
String
,
Object
>>>
entry
:
totalMap
.
entrySet
())
{
String
index
=
entry
.
getKey
();
Map
<
String
,
Map
<
String
,
Object
>>
value
=
entry
.
getValue
();
esOpUtil
.
bulkUpdateFields
(
index
,
value
);
}
map
.
forEach
((
k
,
v
)
->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
}
@Override
...
...
@@ -372,7 +364,7 @@ public class InformationServiceImpl implements InformationService {
public
void
updateInfo
(
JSONObject
jsonObject
,
UserVo
userVo
)
{
SpecialInformation
specialInformation
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
jsonObject
.
get
(
"data"
)),
SpecialInformation
.
class
);
Integer
category
=
(
Integer
)
jsonObject
.
get
(
"category"
);
String
index
=
specialInformation
.
getIndex
();
String
index
=
specialInformation
.
get
Db
Index
();
specialInformation
.
setIndex
(
null
);
//更新content字段
if
(
StringUtils
.
isNotBlank
(
specialInformation
.
getContentWithTag
()))
{
...
...
src/main/java/com/zzsn/event/service/impl/SubjectServiceImpl.java
浏览文件 @
dba7f4fd
...
...
@@ -25,6 +25,8 @@ import com.zzsn.event.util.CodeGenerateUtil;
import
com.zzsn.event.util.CronUtil
;
import
com.zzsn.event.util.HttpUtil
;
import
com.zzsn.event.util.RedisUtil
;
import
com.zzsn.event.util.user.AuthUtil
;
import
com.zzsn.event.util.user.UserVo
;
import
com.zzsn.event.vo.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -127,15 +129,23 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
@Override
public
Page
<
SubjectPage
>
researchCenterPageList
(
SubjectCondition
subjectCondition
,
Integer
pageNo
,
Integer
pageSize
)
{
//查询类别id的所有明细id
List
<
String
>
typeIds
=
new
ArrayList
<>();
String
subjectTypeId
=
subjectCondition
.
getSubjectTypeId
();
if
(
StringUtils
.
isNotEmpty
(
subjectTypeId
)
&&
!
"0"
.
equals
(
subjectTypeId
))
{
typeIds
=
subjectTypeService
.
researchCenterBelowIdList
(
subjectTypeId
,
1
);
}
subjectCondition
.
setTypeIds
(
typeIds
);
Integer
facePublic
=
subjectCondition
.
getFacePublic
();
Page
<
SubjectPage
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
return
baseMapper
.
researchCenterPageList
(
subjectCondition
,
page
);
if
(
facePublic
==
1
)
{
page
=
baseMapper
.
researchCenterFacePageList
(
subjectCondition
,
page
);
}
else
{
//查询类别id的所有明细id
List
<
String
>
typeIds
=
new
ArrayList
<>();
String
subjectTypeId
=
subjectCondition
.
getSubjectTypeId
();
if
(
StringUtils
.
isNotEmpty
(
subjectTypeId
)
&&
!
"0"
.
equals
(
subjectTypeId
))
{
typeIds
=
subjectTypeService
.
researchCenterBelowIdList
(
subjectTypeId
,
1
);
}
subjectCondition
.
setTypeIds
(
typeIds
);
UserVo
loginUser
=
AuthUtil
.
getLoginUser
();
subjectCondition
.
setUsername
(
loginUser
.
getUsername
());
page
=
baseMapper
.
researchCenterPageList
(
subjectCondition
,
page
);
}
return
page
;
}
@Override
...
...
@@ -187,8 +197,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
}*/
//判断开始时间和结束时间是否发生变动
Date
newTimeEnable
=
subjectPage
.
getTimeEnable
();
//判断开始时间和结束时间是否发生变动
todo 还需要吗
/*
Date newTimeEnable = subjectPage.getTimeEnable();
Date oldTimeEnable = oldSubject.getTimeEnable();
if (!((newTimeEnable == null && oldTimeEnable == null) ||
(newTimeEnable != null && oldTimeEnable != null && oldTimeEnable.compareTo(newTimeEnable) == 0))) {
...
...
@@ -200,7 +210,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
}
//更新redis中关键词时间
updateRedisKeyWordsDate(subjectPage.getId(), keyWordIds);
}
}
*/
}
@Override
...
...
src/main/java/com/zzsn/event/service/impl/SubjectSimpleServiceImpl.java
浏览文件 @
dba7f4fd
...
...
@@ -6,21 +6,22 @@ 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.CodePrefixEnum
;
import
com.zzsn.event.es.EsService
;
import
com.zzsn.event.service.*
;
import
com.zzsn.event.util.CodeGenerateUtil
;
import
com.zzsn.event.vo.SearchWordVO
;
import
com.zzsn.event.vo.SubjectKeywordsMap
;
import
com.zzsn.event.vo.SubjectPage
;
import
com.zzsn.event.vo.SubjectSimpleVO
;
import
com.zzsn.event.util.EsOpUtil
;
import
com.zzsn.event.vo.*
;
import
com.zzsn.event.vo.es.SpecialInformation
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* 简化专题创建流程
...
...
@@ -43,8 +44,22 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
private
ISubjectKeywordsMapService
subjectKeywordsMapService
;
@Autowired
private
ClbModelArrangeSubjectMapService
clbModelArrangeSubjectMapService
;
@Autowired
private
ISubjectTypeMapService
subjectTypeMapService
;
@Autowired
private
IProjectSubjectMapService
projectSubjectMapService
;
@Autowired
private
ISubjectSearchEnginesMapService
subjectSearchEnginesMapService
;
@Autowired
private
ISubjectInfoSourceMapService
subjectInfoSourceMapService
;
@Autowired
private
ISubjectModelMapService
subjectModelMapService
;
@Autowired
private
EsService
esService
;
@Autowired
private
EsOpUtil
esOpUtil
;
@Autowired
private
CodeGenerateUtil
codeGenerateUtil
;
private
final
static
String
KEYWORDS_TYPE_ID
=
"1476498704680194050"
;
...
...
@@ -124,6 +139,110 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
return
wordList
;
}
@Override
public
SubjectDetailVO
queryInfo
(
String
subjectId
)
{
SubjectDetailVO
subjectDetailVO
=
subjectService
.
queryInfo
(
subjectId
);
if
(
subjectDetailVO
!=
null
)
{
List
<
SearchWordVO
>
list
=
this
.
subjectBindWordInfo
(
subjectId
);
subjectDetailVO
.
setKeywords
(
list
);
}
return
subjectDetailVO
;
}
@Override
public
void
removeSubject
(
String
subjectId
)
{
subjectService
.
removeById
(
subjectId
);
CompletableFuture
.
runAsync
(()->{
//删除与类别的映射
subjectTypeMapService
.
deleteBySubjectId
(
subjectId
);
//删除与信息源的关联关系
subjectInfoSourceMapService
.
delete
(
subjectId
);
//获取绑定的关键词
LambdaQueryWrapper
<
SubjectKeywordsMap
>
queryWrapper
=
Wrappers
.
lambdaQuery
();
queryWrapper
.
eq
(
SubjectKeywordsMap:
:
getSubjectId
,
subjectId
);
List
<
SubjectKeywordsMap
>
list
=
subjectKeywordsMapService
.
list
(
queryWrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
List
<
String
>
keywordIds
=
list
.
stream
().
map
(
SubjectKeywordsMap:
:
getKeywordsId
).
collect
(
Collectors
.
toList
());
//删除关键词
keywordWordsService
.
removeByIds
(
keywordIds
);
//删除与关键词组的关联关系
subjectKeywordsMapService
.
delete
(
subjectId
);
//删除关键词组关联关系
subjectKeywordsGroupRelationService
.
remove
(
Wrappers
.<
SubjectKeywordsGroupRelation
>
lambdaQuery
().
eq
(
SubjectKeywordsGroupRelation:
:
getSubjectId
,
subjectId
));
}
//删除专题-项目的绑定关系
projectSubjectMapService
.
deleteBySubjectId
(
subjectId
);
//删除事件-模型关系
subjectModelMapService
.
remove
(
Wrappers
.<
SubjectModelMap
>
lambdaQuery
().
eq
(
SubjectModelMap:
:
getSubjectId
,
subjectId
));
//删除事件-搜索引擎关系
subjectSearchEnginesMapService
.
remove
(
Wrappers
.<
SubjectSearchEnginesMap
>
lambdaQuery
().
eq
(
SubjectSearchEnginesMap:
:
getSubjectId
,
subjectId
));
//删除专题/事件-tpu流程关系
clbModelArrangeSubjectMapService
.
remove
(
Wrappers
.<
ClbModelArrangeSubjectMap
>
lambdaQuery
().
eq
(
ClbModelArrangeSubjectMap:
:
getSubjectId
,
subjectId
));
//向python发送消息结束
subjectService
.
send
(
subjectId
,
"-1"
);
});
}
@Override
public
void
selected
(
InfoDataSearchCondition
searchCondition
)
{
String
[]
fetchFields
=
new
String
[]{
"id"
,
"checkStatus"
};
searchCondition
.
setFetchFields
(
fetchFields
);
Map
<
String
,
List
<
SpecialInformation
>>
updateMap
=
new
HashMap
<>();
List
<
SpecialInformation
>
informationList
=
esService
.
informationList
(
searchCondition
);
for
(
SpecialInformation
information
:
informationList
)
{
String
index
=
information
.
getDbIndex
();
information
.
setCheckStatus
(
1
);
if
(
updateMap
.
containsKey
(
index
))
{
updateMap
.
get
(
index
).
add
(
information
);
}
else
{
List
<
SpecialInformation
>
list
=
new
ArrayList
<>();
list
.
add
(
information
);
updateMap
.
put
(
index
,
list
);
}
}
updateMap
.
forEach
((
k
,
v
)->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
}
@Override
public
void
removeSelected
(
InfoDataSearchCondition
searchCondition
)
{
String
[]
fetchFields
=
new
String
[]{
"id"
,
"checkStatus"
};
searchCondition
.
setFetchFields
(
fetchFields
);
Map
<
String
,
List
<
SpecialInformation
>>
updateMap
=
new
HashMap
<>();
List
<
SpecialInformation
>
informationList
=
esService
.
informationList
(
searchCondition
);
for
(
SpecialInformation
information
:
informationList
)
{
String
index
=
information
.
getDbIndex
();
information
.
setCheckStatus
(
0
);
if
(
updateMap
.
containsKey
(
index
))
{
updateMap
.
get
(
index
).
add
(
information
);
}
else
{
List
<
SpecialInformation
>
list
=
new
ArrayList
<>();
list
.
add
(
information
);
updateMap
.
put
(
index
,
list
);
}
}
updateMap
.
forEach
((
k
,
v
)->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
}
@Override
public
void
batchRemove
(
InfoDataSearchCondition
searchCondition
)
{
String
[]
fetchFields
=
new
String
[]{
"id"
,
"deleteFlag"
};
searchCondition
.
setFetchFields
(
fetchFields
);
Map
<
String
,
List
<
SpecialInformation
>>
updateMap
=
new
HashMap
<>();
List
<
SpecialInformation
>
informationList
=
esService
.
informationList
(
searchCondition
);
for
(
SpecialInformation
information
:
informationList
)
{
String
index
=
information
.
getDbIndex
();
information
.
setDeleteFlag
(
1
);
if
(
updateMap
.
containsKey
(
index
))
{
updateMap
.
get
(
index
).
add
(
information
);
}
else
{
List
<
SpecialInformation
>
list
=
new
ArrayList
<>();
list
.
add
(
information
);
updateMap
.
put
(
index
,
list
);
}
}
updateMap
.
forEach
((
k
,
v
)->
esOpUtil
.
docUpdateBulk
(
k
,
v
));
}
//目标集合按照另一个集合的顺序排序
private
void
sortByAnotherList
(
List
<
SearchWordVO
>
list
,
List
<
String
>
anotherList
)
{
list
.
sort
((
o1
,
o2
)
->
{
...
...
src/main/java/com/zzsn/event/util/EsOpUtil.java
浏览文件 @
dba7f4fd
...
...
@@ -7,6 +7,8 @@ import com.alibaba.fastjson2.JSON;
import
com.alibaba.fastjson2.JSONObject
;
import
com.alibaba.fastjson2.JSONWriter
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.zzsn.event.vo.es.Label
;
import
com.zzsn.event.vo.es.SpecialInformation
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.elasticsearch.action.ActionListener
;
...
...
@@ -496,6 +498,35 @@ public class EsOpUtil<T> {
return
false
;
}
public
void
docUpdateBulk
(
String
index
,
List
<
SpecialInformation
>
dataList
){
BulkRequest
bulkRequest
=
new
BulkRequest
();
for
(
SpecialInformation
information
:
dataList
)
{
UpdateRequest
request
=
new
UpdateRequest
(
index
,
information
.
getId
());
request
.
doc
(
JSON
.
toJSONString
(
information
),
XContentType
.
JSON
);
bulkRequest
.
add
(
request
);
}
// 执行更新请求
client
.
bulkAsync
(
bulkRequest
,
RequestOptions
.
DEFAULT
,
new
ActionListener
<
BulkResponse
>()
{
@Override
public
void
onResponse
(
BulkResponse
bulkItemResponses
)
{
BulkItemResponse
[]
bulkItems
=
bulkItemResponses
.
getItems
();
for
(
BulkItemResponse
response
:
bulkItems
)
{
if
(
response
.
isFailed
())
{
//查看所有请求失败结果
log
.
info
(
"批量更新[{}]过程中,id为[{}]的更新失败,失败原因[{}]"
,
response
.
getIndex
(),
response
.
getId
(),
response
.
getFailureMessage
());
}
else
{
//请求成功的
log
.
info
(
"批量更新[{}]过程中,id为[{}]的更新成功,状态[{}],version[{}]"
,
response
.
getIndex
(),
response
.
getId
(),
response
.
status
(),
response
.
getVersion
());
}
}
}
@Override
public
void
onFailure
(
Exception
e
)
{
log
.
warn
(
"批量[{}]更新失败,失败原因[{}]"
,
index
,
e
.
getMessage
());
}
});
}
/**
* 批量删除
*
...
...
@@ -745,6 +776,8 @@ public class EsOpUtil<T> {
for
(
BulkItemResponse
response
:
bulkItemResponses
)
{
if
(
response
.
isFailed
())
{
log
.
info
(
"批量更新字段[{}]过程中,id为[{}]的更新失败,失败原因[{}]"
,
response
.
getIndex
(),
response
.
getId
(),
response
.
getFailureMessage
());
}
else
{
log
.
info
(
"批量保存[{}]过程中,id为[{}]的保存成功,状态[{}],version[{}]"
,
response
.
getIndex
(),
response
.
getId
(),
response
.
status
(),
response
.
getVersion
());
}
}
}
catch
(
IOException
e
)
{
...
...
src/main/java/com/zzsn/event/vo/SubjectDetailVO.java
浏览文件 @
dba7f4fd
...
...
@@ -36,6 +36,8 @@ public class SubjectDetailVO {
/**划分专题库*/
private
String
library
;
/**专题分类id*/
private
String
subjectTypeId
;
/**专题分类名称*/
private
String
subjectTypeName
;
/**专题下的样例文章*/
...
...
src/main/java/com/zzsn/event/vo/es/SpecialInformation.java
浏览文件 @
dba7f4fd
...
...
@@ -123,7 +123,7 @@ public class SpecialInformation {
*/
private
Integer
ismain
;
//数据所在的索引名称
private
Stri
ng
index
;
private
Lo
ng
index
;
//关键词
private
List
<
String
>
keyWordsList
;
//命中词
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论