Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skreceive
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
a4031a6d
由
张雷
编写于
2022-10-02 11:06:01 +0800
浏览文件
选项
浏览文件
标签
下载
差异文件
Merge remote-tracking branch 'origin/dev' into dev
2 个父辈
043edb56
ee2216dd
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
144 行增加
和
17 行删除
src/main/java/com/jkdata/controller/ThirdController.java
src/main/java/com/jkdata/entity/HistoryPoint.java
src/main/java/com/jkdata/entity/SafeArea.java
src/main/java/com/jkdata/service/IThirdService.java
src/main/java/com/jkdata/service/impl/IThirdServiceImpl.java
src/main/java/com/jkdata/tool/StringsUtil.java
src/main/java/com/jkdata/controller/ThirdController.java
查看文件 @
a4031a6
...
...
@@ -2,6 +2,8 @@ package com.jkdata.controller;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jkdata.entity.HistoryPoint
;
import
com.jkdata.entity.SafeArea
;
import
com.jkdata.entity.ThirdPosition
;
import
com.jkdata.service.IThirdService
;
import
com.jkdata.tool.Result
;
...
...
@@ -12,6 +14,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedReader
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
...
...
@@ -106,12 +109,11 @@ public class ThirdController {
* @return
*/
@GetMapping
(
"/positionByDeviceId"
)
public
Result
<
JSONObject
>
getPositionByDeviceId
(
String
deviceId
,
String
startTime
,
String
endTime
)
{
Result
<
JSONObject
>
result
=
new
Result
<
JSONObject
>();
String
res
=
thirdService
.
getPositionByDeviceId
(
deviceId
,
startTime
,
endTime
);
JSONObject
json
=
JSONObject
.
parseObject
(
res
);
public
Result
<
List
<
HistoryPoint
>>
getPositionByDeviceId
(
String
deviceId
,
String
startTime
,
String
endTime
)
{
Result
<
List
<
HistoryPoint
>>
result
=
new
Result
<
List
<
HistoryPoint
>>();
List
<
HistoryPoint
>
list
=
thirdService
.
getPositionByDeviceId
(
deviceId
,
startTime
,
endTime
);
result
.
setSuccess
(
true
);
result
.
setResult
(
json
);
result
.
setResult
(
list
);
return
result
;
}
...
...
@@ -144,16 +146,15 @@ public class ThirdController {
}
/**
* 获取
最近7天的告警统计数据
* 获取
安全区域
* @return
*/
@GetMapping
(
"/safeArea"
)
public
Result
<
Object
>
getSafeArea
()
{
Result
<
Object
>
result
=
new
Result
<
Object
>();
String
res
=
thirdService
.
getSafeArea
();
JSONObject
json
=
JSONObject
.
parseObject
(
res
);
public
Result
<
List
<
SafeArea
>>
getSafeArea
()
{
Result
<
List
<
SafeArea
>>
result
=
new
Result
<
List
<
SafeArea
>>();
List
<
SafeArea
>
list
=
thirdService
.
getSafeArea
();
result
.
setSuccess
(
true
);
result
.
setResult
(
json
.
get
(
"data"
)
);
result
.
setResult
(
list
);
return
result
;
}
}
...
...
src/main/java/com/jkdata/entity/HistoryPoint.java
0 → 100644
查看文件 @
a4031a6
package
com
.
jkdata
.
entity
;
import
lombok.Data
;
@Data
public
class
HistoryPoint
{
/**主键*/
private
Integer
id
;
/**楼层编码*/
private
String
floorId
;
/***/
private
Integer
number
;
/**定位时间*/
private
String
locationTime
;
/**X坐标*/
private
Double
x
;
/**名称*/
private
String
name
;
/**Y坐标*/
private
Double
y
;
/**描述*/
private
String
comment
;
/**设备ID*/
private
String
deviceId
;
/**项目编码*/
private
String
buildingId
;
}
src/main/java/com/jkdata/entity/SafeArea.java
0 → 100644
查看文件 @
a4031a6
package
com
.
jkdata
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
SafeArea
{
/**主键*/
private
Integer
id
;
/**设备ID*/
private
String
deviceIds
;
/**区域坐标*/
private
String
areas
;
/**区域名称*/
private
String
name
;
/**区域简介*/
private
String
comment
;
/**构筑物描述*/
private
Integer
threshold
;
/**项目编码*/
private
Integer
buildingId
;
/**楼层编码*/
private
Integer
floorId
;
/**报警类型*/
private
String
alarmType
;
/**创建时间*/
private
String
createTime
;
/** */
private
Integer
isSwitch
;
/** */
private
Integer
areaType
;
/** */
private
Integer
typeId
;
/** */
private
String
startTime
;
/** */
private
String
endTime
;
}
src/main/java/com/jkdata/service/IThirdService.java
查看文件 @
a4031a6
package
com
.
jkdata
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jkdata.entity.HistoryPoint
;
import
com.jkdata.entity.SafeArea
;
import
com.jkdata.entity.ThirdPosition
;
import
java.util.List
;
import
java.util.Map
;
public
interface
IThirdService
{
...
...
@@ -11,7 +14,7 @@ public interface IThirdService {
String
getBuildingAllInfo
();
String
getPositionByDeviceId
(
String
deviceId
,
String
startTime
,
String
endTime
);
List
<
HistoryPoint
>
getPositionByDeviceId
(
String
deviceId
,
String
startTime
,
String
endTime
);
String
getAlarmListByCount
();
...
...
@@ -19,5 +22,5 @@ public interface IThirdService {
ThirdPosition
getRealTimeLocation
(
String
deviceId
);
String
getSafeArea
();
List
<
SafeArea
>
getSafeArea
();
}
...
...
src/main/java/com/jkdata/service/impl/IThirdServiceImpl.java
查看文件 @
a4031a6
...
...
@@ -2,6 +2,8 @@ package com.jkdata.service.impl;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jkdata.entity.HistoryPoint
;
import
com.jkdata.entity.SafeArea
;
import
com.jkdata.tool.*
;
import
com.jkdata.entity.ThirdPosition
;
import
com.jkdata.mapper.ThirdMapper
;
...
...
@@ -135,7 +137,7 @@ public class IThirdServiceImpl implements IThirdService {
}
@Override
public
String
getPositionByDeviceId
(
String
deviceId
,
String
startTime
,
String
endTime
)
{
public
List
<
HistoryPoint
>
getPositionByDeviceId
(
String
deviceId
,
String
startTime
,
String
endTime
)
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"buildingId"
,
CommonConstant
.
BLD_ID
);
map
.
put
(
"deviceId"
,
deviceId
);
...
...
@@ -144,7 +146,17 @@ public class IThirdServiceImpl implements IThirdService {
map
.
put
(
"startTime"
,
startTime
);
map
.
put
(
"endTime"
,
endTime
);
String
post
=
HttpUtil
.
post
(
CommonConstant
.
HISTORY_URL
,
map
);
return
post
;
JSONObject
json
=
JSONObject
.
parseObject
(
post
);
List
<
HistoryPoint
>
list
=
JSONObject
.
parseArray
(
json
.
get
(
"data"
).
toString
(),
HistoryPoint
.
class
);
for
(
HistoryPoint
historyPoint
:
list
)
{
String
x1
=
String
.
valueOf
(
historyPoint
.
getX
());
String
y1
=
String
.
valueOf
(
historyPoint
.
getY
());
Map
<
String
,
Double
>
pointMap
=
new
HashMap
<>();
//初始化
pointMap
=
CoordinateUtil
.
changCoordinate
(
"B1"
,
x1
,
y1
);
historyPoint
.
setX
(
pointMap
.
get
(
"x"
));
historyPoint
.
setY
(
pointMap
.
get
(
"y"
));
}
return
list
;
}
@Override
...
...
@@ -184,9 +196,24 @@ public class IThirdServiceImpl implements IThirdService {
}
@Override
public
String
getSafeArea
()
{
public
List
<
SafeArea
>
getSafeArea
()
{
String
get
=
HttpUtil
.
get
(
CommonConstant
.
SAFE_AREA_URL
+
"?buildingId="
+
CommonConstant
.
BLD_ID
);
return
get
;
JSONObject
json
=
JSONObject
.
parseObject
(
get
);
List
<
SafeArea
>
list
=
JSONObject
.
parseArray
(
json
.
get
(
"data"
).
toString
(),
SafeArea
.
class
);
for
(
SafeArea
safeArea
:
list
)
{
String
areas
=
safeArea
.
getAreas
();
//66&363,100&348,108&367,74&381
List
<
String
>
arealist
=
Arrays
.
asList
(
areas
.
split
(
","
));
StringBuffer
data
=
new
StringBuffer
();
for
(
String
area:
arealist
)
{
String
x1
=
area
.
split
(
"&"
)[
0
];
String
y1
=
area
.
split
(
"&"
)[
1
];
Map
<
String
,
Double
>
map
=
new
HashMap
<>();
//初始化
map
=
CoordinateUtil
.
changCoordinate
(
"B1"
,
x1
,
y1
);
data
.
append
(
String
.
valueOf
(
map
.
get
(
"x"
))+
"&"
+
String
.
valueOf
(
map
.
get
(
"y"
))).
append
(
","
);
}
safeArea
.
setAreas
(
data
.
toString
().
substring
(
0
,
data
.
toString
().
length
()-
1
));
}
return
list
;
}
...
...
src/main/java/com/jkdata/tool/StringsUtil.java
0 → 100644
查看文件 @
a4031a6
package
com
.
jkdata
.
tool
;
import
java.lang.reflect.Field
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
class
StringsUtil
{
//Object转Map
public
static
Map
<
String
,
Object
>
getObjectToMap
(
Object
obj
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<
String
,
Object
>();
try
{
Class
<?>
clazz
=
obj
.
getClass
();
for
(
Field
field
:
clazz
.
getDeclaredFields
())
{
field
.
setAccessible
(
true
);
String
fieldName
=
field
.
getName
();
Object
value
=
field
.
get
(
obj
);
if
(
value
==
null
)
{
value
=
""
;
}
map
.
put
(
fieldName
,
value
);
}
return
map
;
}
catch
(
Exception
e
){
return
new
LinkedHashMap
<
String
,
Object
>();
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论