diff --git a/src/main/java/org/springblade/modules/capital/controller/ApplyController.java b/src/main/java/org/springblade/modules/capital/controller/ApplyController.java index 0cae798..bda6feb 100644 --- a/src/main/java/org/springblade/modules/capital/controller/ApplyController.java +++ b/src/main/java/org/springblade/modules/capital/controller/ApplyController.java @@ -68,11 +68,10 @@ public class ApplyController extends BladeController { @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入apply") - public R detail(Apply apply) { + public R detail(Apply apply) { Apply detail = applyService.getOne(Condition.getQueryWrapper(apply)); - ApplyVO applyVO = Objects.requireNonNull(BeanUtil.copy(detail, ApplyVO.class)); - applyVO.setDetails(applyDetailService.list(Wrappers.lambdaQuery(ApplyDetail.class).eq(ApplyDetail::getApplyId, apply.getId()))); - return R.data(applyVO); + detail.setDetails(applyDetailService.list(Wrappers.lambdaQuery(ApplyDetail.class).eq(ApplyDetail::getApplyId, apply.getId()))); + return R.data(detail); } /** @@ -83,7 +82,16 @@ public class ApplyController extends BladeController { @ApiOperation(value = "分页", notes = "传入apply") public R> list(ApplyDTO apply, Query query) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Apply.class); + wrapper.orderByDesc(Apply::getCreateTime); IPage pages = applyService.page(Condition.getPage(query), wrapper); + List records = pages.getRecords(); + if (CollectionUtil.isNotEmpty(records)) { + List ids = records.stream().map(Apply::getId).collect(Collectors.toList()); + List details = applyDetailService.list(Wrappers.lambdaQuery(ApplyDetail.class).in(ApplyDetail::getApplyId, ids)); + for (Apply record : records) { + record.setDetails(details.stream().filter(applyDetail -> applyDetail.getApplyId().equals(record.getId())).collect(Collectors.toList())); + } + } return R.data(pages); } diff --git a/src/main/java/org/springblade/modules/capital/controller/InOrderController.java b/src/main/java/org/springblade/modules/capital/controller/InOrderController.java index f98381d..60a667d 100644 --- a/src/main/java/org/springblade/modules/capital/controller/InOrderController.java +++ b/src/main/java/org/springblade/modules/capital/controller/InOrderController.java @@ -1,19 +1,3 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ package org.springblade.modules.capital.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -37,15 +21,12 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.modules.capital.dto.ApplyDTO; import org.springblade.modules.capital.dto.InOrderDTO; -import org.springblade.modules.capital.entity.ApplyDetail; -import org.springblade.modules.capital.entity.Goods; -import org.springblade.modules.capital.entity.InOrderDetail; +import org.springblade.modules.capital.entity.*; import org.springblade.modules.capital.service.IGoodsService; import org.springblade.modules.capital.service.IInOrderDetailService; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import org.springblade.modules.capital.entity.InOrder; import org.springblade.modules.capital.vo.InOrderVO; import org.springblade.modules.capital.excel.InOrderExcel; import org.springblade.modules.capital.service.IInOrderService; @@ -83,16 +64,15 @@ public class InOrderController extends BladeController { @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入inOrder") - public R detail(InOrder inOrder) { + public R detail(InOrder inOrder) { InOrder detail = inOrderService.getById(inOrder.getId()); - InOrderDTO inOrderDTO = BeanUtil.copy(detail, InOrderDTO.class); - if (inOrderDTO != null) { - inOrderDTO.setInUserName(inOrderDTO.getInUserId() != null ? UserCache.getUser(inOrderDTO.getInUserId()).getRealName() : ""); - inOrderDTO.setApproveUserName(inOrderDTO.getApproveUserId() != null ? UserCache.getUser(inOrderDTO.getApproveUserId()).getRealName() : ""); - inOrderDTO.setApplyUserName(inOrderDTO.getApplyUserId() != null ? UserCache.getUser(inOrderDTO.getApplyUserId()).getRealName() : ""); - inOrderDTO.setDetails(iInOrderDetailService.list(Wrappers.lambdaQuery(InOrderDetail.class).eq(InOrderDetail::getOrderId, inOrderDTO.getId()))); + if (detail != null) { + detail.setInUserName(detail.getInUserId() != null ? UserCache.getUser(detail.getInUserId()).getRealName() : ""); + detail.setApproveUserName(detail.getApproveUserId() != null ? UserCache.getUser(detail.getApproveUserId()).getRealName() : ""); + detail.setApplyUserName(detail.getApplyUserId() != null ? UserCache.getUser(detail.getApplyUserId()).getRealName() : ""); + detail.setDetails(iInOrderDetailService.list(Wrappers.lambdaQuery(InOrderDetail.class).eq(InOrderDetail::getOrderId, detail.getId()))); } - return R.data(inOrderDTO); + return R.data(detail); } /** @@ -103,12 +83,18 @@ public class InOrderController extends BladeController { @ApiOperation(value = "分页", notes = "传入inOrder") public R> list(InOrderDTO inOrder, Query query) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(InOrder.class); + wrapper.orderByDesc(InOrder::getCreateTime); IPage pages = inOrderService.page(Condition.getPage(query), wrapper); List records = pages.getRecords(); - for (InOrder record : records) { - record.setInUserName(record.getInUserId() != null ? UserCache.getUser(record.getInUserId()).getRealName() : ""); - record.setApproveUserName(record.getApproveUserId() != null ? UserCache.getUser(record.getApproveUserId()).getRealName() : ""); - record.setApplyUserName(record.getApplyUserId() != null ? UserCache.getUser(record.getApplyUserId()).getRealName() : ""); + if (CollectionUtil.isNotEmpty(records)) { + List ids = records.stream().map(InOrder::getId).collect(Collectors.toList()); + List details = iInOrderDetailService.list(Wrappers.lambdaQuery(InOrderDetail.class).in(InOrderDetail::getOrderId, ids)); + for (InOrder record : records) { + record.setInUserName(record.getInUserId() != null ? UserCache.getUser(record.getInUserId()).getRealName() : ""); + record.setApproveUserName(record.getApproveUserId() != null ? UserCache.getUser(record.getApproveUserId()).getRealName() : ""); + record.setApplyUserName(record.getApplyUserId() != null ? UserCache.getUser(record.getApplyUserId()).getRealName() : ""); + record.setDetails(details.stream().filter(inOrderDetail -> inOrderDetail.getOrderId().equals(record.getId())).collect(Collectors.toList())); + } } return R.data(pages); } diff --git a/src/main/java/org/springblade/modules/capital/dto/InOrderDTO.java b/src/main/java/org/springblade/modules/capital/dto/InOrderDTO.java index 6c3a57f..6df4908 100644 --- a/src/main/java/org/springblade/modules/capital/dto/InOrderDTO.java +++ b/src/main/java/org/springblade/modules/capital/dto/InOrderDTO.java @@ -33,5 +33,5 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) public class InOrderDTO extends InOrder { private static final long serialVersionUID = 1L; - private List details; + } diff --git a/src/main/java/org/springblade/modules/capital/entity/Apply.java b/src/main/java/org/springblade/modules/capital/entity/Apply.java index 4a20a0e..6a490df 100644 --- a/src/main/java/org/springblade/modules/capital/entity/Apply.java +++ b/src/main/java/org/springblade/modules/capital/entity/Apply.java @@ -7,6 +7,8 @@ import lombok.Data; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.Date; +import java.util.List; + import lombok.EqualsAndHashCode; import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.tenant.mp.TenantEntity; @@ -110,4 +112,7 @@ public class Apply extends BaseEntity { private Integer isUpdate; private Integer isReturn; + + @TableField(exist = false) + List details; } diff --git a/src/main/java/org/springblade/modules/capital/entity/InOrder.java b/src/main/java/org/springblade/modules/capital/entity/InOrder.java index a3a509b..6238a59 100644 --- a/src/main/java/org/springblade/modules/capital/entity/InOrder.java +++ b/src/main/java/org/springblade/modules/capital/entity/InOrder.java @@ -7,6 +7,8 @@ import lombok.Data; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.Date; +import java.util.List; + import lombok.EqualsAndHashCode; import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.tenant.mp.TenantEntity; @@ -92,4 +94,7 @@ public class InOrder extends BaseEntity { @ApiModelProperty(value = "") private String remark; + @TableField(exist = false) + private List details; + } diff --git a/src/main/java/org/springblade/modules/capital/vo/ApplyVO.java b/src/main/java/org/springblade/modules/capital/vo/ApplyVO.java index 9d2ba19..1dc9a4a 100644 --- a/src/main/java/org/springblade/modules/capital/vo/ApplyVO.java +++ b/src/main/java/org/springblade/modules/capital/vo/ApplyVO.java @@ -34,5 +34,5 @@ import java.util.List; public class ApplyVO extends Apply { private static final long serialVersionUID = 1L; - List details; + } diff --git a/src/main/java/org/springblade/modules/system/controller/DictBizController.java b/src/main/java/org/springblade/modules/system/controller/DictBizController.java index e90202a..073aa20 100644 --- a/src/main/java/org/springblade/modules/system/controller/DictBizController.java +++ b/src/main/java/org/springblade/modules/system/controller/DictBizController.java @@ -1,4 +1,3 @@ - package org.springblade.modules.system.controller; import com.baomidou.mybatisplus.core.metadata.IPage;