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 1ff3d3e0..b0403dc7 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 @@ -7,9 +7,11 @@ 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.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import cn.iocoder.yudao.module.base.entity.RepairRecords; import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.service.RepairRecordsService; import cn.iocoder.yudao.module.base.service.RepairWorkerService; @@ -365,7 +367,24 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl repairTypeList = dictDataApi.getDictDataList(DICT_REPAIR_TYPE); + Map repairTypeMap = repairTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel)); DlRepairTicketsRespVO result = BeanUtil.toBean(dlRepairTickets, DlRepairTicketsRespVO.class); + result.setRepairTypeText(repairTypeMap.getOrDefault(dlRepairTickets.getRepairType(),"")); + + //查是否存在总检完成的记录,取出他的时间 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(RepairRecords::getTicketId,id) + .eq(RepairRecords::getType,RecordTypeEnum.ZJ.getCode()) + .orderByDesc(BaseDO::getCreateTime); + List repairRecords = repairRecordsService.list(queryWrapper); + if(!repairRecords.isEmpty()){ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String formattedString = repairRecords.get(0).getCreateTime().format(formatter); + result.setRealOverDate(formattedString); + } + AdminUserDO user = userService.getUser(Long.valueOf(dlRepairTickets.getAdviserId())); result.setLinkPhone(user.getMobile()); //查车辆 @@ -380,15 +399,54 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl itemList = titemService.list(new LambdaQueryWrapper().eq(DlRepairTitem::getTicketId, id)); List items = itemList.stream().map(item -> BeanUtil.toBean(item, DlRepairTitemReqVO.class)).collect(Collectors.toList()); - // 取项目 + + + //处理项目 取项目 List projects = items.stream().filter(item -> item.getItemType().equals("01")).collect(Collectors.toList()); + //pc原逻辑 if (CollectionUtil.isNotEmpty(projects)) { Set ids = projects.stream().map(DlRepairTitemReqVO::getProjectId).collect(Collectors.toSet()); List repairProjects = projectService.listByIds(ids); items.forEach(item -> repairProjects.stream().filter(i -> i.getId().equals(item.getProjectId())).findFirst().ifPresent(item::setProject)); } result.setProjects(projects); + if(ifApp){ + //app新增逻辑 + if (CollectionUtil.isNotEmpty(projects)) { + List projectList = new ArrayList<>(); + //查所有服务分类(项目分类) + List baseTypeList = baseTypeService.list(); + Map baseTypeMap = baseTypeList.stream().collect(Collectors.toMap(BaseType::getId,BaseType::getName)); + //先过滤出itenTypeId为null或空为单独一个组 + List nullList = projects.stream().filter(item->StringUtils.isEmpty(item.getItemTypeId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(nullList)) { + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setWares(nullList); + waresGroupVO.setGroupName("未知分组"); + waresGroupVO.setNums(nullList.size()); + waresGroupVO.setShowAll(false); + waresGroupVO.setServicer(nullList.get(0).getSaleName()); + waresGroupVO.setWorker(nullList.get(0).getRepairNames()); + projectList.add(waresGroupVO); + } + //过滤出有分类的进行分组 + Map> groupListMap = projects.stream().filter(item->StringUtils.isNotEmpty(item.getItemTypeId())).collect(Collectors.groupingBy(DlRepairTitem::getItemTypeId)); + for (String key:groupListMap.keySet()){ + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setWares(groupListMap.get(key)); + waresGroupVO.setGroupName(baseTypeMap.get(key)); + waresGroupVO.setGroupId(key); + waresGroupVO.setNums(groupListMap.get(key).size()); + waresGroupVO.setShowAll(false); + waresGroupVO.setServicer(groupListMap.get(key).get(0).getSaleName()); + waresGroupVO.setWorker(groupListMap.get(key).get(0).getRepairNames()); + projectList.add(waresGroupVO); + } + result.setProjectList(projectList); + } + } + //处理配件 if(ifApp){ //app的逻辑 List waresGroupList = new ArrayList<>(); diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java index 82f185ac..bd3e5095 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java @@ -7,12 +7,14 @@ import java.math.BigDecimal; import java.util.List; /** - * app使用的配件明细,按分类分组后的 + * app使用的配件明细(项目),按分类分组后的 * @author vinjor-M * @date 10:10 2024/11/19 **/ @Data public class AppWaresGroupVO { + /** 是否展开数据 */ + private Boolean showAll; /** 分组ID(分类ID) */ private String groupId; /** 分组名称(分类名称) */ @@ -23,7 +25,7 @@ public class AppWaresGroupVO { private Integer nums; /** 总价 */ private BigDecimal totalAmount; - /** 配件明细 */ + /** 配件/项目明细 */ private List wares; /** 配件申请单配件明细 */ private List twItemList; @@ -36,4 +38,9 @@ public class AppWaresGroupVO { private Integer waitingNum; /** 审核不通过数量-- */ private Integer noNum; + + /** 服务顾问人名 */ + private String servicer; + /** 维修工人名 */ + private String worker; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java index 307d594c..3042b811 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java @@ -65,4 +65,11 @@ public class DlRepairTicketsRespVO extends DlRepairTickets { /** app分组回显专用--配件明细 */ List waresGroupList; + /** app分组回显专用--项目明细 */ + List projectList; + + /** 维修类型文本 */ + private String repairTypeText; + /** 车辆实际竣工(总检完成)时间 */ + private String realOverDate; }