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 7c7bbaf1
authored
Aug 21, 2024
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[fix] 设备批量录入和流转的逻辑修改
1 parent
e9d97a35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 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 @
7c7bbaf
...
...
@@ -40,13 +40,13 @@ public class DeviceController {
return
deviceService
.
update
(
dtoList
);
}
@PostMapping
(
"/
single
"
)
@SaCheckPermission
(
value
=
"device:
circulate
"
,
orRole
=
"admin"
)
public
String
circulate
(
@RequestBody
DeviceDTO
dto
)
{
return
deviceService
.
circulate
(
dto
);
@PostMapping
(
"/
record
"
)
@SaCheckPermission
(
value
=
"device:
record
"
,
orRole
=
"admin"
)
public
String
circulate
(
@RequestBody
List
<
DeviceDTO
>
dtoList
)
{
return
deviceService
.
recordDevice
(
dtoList
);
}
@PostMapping
(
"/
batch
"
)
@PostMapping
(
"/
circulate
"
)
@SaCheckPermission
(
value
=
"device:circulateBatch"
,
orRole
=
"admin"
)
public
String
circulateBatch
(
@RequestBody
List
<
DeviceDTO
>
dtoList
)
{
return
deviceService
.
circulateBatch
(
dtoList
);
...
...
src/main/java/vion/service/IDeviceService.java
View file @
7c7bbaf
...
...
@@ -20,7 +20,7 @@ public interface IDeviceService extends MPJBaseService<Device> {
String
update
(
List
<
DeviceDTO
>
dtoList
);
String
circulate
(
DeviceDTO
dto
);
String
recordDevice
(
List
<
DeviceDTO
>
dtoList
);
String
circulateBatch
(
List
<
DeviceDTO
>
dtoList
);
}
src/main/java/vion/service/impl/IDeviceServiceImpl.java
View file @
7c7bbaf
...
...
@@ -7,7 +7,6 @@ import io.github.linpeilie.Converter;
import
lombok.RequiredArgsConstructor
;
import
org.dromara.hutool.core.collection.CollUtil
;
import
org.dromara.hutool.core.text.StrUtil
;
import
org.dromara.hutool.core.util.ObjUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
vion.dto.DeviceDTO
;
...
...
@@ -20,6 +19,7 @@ import vion.service.IDeviceService;
import
vion.vo.DeviceVO
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author HlQ
...
...
@@ -75,28 +75,44 @@ public class IDeviceServiceImpl extends MPJBaseServiceImpl<DeviceMapper, Device>
}
@Override
public
String
circulate
(
DeviceDTO
dto
)
{
// 只有出库才允许单个设备录入
if
(
ObjUtil
.
notEquals
(
dto
.
getStatus
(),
2
))
{
return
"
该设备状态限制,不支持录入
"
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
recordDevice
(
List
<
DeviceDTO
>
dtoList
)
{
if
(
CollUtil
.
isEmpty
(
dtoList
))
{
return
"
设备为空
"
;
}
var
device
=
converter
.
convert
(
dto
,
Device
.
class
);
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
"出库成功"
;
var
statusSet
=
dtoList
.
stream
().
map
(
DeviceDTO:
:
getStatus
).
collect
(
Collectors
.
toSet
());
if
(
statusSet
.
size
()
>
1
||
!
statusSet
.
contains
(
1
))
{
return
"该操作仅支持设备入库"
;
}
return
"出库失败"
;
var
userId
=
dtoList
.
getFirst
().
getUserId
();
var
deviceList
=
converter
.
convert
(
dtoList
,
Device
.
class
);
if
(
this
.
saveBatch
(
deviceList
))
{
var
logList
=
deviceList
.
stream
()
.
map
(
d
->
{
var
deviceLog
=
new
DeviceLog
();
deviceLog
.
setDeviceId
(
d
.
getId
());
deviceLog
.
setOperator
(
userId
);
deviceLog
.
setContent
(
getStatusStr
(
d
.
getStatus
()));
return
deviceLog
;
}).
toList
();
deviceLogService
.
saveBatch
(
logList
);
return
"保存成功"
;
}
return
"保存失败"
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
circulateBatch
(
List
<
DeviceDTO
>
dtoList
)
{
if
(
CollUtil
.
isEmpty
(
dtoList
))
{
return
"录入设备为空"
;
return
"设备为空"
;
}
var
statusSet
=
dtoList
.
stream
().
map
(
DeviceDTO:
:
getStatus
).
collect
(
Collectors
.
toSet
());
if
(
statusSet
.
size
()
>
1
)
{
return
"该操作不允许对设备进行不同处理"
;
}
if
(
statusSet
.
contains
(
1
))
{
return
"该操作不支持入库操作"
;
}
var
userId
=
dtoList
.
getFirst
().
getUserId
();
var
deviceList
=
converter
.
convert
(
dtoList
,
Device
.
class
);
...
...
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