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
7bc7adc0
Commit
7bc7adc0
authored
Mar 22, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 优化信号机状态定时任务
parent
3d227444
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
29 deletions
+61
-29
TDeviceStatusLog.java
.../src/main/java/net/wanji/web/entity/TDeviceStatusLog.java
+3
-0
SignalStatusTask.java
...ce/src/main/java/net/wanji/web/task/SignalStatusTask.java
+25
-19
TDeviceStatusLogMapper.xml
...vice/src/main/resources/mapper/TDeviceStatusLogMapper.xml
+12
-2
HkRunningStatusServiceImpl.java
.../service/runninginfo/impl/HkRunningStatusServiceImpl.java
+9
-6
BeanMapUtils.java
...c/main/java/net/wanji/common/utils/tool/BeanMapUtils.java
+2
-2
CrossInfoMapper.xml
wj-databus/src/main/resources/mapper/CrossInfoMapper.xml
+10
-0
No files found.
signal-control-service/src/main/java/net/wanji/web/entity/TDeviceStatusLog.java
View file @
7bc7adc0
package
net
.
wanji
.
web
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -11,6 +13,7 @@ import java.util.Date;
*/
@Data
public
class
TDeviceStatusLog
{
@TableId
(
type
=
IdType
.
AUTO
)
@ApiModelProperty
(
value
=
"id"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"设备代码"
)
...
...
signal-control-service/src/main/java/net/wanji/web/task/SignalStatusTask.java
View file @
7bc7adc0
...
...
@@ -4,8 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.framework.rest.JsonViewObject
;
import
net.wanji.common.utils.tool.BeanMapUtils
;
import
net.wanji.databus.vo.SignalStatusVO
;
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
;
...
...
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Component;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
/**
...
...
@@ -42,11 +44,13 @@ public class SignalStatusTask {
log
.
error
(
"定时任务同步信号机设备状态utcService调用异常"
);
return
;
}
List
<
SignalStatusLogDTO
>
content
=
(
List
<
SignalStatusLogDTO
>)
jsonViewObject
.
getContent
();
content
.
forEach
(
signalStatusLogDTO
->
{
String
signalId
=
signalStatusLogDTO
.
getSignalId
();
Integer
currentSignalStatus
=
signalStatusLogDTO
.
getStatus
()
==
null
?
0
:
signalStatusLogDTO
.
getStatus
();
Integer
currentFaultType
=
signalStatusLogDTO
.
getFaultType
()
==
null
?
0
:
signalStatusLogDTO
.
getFaultType
();
List
<
Map
<
String
,
Object
>>
source
=
(
List
<
Map
<
String
,
Object
>>)
jsonViewObject
.
getContent
();
List
<
SignalStatusVO
>
content
=
BeanMapUtils
.
mapsToObjects
(
source
,
SignalStatusVO
.
class
);
content
.
forEach
(
signalStatusVO
->
{
String
signalId
=
signalStatusVO
.
getSignalId
();
String
crossId
=
signalStatusVO
.
getCrossId
();
Integer
currentSignalStatus
=
signalStatusVO
.
getStatus
()
==
null
?
0
:
signalStatusVO
.
getStatus
();
Integer
currentFaultType
=
signalStatusVO
.
getFaultType
()
==
null
?
0
:
signalStatusVO
.
getFaultType
();
// 更新数据库状态
LambdaQueryWrapper
<
TDeviceStatusInfo
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
...
...
@@ -58,9 +62,9 @@ public class SignalStatusTask {
tDeviceStatusInfo
.
setFaultType
(
currentFaultType
);
tDeviceStatusMapper
.
updateById
(
tDeviceStatusInfo
);
}
insertDeviceStatusLog
(
signalStatus
LogDTO
,
signal
Id
,
currentSignalStatus
,
currentFaultType
);
insertDeviceStatusLog
(
signalStatus
VO
,
cross
Id
,
currentSignalStatus
,
currentFaultType
);
}
insertControlHist
(
signalStatus
LogDT
O
);
insertControlHist
(
signalStatus
V
O
);
});
}
catch
(
Exception
e
)
{
log
.
error
(
"定时任务同步信号机设备状态远程utcService调用异常"
,
e
);
...
...
@@ -70,12 +74,12 @@ public class SignalStatusTask {
/**
* 插入控制历史表
*
* @param signalStatus
LogDT
O
* @param signalStatus
V
O
*/
private
void
insertControlHist
(
SignalStatus
LogDTO
signalStatusLogDT
O
)
{
private
void
insertControlHist
(
SignalStatus
VO
signalStatusV
O
)
{
// 更新控制历史表
String
crossId
=
signalStatus
LogDT
O
.
getCrossId
();
Integer
controlType
=
signalStatus
LogDT
O
.
getControlType
();
String
crossId
=
signalStatus
V
O
.
getCrossId
();
Integer
controlType
=
signalStatus
V
O
.
getControlType
();
TCrossControlHist
tCrossControlHist
=
controlHistMapper
.
selectRecentOne
(
crossId
);
if
(
Objects
.
nonNull
(
tCrossControlHist
)
&&
!
Objects
.
equals
(
controlType
,
tCrossControlHist
.
getType
()))
{
controlHistMapper
.
insertOne
(
crossId
,
controlType
,
"未知"
);
...
...
@@ -85,26 +89,28 @@ public class SignalStatusTask {
/**
* 信号机状态插入设备日志表
*
* @param signalStatus
LogDT
O
* @param
signal
Id
* @param signalStatus
V
O
* @param
cross
Id
* @param currentSignalStatus
* @param currentFaultType
*/
private
void
insertDeviceStatusLog
(
SignalStatus
LogDTO
signalStatusLogDTO
,
String
signal
Id
,
Integer
currentSignalStatus
,
Integer
currentFaultType
)
{
private
void
insertDeviceStatusLog
(
SignalStatus
VO
signalStatusVO
,
String
cross
Id
,
Integer
currentSignalStatus
,
Integer
currentFaultType
)
{
// 插入日志表
TDeviceStatusLog
tDeviceStatusLogInfoDB
=
tDeviceStatusLogMapper
.
selectLastOne
(
signal
Id
);
TDeviceStatusLog
tDeviceStatusLogInfoDB
=
tDeviceStatusLogMapper
.
selectLastOne
(
cross
Id
);
// DB数据是故障,如果当前正常非故障,状态为 FaultType=100 故障已处理
if
(
Objects
.
nonNull
(
tDeviceStatusLogInfoDB
)
||
tDeviceStatusLogInfoDB
.
getFaultType
()
!=
0
&&
currentFaultType
==
0
)
{
tDeviceStatusLogInfoDB
.
setStatus
(
currentSignalStatus
);
tDeviceStatusLogInfoDB
.
setFaultType
(
100
);
tDeviceStatusLogInfoDB
.
setId
(
null
);
tDeviceStatusLogMapper
.
insert
(
tDeviceStatusLogInfoDB
);
}
else
{
TDeviceStatusLog
tDeviceStatusLog
=
new
TDeviceStatusLog
();
tDeviceStatusLog
.
setCode
(
signal
Id
);
tDeviceStatusLog
.
setName
(
signalStatus
LogDT
O
.
getSignalId
());
tDeviceStatusLog
.
setCode
(
cross
Id
);
tDeviceStatusLog
.
setName
(
signalStatus
V
O
.
getSignalId
());
tDeviceStatusLog
.
setType
(
1
);
tDeviceStatusLog
.
setStatus
(
signalStatus
LogDT
O
.
getStatus
());
tDeviceStatusLog
.
setStatus
(
signalStatus
V
O
.
getStatus
());
tDeviceStatusLog
.
setFaultType
(
currentFaultType
);
tDeviceStatusLog
.
setId
(
null
);
tDeviceStatusLogMapper
.
insert
(
tDeviceStatusLog
);
}
}
...
...
signal-control-service/src/main/resources/mapper/TDeviceStatusLogMapper.xml
View file @
7bc7adc0
...
...
@@ -2,14 +2,24 @@
<!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"
>
<resultMap
type=
"net.wanji.web.entity.TDeviceStatusLog"
id=
"BaseResultMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"code"
column=
"code"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"type"
column=
"type"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"faultType"
column=
"fault_type"
/>
<result
property=
"gmtCreate"
column=
"gmt_create"
/>
</resultMap>
<select
id=
"selectLastOne"
resultMap=
"BaseResultMap"
parameterType=
"String"
>
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
group by gmt_create desc limit 1
</where>
</select>
</mapper>
\ No newline at end of file
signal-utc-service/src/main/java/net/wanji/utc/service/runninginfo/impl/HkRunningStatusServiceImpl.java
View file @
7bc7adc0
...
...
@@ -48,7 +48,7 @@ public class HkRunningStatusServiceImpl implements HkRunningStatusService {
JSONObject
object
=
JSON
.
parseObject
(
strResult
);
Object
o
=
object
.
get
(
"code"
);
// 多信号机情况下,跳过返回信息不成功的获取返回消息成功的信号机数据
if
(!
Objects
.
equals
(
o
,
0
))
{
if
(!
Objects
.
equals
(
String
.
valueOf
(
o
),
"0"
))
{
continue
;
}
if
(
Constants
.
HK_SUCCESS_CODE
.
equals
(
object
.
getInteger
(
Constants
.
HK_CODE_KEY
)))
{
...
...
@@ -61,16 +61,19 @@ public class HkRunningStatusServiceImpl implements HkRunningStatusService {
po
.
setStatus
(
transferStatus
(
obj
.
getInteger
(
"state"
)));
// 告警信息
Integer
hasFault
=
obj
.
getInteger
(
"hasFault"
);
if
(
hasFault
==
0
)
{
//
if (hasFault == 0) {
po
.
setFaultType
(
hasFault
);
}
//
}
// 从Redis中查询控制类型
String
lightsStatusVOStr
=
redisUtil
.
getHash
(
RedisKeyConst
.
KEY_PREFIX
+
RedisKeyConst
.
LIGHTS_STATUS
,
baseCrossInfo
.
getManufacturerCode
()
+
Constants
.
SEPARATOR_UNDER_LINE
+
po
.
getSignalId
());
LightsStatusVO
lightsStatusVO
=
JSON
.
parseObject
(
lightsStatusVOStr
,
LightsStatusVO
.
class
);
Integer
controlType
=
1
;
if
(
Objects
.
nonNull
(
lightsStatusVO
))
{
String
runMode
=
lightsStatusVO
.
getRunMode
();
int
runModeInt
=
Integer
.
parseInt
(
runMode
);
Integer
controlType
=
HkControlModeEnum
.
getCodeByHkCode
(
runModeInt
);
controlType
=
HkControlModeEnum
.
getCodeByHkCode
(
runModeInt
);
}
po
.
setControlType
(
controlType
);
result
.
add
(
po
);
}
...
...
wj-common/src/main/java/net/wanji/common/utils/tool/BeanMapUtils.java
View file @
7bc7adc0
...
...
@@ -76,10 +76,10 @@ public class BeanMapUtils {
try
{
bean
=
clazz
.
newInstance
();
for
(
Field
field
:
getAllFields
(
clazz
))
{
if
(
map
.
containsKey
(
humpToLine
(
field
.
getName
()
)))
{
if
(
map
.
containsKey
(
field
.
getName
(
)))
{
boolean
flag
=
field
.
isAccessible
();
field
.
setAccessible
(
true
);
Object
object
=
map
.
get
(
humpToLine
(
field
.
getName
()
));
Object
object
=
map
.
get
(
field
.
getName
(
));
if
(
object
!=
null
)
{
if
(
field
.
getType
().
isAssignableFrom
(
object
.
getClass
()))
{
field
.
set
(
bean
,
object
);
...
...
wj-databus/src/main/resources/mapper/CrossInfoMapper.xml
View file @
7bc7adc0
...
...
@@ -257,4 +257,14 @@
#{id}
</foreach>
</select>
<select
id=
"selectById"
resultType=
"net.wanji.databus.po.CrossInfoPO"
>
select
<include
refid=
"baseColumn"
/>
from t_base_cross_info
<where>
<if
test=
"id != null and id != ''"
>
id = #{id}
</if>
</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