Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iot-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
iot-service
Commits
b741784f
Commit
b741784f
authored
Aug 14, 2020
by
chenfm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复数据表不存在时报错问题
parent
39fe65bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
DeviceDataServiceImpl.java
...odule/devicemodel/service/impl/DeviceDataServiceImpl.java
+16
-5
No files found.
src/main/java/com/esv/datacenter/iot/module/devicemodel/service/impl/DeviceDataServiceImpl.java
View file @
b741784f
...
...
@@ -60,7 +60,9 @@ public class DeviceDataServiceImpl implements DeviceDataService {
BeanUtils
.
copyProperties
(
dataModelEntity
,
deviceDataVO
);
Map
<
String
,
Object
>
dataMap
=
selectCurrentData
(
deviceId
,
dataModelId
);
deviceDataVO
.
setReportTime
((
Date
)
dataMap
.
get
(
"time"
));
if
(
dataMap
!=
null
&&
dataMap
.
containsKey
(
"time"
))
{
deviceDataVO
.
setReportTime
((
Date
)
dataMap
.
get
(
"time"
));
}
List
<
DataModelPropertyVO
>
propertyList
=
dataModelPropertyService
.
getModelPropertyList
(
dataModelId
);
if
(
propertyList
!=
null
&&
!
propertyList
.
isEmpty
())
{
...
...
@@ -68,12 +70,16 @@ public class DeviceDataServiceImpl implements DeviceDataService {
// List<String> columnNames = new ArrayList<>();
// propertyList.forEach(v -> columnNames.add(v.getPropertyCode()));
for
(
DataModelPropertyVO
dataModelPropertyVO
:
propertyList
)
{
DeviceDataPropertyVO
deviceDataPropertyVO
=
new
DeviceDataPropertyVO
();
BeanUtils
.
copyProperties
(
dataModelPropertyVO
,
deviceDataPropertyVO
);
String
propertyValue
=
String
.
valueOf
(
dataMap
.
get
(
deviceDataPropertyVO
.
getPropertyCode
()));
deviceDataPropertyVO
.
setPropertyValue
(
propertyValue
);
String
propertyCode
=
deviceDataPropertyVO
.
getPropertyCode
();
// 获取最新数据
if
(
dataMap
!=
null
&&
dataMap
.
containsKey
(
propertyCode
))
{
String
propertyValue
=
String
.
valueOf
(
dataMap
.
get
(
propertyCode
));
deviceDataPropertyVO
.
setPropertyValue
(
propertyValue
);
}
// 加入到返回结果集
list
.
add
(
deviceDataPropertyVO
);
}
deviceDataVO
.
setPropertyList
(
list
);
...
...
@@ -88,7 +94,12 @@ public class DeviceDataServiceImpl implements DeviceDataService {
+
tableName
+
" where device_id = ?"
+
" order by time desc limit 1"
;
return
jdbcTemplate
.
queryForMap
(
sql
,
deviceId
);
try
{
return
jdbcTemplate
.
queryForMap
(
sql
,
deviceId
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
}
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