Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
event
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
陈世强
event
Commits
0bbacb7c
提交
0bbacb7c
authored
3月 25, 2024
作者:
chenshiqiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compute
上级
3bf36b9c
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
490 行增加
和
26 行删除
+490
-26
Constants.java
src/main/java/com/zzsn/event/constant/Constants.java
+5
-0
EventController.java
src/main/java/com/zzsn/event/controller/EventController.java
+24
-3
Event.java
src/main/java/com/zzsn/event/entity/Event.java
+4
-0
SubjectInfoSourceMap.java
...main/java/com/zzsn/event/entity/SubjectInfoSourceMap.java
+47
-0
EventMapper.java
src/main/java/com/zzsn/event/mapper/EventMapper.java
+3
-2
SubjectInfoSourceMapMapper.java
...ava/com/zzsn/event/mapper/SubjectInfoSourceMapMapper.java
+36
-0
SubjectKeywordsMapMapper.java
.../java/com/zzsn/event/mapper/SubjectKeywordsMapMapper.java
+2
-0
EventMapper.xml
src/main/java/com/zzsn/event/mapper/xml/EventMapper.xml
+2
-2
SubjectInfoSourceMapMapper.xml
.../com/zzsn/event/mapper/xml/SubjectInfoSourceMapMapper.xml
+82
-0
IEventService.java
src/main/java/com/zzsn/event/service/IEventService.java
+6
-0
ISubjectInfoSourceMapService.java
.../com/zzsn/event/service/ISubjectInfoSourceMapService.java
+57
-0
ISubjectKeywordsMapService.java
...va/com/zzsn/event/service/ISubjectKeywordsMapService.java
+5
-0
EventServiceImpl.java
...in/java/com/zzsn/event/service/impl/EventServiceImpl.java
+132
-14
SubjectInfoSourceMapServiceImpl.java
...n/event/service/impl/SubjectInfoSourceMapServiceImpl.java
+71
-0
SubjectKeywordsMapServiceImpl.java
...zsn/event/service/impl/SubjectKeywordsMapServiceImpl.java
+6
-1
AnalysisTask.java
src/main/java/com/zzsn/event/task/AnalysisTask.java
+2
-2
application.yml
src/main/resources/application.yml
+6
-2
没有找到文件。
src/main/java/com/zzsn/event/constant/Constants.java
浏览文件 @
0bbacb7c
...
...
@@ -15,6 +15,11 @@ public class Constants {
* 关键词数据入缓存 key前缀
*/
public
static
final
String
KEY_WORDS_TO_REDIS_PREFIX
=
"KEY_WORDS_TO_REDIS::"
;
public
static
final
String
MAX_TOTAL_HOT_SCORE
=
"MAX_TOTAL_HOT_SCORE"
;
public
static
final
String
MAX_MEDIA_HOT_SCORE
=
"MAX_MEDIA_HOT_SCORE"
;
public
static
final
String
MAX_WECHAT_HOT_SCORE
=
"MAX_WECHAT_HOT_SCORE"
;
public
static
final
String
MAX_OTHER_HOT_SCORE
=
"MAX_OTHER_HOT_SCORE"
;
public
static
String
[]
FETCH_FIELDS_STATISTIC
=
{
"id"
,
"subjectId"
,
"title"
,
"origin"
,
"publishDate"
,
"sourceAddress"
,
"masterEntryId"
,
"infoSourceType"
};
public
static
String
[]
FETCH_FIELDS_DATA
=
{
"id"
,
"subjectId"
,
"title"
,
"content"
,
"publishDate"
,
"origin"
,
"sourceAddress"
,
"masterEntryId"
,
"infoSourceType"
};
//es 专题库索引
...
...
src/main/java/com/zzsn/event/controller/EventController.java
浏览文件 @
0bbacb7c
...
...
@@ -20,9 +20,13 @@ import org.apache.commons.lang3.ObjectUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.springframework.web.util.WebUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
/**
* 事件
...
...
@@ -72,7 +76,7 @@ public class EventController {
/**
* 添加
*
* @param event
* @param event
Param
* @return
*/
@ApiOperation
(
value
=
"事件-添加"
,
notes
=
"事件-添加"
)
...
...
@@ -125,7 +129,9 @@ public class EventController {
@ApiOperation
(
value
=
"事件-通过id删除"
,
notes
=
"事件-通过id删除"
)
@DeleteMapping
(
value
=
"/delete"
)
public
Result
<?>
delete
(
@RequestParam
(
name
=
"id"
,
required
=
true
)
String
id
)
{
eventService
.
removeById
(
id
);
Event
event
=
eventService
.
getById
(
id
);
iXxlJobInfoService
.
deleteByInfosourceCode
(
event
.
getEventCode
());
eventService
.
deleteMain
(
id
);
return
Result
.
OK
(
"删除成功!"
);
}
...
...
@@ -163,7 +169,7 @@ public class EventController {
public
Object
infoSourceBind
(
@RequestBody
SubjectPage
subjectPage
)
{
try
{
JSONObject
params
=
ObjectUtil
.
objectToJSONObject
(
subjectPage
);;
String
url
=
SERVICE_PROJECT_URL
+
"e
nterpriseData/getYearReportList
"
;
String
url
=
SERVICE_PROJECT_URL
+
"e
vent/infoSource/infoSourceBind
"
;
return
RestUtil
.
post
(
url
,
null
,
params
);
}
catch
(
Exception
e
)
{
return
null
;
...
...
@@ -273,4 +279,19 @@ public class EventController {
List
<
SubjectAnalysis
>
cacheList
=
analysisService
.
eventContext
(
subjectId
,
fakeNum
);
return
Result
.
OK
(
cacheList
);
}
/**
* 添上传
*
* @return
*/
@PostMapping
(
value
=
"/upload"
)
@ResponseBody
public
Result
<?>
uploadKnowledge
(
HttpServletRequest
request
)
{
MultipartHttpServletRequest
multipartRequest
=
(
MultipartHttpServletRequest
)
request
;
MultipartFile
file
=
multipartRequest
.
getFile
(
"file"
);
// 获取上传文件对象
String
orgName
=
file
.
getOriginalFilename
();
// 获取文件名
String
url
=
eventService
.
upload
(
file
);
return
Result
.
OK
(
url
);
}
}
src/main/java/com/zzsn/event/entity/Event.java
浏览文件 @
0bbacb7c
...
...
@@ -119,4 +119,8 @@ public class Event {
/**事件专题时间间隔分析规则(天)*/
@ApiModelProperty
(
value
=
"事件专题时间间隔分析规则(天)"
)
private
Integer
timeAnaRule
;
private
Integer
totalHot
;
private
Integer
mediaHot
;
private
Integer
wechatHot
;
private
Integer
otherHot
;
}
src/main/java/com/zzsn/event/entity/SubjectInfoSourceMap.java
0 → 100644
浏览文件 @
0bbacb7c
package
com
.
zzsn
.
event
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
org.jeecgframework.poi.excel.annotation.Excel
;
import
java.io.Serializable
;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
@Data
@TableName
(
"subject_info_source_map"
)
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@ApiModel
(
value
=
"subject_info_source_map对象"
,
description
=
"专题与信息源关联表"
)
public
class
SubjectInfoSourceMap
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**主键*/
@TableId
(
type
=
IdType
.
ASSIGN_ID
)
@ApiModelProperty
(
value
=
"主键"
)
private
String
id
;
/**专题id*/
@Excel
(
name
=
"专题id"
,
width
=
15
)
@ApiModelProperty
(
value
=
"专题id"
)
private
String
subjectId
;
/**信息源id或信息源组id*/
@Excel
(
name
=
"信息源id或信息源组id"
,
width
=
15
)
@ApiModelProperty
(
value
=
"信息源id或信息源组id"
)
private
String
sourceId
;
/**种类(1:信息源id 2:信息源组id)*/
@Excel
(
name
=
"种类(1:信息源id 2:信息源组id)"
,
width
=
15
)
@ApiModelProperty
(
value
=
"种类(1:信息源id 2:信息源组id)"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"信息源组权重"
)
private
String
weight
;
}
src/main/java/com/zzsn/event/mapper/EventMapper.java
浏览文件 @
0bbacb7c
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.zzsn.event.entity.Event
;
import
com.zzsn.event.vo.SubjectKafkaVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -19,9 +20,9 @@ public interface EventMapper extends BaseMapper<Event> {
List
<
SubjectKafkaVo
>
eventSubjectList
(
int
i
);
List
<
Event
>
pageList
(
Event
event
,
Integer
offset
,
Integer
pageSize
);
List
<
Event
>
pageList
(
@Param
(
"event"
)
Event
event
,
Integer
offset
,
Integer
pageSize
);
Integer
totalCount
(
Event
event
);
Integer
totalCount
(
@Param
(
"event"
)
Event
event
);
List
<
SubjectKafkaVo
>
prosessList
(
Date
disableDate
);
}
src/main/java/com/zzsn/event/mapper/SubjectInfoSourceMapMapper.java
0 → 100644
浏览文件 @
0bbacb7c
package
com
.
zzsn
.
event
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zzsn.event.entity.SubjectInfoSourceMap
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
@Mapper
public
interface
SubjectInfoSourceMapMapper
extends
BaseMapper
<
SubjectInfoSourceMap
>
{
void
deleteBySubjectId
(
@Param
(
"subjectId"
)
String
subjectId
);
void
deleteBySubjectIds
(
@Param
(
"subjectIds"
)
List
<
String
>
subjectIds
);
void
deleteInfoSourceIds
(
@Param
(
"subjectId"
)
String
subjectId
,
@Param
(
"infoSourceIds"
)
List
<
String
>
infoSourceIds
,
@Param
(
"type"
)
Integer
type
);
List
<
String
>
selectInfoSourceBySubject
(
@Param
(
"subjectIds"
)
List
<
String
>
subjectIds
,
@Param
(
"type"
)
Integer
type
);
List
<
String
>
selectInfoSourceBySubjectAndTypes
(
@Param
(
"subjectIds"
)
List
<
String
>
subjectIds
,
@Param
(
"types"
)
List
<
Integer
>
types
);
void
deleteInfoSourceMapByInfoSourceIds
(
@Param
(
"infoSourceIds"
)
List
<
String
>
infoSourceIds
);
void
infoSourceWeight
(
String
subjectId
,
String
infoSourceGroupId
,
String
weight
);
List
<
String
>
selectSubjectIdsByGroupId
(
@Param
(
"infoSourceGroupId"
)
String
infoSourceGroupId
);
}
src/main/java/com/zzsn/event/mapper/SubjectKeywordsMapMapper.java
浏览文件 @
0bbacb7c
...
...
@@ -22,4 +22,6 @@ public interface SubjectKeywordsMapMapper extends BaseMapper<SubjectKeywordsMap>
int
selectCountByKeyWordsId
(
@Param
(
"keyWordsId"
)
String
keyWordsId
);
KeyWordsDTO
selectMaxByKeyWordsId
(
@Param
(
"keyWordsId"
)
String
keyWordsId
);
void
deleteBySubjectId
(
@Param
(
"subjectId"
)
String
subjectId
);
}
src/main/java/com/zzsn/event/mapper/xml/EventMapper.xml
浏览文件 @
0bbacb7c
...
...
@@ -17,7 +17,7 @@
and t1.event_name like CONCAT('%',#{event.eventName},'%')
</if>
<if
test=
"event.eventType!=null and event.eventType != ''"
>
and
d
t1.event_type = #{event.eventType}
and t1.event_type = #{event.eventType}
</if>
limit #{offset}, #{pageSize}
</select>
...
...
@@ -29,7 +29,7 @@
and t1.event_name like CONCAT('%',#{event.eventName},'%')
</if>
<if
test=
"event.eventType!=null and event.eventType != ''"
>
and
d
t1.event_type = #{event.eventType}
and t1.event_type = #{event.eventType}
</if>
</select>
...
...
src/main/java/com/zzsn/event/mapper/xml/SubjectInfoSourceMapMapper.xml
0 → 100644
浏览文件 @
0bbacb7c
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.zzsn.event.mapper.SubjectInfoSourceMapMapper"
>
<select
id=
"selectInfoSourceBySubject"
resultType=
"String"
>
select distinct e.source_id from subject_info_source_map d
inner join info_source_group_map e on d.source_id = e.group_id
where 1 = 1
<if
test=
"subjectIds!=null and subjectIds.size > 0"
>
and d.subject_id in
<foreach
collection=
"subjectIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</if>
<if
test=
"type!=null"
>
and d.type = #{type}
</if>
</select>
<select
id=
"selectInfoSourceBySubjectAndTypes"
resultType=
"java.lang.String"
>
select distinct e.source_id from subject_info_source_map d
inner join info_source_group_map e on d.source_id = e.group_id
where 1 = 1
<if
test=
"subjectIds!=null and subjectIds.size > 0"
>
and d.subject_id in
<foreach
collection=
"subjectIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</if>
<if
test=
"types!=null and types.size > 0"
>
and d.type in
<foreach
collection=
"types"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</if>
</select>
<select
id=
"selectSubjectIdsByGroupId"
resultType=
"String"
>
select distinct subject_id from subject_info_source_map
where source_id = #{infoSourceGroupId} and type = 2
</select>
<delete
id=
"deleteBySubjectId"
>
delete from subject_info_source_map
WHERE subject_id = #{subjectId}
</delete>
<delete
id=
"deleteBySubjectIds"
>
delete from subject_info_source_map
WHERE subject_id in
<foreach
collection=
"subjectIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</delete>
<delete
id=
"deleteInfoSourceIds"
>
delete from subject_info_source_map
WHERE type = #{type}
<if
test=
"infoSourceIds!=null and infoSourceIds.size > 0"
>
and source_id in
<foreach
collection=
"infoSourceIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</if>
<if
test=
"subjectId!=null and subjectId != ''"
>
and subject_id = #{subjectId}
</if>
</delete>
<delete
id=
"deleteInfoSourceMapByInfoSourceIds"
>
delete from subject_info_source_map
where source_id in
<foreach
collection=
"infoSourceIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</delete>
<update
id=
"infoSourceWeight"
>
update subject_info_source_map set weight = #{weight}
where type = 1 and subject_id = #{subjectId} and source_id in (select source_id from info_source_group_map where group_id = #{infoSourceGroupId})
</update>
</mapper>
src/main/java/com/zzsn/event/service/IEventService.java
浏览文件 @
0bbacb7c
...
...
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.zzsn.event.vo.AddEventParam
;
import
com.zzsn.event.vo.KeyWordsPage
;
import
com.zzsn.event.vo.SubjectKafkaVo
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Description: 事件
...
...
@@ -37,4 +39,8 @@ public interface IEventService extends IService<Event> {
* 获取专题绑定的关键词组列表
*/
List
<
KeyWordsPage
>
bindKeyWordsList
(
String
id
);
void
deleteMain
(
String
id
);
String
upload
(
MultipartFile
file
);
}
src/main/java/com/zzsn/event/service/ISubjectInfoSourceMapService.java
0 → 100644
浏览文件 @
0bbacb7c
package
com
.
zzsn
.
event
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.zzsn.event.entity.SubjectInfoSourceMap
;
import
java.util.List
;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
public
interface
ISubjectInfoSourceMapService
extends
IService
<
SubjectInfoSourceMap
>
{
/**
* 根据专题id删除关联数据
*/
void
delete
(
String
subjectId
);
/**
* 根据专题ids批量删除
*/
void
deleteBySubjectIds
(
List
<
String
>
subjectIds
);
/**
* 根据批量删除
*/
void
deleteInfoSourceIds
(
String
subjectId
,
List
<
String
>
infoSourceIds
,
Integer
type
);
/**
* 根据专题查看绑定的信息源id
*/
List
<
String
>
selectInfoSourceBySubject
(
List
<
String
>
subjectIds
,
Integer
...
type
);
/**
* 根据信息源ids删除相应的映射关系
* @param infoSourceIds
*/
void
deleteInfoSourceMapByInfoSourceIds
(
List
<
String
>
infoSourceIds
);
/**
* 更新数据
* @param subjectInfoSourceMap
*/
void
updateMain
(
SubjectInfoSourceMap
subjectInfoSourceMap
);
/**
* 根据信息源组id,查询出关联的专题id
* @param infoSourceGroupId
* @return
*/
List
<
String
>
querySubjectIdsByGroupId
(
String
infoSourceGroupId
);
}
src/main/java/com/zzsn/event/service/ISubjectKeywordsMapService.java
浏览文件 @
0bbacb7c
...
...
@@ -13,6 +13,10 @@ import java.util.List;
* @Version: V1.0
*/
public
interface
ISubjectKeywordsMapService
extends
IService
<
SubjectKeywordsMap
>
{
/**
* 根据专题id删除关联数据
*/
void
delete
(
String
subjectId
);
/**
* 查询这个词组绑定的专题的最小时间
...
...
@@ -35,4 +39,5 @@ public interface ISubjectKeywordsMapService extends IService<SubjectKeywordsMap>
*/
KeyWordsDTO
selectMaxByKeyWordsId
(
String
keyWordsId
);
}
src/main/java/com/zzsn/event/service/impl/EventServiceImpl.java
浏览文件 @
0bbacb7c
...
...
@@ -2,24 +2,20 @@ package com.zzsn.event.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.zzsn.event.constant.Constants
;
import
com.zzsn.event.entity.Event
;
import
com.zzsn.event.enums.CodePrefixEnum
;
import
com.zzsn.event.mapper.EventMapper
;
import
com.zzsn.event.producer.ProduceInfo
;
import
com.zzsn.event.service.IEventService
;
import
com.zzsn.event.service.IKeyWordsService
;
import
com.zzsn.event.service.ISubjectKeywordsMapService
;
import
com.zzsn.event.service.ISubjectSearchEnginesMapService
;
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.service.*
;
import
com.zzsn.event.util.*
;
import
com.zzsn.event.vo.AddEventParam
;
import
com.zzsn.event.vo.KeyWordsDTO
;
import
com.zzsn.event.vo.KeyWordsPage
;
import
com.zzsn.event.vo.SubjectKafkaVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -27,8 +23,16 @@ import org.springframework.context.annotation.Primary;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.time.LocalDate
;
import
java.util.*
;
/**
...
...
@@ -38,6 +42,7 @@ import java.util.*;
* @Version: V1.0
*/
@Service
@Slf4j
public
class
EventServiceImpl
extends
ServiceImpl
<
EventMapper
,
Event
>
implements
IEventService
{
@Value
(
"${hotWords.extractUrl}"
)
private
String
extractHotWordsUrl
;
...
...
@@ -47,25 +52,84 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
private
IKeyWordsService
iKeyWordsService
;
@Autowired
private
ISubjectSearchEnginesMapService
iSubjectSearchEnginesMapService
;
@Autowired
private
ISubjectInfoSourceMapService
iSubjectInfoSourceMapService
;
@Autowired
private
ISubjectKeywordsMapService
iSubjectKeywordsMapService
;
@Autowired
private
ProduceInfo
produceInfo
;
@Autowired
private
RedisUtil
redisUtil
;
@Value
(
"${files.storage}"
)
String
filesStorage
;
@Value
(
"${scoreRule.weekScore}"
)
Integer
weekScore
;
@Value
(
"${scoreRule.monthScore}"
)
Integer
monthScore
;
@Value
(
"${scoreRule.yearScore}"
)
Integer
yearScore
;
@Value
(
"${scoreRule.beforeYearScore}"
)
Integer
beforeYearScore
;
@Override
public
void
compute
()
{
//get the events need to compute
List
<
Event
>
list
=
this
.
list
(
new
LambdaQueryWrapper
<
Event
>().
eq
(
Event:
:
getStatus
,
1
));
for
(
Event
event
:
list
)
{
// latest week data
//total
Integer
totalScore
=
0
;
Integer
totalHot
=
getHot
(
Constants
.
MAX_TOTAL_HOT_SCORE
,
totalScore
);
//media
Integer
mediaScore
=
0
;
Integer
mediaHot
=
getHot
(
Constants
.
MAX_MEDIA_HOT_SCORE
,
mediaScore
);
//wechat
Integer
wechatScore
=
0
;
Integer
wechatHot
=
getHot
(
Constants
.
MAX_WECHAT_HOT_SCORE
,
wechatScore
);
//others
Integer
otherScore
=
0
;
Integer
otherHot
=
getHot
(
Constants
.
MAX_OTHER_HOT_SCORE
,
otherScore
);
event
.
setTotalHot
(
totalHot
);
event
.
setMediaHot
(
mediaHot
);
event
.
setWechatHot
(
wechatHot
);
event
.
setOtherHot
(
otherHot
);
this
.
updateById
(
event
);
// latest month data
// latest year data
// data before a year
}
}
private
Integer
getHot
(
String
key
,
Integer
Score
)
{
Object
total
=
redisUtil
.
get
(
Constants
.
MAX_TOTAL_HOT_SCORE
);
if
(
null
!=
total
)
{
Integer
maxTotalScore
=
(
Integer
)
total
;
if
(
Score
>
maxTotalScore
)
{
redisUtil
.
set
(
Constants
.
MAX_TOTAL_HOT_SCORE
,
Score
);
return
100
;
}
else
{
return
Score
/
maxTotalScore
*
100
;
}
}
else
{
redisUtil
.
set
(
Constants
.
MAX_TOTAL_HOT_SCORE
,
Score
);
return
100
;
}
}
/**
* 计算热度
*
* @param weekTimes 周内次数
* @param monthTimes 月内次数
* @param yearTimes 年内次数
* @param beforeYearTimes 年外次数
*/
private
Integer
computeScore
(
Integer
weekTimes
,
Integer
monthTimes
,
Integer
yearTimes
,
Integer
beforeYearTimes
)
{
// latest week data
// latest month data
// latest year data
// data before a year
return
weekTimes
*
weekScore
+
monthTimes
*
monthScore
+
yearTimes
*
yearScore
+
beforeYearTimes
*
beforeYearScore
;
}
@Override
...
...
@@ -89,7 +153,7 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
Integer
count
=
baseMapper
.
totalCount
(
event
);
IPage
<
Event
>
pageData
=
new
Page
<>(
pageNo
,
pageSize
,
count
);
pageData
.
setRecords
(
pageList
);
return
null
;
return
pageData
;
}
@Override
...
...
@@ -144,10 +208,64 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
updateRedisKeyWordsDate
(
addEventParam
.
getId
(),
keyWordIds
);
}
}
@Override
public
List
<
KeyWordsPage
>
bindKeyWordsList
(
String
subjectId
)
{
return
iKeyWordsService
.
bindKeyWordsList
(
subjectId
);
}
@Override
public
void
deleteMain
(
String
id
)
{
//删除与信息源的关联关系
iSubjectInfoSourceMapService
.
delete
(
id
);
//删除与关键词组的关联关系
iSubjectKeywordsMapService
.
delete
(
id
);
baseMapper
.
deleteById
(
id
);
}
@Override
public
String
upload
(
MultipartFile
file
)
{
try
{
String
fileName
=
file
.
getOriginalFilename
();
// 获取文件名称
long
fileSize
=
file
.
getSize
();
// get file size
log
.
info
(
"文件上传:"
+
fileName
);
String
filePath
=
getFilePath
()
+
fileName
;
//byte[] bytes = file.getBytes(); // get file in bytes
//Files.write(Paths.get(filePath), bytes);
String
path
=
ClassUtils
.
getDefaultClassLoader
().
getResource
(
""
).
getPath
();
file
.
transferTo
(
new
File
(
filesStorage
+
filePath
));
log
.
info
(
"文件上传成功:"
+
fileName
+
"---"
+
filePath
);
return
filePath
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
e
.
getMessage
());
}
// if the operation of file uploading is unsuccessful, an error occurs
log
.
info
(
"上传文件时出现问题!"
);
return
null
;
}
//生成文件夹路径
private
String
getFilePath
()
{
LocalDate
currentDate
=
LocalDate
.
now
();
String
current
=
currentDate
.
toString
().
replace
(
"-"
,
""
);
String
filePath
=
current
+
"/"
;
//判断文件夹是否存在,不存在创建
Path
directory
=
Paths
.
get
(
filesStorage
+
filePath
);
if
(!
Files
.
exists
(
directory
))
{
try
{
Files
.
createDirectories
(
directory
);
log
.
info
(
"文件夹创建成功:"
+
filePath
);
}
catch
(
IOException
e
)
{
log
.
error
(
"文件夹创建失败:"
+
filePath
);
e
.
printStackTrace
();
}
}
return
filePath
;
}
//更新专题绑定的关键词组的缓存信息
private
void
updateRedisKeyWordsDate
(
String
subjectId
,
List
<
String
>
keyWordsIds
)
{
for
(
String
keyWordsId
:
keyWordsIds
)
{
...
...
src/main/java/com/zzsn/event/service/impl/SubjectInfoSourceMapServiceImpl.java
0 → 100644
浏览文件 @
0bbacb7c
package
com
.
zzsn
.
event
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zzsn.event.entity.SubjectInfoSourceMap
;
import
com.zzsn.event.mapper.SubjectInfoSourceMapMapper
;
import
com.zzsn.event.service.ISubjectInfoSourceMapService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @Description: 专题与信息源关联表
* @Author: jeecg-boot
* @Date: 2021-12-09
* @Version: V1.0
*/
@Service
public
class
SubjectInfoSourceMapServiceImpl
extends
ServiceImpl
<
SubjectInfoSourceMapMapper
,
SubjectInfoSourceMap
>
implements
ISubjectInfoSourceMapService
{
@Override
@Transactional
public
void
delete
(
String
subjectId
){
baseMapper
.
deleteBySubjectId
(
subjectId
);
}
@Override
@Transactional
public
void
deleteBySubjectIds
(
List
<
String
>
subjectIds
){
baseMapper
.
deleteBySubjectIds
(
subjectIds
);
}
@Override
public
void
deleteInfoSourceIds
(
String
subjectId
,
List
<
String
>
infoSourceIds
,
Integer
type
){
baseMapper
.
deleteInfoSourceIds
(
subjectId
,
infoSourceIds
,
type
);
}
@Override
public
List
<
String
>
selectInfoSourceBySubject
(
List
<
String
>
subjectIds
,
Integer
...
type
){
List
<
String
>
list
=
new
ArrayList
<>();
if
(
subjectIds
!=
null
&&
subjectIds
.
size
()
>
0
)
{
list
=
baseMapper
.
selectInfoSourceBySubjectAndTypes
(
subjectIds
,
Arrays
.
asList
(
type
));
}
return
list
;
}
@Override
public
void
deleteInfoSourceMapByInfoSourceIds
(
List
<
String
>
infoSourceIds
){
baseMapper
.
deleteInfoSourceMapByInfoSourceIds
(
infoSourceIds
);
}
@Override
public
void
updateMain
(
SubjectInfoSourceMap
subjectInfoSourceMap
){
//更新信息源组信息权重
baseMapper
.
updateById
(
subjectInfoSourceMap
);
//更新绑定的信息源权重(根据绑定的信息源组实现)
baseMapper
.
infoSourceWeight
(
subjectInfoSourceMap
.
getSubjectId
(),
subjectInfoSourceMap
.
getSourceId
(),
subjectInfoSourceMap
.
getWeight
());
}
@Override
public
List
<
String
>
querySubjectIdsByGroupId
(
String
infoSourceGroupId
){
return
baseMapper
.
selectSubjectIdsByGroupId
(
infoSourceGroupId
);
}
}
src/main/java/com/zzsn/event/service/impl/SubjectKeywordsMapServiceImpl.java
浏览文件 @
0bbacb7c
...
...
@@ -7,6 +7,7 @@ import com.zzsn.event.service.ISubjectKeywordsMapService;
import
com.zzsn.event.vo.KeyWordsDTO
;
import
com.zzsn.event.vo.SubjectKeywordsMap
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @Description: 专题关键词关联表
...
...
@@ -17,7 +18,11 @@ import org.springframework.stereotype.Service;
@Service
public
class
SubjectKeywordsMapServiceImpl
extends
ServiceImpl
<
SubjectKeywordsMapMapper
,
SubjectKeywordsMap
>
implements
ISubjectKeywordsMapService
{
@Override
@Transactional
public
void
delete
(
String
subjectId
){
baseMapper
.
deleteBySubjectId
(
subjectId
);
}
@Override
public
KeyWordsDTO
selectMinByKeyWordsId
(
String
keyWordsId
){
return
baseMapper
.
selectMinByKeyWordsId
(
keyWordsId
);
...
...
src/main/java/com/zzsn/event/task/AnalysisTask.java
浏览文件 @
0bbacb7c
...
...
@@ -191,8 +191,8 @@ public class AnalysisTask {
* 定时生成传播路径
* 每天凌晨0点10分执行一次
*/
//
@Scheduled(cron = "0 0 0 * * ?")
@Scheduled
(
cron
=
"0 * * * * ?"
)
@Scheduled
(
cron
=
"0 0 0 * * ?"
)
//
@Scheduled(cron = "0 * * * * ?")
public
void
propagationPath
()
{
Date
today
=
new
Date
();
Date
deadlineDate
=
DateUtil
.
addDate
(
today
,
-
1
);
...
...
src/main/resources/application.yml
浏览文件 @
0bbacb7c
...
...
@@ -6,6 +6,8 @@ spring:
multipart
:
max-request-size
:
1024MB
max-file-size
:
100MB
resources
:
static-locations
:
file:D:/event/
datasource
:
druid
:
stat-view-servlet
:
...
...
@@ -113,4 +115,6 @@ serviceProject:
url
:
https://clb.ciglobal.cn/clb-api/
#热词抽取地址
hotWords
:
extractUrl
:
http://114.116.99.6:8055/task/dispose/extractKeyword
\ No newline at end of file
extractUrl
:
http://114.116.99.6:8055/task/dispose/extractKeyword
files
:
storage
:
D:/event/
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论