From 4fbcbd779a872ecf154df3e85e0b4f6591cc417a Mon Sep 17 00:00:00 2001 From: nixj Date: Sat, 11 May 2024 09:38:40 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90add=E3=80=91=E8=B6=85=E6=A0=87?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/service/BPMOrderDomainService.java | 12 +++--- .../manage/controller/ManageController.java | 9 ++++ .../manage/entity/dto/StandardQueryDto.java | 12 ++++++ .../excel/OrderExceedStandardExcel.java | 34 +++++++++++++++ .../JdbcOrderExceedStandardRepository.java | 4 ++ .../JdbcConsumptionDetailRepositoryImpl.java | 2 +- .../chint/manage/service/ManageService.java | 7 ++- .../service/impl/ManageServiceImpl.java | 43 +++++++++++++++++++ 8 files changed, 114 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/chint/manage/entity/dto/StandardQueryDto.java create mode 100644 src/main/java/com/chint/manage/entity/excel/OrderExceedStandardExcel.java diff --git a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java index 82388995..a0181fc4 100644 --- a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java +++ b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java @@ -173,12 +173,12 @@ public class BPMOrderDomainService { private String getProductTypeName(Integer type){ String typeName = null; switch (type){ - case LEG_TYPE_TRAIN -> typeName="火车"; - case LEG_TYPE_AIRPLANE -> typeName="飞机"; - case LEG_TYPE_HOTEL -> typeName="酒店"; - case LEG_TYPE_TAXI -> typeName="用车"; - case LEG_TYPE_OTHER -> typeName="其他"; - default -> typeName="未分类"; + case LEG_TYPE_TRAIN -> typeName=LEG_TYPE_TRAIN_NAME; + case LEG_TYPE_AIRPLANE -> typeName=LEG_TYPE_AIRPLANE_NAME; + case LEG_TYPE_HOTEL -> typeName=LEG_TYPE_HOTEL_NAME; + case LEG_TYPE_TAXI -> typeName=LEG_TYPE_TAXI_NAME; + case LEG_TYPE_OTHER -> typeName=LEG_TYPE_OTHER_NAME; + default -> typeName=LEG_TYPE_OTHER_NAME+type; } return typeName; } diff --git a/src/main/java/com/chint/manage/controller/ManageController.java b/src/main/java/com/chint/manage/controller/ManageController.java index 85e88852..9a1b923b 100644 --- a/src/main/java/com/chint/manage/controller/ManageController.java +++ b/src/main/java/com/chint/manage/controller/ManageController.java @@ -1,7 +1,9 @@ package com.chint.manage.controller; import com.chint.infrastructure.util.PageResult; +import com.chint.manage.entity.dto.StandardQueryDto; import com.chint.manage.entity.excel.BaseExcel; +import com.chint.manage.entity.excel.OrderExceedStandardExcel; import com.chint.manage.entity.excel.TrainOrderDetailExcel; import com.chint.manage.entity.dto.ConsumptionDetailDto; import com.chint.manage.service.ManageService; @@ -50,4 +52,11 @@ public class ManageController { .contentType(MediaType.parseMediaType("application/octet-stream")) .body(resource); } + + @ApiOperation("超标查询接口") + @PostMapping("/standard/query") + public PageResult standardQuery(@RequestBody StandardQueryDto dto){ + return manageService.standardQuery(dto); + } + } diff --git a/src/main/java/com/chint/manage/entity/dto/StandardQueryDto.java b/src/main/java/com/chint/manage/entity/dto/StandardQueryDto.java new file mode 100644 index 00000000..f4a2ce34 --- /dev/null +++ b/src/main/java/com/chint/manage/entity/dto/StandardQueryDto.java @@ -0,0 +1,12 @@ +package com.chint.manage.entity.dto; + +import com.chint.domain.value_object.BaseQuery; +import lombok.Data; + +@Data +public class StandardQueryDto extends BaseQuery { + private String applicant="";// 申请人 + private String companyName=""; // 出差公司 + private String orderNo=""; //订单号 + private String actualOrderNo=""; //申请单号 +} diff --git a/src/main/java/com/chint/manage/entity/excel/OrderExceedStandardExcel.java b/src/main/java/com/chint/manage/entity/excel/OrderExceedStandardExcel.java new file mode 100644 index 00000000..a1ac57b5 --- /dev/null +++ b/src/main/java/com/chint/manage/entity/excel/OrderExceedStandardExcel.java @@ -0,0 +1,34 @@ +package com.chint.manage.entity.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * + * @Author:nxj + * @Date:2024/5/11 8:51 + */ +@Data +public class OrderExceedStandardExcel { + @ExcelProperty("订单号") + private String orderNo; + @ExcelProperty("出差人") + private String applicant; + @ExcelProperty("出差人公司") + private String companyName; + @ExcelProperty("出差部门") + private String deptName; + @ExcelProperty("超标类型") + private String standardType; + @ExcelProperty("来源") + private String sourceName; + @ExcelProperty("原因") + private String reason; + @ExcelProperty("审批情况") + private String approvalStatus; + @ExcelProperty("超标金额") + private BigDecimal standardAmount; + +} diff --git a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java index 59bfe27c..69a4d6da 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java @@ -2,6 +2,8 @@ package com.chint.manage.mapper; import com.chint.manage.entity.OrderExceedStandard; import io.lettuce.core.dynamic.annotation.Param; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jdbc.repository.query.Modifying; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; @@ -13,4 +15,6 @@ public interface JdbcOrderExceedStandardRepository extends CrudRepository findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContains(String applicant, String company, String actualOrderNo, String orderNo, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java index 605018c6..5bd2dca5 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -70,7 +70,7 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai dto.setOrderNo(""); } PageRequest pageRequest = PageRequest - .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id")); + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); Page data=new PageImpl<>(Collections.emptyList()); switch (dto.getProductType()) { case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getUserName(),dto.getOrderNo(),pageRequest)); diff --git a/src/main/java/com/chint/manage/service/ManageService.java b/src/main/java/com/chint/manage/service/ManageService.java index a484f99f..e61e2979 100644 --- a/src/main/java/com/chint/manage/service/ManageService.java +++ b/src/main/java/com/chint/manage/service/ManageService.java @@ -1,9 +1,10 @@ package com.chint.manage.service; import com.chint.infrastructure.util.PageResult; -import com.chint.manage.entity.excel.BaseExcel; -import com.chint.manage.entity.excel.TrainOrderDetailExcel; import com.chint.manage.entity.dto.ConsumptionDetailDto; +import com.chint.manage.entity.dto.StandardQueryDto; +import com.chint.manage.entity.excel.BaseExcel; +import com.chint.manage.entity.excel.OrderExceedStandardExcel; import java.io.File; @@ -17,4 +18,6 @@ public interface ManageService { PageResult pageConsumptionDetail(ConsumptionDetailDto dto); File saveConsumptionDetail(ConsumptionDetailDto dto); + + PageResult standardQuery(StandardQueryDto dto); } diff --git a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java index c6237833..9e0eedb7 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -1,17 +1,29 @@ package com.chint.manage.service.impl; import com.chint.infrastructure.util.PageResult; +import com.chint.manage.entity.OrderExceedStandard; +import com.chint.manage.entity.dto.StandardQueryDto; import com.chint.manage.entity.excel.BaseExcel; +import com.chint.manage.entity.excel.OrderExceedStandardExcel; import com.chint.manage.entity.excel.TrainOrderDetailExcel; import com.chint.manage.entity.dto.ConsumptionDetailDto; +import com.chint.manage.mapper.JdbcOrderExceedStandardRepository; import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl; import com.chint.manage.service.ManageService; import com.chint.manage.util.ExcelUtil; import org.apache.poi.ss.formula.functions.T; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +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.stereotype.Service; import java.io.File; +import java.util.ArrayList; +import java.util.List; /** * @@ -22,6 +34,8 @@ import java.io.File; public class ManageServiceImpl implements ManageService { @Autowired private JdbcConsumptionDetailRepositoryImpl jdbcConsumptionDetailRepository; + @Autowired + private JdbcOrderExceedStandardRepository jdbcOrderExceedStandardRepository; @Override public PageResult pageConsumptionDetail(ConsumptionDetailDto dto) { @@ -32,4 +46,33 @@ public class ManageServiceImpl implements ManageService { public File saveConsumptionDetail(ConsumptionDetailDto dto) { return ExcelUtil.exportReport(jdbcConsumptionDetailRepository.pageConsumptionDetail(dto).getRecords()); } + + @Override + public PageResult standardQuery(StandardQueryDto dto) { + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); + Page page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContains(dto.getApplicant(), + dto.getCompanyName(), + dto.getActualOrderNo(), + dto.getOrderNo(), + pageRequest); + + List excelList = getOrderExceedStandardExcels(page); + return PageResult.totalPageNum(page.getTotalElements(), excelList); + } + + private static List getOrderExceedStandardExcels(Page page) { + List orderList = page.getContent(); + List excelList = new ArrayList<>(); + for (OrderExceedStandard order : orderList) { + OrderExceedStandardExcel excelOrder = new OrderExceedStandardExcel(); + try { + BeanUtils.copyProperties(order, excelOrder); + } catch (Exception e) { + e.printStackTrace(); + } + excelList.add(excelOrder); + } + return excelList; + } }