From 34c40ce2e68605729486608e4788c1b63eed1cf4 Mon Sep 17 00:00:00 2001 From: nixj Date: Wed, 26 Jun 2024 10:26:44 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E3=80=90update=E3=80=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=9A=82=E6=97=B6=E5=8E=BB=E9=99=A4=EF=BC=8C?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E5=90=8E=E7=BB=AD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/service/BPMOrderDomainService.java | 4 +- .../jdbc/JdbcOrderDetailRepository.java | 21 ++- .../chint/manage/entity/RouteOrderBasic.java | 92 ++++++++++ .../entity/query/ConsumptionDetailQuery.java | 5 + .../mapper/JdbcCarOrderDetailRepository.java | 6 - .../JdbcFlightOrderDetailRepository.java | 6 - .../JdbcHotelOrderDetailRepository.java | 6 - .../JdbcOrderExceedStandardRepository.java | 6 +- .../mapper/JdbcRouteOrderBasicRepository.java | 20 +++ ...dbcRouteOrderExtensionFieldRepository.java | 6 +- .../JdbcTrainOrderDetailRepository.java | 6 - .../JdbcConsumptionDetailRepositoryImpl.java | 170 +++++++++--------- .../service/impl/ManageServiceImpl.java | 35 ++-- .../java/com/chint/manage/util/BaseUtil.java | 6 +- .../manage/util/DataJdbcCreatorUtil.java | 4 +- 15 files changed, 259 insertions(+), 134 deletions(-) create mode 100644 src/main/java/com/chint/manage/entity/RouteOrderBasic.java create mode 100644 src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java diff --git a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java index aecf4e4a..be80a60b 100644 --- a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java +++ b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java @@ -122,7 +122,7 @@ public class BPMOrderDomainService { //保存超标报表 OrderExceedStandard orderExceedStandard = OrderExceedStandard.builder() .applicant(orderDetail.getSupplierName()) - .companyName(user.getCompanyName()) + .companyName(user.getDepartmentInfo().getCompanyName()) .deptName(user.getDepartmentInfo().getDepartmentNameOne()) .standardType(getProductTypeName(command.getProductType())) .sourceName(anExceedStandardDto.getSourceSystem()) @@ -161,7 +161,7 @@ public class BPMOrderDomainService { //保存超标报表 OrderExceedStandard orderExceedStandard = OrderExceedStandard.builder() .applicant(orderDetail.getSupplierName()) - .companyName(user.getCompanyName()) + .companyName(user.getDepartmentInfo().getCompanyName()) .deptName(user.getDepartmentInfo().getDepartmentNameOne()) .standardType(getProductTypeName(command.getProductType())) .sourceName(exceedStandardDto.getOrderSource()) diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java index 1889fff8..cb14e6e1 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -6,6 +6,7 @@ import com.chint.manage.entity.query.OrderPageQuery; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; 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; import org.springframework.data.repository.query.Param; @@ -33,11 +34,24 @@ public interface JdbcOrderDetailRepository extends CrudRepository findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTime, LocalDateTime createTime2, Integer productType, String orderNo); List findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); - List findAllByRouteIdIn(List routeIds); + @Query("SELECT order_no FROM order_detail " + + "WHERE route_id IN (:#{#routeIds})") + List findAllOrderNo(@Param("routeIds") List routeIds); + + @Query("SELECT order_id FROM order_detail " + + "WHERE route_id IN (:#{#routeIds})") + List findAllOrderId(@Param("routeIds") List routeIds); + + @Query("SELECT order_no FROM order_detail " ) + List findAllOrderNo(); + + @Query("SELECT order_id FROM order_detail ") + List findAllOrderId(); @Query("SELECT * FROM order_detail " + - "WHERE route_id IN (:#{#dto.routeIds}) " + +// "WHERE route_id IN (:#{#dto.routeIds}) " + + "WHERE 1=1 " + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " + "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) " + @@ -47,7 +61,8 @@ public interface JdbcOrderDetailRepository extends CrudRepository listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest")PageRequest pageRequest); @Query("SELECT COUNT(*) FROM order_detail " + - "WHERE route_id IN (:#{#dto.routeIds}) " + +// "WHERE route_id IN (:#{#dto.routeIds}) " + + "WHERE 1=1 " + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " + "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+ diff --git a/src/main/java/com/chint/manage/entity/RouteOrderBasic.java b/src/main/java/com/chint/manage/entity/RouteOrderBasic.java new file mode 100644 index 00000000..06b7c382 --- /dev/null +++ b/src/main/java/com/chint/manage/entity/RouteOrderBasic.java @@ -0,0 +1,92 @@ +package com.chint.manage.entity; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; +import java.io.Serial; +import java.io.Serializable; + +/** + * + * @author xx RouteOrderBasic.java + * + **/ +@Data +@Table("route_order") +public class RouteOrderBasic implements Serializable { +@Serial +private static final long serialVersionUID = 1L; + @Id + private Long routeId; + + /****/ + private java.util.Date bookingTime; + + /****/ + private String userId; + + /****/ + private java.util.Date createTime; + + /****/ + private String createUser; + + /****/ + private Integer sort; + + /****/ + private Integer status; + + /****/ + private java.util.Date updateTime; + + /****/ + private String updateUser; + + /****/ + private String fakeOrderNo; + + /****/ + private String actualOrderNo; + + /**差旅订单号**/ + private String routeOrderNo; + + /****/ + private String supplierName; + + /****/ + private String accountCompany; + + /****/ + private String sysCode; + + /****/ + private String instructions; + + /****/ + private String standardLevel; + + /****/ + private String creator; + + /****/ + private String accountCompanyName; + + /**入账公司64位编码**/ + private String accountCompanyCode; + + /****/ + private String projectName; + + /****/ + private String costCenter; + + /****/ + private java.util.Date startTime; + + /****/ + private java.util.Date endTime; + + +} diff --git a/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java b/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java index 0e6f94f0..c57ff26a 100644 --- a/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java +++ b/src/main/java/com/chint/manage/entity/query/ConsumptionDetailQuery.java @@ -4,6 +4,9 @@ import com.chint.domain.value_object.BaseQuery; import com.chint.manage.util.BaseUtil; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * * @Author:nxj @@ -17,6 +20,8 @@ public class ConsumptionDetailQuery extends BaseQuery{ private Integer productType; private String userName=""; private String actualOrderNo=""; //申请单号 + private List orderIds=new ArrayList<>(); + private List orderNos=new ArrayList<>(); public String getActualOrderNo() { return BaseUtil.extractAfterDash(actualOrderNo); diff --git a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java index 9ce9e78e..0674ed1b 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcCarOrderDetailRepository.java @@ -13,11 +13,5 @@ import java.util.List; @Repository public interface JdbcCarOrderDetailRepository extends CrudRepository { - Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds, Pageable pageable); - - Page findAllByUserNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java index b60bd6e6..b34528d2 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcFlightOrderDetailRepository.java @@ -12,11 +12,5 @@ import java.util.List; @Repository public interface JdbcFlightOrderDetailRepository extends CrudRepository { - Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds, Pageable pageable); - - Page findAllByUserNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java index da1fe8db..7899649c 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcHotelOrderDetailRepository.java @@ -14,11 +14,5 @@ import java.util.List; @Repository public interface JdbcHotelOrderDetailRepository extends CrudRepository { - Page findAllByBookingNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByBookingNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds, Pageable pageable); - - Page findAllByBookingNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java index b7cdff16..8de1f15a 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java @@ -2,6 +2,7 @@ package com.chint.manage.mapper; import com.chint.manage.entity.OrderExceedStandard; import io.lettuce.core.dynamic.annotation.Param; +import org.jetbrains.annotations.NotNull; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jdbc.repository.query.Modifying; @@ -18,5 +19,8 @@ public interface JdbcOrderExceedStandardRepository extends CrudRepository findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List orderNos, Pageable pageable); + List findAll(); + +// Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List orderNos, Pageable pageable); +Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(String applicant, String company, String actualOrderNo, String orderNo, Pageable pageable); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java new file mode 100644 index 00000000..c10a3180 --- /dev/null +++ b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java @@ -0,0 +1,20 @@ +package com.chint.manage.mapper; +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.manage.entity.RouteOrderBasic; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + + +/** + * + * @author xx JdbcRouteOrderBasicRepository数据库操作接口类 + * + **/ +@Repository +public interface JdbcRouteOrderBasicRepository extends CrudRepository { + + List findByRouteIdIn(List routeIds); + +} \ No newline at end of file diff --git a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java index 84d46b78..bf44e6af 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java @@ -1,6 +1,8 @@ package com.chint.manage.mapper; import com.chint.manage.entity.RouteOrderExtensionField; +import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -14,5 +16,7 @@ import java.util.List; @Repository public interface JdbcRouteOrderExtensionFieldRepository extends CrudRepository { - List findByBelongDeptCodeIn(List belongDeptCode); + @Query("SELECT * FROM route_order_extension_field " + + "WHERE belong_dept_code IN (:#{#belongDeptCode})") + List findByCondition(@Param("belongDeptCode") List belongDeptCode); } \ No newline at end of file diff --git a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java index befad4b5..db696b2e 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcTrainOrderDetailRepository.java @@ -11,11 +11,5 @@ import java.util.List; @Repository public interface JdbcTrainOrderDetailRepository extends CrudRepository { - Page findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable); - - Page findAllByUserNameContainsAndOrderNoInAndOrderIdIn(String userName, List orderNo,List orderIds ,Pageable pageable); - - Page findAllByUserNameContainsAndOrderIdIn(String userName,List orderIds, Pageable pageable); - List findAllByOrderIdIn(List orderIds); } 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 9fc13b84..a9556787 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -35,15 +35,6 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Autowired private NamedParameterJdbcTemplate jdbcTemplate; - - @Autowired - private JdbcTrainOrderDetailRepository jdbcTrainOrderDetailRepository; - @Autowired - private JdbcCarOrderDetailRepository jdbcCarOrderDetailRepository; - @Autowired - private JdbcHotelOrderDetailRepository jdbcHotelOrderDetailRepository; - @Autowired - private JdbcFlightOrderDetailRepository jdbcFlightOrderDetailRepository; @Autowired private JdbcRouteRepository jdbcRouteRepository; @Autowired @@ -56,23 +47,22 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai public Page itineraryPageQueryByDto(ItineraryPageQuery dto) { String query = "SELECT * FROM route_order " + "WHERE route_id IN (:routeIds) " - + "AND (:actualOrderNo IS NULL OR actual_order_no = :actualOrderNo ) " + "AND actual_order_no IS NOT NULL "; if (!dto.getUserIds().isEmpty()) { - query+="AND user_id IN (:userIds)"; + query+="AND user_id IN (:userIds) "; + } + + if (!dto.getActualOrderNo().isEmpty()) { + query+="AND actual_order_no = :actualOrderNo "; } Map params = new HashMap<>(); - //设置null - if (dto.getActualOrderNo().isEmpty()){ - dto.setActualOrderNo(null); - } + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); params.put("actualOrderNo", dto.getActualOrderNo()); params.put("userIds", dto.getUserIds()); params.put("routeIds", dto.getRouteIds()); - PageRequest pageRequest = PageRequest - .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("route_id").descending()); params.put("offset", pageRequest.getOffset()); params.put("limit", pageRequest.getPageSize()); @@ -87,13 +77,12 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Override public PageResult pageConsumptionDetail(ConsumptionDetailQuery dto) { //数据权限 - List orderIds=baseUtil.getOrderIds(); - if (orderIds==null||orderIds.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } +// List orderIds=baseUtil.getOrderIds(); +// if (orderIds==null||orderIds.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } - PageRequest pageRequest = PageRequest - .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); + List orderIds=jdbcOrderDetailRepository.findAllOrderId(); Page data=new PageImpl<>(Collections.emptyList()); //申请单查询 if (!dto.getActualOrderNo().isEmpty()){ @@ -101,79 +90,100 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai if (orderNos.isEmpty()){ return new PageResult(0,new ArrayList<>()); } - switch (dto.getProductType()) { - case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderNoInAndOrderIdIn(dto.getUserName(),orderNos,orderIds,pageRequest)); - } - return PageResult.totalPageNum(data.getTotalElements(), data.getContent()); + dto.setOrderNos(orderNos); } switch (dto.getProductType()) { - case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); - case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); - case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); - case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderIdIn(dto.getUserName(),orderIds,pageRequest)); + 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()); } - public Page getOrderTrainRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); - // 遍历 OrderBaseRecord,将其转换为 ConsumptionDetailExcel - for (TrainOrderDetail orderRecord : orderRecords) { - TrainOrderDetailExcel trainOrderDetailExcel = new TrainOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, trainOrderDetailExcel); - trainOrderDetailExcels.add(trainOrderDetailExcel); - } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + + private Page trainPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM train_order_detail " + + "WHERE 1=1 "; + + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(TrainOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); } - public Page getOrderFlightRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); - for (FlightOrderDetail orderRecord : orderRecords) { - FlightOrderDetailExcel flightOrderDetailExcel = new FlightOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, flightOrderDetailExcel); - trainOrderDetailExcels.add(flightOrderDetailExcel); - } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + private Page flightPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM flight_order_detail " + + "WHERE 1=1 "; + + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(FlightOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); } - public Page getOrderHotelRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); + private Page hotelPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM hotel_order_detail " + + "WHERE 1=1 "; - for (HotelOrderDetail orderRecord : orderRecords) { - HotelOrderDetailExcel hotelOrderDetailExcel = new HotelOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, hotelOrderDetailExcel); - List customers=orderRecord.getCustomers(); - String userNames = customers.stream() - .map(HotelOrderDetailCustomer::getUserName) // 获取用户名 - .collect(Collectors.joining(",")); // 用逗号分隔拼接 - hotelOrderDetailExcel.setUserName(userNames); - trainOrderDetailExcels.add(hotelOrderDetailExcel); - } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(HotelOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); } - public Page getOrderCarRecord(Page page) { - List orderRecords = page.getContent(); - List trainOrderDetailExcels = new ArrayList<>(); + private Page carPageConsumptionDetail(ConsumptionDetailQuery dto){ + String query = "SELECT * FROM car_order_detail " + + "WHERE 1=1 "; - // 遍历 OrderBaseRecord,将其转换为 ConsumptionDetailExcel - for (CarOrderDetail orderRecord : orderRecords) { - CarOrderDetailExcel carOrderDetailExcel = new CarOrderDetailExcel(); - BeanUtils.copyProperties(orderRecord, carOrderDetailExcel); - trainOrderDetailExcels.add(carOrderDetailExcel); + Map params = new HashMap<>(); + PageRequest pageRequest = PageRequest + .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending()); + + query = getString(dto, query, params, pageRequest); + + String pagedQuery = query + " LIMIT :limit OFFSET :offset"; + long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class); + List results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(CarOrderDetailExcel.class)); + return new PageImpl<>(results, pageRequest, count); + } + + private static String getString(ConsumptionDetailQuery dto, String query, Map params, PageRequest pageRequest) { + if (!dto.getUserName().isEmpty()) { + dto.setUserName("%"+ dto.getUserName()+"%"); + query +="AND user_name LIKE (:userName)"; } - // 构建一个新的 Page 对象并返回 - return new PageImpl<>(trainOrderDetailExcels, page.getPageable(), page.getTotalElements()); + if (!dto.getOrderIds().isEmpty()) { + query +="AND order_id IN (:orderIds)"; + } + + if (!dto.getOrderNos().isEmpty()) { + query +="AND order_no IN (:orderNos)"; + } + + params.put("userName", dto.getUserName()); + params.put("orderNos", dto.getOrderNos()); + params.put("orderIds", dto.getOrderIds()); + + params.put("offset", pageRequest.getOffset()); + params.put("limit", pageRequest.getPageSize()); + return query; } } 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 a8571bf4..66bc7108 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -98,20 +98,19 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult standardQuery(StandardQuery dto) { //数据权限 - List orderNos=baseUtil.getOrderNos(); - if (orderNos==null||orderNos.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } +// List orderNos=baseUtil.getOrderNos(); +// if (orderNos==null||orderNos.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } PageRequest pageRequest = PageRequest .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); - Page page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndCompanyNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(dto.getApplicant(), + Page page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(dto.getApplicant(), dto.getCompanyName(), dto.getActualOrderNo(), dto.getOrderNo(), - orderNos, +// orderNos, pageRequest); - List excelList = getOrderExceedStandardExcels(page); return PageResult.totalPageNum(page.getTotalElements(), excelList); } @@ -128,10 +127,11 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult itineraryPageQuery(ItineraryPageQuery dto) { //数据权限 - List routeIds=baseUtil.getRouteIds(); - if (routeIds==null||routeIds.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } +// List routeIds=baseUtil.getRouteIds(); +// if (routeIds==null||routeIds.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } +// dto.setRouteIds(routeIds); List users=new ArrayList<>(); if (!dto.getApplicant().isEmpty()){ @@ -140,7 +140,6 @@ public class ManageServiceImpl implements ManageService { return PageResult.totalPageNum(0, new ArrayList<>()); } } - dto.setRouteIds(routeIds); dto.setUserIds(users.stream().map(User::getEmployeeNo).toList()); Page page= jdbcConsumptionDetailRepository.itineraryPageQueryByDto(dto); //处理信息 @@ -180,11 +179,11 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult orderPageQuery(OrderPageQuery dto) { //数据权限 - List dataRouteIds=baseUtil.getRouteIds(); - if (dataRouteIds==null||dataRouteIds.isEmpty()) { - return PageResult.totalPageNum(0, new ArrayList<>()); - } - dto.setRouteIds(dataRouteIds); +// List dataRouteIds=baseUtil.getRouteIds(); +// if (dataRouteIds==null||dataRouteIds.isEmpty()) { +// return PageResult.totalPageNum(0, new ArrayList<>()); +// } +// dto.setRouteIds(dataRouteIds); //预订人 if (!dto.getApplicant().equals("")){ @@ -212,7 +211,7 @@ public class ManageServiceImpl implements ManageService { } //部门 if (dto.getBelongDeptCode() != null && !dto.getBelongDeptCode().isEmpty()) { - List routeOrderExtensionFields = jdbcRouteOrderExtensionFieldRepository.findByBelongDeptCodeIn(dto.getBelongDeptCode()); + List routeOrderExtensionFields = jdbcRouteOrderExtensionFieldRepository.findByCondition(dto.getBelongDeptCode()); if (routeOrderExtensionFields == null || routeOrderExtensionFields.isEmpty()) { return PageResult.totalPageNum(0, new ArrayList<>()); } diff --git a/src/main/java/com/chint/manage/util/BaseUtil.java b/src/main/java/com/chint/manage/util/BaseUtil.java index 2bf5dffb..78c8160f 100644 --- a/src/main/java/com/chint/manage/util/BaseUtil.java +++ b/src/main/java/com/chint/manage/util/BaseUtil.java @@ -31,18 +31,18 @@ public class BaseUtil { public List getRouteIds(){ List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgList() .stream().filter(s->s.getOrgShortCode()!=null).map(SystemOrganizationVO::getOrgShortCode).toList(); - List result=jdbcRouteOrderExtensionFieldRepository.findByBelongDeptCodeIn(list); + List result=jdbcRouteOrderExtensionFieldRepository.findByCondition(list); return result.stream().map(RouteOrderExtensionField::getRouteId).toList(); } public List getOrderIds(){ List routeIds = getRouteIds(); - return jdbcOrderDetailRepository.findAllByRouteIdIn(routeIds).stream().map(OrderDetail::getOrderId).toList(); + return jdbcOrderDetailRepository.findAllOrderId(routeIds); } public List getOrderNos(){ List routeIds = getRouteIds(); - return jdbcOrderDetailRepository.findAllByRouteIdIn(routeIds).stream().map(OrderDetail::getOrderNo).toList(); + return jdbcOrderDetailRepository.findAllOrderNo(routeIds); } /** diff --git a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java index 9c762592..558b52cf 100644 --- a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java +++ b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java @@ -39,7 +39,7 @@ public class DataJdbcCreatorUtil { */ private List getTables() throws SQLException { List tables = new ArrayList(); - tables.add("route_order_extension_field"); + tables.add("route_order"); return tables; } @@ -149,7 +149,7 @@ public class DataJdbcCreatorUtil { temp = tables[i].trim(); sb.append(temp.substring(0, 1).toUpperCase()).append(temp.substring(1)); } - beanName = sb.toString(); + beanName = sb.toString()+"Basic"; mapperName = "Jdbc"+beanName + "Repository"; _mapperName = shotFirst(mapperName); serviceName = beanName + "Service"; From 37630ab65cf1eba16c8936cb2b1e310c7e6862af Mon Sep 17 00:00:00 2001 From: nixj Date: Wed, 26 Jun 2024 10:38:35 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E3=80=90update=E3=80=91=E8=A1=8C=E7=A8=8B?= =?UTF-8?q?=E5=8D=95=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chint/manage/entity/query/ItineraryPageQuery.java | 2 +- .../mapper/impl/JdbcConsumptionDetailRepositoryImpl.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java b/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java index 4d743c9d..a2b4e568 100644 --- a/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java +++ b/src/main/java/com/chint/manage/entity/query/ItineraryPageQuery.java @@ -13,7 +13,7 @@ public class ItineraryPageQuery extends BaseQuery { private String applicant="";// 申请人 private String actualOrderNo=""; //申请单号 private List userIds=new ArrayList<>(); - private List routeIds; + private List routeIds=new ArrayList<>(); public String getActualOrderNo() { 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 a9556787..60ba4768 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -46,8 +46,11 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Override public Page itineraryPageQueryByDto(ItineraryPageQuery dto) { String query = "SELECT * FROM route_order " - + "WHERE route_id IN (:routeIds) " - + "AND actual_order_no IS NOT NULL "; + + "WHERE actual_order_no IS NOT NULL "; + + if (!dto.getRouteIds().isEmpty()) { + query+="AND route_id IN (:routeIds) "; + } if (!dto.getUserIds().isEmpty()) { query+="AND user_id IN (:userIds) "; From f5315992b504d4a37cdab97a616f864d07417564 Mon Sep 17 00:00:00 2001 From: nixj Date: Wed, 26 Jun 2024 13:07:42 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E3=80=90update=E3=80=91=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E3=80=81=E7=94=B3=E8=AF=B7=E5=8D=95=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E7=B1=BB=E6=96=B0=E5=A2=9E=EF=BC=8C=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=83=A8=E5=88=86=E4=B8=9A=E5=8A=A1=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jdbc/JdbcOrderDetailRepository.java | 36 -------- .../chint/manage/entity/OrderDetailBasic.java | 79 ++++++++++++++++ .../chint/manage/entity/RouteOrderBasic.java | 92 ------------------- ...ava => RouteOrderExtensionFieldBasic.java} | 2 +- .../JdbcOrderDetailBasicRepository.java | 59 ++++++++++++ .../mapper/JdbcRouteOrderBasicRepository.java | 20 ---- ...uteOrderExtensionFieldBasicRepository.java | 20 ++++ ...dbcRouteOrderExtensionFieldRepository.java | 22 ----- .../JdbcConsumptionDetailRepositoryImpl.java | 2 - .../service/impl/ManageServiceImpl.java | 50 +++++----- .../java/com/chint/manage/util/BaseUtil.java | 19 ++-- .../manage/util/DataJdbcCreatorUtil.java | 10 +- 12 files changed, 198 insertions(+), 213 deletions(-) create mode 100644 src/main/java/com/chint/manage/entity/OrderDetailBasic.java delete mode 100644 src/main/java/com/chint/manage/entity/RouteOrderBasic.java rename src/main/java/com/chint/manage/entity/{RouteOrderExtensionField.java => RouteOrderExtensionFieldBasic.java} (87%) create mode 100644 src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java delete mode 100644 src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java create mode 100644 src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldBasicRepository.java delete mode 100644 src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java index cb14e6e1..de97009d 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -33,40 +33,4 @@ public interface JdbcOrderDetailRepository extends CrudRepository findByCreateTimeBetweenAndProductType(LocalDateTime createTime, LocalDateTime createTime2, Integer productType); List findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTime, LocalDateTime createTime2, Integer productType, String orderNo); List findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); - - @Query("SELECT order_no FROM order_detail " + - "WHERE route_id IN (:#{#routeIds})") - List findAllOrderNo(@Param("routeIds") List routeIds); - - @Query("SELECT order_id FROM order_detail " + - "WHERE route_id IN (:#{#routeIds})") - List findAllOrderId(@Param("routeIds") List routeIds); - - @Query("SELECT order_no FROM order_detail " ) - List findAllOrderNo(); - - @Query("SELECT order_id FROM order_detail ") - List findAllOrderId(); - - - @Query("SELECT * FROM order_detail " + -// "WHERE route_id IN (:#{#dto.routeIds}) " + - "WHERE 1=1 " + - "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + - "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " + - "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) " + - "AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) " + - "AND (:#{#dto.employeeNosEmpty} = TRUE OR employee_no IN (:#{#dto.employeeNos}))" + - "LIMIT :#{#pageRequest.pageSize} OFFSET :#{#pageRequest.pageNumber}") - List listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest")PageRequest pageRequest); - - @Query("SELECT COUNT(*) FROM order_detail " + -// "WHERE route_id IN (:#{#dto.routeIds}) " + - "WHERE 1=1 " + - "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + - "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " + - "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+ - "AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) " + - "AND (:#{#dto.employeeNosEmpty} = TRUE OR employee_no IN (:#{#dto.employeeNos}))") - Integer countByCondition(@Param("dto") OrderPageQuery dto); } diff --git a/src/main/java/com/chint/manage/entity/OrderDetailBasic.java b/src/main/java/com/chint/manage/entity/OrderDetailBasic.java new file mode 100644 index 00000000..dd9cf6c9 --- /dev/null +++ b/src/main/java/com/chint/manage/entity/OrderDetailBasic.java @@ -0,0 +1,79 @@ +package com.chint.manage.entity; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * + * @author xx OrderDetailBasic.java + * + **/ +@Data +@Table("order_detail") +public class OrderDetailBasic implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + @Id + private Long orderId; + + /****/ + private Long routeId; + + /****/ + private Long routeOrderKey; + + /****/ + private String orderNo; + + /****/ + private LocalDateTime startTime; + + /****/ + private LocalDateTime endTime; + + /****/ + private Long originId; + + /****/ + private Long destinationId; + + /****/ + private String supplierName; + + /**商品类型 0-火车 1飞机 2酒店 3打车 4其他**/ + private Integer productType; + + /****/ + private String price; + + /****/ + private LocalDateTime updateTime; + + /****/ + private LocalDateTime createTime; + + /****/ + private String currencyType; + + /****/ + private LocalDateTime orderDate; + + /****/ + private Long legId; + + /****/ + private Integer quantity; + + /****/ + private String employeeNo; + + /****/ + private Integer ifOrigin; + + +} diff --git a/src/main/java/com/chint/manage/entity/RouteOrderBasic.java b/src/main/java/com/chint/manage/entity/RouteOrderBasic.java deleted file mode 100644 index 06b7c382..00000000 --- a/src/main/java/com/chint/manage/entity/RouteOrderBasic.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.chint.manage.entity; - -import lombok.Data; -import org.springframework.data.annotation.Id; -import org.springframework.data.relational.core.mapping.Table; -import java.io.Serial; -import java.io.Serializable; - -/** - * - * @author xx RouteOrderBasic.java - * - **/ -@Data -@Table("route_order") -public class RouteOrderBasic implements Serializable { -@Serial -private static final long serialVersionUID = 1L; - @Id - private Long routeId; - - /****/ - private java.util.Date bookingTime; - - /****/ - private String userId; - - /****/ - private java.util.Date createTime; - - /****/ - private String createUser; - - /****/ - private Integer sort; - - /****/ - private Integer status; - - /****/ - private java.util.Date updateTime; - - /****/ - private String updateUser; - - /****/ - private String fakeOrderNo; - - /****/ - private String actualOrderNo; - - /**差旅订单号**/ - private String routeOrderNo; - - /****/ - private String supplierName; - - /****/ - private String accountCompany; - - /****/ - private String sysCode; - - /****/ - private String instructions; - - /****/ - private String standardLevel; - - /****/ - private String creator; - - /****/ - private String accountCompanyName; - - /**入账公司64位编码**/ - private String accountCompanyCode; - - /****/ - private String projectName; - - /****/ - private String costCenter; - - /****/ - private java.util.Date startTime; - - /****/ - private java.util.Date endTime; - - -} diff --git a/src/main/java/com/chint/manage/entity/RouteOrderExtensionField.java b/src/main/java/com/chint/manage/entity/RouteOrderExtensionFieldBasic.java similarity index 87% rename from src/main/java/com/chint/manage/entity/RouteOrderExtensionField.java rename to src/main/java/com/chint/manage/entity/RouteOrderExtensionFieldBasic.java index f675445b..49fba22c 100644 --- a/src/main/java/com/chint/manage/entity/RouteOrderExtensionField.java +++ b/src/main/java/com/chint/manage/entity/RouteOrderExtensionFieldBasic.java @@ -13,7 +13,7 @@ import java.io.Serializable; **/ @Data @Table("route_order_extension_field") -public class RouteOrderExtensionField implements Serializable { +public class RouteOrderExtensionFieldBasic implements Serializable { @Serial private static final long serialVersionUID = 1L; /****/ diff --git a/src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java b/src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java new file mode 100644 index 00000000..fca7afed --- /dev/null +++ b/src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java @@ -0,0 +1,59 @@ +package com.chint.manage.mapper; +import com.chint.domain.aggregates.order.OrderDetail; +import com.chint.manage.entity.OrderDetailBasic; +import com.chint.manage.entity.query.OrderPageQuery; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.jdbc.repository.query.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + + +/** + * + * @author xx JdbcOrderDetailBasicRepository数据库操作接口类 + * + **/ +@Repository +public interface JdbcOrderDetailBasicRepository extends CrudRepository { + + List findByRouteIdIn(List routeIds); + + @Query("SELECT order_no FROM order_detail " + + "WHERE route_id IN (:#{#routeIds})") + List findAllOrderNo(@Param("routeIds") List routeIds); + + @Query("SELECT order_id FROM order_detail " + + "WHERE route_id IN (:#{#routeIds})") + List findAllOrderId(@Param("routeIds") List routeIds); + + @Query("SELECT order_no FROM order_detail " ) + List findAllOrderNo(); + + @Query("SELECT order_id FROM order_detail ") + List findAllOrderId(); + + + @Query("SELECT * FROM order_detail " + +// "WHERE route_id IN (:#{#dto.routeIds}) " + + "WHERE 1=1 " + + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + + "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " + + "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) " + + "AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) " + + "AND (:#{#dto.employeeNosEmpty} = TRUE OR employee_no IN (:#{#dto.employeeNos}))" + + "LIMIT :#{#pageRequest.pageSize} OFFSET :#{#pageRequest.pageNumber}") + List listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest") PageRequest pageRequest); + + @Query("SELECT COUNT(*) FROM order_detail " + +// "WHERE route_id IN (:#{#dto.routeIds}) " + + "WHERE 1=1 " + + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + + "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " + + "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+ + "AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) " + + "AND (:#{#dto.employeeNosEmpty} = TRUE OR employee_no IN (:#{#dto.employeeNos}))") + Integer countByCondition(@Param("dto") OrderPageQuery dto); +} \ No newline at end of file diff --git a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java deleted file mode 100644 index c10a3180..00000000 --- a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderBasicRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.chint.manage.mapper; -import com.chint.domain.aggregates.order.RouteOrder; -import com.chint.manage.entity.RouteOrderBasic; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - - -/** - * - * @author xx JdbcRouteOrderBasicRepository数据库操作接口类 - * - **/ -@Repository -public interface JdbcRouteOrderBasicRepository extends CrudRepository { - - List findByRouteIdIn(List routeIds); - -} \ No newline at end of file diff --git a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldBasicRepository.java b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldBasicRepository.java new file mode 100644 index 00000000..79caee82 --- /dev/null +++ b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldBasicRepository.java @@ -0,0 +1,20 @@ +package com.chint.manage.mapper; +import com.chint.manage.entity.RouteOrderExtensionFieldBasic; +import org.springframework.data.jdbc.repository.query.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + + +/** + * + * @author xx JdbcRouteOrderExtensionFieldRepository数据库操作接口类 + * + **/ +@Repository +public interface JdbcRouteOrderExtensionFieldBasicRepository extends CrudRepository { + + List findAllByBelongDeptCodeIn(@Param("belongDeptCode") List belongDeptCode); +} \ No newline at end of file diff --git a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java b/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java deleted file mode 100644 index bf44e6af..00000000 --- a/src/main/java/com/chint/manage/mapper/JdbcRouteOrderExtensionFieldRepository.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.chint.manage.mapper; -import com.chint.manage.entity.RouteOrderExtensionField; -import org.springframework.data.jdbc.repository.query.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; - - -/** - * - * @author xx JdbcRouteOrderExtensionFieldRepository数据库操作接口类 - * - **/ -@Repository -public interface JdbcRouteOrderExtensionFieldRepository extends CrudRepository { - - @Query("SELECT * FROM route_order_extension_field " + - "WHERE belong_dept_code IN (:#{#belongDeptCode})") - List findByCondition(@Param("belongDeptCode") List belongDeptCode); -} \ No newline at end of file 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 60ba4768..cdaa38a2 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -84,8 +84,6 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai // if (orderIds==null||orderIds.isEmpty()) { // return PageResult.totalPageNum(0, new ArrayList<>()); // } - - List orderIds=jdbcOrderDetailRepository.findAllOrderId(); Page data=new PageImpl<>(Collections.emptyList()); //申请单查询 if (!dto.getActualOrderNo().isEmpty()){ 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 66bc7108..c89242ff 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -7,14 +7,14 @@ import com.chint.domain.exceptions.CommandException; import com.chint.domain.repository.UserRepository; import com.chint.domain.service.LegDomainService; import com.chint.infrastructure.repository.jdbc.JdbcLocationRepository; -import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; import com.chint.infrastructure.repository.jdbc.JdbcUserRepository; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; +import com.chint.manage.entity.OrderDetailBasic; import com.chint.manage.entity.OrderDownloadRecord; import com.chint.manage.entity.OrderExceedStandard; -import com.chint.manage.entity.RouteOrderExtensionField; +import com.chint.manage.entity.RouteOrderExtensionFieldBasic; import com.chint.manage.entity.dto.ItineraryPageDto; import com.chint.manage.entity.excel.OrderPageExcel; import com.chint.manage.entity.excel.BaseExcel; @@ -67,11 +67,11 @@ public class ManageServiceImpl implements ManageService { @Autowired private BaseUtil baseUtil; @Autowired - private JdbcOrderDetailRepository jdbcOrderDetailRepository; + private JdbcOrderDetailBasicRepository jdbcOrderDetailBasicRepository; @Autowired private JdbcLocationRepository locationRepository; @Autowired - private JdbcRouteOrderExtensionFieldRepository jdbcRouteOrderExtensionFieldRepository; + private JdbcRouteOrderExtensionFieldBasicRepository jdbcRouteOrderExtensionFieldBasicRepository; @Autowired private JdbcTrainOrderDetailRepository jdbcTrainOrderDetailRepository; @Autowired @@ -211,12 +211,12 @@ public class ManageServiceImpl implements ManageService { } //部门 if (dto.getBelongDeptCode() != null && !dto.getBelongDeptCode().isEmpty()) { - List routeOrderExtensionFields = jdbcRouteOrderExtensionFieldRepository.findByCondition(dto.getBelongDeptCode()); - if (routeOrderExtensionFields == null || routeOrderExtensionFields.isEmpty()) { + List routeOrderExtensionFieldBasics = jdbcRouteOrderExtensionFieldBasicRepository.findByCondition(dto.getBelongDeptCode()); + if (routeOrderExtensionFieldBasics == null || routeOrderExtensionFieldBasics.isEmpty()) { return PageResult.totalPageNum(0, new ArrayList<>()); } - List routeOrderExtensionFieldIds = routeOrderExtensionFields.stream() - .map(RouteOrderExtensionField::getRouteId) + List routeOrderExtensionFieldIds = routeOrderExtensionFieldBasics.stream() + .map(RouteOrderExtensionFieldBasic::getRouteId) .collect(Collectors.toList()); List updatedRouteIds = dto.getRouteIds() == null ? routeOrderExtensionFieldIds @@ -234,18 +234,18 @@ public class ManageServiceImpl implements ManageService { dto.setApplicant("%"+dto.getApplicant()+"%"); } - List list=jdbcOrderDetailRepository.listByCondition(dto,dto.getPageResult()); + List list=jdbcOrderDetailBasicRepository.listByCondition(dto,dto.getPageResult()); //处理地点信息 - List locationIds = new ArrayList<>(list.stream().map(OrderDetail::getOriginId).toList()); - locationIds.addAll(list.stream().map(OrderDetail::getDestinationId).toList()); + List locationIds = new ArrayList<>(list.stream().map(OrderDetailBasic::getOriginId).toList()); + locationIds.addAll(list.stream().map(OrderDetailBasic::getDestinationId).toList()); locationIds=locationIds.stream().distinct().filter(Objects::nonNull).collect(Collectors.toList()); List locations=locationRepository.findByLocationIdIn(locationIds); //根据类型处理出行订单信息 Map orderPageDtoMap=new HashMap<>(); - Map> collect = list.stream().collect(Collectors.groupingBy(OrderDetail::getProductType)); - for (Map.Entry> entry : collect.entrySet()) { + Map> collect = list.stream().collect(Collectors.groupingBy(OrderDetailBasic::getProductType)); + for (Map.Entry> entry : collect.entrySet()) { int type = entry.getKey(); - List details = entry.getValue(); + List details = entry.getValue(); switch (type) { case LEG_TYPE_TRAIN -> dealOrderTrainRecord(details,orderPageDtoMap); case LEG_TYPE_AIRPLANE -> dealOrderFlightRecord(details,orderPageDtoMap); @@ -254,11 +254,11 @@ public class ManageServiceImpl implements ManageService { } } //处理行程单信息 - List routeIds=list.stream().map(OrderDetail::getRouteId).toList(); + List routeIds=list.stream().map(OrderDetailBasic::getRouteId).toList(); routeIds=routeIds.stream().distinct().filter(Objects::nonNull).collect(Collectors.toList()); List routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIds); - List users=jdbcUserRepository.findAllByEmployeeNoIn(list.stream().map(OrderDetail::getEmployeeNo).collect(Collectors.toList())); + List users=jdbcUserRepository.findAllByEmployeeNoIn(list.stream().map(OrderDetailBasic::getEmployeeNo).collect(Collectors.toList())); List result = list.stream().map(temp -> { OrderPageExcel obj = orderPageDtoMap.get(temp.getOrderId()); @@ -286,7 +286,7 @@ public class ManageServiceImpl implements ManageService { } return finalObj; }).toList(); - Integer count=jdbcOrderDetailRepository.countByCondition(dto); + Integer count=jdbcOrderDetailBasicRepository.countByCondition(dto); return PageResult.totalPageNum(count, result); } @@ -299,9 +299,9 @@ public class ManageServiceImpl implements ManageService { return ExcelUtil.exportReport(orderPageQuery(dto).getRecords()); } - private void dealOrderTrainRecord(List entry,Map orderPageDtoMap){ + private void dealOrderTrainRecord(List entry,Map orderPageDtoMap){ if (entry!=null&&!entry.isEmpty()){ - List trainOrderDetails=jdbcTrainOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList()); + List trainOrderDetails=jdbcTrainOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetailBasic::getOrderId).toList()); for (TrainOrderDetail trainOrderDetail : trainOrderDetails) { OrderPageExcel orderPageDto=new OrderPageExcel(); orderPageDto.setStatus(trainOrderDetail.getOrderStatus()); @@ -311,9 +311,9 @@ public class ManageServiceImpl implements ManageService { } } - private void dealOrderFlightRecord(List entry,Map orderPageDtoMap){ + private void dealOrderFlightRecord(List entry,Map orderPageDtoMap){ if (entry!=null&&!entry.isEmpty()){ - List flightOrderDetails=jdbcFlightOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList()); + List flightOrderDetails=jdbcFlightOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetailBasic::getOrderId).toList()); for (FlightOrderDetail flightOrderDetail : flightOrderDetails) { OrderPageExcel orderPageDto=new OrderPageExcel(); orderPageDto.setStatus(flightOrderDetail.getOrderStatus()); @@ -323,9 +323,9 @@ public class ManageServiceImpl implements ManageService { } } - private void dealOrderHotelRecord(List entry,Map orderPageDtoMap){ + private void dealOrderHotelRecord(List entry,Map orderPageDtoMap){ if (entry!=null&&!entry.isEmpty()){ - List hotelOrderDetails=jdbcHotelOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList()); + List hotelOrderDetails=jdbcHotelOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetailBasic::getOrderId).toList()); for (HotelOrderDetail hotelOrderDetail : hotelOrderDetails) { OrderPageExcel orderPageDto=new OrderPageExcel(); orderPageDto.setStatus(hotelOrderDetail.getOrderStatus()); @@ -338,9 +338,9 @@ public class ManageServiceImpl implements ManageService { } } - private void dealOrderCarRecord(List entry,Map orderPageDtoMap){ + private void dealOrderCarRecord(List entry,Map orderPageDtoMap){ if (entry!=null&&!entry.isEmpty()){ - List carOrderDetails=jdbcCarOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList()); + List carOrderDetails=jdbcCarOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetailBasic::getOrderId).toList()); for (CarOrderDetail carOrderDetail : carOrderDetails) { OrderPageExcel orderPageDto=new OrderPageExcel(); orderPageDto.setStatus(carOrderDetail.getOrderStatus()); diff --git a/src/main/java/com/chint/manage/util/BaseUtil.java b/src/main/java/com/chint/manage/util/BaseUtil.java index 78c8160f..b36690ff 100644 --- a/src/main/java/com/chint/manage/util/BaseUtil.java +++ b/src/main/java/com/chint/manage/util/BaseUtil.java @@ -1,12 +1,11 @@ package com.chint.manage.util; -import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.user.User; import com.chint.domain.value_object.system.SystemOrganizationVO; -import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; import com.chint.infrastructure.util.BaseContext; -import com.chint.manage.entity.RouteOrderExtensionField; -import com.chint.manage.mapper.JdbcRouteOrderExtensionFieldRepository; +import com.chint.manage.entity.RouteOrderExtensionFieldBasic; +import com.chint.manage.mapper.JdbcOrderDetailBasicRepository; +import com.chint.manage.mapper.JdbcRouteOrderExtensionFieldBasicRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,9 +19,9 @@ import java.util.List; @Component public class BaseUtil { @Autowired - private JdbcRouteOrderExtensionFieldRepository jdbcRouteOrderExtensionFieldRepository; + private JdbcRouteOrderExtensionFieldBasicRepository jdbcRouteOrderExtensionFieldBasicRepository; @Autowired - private JdbcOrderDetailRepository jdbcOrderDetailRepository; + private JdbcOrderDetailBasicRepository jdbcOrderDetailBasicRepository; public User getCurrentUser() { return BaseContext.getCurrentUser(); @@ -31,18 +30,18 @@ public class BaseUtil { public List getRouteIds(){ List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgList() .stream().filter(s->s.getOrgShortCode()!=null).map(SystemOrganizationVO::getOrgShortCode).toList(); - List result=jdbcRouteOrderExtensionFieldRepository.findByCondition(list); - return result.stream().map(RouteOrderExtensionField::getRouteId).toList(); + List result= jdbcRouteOrderExtensionFieldBasicRepository.findAllByBelongDeptCodeIn(list); + return result.stream().map(RouteOrderExtensionFieldBasic::getRouteId).toList(); } public List getOrderIds(){ List routeIds = getRouteIds(); - return jdbcOrderDetailRepository.findAllOrderId(routeIds); + return jdbcOrderDetailBasicRepository.findAllOrderId(routeIds); } public List getOrderNos(){ List routeIds = getRouteIds(); - return jdbcOrderDetailRepository.findAllOrderNo(routeIds); + return jdbcOrderDetailBasicRepository.findAllOrderNo(routeIds); } /** diff --git a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java index 558b52cf..0b6b23d6 100644 --- a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java +++ b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java @@ -39,7 +39,7 @@ public class DataJdbcCreatorUtil { */ private List getTables() throws SQLException { List tables = new ArrayList(); - tables.add("route_order"); + tables.add("order_detail"); return tables; } @@ -179,11 +179,11 @@ public class DataJdbcCreatorUtil { } else if (type.indexOf(type_int) > -1) { return "java.lang.Integer"; } else if (type.indexOf(type_date) > -1) { - return "java.util.Date"; + return "java.time.LocalDateTime"; } else if (type.indexOf(type_text) > -1) { return "java.lang.String"; } else if (type.indexOf(type_timestamp) > -1) { - return "java.util.Date"; + return "java.time.LocalDateTime"; } else if (type.indexOf(type_bit) > -1) { return "java.lang.Boolean"; } else if (type.indexOf(type_decimal) > -1) { @@ -203,11 +203,11 @@ public class DataJdbcCreatorUtil { } else if (type.indexOf(type_longtext) > -1) { return "java.lang.String"; } else if (type.indexOf(type_datetime) > -1) { - return "java.util.Date"; + return "java.time.LocalDateTime"; } else if (type.indexOf(type_binary) > -1) { return "java.lang.Long"; } else if (type.indexOf(type_time) > -1) { - return "java.util.Date"; + return "java.time.LocalDateTime"; } From 3b14f26a76d8a433afd9161d80a6943475165b69 Mon Sep 17 00:00:00 2001 From: nixj Date: Wed, 26 Jun 2024 13:08:27 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E3=80=90update=E3=80=91=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/chint/manage/service/impl/ManageServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c89242ff..959e9741 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -211,7 +211,7 @@ public class ManageServiceImpl implements ManageService { } //部门 if (dto.getBelongDeptCode() != null && !dto.getBelongDeptCode().isEmpty()) { - List routeOrderExtensionFieldBasics = jdbcRouteOrderExtensionFieldBasicRepository.findByCondition(dto.getBelongDeptCode()); + List routeOrderExtensionFieldBasics = jdbcRouteOrderExtensionFieldBasicRepository.findAllByBelongDeptCodeIn(dto.getBelongDeptCode()); if (routeOrderExtensionFieldBasics == null || routeOrderExtensionFieldBasics.isEmpty()) { return PageResult.totalPageNum(0, new ArrayList<>()); } From e80b644f62f9079a88870fe692275136b2bc5dc4 Mon Sep 17 00:00:00 2001 From: nixj Date: Thu, 27 Jun 2024 08:49:40 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E3=80=90add=E3=80=91=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=9E=E7=8E=B0=EF=BC=8C=E4=BC=98=E5=8C=96IP?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/LogConfig/CruxLogInterceptor.java | 72 +++++++++++++++++++ .../config/webconfig/WebConfig.java | 19 ++++- .../manage/entity/CruxSystemLogBasic.java | 53 ++++++++++++++ .../JdbcCruxSystemLogBasicRepository.java | 15 ++++ .../manage/util/DataJdbcCreatorUtil.java | 2 +- .../com/chint/manage/util/IpAddressUtil.java | 64 +++++++++++++++++ 6 files changed, 222 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/chint/infrastructure/config/LogConfig/CruxLogInterceptor.java create mode 100644 src/main/java/com/chint/manage/entity/CruxSystemLogBasic.java create mode 100644 src/main/java/com/chint/manage/mapper/JdbcCruxSystemLogBasicRepository.java create mode 100644 src/main/java/com/chint/manage/util/IpAddressUtil.java diff --git a/src/main/java/com/chint/infrastructure/config/LogConfig/CruxLogInterceptor.java b/src/main/java/com/chint/infrastructure/config/LogConfig/CruxLogInterceptor.java new file mode 100644 index 00000000..22746f10 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/config/LogConfig/CruxLogInterceptor.java @@ -0,0 +1,72 @@ +package com.chint.infrastructure.config.LogConfig; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.manage.entity.CruxSystemLogBasic; +import com.chint.manage.mapper.JdbcCruxSystemLogBasicRepository; +import com.chint.manage.util.IpAddressUtil; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Objects; + +@Slf4j +@Component +public class CruxLogInterceptor implements HandlerInterceptor { + + @Autowired + private JdbcCruxSystemLogBasicRepository jdbcCruxSystemLogBasicRepository; + @Autowired + private IpAddressUtil ipAddressUtil; + + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + // 在请求处理之前进行拦截 + // 获取请求IP + String clientIP = ipAddressUtil.getIpAddress(request); + // 获取请求URL + String url = request.getRequestURL().toString(); + // 获取请求方法 + String method = request.getMethod(); + // 获取url中的请求参数 + String params = request.getQueryString() == null ? "" : request.getQueryString(); + //请求体数据 + String requestBody = ""; + if ("POST".equals(method)) { + requestBody = ContentCachingWrapperFilter.getRequestBody(request); + } + requestBody = requestBody.replaceAll("\\s+", ""); + + //如果有,获取用户 + User user = BaseContext.getCurrentUser(); + String employeeNo = ""; + String name = ""; + if (!Objects.isNull(user)) { + employeeNo = user.getEmployeeNo(); + name = user.getName(); + } + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String accessTime = now.format(formatter); + + //构建对象 + CruxSystemLogBasic systemLog = CruxSystemLogBasic.builder() + .clientIp(clientIP) + .url(url) + .method(method) + .params(params) + .requestBody(requestBody) + .employeeNo(employeeNo) + .name(name) + .accessTime(accessTime).build(); + jdbcCruxSystemLogBasicRepository.save(systemLog); + + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/config/webconfig/WebConfig.java b/src/main/java/com/chint/infrastructure/config/webconfig/WebConfig.java index 7cbded34..f7ca609f 100644 --- a/src/main/java/com/chint/infrastructure/config/webconfig/WebConfig.java +++ b/src/main/java/com/chint/infrastructure/config/webconfig/WebConfig.java @@ -1,10 +1,9 @@ package com.chint.infrastructure.config.webconfig; +import com.chint.infrastructure.config.LogConfig.CruxLogInterceptor; import com.chint.infrastructure.config.LogConfig.RequestLoggingInterceptor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -24,6 +23,14 @@ public class WebConfig implements WebMvcConfigurer { return new RequestLoggingInterceptor(); } + /** + * 关键接口日志记录 + */ + @Bean + public CruxLogInterceptor getCruxLogInterceptor() { + return new CruxLogInterceptor(); + } + @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new JwtTokenAdminInterceptor()) @@ -35,6 +42,14 @@ public class WebConfig implements WebMvcConfigurer { registry.addInterceptor(getMyRequestLoggingInterceptor()) .addPathPatterns("/**") .excludePathPatterns("/location/**", "/**/query/**", "/**/pageQuery/**"); + //关键接口日志记录 + registry.addInterceptor(getCruxLogInterceptor()) + //报表 + .addPathPatterns("/manage/consumption/export","/manage/standard/export","/manage/order/export", + //公告 + "/system/announcement/save","/system/announcement/update", + //权限 + "/users/add/role","/users/edit/role"); } @Override diff --git a/src/main/java/com/chint/manage/entity/CruxSystemLogBasic.java b/src/main/java/com/chint/manage/entity/CruxSystemLogBasic.java new file mode 100644 index 00000000..5d47bce2 --- /dev/null +++ b/src/main/java/com/chint/manage/entity/CruxSystemLogBasic.java @@ -0,0 +1,53 @@ +package com.chint.manage.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; +import java.io.Serial; +import java.io.Serializable; + +/** + * + * @author xx CruxSystemLogBasic.java + * + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Table("crux_system_log") +public class CruxSystemLogBasic implements Serializable { +@Serial +private static final long serialVersionUID = 1L; + @Id + private Integer id; + + /**员工SF号**/ + private String employeeNo; + + /**员工姓名**/ + private String name; + + /**访问时间**/ + private String accessTime; + + /**请求IP**/ + private String clientIp; + + /**请求路径**/ + private String url; + + /**请求方法**/ + private String method; + + /**参数**/ + private String params; + + /**请求体**/ + private String requestBody; + + +} diff --git a/src/main/java/com/chint/manage/mapper/JdbcCruxSystemLogBasicRepository.java b/src/main/java/com/chint/manage/mapper/JdbcCruxSystemLogBasicRepository.java new file mode 100644 index 00000000..7eb878a5 --- /dev/null +++ b/src/main/java/com/chint/manage/mapper/JdbcCruxSystemLogBasicRepository.java @@ -0,0 +1,15 @@ +package com.chint.manage.mapper; +import com.chint.manage.entity.CruxSystemLogBasic; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + + +/** + * + * @author xx JdbcCruxSystemLogBasicRepository数据库操作接口类 + * + **/ +@Repository +public interface JdbcCruxSystemLogBasicRepository extends CrudRepository { + +} \ No newline at end of file diff --git a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java index 0b6b23d6..0d7a1b40 100644 --- a/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java +++ b/src/main/java/com/chint/manage/util/DataJdbcCreatorUtil.java @@ -39,7 +39,7 @@ public class DataJdbcCreatorUtil { */ private List getTables() throws SQLException { List tables = new ArrayList(); - tables.add("order_detail"); + tables.add("crux_system_log"); return tables; } diff --git a/src/main/java/com/chint/manage/util/IpAddressUtil.java b/src/main/java/com/chint/manage/util/IpAddressUtil.java new file mode 100644 index 00000000..32fabd21 --- /dev/null +++ b/src/main/java/com/chint/manage/util/IpAddressUtil.java @@ -0,0 +1,64 @@ +package com.chint.manage.util; + + +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** +* 获取IP工具类 + * 如果是IP白名单限制应该直接使用request.getRemoteAddr() + * 这个无法伪造 +* @Author:nxj +* @Date:2020/6/24 9:20 +*/ +@Component +public class IpAddressUtil { + + private static final String LOCAL = "0:0:0:0:0:0:0:1"; + + + public String getIpAddress(HttpServletRequest request) { + String ip = null; + + //X-Forwarded-For:Squid 服务代理 + String ipAddresses = request.getHeader("X-Forwarded-For"); + String unknown = "unknown"; + if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) { + //Proxy-Client-IP:apache 服务代理 + ipAddresses = request.getHeader("Proxy-Client-IP"); + } + + if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) { + //WL-Proxy-Client-IP:weblogic 服务代理 + ipAddresses = request.getHeader("WL-Proxy-Client-IP"); + } + + if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) { + //HTTP_CLIENT_IP:有些代理服务器 + ipAddresses = request.getHeader("HTTP_CLIENT_IP"); + } + + if (ipAddresses == null || ipAddresses.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) { + //X-Real-IP:nginx服务代理 + ipAddresses = request.getHeader("X-Real-IP"); + } + + //有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP + if (ipAddresses != null && ipAddresses.length() != 0) { + ip = ipAddresses.split(",")[0]; + } + + //还是不能获取到,最后再通过request.getRemoteAddr();获取 + if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ipAddresses)) { + ip = request.getRemoteAddr(); + } + + if(LOCAL.equals(ip)){ + return "127.0.0.1"; + } + return ip; + } +} From 7db999404ba7b99e0d8bab19e4bfa68c9e7bfbe9 Mon Sep 17 00:00:00 2001 From: nixj Date: Thu, 27 Jun 2024 14:28:31 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E3=80=90update=E3=80=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E9=83=A8=E5=88=86=E4=B8=9A=E5=8A=A1=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dtos/response/UserRes.java | 1 - .../chint/domain/aggregates/user/User.java | 2 - .../SystemOrganizationRepository.java | 2 + .../repository/RoleRepositoryImpl.java | 82 +++++++++++-------- .../SystemOrganizationRepositoryImpl.java | 5 ++ .../JdbcSystemOrganizationRepository.java | 7 ++ .../JdbcOrderDetailBasicRepository.java | 8 +- .../JdbcOrderExceedStandardRepository.java | 4 +- .../JdbcConsumptionDetailRepositoryImpl.java | 8 +- .../service/impl/ManageServiceImpl.java | 36 ++++---- .../java/com/chint/manage/util/BaseUtil.java | 3 +- 11 files changed, 90 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/chint/application/dtos/response/UserRes.java b/src/main/java/com/chint/application/dtos/response/UserRes.java index b837eb4a..f550a6e3 100644 --- a/src/main/java/com/chint/application/dtos/response/UserRes.java +++ b/src/main/java/com/chint/application/dtos/response/UserRes.java @@ -21,6 +21,5 @@ public class UserRes { private String rankCode; private String companyCode; private String workStatus; - private List roleOrgList; private List roleList; } diff --git a/src/main/java/com/chint/domain/aggregates/user/User.java b/src/main/java/com/chint/domain/aggregates/user/User.java index b2702496..34b3b542 100644 --- a/src/main/java/com/chint/domain/aggregates/user/User.java +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -82,8 +82,6 @@ public class User implements Serializable { @Transient private List roleOrgCodeList; @Transient - private List roleOrgList; - @Transient private List roleList; public User loadInfoFromDept() { diff --git a/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java b/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java index 54f99ad8..1a125bf5 100644 --- a/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java +++ b/src/main/java/com/chint/domain/repository/SystemOrganizationRepository.java @@ -26,4 +26,6 @@ public interface SystemOrganizationRepository { SystemOrganization queryChild(SystemOrganization systemOrganization); List expandOrganizations(List systemOrganizations); + + List queryOrgCodeListByUserId(Long userId); } diff --git a/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java index dd55677e..467b64e6 100644 --- a/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RoleRepositoryImpl.java @@ -20,6 +20,7 @@ import org.springframework.data.domain.Sort; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Objects; import java.util.Optional; @Repository @@ -94,43 +95,56 @@ public class RoleRepositoryImpl implements RoleRepository { Long userId = user.getUserId(); List orgCodeList = cacheRoleRepository .roleOrgCodeList(userId, null); - List systemOrganizationVOList = cacheRoleRepository - .roleOrgList(userId, null); - - if (systemOrganizationVOList == null || systemOrganizationVOList.isEmpty() || - orgCodeList == null || orgCodeList.isEmpty()) { - List roleList = user.getRoleList(); - List orgListId = roleList - .stream() - .flatMap(role -> role.getRoleOrganizationList().stream()) - .map(RoleOrganization::getOrgId) - .distinct() - .toList(); - - // 获取所有的 SystemOrganization - List rootOrganizations = systemOrganizationRepository.findByIdIn(orgListId); - - // 展开所有的 SystemOrganization - rootOrganizations = systemOrganizationRepository.expandOrganizations(rootOrganizations); - - orgCodeList = rootOrganizations.stream() - .map(SystemOrganization::getOrgShortCode) - .distinct() - .toList(); - - systemOrganizationVOList = rootOrganizations.stream() - .map(SystemOrganization::mapToVO) - .distinct() - .toList(); - + if (orgCodeList == null) { + orgCodeList=systemOrganizationRepository.queryOrgCodeListByUserId(userId); + if (!orgCodeList.isEmpty()) { + orgCodeList=orgCodeList.stream().filter(Objects::nonNull).toList(); + } cacheRoleRepository.evictRoleOrgCodeList(userId); cacheRoleRepository.roleOrgCodeList(userId, orgCodeList); - cacheRoleRepository.evictRoleOrgList(userId); - cacheRoleRepository.roleOrgList(userId, systemOrganizationVOList); } - - // 设置用户的角色组织列表 user.setRoleOrgCodeList(orgCodeList); - user.setRoleOrgList(systemOrganizationVOList); + + +// List orgCodeList = cacheRoleRepository +// .roleOrgCodeList(userId, null); +// List systemOrganizationVOList = cacheRoleRepository +// .roleOrgList(userId, null); +// +// if (systemOrganizationVOList == null || systemOrganizationVOList.isEmpty() || +// orgCodeList == null || orgCodeList.isEmpty()) { +// List roleList = user.getRoleList(); +// List orgListId = roleList +// .stream() +// .flatMap(role -> role.getRoleOrganizationList().stream()) +// .map(RoleOrganization::getOrgId) +// .distinct() +// .toList(); +// +// // 获取所有的 SystemOrganization +// List rootOrganizations = systemOrganizationRepository.findByIdIn(orgListId); +// +// // 展开所有的 SystemOrganization +// rootOrganizations = systemOrganizationRepository.expandOrganizations(rootOrganizations); +// +// orgCodeList = rootOrganizations.stream() +// .map(SystemOrganization::getOrgShortCode) +// .distinct() +// .toList(); +// +// systemOrganizationVOList = rootOrganizations.stream() +// .map(SystemOrganization::mapToVO) +// .distinct() +// .toList(); +// +// cacheRoleRepository.evictRoleOrgCodeList(userId); +// cacheRoleRepository.roleOrgCodeList(userId, orgCodeList); +// cacheRoleRepository.evictRoleOrgList(userId); +// cacheRoleRepository.roleOrgList(userId, systemOrganizationVOList); +// } +// +// // 设置用户的角色组织列表 +// user.setRoleOrgCodeList(orgCodeList); +// user.setRoleOrgList(systemOrganizationVOList); } } diff --git a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java index 4a8e5f6e..c2913e9c 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemOrganizationRepositoryImpl.java @@ -127,6 +127,11 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos return allOrganizations; } + @Override + public List queryOrgCodeListByUserId(Long userId) { + return jdbcSystemOrganizationRepository.queryOrgCodeListByUserId(userId); + } + private void expandOrganizationRecursively(SystemOrganization org, List allOrganizations) { if (org == null) { diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemOrganizationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemOrganizationRepository.java index 1a4d2bca..ccea92b7 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemOrganizationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcSystemOrganizationRepository.java @@ -1,6 +1,7 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.system.SystemOrganization; +import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @@ -15,4 +16,10 @@ public interface JdbcSystemOrganizationRepository extends CrudRepository findByOrgLevelIsNullOrOrgLevel(String orgLevel); List findByOrgShortCodeIn(Collection orgCode); List findByIdIn(Collection id); + + @Query("select so.org_short_code from role_organization ro,system_organization so,role_user ru " + + "where ro.org_id = so.id " + + "and ro.role_id = ru.role_id " + + "and ru.user_id = :#{#userId}") + List queryOrgCodeListByUserId(Long userId); } diff --git a/src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java b/src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java index fca7afed..c3e8189d 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcOrderDetailBasicRepository.java @@ -37,8 +37,8 @@ public interface JdbcOrderDetailBasicRepository extends CrudRepository listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest") PageRequest pageRequest); @Query("SELECT COUNT(*) FROM order_detail " + -// "WHERE route_id IN (:#{#dto.routeIds}) " + - "WHERE 1=1 " + + "WHERE route_id IN (:#{#dto.routeIds}) " + +// "WHERE 1=1 " + "AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " + "AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " + "AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+ diff --git a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java index 8de1f15a..22217979 100644 --- a/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java +++ b/src/main/java/com/chint/manage/mapper/JdbcOrderExceedStandardRepository.java @@ -21,6 +21,6 @@ public interface JdbcOrderExceedStandardRepository extends CrudRepository findAll(); -// Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List orderNos, Pageable pageable); -Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(String applicant, String company, String actualOrderNo, String orderNo, Pageable pageable); + Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List orderNos, Pageable pageable); +//Page findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(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 cdaa38a2..57111b14 100644 --- a/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java +++ b/src/main/java/com/chint/manage/mapper/impl/JdbcConsumptionDetailRepositoryImpl.java @@ -80,10 +80,10 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai @Override public PageResult pageConsumptionDetail(ConsumptionDetailQuery dto) { //数据权限 -// List orderIds=baseUtil.getOrderIds(); -// if (orderIds==null||orderIds.isEmpty()) { -// return PageResult.totalPageNum(0, new ArrayList<>()); -// } + List orderIds=baseUtil.getOrderIds(); + if (orderIds==null||orderIds.isEmpty()) { + return PageResult.totalPageNum(0, new ArrayList<>()); + } Page data=new PageImpl<>(Collections.emptyList()); //申请单查询 if (!dto.getActualOrderNo().isEmpty()){ 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 959e9741..874eda08 100644 --- a/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java +++ b/src/main/java/com/chint/manage/service/impl/ManageServiceImpl.java @@ -98,18 +98,18 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult standardQuery(StandardQuery dto) { //数据权限 -// List orderNos=baseUtil.getOrderNos(); -// if (orderNos==null||orderNos.isEmpty()) { -// return PageResult.totalPageNum(0, new ArrayList<>()); -// } + List orderNos=baseUtil.getOrderNos(); + if (orderNos==null||orderNos.isEmpty()) { + return PageResult.totalPageNum(0, new ArrayList<>()); + } PageRequest pageRequest = PageRequest .of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending()); - Page page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(dto.getApplicant(), + Page page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(dto.getApplicant(), dto.getCompanyName(), dto.getActualOrderNo(), dto.getOrderNo(), -// orderNos, + orderNos, pageRequest); List excelList = getOrderExceedStandardExcels(page); return PageResult.totalPageNum(page.getTotalElements(), excelList); @@ -127,11 +127,11 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult itineraryPageQuery(ItineraryPageQuery dto) { //数据权限 -// List routeIds=baseUtil.getRouteIds(); -// if (routeIds==null||routeIds.isEmpty()) { -// return PageResult.totalPageNum(0, new ArrayList<>()); -// } -// dto.setRouteIds(routeIds); + List routeIds=baseUtil.getRouteIds(); + if (routeIds==null||routeIds.isEmpty()) { + return PageResult.totalPageNum(0, new ArrayList<>()); + } + dto.setRouteIds(routeIds); List users=new ArrayList<>(); if (!dto.getApplicant().isEmpty()){ @@ -163,9 +163,7 @@ public class ManageServiceImpl implements ManageService { @Override public void addOrderDownloadRecord(OrderDownloadRecord orderDownloadRecord) { -// User user= BaseContext.getCurrentUser(); - User user=new User(); - user.setEmployeeNo("123"); + User user= BaseContext.getCurrentUser(); orderDownloadRecord.setEmployeeNo(user.getEmployeeNo()); jdbcOrderDownloadRecordRepository.save(orderDownloadRecord); } @@ -179,11 +177,11 @@ public class ManageServiceImpl implements ManageService { @Override public PageResult orderPageQuery(OrderPageQuery dto) { //数据权限 -// List dataRouteIds=baseUtil.getRouteIds(); -// if (dataRouteIds==null||dataRouteIds.isEmpty()) { -// return PageResult.totalPageNum(0, new ArrayList<>()); -// } -// dto.setRouteIds(dataRouteIds); + List dataRouteIds=baseUtil.getRouteIds(); + if (dataRouteIds==null||dataRouteIds.isEmpty()) { + return PageResult.totalPageNum(0, new ArrayList<>()); + } + dto.setRouteIds(dataRouteIds); //预订人 if (!dto.getApplicant().equals("")){ diff --git a/src/main/java/com/chint/manage/util/BaseUtil.java b/src/main/java/com/chint/manage/util/BaseUtil.java index b36690ff..6db0cdb2 100644 --- a/src/main/java/com/chint/manage/util/BaseUtil.java +++ b/src/main/java/com/chint/manage/util/BaseUtil.java @@ -28,8 +28,7 @@ public class BaseUtil { } public List getRouteIds(){ - List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgList() - .stream().filter(s->s.getOrgShortCode()!=null).map(SystemOrganizationVO::getOrgShortCode).toList(); + List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgCodeList(); List result= jdbcRouteOrderExtensionFieldBasicRepository.findAllByBelongDeptCodeIn(list); return result.stream().map(RouteOrderExtensionFieldBasic::getRouteId).toList(); } From d83f96c6010f15be19302fb611146a10dd8052be Mon Sep 17 00:00:00 2001 From: nixj Date: Thu, 27 Jun 2024 14:35:57 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E3=80=90update=E3=80=91null=E5=80=BC?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/chint/manage/util/BaseUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chint/manage/util/BaseUtil.java b/src/main/java/com/chint/manage/util/BaseUtil.java index 6db0cdb2..2d3ad896 100644 --- a/src/main/java/com/chint/manage/util/BaseUtil.java +++ b/src/main/java/com/chint/manage/util/BaseUtil.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Objects; /** * 基础方法工具类 @@ -28,7 +29,7 @@ public class BaseUtil { } public List getRouteIds(){ - List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgCodeList(); + List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgCodeList().stream().filter(Objects::nonNull).toList(); List result= jdbcRouteOrderExtensionFieldBasicRepository.findAllByBelongDeptCodeIn(list); return result.stream().map(RouteOrderExtensionFieldBasic::getRouteId).toList(); } From a32d491b635047f9ba61bff5679be1db265b9e7d Mon Sep 17 00:00:00 2001 From: nixj Date: Thu, 27 Jun 2024 15:52:54 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E3=80=90add=E3=80=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=8E=B7=E5=8F=96=E6=96=B0=E5=A2=9Enull?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/chint/manage/util/BaseUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chint/manage/util/BaseUtil.java b/src/main/java/com/chint/manage/util/BaseUtil.java index 2d3ad896..228c35b6 100644 --- a/src/main/java/com/chint/manage/util/BaseUtil.java +++ b/src/main/java/com/chint/manage/util/BaseUtil.java @@ -1,7 +1,6 @@ package com.chint.manage.util; import com.chint.domain.aggregates.user.User; -import com.chint.domain.value_object.system.SystemOrganizationVO; import com.chint.infrastructure.util.BaseContext; import com.chint.manage.entity.RouteOrderExtensionFieldBasic; import com.chint.manage.mapper.JdbcOrderDetailBasicRepository; @@ -30,17 +29,20 @@ public class BaseUtil { public List getRouteIds(){ List list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgCodeList().stream().filter(Objects::nonNull).toList(); + if (list.isEmpty()) return null; List result= jdbcRouteOrderExtensionFieldBasicRepository.findAllByBelongDeptCodeIn(list); return result.stream().map(RouteOrderExtensionFieldBasic::getRouteId).toList(); } public List getOrderIds(){ List routeIds = getRouteIds(); + if (routeIds.isEmpty()) return null; return jdbcOrderDetailBasicRepository.findAllOrderId(routeIds); } public List getOrderNos(){ List routeIds = getRouteIds(); + if (routeIds.isEmpty()) return null; return jdbcOrderDetailBasicRepository.findAllOrderNo(routeIds); }