Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
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
zengtianlai3
ioc_sixiang_license
Commits
4b2d99a0
Commit
4b2d99a0
authored
Feb 09, 2023
by
ma
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/origin/master' into for-yx
parents
645cd69c
11c80f94
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
200 additions
and
39 deletions
+200
-39
OperateSchedu.java
...ain/java/iot/sixiang/license/component/OperateSchedu.java
+2
-2
ReportSchedu.java
...main/java/iot/sixiang/license/component/ReportSchedu.java
+45
-0
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+3
-2
DeviceServerHandler.java
.../java/iot/sixiang/license/device/DeviceServerHandler.java
+2
-6
OperateSAMStatusResponseEventHandler.java
...g/license/event/OperateSAMStatusResponseEventHandler.java
+5
-5
ForwardConnectionListener.java
...ot/sixiang/license/forward/ForwardConnectionListener.java
+1
-1
ReportMapper.java
...rc/main/java/iot/sixiang/license/mapper/ReportMapper.java
+4
-0
ReportStatsVO.java
...main/java/iot/sixiang/license/model/vo/ReportStatsVO.java
+31
-0
OperateConnectionListener.java
...ot/sixiang/license/operate/OperateConnectionListener.java
+1
-1
ReportService.java
.../main/java/iot/sixiang/license/service/ReportService.java
+8
-2
ReportServiceImpl.java
...a/iot/sixiang/license/service/impl/ReportServiceImpl.java
+51
-19
TerminalDeviceServiceImpl.java
...xiang/license/service/impl/TerminalDeviceServiceImpl.java
+1
-1
CommonUtil.java
...se/src/main/java/iot/sixiang/license/util/CommonUtil.java
+9
-0
EmailUtils.java
...se/src/main/java/iot/sixiang/license/util/EmailUtils.java
+18
-0
application.yml
license/src/main/resources/application.yml
+1
-0
ReportMapper.xml
license/src/main/resources/mapper/ReportMapper.xml
+18
-0
No files found.
license/src/main/java/iot/sixiang/license/
util
/OperateSchedu.java
→
license/src/main/java/iot/sixiang/license/
component
/OperateSchedu.java
View file @
4b2d99a0
package
iot
.
sixiang
.
license
.
util
;
package
iot
.
sixiang
.
license
.
component
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.operate.OperateManager
;
import
iot.sixiang.license.service.MonitorService
;
import
iot.sixiang.license.service.MonitorService
;
...
@@ -16,12 +16,12 @@ public class OperateSchedu {
...
@@ -16,12 +16,12 @@ public class OperateSchedu {
private
OperateManager
operateManager
;
private
OperateManager
operateManager
;
@Autowired
@Autowired
private
MonitorService
monitorService
;
private
MonitorService
monitorService
;
@Scheduled
(
cron
=
"0 0 0/1 * * ?"
)
@Scheduled
(
cron
=
"0 0 0/1 * * ?"
)
public
void
scheduled
()
{
public
void
scheduled
()
{
operateManager
.
createProxyClient
();
operateManager
.
createProxyClient
();
int
count
=
operateManager
.
getCount
();
int
count
=
operateManager
.
getCount
();
monitorService
.
addMonitor
(
count
);
monitorService
.
addMonitor
(
count
);
operateManager
.
clearCount
();
operateManager
.
clearCount
();
}
}
}
}
license/src/main/java/iot/sixiang/license/component/ReportSchedu.java
0 → 100644
View file @
4b2d99a0
package
iot
.
sixiang
.
license
.
component
;
import
iot.sixiang.license.model.vo.ReportStatsVO
;
import
iot.sixiang.license.service.ReportService
;
import
iot.sixiang.license.util.CommonUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* Created by m33
* Date 2023/2/8 14:10
* Description
*/
@Component
@Slf4j
public
class
ReportSchedu
{
@Resource
private
ReportService
reportService
;
private
final
static
String
PATTERN
=
"yyyy-MM-dd HH:mm:00"
;
/**
* 每整10分钟执行一次
*/
@Scheduled
(
cron
=
"0 0/10 * * * ?"
)
public
void
scheduled
()
{
Date
date
=
new
Date
();
String
startTime
=
CommonUtil
.
dateToString
(
CommonUtil
.
getOffsetDate
(
date
,
-
10
),
PATTERN
);
String
endTime
=
CommonUtil
.
dateToString
(
date
,
PATTERN
);
List
<
ReportStatsVO
>
reportStatsList
=
reportService
.
getReportStatsList
(
startTime
,
endTime
);
if
(
reportStatsList
.
size
()
!=
0
)
{
Map
<
String
,
List
<
ReportStatsVO
>>
map
=
reportStatsList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ReportStatsVO:
:
getUserName
));
for
(
List
<
ReportStatsVO
>
reportStatsVOS
:
map
.
values
())
{
reportService
.
reportToEmail
(
reportStatsVOS
,
startTime
,
endTime
);
}
}
}
}
license/src/main/java/iot/sixiang/license/controller/UserController.java
View file @
4b2d99a0
...
@@ -34,7 +34,6 @@ import iot.sixiang.license.util.EmailUtils;
...
@@ -34,7 +34,6 @@ import iot.sixiang.license.util.EmailUtils;
import
iot.sixiang.license.util.TreeUtil
;
import
iot.sixiang.license.util.TreeUtil
;
import
iot.sixiang.license.xss.XssUtil
;
import
iot.sixiang.license.xss.XssUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.web.bind.WebDataBinder
;
import
org.springframework.web.bind.WebDataBinder
;
...
@@ -80,6 +79,8 @@ public class UserController {
...
@@ -80,6 +79,8 @@ public class UserController {
private
Integer
changePwdMaxErrCount
;
private
Integer
changePwdMaxErrCount
;
@Value
(
"${spring.mail.to}"
)
@Value
(
"${spring.mail.to}"
)
private
String
account
;
private
String
account
;
@Value
(
"${other.web}"
)
private
String
webUrl
;
private
static
final
String
OPERATION_CHANGE
=
"change"
;
private
static
final
String
OPERATION_CHANGE
=
"change"
;
...
@@ -124,7 +125,7 @@ public class UserController {
...
@@ -124,7 +125,7 @@ public class UserController {
}
}
boolean
res
=
userService
.
addUser
(
userName
,
company
,
password
,
user
.
getUserId
(),
++
level
);
boolean
res
=
userService
.
addUser
(
userName
,
company
,
password
,
user
.
getUserId
(),
++
level
);
if
(
res
)
{
if
(
res
)
{
String
content
=
"注册成功!感谢您使用实名制身份验证云应用平台,请点击以下链接登录:
http://web.license.srthinker.com/user
#/login"
;
String
content
=
"注册成功!感谢您使用实名制身份验证云应用平台,请点击以下链接登录:
"
+
webUrl
+
"/
#/login"
;
emailUtils
.
sendSimpleMail
(
userName
,
"感谢您使用实名制身份验证云应用平台"
,
content
);
emailUtils
.
sendSimpleMail
(
userName
,
"感谢您使用实名制身份验证云应用平台"
,
content
);
return
BaseResult
.
success
();
return
BaseResult
.
success
();
}
else
{
}
else
{
...
...
license/src/main/java/iot/sixiang/license/device/DeviceServerHandler.java
View file @
4b2d99a0
...
@@ -10,11 +10,7 @@ import io.netty.channel.socket.SocketChannel;
...
@@ -10,11 +10,7 @@ import io.netty.channel.socket.SocketChannel;
import
iot.sixiang.license.auth.AuthManager
;
import
iot.sixiang.license.auth.AuthManager
;
import
iot.sixiang.license.consts.Constant
;
import
iot.sixiang.license.consts.Constant
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.event.CreateForwardClientEvent
;
import
iot.sixiang.license.event.*
;
import
iot.sixiang.license.event.DeviceClientInactiveEvent
;
import
iot.sixiang.license.event.DeviceClientLicenseEvent
;
import
iot.sixiang.license.event.EventPublisher
;
import
iot.sixiang.license.event.ForwardClientRequestEvent
;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.model.SessionContext
;
import
iot.sixiang.license.model.SessionContext
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
import
iot.sixiang.license.model.dto.ReportErrorMsgDTO
;
...
@@ -184,7 +180,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
...
@@ -184,7 +180,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
UserInfoVO
user
=
userMapper
.
getUserBySn
(
sn
);
UserInfoVO
user
=
userMapper
.
getUserBySn
(
sn
);
Report
report
=
Report
.
builder
().
category
(
0
).
type
(
6
).
sn
(
sn
).
userName
(
user
.
getUserName
())
Report
report
=
Report
.
builder
().
category
(
0
).
type
(
6
).
sn
(
sn
).
userName
(
user
.
getUserName
())
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
reportService
.
reportToEmail
(
report
,
user
.
getNotify
()
);
reportService
.
addReport
(
report
);
}
}
return
license
;
return
license
;
}
}
...
...
license/src/main/java/iot/sixiang/license/event/OperateSAMStatusResponseEventHandler.java
View file @
4b2d99a0
...
@@ -59,11 +59,11 @@ public class OperateSAMStatusResponseEventHandler {
...
@@ -59,11 +59,11 @@ public class OperateSAMStatusResponseEventHandler {
int
typeId
=
2
;
int
typeId
=
2
;
String
title
=
"SAM故障"
;
String
title
=
"SAM故障"
;
String
content
=
"index为"
+
index
+
"的SAM发生故障"
;
String
content
=
"index为"
+
index
+
"的SAM发生故障"
;
alarmService
.
addAlarm
(
typeId
,
title
,
content
);
alarmService
.
addAlarm
(
typeId
,
title
,
content
);
UserInfoVO
user
=
userMapper
.
getRootAccount
();
UserInfoVO
user
=
userMapper
.
getRootAccount
();
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
1
).
userName
(
user
.
getUserName
())
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
1
).
userName
(
user
.
getUserName
())
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
reportService
.
reportToEmail
(
report
,
user
.
getNotify
()
);
reportService
.
addReport
(
report
);
}
}
}
}
SamMonitor
samMonitor
=
new
SamMonitor
();
SamMonitor
samMonitor
=
new
SamMonitor
();
...
@@ -71,15 +71,15 @@ public class OperateSAMStatusResponseEventHandler {
...
@@ -71,15 +71,15 @@ public class OperateSAMStatusResponseEventHandler {
samMonitor
.
setOnlineCount
(
onlineCount
);
samMonitor
.
setOnlineCount
(
onlineCount
);
samMonitor
.
setSamCount
(
samCount
);
samMonitor
.
setSamCount
(
samCount
);
operateManager
.
putSamMonitorMap
(
serverIp
,
samMonitor
);
operateManager
.
putSamMonitorMap
(
serverIp
,
samMonitor
);
if
((
float
)
onlineCount
/
samCount
>
0.7
)
{
if
((
float
)
onlineCount
/
samCount
>
0.7
)
{
int
typeId
=
3
;
int
typeId
=
3
;
String
title
=
"SAM不足"
;
String
title
=
"SAM不足"
;
String
content
=
"当前在线客户端已超过70%"
;
String
content
=
"当前在线客户端已超过70%"
;
alarmService
.
addAlarm
(
typeId
,
title
,
content
);
alarmService
.
addAlarm
(
typeId
,
title
,
content
);
UserInfoVO
user
=
userMapper
.
getRootAccount
();
UserInfoVO
user
=
userMapper
.
getRootAccount
();
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
2
).
userName
(
user
.
getUserName
())
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
2
).
userName
(
user
.
getUserName
())
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
reportService
.
reportToEmail
(
report
,
user
.
getNotify
()
);
reportService
.
addReport
(
report
);
}
}
}
}
}
}
license/src/main/java/iot/sixiang/license/forward/ForwardConnectionListener.java
View file @
4b2d99a0
...
@@ -46,7 +46,7 @@ public class ForwardConnectionListener extends BaseConnectionListener {
...
@@ -46,7 +46,7 @@ public class ForwardConnectionListener extends BaseConnectionListener {
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
3
).
userName
(
user
.
getUserName
())
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
3
).
userName
(
user
.
getUserName
())
.
description
(
"桥接客户端,连接服务器"
+
this
.
host
+
":"
+
this
.
port
+
"失败"
)
.
description
(
"桥接客户端,连接服务器"
+
this
.
host
+
":"
+
this
.
port
+
"失败"
)
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
reportService
.
reportToEmail
(
report
,
user
.
getNotify
()
);
reportService
.
addReport
(
report
);
// forward client连接失败,则强制踢掉设备客户端
// forward client连接失败,则强制踢掉设备客户端
DeviceClientBeForcedOfflineEvent
deviceClientBeForcedOfflineEvent
=
new
DeviceClientBeForcedOfflineEvent
();
DeviceClientBeForcedOfflineEvent
deviceClientBeForcedOfflineEvent
=
new
DeviceClientBeForcedOfflineEvent
();
deviceClientBeForcedOfflineEvent
.
setSn
(
this
.
sn
);
deviceClientBeForcedOfflineEvent
.
setSn
(
this
.
sn
);
...
...
license/src/main/java/iot/sixiang/license/mapper/ReportMapper.java
View file @
4b2d99a0
...
@@ -2,6 +2,7 @@ package iot.sixiang.license.mapper;
...
@@ -2,6 +2,7 @@ package iot.sixiang.license.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.model.vo.ReportStatsVO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
java.util.List
;
import
java.util.List
;
...
@@ -12,5 +13,8 @@ import java.util.List;
...
@@ -12,5 +13,8 @@ import java.util.List;
* Description
* Description
*/
*/
public
interface
ReportMapper
extends
BaseMapper
<
Report
>
{
public
interface
ReportMapper
extends
BaseMapper
<
Report
>
{
List
<
ReportVO
>
getReportList
(
Integer
type
,
String
sn
,
String
startTime
,
String
endTime
,
List
<
Integer
>
userChildIds
);
List
<
ReportVO
>
getReportList
(
Integer
type
,
String
sn
,
String
startTime
,
String
endTime
,
List
<
Integer
>
userChildIds
);
List
<
ReportStatsVO
>
getReportStatsList
(
String
startTime
,
String
endTime
);
}
}
license/src/main/java/iot/sixiang/license/model/vo/ReportStatsVO.java
0 → 100644
View file @
4b2d99a0
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* Created by m33
* Date 2023/2/8 15:12
* Description
*/
@Data
public
class
ReportStatsVO
{
@ApiModelProperty
(
"系统报警数量"
)
private
Integer
systemError
;
@ApiModelProperty
(
"设备报警数量"
)
private
Integer
deviceError
;
@ApiModelProperty
(
"设备编码"
)
private
String
sn
;
@ApiModelProperty
(
"报警账户"
)
private
String
userName
;
@ApiModelProperty
(
"报警公司"
)
private
String
userCompany
;
@ApiModelProperty
(
"报警邮箱"
)
private
String
notify
;
}
license/src/main/java/iot/sixiang/license/operate/OperateConnectionListener.java
View file @
4b2d99a0
...
@@ -37,7 +37,7 @@ public class OperateConnectionListener extends BaseConnectionListener {
...
@@ -37,7 +37,7 @@ public class OperateConnectionListener extends BaseConnectionListener {
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
3
).
userName
(
user
.
getUserName
())
Report
report
=
Report
.
builder
().
category
(
1
).
type
(
3
).
userName
(
user
.
getUserName
())
.
description
(
"运维客户端,连接服务器"
+
this
.
host
+
":"
+
this
.
port
+
"失败"
)
.
description
(
"运维客户端,连接服务器"
+
this
.
host
+
":"
+
this
.
port
+
"失败"
)
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
reportService
.
reportToEmail
(
report
,
user
.
getNotify
()
);
reportService
.
addReport
(
report
);
}
else
{
}
else
{
log
.
info
(
"运维客户端,连接服务器成功:{},{}"
,
this
.
host
,
this
.
port
);
log
.
info
(
"运维客户端,连接服务器成功:{},{}"
,
this
.
host
,
this
.
port
);
//TODO 查询SAM状态
//TODO 查询SAM状态
...
...
license/src/main/java/iot/sixiang/license/service/ReportService.java
View file @
4b2d99a0
package
iot
.
sixiang
.
license
.
service
;
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.dto.ReportDTO
;
import
iot.sixiang.license.model.dto.ReportDTO
;
import
iot.sixiang.license.model.vo.ReportStatsVO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
java.util.List
;
/**
/**
* Created by M=54G
* Created by M=54G
* Date 11/23/22 3:09 PM
* Date 11/23/22 3:09 PM
...
@@ -15,5 +17,9 @@ public interface ReportService {
...
@@ -15,5 +17,9 @@ public interface ReportService {
PageResult
<
ReportVO
>
getReportList
(
ReportDTO
reportDTO
);
PageResult
<
ReportVO
>
getReportList
(
ReportDTO
reportDTO
);
void
reportToEmail
(
Report
report
,
String
notify
);
List
<
ReportStatsVO
>
getReportStatsList
(
String
startTime
,
String
endTime
);
void
addReport
(
Report
report
);
void
reportToEmail
(
List
<
ReportStatsVO
>
reportStatsVOS
,
String
startTime
,
String
endTime
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/ReportServiceImpl.java
View file @
4b2d99a0
...
@@ -2,19 +2,19 @@ package iot.sixiang.license.service.impl;
...
@@ -2,19 +2,19 @@ package iot.sixiang.license.service.impl;
import
cn.hutool.core.lang.Validator
;
import
cn.hutool.core.lang.Validator
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.entity.ReportType
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.mapper.ReportMapper
;
import
iot.sixiang.license.mapper.ReportMapper
;
import
iot.sixiang.license.mapper.ReportTypeMapper
;
import
iot.sixiang.license.mapper.ReportTypeMapper
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.dto.ReportDTO
;
import
iot.sixiang.license.model.dto.ReportDTO
;
import
iot.sixiang.license.model.vo.ReportStatsVO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
iot.sixiang.license.model.vo.ReportVO
;
import
iot.sixiang.license.service.ReportService
;
import
iot.sixiang.license.service.ReportService
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.EmailUtils
;
import
iot.sixiang.license.util.EmailUtils
;
import
iot.sixiang.license.util.TreeUtil
;
import
iot.sixiang.license.util.TreeUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -36,6 +36,8 @@ public class ReportServiceImpl implements ReportService {
...
@@ -36,6 +36,8 @@ public class ReportServiceImpl implements ReportService {
EmailUtils
emailUtils
;
EmailUtils
emailUtils
;
@Resource
@Resource
ReportTypeMapper
reportTypeMapper
;
ReportTypeMapper
reportTypeMapper
;
@Value
(
"${other.web}"
)
private
String
webUrl
;
@Override
@Override
public
PageResult
<
ReportVO
>
getReportList
(
ReportDTO
reportDTO
)
{
public
PageResult
<
ReportVO
>
getReportList
(
ReportDTO
reportDTO
)
{
...
@@ -70,30 +72,60 @@ public class ReportServiceImpl implements ReportService {
...
@@ -70,30 +72,60 @@ public class ReportServiceImpl implements ReportService {
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
}
}
@Override
public
List
<
ReportStatsVO
>
getReportStatsList
(
String
startTime
,
String
endTime
)
{
if
(
StringUtils
.
isEmpty
(
startTime
)
||
StringUtils
.
isEmpty
(
endTime
))
{
throw
new
IotLicenseException
(
403
,
"统计报警失败,时间参数为空"
);
}
return
reportMapper
.
getReportStatsList
(
startTime
,
endTime
);
}
@Override
public
void
addReport
(
Report
report
)
{
reportMapper
.
insert
(
report
);
}
@Async
(
"mailExecutor"
)
@Async
(
"mailExecutor"
)
@Override
@Override
public
void
reportToEmail
(
Report
report
,
String
notify
)
{
public
void
reportToEmail
(
List
<
ReportStatsVO
>
reportStatsVOS
,
String
startTime
,
String
endTime
)
{
if
(
reportStatsVOS
.
size
()
==
0
)
{
return
;
}
String
notify
=
reportStatsVOS
.
get
(
0
).
getNotify
();
String
userName
=
reportStatsVOS
.
get
(
0
).
getUserName
();
String
userCompany
=
reportStatsVOS
.
get
(
0
).
getUserCompany
();
if
(!
Validator
.
isEmail
(
notify
))
{
if
(!
Validator
.
isEmail
(
notify
))
{
throw
new
IotLicenseException
(
403
,
"报警失败,无效的邮箱账号"
);
throw
new
IotLicenseException
(
403
,
"报警失败,无效的邮箱账号"
);
}
}
reportMapper
.
insert
(
report
);
String
content
;
Integer
type
=
report
.
getType
();
String
url
=
webUrl
+
"/#/warn"
;
ReportType
reportType
=
reportTypeMapper
.
selectById
(
type
);
int
systemErrorTotal
=
0
;
if
(
reportType
==
null
)
{
boolean
deviceErrorFlag
=
false
;
throw
new
IotLicenseException
(
403
,
"报警失败,无效的报警类型"
);
StringBuilder
deviceStr
=
new
StringBuilder
();
for
(
ReportStatsVO
reportStatsVO
:
reportStatsVOS
)
{
systemErrorTotal
+=
reportStatsVO
.
getSystemError
();
int
deviceErrorCnt
=
reportStatsVO
.
getDeviceError
();
String
sn
=
reportStatsVO
.
getSn
();
if
(
deviceErrorCnt
!=
0
)
{
deviceErrorFlag
=
true
;
deviceStr
.
append
(
"<p>"
).
append
(
"设备 "
).
append
(
sn
).
append
(
": "
).
append
(
deviceErrorCnt
).
append
(
"条;</p>"
);
}
}
Integer
category
=
report
.
getCategory
();
}
String
content
=
""
;
if
(
systemErrorTotal
!=
0
&&
deviceErrorFlag
)
{
if
(
category
==
1
)
{
content
=
"<p>【实名制身份验证云平台】系统和设备报警!</p><p>报警时间:"
+
startTime
+
"至"
+
endTime
+
";</p>"
content
=
"【实名制身份验证云平台】系统报警!报警时间:"
+
CommonUtil
.
getSystemTime
()
+
",报警事件:"
+
reportType
.
getDescription
()
+
"<p>系统报警:"
+
systemErrorTotal
+
"条;</p>"
+
deviceStr
+
"<p>报警用户:"
+
userName
+
", 公司名称:"
+
userCompany
+
";</p>"
+
",报警用户:"
+
report
.
getUserName
()
+
",公司名称:"
+
report
.
getUserCompany
()
+
",请核实!"
;
+
"<a style='color:blue;text-decoration: none;' href='"
+
url
+
"'>请点击链接核实!</a>"
;
}
else
if
(
category
==
0
)
{
}
else
{
content
=
"【实名制身份验证云平台】设备报警!报警时间:"
+
CommonUtil
.
getSystemTime
()
+
",报警事件:"
+
reportType
.
getDescription
()
if
(
systemErrorTotal
!=
0
)
{
+
",设备SN:"
+
report
.
getSn
()
+
",报警用户:"
+
report
.
getUserName
()
+
",公司名称:"
+
report
.
getUserCompany
()
content
=
"<p>【实名制身份验证云平台】系统报警!</p><p>报警时间:"
+
startTime
+
"至"
+
endTime
+
";</p>"
+
",请核实!"
;
+
"<p>系统报警:"
+
systemErrorTotal
+
"条;</p>"
+
"<p>报警用户:"
+
userName
+
", 公司名称:"
+
userCompany
+
";</p>"
+
"<a style='color:blue;text-decoration: none;' href='"
+
url
+
"'>请点击链接核实!</a>"
;
}
else
{
}
else
{
throw
new
IotLicenseException
(
403
,
"报警失败,无效的报警大类"
);
content
=
"<p>【实名制身份验证云平台】设备报警!</p><p>报警时间:"
+
startTime
+
"至"
+
endTime
+
";</p>"
+
deviceStr
+
"<p>报警用户:"
+
userName
+
", 公司名称:"
+
userCompany
+
";</p>"
+
"<a style='color:blue;text-decoration: none;' href='"
+
url
+
"'>请点击此处核实!</a>"
;
}
}
}
emailUtils
.
send
Simple
Mail
(
notify
,
"实名制身份验证云平台"
,
content
);
emailUtils
.
send
Html
Mail
(
notify
,
"实名制身份验证云平台"
,
content
);
}
}
}
}
license/src/main/java/iot/sixiang/license/service/impl/TerminalDeviceServiceImpl.java
View file @
4b2d99a0
...
@@ -98,7 +98,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
...
@@ -98,7 +98,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
}
}
Report
report
=
Report
.
builder
().
category
(
0
).
type
(
type
).
sn
(
pmsUseLog
.
getSn
()).
userName
(
user
.
getUserName
())
Report
report
=
Report
.
builder
().
category
(
0
).
type
(
type
).
sn
(
pmsUseLog
.
getSn
()).
userName
(
user
.
getUserName
())
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
.
userCompany
(
user
.
getCompany
()).
createTime
(
new
Date
()).
updateTime
(
new
Date
()).
build
();
reportService
.
reportToEmail
(
report
,
user
.
getNotify
()
);
reportService
.
addReport
(
report
);
boolean
res
=
pmsUseService
.
reportErrorMsg
(
reportErrorMsgDTO
);
boolean
res
=
pmsUseService
.
reportErrorMsg
(
reportErrorMsgDTO
);
if
(!
res
)
{
if
(!
res
)
{
return
BaseResult
.
failed
();
return
BaseResult
.
failed
();
...
...
license/src/main/java/iot/sixiang/license/util/CommonUtil.java
View file @
4b2d99a0
...
@@ -50,6 +50,15 @@ public class CommonUtil {
...
@@ -50,6 +50,15 @@ public class CommonUtil {
return
ft
.
format
(
date
);
return
ft
.
format
(
date
);
}
}
/**
* 获取指定日期前或后几分钟
*
* @return
*/
public
static
Date
getOffsetDate
(
Date
date
,
int
minutes
)
{
return
new
Date
(
date
.
getTime
()
+
(
minutes
*
60
*
1000
));
}
/**
/**
* 验证密码-是否包含用户名字符(密码应与用户名无相关性,密码中不得包含用户名的完整字符串、大小写变位或形似变换的字符串)
* 验证密码-是否包含用户名字符(密码应与用户名无相关性,密码中不得包含用户名的完整字符串、大小写变位或形似变换的字符串)
...
...
license/src/main/java/iot/sixiang/license/util/EmailUtils.java
View file @
4b2d99a0
...
@@ -7,9 +7,12 @@ import org.slf4j.LoggerFactory;
...
@@ -7,9 +7,12 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.mail.SimpleMailMessage
;
import
org.springframework.mail.SimpleMailMessage
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.mail.MessagingException
;
import
javax.mail.internet.MimeMessage
;
/**
/**
* Title: EmailUtils
* Title: EmailUtils
...
@@ -49,4 +52,19 @@ public class EmailUtils {
...
@@ -49,4 +52,19 @@ public class EmailUtils {
throw
new
IotLicenseException
(
405
,
"短信邮件发送失败"
);
throw
new
IotLicenseException
(
405
,
"短信邮件发送失败"
);
}
}
}
}
public
void
sendHtmlMail
(
String
to
,
String
subject
,
String
content
)
{
MimeMessage
message
=
mailSender
.
createMimeMessage
();
try
{
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
,
true
);
helper
.
setFrom
(
from
);
helper
.
setTo
(
to
);
helper
.
setSubject
(
subject
);
helper
.
setText
(
content
,
true
);
mailSender
.
send
(
message
);
logger
.
info
(
"=============》一份html邮件已成功发送"
);
}
catch
(
MessagingException
e
)
{
logger
.
error
(
"=============》发送html邮件时发生异常!"
,
e
);
}
}
}
}
license/src/main/resources/application.yml
View file @
4b2d99a0
...
@@ -36,6 +36,7 @@ cros:
...
@@ -36,6 +36,7 @@ cros:
cros_allowed_method
:
GET,POST
cros_allowed_method
:
GET,POST
other
:
other
:
web
:
http://web.license.srthinker.com
md5
:
md5
:
salt
:
PI7dBYlEfeP8IZ6vogqFL1U5pVnyCuNAGja3lsREx4M9r0SX
salt
:
PI7dBYlEfeP8IZ6vogqFL1U5pVnyCuNAGja3lsREx4M9r0SX
error_count
:
error_count
:
...
...
license/src/main/resources/mapper/ReportMapper.xml
View file @
4b2d99a0
...
@@ -33,4 +33,22 @@
...
@@ -33,4 +33,22 @@
AND report_type.deleted = 0
AND report_type.deleted = 0
ORDER BY report.create_time DESC
ORDER BY report.create_time DESC
</select>
</select>
<select
id=
"getReportStatsList"
resultType=
"iot.sixiang.license.model.vo.ReportStatsVO"
>
SELECT
sum( IF ( category = 1, 1, 0 ) ) system_error,
sum( IF ( category = 0, 1, 0 ) ) device_error,
sn,
report.user_name,
report.user_company,
notify
FROM
`report`
INNER JOIN `user` ON report.user_name = `user`.user_name
WHERE
report.deleted = 0
AND report.create_time >= #{startTime}
AND #{endTime} > report.create_time
GROUP BY sn
</select>
</mapper>
</mapper>
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