申领列表、采购列表接口返回详情

main
litao 1 year ago
parent 5ce73992b3
commit dfcfbe5c4b
  1. 16
      src/main/java/org/springblade/modules/capital/controller/ApplyController.java
  2. 50
      src/main/java/org/springblade/modules/capital/controller/InOrderController.java
  3. 2
      src/main/java/org/springblade/modules/capital/dto/InOrderDTO.java
  4. 5
      src/main/java/org/springblade/modules/capital/entity/Apply.java
  5. 5
      src/main/java/org/springblade/modules/capital/entity/InOrder.java
  6. 2
      src/main/java/org/springblade/modules/capital/vo/ApplyVO.java
  7. 1
      src/main/java/org/springblade/modules/system/controller/DictBizController.java

@ -68,11 +68,10 @@ public class ApplyController extends BladeController {
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入apply")
public R<ApplyVO> detail(Apply apply) {
public R<Apply> 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<IPage<Apply>> list(ApplyDTO apply, Query query) {
LambdaQueryWrapper<Apply> wrapper = Wrappers.lambdaQuery(Apply.class);
wrapper.orderByDesc(Apply::getCreateTime);
IPage<Apply> pages = applyService.page(Condition.getPage(query), wrapper);
List<Apply> records = pages.getRecords();
if (CollectionUtil.isNotEmpty(records)) {
List<Long> ids = records.stream().map(Apply::getId).collect(Collectors.toList());
List<ApplyDetail> 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);
}

@ -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<InOrderDTO> detail(InOrder inOrder) {
public R<InOrder> 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<IPage<InOrder>> list(InOrderDTO inOrder, Query query) {
LambdaQueryWrapper<InOrder> wrapper = Wrappers.lambdaQuery(InOrder.class);
wrapper.orderByDesc(InOrder::getCreateTime);
IPage<InOrder> pages = inOrderService.page(Condition.getPage(query), wrapper);
List<InOrder> 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<Long> ids = records.stream().map(InOrder::getId).collect(Collectors.toList());
List<InOrderDetail> 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);
}

@ -33,5 +33,5 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
public class InOrderDTO extends InOrder {
private static final long serialVersionUID = 1L;
private List<InOrderDetail> details;
}

@ -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<ApplyDetail> details;
}

@ -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<InOrderDetail> details;
}

@ -34,5 +34,5 @@ import java.util.List;
public class ApplyVO extends Apply {
private static final long serialVersionUID = 1L;
List<ApplyDetail> details;
}

@ -1,4 +1,3 @@
package org.springblade.modules.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;

Loading…
Cancel
Save