Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fill-system
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
廖旭伟
fill-system
Commits
68a30bbe
Commit
68a30bbe
authored
Jun 21, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加设备相关信息
parent
32d63558
Pipeline
#2629
canceled with stages
Changes
14
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
2184 additions
and
1164 deletions
+2184
-1164
common-lib/src/main/java/com/mortals/xhx/common/pdu/LoginForm.java
...b/src/main/java/com/mortals/xhx/common/pdu/LoginForm.java
+56
-0
common-lib/src/main/java/com/mortals/xhx/common/pdu/device/DeviceReq.java
...ain/java/com/mortals/xhx/common/pdu/device/DeviceReq.java
+138
-0
common-lib/src/main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
.../main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
+31
-0
fill-manager/db/add.sql
fill-manager/db/add.sql
+21
-0
fill-manager/src/main/java/com/mortals/xhx/base/framework/aspect/OperlogAspect.java
.../com/mortals/xhx/base/framework/aspect/OperlogAspect.java
+13
-1
fill-manager/src/main/java/com/mortals/xhx/common/code/DeviceMethodEnum.java
...in/java/com/mortals/xhx/common/code/DeviceMethodEnum.java
+72
-0
fill-manager/src/main/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
...in/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
+66
-0
fill-manager/src/main/java/com/mortals/xhx/common/code/EnabledEnum.java
...rc/main/java/com/mortals/xhx/common/code/EnabledEnum.java
+65
-0
fill-manager/src/main/java/com/mortals/xhx/common/code/OperTypeEnum.java
...c/main/java/com/mortals/xhx/common/code/OperTypeEnum.java
+11
-12
fill-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceEntity.java
...ava/com/mortals/xhx/module/device/model/DeviceEntity.java
+101
-321
fill-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceQuery.java
...java/com/mortals/xhx/module/device/model/DeviceQuery.java
+1362
-815
fill-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
.../com/mortals/xhx/module/device/service/DeviceService.java
+17
-0
fill-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+69
-0
fill-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+162
-15
No files found.
common-lib/src/main/java/com/mortals/xhx/common/pdu/LoginForm.java
0 → 100644
View file @
68a30bbe
package
com.mortals.xhx.common.pdu
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.web.BaseForm
;
public
class
LoginForm
extends
BaseForm
{
private
String
loginName
;
private
String
password
;
private
String
securityCode
;
public
String
getLoginName
()
{
return
loginName
;
}
public
void
setLoginName
(
String
loginName
)
{
this
.
loginName
=
loginName
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getSecurityCode
()
{
return
securityCode
;
}
public
void
setSecurityCode
(
String
securityCode
)
{
this
.
securityCode
=
securityCode
;
}
@Override
public
String
toString
()
{
return
"loginName:"
+
this
.
loginName
+
" password:"
+
this
.
password
;
}
@Override
public
boolean
validate
()
throws
AppException
{
if
(
loginName
==
null
||
loginName
.
trim
().
length
()
==
0
)
{
throw
new
AppException
(
"帐号不能为空!"
);
}
if
(
password
==
null
||
password
.
trim
().
length
()
==
0
)
{
throw
new
AppException
(
"密码不能为空!"
);
}
// if (securityCode == null || securityCode.trim().length() == 0) {
// throw new AppException("验证码不能为空!");
// }
return
super
.
validate
();
}
}
common-lib/src/main/java/com/mortals/xhx/common/pdu/device/DeviceReq.java
0 → 100644
View file @
68a30bbe
package
com.mortals.xhx.common.pdu.device
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
public
class
DeviceReq
implements
Serializable
{
/**
* 1:新增,2:修改,3:删除,4:激活,5:启用,6:停用
*/
private
Integer
receiveMethod
;
/**
* 产品id
*/
private
Long
productId
;
/**
* 产品编码
*/
private
String
productCode
;
/**
* 设备生产厂商ID
*/
private
Long
deviceFirmId
;
/**
* 设备生产厂商名称
*/
private
String
deviceFirmname
;
/**
* 设备名称
*/
private
String
deviceName
;
/**
* 设备编码(暂定mac地址)
*/
private
String
deviceCode
;
/**
* 设备Mac
*/
private
String
deviceMac
;
/**
* 所属站点Id
*/
private
Long
siteId
;
/**
* 所属站点编码
*/
private
String
siteCode
;
/**
* 所属站点名称
*/
private
String
siteName
;
/**
* 设备备注信息
*/
private
String
deviceRemark
;
/**
* 设备
*/
private
String
homeUrl
;
/**
* 设备访问ip
*/
private
String
ip
;
/**
* 中心设备编码
*/
private
String
centernum
;
/**
* 端口
*/
private
String
port
;
/**
* 经度
*/
private
String
lon
;
/**
* 纬度
*/
private
String
lati
;
/**
* 楼层
*/
private
Integer
deviceInBuilding
;
/**
* 所属楼栋
*/
private
Integer
deviceInFloor
;
/**
* 负责人
*/
private
String
leadingOfficial
;
/**
* 联系电话
*/
private
String
leadingOfficialTelephone
;
/**
* 保修期至
*/
private
Date
defectsLiabilityPeriod
;
/**
* 设备状态 (0.未激活,1.离线,2.在线)
*/
private
Integer
deviceStatus
;
/**
* 设备来源(0.旧设备,1.新设备)
*/
private
Integer
source
;
/**
* 激活(0.否,1.是)
*/
private
Integer
active
;
/**
* 设备版本信息
*/
private
String
deviceVersion
;
}
common-lib/src/main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
View file @
68a30bbe
package
com.mortals.xhx.feign.device
;
package
com.mortals.xhx.feign.device
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.common.pdu.LoginForm
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.device.DevicePdu
;
import
com.mortals.xhx.common.pdu.device.DevicePdu
;
import
com.mortals.xhx.common.pdu.device.DeviceReq
;
import
com.mortals.xhx.feign.IFeign
;
import
com.mortals.xhx.feign.IFeign
;
import
feign.hystrix.FallbackFactory
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -59,6 +61,25 @@ public interface IDeviceFeign extends IFeign {
...
@@ -59,6 +61,25 @@ public interface IDeviceFeign extends IFeign {
Rest
<
RespData
<
DevicePdu
>>
save
(
@RequestBody
DevicePdu
devicePdu
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
Rest
<
RespData
<
DevicePdu
>>
save
(
@RequestBody
DevicePdu
devicePdu
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
/**
* 获取token
*
* @param loginForm
* @return
*/
@PostMapping
(
value
=
"/api/getToken"
)
Rest
<
String
>
getToken
(
@RequestBody
LoginForm
loginForm
);
/**
* 设备回调
*
* @param deviceReq
* @return
*/
@PostMapping
(
value
=
"/api/receive"
)
Rest
<
String
>
deviceCall
(
@RequestBody
DeviceReq
deviceReq
,
@RequestHeader
(
"Authorization"
)
String
authorization
);
}
}
...
@@ -87,6 +108,16 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
...
@@ -87,6 +108,16 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
public
Rest
<
RespData
<
DevicePdu
>>
save
(
DevicePdu
devicePdu
,
String
authorization
)
{
public
Rest
<
RespData
<
DevicePdu
>>
save
(
DevicePdu
devicePdu
,
String
authorization
)
{
return
Rest
.
fail
(
"暂时无法保存设备,请稍后再试!"
);
return
Rest
.
fail
(
"暂时无法保存设备,请稍后再试!"
);
}
}
@Override
public
Rest
<
String
>
getToken
(
LoginForm
loginForm
)
{
return
Rest
.
fail
(
"暂时无法获取token,请稍后再试!"
);
}
@Override
public
Rest
<
String
>
deviceCall
(
DeviceReq
deviceReq
,
String
authorization
)
{
return
Rest
.
fail
(
"暂时无法保存设备,请稍后再试!"
);
}
};
};
}
}
}
}
...
...
fill-manager/db/add.sql
View file @
68a30bbe
...
@@ -16,3 +16,24 @@ ALTER TABLE mortals_xhx_matter_datum_print ADD COLUMN `mobile` varchar(64) defau
...
@@ -16,3 +16,24 @@ ALTER TABLE mortals_xhx_matter_datum_print ADD COLUMN `mobile` varchar(64) defau
2023
-
03
-
22
2023
-
03
-
22
-- ----------------------------
-- ----------------------------
INSERT
INTO
`mortals_xhx_task`
(
`id`
,
`name`
,
`taskKey`
,
`status`
,
`excuteService`
,
`excuteParam`
,
`excuteHost`
,
`excuteStrategy`
,
`excuteDate`
,
`excuteTime`
,
`remark`
,
`lastExcuteHost`
,
`lastExcuteTime`
,
`interimExcuteStatus`
,
`createTime`
,
`createUserId`
,
`createUserName`
)
VALUES
(
'4'
,
'同步设备'
,
'SyncSiteDeviceTask'
,
'0'
,
'SyncSiteDeviceTask'
,
NULL
,
NULL
,
'4'
,
'120'
,
'00:00'
,
NULL
,
'127.0.1.1'
,
'2023-02-26 22:15:59'
,
'0'
,
'2023-02-25 14:34:12'
,
'1'
,
NULL
);
INSERT
INTO
`mortals_xhx_task`
(
`id`
,
`name`
,
`taskKey`
,
`status`
,
`excuteService`
,
`excuteParam`
,
`excuteHost`
,
`excuteStrategy`
,
`excuteDate`
,
`excuteTime`
,
`remark`
,
`lastExcuteHost`
,
`lastExcuteTime`
,
`interimExcuteStatus`
,
`createTime`
,
`createUserId`
,
`createUserName`
)
VALUES
(
'4'
,
'同步设备'
,
'SyncSiteDeviceTask'
,
'0'
,
'SyncSiteDeviceTask'
,
NULL
,
NULL
,
'4'
,
'120'
,
'00:00'
,
NULL
,
'127.0.1.1'
,
'2023-02-26 22:15:59'
,
'0'
,
'2023-02-25 14:34:12'
,
'1'
,
NULL
);
-- ----------------------------
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
`onlineTime`
datetime
DEFAULT
NULL
COMMENT
'最近上线时间'
AFTER
enabled
;
ALTER
TABLE
mortals_xhx_device
ADD
COLUMN
`offlineTime`
datetime
DEFAULT
NULL
COMMENT
'最近离线时间'
AFTER
onlineTime
;
\ No newline at end of file
fill-manager/src/main/java/com/mortals/xhx/base/framework/aspect/OperlogAspect.java
View file @
68a30bbe
...
@@ -4,8 +4,10 @@ import java.util.Date;
...
@@ -4,8 +4,10 @@ import java.util.Date;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
cn.hutool.core.util.StrUtil
;
import
com.mortals.framework.model.OperateLogPdu
;
import
com.mortals.framework.model.OperateLogPdu
;
import
com.mortals.framework.service.IMessageProduceService
;
import
com.mortals.framework.service.IMessageProduceService
;
import
com.mortals.xhx.common.code.OperTypeEnum
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.AfterReturning
;
...
@@ -43,6 +45,16 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
...
@@ -43,6 +45,16 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
String
content
,
String
ip
,
Date
logDate
)
{
String
content
,
String
ip
,
Date
logDate
)
{
super
.
doHandlerLog
(
platformMark
,
userId
,
userName
,
loginName
,
requestUrl
,
content
,
ip
,
logDate
);
super
.
doHandlerLog
(
platformMark
,
userId
,
userName
,
loginName
,
requestUrl
,
content
,
ip
,
logDate
);
operLogService
.
insertOperLog
(
ip
,
requestUrl
,
userId
,
userName
,
loginName
,
content
);
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
operateLogPdu
=
new
OperateLogPdu
();
operateLogPdu
.
initAttrValue
();
operateLogPdu
.
initAttrValue
();
operateLogPdu
.
setIp
(
ip
);
operateLogPdu
.
setIp
(
ip
);
...
@@ -53,7 +65,7 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
...
@@ -53,7 +65,7 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
operateLogPdu
.
setPlatformMark
(
platformMark
);
operateLogPdu
.
setPlatformMark
(
platformMark
);
operateLogPdu
.
setLogDate
(
logDate
);
operateLogPdu
.
setLogDate
(
logDate
);
operateLogPdu
.
setContent
(
content
);
operateLogPdu
.
setContent
(
content
);
operateLogPdu
.
setOperType
(
1
);
operateLogPdu
.
setOperType
(
operType
);
messageProduceService
.
syncOperSend
(
operateLogPdu
);
messageProduceService
.
syncOperSend
(
operateLogPdu
);
}
}
...
...
fill-manager/src/main/java/com/mortals/xhx/common/code/DeviceMethodEnum.java
0 → 100644
View file @
68a30bbe
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
fill-manager/src/main/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
0 → 100644
View file @
68a30bbe
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 设备状态 (0.未激活,1.离线,2.在线)枚举类
*
* @author zxfei
*/
public
enum
DeviceStatusEnum
{
未激活
(
0
,
"未激活"
),
离线
(
1
,
"离线"
),
在线
(
2
,
"在线"
);
private
Integer
value
;
private
String
desc
;
DeviceStatusEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
DeviceStatusEnum
getByValue
(
Integer
value
)
{
for
(
DeviceStatusEnum
deviceStatusEnum
:
DeviceStatusEnum
.
values
())
{
if
(
deviceStatusEnum
.
getValue
()
==
value
)
{
return
deviceStatusEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
DeviceStatusEnum
item
:
DeviceStatusEnum
.
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
fill-manager/src/main/java/com/mortals/xhx/common/code/EnabledEnum.java
0 → 100644
View file @
68a30bbe
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
fill-manager/src/main/java/com/mortals/xhx/common/code/OperTypeEnum.java
View file @
68a30bbe
...
@@ -3,20 +3,19 @@ package com.mortals.xhx.common.code;
...
@@ -3,20 +3,19 @@ package com.mortals.xhx.common.code;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
/**
* Created by chendilin on 2018/3/7.
*/
public
enum
OperTypeEnum
{
public
enum
OperTypeEnum
{
SAVE
(
0
,
"添加"
),
SAVE
(
0
,
"添加"
),
UPDATE
(
1
,
"更新"
),
UPDATE
(
1
,
"更新"
),
DELETE
(
2
,
"删除"
),
DELETE
(
2
,
"删除"
),
OTHER
(-
1
,
"其它"
);
SEARCH
(
3
,
"查询"
),
OTHER
(-
1
,
"其它"
);
private
int
value
;
private
int
value
;
private
String
msg
;
private
String
msg
;
private
OperTypeEnum
(
int
value
,
String
msg
)
{
private
OperTypeEnum
(
int
value
,
String
msg
)
{
this
.
value
=
value
;
this
.
value
=
value
;
this
.
msg
=
msg
;
this
.
msg
=
msg
;
}
}
...
@@ -25,11 +24,11 @@ public enum OperTypeEnum {
...
@@ -25,11 +24,11 @@ public enum OperTypeEnum {
return
this
.
value
;
return
this
.
value
;
}
}
public
static
Map
<
String
,
String
>
getEnumMap
()
{
public
static
Map
<
String
,
String
>
getEnumMap
()
{
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
OperTypeEnum
[]
operTypeEnum
=
OperTypeEnum
.
values
();
OperTypeEnum
[]
operTypeEnum
=
OperTypeEnum
.
values
();
for
(
OperTypeEnum
typeEnum
:
operTypeEnum
)
{
for
(
OperTypeEnum
typeEnum
:
operTypeEnum
)
{
resultMap
.
put
(
String
.
valueOf
(
typeEnum
.
value
),
typeEnum
.
msg
);
resultMap
.
put
(
String
.
valueOf
(
typeEnum
.
value
),
typeEnum
.
msg
);
}
}
return
resultMap
;
return
resultMap
;
}
}
...
...
fill-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceEntity.java
View file @
68a30bbe
This diff is collapsed.
Click to expand it.
fill-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceQuery.java
View file @
68a30bbe
This diff is collapsed.
Click to expand it.
fill-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
View file @
68a30bbe
package
com.mortals.xhx.module.device.service
;
package
com.mortals.xhx.module.device.service
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.module.device.dao.DeviceDao
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
/**
/**
* DeviceService
* DeviceService
...
@@ -10,5 +12,20 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
...
@@ -10,5 +12,20 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
* @date 2023-02-25
* @date 2023-02-25
*/
*/
public
interface
DeviceService
extends
ICRUDService
<
DeviceEntity
,
Long
>{
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
fill-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
68a30bbe
package
com.mortals.xhx.module.device.service.impl
;
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.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.dao.DeviceDao
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
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.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.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Date
;
/**
/**
* DeviceService
* DeviceService
* 设备 service实现
* 设备 service实现
...
@@ -13,6 +31,57 @@ import org.springframework.stereotype.Service;
...
@@ -13,6 +31,57 @@ import org.springframework.stereotype.Service;
* @date 2023-02-25
* @date 2023-02-25
*/
*/
@Service
(
"deviceService"
)
@Service
(
"deviceService"
)
@Slf4j
public
class
DeviceServiceImpl
extends
AbstractCRUDServiceImpl
<
DeviceDao
,
DeviceEntity
,
Long
>
implements
DeviceService
{
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
fill-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
68a30bbe
package
com.mortals.xhx.module.device.web
;
package
com.mortals.xhx.module.device.web
;
import
com.mortals.framework.model.Context
;
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.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.common.code.DeviceMethodEnum
;
import
com.mortals.xhx.module.device.service.DeviceService
;
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.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
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.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
* @author zxfei
* @date 2023-02-25
* @date 2023-02-25
*/
*/
@RestController
@RestController
@RequestMapping
(
"device"
)
@RequestMapping
(
"device"
)
public
class
DeviceController
extends
BaseCRUDJsonBodyMappingController
<
DeviceService
,
DeviceEntity
,
Long
>
{
@Slf4j
public
class
DeviceController
extends
BaseCRUDJsonBodyMappingController
<
DeviceService
,
DeviceEntity
,
Long
>
{
@Autowired
@Autowired
private
ParamService
paramService
;
private
ParamService
paramService
;
public
DeviceController
(){
@Autowired
super
.
setModuleDesc
(
"设备"
);
private
IDeviceFeign
deviceFeign
;
@Value
(
"${token.loginName:'admin'}"
)
private
String
loginName
;
@Value
(
"${token.password:'admin'}"
)
private
String
password
;
public
DeviceController
()
{
super
.
setModuleDesc
(
"设备"
);
}
}
@Override
@Override
protected
void
init
(
Map
<
String
,
Object
>
model
,
Context
context
)
{
protected
void
init
(
Map
<
String
,
Object
>
model
,
Context
context
)
{
this
.
addDict
(
model
,
"deviceSrc"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceSrc"
));
this
.
addDict
(
model
,
"deviceSrc"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceSrc"
));
this
.
addDict
(
model
,
"deviceStatus"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceStatus"
));
this
.
addDict
(
model
,
"deviceStatus"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"deviceStatus"
));
this
.
addDict
(
model
,
"source"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"source"
));
this
.
addDict
(
model
,
"source"
,
paramService
.
getParamBySecondOrganize
(
"Device"
,
"source"
));
this
.
addDict
(
model
,
"enabled"
,
EnabledEnum
.
getEnumMap
());
super
.
init
(
model
,
context
);
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
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