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
ad35804c
Commit
ad35804c
authored
Dec 27, 2022
by
zhangsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug 修改
parent
e42cbae0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
325 additions
and
116 deletions
+325
-116
OrgUsrMapper.java
...join/amos/boot/module/common/api/mapper/OrgUsrMapper.java
+0
-2
OrgUsrMapper.xml
...ule-common-api/src/main/resources/mapper/OrgUsrMapper.xml
+1
-11
OrgUsrServiceImpl.java
...oot/module/common/biz/service/impl/OrgUsrServiceImpl.java
+1
-1
TopographyController.java
.../yeejoin/equipmanage/controller/TopographyController.java
+323
-102
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/mapper/OrgUsrMapper.java
View file @
ad35804c
...
@@ -140,8 +140,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
...
@@ -140,8 +140,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List
<
OrgUsr
>
companyTreeByUserToPatrolRoute
(
Map
<
String
,
Object
>
param
);
List
<
OrgUsr
>
companyTreeByUserToPatrolRoute
(
Map
<
String
,
Object
>
param
);
String
getBizOrgCodeByOrgCode
(
String
orgCode
);
OrgUsr
queryByBizCode
(
@Param
(
"code"
)
String
code
);
OrgUsr
queryByBizCode
(
@Param
(
"code"
)
String
code
);
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/resources/mapper/OrgUsrMapper.xml
View file @
ad35804c
...
@@ -1165,7 +1165,7 @@ LEFT JOIN (
...
@@ -1165,7 +1165,7 @@ LEFT JOIN (
FROM
FROM
cb_org_usr u
cb_org_usr u
LEFT JOIN cb_firefighters_post cfp ON cfp.org_usr_id = u.sequence_nbr
LEFT JOIN cb_firefighters_post cfp ON cfp.org_usr_id = u.sequence_nbr
LEFT JOIN cb_firefighters cf ON
cf.org_usr_id = u.sequence_nbr
LEFT JOIN cb_firefighters cf ON
CONCAT( u.sequence_nbr, '' ) = cf.org_usr_id
LEFT JOIN cb_fire_team cft ON cft.sequence_nbr = cf.fire_team_id
LEFT JOIN cb_fire_team cft ON cft.sequence_nbr = cf.fire_team_id
WHERE
WHERE
u.is_delete = 0
u.is_delete = 0
...
@@ -1187,14 +1187,4 @@ LEFT JOIN (
...
@@ -1187,14 +1187,4 @@ LEFT JOIN (
and usr.is_delete = false
and usr.is_delete = false
</select>
</select>
<select
id=
"getBizOrgCodeByOrgCode"
resultType=
"java.lang.String"
>
SELECT
biz_org_code
FROM
cb_org_usr
where
is_delete = false
and amos_org_code = #{orgCode}
limit 1
</select>
</mapper>
</mapper>
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/impl/OrgUsrServiceImpl.java
View file @
ad35804c
...
@@ -3536,7 +3536,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
...
@@ -3536,7 +3536,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
public
List
<
OrgMenuDto
>
companyTreeByUserToPatrolRoute
(
ReginParams
reginParams
)
{
public
List
<
OrgMenuDto
>
companyTreeByUserToPatrolRoute
(
ReginParams
reginParams
)
{
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
String
bizOrgCode
=
orgUsrMapper
.
getBizOrgCodeByOrgCode
(
reginParams
.
getCompany
().
getOrgCode
()
);
String
bizOrgCode
=
reginParams
.
getPersonIdentity
().
getCompanyBizOrgCode
(
);
param
.
put
(
"bizOrgCode"
,
bizOrgCode
);
param
.
put
(
"bizOrgCode"
,
bizOrgCode
);
List
<
OrgUsr
>
list
=
orgUsrMapper
.
companyTreeByUserToPatrolRoute
(
param
);
List
<
OrgUsr
>
list
=
orgUsrMapper
.
companyTreeByUserToPatrolRoute
(
param
);
return
buildTreeParallel
(
list
);
return
buildTreeParallel
(
list
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/TopographyController.java
View file @
ad35804c
...
@@ -915,38 +915,67 @@ public class TopographyController extends AbstractBaseController {
...
@@ -915,38 +915,67 @@ public class TopographyController extends AbstractBaseController {
// List<IotDataVO> timeList = vos.stream().filter(x -> x.getKey().equals("time")).collect(Collectors.toList());
// List<IotDataVO> timeList = vos.stream().filter(x -> x.getKey().equals("time")).collect(Collectors.toList());
// List<Date> dates = new ArrayList<>();
// List<Date> dates = new ArrayList<>();
Map
<
String
,
List
<
Date
>>
dateMap
=
new
HashMap
<>();
Map
<
String
,
List
<
Date
>>
dateMap
=
new
HashMap
<>();
String
indexKey
=
null
;
// String indexKey = null;
String
useDate
=
null
;
// String useDate = null;
for
(
IotDataVO
vo
:
vos
)
{
if
(!
vo
.
getKey
().
equals
(
"time"
))
{
indexKey
=
vo
.
getKey
();
for
(
int
i
=
0
;
i
<
vos
.
size
();
i
=
i
+
2
)
{
if
(
useDate
!=
null
)
{
Date
useDate
=
null
;
SimpleDateFormat
sdf1
=
new
SimpleDateFormat
(
DateUtils
.
DATE_TIME_PATTERN
);
String
indexKey
=
null
;
if
(!
dateMap
.
containsKey
(
indexKey
))
{
if
(
vos
.
get
(
i
).
getKey
().
equals
(
"time"
))
{
ArrayList
<
Date
>
dates1
=
new
ArrayList
<>();
String
strDate
=
String
.
valueOf
(
vos
.
get
(
i
).
getValue
()).
substring
(
0
,
19
);
dates1
.
add
(
sdf1
.
parse
(
useDate
));
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
ISO8601_DATE_HOUR_MIN_SEC
);
dateMap
.
put
(
indexKey
,
dates1
);
useDate
=
sdf
.
parse
(
strDate
);
}
else
{
indexKey
=
String
.
valueOf
(
vos
.
get
(
i
+
1
).
getKey
());
dateMap
.
get
(
indexKey
).
add
(
sdf1
.
parse
(
useDate
));
}
indexKey
=
null
;
}
}
else
{
}
else
{
String
value
=
String
.
valueOf
(
vo
.
getValue
());
String
strDate
=
String
.
valueOf
(
vos
.
get
(
i
+
1
).
getValue
()).
substring
(
0
,
19
);
String
strDate
=
value
.
substring
(
0
,
19
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
ISO8601_DATE_HOUR_MIN_SEC
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
ISO8601_DATE_HOUR_MIN_SEC
);
SimpleDateFormat
sdf1
=
new
SimpleDateFormat
(
DateUtils
.
DATE_TIME_PATTERN
);
useDate
=
sdf
.
parse
(
strDate
);
logger
.
info
(
"返回时间===================================("
+
vo
.
getValue
()
+
") ======================================="
);
indexKey
=
String
.
valueOf
(
vos
.
get
(
i
).
getKey
());
sdf
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
}
Date
date
=
sdf
.
parse
(
strDate
);
if
(!
dateMap
.
containsKey
(
indexKey
))
{
String
time
=
DateTimeUtil
.
format
(
date
,
DateTimeUtil
.
ISO_DATE_HOUR24_MIN_SEC
);
ArrayList
<
Date
>
dates1
=
new
ArrayList
<>();
if
(
indexKey
==
null
)
{
dates1
.
add
(
useDate
);
useDate
=
time
;
dateMap
.
put
(
indexKey
,
dates1
);
}
}
else
{
// dates.add(sdf1.parse(time));
dateMap
.
get
(
indexKey
).
add
(
useDate
);
logger
.
info
(
"返回时间===================================("
+
sdf1
.
parse
(
time
)
+
") ======================================="
);
}
}
}
}
// 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
);
List
<
EquipmentSpecificIndex
>
indexes
=
equipmentSpecificIndexMapper
.
getEquipmentSpeIndexByIotCodeAndTrend
(
iotCode
);
...
@@ -1067,96 +1096,59 @@ public class TopographyController extends AbstractBaseController {
...
@@ -1067,96 +1096,59 @@ public class TopographyController extends AbstractBaseController {
List
<
String
>
split
=
Arrays
.
asList
(
equipId
.
split
(
","
));
EquipmentSpecific
equipmentSpecific
=
equipmentSpecificService
.
getById
(
equipId
);
String
allKeys
=
null
;
String
iotCode
=
equipmentSpecific
.
getIotCode
();
String
names
=
null
;
List
<
IotIndexItemVo
>
iotIndexItemVos
=
new
ArrayList
<>();
List
<
IotIndexItemVo
>
iotIndexItemVoListNew
=
new
ArrayList
<>();
Map
<
String
,
String
>
keyIotMap
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
typeNameMap
=
new
HashMap
<>();
Map
<
String
,
String
>
typeCodeAndIndexKeyMap
=
new
HashMap
<>();
List
<
String
>
typeCodeList
=
new
ArrayList
<>();
List
<
String
>
typeNameList
=
new
ArrayList
<>();
List
<
String
>
indexKeyList
=
new
ArrayList
<>();
List
<
EquipmentIndex
>
equipmentSpecifics
=
equipmentIndexService
.
getPerfQutoaIotList
(
Long
.
valueOf
(
equipId
));
for
(
String
specificId
:
split
)
{
EquipmentSpecific
equipmentSpecific
=
equipmentSpecificService
.
getById
(
specificId
);
String
iotCode
=
equipmentSpecific
.
getIotCode
();
List
<
EquipmentIndex
>
equipmentSpecifics
=
equipmentIndexService
.
getPerfQutoaIotList
(
Long
.
valueOf
(
specificId
));
if
(
equipmentSpecifics
.
size
()
==
0
)
{
return
CommonResponseUtil
.
success
();
}
String
allKeys
;
String
names
;
Map
<
String
,
String
>
map
=
new
HashMap
<>();
List
<
IotIndexItemVo
>
iotIndexItemVos
=
new
ArrayList
<>();
if
(
equipmentSpecifics
.
size
()
==
0
)
{
equipmentSpecifics
.
stream
().
forEach
((
e
)->{
return
CommonResponseUtil
.
success
();
IotIndexItemVo
itemVo
=
new
IotIndexItemVo
();
if
(!
e
.
getIsTrend
())
{
map
.
put
(
e
.
getPerfQuotaDefinitionId
(),
e
.
getPerfQuotaName
());
itemVo
.
setKey
(
e
.
getPerfQuotaDefinitionId
());
itemVo
.
setName
(
e
.
getPerfQuotaName
());
itemVo
.
setColor
(
e
.
getEmergencyLevelColor
());
iotIndexItemVos
.
add
(
itemVo
);
}
}
});
equipmentSpecifics
.
stream
().
forEach
((
e
)->{
IotIndexItemVo
itemVo
=
new
IotIndexItemVo
();
IotIndexItemVo
indexItemVo
=
new
IotIndexItemVo
();
if
(!
e
.
getIsTrend
())
{
if
(!
typeNameMap
.
containsKey
(
e
.
getTypeCode
()))
{
indexItemVo
.
setKey
(
e
.
getTypeCode
());
indexItemVo
.
setName
(
e
.
getTypeName
());
indexItemVo
.
setColor
(
e
.
getEmergencyLevelColor
());
iotIndexItemVoListNew
.
add
(
indexItemVo
);
}
map
.
put
(
e
.
getPerfQuotaDefinitionId
(),
e
.
getPerfQuotaName
());
allKeys
=
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getPerfQuotaDefinitionId
).
collect
(
Collectors
.
joining
(
","
));
typeNameMap
.
put
(
e
.
getTypeCode
(),
e
.
getTypeName
());
names
=
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getPerfQuotaName
).
collect
(
Collectors
.
joining
(
","
));
itemVo
.
setKey
(
e
.
getPerfQuotaDefinitionId
());
itemVo
.
setName
(
e
.
getPerfQuotaName
());
itemVo
.
setColor
(
e
.
getEmergencyLevelColor
());
keyIotMap
.
put
(
e
.
getPerfQuotaDefinitionId
()
+
iotCode
,
iotCode
);
iotIndexItemVos
.
add
(
itemVo
);
typeCodeAndIndexKeyMap
.
put
(
e
.
getPerfQuotaDefinitionId
(),
e
.
getTypeCode
());
}
});
if
(!
CollectionUtils
.
isEmpty
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeCode
).
distinct
().
collect
(
Collectors
.
toList
())))
{
typeCodeList
.
addAll
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeCode
).
distinct
().
collect
(
Collectors
.
toList
()));
}
if
(!
CollectionUtils
.
isEmpty
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeName
).
distinct
().
collect
(
Collectors
.
toList
())))
{
typeNameList
.
addAll
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeName
).
distinct
().
collect
(
Collectors
.
toList
()));
}
if
(!
CollectionUtils
.
isEmpty
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
t
->
{
return
t
.
getPerfQuotaDefinitionId
()
+
iotCode
;
}).
distinct
().
collect
(
Collectors
.
toList
())))
{
indexKeyList
.
addAll
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
t
->
{
return
t
.
getPerfQuotaDefinitionId
()
+
iotCode
;
}).
distinct
().
collect
(
Collectors
.
toList
()));
}
}
allKeys
=
typeCodeList
.
stream
().
distinct
().
collect
(
Collectors
.
joining
(
","
));
names
=
typeNameList
.
stream
().
distinct
().
collect
(
Collectors
.
joining
(
","
));
String
parmfieldKey
=
""
;
String
parmfieldKey
=
""
;
String
parmfieldName
=
""
;
String
parmfieldName
=
""
;
if
(
StringUtils
.
isEmpty
(
fieldKey
)
)
{
if
(
StringUtils
.
isEmpty
(
fieldKey
)
)
{
parmfieldKey
=
allKeys
;
parmfieldKey
=
allKeys
;
parmfieldName
=
names
;
}
else
{
}
else
{
parmfieldKey
=
fieldKey
;
parmfieldKey
=
fieldKey
;
for
(
String
s:
fieldKey
.
split
(
","
)
)
{
for
(
String
s:
fieldKey
.
split
(
","
)
)
{
parmfieldName
=
parmfieldName
+
typeNameM
ap
.
get
(
s
)
+
","
;
parmfieldName
=
parmfieldName
+
m
ap
.
get
(
s
)
+
","
;
}
}
}
}
String
prefix
=
null
;
String
suffix
=
null
;
if
(
StringUtil
.
isNotEmpty
(
iotCode
)
&&
iotCode
.
length
()
>
8
)
{
prefix
=
iotCode
.
substring
(
0
,
8
);
suffix
=
iotCode
.
substring
(
8
);
}
else
{
return
CommonResponseUtil
.
failure
(
"装备物联编码不存在或编码错误,请确认!"
);
}
ResponseModel
entity
=
null
;
ResponseModel
entity
=
null
;
String
[]
filedKeyArr
=
parmfieldKey
.
split
(
","
);
String
[]
filedKeyArr
=
parmfieldKey
.
split
(
","
);
List
<
IotIndexResMinotVo
>
res
=
new
ArrayList
<>();
List
<
IotIndexResMinotVo
>
res
=
new
ArrayList
<>();
IotIndexResMinotFinalVo
indexResMinotFinalVo
=
new
IotIndexResMinotFinalVo
();
IotIndexResMinotFinalVo
indexResMinotFinalVo
=
new
IotIndexResMinotFinalVo
();
List
<
Date
>
datesFinal
=
new
ArrayList
<>();
List
<
Date
>
datesFinal
=
new
ArrayList
<>();
for
(
String
indexKey
:
indexKeyList
)
{
for
(
String
st
:
filedKeyArr
)
{
String
prefix
=
null
;
String
suffix
=
null
;
String
iotCode
=
keyIotMap
.
get
(
indexKey
);
String
st
=
""
;
if
(
StringUtil
.
isNotEmpty
(
iotCode
)
&&
iotCode
.
length
()
>
8
)
{
prefix
=
iotCode
.
substring
(
0
,
8
);
suffix
=
iotCode
.
substring
(
8
);
st
=
indexKey
.
substring
(
0
,
indexKey
.
length
()
-
16
);
}
else
{
return
CommonResponseUtil
.
failure
(
"装备物联编码不存在或编码错误,请确认!"
);
}
try
{
try
{
entity
=
iotFeign
.
selectList
(
getAppKey
(),
getProduct
(),
getToken
(),
beginDate
,
endDate
,
prefix
,
suffix
,
st
);
entity
=
iotFeign
.
selectList
(
getAppKey
(),
getProduct
(),
getToken
(),
beginDate
,
endDate
,
prefix
,
suffix
,
st
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -1268,12 +1260,12 @@ public class TopographyController extends AbstractBaseController {
...
@@ -1268,12 +1260,12 @@ public class TopographyController extends AbstractBaseController {
if
(
iotData
.
size
()
==
0
)
{
if
(
iotData
.
size
()
==
0
)
{
fullData
(
iotIndexItemVos
,
iotData
,
times
,
map
);
fullData
(
iotIndexItemVos
,
iotData
,
times
,
map
);
}
}
List
<
IotIndexResItemVo
>
iotIndexResItemVos
=
doIndexData
(
iotData
,
typeNameMap
,
typeCodeAndIndexKeyMap
);
indexResMinotFinalVo
.
setTimes
(
times
);
indexResMinotFinalVo
.
setTimes
(
times
);
indexResMinotFinalVo
.
setNameKey
(
StringUtils
.
isEmpty
(
fieldKey
)
?
allKeys
.
toString
().
split
(
","
)
:
fieldKey
.
split
(
","
));
indexResMinotFinalVo
.
setNameKey
(
StringUtils
.
isEmpty
(
fieldKey
)
?
allKeys
.
split
(
","
)
:
fieldKey
.
split
(
","
));
indexResMinotFinalVo
.
setName
(
StringUtils
.
isEmpty
(
fieldKey
)
?
names
.
toString
().
split
(
","
)
:
parmfieldName
.
split
(
","
));
indexResMinotFinalVo
.
setName
(
StringUtils
.
isEmpty
(
fieldKey
)
?
names
.
split
(
","
)
:
parmfieldName
.
split
(
","
));
indexResMinotFinalVo
.
setItems
(
iotIndexItemVo
ListNew
);
indexResMinotFinalVo
.
setItems
(
iotIndexItemVo
s
);
indexResMinotFinalVo
.
setIotData
(
iot
IndexResItemVos
);
indexResMinotFinalVo
.
setIotData
(
iot
Data
);
}
}
return
CommonResponseUtil
.
success
(
indexResMinotFinalVo
);
return
CommonResponseUtil
.
success
(
indexResMinotFinalVo
);
...
@@ -1451,4 +1443,233 @@ public class TopographyController extends AbstractBaseController {
...
@@ -1451,4 +1443,233 @@ public class TopographyController extends AbstractBaseController {
String
time
=
DateTimeUtil
.
format
(
date
,
DateTimeUtil
.
ISO_DATE_HOUR24_MIN_SEC
);
String
time
=
DateTimeUtil
.
format
(
date
,
DateTimeUtil
.
ISO_DATE_HOUR24_MIN_SEC
);
return
sdf1
.
parse
(
time
);
return
sdf1
.
parse
(
time
);
}
}
/***
*
* 根据设备id获取当前设备的物联指标趋势 【水源页面用】
*
* **/
@RequestMapping
(
value
=
"/equipment/trenIotByWater"
,
method
=
RequestMethod
.
GET
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据设备id获取当前设备的物联指标趋势【水源页面】"
,
notes
=
"根据设备id获取当前设备的物联指标趋势【水源页面】"
)
public
ResponseModel
trenIotByWater
(
@RequestParam
(
required
=
false
)
String
totalType
,
@RequestParam
(
required
=
false
)
String
equipId
,
@RequestParam
(
required
=
false
)
String
fieldKey
,
@RequestParam
(
required
=
false
)
String
isTrend
,
@RequestParam
(
required
=
false
)
String
beginDate
,
@RequestParam
(
required
=
false
)
String
endDate
)
throws
Exception
{
List
<
String
>
split
=
Arrays
.
asList
(
equipId
.
split
(
","
));
String
allKeys
=
null
;
String
names
=
null
;
List
<
IotIndexItemVo
>
iotIndexItemVos
=
new
ArrayList
<>();
List
<
IotIndexItemVo
>
iotIndexItemVoListNew
=
new
ArrayList
<>();
Map
<
String
,
String
>
keyIotMap
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
typeNameMap
=
new
HashMap
<>();
Map
<
String
,
String
>
typeCodeAndIndexKeyMap
=
new
HashMap
<>();
List
<
String
>
typeCodeList
=
new
ArrayList
<>();
List
<
String
>
typeNameList
=
new
ArrayList
<>();
List
<
String
>
indexKeyList
=
new
ArrayList
<>();
for
(
String
specificId
:
split
)
{
EquipmentSpecific
equipmentSpecific
=
equipmentSpecificService
.
getById
(
specificId
);
String
iotCode
=
equipmentSpecific
.
getIotCode
();
List
<
EquipmentIndex
>
equipmentSpecifics
=
equipmentIndexService
.
getPerfQutoaIotList
(
Long
.
valueOf
(
specificId
));
if
(
equipmentSpecifics
.
size
()
==
0
)
{
return
CommonResponseUtil
.
success
();
}
equipmentSpecifics
.
stream
().
forEach
((
e
)->{
IotIndexItemVo
itemVo
=
new
IotIndexItemVo
();
IotIndexItemVo
indexItemVo
=
new
IotIndexItemVo
();
if
(!
e
.
getIsTrend
())
{
if
(!
typeNameMap
.
containsKey
(
e
.
getTypeCode
()))
{
indexItemVo
.
setKey
(
e
.
getTypeCode
());
indexItemVo
.
setName
(
e
.
getTypeName
());
indexItemVo
.
setColor
(
e
.
getEmergencyLevelColor
());
iotIndexItemVoListNew
.
add
(
indexItemVo
);
}
map
.
put
(
e
.
getPerfQuotaDefinitionId
(),
e
.
getPerfQuotaName
());
typeNameMap
.
put
(
e
.
getTypeCode
(),
e
.
getTypeName
());
itemVo
.
setKey
(
e
.
getPerfQuotaDefinitionId
());
itemVo
.
setName
(
e
.
getPerfQuotaName
());
itemVo
.
setColor
(
e
.
getEmergencyLevelColor
());
keyIotMap
.
put
(
e
.
getPerfQuotaDefinitionId
()
+
iotCode
,
iotCode
);
iotIndexItemVos
.
add
(
itemVo
);
typeCodeAndIndexKeyMap
.
put
(
e
.
getPerfQuotaDefinitionId
(),
e
.
getTypeCode
());
}
});
if
(!
CollectionUtils
.
isEmpty
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeCode
).
distinct
().
collect
(
Collectors
.
toList
())))
{
typeCodeList
.
addAll
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeCode
).
distinct
().
collect
(
Collectors
.
toList
()));
}
if
(!
CollectionUtils
.
isEmpty
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeName
).
distinct
().
collect
(
Collectors
.
toList
())))
{
typeNameList
.
addAll
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
EquipmentIndex:
:
getTypeName
).
distinct
().
collect
(
Collectors
.
toList
()));
}
if
(!
CollectionUtils
.
isEmpty
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
t
->
{
return
t
.
getPerfQuotaDefinitionId
()
+
iotCode
;
}).
distinct
().
collect
(
Collectors
.
toList
())))
{
indexKeyList
.
addAll
(
equipmentSpecifics
.
stream
().
filter
(
equipmentIndex
->
!
equipmentIndex
.
getIsTrend
()).
map
(
t
->
{
return
t
.
getPerfQuotaDefinitionId
()
+
iotCode
;
}).
distinct
().
collect
(
Collectors
.
toList
()));
}
}
allKeys
=
typeCodeList
.
stream
().
distinct
().
collect
(
Collectors
.
joining
(
","
));
names
=
typeNameList
.
stream
().
distinct
().
collect
(
Collectors
.
joining
(
","
));
String
parmfieldKey
=
""
;
String
parmfieldName
=
""
;
if
(
StringUtils
.
isEmpty
(
fieldKey
)
)
{
parmfieldKey
=
allKeys
;
parmfieldName
=
names
;
}
else
{
parmfieldKey
=
fieldKey
;
for
(
String
s:
fieldKey
.
split
(
","
)
)
{
parmfieldName
=
parmfieldName
+
typeNameMap
.
get
(
s
)
+
","
;
}
}
ResponseModel
entity
=
null
;
String
[]
filedKeyArr
=
parmfieldKey
.
split
(
","
);
List
<
IotIndexResMinotVo
>
res
=
new
ArrayList
<>();
IotIndexResMinotFinalVo
indexResMinotFinalVo
=
new
IotIndexResMinotFinalVo
();
List
<
Date
>
datesFinal
=
new
ArrayList
<>();
for
(
String
indexKey
:
indexKeyList
)
{
String
prefix
=
null
;
String
suffix
=
null
;
String
iotCode
=
keyIotMap
.
get
(
indexKey
);
String
st
=
""
;
if
(
StringUtil
.
isNotEmpty
(
iotCode
)
&&
iotCode
.
length
()
>
8
)
{
prefix
=
iotCode
.
substring
(
0
,
8
);
suffix
=
iotCode
.
substring
(
8
);
st
=
indexKey
.
substring
(
0
,
indexKey
.
length
()
-
16
);
}
else
{
return
CommonResponseUtil
.
failure
(
"装备物联编码不存在或编码错误,请确认!"
);
}
try
{
entity
=
iotFeign
.
selectList
(
getAppKey
(),
getProduct
(),
getToken
(),
beginDate
,
endDate
,
prefix
,
suffix
,
st
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"调用AMOS-API-IOT服务失败,请检查服务是否正常!"
);
}
if
(
200
==
entity
.
getStatus
()
&&
!
ObjectUtils
.
isEmpty
(
entity
.
getResult
()))
{
String
json
=
JSON
.
toJSONString
(
entity
.
getResult
());
List
<
Map
<
String
,
String
>>
listObject
=
(
List
<
Map
<
String
,
String
>>)
JSONArray
.
parse
(
json
);
List
<
IotDataVO
>
vos
=
new
ArrayList
<>();
Map
<
String
,
String
>
timeAndValue
=
new
HashMap
<>();
for
(
Map
<
String
,
String
>
mapList
:
listObject
)
{
for
(
Map
.
Entry
entry
:
mapList
.
entrySet
())
{
if
(!
"name"
.
equals
(
entry
.
getKey
())
&&
!
"deviceName"
.
equals
(
entry
.
getKey
()))
{
IotDataVO
vo
=
new
IotDataVO
();
vo
.
setKey
(
String
.
valueOf
(
entry
.
getKey
()));
vo
.
setValue
(
String
.
valueOf
(
entry
.
getValue
()));
vos
.
add
(
vo
);
}
}
if
(
mapList
.
containsKey
(
st
))
{
timeAndValue
.
put
(
mapList
.
get
(
"time"
),
mapList
.
get
(
st
));
}
}
List
<
IotDataVO
>
timeList
=
vos
.
stream
().
filter
(
x
->
x
.
getKey
().
equals
(
"time"
)).
collect
(
Collectors
.
toList
());
List
<
String
>
dates
=
new
ArrayList
<>();
for
(
IotDataVO
vo
:
timeList
)
{
String
value
=
String
.
valueOf
(
vo
.
getValue
());
dates
.
add
(
value
);
}
List
<
IotDataVO
>
dataList
=
new
ArrayList
<>();
// 处理遥信 时间处理
if
(
totalType
.
equals
(
"hour"
))
{
handle
(
datesFinal
,
dates
,
beginDate
,
st
,
dataList
,
timeAndValue
);
}
else
if
(
totalType
.
equals
(
"day"
))
{
handleDay
(
datesFinal
,
beginDate
,
endDate
,
st
,
dates
,
dataList
,
timeAndValue
);
}
else
if
(
totalType
.
equals
(
"week"
))
{
handWeek
(
beginDate
,
st
,
dates
,
dataList
,
timeAndValue
);
}
else
{
handMonth
(
beginDate
,
st
,
dates
,
dataList
,
timeAndValue
);
}
IotIndexResMinotVo
iotIndexResVo
=
new
IotIndexResMinotVo
();
iotIndexResVo
.
setIotData
(
dataList
);
res
.
add
(
iotIndexResVo
);
}
}
List
<
IotIndexResItemVo
>
iotData
=
new
ArrayList
<>();
for
(
IotIndexResMinotVo
s
:
res
)
{
IotIndexResItemVo
itemVo
=
new
IotIndexResItemVo
();
List
<
Integer
>
list
=
new
ArrayList
<>();
for
(
IotDataVO
v:
s
.
getIotData
())
{
list
.
add
(
Integer
.
parseInt
(
v
.
getValue
().
toString
()));
itemVo
.
setName
(
map
.
get
(
v
.
getKey
()));
itemVo
.
setKey
(
v
.
getKey
());
}
itemVo
.
setData
(
list
.
stream
().
mapToInt
(
i
->
i
).
toArray
());
iotData
.
add
(
itemVo
);
}
if
(
totalType
.
equals
(
"week"
)
||
totalType
.
equals
(
"month"
)
||
totalType
.
equals
(
"hour"
)
||
totalType
.
equals
(
"day"
))
{
List
<
String
>
times
=
null
;
if
(
totalType
.
equals
(
"week"
))
{
times
=
DateUtils
.
getWeeksMap
(
DateUtils
.
dateToStringMonth
(
beginDate
));
}
else
if
(
totalType
.
equals
(
"month"
))
{
String
year
=
beginDate
.
substring
(
0
,
4
);
times
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<=
12
;
i
++)
{
if
(
i
<
10
)
{
String
m
=
year
+
"-"
+
"0"
+
i
;
times
.
add
(
m
);
}
else
{
String
m
=
year
+
"-"
+
i
;
times
.
add
(
m
);
}
}
}
else
if
(
totalType
.
equals
(
"hour"
)
||
totalType
.
equals
(
"day"
))
{
times
=
new
ArrayList
<>();
if
(
totalType
.
equals
(
"hour"
))
{
String
[]
arr
=
DateUtils
.
TWENTY_FOUR
;
Date
date
=
DateUtils
.
dateParse
(
beginDate
,
DateUtils
.
DATE_PATTERN
);
String
dateDayT
=
DateUtils
.
dateFormat
(
date
,
DateUtils
.
DATE_PATTERN
);
if
(
datesFinal
.
size
()
==
0
)
{
for
(
String
str
:
arr
)
{
String
dateDay
=
dateDayT
;
dateDay
=
dateDay
+
str
;
datesFinal
.
add
(
DateUtils
.
dateParse
(
dateDay
,
DateUtils
.
DATE_TIME_PATTERN
));
}
}
}
else
{
if
(
datesFinal
.
size
()
==
0
)
{
datesFinal
.
addAll
(
DateUtils
.
findDaysStr
(
DateUtils
.
dateToString
(
beginDate
),
DateUtils
.
dateToString
(
endDate
)));
}
}
for
(
Date
date
:
datesFinal
)
{
times
.
add
(
DateUtils
.
convertDateToString
(
date
,
totalType
.
equals
(
"hour"
)
?
DateUtils
.
HOUR_PATTERN
:
DateUtils
.
DATE_PATTERN
));
}
}
if
(
iotData
.
size
()
==
0
)
{
fullData
(
iotIndexItemVos
,
iotData
,
times
,
map
);
}
List
<
IotIndexResItemVo
>
iotIndexResItemVos
=
doIndexData
(
iotData
,
typeNameMap
,
typeCodeAndIndexKeyMap
);
indexResMinotFinalVo
.
setTimes
(
times
);
indexResMinotFinalVo
.
setNameKey
(
StringUtils
.
isEmpty
(
fieldKey
)
?
allKeys
.
toString
().
split
(
","
)
:
fieldKey
.
split
(
","
));
indexResMinotFinalVo
.
setName
(
StringUtils
.
isEmpty
(
fieldKey
)
?
names
.
toString
().
split
(
","
)
:
parmfieldName
.
split
(
","
));
indexResMinotFinalVo
.
setItems
(
iotIndexItemVoListNew
);
indexResMinotFinalVo
.
setIotData
(
iotIndexResItemVos
);
}
return
CommonResponseUtil
.
success
(
indexResMinotFinalVo
);
}
}
}
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