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
218d144c
Commit
218d144c
authored
Apr 11, 2024
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' into 'master'
Release See merge request
!481
parents
a5132c77
f29de156
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
1 deletions
+78
-1
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
+1
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppIndexController.java
+10
-0
src/main/java/com/zhiwei/brandkbs2/service/IndexService.java
+8
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
+52
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+1
-1
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
+4
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/common/RedisKeyPrefix.java
View file @
218d144c
...
...
@@ -27,6 +27,7 @@ public class RedisKeyPrefix {
public
static
final
String
INDEX_PLATFORM
=
"BRANDKBS:INDEX:PLATFORM:"
;
public
static
final
String
INDEX_SPREAD
=
"BRANDKBS:INDEX:SPREAD:"
;
public
static
final
String
INDEX_COMPARE_SUMMARY_MOBILE
=
"BRANDKBS:INDEX:COMPARE_SUMMARY:MOBILE:"
;
public
static
final
String
INDEX_EMOTION
=
"BRANDKBS:INDEX:EMOTION:"
;
/**
* 渠道榜单缓存
*/
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppIndexController.java
View file @
218d144c
...
...
@@ -90,5 +90,15 @@ public class AppIndexController extends BaseController {
return
ResponseResult
.
success
(
indexService
.
getSpreadingTend
(
startTime
,
endTime
,
true
));
}
@ApiOperation
(
"首页-净情感度"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
paramType
=
"query"
,
dataType
=
"long"
)
})
@GetMapping
(
"/emotion-percent"
)
public
ResponseResult
getEmotionPercent
(
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
)
{
return
ResponseResult
.
success
(
indexService
.
getEmotionPercent
(
startTime
,
endTime
,
false
));
}
}
src/main/java/com/zhiwei/brandkbs2/service/IndexService.java
View file @
218d144c
...
...
@@ -81,4 +81,12 @@ public interface IndexService {
*/
JSONObject
getMobileWholeCriteria
(
Long
startTime
,
Long
endTime
);
/**
* 获取主品牌净情感度
* @param startTime 开始时间
* @param endTime 结束时间
* @param cache 是否优先读取缓存
* @return
*/
JSONObject
getEmotionPercent
(
Long
startTime
,
Long
endTime
,
boolean
cache
);
}
src/main/java/com/zhiwei/brandkbs2/service/impl/IndexServiceImpl.java
View file @
218d144c
...
...
@@ -334,6 +334,58 @@ public class IndexServiceImpl implements IndexService {
return
result
;
}
@Override
public
JSONObject
getEmotionPercent
(
Long
startTime
,
Long
endTime
,
boolean
cache
)
{
if
(
Objects
.
isNull
(
startTime
)
||
Objects
.
isNull
(
endTime
))
{
Long
[]
timeRangeMonth
=
commonService
.
getTimeRangeMonth
();
startTime
=
timeRangeMonth
[
0
];
endTime
=
timeRangeMonth
[
1
];
}
String
projectId
=
UserThreadLocal
.
getProjectId
();
String
redisKey
=
RedisUtil
.
getIndexEmotionKey
(
projectId
,
startTime
,
endTime
);
String
resultStr
;
// 返回缓存
if
(
cache
&&
StringUtils
.
isNotEmpty
(
resultStr
=
redisUtil
.
get
(
redisKey
)))
{
return
JSON
.
parseObject
(
resultStr
);
}
JSONObject
jsonObject
=
new
JSONObject
();
try
{
// 关于NSR计算:NSR净情感度=(正面-负面)/(正面+负面)*100%
// 项目总正面稿件数
long
totalPositiveCount
=
markDataService
.
getYuqingMarkCount
(
null
,
null
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 项目总负面稿件数
long
totalNegativeCount
=
markDataService
.
getYuqingMarkCount
(
null
,
null
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 项目均值NSR
double
avg
=
0
==
totalPositiveCount
+
totalNegativeCount
?
0
:(
totalPositiveCount
-
totalNegativeCount
)
/
(
double
)
(
totalPositiveCount
+
totalNegativeCount
);
jsonObject
.
put
(
"avgNSR"
,
avg
);
// 正面稿件数
long
positiveCount
=
markDataService
.
getYuqingMarkCount
(
startTime
,
endTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
jsonObject
.
put
(
"positiveCount"
,
positiveCount
);
// 负面稿件数
long
negativeCount
=
markDataService
.
getYuqingMarkCount
(
startTime
,
endTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
jsonObject
.
put
(
"negativeCount"
,
negativeCount
);
// 本次NSR
double
NSR
=
0
==
positiveCount
+
negativeCount
?
0
:(
positiveCount
-
negativeCount
)
/
(
double
)
(
positiveCount
+
negativeCount
);
jsonObject
.
put
(
"NSR"
,
NSR
);
// 上一周期开始时间
long
previousStartTime
=
startTime
-
(
endTime
-
startTime
);
// 上一周期正面稿件数
long
previousPositiveCount
=
markDataService
.
getYuqingMarkCount
(
previousStartTime
,
startTime
,
EmotionEnum
.
POSITIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 上一周期负面稿件数
long
previousNegativeCount
=
markDataService
.
getYuqingMarkCount
(
previousStartTime
,
startTime
,
EmotionEnum
.
NEGATIVE
.
getName
(),
projectId
,
Constant
.
PRIMARY_CONTEND_ID
);
// 上一周期NSR
double
previousNSR
=
0
==
previousPositiveCount
+
previousNegativeCount
?
0
:(
previousPositiveCount
-
previousNegativeCount
)
/
(
double
)
(
previousPositiveCount
+
previousNegativeCount
);
// 环比
jsonObject
.
put
(
"compare"
,
NSR
-
previousNSR
);
redisUtil
.
setExpire
(
redisKey
,
JSON
.
toJSONString
(
jsonObject
));
}
catch
(
Exception
e
)
{
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"getEmotionPercent异常"
,
e
);
}
return
jsonObject
;
}
public
List
<
JSONObject
>
getPlatformProportionWithPlatform
(
Long
startTime
,
Long
endTime
,
String
emotion
,
String
projectId
,
String
contendId
,
long
normalCount
)
{
List
<
String
>
platformIds
=
GlobalPojo
.
PLATFORMS
.
stream
().
map
(
MessagePlatform:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
resultList
=
new
ArrayList
<>(
platformIds
.
size
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
218d144c
...
...
@@ -2749,7 +2749,7 @@ public class MarkDataServiceImpl implements MarkDataService {
}
catch
(
Exception
e
){
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"新舆情分析getActiveChannels异常-"
,
e
);
}
return
list
;
return
list
.
stream
().
limit
(
20
).
collect
(
Collectors
.
toList
())
;
}
@Override
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/TaskServiceImpl.java
View file @
218d144c
...
...
@@ -188,6 +188,8 @@ public class TaskServiceImpl implements TaskService {
indexService
.
getPlatformInfo
(
null
,
null
,
false
);
// 首页-传播趋势
indexService
.
getSpreadingTend
(
null
,
null
,
false
);
// 首页-净情感度
indexService
.
getEmotionPercent
(
null
,
null
,
false
);
log
.
info
(
"项目:{}-首页缓存已完成:{}个"
,
project
.
getProjectName
(),
total
.
incrementAndGet
());
return
null
;
},
cacheServiceExecutor
)).
toArray
(
CompletableFuture
[]::
new
)).
join
();
...
...
src/main/java/com/zhiwei/brandkbs2/util/RedisUtil.java
View file @
218d144c
...
...
@@ -59,6 +59,10 @@ public class RedisUtil {
return
RedisKeyPrefix
.
INDEX_SPREAD
+
Tools
.
concat
(
projectId
,
startTime
,
endTime
);
}
public
static
String
getIndexEmotionKey
(
String
projectId
,
Long
startTime
,
Long
endTime
)
{
return
RedisKeyPrefix
.
INDEX_EMOTION
+
Tools
.
concat
(
projectId
,
startTime
,
endTime
);
}
public
static
String
getChannelRecordList
(
String
projectId
,
Long
startTime
,
Long
endTime
,
String
platform
,
int
emotion
)
{
return
RedisKeyPrefix
.
CHANNEL_RECORD_LIST
+
Tools
.
concat
(
projectId
,
startTime
,
endTime
,
platform
,
emotion
);
}
...
...
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