Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
fmboot
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
a30d7c24
由
张雷
编写于
2023-05-24 23:32:51 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
奥体项目实时数据接口修改
1 个父辈
7a86522a
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
733 行增加
和
44 行删除
fm-product/src/main/java/com/skua/modules/business/controller/OlympicCenterController.java
fm-product/src/main/java/com/skua/modules/business/mapper/WhatStructDataMapper.java
fm-product/src/main/java/com/skua/modules/business/mapper/xml/WhatStructDataMapper.xml
fm-product/src/main/java/com/skua/modules/business/service/IOlympicCenterService.java
fm-product/src/main/java/com/skua/modules/business/service/impl/OlympicCenterServiceImpl.java
fm-product/src/main/java/com/skua/modules/location/controller/UserLocationController.java
fm-product/src/main/java/com/skua/modules/location/service/ILocationService.java
fm-product/src/main/java/com/skua/modules/location/service/impl/BkyhLocationServiceImpl.java
fm-product/src/main/java/com/skua/modules/location/service/impl/YwLocationServiceImpl.java
fm-product/src/main/java/com/skua/modules/location/vo/QueryParams.java
fm-product/src/main/java/com/skua/modules/monitor/service/IFmPgQueryService.java
fm-product/src/main/java/com/skua/modules/monitor/service/impl/FmPgQueryServiceImpl.java
fm-system/pom.xml
fm-system/src/main/resources/application-dev.yml
fm-system/src/main/resources/application-prod.yml
fm-system/src/main/resources/application-what.yml
fm-system/src/main/resources/application-yw.yml
fm-product/src/main/java/com/skua/modules/business/controller/OlympicCenterController.java
查看文件 @
a30d7c2
...
...
@@ -39,6 +39,16 @@ public class OlympicCenterController {
return
result
;
}
@ApiOperation
(
value
=
"获取整体实时数据"
,
notes
=
"获取整体实时数据"
)
@GetMapping
(
value
=
"/getRealTimeDataNew"
)
public
Result
<
Map
<
String
,
Object
>>
getRealTimeDataNew
(
String
sourceType
){
Result
<
Map
<
String
,
Object
>>
result
=
new
Result
<
Map
<
String
,
Object
>>();
Map
<
String
,
Object
>
map
=
olympicCenterService
.
getRealTimeDataNew
(
sourceType
);
result
.
setResult
(
map
);
result
.
setSuccess
(
true
);
return
result
;
}
@ApiOperation
(
value
=
"获取整体实时数据给UE"
,
notes
=
"获取整体实时数据给UE"
)
@GetMapping
(
value
=
"/getRealTimeDataToUE"
)
public
Result
<
Map
<
String
,
Object
>>
getRealTimeDataToUE
(){
...
...
@@ -49,6 +59,16 @@ public class OlympicCenterController {
return
result
;
}
@ApiOperation
(
value
=
"获取整体实时数据给UE"
,
notes
=
"获取整体实时数据给UE"
)
@GetMapping
(
value
=
"/getRealTimeDataToUENew"
)
public
Result
<
Map
<
String
,
Object
>>
getRealTimeDataToUENew
(){
Result
<
Map
<
String
,
Object
>>
result
=
new
Result
<
Map
<
String
,
Object
>>();
Map
<
String
,
Object
>
map
=
olympicCenterService
.
getRealTimeDataToUENew
();
result
.
setResult
(
map
);
result
.
setSuccess
(
true
);
return
result
;
}
/**
* 获取泵站指标历史趋势曲线
* @param field ssll:瞬时流量 ljll:累计流量 rll:日流量
...
...
@@ -108,4 +128,15 @@ public class OlympicCenterController {
return
result
;
}
@ApiOperation
(
value
=
"获取趋势图"
,
notes
=
"获取趋势图"
)
@GetMapping
(
value
=
"/getPressureChartNew"
)
public
Result
<
List
<
EchartResult
>>
getPressureChartNew
(
String
equipId
,
String
type
){
Result
<
List
<
EchartResult
>>
result
=
new
Result
<
List
<
EchartResult
>>();
List
<
EchartResult
>
list
=
new
ArrayList
<
EchartResult
>();
list
=
olympicCenterService
.
getPressureChartNew
(
equipId
,
type
);
result
.
setResult
(
list
);
result
.
setSuccess
(
true
);
return
result
;
}
}
...
...
fm-product/src/main/java/com/skua/modules/business/mapper/WhatStructDataMapper.java
查看文件 @
a30d7c2
...
...
@@ -15,4 +15,10 @@ public interface WhatStructDataMapper {
List
<
WhatStructData
>
getListForUE
();
WhatStructData
getOneById
(
@Param
(
"id"
)
String
id
);
List
<
WhatStructData
>
getListByType
(
@Param
(
"sourceType"
)
String
sourceType
);
List
<
WhatStructData
>
getDataList
(
@Param
(
"equipId"
)
String
equipId
);
List
<
WhatStructData
>
getListForUENew
();
}
...
...
fm-product/src/main/java/com/skua/modules/business/mapper/xml/WhatStructDataMapper.xml
查看文件 @
a30d7c2
...
...
@@ -14,4 +14,23 @@
select * from what_struct_data where id = #{id} limit 1
</select>
<select
id=
"getListByType"
resultType=
"com.skua.modules.business.entity.WhatStructData"
>
select * from what_struct_data_bak
where 1=1
<if
test=
"sourceType!=null and sourceType!=''"
>
and system_code = #{sourceType}
</if>
order by monitor_sort
</select>
<select
id=
"getDataList"
resultType=
"com.skua.modules.business.entity.WhatStructData"
>
select * from what_struct_data_bak
where id LIKE CONCAT( #{equipId},'%')
order by monitor_sort
</select>
<select
id=
"getListForUENew"
resultType=
"com.skua.modules.business.entity.WhatStructData"
>
select * from what_struct_data_bak order by monitor_sort
</select>
</mapper>
\ No newline at end of file
...
...
fm-product/src/main/java/com/skua/modules/business/service/IOlympicCenterService.java
查看文件 @
a30d7c2
...
...
@@ -21,4 +21,10 @@ public interface IOlympicCenterService {
Map
<
String
,
Object
>
getBzRealTimeData
(
String
sourceType
);
Map
<
String
,
Object
>
getRealTimeDataToUE
();
Map
<
String
,
Object
>
getRealTimeDataNew
(
String
sourceType
);
List
<
EchartResult
>
getPressureChartNew
(
String
equipId
,
String
type
);
Map
<
String
,
Object
>
getRealTimeDataToUENew
();
}
...
...
fm-product/src/main/java/com/skua/modules/business/service/impl/OlympicCenterServiceImpl.java
查看文件 @
a30d7c2
package
com
.
skua
.
modules
.
business
.
service
.
impl
;
import
com.skua.core.service.IFactoryInfoService
;
import
com.skua.core.service.IPgQueryService
;
import
com.skua.modules.business.entity.WhatStructData
;
import
com.skua.modules.business.mapper.WhatStructDataMapper
;
import
com.skua.modules.business.service.IOlympicCenterService
;
import
com.skua.modules.business.vo.EchartResult
;
import
com.skua.modules.business.vo.TextResult
;
import
com.skua.modules.monitor.service.IFmPgQueryService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -24,7 +24,7 @@ import java.util.*;
public
class
OlympicCenterServiceImpl
implements
IOlympicCenterService
{
@Autowired
private
I
PgQueryService
p
gQueryService
;
private
I
FmPgQueryService
fmP
gQueryService
;
@Autowired
private
IFactoryInfoService
factoryInfoService
;
//queryReportData
...
...
@@ -39,7 +39,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
Map
<
String
,
Object
>
monitorMap
=
new
HashMap
<>();
List
<
WhatStructData
>
pybList
=
new
ArrayList
<>();
List
<
WhatStructData
>
fybList
=
new
ArrayList
<>();
List
<
WhatStructData
>
lj
b
List
=
new
ArrayList
<>();
List
<
WhatStructData
>
ljList
=
new
ArrayList
<>();
List
<
WhatStructData
>
wybList
=
new
ArrayList
<>();
List
<
TextResult
>
pList
=
new
ArrayList
<>();
List
<
TextResult
>
fList
=
new
ArrayList
<>();
...
...
@@ -57,7 +57,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
else
if
(
"flow"
.
equals
(
whatStructData
.
getEquipType
())){
fybList
.
add
(
whatStructData
);
}
else
if
(
"flow_ljll"
.
equals
(
whatStructData
.
getEquipType
())){
lj
b
List
.
add
(
whatStructData
);
ljList
.
add
(
whatStructData
);
}
else
if
(
"temperature"
.
equals
(
whatStructData
.
getEquipType
())){
wybList
.
add
(
whatStructData
);
}
else
{
}
...
...
@@ -65,7 +65,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
}
}
List
<
Map
<
String
,
Object
>>
monitorList
=
p
gQueryService
.
queryFactoryMonitorFromRealTimeData
(
AT_ID
,
pgField
);
List
<
Map
<
String
,
Object
>>
monitorList
=
fmP
gQueryService
.
queryFactoryMonitorFromRealTimeData
(
AT_ID
,
pgField
);
if
(
monitorList
.
size
()==
1
){
monitorMap
=
monitorList
.
get
(
0
);
if
(
"feed"
.
equals
(
sourceType
)){
//压力14流量8
...
...
@@ -102,12 +102,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
for
(
int
k
=
0
;
k
<
8
;
k
++)
{
TextResult
textResult
=
new
TextResult
();
if
(
k
<
lj
b
List
.
size
()){
textResult
.
setTitle
(
lj
b
List
.
get
(
k
).
getId
());
if
(
monitorMap
.
get
(
lj
b
List
.
get
(
k
).
getMonitorId
())==
null
){
if
(
k
<
ljList
.
size
()){
textResult
.
setTitle
(
ljList
.
get
(
k
).
getId
());
if
(
monitorMap
.
get
(
ljList
.
get
(
k
).
getMonitorId
())==
null
){
textResult
.
setValue
(
"--"
);
}
else
{
textResult
.
setValue
(
monitorMap
.
get
(
lj
b
List
.
get
(
k
).
getMonitorId
()).
toString
());
textResult
.
setValue
(
monitorMap
.
get
(
ljList
.
get
(
k
).
getMonitorId
()).
toString
());
}
}
else
{
textResult
.
setTitle
(
"flow_ljll"
+(
k
+
1
));
...
...
@@ -151,12 +151,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
for
(
int
h
=
0
;
h
<
4
;
h
++)
{
TextResult
textResult
=
new
TextResult
();
if
(
h
<
lj
b
List
.
size
()){
textResult
.
setTitle
(
lj
b
List
.
get
(
h
).
getId
());
if
(
monitorMap
.
get
(
lj
b
List
.
get
(
h
).
getMonitorId
())==
null
){
if
(
h
<
ljList
.
size
()){
textResult
.
setTitle
(
ljList
.
get
(
h
).
getId
());
if
(
monitorMap
.
get
(
ljList
.
get
(
h
).
getMonitorId
())==
null
){
textResult
.
setValue
(
"--"
);
}
else
{
textResult
.
setValue
(
monitorMap
.
get
(
lj
b
List
.
get
(
h
).
getMonitorId
()).
toString
());
textResult
.
setValue
(
monitorMap
.
get
(
ljList
.
get
(
h
).
getMonitorId
()).
toString
());
}
}
else
{
textResult
.
setTitle
(
"flow_ljll"
+(
h
+
1
));
...
...
@@ -216,12 +216,12 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
}
for
(
int
k
=
0
;
k
<
2
;
k
++)
{
TextResult
textResult
=
new
TextResult
();
if
(
k
<
lj
b
List
.
size
()){
textResult
.
setTitle
(
lj
b
List
.
get
(
k
).
getId
());
if
(
monitorMap
.
get
(
lj
b
List
.
get
(
k
).
getMonitorId
())==
null
){
if
(
k
<
ljList
.
size
()){
textResult
.
setTitle
(
ljList
.
get
(
k
).
getId
());
if
(
monitorMap
.
get
(
ljList
.
get
(
k
).
getMonitorId
())==
null
){
textResult
.
setValue
(
"--"
);
}
else
{
textResult
.
setValue
(
monitorMap
.
get
(
lj
b
List
.
get
(
k
).
getMonitorId
()).
toString
());
textResult
.
setValue
(
monitorMap
.
get
(
ljList
.
get
(
k
).
getMonitorId
()).
toString
());
}
}
else
{
textResult
.
setTitle
(
"flow_ljll"
+(
k
+
1
));
...
...
@@ -403,9 +403,9 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
list
.
add
(
echartResult
);
}
}
else
{
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
Calendar
date
=
Calendar
.
getInstance
();
date
.
add
(
Calendar
.
DATE
,
i
-
30
);
date
.
add
(
Calendar
.
DATE
,
i
-
7
);
String
newDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
date
.
getTime
()).
substring
(
5
,
10
);
EchartResult
echartResult
=
new
EchartResult
();
echartResult
.
setName
(
newDate
);
...
...
@@ -524,7 +524,7 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
for
(
WhatStructData
whatStructData:
list
)
{
pgField
=
pgField
+
","
+
whatStructData
.
getMonitorId
();
}
List
<
Map
<
String
,
Object
>>
monitorList
=
p
gQueryService
.
queryFactoryMonitorFromRealTimeData
(
AT_ID
,
pgField
);
List
<
Map
<
String
,
Object
>>
monitorList
=
fmP
gQueryService
.
queryFactoryMonitorFromRealTimeData
(
AT_ID
,
pgField
);
if
(
monitorList
.
size
()==
1
){
monitorMap
=
monitorList
.
get
(
0
);
for
(
WhatStructData
whatStructData:
list
)
{
...
...
@@ -547,6 +547,460 @@ public class OlympicCenterServiceImpl implements IOlympicCenterService {
return
map
;
}
@Override
public
Map
<
String
,
Object
>
getRealTimeDataNew
(
String
sourceType
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
WhatStructData
>
list
=
whatStructDataMapper
.
getListByType
(
sourceType
);
Map
<
String
,
Object
>
monitorMap
=
new
HashMap
<>();
List
<
WhatStructData
>
pybList
=
new
ArrayList
<>();
List
<
WhatStructData
>
fybList
=
new
ArrayList
<>();
List
<
WhatStructData
>
ljList
=
new
ArrayList
<>();
List
<
WhatStructData
>
wybList
=
new
ArrayList
<>();
List
<
TextResult
>
pList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
fList
=
new
ArrayList
<>();
List
<
TextResult
>
wList
=
new
ArrayList
<>();
String
pgField
=
""
;
if
(
sourceType
==
null
){
for
(
WhatStructData
whatStructData:
list
)
{
pgField
=
pgField
+
","
+
whatStructData
.
getMonitorId
();
}
}
else
{
for
(
WhatStructData
whatStructData:
list
)
{
if
(
sourceType
.
equals
(
whatStructData
.
getSystemCode
())){
if
(
"pressure"
.
equals
(
whatStructData
.
getEquipType
())){
pybList
.
add
(
whatStructData
);
}
else
if
(
"flow"
.
equals
(
whatStructData
.
getEquipType
())){
fybList
.
add
(
whatStructData
);
}
else
if
(
"flow_ljll"
.
equals
(
whatStructData
.
getEquipType
())||
"flow_rljll"
.
equals
(
whatStructData
.
getEquipType
())){
ljList
.
add
(
whatStructData
);
}
else
if
(
"temperature"
.
equals
(
whatStructData
.
getEquipType
())){
wybList
.
add
(
whatStructData
);
}
else
{
}
pgField
=
pgField
+
","
+
whatStructData
.
getMonitorId
();
}
}
}
List
<
Map
<
String
,
Object
>>
monitorList
=
fmPgQueryService
.
queryFactoryMonitorFromRealTimeData
(
AT_ID
,
pgField
);
if
(
monitorList
.
size
()==
1
){
monitorMap
=
monitorList
.
get
(
0
);
if
(
"feed"
.
equals
(
sourceType
)){
//压力14流量8
for
(
int
i
=
0
;
i
<
14
;
i
++)
{
TextResult
textResult
=
new
TextResult
();
if
(
i
<
pybList
.
size
()){
textResult
.
setTitle
(
pybList
.
get
(
i
).
getId
());
if
(
monitorMap
.
get
(
pybList
.
get
(
i
).
getMonitorId
())==
null
){
textResult
.
setValue
(
"--"
);
}
else
{
double
pResult
=
formatDouble
(
Double
.
parseDouble
(
monitorMap
.
get
(
pybList
.
get
(
i
).
getMonitorId
()).
toString
())/
100
);
textResult
.
setValue
(
String
.
valueOf
(
pResult
));
}
}
else
{
textResult
.
setTitle
(
"pressure"
+(
i
+
1
));
textResult
.
setValue
(
"--"
);
}
pList
.
add
(
i
,
textResult
);
}
for
(
int
j
=
0
;
j
<
8
;
j
++)
{
Map
<
String
,
Object
>
fMap
=
new
HashMap
<>();
List
<
TextResult
>
flowList
=
new
ArrayList
<>();
TextResult
flow
=
new
TextResult
();
TextResult
fFlow
=
new
TextResult
();
TextResult
rFlow
=
new
TextResult
();
if
(
j
<
fybList
.
size
()){
flow
.
setTitle
(
fybList
.
get
(
j
).
getEquipType
());
if
(
fybList
.
get
(
j
).
getMonitorId
()!=
null
){
flow
.
setValue
(
monitorMap
.
get
(
fybList
.
get
(
j
).
getMonitorId
()).
toString
());
flowList
.
add
(
flow
);
String
equipCode
=
fybList
.
get
(
j
).
getEquipCode
();
int
fcount
=
0
;
for
(
WhatStructData
whatStructData
:
ljList
)
{
if
(
fcount
<
2
){
if
(
equipCode
.
equals
(
whatStructData
.
getEquipCode
())){
if
(
"flow_ljll"
.
equals
(
whatStructData
.
getEquipType
())){
fFlow
.
setTitle
(
whatStructData
.
getEquipType
());
fFlow
.
setValue
(
monitorMap
.
get
(
whatStructData
.
getMonitorId
()).
toString
());
flowList
.
add
(
fFlow
);
fcount
++;
}
else
if
(
"flow_rljll"
.
equals
(
whatStructData
.
getEquipType
())){
rFlow
.
setTitle
(
whatStructData
.
getEquipType
());
rFlow
.
setValue
(
monitorMap
.
get
(
whatStructData
.
getMonitorId
()).
toString
());
flowList
.
add
(
rFlow
);
fcount
++;
}
else
{}
}
}
else
{
break
;
}
}
}
else
{
flow
.
setValue
(
"--"
);
flowList
.
add
(
flow
);
fFlow
.
setTitle
(
"flow_ljll"
);
fFlow
.
setValue
(
"--"
);
flowList
.
add
(
fFlow
);
rFlow
.
setTitle
(
"flow_rljll"
);
rFlow
.
setValue
(
"--"
);
flowList
.
add
(
rFlow
);
}
fMap
.
put
(
fybList
.
get
(
j
).
getId
(),
flowList
);
}
else
{
flow
.
setTitle
((
j
+
1
)+
"flow"
);
flow
.
setValue
(
"--"
);
flowList
.
add
(
flow
);
fFlow
.
setTitle
((
j
+
1
)+
"flow_ljll"
);
fFlow
.
setValue
(
"--"
);
flowList
.
add
(
fFlow
);
rFlow
.
setTitle
((
j
+
1
)+
"flow_rljll"
);
rFlow
.
setValue
(
"--"
);
flowList
.
add
(
rFlow
);
fMap
.
put
(
"flow"
+(
j
+
1
),
flowList
);
}
fList
.
add
(
j
,
fMap
);
}
map
.
put
(
"pressure"
,
pList
);
map
.
put
(
"flow"
,
fList
);
}
else
if
(
"hot"
.
equals
(
sourceType
)){
//压力10流量4温度4;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
TextResult
textResult
=
new
TextResult
();
if
(
i
<
pybList
.
size
()){
textResult
.
setTitle
(
pybList
.
get
(
i
).
getId
());
if
(
monitorMap
.
get
(
pybList
.
get
(
i
).
getMonitorId
())==
null
){
textResult
.
setValue
(
"--"
);
}
else
{
double
pResult
=
formatDouble
(
Double
.
parseDouble
(
monitorMap
.
get
(
pybList
.
get
(
i
).
getMonitorId
()).
toString
())/
100
);
textResult
.
setValue
(
String
.
valueOf
(
pResult
));
}
}
else
{
textResult
.
setTitle
(
"pressure"
+(
i
+
1
));
textResult
.
setValue
(
"--"
);
}
pList
.
add
(
i
,
textResult
);
}
for
(
int
j
=
0
;
j
<
4
;
j
++)
{
Map
<
String
,
Object
>
fMap
=
new
HashMap
<>();
List
<
TextResult
>
flowList
=
new
ArrayList
<>();
TextResult
flow
=
new
TextResult
();
TextResult
fFlow
=
new
TextResult
();
TextResult
rFlow
=
new
TextResult
();
if
(
j
<
fybList
.
size
()){
flow
.
setTitle
(
fybList
.
get
(
j
).
getEquipType
());
if
(
fybList
.
get
(
j
).
getMonitorId
()!=
null
){
flow
.
setValue
(
monitorMap
.
get
(
fybList
.
get
(
j
).
getMonitorId
()).
toString
());
flowList
.
add
(
flow
);
String
equipCode
=
fybList
.
get
(
j
).
getEquipCode
();
int
fcount
=
0
;
for
(
WhatStructData
whatStructData
:
ljList
)
{
if
(
fcount
<
2
){
if
(
equipCode
.
equals
(
whatStructData
.
getEquipCode
())){
if
(
"flow_ljll"
.
equals
(
whatStructData
.
getEquipType
())){
fFlow
.
setTitle
(
whatStructData
.
getEquipType
());
fFlow
.
setValue
(
monitorMap
.
get
(
whatStructData
.
getMonitorId
()).
toString
());
flowList
.
add
(
fFlow
);
fcount
++;
}
else
if
(
"flow_rljll"
.
equals
(
whatStructData
.
getEquipType
())){
rFlow
.
setTitle
(
whatStructData
.
getEquipType
());
rFlow
.
setValue
(
monitorMap
.
get
(
whatStructData
.
getMonitorId
()).
toString
());
flowList
.
add
(
rFlow
);
fcount
++;
}
else
{}
}
}
else
{
break
;
}
}
}
else
{
flow
.
setValue
(
"--"
);
flowList
.
add
(
flow
);
fFlow
.
setTitle
(
"flow_ljll"
);
fFlow
.
setValue
(
"--"
);
flowList
.
add
(
fFlow
);
rFlow
.
setTitle
(
"flow_rljll"
);
rFlow
.
setValue
(
"--"
);
flowList
.
add
(
rFlow
);
}
fMap
.
put
(
fybList
.
get
(
j
).
getId
(),
flowList
);
}
else
{
flow
.
setTitle
((
j
+
1
)+
"flow"
);
flow
.
setValue
(
"--"
);
flowList
.
add
(
flow
);
fFlow
.
setTitle
((
j
+
1
)+
"flow_ljll"
);
fFlow
.
setValue
(
"--"
);
flowList
.
add
(
fFlow
);
rFlow
.
setTitle
((
j
+
1
)+
"flow_rljll"
);
rFlow
.
setValue
(
"--"
);
flowList
.
add
(
rFlow
);
fMap
.
put
(
"flow"
+(
j
+
1
),
flowList
);
}
fList
.
add
(
j
,
fMap
);
}
for
(
int
k
=
0
;
k
<
4
;
k
++)
{
TextResult
textResult
=
new
TextResult
();
if
(
k
<
wybList
.
size
()){
textResult
.
setTitle
(
wybList
.
get
(
k
).
getId
());
if
(
monitorMap
.
get
(
wybList
.
get
(
k
).
getMonitorId
())==
null
){
textResult
.
setValue
(
"--"
);
}
else
{
textResult
.
setValue
(
monitorMap
.
get
(
wybList
.
get
(
k
).
getMonitorId
()).
toString
());
}
}
else
{
textResult
.
setTitle
(
"temperature"
+(
k
+
1
));
textResult
.
setValue
(
"--"
);
}
wList
.
add
(
k
,
textResult
);
}
map
.
put
(
"pressure"
,
pList
);
map
.
put
(
"flow"
,
fList
);
map
.
put
(
"temperature"
,
wList
);
}
else
if
(
"fire"
.
equals
(
sourceType
)){
//压力9流量2.
for
(
int
i
=
0
;
i
<
9
;
i
++)
{
TextResult
textResult
=
new
TextResult
();
if
(
i
<
pybList
.
size
()){
textResult
.
setTitle
(
pybList
.
get
(
i
).
getId
());
if
(
monitorMap
.
get
(
pybList
.
get
(
i
).
getMonitorId
())==
null
){
textResult
.
setValue
(
"--"
);
}
else
{
double
pResult
=
formatDouble
(
Double
.
parseDouble
(
monitorMap
.
get
(
pybList
.
get
(
i
).
getMonitorId
()).
toString
())/
100
);
textResult
.
setValue
(
String
.
valueOf
(
pResult
));
}
}
else
{
textResult
.
setTitle
(
"pressure"
+(
i
+
1
));
textResult
.
setValue
(
"--"
);
}
pList
.
add
(
i
,
textResult
);
}
for
(
int
j
=
0
;
j
<
2
;
j
++)
{
Map
<
String
,
Object
>
fMap
=
new
HashMap
<>();
List
<
TextResult
>
flowList
=
new
ArrayList
<>();
TextResult
flow
=
new
TextResult
();
TextResult
fFlow
=
new
TextResult
();
TextResult
rFlow
=
new
TextResult
();
if
(
j
<
fybList
.
size
()){
flow
.
setTitle
(
fybList
.
get
(
j
).
getEquipType
());
if
(
fybList
.
get
(
j
).
getMonitorId
()!=
null
){
flow
.
setValue
(
monitorMap
.
get
(
fybList
.
get
(
j
).
getMonitorId
()).
toString
());
flowList
.
add
(
flow
);
String
equipCode
=
fybList
.
get
(
j
).
getEquipCode
();
int
fcount
=
0
;
for
(
WhatStructData
whatStructData
:
ljList
)
{
if
(
fcount
<
2
){
if
(
equipCode
.
equals
(
whatStructData
.
getEquipCode
())){
if
(
"flow_ljll"
.
equals
(
whatStructData
.
getEquipType
())){
fFlow
.
setTitle
(
whatStructData
.
getEquipType
());
fFlow
.
setValue
(
monitorMap
.
get
(
whatStructData
.
getMonitorId
()).
toString
());
flowList
.
add
(
fFlow
);
fcount
++;
}
else
if
(
"flow_rljll"
.
equals
(
whatStructData
.
getEquipType
())){
rFlow
.
setTitle
(
whatStructData
.
getEquipType
());
rFlow
.
setValue
(
monitorMap
.
get
(
whatStructData
.
getMonitorId
()).
toString
());
flowList
.
add
(
rFlow
);
fcount
++;
}
else
{}
}
}
else
{
break
;
}
}
}
else
{
flow
.
setValue
(
"--"
);
flowList
.
add
(
flow
);
fFlow
.
setTitle
(
"flow_ljll"
);
fFlow
.
setValue
(
"--"
);
flowList
.
add
(
fFlow
);
rFlow
.
setTitle
(
"flow_rljll"
);
rFlow
.
setValue
(
"--"
);
flowList
.
add
(
rFlow
);
}
fMap
.
put
(
fybList
.
get
(
j
).
getId
(),
flowList
);
}
else
{
flow
.
setTitle
((
j
+
1
)+
"flow"
);
flow
.
setValue
(
"--"
);
flowList
.
add
(
flow
);
fFlow
.
setTitle
((
j
+
1
)+
"flow_ljll"
);
fFlow
.
setValue
(
"--"
);
flowList
.
add
(
fFlow
);
rFlow
.
setTitle
((
j
+
1
)+
"flow_rljll"
);
rFlow
.
setValue
(
"--"
);
flowList
.
add
(
rFlow
);
fMap
.
put
(
"flow"
+(
j
+
1
),
flowList
);
}
fList
.
add
(
j
,
fMap
);
}
map
.
put
(
"pressure"
,
pList
);
map
.
put
(
"flow"
,
fList
);
}
else
{
for
(
int
i
=
0
;
i
<
33
;
i
++)
{
TextResult
textResult
=
new
TextResult
();
textResult
.
setTitle
(
"pressure"
+(
i
+
1
));
textResult
.
setValue
(
"0.00"
);
pList
.
add
(
i
,
textResult
);
}
for
(
int
j
=
0
;
j
<
14
;
j
++)
{
Map
<
String
,
Object
>
fMap
=
new
HashMap
<>();
List
<
TextResult
>
flowList
=
new
ArrayList
<>();
TextResult
flow
=
new
TextResult
();
TextResult
fFlow
=
new
TextResult
();
TextResult
rFlow
=
new
TextResult
();
flow
.
setTitle
(
"flow"
);
flow
.
setValue
(
"--"
);
flowList
.
add
(
flow
);
fFlow
.
setTitle
(
"flow_ljll"
);
fFlow
.
setValue
(
"--"
);
flowList
.
add
(
fFlow
);
rFlow
.
setTitle
(
"flow_rljll"
);
rFlow
.
setValue
(
"--"
);
flowList
.
add
(
rFlow
);
fMap
.
put
(
"F0"
+(
j
+
1
),
flowList
);
fList
.
add
(
fMap
);
}
for
(
int
k
=
0
;
k
<
4
;
k
++)
{
TextResult
textResult
=
new
TextResult
();
textResult
.
setTitle
(
"temperature"
+(
k
+
1
));
textResult
.
setValue
(
"--"
);
wList
.
add
(
k
,
textResult
);
}
map
.
put
(
"pressure"
,
pList
);
map
.
put
(
"flow"
,
fList
);
map
.
put
(
"temperature"
,
wList
);
}
}
return
map
;
}
@Override
public
List
<
EchartResult
>
getPressureChartNew
(
String
equipId
,
String
type
)
{
List
<
EchartResult
>
list
=
new
ArrayList
<>();
List
<
WhatStructData
>
wList
=
whatStructDataMapper
.
getDataList
(
equipId
);
String
pgField
=
""
;
if
(
wList
.
size
()
==
0
){
return
list
;
}
else
{
for
(
WhatStructData
whatStructData:
wList
)
{
pgField
=
pgField
+
","
+
whatStructData
.
getMonitorId
();
}
}
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DATE
,
-
7
);
String
startDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
cal
.
getTime
());
String
start
=
startDate
+
" 00:00:00"
;
String
endDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
new
Date
());
String
end
=
endDate
+
" 23:59:59"
;
List
<
Map
<
String
,
Object
>>
dataList
=
factoryInfoService
.
queryReportData
(
AT_ID
,
pgField
,
start
,
end
,
"hour"
);
if
(
dataList
.
size
()>
0
){
for
(
Map
<
String
,
Object
>
map:
dataList
)
{
EchartResult
echartResult
=
new
EchartResult
();
echartResult
.
setName
(
map
.
get
(
"time"
).
toString
());
if
(
"p"
.
equals
(
type
)){
double
pResult
=
formatDouble
(
Double
.
parseDouble
(
map
.
get
(
wList
.
get
(
0
).
getMonitorId
()).
toString
())/
100
);
echartResult
.
setValue
(
String
.
valueOf
(
pResult
));
echartResult
.
setSeries
(
"压力表"
);
list
.
add
(
echartResult
);
}
else
if
(
"f"
.
equals
(
type
)){
for
(
WhatStructData
whatStructData:
wList
)
{
EchartResult
eResult
=
new
EchartResult
();
eResult
.
setName
(
map
.
get
(
"time"
).
toString
());
eResult
.
setValue
(
map
.
get
(
whatStructData
.
getMonitorId
()).
toString
());
eResult
.
setSeries
(
whatStructData
.
getEquipType
());
list
.
add
(
eResult
);
}
}
else
if
(
"t"
.
equals
(
type
)){
echartResult
.
setValue
(
map
.
get
(
wList
.
get
(
0
).
getMonitorId
()).
toString
());
echartResult
.
setSeries
(
"温度计"
);
list
.
add
(
echartResult
);
}
else
{
echartResult
.
setValue
(
"--"
);
echartResult
.
setSeries
(
"--"
);
list
.
add
(
echartResult
);
}
}
}
else
{
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
Calendar
date
=
Calendar
.
getInstance
();
date
.
add
(
Calendar
.
DATE
,
i
-
7
);
String
newDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
date
.
getTime
()).
substring
(
5
,
10
);
EchartResult
echartResult
=
new
EchartResult
();
echartResult
.
setName
(
newDate
);
echartResult
.
setValue
(
"--"
);
if
(
"p"
.
equals
(
type
)){
echartResult
.
setSeries
(
"压力表"
);
}
else
if
(
"f"
.
equals
(
type
)){
echartResult
.
setSeries
(
"流量计"
);
}
else
if
(
"t"
.
equals
(
type
)){
echartResult
.
setSeries
(
"温度计"
);
}
else
{
echartResult
.
setSeries
(
"--"
);
}
list
.
add
(
echartResult
);
}
}
return
list
;
}
@Override
public
Map
<
String
,
Object
>
getRealTimeDataToUENew
()
{
List
<
WhatStructData
>
list
=
whatStructDataMapper
.
getListForUENew
();
List
<
WhatStructData
>
fList
=
new
ArrayList
<>();
List
<
WhatStructData
>
otherList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
monitorMap
=
new
HashMap
<>();
String
pgField
=
""
;
for
(
WhatStructData
whatStructData:
list
)
{
pgField
=
pgField
+
","
+
whatStructData
.
getMonitorId
();
if
(
"flow"
.
equals
(
whatStructData
.
getEquipType
())){
fList
.
add
(
whatStructData
);
}
if
(!
whatStructData
.
getEquipType
().
contains
(
"flow"
)){
otherList
.
add
(
whatStructData
);
}
}
List
<
Map
<
String
,
Object
>>
monitorList
=
fmPgQueryService
.
queryFactoryMonitorFromRealTimeData
(
AT_ID
,
pgField
);
if
(
monitorList
.
size
()==
1
){
monitorMap
=
monitorList
.
get
(
0
);
for
(
WhatStructData
whatStructData:
fList
)
{
if
(
whatStructData
.
getMonitorId
()!=
null
){
String
fId
=
whatStructData
.
getId
();
Map
<
String
,
Object
>
beanMap
=
new
HashMap
<>();
for
(
WhatStructData
bean
:
list
)
{
if
(
bean
.
getId
().
startsWith
(
fId
)){
beanMap
.
put
(
bean
.
getEquipType
(),
monitorMap
.
get
(
bean
.
getMonitorId
()));
}
}
map
.
put
(
fId
,
beanMap
);
}
else
{
Map
<
String
,
Object
>
kMap
=
new
HashMap
<>();
kMap
.
put
(
"flow"
,
"--"
);
kMap
.
put
(
"flow_ljll"
,
"--"
);
kMap
.
put
(
"flow_rljll"
,
"--"
);
map
.
put
(
whatStructData
.
getId
(),
kMap
);
}
}
for
(
WhatStructData
whatStructData:
otherList
)
{
if
(
whatStructData
.
getMonitorId
()!=
null
){
if
(
"pressure"
.
equals
(
whatStructData
.
getEquipType
())){
double
pResult
=
formatDouble
(
Double
.
parseDouble
(
monitorMap
.
get
(
whatStructData
.
getMonitorId
()).
toString
())/
100
);
map
.
put
(
whatStructData
.
getId
(),
String
.
valueOf
(
pResult
));
}
else
{
map
.
put
(
whatStructData
.
getId
(),
monitorMap
.
get
(
whatStructData
.
getMonitorId
()));
}
}
else
{
map
.
put
(
whatStructData
.
getId
(),
"--"
);
}
}
}
else
{
for
(
WhatStructData
whatStructData:
fList
)
{
Map
<
String
,
Object
>
kMap
=
new
HashMap
<>();
kMap
.
put
(
"flow"
,
"--"
);
kMap
.
put
(
"flow_ljll"
,
"--"
);
kMap
.
put
(
"flow_rljll"
,
"--"
);
map
.
put
(
whatStructData
.
getId
(),
kMap
);
}
for
(
WhatStructData
whatStructData:
otherList
)
{
map
.
put
(
whatStructData
.
getId
(),
"--"
);
}
}
return
map
;
}
// public static void main(String[] args) {
// for (int i = 0; i < 24; i++) {
// Calendar date = Calendar.getInstance();
...
...
fm-product/src/main/java/com/skua/modules/location/controller/UserLocationController.java
查看文件 @
a30d7c2
...
...
@@ -6,6 +6,7 @@ import com.skua.modules.location.UserLocationFactory;
import
com.skua.modules.location.entity.UserBaseInfo
;
import
com.skua.modules.location.entity.UserLocation
;
import
com.skua.modules.location.service.ILocationService
;
import
com.skua.modules.location.vo.QueryParams
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -14,7 +15,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Api
(
tags
=
"人员定位系统对接"
)
...
...
@@ -26,12 +29,12 @@ public class UserLocationController {
@AutoLog
(
value
=
"义乌人员定位-获取所有人员列表"
)
@ApiOperation
(
value
=
"义乌人员定位-获取所有人员列表"
,
notes
=
"义乌人员定位-获取所有人员列表"
)
@GetMapping
(
value
=
"/yw/getAllUser"
)
public
Result
<
List
<
UserBaseInfo
>>
getAllUserYW
(
String
userName
)
{
Result
<
List
<
UserBaseInfo
>>
result
=
new
Result
<
List
<
UserBaseInfo
>>();
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
public
Result
<
Map
<
String
,
Object
>>
getAllUserYW
(
QueryParams
queryParams
)
{
Result
<
Map
<
String
,
Object
>>
result
=
new
Result
<
Map
<
String
,
Object
>>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
ILocationService
locationService
=
UserLocationFactory
.
getLocationService
(
"YW"
);
list
=
locationService
.
getAllUser
(
userName
);
result
.
setResult
(
list
);
map
=
locationService
.
getAllUser
(
queryParams
);
result
.
setResult
(
map
);
result
.
setSuccess
(
true
);
return
result
;
}
...
...
@@ -66,12 +69,12 @@ public class UserLocationController {
@AutoLog
(
value
=
"余杭人员定位-获取所有人员列表"
)
@ApiOperation
(
value
=
"余杭人员定位-获取所有人员列表"
,
notes
=
"余杭人员定位-获取所有人员列表"
)
@GetMapping
(
value
=
"/yh/getAllUser"
)
public
Result
<
List
<
UserBaseInfo
>>
getAllUserBKYH
(
String
userName
)
{
Result
<
List
<
UserBaseInfo
>>
result
=
new
Result
<
List
<
UserBaseInfo
>>();
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
public
Result
<
Map
<
String
,
Object
>>
getAllUserBKYH
(
QueryParams
queryParams
)
{
Result
<
Map
<
String
,
Object
>>
result
=
new
Result
<
Map
<
String
,
Object
>>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
ILocationService
locationService
=
UserLocationFactory
.
getLocationService
(
"BKYH"
);
list
=
locationService
.
getAllUser
(
userName
);
result
.
setResult
(
list
);
map
=
locationService
.
getAllUser
(
queryParams
);
result
.
setResult
(
map
);
result
.
setSuccess
(
true
);
return
result
;
}
...
...
fm-product/src/main/java/com/skua/modules/location/service/ILocationService.java
查看文件 @
a30d7c2
...
...
@@ -2,8 +2,10 @@ package com.skua.modules.location.service;
import
com.skua.modules.location.entity.UserBaseInfo
;
import
com.skua.modules.location.entity.UserLocation
;
import
com.skua.modules.location.vo.QueryParams
;
import
java.util.List
;
import
java.util.Map
;
public
interface
ILocationService
{
...
...
@@ -11,7 +13,7 @@ public interface ILocationService {
List
<
UserLocation
>
getUserHistory
(
String
deviceCode
,
String
startTime
,
String
endTime
);
List
<
UserBaseInfo
>
getAllUser
(
String
userName
);
Map
<
String
,
Object
>
getAllUser
(
QueryParams
queryParams
);
}
...
...
fm-product/src/main/java/com/skua/modules/location/service/impl/BkyhLocationServiceImpl.java
查看文件 @
a30d7c2
...
...
@@ -6,6 +6,7 @@ import com.skua.modules.location.entity.*;
import
com.skua.modules.location.service.ILocationService
;
import
com.skua.modules.location.util.ChangeLocationUtils
;
import
com.skua.modules.location.util.MD5Util
;
import
com.skua.modules.location.vo.QueryParams
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -108,8 +109,9 @@ public class BkyhLocationServiceImpl implements ILocationService {
}
@Override
public
List
<
UserBaseInfo
>
getAllUser
(
String
userName
)
{
public
Map
<
String
,
Object
>
getAllUser
(
QueryParams
queryParams
)
{
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
String
post
=
getBuildingAllInfo
();
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
parseObject
(
post
).
get
(
"data"
).
toString
());
List
<
UserBaseInfoBkyhResult
>
userList
=
JSONObject
.
parseArray
(
json
.
get
(
"devices"
).
toString
(),
UserBaseInfoBkyhResult
.
class
);
...
...
@@ -131,7 +133,8 @@ public class BkyhLocationServiceImpl implements ILocationService {
userBaseInfo
.
setUserName
(
userBaseInfoBkyhResult
.
getName
());
list
.
add
(
userBaseInfo
);
}
return
list
;
map
.
put
(
"list"
,
list
);
return
map
;
}
}
...
...
fm-product/src/main/java/com/skua/modules/location/service/impl/YwLocationServiceImpl.java
查看文件 @
a30d7c2
...
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.skua.modules.location.entity.*
;
import
com.skua.modules.location.service.ILocationService
;
import
com.skua.modules.location.util.ChangeLocationUtils
;
import
com.skua.modules.location.vo.QueryParams
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
...
...
@@ -94,17 +95,19 @@ public class YwLocationServiceImpl implements ILocationService {
}
@Override
public
List
<
UserBaseInfo
>
getAllUser
(
String
userName
)
{
public
Map
<
String
,
Object
>
getAllUser
(
QueryParams
queryParams
)
{
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"username"
,
username
);
map
.
put
(
"password"
,
password
);
map
.
put
(
"page"
,
1
);
map
.
put
(
"rows"
,
1000
);
map
.
put
(
"emp"
,
userName
);
String
post
=
HttpUtil
.
get
(
url
+
"open/information/getEmp.do"
,
map
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
pmap
=
new
HashMap
<>();
pmap
.
put
(
"username"
,
username
);
pmap
.
put
(
"password"
,
password
);
pmap
.
put
(
"page"
,
1
);
pmap
.
put
(
"rows"
,
1000
);
pmap
.
put
(
"emp"
,
queryParams
.
getUserName
());
String
post
=
HttpUtil
.
get
(
url
+
"open/information/getEmp.do"
,
pmap
);
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
parseObject
(
post
).
get
(
"data"
).
toString
());
List
<
UserBaseInfoYwResult
>
userList
=
JSONObject
.
parseArray
(
json
.
get
(
"rows"
).
toString
(),
UserBaseInfoYwResult
.
class
);
List
<
Map
>
onlineList
=
getOnLineList
();
for
(
UserBaseInfoYwResult
userBaseInfoYwResult
:
userList
)
{
UserBaseInfo
userBaseInfo
=
new
UserBaseInfo
();
userBaseInfo
.
setDeviceCode
(
userBaseInfoYwResult
.
getDeviceno
());
...
...
@@ -114,6 +117,19 @@ public class YwLocationServiceImpl implements ILocationService {
userBaseInfo
.
setUserStatus
(
"0"
);
list
.
add
(
userBaseInfo
);
}
map
.
put
(
"list"
,
list
);
map
.
put
(
"onlineCount"
,
onlineList
.
size
());
return
map
;
}
public
List
<
Map
>
getOnLineList
(){
List
<
Map
>
list
=
new
ArrayList
<>();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"username"
,
username
);
map
.
put
(
"password"
,
password
);
String
post
=
HttpUtil
.
get
(
url
+
"/open/information/getRealInformation.do"
,
map
);
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
parseObject
(
post
).
get
(
"data"
).
toString
());
list
=
JSONObject
.
parseArray
(
json
.
get
(
"list"
).
toString
(),
Map
.
class
);
return
list
;
}
}
...
...
fm-product/src/main/java/com/skua/modules/location/vo/QueryParams.java
0 → 100644
查看文件 @
a30d7c2
package
com
.
skua
.
modules
.
location
.
vo
;
import
lombok.Data
;
@Data
public
class
QueryParams
{
/**人员名称*/
private
String
userName
;
/**在线状态*/
private
String
userStatus
;
}
fm-product/src/main/java/com/skua/modules/monitor/service/IFmPgQueryService.java
0 → 100644
查看文件 @
a30d7c2
package
com
.
skua
.
modules
.
monitor
.
service
;
import
java.util.List
;
import
java.util.Map
;
/**
* PG实时数据查询接口
*/
public
interface
IFmPgQueryService
{
List
<
Map
<
String
,
Object
>>
queryFactoryMonitorFromRealTimeData
(
String
factoryId
,
String
fields
);
}
fm-product/src/main/java/com/skua/modules/monitor/service/impl/FmPgQueryServiceImpl.java
0 → 100644
查看文件 @
a30d7c2
package
com
.
skua
.
modules
.
monitor
.
service
.
impl
;
import
com.skua.core.context.SpringContextUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
com.skua.modules.monitor.service.IFmPgQueryService
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* 数据指标信息表
*/
@Service
public
class
FmPgQueryServiceImpl
implements
IFmPgQueryService
{
@Override
public
List
<
Map
<
String
,
Object
>>
queryFactoryMonitorFromRealTimeData
(
String
factoryId
,
String
fields
)
{
String
[]
factoryIdArray
=
factoryId
.
split
(
","
);
String
sqlPart
=
""
;
for
(
String
id
:
factoryIdArray
)
{
sqlPart
=
sqlPart
+
",'"
+
id
+
"'"
;
}
sqlPart
=
sqlPart
.
substring
(
1
);
JdbcTemplate
pgDb
=
(
JdbcTemplate
)
SpringContextUtils
.
getBean
(
"pg-db"
);
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<
Map
<
String
,
Object
>>();
JdbcTemplate
masterDB
=
(
JdbcTemplate
)
SpringContextUtils
.
getBean
(
"master"
);
List
<
Map
<
String
,
Object
>>
factoryDesign
=
masterDB
.
queryForList
(
"select * from sys_factory_device where factory_id in ("
+
sqlPart
+
")"
);
if
(
factoryDesign
==
null
||
factoryDesign
.
size
()==
0
)
{
return
result
;
}
StringBuilder
str
=
new
StringBuilder
();
String
[]
fieldsArr
=
fields
.
split
(
","
);
for
(
int
i
=
0
;
i
<
fieldsArr
.
length
;
++
i
){
if
(!
StringUtils
.
isEmpty
(
fieldsArr
[
i
])&&!
fieldsArr
[
i
].
equals
(
"null"
))
{
str
.
append
(
"'"
+
fieldsArr
[
i
]+
"'"
).
append
(
","
);
}
}
if
(
fieldsArr
.
length
>
0
){
str
.
append
(
"''"
);
}
else
{
return
result
;
}
String
deviceIds
=
""
;
for
(
Map
<
String
,
Object
>
map:
factoryDesign
)
{
deviceIds
=
deviceIds
+
",'"
+
map
.
get
(
"device_id"
)+
"'"
;
}
deviceIds
=
deviceIds
.
substring
(
1
);
Date
d
=
new
Date
();
//获取时间
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
long
todayTimeStemp
=
gettimeStemp
(
sdf
.
format
(
d
)+
" 00:00:00"
,
"yyyy-MM-dd"
);
//获取pg数据库时间,向前推采集频率的三倍时间,做数据容错
String
sql
=
"select ts as time,nm as monitorId,v as monitorValue from realtimedata where nm in("
+
str
.
toString
()+
") and factoryname in ("
+
deviceIds
+
")"
;
List
<
Map
<
String
,
Object
>>
monitorList
=
pgDb
.
queryForList
(
sql
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
monitorList
.
size
()
>
0
){
map
.
put
(
"time"
,
monitorList
.
get
(
0
).
get
(
"time"
).
toString
());
for
(
int
m
=
0
;
m
<
monitorList
.
size
();
m
++)
{
if
(
Long
.
parseLong
(
monitorList
.
get
(
m
).
get
(
"time"
).
toString
())
>
todayTimeStemp
){
map
.
put
(
monitorList
.
get
(
m
).
get
(
"monitorId"
).
toString
(),
monitorList
.
get
(
m
).
get
(
"monitorValue"
));
}
else
{
map
.
put
(
monitorList
.
get
(
m
).
get
(
"monitorId"
).
toString
(),
0.00
);
}
}
result
.
add
(
map
);
}
else
{
return
result
;
}
return
result
;
}
public
static
void
main
(
String
[]
args
)
{
Date
d
=
new
Date
();
//获取时间
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
System
.
out
.
println
(
gettimeStemp
(
sdf
.
format
(
d
)+
" 00:00:00"
,
"yyyy-MM-dd"
));
}
public
static
long
gettimeStemp
(
String
time
,
String
format
)
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
if
(!
""
.
equals
(
format
))
{
simpleDateFormat
=
new
SimpleDateFormat
(
format
);
}
long
timeStemp
=
0
;
try
{
Date
date
=
simpleDateFormat
.
parse
(
time
);
timeStemp
=
date
.
getTime
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
timeStemp
/
1000
;
}
}
fm-system/pom.xml
查看文件 @
a30d7c2
...
...
@@ -57,7 +57,6 @@
</exclusion>
</exclusions>
</dependency>
<!-- online form -->
</dependencies>
<build>
...
...
fm-system/src/main/resources/application-dev.yml
查看文件 @
a30d7c2
...
...
@@ -185,3 +185,10 @@ skua :
#cas单点登录
cas
:
prefixUrl
:
http://cas.example.org:8443/cas
#微信相关
wx
:
# 公众号
app-id
:
wxbdc5610cc59c1631
app-secret
:
xxxxxxxxxxxxxxxxxxxxxxx
redirect-url
:
https://passport.yhd.com/wechat/callback.do
...
...
fm-system/src/main/resources/application-prod.yml
查看文件 @
a30d7c2
...
...
@@ -98,9 +98,9 @@ spring:
driver-class-name
:
com.mysql.jdbc.Driver
# 多数据源配置
pg-db
:
url
:
jdbc:postgresql://
120.24.205.69
:10086/postgres?useUnicode=true&characterEncoding=UTF8
url
:
jdbc:postgresql://
47.104.99.86
:10086/postgres?useUnicode=true&characterEncoding=UTF8
username
:
postgres
password
:
server_2021_%Jksc
password
:
JKjnf9713xt
driver-class-name
:
org.postgresql.Driver
#redis 配置
redis
:
...
...
@@ -186,3 +186,10 @@ skua :
#cas单点登录
cas
:
prefixUrl
:
http://cas.example.org:8443/cas
#微信相关
wx
:
# 公众号
app-id
:
wxbdc5610cc59c1631
app-secret
:
xxxxxxxxxxxxxxxxxxxxxxx
redirect-url
:
https://passport.yhd.com/wechat/callback.do
...
...
fm-system/src/main/resources/application-what.yml
查看文件 @
a30d7c2
...
...
@@ -186,3 +186,10 @@ skua :
#cas单点登录
cas
:
prefixUrl
:
http://cas.example.org:8443/cas
#微信相关
wx
:
# 公众号
app-id
:
wxbdc5610cc59c1631
app-secret
:
xxxxxxxxxxxxxxxxxxxxxxx
redirect-url
:
https://passport.yhd.com/wechat/callback.do
...
...
fm-system/src/main/resources/application-yw.yml
查看文件 @
a30d7c2
...
...
@@ -186,3 +186,9 @@ skua :
#cas单点登录
cas
:
prefixUrl
:
http://cas.example.org:8443/cas
#微信相关
wx
:
# 公众号
app-id
:
wxbdc5610cc59c1631
app-secret
:
xxxxxxxxxxxxxxxxxxxxxxx
redirect-url
:
https://passport.yhd.com/wechat/callback.do
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论