From 88872c2922af92610d9157bb5bc0318ce5fa8f81 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 13 Jun 2024 13:36:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=93=E7=AE=97=E6=8B=89=E5=8F=96?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9B=B4=E5=A4=9A=E6=8B=89=E5=8F=96=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/OrderRecordGenerateCommand.java | 5 + .../application/dtos/RecordMonthSaveDTO.java | 1 + .../application/in/AutoWorkController.java | 1 + .../domain/aggregates/order/Location.java | 20 +- .../domain/repository/LocationRepository.java | 3 + .../domain/service/LocationDomainService.java | 46 ++- .../service/auth/AuthenticateServiceImpl.java | 7 +- .../order_record/CTripOrderRecordPuller.java | 8 +- .../repository/CTripOrderDetailImpl.java | 33 +- .../repository/LocationRepositoryImpl.java | 5 + .../jdbc/JdbcLocationRepository.java | 1 + .../infrastructure/util/DateTimeUtil.java | 2 +- .../ctrip/dto/order/BaseOrderResponse.java | 9 + .../ctrip/dto/order/OrderCarResponse.java | 4 +- .../ctrip/dto/order/OrderFlightResponse.java | 3 +- .../ctrip/dto/order/OrderHotelResponse.java | 5 +- .../ctrip/order/CTripOrderDetailRequest.java | 112 +++++-- .../ctrip/order/CTripOrderRecordAutoSave.java | 313 ++++++++++-------- src/test/java/com/chint/CTripTest.java | 5 +- src/test/java/com/chint/LYTest.java | 4 +- src/test/java/com/chint/ManageTest.java | 2 +- .../java/com/chint/RouteApplicationTests.java | 21 +- 22 files changed, 426 insertions(+), 184 deletions(-) create mode 100644 src/main/java/com/chint/interfaces/rest/ctrip/dto/order/BaseOrderResponse.java diff --git a/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java b/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java index 94aa3419..276fcf97 100644 --- a/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java +++ b/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java @@ -36,4 +36,9 @@ public class OrderRecordGenerateCommand extends Command { this.setDate(date); return this; } + + public OrderRecordGenerateCommand oneDate(String oneDate) { + this.setOneDate(oneDate); + return this; + } } diff --git a/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java b/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java index d3c50b0e..7cbd348c 100644 --- a/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java +++ b/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java @@ -7,4 +7,5 @@ public class RecordMonthSaveDTO { private String date; private String supplierName; private Integer productType; + private String oneDate; } diff --git a/src/main/java/com/chint/application/in/AutoWorkController.java b/src/main/java/com/chint/application/in/AutoWorkController.java index 6828d763..6c55da04 100644 --- a/src/main/java/com/chint/application/in/AutoWorkController.java +++ b/src/main/java/com/chint/application/in/AutoWorkController.java @@ -103,6 +103,7 @@ public class AutoWorkController { .of(param.getSupplierName(), OrderRecordPuller.class); //将昨天的结算数据生成为财务共享需要的数据 OrderRecordGenerateCommand command = Command.of(OrderRecordGenerateCommand.class) + .oneDate(param.getOneDate()) .supplierName(param.getSupplierName()); if (date != null) { command.startTime(DateTimeUtil.firstDayOfMonth(date)) diff --git a/src/main/java/com/chint/domain/aggregates/order/Location.java b/src/main/java/com/chint/domain/aggregates/order/Location.java index 3083296c..e59ac34d 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Location.java +++ b/src/main/java/com/chint/domain/aggregates/order/Location.java @@ -5,11 +5,14 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.data.annotation.Id; +import org.springframework.data.annotation.Transient; import org.springframework.data.relational.core.mapping.Column; import org.springframework.data.relational.core.mapping.Table; import java.io.Serial; import java.io.Serializable; +import java.util.List; +import java.util.Objects; @Data @AllArgsConstructor @@ -33,8 +36,23 @@ public class Location implements Serializable { private Long cityId; private Integer isHaveAirport; private Integer locationType; + @Transient + private List childLocationList; - public boolean isInternal(){ + public boolean isInternal() { return isInternal == 1; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Location location = (Location) o; + return Objects.equals(locationPath, location.locationPath) && Objects.equals(locationPathName, location.locationPathName) && Objects.equals(locationName, location.locationName) && Objects.equals(locationEnName, location.locationEnName) && Objects.equals(locationShortName, location.locationShortName) && Objects.equals(firstPinYin, location.firstPinYin) && Objects.equals(parentLocationId, location.parentLocationId) && Objects.equals(isInternal, location.isInternal) && Objects.equals(level, location.level) && Objects.equals(cityId, location.cityId) && Objects.equals(isHaveAirport, location.isHaveAirport) && Objects.equals(locationType, location.locationType) && Objects.equals(childLocationList, location.childLocationList); + } + + @Override + public int hashCode() { + return Objects.hash(locationPath, locationPathName, locationName, locationEnName, locationShortName, firstPinYin, parentLocationId, isInternal, level, cityId, isHaveAirport, locationType, childLocationList); + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index 67c7dcd4..9de37d87 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -19,6 +19,7 @@ public interface LocationRepository { List findAll(); + Location findByCityIdAndLevelThree(Long cityId); Location findByCityIdAndLevelFour(Long cityId); @@ -56,6 +57,8 @@ public interface LocationRepository { Location findByCityName(String localName); + List findByParentId(Long parentId); + Location findByDistrictShotName(String name); List findChinaCityByLevel(String locationNames, Integer level); diff --git a/src/main/java/com/chint/domain/service/LocationDomainService.java b/src/main/java/com/chint/domain/service/LocationDomainService.java index e6250693..9562b23c 100644 --- a/src/main/java/com/chint/domain/service/LocationDomainService.java +++ b/src/main/java/com/chint/domain/service/LocationDomainService.java @@ -9,7 +9,8 @@ import com.chint.infrastructure.constant.LocationConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; import static com.chint.infrastructure.constant.LocationConstant.*; @@ -53,4 +54,47 @@ public class LocationDomainService { default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); }; } + + public List queryLocationAndChildren() { + // 1. 加载所有的 Location 到内存中 + List allLocations = locationRepository.findAll().stream().distinct().toList(); + + // 2. 将 Location 根据 ParentId 分组 + Map> locationsByParentId = allLocations.stream() + .filter(location -> location.getParentLocationId() != null) + .collect(Collectors.groupingBy(Location::getParentLocationId)); + + // 3. 递归设置子 Location + List rootLocations = new ArrayList<>(); + Set visited = new HashSet<>(); + for (Location location : allLocations) { + if (location.getParentLocationId() == null) { + rootLocations.add(location); + } + if (!location.getLocationType().equals(LOCATION_TYPE_COUNTY) && + !location.getLocationType().equals(LOCATION_TYPE_DISTRICT) && + !location.getLocationType().equals(LOCATION_TYPE_AIRPORT)) { + if (!visited.contains(location.getLocationId())) { + location.setChildLocationList(getChildren(location.getLocationId(), locationsByParentId, visited)); + } + } + } + + return rootLocations; + } + + private List getChildren(Long parentId, Map> locationsByParentId, Set visited) { + List children = locationsByParentId.getOrDefault(parentId, Collections.emptyList()); + for (Location child : children) { + if (!visited.contains(child.getLocationId())) { + visited.add(child.getLocationId()); + if (!child.getLocationType().equals(LOCATION_TYPE_COUNTY) && + !child.getLocationType().equals(LOCATION_TYPE_DISTRICT) && + !child.getLocationType().equals(LOCATION_TYPE_AIRPORT)) { + child.setChildLocationList(getChildren(child.getLocationId(), locationsByParentId, visited)); + } + } + } + return children; + } } diff --git a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java index 021d2766..39192dd6 100644 --- a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java +++ b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java @@ -73,7 +73,10 @@ public class AuthenticateServiceImpl implements AuthenticateService { private UserLoginResult getUserLoginResult(User user) { UserLoginParam userLoginParam = user.getUserLoginParam(); - user.setCompanyCode(userLoginParam.getCompanyCode()); + String companyCode = userLoginParam.getCompanyCode(); + if (companyCode != null && !companyCode.isEmpty()) { + user.setCompanyCode(companyCode); + } user.setUserLoginParam(userLoginParam); List fsscSystemList = user.getFsscSystemList(); Map claims = new HashMap<>(); @@ -95,7 +98,7 @@ public class AuthenticateServiceImpl implements AuthenticateService { } @Override - public Token authenticateClient(AuthenticationDto authenticationDto) { + public Token authenticateClient(AuthenticationDto authenticationDto) { //区分测试环境还是正式环境 String clientType; if (envMark.equals("prod")) { diff --git a/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java b/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java index 910e27f9..be290029 100644 --- a/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java +++ b/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java @@ -18,7 +18,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller { @Override public boolean pullTrainOrderRecord(OrderRecordGenerateCommand command) { try { - cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable(command.getDate())); + cTripOrderRecordAutoSave.cTripCarRecordAutoSave(command); } catch (Exception e) { e.printStackTrace(); return false; @@ -29,7 +29,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller { @Override public boolean pullFlightOrderRecord(OrderRecordGenerateCommand command) { try { - cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(Optional.ofNullable(command.getDate())); + cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(command); } catch (Exception e) { e.printStackTrace(); return false; @@ -40,7 +40,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller { @Override public boolean pullHotelOrderRecord(OrderRecordGenerateCommand command) { try { - cTripOrderRecordAutoSave.cTripHotelRecordAutoSave(Optional.ofNullable(command.getDate())); + cTripOrderRecordAutoSave.cTripHotelRecordAutoSave(command); } catch (Exception e) { e.printStackTrace(); return false; @@ -51,7 +51,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller { @Override public boolean pullCarOrderRecord(OrderRecordGenerateCommand command) { try { - cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable(command.getDate())); + cTripOrderRecordAutoSave.cTripCarRecordAutoSave(command); } catch (Exception e) { e.printStackTrace(); return false; diff --git a/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java b/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java index 0c5d3269..0019c7fe 100644 --- a/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java @@ -117,7 +117,16 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository { @Override public void saveAllCTripFlightRecord(List cTripFlightRecordList) { - jdbcCTripFlightRecordRepository.saveAll(cTripFlightRecordList); + if (cTripFlightRecordList.size() > 1000) { + int batchSize = 1000; + for (int i = 0; i < cTripFlightRecordList.size(); i += batchSize) { + int end = Math.min(i + batchSize, cTripFlightRecordList.size()); + List batch = cTripFlightRecordList.subList(i, end); + jdbcCTripFlightRecordRepository.saveAll(batch); + } + } else { + jdbcCTripFlightRecordRepository.saveAll(cTripFlightRecordList); + } } @Override @@ -137,7 +146,16 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository { @Override public void saveAllCTripHotelRecord(List cTripHotelRecordList) { - jdbcCTripHotelRecordRepository.saveAll(cTripHotelRecordList); + if (cTripHotelRecordList.size() > 1000) { + int batchSize = 1000; + for (int i = 0; i < cTripHotelRecordList.size(); i += batchSize) { + int end = Math.min(i + batchSize, cTripHotelRecordList.size()); + List batch = cTripHotelRecordList.subList(i, end); + jdbcCTripHotelRecordRepository.saveAll(batch); + } + } else { + jdbcCTripHotelRecordRepository.saveAll(cTripHotelRecordList); + } } @Override @@ -172,7 +190,16 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository { @Override public void saveAllCTripCarRecord(List cTripCarRecordList) { - jdbcCTripCarRecordRepository.saveAll(cTripCarRecordList); + if (cTripCarRecordList.size() > 1000) { + int batchSize = 1000; + for (int i = 0; i < cTripCarRecordList.size(); i += batchSize) { + int end = Math.min(i + batchSize, cTripCarRecordList.size()); + List batch = cTripCarRecordList.subList(i, end); + jdbcCTripCarRecordRepository.saveAll(batch); + } + } else { + jdbcCTripCarRecordRepository.saveAll(cTripCarRecordList); + } } @Override diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 5db7fd96..4eead97b 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -184,6 +184,11 @@ public class LocationRepositoryImpl implements LocationRepository { return jdbcLocationRepository.findByLocationNameAndLevelOrLocationNameAndLevel(localName, 3, localName, 4); } + @Override + public List findByParentId(Long parentId) { + return jdbcLocationRepository.findByParentLocationId(parentId); + } + @Override public Location findByDistrictShotName(String name) { diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java index 9fa61443..b1d04737 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -11,6 +11,7 @@ import java.util.List; @Repository public interface JdbcLocationRepository extends CrudRepository { + List findByParentLocationId(Long parentLocationId); Location findByCityIdAndLocationShortName(Long cityId, String locationShortName); diff --git a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java index 34f48d0f..ff187dcb 100644 --- a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java +++ b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java @@ -39,7 +39,7 @@ public class DateTimeUtil { } public static LocalDateTime strToTimeYYYYMMDD(String input) { - return LocalDateTime.parse(input, formatterDateYYYYMMDD); + return LocalDate.parse(input, formatterDateYYYYMMDD).atStartOfDay(); } public static LocalDateTime strToTime(String input) { diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/BaseOrderResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/BaseOrderResponse.java new file mode 100644 index 00000000..92e56311 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/BaseOrderResponse.java @@ -0,0 +1,9 @@ +package com.chint.interfaces.rest.ctrip.dto.order; + +import lombok.Data; + +@Data +public class BaseOrderResponse { + private Integer TotalSize; + private Integer TotalRecord; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderCarResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderCarResponse.java index f4c979e6..d25f7aff 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderCarResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderCarResponse.java @@ -1,13 +1,15 @@ package com.chint.interfaces.rest.ctrip.dto.order; import com.chint.domain.aggregates.order.CarOrderDetail; +import com.chint.interfaces.rest.amap.BaseResponse; +import io.swagger.models.auth.In; import lombok.Data; import java.math.BigDecimal; import java.util.List; @Data -public class OrderCarResponse { +public class OrderCarResponse extends BaseOrderResponse { private List CarOrderAccountSettlementList; private ResponseStatus Status; diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java index 57b81fc8..dac5394f 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java @@ -1,12 +1,13 @@ package com.chint.interfaces.rest.ctrip.dto.order; +import com.chint.interfaces.rest.amap.BaseResponse; import lombok.Data; import java.util.Date; import java.util.List; @Data -public class OrderFlightResponse { +public class OrderFlightResponse extends BaseOrderResponse { private List FlightOrderAccountSettlementList; private Status Status; diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderHotelResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderHotelResponse.java index f0d5b193..5819ed3f 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderHotelResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderHotelResponse.java @@ -1,12 +1,13 @@ package com.chint.interfaces.rest.ctrip.dto.order; +import com.chint.interfaces.rest.amap.BaseResponse; import lombok.Data; import java.math.BigDecimal; import java.util.List; @Data -public class OrderHotelResponse { +public class OrderHotelResponse extends BaseOrderResponse { private List LstHtlSettlement; private Status Status; @@ -80,6 +81,7 @@ public class OrderHotelResponse { private BigDecimal averagePrice; } + @lombok.Data public static class SettlementOrderDetail { private long OrderId; @@ -246,7 +248,6 @@ public class OrderHotelResponse { } - @lombok.Data public static class SettlementHotelDetail { private String HotelName; diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java index 9fbb2d5d..44e17601 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderDetailRequest.java @@ -12,6 +12,11 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.BiConsumer; import static com.chint.infrastructure.constant.CTripConstant.*; @@ -59,17 +64,13 @@ public class CTripOrderDetailRequest { public OrderFlightResponse getFlightOrder() { LocalDateTime now = LocalDateTime.now(); LocalDateTime localDateTime = now.minusDays(1L); - return postRequest.post(flightOrderUrl, - getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)), - OrderFlightResponse.class); + return pageQueryFlightResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now))); } public OrderFlightResponse getFlightOrder(String oneDate) { LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate); LocalDateTime localDateTime = oneDateL.minusDays(1L); - return postRequest.post(flightOrderUrl, - getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)), - OrderFlightResponse.class); + return pageQueryFlightResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL))); } public OrderFlightResponse getFlightOrderByDate(String date) { @@ -79,8 +80,8 @@ public class CTripOrderDetailRequest { public OrderFlightResponse getFlightOrder(String dateFrom, String dateTo) { - return postRequest.post(flightOrderUrl, getParamByBatch(dateFrom, dateTo), - OrderFlightResponse.class); + + return pageQueryFlightResponse(getParamByBatch(dateFrom, dateTo)); } public OrderHotelResponse getHotelOrderByDate(String date) { @@ -91,22 +92,17 @@ public class CTripOrderDetailRequest { public OrderHotelResponse getHotelOrder() { LocalDateTime now = LocalDateTime.now(); LocalDateTime localDateTime = now.minusDays(1L); - return postRequest.post(hotelOrderUrl, - getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)), - OrderHotelResponse.class); + return pageQueryHotelResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now))); } public OrderHotelResponse getHotelOrder(String oneDate) { LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate); LocalDateTime localDateTime = oneDateL.minusDays(1L); - return postRequest.post(hotelOrderUrl, - getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)), - OrderHotelResponse.class); + return pageQueryHotelResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL))); } public OrderHotelResponse getHotelOrder(String dateFrom, String dateTo) { - return postRequest.post(hotelOrderUrl, getParamByBatch(dateFrom, dateTo), - OrderHotelResponse.class); + return pageQueryHotelResponse(getParamByBatch(dateFrom, dateTo)); } public OrderTrainResponse getTrainOrderByDate(String date) { @@ -145,22 +141,17 @@ public class CTripOrderDetailRequest { public OrderCarResponse getCarOrder() { LocalDateTime now = LocalDateTime.now(); LocalDateTime localDateTime = now.minusDays(1L); - return postRequest.post(carOrderUrl, - getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)), - OrderCarResponse.class); + return pageQueryCarResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now))); } public OrderCarResponse getCarOrder(String oneDate) { LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate); LocalDateTime localDateTime = oneDateL.minusDays(1L); - return postRequest.post(carOrderUrl, - getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)), - OrderCarResponse.class); + return pageQueryCarResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL))); } public OrderCarResponse getCarOrder(String dateFrom, String dateTo) { - return postRequest.post(carOrderUrl, getParamByBatch(dateFrom, dateTo), - OrderCarResponse.class); + return pageQueryCarResponse(getParamByBatch(dateFrom, dateTo)); } private OrderRecordParam getParamByDateFromAndDateTo(String dateFrom, String dateTo) { @@ -191,4 +182,77 @@ public class CTripOrderDetailRequest { orderFlightParam.setTicket(ticketRequest.loadTicket()); return orderFlightParam; } + + private OrderHotelResponse pageQueryHotelResponse(OrderRecordParam param) { + return pageQueryResponse( + param, + hotelOrderUrl, + OrderHotelResponse.class, + (initialResponse, response) -> initialResponse.getLstHtlSettlement() + .addAll(response.getLstHtlSettlement()) + ); + } + + private OrderFlightResponse pageQueryFlightResponse(OrderRecordParam param) { + return pageQueryResponse( + param, + flightOrderUrl, + OrderFlightResponse.class, + (initialResponse, response) -> initialResponse.getFlightOrderAccountSettlementList() + .addAll(response.getFlightOrderAccountSettlementList()) + ); + } + + private OrderCarResponse pageQueryCarResponse(OrderRecordParam param) { + return pageQueryResponse( + param, + carOrderUrl, + OrderCarResponse.class, + (initialResponse, response) -> initialResponse.getCarOrderAccountSettlementList() + .addAll(response.getCarOrderAccountSettlementList()) + ); + } + + private T pageQueryResponse(OrderRecordParam param, String url, Class responseType, BiConsumer mergeFunction) { + param.setPageIndex(1); + param.setPageSize(100); + + // Initial request to get total size + T initialResponse = postRequest.post(url, param, responseType); + int totalSize = initialResponse.getTotalSize(); + + // List to hold all CompletableFuture instances + List> futures = new ArrayList<>(); + futures.add(CompletableFuture.completedFuture(initialResponse)); // Add initial response + + // Create CompletableFuture for each page + for (int i = 2; i <= totalSize; i++) { + int pageIndex = i; + CompletableFuture future = CompletableFuture.supplyAsync(() -> { + param.setPageIndex(pageIndex); + return postRequest.post(url, param, responseType); + }); + futures.add(future); + } + + // Combine all responses + CompletableFuture allOf = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); + CompletableFuture combinedFuture = allOf.thenApply(v -> { + futures.forEach(future -> { + try { + T response = future.get(); + mergeFunction.accept(initialResponse, response); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }); + return initialResponse; + }); + + try { + return combinedFuture.get(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java index 55e66df6..8b6f9798 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java @@ -1,5 +1,6 @@ package com.chint.interfaces.rest.ctrip.order; +import com.chint.application.commands.OrderRecordGenerateCommand; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*; import com.chint.domain.repository.CTripOrderDetailRepository; import com.chint.infrastructure.util.DateTimeUtil; @@ -42,86 +43,107 @@ public class CTripOrderRecordAutoSave { this.cTripCarRecordAutoSave(Optional.of(date)); } + public void cTripFlightRecordAutoSave(Optional date) { OrderFlightResponse flightOrder = date .flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getFlightOrderByDate(it))) .orElseGet(() -> cTripOrderDetailRequest.getFlightOrder()); - List flightOrderAccountSettlementList = flightOrder - .getFlightOrderAccountSettlementList(); + cTripFlightRecordAutoSave(flightOrder); + } + + public void cTripFlightRecordAutoSave(OrderRecordGenerateCommand command) { + OrderFlightResponse response = Optional.ofNullable(command.getOneDate()) + .map(cTripOrderDetailRequest::getFlightOrder) + .or(() -> Optional.ofNullable(command.getDate()) + .flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getFlightOrderByDate(it)))) + .orElseGet(cTripOrderDetailRequest::getFlightOrder); + cTripFlightRecordAutoSave(response); + } + + private void cTripFlightRecordAutoSave(OrderFlightResponse response) { + List flightOrderAccountSettlementList = response.getFlightOrderAccountSettlementList(); if (flightOrderAccountSettlementList != null && !flightOrderAccountSettlementList.isEmpty()) { - List flightOrderSettlementInfos = flightOrderAccountSettlementList - .stream() + List recordIds = flightOrderAccountSettlementList.stream() .flatMap(it -> it.getOrderSettlementList().stream()) - .toList(); - List recordIds = flightOrderSettlementInfos - .stream() .map(it -> String.valueOf(it.getOrderSettlementBaseInfo().getRecordID())) .toList(); Map cTripFlightRecordMap = cTripOrderDetailRepository.findFlightRecordByRecordIdIn(recordIds) .stream() .collect(Collectors.toMap(CTripFlightRecord::getRecordId, Function.identity())); - - List cTripFlightRecords = flightOrderSettlementInfos.stream() - .map(it -> { - //对数据库进行查找 ,如果发现已经存在 , 就使用查找出来的 - OrderFlightResponse.FlightOrderSettlementBaseInfo orderSettlementBaseInfo = it.getOrderSettlementBaseInfo(); - OrderFlightResponse.FlightTripRecordInfo flightTripRecordInfo = it.getFlightTripRecordInfo(); - CTripFlightRecord record = cTripFlightRecordMap.get(String.valueOf(orderSettlementBaseInfo.getRecordID())); - if (record == null) { - record = CTripFlightRecord.of( - CTripFlightRecordBase.changeInfo(orderSettlementBaseInfo), - CTripFlightInfo.of(it.getOrderFlightInfo()), - CTripFlightBaseInfo.of(it.getOrderBaseInfo()), - CTripFlightTripInfo.of(flightTripRecordInfo)); - } else { - Long originId = record.getId(); - record = CTripFlightRecord.of( - CTripFlightRecordBase.changeInfo(orderSettlementBaseInfo), - CTripFlightInfo.of(it.getOrderFlightInfo()), - CTripFlightBaseInfo.of(it.getOrderBaseInfo()), - CTripFlightTripInfo.of(flightTripRecordInfo)); - record.setId(originId); - } - if (it.getOrderPrintDetailInfo() != null) { - record.printInfo(CTripFlightPrintInfo.of(it.getOrderPrintDetailInfo())); - } - //补充额外的字段 - OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo(); - record.setRouteOrderNo(orderBaseInfo.getJourneyID()); - OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo(); - - if (orderPassengerInfo != null) { - record.setTicketNo(orderPassengerInfo.getTicketNo()); - record.setUserCode(orderPassengerInfo.getEmployeeID()); - record.setUserName(orderPassengerInfo.getPassengerName()); - } else { - record.setUserCode(orderBaseInfo.getEmployeeID()); - record.setUserName(orderBaseInfo.getName()); - } - record.setBookingUserCode(orderBaseInfo.getPreEmployeeID()); - record.setBookingUserName(orderBaseInfo.getName()); - record.setBookingUserPhone(""); - return record; - }).toList(); + List cTripFlightRecords = flightOrderAccountSettlementList.stream() + .flatMap(it -> it.getOrderSettlementList().stream()) + .map(it -> createOrUpdateFlightRecord(it, cTripFlightRecordMap)) + .distinct() + .toList(); cTripOrderDetailRepository.saveAllCTripFlightRecord(cTripFlightRecords); } } + private CTripFlightRecord createOrUpdateFlightRecord(OrderFlightResponse.FlightOrderSettlementInfo it, Map cTripFlightRecordMap) { + OrderFlightResponse.FlightOrderSettlementBaseInfo orderSettlementBaseInfo = it.getOrderSettlementBaseInfo(); + OrderFlightResponse.FlightTripRecordInfo flightTripRecordInfo = it.getFlightTripRecordInfo(); + CTripFlightRecord record = cTripFlightRecordMap.get(String.valueOf(orderSettlementBaseInfo.getRecordID())); + + if (record == null) { + record = CTripFlightRecord.of( + CTripFlightRecordBase.changeInfo(orderSettlementBaseInfo), + CTripFlightInfo.of(it.getOrderFlightInfo()), + CTripFlightBaseInfo.of(it.getOrderBaseInfo()), + CTripFlightTripInfo.of(flightTripRecordInfo)); + } else { + Long originId = record.getId(); + record = CTripFlightRecord.of( + CTripFlightRecordBase.changeInfo(orderSettlementBaseInfo), + CTripFlightInfo.of(it.getOrderFlightInfo()), + CTripFlightBaseInfo.of(it.getOrderBaseInfo()), + CTripFlightTripInfo.of(flightTripRecordInfo)); + record.setId(originId); + } + + if (it.getOrderPrintDetailInfo() != null) { + record.printInfo(CTripFlightPrintInfo.of(it.getOrderPrintDetailInfo())); + } + + // 补充额外的字段 + OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo(); + record.setRouteOrderNo(orderBaseInfo.getJourneyID()); + + OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo(); + if (orderPassengerInfo != null) { + record.setTicketNo(orderPassengerInfo.getTicketNo()); + record.setUserCode(orderPassengerInfo.getEmployeeID()); + record.setUserName(orderPassengerInfo.getPassengerName()); + } else { + record.setUserCode(orderBaseInfo.getEmployeeID()); + record.setUserName(orderBaseInfo.getName()); + } + record.setBookingUserCode(orderBaseInfo.getPreEmployeeID()); + record.setBookingUserName(orderBaseInfo.getName()); + record.setBookingUserPhone(""); + return record; + } public void cTripHotelRecordAutoSave(Optional date) { - OrderHotelResponse hotelOrder = date .flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getHotelOrderByDate(it))) .orElseGet(() -> cTripOrderDetailRequest.getHotelOrder()); + cTripHotelRecordAutoSave(hotelOrder); + } - List lstHtlSettlement = hotelOrder.getLstHtlSettlement(); + public void cTripHotelRecordAutoSave(OrderRecordGenerateCommand command){ + OrderHotelResponse response = Optional.ofNullable(command.getOneDate()) + .map(cTripOrderDetailRequest::getHotelOrder) + .or(() -> Optional.ofNullable(command.getDate()) + .flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getHotelOrder(it)))) + .orElseGet(cTripOrderDetailRequest::getHotelOrder); + cTripHotelRecordAutoSave(response); + } + + private void cTripHotelRecordAutoSave(OrderHotelResponse response) { + List lstHtlSettlement = response.getLstHtlSettlement(); if (lstHtlSettlement != null && !lstHtlSettlement.isEmpty()) { - List hotelSettlementDetailList = lstHtlSettlement.stream() + List recordIds = lstHtlSettlement.stream() .flatMap(it -> it.getLstHotelSettlementDetail().stream()) - .toList(); - - List recordIds = hotelSettlementDetailList - .stream() .map(it -> String.valueOf(it.getSettlementDetail().getRecordId())) .toList(); @@ -129,42 +151,48 @@ public class CTripOrderRecordAutoSave { .stream() .collect(Collectors.toMap(CTripHotelRecord::getRecordId, Function.identity())); - List list = hotelSettlementDetailList.stream() - .map(it -> { - OrderHotelResponse.SettlementDetail settlementDetail = it.getSettlementDetail(); - CTripHotelRecord record = cTripHotelRecordMap.get(String.valueOf(settlementDetail.getRecordId())); - OrderHotelResponse.SettlementOrderDetail settlementOrderDetail = it.getOrderDetail(); - if (record == null) { - record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), - CTripHotelInfo.of(it.getHotelDetail()), - CTripHotelOrderDetail.of(settlementOrderDetail)); - } else { - Long originId = record.getId(); - record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), - CTripHotelInfo.of(it.getHotelDetail()), - CTripHotelOrderDetail.of(settlementOrderDetail)); - record.setId(originId); - } - //补充额外的字段 - - record.setRouteOrderNo(settlementOrderDetail.getHotelRelatedJourneyNo()); - List clientDetailList = settlementOrderDetail.getClientDetailList(); - if (clientDetailList != null && !clientDetailList.isEmpty()) { - OrderHotelResponse.SettlementClientDetail settlementClientDetail = clientDetailList.get(0); - record.setUserCode(settlementClientDetail.getEmployeeID()); - record.setUserName(settlementOrderDetail.getClientName()); - } - record.setBookingUserCode(settlementOrderDetail.getEmployeeID()); - record.setBookingUserName(settlementOrderDetail.getEmployeeName()); - record.setBookingUserPhone(""); - return record; - }).toList(); - Map> collect = list.stream() - .collect(Collectors.groupingBy(record -> record.getId() != null)); - collect.values().forEach(it -> cTripOrderDetailRepository.saveAllCTripHotelRecord(it)); + List list = lstHtlSettlement.stream() + .flatMap(it -> it.getLstHotelSettlementDetail().stream()) + .map(it -> createOrUpdateHotelRecord(it, cTripHotelRecordMap)) + .distinct() + .toList(); + cTripOrderDetailRepository.saveAllCTripHotelRecord(list); } } + private CTripHotelRecord createOrUpdateHotelRecord(OrderHotelResponse.LstHotelSettlementDetail it, Map cTripHotelRecordMap) { + OrderHotelResponse.SettlementDetail settlementDetail = it.getSettlementDetail(); + CTripHotelRecord record = cTripHotelRecordMap.get(String.valueOf(settlementDetail.getRecordId())); + OrderHotelResponse.SettlementOrderDetail settlementOrderDetail = it.getOrderDetail(); + + if (record == null) { + record = CTripHotelRecord.of( + CTripHotelRecordBase.changeInfo(settlementDetail), + CTripHotelInfo.of(it.getHotelDetail()), + CTripHotelOrderDetail.of(settlementOrderDetail)); + } else { + Long originId = record.getId(); + record = CTripHotelRecord.of( + CTripHotelRecordBase.changeInfo(settlementDetail), + CTripHotelInfo.of(it.getHotelDetail()), + CTripHotelOrderDetail.of(settlementOrderDetail)); + record.setId(originId); + } + + // 补充额外的字段 + record.setRouteOrderNo(settlementOrderDetail.getHotelRelatedJourneyNo()); + List clientDetailList = settlementOrderDetail.getClientDetailList(); + if (clientDetailList != null && !clientDetailList.isEmpty()) { + OrderHotelResponse.SettlementClientDetail settlementClientDetail = clientDetailList.get(0); + record.setUserCode(settlementClientDetail.getEmployeeID()); + record.setUserName(settlementOrderDetail.getClientName()); + } + record.setBookingUserCode(settlementOrderDetail.getEmployeeID()); + record.setBookingUserName(settlementOrderDetail.getEmployeeName()); + record.setBookingUserPhone(""); + return record; + } + public void cTripTrainRecordAutoSave(Optional date) { @@ -201,65 +229,76 @@ public class CTripOrderRecordAutoSave { OrderCarResponse carOrder = date .flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrderByDate(it))) .orElseGet(() -> cTripOrderDetailRequest.getCarOrder()); + cTripCarRecordAutoSave(carOrder); + } - List settlementList = carOrder.getCarOrderAccountSettlementList(); + public void cTripCarRecordAutoSave(OrderRecordGenerateCommand command){ + OrderCarResponse response = Optional.ofNullable(command.getOneDate()) + .map(cTripOrderDetailRequest::getCarOrder) + .or(() -> Optional.ofNullable(command.getDate()) + .flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrder(it)))) + .orElseGet(cTripOrderDetailRequest::getCarOrder); + cTripCarRecordAutoSave(response); + } + + private void cTripCarRecordAutoSave(OrderCarResponse response) { + List settlementList = response.getCarOrderAccountSettlementList(); if (settlementList != null && !settlementList.isEmpty()) { - List carOrderSettlementDetailList = settlementList.stream() + // 使用流处理,减少中间集合 + List recordIds = settlementList.stream() + .distinct() .flatMap(it -> it.getCarSettlementDetailList().stream()) - .toList(); - - List recordIds = carOrderSettlementDetailList - .stream() .map(it -> String.valueOf(it.getSettlementBaseInfo().getRecordId())) .toList(); Map cTripCarRecordMap = cTripOrderDetailRepository .findCarRecordByRecordIdIn(recordIds) .stream() - .collect(Collectors.toMap(CTripCarRecord::getRecordId, Function.identity())); + .collect(Collectors.toMap(CTripCarRecord::getRecordId, Function.identity(), (existing, replacement) -> existing)); + List list = settlementList.stream() + .flatMap(it -> it.getCarSettlementDetailList().stream()) + .map(it -> createOrUpdateRecord(it, cTripCarRecordMap)) + .distinct() + .toList(); - List list = carOrderSettlementDetailList.stream() - .map(it -> { - OrderCarResponse.CarOrderDetail orderDetail = it.getOrderDetail(); - OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = it.getSettlementBaseInfo(); - CTripCarRecord record = cTripCarRecordMap.get(String.valueOf(settlementBaseInfo.getRecordId())); - - List passengerInfoList = orderDetail.getPassengerInfoList(); - OrderCarResponse.CarOrderPassengerInfo carOrderPassengerInfo = passengerInfoList.get(0); - - if (record == null) { - record = CTripCarRecord.of( - CTripCarRecordBase.changeInfo(settlementBaseInfo), - CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()), - CTripCarPassengerInfo.of(carOrderPassengerInfo) - ); - } else { - Long originId = record.getId(); - record = CTripCarRecord.of( - CTripCarRecordBase.changeInfo(settlementBaseInfo), - CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()), - CTripCarPassengerInfo.of(carOrderPassengerInfo) - ); - record.setId(originId); - } - //补充额外的字段 - OrderCarResponse.CarOrderCorpInfo corpInfo = orderDetail.getCorpInfo(); - record.setRouteOrderNo(corpInfo.getJouneryId()); - OrderCarResponse.CarOrderBaseInfo orderBaseInfo = orderDetail.getOrderBaseInfo(); - - String orderDate = orderBaseInfo.getOrderDate(); - record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate))); - - - record.setUserCode(carOrderPassengerInfo.getEmployeeID()); - record.setUserName(carOrderPassengerInfo.getPassengerName()); - record.setBookingUserCode(orderBaseInfo.getPreEmployeeID()); - record.setBookingUserName(orderBaseInfo.getUserName()); - record.setBookingUserPhone(orderBaseInfo.getContactMobile()); - return record; - }).toList(); + // 批量保存 cTripOrderDetailRepository.saveAllCTripCarRecord(list); } } + + private CTripCarRecord createOrUpdateRecord(OrderCarResponse.CarOrderSettlementDetail it, Map cTripCarRecordMap) { + OrderCarResponse.CarOrderDetail orderDetail = it.getOrderDetail(); + OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = it.getSettlementBaseInfo(); + CTripCarRecord record = cTripCarRecordMap.get(String.valueOf(settlementBaseInfo.getRecordId())); + List passengerInfoList = orderDetail.getPassengerInfoList(); + OrderCarResponse.CarOrderPassengerInfo carOrderPassengerInfo = passengerInfoList.get(0); + if (record == null) { + record = CTripCarRecord.of( + CTripCarRecordBase.changeInfo(settlementBaseInfo), + CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()), + CTripCarPassengerInfo.of(carOrderPassengerInfo) + ); + } else { + Long originId = record.getId(); + record = CTripCarRecord.of( + CTripCarRecordBase.changeInfo(settlementBaseInfo), + CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()), + CTripCarPassengerInfo.of(carOrderPassengerInfo) + ); + record.setId(originId); + } + // 补充额外的字段 + OrderCarResponse.CarOrderCorpInfo corpInfo = orderDetail.getCorpInfo(); + record.setRouteOrderNo(corpInfo.getJouneryId()); + OrderCarResponse.CarOrderBaseInfo orderBaseInfo = orderDetail.getOrderBaseInfo(); + String orderDate = orderBaseInfo.getOrderDate(); + record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate))); + record.setUserCode(carOrderPassengerInfo.getEmployeeID()); + record.setUserName(carOrderPassengerInfo.getPassengerName()); + record.setBookingUserCode(orderBaseInfo.getPreEmployeeID()); + record.setBookingUserName(orderBaseInfo.getUserName()); + record.setBookingUserPhone(orderBaseInfo.getContactMobile()); + return record; + } } diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index 79b68949..881c477f 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -250,7 +250,7 @@ public class CTripTest { @Test void search() { BaseContext.setCurrentUser(user); - SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31592018105"); + SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31839097186"); System.out.println(response); } @@ -609,7 +609,6 @@ public class CTripTest { @Test void pullCarRecord() { - cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable("202405")); -// cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(Optional.ofNullable("202405")); + cTripOrderRecordAutoSave.cTripHotelRecordAutoSave(Optional.ofNullable("202405")); } } diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 886fbe4f..d042b74d 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -828,7 +828,7 @@ public class LYTest { @Test void searchHotel() { - HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240417095100616718"); + HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240321165300961176"); Gson gson = new Gson(); String json = gson.toJson(hotelOrderDetail); System.out.println(json); @@ -859,7 +859,7 @@ public class LYTest { // System.out.println(json); - TrainDetailResponse trainDetailResponse = lySearchRequest.getTrainOrderDetail("DT24041069650132424"); + TrainDetailResponse trainDetailResponse = lySearchRequest.getTrainOrderDetail("DT24051073034383248"); Gson gson = new Gson(); String json = gson.toJson(trainDetailResponse); System.out.println(json); diff --git a/src/test/java/com/chint/ManageTest.java b/src/test/java/com/chint/ManageTest.java index 1d5a4562..f6c6be7a 100644 --- a/src/test/java/com/chint/ManageTest.java +++ b/src/test/java/com/chint/ManageTest.java @@ -52,7 +52,7 @@ public class ManageTest { @Test void recordAdd(){ OrderPageQuery dto=new OrderPageQuery(); - dto.setOderNo("123"); +// dto.setOderNo("123"); OrderDownloadRecord downloadRecord=OrderDownloadRecord.builder() .fileUrl("url") .status("已完成") diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 56eb018c..4e144051 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -15,6 +15,7 @@ import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHo import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.*; import com.chint.domain.service.JTCompanyDomainService; +import com.chint.domain.service.LocationDomainService; import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.SystemDomainService; import com.chint.domain.service.order_sync.LYOrderSyncAdapter; @@ -53,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; +import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -110,6 +112,9 @@ class RouteApplicationTests { @Autowired private UserRepository userRepository; + @Autowired + private LocationDomainService locationDomainService; + @Value("${FSSC.jt-baseUrl}") private String jtFSSCUrl; @@ -316,7 +321,7 @@ class RouteApplicationTests { @Test void loginSignProd() { - String sfno = "240611055"; + String sfno = "230228069"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; @@ -1472,4 +1477,18 @@ class RouteApplicationTests { void roleTest() { } + + @Test + void exposedLocation(){ + List locations = locationDomainService.queryLocationAndChildren(); + // 将数据转换为JSON格式 + Gson gson = new Gson(); + String json = gson.toJson(locations); + // 将JSON写入txt文件 + try (FileWriter fileWriter = new FileWriter("D:\\data\\locations.txt")) { + fileWriter.write(json); + } catch (IOException e) { + e.printStackTrace(); + } + } }