diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/tickets/controller/TicketsAPI.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/tickets/controller/TicketsAPI.java index 7c925361..5a7be083 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/tickets/controller/TicketsAPI.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/app/tickets/controller/TicketsAPI.java @@ -39,6 +39,6 @@ public class TicketsAPI { @Operation(summary = "维修工单表 查看一个工单的详细信息") @TenantIgnore public CommonResult getTicketsById(@RequestParam(value = "id") String id){ - return success(dlRepairTicketsService.getTicketsById(id)); + return success(dlRepairTicketsService.getTicketsById(id,null)); } } 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 898aab4d..e9cd6a20 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 @@ -74,13 +74,14 @@ public class DlRepairTicketsController { * 获得一个工单的详细信息 * * @param id 工单ID + * @param ifApp 是否是APP发起的查询 * @author 小李 * @date 16:05 2024/9/21 **/ @GetMapping("/get") @Operation(summary = "查看一个工单的详细信息") - public CommonResult getTicketsById(@RequestParam("id") String id) { - return success(dlRepairTicketsService.getTicketsById(id)); + public CommonResult getTicketsById(@RequestParam("id") String id,@RequestParam("ifApp")Boolean ifApp) { + return success(dlRepairTicketsService.getTicketsById(id,ifApp)); } /** 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 c3ac254b..1da62048 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.tickets.mapper; import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; +import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemReqVO; import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemRespVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -42,6 +43,15 @@ public interface DlRepairTitemMapper extends BaseMapper { * @return java.util.List **/ List selectProjList(@Param("ticketId")String ticketId,@Param("isOpen")String isOpen); + + /** + * 根据工单ID查询所有配件明细--带着分组名称和ID + * @author vinjor-M + * @date 10:44 2024/11/19 + * @param ticketId 工单ID + * @return java.util.List + **/ + List selectByTicketId(@Param("ticketId")String ticketId); } 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 85e0eb58..3194be45 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 @@ -42,10 +42,11 @@ public interface DlRepairTicketsService extends IService { * 获得一个工单的详细信息 * * @param id 工单ID + * @param ifApp 是否是APP发起的查询 * @author 小李 * @date 16:05 2024/9/21 **/ - DlRepairTicketsRespVO getTicketsById(String id); + DlRepairTicketsRespVO getTicketsById(String id,Boolean ifApp); /** * 维修工单表 作废 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 64d87275..00dc57b3 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 @@ -52,6 +52,7 @@ import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; import cn.iocoder.yudao.module.tickets.entity.DlTicketWares; import cn.iocoder.yudao.module.tickets.entity.DlTwItem; import cn.iocoder.yudao.module.tickets.mapper.DlRepairTicketsMapper; +import cn.iocoder.yudao.module.tickets.mapper.DlRepairTitemMapper; import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService; import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService; @@ -105,6 +106,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl wares = items.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(wares)) { - // 单位字典 - List recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_UNIT); - Map unitMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel)); - - Set ids = wares.stream().map(DlRepairTitemReqVO::getPartId).collect(Collectors.toSet()); - List repairWares = waresService.listByIds(ids); - items.forEach(item -> { - repairWares.stream().filter(i -> i.getId().equals(item.getPartId())).findFirst().ifPresent(item::setWare); - item.setItemUnit(unitMap.get(item.getItemUnit())); - }); + if(ifApp){ + //app的逻辑 + List waresGroupList = new ArrayList<>(); + //查这个工单的配件 + List waresList = repairTitemMapper.selectByTicketId(id); + if (CollectionUtil.isNotEmpty(waresList)) { + //先过滤出itenTypeId为null或空,或者itemTypeName为null或空的,为单独一个组 + List nullList = waresList.stream().filter(item->StringUtils.isEmpty(item.getItemTypeId()) || StringUtils.isEmpty(item.getItemTypeName())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(nullList)) { + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setWares(nullList); + waresGroupVO.setGroupName("未知分组"); + waresGroupVO.setNums(nullList.size()); + waresGroupVO.setTotalAmount(nullList.stream().peek(item->{ + if(null==item.getItemMoney()){ + item.setItemMoney(new BigDecimal(0)); + } + }).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO,BigDecimal::add)); + waresGroupList.add(waresGroupVO); + } + //过滤出有分类的进行分组 + Map> groupListMap = waresList.stream().filter(item->StringUtils.isNotEmpty(item.getItemTypeId()) && StringUtils.isNotEmpty(item.getItemTypeName())).collect(Collectors.groupingBy(DlRepairTitem::getItemTypeId)); + for (String key:groupListMap.keySet()){ + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setWares(groupListMap.get(key)); + waresGroupVO.setGroupName(groupListMap.get(key).get(0).getItemTypeName()); + waresGroupVO.setGroupId(key); + waresGroupVO.setNums(groupListMap.get(key).size()); + waresGroupVO.setTotalAmount(groupListMap.get(key).stream().peek(item->{ + if(null==item.getItemMoney()){ + item.setItemMoney(new BigDecimal(0)); + } + }).map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO,BigDecimal::add)); + waresGroupList.add(waresGroupVO); + } + } + result.setWaresGroupList(waresGroupList); + }else{ + // 取配件----原有逻辑-电脑端 + List wares = items.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(wares)) { + // 单位字典 + List recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_UNIT); + Map unitMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel)); + Set ids = wares.stream().map(DlRepairTitemReqVO::getPartId).collect(Collectors.toSet()); + List repairWares = waresService.listByIds(ids); + items.forEach(item -> { + repairWares.stream().filter(i -> i.getId().equals(item.getPartId())).findFirst().ifPresent(item::setWare); + item.setUnitText(unitMap.get(item.getItemUnit())); + }); + } + result.setWares(wares); } - result.setWares(wares); // 取附加 List others = items.stream().filter(item -> item.getItemType().equals("03")).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(others)) { 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 new file mode 100644 index 00000000..6774b060 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.tickets.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * app使用的配件明细,按分类分组后的 + * @author vinjor-M + * @date 10:10 2024/11/19 +**/ +@Data +public class AppWaresGroupVO { + /** 分组ID(分类ID) */ + private String groupId; + /** 分组名称(分类名称) */ + private String groupName; + /** 数量 */ + private Integer nums; + /** 总价 */ + private BigDecimal totalAmount; + /** 配件明细 */ + private List wares; +} 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 694d3ea4..307d594c 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 @@ -63,4 +63,6 @@ public class DlRepairTicketsRespVO extends DlRepairTickets { /** 维修班组长是否可以重新派工--当前施工人是自己或者本班组内的人员 */ private Boolean canOperate; + /** app分组回显专用--配件明细 */ + List waresGroupList; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemReqVO.java index 00d921b5..283d519e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemReqVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTitemReqVO.java @@ -23,4 +23,9 @@ public class DlRepairTitemReqVO extends DlRepairTitem { // 附加详情 private DlRepairOther other; + /** 配件分类名称 */ + private String itemTypeName; + /** 配件单位名称 */ + private String unitText; + } diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml index ff4e32fd..f08bf9bc 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTitemMapper.xml @@ -109,4 +109,37 @@ drt.update_time, drri.create_time +