Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bill-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
bill-platform
Commits
978ebbcb
Commit
978ebbcb
authored
Aug 05, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新调整统计线程实现
parent
f60af084
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
191 additions
and
26 deletions
+191
-26
bill-manager/src/main/java/com/mortals/xhx/common/thread/StatAllThread.java
...ain/java/com/mortals/xhx/common/thread/StatAllThread.java
+53
-0
bill-manager/src/main/java/com/mortals/xhx/common/thread/StatThread.java
...c/main/java/com/mortals/xhx/common/thread/StatThread.java
+3
-4
bill-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatAllTaskImpl.java
...java/com/mortals/xhx/daemon/task/SiteStatAllTaskImpl.java
+106
-0
bill-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
...in/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
+7
-7
bill-manager/src/main/java/com/mortals/xhx/module/access/model/vo/AccessVo.java
...java/com/mortals/xhx/module/access/model/vo/AccessVo.java
+2
-0
bill-manager/src/main/java/com/mortals/xhx/module/access/web/AccessController.java
...a/com/mortals/xhx/module/access/web/AccessController.java
+9
-4
bill-manager/src/main/java/com/mortals/xhx/module/ph/web/PhQueueStatController.java
.../com/mortals/xhx/module/ph/web/PhQueueStatController.java
+3
-3
bill-manager/src/main/java/com/mortals/xhx/module/pj/web/PjEvaluateStatController.java
...m/mortals/xhx/module/pj/web/PjEvaluateStatController.java
+3
-3
bill-manager/src/main/java/com/mortals/xhx/module/stat/web/StatController.java
.../java/com/mortals/xhx/module/stat/web/StatController.java
+4
-4
bill-manager/src/test/java/com/mortals/httpclient/system.http
...-manager/src/test/java/com/mortals/httpclient/system.http
+1
-1
No files found.
bill-manager/src/main/java/com/mortals/xhx/common/thread/StatAllThread.java
0 → 100644
View file @
978ebbcb
package
com.mortals.xhx.common.thread
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.mortals.framework.model.Context
;
import
com.mortals.xhx.common.code.StatTypeEnum
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
import
com.mortals.xhx.module.pj.service.PjEvaluateStatService
;
import
com.mortals.xhx.module.stat.service.StatService
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
java.util.List
;
/**
* 站点统计数据线程
*
* @author: zxfei
* @date: 2024/8/2 14:13
*/
@Slf4j
@AllArgsConstructor
public
class
StatAllThread
implements
Runnable
{
private
DateTime
attendStart
;
private
Long
compare
;
private
SitePdu
site
;
private
Context
context
;
private
List
<
Integer
>
typeStatList
;
@Override
public
void
run
()
{
if
(
ObjectUtils
.
isEmpty
(
site
.
getId
()))
return
;
StopWatch
stopWatch
=
new
StopWatch
();
StatService
statService
=
SpringUtil
.
getBean
(
StatService
.
class
);
if
(
typeStatList
.
contains
(
StatTypeEnum
.
STAT_ALL
.
getValue
()))
{
statService
.
updateSiteStatLog
(
attendStart
,
compare
,
stopWatch
,
site
,
context
);
}
}
}
bill-manager/src/main/java/com/mortals/xhx/common/thread/StatThread.java
View file @
978ebbcb
...
...
@@ -30,7 +30,7 @@ public class StatThread implements Runnable {
private
Long
compare
;
private
List
<
SitePdu
>
statSiteList
;
private
SitePdu
site
;
private
Context
context
;
...
...
@@ -39,8 +39,7 @@ public class StatThread implements Runnable {
@Override
public
void
run
()
{
for
(
SitePdu
site
:
statSiteList
)
{
if
(
ObjectUtils
.
isEmpty
(
site
.
getId
()))
continue
;
if
(
ObjectUtils
.
isEmpty
(
site
.
getId
()))
return
;
StopWatch
stopWatch
=
new
StopWatch
();
PhQueueStatService
phQueueStatService
=
SpringUtil
.
getBean
(
PhQueueStatService
.
class
);
...
...
@@ -58,7 +57,7 @@ public class StatThread implements Runnable {
if
(
typeStatList
.
contains
(
StatTypeEnum
.
STAT_ALL
.
getValue
()))
{
statService
.
updateSiteStatLog
(
attendStart
,
compare
,
stopWatch
,
site
,
context
);
}
}
}
...
...
bill-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatAllTaskImpl.java
0 → 100644
View file @
978ebbcb
package
com.mortals.xhx.daemon.task
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.xhx.common.code.StatTypeEnum
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.thread.StatThread
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
import
com.mortals.xhx.module.access.service.AccessService
;
import
com.mortals.xhx.module.ph.model.PhQueueStatEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatQuery
;
import
com.mortals.xhx.module.pj.service.PjEvaluateStatService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
/**
* 站点评价统计任务
*
* @author: zxfei
* @date: 2022/3/9 15:19
*/
@Slf4j
@Service
(
"SiteStatAllTask"
)
public
class
SiteStatAllTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
PjEvaluateStatService
pjEvaluateStatService
;
@Autowired
private
PhQueueStatService
phQueueStatService
;
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
AccessService
accessService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"站点评价统计任务"
);
//统计最近4天
Long
compare
=
DataUtil
.
converStr2Long
(
task
.
getExcuteParam
(),
4L
);
statByDate
(
compare
);
}
private
void
statByDate
(
Long
compare
)
{
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
DateTime
attendStart
=
DateUtil
.
offsetDay
(
new
Date
(),
-
compare
.
intValue
());
for
(
SitePdu
site
:
sitePduList
)
{
if
(
ObjectUtils
.
isEmpty
(
site
.
getId
()))
continue
;
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
,
null
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_ALL
.
getValue
()));
ThreadPool
.
getInstance
().
execute
(
statThread
);
}
}
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
}
public
static
void
main
(
String
[]
args
)
{
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
DateTime
beforeDate
=
DateUtil
.
offsetDay
(
new
Date
(),
-
i
);
int
year
=
beforeDate
.
year
();
int
month
=
beforeDate
.
month
()
+
1
;
int
day
=
beforeDate
.
dayOfMonth
();
System
.
out
.
println
(
year
+
"年"
+
month
+
"月"
+
day
+
"日"
);
}
/* int year = DateUtil.date().year();
int month = DateUtil.date().month() + 1;
int day = DateUtil.date().dayOfMonth();
// System.out.println(year + "年" + month + "月" + day + "日");
System.out.println(dateTime.toString("yyyy-MM-dd"));*/
}
}
bill-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
View file @
978ebbcb
...
...
@@ -79,18 +79,18 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
}
private
void
statByDate
(
Long
compare
)
{
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
DateTime
attendStart
=
DateUtil
.
offsetDay
(
new
Date
(),
-
compare
.
intValue
());
//
for (SitePdu site : sitePduList) {
//
if (ObjectUtils.isEmpty(site.getId())) continue;
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
PduList
,
null
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
(),
StatTypeEnum
.
STAT_PJ
.
getValue
(),
StatTypeEnum
.
STAT_ALL
.
getValue
()));
for
(
SitePdu
site
:
sitePduList
)
{
if
(
ObjectUtils
.
isEmpty
(
site
.
getId
()))
continue
;
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
,
null
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
(),
StatTypeEnum
.
STAT_PJ
.
getValue
()));
ThreadPool
.
getInstance
().
execute
(
statThread
);
//
}
}
}
private
void
updateSiteCache
()
{
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
for
(
SitePdu
site
:
sitePduList
)
{
updatePjSectionCache
(
site
);
...
...
bill-manager/src/main/java/com/mortals/xhx/module/access/model/vo/AccessVo.java
View file @
978ebbcb
...
...
@@ -22,6 +22,8 @@ public class AccessVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */
private
List
<
Long
>
idList
;
private
List
<
Integer
>
typeStatusList
;
public
static
void
main
(
String
[]
args
)
{
AccessEntity
accessEntity
=
new
AccessEntity
();
...
...
bill-manager/src/main/java/com/mortals/xhx/module/access/web/AccessController.java
View file @
978ebbcb
...
...
@@ -19,6 +19,7 @@ import com.mortals.xhx.module.access.model.AccessQuery;
import
com.mortals.xhx.module.access.service.AccessService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -75,12 +76,16 @@ public class AccessController extends BaseCRUDJsonBodyMappingController<AccessSe
log
.
info
(
"计算天数区间:{}"
,
compare
);
accessQuery
.
setAccessTimeStart
(
null
);
accessQuery
.
setAccessTimeEnd
(
null
);
if
(
ObjectUtils
.
isEmpty
(
accessQuery
.
getTypeStatusList
()))
{
accessQuery
.
setTypeStatusList
(
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
(),
StatTypeEnum
.
STAT_PJ
.
getValue
()));
}
List
<
SitePdu
>
statSiteList
=
accessService
.
getStatSiteList
(
accessQuery
);
//for (SitePdu site : statSiteList) {
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
statSiteList
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
(),
StatTypeEnum
.
STAT_PJ
.
getValue
(),
StatTypeEnum
.
STAT_ALL
.
getValue
()));
for
(
SitePdu
site
:
statSiteList
)
{
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
,
context
,
accessQuery
.
getTypeStatusList
());
ThreadPool
.
getInstance
().
execute
(
statThread
);
//
}
}
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
...
...
bill-manager/src/main/java/com/mortals/xhx/module/ph/web/PhQueueStatController.java
View file @
978ebbcb
...
...
@@ -179,10 +179,10 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
Long
compare
=
DateUtil
.
between
(
attendEnd
,
attendStart
,
DateUnit
.
DAY
);
log
.
info
(
"计算天数区间:{}"
,
compare
);
List
<
SitePdu
>
statSiteList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
//
for (SitePdu site : statSiteList) {
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
s
tatSiteList
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
()));
for
(
SitePdu
site
:
statSiteList
)
{
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
s
ite
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
()));
ThreadPool
.
getInstance
().
execute
(
statThread
);
//
}
}
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
...
...
bill-manager/src/main/java/com/mortals/xhx/module/pj/web/PjEvaluateStatController.java
View file @
978ebbcb
...
...
@@ -184,10 +184,10 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
Long
compare
=
DateUtil
.
between
(
attendEnd
,
attendStart
,
DateUnit
.
DAY
);
log
.
info
(
"计算天数区间:{}"
,
compare
);
List
<
SitePdu
>
statSiteList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
//
for (SitePdu site : statSiteList) {
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
s
tatSiteList
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PJ
.
getValue
()));
for
(
SitePdu
site
:
statSiteList
)
{
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
s
ite
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PJ
.
getValue
()));
ThreadPool
.
getInstance
().
execute
(
statThread
);
//
}
}
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
...
...
bill-manager/src/main/java/com/mortals/xhx/module/stat/web/StatController.java
View file @
978ebbcb
...
...
@@ -100,10 +100,10 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
Long
compare
=
DateUtil
.
between
(
attendEnd
,
attendStart
,
DateUnit
.
DAY
);
log
.
info
(
"计算天数区间:{}"
,
compare
);
List
<
SitePdu
>
statSiteList
=
accessService
.
getStatSiteList
(
new
AccessQuery
());
//
for (SitePdu site : statSiteList) {
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
statSiteList
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_ALL
.
getValue
()));
for
(
SitePdu
site
:
statSiteList
)
{
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_ALL
.
getValue
()));
ThreadPool
.
getInstance
().
execute
(
statThread
);
//
}
}
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
...
...
bill-manager/src/test/java/com/mortals/httpclient/system.http
View file @
978ebbcb
...
...
@@ -76,7 +76,7 @@ Content-Type: application/json
{
"accessTimeStart": "2023-01-01",
"accessTimeEnd": "2024-08-0
1
"
"accessTimeEnd": "2024-08-0
5
"
}
...
...
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