diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTwItemController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTwItemController.java index 8deeac17..83ff9a56 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTwItemController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTwItemController.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.tickets.controller.admin; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.tickets.entity.DlTwItem; import cn.iocoder.yudao.module.tickets.service.DlTwItemService; import cn.iocoder.yudao.module.tickets.vo.AddTwiVO; import cn.iocoder.yudao.module.tickets.vo.DlTwItemReqVO; @@ -40,6 +39,19 @@ public class DlTwItemController { return success(dlTwItemService.listTwItem(reqVO)); } + /** + * APP查询配件申请单列表-按配件分类进行分组 + * @author vinjor-M + * @date 14:01 2024/11/20 + * @param reqVO TODO + * @return cn.iocoder.yudao.framework.common.pojo.CommonResult + **/ + @GetMapping("/listApp") + @Operation(summary = "APP查询配件申请单列表-按配件分类进行分组") + public CommonResult listApp(DlTwItemReqVO reqVO){ + return success(dlTwItemService.listApp(reqVO)); + } + /** * 给配件申请表子表添加数据 * diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlTwItemMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlTwItemMapper.java index bd54eb0e..a821dbd4 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlTwItemMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/mapper/DlTwItemMapper.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.tickets.mapper; import cn.iocoder.yudao.module.tickets.entity.DlTwItem; import cn.iocoder.yudao.module.tickets.vo.DlTwItemReqVO; +import cn.iocoder.yudao.module.tickets.vo.DlTwItemRespVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -25,6 +26,15 @@ public interface DlTwItemMapper extends BaseMapper { * @param reqVO 请求对象 **/ List listTwItem(@Param("map") DlTwItemReqVO reqVO); + + /** + * APP查询配件申请单列表-按配件分类进行分组 + * @author vinjor-M + * @date 14:04 2024/11/20 + * @param reqVO + * @return java.util.List + **/ + List listTwItemApp(@Param("map") DlTwItemReqVO reqVO); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlTwItemService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlTwItemService.java index f98bad59..532bb31a 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlTwItemService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlTwItemService.java @@ -33,4 +33,13 @@ public interface DlTwItemService extends IService { * @param addTwiVO 对象 **/ void addTwi(AddTwiVO addTwiVO); + + /** + * APP查询配件申请单列表-按配件分类进行分组 + * @author vinjor-M + * @date 14:03 2024/11/20 + * @param reqVO + * @return java.lang.Object + **/ + Object listApp(DlTwItemReqVO reqVO); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTwItemServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTwItemServiceImpl.java index 5e17804d..ca30ae54 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTwItemServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTwItemServiceImpl.java @@ -6,19 +6,22 @@ import cn.iocoder.yudao.module.project.entity.RepairWares; import cn.iocoder.yudao.module.project.service.RepairWaresService; import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; -import cn.iocoder.yudao.module.tickets.entity.DlTicketWares; import cn.iocoder.yudao.module.tickets.entity.DlTwItem; import cn.iocoder.yudao.module.tickets.mapper.DlTwItemMapper; import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService; import cn.iocoder.yudao.module.tickets.service.DlTwItemService; import cn.iocoder.yudao.module.tickets.vo.AddTwiVO; +import cn.iocoder.yudao.module.tickets.vo.AppWaresGroupVO; import cn.iocoder.yudao.module.tickets.vo.DlTwItemReqVO; import cn.iocoder.yudao.module.tickets.vo.DlTwItemRespVO; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,6 +40,8 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU public class DlTwItemServiceImpl extends ServiceImpl implements DlTwItemService { + @Resource + private DlTwItemMapper dlTwItemMapper; @Resource private RepairWaresService repairWaresService; @Resource @@ -113,6 +118,55 @@ public class DlTwItemServiceImpl extends ServiceImpl // 新增 baseMapper.insert(twItems); } + + /** + * APP查询配件申请单列表-按配件分类进行分组 + * + * @param reqVO + * @return java.lang.Object + * @author vinjor-M + * @date 14:03 2024/11/20 + **/ + @Override + public Object listApp(DlTwItemReqVO reqVO) { + // 查记录 + List dlTwItemRespVOList = dlTwItemMapper.listTwItemApp(reqVO); + List waresGroupList = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(dlTwItemRespVOList)) { + //先过滤出itenTypeId为null或空,或者itemTypeName为null或空的,为单独一个组 + List nullList = dlTwItemRespVOList.stream().filter(item-> StringUtils.isEmpty(item.getTypeId()) || StringUtils.isEmpty(item.getTypeName())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(nullList)) { + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setTwItemList(nullList.stream().peek(item->{ + if(StringUtils.isEmpty(item.getWaresStatus())){ + item.setSelected(false); + }else{ + item.setApprovalTime(item.getUpdateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + } + }).collect(Collectors.toList())); + waresGroupVO.setGroupName("未知分组"); + waresGroupVO.setNums(nullList.size()); + waresGroupList.add(waresGroupVO); + } + //过滤出有分类的进行分组 + Map> groupListMap = dlTwItemRespVOList.stream().filter(item->StringUtils.isNotEmpty(item.getTypeId()) && StringUtils.isNotEmpty(item.getTypeName())).collect(Collectors.groupingBy(DlTwItemRespVO::getTypeId)); + for (String key:groupListMap.keySet()){ + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setTwItemList(groupListMap.get(key).stream().peek(item->{ + if(StringUtils.isEmpty(item.getWaresStatus())){ + item.setSelected(false); + }else{ + item.setApprovalTime(item.getUpdateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + } + }).collect(Collectors.toList())); + waresGroupVO.setGroupName(groupListMap.get(key).get(0).getTypeName()); + waresGroupVO.setGroupId(key); + waresGroupVO.setNums(groupListMap.get(key).size()); + waresGroupList.add(waresGroupVO); + } + } + return waresGroupList; + } } 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 6774b060..c6d0be4d 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 @@ -16,10 +16,13 @@ public class AppWaresGroupVO { private String groupId; /** 分组名称(分类名称) */ private String groupName; - /** 数量 */ + /** 数量--兼容待审核的配件数量 */ private Integer nums; /** 总价 */ private BigDecimal totalAmount; /** 配件明细 */ private List wares; + + /** 配件申请单配件明细 */ + private List twItemList; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTwItemRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTwItemRespVO.java index 64a623cb..6edf4803 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTwItemRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTwItemRespVO.java @@ -4,6 +4,8 @@ import cn.iocoder.yudao.module.project.entity.RepairWares; import cn.iocoder.yudao.module.tickets.entity.DlTwItem; import lombok.Data; +import java.math.BigDecimal; + /** * 工单配件申请/退回子表响应VO * @@ -15,6 +17,18 @@ public class DlTwItemRespVO extends DlTwItem { /** 配件详情 */ private RepairWares wares; + /** 配件分类id */ + private String typeId; /** 配件分类名称 */ private String typeName; + /** 配件计量单位名称 */ + private String unitText; + /** 是否选中 */ + private Boolean selected; + /** 售价 */ + private BigDecimal salePrice; + /** 库存 */ + private Integer stock; + /** 审核时间 */ + private String approvalTime; } diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml index 9200d38b..2bbf3b12 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml @@ -47,4 +47,47 @@ and dti.wares_status = #{map.waresStatus} +