【add】行程单查询功能实现
This commit is contained in:
parent
7a81b68b9b
commit
28113043f4
|
@ -1,11 +1,13 @@
|
||||||
package com.chint.manage.controller;
|
package com.chint.manage.controller;
|
||||||
|
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
import com.chint.manage.entity.dto.StandardQueryDto;
|
import com.chint.infrastructure.util.Result;
|
||||||
|
import com.chint.manage.entity.dto.OrderPageDto;
|
||||||
import com.chint.manage.entity.excel.BaseExcel;
|
import com.chint.manage.entity.excel.BaseExcel;
|
||||||
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
||||||
import com.chint.manage.entity.excel.TrainOrderDetailExcel;
|
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||||
import com.chint.manage.entity.dto.ConsumptionDetailDto;
|
import com.chint.manage.entity.query.OrderPageQuery;
|
||||||
|
import com.chint.manage.entity.query.StandardQuery;
|
||||||
import com.chint.manage.service.ManageService;
|
import com.chint.manage.service.ManageService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -14,7 +16,10 @@ import org.springframework.core.io.InputStreamResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -31,13 +36,13 @@ public class ManageController {
|
||||||
|
|
||||||
@ApiOperation("消费明细查询接口")
|
@ApiOperation("消费明细查询接口")
|
||||||
@PostMapping("/query")
|
@PostMapping("/query")
|
||||||
public PageResult<? extends BaseExcel> query(@RequestBody ConsumptionDetailDto dto){
|
public PageResult<? extends BaseExcel> query(@RequestBody ConsumptionDetailQuery dto){
|
||||||
return manageService.pageConsumptionDetail(dto);
|
return manageService.pageConsumptionDetail(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("消费明细导出接口")
|
@ApiOperation("消费明细导出接口")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public ResponseEntity<Resource> export(@RequestBody ConsumptionDetailDto dto) {
|
public ResponseEntity<Resource> export(@RequestBody ConsumptionDetailQuery dto) {
|
||||||
dto.setPageNum(1);
|
dto.setPageNum(1);
|
||||||
dto.setPageSize(Integer.MAX_VALUE);
|
dto.setPageSize(Integer.MAX_VALUE);
|
||||||
File file = manageService.saveConsumptionDetail(dto);
|
File file = manageService.saveConsumptionDetail(dto);
|
||||||
|
@ -55,13 +60,13 @@ public class ManageController {
|
||||||
|
|
||||||
@ApiOperation("超标报表查询接口")
|
@ApiOperation("超标报表查询接口")
|
||||||
@PostMapping("/standard/query")
|
@PostMapping("/standard/query")
|
||||||
public PageResult<OrderExceedStandardExcel> standardQuery(@RequestBody StandardQueryDto dto){
|
public PageResult<OrderExceedStandardExcel> standardQuery(@RequestBody StandardQuery dto){
|
||||||
return manageService.standardQuery(dto);
|
return manageService.standardQuery(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("超标报表导出接口")
|
@ApiOperation("超标报表导出接口")
|
||||||
@PostMapping("/standard/export")
|
@PostMapping("/standard/export")
|
||||||
public ResponseEntity<Resource> standardExport(@RequestBody StandardQueryDto dto){
|
public ResponseEntity<Resource> standardExport(@RequestBody StandardQuery dto){
|
||||||
dto.setPageNum(1);
|
dto.setPageNum(1);
|
||||||
dto.setPageSize(Integer.MAX_VALUE);
|
dto.setPageSize(Integer.MAX_VALUE);
|
||||||
File file = manageService.standardExport(dto);
|
File file = manageService.standardExport(dto);
|
||||||
|
@ -77,4 +82,10 @@ public class ManageController {
|
||||||
.body(resource);
|
.body(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("行程单查询接口")
|
||||||
|
@PostMapping("/order/pageQuery")
|
||||||
|
public Result<PageResult<OrderPageDto>> orderPageQuery(@RequestBody OrderPageQuery dto){
|
||||||
|
return manageService.orderPageQuery(dto);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.chint.manage.entity.dto;
|
||||||
|
|
||||||
|
import com.chint.application.dtos.response.LocationRes;
|
||||||
|
import com.chint.domain.aggregates.order.ApprovalEvent;
|
||||||
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderPageDto {
|
||||||
|
private Long routeId;
|
||||||
|
//差旅订单单号
|
||||||
|
private String routeOrderNo;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private String userId;
|
||||||
|
private String userName;
|
||||||
|
//差标等级
|
||||||
|
private String standardLevel;
|
||||||
|
//申请说明
|
||||||
|
private String instructions;
|
||||||
|
private String actualOrderNo;
|
||||||
|
private List<ApprovalEvent> approveEvents;
|
||||||
|
|
||||||
|
private String approvalStatus;
|
||||||
|
|
||||||
|
private List<Leg> legItems;
|
||||||
|
|
||||||
|
//差旅订单总价值
|
||||||
|
private List<LocationRes> locationResList;
|
||||||
|
|
||||||
|
public String getApprovalStatus() {
|
||||||
|
if (this.approveEvents != null && !this.approveEvents.isEmpty()) {
|
||||||
|
ApprovalEvent lastApprovalEvent = getLastApprovalEvent();
|
||||||
|
if (lastApprovalEvent != null) {
|
||||||
|
lastApprovalEvent.reloadStatus();
|
||||||
|
this.approvalStatus = lastApprovalEvent.getEventName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return approvalStatus;
|
||||||
|
}
|
||||||
|
private ApprovalEvent getLastApprovalEvent() {
|
||||||
|
return this.approveEvents.isEmpty() ? null : this.approveEvents.get(this.approveEvents.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.chint.manage.entity.dto;
|
package com.chint.manage.entity.query;
|
||||||
|
|
||||||
import com.chint.domain.value_object.BaseQuery;
|
import com.chint.domain.value_object.BaseQuery;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -9,7 +9,7 @@ import lombok.Data;
|
||||||
* @Date:2024/5/8 8:58
|
* @Date:2024/5/8 8:58
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ConsumptionDetailDto extends BaseQuery{
|
public class ConsumptionDetailQuery extends BaseQuery{
|
||||||
/**
|
/**
|
||||||
* 0-火车 1飞机 2酒店 3打车
|
* 0-火车 1飞机 2酒店 3打车
|
||||||
*/
|
*/
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.chint.manage.entity.query;
|
||||||
|
|
||||||
|
import com.chint.domain.value_object.BaseQuery;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderPageQuery extends BaseQuery {
|
||||||
|
private String supplierName;// 申请人
|
||||||
|
private String actualOrderNo; //申请单号
|
||||||
|
private List<String> userIds=new ArrayList<>();
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package com.chint.manage.entity.dto;
|
package com.chint.manage.entity.query;
|
||||||
|
|
||||||
import com.chint.domain.value_object.BaseQuery;
|
import com.chint.domain.value_object.BaseQuery;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class StandardQueryDto extends BaseQuery {
|
public class StandardQuery extends BaseQuery {
|
||||||
private String applicant="";// 申请人
|
private String applicant="";// 申请人
|
||||||
private String companyName=""; // 出差公司
|
private String companyName=""; // 出差公司
|
||||||
private String orderNo=""; //订单号
|
private String orderNo=""; //订单号
|
|
@ -1,15 +1,14 @@
|
||||||
package com.chint.manage.mapper;
|
package com.chint.manage.mapper;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.OrderDetail;
|
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
|
import com.chint.manage.entity.dto.OrderPageDto;
|
||||||
import com.chint.manage.entity.excel.BaseExcel;
|
import com.chint.manage.entity.excel.BaseExcel;
|
||||||
import com.chint.manage.entity.excel.TrainOrderDetailExcel;
|
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||||
import com.chint.manage.entity.dto.ConsumptionDetailDto;
|
import com.chint.manage.entity.query.OrderPageQuery;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
|
|
||||||
public interface JdbcConsumptionDetailRepository {
|
public interface JdbcConsumptionDetailRepository {
|
||||||
Page<OrderDetail> findAllByProductType(String productType, String param2, String param3, Pageable pageable);
|
Page<OrderPageDto> orderPageQueryByDto(OrderPageQuery dto);
|
||||||
|
|
||||||
PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailDto dto);
|
PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto);
|
||||||
}
|
}
|
|
@ -2,12 +2,17 @@ package com.chint.manage.mapper.impl;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.*;
|
import com.chint.domain.aggregates.order.*;
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
|
import com.chint.manage.entity.dto.OrderPageDto;
|
||||||
|
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||||
|
import com.chint.manage.entity.query.OrderPageQuery;
|
||||||
import com.chint.manage.entity.excel.*;
|
import com.chint.manage.entity.excel.*;
|
||||||
import com.chint.manage.entity.dto.ConsumptionDetailDto;
|
|
||||||
import com.chint.manage.mapper.*;
|
import com.chint.manage.mapper.*;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.*;
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -39,30 +44,32 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<OrderDetail> findAllByProductType(String productType, String supplierName, String orderNo, Pageable pageable) {
|
public Page<OrderPageDto> orderPageQueryByDto(OrderPageQuery dto) {
|
||||||
String query = "SELECT * FROM order_detail " +
|
String query = "SELECT * FROM route_order " +
|
||||||
"WHERE product_type = :productType " +
|
"WHERE 1 = 1 " +
|
||||||
"AND (:supplierName IS NULL OR supplier_name = :supplierName) " +
|
"AND (:actualOrderNo IS NULL OR actual_order_no = :actualOrderNo ) ";
|
||||||
"AND (:orderNo IS NULL OR order_no = :orderNo) " +
|
|
||||||
"ORDER BY order_id";
|
if (!dto.getUserIds().isEmpty()) {
|
||||||
|
query+="AND user_id IN (:userIds)";
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("productType", productType);
|
params.put("actualOrderNo", dto.getActualOrderNo());
|
||||||
params.put("supplierName", supplierName);
|
PageRequest pageRequest = PageRequest
|
||||||
params.put("orderNo", orderNo);
|
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("route_id").descending());
|
||||||
params.put("offset", pageable.getOffset());
|
params.put("offset", pageRequest.getOffset());
|
||||||
params.put("limit", pageable.getPageSize());
|
params.put("limit", pageRequest.getPageSize());
|
||||||
|
|
||||||
String pagedQuery = query + " LIMIT :limit OFFSET :offset";
|
String pagedQuery = query + " LIMIT :limit OFFSET :offset";
|
||||||
|
|
||||||
List<OrderDetail> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(OrderDetail.class));
|
List<OrderPageDto> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(OrderPageDto.class));
|
||||||
long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class);
|
long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class);
|
||||||
|
|
||||||
return new PageImpl<>(results, pageable, count);
|
return new PageImpl<>(results, pageRequest, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailDto dto) {
|
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
|
||||||
if (dto.getUserName()==null){
|
if (dto.getUserName()==null){
|
||||||
dto.setUserName("");
|
dto.setUserName("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package com.chint.manage.service;
|
package com.chint.manage.service;
|
||||||
|
|
||||||
|
import com.chint.application.dtos.response.RouteOrderPageRes;
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
import com.chint.manage.entity.dto.ConsumptionDetailDto;
|
import com.chint.infrastructure.util.Result;
|
||||||
import com.chint.manage.entity.dto.StandardQueryDto;
|
import com.chint.manage.entity.dto.OrderPageDto;
|
||||||
|
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||||
|
import com.chint.manage.entity.query.OrderPageQuery;
|
||||||
|
import com.chint.manage.entity.query.StandardQuery;
|
||||||
import com.chint.manage.entity.excel.BaseExcel;
|
import com.chint.manage.entity.excel.BaseExcel;
|
||||||
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
||||||
|
|
||||||
|
@ -15,11 +19,13 @@ import java.io.File;
|
||||||
*/
|
*/
|
||||||
public interface ManageService {
|
public interface ManageService {
|
||||||
|
|
||||||
PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailDto dto);
|
PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto);
|
||||||
|
|
||||||
File saveConsumptionDetail(ConsumptionDetailDto dto);
|
File saveConsumptionDetail(ConsumptionDetailQuery dto);
|
||||||
|
|
||||||
PageResult<OrderExceedStandardExcel> standardQuery(StandardQueryDto dto);
|
PageResult<OrderExceedStandardExcel> standardQuery(StandardQuery dto);
|
||||||
|
|
||||||
File standardExport(StandardQueryDto dto);
|
File standardExport(StandardQuery dto);
|
||||||
|
|
||||||
|
Result<PageResult<OrderPageDto>> orderPageQuery(OrderPageQuery dto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,28 @@
|
||||||
package com.chint.manage.service.impl;
|
package com.chint.manage.service.impl;
|
||||||
|
|
||||||
|
import com.chint.application.dtos.response.LocationRes;
|
||||||
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
|
import com.chint.domain.aggregates.user.User;
|
||||||
|
import com.chint.domain.repository.UserRepository;
|
||||||
|
import com.chint.domain.service.LegDomainService;
|
||||||
|
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
|
import com.chint.infrastructure.util.Result;
|
||||||
import com.chint.manage.entity.OrderExceedStandard;
|
import com.chint.manage.entity.OrderExceedStandard;
|
||||||
import com.chint.manage.entity.dto.ConsumptionDetailDto;
|
import com.chint.manage.entity.dto.OrderPageDto;
|
||||||
import com.chint.manage.entity.dto.StandardQueryDto;
|
|
||||||
import com.chint.manage.entity.excel.BaseExcel;
|
import com.chint.manage.entity.excel.BaseExcel;
|
||||||
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
||||||
import com.chint.manage.entity.excel.TrainOrderDetailExcel;
|
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||||
import com.chint.manage.entity.dto.ConsumptionDetailDto;
|
import com.chint.manage.entity.query.OrderPageQuery;
|
||||||
|
import com.chint.manage.entity.query.StandardQuery;
|
||||||
import com.chint.manage.mapper.JdbcOrderExceedStandardRepository;
|
import com.chint.manage.mapper.JdbcOrderExceedStandardRepository;
|
||||||
import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl;
|
import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl;
|
||||||
import com.chint.manage.service.ManageService;
|
import com.chint.manage.service.ManageService;
|
||||||
import com.chint.manage.util.ExcelUtil;
|
import com.chint.manage.util.ExcelUtil;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -24,6 +30,10 @@ import org.springframework.stereotype.Service;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -36,19 +46,25 @@ public class ManageServiceImpl implements ManageService {
|
||||||
private JdbcConsumptionDetailRepositoryImpl jdbcConsumptionDetailRepository;
|
private JdbcConsumptionDetailRepositoryImpl jdbcConsumptionDetailRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcOrderExceedStandardRepository jdbcOrderExceedStandardRepository;
|
private JdbcOrderExceedStandardRepository jdbcOrderExceedStandardRepository;
|
||||||
|
@Autowired
|
||||||
|
private LegDomainService legDomainService;
|
||||||
|
@Autowired
|
||||||
|
private UserRepository userRepository;
|
||||||
|
@Autowired
|
||||||
|
private JdbcRouteRepository jdbcRouteRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailDto dto) {
|
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
|
||||||
return jdbcConsumptionDetailRepository.pageConsumptionDetail(dto);
|
return jdbcConsumptionDetailRepository.pageConsumptionDetail(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File saveConsumptionDetail(ConsumptionDetailDto dto) {
|
public File saveConsumptionDetail(ConsumptionDetailQuery dto) {
|
||||||
return ExcelUtil.exportReport(jdbcConsumptionDetailRepository.pageConsumptionDetail(dto).getRecords());
|
return ExcelUtil.exportReport(jdbcConsumptionDetailRepository.pageConsumptionDetail(dto).getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OrderExceedStandardExcel> standardQuery(StandardQueryDto dto) {
|
public PageResult<OrderExceedStandardExcel> standardQuery(StandardQuery dto) {
|
||||||
PageRequest pageRequest = PageRequest
|
PageRequest pageRequest = PageRequest
|
||||||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending());
|
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending());
|
||||||
Page<OrderExceedStandard> page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContains(dto.getApplicant(),
|
Page<OrderExceedStandard> page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContains(dto.getApplicant(),
|
||||||
|
@ -62,10 +78,34 @@ public class ManageServiceImpl implements ManageService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File standardExport(StandardQueryDto dto) {
|
public File standardExport(StandardQuery dto) {
|
||||||
return ExcelUtil.exportReport(standardQuery(dto).getRecords());
|
return ExcelUtil.exportReport(standardQuery(dto).getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<PageResult<OrderPageDto>> orderPageQuery(OrderPageQuery dto) {
|
||||||
|
|
||||||
|
Page<OrderPageDto> page= jdbcConsumptionDetailRepository.orderPageQueryByDto(dto);
|
||||||
|
//处理信息
|
||||||
|
List<OrderPageDto> list=page.getContent();
|
||||||
|
//查询行程和审批单信息
|
||||||
|
List<Long> routeIdList=list.stream().map(OrderPageDto::getRouteId).toList();
|
||||||
|
List<RouteOrder> routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIdList);
|
||||||
|
|
||||||
|
List<OrderPageDto> orders = list
|
||||||
|
.stream()
|
||||||
|
.map(routeOrder -> {
|
||||||
|
RouteOrder order=routeOrders.stream().filter(s->s.getRouteId().equals(routeOrder.getRouteId())).toList().get(0);
|
||||||
|
routeOrder.setApproveEvents(order.getApproveEvents());
|
||||||
|
routeOrder.setLegItems(order.getLegItems());
|
||||||
|
legDomainService.queryLocation(routeOrder.getLegItems());
|
||||||
|
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
|
||||||
|
return getRouteOrderPageRes(routeOrder, user);
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
return Result.Success(SUCCESS,PageResult.totalPageNum(page.getTotalElements(), orders));
|
||||||
|
}
|
||||||
|
|
||||||
private static List<OrderExceedStandardExcel> getOrderExceedStandardExcels(Page<OrderExceedStandard> page) {
|
private static List<OrderExceedStandardExcel> getOrderExceedStandardExcels(Page<OrderExceedStandard> page) {
|
||||||
List<OrderExceedStandard> orderList = page.getContent();
|
List<OrderExceedStandard> orderList = page.getContent();
|
||||||
List<OrderExceedStandardExcel> excelList = new ArrayList<>();
|
List<OrderExceedStandardExcel> excelList = new ArrayList<>();
|
||||||
|
@ -80,4 +120,18 @@ public class ManageServiceImpl implements ManageService {
|
||||||
}
|
}
|
||||||
return excelList;
|
return excelList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static OrderPageDto getRouteOrderPageRes(OrderPageDto res, User user) {
|
||||||
|
List<Leg> legItems=res.getLegItems();
|
||||||
|
List<LocationRes> locationRes = legItems
|
||||||
|
.stream()
|
||||||
|
.flatMap(leg -> Stream.of(leg.getOriginLocation(), leg.getDestinationLocation()))
|
||||||
|
.map(LocationRes::copyFrom)
|
||||||
|
.distinct()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
res.setLocationResList(locationRes);
|
||||||
|
res.setUserName(user.getName());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,17 @@ import com.chint.domain.aggregates.order.OrderDetail;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
import com.chint.manage.entity.OrderExceedStandard;
|
import com.chint.manage.entity.OrderExceedStandard;
|
||||||
import com.chint.manage.entity.dto.ConsumptionDetailDto;
|
import com.chint.manage.entity.dto.OrderPageDto;
|
||||||
import com.chint.manage.entity.excel.BaseExcel;
|
import com.chint.manage.entity.excel.BaseExcel;
|
||||||
|
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||||
|
import com.chint.manage.entity.query.OrderPageQuery;
|
||||||
import com.chint.manage.mapper.JdbcOrderExceedStandardRepository;
|
import com.chint.manage.mapper.JdbcOrderExceedStandardRepository;
|
||||||
|
import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl;
|
||||||
import com.chint.manage.service.ManageService;
|
import com.chint.manage.service.ManageService;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@ -22,6 +26,16 @@ public class ManageTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcOrderExceedStandardRepository jdbcOrderExceedStandardRepository;
|
private JdbcOrderExceedStandardRepository jdbcOrderExceedStandardRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcConsumptionDetailRepositoryImpl jdbcConsumptionDetailRepository;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void pageQuery(){
|
||||||
|
OrderPageQuery dto=new OrderPageQuery();
|
||||||
|
Page<OrderPageDto> page= jdbcConsumptionDetailRepository.orderPageQueryByDto(dto);
|
||||||
|
System.out.println(page);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void update(){
|
void update(){
|
||||||
|
@ -47,7 +61,7 @@ public class ManageTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void pageManageService(){
|
void pageManageService(){
|
||||||
ConsumptionDetailDto dto=new ConsumptionDetailDto();
|
ConsumptionDetailQuery dto=new ConsumptionDetailQuery();
|
||||||
dto.setPageNum(1);
|
dto.setPageNum(1);
|
||||||
dto.setPageSize(10);
|
dto.setPageSize(10);
|
||||||
dto.setProductType(0);
|
dto.setProductType(0);
|
||||||
|
|
Loading…
Reference in New Issue