Commit 5962e7aa by 赵剑炜

修改了部分单警柜的方法

parent 0b1c8eda
...@@ -46,97 +46,96 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet ...@@ -46,97 +46,96 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String AddOrUpdateBoxInfo(UpdateCabinetReq req) { public String AddOrUpdateBoxInfo(UpdateCabinetReq req) {
// Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>() Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
// .eq(Cabinet::getCabinetNum, req.getSerialNum())); .eq(Cabinet::getCabinetNum, req.getSerialNum()));
// if (ObjectUtil.isNull(cabinet)) { if (ObjectUtil.isNull(cabinet)) {
// throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS); throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
// } }
//
// List<UpdateCabinetBoxReq> addList = req.getCabinetBoxList(); List<UpdateCabinetBoxReq> addList = req.getCabinetBoxList();
// List<CabinetBox> existingBoxes = list(new LambdaQueryWrapper<CabinetBox>() List<CabinetBox> existingBoxes = list(new LambdaQueryWrapper<CabinetBox>()
// .eq(CabinetBox::getCabinetId, cabinet.getId())); .eq(CabinetBox::getCabinetId, cabinet.getId()));
//
// Map<Integer, CabinetBox> existingBoxMap = existingBoxes.stream() Map<Integer, CabinetBox> existingBoxMap = existingBoxes.stream()
// .collect(Collectors.toMap(CabinetBox::getNum, Function.identity())); .collect(Collectors.toMap(CabinetBox::getNum, Function.identity()));
//
// List<CabinetBox> boxListAdd = new ArrayList<>(); List<CabinetBox> boxListAdd = new ArrayList<>();
//
// for (UpdateCabinetBoxReq boxReq : addList) { for (UpdateCabinetBoxReq boxReq : addList) {
// CabinetBox box = new CabinetBox(); CabinetBox box = new CabinetBox();
// box.setCabinetId(cabinet.getId()); box.setCabinetId(cabinet.getId());
// box.setPower(boxReq.getPower()); box.setPower(boxReq.getPower());
// box.setEquipmentConfig(boxReq.getEquipmentConfig()); box.setEquipmentConfig(boxReq.getEquipmentConfig());
// box.setContainType(boxReq.getContainType()); box.setContainType(boxReq.getContainType());
// box.setState(0); box.setState(1);
// box.setBoxName(boxReq.getBoxName()); box.setBoxName(boxReq.getBoxName());
// box.setNum(boxReq.getNum()); box.setNum(boxReq.getNum());
// box.setUpdateTime(new Date()); box.setUpdateTime(new Date());
// // 在内存中比较是否存在相同 SerialNum 和相同 num 的数据 // 在内存中比较是否存在相同 SerialNum 和相同 num 的数据
// CabinetBox existingBox = existingBoxMap.get(boxReq.getNum()); CabinetBox existingBox = existingBoxMap.get(boxReq.getNum());
//
// if (existingBox != null) { if (existingBox != null) {
// // 如果存在,则更新数据 // 如果存在,则更新数据
// box.setId(existingBox.getId()); box.setId(existingBox.getId());
// updateById(box); updateById(box);
// } else { } else {
// // 如果不存在,则新增数据 // 如果不存在,则新增数据
// boxListAdd.add(box); Integer num = cabinet.getNum();//获取当前柜的总数量
// } if (num == null) {
// } num = 0;
// }
// Integer num = cabinet.getNum();//获取当前柜的总数量 cabinet.setNum(num + addList.size());
// if (num == null) { boxListAdd.add(box);
// num = 0; }
// } }
//
// // 更新 Cabinet 实体
// cabinet.setNum(num + addList.size());
// cabinetService.updateById(cabinet);
// cabinetService.updateById(cabinet);
// if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送
// { if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送
// MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange"); {
// } MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange");
// // 批量保存新增的数据 }
// saveBatch(boxListAdd); // 批量保存新增的数据
// saveBatch(boxListAdd);
// return cabinet.getId();
return null; return cabinet.getId();
} }
//删除箱门 //删除箱门
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String DeleteBox(UpdateCabinetReq req) { public String DeleteBox(UpdateCabinetReq req) {
// Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>() Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
// .eq(Cabinet::getCabinetNum, req.getSerialNum())); .eq(Cabinet::getCabinetNum, req.getSerialNum()));
// if (ObjectUtil.isNull(cabinet)){ if (ObjectUtil.isNull(cabinet)){
// throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS); throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
// } }
// CabinetBox one = getOne(new LambdaQueryWrapper<CabinetBox>() CabinetBox one = getOne(new LambdaQueryWrapper<CabinetBox>()
// .eq(CabinetBox::getCabinetId, cabinet.getId()) .eq(CabinetBox::getCabinetId, cabinet.getId())
// .eq(CabinetBox::getId,req.getId())); .eq(CabinetBox::getId,req.getId()));
// if (ObjectUtil.isNotNull(one)){ if (ObjectUtil.isNotNull(one)){
// throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_IS_EXISTS); throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_IS_EXISTS);
// } }
// //添加单警柜箱门信息默认状态为0正常 //添加单警柜箱门信息默认状态为0正常
// List<String> boxNumList = req.getNumList(); List<String> boxNumList = req.getNumList();
// remove(new LambdaQueryWrapper<CabinetBox>() remove(new LambdaQueryWrapper<CabinetBox>()
// .eq(CabinetBox::getCabinetId, cabinet.getId()) .eq(CabinetBox::getCabinetId, cabinet.getId())
// .in(CabinetBox::getNum, boxNumList)); .in(CabinetBox::getNum, boxNumList));
//
// // 更新 Cabinet 实体的 num 字段 // 更新 Cabinet 实体的 num 字段
// Integer cabinetNum = cabinet.getNum(); Integer cabinetNum = cabinet.getNum();
// if (cabinetNum != null) { if (cabinetNum != null) {
// cabinet.setNum(cabinetNum - boxNumList.size()); cabinet.setNum(cabinetNum - boxNumList.size());
// cabinetService.updateById(cabinet); cabinetService.updateById(cabinet);
// } }
// if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送 if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送
// { {
// MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange"); MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange");
// } }
// return cabinet.getId(); return cabinet.getId();
return null;
} }
//判断箱子信息是否存在 //判断箱子信息是否存在
@Override @Override
......
...@@ -304,7 +304,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -304,7 +304,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
// 查询单警柜的箱门信息 // 查询单警柜的箱门信息
List<CabinetBox> list = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>() List<CabinetBox> list = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>()
.eq(ObjectUtil.isNotEmpty(cabinet.getId()), CabinetBox::getCabinetId, cabinet.getId()) .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() List<CabinetBoxDto> boxList = list.stream()
.map(cabinetBox -> { .map(cabinetBox -> {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论