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
3f175afd
Commit
3f175afd
authored
Jul 13, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备列表导出优化
parent
b39a9aed
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
62 deletions
+80
-62
common-lib/src/main/java/com/mortals/xhx/feign/site/ISiteFeign.java
.../src/main/java/com/mortals/xhx/feign/site/ISiteFeign.java
+15
-14
device-manager/src/main/java/com/mortals/xhx/busiz/rsp/DeviceInfo.java
...r/src/main/java/com/mortals/xhx/busiz/rsp/DeviceInfo.java
+7
-0
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+23
-27
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
...r/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
+4
-0
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
.../com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
+6
-5
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+7
-4
doc/api.md
doc/api.md
+18
-12
No files found.
common-lib/src/main/java/com/mortals/xhx/feign/site/ISiteFeign.java
View file @
3f175afd
package
com.mortals.xhx.feign.site
;
package
com.mortals.xhx.feign.site
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
...
@@ -30,7 +31,7 @@ public interface ISiteFeign extends IFeign {
...
@@ -30,7 +31,7 @@ public interface ISiteFeign extends IFeign {
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/site/list"
)
@PostMapping
(
value
=
"/site/list"
)
String
list
(
@RequestBody
SitePdu
sitePdu
);
Rest
<
RespData
<
List
<
SitePdu
>>>
list
(
@RequestBody
SitePdu
sitePdu
);
/**
/**
...
@@ -40,7 +41,7 @@ public interface ISiteFeign extends IFeign {
...
@@ -40,7 +41,7 @@ public interface ISiteFeign extends IFeign {
* @return
* @return
*/
*/
@GetMapping
(
value
=
"/site/info"
)
@GetMapping
(
value
=
"/site/info"
)
String
info
(
@RequestParam
(
value
=
"id"
)
Long
id
);
Rest
<
SitePdu
>
info
(
@RequestParam
(
value
=
"id"
)
Long
id
);
/**
/**
* 删除站点
* 删除站点
...
@@ -49,7 +50,7 @@ public interface ISiteFeign extends IFeign {
...
@@ -49,7 +50,7 @@ public interface ISiteFeign extends IFeign {
* @return
* @return
*/
*/
@GetMapping
(
value
=
"/site/delete"
)
@GetMapping
(
value
=
"/site/delete"
)
String
delete
(
Long
[]
ids
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
Rest
<
Void
>
delete
(
Long
[]
ids
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
/**
/**
...
@@ -59,7 +60,7 @@ public interface ISiteFeign extends IFeign {
...
@@ -59,7 +60,7 @@ public interface ISiteFeign extends IFeign {
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/site/save"
)
@PostMapping
(
value
=
"/site/save"
)
String
save
(
@RequestBody
SitePdu
sitePdu
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
Rest
<
RespData
<
SitePdu
>>
save
(
@RequestBody
SitePdu
sitePdu
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
/**
/**
* 获取站点树
* 获取站点树
...
@@ -87,26 +88,26 @@ public interface ISiteFeign extends IFeign {
...
@@ -87,26 +88,26 @@ public interface ISiteFeign extends IFeign {
class
SiteFeignFallbackFactory
implements
FallbackFactory
<
ISiteFeign
>
{
class
SiteFeignFallbackFactory
implements
FallbackFactory
<
ISiteFeign
>
{
@Override
@Override
public
ISiteFeign
create
(
Throwable
t
)
{
public
ISiteFeign
create
(
Throwable
t
)
{
log
.
error
(
"异常:"
,
t
);
log
.
error
(
"异常:"
,
t
);
return
new
ISiteFeign
()
{
return
new
ISiteFeign
()
{
@Override
@Override
public
String
list
(
SitePdu
sitePdu
)
{
public
Rest
<
RespData
<
List
<
SitePdu
>>>
list
(
SitePdu
sitePdu
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法获取站点列表,请稍后再试!"
)
);
return
Rest
.
fail
(
"暂时无法获取站点列表,请稍后再试!"
);
}
}
@Override
@Override
public
String
info
(
Long
id
)
{
public
Rest
<
SitePdu
>
info
(
Long
id
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法获取站点详细,请稍后再试!"
)
);
return
Rest
.
fail
(
"暂时无法获取站点详细,请稍后再试!"
);
}
}
@Override
@Override
public
String
delete
(
Long
[]
ids
,
String
authorization
)
{
public
Rest
<
Void
>
delete
(
Long
[]
ids
,
String
authorization
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法删除站点,请稍后再试!"
)
);
return
Rest
.
fail
(
"暂时无法删除站点,请稍后再试!"
);
}
}
@Override
@Override
public
String
save
(
SitePdu
sitePdu
,
String
authorization
)
{
public
Rest
<
RespData
<
SitePdu
>>
save
(
SitePdu
sitePdu
,
String
authorization
)
{
return
JSON
.
toJSONString
(
Rest
.
fail
(
"暂时无法保存站点,请稍后再试!"
)
);
return
Rest
.
fail
(
"暂时无法保存站点,请稍后再试!"
);
}
}
@Override
@Override
...
@@ -116,7 +117,7 @@ class SiteFeignFallbackFactory implements FallbackFactory<ISiteFeign> {
...
@@ -116,7 +117,7 @@ class SiteFeignFallbackFactory implements FallbackFactory<ISiteFeign> {
@Override
@Override
public
Rest
<
List
<
SitePdu
>>
getFlatSitesBySiteId
(
SitePdu
sitePdu
)
{
public
Rest
<
List
<
SitePdu
>>
getFlatSitesBySiteId
(
SitePdu
sitePdu
)
{
return
Rest
.
fail
(
"暂时无法获取站点子站点,请稍后再试!"
);
return
Rest
.
fail
(
"暂时无法获取站点子站点,请稍后再试!"
);
}
}
};
};
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/rsp/DeviceInfo.java
View file @
3f175afd
...
@@ -36,5 +36,12 @@ public class DeviceInfo implements Serializable {
...
@@ -36,5 +36,12 @@ public class DeviceInfo implements Serializable {
*/
*/
private
String
productName
;
private
String
productName
;
/**
* 设备启用状态 (0.停止,1.启用)
*/
private
Integer
enabled
;
private
Integer
source
;
}
}
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
3f175afd
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.DateUtils
;
...
@@ -20,6 +21,7 @@ import com.mortals.xhx.common.code.*;
...
@@ -20,6 +21,7 @@ import com.mortals.xhx.common.code.*;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.DownMsgTask
;
import
com.mortals.xhx.common.utils.DownMsgTask
;
...
@@ -153,6 +155,8 @@ public class DeviceApiController {
...
@@ -153,6 +155,8 @@ public class DeviceApiController {
deviceInfo
.
setSiteName
(
deviceEntity
.
getSiteName
());
deviceInfo
.
setSiteName
(
deviceEntity
.
getSiteName
());
deviceInfo
.
setProductId
(
productEntity
.
getId
());
deviceInfo
.
setProductId
(
productEntity
.
getId
());
deviceInfo
.
setProductName
(
productEntity
.
getProductName
());
deviceInfo
.
setProductName
(
productEntity
.
getProductName
());
deviceInfo
.
setEnabled
(
deviceEntity
.
getEnabled
());
registerResp
.
setDeviceInfo
(
deviceInfo
);
registerResp
.
setDeviceInfo
(
deviceInfo
);
String
content
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
registerResp
),
9
,
DES_STR
,
ENCRYPT_STR
);
String
content
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
registerResp
),
9
,
DES_STR
,
ENCRYPT_STR
);
deviceResp
.
setContent
(
content
);
deviceResp
.
setContent
(
content
);
...
@@ -160,7 +164,7 @@ public class DeviceApiController {
...
@@ -160,7 +164,7 @@ public class DeviceApiController {
deviceEntity
.
setDeviceStatus
(
DeviceStatusEnum
.
在线
.
getValue
());
deviceEntity
.
setDeviceStatus
(
DeviceStatusEnum
.
在线
.
getValue
());
deviceService
.
update
(
deviceEntity
);
deviceService
.
update
(
deviceEntity
);
rsp
.
setData
(
deviceResp
);
rsp
.
setData
(
deviceResp
);
deviceService
.
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ONLINE
);
deviceService
.
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ONLINE
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
...
@@ -210,15 +214,6 @@ public class DeviceApiController {
...
@@ -210,15 +214,6 @@ public class DeviceApiController {
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
DeviceInitResp
deviceInitResp
=
new
DeviceInitResp
();
DeviceInitResp
deviceInitResp
=
new
DeviceInitResp
();
try
{
try
{
List
<
PlatformInfo
>
platformInfoList
=
platformService
.
find
(
new
PlatformEntity
()).
stream
().
map
(
item
->
{
PlatformInfo
platformInfo
=
new
PlatformInfo
();
platformInfo
.
setPlatformId
(
item
.
getId
());
platformInfo
.
setPlatformName
(
item
.
getPlatformName
());
platformInfo
.
setPlatformSn
(
item
.
getPlatformSn
());
return
platformInfo
;
}).
collect
(
Collectors
.
toList
());
deviceInitResp
.
setPlatformList
(
platformInfoList
);
if
(
ObjectUtils
.
isEmpty
(
platformInfoList
))
deviceInitResp
.
setPlatformList
(
new
ArrayList
<>());
List
<
ProductInfo
>
productInfoList
=
productService
.
find
(
new
ProductEntity
()).
stream
().
map
(
item
->
{
List
<
ProductInfo
>
productInfoList
=
productService
.
find
(
new
ProductEntity
()).
stream
().
map
(
item
->
{
ProductInfo
productInfo
=
new
ProductInfo
();
ProductInfo
productInfo
=
new
ProductInfo
();
BeanUtils
.
copyProperties
(
item
,
productInfo
,
BeanUtil
.
getNullPropertyNames
(
item
));
BeanUtils
.
copyProperties
(
item
,
productInfo
,
BeanUtil
.
getNullPropertyNames
(
item
));
...
@@ -237,12 +232,11 @@ public class DeviceApiController {
...
@@ -237,12 +232,11 @@ public class DeviceApiController {
deviceInitResp
.
setFirmList
(
firmList
);
deviceInitResp
.
setFirmList
(
firmList
);
if
(
ObjectUtils
.
isEmpty
(
firmList
))
deviceInitResp
.
setFirmList
(
new
ArrayList
<>());
if
(
ObjectUtils
.
isEmpty
(
firmList
))
deviceInitResp
.
setFirmList
(
new
ArrayList
<>());
SitePdu
sitePdu
=
new
SitePdu
();
String
resp
=
siteFeign
.
list
(
new
SitePdu
());
sitePdu
.
setSize
(-
1
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
resp
);
Rest
<
RespData
<
List
<
SitePdu
>>>
resp
=
siteFeign
.
list
(
new
SitePdu
());
if
(
jsonObject
.
getInteger
(
"code"
)
==
1
)
{
if
(
resp
.
getCode
()
==
1
)
{
List
<
SitePdu
>
sitePduList
=
jsonObject
.
getJSONObject
(
"data"
).
getObject
(
"data"
,
new
TypeReference
<
List
<
SitePdu
>>()
{
List
<
SitePdu
>
sitePduList
=
resp
.
getData
().
getData
();
});
List
<
SiteInfo
>
siteInfoList
=
sitePduList
.
stream
().
map
(
site
->
{
List
<
SiteInfo
>
siteInfoList
=
sitePduList
.
stream
().
map
(
site
->
{
SiteInfo
siteInfo
=
new
SiteInfo
();
SiteInfo
siteInfo
=
new
SiteInfo
();
siteInfo
.
setSiteId
(
site
.
getId
());
siteInfo
.
setSiteId
(
site
.
getId
());
...
@@ -309,8 +303,6 @@ public class DeviceApiController {
...
@@ -309,8 +303,6 @@ public class DeviceApiController {
deviceEntity
.
setCreateTime
(
new
Date
());
deviceEntity
.
setCreateTime
(
new
Date
());
deviceEntity
.
setCreateUserId
(
1L
);
deviceEntity
.
setCreateUserId
(
1L
);
deviceService
.
save
(
deviceEntity
,
null
);
deviceService
.
save
(
deviceEntity
,
null
);
}
else
{
}
else
{
//更新
//更新
saveOrUpdate
(
req
,
platformEntity
,
productEntity
,
deviceEntity
);
saveOrUpdate
(
req
,
platformEntity
,
productEntity
,
deviceEntity
);
...
@@ -319,8 +311,8 @@ public class DeviceApiController {
...
@@ -319,8 +311,8 @@ public class DeviceApiController {
deviceService
.
update
(
deviceEntity
,
null
);
deviceService
.
update
(
deviceEntity
,
null
);
}
}
deviceService
.
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ACTIVE
);
//deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity,
DeviceMethodEnum.ACTIVE);
deviceService
.
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ONLINE
);
//deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity,
DeviceMethodEnum.ONLINE);
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
authInfo
.
setHost
(
host
);
authInfo
.
setHost
(
host
);
authInfo
.
setPort
(
port
);
authInfo
.
setPort
(
port
);
...
@@ -347,6 +339,8 @@ public class DeviceApiController {
...
@@ -347,6 +339,8 @@ public class DeviceApiController {
deviceInfo
.
setSiteName
(
deviceEntity
.
getSiteName
());
deviceInfo
.
setSiteName
(
deviceEntity
.
getSiteName
());
deviceInfo
.
setProductId
(
productEntity
.
getId
());
deviceInfo
.
setProductId
(
productEntity
.
getId
());
deviceInfo
.
setProductName
(
productEntity
.
getProductName
());
deviceInfo
.
setProductName
(
productEntity
.
getProductName
());
deviceInfo
.
setEnabled
(
deviceEntity
.
getEnabled
());
deviceInfo
.
setSource
(
deviceEntity
.
getSource
());
registerResp
.
setDeviceInfo
(
deviceInfo
);
registerResp
.
setDeviceInfo
(
deviceInfo
);
String
content
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
registerResp
),
9
,
DES_STR
,
ENCRYPT_STR
);
String
content
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
registerResp
),
9
,
DES_STR
,
ENCRYPT_STR
);
...
@@ -369,7 +363,6 @@ public class DeviceApiController {
...
@@ -369,7 +363,6 @@ public class DeviceApiController {
private
void
saveOrUpdate
(
DeviceReq
req
,
PlatformEntity
platformEntity
,
ProductEntity
productEntity
,
DeviceEntity
deviceEntity
)
{
private
void
saveOrUpdate
(
DeviceReq
req
,
PlatformEntity
platformEntity
,
ProductEntity
productEntity
,
DeviceEntity
deviceEntity
)
{
BeanUtils
.
copyProperties
(
req
,
deviceEntity
,
BeanUtil
.
getNullPropertyNames
(
req
));
BeanUtils
.
copyProperties
(
req
,
deviceEntity
,
BeanUtil
.
getNullPropertyNames
(
req
));
deviceEntity
.
setPlatformId
(
platformEntity
.
getId
());
deviceEntity
.
setPlatformId
(
platformEntity
.
getId
());
deviceEntity
.
setPlatformName
(
platformEntity
.
getPlatformName
());
deviceEntity
.
setPlatformName
(
platformEntity
.
getPlatformName
());
...
@@ -385,7 +378,9 @@ public class DeviceApiController {
...
@@ -385,7 +378,9 @@ public class DeviceApiController {
deviceEntity
.
setDeviceCode
(
req
.
getDeviceCode
());
deviceEntity
.
setDeviceCode
(
req
.
getDeviceCode
());
deviceEntity
.
setEnabled
(
YesNoEnum
.
YES
.
getValue
());
deviceEntity
.
setEnabled
(
YesNoEnum
.
YES
.
getValue
());
deviceEntity
.
setDeviceStatus
(
DeviceStatusEnum
.
离线
.
getValue
());
deviceEntity
.
setDeviceStatus
(
DeviceStatusEnum
.
未激活
.
getValue
());
deviceEntity
.
setSource
(
req
.
getSource
());
}
}
/**
/**
...
@@ -402,7 +397,7 @@ public class DeviceApiController {
...
@@ -402,7 +397,7 @@ public class DeviceApiController {
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
try
{
DownMsgTask
downMsgTask
=
new
DownMsgTask
(
list
,
platformService
,
productService
,
deviceService
,
deviceLogService
);
DownMsgTask
downMsgTask
=
new
DownMsgTask
(
list
,
platformService
,
productService
,
deviceService
,
deviceLogService
);
sendTaskThreadPool
.
execute
(
downMsgTask
);
sendTaskThreadPool
.
execute
(
downMsgTask
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
log
.
error
(
"接收数据失败"
,
e
);
...
@@ -525,7 +520,7 @@ public class DeviceApiController {
...
@@ -525,7 +520,7 @@ public class DeviceApiController {
}
}
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
throw
new
AppException
(
PLATFORM_IS_EMPTY
,
PLATFORM_IS_EMPTY_CONTENT
);
throw
new
AppException
(
PLATFORM_IS_EMPTY
,
PLATFORM_IS_EMPTY_CONTENT
);
}
}
deviceEntity
=
new
DeviceEntity
();
deviceEntity
=
new
DeviceEntity
();
...
@@ -557,17 +552,17 @@ public class DeviceApiController {
...
@@ -557,17 +552,17 @@ public class DeviceApiController {
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
DEVICE_CODE_IS_EMPTY
,
DEVICE_CODE_IS_EMPTY_CONTENT
);
throw
new
AppException
(
DEVICE_CODE_IS_EMPTY
,
DEVICE_CODE_IS_EMPTY_CONTENT
);
}
}
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
req
.
getProductCode
()));
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
req
.
getProductCode
()));
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
PRODUCT_IS_EMPTY
,
PRODUCT_IS_EMPTY_CONTENT
);
throw
new
AppException
(
PRODUCT_IS_EMPTY
,
PRODUCT_IS_EMPTY_CONTENT
);
}
}
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
throw
new
AppException
(
PLATFORM_IS_EMPTY
,
PLATFORM_IS_EMPTY_CONTENT
);
throw
new
AppException
(
PLATFORM_IS_EMPTY
,
PLATFORM_IS_EMPTY_CONTENT
);
}
}
deviceEntity
.
setDeviceName
(
req
.
getDeviceName
());
deviceEntity
.
setDeviceName
(
req
.
getDeviceName
());
...
@@ -650,6 +645,7 @@ public class DeviceApiController {
...
@@ -650,6 +645,7 @@ public class DeviceApiController {
deviceEntity
.
setCreateUserId
(
1L
);
deviceEntity
.
setCreateUserId
(
1L
);
deviceService
.
getDeviceDao
().
insert
(
deviceEntity
);
deviceService
.
getDeviceDao
().
insert
(
deviceEntity
);
deviceService
.
putCache
(
deviceEntity
.
getDeviceCode
(),
deviceEntity
);
deviceService
.
putCache
(
deviceEntity
.
getDeviceCode
(),
deviceEntity
);
throw
new
AppException
(
DEVICE_CONFIG_IS_EMPTY
,
DEVICE_CONFIG_IS_EMPTY_CONTENT
);
}
}
return
deviceEntity
;
return
deviceEntity
;
...
...
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
View file @
3f175afd
...
@@ -101,4 +101,8 @@ public interface ErrorCode {
...
@@ -101,4 +101,8 @@ public interface ErrorCode {
public
static
final
int
SITEID_IS_EMPTY
=
1007
;
public
static
final
int
SITEID_IS_EMPTY
=
1007
;
public
static
final
String
SITEID_IS_EMPTY_CONTENT
=
"站点ID为空!"
;
public
static
final
String
SITEID_IS_EMPTY_CONTENT
=
"站点ID为空!"
;
public
static
final
int
DEVICE_CONFIG_IS_EMPTY
=
1008
;
public
static
final
String
DEVICE_CONFIG_IS_EMPTY_CONTENT
=
"设备创建,请完善设备配置信息!"
;
}
}
device-manager/src/main/java/com/mortals/xhx/daemon/task/DeviceTotalStatTaskImpl.java
View file @
3f175afd
...
@@ -3,6 +3,7 @@ package com.mortals.xhx.daemon.task;
...
@@ -3,6 +3,7 @@ package com.mortals.xhx.daemon.task;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.service.ITaskExcuteService
;
...
@@ -11,6 +12,7 @@ import com.mortals.xhx.common.code.DeviceStatusEnum;
...
@@ -11,6 +12,7 @@ import com.mortals.xhx.common.code.DeviceStatusEnum;
import
com.mortals.xhx.common.code.LogTypeEnum
;
import
com.mortals.xhx.common.code.LogTypeEnum
;
import
com.mortals.xhx.common.code.SendStatusEnum
;
import
com.mortals.xhx.common.code.SendStatusEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity
;
import
com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity
;
...
@@ -100,11 +102,10 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
...
@@ -100,11 +102,10 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
deviceStatEntity
.
setDeviceAddCount
(
deviceTotalCount
-
yesterdayDeviceStat
.
getDeviceTotalCount
());
deviceStatEntity
.
setDeviceAddCount
(
deviceTotalCount
-
yesterdayDeviceStat
.
getDeviceTotalCount
());
//站点数量
//站点数量
String
resp
=
siteFeign
.
list
(
new
SitePdu
());
Rest
<
RespData
<
List
<
SitePdu
>>>
resp
=
siteFeign
.
list
(
new
SitePdu
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
resp
);
if
(
jsonObject
.
getInteger
(
"code"
)
==
1
)
{
if
(
resp
.
getCode
()==
1
)
{
List
<
SitePdu
>
sitePduList
=
jsonObject
.
getJSONObject
(
"data"
).
getObject
(
"data"
,
new
TypeReference
<
List
<
SitePdu
>>()
{
List
<
SitePdu
>
sitePduList
=
resp
.
getData
().
getData
();
});
deviceStatEntity
.
setSiteTotalCount
(
sitePduList
.
size
());
deviceStatEntity
.
setSiteTotalCount
(
sitePduList
.
size
());
deviceStatEntity
.
setSiteAddCount
(
sitePduList
.
size
()
-
yesterdayDeviceStat
.
getSiteTotalCount
());
deviceStatEntity
.
setSiteAddCount
(
sitePduList
.
size
()
-
yesterdayDeviceStat
.
getSiteTotalCount
());
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
3f175afd
...
@@ -176,7 +176,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -176,7 +176,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
Set
<
TopicPartitionInfo
>
topicPartitionInfos
=
new
HashSet
<>();
Set
<
TopicPartitionInfo
>
topicPartitionInfos
=
new
HashSet
<>();
topicPartitionInfos
.
add
(
topicPartitionInfo
);
topicPartitionInfos
.
add
(
topicPartitionInfo
);
mainConsumer
.
subscribe
(
topicPartitionInfos
);
mainConsumer
.
subscribe
(
topicPartitionInfos
);
//新增设备通知第三方平台
//新增设备通知第三方平台,先新增后激活
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ADD
);
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ACTIVE
);
sendThirdParty
(
deviceEntity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ACTIVE
);
}
}
...
@@ -210,7 +211,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -210,7 +211,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
registerRabbitQueue
(
entity
,
platformEntity
,
productEntity
);
registerRabbitQueue
(
entity
,
platformEntity
,
productEntity
);
//新增设备通知第三方平台
//新增设备通知第三方平台
sendThirdParty
(
entity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
ADD
);
//
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ADD);
}
else
{
}
else
{
throw
new
AppException
(
"产品或平台不存在!"
);
throw
new
AppException
(
"产品或平台不存在!"
);
}
}
...
@@ -251,8 +252,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -251,8 +252,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
!
ObjectUtils
.
isEmpty
(
productEntity
))
{
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
!
ObjectUtils
.
isEmpty
(
productEntity
))
{
//注册rabbmit相关队列与绑定
//注册rabbmit相关队列与绑定
registerRabbitQueue
(
entity
,
platformEntity
,
productEntity
);
registerRabbitQueue
(
entity
,
platformEntity
,
productEntity
);
//新增设备通知第三方平台
//新增设备通知第三方平台 激活后的设备才通知
sendThirdParty
(
entity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
UPDATE
);
if
(
entity
.
getDeviceStatus
()>
0
){
sendThirdParty
(
entity
,
productEntity
,
platformEntity
,
DeviceMethodEnum
.
UPDATE
);
}
}
}
super
.
updateAfter
(
entity
,
context
);
super
.
updateAfter
(
entity
,
context
);
}
}
...
...
doc/api.md
View file @
3f175afd
...
@@ -123,6 +123,13 @@ rabbmitInfo|Object|rabbmit相关链接信息|-
...
@@ -123,6 +123,13 @@ rabbmitInfo|Object|rabbmit相关链接信息|-
serviceInfo|Object|服务接口连接信息|-
serviceInfo|Object|服务接口连接信息|-
 
homeUrl|String|首页|-
 
homeUrl|String|首页|-
 
serverUrl|String|前端服务接口地址|-
 
serverUrl|String|前端服务接口地址|-
deviceInfo|Object|设备基础信息|-
 
siteId|Long|站点ID|-
 
siteCode|String|站点编码|-
 
siteName|String|站点名称|-
 
productId|Long|设备产品类型Id|-
 
productName|String|设备产品类型|-
 
enabled|Integer|设备启用状态 (0.停止,1.启用)|-
**响应消息样例:**
**响应消息样例:**
...
@@ -163,10 +170,6 @@ serviceInfo|Object|服务接口连接信息|-
...
@@ -163,10 +170,6 @@ serviceInfo|Object|服务接口连接信息|-
code|Integer|结果码(-1.失败,1.成功)|-
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
msg|String|消息|-
data|object|数据对象|-
data|object|数据对象|-
 
platformList|array|平台列表|数组
  
platformId|Long|平台id|-
  
platformName|String|名称|-
  
platformSn|String|编码|-
 
productList|array|产品列表|数组
 
productList|array|产品列表|数组
  
productId|Long|产品id|-
  
productId|Long|产品id|-
  
productName|String|产品名称|-
  
productName|String|产品名称|-
...
@@ -191,13 +194,6 @@ data|object|数据对象|-
...
@@ -191,13 +194,6 @@ data|object|数据对象|-
"deviceFirmname": "四川新鸿翔"
"deviceFirmname": "四川新鸿翔"
}
}
],
],
"platformList": [
{
"platformId": 1,
"platformName": "排号系统",
"platformSn": "phxt"
}
],
"productList": [
"productList": [
{
{
"productCode": "pdj",
"productCode": "pdj",
...
@@ -377,7 +373,16 @@ rabbmitInfo|Object|rabbmit相关链接信息|-
...
@@ -377,7 +373,16 @@ rabbmitInfo|Object|rabbmit相关链接信息|-
serviceInfo|Object|服务接口连接信息|-
serviceInfo|Object|服务接口连接信息|-
 
homeUrl|String|首页|-
 
homeUrl|String|首页|-
 
serverUrl|String|前端服务接口地址|-
 
serverUrl|String|前端服务接口地址|-
serviceInfo|Object|服务接口连接信息|-
 
homeUrl|String|首页|-
 
serverUrl|String|前端服务接口地址|-
deviceInfo|Object|设备基础信息|-
 
siteId|Long|站点ID|-
 
siteCode|String|站点编码|-
 
siteName|String|站点名称|-
 
productId|Long|设备产品类型Id|-
 
productName|String|设备产品类型|-
 
enabled|Integer|设备启用状态 (0.停止,1.启用)|-
**响应消息样例:**
**响应消息样例:**
```
```
...
@@ -671,6 +676,7 @@ key|String|消息唯一标识|是|-
...
@@ -671,6 +676,7 @@ key|String|消息唯一标识|是|-
1005|所属平台不存在!请在后台添加后再激活|-
1005|所属平台不存在!请在后台添加后再激活|-
1006|当前设备所属产品平台未配置,请在后台配置后再激活|-
1006|当前设备所属产品平台未配置,请在后台配置后再激活|-
1007|站点ID为空|-
1007|站点ID为空|-
1008|设备已创建,请完善设备配置信息|-
-1|系统内部异常|-
-1|系统内部异常|-
...
...
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