Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sample-form-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
赵啸非
sample-form-platform
Commits
c6ba21e2
Commit
c6ba21e2
authored
Jun 21, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加设备相关信息
parent
fa7b842e
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
2980 additions
and
1976 deletions
+2980
-1976
common-lib/src/main/java/com/mortals/xhx/common/pdu/device/DeviceReq.java
...ain/java/com/mortals/xhx/common/pdu/device/DeviceReq.java
+0
-1
sample-form-manager/db/add.sql
sample-form-manager/db/add.sql
+22
-0
sample-form-manager/src/main/java/com/mortals/xhx/base/framework/aspect/OperlogAspect.java
.../com/mortals/xhx/base/framework/aspect/OperlogAspect.java
+14
-9
sample-form-manager/src/main/java/com/mortals/xhx/common/code/DeviceMethodEnum.java
...in/java/com/mortals/xhx/common/code/DeviceMethodEnum.java
+72
-0
sample-form-manager/src/main/java/com/mortals/xhx/common/code/EnabledEnum.java
...rc/main/java/com/mortals/xhx/common/code/EnabledEnum.java
+65
-0
sample-form-manager/src/main/java/com/mortals/xhx/common/code/OperTypeEnum.java
...c/main/java/com/mortals/xhx/common/code/OperTypeEnum.java
+11
-12
sample-form-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceEntity.java
...ava/com/mortals/xhx/module/device/model/DeviceEntity.java
+96
-321
sample-form-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceQuery.java
...java/com/mortals/xhx/module/device/model/DeviceQuery.java
+1361
-814
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
.../com/mortals/xhx/module/device/service/DeviceService.java
+18
-0
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+70
-0
sample-form-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+148
-12
sample-form-manager/src/main/resources/sqlmap/module/device/DeviceMapper.xml
.../src/main/resources/sqlmap/module/device/DeviceMapper.xml
+1103
-807
No files found.
common-lib/src/main/java/com/mortals/xhx/common/pdu/device/DeviceReq.java
View file @
c6ba21e2
package
com.mortals.xhx.common.pdu.device
;
import
com.fasterxml.jackson.databind.annotation.JsonDeserialize
;
import
lombok.Data
;
import
java.io.Serializable
;
...
...
sample-form-manager/db/add.sql
0 → 100644
View file @
c6ba21e2
-- ----------------------------
2023
-
06
-
21
-- ----------------------------
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`deviceFirmId`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'设备生产厂商ID'
AFTER
siteName
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`deviceFirmname`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'设备生产厂商名称'
AFTER
deviceFirmId
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`ip`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
DEFAULT
NULL
COMMENT
'设备访问ip'
AFTER
deviceFirmname
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`port`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
DEFAULT
NULL
COMMENT
'端口'
AFTER
ip
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`enabled`
tinyint
(
2
)
DEFAULT
NULL
COMMENT
'启用状态 (0.停止,1.启用)'
AFTER
port
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`deviceRemark`
varchar
(
256
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
DEFAULT
NULL
COMMENT
'备注'
AFTER
enabled
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`onlineTime`
datetime
DEFAULT
NULL
COMMENT
'最近上线时间'
AFTER
deviceRemark
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`offlineTime`
datetime
DEFAULT
NULL
COMMENT
'最近离线时间'
AFTER
onlineTime
;
\ No newline at end of file
sample-form-manager/src/main/java/com/mortals/xhx/base/framework/aspect/OperlogAspect.java
View file @
c6ba21e2
...
...
@@ -4,8 +4,10 @@ import java.util.Date;
import
javax.servlet.http.HttpServletRequest
;
import
cn.hutool.core.util.StrUtil
;
import
com.mortals.framework.model.OperateLogPdu
;
import
com.mortals.framework.service.IMessageProduceService
;
import
com.mortals.xhx.common.code.OperTypeEnum
;
import
com.mortals.xhx.system.MessageProducer
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
...
...
@@ -41,9 +43,17 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
public
void
doHandlerLog
(
String
platformMark
,
Long
userId
,
String
userName
,
String
loginName
,
String
requestUrl
,
String
content
,
String
ip
,
Date
logDate
)
{
super
.
doHandlerLog
(
platformMark
,
userId
,
userName
,
loginName
,
requestUrl
,
content
,
ip
,
logDate
);
if
(
ObjectUtils
.
isEmpty
(
userId
))
return
;
operLogService
.
insertOperLog
(
ip
,
requestUrl
,
userId
,
userName
,
loginName
,
content
);
int
operType
=
OperTypeEnum
.
OTHER
.
getValue
();
//判断内容包含
if
(
StrUtil
.
contains
(
content
,
"查询"
)
||
StrUtil
.
contains
(
content
,
"查看"
))
{
operType
=
OperTypeEnum
.
SEARCH
.
getValue
();
}
else
if
(
StrUtil
.
contains
(
content
,
"保存"
)
||
StrUtil
.
contains
(
content
,
"新增"
)
||
StrUtil
.
contains
(
content
,
"修改"
))
{
operType
=
OperTypeEnum
.
SAVE
.
getValue
();
}
else
if
(
StrUtil
.
contains
(
content
,
"删除"
))
{
operType
=
OperTypeEnum
.
DELETE
.
getValue
();
}
OperateLogPdu
operateLogPdu
=
new
OperateLogPdu
();
operateLogPdu
.
initAttrValue
();
operateLogPdu
.
setIp
(
ip
);
...
...
@@ -54,17 +64,13 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
operateLogPdu
.
setPlatformMark
(
platformMark
);
operateLogPdu
.
setLogDate
(
logDate
);
operateLogPdu
.
setContent
(
content
);
operateLogPdu
.
setOperType
(
1
);
operateLogPdu
.
setOperType
(
operType
);
messageProducer
.
syncOperSend
(
operateLogPdu
);
}
@Override
public
void
doHandlerLog
(
String
platformMark
,
String
loginName
,
String
requestUrl
,
String
content
,
String
ip
)
{
// operLogService.insertOperLog(ip, requestUrl, null, "", loginName,
// content);
this
.
doHandlerLog
(
platformMark
,
null
,
""
,
loginName
,
requestUrl
,
content
,
ip
,
new
Date
());
}
@Pointcut
(
"execution(public * com.mortals.xhx..*Controller.*(..))"
)
...
...
@@ -79,7 +85,6 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
// url
logger
.
info
(
"ip[{}]url[{}]"
,
request
.
getRemoteAddr
(),
request
.
getRequestURL
());
// 参数第1和第2个参数为HttpServletRequest request, HttpServletResponse
// response
if
(
joinPoint
.
getArgs
().
length
>
2
)
{
logger
.
info
(
"args={}"
,
joinPoint
.
getArgs
()[
2
]);
}
else
{
...
...
sample-form-manager/src/main/java/com/mortals/xhx/common/code/DeviceMethodEnum.java
0 → 100644
View file @
c6ba21e2
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 设备请求方式,1:新增,2:修改,3:删除,4:激活,5:启用,6:停用
*
* @author zxfei
*/
public
enum
DeviceMethodEnum
{
ADD
(
1
,
"新增"
),
UPDATE
(
2
,
"修改"
),
DEL
(
3
,
"删除"
),
ACTIVE
(
4
,
"激活"
),
ENABLED
(
5
,
"启用"
),
STOP
(
6
,
"停用"
),
ONLINE
(
7
,
"上线"
),
OFFLINE
(
8
,
"下线"
)
;
private
Integer
value
;
private
String
desc
;
DeviceMethodEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
DeviceMethodEnum
getByValue
(
Integer
value
)
{
for
(
DeviceMethodEnum
deviceTypeEnum
:
DeviceMethodEnum
.
values
())
{
if
(
deviceTypeEnum
.
getValue
()
==
value
)
{
return
deviceTypeEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
DeviceMethodEnum
item
:
DeviceMethodEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
sample-form-manager/src/main/java/com/mortals/xhx/common/code/EnabledEnum.java
0 → 100644
View file @
c6ba21e2
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 启用状态 (0.停止,1.启用)枚举类
*
* @author zxfei
*/
public
enum
EnabledEnum
{
停止
(
0
,
"停止"
),
启用
(
1
,
"启用"
);
private
Integer
value
;
private
String
desc
;
EnabledEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
EnabledEnum
getByValue
(
Integer
value
)
{
for
(
EnabledEnum
enabledEnum
:
EnabledEnum
.
values
())
{
if
(
enabledEnum
.
getValue
()
==
value
)
{
return
enabledEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
EnabledEnum
item
:
EnabledEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
sample-form-manager/src/main/java/com/mortals/xhx/common/code/OperTypeEnum.java
View file @
c6ba21e2
...
...
@@ -3,20 +3,19 @@ package com.mortals.xhx.common.code;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by chendilin on 2018/3/7.
*/
public
enum
OperTypeEnum
{
SAVE
(
0
,
"添加"
),
UPDATE
(
1
,
"更新"
),
DELETE
(
2
,
"删除"
),
OTHER
(-
1
,
"其它"
);
SAVE
(
0
,
"添加"
),
UPDATE
(
1
,
"更新"
),
DELETE
(
2
,
"删除"
),
SEARCH
(
3
,
"查询"
),
OTHER
(-
1
,
"其它"
);
private
int
value
;
private
String
msg
;
private
OperTypeEnum
(
int
value
,
String
msg
)
{
private
OperTypeEnum
(
int
value
,
String
msg
)
{
this
.
value
=
value
;
this
.
msg
=
msg
;
}
...
...
@@ -25,11 +24,11 @@ public enum OperTypeEnum {
return
this
.
value
;
}
public
static
Map
<
String
,
String
>
getEnumMap
()
{
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
public
static
Map
<
String
,
String
>
getEnumMap
()
{
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
OperTypeEnum
[]
operTypeEnum
=
OperTypeEnum
.
values
();
for
(
OperTypeEnum
typeEnum
:
operTypeEnum
)
{
resultMap
.
put
(
String
.
valueOf
(
typeEnum
.
value
),
typeEnum
.
msg
);
resultMap
.
put
(
String
.
valueOf
(
typeEnum
.
value
),
typeEnum
.
msg
);
}
return
resultMap
;
}
...
...
sample-form-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceEntity.java
View file @
c6ba21e2
package
com.mortals.xhx.module.device.model
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.ArrayList
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.mortals.framework.annotation.Excel
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.xhx.module.device.model.vo.DeviceVo
;
import
lombok.Data
;
/**
* 设备实体对象
*
* @author zxfei
* @date 2023-02-25
*/
* 设备实体对象
*
* @author zxfei
* @date 2023-06-21
*/
@Data
public
class
DeviceEntity
extends
DeviceVo
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -84,252 +85,34 @@ public class DeviceEntity extends DeviceVo {
* 设备来源(0.旧设备,1.新设备)
*/
private
Integer
source
;
public
DeviceEntity
(){}
/**
* 获取 设备id
* @return Long
*/
public
Long
getDeviceId
(){
return
deviceId
;
}
/**
* 设置 设备id
* @param deviceId
*/
public
void
setDeviceId
(
Long
deviceId
){
this
.
deviceId
=
deviceId
;
}
/**
* 获取 设备名称
* @return String
*/
public
String
getDeviceName
(){
return
deviceName
;
}
/**
* 设置 设备名称
* @param deviceName
*/
public
void
setDeviceName
(
String
deviceName
){
this
.
deviceName
=
deviceName
;
}
/**
* 获取 设备编码
* @return String
*/
public
String
getDeviceCode
(){
return
deviceCode
;
}
/**
* 设置 设备编码
* @param deviceCode
*/
public
void
setDeviceCode
(
String
deviceCode
){
this
.
deviceCode
=
deviceCode
;
}
/**
* 获取 设备的MAC地址
* @return String
*/
public
String
getDeviceMac
(){
return
deviceMac
;
}
/**
* 设置 设备的MAC地址
* @param deviceMac
* 设备生产厂商ID
*/
public
void
setDeviceMac
(
String
deviceMac
){
this
.
deviceMac
=
deviceMac
;
}
/**
* 获取 站点Id
* @return Long
*/
public
Long
getSiteId
(){
return
siteId
;
}
/**
* 设置 站点Id
* @param siteId
*/
public
void
setSiteId
(
Long
siteId
){
this
.
siteId
=
siteId
;
}
private
Long
deviceFirmId
;
/**
* 获取 站点编号,来源基础服务平台
* @return String
* 设备生产厂商名称
*/
public
String
getSiteCode
(){
return
siteCode
;
}
private
String
deviceFirmname
;
/**
* 设置 站点编号,来源基础服务平台
* @param siteCode
* 设备访问ip
*/
public
void
setSiteCode
(
String
siteCode
){
this
.
siteCode
=
siteCode
;
}
private
String
ip
;
/**
* 获取 站点名称
* @return String
* 端口
*/
public
String
getSiteName
(){
return
siteName
;
}
private
String
port
;
/**
* 设置 站点名称
* @param siteName
* 启用状态 (0.停止,1.启用)
*/
public
void
setSiteName
(
String
siteName
){
this
.
siteName
=
siteName
;
}
/**
* 获取 产品编码
* @return String
*/
public
String
getProductCode
(){
return
productCode
;
}
private
Integer
enabled
;
/**
* 设置 产品编码
* @param productCode
* 最近上线时间
*/
public
void
setProductCode
(
String
productCode
){
this
.
productCode
=
productCode
;
}
/**
* 获取 产品名称
* @return String
*/
public
String
getProductName
(){
return
productName
;
}
/**
* 设置 产品名称
* @param productName
*/
public
void
setProductName
(
String
productName
){
this
.
productName
=
productName
;
}
/**
* 获取 设备来源(0.子设备,1.网关设备,2.直连设备)
* @return Integer
*/
public
Integer
getDeviceSrc
(){
return
deviceSrc
;
}
/**
* 设置 设备来源(0.子设备,1.网关设备,2.直连设备)
* @param deviceSrc
*/
public
void
setDeviceSrc
(
Integer
deviceSrc
){
this
.
deviceSrc
=
deviceSrc
;
}
private
Date
onlineTime
;
/**
* 获取 经度
* @return String
* 最近离线时间
*/
public
String
getLon
(){
return
lon
;
}
/**
* 设置 经度
* @param lon
*/
public
void
setLon
(
String
lon
){
this
.
lon
=
lon
;
}
/**
* 获取 纬度
* @return String
*/
public
String
getLati
(){
return
lati
;
}
/**
* 设置 纬度
* @param lati
*/
public
void
setLati
(
String
lati
){
this
.
lati
=
lati
;
}
/**
* 获取 负责人
* @return String
*/
public
String
getLeadingOfficial
(){
return
leadingOfficial
;
}
/**
* 设置 负责人
* @param leadingOfficial
*/
public
void
setLeadingOfficial
(
String
leadingOfficial
){
this
.
leadingOfficial
=
leadingOfficial
;
}
/**
* 获取 联系电话
* @return String
*/
public
String
getLeadingOfficialTelephone
(){
return
leadingOfficialTelephone
;
}
/**
* 设置 联系电话
* @param leadingOfficialTelephone
*/
public
void
setLeadingOfficialTelephone
(
String
leadingOfficialTelephone
){
this
.
leadingOfficialTelephone
=
leadingOfficialTelephone
;
}
/**
* 获取 设备状态 (0.未激活,1.离线,2.在线)
* @return Integer
*/
public
Integer
getDeviceStatus
(){
return
deviceStatus
;
}
/**
* 设置 设备状态 (0.未激活,1.离线,2.在线)
* @param deviceStatus
*/
public
void
setDeviceStatus
(
Integer
deviceStatus
){
this
.
deviceStatus
=
deviceStatus
;
}
/**
* 获取 备注
* @return String
*/
public
String
getDeviceRemark
(){
return
deviceRemark
;
}
/**
* 设置 备注
* @param deviceRemark
*/
public
void
setDeviceRemark
(
String
deviceRemark
){
this
.
deviceRemark
=
deviceRemark
;
}
/**
* 获取 设备来源(0.旧设备,1.新设备)
* @return Integer
*/
public
Integer
getSource
(){
return
source
;
}
/**
* 设置 设备来源(0.旧设备,1.新设备)
* @param source
*/
public
void
setSource
(
Integer
source
){
this
.
source
=
source
;
}
private
Date
offlineTime
;
@Override
public
int
hashCode
()
{
return
this
.
getId
().
hashCode
();
...
...
@@ -346,62 +129,54 @@ public class DeviceEntity extends DeviceVo {
return
false
;
}
public
String
toString
(){
StringBuilder
sb
=
new
StringBuilder
(
""
);
sb
.
append
(
",deviceId:"
).
append
(
getDeviceId
());
sb
.
append
(
",deviceName:"
).
append
(
getDeviceName
());
sb
.
append
(
",deviceCode:"
).
append
(
getDeviceCode
());
sb
.
append
(
",deviceMac:"
).
append
(
getDeviceMac
());
sb
.
append
(
",siteId:"
).
append
(
getSiteId
());
sb
.
append
(
",siteCode:"
).
append
(
getSiteCode
());
sb
.
append
(
",siteName:"
).
append
(
getSiteName
());
sb
.
append
(
",productCode:"
).
append
(
getProductCode
());
sb
.
append
(
",productName:"
).
append
(
getProductName
());
sb
.
append
(
",deviceSrc:"
).
append
(
getDeviceSrc
());
sb
.
append
(
",lon:"
).
append
(
getLon
());
sb
.
append
(
",lati:"
).
append
(
getLati
());
sb
.
append
(
",leadingOfficial:"
).
append
(
getLeadingOfficial
());
sb
.
append
(
",leadingOfficialTelephone:"
).
append
(
getLeadingOfficialTelephone
());
sb
.
append
(
",deviceStatus:"
).
append
(
getDeviceStatus
());
sb
.
append
(
",deviceRemark:"
).
append
(
getDeviceRemark
());
sb
.
append
(
",source:"
).
append
(
getSource
());
return
sb
.
toString
();
}
public
void
initAttrValue
(){
this
.
deviceId
=
null
;
this
.
deviceId
=
-
1L
;
this
.
deviceName
=
null
;
this
.
deviceName
=
""
;
this
.
deviceCode
=
null
;
this
.
deviceCode
=
""
;
this
.
deviceMac
=
null
;
this
.
deviceMac
=
""
;
this
.
siteId
=
null
;
this
.
siteId
=
-
1L
;
this
.
siteCode
=
null
;
this
.
siteCode
=
""
;
this
.
siteName
=
null
;
this
.
siteName
=
""
;
this
.
productCode
=
null
;
this
.
productCode
=
""
;
this
.
productName
=
null
;
this
.
productName
=
""
;
this
.
deviceSrc
=
2
;
this
.
lon
=
null
;
this
.
lon
=
""
;
this
.
lati
=
null
;
this
.
lati
=
""
;
this
.
leadingOfficial
=
null
;
this
.
leadingOfficial
=
""
;
this
.
leadingOfficialTelephone
=
null
;
this
.
leadingOfficialTelephone
=
""
;
this
.
deviceStatus
=
null
;
this
.
deviceStatus
=
0
;
this
.
deviceRemark
=
null
;
this
.
deviceRemark
=
""
;
this
.
source
=
1
;
this
.
deviceFirmId
=
-
1L
;
this
.
deviceFirmname
=
""
;
this
.
ip
=
""
;
this
.
port
=
""
;
this
.
enabled
=
0
;
this
.
onlineTime
=
null
;
this
.
offlineTime
=
null
;
}
}
\ No newline at end of file
sample-form-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceQuery.java
View file @
c6ba21e2
This diff is collapsed.
Click to expand it.
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
View file @
c6ba21e2
package
com.mortals.xhx.module.device.service
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.module.device.dao.DeviceDao
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
/**
* DeviceService
...
...
@@ -11,4 +13,20 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
*/
public
interface
DeviceService
extends
ICRUDService
<
DeviceEntity
,
Long
>{
DeviceDao
getDao
();
/**
* 设备激活
* @param deviceCode
* @param context
*/
void
active
(
String
deviceCode
,
Context
context
);
/**
* 设备启用停用
* @param id
* @param context
*/
void
deviceEnabled
(
Long
id
,
Integer
status
,
Context
context
);
}
\ No newline at end of file
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
c6ba21e2
package
com.mortals.xhx.module.device.service.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.xhx.common.code.DeviceMethodEnum
;
import
com.mortals.xhx.common.code.DeviceStatusEnum
;
import
com.mortals.xhx.common.code.EnabledEnum
;
import
com.mortals.xhx.common.pdu.LoginForm
;
import
com.mortals.xhx.common.pdu.device.DeviceReq
;
import
com.mortals.xhx.feign.device.IDeviceFeign
;
import
com.mortals.xhx.module.device.dao.DeviceDao
;
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
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Date
;
/**
* DeviceService
* 设备 service实现
...
...
@@ -13,6 +31,58 @@ import org.springframework.stereotype.Service;
* @date 2023-02-25
*/
@Service
(
"deviceService"
)
@Slf4j
public
class
DeviceServiceImpl
extends
AbstractCRUDServiceImpl
<
DeviceDao
,
DeviceEntity
,
Long
>
implements
DeviceService
{
@Autowired
private
IDeviceFeign
deviceFeign
;
@Value
(
"${token.loginName:'admin'}"
)
private
String
loginName
;
@Value
(
"${token.password:'admin'}"
)
private
String
password
;
@Override
public
void
active
(
String
deviceCode
,
Context
context
)
{
DeviceEntity
deviceEntity
=
this
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
deviceCode
));
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
throw
new
AppException
(
"当前设备不存在!"
);
if
(
deviceEntity
.
getDeviceStatus
()
>
DeviceStatusEnum
.
未激活
.
getValue
())
throw
new
AppException
(
"当前设备已激活!"
);
deviceEntity
.
setDeviceStatus
(
DeviceStatusEnum
.
离线
.
getValue
());
deviceEntity
.
setEnabled
(
EnabledEnum
.
启用
.
getValue
());
this
.
getDao
().
update
(
deviceEntity
);
String
token
=
getToken
();
DeviceReq
deviceReq
=
new
DeviceReq
();
deviceReq
.
setReceiveMethod
(
DeviceMethodEnum
.
ACTIVE
.
getValue
());
deviceReq
.
setDeviceCode
(
deviceCode
);
Rest
<
String
>
rest
=
deviceFeign
.
deviceCall
(
deviceReq
,
token
);
log
.
info
(
"激活结果:{}"
,
JSON
.
toJSONString
(
rest
));
}
@Override
public
void
deviceEnabled
(
Long
id
,
Integer
enabled
,
Context
context
)
{
DeviceEntity
deviceEntity
=
this
.
get
(
id
,
context
);
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
throw
new
AppException
(
"当前设备不存在!"
);
deviceEntity
.
setEnabled
(
enabled
);
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
getContextUserId
(
context
));
this
.
getDao
().
update
(
deviceEntity
);
String
token
=
getToken
();
DeviceReq
deviceReq
=
new
DeviceReq
();
deviceReq
.
setReceiveMethod
(
DeviceMethodEnum
.
ENABLED
.
getValue
());
deviceReq
.
setDeviceCode
(
deviceEntity
.
getDeviceCode
());
Rest
<
String
>
rest
=
deviceFeign
.
deviceCall
(
deviceReq
,
token
);
log
.
info
(
"启用结果:{}"
,
JSON
.
toJSONString
(
rest
));
}
private
String
getToken
()
{
LoginForm
loginForm
=
new
LoginForm
();
loginForm
.
setLoginName
(
loginName
);
loginForm
.
setPassword
(
password
);
Rest
<
String
>
rest
=
deviceFeign
.
getToken
(
loginForm
);
String
token
=
rest
.
getData
();
return
token
;
}
}
\ No newline at end of file
sample-form-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
c6ba21e2
package
com.mortals.xhx.module.device.web
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.common.code.DeviceMethodEnum
;
import
com.mortals.xhx.common.code.EnabledEnum
;
import
com.mortals.xhx.common.pdu.LoginForm
;
import
com.mortals.xhx.common.pdu.device.DeviceReq
;
import
com.mortals.xhx.feign.device.IDeviceFeign
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
com.mortals.framework.model.Context
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
org.apache.commons.lang3.ArrayUtils
;
import
com.mortals.framework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.Arrays
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.*;
/**
*
* 设备
*
* @author zxfei
* @date 2023-02-25
*/
* 设备
*
* @author zxfei
* @date 2023-02-25
*/
@RestController
@RequestMapping
(
"device"
)
public
class
DeviceController
extends
BaseCRUDJsonBodyMappingController
<
DeviceService
,
DeviceEntity
,
Long
>
{
@Slf4j
public
class
DeviceController
extends
BaseCRUDJsonBodyMappingController
<
DeviceService
,
DeviceEntity
,
Long
>
{
@Autowired
private
ParamService
paramService
;
public
DeviceController
(){
super
.
setModuleDesc
(
"设备"
);
@Autowired
private
IDeviceFeign
deviceFeign
;
@Value
(
"${token.loginName:'admin'}"
)
private
String
loginName
;
@Value
(
"${token.password:'admin'}"
)
private
String
password
;
public
DeviceController
()
{
super
.
setModuleDesc
(
"设备"
);
}
@Override
protected
void
init
(
Map
<
String
,
Object
>
model
,
Context
context
)
{
this
.
addDict
(
model
,
"deviceSrc"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceSrc"
));
this
.
addDict
(
model
,
"deviceStatus"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceStatus"
));
this
.
addDict
(
model
,
"source"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"source"
));
this
.
addDict
(
model
,
"deviceSrc"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceSrc"
));
this
.
addDict
(
model
,
"deviceStatus"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceStatus"
));
this
.
addDict
(
model
,
"source"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"source"
));
this
.
addDict
(
model
,
"enabled"
,
EnabledEnum
.
getEnumMap
());
super
.
init
(
model
,
context
);
}
/**
* 设备激活
*/
@PostMapping
(
value
=
"active"
)
public
Rest
<
Void
>
deviceActive
(
@RequestBody
DeviceEntity
deviceEntity
)
{
log
.
info
(
"设备激活:{}"
,
deviceEntity
.
getDeviceCode
());
String
busiDesc
=
this
.
getModuleDesc
()
+
"设备激活"
;
Rest
<
Void
>
rest
=
Rest
.
ok
(
busiDesc
+
" 【成功】"
);
try
{
this
.
service
.
active
(
deviceEntity
.
getDeviceCode
(),
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"设备激活消息"
,
e
);
rest
=
Rest
.
fail
(
super
.
convertException
(
e
));
}
return
rest
;
}
/**
* 设备启用停用
*/
@PostMapping
(
value
=
"enable"
)
public
String
deviceEnable
(
@RequestBody
DeviceEntity
deviceEntity
)
{
JSONObject
jsonObject
=
new
JSONObject
();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
busiDesc
=
this
.
getModuleDesc
()
+
"设备"
;
try
{
this
.
service
.
deviceEnabled
(
deviceEntity
.
getId
(),
deviceEntity
.
getEnabled
(),
getContext
());
recordSysLog
(
request
,
busiDesc
+
EnabledEnum
.
getByValue
(
deviceEntity
.
getEnabled
()).
getDesc
()
+
" 【成功】"
);
jsonObject
.
put
(
KEY_RESULT_DATA
,
model
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
}
catch
(
Exception
e
)
{
log
.
error
(
"设备启用停用消息"
,
e
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
jsonObject
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
}
return
jsonObject
.
toJSONString
();
}
@Override
protected
int
saveAfter
(
DeviceEntity
entity
,
Map
<
String
,
Object
>
model
,
Context
context
)
throws
AppException
{
if
(
ObjectUtils
.
isEmpty
(
entity
.
getUpdateTime
()))
{
String
token
=
getToken
();
DeviceReq
deviceReq
=
new
DeviceReq
();
deviceReq
.
setReceiveMethod
(
DeviceMethodEnum
.
ADD
.
getValue
());
deviceReq
.
setDeviceName
(
entity
.
getDeviceName
());
deviceReq
.
setDeviceCode
(
entity
.
getDeviceCode
());
deviceReq
.
setProductCode
(
entity
.
getProductCode
());
deviceReq
.
setIp
(
entity
.
getIp
());
deviceReq
.
setPort
(
entity
.
getPort
());
deviceReq
.
setSiteId
(
1L
);
deviceReq
.
setSiteCode
(
"511500000000-0001"
);
deviceReq
.
setSiteName
(
"宜宾市民中心"
);
deviceReq
.
setLeadingOfficial
(
entity
.
getLeadingOfficial
());
deviceReq
.
setLeadingOfficialTelephone
(
entity
.
getLeadingOfficialTelephone
());
deviceReq
.
setSource
(
1
);
deviceReq
.
setDeviceStatus
(
entity
.
getDeviceStatus
());
Rest
<
String
>
rest
=
deviceFeign
.
deviceCall
(
deviceReq
,
token
);
log
.
info
(
"添加结果:{}"
,
JSON
.
toJSONString
(
rest
));
}
else
{
String
token
=
getToken
();
DeviceReq
deviceReq
=
new
DeviceReq
();
deviceReq
.
setReceiveMethod
(
DeviceMethodEnum
.
UPDATE
.
getValue
());
deviceReq
.
setDeviceName
(
entity
.
getDeviceName
());
deviceReq
.
setDeviceCode
(
entity
.
getDeviceCode
());
deviceReq
.
setProductCode
(
entity
.
getProductCode
());
deviceReq
.
setIp
(
entity
.
getIp
());
deviceReq
.
setPort
(
entity
.
getPort
());
deviceReq
.
setSiteId
(
1L
);
deviceReq
.
setSiteCode
(
"511500000000-0001"
);
deviceReq
.
setSiteName
(
"宜宾市民中心"
);
deviceReq
.
setLeadingOfficial
(
entity
.
getLeadingOfficial
());
deviceReq
.
setLeadingOfficialTelephone
(
entity
.
getLeadingOfficialTelephone
());
deviceReq
.
setSource
(
1
);
deviceReq
.
setDeviceStatus
(
entity
.
getDeviceStatus
());
Rest
<
String
>
rest
=
deviceFeign
.
deviceCall
(
deviceReq
,
token
);
log
.
info
(
"更新结果:{}"
,
JSON
.
toJSONString
(
rest
));
}
return
super
.
saveAfter
(
entity
,
model
,
context
);
}
@Override
protected
void
deleteBefore
(
Long
[]
ids
,
Context
context
)
throws
AppException
{
super
.
deleteBefore
(
ids
,
context
);
String
token
=
getToken
();
DeviceQuery
deviceQuery
=
new
DeviceQuery
();
deviceQuery
.
setIdList
(
Arrays
.
asList
(
ids
));
List
<
DeviceEntity
>
deviceEntities
=
this
.
service
.
find
(
deviceQuery
,
context
);
for
(
DeviceEntity
entity
:
deviceEntities
)
{
DeviceReq
deviceReq
=
new
DeviceReq
();
deviceReq
.
setReceiveMethod
(
DeviceMethodEnum
.
DEL
.
getValue
());
deviceReq
.
setDeviceCode
(
entity
.
getDeviceCode
());
Rest
<
String
>
rest
=
deviceFeign
.
deviceCall
(
deviceReq
,
token
);
log
.
info
(
"删除结果:{}"
,
JSON
.
toJSONString
(
rest
));
}
}
private
String
getToken
()
{
LoginForm
loginForm
=
new
LoginForm
();
loginForm
.
setLoginName
(
loginName
);
loginForm
.
setPassword
(
password
);
Rest
<
String
>
rest
=
deviceFeign
.
getToken
(
loginForm
);
String
token
=
rest
.
getData
();
return
token
;
}
}
\ No newline at end of file
sample-form-manager/src/main/resources/sqlmap/module/device/DeviceMapper.xml
View file @
c6ba21e2
This diff is collapsed.
Click to expand it.
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