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
c09d6168
Commit
c09d6168
authored
Nov 26, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改同步任务
parent
105a2aae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
161 additions
and
15 deletions
+161
-15
sample-form-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartedService.java
...als/xhx/daemon/applicationservice/DemoStartedService.java
+30
-5
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncSiteDeviceTaskImpl.java
...a/com/mortals/xhx/daemon/task/SyncSiteDeviceTaskImpl.java
+4
-6
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncSiteMatterTaskImpl.java
...a/com/mortals/xhx/daemon/task/SyncSiteMatterTaskImpl.java
+0
-4
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
.../com/mortals/xhx/module/device/service/DeviceService.java
+5
-0
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+122
-0
No files found.
sample-form-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DemoStartedService.java
View file @
c09d6168
package
com.mortals.xhx.daemon.applicationservice
;
package
com.mortals.xhx.daemon.applicationservice
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.feign.device.IDeviceFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.skin.service.SkinService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
@Component
@Component
//@ConditionalOnProperty(name="com.mortal",prefix = "",havingValue = "xxx")
@Slf4j
public
class
DemoStartedService
implements
IApplicationStartedService
{
public
class
DemoStartedService
implements
IApplicationStartedService
{
private
static
Log
logger
=
LogFactory
.
getLog
(
DemoStartedService
.
class
);
@Autowired
private
UserService
userService
;
@Autowired
private
DeviceService
deviceService
;
@Autowired
private
SkinService
skinService
;
@Override
@Override
public
void
start
()
{
public
void
start
()
{
logger
.
info
(
"开始服务..[配置已加载完成,并且所有框架都已经初始化]"
);
log
.
info
(
"开始服务..[配置已加载完成,并且所有框架都已经初始化]"
);
//初始执行同步用户与皮肤任务
log
.
info
(
"开始同步设备列表!"
);
deviceService
.
syncDevice
();
log
.
info
(
"结束同步设备列表!"
);
log
.
info
(
"开始同步皮肤列表!"
);
skinService
.
syncSkin
();
log
.
info
(
"结束同步皮肤列表!"
);
log
.
info
(
"开始同步用户!"
);
userService
.
refreshUser
();
log
.
info
(
"结束同步用户!"
);
}
}
@Override
@Override
public
void
stop
()
{
public
void
stop
()
{
log
ger
.
info
(
"停止服务.."
);
log
.
info
(
"停止服务.."
);
}
}
@Override
@Override
...
...
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncSiteDeviceTaskImpl.java
View file @
c09d6168
...
@@ -56,13 +56,11 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -56,13 +56,11 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
private
DeviceService
deviceService
;
private
DeviceService
deviceService
;
@Autowired
@Autowired
private
SkinService
skinService
;
private
SkinService
skinService
;
@Autowired
private
ISkinBaseFeign
skinBaseFeign
;
@Override
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"开始同步设备列表!"
);
log
.
info
(
"开始同步设备列表!"
);
syncDevice
();
deviceService
.
syncDevice
();
log
.
info
(
"结束同步设备列表!"
);
log
.
info
(
"结束同步设备列表!"
);
log
.
info
(
"开始同步皮肤列表!"
);
log
.
info
(
"开始同步皮肤列表!"
);
...
@@ -109,7 +107,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -109,7 +107,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
DeviceEntity
deviceEntity
=
new
DeviceEntity
();
DeviceEntity
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
initAttrValue
();
deviceEntity
.
initAttrValue
();
BeanUtils
.
copyProperties
(
newDevice
,
deviceEntity
,
BeanUtil
.
getNullPropertyNames
(
newDevice
));
BeanUtils
.
copyProperties
(
newDevice
,
deviceEntity
,
BeanUtil
.
getNullPropertyNames
(
newDevice
));
deviceEntity
.
setDeviceId
(
newDevice
.
getId
());
deviceEntity
.
setDeviceId
(
newDevice
.
getId
());
return
deviceEntity
;
return
deviceEntity
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
...
@@ -124,7 +122,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -124,7 +122,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
List
<
DeviceEntity
>
updateDeviceLsit
=
newDeviceList
.
stream
().
map
(
item
->
{
List
<
DeviceEntity
>
updateDeviceLsit
=
newDeviceList
.
stream
().
map
(
item
->
{
if
(
oldDeviceMap
.
containsKey
(
item
.
getDeviceCode
()))
{
if
(
oldDeviceMap
.
containsKey
(
item
.
getDeviceCode
()))
{
item
.
setId
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getId
());
item
.
setId
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getId
());
// item.setDeviceId(item.getId());
// item.setDeviceId(item.getId());
item
.
setProductCode
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getProductCode
());
item
.
setProductCode
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getProductCode
());
item
.
setProductName
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getProductName
());
item
.
setProductName
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getProductName
());
item
.
setUpdateTime
(
new
Date
());
item
.
setUpdateTime
(
new
Date
());
...
@@ -136,7 +134,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
...
@@ -136,7 +134,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
List
<
DeviceEntity
>
saveDeviceList
=
newDeviceList
.
stream
().
map
(
item
->
{
List
<
DeviceEntity
>
saveDeviceList
=
newDeviceList
.
stream
().
map
(
item
->
{
//log.info("deviceCode:{},oldDeviceMap:{}",item.getDeviceCode(),oldDeviceMap.containsKey(item.getDeviceCode()));
//log.info("deviceCode:{},oldDeviceMap:{}",item.getDeviceCode(),oldDeviceMap.containsKey(item.getDeviceCode()));
if
(!
oldDeviceMap
.
containsKey
(
item
.
getDeviceCode
()))
{
if
(!
oldDeviceMap
.
containsKey
(
item
.
getDeviceCode
()))
{
// item.setDeviceId(item.getId());
// item.setDeviceId(item.getId());
item
.
setCreateUserId
(
1L
);
item
.
setCreateUserId
(
1L
);
item
.
setProductName
(
"样表机"
);
item
.
setProductName
(
"样表机"
);
item
.
setCreateUserName
(
"系统管理员"
);
item
.
setCreateUserName
(
"系统管理员"
);
...
...
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncSiteMatterTaskImpl.java
View file @
c09d6168
...
@@ -82,10 +82,6 @@ public class SyncSiteMatterTaskImpl implements ITaskExcuteService {
...
@@ -82,10 +82,6 @@ public class SyncSiteMatterTaskImpl implements ITaskExcuteService {
// sheetMatterService.getDao().delete(new SheetMatterQuery().siteId(site.getId()));
// sheetMatterService.getDao().delete(new SheetMatterQuery().siteId(site.getId()));
log
.
info
(
"新增事项数量:{}"
,
sheetMatterEntities
.
size
());
log
.
info
(
"新增事项数量:{}"
,
sheetMatterEntities
.
size
());
sheetMatterService
.
save
(
sheetMatterEntities
);
sheetMatterService
.
save
(
sheetMatterEntities
);
/* List<List<SheetMatterEntity>> partition = ListUtil.partition(sheetMatterEntities, 500);
for (List<SheetMatterEntity> matterEntities : partition) {
}*/
}
}
}
else
{
}
else
{
log
.
info
(
"请求错误,code:{} msg:{}"
,
siteMatterRest
.
getCode
(),
siteMatterRest
.
getMsg
());
log
.
info
(
"请求错误,code:{} msg:{}"
,
siteMatterRest
.
getCode
(),
siteMatterRest
.
getMsg
());
...
...
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
View file @
c09d6168
...
@@ -30,4 +30,9 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long> {
...
@@ -30,4 +30,9 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long> {
* @param context
* @param context
*/
*/
void
deviceEnabled
(
Long
id
,
Integer
status
,
Context
context
);
void
deviceEnabled
(
Long
id
,
Integer
status
,
Context
context
);
void
syncDevice
();
}
}
\ No newline at end of file
sample-form-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
c09d6168
...
@@ -9,20 +9,31 @@ import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
...
@@ -9,20 +9,31 @@ import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import
com.mortals.xhx.common.code.DeviceMethodEnum
;
import
com.mortals.xhx.common.code.DeviceMethodEnum
;
import
com.mortals.xhx.common.code.DeviceStatusEnum
;
import
com.mortals.xhx.common.code.DeviceStatusEnum
;
import
com.mortals.xhx.common.code.EnabledEnum
;
import
com.mortals.xhx.common.code.EnabledEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.LoginForm
;
import
com.mortals.xhx.common.pdu.LoginForm
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.device.DevicePdu
;
import
com.mortals.xhx.common.pdu.device.DeviceReq
;
import
com.mortals.xhx.common.pdu.device.DeviceReq
;
import
com.mortals.xhx.common.pdu.product.ProductPdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.feign.device.IDeviceFeign
;
import
com.mortals.xhx.feign.device.IDeviceFeign
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
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.model.DeviceQuery
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* DeviceService
* DeviceService
...
@@ -43,6 +54,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -43,6 +54,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
private
String
password
;
private
String
password
;
@Autowired
private
ISiteFeign
siteFeign
;
@Override
@Override
protected
String
getExtKey
(
DeviceEntity
data
)
{
protected
String
getExtKey
(
DeviceEntity
data
)
{
return
data
.
getDeviceCode
();
return
data
.
getDeviceCode
();
...
@@ -83,6 +98,113 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -83,6 +98,113 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
log
.
info
(
"启用结果:{}"
,
JSON
.
toJSONString
(
rest
));
log
.
info
(
"启用结果:{}"
,
JSON
.
toJSONString
(
rest
));
}
}
@Override
public
void
syncDevice
()
{
Long
productId
=
null
;
ProductPdu
productPdu
=
new
ProductPdu
();
productPdu
.
setProductCode
(
"ybj"
);
Rest
<
RespData
<
List
<
ProductPdu
>>>
rest
=
deviceFeign
.
list
(
productPdu
);
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
()
&&
!
ObjectUtils
.
isEmpty
(
rest
.
getData
()))
{
if
(!
ObjectUtils
.
isEmpty
(
rest
.
getData
().
getData
()))
{
ProductPdu
pdu
=
rest
.
getData
().
getData
().
get
(
0
);
productId
=
pdu
.
getId
();
}
}
SitePdu
sitePdu
=
new
SitePdu
();
sitePdu
.
setId
(
1L
);
Rest
<
List
<
SitePdu
>>
siteRest
=
siteFeign
.
getFlatSitesBySiteId
(
sitePdu
);
if
(
siteRest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
log
.
info
(
"站点总数量:{}"
,
siteRest
.
getData
().
size
());
for
(
SitePdu
site
:
siteRest
.
getData
())
{
log
.
info
(
"站点名称:{}"
,
site
.
getSiteName
());
DevicePdu
devicePdu
=
new
DevicePdu
();
if
(!
ObjectUtils
.
isEmpty
(
productId
))
{
devicePdu
.
setProductId
(
productId
);
}
else
{
devicePdu
.
setProductName
(
"样表机"
);
}
devicePdu
.
setSiteId
(
site
.
getId
());
devicePdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
DevicePdu
>>>
deviceRest
=
deviceFeign
.
list
(
devicePdu
);
log
.
info
(
"deviceRest:{}"
,
JSON
.
toJSONString
(
deviceRest
));
if
(
YesNoEnum
.
YES
.
getValue
()
==
deviceRest
.
getCode
())
{
List
<
DevicePdu
>
devicePduList
=
deviceRest
.
getData
().
getData
();
log
.
info
(
"样表机总数量:{}"
,
devicePduList
.
size
());
if
(!
ObjectUtils
.
isEmpty
(
devicePduList
))
{
List
<
DeviceEntity
>
newDeviceList
=
devicePduList
.
stream
().
map
(
newDevice
->
{
DeviceEntity
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
initAttrValue
();
BeanUtils
.
copyProperties
(
newDevice
,
deviceEntity
,
BeanUtil
.
getNullPropertyNames
(
newDevice
));
deviceEntity
.
setDeviceId
(
newDevice
.
getId
());
return
deviceEntity
;
}).
collect
(
Collectors
.
toList
());
List
<
DeviceEntity
>
oldDeviceList
=
this
.
find
(
new
DeviceQuery
().
siteId
(
site
.
getId
()));
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
>
newDeviceMap
=
newDeviceList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getDeviceCode
(),
y
->
y
,
(
o
,
n
)
->
n
));
//log.info("oldDeviceMap:{}", JSON.toJSONString(oldDeviceMap));
List
<
DeviceEntity
>
updateDeviceLsit
=
newDeviceList
.
stream
().
map
(
item
->
{
if
(
oldDeviceMap
.
containsKey
(
item
.
getDeviceCode
()))
{
item
.
setId
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getId
());
// item.setDeviceId(item.getId());
item
.
setProductCode
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getProductCode
());
item
.
setProductName
(
oldDeviceMap
.
get
(
item
.
getDeviceCode
()).
getProductName
());
item
.
setUpdateTime
(
new
Date
());
return
item
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
List
<
DeviceEntity
>
saveDeviceList
=
newDeviceList
.
stream
().
map
(
item
->
{
//log.info("deviceCode:{},oldDeviceMap:{}",item.getDeviceCode(),oldDeviceMap.containsKey(item.getDeviceCode()));
if
(!
oldDeviceMap
.
containsKey
(
item
.
getDeviceCode
()))
{
// item.setDeviceId(item.getId());
item
.
setCreateUserId
(
1L
);
item
.
setProductName
(
"样表机"
);
item
.
setCreateUserName
(
"系统管理员"
);
item
.
setCreateTime
(
new
Date
());
return
item
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
//做差集
List
<
Long
>
delDeviceList
=
oldDeviceList
.
stream
().
map
(
item
->
{
if
(!
newDeviceMap
.
containsKey
(
item
.
getDeviceCode
()))
{
return
item
.
getId
();
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
updateDeviceLsit
))
{
log
.
info
(
"设备更新,size:{}"
,
updateDeviceLsit
.
size
());
this
.
update
(
updateDeviceLsit
);
}
if
(!
ObjectUtils
.
isEmpty
(
saveDeviceList
))
{
log
.
info
(
"设备新增,size:{}"
,
saveDeviceList
.
size
());
this
.
save
(
saveDeviceList
);
}
if
(!
ObjectUtils
.
isEmpty
(
delDeviceList
))
{
log
.
info
(
"设备删除,size:{}"
,
delDeviceList
.
size
());
this
.
remove
(
delDeviceList
,
null
);
}
}
}
else
{
log
.
info
(
"设备列表查询异常,{}"
,
JSON
.
toJSONString
(
deviceRest
));
}
}
}
else
{
log
.
info
(
"站点列表查询异常,{}"
,
JSON
.
toJSONString
(
siteRest
));
}
}
/* private String getToken() {
/* private String getToken() {
LoginForm loginForm = new LoginForm();
LoginForm loginForm = new LoginForm();
...
...
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