From c179d59cc2ad5ba7597ad5c0e3b576d0501352b6 Mon Sep 17 00:00:00 2001 From: Vinjor Date: Tue, 12 Nov 2024 19:14:11 +0800 Subject: [PATCH] 1 --- .../admin/DlRepairTitemController.java | 40 +++++++++++++++++-- .../yudao/module/tickets/vo/AddProjVO.java | 4 ++ .../mapper/tickets/DlRepairTicketsMapper.xml | 4 +- 3 files changed, 43 insertions(+), 5 deletions(-) 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 09957768..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 )+"。"; diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddProjVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddProjVO.java index 8302167c..928898bd 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddProjVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddProjVO.java @@ -16,6 +16,10 @@ public class AddProjVO { private List itemList; /** 签字图片相对路径 */ private String image; + /** 要删除的项目id */ + private List delProjIdList; /** 备注内容 */ private String remark; + /** 工单id */ + private String ticketId; } 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