Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
b25b6eb9
Commit
b25b6eb9
authored
Jan 10, 2023
by
zhangsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
水池液位趋势修改
parent
b918e882
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
59 deletions
+74
-59
TopographyController.java
.../yeejoin/equipmanage/controller/TopographyController.java
+61
-59
IotFeign.java
...src/main/java/com/yeejoin/equipmanage/fegin/IotFeign.java
+13
-0
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/TopographyController.java
View file @
b25b6eb9
...
...
@@ -38,6 +38,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -846,18 +847,18 @@ public class TopographyController extends AbstractBaseController {
@RequestParam
(
required
=
false
)
String
endDate
)
throws
ParseException
{
Map
<
String
,
List
<
IotIndexResVo
>>
resultMap
=
new
HashMap
<>();
List
<
String
>
split
=
Arrays
.
asList
(
equipSpeId
.
split
(
","
));
List
<
String
>
split
=
Arrays
.
asList
(
equipSpeId
.
split
(
","
));
List
<
IotIndexResVo
>
finalRes
=
new
ArrayList
<>();
List
<
IotIndexResVo
>
finalResContainsWaterLevel
=
new
ArrayList
<>();
List
<
IotIndexResVo
>
resultResContainsWater
=
new
ArrayList
<>();
Map
<
String
,
String
>
iotCodeMap
=
new
HashMap
<>();
for
(
String
specId
:
split
)
{
String
eqpId
;
String
iotCode
=
null
;
if
(
null
!=
fieldKey
||
null
!=
isTrend
)
{
if
(
null
!=
fieldKey
||
null
!=
isTrend
)
{
EquipmentSpecific
equipmentSpecific
=
equipmentSpecificService
.
getById
(
specId
);
iotCode
=
equipmentSpecific
.
getIotCode
();
iotCodeMap
.
put
(
specId
,
iotCode
);
List
<
EquipmentIndex
>
equipmentSpecifics
=
equipmentIndexService
.
getPerfQutoaIotList
(
Long
.
valueOf
(
specId
));
...
...
@@ -867,7 +868,6 @@ public class TopographyController extends AbstractBaseController {
if
(
"true"
.
equals
(
isTrend
))
{
fieldKey
=
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getPerfQuotaDefinitionId
).
collect
(
Collectors
.
joining
(
","
));
}
}
else
{
if
(
StringUtil
.
isNotEmpty
(
specId
))
{
eqpId
=
specId
;
...
...
@@ -882,7 +882,6 @@ public class TopographyController extends AbstractBaseController {
EquipmentSpecific
equipmentSpecific
=
equipmentSpecificService
.
getById
(
eqpId
);
iotCode
=
equipmentSpecific
.
getIotCode
();
}
String
prefix
=
null
;
String
suffix
=
null
;
if
(
StringUtil
.
isNotEmpty
(
iotCode
)
&&
iotCode
.
length
()
>
8
)
{
...
...
@@ -911,14 +910,7 @@ public class TopographyController extends AbstractBaseController {
}
}
}
// List<IotDataVO> timeList = vos.stream().filter(x -> x.getKey().equals("time")).collect(Collectors.toList());
// List<Date> dates = new ArrayList<>();
Map
<
String
,
List
<
Date
>>
dateMap
=
new
HashMap
<>();
// String indexKey = null;
// String useDate = null;
for
(
int
i
=
0
;
i
<
vos
.
size
();
i
=
i
+
2
)
{
Date
useDate
=
null
;
String
indexKey
=
null
;
...
...
@@ -941,44 +933,7 @@ public class TopographyController extends AbstractBaseController {
dateMap
.
get
(
indexKey
).
add
(
useDate
);
}
}
// for (IotDataVO vo : vos) {
// if (!vo.getKey().equals("time")) {
// indexKey = vo.getKey();
// if (useDate != null) {
// SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
// if (!dateMap.containsKey(indexKey)) {
// ArrayList<Date> dates1 = new ArrayList<>();
// dates1.add(sdf1.parse(useDate));
// dateMap.put(indexKey, dates1);
// } else {
// dateMap.get(indexKey).add(sdf1.parse(useDate));
// }
// indexKey = null;
// }
// } else {
// String value = String.valueOf(vo.getValue());
// String strDate = value.substring(0, 19);
// SimpleDateFormat sdf = new SimpleDateFormat(ISO8601_DATE_HOUR_MIN_SEC);
// SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
// logger.info("返回时间===================================(" + vo.getValue() + ") =======================================");
// sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
// Date date = sdf.parse(strDate);
// String time = DateTimeUtil.format(date, DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC);
// if (indexKey == null) {
// useDate = time;
// }
//// dates.add(sdf1.parse(time));
// logger.info("返回时间===================================(" + sdf1.parse(time) + ") =======================================");
// }
// }
List
<
EquipmentSpecificIndex
>
indexes
=
equipmentSpecificIndexMapper
.
getEquipmentSpeIndexByIotCodeAndTrend
(
iotCode
);
if
(
0
<
indexes
.
size
())
{
List
<
TopographyIotIndexTrendVo
>
list
=
new
ArrayList
<>();
vos
.
forEach
(
iotDataVO
->
{
...
...
@@ -1006,7 +961,6 @@ public class TopographyController extends AbstractBaseController {
for
(
String
str
:
maps
.
keySet
())
{
mapIndex
.
put
(
str
,
maps
.
get
(
str
).
get
(
0
).
getId
());
}
List
<
IotIndexResVo
>
res
=
new
ArrayList
<>();
List
<
IotIndexResVo
>
resContainsWaterLevelList
=
new
ArrayList
<>();
for
(
String
s
:
mapIndex
.
keySet
())
{
...
...
@@ -1027,7 +981,6 @@ public class TopographyController extends AbstractBaseController {
res
.
add
(
vo
);
}
}
for
(
IotIndexResVo
s
:
res
)
{
s
.
setIotData
(
map
.
get
(
s
.
getNameKey
()));
s
.
setTimes
(
dateMap
.
get
(
s
.
getNameKey
()));
...
...
@@ -1037,9 +990,9 @@ public class TopographyController extends AbstractBaseController {
}
}
}
List
<
Date
>
containsWaterDates
=
new
ArrayList
<>();
Map
<
String
,
Map
<
Date
,
IotDataVO
>>
iotDataAndDateMap
=
new
HashMap
<>();
List
<
Date
>
containsWaterDates
=
new
ArrayList
<>();
Map
<
String
,
Map
<
Date
,
IotDataVO
>>
iotDataAndDateMap
=
new
HashMap
<>();
finalResContainsWaterLevel
.
stream
().
forEach
(
item
->
{
if
(!
CollectionUtils
.
isEmpty
(
item
.
getTimes
()))
{
containsWaterDates
.
addAll
(
item
.
getTimes
());
...
...
@@ -1051,9 +1004,9 @@ public class TopographyController extends AbstractBaseController {
}
});
List
<
Date
>
collect
=
containsWaterDates
.
stream
().
distinct
().
sorted
(
Comparator
.
comparing
(
t
->
t
)).
collect
(
Collectors
.
toList
());
IotIndexResVo
iotIndexRes
=
new
IotIndexResVo
();
Map
<
String
,
List
<
IotDataVO
>>
map
=
new
HashMap
<>();
for
(
IotIndexResVo
indexResVo
:
finalResContainsWaterLevel
)
{
IotIndexResVo
iotIndexRes
=
new
IotIndexResVo
();
iotIndexRes
.
setName
(
indexResVo
.
getName
());
iotIndexRes
.
setTimes
(
collect
);
iotIndexRes
.
setId
(
indexResVo
.
getId
());
...
...
@@ -1063,16 +1016,65 @@ public class TopographyController extends AbstractBaseController {
List
<
IotDataVO
>
list
=
new
ArrayList
<>();
collect
.
forEach
(
item
->
{
IotDataVO
iotDataVO
=
new
IotDataVO
();
iotDataVO
.
setValue
(
0
);
iotDataVO
.
setKey
(
indexResVo
.
getIotData
().
get
(
0
).
getKey
());
iotDataVO
.
setValue
(
0
);
if
(
dateIotDataVOMap
.
containsKey
(
item
))
{
iotDataVO
.
setValue
(
dateIotDataVOMap
.
get
(
item
).
getValue
());
}
else
{
String
currentIotCode
=
iotCodeMap
.
get
(
indexResVo
.
getEquipId
());
String
currentPrefix
=
currentIotCode
.
substring
(
0
,
8
);
String
currentSuffix
=
currentIotCode
.
substring
(
8
);
ResponseModel
entity
=
null
;
try
{
entity
=
iotFeign
.
selectPage
(
getAppKey
(),
getProduct
(),
getToken
(),
"2000-01-01 00:00:00"
,
endDate
,
currentPrefix
,
currentSuffix
,
indexResVo
.
getIotData
().
get
(
0
).
getKey
(),
0
,
1
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"调用AMOS-API-IOT服务失败,请检查服务是否正常!"
);
}
if
(
200
==
entity
.
getStatus
()
&&
!
ObjectUtils
.
isEmpty
(
entity
.
getResult
()))
{
String
json
=
JSON
.
toJSONString
(
entity
.
getResult
());
Map
<
String
,
Object
>
listObject
=
(
Map
<
String
,
Object
>)
JSONArray
.
parse
(
json
);
List
<
Map
<
String
,
String
>>
listData
=
(
List
<
Map
<
String
,
String
>>)
listObject
.
get
(
"records"
);
if
(!
CollectionUtils
.
isEmpty
(
listData
))
{
for
(
Map
.
Entry
<
String
,
String
>
stringStringEntry
:
listData
.
get
(
0
).
entrySet
())
{
if
(
indexResVo
.
getIotData
().
get
(
0
).
getKey
().
equals
(
stringStringEntry
.
getKey
()))
{
iotDataVO
.
setValue
(
String
.
valueOf
(
stringStringEntry
.
getValue
()));
}
}
}
else
{
iotDataVO
.
setValue
(
0
);
}
}
else
{
iotDataVO
.
setValue
(
0
);
}
}
list
.
add
(
iotDataVO
);
});
iotIndexRes
.
setIotData
(
list
);
resultResContainsWater
.
add
(
iotIndexRes
);
map
.
put
(
indexResVo
.
getEquipId
(),
list
);
}
List
<
IotDataVO
>
list
=
new
ArrayList
<>();
int
j
=
0
;
for
(
Map
.
Entry
<
String
,
List
<
IotDataVO
>>
stringListEntry
:
map
.
entrySet
())
{
if
(
j
==
0
)
{
list
=
stringListEntry
.
getValue
();
}
else
{
for
(
int
i
=
0
;
i
<
stringListEntry
.
getValue
().
size
();
i
++)
{
Object
last
=
list
.
get
(
i
).
getValue
();
Object
current
=
stringListEntry
.
getValue
().
get
(
i
).
getValue
();
BigDecimal
value1
=
new
BigDecimal
(
String
.
valueOf
(
last
));
BigDecimal
value2
=
new
BigDecimal
(
String
.
valueOf
(
current
));
BigDecimal
add
=
value1
.
add
(
value2
);
BigDecimal
divide
=
add
.
divide
(
new
BigDecimal
(
2
),
2
,
BigDecimal
.
ROUND_DOWN
);
list
.
get
(
i
).
setValue
(
divide
);
}
}
j
++;
}
iotIndexRes
.
setIotData
(
list
);
resultResContainsWater
.
add
(
iotIndexRes
);
resultMap
.
put
(
"noMergeList"
,
finalRes
);
resultMap
.
put
(
"mergeList"
,
resultResContainsWater
);
return
CommonResponseUtil
.
success
(
resultMap
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/fegin/IotFeign.java
View file @
b25b6eb9
...
...
@@ -25,4 +25,17 @@ public interface IotFeign {
@RequestParam
(
value
=
"deviceName"
)
String
deviceName
,
@RequestParam
(
required
=
false
,
value
=
"fieldKey"
)
String
fieldKey
);
@RequestMapping
(
value
=
"/v1/livedata/page"
,
method
=
RequestMethod
.
GET
,
consumes
=
"application/json"
)
ResponseModel
selectPage
(
@RequestHeader
(
"appKey"
)
String
appKey
,
@RequestHeader
(
"product"
)
String
product
,
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
value
=
"timeStart"
)
String
beginDate
,
@RequestParam
(
value
=
"timeEnd"
)
String
endDate
,
@RequestParam
(
value
=
"productKey"
)
String
productKey
,
@RequestParam
(
value
=
"deviceName"
)
String
deviceName
,
@RequestParam
(
required
=
false
,
value
=
"fieldKey"
)
String
fieldKey
,
@RequestParam
(
value
=
"current"
)
Integer
current
,
@RequestParam
(
value
=
"size"
)
Integer
size
);
}
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