Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jyzb_platformV2
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
赵剑炜
jyzb_platformV2
Commits
5962e7aa
Commit
5962e7aa
authored
Jan 03, 2024
by
赵剑炜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了部分单警柜的方法
parent
0b1c8eda
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
86 行增加
和
86 行删除
+86
-86
CabinetBoxServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetBoxServiceImpl.java
+84
-85
CabinetServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetServiceImpl.java
+2
-1
没有找到文件。
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetBoxServiceImpl.java
View file @
5962e7aa
...
...
@@ -46,97 +46,96 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
AddOrUpdateBoxInfo
(
UpdateCabinetReq
req
)
{
//
Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
//
.eq(Cabinet::getCabinetNum, req.getSerialNum()));
//
if (ObjectUtil.isNull(cabinet)) {
//
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
//
}
//
//
List<UpdateCabinetBoxReq> addList = req.getCabinetBoxList();
//
List<CabinetBox> existingBoxes = list(new LambdaQueryWrapper<CabinetBox>()
//
.eq(CabinetBox::getCabinetId, cabinet.getId()));
//
//
Map<Integer, CabinetBox> existingBoxMap = existingBoxes.stream()
//
.collect(Collectors.toMap(CabinetBox::getNum, Function.identity()));
//
//
List<CabinetBox> boxListAdd = new ArrayList<>();
//
//
for (UpdateCabinetBoxReq boxReq : addList) {
//
CabinetBox box = new CabinetBox();
//
box.setCabinetId(cabinet.getId());
//
box.setPower(boxReq.getPower());
//
box.setEquipmentConfig(boxReq.getEquipmentConfig());
//
box.setContainType(boxReq.getContainType());
// box.setState(0
);
//
box.setBoxName(boxReq.getBoxName());
//
box.setNum(boxReq.getNum());
//
box.setUpdateTime(new Date());
//
// 在内存中比较是否存在相同 SerialNum 和相同 num 的数据
//
CabinetBox existingBox = existingBoxMap.get(boxReq.getNum());
//
//
if (existingBox != null) {
//
// 如果存在,则更新数据
//
box.setId(existingBox.getId());
//
updateById(box);
//
} else {
//
// 如果不存在,则新增数据
// boxListAdd.add(box);
// }
// }
//
// Integer num = cabinet.getNum();//获取当前柜的总数量
// if (num == null) {
// num = 0;
//
}
//
// // 更新 Cabinet 实体
// cabinet.setNum(num + addList.size());
// cabinetService.updateById(cabinet);
//
// if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送
// {
// MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange");
// }
// // 批量保存新增的数据
// saveBatch(boxListAdd);
//
// return cabinet.getId();
return
null
;
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
req
.
getSerialNum
()));
if
(
ObjectUtil
.
isNull
(
cabinet
))
{
throw
new
ServiceException
(
CabinetExceptionEnum
.
CABINET_ISNOT_EXISTS
);
}
List
<
UpdateCabinetBoxReq
>
addList
=
req
.
getCabinetBoxList
();
List
<
CabinetBox
>
existingBoxes
=
list
(
new
LambdaQueryWrapper
<
CabinetBox
>()
.
eq
(
CabinetBox:
:
getCabinetId
,
cabinet
.
getId
()));
Map
<
Integer
,
CabinetBox
>
existingBoxMap
=
existingBoxes
.
stream
()
.
collect
(
Collectors
.
toMap
(
CabinetBox:
:
getNum
,
Function
.
identity
()));
List
<
CabinetBox
>
boxListAdd
=
new
ArrayList
<>();
for
(
UpdateCabinetBoxReq
boxReq
:
addList
)
{
CabinetBox
box
=
new
CabinetBox
();
box
.
setCabinetId
(
cabinet
.
getId
());
box
.
setPower
(
boxReq
.
getPower
());
box
.
setEquipmentConfig
(
boxReq
.
getEquipmentConfig
());
box
.
setContainType
(
boxReq
.
getContainType
());
box
.
setState
(
1
);
box
.
setBoxName
(
boxReq
.
getBoxName
());
box
.
setNum
(
boxReq
.
getNum
());
box
.
setUpdateTime
(
new
Date
());
// 在内存中比较是否存在相同 SerialNum 和相同 num 的数据
CabinetBox
existingBox
=
existingBoxMap
.
get
(
boxReq
.
getNum
());
if
(
existingBox
!=
null
)
{
// 如果存在,则更新数据
box
.
setId
(
existingBox
.
getId
());
updateById
(
box
);
}
else
{
// 如果不存在,则新增数据
Integer
num
=
cabinet
.
getNum
();
//获取当前柜的总数量
if
(
num
==
null
)
{
num
=
0
;
}
cabinet
.
setNum
(
num
+
addList
.
size
());
boxListAdd
.
add
(
box
);
}
}
cabinetService
.
updateById
(
cabinet
);
if
(
req
.
getActionFrom
().
equals
(
"platform"
))
//请求来源于平台,则进行推送
{
MQ
.
SendMsg
(
"cabinetMsg"
,
req
.
getSerialNum
(),
"cabinetChange"
);
}
// 批量保存新增的数据
saveBatch
(
boxListAdd
);
return
cabinet
.
getId
()
;
}
//删除箱门
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
DeleteBox
(
UpdateCabinetReq
req
)
{
// Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
// .eq(Cabinet::getCabinetNum, req.getSerialNum()));
// if (ObjectUtil.isNull(cabinet)){
// throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
// }
// CabinetBox one = getOne(new LambdaQueryWrapper<CabinetBox>()
// .eq(CabinetBox::getCabinetId, cabinet.getId())
// .eq(CabinetBox::getId,req.getId()));
// if (ObjectUtil.isNotNull(one)){
// throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_IS_EXISTS);
// }
// //添加单警柜箱门信息默认状态为0正常
// List<String> boxNumList = req.getNumList();
// remove(new LambdaQueryWrapper<CabinetBox>()
// .eq(CabinetBox::getCabinetId, cabinet.getId())
// .in(CabinetBox::getNum, boxNumList));
//
// // 更新 Cabinet 实体的 num 字段
// Integer cabinetNum = cabinet.getNum();
// if (cabinetNum != null) {
// cabinet.setNum(cabinetNum - boxNumList.size());
// cabinetService.updateById(cabinet);
// }
// if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送
// {
// MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange");
// }
// return cabinet.getId();
return
null
;
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
req
.
getSerialNum
()));
if
(
ObjectUtil
.
isNull
(
cabinet
)){
throw
new
ServiceException
(
CabinetExceptionEnum
.
CABINET_ISNOT_EXISTS
);
}
CabinetBox
one
=
getOne
(
new
LambdaQueryWrapper
<
CabinetBox
>()
.
eq
(
CabinetBox:
:
getCabinetId
,
cabinet
.
getId
())
.
eq
(
CabinetBox:
:
getId
,
req
.
getId
()));
if
(
ObjectUtil
.
isNotNull
(
one
)){
throw
new
ServiceException
(
CabinetBoxExceptionEnum
.
CABINETBOX_IS_EXISTS
);
}
//添加单警柜箱门信息默认状态为0正常
List
<
String
>
boxNumList
=
req
.
getNumList
();
remove
(
new
LambdaQueryWrapper
<
CabinetBox
>()
.
eq
(
CabinetBox:
:
getCabinetId
,
cabinet
.
getId
())
.
in
(
CabinetBox:
:
getNum
,
boxNumList
));
// 更新 Cabinet 实体的 num 字段
Integer
cabinetNum
=
cabinet
.
getNum
();
if
(
cabinetNum
!=
null
)
{
cabinet
.
setNum
(
cabinetNum
-
boxNumList
.
size
());
cabinetService
.
updateById
(
cabinet
);
}
if
(
req
.
getActionFrom
().
equals
(
"platform"
))
//请求来源于平台,则进行推送
{
MQ
.
SendMsg
(
"cabinetMsg"
,
req
.
getSerialNum
(),
"cabinetChange"
);
}
return
cabinet
.
getId
();
}
//判断箱子信息是否存在
@Override
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetServiceImpl.java
View file @
5962e7aa
...
...
@@ -304,7 +304,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
// 查询单警柜的箱门信息
List
<
CabinetBox
>
list
=
cabinetBoxService
.
list
(
new
LambdaQueryWrapper
<
CabinetBox
>()
.
eq
(
ObjectUtil
.
isNotEmpty
(
cabinet
.
getId
()),
CabinetBox:
:
getCabinetId
,
cabinet
.
getId
())
.
eq
(
ObjectUtil
.
isNotEmpty
(
req
.
getContainType
()),
CabinetBox:
:
getContainType
,
req
.
getContainType
()));
.
eq
(
ObjectUtil
.
isNotEmpty
(
req
.
getContainType
()),
CabinetBox:
:
getContainType
,
req
.
getContainType
())
.
orderByAsc
(
CabinetBox:
:
getNum
));
List
<
CabinetBoxDto
>
boxList
=
list
.
stream
()
.
map
(
cabinetBox
->
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论