Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenjunjie
brandkbs2
Commits
ad4b9440
Commit
ad4b9440
authored
Feb 01, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'release'
Feature See merge request
!182
parents
4db2eabc
4a4dd4ec
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
8 deletions
+86
-8
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
+10
-2
src/main/java/com/zhiwei/brandkbs2/dao/QbjcPojoDao.java
+6
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/QbjcPojoDaoImpl.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/service/SystemInfoService.java
+7
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
+50
-6
src/main/java/com/zhiwei/brandkbs2/service/impl/SystemInfoServiceImpl.java
+5
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
View file @
ad4b9440
...
...
@@ -3,9 +3,11 @@ package com.zhiwei.brandkbs2.common;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
com.zhiwei.brandkbs2.pojo.ChannelTag
;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
com.zhiwei.brandkbs2.service.SystemInfoService
;
import
com.zhiwei.middleware.mark.vo.MarkerTag
;
import
com.zhiwei.qbjc.bean.pojo.common.MessagePlatform
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -47,6 +49,11 @@ public class GlobalPojo {
**/
public
static
Map
<
String
,
List
<
Tag
>>
TAGS
;
/**
* 品见情感倾向标签
*/
public
static
List
<
Tag
>
LINKED_GROUP_ID_TAGS
;
public
static
Map
<
String
,
String
>
CHANNEL_TAGS
;
...
...
@@ -89,12 +96,13 @@ public class GlobalPojo {
try
{
PLATFORMS
=
systemInfoService
.
getPlatforms
();
TAGS
=
systemInfoService
.
getTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
Tag:
:
getGroupName
));
LINKED_GROUP_ID_TAGS
=
systemInfoService
.
findEmotionTagByLinkedGroupId
();
CHANNEL_TAGS
=
systemInfoService
.
getChannelTags
().
stream
().
collect
(
Collectors
.
toMap
(
ChannelTag:
:
getChannel
,
ChannelTag:
:
getTag
));
MEDIA_TYPE
=
systemInfoService
.
getMediaTypes
();
PROJECT_MAP
=
systemInfoService
.
getProjects
();
YU_QING_PROJECTS
=
systemInfoService
.
getYuQingProjects
();
log
.
info
(
"{}-获取PLATFORMS-size:{},TAGS-size:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{}"
,
logMsg
,
PLATFORMS
.
size
(),
TAGS
.
size
(),
CHANNEL_TAGS
.
size
(),
MEDIA_TYPE
.
size
(),
PROJECT_MAP
.
size
(),
YU_QING_PROJECTS
.
size
());
log
.
info
(
"{}-获取PLATFORMS-size:{},TAGS-size:{},
LINKED_GROUP_ID_TAGS:{},
CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{}"
,
logMsg
,
PLATFORMS
.
size
(),
TAGS
.
size
(),
LINKED_GROUP_ID_TAGS
.
size
(),
CHANNEL_TAGS
.
size
(),
MEDIA_TYPE
.
size
(),
PROJECT_MAP
.
size
(),
YU_QING_PROJECTS
.
size
());
}
catch
(
Exception
e
)
{
log
.
info
(
"{}-获取缓存值异常"
,
logMsg
,
e
);
}
...
...
src/main/java/com/zhiwei/brandkbs2/dao/QbjcPojoDao.java
View file @
ad4b9440
...
...
@@ -29,4 +29,10 @@ public interface QbjcPojoDao {
*/
List
<
Tag
>
findTagAll
();
/**
* 获取qbjcTag
*
* @return tags
*/
List
<
Tag
>
findEmotionTagByLinkedGroupId
();
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/QbjcPojoDaoImpl.java
View file @
ad4b9440
...
...
@@ -5,11 +5,13 @@ import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @ClassName: QbjcPojoDaoImpl
...
...
@@ -33,5 +35,11 @@ public class QbjcPojoDaoImpl implements QbjcPojoDao {
return
mongoTemplate
.
find
(
new
Query
(),
Tag
.
class
);
}
@Override
public
List
<
Tag
>
findEmotionTagByLinkedGroupId
()
{
return
mongoTemplate
.
find
(
new
Query
(),
Tag
.
class
).
stream
().
filter
(
tag
->
tag
.
getGroupName
().
equals
(
"情感倾向"
)).
collect
(
Collectors
.
toList
());
}
}
src/main/java/com/zhiwei/brandkbs2/service/SystemInfoService.java
View file @
ad4b9440
...
...
@@ -32,6 +32,13 @@ public interface SystemInfoService {
List
<
Tag
>
getTags
();
/**
* 获取qbjcTag
*
* @return tags
*/
List
<
Tag
>
findEmotionTagByLinkedGroupId
();
/**
* 获取ChannelTags
*
* @return List<ChannelTag>
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
View file @
ad4b9440
...
...
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONObject;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.ProjectDao
;
import
com.zhiwei.brandkbs2.dao.QbjcPojoDao
;
import
com.zhiwei.brandkbs2.dao.UserDao
;
import
com.zhiwei.brandkbs2.enmus.response.ProjectCodeEnum
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
...
...
@@ -16,7 +18,9 @@ import com.zhiwei.brandkbs2.pojo.Project;
import
com.zhiwei.brandkbs2.pojo.User
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.pojo.vo.ProjectVO
;
import
com.zhiwei.brandkbs2.service.CommonService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
com.zhiwei.brandkbs2.service.SystemInfoService
;
import
com.zhiwei.brandkbs2.service.UserService
;
import
com.zhiwei.brandkbs2.util.MongoUtil
;
import
com.zhiwei.brandkbs2.util.Tools
;
...
...
@@ -25,8 +29,11 @@ import com.zhiwei.middleware.event.core.EventTagClient;
import
com.zhiwei.middleware.event.pojo.dto.EventTagRelatedDTO
;
import
com.zhiwei.middleware.event.pojo.entity.BrandkbsBasicInfo
;
import
com.zhiwei.middleware.event.pojo.entity.Event
;
import
com.zhiwei.middleware.mark.pojo.enums.TagField
;
import
com.zhiwei.middleware.mark.vo.MarkerTag
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -40,6 +47,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Array
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -53,12 +61,18 @@ import java.util.stream.Collectors;
public
class
ProjectServiceImpl
implements
ProjectService
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
ProjectServiceImpl
.
class
);
// 品见情感标签默认只需要这些
private
static
final
List
<
String
>
EMOTION_MARKER_TAGS
=
Arrays
.
asList
(
"正面"
,
"负面"
,
"中性"
,
"敏感"
);
@Resource
(
name
=
"userDao"
)
private
UserDao
userDao
;
@Resource
(
name
=
"projectDao"
)
private
ProjectDao
projectDao
;
@Resource
(
name
=
"qbjcPojoDao"
)
private
QbjcPojoDao
qbjcPojoDao
;
@Resource
(
name
=
"mongoUtil"
)
private
com
.
zhiwei
.
brandkbs2
.
util
.
MongoUtil
mongoUtil
;
...
...
@@ -370,19 +384,37 @@ public class ProjectServiceImpl implements ProjectService {
List
<
Project
>
projects
=
projectDao
.
findList
(
query
);
for
(
Project
project
:
projects
)
{
if
(
Objects
.
equals
(
project
.
getBrandLinkedGroupId
(),
linkedGroupId
))
{
if
(!
Tools
.
isEmpty
(
project
.
getHitTags
()))
{
Map
<
String
,
List
<
MarkerTag
>>
tagsMap
=
new
HashMap
<>();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"tags"
,
project
.
getHitTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
)));
if
(!
Tools
.
isEmpty
(
project
.
getHitTags
()))
{
tagsMap
.
putAll
(
project
.
getHitTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
)));
}
Map
<
String
,
List
<
MarkerTag
>>
emotionMarkerTags
=
getEmotionMarkerTags
(
project
.
getBrandLinkedGroup
());
if
(!
Tools
.
isEmpty
(
tagsMap
.
get
(
Constant
.
EMOTION_LABEL_KEY
)))
{
tagsMap
.
get
(
Constant
.
EMOTION_LABEL_KEY
).
addAll
(
0
,
emotionMarkerTags
.
get
(
Constant
.
EMOTION_LABEL_KEY
));
}
else
{
tagsMap
.
putAll
(
emotionMarkerTags
);
}
jsonObject
.
put
(
"tags"
,
tagsMap
);
BrandkbsBasicInfo
brandkbsBasicInfo
=
new
BrandkbsBasicInfo
(
project
.
getProjectName
(),
project
.
getId
(),
project
.
getBrandName
(),
project
.
getId
());
jsonObject
.
put
(
"brandkbsBasicInfo"
,
brandkbsBasicInfo
);
result
.
add
(
jsonObject
);
}
}
else
{
if
(!
Tools
.
isEmpty
(
project
.
getContendList
()))
{
for
(
Contend
contend
:
project
.
getContendList
())
{
if
(
Objects
.
equals
(
contend
.
getBrandLinkedGroupId
(),
linkedGroupId
)
&&
!
Tools
.
isEmpty
(
contend
.
getHitTags
()))
{
Map
<
String
,
List
<
MarkerTag
>>
tagsMap
=
new
HashMap
<>();
if
(
Objects
.
equals
(
contend
.
getBrandLinkedGroupId
(),
linkedGroupId
))
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"tags"
,
contend
.
getHitTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
)));
if
(!
Tools
.
isEmpty
(
contend
.
getHitTags
()))
{
tagsMap
.
putAll
(
contend
.
getHitTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
)));
}
if
(
contend
.
isHasEmotion
()){
Map
<
String
,
List
<
MarkerTag
>>
emotionMarkerTags
=
getEmotionMarkerTags
(
contend
.
getBrandLinkedGroup
());
if
(
Tools
.
isEmpty
(
tagsMap
.
get
(
Constant
.
EMOTION_LABEL_KEY
)))
{
tagsMap
.
putAll
(
emotionMarkerTags
);
}
}
jsonObject
.
put
(
"tags"
,
tagsMap
);
BrandkbsBasicInfo
brandkbsBasicInfo
=
new
BrandkbsBasicInfo
(
project
.
getProjectName
(),
project
.
getId
(),
contend
.
getBrandName
(),
contend
.
getId
());
jsonObject
.
put
(
"brandkbsBasicInfo"
,
brandkbsBasicInfo
);
result
.
add
(
jsonObject
);
...
...
@@ -390,7 +422,6 @@ public class ProjectServiceImpl implements ProjectService {
}
}
}
}
return
ResponseResult
.
success
(
result
);
}
catch
(
Exception
e
){
log
.
error
(
"外部接口获取hitTags出错"
,
e
);
...
...
@@ -398,6 +429,19 @@ public class ProjectServiceImpl implements ProjectService {
}
}
/**
* 获取舆情对应项目的情感标签
* @param brandName
* @return
*/
private
Map
<
String
,
List
<
MarkerTag
>>
getEmotionMarkerTags
(
String
brandName
){
return
GlobalPojo
.
LINKED_GROUP_ID_TAGS
.
stream
().
filter
(
tag
->
!
Tools
.
isEmpty
(
tag
.
getProject
())
&&
tag
.
getProject
().
equals
(
brandName
)
&&
EMOTION_MARKER_TAGS
.
contains
(
tag
.
getName
()))
.
map
(
tag
->
Tools
.
convertMap
(
tag
,
MarkerTag
.
class
))
.
sorted
(
Comparator
.
comparing
(
MarkerTag:
:
getId
))
.
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
));
}
// public JSONObject getUserInfoAndProjectConfig(User user) {
// long start = System.currentTimeMillis();
// JSONObject result = new JSONObject();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/SystemInfoServiceImpl.java
View file @
ad4b9440
...
...
@@ -67,6 +67,11 @@ public class SystemInfoServiceImpl implements SystemInfoService {
}
@Override
public
List
<
Tag
>
findEmotionTagByLinkedGroupId
()
{
return
qbjcPojoDao
.
findEmotionTagByLinkedGroupId
();
}
@Override
public
List
<
ChannelTag
>
getChannelTags
()
{
return
channelTagDao
.
findList
(
null
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment