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
815aa59c
Commit
815aa59c
authored
Jun 08, 2023
by
“yiyousong”
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.scsmile.cn/zxf/sample-form-platform
parents
fac0d394
c068b232
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
252 additions
and
10 deletions
+252
-10
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
+139
-0
common-lib/src/main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
.../main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
+38
-3
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncSiteDeviceTaskImpl.java
...a/com/mortals/xhx/daemon/task/SyncSiteDeviceTaskImpl.java
+19
-7
No files found.
common-lib/src/main/java/com/mortals/xhx/common/pdu/LoginForm.java
0 → 100644
View file @
815aa59c
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 @
815aa59c
package
com.mortals.xhx.common.pdu.device
;
import
com.fasterxml.jackson.databind.annotation.JsonDeserialize
;
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 @
815aa59c
package
com.mortals.xhx.feign.device
;
package
com.mortals.xhx.feign.device
;
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.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
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
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 设备 Feign接口
* 设备 Feign接口
*
* @author zxfei
* @author zxfei
* @date 2023-02-25
* @date 2023-02-25
*/
*/
...
@@ -46,8 +52,27 @@ public interface IDeviceFeign extends IFeign {
...
@@ -46,8 +52,27 @@ public interface IDeviceFeign extends IFeign {
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/device/save"
)
@PostMapping
(
value
=
"/device/save"
)
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
);
}
}
...
@@ -72,6 +97,16 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
...
@@ -72,6 +97,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
(
"暂时无法保存设备,请稍后再试!"
);
}
};
};
}
}
}
}
...
...
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncSiteDeviceTaskImpl.java
View file @
815aa59c
package
com.mortals.xhx.daemon.task
;
package
com.mortals.xhx.daemon.task
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.annotation.JsonAlias
;
import
com.fasterxml.jackson.annotation.JsonAlias
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
...
@@ -33,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -33,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.sql.Struct
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -74,13 +76,13 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -74,13 +76,13 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
if
(
siteRest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
if
(
siteRest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
log
.
info
(
"站点总数量:{}"
,
siteRest
.
getData
().
size
());
log
.
info
(
"站点总数量:{}"
,
siteRest
.
getData
().
size
());
siteRest
.
getData
().
forEach
(
site
->
{
siteRest
.
getData
().
forEach
(
site
->
{
log
.
info
(
"站点名称:{}"
,
site
.
getSiteName
());
log
.
info
(
"站点名称:{}"
,
site
.
getSiteName
());
DevicePdu
devicePdu
=
new
DevicePdu
();
DevicePdu
devicePdu
=
new
DevicePdu
();
devicePdu
.
setProductCode
(
"ybj"
);
devicePdu
.
setProductCode
(
"ybj"
);
devicePdu
.
setSiteId
(
site
.
getId
());
devicePdu
.
setSiteId
(
site
.
getId
());
devicePdu
.
setSize
(-
1
);
devicePdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
DevicePdu
>>>
deviceRest
=
deviceFeign
.
list
(
devicePdu
);
Rest
<
RespData
<
List
<
DevicePdu
>>>
deviceRest
=
deviceFeign
.
list
(
devicePdu
);
log
.
info
(
"deviceRest:{}"
,
JSON
.
toJSONString
(
deviceRest
));
log
.
info
(
"deviceRest:{}"
,
JSON
.
toJSONString
(
deviceRest
));
if
(
YesNoEnum
.
YES
.
getValue
()
==
deviceRest
.
getCode
())
{
if
(
YesNoEnum
.
YES
.
getValue
()
==
deviceRest
.
getCode
())
{
List
<
DevicePdu
>
devicePduList
=
deviceRest
.
getData
().
getData
();
List
<
DevicePdu
>
devicePduList
=
deviceRest
.
getData
().
getData
();
log
.
info
(
"样表机总数量:{}"
,
devicePduList
.
size
());
log
.
info
(
"样表机总数量:{}"
,
devicePduList
.
size
());
...
@@ -93,7 +95,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -93,7 +95,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
List
<
DeviceEntity
>
oldDeviceList
=
deviceService
.
find
(
new
DeviceQuery
().
siteId
(
site
.
getId
()));
List
<
DeviceEntity
>
oldDeviceList
=
deviceService
.
find
(
new
DeviceQuery
().
siteId
(
site
.
getId
()));
log
.
info
(
"siteId:{} oldDeviceList size:{}"
,
site
.
getId
(),
oldDeviceList
.
size
());
log
.
info
(
"siteId:{} oldDeviceList size:{}"
,
site
.
getId
(),
oldDeviceList
.
size
());
Map
<
String
,
DeviceEntity
>
oldDeviceMap
=
oldDeviceList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getDeviceCode
(),
y
->
y
,
(
o
,
n
)
->
n
));
Map
<
String
,
DeviceEntity
>
oldDeviceMap
=
oldDeviceList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getDeviceCode
(),
y
->
y
,
(
o
,
n
)
->
n
));
Map
<
String
,
DeviceEntity
>
newDeviceMap
=
newDeviceList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getDeviceCode
(),
y
->
y
,
(
o
,
n
)
->
n
));
Map
<
String
,
DeviceEntity
>
newDeviceMap
=
newDeviceList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getDeviceCode
(),
y
->
y
,
(
o
,
n
)
->
n
));
...
@@ -144,7 +146,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -144,7 +146,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
if
(!
ObjectUtils
.
isEmpty
(
delDeviceList
))
{
if
(!
ObjectUtils
.
isEmpty
(
delDeviceList
))
{
log
.
info
(
"设备删除,size:{}"
,
delDeviceList
.
size
());
log
.
info
(
"设备删除,size:{}"
,
delDeviceList
.
size
());
deviceService
.
remove
(
delDeviceList
,
null
);
deviceService
.
remove
(
delDeviceList
,
null
);
}
}
}
}
}
else
{
}
else
{
...
@@ -170,6 +172,9 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -170,6 +172,9 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
List
<
SkinEntity
>
newSkinList
=
skinBasePduList
.
stream
().
map
(
newSkin
->
{
List
<
SkinEntity
>
newSkinList
=
skinBasePduList
.
stream
().
map
(
newSkin
->
{
SkinEntity
skinEntity
=
new
SkinEntity
();
SkinEntity
skinEntity
=
new
SkinEntity
();
skinEntity
.
initAttrValue
();
skinEntity
.
initAttrValue
();
//存相对地址
newSkin
.
setCssFilePath
(
"/"
+
StrUtil
.
subAfter
(
newSkin
.
getCssFilePath
(),
"/"
,
true
));
newSkin
.
setPreviewImagePath
(
"/"
+
StrUtil
.
subAfter
(
newSkin
.
getPreviewImagePath
(),
"/"
,
true
));
BeanUtils
.
copyProperties
(
newSkin
,
skinEntity
,
BeanUtil
.
getNullPropertyNames
(
newSkin
));
BeanUtils
.
copyProperties
(
newSkin
,
skinEntity
,
BeanUtil
.
getNullPropertyNames
(
newSkin
));
return
skinEntity
;
return
skinEntity
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
...
@@ -219,7 +224,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -219,7 +224,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
if
(!
ObjectUtils
.
isEmpty
(
delSkinList
))
{
if
(!
ObjectUtils
.
isEmpty
(
delSkinList
))
{
log
.
info
(
"皮肤删除,size:{}"
,
delSkinList
.
size
());
log
.
info
(
"皮肤删除,size:{}"
,
delSkinList
.
size
());
skinService
.
remove
(
delSkinList
,
null
);
skinService
.
remove
(
delSkinList
,
null
);
}
}
}
}
...
@@ -230,4 +235,11 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -230,4 +235,11 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
public
void
stopTask
(
ITask
task
)
throws
AppException
{
public
void
stopTask
(
ITask
task
)
throws
AppException
{
}
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
"http://10.12.185.213:11071/file%2Ffileupload%2F1682068396920.css"
;
System
.
out
.
println
(
StrUtil
.
subAfter
(
str
,
"/"
,
true
));
}
}
}
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