From 00b61fd55bb7e04f337a81b38ecf22782f322cf9 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 3 Apr 2024 14:20:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E7=AE=97=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=8F=AA=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=8A=E4=B8=AA=E6=9C=88=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../queryies/OrderDetailQuery.java | 13 ++++------- .../order/order_record/OrderFlightRecord.java | 7 +++--- .../CTripOrderRecordExtensionFactory.java | 14 +++++++---- .../repository/OrderCarRecordRepository.java | 7 +++++- .../OrderFlightRecordRepository.java | 4 ++++ .../OrderHotelRecordRepository.java | 8 ++++++- .../OrderTrainRecordRepository.java | 7 +++++- .../service/OrderRecordDomainService.java | 23 +++++++++++++++++++ .../OrderCarRecordRepositoryImpl.java | 10 ++++++++ .../OrderFlightRecordRepositoryImpl.java | 9 ++++++++ .../OrderHotelRecordRepositoryImpl.java | 11 +++++++++ .../OrderTrainRecordRepositoryImpl.java | 10 ++++++++ .../jdbc/JdbcOrderCarRecordRepository.java | 3 +++ .../jdbc/JdbcOrderFlightRecordRepository.java | 2 ++ .../jdbc/JdbcOrderHotelRecordRepository.java | 4 +++- .../jdbc/JdbcOrderTrainRecordRepository.java | 1 + .../infrastructure/util/DateTimeUtil.java | 16 +++++++++++++ .../java/com/chint/RouteApplicationTests.java | 4 +++- 18 files changed, 132 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/chint/domain/service/OrderRecordDomainService.java diff --git a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java index f701e7b1..13a943e3 100644 --- a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java @@ -57,15 +57,12 @@ public class OrderDetailQuery { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter); LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter); + //只获取账期号为上个月的结算数据 return switch (productType) { - case 1 -> orderFlightRecordRepository.findByUpdateDataTime(targetTimeBegin, - targetTimeEnd, pageSize, pageNum, systemType); - case 2 -> orderHotelRecordRepository.findByUpdateDataTime(targetTimeBegin, - targetTimeEnd, pageSize, pageNum, systemType); - case 3 -> orderTrainRecordRepository.findByUpdateDataTime(targetTimeBegin, - targetTimeEnd, pageSize, pageNum, systemType); - case 4 -> orderCarRecordRepository.findByUpdateDataTime(targetTimeBegin, - targetTimeEnd, pageSize, pageNum, systemType); + case 1 -> orderFlightRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType); + case 2 -> orderHotelRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType); + case 3 -> orderTrainRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType); + case 4 -> orderCarRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType); default -> throw new NotFoundException("错误产品类型"); }; } diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java index 49b3c18a..5967781b 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java @@ -118,19 +118,20 @@ public class OrderFlightRecord extends OrderBaseRecord { } // 加载机票信息 - public OrderFlightRecord loadTicketInfo(String issueTicketTime, + public OrderFlightRecord loadTicketInfo( String ticketNo, String facePrice, String useStatus) { - this.setIssueTicketTime(issueTicketTime); + this.setTicketNo(ticketNo); this.setFacePrice(facePrice); this.setUseStatus(useStatus); return this; } - public OrderFlightRecord loadScheduleNum(String scheduleNum){ + public OrderFlightRecord loadScheduleNum(String issueTicketTime,String scheduleNum){ this.setScheduleNum(scheduleNum); + this.setIssueTicketTime(issueTicketTime); return this; } diff --git a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java index 7f88235a..3d2897b2 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java @@ -11,6 +11,7 @@ import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.RouteRepository; import com.chint.domain.service.OrderDetailDomainService; import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository; +import com.chint.infrastructure.util.DateTimeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -46,6 +47,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setAccountCompanyId(cTripCarPassengerInfo.getCostCenter1()); orderRecordBasic.setAccountCompanyName(cTripCarPassengerInfo.getCostCenter2()); + orderRecordBasic.setOfflineCcomyCode(cTripCarPassengerInfo.getCostCenter1()); orderRecordBasic.setProjectOrderNo(cTripCarPassengerInfo.getCostCenter5()); String sysCode = cTripCarPassengerInfo.getCostCenter3(); if (sysCode != null) { @@ -205,6 +207,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setAccountCompanyId(cTripFlightBaseInfo.getCostCenter()); orderRecordBasic.setAccountCompanyName(cTripFlightBaseInfo.getCostCenter2()); + orderRecordBasic.setOfflineCcomyCode(cTripFlightBaseInfo.getCostCenter()); orderRecordBasic.setProjectOrderNo(cTripFlightBaseInfo.getCostCenter5()); String sysCode = cTripFlightBaseInfo.getCostCenter3(); if (sysCode != null) { @@ -279,17 +282,17 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac return b; } }); - orderFlightRecord.loadScheduleNum(print.isPresent() ? print.get().getPrintNo() : ""); + orderFlightRecord.loadScheduleNum(print.map(cTripFlightSegmentPrint -> DateTimeUtil.timeFromInstant(cTripFlightSegmentPrint.getPrintTime())).orElse(""), + print.isPresent() ? print.get().getPrintNo() : ""); } + // 加载机票信息 if (cTripFlightTripInfo != null) { - orderFlightRecord.loadTicketInfo(cTripFlightRecordBase.getCreateTime(), + orderFlightRecord.loadTicketInfo(cTripFlightTripInfo.getTicketNo(), String.valueOf(cTripFlightRecordBase.getPrice()), - cTripFlightTripInfo.getTicketNo(), cTripFlightTripInfo.getTicketNoStatusName()); } else { - orderFlightRecord.loadTicketInfo(cTripFlightRecordBase.getCreateTime(), - String.valueOf(cTripFlightRecordBase.getPrice()), + orderFlightRecord.loadTicketInfo(String.valueOf(cTripFlightRecordBase.getPrice()), "", "无机票信息"); } @@ -376,6 +379,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setAccountCompanyId(cTripHotelOrderDetail.getCostCenter()); orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2()); + orderRecordBasic.setOfflineCcomyCode(cTripHotelOrderDetail.getCostCenter()); orderRecordBasic.setProjectOrderNo(cTripHotelOrderDetail.getCostCenter5()); String sysCode = cTripHotelOrderDetail.getCostCenter3(); if (sysCode != null) { diff --git a/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java index 435ed60c..edfed599 100644 --- a/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java @@ -1,6 +1,7 @@ package com.chint.domain.repository; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; +import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; import com.chint.infrastructure.util.PageResult; import java.time.LocalDateTime; @@ -12,5 +13,9 @@ public interface OrderCarRecordRepository { Optional findByDetailId(String detailId); - PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, + Integer pageSize, Integer pageNum ,String systemType); + PageResult findBySystemTypeAndLastMonth(Integer pageSize, + Integer pageNum, + String systemType); } diff --git a/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java index 26776622..6312ebcf 100644 --- a/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java @@ -17,4 +17,8 @@ public interface OrderFlightRecordRepository { Integer pageSize, Integer pageNum, String systemType); + + PageResult findBySystemTypeAndLastMonth(Integer pageSize, + Integer pageNum, + String systemType); } diff --git a/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java index be2cc0fd..2bc09547 100644 --- a/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java @@ -1,6 +1,7 @@ package com.chint.domain.repository; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; +import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.infrastructure.util.PageResult; @@ -13,5 +14,10 @@ public interface OrderHotelRecordRepository { Optional findByDetailId(String detailId); - PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, + Integer pageSize, Integer pageNum ,String systemType); + + PageResult findBySystemTypeAndLastMonth(Integer pageSize, + Integer pageNum, + String systemType); } diff --git a/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java index 3a50a491..7b136f16 100644 --- a/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java @@ -14,5 +14,10 @@ public interface OrderTrainRecordRepository { Optional findByDetailId(String detailId); - PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, + Integer pageSize, Integer pageNum ,String systemType); + + PageResult findBySystemTypeAndLastMonth(Integer pageSize, + Integer pageNum, + String systemType); } diff --git a/src/main/java/com/chint/domain/service/OrderRecordDomainService.java b/src/main/java/com/chint/domain/service/OrderRecordDomainService.java new file mode 100644 index 00000000..6b257d55 --- /dev/null +++ b/src/main/java/com/chint/domain/service/OrderRecordDomainService.java @@ -0,0 +1,23 @@ +package com.chint.domain.service; + +import com.chint.domain.repository.OrderCarRecordRepository; +import com.chint.domain.repository.OrderFlightRecordRepository; +import com.chint.domain.repository.OrderHotelRecordRepository; +import com.chint.domain.repository.OrderTrainRecordRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class OrderRecordDomainService { + + @Autowired + private OrderCarRecordRepository orderCarRecordRepository; + @Autowired + private OrderHotelRecordRepository orderHotelRecordRepository; + @Autowired + private OrderFlightRecordRepository orderFlightRecordRepository; + @Autowired + private OrderTrainRecordRepository orderTrainRecordRepository; + + +} diff --git a/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java index 26d0ae29..edfdd80a 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java @@ -3,6 +3,7 @@ package com.chint.infrastructure.repository; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.repository.OrderCarRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderCarRecordRepository; +import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -44,4 +45,13 @@ public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository { startTime, endTime, startTime, endTime, pageRequest); return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); } + + @Override + public PageResult findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + String lastMonth = DateTimeUtil.lastMonthStr(); + Page res = orderCarRecordRepository. + findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest); + return PageResult.totalPageNum(res.getTotalElements(), res.getContent()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java index 68268d29..5c49ae4d 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java @@ -3,6 +3,7 @@ package com.chint.infrastructure.repository; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.repository.OrderFlightRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderFlightRecordRepository; +import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -42,4 +43,12 @@ public class OrderFlightRecordRepositoryImpl implements OrderFlightRecordReposit return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); } + @Override + public PageResult findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + String lastMonth = DateTimeUtil.lastMonthStr(); + Page res = jdbcOrderFlightRecordRepository. + findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest); + return PageResult.totalPageNum(res.getTotalElements(), res.getContent()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java index 23c216ef..8c13259b 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java @@ -1,8 +1,10 @@ package com.chint.infrastructure.repository; +import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.domain.repository.OrderHotelRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository; +import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -41,4 +43,13 @@ public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepositor startTime, endTime, startTime, endTime, pageRequest); return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); } + + @Override + public PageResult findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + String lastMonth = DateTimeUtil.lastMonthStr(); + Page res = jdbcOrderHotelRecordRepository. + findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest); + return PageResult.totalPageNum(res.getTotalElements(), res.getContent()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java index 64041ced..e098a800 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java @@ -3,6 +3,7 @@ package com.chint.infrastructure.repository; import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; import com.chint.domain.repository.OrderTrainRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderTrainRecordRepository; +import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -40,4 +41,13 @@ public class OrderTrainRecordRepositoryImpl implements OrderTrainRecordRepositor startTime, endTime, startTime, endTime, pageRequest); return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); } + + @Override + public PageResult findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + String lastMonth = DateTimeUtil.lastMonthStr(); + Page res = jdbcOrderTrainRecordRepository. + findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest); + return PageResult.totalPageNum(res.getTotalElements(), res.getContent()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java index 6e0a4bdc..d8ec2073 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java @@ -15,5 +15,8 @@ public interface JdbcOrderCarRecordRepository extends CrudRepository findByDetailId(String detailId); Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); + + Page findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable); + Page findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java index e6dd5c8d..81b3fe7c 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java @@ -14,5 +14,7 @@ public interface JdbcOrderFlightRecordRepository extends CrudRepository findByDetailId(String detailId); Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); + + Page findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable); Page findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java index 658e713c..f3059438 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java @@ -1,6 +1,5 @@ package com.chint.infrastructure.repository.jdbc; -import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -16,5 +15,8 @@ public interface JdbcOrderHotelRecordRepository extends CrudRepository findByDetailId(String detailId); Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); + + Page findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable); + Page findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java index 690dc56c..64736afc 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java @@ -14,6 +14,7 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository findByDetailId(String detailId); Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); + Page findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable); Page findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable); } diff --git a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java index 347d89c2..a9b50110 100644 --- a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java +++ b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java @@ -1,7 +1,9 @@ package com.chint.infrastructure.util; +import java.time.Instant; import java.time.LocalDateTime; import java.time.YearMonth; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; public class DateTimeUtil { @@ -14,6 +16,11 @@ public class DateTimeUtil { private final static DateTimeFormatter formatterDateYYYYMMDD = DateTimeFormatter.ofPattern("yyyyMMdd"); + public static String timeFromInstant(Long instant) { + LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(instant), ZoneId.systemDefault()); + return formatter.format(localDateTime); + } + public static String timeToStr(LocalDateTime input) { return input.format(formatterDate); } @@ -53,4 +60,13 @@ public class DateTimeUtil { return yearMonth.atEndOfMonth().atTime(23, 59, 59); } + public static String lastMonthStr() { + // 获取当前日期和时间 + LocalDateTime currentDateTime = LocalDateTime.now(); + // 获取上个月的同一时间 + LocalDateTime lastMonthDateTime = currentDateTime.minusMonths(1); + // 指定所需格式 + // 格式化日期时间 + return lastMonthDateTime.format(formatterDateYYYYMM); + } } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 0a70fb33..fcb90b91 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -55,6 +55,7 @@ import java.util.*; import java.util.stream.Collectors; import static com.chint.infrastructure.constant.LocationConstant.*; +import static com.chint.infrastructure.util.DateTimeUtil.lastMonthStr; @Slf4j @SpringBootTest @@ -1249,9 +1250,10 @@ class RouteApplicationTests { orderDomainService.checkCompanyNameIfBlack("乐清正泰电器销售有限公司"); } -// @Test + @Test void testSplid(){ String str = "20240301"; System.out.println(str.substring(0, 5)); + System.out.println(lastMonthStr()); } }