Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
fmboot
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
0dbf5212
由
张雷
编写于
2024-02-02 17:27:44 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
奥体项目数据问题修改
1 个父辈
efd7ebc2
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
213 行增加
和
1 行删除
fm-product/src/main/java/com/skua/modules/business/service/impl/OlympicCenterServiceImpl.java
fm-product/src/main/java/com/skua/modules/location/service/impl/YwLocationServiceImpl.java
fm-system/src/main/java/com/skua/modules/quartz/job/SyncHnjzDataJob.java
fm-product/src/main/java/com/skua/modules/business/service/impl/OlympicCenterServiceImpl.java
查看文件 @
0dbf521
...
...
@@ -1415,6 +1415,16 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
map
.
put
(
"name"
,
whatStructData
.
getMonitorName
());
map
.
put
(
"time"
,
""
);
map
.
put
(
"value"
,
""
);
for
(
Map
<
String
,
Object
>
mMap
:
monitorList
)
{
if
(
whatStructData
.
getMonitorId
()!=
null
){
if
(
whatStructData
.
getMonitorId
().
equals
(
mMap
.
get
(
"monitorid"
))){
map
.
put
(
"time"
,
timeStampToDateStr
(
mMap
.
get
(
"time"
)));
map
.
put
(
"value"
,
formatDouble
(
Double
.
parseDouble
(
mMap
.
get
(
"monitorvalue"
).
toString
())*
Double
.
parseDouble
(
whatStructData
.
getMonitorZoom
())));
}
}
else
{
break
;
}
}
list
.
add
(
map
);
}
}
else
{
...
...
fm-product/src/main/java/com/skua/modules/location/service/impl/YwLocationServiceImpl.java
查看文件 @
0dbf521
...
...
@@ -119,7 +119,7 @@ public class YwLocationServiceImpl implements ILocationService {
userBaseInfo
.
setUserType
(
"员工"
);
if
(
onlineMap
.
get
(
userBaseInfoYwResult
.
getDeviceno
())!=
null
){
userBaseInfo
.
setUserStatus
(
"1"
);
UserLocation
userLocation
=
JSON
.
parseObject
(
onlineMap
.
get
(
userBaseInfoYwResult
.
getDeviceno
()).
toString
(
),
UserLocation
.
class
);
UserLocation
userLocation
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
onlineMap
.
get
(
userBaseInfoYwResult
.
getDeviceno
())
),
UserLocation
.
class
);
userBaseInfo
.
setX
(
userLocation
.
getX
());
userBaseInfo
.
setY
(
userLocation
.
getY
());
userBaseInfo
.
setFloor
(
userLocation
.
getFloor
());
...
...
fm-system/src/main/java/com/skua/modules/quartz/job/SyncHnjzDataJob.java
0 → 100644
查看文件 @
0dbf521
package
com
.
skua
.
modules
.
quartz
.
job
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.Method
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.skua.core.cache.RedisUtil
;
import
com.skua.core.context.SpringContextUtils
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.quartz.Job
;
import
org.quartz.JobExecutionContext
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Map
;
import
java.util.Random
;
/**
* 同步河南焦作采集数据
*/
@Slf4j
public
class
SyncHnjzDataJob
implements
Job
{
// private static final String HNJZ_URL = "https://399w65q886.oicp.vip/parsing/api/RiverMonitoring/RiverwayHXW";//河南焦作数据同步地址-测试
private
static
final
String
HNJZ_URL
=
"http://123.60.20.81:9876/parsing/api/RiverMonitoring/RiverwayHXW"
;
//河南焦作数据同步地址-正式
@Autowired
private
RedisUtil
redisUtil
;
//格式化时间
private
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
private
String
parameter
;
public
void
setParameter
(
String
parameter
)
{
this
.
parameter
=
parameter
;
}
@SneakyThrows
@Override
public
void
execute
(
JobExecutionContext
jobExecutionContext
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
String
cjDateTime
=
now
.
format
(
formatter
);
log
.
info
(
String
.
format
(
" 同步河南焦作采集数据 ! 时间:"
+
cjDateTime
));
JdbcTemplate
hxDB
=
(
JdbcTemplate
)
SpringContextUtils
.
getBean
(
"mysql-hx"
);
String
sql
=
"SELECT "
+
" id,\n"
+
" create_by as createBy,\n"
+
" create_time as createTime,\n"
+
" update_by as updateBy,\n"
+
" update_time as updateTime,\n"
+
" sys_org_code as sysOrgCode,\n"
+
" del_flag as delFlag,\n"
+
" eqm_id as eqmId,\n"
+
" eqm_no as eqmNo,\n"
+
" eqm_name as eqmName,\n"
+
" project_id as projectId,\n"
+
" area_id as areaId,\n"
+
" temperature,\n"
+
" humidity,\n"
+
" battery,\n"
+
" rssi,\n"
+
" sinr,\n"
+
" batpercent,\n"
+
" datatype1,\n"
+
" datavalue1,\n"
+
" newdatavalue1,\n"
+
" datatype2,\n"
+
" datavalue2,\n"
+
" newdatavalue2,\n"
+
" datatype3,\n"
+
" datavalue3,\n"
+
" newdatavalue3,\n"
+
" datatype4,\n"
+
" datavalue4,\n"
+
" newdatavalue4,\n"
+
" collect_time as collectTime,\n"
+
" remark,\n"
+
" platform_id as platformId,\n"
+
" tcp_flag as tcpFlag,\n"
+
" datatype5,\n"
+
" datavalue5,\n"
+
" datatype6,\n"
+
" datavalue6,\n"
+
" datatype7,\n"
+
" datavalue7,\n"
+
" datatype8,\n"
+
" datavalue8,\n"
+
" light,\n"
+
" lat,\n"
+
" lng,\n"
+
" x_axis as xAxis,\n"
+
" y_axis as yAxis,\n"
+
" hostch_no as hostchNo\n"
+
" FROM\n"
+
" dcs_current_info \n"
+
" WHERE\n"
+
" platform_id = 'JJ202309250005' \n"
+
" ORDER BY\n"
+
" create_time DESC \n"
+
" LIMIT 1"
;
Map
<
String
,
Object
>
map
=
hxDB
.
queryForMap
(
sql
);
if
(
"mn"
.
equals
(
this
.
parameter
)){
map
.
put
(
"id"
,
null
);
map
.
put
(
"temperature"
,
randomZhengShu
(
17
,
19
));
map
.
put
(
"humidity"
,
randomZhengShu
(
50
,
60
));
map
.
put
(
"battery"
,
randomXiaoShu
(
7.00
,
8.00
));
map
.
put
(
"rssi"
,
randomZhengShu
(-
113
,-
100
));
map
.
put
(
"sinr"
,
randomZhengShu
(
20
,
26
));
map
.
put
(
"batpercent"
,
randomZhengShu
(
60
,
100
));
map
.
put
(
"datatype1"
,
1
);
double
datavalue1
=
randomXiaoShu
(
0.03
,
0.06
);
map
.
put
(
"datavalue1"
,
datavalue1
);
map
.
put
(
"newdatavalue1"
,
datavalue1
);
map
.
put
(
"datatype2"
,
2
);
double
datavalue2
=
randomXiaoShu
(
0.01
,
0.015
);
map
.
put
(
"datavalue2"
,
datavalue2
);
map
.
put
(
"newdatavalue2"
,
datavalue2
);
map
.
put
(
"dataValueSsll"
,
calculateLS
(
datavalue1
,
datavalue2
,
1.65
));
map
.
put
(
"collectTime"
,
cjDateTime
);
map
.
put
(
"createTime"
,
cjDateTime
);
map
.
put
(
"updateTime"
,
cjDateTime
);
map
.
put
(
"light"
,
randomXiaoShu
(
3.00
,
4.00
));
map
.
put
(
"remark"
,
null
);
log
.
info
(
"河南焦作数据同步请求参数为:"
+
map
);
}
else
{
if
(
map
.
size
()
>
0
){
String
collectTime
=
map
.
get
(
"collectTime"
).
toString
();
double
yw
=
0.00
;
double
ls
=
0.00
;
if
(
map
.
get
(
"datavalue1"
)!=
null
){
yw
=
Double
.
parseDouble
(
map
.
get
(
"datavalue1"
).
toString
());
}
if
(
map
.
get
(
"datavalue2"
)!=
null
){
ls
=
Double
.
parseDouble
(
map
.
get
(
"datavalue2"
).
toString
());
}
map
.
put
(
"dataValueSsll"
,
calculateLS
(
yw
,
ls
,
1.65
));
String
key
=
"hnjz-"
+
collectTime
;
Object
code
=
redisUtil
.
get
(
key
);
if
(
code
==
null
){
redisUtil
.
set
(
key
,
map
);
log
.
info
(
"河南焦作数据同步请求参数为("
+
key
+
"):"
+
map
);
}
}
}
ObjectMapper
mapper
=
new
ObjectMapper
();
String
json
=
mapper
.
writeValueAsString
(
map
);
HttpRequest
request
=
HttpUtil
.
createPost
(
HNJZ_URL
);
request
.
contentType
(
"application/json"
);
request
.
body
(
json
);
String
post
=
request
.
execute
().
body
();
log
.
info
(
"回复的消息为:"
+
post
);
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"随机数:"
+
calculateLS
(
0.03
,
0.015
,
1.65
));
}
public
static
int
randomZhengShu
(
int
min
,
int
max
){
Random
random
=
new
Random
();
int
randomNumber
=
random
.
nextInt
(
max
-
min
+
1
)
+
min
;
return
randomNumber
;
}
public
static
double
randomXiaoShu
(
double
min
,
double
max
){
Random
random
=
new
Random
();
double
randomNumber
=
min
+
(
max
-
min
)
*
random
.
nextDouble
();
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"#.###"
);
String
formattedNumber
=
decimalFormat
.
format
(
randomNumber
);
return
Double
.
parseDouble
(
formattedNumber
);
}
/**
* 流量计算
* @param currentValue
* @param speedValue
* @param tubedia
* @return
*/
public
static
String
calculateLS
(
double
currentValue
,
double
speedValue
,
double
tubedia
)
{
double
H
=
currentValue
;
//水深(液位),计算流量的设备一定会同时上传流速speed(单位m/s)和液位值level(单位m/s)
double
D
=
tubedia
;
//圆管直径diam,单位m
double
R
=
D
/
2
;
//管道半径
double
S
=
0
;
//圆管截面积
if
(
H
>=
D
)
{
S
=
Math
.
PI
*
R
*
R
;
}
else
if
(
H
<=
R
)
{
double
ang
=
Math
.
acos
((
R
-
H
)
/
R
)
*
R
*
R
;
S
=
ang
-
Math
.
sqrt
(
R
*
R
-
(
R
-
H
)
*
(
R
-
H
))
*
Math
.
abs
(
R
-
H
);
}
else
if
(
R
<
H
&&
H
<
D
)
{
double
ang
=
Math
.
acos
((
R
-
H
)
/
R
)
*
R
*
R
;
S
=
ang
+
Math
.
sqrt
(
R
*
R
-
(
R
-
H
)
*
(
R
-
H
))
*
Math
.
abs
(
R
-
H
);
}
//计算瞬时流量flow,单位m3/s
DecimalFormat
df
=
new
DecimalFormat
(
"#.####"
);
return
df
.
format
(
speedValue
*
S
);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论