Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TDLCloud
Project
Project
Details
Activity
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
WitCloud
TDLCloud
Commits
beb6eca9
Commit
beb6eca9
authored
Mar 28, 2018
by
chenying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3.28修改线路途径地的到达时间和出发时间
parent
cc9776bc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
418 additions
and
7 deletions
+418
-7
UpdateCircuitTransferArrivalTimeVo.java
...ple/tdl/domain/vo/UpdateCircuitTransferArrivalTimeVo.java
+33
-0
UpdateCircuitTransferStartTimeVo.java
...ample/tdl/domain/vo/UpdateCircuitTransferStartTimeVo.java
+33
-0
CircuitTransferMapper.java
...in/java/com/example/tdl/mapper/CircuitTransferMapper.java
+6
-1
CircuitTransferService.java
.../java/com/example/tdl/service/CircuitTransferService.java
+10
-0
AlarmDataController.java
src/main/java/com/example/tdl/web/AlarmDataController.java
+205
-0
CircuitTransferController.java
...n/java/com/example/tdl/web/CircuitTransferController.java
+113
-0
CircuitTransferMapper.xml
src/main/resources/mapper/CircuitTransferMapper.xml
+18
-6
No files found.
src/main/java/com/example/tdl/domain/vo/UpdateCircuitTransferArrivalTimeVo.java
0 → 100644
View file @
beb6eca9
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
UpdateCircuitTransferArrivalTimeVo
{
private
String
transportationNo
;
private
Integer
sequence
;
private
Long
arrivalTime
;
public
String
getTransportationNo
()
{
return
transportationNo
;
}
public
void
setTransportationNo
(
String
transportationNo
)
{
this
.
transportationNo
=
transportationNo
;
}
public
Integer
getSequence
()
{
return
sequence
;
}
public
void
setSequence
(
Integer
sequence
)
{
this
.
sequence
=
sequence
;
}
public
Long
getArrivalTime
()
{
return
arrivalTime
;
}
public
void
setArrivalTime
(
Long
arrivalTime
)
{
this
.
arrivalTime
=
arrivalTime
;
}
}
src/main/java/com/example/tdl/domain/vo/UpdateCircuitTransferStartTimeVo.java
0 → 100644
View file @
beb6eca9
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
UpdateCircuitTransferStartTimeVo
{
private
String
transportationNo
;
private
Integer
sequence
;
private
Long
startTime
;
public
String
getTransportationNo
()
{
return
transportationNo
;
}
public
void
setTransportationNo
(
String
transportationNo
)
{
this
.
transportationNo
=
transportationNo
;
}
public
Integer
getSequence
()
{
return
sequence
;
}
public
void
setSequence
(
Integer
sequence
)
{
this
.
sequence
=
sequence
;
}
public
Long
getStartTime
()
{
return
startTime
;
}
public
void
setStartTime
(
Long
startTime
)
{
this
.
startTime
=
startTime
;
}
}
src/main/java/com/example/tdl/mapper/CircuitTransferMapper.java
View file @
beb6eca9
...
...
@@ -2,7 +2,8 @@ package com.example.tdl.mapper;
import
com.example.tdl.domain.vo.CircuitTransferVo
;
import
com.example.tdl.domain.vo.ResultCityVo
;
import
com.example.tdl.domain.vo.UpdateCircuitTransferArrivalTimeVo
;
import
com.example.tdl.domain.vo.UpdateCircuitTransferStartTimeVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
...
...
@@ -11,4 +12,8 @@ import java.util.List;
public
interface
CircuitTransferMapper
{
List
<
CircuitTransferVo
>
getCity
(
String
transportationNo
);
int
updateArrivalTime
(
UpdateCircuitTransferArrivalTimeVo
updateCircuitTransferVo
);
int
updateStartTime
(
UpdateCircuitTransferStartTimeVo
updateCircuitTransferStartTimeVo
);
}
src/main/java/com/example/tdl/service/CircuitTransferService.java
View file @
beb6eca9
...
...
@@ -2,6 +2,8 @@ package com.example.tdl.service;
import
com.example.tdl.domain.vo.CircuitTransferVo
;
import
com.example.tdl.domain.vo.UpdateCircuitTransferArrivalTimeVo
;
import
com.example.tdl.domain.vo.UpdateCircuitTransferStartTimeVo
;
import
com.example.tdl.mapper.CircuitTransferMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -17,4 +19,12 @@ public class CircuitTransferService {
public
List
<
CircuitTransferVo
>
getCity
(
String
transportationNo
){
return
circuitTransferMapper
.
getCity
(
transportationNo
);
}
public
int
updateArrivalTime
(
UpdateCircuitTransferArrivalTimeVo
updateCircuitTransferVo
){
return
circuitTransferMapper
.
updateArrivalTime
(
updateCircuitTransferVo
);
}
public
int
updateStartTime
(
UpdateCircuitTransferStartTimeVo
updateCircuitTransferStartTimeVo
){
return
circuitTransferMapper
.
updateStartTime
(
updateCircuitTransferStartTimeVo
);
}
}
src/main/java/com/example/tdl/web/AlarmDataController.java
0 → 100644
View file @
beb6eca9
package
com
.
example
.
tdl
.
web
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.CircuitAlarmVo
;
import
com.example.tdl.domain.vo.LocationDataVo
;
import
com.example.tdl.domain.vo.LocationMessageVo
;
import
com.example.tdl.domain.vo.ResultGatewayVo
;
import
com.example.tdl.service.CircuitService
;
import
com.example.tdl.service.TDLDeviceService
;
import
com.example.tdl.service.redis.RealRedisService
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.influxdb.dto.Query
;
import
org.influxdb.dto.QueryResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.influxdb.InfluxDBTemplate
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@RestController
public
class
AlarmDataController
{
private
CommFeedback
fb
=
new
CommFeedback
();
private
Gson
gson
=
new
Gson
();
@Autowired
private
CircuitService
circuitService
;
@Autowired
private
InfluxDBTemplate
influxDBTemplate
;
@Autowired
private
TDLDeviceService
tdlDeviceService
;
@Autowired
private
RealRedisService
realRedisService
;
private
final
static
String
database
=
"original"
;
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/getAlarmCircuit"
,
method
=
RequestMethod
.
POST
)
public
Object
getAlarmCircuit
(
@RequestBody
String
transportationNo
){
// String transportationNo="CHN20180227G0505";
JSONObject
jsonObject
=
JSON
.
parseObject
(
transportationNo
);
transportationNo
=(
String
)
jsonObject
.
get
(
"transportationNo"
);
ResultGatewayVo
resultGatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
if
(
resultGatewayVo
==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"该线路没有绑定网关"
);
return
gson
.
toJson
(
fb
);
}
Integer
circuitState
=
circuitService
.
getByTransportationNo
(
transportationNo
).
getCircuitState
();
String
device
=
resultGatewayVo
.
getType
()
+
"_"
+
resultGatewayVo
.
getSN
();
if
(
circuitState
==
0
){
return
null
;
}
else
if
(
circuitState
==
1
){
List
<
String
>
list
=
tdlDeviceService
.
getByGatewaySN
(
resultGatewayVo
.
getSN
(),
resultGatewayVo
.
getType
());
String
tdl
=
""
;
if
(
list
.
size
()==
1
){
tdl
=
"'tdl-"
+
list
.
get
(
0
)+
"'"
;
}
else
if
(
list
.
size
()==
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"该网关下没有tdl设备"
);
return
gson
.
toJson
(
fb
);
}
else
{
for
(
int
a
=
0
;
a
<
list
.
size
();
a
++){
tdl
=
tdl
+
"'tdl-"
+
list
.
get
(
a
)+
"'"
;
if
(
a
<
list
.
size
()-
1
){
tdl
=
tdl
+
"or \"tdl\"="
;
}
}
}
String
sql
=
"SELECT \"b\",\"tdl\" FROM \"tdl_policy\".\""
+
device
+
"\" where \"tdl\"= "
+
tdl
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
List
<
CircuitAlarmVo
>
circuitAlarmVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()!=
null
){
circuitAlarmVos
=
getAlarmData
(
queryResult
);
}
String
sqls
=
""
;
for
(
int
a
=
0
;
a
<
circuitAlarmVos
.
size
();
a
++){
sqls
=
sqls
+
"SELECT \"time\",\"lng\",\"lat\" FROM \"tdl_policy\".\""
+
device
+
"\" where time <='"
+
circuitAlarmVos
.
get
(
a
).
getTime
()+
"' ORDER BY time desc limit 1;"
;
}
QueryResult
queryResults
=
influxDBTemplate
.
query
(
new
Query
(
sqls
,
database
));
List
<
LocationDataVo
>
locationDataVos
=
new
ArrayList
<>();
if
(
queryResults
.
getResults
().
get
(
0
).
getSeries
()!=
null
){
locationDataVos
=
getAddress
(
queryResults
);
}
String
sql1
=
"SELECT \"time\",\"lng\",\"lat\" FROM \"tdl_policy\".\""
+
device
+
"\" order by time"
;
QueryResult
queryResult1
=
influxDBTemplate
.
query
(
new
Query
(
sql1
,
database
));
List
<
LocationDataVo
>
locationDataVos1
=
new
ArrayList
<>();
if
(
queryResult1
.
getResults
().
get
(
0
).
getSeries
()!=
null
){
locationDataVos1
=
getAllAddress
(
queryResult1
);
}
for
(
int
a
=
0
;
a
<
locationDataVos1
.
size
();
a
++){
for
(
int
b
=
0
;
b
<
locationDataVos
.
size
();
b
++){
if
(
locationDataVos1
.
get
(
a
).
getLng
().
equals
(
locationDataVos
.
get
(
b
).
getLng
())&&
locationDataVos1
.
get
(
a
).
getLat
().
equals
(
locationDataVos
.
get
(
b
).
getLat
())){
locationDataVos1
.
get
(
a
).
setError
(
1
);
}
}
}
return
gson
.
toJson
(
locationDataVos1
);
}
else
{
// Map<Object,Object> map=new HashMap<>();
// map.put(device,locationDataVos1);
// realRedisService.setHash("CircuitAlarm",map,System.currentTimeMillis());
Object
o
=
realRedisService
.
getHash
(
"CircuitAlarm"
,
device
);
return
gson
.
toJson
(
o
);
}
}
public
List
<
LocationDataVo
>
getAddress
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
lists
=
getValue
(
queryResult
);
List
<
LocationDataVo
>
locationDataVos
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
lists
){
LocationDataVo
locationDataVo
=
new
LocationDataVo
();
locationDataVo
.
setTime
(
dateToStamp
(
value
.
get
(
0
).
toString
()));
locationDataVo
.
setLng
((
Double
)
value
.
get
(
1
));
locationDataVo
.
setLat
((
Double
)
value
.
get
(
2
));
locationDataVos
.
add
(
locationDataVo
);
}
return
locationDataVos
;
}
public
List
<
LocationDataVo
>
getAllAddress
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
lists
=
getValues
(
queryResult
);
List
<
LocationDataVo
>
locationDataVos
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
lists
){
LocationDataVo
locationDataVo
=
new
LocationDataVo
();
locationDataVo
.
setTime
(
dateToStamp
(
value
.
get
(
0
).
toString
()));
locationDataVo
.
setLng
((
Double
)
value
.
get
(
1
));
locationDataVo
.
setLat
((
Double
)
value
.
get
(
2
));
locationDataVo
.
setError
(
0
);
locationDataVos
.
add
(
locationDataVo
);
}
return
locationDataVos
;
}
public
List
<
CircuitAlarmVo
>
getAlarmData
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
lists
=
getValues
(
queryResult
);
List
<
CircuitAlarmVo
>
alarmVoList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
lists
){
CircuitAlarmVo
circuitAlarmVo
=
new
CircuitAlarmVo
();
circuitAlarmVo
.
setTime
(
value
.
get
(
0
).
toString
());
circuitAlarmVo
.
setShockEnergy
(
value
.
get
(
1
).
toString
());
circuitAlarmVo
.
setTdl
(
value
.
get
(
2
).
toString
());
alarmVoList
.
add
(
circuitAlarmVo
);
}
return
alarmVoList
;
}
public
List
<
List
<
Object
>>
getValues
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
lists
=
new
ArrayList
<>();
for
(
QueryResult
.
Result
result:
queryResult
.
getResults
()){
if
(
result
.
getSeries
()!=
null
){
for
(
QueryResult
.
Series
series:
result
.
getSeries
()){
if
(
series
!=
null
){
lists
=
series
.
getValues
();
}
}
}
}
return
lists
;
}
public
List
<
List
<
Object
>>
getValue
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
lists
=
new
ArrayList
<>();
for
(
QueryResult
.
Result
result:
queryResult
.
getResults
()){
if
(
result
.
getSeries
()!=
null
){
for
(
int
a
=
0
;
a
<
result
.
getSeries
().
size
();
a
++){
lists
.
add
(
result
.
getSeries
().
get
(
a
).
getValues
().
get
(
0
));
}
}
}
return
lists
;
}
public
String
dateToStamp
(
String
time
){
String
res
;
Date
date
=
null
;
try
{
if
(
time
.
length
()!=
20
){
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
);
date
=
simpleDateFormat
.
parse
(
time
);
}
else
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
date
=
simpleDateFormat
.
parse
(
time
);
}
long
ts
=
date
.
getTime
()*
1000000
;
res
=
String
.
valueOf
(
ts
);
}
catch
(
Exception
e
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"时间转换出错"
);
return
gson
.
toJson
(
fb
);
}
return
res
;
}
}
\ No newline at end of file
src/main/java/com/example/tdl/web/CircuitTransferController.java
0 → 100644
View file @
beb6eca9
package
com
.
example
.
tdl
.
web
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.UpdateCircuitTransferArrivalTimeVo
;
import
com.example.tdl.domain.vo.UpdateCircuitTransferStartTimeVo
;
import
com.example.tdl.service.CircuitTransferService
;
import
com.example.tdl.service.RoleService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/circuitTransfer"
)
public
class
CircuitTransferController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
CircuitTransferController
.
class
);
CommFeedback
fb
=
new
CommFeedback
();
Gson
gson
=
new
Gson
();
@Autowired
private
CircuitTransferService
circuitTransferService
;
@Autowired
private
TokenRedisService
tokenRedisService
;
//修改线路途径地到达时间
@ApiOperation
(
value
=
"修改线路途径地到达时间"
,
notes
=
"修改线路途径地到达时间,修改所需要传的参数:"
+
" transportationNo:线路编号,"
+
" sequence:途径序号,"
+
" arrivalTime:修改的到达时间。"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/updateArrivalTime"
,
method
=
RequestMethod
.
POST
)
public
Object
updateArrivalTime
(
@RequestBody
UpdateCircuitTransferArrivalTimeVo
updateCircuitTransferArrivalTimeVo
){
if
(
StringUtils
.
isEmpty
(
updateCircuitTransferArrivalTimeVo
.
getTransportationNo
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"需要修改的线路编号不能为空"
);
return
gson
.
toJson
(
fb
);
}
if
(
updateCircuitTransferArrivalTimeVo
.
getSequence
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"需要修改的途径地序号不能为空"
);
return
gson
.
toJson
(
fb
);
}
if
(
updateCircuitTransferArrivalTimeVo
.
getArrivalTime
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"修改后的到达时间不能为空"
);
return
gson
.
toJson
(
fb
);
}
int
a
=
circuitTransferService
.
updateArrivalTime
(
updateCircuitTransferArrivalTimeVo
);
if
(
a
>=
0
){
fb
.
setCode
(
1
);
fb
.
setMessage
(
"修改途径地到达时间成功"
);
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
"修改途径地到达时间失败"
);
}
return
gson
.
toJson
(
fb
);
}
//修改线路途径地到达时间
@ApiOperation
(
value
=
"修改线路途径地到达时间"
,
notes
=
"修改线路途径地到达时间,修改所需要传的参数:"
+
" transportationNo:线路编号,"
+
" sequence:途径序号,"
+
" arrivalTime:修改的到达时间。"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/updateStartTime"
,
method
=
RequestMethod
.
POST
)
public
Object
updateStartTime
(
@RequestBody
UpdateCircuitTransferStartTimeVo
updateCircuitTransferStartTimeVo
){
if
(
StringUtils
.
isEmpty
(
updateCircuitTransferStartTimeVo
.
getTransportationNo
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"需要修改的线路编号不能为空"
);
return
gson
.
toJson
(
fb
);
}
if
(
updateCircuitTransferStartTimeVo
.
getSequence
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"需要修改的途径地序号不能为空"
);
return
gson
.
toJson
(
fb
);
}
if
(
updateCircuitTransferStartTimeVo
.
getStartTime
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"修改后的出发时间不能为空"
);
return
gson
.
toJson
(
fb
);
}
int
a
=
circuitTransferService
.
updateStartTime
(
updateCircuitTransferStartTimeVo
);
if
(
a
>=
0
){
fb
.
setCode
(
1
);
fb
.
setMessage
(
"修改途径地出发时间成功"
);
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
"修改途径地出发时间失败"
);
}
return
gson
.
toJson
(
fb
);
}
}
src/main/resources/mapper/CircuitTransferMapper.xml
View file @
beb6eca9
<?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=
"com.example.tdl.mapper.CircuitTransferMapper"
>
<select
id=
"getCity"
resultType=
"com.example.tdl.domain.vo.CircuitTransferVo"
parameterType=
"String"
>
select c.city,ct.arrivalTime,ct.startTime,ct.sequence from circuit_transfer ct,city c,circuit cr
where c.id=ct.city_id
and ct.circuit_id =cr.id
and cr.transportationNo = #{transportationNo,jdbcType=VARCHAR}
</select>
<select
id=
"getCity"
resultType=
"com.example.tdl.domain.vo.CircuitTransferVo"
parameterType=
"String"
>
select c.city,ct.arrivalTime,ct.startTime,ct.sequence from circuit_transfer ct,city c,circuit cr
where c.id=ct.city_id
and ct.circuit_id =cr.id
and cr.transportationNo = #{transportationNo,jdbcType=VARCHAR}
</select>
<update
id=
"updateArrivalTime"
parameterType=
"com.example.tdl.domain.vo.UpdateCircuitTransferArrivalTimeVo"
>
UPDATE circuit_transfer set arrivalTime=#{arrivalTime,jdbcType=BIGINT}
WHERE circuit_id=(SELECT id from circuit WHERE transportationNo = #{transportationNo,jdbcType=VARCHAR})
AND sequence=#{sequence,jdbcType=INTEGER}
</update>
<update
id=
"updateStartTime"
parameterType=
"com.example.tdl.domain.vo.UpdateCircuitTransferStartTimeVo"
>
UPDATE circuit_transfer set startTime=#{startTime,jdbcType=BIGINT}
WHERE circuit_id=(SELECT id from circuit WHERE transportationNo = #{transportationNo,jdbcType=VARCHAR})
AND sequence=#{sequence,jdbcType=INTEGER}
</update>
</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