From c6e571e56caa6cf2a5d07a2d001db3d77cba2c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Fri, 18 Oct 2024 17:11:58 +0800 Subject: [PATCH] =?UTF-8?q?app=E6=96=B0=E5=BB=BA=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=B5=B0=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/RepairProjectController.java | 9 +++++ .../project/mapper/RepairProjectMapper.java | 8 ++++ .../project/service/RepairProjectService.java | 8 ++++ .../impl/RepairProjectServiceImpl.java | 38 +++++++++++++++++++ .../module/project/vo/RepairProjectAppvo.java | 13 +++++++ .../mapper/project/RepairProjectMapper.xml | 12 ++++++ 6 files changed, 88 insertions(+) create mode 100644 dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectAppvo.java diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java index c2874b70..db435e3d 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java @@ -128,4 +128,13 @@ public class RepairProjectController { List list = repairProjectService.list(new LambdaQueryWrapper().eq(RepairProject::getName, name)); return success(list.stream().max(Comparator.comparing(RepairProject::getCreateTime)).orElse(null)); } + + /** + * 获取维修项目和分类 + * @return + */ + @GetMapping("/getRepairProjectAndCateGory") + public CommonResult getRepairProjectAndCateGory(){ + return success(repairProjectService.getRepairProjectAndCateGory()); + } } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java index a35fbe10..d57ec2f0 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/mapper/RepairProjectMapper.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.project.mapper; import cn.iocoder.yudao.module.project.entity.RepairProject; +import cn.iocoder.yudao.module.project.vo.RepairProjectAppvo; import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -9,6 +10,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; + /** * 维修项目 Mapper * @@ -28,4 +31,9 @@ public interface RepairProjectMapper extends BaseMapper { **/ IPage selectListPage(@Param("entity") RepairProjectPageReqVO pageReqVO, Page page); + /** + * 查询维修项目和维修项目分类信息 + * @return + */ + List selectProjectAndCateGory(); } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java index bc23ab89..9cb2a453 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairProjectService.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.project.service; import cn.iocoder.yudao.module.project.entity.RepairProject; +import cn.iocoder.yudao.module.project.vo.RepairProjectAppvo; import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO; import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO; @@ -9,6 +10,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * 维修项目 Service 接口 * @@ -56,4 +59,9 @@ public interface RepairProjectService extends IService { IPage queryListPage(RepairProjectPageReqVO pageReqVO, Page page); + /** + * 查询服务分类和维修项目列表 + * @return + */ + List getRepairProjectAndCateGory(); } \ No newline at end of file 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 7fdd8dfe..10afa53e 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 @@ -1,9 +1,13 @@ package cn.iocoder.yudao.module.project.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.project.entity.RepairProject; import cn.iocoder.yudao.module.project.mapper.RepairProjectMapper; import cn.iocoder.yudao.module.project.service.RepairProjectService; +import cn.iocoder.yudao.module.project.vo.RepairProjectAppvo; import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO; import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO; @@ -14,6 +18,9 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; /** * 维修项目 Service 实现类 @@ -82,5 +89,36 @@ 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)); + } + } + list.add(repairProjectAppvo); + } + return list; + } + } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectAppvo.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectAppvo.java new file mode 100644 index 00000000..66128b3e --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairProjectAppvo.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.project.vo; + +import cn.iocoder.yudao.module.project.entity.RepairProject; +import lombok.Data; + +import java.util.List; + +@Data +public class RepairProjectAppvo extends RepairProject{ + private String typeName; + private String typeId; + private List groupList; +} diff --git a/dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml b/dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml index e2314d79..bb2dca22 100644 --- a/dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/project/RepairProjectMapper.xml @@ -33,4 +33,16 @@ ORDER BY drp.create_time DESC + \ No newline at end of file