From 4c6e611fcce20d6338cb33ef8cd8b421c1b95620 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 2 Jul 2024 00:48:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=B6=85=E6=A0=87=E6=8A=A5=E8=A1=A8=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E4=BA=BA=E5=90=8D=E7=A7=B0=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=20=E4=BF=AE=E5=A4=8D=E6=B6=88?= =?UTF-8?q?=E8=B4=B9=E6=98=8E=E7=BB=86=E6=9F=A5=E8=AF=A2=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JdbcConsumptionDetailRepositoryImpl.java | 84 +++++++++---------- .../service/impl/ManageServiceImpl.java | 14 ++++ 2 files changed, 56 insertions(+), 42 deletions(-) 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 b4f33898..1d4f2c17 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -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.*; /** - * * @Author:nxj * @Date:2024/5/8 9:57 */ @@ -45,20 +41,20 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Override public Page 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 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 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 pageConsumptionDetail(ConsumptionDetailQuery dto) { //数据权限 // List orderIds=baseUtil.getOrderIds(); - List companyCodes =baseUtil.getCompanyCode(); - if (companyCodes==null||companyCodes.isEmpty()) { + List companyCodes = baseUtil.getCompanyCode(); + if (companyCodes == null || companyCodes.isEmpty()) { return PageResult.totalPageNum(0, new ArrayList<>()); } dto.setCompanyCodes(companyCodes); - Page data=new PageImpl<>(Collections.emptyList()); + Page data = new PageImpl<>(Collections.emptyList()); //申请单查询 - if (!dto.getActualOrderNo().isEmpty()){ - List orderNos=jdbcRouteRepository.findByActualOrderNo(dto.getActualOrderNo() + "%"); - if (orderNos.isEmpty()){ - return new PageResult(0,new ArrayList<>()); + if (!dto.getActualOrderNo().isEmpty()) { + List orderNos = jdbcRouteRepository.findByActualOrderNo(dto.getActualOrderNo() + "%"); + if (orderNos.isEmpty()) { + return new PageResult(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 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 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 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 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 flightPageConsumptionDetail(ConsumptionDetailQuery dto){ + private Page 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 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 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 hotelPageConsumptionDetail(ConsumptionDetailQuery dto){ + private Page 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 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 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 carPageConsumptionDetail(ConsumptionDetailQuery dto){ + private Page 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 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 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 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()); 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 ea53f451..1d48b334 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -106,6 +106,19 @@ public class ManageServiceImpl implements ManageService { } dto.setCompanyCods(companyCods); Page page=manageOrderDetailRepository.OrderExceedStandard(dto); + List content = page.getContent(); + Set employees=new HashSet<>(); + for (OrderExceedStandard orderExceedStandard : content) { + employees.add(orderExceedStandard.getEmployeeNo()); + } + List 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 excelList = getOrderExceedStandardExcels(page); return PageResult.totalPageNum(page.getTotalElements(), excelList); } @@ -353,6 +366,7 @@ public class ManageServiceImpl implements ManageService { List excelList = new ArrayList<>(); for (OrderExceedStandard order : orderList) { OrderExceedStandardExcel excelOrder = new OrderExceedStandardExcel(); + try { BeanUtils.copyProperties(order, excelOrder); } catch (Exception e) {