Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
signal
traffic-signal-platform
Commits
f6811ed2
Commit
f6811ed2
authored
Feb 06, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 态势检测-故障告警,故障统计
parent
e4f75e3f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
13 deletions
+159
-13
SituationDetectionController.java
...et/wanji/web/controller/SituationDetectionController.java
+18
-1
TDeviceStatusLog.java
.../src/main/java/net/wanji/web/entity/TDeviceStatusLog.java
+28
-0
AllDeviceStatusMapper.java
...main/java/net/wanji/web/mapper/AllDeviceStatusMapper.java
+0
-2
TDeviceStatusLogMapper.java
...ain/java/net/wanji/web/mapper/TDeviceStatusLogMapper.java
+14
-0
SituationDetectionService.java
...java/net/wanji/web/service/SituationDetectionService.java
+5
-0
SituationDetectionServiceImpl.java
...wanji/web/service/impl/SituationDetectionServiceImpl.java
+30
-3
SignalStatusTask.java
...ce/src/main/java/net/wanji/web/task/SignalStatusTask.java
+49
-7
TDeviceStatusLogMapper.xml
...vice/src/main/resources/mapper/TDeviceStatusLogMapper.xml
+15
-0
No files found.
signal-control-service/src/main/java/net/wanji/web/controller/SituationDetectionController.java
View file @
f6811ed2
...
...
@@ -3,6 +3,7 @@ package net.wanji.web.controller;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
net.wanji.feign.pojo.result.JsonViewObject
;
import
net.wanji.web.entity.TDeviceStatusLog
;
import
net.wanji.web.po.AreaTreePO
;
import
net.wanji.web.service.SituationDetectionService
;
import
net.wanji.web.vo.situationDetection.*
;
...
...
@@ -177,7 +178,7 @@ public class SituationDetectionController extends BaseController {
return
jsonViewObject
.
success
(
areaTreePOS
);
}
@ApiOperation
(
value
=
"查询区域列表"
,
notes
=
"
辖区分组
"
)
@ApiOperation
(
value
=
"查询区域列表"
,
notes
=
"
查询区域列表
"
)
@GetMapping
(
"/selectAreaList"
)
public
JsonViewObject
selectAreaList
(
Integer
areaId
)
{
List
<
AreaListVO
>
areaListVOS
=
situationDetectionService
.
selectAreaList
(
areaId
);
...
...
@@ -185,4 +186,20 @@ public class SituationDetectionController extends BaseController {
return
jsonViewObject
.
success
(
areaListVOS
);
}
@ApiOperation
(
value
=
"查询信号机故障列表"
,
notes
=
"查询信号机故障列表"
)
@GetMapping
(
"/listSignalFaultInfos"
)
public
JsonViewObject
listSignalFaultInfos
()
{
List
<
TDeviceStatusLog
>
tDeviceStatusInfos
=
situationDetectionService
.
listSignalFaultInfos
();
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
return
jsonViewObject
.
success
(
tDeviceStatusInfos
);
}
@ApiOperation
(
value
=
"查询信号机故障列表"
,
notes
=
"查询信号机故障列表"
)
@GetMapping
(
"/countSignalFaultInfos"
)
public
JsonViewObject
countSignalFaultInfos
()
{
Map
<
String
,
Integer
>
result
=
situationDetectionService
.
countSignalFaultInfos
();
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
return
jsonViewObject
.
success
(
result
);
}
}
signal-control-service/src/main/java/net/wanji/web/entity/TDeviceStatusLog.java
0 → 100644
View file @
f6811ed2
package
net
.
wanji
.
web
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @author duanruiming
* @date 2023/01/03 15:46
*/
@Data
public
class
TDeviceStatusLog
{
@ApiModelProperty
(
value
=
"id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"设备代码"
)
private
String
code
;
@ApiModelProperty
(
value
=
"设备名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"设备类型:1信号;2卡口;3地磁;4视频;5微波;6激光;7电警;8 MEC"
)
private
int
type
;
@ApiModelProperty
(
value
=
"设备状态:0离线;1在线;"
)
private
int
status
;
@ApiModelProperty
(
value
=
"信号机故障类型:0正常;1检测器故障;2时钟故障;3电源故障;4驱动模块故障;5信号灯故障;6箱门开启;7方案错误;8绿冲突;9红全熄;10行人红熄;"
,
notes
=
""
)
private
int
faultType
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
gmtCreate
;
}
signal-control-service/src/main/java/net/wanji/web/mapper/AllDeviceStatusMapper.java
View file @
f6811ed2
package
net
.
wanji
.
web
.
mapper
;
import
com.baomidou.dynamic.datasource.annotation.DS
;
import
net.wanji.web.po.AllDeviceStatusPO
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -12,7 +11,6 @@ import java.util.List;
* @date 2022/10/27 14:25
*/
@Repository
//@DS("webService") 查询新数据库20221228
public
interface
AllDeviceStatusMapper
{
List
<
AllDeviceStatusPO
>
selectAllDeviceStatus
(
String
adCode
);
}
signal-control-service/src/main/java/net/wanji/web/mapper/TDeviceStatusLogMapper.java
0 → 100644
View file @
f6811ed2
package
net
.
wanji
.
web
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
net.wanji.web.entity.TDeviceStatusLog
;
import
org.springframework.stereotype.Repository
;
/**
* @author duanruiming
* @date 2023/02/06 17:22
*/
@Repository
public
interface
TDeviceStatusLogMapper
extends
BaseMapper
<
TDeviceStatusLog
>
{
TDeviceStatusLog
selectLastOne
(
String
code
);
}
signal-control-service/src/main/java/net/wanji/web/service/SituationDetectionService.java
View file @
f6811ed2
package
net
.
wanji
.
web
.
service
;
import
net.wanji.web.entity.TBaseCrossInfo
;
import
net.wanji.web.entity.TDeviceStatusLog
;
import
net.wanji.web.po.AreaTreePO
;
import
net.wanji.web.vo.situationDetection.*
;
...
...
@@ -39,4 +40,8 @@ public interface SituationDetectionService {
List
<
AreaTreePO
>
jurisdictionTree
();
List
<
AreaListVO
>
selectAreaList
(
Integer
areaId
);
List
<
TDeviceStatusLog
>
listSignalFaultInfos
();
Map
<
String
,
Integer
>
countSignalFaultInfos
();
}
signal-control-service/src/main/java/net/wanji/web/service/impl/SituationDetectionServiceImpl.java
View file @
f6811ed2
...
...
@@ -7,9 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
lombok.RequiredArgsConstructor
;
import
net.wanji.web.common.enums.*
;
import
net.wanji.web.common.util.CrossUtil
;
import
net.wanji.web.entity.TBaseAreaCross
;
import
net.wanji.web.entity.TBaseAreaInfo
;
import
net.wanji.web.entity.TBaseCrossInfo
;
import
net.wanji.web.entity.*
;
import
net.wanji.web.mapper.*
;
import
net.wanji.web.po.*
;
import
net.wanji.web.service.SituationDetectionService
;
...
...
@@ -46,6 +44,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
private
final
TBaseAreaInfoMapper
tBaseAreaInfoMapper
;
private
final
TBaseCrossInfoService
tBaseCrossInfoService
;
private
final
TBaseAreaCrossMapper
tBaseAreaCrossMapper
;
private
final
TDeviceStatusLogMapper
tDeviceStatusLogMapper
;
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
...
...
@@ -450,6 +449,34 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
return
results
;
}
@Override
public
List
<
TDeviceStatusLog
>
listSignalFaultInfos
()
{
LambdaQueryWrapper
<
TDeviceStatusLog
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
ne
(
TDeviceStatusLog:
:
getFaultType
,
0
);
return
tDeviceStatusLogMapper
.
selectList
(
queryWrapper
);
}
@Override
public
Map
<
String
,
Integer
>
countSignalFaultInfos
()
{
HashMap
<
String
,
Integer
>
resultMap
=
new
HashMap
<>();
List
<
TDeviceStatusLog
>
tDeviceStatusInfos
=
listSignalFaultInfos
();
int
dealSize
=
0
;
int
faultSize
=
0
;
for
(
TDeviceStatusLog
tDeviceStatusLog
:
tDeviceStatusInfos
)
{
int
faultType
=
tDeviceStatusLog
.
getFaultType
();
if
(
100
==
faultType
)
{
dealSize
++;
}
if
(
faultType
>
0
&&
faultType
<
100
)
{
faultSize
++;
}
}
resultMap
.
put
(
"dealSize"
,
dealSize
);
resultMap
.
put
(
"faultSize"
,
faultSize
);
resultMap
.
put
(
"allSize"
,
tDeviceStatusInfos
.
size
());
return
resultMap
;
}
}
class
CrossAlarmComparator
implements
Comparator
<
CrossAlarmOutVO
>
{
...
...
signal-control-service/src/main/java/net/wanji/web/task/SignalStatusTask.java
View file @
f6811ed2
...
...
@@ -8,11 +8,14 @@ import net.wanji.feign.service.UtcFeignClients;
import
net.wanji.web.dto.SignalStatusLogDTO
;
import
net.wanji.web.entity.TCrossControlHist
;
import
net.wanji.web.entity.TDeviceStatusInfo
;
import
net.wanji.web.entity.TDeviceStatusLog
;
import
net.wanji.web.mapper.ControlHistMapper
;
import
net.wanji.web.mapper.TDeviceStatusLogMapper
;
import
net.wanji.web.mapper.TDeviceStatusMapper
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Objects
;
...
...
@@ -28,8 +31,10 @@ public class SignalStatusTask {
private
final
UtcFeignClients
utcFeignClients
;
private
final
TDeviceStatusMapper
tDeviceStatusMapper
;
private
final
ControlHistMapper
controlHistMapper
;
private
final
TDeviceStatusLogMapper
tDeviceStatusLogMapper
;
@Scheduled
(
fixedRate
=
1
*
60
*
1000
)
@Transactional
public
void
syncSignalStatus
()
{
try
{
JsonViewObject
jsonViewObject
=
utcFeignClients
.
runningStatusAlarm
();
...
...
@@ -53,20 +58,57 @@ public class SignalStatusTask {
tDeviceStatusInfo
.
setFaultType
(
currentFaultType
);
tDeviceStatusMapper
.
updateById
(
tDeviceStatusInfo
);
}
insertDeviceStatusLog
(
signalStatusLogDTO
,
signalId
,
currentSignalStatus
,
currentFaultType
);
}
// 更新控制历史表
String
crossId
=
signalStatusLogDTO
.
getCrossId
();
Integer
controlType
=
signalStatusLogDTO
.
getControlType
();
TCrossControlHist
tCrossControlHist
=
controlHistMapper
.
selectRecentOne
(
crossId
);
if
(
Objects
.
nonNull
(
tCrossControlHist
)
&&
!
Objects
.
equals
(
controlType
,
tCrossControlHist
.
getType
()))
{
controlHistMapper
.
insertOne
(
crossId
,
controlType
,
"未知"
);
}
insertControlHist
(
signalStatusLogDTO
);
});
}
catch
(
Exception
e
)
{
log
.
error
(
"定时任务同步信号机设备状态远程utcService调用异常"
,
e
);
}
}
/**
* 插入控制历史表
*
* @param signalStatusLogDTO
*/
private
void
insertControlHist
(
SignalStatusLogDTO
signalStatusLogDTO
)
{
// 更新控制历史表
String
crossId
=
signalStatusLogDTO
.
getCrossId
();
Integer
controlType
=
signalStatusLogDTO
.
getControlType
();
TCrossControlHist
tCrossControlHist
=
controlHistMapper
.
selectRecentOne
(
crossId
);
if
(
Objects
.
nonNull
(
tCrossControlHist
)
&&
!
Objects
.
equals
(
controlType
,
tCrossControlHist
.
getType
()))
{
controlHistMapper
.
insertOne
(
crossId
,
controlType
,
"未知"
);
}
}
/**
* 信号机状态插入设备日志表
*
* @param signalStatusLogDTO
* @param signalId
* @param currentSignalStatus
* @param currentFaultType
*/
private
void
insertDeviceStatusLog
(
SignalStatusLogDTO
signalStatusLogDTO
,
String
signalId
,
Integer
currentSignalStatus
,
Integer
currentFaultType
)
{
// 插入日志表
TDeviceStatusLog
tDeviceStatusLogInfoDB
=
tDeviceStatusLogMapper
.
selectLastOne
(
signalId
);
// DB数据是故障,如果当前正常非故障,状态为 FaultType=100 故障已处理
if
(
Objects
.
nonNull
(
tDeviceStatusLogInfoDB
)
||
tDeviceStatusLogInfoDB
.
getFaultType
()
!=
0
&&
currentFaultType
==
0
)
{
tDeviceStatusLogInfoDB
.
setStatus
(
currentSignalStatus
);
tDeviceStatusLogInfoDB
.
setFaultType
(
100
);
tDeviceStatusLogMapper
.
insert
(
tDeviceStatusLogInfoDB
);
}
else
{
TDeviceStatusLog
tDeviceStatusLog
=
new
TDeviceStatusLog
();
tDeviceStatusLog
.
setCode
(
signalId
);
tDeviceStatusLog
.
setName
(
signalStatusLogDTO
.
getSignalId
());
tDeviceStatusLog
.
setType
(
1
);
tDeviceStatusLog
.
setStatus
(
signalStatusLogDTO
.
getStatus
());
tDeviceStatusLog
.
setFaultType
(
currentFaultType
);
tDeviceStatusLogMapper
.
insert
(
tDeviceStatusLog
);
}
}
private
static
boolean
isExucuteUpdate
(
Integer
currentSignalStatus
,
Integer
currentFaultType
,
TDeviceStatusInfo
tDeviceStatusInfo
)
{
return
Objects
.
nonNull
(
tDeviceStatusInfo
)
&&
(
currentSignalStatus
!=
tDeviceStatusInfo
.
getStatus
()
||
currentFaultType
!=
tDeviceStatusInfo
.
getFaultType
());
}
...
...
signal-control-service/src/main/resources/mapper/TDeviceStatusLogMapper.xml
0 → 100644
View file @
f6811ed2
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"net.wanji.web.mapper.TDeviceStatusLogMapper"
>
<select
id=
"selectLastOne"
>
select id, code, name, type, status,fault_type, gmt_create
from t_device_status_log
<where>
<if
test=
"code != null and code != ''"
>
and code = #{code}
</if>
and gmt_create = select max(gmt_create) from t_device_status_log
</where>
</select>
</mapper>
\ No newline at end of file
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