Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
4a641297
提交
4a641297
authored
3月 06, 2025
作者:
925993793@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【fix】事情配置修改后资讯处理逻辑补充
上级
b959657d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
51 行增加
和
2 行删除
+51
-2
FileController.java
src/main/java/com/zzsn/event/controller/FileController.java
+0
-2
EventSimpleService.java
src/main/java/com/zzsn/event/service/EventSimpleService.java
+41
-0
EventServiceImpl.java
...in/java/com/zzsn/event/service/impl/EventServiceImpl.java
+10
-0
没有找到文件。
src/main/java/com/zzsn/event/controller/FileController.java
浏览文件 @
4a641297
...
...
@@ -29,8 +29,6 @@ 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
;
...
...
src/main/java/com/zzsn/event/service/EventSimpleService.java
浏览文件 @
4a641297
package
com
.
zzsn
.
event
.
service
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.zzsn.event.constant.Constants
;
import
com.zzsn.event.entity.*
;
import
com.zzsn.event.enums.CodePrefixEnum
;
import
com.zzsn.event.util.CodeGenerateUtil
;
import
com.zzsn.event.util.CronUtil
;
import
com.zzsn.event.util.DateUtil
;
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.AddEventVO
;
...
...
@@ -16,6 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -43,6 +48,9 @@ public class EventSimpleService {
@Autowired
private
EventRegionMapService
eventRegionMapService
;
@Autowired
private
RedisUtil
redisUtil
;
//默认搜索引擎
/**
...
...
@@ -94,6 +102,7 @@ public class EventSimpleService {
public
void
updateMain
(
AddEventVO
addEventVO
){
String
eventId
=
addEventVO
.
getId
();
Event
oldEvent
=
eventService
.
getById
(
eventId
);
Event
event
=
new
Event
();
BeanUtils
.
copyProperties
(
addEventVO
,
event
);
eventService
.
updateById
(
event
);
...
...
@@ -102,6 +111,8 @@ public class EventSimpleService {
eventRegionMapService
.
remove
(
Wrappers
.<
EventRegionMap
>
lambdaQuery
().
eq
(
EventRegionMap:
:
getEventId
,
eventId
));
List
<
RegionVO
>
regionList
=
addEventVO
.
getRegionList
();
addRegionMap
(
eventId
,
regionList
);
//修改redis缓存,,用于向事件里补充数据
updateRedisCache
(
event
,
oldEvent
);
});
}
...
...
@@ -136,4 +147,34 @@ public class EventSimpleService {
eventRegionMapService
.
saveBatch
(
dataList
);
}
}
/**
* 修改事件时间缓存,用于补充数据(只有启用过的事件才会起作用)
*
* @param event 新事件信息
* @param oldEvent 旧事件信息
* @author lkg
* @date 2025/2/7
*/
private
void
updateRedisCache
(
Event
event
,
Event
oldEvent
)
{
Date
firstOpenTime
=
oldEvent
.
getFirstOpenTime
();
if
(
firstOpenTime
!=
null
)
{
Date
oldTimeEnable
=
oldEvent
.
getStartTime
();
LocalDate
oldStart
=
oldTimeEnable
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
();
Date
timeEnable
=
event
.
getStartTime
();
List
<
String
>
newDateList
=
new
ArrayList
<>();
LocalDate
start
=
timeEnable
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
();
if
(
start
.
isBefore
(
oldStart
))
{
for
(
LocalDate
date
=
start
;
date
.
isBefore
(
oldStart
);
date
=
date
.
plusDays
(
1
))
{
// 在这里处理每一天的逻辑
//格式化date成字符串
String
format
=
date
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
newDateList
.
add
(
format
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
newDateList
))
{
redisUtil
.
rpushMultipleValues
(
Constants
.
HISTORY_EVENT_DATE_QUEUE
+
event
.
getEventCode
(),
newDateList
.
toArray
(
new
String
[
0
]));
}
}
}
}
src/main/java/com/zzsn/event/service/impl/EventServiceImpl.java
浏览文件 @
4a641297
...
...
@@ -458,6 +458,8 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
LambdaUpdateWrapper
<
Event
>
updateWrapper
=
Wrappers
.
lambdaUpdate
();
updateWrapper
.
eq
(
Event:
:
getId
,
eventId
)
.
set
(
Event:
:
getStatus
,
0
)
.
set
(
Event:
:
getTotalHot
,
null
)
.
set
(
Event:
:
getRelationEvents
,
null
)
.
set
(
Event:
:
getFirstOpenTime
,
null
);
this
.
update
(
updateWrapper
);
CompletableFuture
.
runAsync
(()
->
{
...
...
@@ -474,12 +476,18 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
.
set
(
EventTag:
:
getExtractLocationTag
,
null
)
.
eq
(
EventTag:
:
getEventId
,
eventId
)
);
//删除redis中事件分析数据
redisUtil
.
del
(
Constants
.
SUBJECT_ANALYSIS_PRE
+
Constants
.
PROPAGATION_KEY
+
eventId
);
//调用python接口
pythonUtil
.
clearDuplicateHistory
(
Collections
.
singletonList
(
eventId
));
//清空专题数据
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
(
QueryBuilders
.
termQuery
(
"subjectId.keyword"
,
eventId
));
esOpUtil
.
docDeleteByQuery
(
Constants
.
SUBJECT_INDEX
,
boolQuery
);
//清空判重库的数据 repeathold
BoolQueryBuilder
bool
=
QueryBuilders
.
boolQuery
();
bool
.
must
(
QueryBuilders
.
termQuery
(
"subjectId"
,
eventId
));
esOpUtil
.
docDeleteByQuery
(
Constants
.
ES_REPEAT_OLD
,
bool
);
try
{
Thread
.
sleep
(
30000
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -494,6 +502,8 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
//删除数据处理到的时间节点
Event
event
=
this
.
getById
(
eventId
);
redisUtil
.
del
(
"SUBJECT_DATA_TO_REDIS::"
+
event
.
getEventCode
());
//立即执行一次
kafkaTemplate
.
send
(
EVENT_MODEL_KAFKA_CHANNEL
,
event
.
getEventCode
());
});
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论