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
d6841459
Commit
d6841459
authored
Jan 31, 2023
by
陈健智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改舆情外部接口
parent
8dfacb6d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
27 deletions
+66
-27
src/main/java/com/zhiwei/brandkbs2/common/GlobalPojo.java
+10
-2
src/main/java/com/zhiwei/brandkbs2/dao/QbjcPojoDao.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/dao/impl/QbjcPojoDaoImpl.java
+3
-2
src/main/java/com/zhiwei/brandkbs2/service/SystemInfoService.java
+7
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
+40
-22
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 @
d6841459
...
@@ -3,9 +3,11 @@ package com.zhiwei.brandkbs2.common;
...
@@ -3,9 +3,11 @@ package com.zhiwei.brandkbs2.common;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
com.zhiwei.brandkbs2.pojo.ChannelTag
;
import
com.zhiwei.brandkbs2.pojo.ChannelTag
;
import
com.zhiwei.brandkbs2.pojo.Event
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
com.zhiwei.brandkbs2.service.EventService
;
import
com.zhiwei.brandkbs2.service.SystemInfoService
;
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.MessagePlatform
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
com.zhiwei.qbjc.bean.pojo.common.Tag
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
...
@@ -47,6 +49,11 @@ public class GlobalPojo {
...
@@ -47,6 +49,11 @@ public class GlobalPojo {
**/
**/
public
static
Map
<
String
,
List
<
Tag
>>
TAGS
;
public
static
Map
<
String
,
List
<
Tag
>>
TAGS
;
/**
* 品见情感倾向标签
*/
public
static
List
<
Tag
>
LINKED_GROUP_ID_TAGS
;
public
static
Map
<
String
,
String
>
CHANNEL_TAGS
;
public
static
Map
<
String
,
String
>
CHANNEL_TAGS
;
...
@@ -89,12 +96,13 @@ public class GlobalPojo {
...
@@ -89,12 +96,13 @@ public class GlobalPojo {
try
{
try
{
PLATFORMS
=
systemInfoService
.
getPlatforms
();
PLATFORMS
=
systemInfoService
.
getPlatforms
();
TAGS
=
systemInfoService
.
getTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
Tag:
:
getGroupName
));
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
));
CHANNEL_TAGS
=
systemInfoService
.
getChannelTags
().
stream
().
collect
(
Collectors
.
toMap
(
ChannelTag:
:
getChannel
,
ChannelTag:
:
getTag
));
MEDIA_TYPE
=
systemInfoService
.
getMediaTypes
();
MEDIA_TYPE
=
systemInfoService
.
getMediaTypes
();
PROJECT_MAP
=
systemInfoService
.
getProjects
();
PROJECT_MAP
=
systemInfoService
.
getProjects
();
YU_QING_PROJECTS
=
systemInfoService
.
getYuQingProjects
();
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
(),
log
.
info
(
"{}-获取PLATFORMS-size:{},TAGS-size:{},
LINKED_GROUP_ID_TAGS:{},
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
());
LINKED_GROUP_ID_TAGS
.
size
(),
CHANNEL_TAGS
.
size
(),
MEDIA_TYPE
.
size
(),
PROJECT_MAP
.
size
(),
YU_QING_PROJECTS
.
size
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"{}-获取缓存值异常"
,
logMsg
,
e
);
log
.
info
(
"{}-获取缓存值异常"
,
logMsg
,
e
);
}
}
...
...
src/main/java/com/zhiwei/brandkbs2/dao/QbjcPojoDao.java
View file @
d6841459
...
@@ -34,5 +34,5 @@ public interface QbjcPojoDao {
...
@@ -34,5 +34,5 @@ public interface QbjcPojoDao {
*
*
* @return tags
* @return tags
*/
*/
List
<
Tag
>
findEmotionTagByLinkedGroupId
(
String
linkedGroupId
);
List
<
Tag
>
findEmotionTagByLinkedGroupId
();
}
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/QbjcPojoDaoImpl.java
View file @
d6841459
...
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
...
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* @ClassName: QbjcPojoDaoImpl
* @ClassName: QbjcPojoDaoImpl
...
@@ -35,8 +36,8 @@ public class QbjcPojoDaoImpl implements QbjcPojoDao {
...
@@ -35,8 +36,8 @@ public class QbjcPojoDaoImpl implements QbjcPojoDao {
}
}
@Override
@Override
public
List
<
Tag
>
findEmotionTagByLinkedGroupId
(
String
linkedGroupId
)
{
public
List
<
Tag
>
findEmotionTagByLinkedGroupId
()
{
return
mongoTemplate
.
find
(
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
linkedGroupId
)),
Tag
.
class
);
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 @
d6841459
...
@@ -32,6 +32,13 @@ public interface SystemInfoService {
...
@@ -32,6 +32,13 @@ public interface SystemInfoService {
List
<
Tag
>
getTags
();
List
<
Tag
>
getTags
();
/**
/**
* 获取qbjcTag
*
* @return tags
*/
List
<
Tag
>
findEmotionTagByLinkedGroupId
();
/**
* 获取ChannelTags
* 获取ChannelTags
*
*
* @return List<ChannelTag>
* @return List<ChannelTag>
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/ProjectServiceImpl.java
View file @
d6841459
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.GenericAttribute
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.common.GlobalPojo
;
import
com.zhiwei.brandkbs2.config.Constant
;
import
com.zhiwei.brandkbs2.dao.ProjectDao
;
import
com.zhiwei.brandkbs2.dao.ProjectDao
;
import
com.zhiwei.brandkbs2.dao.QbjcPojoDao
;
import
com.zhiwei.brandkbs2.dao.QbjcPojoDao
;
import
com.zhiwei.brandkbs2.dao.UserDao
;
import
com.zhiwei.brandkbs2.dao.UserDao
;
...
@@ -60,6 +61,7 @@ import java.util.stream.Collectors;
...
@@ -60,6 +61,7 @@ import java.util.stream.Collectors;
public
class
ProjectServiceImpl
implements
ProjectService
{
public
class
ProjectServiceImpl
implements
ProjectService
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
ProjectServiceImpl
.
class
);
private
static
final
Logger
log
=
LogManager
.
getLogger
(
ProjectServiceImpl
.
class
);
// 品见情感标签默认只需要这些
private
static
final
List
<
String
>
EMOTION_MARKER_TAGS
=
Arrays
.
asList
(
"正面"
,
"负面"
,
"中性"
,
"敏感"
);
private
static
final
List
<
String
>
EMOTION_MARKER_TAGS
=
Arrays
.
asList
(
"正面"
,
"负面"
,
"中性"
,
"敏感"
);
@Resource
(
name
=
"userDao"
)
@Resource
(
name
=
"userDao"
)
...
@@ -380,41 +382,44 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -380,41 +382,44 @@ public class ProjectServiceImpl implements ProjectService {
// 暂且将测试项目排除
// 暂且将测试项目排除
query
.
addCriteria
(
Criteria
.
where
(
"_id"
).
ne
(
"632052f0abed641ef800476c"
));
query
.
addCriteria
(
Criteria
.
where
(
"_id"
).
ne
(
"632052f0abed641ef800476c"
));
List
<
Project
>
projects
=
projectDao
.
findList
(
query
);
List
<
Project
>
projects
=
projectDao
.
findList
(
query
);
// 情感倾向标签
List
<
Tag
>
tags
=
qbjcPojoDao
.
findEmotionTagByLinkedGroupId
(
linkedGroupId
);
Map
<
String
,
List
<
MarkerTag
>>
emotionMarkerTags
=
tags
.
stream
().
filter
(
tag
->
tag
.
getGroupName
().
equals
(
"情感倾向"
)
&&
EMOTION_MARKER_TAGS
.
contains
(
tag
.
getName
()))
.
map
(
tag
->
Tools
.
convertMap
(
tag
,
MarkerTag
.
class
))
.
sorted
(
Comparator
.
comparing
(
MarkerTag:
:
getId
))
.
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
));
Map
<
String
,
List
<
MarkerTag
>>
tagsMap
=
new
HashMap
<>();
for
(
Project
project
:
projects
)
{
for
(
Project
project
:
projects
)
{
if
(
Objects
.
equals
(
project
.
getBrandLinkedGroupId
(),
linkedGroupId
))
{
if
(
Objects
.
equals
(
project
.
getBrandLinkedGroupId
(),
linkedGroupId
))
{
Map
<
String
,
List
<
MarkerTag
>>
tagsMap
=
new
HashMap
<>();
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
if
(!
Tools
.
isEmpty
(
project
.
getHitTags
()))
{
if
(!
Tools
.
isEmpty
(
project
.
getHitTags
()))
{
tagsMap
.
putAll
(
project
.
getHitTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
)));
tagsMap
.
putAll
(
project
.
getHitTags
().
stream
().
collect
(
Collectors
.
groupingBy
(
MarkerTag:
:
getGroupName
)));
}
}
tagsMap
.
putAll
(
emotionMarkerTags
);
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
);
jsonObject
.
put
(
"tags"
,
tagsMap
);
BrandkbsBasicInfo
brandkbsBasicInfo
=
new
BrandkbsBasicInfo
(
project
.
getProjectName
(),
project
.
getId
(),
project
.
getBrandName
(),
project
.
getId
());
BrandkbsBasicInfo
brandkbsBasicInfo
=
new
BrandkbsBasicInfo
(
project
.
getProjectName
(),
project
.
getId
(),
project
.
getBrandName
(),
project
.
getId
());
jsonObject
.
put
(
"brandkbsBasicInfo"
,
brandkbsBasicInfo
);
jsonObject
.
put
(
"brandkbsBasicInfo"
,
brandkbsBasicInfo
);
result
.
add
(
jsonObject
);
result
.
add
(
jsonObject
);
}
else
{
}
if
(!
Tools
.
isEmpty
(
project
.
getContendList
()))
{
if
(!
Tools
.
isEmpty
(
project
.
getContendList
()))
{
for
(
Contend
contend
:
project
.
getContendList
())
{
for
(
Contend
contend
:
project
.
getContendList
())
{
if
(
Objects
.
equals
(
contend
.
getBrandLinkedGroupId
(),
linkedGroupId
))
{
Map
<
String
,
List
<
MarkerTag
>>
tagsMap
=
new
HashMap
<>();
JSONObject
jsonObject
=
new
JSONObject
();
if
(
Objects
.
equals
(
contend
.
getBrandLinkedGroupId
(),
linkedGroupId
))
{
if
(!
Tools
.
isEmpty
(
contend
.
getHitTags
()))
{
JSONObject
jsonObject
=
new
JSONObject
();
tagsMap
.
putAll
(
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
()){
}
if
(
contend
.
isHasEmotion
()){
Map
<
String
,
List
<
MarkerTag
>>
emotionMarkerTags
=
getEmotionMarkerTags
(
contend
.
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
);
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
);
}
}
jsonObject
.
put
(
"tags"
,
tagsMap
);
BrandkbsBasicInfo
brandkbsBasicInfo
=
new
BrandkbsBasicInfo
(
project
.
getProjectName
(),
project
.
getId
(),
contend
.
getBrandName
(),
contend
.
getId
());
jsonObject
.
put
(
"brandkbsBasicInfo"
,
brandkbsBasicInfo
);
result
.
add
(
jsonObject
);
}
}
}
}
}
}
...
@@ -426,6 +431,19 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -426,6 +431,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) {
// public JSONObject getUserInfoAndProjectConfig(User user) {
// long start = System.currentTimeMillis();
// long start = System.currentTimeMillis();
// JSONObject result = new JSONObject();
// JSONObject result = new JSONObject();
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/SystemInfoServiceImpl.java
View file @
d6841459
...
@@ -67,6 +67,11 @@ public class SystemInfoServiceImpl implements SystemInfoService {
...
@@ -67,6 +67,11 @@ public class SystemInfoServiceImpl implements SystemInfoService {
}
}
@Override
@Override
public
List
<
Tag
>
findEmotionTagByLinkedGroupId
()
{
return
qbjcPojoDao
.
findEmotionTagByLinkedGroupId
();
}
@Override
public
List
<
ChannelTag
>
getChannelTags
()
{
public
List
<
ChannelTag
>
getChannelTags
()
{
return
channelTagDao
.
findList
(
null
);
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