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 958c975f..6e420e7f 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 @@ -256,9 +256,11 @@ public class DlRepairSoServiceImpl extends ServiceImpl 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()))); } + // 采购改了入库逻辑,不能在这里扣库存 +// else { +// wares.setStock(item.getStock().subtract(BigDecimal.valueOf(repairSoiByWares.getGoodsCount()))); +// } }); newWares.add(wares); }); diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTitemController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTitemController.java index eadcf5ef..cc454097 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTitemController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTitemController.java @@ -3,8 +3,12 @@ package cn.iocoder.yudao.module.tickets.controller.admin; import cn.iocoder.yudao.common.RecordTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.base.service.RepairRecordsService; +import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; +import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService; import cn.iocoder.yudao.module.tickets.vo.AddProjVO; import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemReqVO; @@ -15,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; @@ -36,6 +41,8 @@ public class DlRepairTitemController { @Resource private DlRepairTitemService dlRepairTitemService; @Resource + private DlRepairTicketsService dlRepairTicketsService; + @Resource private RepairRecordsService repairRecordsService; /** @@ -84,13 +91,25 @@ public class DlRepairTitemController { * 更新工单子表,维修项目配件的单价、数量、折扣、单项总价等 * @author vinjor-M * @date 16:10 2024/10/31 - * @param itemList 工单子表列表 + * @param addProjVO 工单子表列表 * @return cn.iocoder.yudao.framework.common.pojo.CommonResult **/ @PutMapping("/updateRepairItem") @Operation(summary = "修改维修工单子表的维修人员和销售人员信息") - public CommonResult updateRepairItem(@RequestBody List itemList){ - dlRepairTitemService.updateRepairItem(itemList); + public CommonResult updateRepairItem(@RequestBody AddProjVO addProjVO){ + //删除项目 + if(null!=addProjVO.getDelProjIdList() && !addProjVO.getDelProjIdList().isEmpty()){ + dlRepairTitemService.removeBatchByIds(addProjVO.getDelProjIdList()); + //更新主表的id + DlRepairTickets repairTickets = new DlRepairTickets(); + repairTickets.setId(addProjVO.getTicketId()); + repairTickets.setUpdateTime(LocalDateTime.now()); + dlRepairTicketsService.updateById(repairTickets); + } + if(!addProjVO.getItemList().isEmpty()){ + //更新项目 + dlRepairTitemService.updateRepairItem(addProjVO.getItemList()); + } return ok(); } @@ -129,7 +148,22 @@ public class DlRepairTitemController { @PostMapping("/addNewProj") @Operation(summary = "添加维修项目") public CommonResult addNewProj(@RequestBody AddProjVO addProjVO){ + //获取当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + addProjVO.getItemList().forEach(item->{ + if(null==item.getSaleId()){ + //默认销售人员是当前用户 + item.setSaleId(loginUser.getId()); + item.setSaleName(loginUser.getInfo().get("nickname")); + } + }); dlRepairTitemService.saveBatch(addProjVO.getItemList()); + //更新主表的更新时间 + DlRepairTickets repairTickets = new DlRepairTickets(); + repairTickets.setId(addProjVO.getItemList().get(0).getTicketId()); + repairTickets.setUpdateTime(LocalDateTime.now()); + dlRepairTicketsService.updateById(repairTickets); + List projNameList = addProjVO.getItemList().stream().map(DlRepairTitem::getItemName).collect(Collectors.toList()); //最后记录操作日志--创建工单 String remark = "添加维修项目"+String.join(", ",projNameList )+"。"; @@ -163,7 +197,7 @@ public class DlRepairTitemController { @GetMapping("/getProjList") @Operation(summary = "查某工单维修项目进度") public CommonResult getProjList(@RequestParam("ticketId") String ticketId){ - return success(dlRepairTitemService.getProjList(ticketId)); + return success(dlRepairTitemService.getProjList(ticketId,null)); } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/app/ApiRepairTitemController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/app/ApiRepairTitemController.java index 7452f3bd..1798a6db 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/app/ApiRepairTitemController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/app/ApiRepairTitemController.java @@ -37,7 +37,7 @@ public class ApiRepairTitemController { @Operation(summary = "查某工单维修项目进度") @TenantIgnore public CommonResult getProjList(@RequestParam("ticketId") String ticketId){ - return success(dlRepairTitemService.getProjList(ticketId)); + return success(dlRepairTitemService.getProjList(ticketId,"1")); } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTicketWares.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTicketWares.java index 259efddf..9c6f7e8c 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTicketWares.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTicketWares.java @@ -60,7 +60,7 @@ public class DlTicketWares extends TenantBaseDO { /** 维修顾问name(system_user的nickname) */ private String adviserName; - /** 状态:01待审批、02已审批、03已驳回,ticket_wares_status */ + /** 状态:01待审批、02已审批,ticket_wares_status */ private String status; /** 备注 */ diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlRepairTitemMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlRepairTitemMapper.java index a17f4976..c3ac254b 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlRepairTitemMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlRepairTitemMapper.java @@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 针对表【dl_repair_titem(维修工单子表)】的数据库操作Mapper * @@ -31,6 +33,15 @@ public interface DlRepairTitemMapper extends BaseMapper { * @param dlRepairTitem */ void updateRepairAndSale(DlRepairTitem dlRepairTitem); + + /** + * 查某工单维修项目进度 + * @author vinjor-M + * @date 15:33 2024/11/12 + * @param ticketId 工单id + * @return java.util.List + **/ + List selectProjList(@Param("ticketId")String ticketId,@Param("isOpen")String isOpen); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTitemService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTitemService.java index a0c126b3..9c2d3977 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTitemService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTitemService.java @@ -82,5 +82,5 @@ public interface DlRepairTitemService extends IService { * @param ticketId 工单ID * @return java.util.List **/ - List getProjList(String ticketId); + List getProjList(String ticketId,String isOpen); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index a4605b3e..1a4c1845 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.*; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; +import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.service.RepairRecordsService; @@ -247,9 +248,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl { item.setTicketId(ticketsRespVO.getId()); + if(null==item.getSaleId()){ + //默认销售人员是当前用户 + item.setSaleId(loginUser.getId()); + item.setSaleName(loginUser.getInfo().get("nickname")); + } if ("01".equals(item.getItemType())) { //维修项目,初始状态,待派工 item.setItemStatus(TicketsItemStatusEnum.WAITING_WORK.getCode()); @@ -1244,20 +1252,21 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl status = new ArrayList<>(); - status.add("01"); // 待审核 - status.add("05"); // 已驳回 - // 查工单所有已通过的配件申请单 + // 先查满足条件的申请表---配件申请表现在只有待审批和已审批,并且其子表的数据也可能同时有两种情况 +// ArrayList status = new ArrayList<>(); +// status.add("01"); // 待审核 +// status.add("05"); // 已驳回 + // 查工单所有已通过的配件申请单----这里直接查全部 List list = ticketWaresService.list(new LambdaQueryWrapper().and(item -> { - item.eq(DlTicketWares::getTicketId, id) - .notIn(DlTicketWares::getStatus, status); + item.eq(DlTicketWares::getTicketId, id); +// .notIn(DlTicketWares::getStatus, status); })); if (CollectionUtil.isNotEmpty(list)) { - // 查配件申请表的所有已领取数量小于申请数量的子表信息 + // 查配件申请表的所有已领取数量小于申请数量的子表信息----这里需要加上一个条件,得是审核通过的才行 List ids = list.stream().map(DlTicketWares::getId).collect(Collectors.toList()); List twItems = twItemService.list(new LambdaQueryWrapper().and(item -> { item.in(DlTwItem::getTwId, ids) + .eq(DlTwItem::getWaresStatus, "1") .apply("wares_already_count < wares_count"); })); if (CollectionUtil.isNotEmpty(twItems)) { diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java index 14e735d6..a15315ac 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -31,6 +32,8 @@ public class DlRepairTitemServiceImpl extends ServiceImpl getProjList(String ticketId) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .eq(DlRepairTitem::getTicketId,ticketId) - .eq(DlRepairTitem::getItemType,"01") - .orderByDesc(DlRepairTitem::getItemStatus); - return this.list(queryWrapper); + public List getProjList(String ticketId,String isOpen) { + return dlRepairTitemMapper.selectProjList(ticketId,isOpen); } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java index 66e524db..9cd3c50e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.common.SoStatusEnum; import cn.iocoder.yudao.common.TicketsItemStatusEnum; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.service.RepairRecordsService; import cn.iocoder.yudao.module.base.service.RepairWorkerService; @@ -138,7 +139,6 @@ public class DlTicketWaresServiceImpl extends ServiceImpl { DlTwItem twItem = BeanUtil.toBean(item, DlTwItem.class); twItem.setTwId(ticketWares.getId()); - twItem.setWaresStatus("0"); + twItem.setWaresStatus(""); + twItem.setWaresAlreadyCount(0); return twItem; }).collect(Collectors.toList()); if (CollectionUtil.isEmpty(list)) { @@ -260,115 +261,87 @@ public class DlTicketWaresServiceImpl extends ServiceImpl repairItemList = respVO.getWares(); - DlTicketWares updateObj = this.getById(mainId); - String ticketMainId = updateObj.getTicketId(); - updateObj.setStatus(status); - this.updateById(updateObj); - // 如果是通过并且是领料就还需要把配件信息加入到工单中 - if (ObjectUtil.isNotEmpty(status) && status.equals("02")) { - // 更新维修工单 - if(null!=respVO.getRepairWaresList()){ - repairItemList= new ArrayList<>(); - //走的是更新配件库价格 - Map updateMap = respVO.getRepairWaresList().stream().collect(Collectors.toMap(RepairWares::getId,RepairWares::getPrice)); - //更新配件库的价格 - List updateWaresList = new ArrayList<>(); - //去库里面查需要的配件 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .eq(DlTwItem::getTwId, mainId); - List applyList = twItemService.list(queryWrapper); - if (!applyList.isEmpty()) { - //查配件库 - List waresList = repairWaresService.listByIds(applyList.stream().map(DlTwItem::getWaresId).collect(Collectors.toList())); - Map waresMap = waresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity())); - //组装工单子表数据 - for (DlTwItem item : applyList) { - DlRepairTitem repairTitem = new DlRepairTitem(); - repairTitem.setTicketId(ticketMainId); - repairTitem.setItemCount(item.getWaresCount()); - repairTitem.setItemName(item.getWaresName()); - repairTitem.setItemUnit(waresMap.get(item.getWaresId()).getUnit()); - //取前端传过来的销售价格 - repairTitem.setItemPrice(updateMap.get(item.getId())); - //默认不打折为1 - repairTitem.setItemDiscount(new BigDecimal(1)); - repairTitem.setItemMoney(new BigDecimal(repairTitem.getItemCount()).multiply(repairTitem.getItemPrice())); - //类型是配件 - repairTitem.setItemType("02"); - repairTitem.setPartId(item.getWaresId()); - repairTitem.setItemStatus(TicketsItemStatusEnum.WAITING_RECEIVE.getCode()); - repairItemList.add(repairTitem); - //组装配件库更新价格 - RepairWares update = new RepairWares(); - update.setId(item.getWaresId()); - update.setPrice(updateMap.get(item.getId())); - updateWaresList.add(update); + // 取出前端操作的配件申请表的子项id + List twItemIds = respVO.getItems().stream().map(DlTwItem::getId).collect(Collectors.toList()); + // 查所有的子项 + List twItems = twItemService.listByIds(twItemIds); + // 取所有的配件信息 + List wareIds = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toList()); + List repairWares = repairWaresService.listByIds(wareIds); + // 更新配件申请表子表 + List newTwitems = twItemIds.stream().map(item -> { + DlTwItem twItem = new DlTwItem(); + twItem.setId(item); + twItem.setWaresStatus(status.equals("01") ? "1" : "0"); + twItem.setHandleId(SecurityFrameworkUtils.getLoginUserId()); + twItem.setHandleName(SecurityFrameworkUtils.getLoginUserNickname()); + return twItem; + }).collect(Collectors.toList()); + twItemService.updateBatchById(newTwitems); + // 更新配件申请主表 + List allTwitems = twItemService.list(new LambdaQueryWrapper().in(DlTwItem::getTwId, respVO.getId())); + List passTwitems = allTwitems.stream().filter(item -> item.getWaresStatus().equals("1") || item.getWaresStatus().equals("0")).collect(Collectors.toList()); + boolean isStatus = CollectionUtil.isNotEmpty(passTwitems) && passTwitems.size() == allTwitems.size(); + if (isStatus) { + baseMapper.update(new LambdaUpdateWrapper().set(DlTicketWares::getStatus, "02").eq(DlTicketWares::getId, respVO.getId())); + } + // 更新维修工单子表 + if (status.equals("01")) { + DlTicketWares ticketWares = baseMapper.selectById(respVO.getId()); + List titems = repairTitemService.list(new LambdaQueryWrapper().and(i -> { + i.in(DlRepairTitem::getTicketId, ticketWares.getTicketId()) + .eq(DlRepairTitem::getItemType, "02"); + })); + // 要修改的 + List updateTitems = titems.stream().filter(item -> wareIds.contains(item.getPartId())).collect(Collectors.toList()); + // 修改 + if (CollectionUtil.isNotEmpty(updateTitems)) { + List newTitems = updateTitems.stream().map(item -> { + DlRepairTitem titem = new DlRepairTitem(); + titem.setId(item.getId()); + DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).findFirst().orElse(null); + if (twItem != null) { + titem.setItemCount(item.getItemCount() + twItem.getWaresCount()); + titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(item.getItemDiscount())); } - } - if(!updateWaresList.isEmpty()){ - repairWaresService.updateBatchById(updateWaresList); - } - } - // 更新维修工单子表----需要合并相同的配件,故修改 - // 先查维修工单的子表中的配件相关的信息 - List oldTitem = repairTitemService.list(new LambdaQueryWrapper().and(i -> i.eq(DlRepairTitem::getTicketId, ticketMainId).eq(DlRepairTitem::getItemType, "02"))); - // 过滤出新申请的配件里面有没有已经存在于工单子表的 - List waresIds = oldTitem.stream().map(DlRepairTitem::getPartId).collect(Collectors.toList()); - List already = repairItemList.stream().filter(item -> waresIds.contains(item.getPartId())).collect(Collectors.toList()); - // 更新已经存在的配件 - if (CollectionUtil.isNotEmpty(already)) { - List updateItems = new ArrayList<>(); - already.forEach(item -> { - DlRepairTitem titem = oldTitem.stream().filter(i -> i.getPartId().equals(item.getPartId())).findFirst().orElse(null); - if (titem != null) { - DlRepairTitem newItem = new DlRepairTitem(); - newItem.setId(titem.getId()); - newItem.setItemCount(titem.getItemCount() + item.getItemCount()); - // 如果设置了折扣就用,没有就是1 - BigDecimal itemDiscount = titem.getItemDiscount() == null ? new BigDecimal(1) : titem.getItemDiscount(); - // titem取价格、newItem取数量 - newItem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(newItem.getItemCount())).multiply(itemDiscount)); - updateItems.add(newItem); - } - }); - if (CollectionUtil.isNotEmpty(updateItems)) { - repairTitemService.updateBatchById(updateItems); - } - } - // 新增维修工单中没有的配件 - List newItems = repairItemList.stream().filter(item -> !waresIds.contains(item.getPartId())).collect(Collectors.toList()); - newItems.forEach(item -> { - // 主表id - item.setTicketId(ticketMainId); - // 类型为配件 - item.setItemType("02"); - // 状态为未领料 - item.setItemStatus(TicketsItemStatusEnum.WAITING_RECEIVE.getCode()); - }); - repairTitemService.saveBatch(newItems); - - // 重新计算工单 - boolean flag = repairTicketsService.computeTicket(ticketMainId); - if (!flag) { - throw exception0(500, "系统异常"); - } - - // 更新仓库 - if (CollectionUtil.isNotEmpty(repairItemList)){ - List updateWares = repairItemList.stream().map(item -> { - RepairWares wares = new RepairWares(); - wares.setId(item.getPartId()); - wares.setPrice(item.getItemPrice()); - return wares; + return titem; }).collect(Collectors.toList()); - repairWaresService.updateBatchById(updateWares); + repairTitemService.updateBatchById(newTitems); + } + // 要新增的 + if (updateTitems.size() < wareIds.size()) { + List titemIds = updateTitems.stream().map(DlRepairTitem::getPartId).collect(Collectors.toList()); + List newWares = repairWares.stream().filter(item -> !titemIds.contains(item.getId())).collect(Collectors.toList()); + // 新增 + List newTitems = newWares.stream().map(item -> { + DlRepairTitem titem = new DlRepairTitem(); + titem.setTicketId(ticketWares.getTicketId()); + titem.setItemType("02"); + titem.setItemName(item.getName()); + DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null); + titem.setItemCount(twItem != null ? twItem.getWaresCount() : 0); + titem.setItemUnit(item.getUnit()); + titem.setItemPrice(item.getPrice() != null ? item.getPrice() : BigDecimal.ZERO); + titem.setItemDiscount(BigDecimal.ONE); + titem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(titem.getItemDiscount())); + titem.setRepairIds(String.valueOf(ticketWares.getRepairId())); + titem.setRepairNames(ticketWares.getRepairName()); + titem.setSaleId(ticketWares.getAdviserId()); + titem.setSaleName(ticketWares.getAdviserName()); + titem.setPartId(item.getId()); + titem.setItemStatus("04"); + titem.setRemark(twItem != null ? twItem.getRemark() : null); + return titem; + }).collect(Collectors.toList()); + repairTitemService.saveBatch(newTitems); + } + + // 更新维修工单主表 + boolean flag = repairTicketsService.computeTicket(ticketWares.getTicketId()); + if (!flag) { + throw exception0(500, "重新计算工单错误"); } // 发送通过的消息给仓库 @@ -378,14 +351,12 @@ public class DlTicketWaresServiceImpl extends ServiceImpl repairWorkerService.sentMessage(id, "您有新的配件申请单需要处理")); } } - // 如果是驳回,通知维修工 - if (status.equals("05")) { - // 发送没有通过的消息给员工 - DlTicketWares ticketWares = baseMapper.selectById(respVO.getId()); - repairWorkerService.sentMessage(ticketWares.getRepairId(), "您的配件申请单被驳回了"); - } + // 通知维修工 + DlTicketWares ticketWares = baseMapper.selectById(respVO.getId()); + repairWorkerService.sentMessage(ticketWares.getRepairId(), "您有新的配件申请单" + (status.equals("01") ? "审批通过了" : "被驳回了")); + //插入记录 - repairRecordsService.saveRepairRecord(respVO.getTicketId(),null,RecordTypeEnum.SPPJSQD.getCode(),"审批配件申请单",null); + repairRecordsService.saveRepairRecord(respVO.getTicketId(), null, RecordTypeEnum.SPPJSQD.getCode(), "审批配件申请单", null); } /** @@ -450,14 +421,14 @@ public class DlTicketWaresServiceImpl extends ServiceImpl wares = repairWaresService.list(new LambdaQueryWrapper().in(RepairWares::getId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()))); - Map waresNameMap = wares.stream().collect(Collectors.toMap(RepairWares::getId,RepairWares::getName)); - String remarkStr=""; - for(DlRepairSoi item:respVO.getRepairSois()){ + Map waresNameMap = wares.stream().collect(Collectors.toMap(RepairWares::getId, RepairWares::getName)); + String remarkStr = ""; + for (DlRepairSoi item : respVO.getRepairSois()) { //组装通知领取配件的文字 - if(!"".equals(remarkStr)){ - remarkStr +=";"; + if (!"".equals(remarkStr)) { + remarkStr += ";"; } - remarkStr += waresNameMap.get(item.getGoodsId())+"x"+item.getGoodsCount(); + remarkStr += waresNameMap.get(item.getGoodsId()) + "x" + item.getGoodsCount(); } if (type.equals("02")) { // 领料 // 构造新数据 @@ -472,8 +443,8 @@ public class DlTicketWaresServiceImpl extends ServiceImpl itemList; /** 签字图片相对路径 */ private String image; + /** 要删除的项目id */ + private List delProjIdList; /** 备注内容 */ private String remark; + /** 工单id */ + private String ticketId; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemRespVO.java index 4788e3d4..e79b78f1 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemRespVO.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.tickets.vo; +import cn.iocoder.yudao.module.base.entity.RepairRecordsItem; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; import lombok.Data; import java.util.Date; +import java.util.List; /** * 维修工单子表 响应VO @@ -24,4 +26,9 @@ public class DlRepairTitemRespVO extends DlRepairTitem { private String corpId; private String ticketNo; + + /** + * 维修项目的维修过程图片 + **/ + private List recordsItemList; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresReqVO.java index 70fb6a45..65d977af 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresReqVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresReqVO.java @@ -23,7 +23,7 @@ public class DlTicketWaresReqVO extends DlTicketWares { /** 角色 */ private Integer userRole; - /** 查看可以退料的数据时为tru */ + /** 查看可以退料的数据时为true */ private Boolean isBack; /** 查看待审核的数据时为true */ diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml index 349d4b4c..f162f649 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml @@ -274,7 +274,7 @@ GROUP BY drt.id - order by drt.create_time desc + order by drt.update_time desc diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml index 73d98ddd..ff4e32fd 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml @@ -3,6 +3,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE dl_repair_titem @@ -56,4 +82,31 @@ FROM dl_repair_titem drti LEFT JOIN dl_repair_tickets drt ON drti.ticket_id = drt.id + diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlTicketWaresMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlTicketWaresMapper.xml index 7d44fb5d..ec7b8bcc 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlTicketWaresMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlTicketWaresMapper.xml @@ -48,14 +48,14 @@