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
cc86484b
Commit
cc86484b
authored
Aug 02, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新调整统计线程实现
parent
8bec0536
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
468 additions
and
568 deletions
+468
-568
bill-manager/src/main/java/com/mortals/xhx/common/code/StatTypeEnum.java
...c/main/java/com/mortals/xhx/common/code/StatTypeEnum.java
+66
-0
bill-manager/src/main/java/com/mortals/xhx/common/thread/PhStatThread.java
...main/java/com/mortals/xhx/common/thread/PhStatThread.java
+57
-0
bill-manager/src/main/java/com/mortals/xhx/common/thread/StatThread.java
...c/main/java/com/mortals/xhx/common/thread/StatThread.java
+59
-0
bill-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
...in/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
+9
-151
bill-manager/src/main/java/com/mortals/xhx/module/access/service/AccessService.java
.../com/mortals/xhx/module/access/service/AccessService.java
+4
-0
bill-manager/src/main/java/com/mortals/xhx/module/access/service/impl/AccessServiceImpl.java
...als/xhx/module/access/service/impl/AccessServiceImpl.java
+1
-4
bill-manager/src/main/java/com/mortals/xhx/module/access/web/AccessController.java
...a/com/mortals/xhx/module/access/web/AccessController.java
+56
-19
bill-manager/src/main/java/com/mortals/xhx/module/ph/service/PhQueueStatService.java
...com/mortals/xhx/module/ph/service/PhQueueStatService.java
+6
-0
bill-manager/src/main/java/com/mortals/xhx/module/ph/service/impl/PhQueueStatServiceImpl.java
...ls/xhx/module/ph/service/impl/PhQueueStatServiceImpl.java
+72
-6
bill-manager/src/main/java/com/mortals/xhx/module/ph/web/PhQueueStatController.java
.../com/mortals/xhx/module/ph/web/PhQueueStatController.java
+14
-152
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/PjEvaluateStatService.java
.../mortals/xhx/module/pj/service/PjEvaluateStatService.java
+5
-0
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/impl/PjEvaluateStatServiceImpl.java
...xhx/module/pj/service/impl/PjEvaluateStatServiceImpl.java
+67
-2
bill-manager/src/main/java/com/mortals/xhx/module/pj/web/PjEvaluateStatController.java
...m/mortals/xhx/module/pj/web/PjEvaluateStatController.java
+10
-144
bill-manager/src/main/java/com/mortals/xhx/module/stat/service/StatService.java
...java/com/mortals/xhx/module/stat/service/StatService.java
+6
-0
bill-manager/src/main/java/com/mortals/xhx/module/stat/service/impl/StatServiceImpl.java
...mortals/xhx/module/stat/service/impl/StatServiceImpl.java
+26
-0
bill-manager/src/main/java/com/mortals/xhx/module/stat/web/StatController.java
.../java/com/mortals/xhx/module/stat/web/StatController.java
+10
-90
No files found.
bill-manager/src/main/java/com/mortals/xhx/common/code/StatTypeEnum.java
0 → 100644
View file @
cc86484b
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 统计模式枚举类
*
* @author zxfei
*/
public
enum
StatTypeEnum
{
STAT_PH
(
0
,
"排号"
),
STAT_PJ
(
1
,
"评价"
),
STAT_ALL
(
2
,
"All"
);
private
Integer
value
;
private
String
desc
;
StatTypeEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
StatTypeEnum
getByValue
(
Integer
value
)
{
for
(
StatTypeEnum
activeEnum
:
StatTypeEnum
.
values
())
{
if
(
activeEnum
.
getValue
()
==
value
)
{
return
activeEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
StatTypeEnum
item
:
StatTypeEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/common/thread/PhStatThread.java
0 → 100644
View file @
cc86484b
package
com.mortals.xhx.common.thread
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
import
com.mortals.xhx.module.access.model.AccessSystemEntity
;
import
com.mortals.xhx.module.access.service.AccessService
;
import
com.mortals.xhx.module.ph.model.PhQueueQuery
;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.TreeSet
;
import
java.util.stream.Collectors
;
import
static
java
.
util
.
stream
.
Collectors
.
collectingAndThen
;
import
static
java
.
util
.
stream
.
Collectors
.
toCollection
;
/**
* 排号统计数据
* @author: zxfei
* @date: 2024/8/2 14:13
*/
@Slf4j
@AllArgsConstructor
public
class
PhStatThread
implements
Runnable
{
private
DateTime
attendStart
;
private
Long
compare
;
private
SitePdu
site
;
private
Context
context
;
@Override
public
void
run
()
{
StopWatch
stopWatch
=
new
StopWatch
();
PhQueueStatService
phQueueStatService
=
SpringUtil
.
getBean
(
PhQueueStatService
.
class
);
phQueueStatService
.
updateSitePhStatLog
(
attendStart
,
compare
,
stopWatch
,
site
,
context
);
}
}
bill-manager/src/main/java/com/mortals/xhx/common/thread/StatThread.java
0 → 100644
View file @
cc86484b
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.StopWatch
;
import
java.util.List
;
/**
* 站点统计数据线程
*
* @author: zxfei
* @date: 2024/8/2 14:13
*/
@Slf4j
@AllArgsConstructor
public
class
StatThread
implements
Runnable
{
private
DateTime
attendStart
;
private
Long
compare
;
private
SitePdu
site
;
private
Context
context
;
private
List
<
Integer
>
typeStatList
;
@Override
public
void
run
()
{
StopWatch
stopWatch
=
new
StopWatch
();
PhQueueStatService
phQueueStatService
=
SpringUtil
.
getBean
(
PhQueueStatService
.
class
);
PjEvaluateStatService
pjEvaluateStatService
=
SpringUtil
.
getBean
(
PjEvaluateStatService
.
class
);
StatService
statService
=
SpringUtil
.
getBean
(
StatService
.
class
);
if
(
typeStatList
.
contains
(
StatTypeEnum
.
STAT_PH
.
getValue
()))
{
phQueueStatService
.
updateSitePhStatLog
(
attendStart
,
compare
,
stopWatch
,
site
,
context
);
}
if
(
typeStatList
.
contains
(
StatTypeEnum
.
STAT_PJ
.
getValue
()))
{
pjEvaluateStatService
.
updateSitePjStatLog
(
attendStart
,
compare
,
stopWatch
,
site
,
context
);
}
if
(
typeStatList
.
contains
(
StatTypeEnum
.
STAT_ALL
.
getValue
()))
{
statService
.
updateSiteStatLog
(
attendStart
,
compare
,
stopWatch
,
site
,
context
);
}
}
}
bill-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
View file @
cc86484b
package
com.mortals.xhx.daemon.task
;
package
com.mortals.xhx.daemon.task
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.xhx.common.code.AccessTypeEnum
;
import
com.mortals.xhx.common.code.AccessTypeEnum
;
import
com.mortals.xhx.common.code.StatTypeEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.keys.RedisCacheKeys
;
import
com.mortals.xhx.common.keys.RedisCacheKeys
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.thread.StatThread
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
...
@@ -80,162 +84,16 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
...
@@ -80,162 +84,16 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
private
void
statByDate
()
{
private
void
statByDate
()
{
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
();
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
();
Long
compare
=
4L
;
DateTime
attendStart
=
DateUtil
.
offsetDay
(
new
Date
(),
-
compare
.
intValue
());
for
(
SitePdu
site
:
sitePduList
)
{
for
(
SitePdu
site
:
sitePduList
)
{
if
(
ObjectUtils
.
isEmpty
(
site
.
getId
()))
continue
;
if
(
ObjectUtils
.
isEmpty
(
site
.
getId
()))
continue
;
StopWatch
allStopWatch
=
new
StopWatch
(
"allStopWatch"
);
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
,
null
,
StopWatch
pjqStopWatch
=
new
StopWatch
(
"pjqStopWatch"
);
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
(),
StatTypeEnum
.
STAT_PJ
.
getValue
(),
StatTypeEnum
.
STAT_ALL
.
getValue
()));
StopWatch
pdjStopWatch
=
new
StopWatch
(
"pdjStopWatch"
);
ThreadPool
.
getInstance
().
execute
(
statThread
);
allStopWatch
.
start
();
AccessStatLogEntity
statLogAllEntity
=
new
AccessStatLogEntity
();
statLogAllEntity
.
initAttrValue
();
statLogAllEntity
.
setCreateUserId
(
1L
);
statLogAllEntity
.
setCreateTime
(
new
Date
());
statLogAllEntity
.
setSiteId
(
site
.
getId
());
statLogAllEntity
.
setSiteCode
(
site
.
getSiteCode
());
statLogAllEntity
.
setSiteName
(
site
.
getSiteName
());
statLogAllEntity
.
setStatStartTime
(
new
Date
());
statLogAllEntity
.
setType
(
AccessTypeEnum
.
全部
.
getValue
());
pjqStopWatch
.
start
();
AccessStatLogEntity
statLogEntity
=
new
AccessStatLogEntity
();
statLogEntity
.
initAttrValue
();
statLogEntity
.
setCreateUserId
(
1L
);
statLogEntity
.
setCreateTime
(
new
Date
());
statLogEntity
.
setSiteId
(
site
.
getId
());
statLogEntity
.
setSiteCode
(
site
.
getSiteCode
());
statLogEntity
.
setSiteName
(
site
.
getSiteName
());
AccessQuery
accessQuery
=
new
AccessQuery
();
accessQuery
.
setSiteId
(
site
.
getId
()
==
null
?
0L
:
site
.
getId
());
AccessEntity
accessEntity
=
accessService
.
selectOne
(
accessQuery
);
if
(!
ObjectUtils
.
isEmpty
(
accessEntity
))
{
statLogEntity
.
setAccessId
(
accessEntity
.
getId
());
}
statLogEntity
.
setStatStartTime
(
new
Date
());
statLogEntity
.
setType
(
AccessTypeEnum
.
评价器
.
getValue
());
int
range
=
4
;
for
(
int
i
=
0
;
i
<
range
;
i
++)
{
DateTime
beforeDate
=
DateUtil
.
offsetDay
(
new
Date
(),
-
i
);
int
year
=
beforeDate
.
year
();
int
month
=
beforeDate
.
month
()
+
1
;
int
day
=
beforeDate
.
dayOfMonth
();
PjEvaluateStatEntity
sitestatEntity
=
new
PjEvaluateStatEntity
();
sitestatEntity
.
initAttrValue
();
sitestatEntity
.
setSiteId
(
site
.
getId
());
sitestatEntity
.
setSiteName
(
site
.
getSiteName
());
sitestatEntity
.
setSiteCode
(
site
.
getSiteCode
());
sitestatEntity
.
setYear
(
year
);
sitestatEntity
.
setMonth
(
month
);
sitestatEntity
.
setDay
(
day
);
//设置年月日
pjEvaluateStatService
.
updateSitePjStat
(
sitestatEntity
,
null
);
}
pjqStopWatch
.
stop
();
statLogEntity
.
setStatEndTime
(
new
Date
());
statLogEntity
.
setDuration
(
pjqStopWatch
.
getLastTaskTimeMillis
());
accessStatLogService
.
save
(
statLogEntity
,
null
);
pdjStopWatch
.
start
();
statLogEntity
.
setStatStartTime
(
new
Date
());
statLogEntity
.
setType
(
AccessTypeEnum
.
排队机
.
getValue
());
for
(
int
i
=
0
;
i
<
range
;
i
++)
{
DateTime
beforeDate
=
DateUtil
.
offsetDay
(
new
Date
(),
-
i
);
int
year
=
beforeDate
.
year
();
int
month
=
beforeDate
.
month
()
+
1
;
int
day
=
beforeDate
.
dayOfMonth
();
//设置排号
PhQueueStatEntity
phQueueStatEntity
=
new
PhQueueStatEntity
();
phQueueStatEntity
.
initAttrValue
();
phQueueStatEntity
.
setSiteId
(
site
.
getId
());
phQueueStatEntity
.
setSiteName
(
site
.
getSiteName
());
phQueueStatEntity
.
setSiteCode
(
site
.
getSiteCode
());
phQueueStatEntity
.
setYear
(
year
);
phQueueStatEntity
.
setMonth
(
month
);
phQueueStatEntity
.
setDay
(
day
);
phQueueStatService
.
updateSitePhStat
(
phQueueStatEntity
,
null
);
}
pdjStopWatch
.
stop
();
statLogEntity
.
setStatEndTime
(
new
Date
());
statLogEntity
.
setDuration
(
pjqStopWatch
.
getLastTaskTimeMillis
());
accessStatLogService
.
save
(
statLogEntity
,
null
);
for
(
int
i
=
0
;
i
<
range
;
i
++)
{
DateTime
beforeDate
=
DateUtil
.
offsetDay
(
new
Date
(),
-
i
);
int
year
=
beforeDate
.
year
();
int
month
=
beforeDate
.
month
()
+
1
;
int
day
=
beforeDate
.
dayOfMonth
();
StatEntity
statEntity
=
new
StatEntity
();
statEntity
.
initAttrValue
();
statEntity
.
setSiteId
(
site
.
getId
());
statEntity
.
setSiteName
(
site
.
getSiteName
());
statEntity
.
setSiteCode
(
site
.
getSiteCode
());
statEntity
.
setYear
(
year
);
statEntity
.
setMonth
(
month
);
statEntity
.
setDay
(
day
);
//设置年月日
statService
.
updateSiteStat
(
statEntity
,
null
);
}
allStopWatch
.
stop
();
statLogAllEntity
.
setStatEndTime
(
new
Date
());
statLogAllEntity
.
setDuration
(
pjqStopWatch
.
getLastTaskTimeMillis
());
accessStatLogService
.
save
(
statLogAllEntity
,
null
);
}
}
}
}
/* private List<SitePdu> getStatSiteList() {
AccessQuery accessQuery = new AccessQuery();
// accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery);
accessEntities = accessEntities.stream().filter(item -> {
List<AccessSystemEntity> accessSystemList = item.getAccessSystemList();
//判断排队机或者评价系统是否开通
if(ObjectUtils.isEmpty(accessSystemList))return false;
List<AccessSystemEntity> collect = accessSystemList.stream().filter(f -> f.getEnabled() == YesNoEnum.YES.getValue()).collect(Collectors.toList());
if(ObjectUtils.isEmpty(collect)){return false;}
return true;
}).collect(Collectors.toList());
List<SitePdu> sitePduList = new ArrayList<>();
for (AccessEntity accessEntity : accessEntities) {
if(accessEntity.getSiteId()==1L){
SitePdu site = new SitePdu();
site.setId(accessEntity.getSiteId());
site.setSiteName(accessEntity.getSiteName());
site.setSiteCode(accessEntity.getSiteCode());
site.setAreaCode(accessEntity.getAreaCode());
sitePduList.add(site);
continue;
}
SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getSiteId());
Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if (YesNoEnum.YES.getValue() == sitesRest.getCode()) {
sitePduList.addAll(sitesRest.getData());
}
}
if (!ObjectUtils.isEmpty(sitePduList)) {
sitePduList = sitePduList.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new));
}
return sitePduList;
}*/
private
void
updateSiteCache
()
{
private
void
updateSiteCache
()
{
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
();
List
<
SitePdu
>
sitePduList
=
accessService
.
getStatSiteList
();
...
...
bill-manager/src/main/java/com/mortals/xhx/module/access/service/AccessService.java
View file @
cc86484b
...
@@ -18,5 +18,9 @@ public interface AccessService extends ICRUDService<AccessEntity,Long>{
...
@@ -18,5 +18,9 @@ public interface AccessService extends ICRUDService<AccessEntity,Long>{
AccessDao
getDao
();
AccessDao
getDao
();
/**
* 获取统计站点列表
* @return
*/
List
<
SitePdu
>
getStatSiteList
();
List
<
SitePdu
>
getStatSiteList
();
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/access/service/impl/AccessServiceImpl.java
View file @
cc86484b
...
@@ -129,7 +129,6 @@ public class AccessServiceImpl extends AbstractCRUDServiceImpl<AccessDao, Access
...
@@ -129,7 +129,6 @@ public class AccessServiceImpl extends AbstractCRUDServiceImpl<AccessDao, Access
@Override
@Override
public
List
<
SitePdu
>
getStatSiteList
()
{
public
List
<
SitePdu
>
getStatSiteList
()
{
AccessQuery
accessQuery
=
new
AccessQuery
();
AccessQuery
accessQuery
=
new
AccessQuery
();
// accessQuery.setTagNotList(Arrays.asList(""));
List
<
AccessEntity
>
accessEntities
=
this
.
find
(
accessQuery
);
List
<
AccessEntity
>
accessEntities
=
this
.
find
(
accessQuery
);
accessEntities
=
accessEntities
.
stream
().
filter
(
item
->
{
accessEntities
=
accessEntities
.
stream
().
filter
(
item
->
{
List
<
AccessSystemEntity
>
accessSystemList
=
item
.
getAccessSystemList
();
List
<
AccessSystemEntity
>
accessSystemList
=
item
.
getAccessSystemList
();
...
@@ -144,9 +143,7 @@ public class AccessServiceImpl extends AbstractCRUDServiceImpl<AccessDao, Access
...
@@ -144,9 +143,7 @@ public class AccessServiceImpl extends AbstractCRUDServiceImpl<AccessDao, Access
List
<
SitePdu
>
sitePduList
=
new
ArrayList
<>();
List
<
SitePdu
>
sitePduList
=
new
ArrayList
<>();
for
(
AccessEntity
accessEntity
:
accessEntities
)
{
for
(
AccessEntity
accessEntity
:
accessEntities
)
{
if
(
ObjectUtils
.
isEmpty
(
accessEntity
.
getSiteId
()))
continue
;
if
(
ObjectUtils
.
isEmpty
(
accessEntity
.
getSiteId
()))
continue
;
if
(
accessEntity
.
getSiteId
()
==
1L
)
{
if
(
accessEntity
.
getSiteId
()
==
1L
)
{
SitePdu
site
=
new
SitePdu
();
SitePdu
site
=
new
SitePdu
();
site
.
setId
(
accessEntity
.
getSiteId
());
site
.
setId
(
accessEntity
.
getSiteId
());
...
...
bill-manager/src/main/java/com/mortals/xhx/module/access/web/AccessController.java
View file @
cc86484b
package
com.mortals.xhx.module.access.web
;
package
com.mortals.xhx.module.access.web
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.common.code.StatTypeEnum
;
import
com.mortals.xhx.common.code.TypeEnum
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.thread.StatThread
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
com.mortals.framework.model.Context
;
import
java.util.Arrays
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.service.AccessService
;
import
org.apache.commons.lang3.ArrayUtils
;
import
com.mortals.framework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.Arrays
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.*;
import
com.mortals.xhx.common.code.*
;
/**
/**
*
*
* 区域接入
* 区域接入
...
@@ -34,10 +37,10 @@ import com.mortals.xhx.common.code.*;
...
@@ -34,10 +37,10 @@ import com.mortals.xhx.common.code.*;
*/
*/
@RestController
@RestController
@RequestMapping
(
"access"
)
@RequestMapping
(
"access"
)
@Slf4j
public
class
AccessController
extends
BaseCRUDJsonBodyMappingController
<
AccessService
,
AccessEntity
,
Long
>
{
public
class
AccessController
extends
BaseCRUDJsonBodyMappingController
<
AccessService
,
AccessEntity
,
Long
>
{
@Autowired
@Autowired
private
ParamService
param
Service
;
private
AccessService
access
Service
;
public
AccessController
(){
public
AccessController
(){
super
.
setModuleDesc
(
"区域接入"
);
super
.
setModuleDesc
(
"区域接入"
);
...
@@ -55,4 +58,38 @@ public class AccessController extends BaseCRUDJsonBodyMappingController<AccessSe
...
@@ -55,4 +58,38 @@ public class AccessController extends BaseCRUDJsonBodyMappingController<AccessSe
super
.
doListBefore
(
query
,
model
,
context
);
super
.
doListBefore
(
query
,
model
,
context
);
}
}
@PostMapping
(
value
=
"/stat"
)
@UnAuth
public
Rest
<
String
>
stat
(
@RequestBody
AccessQuery
accessQuery
)
{
Rest
<
String
>
ret
=
new
Rest
();
Map
<
String
,
Object
>
model
=
new
HashMap
();
Context
context
=
this
.
getContext
();
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
();
int
code
=
1
;
try
{
//天数区间分段计算
DateTime
attendStart
=
DateUtil
.
parseDate
(
accessQuery
.
getAccessTimeStart
());
DateTime
attendEnd
=
DateUtil
.
parseDate
(
accessQuery
.
getAccessTimeEnd
());
Long
compare
=
DateUtil
.
between
(
attendEnd
,
attendStart
,
DateUnit
.
DAY
);
log
.
info
(
"计算天数区间:{}"
,
compare
);
List
<
SitePdu
>
statSiteList
=
accessService
.
getStatSiteList
();
for
(
SitePdu
site
:
statSiteList
)
{
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_PH
.
getValue
(),
StatTypeEnum
.
STAT_PJ
.
getValue
(),
StatTypeEnum
.
STAT_ALL
.
getValue
()));
ThreadPool
.
getInstance
().
execute
(
statThread
);
}
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
code
=
-
1
;
this
.
doException
(
this
.
request
,
busiDesc
,
model
,
e
);
model
.
put
(
"message_info"
,
e
.
getMessage
());
}
this
.
init
(
model
,
context
);
ret
.
setCode
(
code
);
ret
.
setMsg
(
model
.
get
(
"message_info"
)
==
null
?
""
:
model
.
remove
(
"message_info"
).
toString
());
return
ret
;
}
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/ph/service/PhQueueStatService.java
View file @
cc86484b
package
com.mortals.xhx.module.ph.service
;
package
com.mortals.xhx.module.ph.service
;
import
cn.hutool.core.date.DateTime
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.module.ph.model.PhQueueStatEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueStatEntity
;
import
com.mortals.xhx.module.ph.dao.PhQueueStatDao
;
import
com.mortals.xhx.module.ph.dao.PhQueueStatDao
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
org.springframework.util.StopWatch
;
import
java.util.List
;
import
java.util.List
;
...
@@ -30,4 +33,7 @@ public interface PhQueueStatService extends ICRUDService<PhQueueStatEntity, Long
...
@@ -30,4 +33,7 @@ public interface PhQueueStatService extends ICRUDService<PhQueueStatEntity, Long
void
saveUpdatePhStatList
(
List
<
PhQueueStatEntity
>
saveAndUpdatelist
);
void
saveUpdatePhStatList
(
List
<
PhQueueStatEntity
>
saveAndUpdatelist
);
void
updateSitePhStatLog
(
DateTime
attendStart
,
Long
compare
,
StopWatch
stopWatch
,
SitePdu
site
,
Context
context
);
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/ph/service/impl/PhQueueStatServiceImpl.java
View file @
cc86484b
package
com.mortals.xhx.module.ph.service.impl
;
package
com.mortals.xhx.module.ph.service.impl
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.google.common.collect.Lists
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.xhx.common.code.AccessTypeEnum
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
import
com.mortals.xhx.module.access.model.AccessStatLogEntity
;
import
com.mortals.xhx.module.access.service.AccessService
;
import
com.mortals.xhx.module.access.service.AccessStatLogService
;
import
com.mortals.xhx.module.ph.model.PhQueueEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueQuery
;
import
com.mortals.xhx.module.ph.model.PhQueueQuery
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
...
@@ -21,6 +31,7 @@ import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
...
@@ -21,6 +31,7 @@ import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
...
@@ -39,6 +50,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -39,6 +50,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
@Autowired
@Autowired
private
PhQueueService
phQueueService
;
private
PhQueueService
phQueueService
;
@Autowired
private
AccessService
accessService
;
@Autowired
private
AccessStatLogService
accessStatLogService
;
@Override
@Override
...
@@ -62,7 +77,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -62,7 +77,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
// log.info("更新站点排队统计数据,站点ID:{},站点名称:{},日期:{},排队数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size());
// log.info("更新站点排队统计数据,站点ID:{},站点名称:{},日期:{},排队数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size());
updateSitePhCount
(
entity
,
phQueueEntities
);
updateSitePhCount
(
entity
,
phQueueEntities
);
List
<
PhQueueStatEntity
>
saveOrUpdateList
=
new
ArrayList
<>();
List
<
PhQueueStatEntity
>
saveOrUpdateList
=
new
ArrayList
<>();
//部门
//部门
List
<
PhQueueStatEntity
>
phQueueStatEntities
=
updateSiteSectionNamePhCount
(
currentDate
,
entity
,
phQueueEntities
);
List
<
PhQueueStatEntity
>
phQueueStatEntities
=
updateSiteSectionNamePhCount
(
currentDate
,
entity
,
phQueueEntities
);
...
@@ -176,7 +191,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -176,7 +191,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
phQueueStatEntity
.
setWindowFromnum
(
window
);
phQueueStatEntity
.
setWindowFromnum
(
window
);
return
phQueueStatEntity
;
return
phQueueStatEntity
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
// saveUpdatePhStatList(saveAndUpdatelist);
// saveUpdatePhStatList(saveAndUpdatelist);
return
saveAndUpdatelist
;
return
saveAndUpdatelist
;
}
}
...
@@ -209,7 +224,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -209,7 +224,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
}
}
private
List
<
PhQueueStatEntity
>
updateSiteConditionPhCount
(
PhQueueStatEntity
entity
,
List
<
PhQueueEntity
>
phQueueEntities
)
{
private
List
<
PhQueueStatEntity
>
updateSiteConditionPhCount
(
PhQueueStatEntity
entity
,
List
<
PhQueueEntity
>
phQueueEntities
)
{
List
<
PhQueueStatEntity
>
phQueueStatEntities
=
new
ArrayList
<>();
List
<
PhQueueStatEntity
>
phQueueStatEntities
=
new
ArrayList
<>();
...
@@ -253,7 +268,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -253,7 +268,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
phQueueStatEntity
.
setSectionName
(
split
[
1
]);
phQueueStatEntity
.
setSectionName
(
split
[
1
]);
return
phQueueStatEntity
;
return
phQueueStatEntity
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
//saveUpdatePhStatList(saveAndUpdatelist);
//saveUpdatePhStatList(saveAndUpdatelist);
return
saveAndUpdatelist
;
return
saveAndUpdatelist
;
}
}
...
@@ -275,7 +290,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -275,7 +290,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
phQueueStatEntity
.
setWindowFromnum
(
split
[
1
]);
phQueueStatEntity
.
setWindowFromnum
(
split
[
1
]);
return
phQueueStatEntity
;
return
phQueueStatEntity
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
// saveUpdatePhStatList(saveAndUpdatelist);
// saveUpdatePhStatList(saveAndUpdatelist);
return
saveAndUpdatelist
;
return
saveAndUpdatelist
;
}
}
...
@@ -322,7 +337,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -322,7 +337,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
phQueueStatEntity
.
setWindowFromnum
(
split
[
2
]);
phQueueStatEntity
.
setWindowFromnum
(
split
[
2
]);
return
phQueueStatEntity
;
return
phQueueStatEntity
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
// saveUpdatePhStatList(saveAndUpdatelist);
// saveUpdatePhStatList(saveAndUpdatelist);
return
saveAndUpdatelist
;
return
saveAndUpdatelist
;
}
}
...
@@ -382,6 +397,57 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
...
@@ -382,6 +397,57 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
}
}
}
}
public
void
updateSitePhStatLog
(
DateTime
attendStart
,
Long
compare
,
StopWatch
stopWatch
,
SitePdu
site
,
Context
context
)
{
log
.
info
(
"统计站点:{}"
,
site
.
getSiteName
());
stopWatch
.
start
(
"站点排号统计开始"
);
AccessStatLogEntity
statLogEntity
=
new
AccessStatLogEntity
();
statLogEntity
.
initAttrValue
();
statLogEntity
.
setStatStartTime
(
new
Date
());
statLogEntity
.
setType
(
AccessTypeEnum
.
排队机
.
getValue
());
statLogEntity
.
setCreateUserId
(
1L
);
statLogEntity
.
setCreateTime
(
new
Date
());
statLogEntity
.
setSiteId
(
site
.
getId
());
statLogEntity
.
setSiteCode
(
site
.
getSiteCode
());
statLogEntity
.
setSiteName
(
site
.
getSiteName
());
AccessQuery
accessQuery
=
new
AccessQuery
();
accessQuery
.
setSiteId
(
site
.
getId
()
==
null
?
0L
:
site
.
getId
());
AccessEntity
accessEntity
=
accessService
.
selectOne
(
accessQuery
);
if
(!
ObjectUtils
.
isEmpty
(
accessEntity
))
{
statLogEntity
.
setAccessId
(
accessEntity
.
getId
());
}
List
<
PhQueueStatEntity
>
saveOrUpdateList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<=
compare
.
intValue
();
i
++)
{
DateTime
curDate
=
DateUtil
.
offsetDay
(
attendStart
,
i
);
// log.info("记录日期:{}", curDate.toDateStr());
PhQueueStatEntity
sitestatEntity
=
new
PhQueueStatEntity
();
sitestatEntity
.
initAttrValue
();
sitestatEntity
.
setSiteId
(
site
.
getId
());
sitestatEntity
.
setSiteName
(
site
.
getSiteName
());
sitestatEntity
.
setSiteCode
(
site
.
getSiteCode
());
sitestatEntity
.
setYear
(
curDate
.
year
());
sitestatEntity
.
setMonth
(
curDate
.
month
()
+
1
);
sitestatEntity
.
setDay
(
curDate
.
dayOfMonth
());
//设置年月日
Rest
<
List
<
PhQueueStatEntity
>>
listRest
=
this
.
updateSitePhStat
(
sitestatEntity
,
context
);
saveOrUpdateList
.
addAll
(
listRest
.
getData
());
}
List
<
List
<
PhQueueStatEntity
>>
partition
=
Lists
.
partition
(
saveOrUpdateList
,
1000
);
for
(
List
<
PhQueueStatEntity
>
phQueueStatEntities
:
partition
)
{
this
.
saveUpdatePhStatList
(
phQueueStatEntities
);
}
stopWatch
.
stop
();
statLogEntity
.
setStatEndTime
(
new
Date
());
statLogEntity
.
setDuration
(
stopWatch
.
getLastTaskTimeMillis
());
accessStatLogService
.
save
(
statLogEntity
,
context
);
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
str
=
"adbc&&"
;
String
str
=
"adbc&&"
;
List
<
String
>
split
=
StrUtil
.
split
(
str
,
"&"
);
List
<
String
>
split
=
StrUtil
.
split
(
str
,
"&"
);
...
...
bill-manager/src/main/java/com/mortals/xhx/module/ph/web/PhQueueStatController.java
View file @
cc86484b
This diff is collapsed.
Click to expand it.
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/PjEvaluateStatService.java
View file @
cc86484b
package
com.mortals.xhx.module.pj.service
;
package
com.mortals.xhx.module.pj.service
;
import
cn.hutool.core.date.DateTime
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
com.mortals.xhx.module.pj.dao.PjEvaluateStatDao
;
import
com.mortals.xhx.module.pj.dao.PjEvaluateStatDao
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatQuery
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatQuery
;
import
org.springframework.util.StopWatch
;
import
java.util.List
;
import
java.util.List
;
...
@@ -33,4 +36,6 @@ public interface PjEvaluateStatService extends ICRUDService<PjEvaluateStatEntity
...
@@ -33,4 +36,6 @@ public interface PjEvaluateStatService extends ICRUDService<PjEvaluateStatEntity
List
<
PjEvaluateStatEntity
>
getBillInfos
(
PjEvaluateStatQuery
query
,
PageInfo
pageInfo
,
Context
context
);
List
<
PjEvaluateStatEntity
>
getBillInfos
(
PjEvaluateStatQuery
query
,
PageInfo
pageInfo
,
Context
context
);
void
saveUpdatePjEvaluateStatList
(
List
<
PjEvaluateStatEntity
>
saveAndUpdatelist
);
void
saveUpdatePjEvaluateStatList
(
List
<
PjEvaluateStatEntity
>
saveAndUpdatelist
);
void
updateSitePjStatLog
(
DateTime
attendStart
,
Long
compare
,
StopWatch
stopWatch
,
SitePdu
site
,
Context
context
);
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/pj/service/impl/PjEvaluateStatServiceImpl.java
View file @
cc86484b
package
com.mortals.xhx.module.pj.service.impl
;
package
com.mortals.xhx.module.pj.service.impl
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.google.common.collect.Lists
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.xhx.common.code.AccessTypeEnum
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
import
com.mortals.xhx.module.access.model.AccessStatLogEntity
;
import
com.mortals.xhx.module.access.service.AccessService
;
import
com.mortals.xhx.module.access.service.AccessStatLogService
;
import
com.mortals.xhx.module.pj.model.PjEvaluateEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateQuery
;
import
com.mortals.xhx.module.pj.model.PjEvaluateQuery
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatQuery
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatQuery
;
...
@@ -21,6 +31,7 @@ import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
...
@@ -21,6 +31,7 @@ import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import
com.mortals.xhx.module.pj.service.PjEvaluateStatService
;
import
com.mortals.xhx.module.pj.service.PjEvaluateStatService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
...
@@ -39,7 +50,10 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
...
@@ -39,7 +50,10 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
@Autowired
@Autowired
private
PjEvaluateService
pjEvaluateService
;
private
PjEvaluateService
pjEvaluateService
;
@Autowired
private
AccessService
accessService
;
@Autowired
private
AccessStatLogService
accessStatLogService
;
@Override
@Override
public
Result
<
PjEvaluateStatEntity
>
find
(
PjEvaluateStatEntity
entity
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
{
public
Result
<
PjEvaluateStatEntity
>
find
(
PjEvaluateStatEntity
entity
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
{
...
@@ -90,7 +104,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
...
@@ -90,7 +104,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
saveAndUpdatelist
.
addAll
(
pjEvaluateStatEntities3
);
saveAndUpdatelist
.
addAll
(
pjEvaluateStatEntities3
);
saveAndUpdatelist
.
addAll
(
pjEvaluateStatEntities4
);
saveAndUpdatelist
.
addAll
(
pjEvaluateStatEntities4
);
// saveUpdatePjEvaluateStatList(saveAndUpdatelist);
// saveUpdatePjEvaluateStatList(saveAndUpdatelist);
return
Rest
.
ok
(
saveAndUpdatelist
);
return
Rest
.
ok
(
saveAndUpdatelist
);
}
}
...
@@ -379,5 +393,56 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
...
@@ -379,5 +393,56 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
}
}
}
}
@Override
public
void
updateSitePjStatLog
(
DateTime
attendStart
,
Long
compare
,
StopWatch
stopWatch
,
SitePdu
site
,
Context
context
)
{
stopWatch
.
start
(
"站点评价统计开始"
);
AccessStatLogEntity
statLogEntity
=
new
AccessStatLogEntity
();
statLogEntity
.
initAttrValue
();
statLogEntity
.
setStatStartTime
(
new
Date
());
statLogEntity
.
setType
(
AccessTypeEnum
.
排队机
.
getValue
());
statLogEntity
.
setCreateUserId
(
1L
);
statLogEntity
.
setCreateTime
(
new
Date
());
statLogEntity
.
setSiteId
(
site
.
getId
());
statLogEntity
.
setSiteCode
(
site
.
getSiteCode
());
statLogEntity
.
setSiteName
(
site
.
getSiteName
());
AccessQuery
accessQuery
=
new
AccessQuery
();
accessQuery
.
setSiteId
(
site
.
getId
()
==
null
?
0L
:
site
.
getId
());
AccessEntity
accessEntity
=
accessService
.
selectOne
(
accessQuery
);
if
(!
ObjectUtils
.
isEmpty
(
accessEntity
))
{
statLogEntity
.
setAccessId
(
accessEntity
.
getId
());
}
List
<
PjEvaluateStatEntity
>
saveAndUpdatelist
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<=
compare
.
intValue
();
i
++)
{
DateTime
curDate
=
DateUtil
.
offsetDay
(
attendStart
,
i
);
//log.info("记录日期:{}", curDate.toDateStr());
PjEvaluateStatEntity
sitestatEntity
=
new
PjEvaluateStatEntity
();
sitestatEntity
.
initAttrValue
();
sitestatEntity
.
setSiteId
(
site
.
getId
());
sitestatEntity
.
setSiteName
(
site
.
getSiteName
());
sitestatEntity
.
setSiteCode
(
site
.
getSiteCode
());
sitestatEntity
.
setYear
(
curDate
.
year
());
sitestatEntity
.
setMonth
(
curDate
.
month
()
+
1
);
sitestatEntity
.
setDay
(
curDate
.
dayOfMonth
());
//设置年月日
Rest
<
List
<
PjEvaluateStatEntity
>>
rest
=
this
.
updateSitePjStat
(
sitestatEntity
,
context
);
saveAndUpdatelist
.
addAll
(
rest
.
getData
());
}
List
<
List
<
PjEvaluateStatEntity
>>
partition
=
Lists
.
partition
(
saveAndUpdatelist
,
1000
);
for
(
List
<
PjEvaluateStatEntity
>
pjEvaluateStatEntities
:
partition
)
{
this
.
saveUpdatePjEvaluateStatList
(
pjEvaluateStatEntities
);
}
stopWatch
.
stop
();
statLogEntity
.
setStatEndTime
(
new
Date
());
statLogEntity
.
setDuration
(
stopWatch
.
getLastTaskTimeMillis
());
accessStatLogService
.
save
(
statLogEntity
,
context
);
}
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/pj/web/PjEvaluateStatController.java
View file @
cc86484b
This diff is collapsed.
Click to expand it.
bill-manager/src/main/java/com/mortals/xhx/module/stat/service/StatService.java
View file @
cc86484b
package
com.mortals.xhx.module.stat.service
;
package
com.mortals.xhx.module.stat.service
;
import
cn.hutool.core.date.DateTime
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
com.mortals.xhx.module.pj.model.PjEvaluateStatEntity
;
import
com.mortals.xhx.module.stat.model.StatEntity
;
import
com.mortals.xhx.module.stat.model.StatEntity
;
import
com.mortals.xhx.module.stat.dao.StatDao
;
import
com.mortals.xhx.module.stat.dao.StatDao
;
import
org.springframework.util.StopWatch
;
/**
/**
* StatService
* StatService
*
*
...
@@ -27,4 +31,6 @@ public interface StatService extends ICRUDService<StatEntity,Long>{
...
@@ -27,4 +31,6 @@ public interface StatService extends ICRUDService<StatEntity,Long>{
Rest
<
Void
>
updateSiteStat
(
StatEntity
entity
,
Context
context
);
Rest
<
Void
>
updateSiteStat
(
StatEntity
entity
,
Context
context
);
void
updateSiteStatLog
(
DateTime
attendStart
,
Long
compare
,
StopWatch
stopWatch
,
SitePdu
site
,
Context
context
);
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/stat/service/impl/StatServiceImpl.java
View file @
cc86484b
package
com.mortals.xhx.module.stat.service.impl
;
package
com.mortals.xhx.module.stat.service.impl
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.module.access.service.AccessStatLogService
;
import
com.mortals.xhx.module.ph.model.PhQueueStatEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueStatEntity
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
import
com.mortals.xhx.module.ph.model.PhQueueStatQuery
;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
import
com.mortals.xhx.module.ph.service.PhQueueStatService
;
...
@@ -24,6 +28,7 @@ import com.mortals.xhx.module.stat.model.StatEntity;
...
@@ -24,6 +28,7 @@ import com.mortals.xhx.module.stat.model.StatEntity;
import
com.mortals.xhx.module.stat.service.StatService
;
import
com.mortals.xhx.module.stat.service.StatService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -46,6 +51,8 @@ public class StatServiceImpl extends AbstractCRUDServiceImpl<StatDao, StatEntity
...
@@ -46,6 +51,8 @@ public class StatServiceImpl extends AbstractCRUDServiceImpl<StatDao, StatEntity
private
PjEvaluateStatService
pjEvaluateStatService
;
private
PjEvaluateStatService
pjEvaluateStatService
;
@Autowired
@Autowired
private
PhQueueStatService
phQueueStatService
;
private
PhQueueStatService
phQueueStatService
;
@Autowired
private
AccessStatLogService
accessStatLogService
;
@Override
@Override
...
@@ -124,4 +131,23 @@ public class StatServiceImpl extends AbstractCRUDServiceImpl<StatDao, StatEntity
...
@@ -124,4 +131,23 @@ public class StatServiceImpl extends AbstractCRUDServiceImpl<StatDao, StatEntity
}
}
return
Rest
.
ok
();
return
Rest
.
ok
();
}
}
@Override
public
void
updateSiteStatLog
(
DateTime
attendStart
,
Long
compare
,
StopWatch
stopWatch
,
SitePdu
site
,
Context
context
)
{
for
(
int
i
=
0
;
i
<=
compare
.
intValue
();
i
++)
{
DateTime
curDate
=
DateUtil
.
offsetDay
(
attendStart
,
i
);
StatEntity
statEntity
=
new
StatEntity
();
statEntity
.
initAttrValue
();
statEntity
.
setSiteId
(
site
.
getId
());
statEntity
.
setSiteName
(
site
.
getSiteName
());
statEntity
.
setSiteCode
(
site
.
getSiteCode
());
statEntity
.
setYear
(
curDate
.
year
());
statEntity
.
setMonth
(
curDate
.
month
()
+
1
);
statEntity
.
setDay
(
curDate
.
dayOfMonth
());
//设置年月日
this
.
updateSiteStat
(
statEntity
,
context
);
}
}
}
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/module/stat/web/StatController.java
View file @
cc86484b
...
@@ -11,6 +11,7 @@ import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
...
@@ -11,6 +11,7 @@ import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.thread.StatThread
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessEntity
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
import
com.mortals.xhx.module.access.model.AccessQuery
;
...
@@ -94,96 +95,15 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
...
@@ -94,96 +95,15 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
();
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
();
int
code
=
1
;
int
code
=
1
;
try
{
try
{
DateTime
attendStart
=
DateUtil
.
parseDate
(
query
.
getCreateTimeStart
());
Runnable
runnable
=
new
Runnable
()
{
DateTime
attendEnd
=
DateUtil
.
parseDate
(
query
.
getCreateTimeEnd
());
@Override
Long
compare
=
DateUtil
.
between
(
attendEnd
,
attendStart
,
DateUnit
.
DAY
);
public
void
run
()
{
log
.
info
(
"计算天数区间:{}"
,
compare
);
//天数区间分段计算
List
<
SitePdu
>
statSiteList
=
accessService
.
getStatSiteList
();
DateTime
attendStart
=
DateUtil
.
parseDate
(
query
.
getCreateTimeStart
());
for
(
SitePdu
site
:
statSiteList
)
{
DateTime
attendEnd
=
DateUtil
.
parseDate
(
query
.
getCreateTimeEnd
());
StatThread
statThread
=
new
StatThread
(
attendStart
,
compare
,
site
,
context
,
Arrays
.
asList
(
StatTypeEnum
.
STAT_ALL
.
getValue
()));
Long
compare
=
DateUtil
.
between
(
attendEnd
,
attendStart
,
DateUnit
.
DAY
);
ThreadPool
.
getInstance
().
execute
(
statThread
);
StopWatch
stopWatch
=
new
StopWatch
(
"stopwatch"
);
}
log
.
info
(
"计算天数区间:{}"
,
compare
);
AccessQuery
accessQuery
=
new
AccessQuery
();
/* accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery);*/
List
<
AccessEntity
>
accessEntities
=
accessService
.
find
(
accessQuery
).
stream
().
filter
(
item
->
{
List
<
AccessSystemEntity
>
accessSystemList
=
item
.
getAccessSystemList
();
//判断排队机或者评价系统是否开通
if
(
ObjectUtils
.
isEmpty
(
accessSystemList
))
return
false
;
List
<
AccessSystemEntity
>
collect
=
accessSystemList
.
stream
().
filter
(
f
->
f
.
getEnabled
()
==
YesNoEnum
.
YES
.
getValue
()).
collect
(
Collectors
.
toList
());
if
(
ObjectUtils
.
isEmpty
(
collect
)){
return
false
;}
return
true
;
}).
collect
(
Collectors
.
toList
());
List
<
SitePdu
>
sitePduList
=
new
ArrayList
<>();
for
(
AccessEntity
accessEntity
:
accessEntities
)
{
SitePdu
sitePdu
=
new
SitePdu
();
sitePdu
.
setId
(
accessEntity
.
getId
());
Rest
<
List
<
SitePdu
>>
sitesRest
=
siteFeign
.
getFlatSitesBySiteId
(
sitePdu
);
if
(
YesNoEnum
.
YES
.
getValue
()
==
sitesRest
.
getCode
())
{
sitePduList
.
addAll
(
sitesRest
.
getData
());
}
}
if
(!
ObjectUtils
.
isEmpty
(
sitePduList
))
{
sitePduList
=
sitePduList
.
stream
().
collect
(
collectingAndThen
(
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
SitePdu:
:
getId
))),
ArrayList:
:
new
));
for
(
SitePdu
site
:
sitePduList
)
{
for
(
int
i
=
0
;
i
<=
compare
.
intValue
();
i
++)
{
DateTime
curDate
=
DateUtil
.
offsetDay
(
attendStart
,
i
);
StatEntity
statEntity
=
new
StatEntity
();
statEntity
.
initAttrValue
();
statEntity
.
setSiteId
(
site
.
getId
());
statEntity
.
setSiteName
(
site
.
getSiteName
());
statEntity
.
setSiteCode
(
site
.
getSiteCode
());
statEntity
.
setYear
(
curDate
.
year
());
statEntity
.
setMonth
(
curDate
.
month
()
+
1
);
statEntity
.
setDay
(
curDate
.
dayOfMonth
());
//设置年月日
statService
.
updateSiteStat
(
statEntity
,
context
);
}
}
}
/*
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> {
StatEntity statEntity = new StatEntity();
statEntity.initAttrValue();
statEntity.setSiteId(site.getId());
statEntity.setSiteName(site.getSiteName());
statEntity.setSiteCode(site.getSiteCode());
statEntity.setYear(curDate.year());
statEntity.setMonth(curDate.month() + 1);
statEntity.setDay(curDate.dayOfMonth());
//设置年月日
statService.updateSiteStat(statEntity, context);
});
}
stopWatch.stop();
log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
}*/
}
};
ThreadPool
.
getInstance
().
execute
(
runnable
);
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
this
.
recordSysLog
(
this
.
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
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