Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
266f2b47
Commit
266f2b47
authored
Jun 19, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加设备上线和下线的业务日志记录
parent
f800ac00
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
187 additions
and
50 deletions
+187
-50
common-lib/src/main/java/com/mortals/xhx/feign/site/ISiteFeign.java
.../src/main/java/com/mortals/xhx/feign/site/ISiteFeign.java
+7
-0
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+1
-11
device-manager/src/main/java/com/mortals/xhx/module/site/model/SiteTreeSelect.java
...ava/com/mortals/xhx/module/site/model/SiteTreeSelect.java
+119
-9
device-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteServiceImpl.java
...mortals/xhx/module/site/service/impl/SiteServiceImpl.java
+25
-30
device-manager/src/main/java/com/mortals/xhx/module/sitestat/service/impl/SitestatServiceImpl.java
...xhx/module/sitestat/service/impl/SitestatServiceImpl.java
+35
-0
No files found.
common-lib/src/main/java/com/mortals/xhx/feign/site/ISiteFeign.java
View file @
266f2b47
...
@@ -89,6 +89,8 @@ public interface ISiteFeign extends IFeign {
...
@@ -89,6 +89,8 @@ public interface ISiteFeign extends IFeign {
Rest
<
List
<
SitePdu
>>
getFlatSitesByAreaCode
(
@RequestBody
SitePdu
sitePdu
);
Rest
<
List
<
SitePdu
>>
getFlatSitesByAreaCode
(
@RequestBody
SitePdu
sitePdu
);
@PostMapping
(
value
=
"/site/countSitesByArea"
)
Rest
<
Integer
>
countSitesByArea
(
@RequestBody
SitePdu
sitePdu
);
}
}
...
@@ -134,6 +136,11 @@ class SiteFeignFallbackFactory implements FallbackFactory<ISiteFeign> {
...
@@ -134,6 +136,11 @@ class SiteFeignFallbackFactory implements FallbackFactory<ISiteFeign> {
public
Rest
<
List
<
SitePdu
>>
getFlatSitesByAreaCode
(
SitePdu
sitePdu
)
{
public
Rest
<
List
<
SitePdu
>>
getFlatSitesByAreaCode
(
SitePdu
sitePdu
)
{
return
Rest
.
fail
(
"暂时无法获取站点子站点,请稍后再试!"
);
return
Rest
.
fail
(
"暂时无法获取站点子站点,请稍后再试!"
);
}
}
@Override
public
Rest
<
Integer
>
countSitesByArea
(
SitePdu
sitePdu
)
{
return
Rest
.
fail
(
"暂时无法获取站点子站点数量,请稍后再试!"
);
}
};
};
}
}
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
266f2b47
...
@@ -304,13 +304,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -304,13 +304,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
Set
<
TopicPartitionInfo
>
set
=
new
HashSet
<>();
Set
<
TopicPartitionInfo
>
set
=
new
HashSet
<>();
set
.
add
(
topicPartitionInfo
);
set
.
add
(
topicPartitionInfo
);
/* if (status == YesNoEnum.YES.getValue()) {
//开启
consumerService.getMainConsumer().subscribe(set);
} else {
//关闭
consumerService.getMainConsumer().unsubscribe(set);
}*/
}
}
...
@@ -346,17 +340,13 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -346,17 +340,13 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
@Override
public
Rest
<
String
>
sendThirdParty
(
DeviceEntity
entity
,
ProductEntity
productEntity
,
PlatformEntity
platformEntity
,
DeviceMethodEnum
update
)
{
public
Rest
<
String
>
sendThirdParty
(
DeviceEntity
entity
,
ProductEntity
productEntity
,
PlatformEntity
platformEntity
,
DeviceMethodEnum
update
)
{
//todo 修改为异步发送消息,当前消息存放到redis的队列中
//todo 修改为异步发送消息,当前消息存放到redis的队列中
DeviceReq
deviceReq
=
new
DeviceReq
();
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
deviceReq
.
setDeviceStatus
(
update
.
getValue
());
deviceReq
.
setDeviceStatus
(
update
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setDeviceInBuilding
(
entity
.
getDeviceInBuilding
()
==
null
?
0
:
entity
.
getDeviceInBuilding
());
deviceReq
.
setDeviceInBuilding
(
entity
.
getDeviceInBuilding
()
==
null
?
0
:
entity
.
getDeviceInBuilding
());
deviceReq
.
setDeviceInFloor
(
entity
.
getDeviceInFloor
()
==
null
?
0
:
entity
.
getDeviceInFloor
());
deviceReq
.
setDeviceInFloor
(
entity
.
getDeviceInFloor
()
==
null
?
0
:
entity
.
getDeviceInFloor
());
//http://192.168.0.98:8090/inter/device/deviceIn
//http://192.168.0.98:8090/inter/device/deviceIn
//判断是否是php,如果不是 则是java 则内部调用
//判断是否是php,如果不是 则是java 则内部调用
if
(
"smartOffice"
.
equals
(
platformEntity
.
getPlatformSn
()))
{
if
(
"smartOffice"
.
equals
(
platformEntity
.
getPlatformSn
()))
{
...
...
device-manager/src/main/java/com/mortals/xhx/module/site/model/SiteTreeSelect.java
View file @
266f2b47
package
com.mortals.xhx.module.site.model
;
package
com.mortals.xhx.module.site.model
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.parser.DefaultJSONParser
;
import
com.alibaba.fastjson.parser.JSONToken
;
import
com.alibaba.fastjson.parser.deserializer.ObjectDeserializer
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.xhx.common.code.DeviceStatusEnum
;
import
com.mortals.xhx.common.code.EnabledEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.utils.SpringUtils
;
import
lombok.Data
;
import
lombok.Data
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.lang.reflect.Type
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -30,6 +48,11 @@ public class SiteTreeSelect implements Serializable {
...
@@ -30,6 +48,11 @@ public class SiteTreeSelect implements Serializable {
*/
*/
private
String
siteCode
;
private
String
siteCode
;
/**
* 站点详细地址
*/
private
String
detailAddress
;
/**
/**
* 节点名称
* 节点名称
*/
*/
...
@@ -38,6 +61,10 @@ public class SiteTreeSelect implements Serializable {
...
@@ -38,6 +61,10 @@ public class SiteTreeSelect implements Serializable {
* 区域编码
* 区域编码
*/
*/
private
String
areaCode
;
private
String
areaCode
;
/**
* 为区域时 层级
*/
private
Integer
level
;
/**
/**
* 是否叶子节点
* 是否叶子节点
*/
*/
...
@@ -62,11 +89,39 @@ public class SiteTreeSelect implements Serializable {
...
@@ -62,11 +89,39 @@ public class SiteTreeSelect implements Serializable {
*/
*/
private
String
icon
;
private
String
icon
;
/**
* 设备总数
*/
private
Integer
deviceTotal
;
/**
* 在线总数
*/
private
Integer
offlineTotal
;
/**
* 离线总数
*/
private
Integer
onlineTotal
;
/**
* 未激活设备数量
*/
private
Integer
UnActiveTotal
;
/**
* 子节点数量
*/
private
Integer
siteCount
;
/**
/**
* 子节点
* 子节点
*/
*/
private
List
<
SiteTreeSelect
>
children
;
private
List
<
SiteTreeSelect
>
children
;
public
SiteTreeSelect
()
{
}
public
SiteTreeSelect
(
AreaEntity
entity
)
{
public
SiteTreeSelect
(
AreaEntity
entity
)
{
//如果是站点,则替换名称和id
//如果是站点,则替换名称和id
...
@@ -93,6 +148,7 @@ public class SiteTreeSelect implements Serializable {
...
@@ -93,6 +148,7 @@ public class SiteTreeSelect implements Serializable {
this
.
siteCode
=
collect
.
stream
().
map
(
item
->
item
.
getSiteCode
()).
collect
(
Collectors
.
joining
(
","
));
this
.
siteCode
=
collect
.
stream
().
map
(
item
->
item
.
getSiteCode
()).
collect
(
Collectors
.
joining
(
","
));
this
.
type
=
"site"
;
this
.
type
=
"site"
;
this
.
icon
=
"el-icon-wind-power"
;
this
.
icon
=
"el-icon-wind-power"
;
this
.
detailAddress
=
collect
.
stream
().
map
(
item
->
item
.
getDetailAddress
()).
collect
(
Collectors
.
joining
(
","
));
this
.
longitude
=
collect
.
stream
().
findFirst
().
map
(
item
->
item
.
getLongitude
()).
orElseGet
(()
->
""
);
this
.
longitude
=
collect
.
stream
().
findFirst
().
map
(
item
->
item
.
getLongitude
()).
orElseGet
(()
->
""
);
this
.
latitude
=
collect
.
stream
().
findFirst
().
map
(
item
->
item
.
getLatitude
()).
orElseGet
(()
->
""
);
this
.
latitude
=
collect
.
stream
().
findFirst
().
map
(
item
->
item
.
getLatitude
()).
orElseGet
(()
->
""
);
}
else
{
}
else
{
...
@@ -101,6 +157,7 @@ public class SiteTreeSelect implements Serializable {
...
@@ -101,6 +157,7 @@ public class SiteTreeSelect implements Serializable {
this
.
type
=
"area"
;
this
.
type
=
"area"
;
this
.
icon
=
"el-icon-place"
;
this
.
icon
=
"el-icon-place"
;
}
}
this
.
level
=
entity
.
getAreaLevel
();
if
(
"False"
.
equalsIgnoreCase
(
entity
.
getHaveSonArea
()))
{
if
(
"False"
.
equalsIgnoreCase
(
entity
.
getHaveSonArea
()))
{
this
.
isLeaf
=
true
;
this
.
isLeaf
=
true
;
//this.children = new ArrayList();
//this.children = new ArrayList();
...
@@ -113,16 +170,69 @@ public class SiteTreeSelect implements Serializable {
...
@@ -113,16 +170,69 @@ public class SiteTreeSelect implements Serializable {
}
}
public
SiteTreeSelect
(
SiteEntity
entity
)
{
// 反序列化器
this
.
id
=
entity
.
getId
().
toString
();
public
static
class
Deserializer
implements
ObjectDeserializer
{
this
.
label
=
entity
.
getSiteName
();
@Override
this
.
isLeaf
=
true
;
public
SiteTreeSelect
deserialze
(
DefaultJSONParser
parser
,
Type
type
,
Object
fieldName
)
{
this
.
type
=
"site"
;
SiteTreeSelect
node
=
new
SiteTreeSelect
();
this
.
icon
=
"el-icon-document"
;
JSONObject
jsonObject
=
parser
.
parseObject
();
node
.
setId
(
jsonObject
.
getString
(
"id"
));
this
.
longitude
=
entity
.
getLongitude
();
node
.
setSiteCode
(
jsonObject
.
getString
(
"siteCode"
));
this
.
latitude
=
entity
.
getLatitude
();
node
.
setLabel
(
jsonObject
.
getString
(
"label"
));
node
.
setAreaCode
(
jsonObject
.
getString
(
"areacode"
));
node
.
setIsLeaf
(
jsonObject
.
getBoolean
(
"isLeaf"
));
node
.
setLongitude
(
jsonObject
.
getString
(
"longitude"
));
node
.
setLatitude
(
jsonObject
.
getString
(
"latitude"
));
node
.
setType
(
jsonObject
.
getString
(
"type"
));
node
.
setIcon
(
jsonObject
.
getString
(
"icon"
));
ISiteFeign
siteFeign
=
SpringUtils
.
getBean
(
ISiteFeign
.
class
);
SitePdu
sitePdu
=
new
SitePdu
();
if
(
"site"
.
equals
(
node
.
getType
()))
{
//统计当前站点下的所有在线 离线 设备总数。
DeviceService
deviceService
=
SpringUtils
.
getBean
(
DeviceService
.
class
);
List
<
DeviceEntity
>
deviceList
=
deviceService
.
find
(
new
DeviceQuery
().
siteId
(
DataUtil
.
converStr2Long
(
node
.
getId
(),
-
1
)));
node
.
setDeviceTotal
(
deviceList
.
size
());
//未激活数量
Long
deviceUnActiveCount
=
deviceList
.
parallelStream
()
.
filter
(
f
->
f
.
getDeviceStatus
()
==
DeviceStatusEnum
.
未激活
.
getValue
())
.
count
();
node
.
setUnActiveTotal
(
deviceUnActiveCount
.
intValue
());
Long
deviceOnlineCount
=
deviceList
.
parallelStream
()
.
filter
(
f
->
f
.
getDeviceStatus
()
>
DeviceStatusEnum
.
未激活
.
getValue
())
.
filter
(
f
->
f
.
getEnabled
()
==
EnabledEnum
.
启用
.
getValue
())
.
filter
(
f
->
f
.
getDeviceStatus
()
==
DeviceStatusEnum
.
在线
.
getValue
())
.
count
();
node
.
setOnlineTotal
(
deviceOnlineCount
.
intValue
());
//离线数量
Long
deviceOfflineCount
=
deviceList
.
parallelStream
()
.
filter
(
f
->
f
.
getDeviceStatus
()
>
DeviceStatusEnum
.
未激活
.
getValue
())
.
filter
(
f
->
f
.
getEnabled
()
==
EnabledEnum
.
启用
.
getValue
())
.
filter
(
f
->
f
.
getDeviceStatus
()
==
DeviceStatusEnum
.
离线
.
getValue
())
.
count
();
node
.
setOfflineTotal
(
deviceOfflineCount
.
intValue
());
}
//todo 统计当前区域下的所有站点数量
sitePdu
.
setAreaCode
(
node
.
getAreaCode
());
Rest
<
Integer
>
rest
=
siteFeign
.
countSitesByArea
(
sitePdu
);
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
node
.
setSiteCount
(
rest
.
getData
());
}
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"children"
);
List
<
SiteTreeSelect
>
children
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
SiteTreeSelect
child
=
JSON
.
parseObject
(
jsonArray
.
getJSONObject
(
i
).
toJSONString
(),
SiteTreeSelect
.
class
);
children
.
add
(
child
);
}
node
.
setChildren
(
children
);
return
node
;
}
@Override
public
int
getFastMatchToken
()
{
return
JSONToken
.
LBRACE
;
}
}
}
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteServiceImpl.java
View file @
266f2b47
...
@@ -6,8 +6,10 @@ import com.mortals.framework.model.Context;
...
@@ -6,8 +6,10 @@ import com.mortals.framework.model.Context;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.common.code.PlatformTypeEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.utils.SyncTreeSiteThread
;
import
com.mortals.xhx.common.utils.SyncTreeSiteThread
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.model.AreaQuery
;
import
com.mortals.xhx.module.area.model.AreaQuery
;
...
@@ -19,6 +21,7 @@ import com.mortals.xhx.module.site.model.SiteTreeSelect;
...
@@ -19,6 +21,7 @@ import com.mortals.xhx.module.site.model.SiteTreeSelect;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -46,6 +49,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
...
@@ -46,6 +49,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
private
AreaService
areaService
;
private
AreaService
areaService
;
@Autowired
@Autowired
private
IUserFeign
userFeign
;
private
IUserFeign
userFeign
;
@Value
(
"${platform.type:cloud}"
)
private
String
platFormType
;
//版本,默认云服务版本
@Autowired
private
ISiteFeign
siteFeign
;
@Override
@Override
protected
void
validData
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
validData
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
...
@@ -189,13 +196,25 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
...
@@ -189,13 +196,25 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override
@Override
public
List
<
SiteTreeSelect
>
getSiteTree
(
Context
context
)
{
public
List
<
SiteTreeSelect
>
getSiteTree
(
Context
context
)
{
List
<
SiteTreeSelect
>
siteTreeSelects
=
siteTreeMap
.
get
(
context
.
getUser
().
getId
());
//判断是单机还是云
//如果所属站点为空返回全节点树
List
<
SiteTreeSelect
>
siteTreeSelects
=
new
ArrayList
<>();
if
(!
ObjectUtils
.
isEmpty
(
siteTreeSelects
))
{
if
(
platFormType
.
equalsIgnoreCase
(
PlatformTypeEnum
.
STANDALONE
.
getValue
()))
{
return
siteTreeSelects
;
siteTreeSelects
=
siteTreeMap
.
get
(
context
.
getUser
().
getId
());
}
else
{
//如果所属站点为空返回全节点树
return
siteTreeMap
.
get
(
0
);
if
(!
ObjectUtils
.
isEmpty
(
siteTreeSelects
))
{
return
siteTreeSelects
;
}
else
{
return
siteTreeMap
.
get
(
0
);
}
}
else
{
//云服务版本,获取站点树
// siteFeign.siteTree()
}
}
return
siteTreeSelects
;
}
}
@Override
@Override
...
@@ -282,20 +301,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
...
@@ -282,20 +301,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override
@Override
public
List
<
SiteEntity
>
getListAllInfoByQuery
(
SiteQuery
query
,
Context
context
)
throws
AppException
{
public
List
<
SiteEntity
>
getListAllInfoByQuery
(
SiteQuery
query
,
Context
context
)
throws
AppException
{
List
<
SiteEntity
>
list
=
this
.
find
(
query
,
context
);
List
<
SiteEntity
>
list
=
this
.
find
(
query
,
context
);
// if (CollectionUtils.isNotEmpty(list)) {
// list.stream().forEach(item -> {
// ModelQuery modelQuery = new ModelQuery();
// List<String> modelIds = StringUtils.converStr2List(item.getModelIds());
// List<Long> ids = modelIds.stream().map(s -> DataUtil.converStr2Long(s.trim(), 0)).collect(Collectors.toList());
// if (ids.isEmpty()) {
// ids.add(0l);
// }
// modelQuery.setIdList(ids);
// List<ModelEntity> modelEntityList = modelService.find(modelQuery);
// item.setModelList(modelEntityList);
// });
// }
return
list
;
return
list
;
}
}
...
@@ -308,16 +313,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
...
@@ -308,16 +313,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override
@Override
public
void
changeUrlPath
(
SiteEntity
siteEntity
)
{
public
void
changeUrlPath
(
SiteEntity
siteEntity
)
{
// if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getLogoPath())) {
// String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_IMAGE_URL, "http://192.168.0.98:11091");
// String fullPath = URLUtil.completeUrl(domain, siteEntity.getLogoPath());
// siteEntity.setLogoFullPath(fullPath);
// }
// if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getModelIds())) {
// List<Long> modelIdlist = StrUtil.split(siteEntity.getModelIds(), ",".charAt(0), -1, true, (String str) -> Long.parseLong(str));
// List<ModelEntity> collect =modelService.find(new ModelQuery().idList(modelIdlist));
// siteEntity.setModelList(collect);
// }
}
}
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/sitestat/service/impl/SitestatServiceImpl.java
View file @
266f2b47
package
com.mortals.xhx.module.sitestat.service.impl
;
package
com.mortals.xhx.module.sitestat.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
...
@@ -226,6 +228,22 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
...
@@ -226,6 +228,22 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
String
token
=
context
.
getUser
().
getToken
();
String
token
=
context
.
getUser
().
getToken
();
if
(!
ObjectUtils
.
isEmpty
(
token
))
{
if
(!
ObjectUtils
.
isEmpty
(
token
))
{
String
resp
=
siteFeign
.
siteTree
(
token
);
String
resp
=
siteFeign
.
siteTree
(
token
);
Rest
<
String
>
rest
=
JSON
.
parseObject
(
resp
,
new
TypeReference
<
Rest
<
String
>>()
{
});
if
(
rest
.
getCode
()==
YesNoEnum
.
YES
.
getValue
()){
String
siteTreeSelectStr
=
rest
.
getData
();
JSONArray
jsonArray
=
JSON
.
parseArray
(
siteTreeSelectStr
);
// if (ObjectUtils.isEmpty(jsonArray)) {
// return new ArrayList<>();
// }
List
<
SiteTreeSelect
>
collect
=
jsonArray
.
stream
().
map
(
item
->
{
SiteTreeSelect
siteTreeSelect
=
JSON
.
parseObject
(
item
.
toString
(),
SiteTreeSelect
.
class
);
return
siteTreeSelect
;
}).
collect
(
Collectors
.
toList
());
}
return
resp
;
return
resp
;
}
}
}
else
{
}
else
{
...
@@ -277,4 +295,21 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
...
@@ -277,4 +295,21 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
String
siteTreeSelectStr
=
"[{\"areaCode\":\"511500000000\",\"children\":[{\"areaCode\":\"511502000000\",\"children\":[{\"areaCode\":\"511502012000\",\"children\":[{\"areaCode\":\"511502012001\",\"icon\":\"el-icon-wind-power\",\"id\":\"4\",\"isLeaf\":true,\"label\":\"东街站点\",\"latitude\":\"2\",\"longitude\":\"1\",\"siteCode\":\"511502012001-0001\",\"type\":\"site\"}],\"icon\":\"el-icon-place\",\"id\":\"1b01f5486d63467aaa24eafbee797b47\",\"isLeaf\":false,\"label\":\"合江门街道\",\"type\":\"area\"}],\"icon\":\"el-icon-wind-power\",\"id\":\"2\",\"isLeaf\":false,\"label\":\"翠屏区市民中心\",\"latitude\":\"31.467450\",\"longitude\":\"104.679114\",\"siteCode\":\"511502000000-0001\",\"type\":\"site\"},{\"areaCode\":\"511521000000\",\"children\":[],\"icon\":\"el-icon-wind-power\",\"id\":\"3\",\"isLeaf\":false,\"label\":\"徐州区办事处\",\"latitude\":\"28.758065\",\"longitude\":\"104.647877\",\"siteCode\":\"511521000000-0001\",\"type\":\"site\"}],\"icon\":\"el-icon-wind-power\",\"id\":\"1\",\"isLeaf\":false,\"label\":\"四川恒升信达科技有限公司\",\"latitude\":\"30.595081\",\"longitude\":\"104.062983\",\"siteCode\":\"511500000000-0001\",\"type\":\"site\"}]"
;
JSONArray
jsonArray
=
JSON
.
parseArray
(
siteTreeSelectStr
);
List
<
SiteTreeSelect
>
collect
=
jsonArray
.
stream
().
map
(
item
->
{
SiteTreeSelect
siteTreeSelect
=
JSON
.
parseObject
(
item
.
toString
(),
SiteTreeSelect
.
class
);
return
siteTreeSelect
;
}).
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
JSON
.
toJSONString
(
collect
));
}
}
}
\ No newline at end of file
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