Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart-office-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
赵啸非
smart-office-platform
Commits
cd40e0e7
Commit
cd40e0e7
authored
May 29, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改同步用户
parent
b11e4ace
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
smart-office-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+37
-0
smart-office-manager/src/main/java/com/mortals/xhx/module/room/service/impl/RoomServiceImpl.java
...mortals/xhx/module/room/service/impl/RoomServiceImpl.java
+21
-1
No files found.
smart-office-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
cd40e0e7
...
...
@@ -11,6 +11,9 @@ 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
com.mortals.xhx.module.room.model.RoomDeviceEntity
;
import
com.mortals.xhx.module.room.model.RoomDeviceQuery
;
import
com.mortals.xhx.module.room.service.RoomDeviceService
;
import
lombok.Data
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -45,6 +48,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
private
String
loginName
;
@Value
(
"${token.password:'admin'}"
)
private
String
password
;
@Autowired
private
RoomDeviceService
roomDeviceService
;
@Override
protected
void
validData
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
...
...
@@ -52,11 +57,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity
.
setDeviceCode
(
entity
.
getDeviceMac
());
}
@Override
protected
void
saveBefore
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
super
.
saveBefore
(
entity
,
context
);
}
@Override
protected
void
saveAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
super
.
saveAfter
(
entity
,
context
);
RoomDeviceEntity
roomDeviceEntity
=
new
RoomDeviceEntity
();
roomDeviceEntity
.
initAttrValue
();
roomDeviceEntity
.
setRoomId
(
entity
.
getRoomId
());
roomDeviceEntity
.
setRoomName
(
entity
.
getRoomName
());
roomDeviceEntity
.
setDeviceId
(
entity
.
getId
());
roomDeviceEntity
.
setDeviceCode
(
entity
.
getDeviceCode
());
roomDeviceEntity
.
setDeviceName
(
entity
.
getDeviceName
());
roomDeviceService
.
save
(
roomDeviceEntity
,
context
);
}
@Override
protected
void
updateBefore
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
super
.
updateBefore
(
entity
,
context
);
DeviceEntity
beforeEntity
=
this
.
get
(
entity
.
getId
(),
context
);
if
(!
beforeEntity
.
getDeviceCode
().
equals
(
entity
.
getDeviceCode
()))
{
RoomDeviceQuery
roomDeviceQuery
=
new
RoomDeviceQuery
();
roomDeviceQuery
.
setDeviceCode
(
beforeEntity
.
getDeviceCode
());
roomDeviceQuery
.
setRoomId
(
entity
.
getRoomId
());
RoomDeviceEntity
roomDeviceEntity
=
roomDeviceService
.
selectOne
(
roomDeviceQuery
);
if
(!
ObjectUtils
.
isEmpty
(
roomDeviceEntity
))
{
roomDeviceEntity
.
setDeviceCode
(
entity
.
getDeviceCode
());
roomDeviceEntity
.
setDeviceId
(
entity
.
getId
());
roomDeviceEntity
.
setDeviceName
(
entity
.
getDeviceName
());
roomDeviceEntity
.
setUpdateTime
(
new
Date
());
roomDeviceService
.
update
(
roomDeviceEntity
,
context
);
}
}
}
@Override
protected
void
updateAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
...
...
smart-office-manager/src/main/java/com/mortals/xhx/module/room/service/impl/RoomServiceImpl.java
View file @
cd40e0e7
...
...
@@ -52,6 +52,12 @@ public class RoomServiceImpl extends AbstractCRUDServiceImpl<RoomDao, RoomEntity
item
.
setDeviceName
(
deviceCache
==
null
?
""
:
deviceCache
.
getDeviceName
());
item
.
setCreateUserId
(
this
.
getContextUserId
(
context
));
item
.
setCreateTime
(
new
Date
());
DeviceEntity
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
setId
(
item
.
getDeviceId
());
deviceEntity
.
setRoomId
(
entity
.
getId
());
deviceEntity
.
setRoomName
(
entity
.
getRoomName
());
deviceService
.
update
(
deviceEntity
);
}).
count
();
roomDeviceService
.
save
(
entity
.
getRoomDeviceList
());
}
...
...
@@ -69,7 +75,6 @@ public class RoomServiceImpl extends AbstractCRUDServiceImpl<RoomDao, RoomEntity
Long
[]
roomDeviceIds
=
roomDeviceService
.
find
(
roomDeviceQuery
).
stream
().
map
(
RoomDeviceEntity:
:
getId
).
toArray
(
Long
[]::
new
);
roomDeviceService
.
remove
(
roomDeviceIds
,
context
);
roomDeviceIds
=
roomDeviceService
.
find
(
new
RoomDeviceQuery
().
roomId
(
entity
.
getId
())).
stream
().
map
(
RoomDeviceEntity:
:
getId
).
toArray
(
Long
[]::
new
);
roomDeviceService
.
remove
(
roomDeviceIds
,
context
);
entity
.
getRoomDeviceList
().
stream
().
peek
(
item
->
{
...
...
@@ -83,6 +88,13 @@ public class RoomServiceImpl extends AbstractCRUDServiceImpl<RoomDao, RoomEntity
item
.
setCreateTime
(
new
Date
());
item
.
setUpdateUserId
(
this
.
getContextUserId
(
context
));
item
.
setUpdateTime
(
new
Date
());
DeviceEntity
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
setId
(
item
.
getDeviceId
());
deviceEntity
.
setRoomId
(
entity
.
getId
());
deviceEntity
.
setRoomName
(
entity
.
getRoomName
());
deviceService
.
update
(
deviceEntity
);
}).
count
();
roomDeviceService
.
save
(
entity
.
getRoomDeviceList
());
}
...
...
@@ -93,6 +105,14 @@ public class RoomServiceImpl extends AbstractCRUDServiceImpl<RoomDao, RoomEntity
protected
void
removeAfter
(
Long
[]
ids
,
Context
context
,
int
result
)
throws
AppException
{
List
<
RoomDeviceEntity
>
roomDevicelist
=
roomDeviceService
.
find
(
new
RoomDeviceQuery
().
roomIdList
(
Arrays
.
asList
(
ids
)));
roomDeviceService
.
removeList
(
roomDevicelist
,
context
);
roomDevicelist
.
stream
().
forEach
(
item
->{
DeviceEntity
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
setId
(
item
.
getDeviceId
());
deviceEntity
.
setRoomId
(-
1L
);
deviceEntity
.
setRoomName
(
""
);
deviceService
.
update
(
deviceEntity
);
});
super
.
removeAfter
(
ids
,
context
,
result
);
}
}
\ 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