Compare commits
4 Commits
f3e4ba39d1
...
35e61c5321
Author | SHA1 | Date | |
---|---|---|---|
![]() |
35e61c5321 | ||
![]() |
950f014f0f | ||
![]() |
13273992ed | ||
![]() |
a4257f3bd3 |
@ -96,6 +96,10 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
@Resource
|
@Resource
|
||||||
private BaseSupplierService supplierService;
|
private BaseSupplierService supplierService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Lazy
|
||||||
|
private RepairWaresService repairWaresService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购单/领料单 新增
|
* 采购单/领料单 新增
|
||||||
*
|
*
|
||||||
@ -185,6 +189,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
* @date 11:12 2024/9/18
|
* @date 11:12 2024/9/18
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
|
@DSTransactional
|
||||||
public void voidRepairSo(DlRepairSoReqVO repairSoReqVO) {
|
public void voidRepairSo(DlRepairSoReqVO repairSoReqVO) {
|
||||||
baseMapper.updateById(repairSoReqVO);
|
baseMapper.updateById(repairSoReqVO);
|
||||||
|
|
||||||
@ -197,6 +202,54 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
boolean flag = so.getUserId().equals(loginUserId);
|
boolean flag = so.getUserId().equals(loginUserId);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
repairWorkerService.sentMessage(Long.valueOf(so.getCreator()), (so.getSoType().equals("02") ? "领料单:" : "退料单:") + so.getSoNo() + "已被" + so.getUserName() + "作废");
|
repairWorkerService.sentMessage(Long.valueOf(so.getCreator()), (so.getSoType().equals("02") ? "领料单:" : "退料单:") + so.getSoNo() + "已被" + so.getUserName() + "作废");
|
||||||
|
// 需要更新库存和申请表数据
|
||||||
|
// 查单据子表
|
||||||
|
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().in(DlRepairSoi::getSoId, so.getId()));
|
||||||
|
// 查要操作申请表子表
|
||||||
|
List<DlTwItem> oldTwItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
|
||||||
|
item.eq(DlTwItem::getTwId, so.getTwId())
|
||||||
|
.in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
|
||||||
|
}));
|
||||||
|
// 查要操作的配件
|
||||||
|
List<RepairWares> oldWares = repairWaresService.list(new LambdaQueryWrapper<RepairWares>().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())));
|
||||||
|
// 新的申请表子表数据和配件数据
|
||||||
|
List<DlTwItem> newTwItems = new ArrayList<>();
|
||||||
|
List<RepairWares> newWares = new ArrayList<>();
|
||||||
|
// 需要区分是领料还是退料
|
||||||
|
// 得到新申请表子表数据
|
||||||
|
oldTwItems.forEach(item -> {
|
||||||
|
DlTwItem dlTwItem = new DlTwItem();
|
||||||
|
dlTwItem.setId(item.getId());
|
||||||
|
sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(repairSoiByTwItem -> {
|
||||||
|
if (so.getSoType().equals("02")){
|
||||||
|
dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() - repairSoiByTwItem.getGoodsCount());
|
||||||
|
dlTwItem.setWaresCouldCount(item.getWaresCouldCount() + repairSoiByTwItem.getGoodsCount());
|
||||||
|
dlTwItem.setWaresStatus("02");
|
||||||
|
}else {
|
||||||
|
dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() + repairSoiByTwItem.getGoodsCount());
|
||||||
|
dlTwItem.setWaresCouldCount(item.getWaresCouldCount() - repairSoiByTwItem.getGoodsCount());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newTwItems.add(dlTwItem);
|
||||||
|
});
|
||||||
|
// 得到新配件数据
|
||||||
|
oldWares.forEach(item -> {
|
||||||
|
RepairWares wares = new RepairWares();
|
||||||
|
wares.setId(item.getId());
|
||||||
|
sois.stream().filter(i -> i.getGoodsId().equals(wares.getId())).findFirst().ifPresent(repairSoiByWares -> {
|
||||||
|
if (so.getSoType().equals("02")){
|
||||||
|
wares.setStock(item.getStock().add(BigDecimal.valueOf(repairSoiByWares.getGoodsCount())));
|
||||||
|
}else {
|
||||||
|
wares.setStock(item.getStock().subtract(BigDecimal.valueOf(repairSoiByWares.getGoodsCount())));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newWares.add(wares);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 更新申请表子表
|
||||||
|
twItemService.updateBatchById(newTwItems);
|
||||||
|
// 更新配件
|
||||||
|
repairWaresService.updateBatchById(newWares);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,53 +302,54 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
.list(new LambdaQueryWrapper<DlRepairSoi>()
|
.list(new LambdaQueryWrapper<DlRepairSoi>()
|
||||||
.eq(DlRepairSoi::getSoId, id)
|
.eq(DlRepairSoi::getSoId, id)
|
||||||
);
|
);
|
||||||
// 查库存
|
// 查库存---生成领料单的时候更新了
|
||||||
List<RepairWares> wares = waresService
|
// List<RepairWares> wares = waresService
|
||||||
.list(new LambdaQueryWrapper<RepairWares>()
|
// .list(new LambdaQueryWrapper<RepairWares>()
|
||||||
.in(RepairWares::getId, sois.stream()
|
// .in(RepairWares::getId, sois.stream()
|
||||||
.map(DlRepairSoi::getGoodsId)
|
// .map(DlRepairSoi::getGoodsId)
|
||||||
.collect(Collectors.toList())
|
// .collect(Collectors.toList())
|
||||||
));
|
// ));
|
||||||
// 更新库存
|
// // 更新库存
|
||||||
List<RepairWares> newWares = wares.stream().map(item -> {
|
// List<RepairWares> newWares = wares.stream().map(item -> {
|
||||||
RepairWares ware = new RepairWares();
|
// RepairWares ware = new RepairWares();
|
||||||
ware.setId(item.getId());
|
// ware.setId(item.getId());
|
||||||
sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> {
|
// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> {
|
||||||
ware.setStock(item.getStock().subtract(BigDecimal.valueOf(i.getGoodsCount())));
|
// ware.setStock(item.getStock().subtract(BigDecimal.valueOf(i.getGoodsCount())));
|
||||||
});
|
// });
|
||||||
return ware;
|
// return ware;
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
waresService.updateBatchById(newWares);
|
// waresService.updateBatchById(newWares);
|
||||||
// 更新主表状态 为已领料
|
// 更新主表状态 为已领料
|
||||||
DlRepairSo dlRepairSo = new DlRepairSo();
|
DlRepairSo dlRepairSo = new DlRepairSo();
|
||||||
dlRepairSo.setId(id);
|
dlRepairSo.setId(id);
|
||||||
dlRepairSo.setSoStatus(SoStatusEnum.PICKED.getCode());
|
dlRepairSo.setSoStatus(SoStatusEnum.PICKED.getCode());
|
||||||
baseMapper.updateById(dlRepairSo);
|
baseMapper.updateById(dlRepairSo);
|
||||||
|
|
||||||
// 更新申请表的数据
|
// 更新申请表的数据----生成领料单的时候更新了
|
||||||
DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper<DlRepairSo>().eq(DlRepairSo::getId, id));
|
// // 查申请表的子表对应的配件信息
|
||||||
// 查申请表的子表对应的配件信息
|
// List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
|
||||||
List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
|
// item.eq(DlTwItem::getTwId, so.getTwId())
|
||||||
item.eq(DlTwItem::getTwId, so.getTwId())
|
// .in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
|
||||||
.in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
|
// }));
|
||||||
}));
|
// // 更新子表
|
||||||
// 更新子表
|
// List<DlTwItem> newTwItems = twItems.stream().map(item -> {
|
||||||
List<DlTwItem> newTwItems = twItems.stream().map(item -> {
|
// DlTwItem dlTwItem = new DlTwItem();
|
||||||
DlTwItem dlTwItem = new DlTwItem();
|
// dlTwItem.setId(item.getId());
|
||||||
dlTwItem.setId(item.getId());
|
// dlTwItem.setWaresAlreadyCount(ObjectUtil.isNotEmpty(item.getWaresAlreadyCount()) ? item.getWaresAlreadyCount() + item.getWaresCouldCount() : item.getWaresCouldCount());
|
||||||
dlTwItem.setWaresAlreadyCount(ObjectUtil.isNotEmpty(item.getWaresAlreadyCount()) ? item.getWaresAlreadyCount() + item.getWaresCouldCount() : item.getWaresCouldCount());
|
// dlTwItem.setWaresStatus(dlTwItem.getWaresAlreadyCount().equals(item.getWaresCount()) ? "01" : item.getWaresStatus());
|
||||||
dlTwItem.setWaresStatus(dlTwItem.getWaresAlreadyCount().equals(item.getWaresCount()) ? "01" : item.getWaresStatus());
|
// return dlTwItem;
|
||||||
return dlTwItem;
|
// }).collect(Collectors.toList());
|
||||||
}).collect(Collectors.toList());
|
// twItemService.updateBatchById(newTwItems);
|
||||||
twItemService.updateBatchById(newTwItems);
|
|
||||||
|
|
||||||
// 查最新的子表信息
|
// 查最新的子表信息
|
||||||
|
DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper<DlRepairSo>().eq(DlRepairSo::getId, id));
|
||||||
List<DlTwItem> list = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, so.getTwId()));
|
List<DlTwItem> list = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, so.getTwId()));
|
||||||
// 判断是部分完成还是全部完成
|
// 判断是部分完成还是全部完成
|
||||||
DlTicketWares dlTicketWares = new DlTicketWares();
|
DlTicketWares dlTicketWares = new DlTicketWares();
|
||||||
dlTicketWares.setId(so.getTwId());
|
dlTicketWares.setId(so.getTwId());
|
||||||
List<DlTwItem> flag = list.stream().filter(item -> !item.getWaresStatus().equals("01")).collect(Collectors.toList());
|
List<DlTwItem> flag = list.stream().filter(item -> !item.getWaresStatus().equals("01")).collect(Collectors.toList());
|
||||||
dlTicketWares.setStatus(CollectionUtil.isEmpty(flag) ? "03" : "04");
|
dlTicketWares.setStatus(CollectionUtil.isEmpty(flag) ? "03" : "04");
|
||||||
|
// 更新主表的状态
|
||||||
ticketWaresService.updateById(dlTicketWares);
|
ticketWaresService.updateById(dlTicketWares);
|
||||||
|
|
||||||
// 查主表记录
|
// 查主表记录
|
||||||
@ -319,92 +373,94 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
.set(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
|
.set(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
|
||||||
.eq(DlRepairSo::getId, id)
|
.eq(DlRepairSo::getId, id)
|
||||||
);
|
);
|
||||||
// 更新配件申请表
|
// 更新配件申请表----生成退料单的时候更新了
|
||||||
DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper<DlRepairSo>().eq(DlRepairSo::getId, id));
|
// DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper<DlRepairSo>().eq(DlRepairSo::getId, id));
|
||||||
// 查配件退料表子表
|
// // 查配件退料表子表
|
||||||
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, so.getId()));
|
// List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, so.getId()));
|
||||||
// 查申请表子表
|
// // 查申请表子表
|
||||||
List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, so.getTwId()));
|
// List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, so.getTwId()));
|
||||||
// 得到需要更新的数据
|
// // 得到需要更新的数据
|
||||||
List<DlTwItem> newTwItems = twItems.stream().map(item -> {
|
// List<DlTwItem> newTwItems = twItems.stream().map(item -> {
|
||||||
DlTwItem dlTwItem = new DlTwItem();
|
// DlTwItem dlTwItem = new DlTwItem();
|
||||||
dlTwItem.setId(item.getId());
|
// dlTwItem.setId(item.getId());
|
||||||
sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(i -> {
|
// sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(i -> {
|
||||||
dlTwItem.setWaresBackCount(
|
// dlTwItem.setWaresBackCount(
|
||||||
ObjectUtil.isNotEmpty(item.getWaresBackCount())
|
// ObjectUtil.isNotEmpty(item.getWaresBackCount())
|
||||||
? item.getWaresCount() + item.getWaresBackCount()
|
// ? item.getWaresCount() + item.getWaresBackCount()
|
||||||
: i.getGoodsCount());
|
// : i.getGoodsCount());
|
||||||
// 如果退料数就是领料申请数,那就是全退了
|
// // 如果退料数就是领料申请数,那就是全退了
|
||||||
if (i.getGoodsCount().equals(dlTwItem.getWaresCount())) {
|
// if (i.getGoodsCount().equals(dlTwItem.getWaresCount())) {
|
||||||
dlTwItem.setWaresStatus("03");
|
// dlTwItem.setWaresStatus("03");
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
return dlTwItem;
|
// return dlTwItem;
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
twItemService.updateBatchById(newTwItems);
|
// twItemService.updateBatchById(newTwItems);
|
||||||
// 更新库存
|
// // 更新库存
|
||||||
// 查库存
|
// // 查库存
|
||||||
List<RepairWares> wares = waresService.list(new LambdaQueryWrapper<RepairWares>().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())));
|
// List<RepairWares> wares = waresService.list(new LambdaQueryWrapper<RepairWares>().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())));
|
||||||
// 构建新数据
|
// // 构建新数据
|
||||||
List<RepairWares> newWares = wares.stream().map(item -> {
|
// List<RepairWares> newWares = wares.stream().map(item -> {
|
||||||
RepairWares ware = new RepairWares();
|
// RepairWares ware = new RepairWares();
|
||||||
ware.setId(item.getId());
|
// ware.setId(item.getId());
|
||||||
sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> {
|
// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> {
|
||||||
ware.setStock(item.getStock().add(BigDecimal.valueOf(i.getGoodsCount())));
|
// ware.setStock(item.getStock().add(BigDecimal.valueOf(i.getGoodsCount())));
|
||||||
});
|
// });
|
||||||
return ware;
|
// return ware;
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
waresService.updateBatchById(newWares);
|
// waresService.updateBatchById(newWares);
|
||||||
|
|
||||||
// 更新维修工单
|
// 更新维修工单----最后完成工单的时候来更新
|
||||||
// 查申请表主表
|
// // 查配件退料表子表
|
||||||
DlTicketWares ticketWares = ticketWaresService.getOne(new LambdaQueryWrapper<DlTicketWares>().eq(DlTicketWares::getId, so.getTwId()));
|
// List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, so.getId()));
|
||||||
// 查维修工单子表为配件的数据
|
// // 查申请表主表
|
||||||
List<DlRepairTitem> titems = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(item -> {
|
// DlTicketWares ticketWares = ticketWaresService.getOne(new LambdaQueryWrapper<DlTicketWares>().eq(DlTicketWares::getId, so.getTwId()));
|
||||||
item.eq(DlRepairTitem::getTicketId, ticketWares.getTicketId())
|
// // 查维修工单子表为配件的数据
|
||||||
.eq(DlRepairTitem::getItemType, "02")
|
// List<DlRepairTitem> titems = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(item -> {
|
||||||
.in(DlRepairTitem::getPartId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
|
// item.eq(DlRepairTitem::getTicketId, ticketWares.getTicketId())
|
||||||
}));
|
// .eq(DlRepairTitem::getItemType, "02")
|
||||||
// 构建新数据,更新维修工单子表
|
// .in(DlRepairTitem::getPartId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
|
||||||
List<DlRepairTitem> newTitems = titems.stream().map(item -> {
|
// }));
|
||||||
DlRepairTitem titem = new DlRepairTitem();
|
// // 构建新数据,更新维修工单子表
|
||||||
titem.setId(item.getId());
|
// List<DlRepairTitem> newTitems = titems.stream().map(item -> {
|
||||||
sois.stream().filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst().ifPresent(i -> {
|
// DlRepairTitem titem = new DlRepairTitem();
|
||||||
titem.setItemCount(item.getItemCount() - i.getGoodsCount());
|
// titem.setId(item.getId());
|
||||||
BigDecimal itemDiscount = ObjectUtil.isNotEmpty(item.getItemDiscount()) ? item.getItemDiscount() : BigDecimal.ONE;
|
// sois.stream().filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst().ifPresent(i -> {
|
||||||
titem.setItemMoney(new BigDecimal(titem.getItemCount()).multiply(item.getItemPrice()).multiply(itemDiscount));
|
// titem.setItemCount(item.getItemCount() - i.getGoodsCount());
|
||||||
});
|
// BigDecimal itemDiscount = ObjectUtil.isNotEmpty(item.getItemDiscount()) ? item.getItemDiscount() : BigDecimal.ONE;
|
||||||
return titem;
|
// titem.setItemMoney(new BigDecimal(titem.getItemCount()).multiply(item.getItemPrice()).multiply(itemDiscount));
|
||||||
}).collect(Collectors.toList());
|
// });
|
||||||
// 分开全部退料了的和没有全部退料的数据
|
// return titem;
|
||||||
List<DlRepairTitem> delTitems = newTitems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
if (CollectionUtil.isEmpty(delTitems)) {
|
// // 分开全部退料了的和没有全部退料的数据
|
||||||
titemService.updateBatchById(newTitems);
|
// List<DlRepairTitem> delTitems = newTitems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList());
|
||||||
} else {
|
// if (CollectionUtil.isEmpty(delTitems)) {
|
||||||
titemService.removeBatchByIds(delTitems);
|
// titemService.updateBatchById(newTitems);
|
||||||
List<DlRepairTitem> updateTitems = newTitems.stream().filter(item -> !delTitems.contains(item)).collect(Collectors.toList());
|
// } else {
|
||||||
if (CollectionUtil.isEmpty(updateTitems)) {
|
// titemService.removeBatchByIds(delTitems);
|
||||||
titemService.updateBatchById(updateTitems);
|
// List<DlRepairTitem> updateTitems = newTitems.stream().filter(item -> !delTitems.contains(item)).collect(Collectors.toList());
|
||||||
}
|
// if (CollectionUtil.isEmpty(updateTitems)) {
|
||||||
|
// titemService.updateBatchById(updateTitems);
|
||||||
}
|
// }
|
||||||
// 更新维修工单
|
//
|
||||||
DlRepairTickets tickets = ticketsService.getOne(new LambdaQueryWrapper<DlRepairTickets>().eq(DlRepairTickets::getId, ticketWares.getTicketId()));
|
// }
|
||||||
// 查最新的子表信息
|
// // 更新维修工单
|
||||||
List<DlRepairTitem> list = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().in(DlRepairTitem::getTicketId, tickets.getId()));
|
// DlRepairTickets tickets = ticketsService.getOne(new LambdaQueryWrapper<DlRepairTickets>().eq(DlRepairTickets::getId, ticketWares.getTicketId()));
|
||||||
// 计算工单总子项、工单配件总价、工单总价
|
// // 查最新的子表信息
|
||||||
DlRepairTickets newTickets = new DlRepairTickets();
|
// List<DlRepairTitem> list = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().in(DlRepairTitem::getTicketId, tickets.getId()));
|
||||||
newTickets.setId(tickets.getId());
|
// // 计算工单总子项、工单配件总价、工单总价
|
||||||
newTickets.setCount(list.stream().mapToInt(DlRepairTitem::getItemCount).sum());
|
// DlRepairTickets newTickets = new DlRepairTickets();
|
||||||
newTickets.setPartPrice(list.stream()
|
// newTickets.setId(tickets.getId());
|
||||||
.filter(item -> item.getItemType().equals("02"))
|
// newTickets.setCount(list.stream().mapToInt(DlRepairTitem::getItemCount).sum());
|
||||||
.map(DlRepairTitem::getItemMoney)
|
// newTickets.setPartPrice(list.stream()
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
// .filter(item -> item.getItemType().equals("02"))
|
||||||
BigDecimal projectPrice = tickets.getProjectPrice() == null ? BigDecimal.ZERO : tickets.getProjectPrice();
|
// .map(DlRepairTitem::getItemMoney)
|
||||||
BigDecimal otherPrice = tickets.getOtherPrice() != null ? tickets.getOtherPrice() : BigDecimal.ZERO;
|
// .reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
BigDecimal partPrice = newTickets.getPartPrice() == null ? BigDecimal.ZERO : newTickets.getPartPrice();
|
// BigDecimal projectPrice = tickets.getProjectPrice() == null ? BigDecimal.ZERO : tickets.getProjectPrice();
|
||||||
newTickets.setTotalPrice(projectPrice.add(partPrice).add(otherPrice));
|
// BigDecimal otherPrice = tickets.getOtherPrice() != null ? tickets.getOtherPrice() : BigDecimal.ZERO;
|
||||||
ticketsService.updateById(newTickets);
|
// BigDecimal partPrice = newTickets.getPartPrice() == null ? BigDecimal.ZERO : newTickets.getPartPrice();
|
||||||
|
// newTickets.setTotalPrice(projectPrice.add(partPrice).add(otherPrice));
|
||||||
|
// ticketsService.updateById(newTickets);
|
||||||
|
|
||||||
// 查主表
|
// 查主表
|
||||||
DlRepairSo newSo = baseMapper.selectById(id);
|
DlRepairSo newSo = baseMapper.selectById(id);
|
||||||
@ -469,7 +525,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
inWares.setInCount(filterSoi.getInCount());
|
inWares.setInCount(filterSoi.getInCount());
|
||||||
inWares.setId(null);
|
inWares.setId(null);
|
||||||
//采购品中入库数量字段累加
|
//采购品中入库数量字段累加
|
||||||
item.setInCount(item.getInCount() == null?0:item.getInCount()+filterSoi.getInCount());
|
item.setInCount(item.getInCount() == null ? 0 : item.getInCount() + filterSoi.getInCount());
|
||||||
inWaresList.add(inWares);
|
inWaresList.add(inWares);
|
||||||
});
|
});
|
||||||
//更新采购品
|
//更新采购品
|
||||||
@ -481,12 +537,11 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
|||||||
Map<String, DlRepairSoi> wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getWareId, soi -> soi));
|
Map<String, DlRepairSoi> wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getWareId, soi -> soi));
|
||||||
waresList.forEach(item -> {
|
waresList.forEach(item -> {
|
||||||
DlRepairSoi filterSoi = wareMap.get(item.getId());
|
DlRepairSoi filterSoi = wareMap.get(item.getId());
|
||||||
item.setStock((item.getStock()==null?new BigDecimal(0):item.getStock()).add(new BigDecimal(filterSoi.getInCount())));
|
item.setStock((item.getStock() == null ? new BigDecimal(0) : item.getStock()).add(new BigDecimal(filterSoi.getInCount())));
|
||||||
});
|
});
|
||||||
waresService.updateBatchById(waresList);
|
waresService.updateBatchById(waresList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,30 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
|||||||
@Override
|
@Override
|
||||||
@DSTransactional
|
@DSTransactional
|
||||||
public DlRepairTicketsRespVO createTickets(DlRepairTicketsRespVO ticketsRespVO) {
|
public DlRepairTicketsRespVO createTickets(DlRepairTicketsRespVO ticketsRespVO) {
|
||||||
|
// 验证
|
||||||
|
if (ObjectUtil.isEmpty(ticketsRespVO.getCarId())){
|
||||||
|
throw exception0(500, "车辆信息为空");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(ticketsRespVO.getAdviserId())){
|
||||||
|
throw exception0(500, "服务顾问为空");
|
||||||
|
}
|
||||||
|
ticketsRespVO.getItemList().forEach(item -> {
|
||||||
|
if (ObjectUtil.isEmpty(item.getRepairIds()) || ObjectUtil.isEmpty(item.getSaleId())){
|
||||||
|
String message = "";
|
||||||
|
switch (item.getItemType()){
|
||||||
|
case "01":
|
||||||
|
message += "项目:";
|
||||||
|
break;
|
||||||
|
case "02":
|
||||||
|
message += "配件:";
|
||||||
|
break;
|
||||||
|
case "03":
|
||||||
|
message += "其他:";
|
||||||
|
}
|
||||||
|
message += (item.getItemName() + (ObjectUtil.isEmpty(item.getRepairIds()) ? "施工人员" : "销售人员") + "为空");
|
||||||
|
throw exception0(500, message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 门店信息
|
// 门店信息
|
||||||
Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
||||||
|
@ -340,7 +340,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果是驳回,通知维修工
|
// 如果是驳回,通知维修工
|
||||||
if (status.equals("05")){
|
if (status.equals("05")) {
|
||||||
// 发送没有通过的消息给员工
|
// 发送没有通过的消息给员工
|
||||||
DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
|
DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
|
||||||
repairWorkerService.sentMessage(ticketWares.getRepairId(), "您的配件申请单被驳回了");
|
repairWorkerService.sentMessage(ticketWares.getRepairId(), "您的配件申请单被驳回了");
|
||||||
@ -450,12 +450,15 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
});
|
});
|
||||||
repairSoiService.saveBatch(respVO.getRepairSois());
|
repairSoiService.saveBatch(respVO.getRepairSois());
|
||||||
// 更新配件申请子表
|
// 更新配件申请子表
|
||||||
/*
|
// 分领料和退料
|
||||||
同理,通知领料的数量可能与实际需要的数量不一致,需要重新计算状态
|
// 先取出要操作的子表数据
|
||||||
*/
|
List<DlTwItem> oldData = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
|
||||||
// 先查老数据,领料才需要更新
|
item.eq(DlTwItem::getTwId, respVO.getRepairSo().getTwId())
|
||||||
if (type.equals("02")) {
|
.in(DlTwItem::getWaresId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
|
||||||
List<DlTwItem> oldData = twItemService.list(new LambdaQueryWrapper<DlTwItem>().in(DlTwItem::getId, respVO.getItems().stream().map(DlTwItem::getId).collect(Collectors.toList())));
|
}));
|
||||||
|
// 要操作的库存数据
|
||||||
|
List<RepairWares> wares = repairWaresService.list(new LambdaQueryWrapper<RepairWares>().in(RepairWares::getId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())));
|
||||||
|
if (type.equals("02")) { // 领料
|
||||||
// 构造新数据
|
// 构造新数据
|
||||||
List<DlTwItem> newData = oldData.stream().map(item -> {
|
List<DlTwItem> newData = oldData.stream().map(item -> {
|
||||||
DlTwItem dlTwItem = new DlTwItem();
|
DlTwItem dlTwItem = new DlTwItem();
|
||||||
@ -464,13 +467,85 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
.filter(i -> i.getGoodsId().equals(item.getWaresId()))
|
.filter(i -> i.getGoodsId().equals(item.getWaresId()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(repairSoi -> {
|
.ifPresent(repairSoi -> {
|
||||||
dlTwItem.setWaresCouldCount(repairSoi.getGoodsCount());
|
// 先取该申请配件的已领料数量,如过是第一次就是0
|
||||||
dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus());
|
Integer waresAlreadyCount = item.getWaresAlreadyCount() == null ? 0 : item.getWaresAlreadyCount();
|
||||||
|
// 取本来的已领取数量+本次要领取的数量
|
||||||
|
dlTwItem.setWaresAlreadyCount(repairSoi.getGoodsCount() + waresAlreadyCount);
|
||||||
|
// 可领取数量就是申请数量-已领料数量
|
||||||
|
// item是操作的申请配件的数量,dlTwItem取最新的已领取数量
|
||||||
|
dlTwItem.setWaresCouldCount(item.getWaresCount() - dlTwItem.getWaresAlreadyCount());
|
||||||
|
// dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus());
|
||||||
|
// 如果已领取数量等于申请数量,那这个配件就是领料完了,为01已领料,反之不变
|
||||||
|
dlTwItem.setWaresStatus(item.getWaresCount().equals(dlTwItem.getWaresAlreadyCount()) ? "01" : item.getWaresStatus());
|
||||||
});
|
});
|
||||||
return dlTwItem;
|
return dlTwItem;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
twItemService.updateBatchById(newData);
|
twItemService.updateBatchById(newData);
|
||||||
|
|
||||||
|
// 同时操作库存扣减
|
||||||
|
// 构造新数据
|
||||||
|
List<RepairWares> newWares = wares.stream().map(item -> {
|
||||||
|
RepairWares ware = new RepairWares();
|
||||||
|
ware.setId(item.getId());
|
||||||
|
respVO.getRepairSois().stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(repairSoi -> ware.setStock(item.getStock().subtract(BigDecimal.valueOf(repairSoi.getGoodsCount()))));
|
||||||
|
return ware;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
// 更新库存
|
||||||
|
repairWaresService.updateBatchById(newWares);
|
||||||
|
} else { // 退料
|
||||||
|
// 构造新数据
|
||||||
|
List<DlTwItem> newData = oldData.stream().map(item -> {
|
||||||
|
DlTwItem dlTwItem = new DlTwItem();
|
||||||
|
dlTwItem.setId(item.getId());
|
||||||
|
respVO.getRepairSois().stream()
|
||||||
|
.filter(i -> i.getGoodsId().equals(item.getWaresId()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(repairSoi -> {
|
||||||
|
// 取本来的已领取数量-本次要退料的数量
|
||||||
|
dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() - repairSoi.getGoodsCount());
|
||||||
|
// 可领取数量就是上次的可领取+退料数量
|
||||||
|
// item是操作的可领取数量,repairSoi是取本次退料的数量
|
||||||
|
dlTwItem.setWaresCouldCount(item.getWaresCouldCount() + repairSoi.getGoodsCount());
|
||||||
|
// dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus());
|
||||||
|
// 如果可领料数量等于申请数量,那这个配件就是退料完了,为03已退料,反之不变
|
||||||
|
dlTwItem.setWaresStatus(item.getWaresCount().equals(dlTwItem.getWaresCouldCount()) ? "03" : "02");
|
||||||
|
});
|
||||||
|
return dlTwItem;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
twItemService.updateBatchById(newData);
|
||||||
|
|
||||||
|
// 同时操作库存新增
|
||||||
|
// 构造新数据
|
||||||
|
List<RepairWares> newWares = wares.stream().map(item -> {
|
||||||
|
RepairWares ware = new RepairWares();
|
||||||
|
ware.setId(item.getId());
|
||||||
|
respVO.getRepairSois().stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(repairSoi -> ware.setStock(item.getStock().add(BigDecimal.valueOf(repairSoi.getGoodsCount()))));
|
||||||
|
return ware;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
// 更新库存
|
||||||
|
repairWaresService.updateBatchById(newWares);
|
||||||
}
|
}
|
||||||
|
// /*
|
||||||
|
// 同理,通知领料的数量可能与实际需要的数量不一致,需要重新计算状态
|
||||||
|
// */
|
||||||
|
// // 先查老数据,领料才需要更新
|
||||||
|
// if (type.equals("02")) {
|
||||||
|
// List<DlTwItem> oldData = twItemService.list(new LambdaQueryWrapper<DlTwItem>().in(DlTwItem::getId, respVO.getItems().stream().map(DlTwItem::getId).collect(Collectors.toList())));
|
||||||
|
// // 构造新数据
|
||||||
|
// List<DlTwItem> newData = oldData.stream().map(item -> {
|
||||||
|
// DlTwItem dlTwItem = new DlTwItem();
|
||||||
|
// dlTwItem.setId(item.getId());
|
||||||
|
// respVO.getRepairSois().stream()
|
||||||
|
// .filter(i -> i.getGoodsId().equals(item.getWaresId()))
|
||||||
|
// .findFirst()
|
||||||
|
// .ifPresent(repairSoi -> {
|
||||||
|
// dlTwItem.setWaresCouldCount(repairSoi.getGoodsCount());
|
||||||
|
// dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus());
|
||||||
|
// });
|
||||||
|
// return dlTwItem;
|
||||||
|
// }).collect(Collectors.toList());
|
||||||
|
// twItemService.updateBatchById(newData);
|
||||||
|
// }
|
||||||
|
|
||||||
// 通知维修工
|
// 通知维修工
|
||||||
// 查维修工的userId
|
// 查维修工的userId
|
||||||
@ -482,7 +557,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
*
|
*
|
||||||
* @param respVO 请求对象
|
* @param respVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 22:07 2024/10/16
|
* @date 22:07 2024/10/16 应该是弃用了,但不确定,先不删
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
@DSTransactional
|
@DSTransactional
|
||||||
@ -509,7 +584,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
*
|
*
|
||||||
* @param respVO 请求对象
|
* @param respVO 请求对象
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 22:03 2024/10/17
|
* @date 22:03 2024/10/17 应该是弃用了,但不确定,先不删
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void passBackTicketWares(DlTicketWaresRespVO respVO) {
|
public void passBackTicketWares(DlTicketWaresRespVO respVO) {
|
||||||
|
Loading…
Reference in New Issue
Block a user