From 6a761fb4b38331fbda2a3191bbd6e342b79d72c1 Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Mon, 4 Nov 2024 15:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=98=E5=B7=A5=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E9=A2=86=E6=96=99=E3=80=81=E9=80=80=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/DlRepairSoController.java | 8 +- .../service/DlRepairSoService.java | 4 +- .../service/impl/DlRepairSoServiceImpl.java | 148 +++--------------- 3 files changed, 25 insertions(+), 135 deletions(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java index 8a8ba885..26cf5395 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java @@ -97,8 +97,8 @@ public class DlRepairSoController { **/ @GetMapping("/confirmGet") @Operation(summary = "员工确认领料") - public CommonResult confirmGet(@RequestParam("id") String id) { - dlRepairSoService.confirmGet(id); + public CommonResult confirmGet(@RequestParam("id") String id, @RequestParam(value = "image", required = false) String image) { + dlRepairSoService.confirmGet(id, image); return CommonResult.ok(); } @@ -111,8 +111,8 @@ public class DlRepairSoController { **/ @GetMapping("/confirmBack") @Operation(summary = "员工确认退料") - public CommonResult confirmBack(@RequestParam("id") String id) { - dlRepairSoService.confirmBack(id); + public CommonResult confirmBack(@RequestParam("id") String id, @RequestParam(value = "image", required = false) String image) { + dlRepairSoService.confirmBack(id, image); return CommonResult.ok(); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java index 8893fd34..09e8f8c1 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoService.java @@ -58,7 +58,7 @@ public interface DlRepairSoService extends IService { * @author 小李 * @date 11:58 2024/10/21 **/ - void confirmGet(String id); + void confirmGet(String id, String image); /** * 员工确认退料 @@ -67,7 +67,7 @@ public interface DlRepairSoService extends IService { * @author 小李 * @date 19:41 2024/10/21 **/ - void confirmBack(String id); + void confirmBack(String id, String image); /** * 采购入库 diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java index 06a68890..57df6332 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java @@ -3,9 +3,11 @@ package cn.iocoder.yudao.module.stockOperate.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.common.RecordTypeEnum; import cn.iocoder.yudao.common.RepairErrorCodeConstants; import cn.iocoder.yudao.common.SoStatusEnum; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.base.service.RepairRecordsService; import cn.iocoder.yudao.module.base.service.RepairWorkerService; import cn.iocoder.yudao.module.company.entity.Company; import cn.iocoder.yudao.module.company.service.CompanyService; @@ -99,6 +101,10 @@ public class DlRepairSoServiceImpl extends ServiceImpl sois = repairSoiService - .list(new LambdaQueryWrapper() - .eq(DlRepairSoi::getSoId, id) - ); - // 查库存---生成领料单的时候更新了 -// List wares = waresService -// .list(new LambdaQueryWrapper() -// .in(RepairWares::getId, sois.stream() -// .map(DlRepairSoi::getGoodsId) -// .collect(Collectors.toList()) -// )); -// // 更新库存 -// List newWares = wares.stream().map(item -> { -// RepairWares ware = new RepairWares(); -// ware.setId(item.getId()); -// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> { -// ware.setStock(item.getStock().subtract(BigDecimal.valueOf(i.getGoodsCount()))); -// }); -// return ware; -// }).collect(Collectors.toList()); -// waresService.updateBatchById(newWares); + public void confirmGet(String id, String image) { // 更新主表状态 为已领料 DlRepairSo dlRepairSo = new DlRepairSo(); dlRepairSo.setId(id); dlRepairSo.setSoStatus(SoStatusEnum.PICKED.getCode()); baseMapper.updateById(dlRepairSo); - // 更新申请表的数据----生成领料单的时候更新了 -// // 查申请表的子表对应的配件信息 -// List twItems = twItemService.list(new LambdaQueryWrapper().and(item -> { -// item.eq(DlTwItem::getTwId, so.getTwId()) -// .in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); -// })); -// // 更新子表 -// List newTwItems = twItems.stream().map(item -> { -// DlTwItem dlTwItem = new DlTwItem(); -// dlTwItem.setId(item.getId()); -// dlTwItem.setWaresAlreadyCount(ObjectUtil.isNotEmpty(item.getWaresAlreadyCount()) ? item.getWaresAlreadyCount() + item.getWaresCouldCount() : item.getWaresCouldCount()); -// dlTwItem.setWaresStatus(dlTwItem.getWaresAlreadyCount().equals(item.getWaresCount()) ? "01" : item.getWaresStatus()); -// return dlTwItem; -// }).collect(Collectors.toList()); -// twItemService.updateBatchById(newTwItems); - // 查最新的子表信息 DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper().eq(DlRepairSo::getId, id)); List list = twItemService.list(new LambdaQueryWrapper().eq(DlTwItem::getTwId, so.getTwId())); @@ -369,6 +337,12 @@ public class DlRepairSoServiceImpl extends ServiceImpl() .set(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode()) .eq(DlRepairSo::getId, id) ); - // 更新配件申请表----生成退料单的时候更新了 -// DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper().eq(DlRepairSo::getId, id)); -// // 查配件退料表子表 -// List sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, so.getId())); -// // 查申请表子表 -// List twItems = twItemService.list(new LambdaQueryWrapper().eq(DlTwItem::getTwId, so.getTwId())); -// // 得到需要更新的数据 -// List newTwItems = twItems.stream().map(item -> { -// DlTwItem dlTwItem = new DlTwItem(); -// dlTwItem.setId(item.getId()); -// sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(i -> { -// dlTwItem.setWaresBackCount( -// ObjectUtil.isNotEmpty(item.getWaresBackCount()) -// ? item.getWaresCount() + item.getWaresBackCount() -// : i.getGoodsCount()); -// // 如果退料数就是领料申请数,那就是全退了 -// if (i.getGoodsCount().equals(dlTwItem.getWaresCount())) { -// dlTwItem.setWaresStatus("03"); -// } -// }); -// return dlTwItem; -// }).collect(Collectors.toList()); -// twItemService.updateBatchById(newTwItems); -// // 更新库存 -// // 查库存 -// List wares = waresService.list(new LambdaQueryWrapper().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()))); -// // 构建新数据 -// List newWares = wares.stream().map(item -> { -// RepairWares ware = new RepairWares(); -// ware.setId(item.getId()); -// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> { -// ware.setStock(item.getStock().add(BigDecimal.valueOf(i.getGoodsCount()))); -// }); -// return ware; -// }).collect(Collectors.toList()); -// waresService.updateBatchById(newWares); - - // 更新维修工单----最后完成工单的时候来更新 -// // 查配件退料表子表 -// List sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, so.getId())); -// // 查申请表主表 -// DlTicketWares ticketWares = ticketWaresService.getOne(new LambdaQueryWrapper().eq(DlTicketWares::getId, so.getTwId())); -// // 查维修工单子表为配件的数据 -// List titems = titemService.list(new LambdaQueryWrapper().and(item -> { -// item.eq(DlRepairTitem::getTicketId, ticketWares.getTicketId()) -// .eq(DlRepairTitem::getItemType, "02") -// .in(DlRepairTitem::getPartId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); -// })); -// // 构建新数据,更新维修工单子表 -// List newTitems = titems.stream().map(item -> { -// DlRepairTitem titem = new DlRepairTitem(); -// titem.setId(item.getId()); -// sois.stream().filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst().ifPresent(i -> { -// titem.setItemCount(item.getItemCount() - i.getGoodsCount()); -// BigDecimal itemDiscount = ObjectUtil.isNotEmpty(item.getItemDiscount()) ? item.getItemDiscount() : BigDecimal.ONE; -// titem.setItemMoney(new BigDecimal(titem.getItemCount()).multiply(item.getItemPrice()).multiply(itemDiscount)); -// }); -// return titem; -// }).collect(Collectors.toList()); -// // 分开全部退料了的和没有全部退料的数据 -// List delTitems = newTitems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList()); -// if (CollectionUtil.isEmpty(delTitems)) { -// titemService.updateBatchById(newTitems); -// } else { -// titemService.removeBatchByIds(delTitems); -// List updateTitems = newTitems.stream().filter(item -> !delTitems.contains(item)).collect(Collectors.toList()); -// if (CollectionUtil.isEmpty(updateTitems)) { -// titemService.updateBatchById(updateTitems); -// } -// -// } -// // 更新维修工单 -// DlRepairTickets tickets = ticketsService.getOne(new LambdaQueryWrapper().eq(DlRepairTickets::getId, ticketWares.getTicketId())); -// // 查最新的子表信息 -// List list = titemService.list(new LambdaQueryWrapper().in(DlRepairTitem::getTicketId, tickets.getId())); -// // 计算工单总子项、工单配件总价、工单总价 -// DlRepairTickets newTickets = new DlRepairTickets(); -// newTickets.setId(tickets.getId()); -// newTickets.setCount(list.stream().mapToInt(DlRepairTitem::getItemCount).sum()); -// newTickets.setPartPrice(list.stream() -// .filter(item -> item.getItemType().equals("02")) -// .map(DlRepairTitem::getItemMoney) -// .reduce(BigDecimal.ZERO, BigDecimal::add)); -// BigDecimal projectPrice = tickets.getProjectPrice() == null ? BigDecimal.ZERO : tickets.getProjectPrice(); -// BigDecimal otherPrice = tickets.getOtherPrice() != null ? tickets.getOtherPrice() : BigDecimal.ZERO; -// BigDecimal partPrice = newTickets.getPartPrice() == null ? BigDecimal.ZERO : newTickets.getPartPrice(); -// newTickets.setTotalPrice(projectPrice.add(partPrice).add(otherPrice)); -// ticketsService.updateById(newTickets); - // 查主表 DlRepairSo newSo = baseMapper.selectById(id); // 通知仓库 repairWorkerService.sentMessage(Long.valueOf(newSo.getCreator()), newSo.getUserName() + "已确认退料单:" + newSo.getSoNo()); + // 记录日志 + // 查申请表 + DlTicketWares byId = ticketWaresService.getById(newSo.getTwId()); + // 记录日志 + recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.TL.getCode(), null, image); } /**