From fb27a36be1d8601c9059b3ce3f7684f118e3bee5 Mon Sep 17 00:00:00 2001 From: PQZ Date: Fri, 11 Oct 2024 16:55:06 +0800 Subject: [PATCH] 1 --- .../iocoder/yudao/common/BaseConstants.java | 19 ++++ .../module/base/entity/RepairRecords.java | 6 +- .../base/mapper/RepairRecordsMapper.java | 9 ++ .../service/RepairRecordsItemService.java | 35 ++++++ .../base/service/RepairRecordsService.java | 27 +++-- .../impl/RepairRecordsItemServiceImpl.java | 104 +++++++++++++++++- .../impl/RepairRecordsServiceImpl.java | 64 ++++++++++- .../base/vo/RepairRecordsPageReqVO.java | 2 + .../module/base/vo/RepairRecordsRespVO.java | 7 ++ .../base/vo/RepairRecordsSaveReqVO.java | 7 -- .../mapper/base/RepairRecordsMapper.xml | 21 +++- 11 files changed, 270 insertions(+), 31 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java index 670e7666..bbb18eca 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java @@ -94,6 +94,8 @@ public class BaseConstants { public static final String ORDER_KKYL = "3"; /**订单店铺名称*/ public static final String ORDER_TENANT_NAME = "蓝安集团"; + /**------工单记录常量-----------*/ + /**工单*/ public static final String REPAIR_RECORD_TYPE_TICKET = "ticket"; /**工单附属项目*/ @@ -101,4 +103,21 @@ public class BaseConstants { /**维修记录*/ public static final String REPAIR_RECORD_TYPE_RECORD = "record"; + /**创建工单*/ + public static final String REPAIR_RECORD_TYPE_CJGD = "cjgd"; + /**指派施工*/ + public static final String REPAIR_RECORD_TYPE_ZPSG = "zpsg"; + /**领料*/ + public static final String REPAIR_RECORD_TYPE_LL = "ll"; + /**退料*/ + public static final String REPAIR_RECORD_TYPE_TL = "tl"; + /**施工完成(自检)*/ + public static final String REPAIR_RECORD_TYPE_SGWCZJ = "sgwczj"; + /**总检*/ + public static final String REPAIR_RECORD_TYPE_ZJ = "zj"; + /**结束工单*/ + public static final String REPAIR_RECORD_TYPE_JSGD = "jsgd"; + + + } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairRecords.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairRecords.java index 29832c35..6b9e0de5 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairRecords.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/entity/RepairRecords.java @@ -41,10 +41,6 @@ public class RepairRecords extends TenantBaseDO { * 记录描述 */ private String remark; - /** - * 过程记录中的图片(多个,拼接) - */ - private String image; /** * 处理人 */ @@ -52,6 +48,6 @@ public class RepairRecords extends TenantBaseDO { /** * 处理人员工表id */ - private String dealUserId; + private Long dealUserId; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairRecordsMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairRecordsMapper.java index 12cf61b8..d37a3b0e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairRecordsMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/mapper/RepairRecordsMapper.java @@ -17,6 +17,15 @@ import java.util.List; @Mapper public interface RepairRecordsMapper extends BaseMapper { + /** + * 查询维修记录 + * @author lzt + * @param entity 查询条件 + * @return List + * @date 2024年10月9日 + */ + List queryRepairRecords(@Param("entity") RepairRecordsPageReqVO entity); + } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsItemService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsItemService.java index 56da29c6..c2bc36e5 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsItemService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsItemService.java @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.base.service; import cn.iocoder.yudao.module.base.entity.RepairRecordsItem; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * 维修记录 Service 接口 * @@ -20,4 +22,37 @@ public interface RepairRecordsItemService extends IService { **/ void removeByMainId(String mainType, String mainId); + /** + * 通过主表id查询图片 + * + * @param mainType ticket:工单;repairItem:工单附属项目;record:维修记录 + * @param mainId 主表id + * @param isOpen 是否开放给用户(默认查询全部,如不为null则根据条件查询) + * @return 记录图片集合 + * @author PQZ + * @date 14:30 2024/10/11 + **/ + List getByMainId(String mainType, String mainId, String isOpen); + + /** + * 保存维修记录相关的图片 + * + * @param recordId 记录id + * @param ticketId 工单id + * @param repairItemId 工单子表id + * @param image 上传附件相对路径(多个用“,”分隔) + * @author PQZ + * @date 14:09 2024/10/11 + **/ + void saveItem(String recordId, String ticketId, String repairItemId, String image); + + /** + * 设置图片是否开放给用户 + * + * @param ids 前端选中图片id(多个用“,”分隔) + * @param isOpen 0否1是 + * @author PQZ + * @date 14:22 2024/10/11 + **/ + void setRepairOpen(String ids, String isOpen); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsService.java index 99e4c745..4d418bc2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/RepairRecordsService.java @@ -3,13 +3,8 @@ package cn.iocoder.yudao.module.base.service; import cn.iocoder.yudao.module.base.entity.RepairRecords; import cn.iocoder.yudao.module.base.vo.RepairRecordsPageReqVO; import cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO; -import cn.iocoder.yudao.module.base.vo.RepairRecordsSaveReqVO; -import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; -import javax.validation.Valid; import java.util.List; /** @@ -20,11 +15,25 @@ import java.util.List; public interface RepairRecordsService extends IService { /** - * 创建维修记录 + * 保存维修记录 + * + * @param ticketId 工单id + * @param repairItemId 工单子表id + * @param type 工作类型(数据字典:repair_records_type;后端已初始化常量,可直接引用base包中BaseConstants下106-119行) + * @param remark 备注 + * @param images 图片(相对路径按照“,”分隔) * @author PQZ - * @date 11:41 2024/10/11 - * @param saveReqVO RepairRecordsSaveReqVO实体 + * @date 14:51 2024/10/11 + **/ + void saveRepairRecord(String ticketId, String repairItemId, String type, String remark, String images); + + /** + * 根据条件查询维修记录 + * @author PQZ + * @date 15:14 2024/10/11 + * @param pageReqVO RepairRecordsPageReqVO实体 + * @return java.util.List **/ - void saveRepairRecord(RepairRecordsSaveReqVO saveReqVO); + List queryList(RepairRecordsPageReqVO pageReqVO); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsItemServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsItemServiceImpl.java index c8271100..88e3dbb5 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsItemServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/service/impl/RepairRecordsItemServiceImpl.java @@ -1,15 +1,20 @@ package cn.iocoder.yudao.module.base.service.impl; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.base.entity.RepairRecordsItem; import cn.iocoder.yudao.module.base.mapper.RepairRecordsItemMapper; import cn.iocoder.yudao.module.base.service.RepairRecordsItemService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; import static cn.iocoder.yudao.common.BaseConstants.*; @@ -36,6 +41,97 @@ public class RepairRecordsItemServiceImpl extends ServiceImpl lambdaQueryWrapper = queryType(mainType, mainId); + remove(lambdaQueryWrapper); + } + + /** + * 通过主表id查询图片 + * + * @param mainType ticket:工单;repairItem:工单附属项目;record:维修记录 + * @param mainId 主表id + * @param isOpen 是否开放给用户(默认查询全部,如不为null则根据条件查询) + * @return 记录图片集合 + * @author PQZ + * @date 14:30 2024/10/11 + **/ + @Override + public List getByMainId(String mainType, String mainId, String isOpen) { + //根据不同类型初始化不通过查询条件 + LambdaQueryWrapper lambdaQueryWrapper = queryType(mainType, mainId); + //默认查询全部,如不为null则根据条件查询 + if (StringUtils.isNotEmpty(isOpen)) { + lambdaQueryWrapper.eq(RepairRecordsItem::getIsOpen, isOpen); + } + return list(lambdaQueryWrapper); + } + + + /** + * 保存维修记录相关的图片 + * + * @param recordId 记录id + * @param ticketId 工单id + * @param repairItemId 工单子表id + * @param image 上传附件相对路径(多个用“,”分隔) + * @author PQZ + * @date 14:09 2024/10/11 + **/ + @Override + public void saveItem(String recordId, String ticketId, String repairItemId, String image) { + //根据记录id删除改记录中原有的图片 + removeByMainId(REPAIR_RECORD_TYPE_RECORD, recordId); + //组装维修记录图片集合 + List saveList = new ArrayList<>(); + if (StringUtils.isNotEmpty(image)) { + //字符串转换集合 + List imageList = Arrays.stream(image.split(",")) + .collect(Collectors.toList()); + imageList.forEach(item -> { + RepairRecordsItem saveItem = new RepairRecordsItem(); + saveItem.setRecordId(recordId); + saveItem.setTicketId(ticketId); + saveItem.setRepairItemId(repairItemId); + saveItem.setImage(item); + saveList.add(saveItem); + }); + saveBatch(saveList); + } + } + + /** + * 设置图片是否开放给用户 + * + * @param ids 前端选中图片id(多个用“,”分隔) + * @param isOpen 0否1是 + * @author PQZ + * @date 14:22 2024/10/11 + **/ + @Override + public void setRepairOpen(String ids, String isOpen) { + if (StringUtils.isNotEmpty(ids)) { + //id字符串转换集合 + List idList = Arrays.stream(ids.split(",")) + .collect(Collectors.toList()); + LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + //设置更新条件 + lambdaUpdateWrapper.in(RepairRecordsItem::getId, idList).set(RepairRecordsItem::getIsOpen, isOpen); + //更新 + update(lambdaUpdateWrapper); + } + } + + /** + * 封装查询条件 + * + * @param mainType ticket:工单;repairItem:工单附属项目;record:维修记录 + * @param mainId 主表id + * @return com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper + * @author PQZ + * @date 14:36 2024/10/11 + **/ + private LambdaQueryWrapper queryType(String mainType, String mainId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); switch (mainType) { //匹配根据工单表id删除条件 @@ -44,15 +140,15 @@ public class RepairRecordsItemServiceImpl extends ServiceImpl + * @author PQZ + * @date 15:14 2024/10/11 + **/ + @Override + public List queryList(RepairRecordsPageReqVO pageReqVO) { + //根据条件查询维修记录 + List list = repairRecordsMapper.queryRepairRecords(pageReqVO); + //为每一条维修记录设置查询附件 + list.forEach(item -> { + List itemList = itemService.getByMainId(REPAIR_RECORD_TYPE_RECORD, item.getId(), pageReqVO.getIsOpen()); + item.setItemList(itemList); + //相对路径按照“,”分隔 + item.setImages(itemList.stream().map(RepairRecordsItem::getImage).collect(Collectors.joining(","))); + }); + return list; } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsPageReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsPageReqVO.java index f9d55f49..638809e4 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsPageReqVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsPageReqVO.java @@ -11,5 +11,7 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class RepairRecordsPageReqVO extends RepairRecords { + /**是否开放给用户*/ + private String isOpen; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java index 3228b872..76e0cb96 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsRespVO.java @@ -1,13 +1,20 @@ package cn.iocoder.yudao.module.base.vo; import cn.iocoder.yudao.module.base.entity.RepairRecords; +import cn.iocoder.yudao.module.base.entity.RepairRecordsItem; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; + @Schema(description = "管理后台 - 维修记录 Response VO") @Data @ExcelIgnoreUnannotated public class RepairRecordsRespVO extends RepairRecords { + /**维修记录关联子表*/ + private List itemList; + /**维修记录关联附件信息*/ + private String images; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsSaveReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsSaveReqVO.java index fc4d3090..4f30098c 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsSaveReqVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/RepairRecordsSaveReqVO.java @@ -1,20 +1,13 @@ package cn.iocoder.yudao.module.base.vo; import cn.iocoder.yudao.module.base.entity.RepairRecords; -import cn.iocoder.yudao.module.base.entity.RepairRecordsItem; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.util.List; - @Schema(description = "管理后台 - 维修记录新增/修改 Request VO") @Data public class RepairRecordsSaveReqVO extends RepairRecords { - /**维修记录附件表*/ - List itemList; - /**当前维修记录中需要保存的附件信息*/ - String images; } diff --git a/dl-module-repair/src/main/resources/mapper/base/RepairRecordsMapper.xml b/dl-module-repair/src/main/resources/mapper/base/RepairRecordsMapper.xml index e5b4971d..4885f903 100644 --- a/dl-module-repair/src/main/resources/mapper/base/RepairRecordsMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/base/RepairRecordsMapper.xml @@ -9,6 +9,25 @@ 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ --> - +