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
5341dd21
Commit
5341dd21
authored
Apr 17, 2018
by
chenying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4.17修改预警信息,给预警添加公司
parent
8082a828
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
166 additions
and
89 deletions
+166
-89
AddAlarmVo.java
src/main/java/com/example/tdl/domain/vo/AddAlarmVo.java
+10
-0
DelAlarmVo.java
src/main/java/com/example/tdl/domain/vo/DelAlarmVo.java
+10
-0
UpdateAlarmVo.java
src/main/java/com/example/tdl/domain/vo/UpdateAlarmVo.java
+10
-0
AlarmMapper.java
src/main/java/com/example/tdl/mapper/AlarmMapper.java
+5
-5
AlarmService.java
src/main/java/com/example/tdl/service/AlarmService.java
+10
-10
AlarmController.java
src/main/java/com/example/tdl/web/AlarmController.java
+45
-20
CircuitController.java
src/main/java/com/example/tdl/web/CircuitController.java
+44
-41
EquipmentBindingController.java
.../java/com/example/tdl/web/EquipmentBindingController.java
+10
-2
application.properties
src/main/resources/application.properties
+2
-2
AlarmMapper.xml
src/main/resources/mapper/AlarmMapper.xml
+20
-9
No files found.
src/main/java/com/example/tdl/domain/vo/AddAlarmVo.java
View file @
5341dd21
...
@@ -20,6 +20,8 @@ public class AddAlarmVo {
...
@@ -20,6 +20,8 @@ public class AddAlarmVo {
private
String
remark
;
private
String
remark
;
private
String
companyName
;
public
String
getAlarmType
()
{
public
String
getAlarmType
()
{
return
alarmType
;
return
alarmType
;
}
}
...
@@ -91,4 +93,12 @@ public class AddAlarmVo {
...
@@ -91,4 +93,12 @@ public class AddAlarmVo {
public
void
setRemark
(
String
remark
)
{
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
this
.
remark
=
remark
;
}
}
public
String
getCompanyName
()
{
return
companyName
;
}
public
void
setCompanyName
(
String
companyName
)
{
this
.
companyName
=
companyName
;
}
}
}
src/main/java/com/example/tdl/domain/vo/DelAlarmVo.java
View file @
5341dd21
...
@@ -5,6 +5,16 @@ public class DelAlarmVo {
...
@@ -5,6 +5,16 @@ public class DelAlarmVo {
private
String
alarmScene
;
private
String
alarmScene
;
private
String
companyName
;
public
String
getCompanyName
()
{
return
companyName
;
}
public
void
setCompanyName
(
String
companyName
)
{
this
.
companyName
=
companyName
;
}
public
String
getAlarmType
()
{
public
String
getAlarmType
()
{
return
alarmType
;
return
alarmType
;
}
}
...
...
src/main/java/com/example/tdl/domain/vo/UpdateAlarmVo.java
View file @
5341dd21
...
@@ -24,6 +24,16 @@ public class UpdateAlarmVo {
...
@@ -24,6 +24,16 @@ public class UpdateAlarmVo {
private
String
oldAlarmScene
;
private
String
oldAlarmScene
;
private
String
companyName
;
public
String
getCompanyName
()
{
return
companyName
;
}
public
void
setCompanyName
(
String
companyName
)
{
this
.
companyName
=
companyName
;
}
public
String
getAlarmType
()
{
public
String
getAlarmType
()
{
return
alarmType
;
return
alarmType
;
}
}
...
...
src/main/java/com/example/tdl/mapper/AlarmMapper.java
View file @
5341dd21
...
@@ -12,9 +12,9 @@ import java.util.List;
...
@@ -12,9 +12,9 @@ import java.util.List;
@Mapper
@Mapper
public
interface
AlarmMapper
{
public
interface
AlarmMapper
{
List
<
ResultAlarmVo
>
getAll
();
List
<
ResultAlarmVo
>
getAll
(
String
companyName
);
List
<
ResultAlarmVo
>
getAllByAlarmType
(
String
alarmType
);
List
<
ResultAlarmVo
>
getAllByAlarmType
(
@Param
(
"companyName"
)
String
companyName
,
@Param
(
"alarmType"
)
String
alarmType
);
int
addAlarm
(
AddAlarmVo
addAlarmVo
);
int
addAlarm
(
AddAlarmVo
addAlarmVo
);
...
@@ -22,9 +22,9 @@ public interface AlarmMapper {
...
@@ -22,9 +22,9 @@ public interface AlarmMapper {
int
delAlarm
(
DelAlarmVo
delAlarmVo
);
int
delAlarm
(
DelAlarmVo
delAlarmVo
);
ResultAlarmVo
getByTypeAndScene
(
@Param
(
"alarmType"
)
String
alarmType
,
@Param
(
"alarmScene"
)
String
alarmScene
);
ResultAlarmVo
getByTypeAndScene
(
@Param
(
"alarmType"
)
String
alarmType
,
@Param
(
"alarmScene"
)
String
alarmScene
,
@Param
(
"companyName"
)
String
companyName
);
List
<
String
>
getForWarehouse
();
List
<
String
>
getForWarehouse
(
String
companyName
);
List
<
String
>
getForTransportation
();
List
<
String
>
getForTransportation
(
String
companyName
);
}
}
src/main/java/com/example/tdl/service/AlarmService.java
View file @
5341dd21
...
@@ -17,12 +17,12 @@ public class AlarmService {
...
@@ -17,12 +17,12 @@ public class AlarmService {
@Autowired
@Autowired
private
AlarmMapper
alarmMapper
;
private
AlarmMapper
alarmMapper
;
public
List
<
ResultAlarmVo
>
getAll
(){
public
List
<
ResultAlarmVo
>
getAll
(
String
companyName
){
return
alarmMapper
.
getAll
();
return
alarmMapper
.
getAll
(
companyName
);
}
}
public
List
<
ResultAlarmVo
>
getAllByAlarmType
(
String
alarmType
){
public
List
<
ResultAlarmVo
>
getAllByAlarmType
(
String
companyName
,
String
alarmType
){
return
alarmMapper
.
getAllByAlarmType
(
alarmType
);
return
alarmMapper
.
getAllByAlarmType
(
companyName
,
alarmType
);
}
}
public
int
addAlarm
(
AddAlarmVo
addAlarmVo
){
public
int
addAlarm
(
AddAlarmVo
addAlarmVo
){
...
@@ -37,16 +37,16 @@ public class AlarmService {
...
@@ -37,16 +37,16 @@ public class AlarmService {
return
alarmMapper
.
delAlarm
(
delAlarmVo
);
return
alarmMapper
.
delAlarm
(
delAlarmVo
);
}
}
public
ResultAlarmVo
getByTypeAndScene
(
String
alarmType
,
String
alarmScene
){
public
ResultAlarmVo
getByTypeAndScene
(
String
alarmType
,
String
alarmScene
,
String
companyName
){
return
alarmMapper
.
getByTypeAndScene
(
alarmType
,
alarmScene
);
return
alarmMapper
.
getByTypeAndScene
(
alarmType
,
alarmScene
,
companyName
);
}
}
public
List
<
String
>
getForWarehouse
(){
public
List
<
String
>
getForWarehouse
(
String
companyName
){
return
alarmMapper
.
getForWarehouse
();
return
alarmMapper
.
getForWarehouse
(
companyName
);
}
}
public
List
<
String
>
getForTransportation
(){
public
List
<
String
>
getForTransportation
(
String
companyName
){
return
alarmMapper
.
getForTransportation
();
return
alarmMapper
.
getForTransportation
(
companyName
);
}
}
}
}
src/main/java/com/example/tdl/web/AlarmController.java
View file @
5341dd21
...
@@ -3,9 +3,7 @@ package com.example.tdl.web;
...
@@ -3,9 +3,7 @@ package com.example.tdl.web;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.AddAlarmVo
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.domain.vo.DelAlarmVo
;
import
com.example.tdl.domain.vo.UpdateAlarmVo
;
import
com.example.tdl.service.AlarmService
;
import
com.example.tdl.service.AlarmService
;
import
com.example.tdl.service.WarehouseService
;
import
com.example.tdl.service.WarehouseService
;
...
@@ -21,6 +19,9 @@ import org.slf4j.LoggerFactory;
...
@@ -21,6 +19,9 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@RestController
@RestController
@RequestMapping
(
"/alarm"
)
@RequestMapping
(
"/alarm"
)
...
@@ -56,8 +57,11 @@ public class AlarmController {
...
@@ -56,8 +57,11 @@ public class AlarmController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/getAll"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/getAll"
,
method
=
RequestMethod
.
GET
)
public
Object
getAll
(){
public
Object
getAll
(
HttpServletRequest
request
){
return
alarmService
.
getAll
();
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
return
alarmService
.
getAll
(
user
.
getCompanyName
());
}
}
//根据预警类型模糊查询
//根据预警类型模糊查询
...
@@ -75,14 +79,17 @@ public class AlarmController {
...
@@ -75,14 +79,17 @@ public class AlarmController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/getAllByAlarmType"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/getAllByAlarmType"
,
method
=
RequestMethod
.
POST
)
public
Object
getAllByAlarmType
(
@RequestBody
String
alarmType
){
public
Object
getAllByAlarmType
(
@RequestBody
String
alarmType
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
alarmType
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
alarmType
);
alarmType
=(
String
)
jsonObject
.
get
(
"alarmType"
);
alarmType
=(
String
)
jsonObject
.
get
(
"alarmType"
);
return
alarmService
.
getAllByAlarmType
(
alarmType
);
return
alarmService
.
getAllByAlarmType
(
user
.
getCompanyName
(),
alarmType
);
}
}
//添加预警信息
//添加预警信息
@ApiOperation
(
value
=
"添加预警信息"
,
notes
=
"添加预警信息,传递参数:"
+
@ApiOperation
(
value
=
"添加预警信息"
,
notes
=
"添加预警信息,
companyName不用传,需要
传递参数:"
+
" alarmType:预警类型,"
+
" alarmType:预警类型,"
+
" alarmScene:预警场景,"
+
" alarmScene:预警场景,"
+
" temMax:温度上限,"
+
" temMax:温度上限,"
+
...
@@ -96,7 +103,10 @@ public class AlarmController {
...
@@ -96,7 +103,10 @@ public class AlarmController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/addAlarm"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/addAlarm"
,
method
=
RequestMethod
.
POST
)
public
Object
addAlarm
(
@RequestBody
AddAlarmVo
addAlarmVo
){
public
Object
addAlarm
(
@RequestBody
AddAlarmVo
addAlarmVo
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
if
(
StringUtils
.
isEmpty
(
addAlarmVo
.
getAlarmType
())){
if
(
StringUtils
.
isEmpty
(
addAlarmVo
.
getAlarmType
())){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
"预警类型不能为空"
);
fb
.
setMessage
(
"预警类型不能为空"
);
...
@@ -142,11 +152,12 @@ public class AlarmController {
...
@@ -142,11 +152,12 @@ public class AlarmController {
fb
.
setMessage
(
"震度不能为空"
);
fb
.
setMessage
(
"震度不能为空"
);
return
gson
.
toJson
(
fb
);
return
gson
.
toJson
(
fb
);
}
}
if
(
alarmService
.
getByTypeAndScene
(
addAlarmVo
.
getAlarmType
(),
addAlarmVo
.
getAlarmScene
())!=
null
){
if
(
alarmService
.
getByTypeAndScene
(
addAlarmVo
.
getAlarmType
(),
addAlarmVo
.
getAlarmScene
()
,
user
.
getCompanyName
()
)!=
null
){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
"添加的预警类型在该场景中已存在"
);
fb
.
setMessage
(
"添加的预警类型在该场景中已存在"
);
return
gson
.
toJson
(
fb
);
return
gson
.
toJson
(
fb
);
}
}
addAlarmVo
.
setCompanyName
(
user
.
getCompanyName
());
int
a
=
alarmService
.
addAlarm
(
addAlarmVo
);
int
a
=
alarmService
.
addAlarm
(
addAlarmVo
);
if
(
a
>
0
){
if
(
a
>
0
){
fb
.
setCode
(
1
);
fb
.
setCode
(
1
);
...
@@ -159,7 +170,7 @@ public class AlarmController {
...
@@ -159,7 +170,7 @@ public class AlarmController {
}
}
//修改预警信息
//修改预警信息
@ApiOperation
(
value
=
"修改预警信息"
,
notes
=
"修改预警信息,传递参数:"
+
@ApiOperation
(
value
=
"修改预警信息"
,
notes
=
"修改预警信息,
companyName不用传,需要
传递参数:"
+
" oldAlarmType:需要修改的预警类型,"
+
" oldAlarmType:需要修改的预警类型,"
+
" oldAlarmScene:需要修改的预警场景,"
+
" oldAlarmScene:需要修改的预警场景,"
+
" alarmType:预警类型,"
+
" alarmType:预警类型,"
+
...
@@ -175,7 +186,10 @@ public class AlarmController {
...
@@ -175,7 +186,10 @@ public class AlarmController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/updateAlarm"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/updateAlarm"
,
method
=
RequestMethod
.
POST
)
public
Object
updateAlarm
(
@RequestBody
UpdateAlarmVo
updateAlarmVo
){
public
Object
updateAlarm
(
@RequestBody
UpdateAlarmVo
updateAlarmVo
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
if
(
StringUtils
.
isEmpty
(
updateAlarmVo
.
getOldAlarmType
())){
if
(
StringUtils
.
isEmpty
(
updateAlarmVo
.
getOldAlarmType
())){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
"需要修改的预警类型不能为空"
);
fb
.
setMessage
(
"需要修改的预警类型不能为空"
);
...
@@ -235,11 +249,12 @@ public class AlarmController {
...
@@ -235,11 +249,12 @@ public class AlarmController {
fb
.
setMessage
(
"震度不能为空"
);
fb
.
setMessage
(
"震度不能为空"
);
return
gson
.
toJson
(
fb
);
return
gson
.
toJson
(
fb
);
}
}
if
(
alarmService
.
getByTypeAndScene
(
updateAlarmVo
.
getAlarmType
(),
updateAlarmVo
.
getAlarmType
())!=
null
&&!
updateAlarmVo
.
getAlarmType
().
equals
(
updateAlarmVo
.
getAlarmType
())&&!
updateAlarmVo
.
getAlarmScene
().
equals
(
updateAlarmVo
.
getAlarmScene
())){
if
(
alarmService
.
getByTypeAndScene
(
updateAlarmVo
.
getAlarmType
(),
updateAlarmVo
.
getAlarmType
()
,
user
.
getCompanyName
()
)!=
null
&&!
updateAlarmVo
.
getAlarmType
().
equals
(
updateAlarmVo
.
getAlarmType
())&&!
updateAlarmVo
.
getAlarmScene
().
equals
(
updateAlarmVo
.
getAlarmScene
())){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
"修改的预警类型在该场景中已存在"
);
fb
.
setMessage
(
"修改的预警类型在该场景中已存在"
);
return
gson
.
toJson
(
fb
);
return
gson
.
toJson
(
fb
);
}
}
updateAlarmVo
.
setCompanyName
(
user
.
getCompanyName
());
int
a
=
alarmService
.
updateAlarm
(
updateAlarmVo
);
int
a
=
alarmService
.
updateAlarm
(
updateAlarmVo
);
if
(
a
>
0
){
if
(
a
>
0
){
fb
.
setCode
(
1
);
fb
.
setCode
(
1
);
...
@@ -253,14 +268,17 @@ public class AlarmController {
...
@@ -253,14 +268,17 @@ public class AlarmController {
}
}
//删除预警信息
//删除预警信息
@ApiOperation
(
value
=
"删除预警信息"
,
notes
=
"删除预警信息,传值说明:"
+
@ApiOperation
(
value
=
"删除预警信息"
,
notes
=
"删除预警信息,
companyName不用传,
传值说明:"
+
" alarmType:需要删除的预警类型,"
+
" alarmType:需要删除的预警类型,"
+
" alarmScene:需要删除的预警场景"
)
" alarmScene:需要删除的预警场景"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/delAlarm"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/delAlarm"
,
method
=
RequestMethod
.
POST
)
public
Object
delAlarm
(
@RequestBody
DelAlarmVo
delAlarmVo
){
public
Object
delAlarm
(
@RequestBody
DelAlarmVo
delAlarmVo
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
if
(
StringUtils
.
isEmpty
(
delAlarmVo
.
getAlarmScene
())){
if
(
StringUtils
.
isEmpty
(
delAlarmVo
.
getAlarmScene
())){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
"需要删除的预警场景不能为空"
);
fb
.
setMessage
(
"需要删除的预警场景不能为空"
);
...
@@ -271,7 +289,8 @@ public class AlarmController {
...
@@ -271,7 +289,8 @@ public class AlarmController {
fb
.
setMessage
(
"需要删除的预警类型不能为空"
);
fb
.
setMessage
(
"需要删除的预警类型不能为空"
);
return
gson
.
toJson
(
fb
);
return
gson
.
toJson
(
fb
);
}
}
if
(
warehouseService
.
getByAlarm
(
delAlarmVo
)!=
null
){
delAlarmVo
.
setCompanyName
(
user
.
getCompanyName
());
if
(
warehouseService
.
getByAlarm
(
delAlarmVo
).
size
()>
0
){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
"该预警正在被使用"
);
fb
.
setMessage
(
"该预警正在被使用"
);
return
gson
.
toJson
(
fb
);
return
gson
.
toJson
(
fb
);
...
@@ -293,8 +312,11 @@ public class AlarmController {
...
@@ -293,8 +312,11 @@ public class AlarmController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/getForWarehouse"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/getForWarehouse"
,
method
=
RequestMethod
.
GET
)
public
Object
getForWarehouse
(){
public
Object
getForWarehouse
(
HttpServletRequest
request
){
return
alarmService
.
getForWarehouse
();
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
return
alarmService
.
getForWarehouse
(
user
.
getCompanyName
());
}
}
...
@@ -304,8 +326,11 @@ public class AlarmController {
...
@@ -304,8 +326,11 @@ public class AlarmController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/getForTransportation"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/getForTransportation"
,
method
=
RequestMethod
.
GET
)
public
Object
getForTransportation
(){
public
Object
getForTransportation
(
HttpServletRequest
request
){
return
alarmService
.
getForTransportation
();
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
return
alarmService
.
getForTransportation
(
user
.
getCompanyName
());
}
}
}
}
src/main/java/com/example/tdl/web/CircuitController.java
View file @
5341dd21
...
@@ -485,7 +485,7 @@ public class CircuitController {
...
@@ -485,7 +485,7 @@ public class CircuitController {
alarmTypeVar
=
alarmTypeVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
()
+
" "
;
alarmTypeVar
=
alarmTypeVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
()
+
" "
;
TDLSNVar
=
TDLSNVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
()
+
" "
;
TDLSNVar
=
TDLSNVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
()
+
" "
;
devList
.
add
(
"TDL-"
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
());
devList
.
add
(
"TDL-"
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
());
saveAlarmRule
(
"TDL/"
+
type
+
"/"
+
addCircuitVo
.
getSN
()+
"/Data"
,
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
(),
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
());
saveAlarmRule
(
"TDL/"
+
type
+
"/"
+
addCircuitVo
.
getSN
()+
"/Data"
,
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
(),
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
()
,
request
);
}
}
if
(
StringUtils
.
isEmpty
(
addCircuitVo
.
getCargoNo
())){
if
(
StringUtils
.
isEmpty
(
addCircuitVo
.
getCargoNo
())){
...
@@ -847,14 +847,14 @@ public class CircuitController {
...
@@ -847,14 +847,14 @@ public class CircuitController {
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@RequestMapping
(
value
=
"/getBy
Plate
No"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/getBy
Container
No"
,
method
=
RequestMethod
.
POST
)
public
Object
getBy
PlateNo
(
@RequestBody
String
plate
No
,
HttpServletRequest
request
){
public
Object
getBy
ContainerNo
(
@RequestBody
String
cargo
No
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
plate
No
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
cargo
No
);
plateNo
=(
String
)
jsonObject
.
get
(
"plate
No"
);
cargoNo
=(
String
)
jsonObject
.
get
(
"cargo
No"
);
return
circuitService
.
getByPlateNo
(
plate
No
,
user
.
getCompanyName
());
return
circuitService
.
getByPlateNo
(
cargo
No
,
user
.
getCompanyName
());
}
}
//评价
//评价
...
@@ -1235,8 +1235,11 @@ public class CircuitController {
...
@@ -1235,8 +1235,11 @@ public class CircuitController {
}
}
//将报警规则存到redis中
//将报警规则存到redis中
public
void
saveAlarmRule
(
String
topic
,
String
TDLSN
,
String
alarmType
){
public
void
saveAlarmRule
(
String
topic
,
String
TDLSN
,
String
alarmType
,
HttpServletRequest
request
){
ResultAlarmVo
alarmVo
=
alarmService
.
getByTypeAndScene
(
alarmType
,
"运输"
);
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
ResultAlarmVo
alarmVo
=
alarmService
.
getByTypeAndScene
(
alarmType
,
"运输"
,
user
.
getCompanyName
());
for
(
String
alias
:
list
){
for
(
String
alias
:
list
){
List
<
AlarmRuleVo
>
alarmRuleVos
=
new
ArrayList
<>();
List
<
AlarmRuleVo
>
alarmRuleVos
=
new
ArrayList
<>();
AlarmRuleVo
alarmRuleVo
=
new
AlarmRuleVo
();
AlarmRuleVo
alarmRuleVo
=
new
AlarmRuleVo
();
...
...
src/main/java/com/example/tdl/web/EquipmentBindingController.java
View file @
5341dd21
...
@@ -10,6 +10,7 @@ import com.example.tdl.service.ConfigService;
...
@@ -10,6 +10,7 @@ import com.example.tdl.service.ConfigService;
import
com.example.tdl.service.GatewayService
;
import
com.example.tdl.service.GatewayService
;
import
com.example.tdl.service.TDLDeviceService
;
import
com.example.tdl.service.TDLDeviceService
;
import
com.example.tdl.service.redis.AlarmRedisService
;
import
com.example.tdl.service.redis.AlarmRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
...
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -23,6 +24,7 @@ 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
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -52,6 +54,9 @@ public class EquipmentBindingController {
...
@@ -52,6 +54,9 @@ public class EquipmentBindingController {
@Autowired
@Autowired
private
AlarmService
alarmService
;
private
AlarmService
alarmService
;
@Autowired
private
TokenRedisService
tokenRedisService
;
List
<
String
>
list
=
new
ArrayList
<
String
>(){{
List
<
String
>
list
=
new
ArrayList
<
String
>(){{
add
(
"T"
);
add
(
"T"
);
add
(
"h"
);
add
(
"h"
);
...
@@ -73,7 +78,10 @@ public class EquipmentBindingController {
...
@@ -73,7 +78,10 @@ public class EquipmentBindingController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
@PostMapping
(
"/binding"
)
@PostMapping
(
"/binding"
)
public
Object
binding
(
@RequestBody
BindingVo
bindingVo
){
public
Object
binding
(
@RequestBody
BindingVo
bindingVo
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
//获取gateWay的信息
//获取gateWay的信息
ResultGatewayVo
resultGatewayVo
=
gatewayService
.
getBySNAndType
(
bindingVo
.
getSN
(),
bindingVo
.
getType
());
ResultGatewayVo
resultGatewayVo
=
gatewayService
.
getBySNAndType
(
bindingVo
.
getSN
(),
bindingVo
.
getType
());
if
(
resultGatewayVo
.
getUseScene
()
!=
0
&&
resultGatewayVo
.
getUseScene
()
!=
bindingVo
.
getMode
()){
if
(
resultGatewayVo
.
getUseScene
()
!=
0
&&
resultGatewayVo
.
getUseScene
()
!=
bindingVo
.
getMode
()){
...
@@ -119,7 +127,7 @@ public class EquipmentBindingController {
...
@@ -119,7 +127,7 @@ public class EquipmentBindingController {
fb
.
setCode
(
1
);
fb
.
setCode
(
1
);
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
//根据报警类型货报警信息
//根据报警类型货报警信息
ResultAlarmVo
alarmVo
=
alarmService
.
getByTypeAndScene
(
bindingVo
.
getAlarmType
(),
"运输"
);
ResultAlarmVo
alarmVo
=
alarmService
.
getByTypeAndScene
(
bindingVo
.
getAlarmType
(),
"运输"
,
user
.
getCompanyName
()
);
for
(
String
alias
:
list
){
for
(
String
alias
:
list
){
List
<
AlarmRuleVo
>
alarmRuleVos
=
new
ArrayList
<>();
List
<
AlarmRuleVo
>
alarmRuleVos
=
new
ArrayList
<>();
AlarmRuleVo
alarmRuleVo
=
new
AlarmRuleVo
();
AlarmRuleVo
alarmRuleVo
=
new
AlarmRuleVo
();
...
...
src/main/resources/application.properties
View file @
5341dd21
spring.datasource.url
=
jdbc:mysql://1
92.168.1.16
:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.url
=
jdbc:mysql://1
27.0.0.1
:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username
=
root
spring.datasource.username
=
root
spring.datasource.password
=
37774020
spring.datasource.password
=
root
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
threadpool.corepoolsize
=
30
threadpool.corepoolsize
=
30
...
...
src/main/resources/mapper/AlarmMapper.xml
View file @
5341dd21
...
@@ -2,14 +2,18 @@
...
@@ -2,14 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.example.tdl.mapper.AlarmMapper"
>
<mapper
namespace=
"com.example.tdl.mapper.AlarmMapper"
>
<!--查询所有预警信息-->
<!--查询所有预警信息-->
<select
id=
"getAll"
resultType=
"com.example.tdl.domain.vo.ResultAlarmVo"
>
<select
id=
"getAll"
resultType=
"com.example.tdl.domain.vo.ResultAlarmVo"
parameterType=
"String"
>
SELECT alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark from alarm
SELECT alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
from alarm a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR}
</select>
</select>
<!--根据预警类型模糊查询-->
<!--根据预警类型模糊查询-->
<select
id=
"getAllByAlarmType"
resultType=
"com.example.tdl.domain.vo.ResultAlarmVo"
parameterType=
"String"
>
<select
id=
"getAllByAlarmType"
resultType=
"com.example.tdl.domain.vo.ResultAlarmVo"
parameterType=
"String"
>
SELECT alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark from alarm
SELECT alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
WHERE alarmType LIKE CONCAT(CONCAT('%',#{alarmType,jdbcType=VARCHAR}), '%')
from alarm a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR}
AND alarmType LIKE CONCAT(CONCAT('%',#{alarmType,jdbcType=VARCHAR}), '%')
</select>
</select>
<!--添加预警信息-->
<!--添加预警信息-->
...
@@ -24,6 +28,7 @@
...
@@ -24,6 +28,7 @@
#{humidityMin,jdbcType=FLOAT},
#{humidityMin,jdbcType=FLOAT},
#{tilt,jdbcType=FLOAT},
#{tilt,jdbcType=FLOAT},
#{shock,jdbcType=VARCHAR},
#{shock,jdbcType=VARCHAR},
(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR}),
#{remark,jdbcType=VARCHAR}
#{remark,jdbcType=VARCHAR}
)
)
</insert>
</insert>
...
@@ -42,26 +47,32 @@
...
@@ -42,26 +47,32 @@
remark=#{remark,jdbcType=VARCHAR}
remark=#{remark,jdbcType=VARCHAR}
WHERE alarmType=#{oldAlarmType,jdbcType=VARCHAR}
WHERE alarmType=#{oldAlarmType,jdbcType=VARCHAR}
AND alarmScene=#{oldAlarmScene,jdbcType=VARCHAR}
AND alarmScene=#{oldAlarmScene,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</update>
</update>
<!--删除预警信息-->
<!--删除预警信息-->
<delete
id=
"delAlarm"
parameterType=
"com.example.tdl.domain.vo.DelAlarmVo"
>
<delete
id=
"delAlarm"
parameterType=
"com.example.tdl.domain.vo.DelAlarmVo"
>
DELETE from alarm WHERE alarmType=#{alarmType,jdbcType=VARCHAR} AND alarmScene=#{alarmScene,jdbcType=VARCHAR}
DELETE from alarm WHERE alarmType=#{alarmType,jdbcType=VARCHAR}
AND alarmScene=#{alarmScene,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</delete>
</delete>
<!--根据预警类型和预警场景查询-->
<!--根据预警类型和预警场景查询-->
<select
id=
"getByTypeAndScene"
parameterType=
"String"
resultType=
"com.example.tdl.domain.vo.ResultAlarmVo"
>
<select
id=
"getByTypeAndScene"
parameterType=
"String"
resultType=
"com.example.tdl.domain.vo.ResultAlarmVo"
>
SELECT alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark from alarm
SELECT alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
WHERE alarmType=#{alarmType,jdbcType=VARCHAR} AND alarmScene=#{alarmScene,jdbcType=VARCHAR}
from alarm a INNER JOIN company c ON a.company_id=c.id
WHERE c.companyName=#{companyName,jdbcType=VARCHAR}
AND alarmType=#{alarmType,jdbcType=VARCHAR}
AND alarmScene=#{alarmScene,jdbcType=VARCHAR}
</select>
</select>
<!--查询仓库的预警类型-->
<!--查询仓库的预警类型-->
<select
id=
"getForWarehouse"
resultType=
"String"
>
<select
id=
"getForWarehouse"
resultType=
"String"
>
SELECT alarmType from alarm WHERE alarmScene="仓库"
SELECT alarmType from alarm WHERE alarmScene="仓库"
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select>
</select>
<!--查询仓库的预警类型-->
<!--查询仓库的预警类型-->
<select
id=
"getForTransportation"
resultType=
"String"
>
<select
id=
"getForTransportation"
resultType=
"String"
>
SELECT alarmType from alarm WHERE alarmScene="运输"
SELECT alarmType from alarm WHERE alarmScene="运输"
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
</select>
</select>
</mapper>
</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