From 8859ec67067fa3940c23f9a66c74f74a4a8db2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Mon, 21 Oct 2024 13:09:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E4=BF=AEapp=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=90=8E=E6=8C=87=E5=AE=9A=E6=96=BD=E5=B7=A5?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=92=8C=E9=94=80=E5=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/RepairProjectServiceImpl.java | 47 ++++++++++--------- .../admin/DlRepairTicketsController.java | 3 +- .../admin/DlRepairTitemController.java | 18 +++++-- .../tickets/mapper/DlRepairTitemMapper.java | 6 +++ .../service/DlRepairTicketsService.java | 2 +- .../tickets/service/DlRepairTitemService.java | 7 +++ .../impl/DlRepairTicketsServiceImpl.java | 3 +- .../impl/DlRepairTitemServiceImpl.java | 12 +++++ .../mapper/tickets/DlRepairTitemMapper.xml | 22 ++++++++- 9 files changed, 88 insertions(+), 32 deletions(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java index 10afa53e..9f60fa49 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairProjectServiceImpl.java @@ -19,7 +19,9 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -86,7 +88,7 @@ public class RepairProjectServiceImpl extends ServiceImpl queryListPage(RepairProjectPageReqVO pageReqVO, Page page) { - return repairProjectMapper.selectListPage(pageReqVO,page); + return repairProjectMapper.selectListPage(pageReqVO, page); } /** @@ -97,28 +99,29 @@ public class RepairProjectServiceImpl extends ServiceImpl getRepairProjectAndCateGory() { List repairProjectAppvos = repairProjectMapper.selectProjectAndCateGory(); - // 提取并去重 typeId - List uniqueTypeIds = repairProjectAppvos.stream() - .map(RepairProjectAppvo::getTypeId) - .distinct() - .collect(Collectors.toList()); - List list = new ArrayList<>(); - for (String uniqueTypeId : uniqueTypeIds) { - RepairProjectAppvo repairProjectAppvo = new RepairProjectAppvo(); - repairProjectAppvo.setTypeId(uniqueTypeId); - if (ObjectUtil.isNotEmpty(uniqueTypeId)) { - List filteredList = repairProjectAppvos.stream() - .filter(appvo -> uniqueTypeId.equals(appvo.getTypeId())) - .collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(filteredList)) { - repairProjectAppvo.setTypeName(filteredList.get(0).getTypeName()); - repairProjectAppvo.setGroupList(BeanUtil.copyToList(filteredList, RepairProject.class)); - } + +// 使用 LinkedHashMap 按 typeId 分组,排除 typeId 为 null 的条目 + Map> groupedByTypeId = new LinkedHashMap<>(); + for (RepairProjectAppvo appvo : repairProjectAppvos) { + if (ObjectUtil.isNotEmpty(appvo.getTypeId())) { + groupedByTypeId.computeIfAbsent(appvo.getTypeId(), k -> new ArrayList<>()).add(appvo); } - list.add(repairProjectAppvo); } - return list; + + // 创建结果列表 + List resultList = new ArrayList<>(); + for (Map.Entry> entry : groupedByTypeId.entrySet()) { + RepairProjectAppvo repairProjectAppvo = new RepairProjectAppvo(); + repairProjectAppvo.setTypeId(entry.getKey()); + List filteredList = entry.getValue(); + repairProjectAppvo.setTypeName(filteredList.get(0).getTypeName()); + + // 只在最后一次调用 copyToList + repairProjectAppvo.setGroupList(BeanUtil.copyToList(filteredList, RepairProject.class)); + resultList.add(repairProjectAppvo); + } + + return resultList; + } - - } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java index b01f0f79..9e29197e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java @@ -45,8 +45,7 @@ public class DlRepairTicketsController { @PostMapping("/create") @Operation(summary = "维修工单表 新增") public CommonResult createTicket(@RequestBody DlRepairTicketsRespVO ticketsRespVO) { - dlRepairTicketsService.createTickets(ticketsRespVO); - return CommonResult.ok(); + return CommonResult.success(dlRepairTicketsService.createTickets(ticketsRespVO)); } /** 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 072e1a0c..f6ca7c1d 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 @@ -7,10 +7,7 @@ import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemReqVO; import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemRespVO; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -23,7 +20,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; * @date 18:21 2024/9/13 **/ @RestController -@RequestMapping("/repair/titem") + @RequestMapping("/repair/titem") public class DlRepairTitemController { /** * 服务对象 @@ -61,5 +58,16 @@ public class DlRepairTitemController { public CommonResult getProjectList(@RequestParam("ticketId") String ticketId){ return success(dlRepairTitemService.getProjectList(ticketId)); } + + /** + * 修改维修工单子表的维修人员和销售人员信息(app) + * @param dlRepairTitemReqVO + * @return + */ + @PutMapping("/updateRepairAndSale") + @Operation(summary = "修改维修工单子表的维修人员和销售人员信息") + public CommonResult updateRepairAndSale(@RequestBody DlRepairTitemReqVO dlRepairTitemReqVO){ + return success(dlRepairTitemService.updateRepairAndSale(dlRepairTitemReqVO)); + } } 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 251166c1..a17f4976 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 @@ -25,6 +25,12 @@ public interface DlRepairTitemMapper extends BaseMapper { * @param repairTitemRespVO 查询对象 **/ IPage getTItemPage(@Param("map") DlRepairTitemRespVO repairTitemRespVO, Page page); + + /** + * 更新工单子表中维修人员、销售人员信息(app) + * @param dlRepairTitem + */ + void updateRepairAndSale(DlRepairTitem dlRepairTitem); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java index 97fedb38..bfae38a6 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java @@ -25,7 +25,7 @@ public interface DlRepairTicketsService extends IService { * @author 小李 * @date 11:33 2024/9/20 **/ - void createTickets(DlRepairTicketsRespVO ticketsRespVO); + DlRepairTicketsRespVO createTickets(DlRepairTicketsRespVO ticketsRespVO); /** * 维修工单表 分页 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 82bd2045..ed7bd6f3 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 @@ -34,4 +34,11 @@ public interface DlRepairTitemService extends IService { **/ List getProjectList(String ticketId); + /** + * 更新工单子表中维修人员、销售人员信息(app) + * @param dlRepairTitem + * @return + */ + DlRepairTitem updateRepairAndSale(DlRepairTitem dlRepairTitem); + } 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 f7e69d0f..894022b4 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 @@ -155,7 +155,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl - SELECT drti.id, drti.ticket_id, drti.item_name,