fix:修复后台管理超标报表申请人名称错误的问题, 修复消费明细查询报错的问题

This commit is contained in:
lulz1 2024-07-02 00:48:06 +08:00
parent e2421e2c14
commit 4c6e611fcc
2 changed files with 56 additions and 42 deletions

View File

@ -1,16 +1,14 @@
package com.chint.manage.mapper.impl;
import com.chint.domain.aggregates.order.*;
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
import com.chint.infrastructure.util.PageResult;
import com.chint.manage.entity.dto.ItineraryPageDto;
import com.chint.manage.entity.excel.*;
import com.chint.manage.entity.query.ConsumptionDetailQuery;
import com.chint.manage.entity.query.ItineraryPageQuery;
import com.chint.manage.entity.excel.*;
import com.chint.manage.mapper.*;
import com.chint.manage.mapper.JdbcConsumptionDetailRepository;
import com.chint.manage.util.BaseUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
@ -21,12 +19,10 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import java.util.*;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.LegConstant.*;
/**
*
* @Authornxj
* @Date2024/5/8 9:57
*/
@ -45,20 +41,20 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
@Override
public Page<ItineraryPageDto> itineraryPageQueryByDto(ItineraryPageQuery dto) {
String query ="LEFT JOIN route_order_extension_field roef ON roef.route_id=ro.route_id "
String query = "LEFT JOIN route_order_extension_field roef ON roef.route_id=ro.route_id "
+ "WHERE actual_order_no IS NOT NULL ";
if (!dto.getCompanyCodes().isEmpty()) {
query+="AND roef.company_code IN (:companyCodes) ";
query += "AND roef.company_code IN (:companyCodes) ";
}
if (!dto.getUserIds().isEmpty()) {
query+="AND ro.user_id IN (:userIds) ";
query += "AND ro.user_id IN (:userIds) ";
}
if (!dto.getActualOrderNo().isEmpty()) {
dto.setActualOrderNo(dto.getActualOrderNo()+"%");
query+="AND ro.actual_order_no LIKE (:actualOrderNo) ";
dto.setActualOrderNo(dto.getActualOrderNo() + "%");
query += "AND ro.actual_order_no LIKE (:actualOrderNo) ";
}
Map<String, Object> params = new HashMap<>();
@ -70,10 +66,10 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
params.put("offset", pageRequest.getOffset());
params.put("limit", pageRequest.getPageSize());
String pagedQuery ="SELECT * FROM route_order ro "+ query + " LIMIT :limit OFFSET :offset";
String pagedQuery = "SELECT * FROM route_order ro " + query + " LIMIT :limit OFFSET :offset";
List<ItineraryPageDto> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(ItineraryPageDto.class));
String countQuery="SELECT COUNT(*) FROM route_order ro "+query;
String countQuery = "SELECT COUNT(*) FROM route_order ro " + query;
long count = jdbcTemplate.queryForObject(countQuery, params, Long.class);
return new PageImpl<>(results, pageRequest, count);
@ -83,35 +79,35 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
//数据权限
// List<Long> orderIds=baseUtil.getOrderIds();
List<String> companyCodes =baseUtil.getCompanyCode();
if (companyCodes==null||companyCodes.isEmpty()) {
List<String> companyCodes = baseUtil.getCompanyCode();
if (companyCodes == null || companyCodes.isEmpty()) {
return PageResult.totalPageNum(0, new ArrayList<>());
}
dto.setCompanyCodes(companyCodes);
Page<? extends BaseExcel> data=new PageImpl<>(Collections.emptyList());
Page<? extends BaseExcel> data = new PageImpl<>(Collections.emptyList());
//申请单查询
if (!dto.getActualOrderNo().isEmpty()){
List<String> orderNos=jdbcRouteRepository.findByActualOrderNo(dto.getActualOrderNo() + "%");
if (orderNos.isEmpty()){
return new PageResult<BaseExcel>(0,new ArrayList<>());
if (!dto.getActualOrderNo().isEmpty()) {
List<String> orderNos = jdbcRouteRepository.findByActualOrderNo(dto.getActualOrderNo() + "%");
if (orderNos.isEmpty()) {
return new PageResult<BaseExcel>(0, new ArrayList<>());
}
dto.setOrderNos(orderNos);
}
switch (dto.getProductType()) {
case LEG_TYPE_TRAIN -> data=trainPageConsumptionDetail(dto);
case LEG_TYPE_AIRPLANE -> data=flightPageConsumptionDetail(dto);
case LEG_TYPE_HOTEL -> data=hotelPageConsumptionDetail(dto);
case LEG_TYPE_TAXI -> data=carPageConsumptionDetail(dto);
case LEG_TYPE_TRAIN -> data = trainPageConsumptionDetail(dto);
case LEG_TYPE_AIRPLANE -> data = flightPageConsumptionDetail(dto);
case LEG_TYPE_HOTEL -> data = hotelPageConsumptionDetail(dto);
case LEG_TYPE_TAXI -> data = carPageConsumptionDetail(dto);
}
return PageResult.totalPageNum(data.getTotalElements(), data.getContent());
}
private Page<TrainOrderDetailExcel> trainPageConsumptionDetail(ConsumptionDetailQuery dto){
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
private Page<TrainOrderDetailExcel> trainPageConsumptionDetail(ConsumptionDetailQuery dto) {
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id " +
"WHERE 1=1 ";
Map<String, Object> params = new HashMap<>();
@ -119,7 +115,7 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending());
query = getString(dto, query, params, pageRequest);
String pagedQuery ="SELECT * FROM train_order_detail tod "
String pagedQuery = "SELECT * FROM train_order_detail tod "
+ query + " LIMIT :limit OFFSET :offset";
List<TrainOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(TrainOrderDetailExcel.class));
@ -128,9 +124,9 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
return new PageImpl<>(results, pageRequest, count);
}
private Page<FlightOrderDetailExcel> flightPageConsumptionDetail(ConsumptionDetailQuery dto){
private Page<FlightOrderDetailExcel> flightPageConsumptionDetail(ConsumptionDetailQuery dto) {
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id " +
"WHERE 1=1 ";
Map<String, Object> params = new HashMap<>();
@ -138,7 +134,7 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending());
query = getString(dto, query, params, pageRequest);
String pagedQuery ="SELECT * FROM flight_order_detail tod "
String pagedQuery = "SELECT * FROM flight_order_detail tod "
+ query + " LIMIT :limit OFFSET :offset";
List<FlightOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(FlightOrderDetailExcel.class));
@ -147,9 +143,9 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
return new PageImpl<>(results, pageRequest, count);
}
private Page<HotelOrderDetailExcel> hotelPageConsumptionDetail(ConsumptionDetailQuery dto){
private Page<HotelOrderDetailExcel> hotelPageConsumptionDetail(ConsumptionDetailQuery dto) {
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id " +
"WHERE 1=1 ";
Map<String, Object> params = new HashMap<>();
@ -157,7 +153,7 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending());
query = getString(dto, query, params, pageRequest);
String pagedQuery ="SELECT * FROM hotel_order_detail tod "
String pagedQuery = "SELECT * FROM hotel_order_detail tod "
+ query + " LIMIT :limit OFFSET :offset";
List<HotelOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(HotelOrderDetailExcel.class));
@ -166,9 +162,9 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
return new PageImpl<>(results, pageRequest, count);
}
private Page<CarOrderDetailExcel> carPageConsumptionDetail(ConsumptionDetailQuery dto){
private Page<CarOrderDetailExcel> carPageConsumptionDetail(ConsumptionDetailQuery dto) {
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id " +
"WHERE 1=1 ";
Map<String, Object> params = new HashMap<>();
@ -177,7 +173,7 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
query = getString(dto, query, params, pageRequest);
String pagedQuery ="SELECT * FROM car_order_detail tod "
String pagedQuery = "SELECT * FROM car_order_detail tod "
+ query + " LIMIT :limit OFFSET :offset";
List<CarOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(CarOrderDetailExcel.class));
@ -187,17 +183,21 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
}
private static String getString(ConsumptionDetailQuery dto, String query, Map<String, Object> params, PageRequest pageRequest) {
if (!dto.getUserName().isEmpty()) {
dto.setUserName(dto.getUserName()+"%");
query +="AND tod.user_name LIKE (:userName)";
if (!dto.getUserName().isEmpty() && LEG_TYPE_HOTEL != dto.getProductType()) {
dto.setUserName(dto.getUserName() + "%");
query += "AND tod.user_name LIKE (:userName)";
}
if (!dto.getUserName().isEmpty() && dto.getProductType().equals(LEG_TYPE_HOTEL)) {
dto.setUserName(dto.getUserName() + "%");
query += "AND tod.booking_name LIKE (:userName)";
}
if (!dto.getCompanyCodes().isEmpty()) {
query +="AND roef.company_code IN (:companyCodes)";
query += "AND roef.company_code IN (:companyCodes)";
}
if (!dto.getOrderNos().isEmpty()) {
query +="AND tod.order_no IN (:orderNos)";
query += "AND tod.order_no IN (:orderNos)";
}
params.put("userName", dto.getUserName());

View File

@ -106,6 +106,19 @@ public class ManageServiceImpl implements ManageService {
}
dto.setCompanyCods(companyCods);
Page<OrderExceedStandard> page=manageOrderDetailRepository.OrderExceedStandard(dto);
List<OrderExceedStandard> content = page.getContent();
Set<String> employees=new HashSet<>();
for (OrderExceedStandard orderExceedStandard : content) {
employees.add(orderExceedStandard.getEmployeeNo());
}
List<UserBasic> allByEmployeeNoIn = userBasicRepository.
findAllByEmployeeNoIn(employees.stream().toList());
for (OrderExceedStandard orderExceedStandard : content) {
for (UserBasic userBasic : allByEmployeeNoIn) {
if(userBasic.getEmployeeNo().equals(orderExceedStandard.getEmployeeNo())){}
orderExceedStandard.setApplicant(userBasic.getName());
}
}
List<OrderExceedStandardExcel> excelList = getOrderExceedStandardExcels(page);
return PageResult.totalPageNum(page.getTotalElements(), excelList);
}
@ -353,6 +366,7 @@ public class ManageServiceImpl implements ManageService {
List<OrderExceedStandardExcel> excelList = new ArrayList<>();
for (OrderExceedStandard order : orderList) {
OrderExceedStandardExcel excelOrder = new OrderExceedStandardExcel();
try {
BeanUtils.copyProperties(order, excelOrder);
} catch (Exception e) {