Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e9d97a35
authored
Aug 21, 2024
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[fix] 设备状态流转问题修改
1 parent
24057cc6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
21 deletions
src/main/java/vion/controller/DeviceController.java
src/main/java/vion/service/IDeviceService.java
src/main/java/vion/service/impl/IDeviceServiceImpl.java
src/main/java/vion/controller/DeviceController.java
View file @
e9d97a3
...
...
@@ -41,15 +41,15 @@ public class DeviceController {
}
@PostMapping
(
"/single"
)
@SaCheckPermission
(
value
=
"device:
sav
e"
,
orRole
=
"admin"
)
public
String
sav
e
(
@RequestBody
DeviceDTO
dto
)
{
return
deviceService
.
sav
e
(
dto
);
@SaCheckPermission
(
value
=
"device:
circulat
e"
,
orRole
=
"admin"
)
public
String
circulat
e
(
@RequestBody
DeviceDTO
dto
)
{
return
deviceService
.
circulat
e
(
dto
);
}
@PostMapping
(
"/batch"
)
@SaCheckPermission
(
value
=
"device:
sav
eBatch"
,
orRole
=
"admin"
)
public
String
sav
eBatch
(
@RequestBody
List
<
DeviceDTO
>
dtoList
)
{
return
deviceService
.
sav
eBatch
(
dtoList
);
@SaCheckPermission
(
value
=
"device:
circulat
eBatch"
,
orRole
=
"admin"
)
public
String
circulat
eBatch
(
@RequestBody
List
<
DeviceDTO
>
dtoList
)
{
return
deviceService
.
circulat
eBatch
(
dtoList
);
}
}
src/main/java/vion/service/IDeviceService.java
View file @
e9d97a3
...
...
@@ -20,7 +20,7 @@ public interface IDeviceService extends MPJBaseService<Device> {
String
update
(
List
<
DeviceDTO
>
dtoList
);
String
sav
e
(
DeviceDTO
dto
);
String
circulat
e
(
DeviceDTO
dto
);
String
sav
eBatch
(
List
<
DeviceDTO
>
dtoList
);
String
circulat
eBatch
(
List
<
DeviceDTO
>
dtoList
);
}
src/main/java/vion/service/impl/IDeviceServiceImpl.java
View file @
e9d97a3
...
...
@@ -75,45 +75,41 @@ public class IDeviceServiceImpl extends MPJBaseServiceImpl<DeviceMapper, Device>
}
@Override
public
String
sav
e
(
DeviceDTO
dto
)
{
public
String
circulat
e
(
DeviceDTO
dto
)
{
// 只有出库才允许单个设备录入
if
(
ObjUtil
.
notEquals
(
dto
.
getStatus
(),
2
))
{
return
"该设备状态限制,不支持录入"
;
}
var
device
=
converter
.
convert
(
dto
,
Device
.
class
);
if
(
this
.
save
(
device
))
{
if
(
this
.
updateById
(
device
))
{
var
deviceLog
=
new
DeviceLog
();
deviceLog
.
setDeviceId
(
device
.
getId
());
deviceLog
.
setOperator
(
dto
.
getUserId
());
deviceLog
.
setContent
(
getStatusStr
(
dto
.
getStatus
()));
deviceLogService
.
save
(
deviceLog
);
return
"
保存
成功"
;
return
"
出库
成功"
;
}
return
"
保存
失败"
;
return
"
出库
失败"
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
sav
eBatch
(
List
<
DeviceDTO
>
dtoList
)
{
public
String
circulat
eBatch
(
List
<
DeviceDTO
>
dtoList
)
{
if
(
CollUtil
.
isEmpty
(
dtoList
))
{
return
"录入设备为空"
;
}
var
userId
=
dtoList
.
getFirst
().
getUserId
();
var
deviceList
=
converter
.
convert
(
dtoList
,
Device
.
class
);
if
(
this
.
saveBatch
(
deviceList
))
{
var
logList
=
deviceList
.
stream
()
.
map
(
d
->
{
deviceList
.
forEach
(
d
->
{
this
.
lambdaUpdate
().
eq
(
Device:
:
getSerialNum
,
d
.
getSerialNum
()).
update
(
d
);
var
deviceLog
=
new
DeviceLog
();
deviceLog
.
setDeviceId
(
d
.
getId
());
deviceLog
.
setOperator
(
userId
);
deviceLog
.
setContent
(
getStatusStr
(
d
.
getStatus
()));
return
deviceLog
;
}).
toList
();
deviceLogService
.
saveBatch
(
logList
);
deviceLogService
.
save
(
deviceLog
);
});
return
"保存成功"
;
}
return
"保存失败"
;
}
private
String
getStatusStr
(
Integer
status
)
{
return
switch
(
status
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment