feat: 结算拉取增加更多拉取方式
This commit is contained in:
parent
925e4c5954
commit
88872c2922
|
@ -36,4 +36,9 @@ public class OrderRecordGenerateCommand extends Command {
|
||||||
this.setDate(date);
|
this.setDate(date);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OrderRecordGenerateCommand oneDate(String oneDate) {
|
||||||
|
this.setOneDate(oneDate);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,5 @@ public class RecordMonthSaveDTO {
|
||||||
private String date;
|
private String date;
|
||||||
private String supplierName;
|
private String supplierName;
|
||||||
private Integer productType;
|
private Integer productType;
|
||||||
|
private String oneDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ public class AutoWorkController {
|
||||||
.of(param.getSupplierName(), OrderRecordPuller.class);
|
.of(param.getSupplierName(), OrderRecordPuller.class);
|
||||||
//将昨天的结算数据生成为财务共享需要的数据
|
//将昨天的结算数据生成为财务共享需要的数据
|
||||||
OrderRecordGenerateCommand command = Command.of(OrderRecordGenerateCommand.class)
|
OrderRecordGenerateCommand command = Command.of(OrderRecordGenerateCommand.class)
|
||||||
|
.oneDate(param.getOneDate())
|
||||||
.supplierName(param.getSupplierName());
|
.supplierName(param.getSupplierName());
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
command.startTime(DateTimeUtil.firstDayOfMonth(date))
|
command.startTime(DateTimeUtil.firstDayOfMonth(date))
|
||||||
|
|
|
@ -5,11 +5,14 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.data.annotation.Id;
|
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.Column;
|
||||||
import org.springframework.data.relational.core.mapping.Table;
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -33,8 +36,23 @@ public class Location implements Serializable {
|
||||||
private Long cityId;
|
private Long cityId;
|
||||||
private Integer isHaveAirport;
|
private Integer isHaveAirport;
|
||||||
private Integer locationType;
|
private Integer locationType;
|
||||||
|
@Transient
|
||||||
|
private List<Location> childLocationList;
|
||||||
|
|
||||||
public boolean isInternal(){
|
public boolean isInternal() {
|
||||||
return isInternal == 1;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ public interface LocationRepository {
|
||||||
|
|
||||||
List<Location> findAll();
|
List<Location> findAll();
|
||||||
|
|
||||||
|
|
||||||
Location findByCityIdAndLevelThree(Long cityId);
|
Location findByCityIdAndLevelThree(Long cityId);
|
||||||
|
|
||||||
Location findByCityIdAndLevelFour(Long cityId);
|
Location findByCityIdAndLevelFour(Long cityId);
|
||||||
|
@ -56,6 +57,8 @@ public interface LocationRepository {
|
||||||
|
|
||||||
Location findByCityName(String localName);
|
Location findByCityName(String localName);
|
||||||
|
|
||||||
|
List<Location> findByParentId(Long parentId);
|
||||||
|
|
||||||
Location findByDistrictShotName(String name);
|
Location findByDistrictShotName(String name);
|
||||||
|
|
||||||
List<Location> findChinaCityByLevel(String locationNames, Integer level);
|
List<Location> findChinaCityByLevel(String locationNames, Integer level);
|
||||||
|
|
|
@ -9,7 +9,8 @@ import com.chint.infrastructure.constant.LocationConstant;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.LocationConstant.*;
|
import static com.chint.infrastructure.constant.LocationConstant.*;
|
||||||
|
|
||||||
|
@ -53,4 +54,47 @@ public class LocationDomainService {
|
||||||
default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND);
|
default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Location> queryLocationAndChildren() {
|
||||||
|
// 1. 加载所有的 Location 到内存中
|
||||||
|
List<Location> allLocations = locationRepository.findAll().stream().distinct().toList();
|
||||||
|
|
||||||
|
// 2. 将 Location 根据 ParentId 分组
|
||||||
|
Map<Long, List<Location>> locationsByParentId = allLocations.stream()
|
||||||
|
.filter(location -> location.getParentLocationId() != null)
|
||||||
|
.collect(Collectors.groupingBy(Location::getParentLocationId));
|
||||||
|
|
||||||
|
// 3. 递归设置子 Location
|
||||||
|
List<Location> rootLocations = new ArrayList<>();
|
||||||
|
Set<Long> 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<Location> getChildren(Long parentId, Map<Long, List<Location>> locationsByParentId, Set<Long> visited) {
|
||||||
|
List<Location> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,10 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
||||||
|
|
||||||
private UserLoginResult getUserLoginResult(User user) {
|
private UserLoginResult getUserLoginResult(User user) {
|
||||||
UserLoginParam userLoginParam = user.getUserLoginParam();
|
UserLoginParam userLoginParam = user.getUserLoginParam();
|
||||||
user.setCompanyCode(userLoginParam.getCompanyCode());
|
String companyCode = userLoginParam.getCompanyCode();
|
||||||
|
if (companyCode != null && !companyCode.isEmpty()) {
|
||||||
|
user.setCompanyCode(companyCode);
|
||||||
|
}
|
||||||
user.setUserLoginParam(userLoginParam);
|
user.setUserLoginParam(userLoginParam);
|
||||||
List<FsscSystem> fsscSystemList = user.getFsscSystemList();
|
List<FsscSystem> fsscSystemList = user.getFsscSystemList();
|
||||||
Map<String, Object> claims = new HashMap<>();
|
Map<String, Object> claims = new HashMap<>();
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller {
|
||||||
@Override
|
@Override
|
||||||
public boolean pullTrainOrderRecord(OrderRecordGenerateCommand command) {
|
public boolean pullTrainOrderRecord(OrderRecordGenerateCommand command) {
|
||||||
try {
|
try {
|
||||||
cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable(command.getDate()));
|
cTripOrderRecordAutoSave.cTripCarRecordAutoSave(command);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,7 +29,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller {
|
||||||
@Override
|
@Override
|
||||||
public boolean pullFlightOrderRecord(OrderRecordGenerateCommand command) {
|
public boolean pullFlightOrderRecord(OrderRecordGenerateCommand command) {
|
||||||
try {
|
try {
|
||||||
cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(Optional.ofNullable(command.getDate()));
|
cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(command);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
@ -40,7 +40,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller {
|
||||||
@Override
|
@Override
|
||||||
public boolean pullHotelOrderRecord(OrderRecordGenerateCommand command) {
|
public boolean pullHotelOrderRecord(OrderRecordGenerateCommand command) {
|
||||||
try {
|
try {
|
||||||
cTripOrderRecordAutoSave.cTripHotelRecordAutoSave(Optional.ofNullable(command.getDate()));
|
cTripOrderRecordAutoSave.cTripHotelRecordAutoSave(command);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
@ -51,7 +51,7 @@ public class CTripOrderRecordPuller implements OrderRecordPuller {
|
||||||
@Override
|
@Override
|
||||||
public boolean pullCarOrderRecord(OrderRecordGenerateCommand command) {
|
public boolean pullCarOrderRecord(OrderRecordGenerateCommand command) {
|
||||||
try {
|
try {
|
||||||
cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable(command.getDate()));
|
cTripOrderRecordAutoSave.cTripCarRecordAutoSave(command);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -117,8 +117,17 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAllCTripFlightRecord(List<CTripFlightRecord> cTripFlightRecordList) {
|
public void saveAllCTripFlightRecord(List<CTripFlightRecord> 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<CTripFlightRecord> batch = cTripFlightRecordList.subList(i, end);
|
||||||
|
jdbcCTripFlightRecordRepository.saveAll(batch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
jdbcCTripFlightRecordRepository.saveAll(cTripFlightRecordList);
|
jdbcCTripFlightRecordRepository.saveAll(cTripFlightRecordList);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CTripFlightRecord findFlightRecordById(Long id) {
|
public CTripFlightRecord findFlightRecordById(Long id) {
|
||||||
|
@ -137,8 +146,17 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAllCTripHotelRecord(List<CTripHotelRecord> cTripHotelRecordList) {
|
public void saveAllCTripHotelRecord(List<CTripHotelRecord> 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<CTripHotelRecord> batch = cTripHotelRecordList.subList(i, end);
|
||||||
|
jdbcCTripHotelRecordRepository.saveAll(batch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
jdbcCTripHotelRecordRepository.saveAll(cTripHotelRecordList);
|
jdbcCTripHotelRecordRepository.saveAll(cTripHotelRecordList);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CTripHotelRecord findHotelRecordById(Long id) {
|
public CTripHotelRecord findHotelRecordById(Long id) {
|
||||||
|
@ -172,8 +190,17 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAllCTripCarRecord(List<CTripCarRecord> cTripCarRecordList) {
|
public void saveAllCTripCarRecord(List<CTripCarRecord> 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<CTripCarRecord> batch = cTripCarRecordList.subList(i, end);
|
||||||
|
jdbcCTripCarRecordRepository.saveAll(batch);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
jdbcCTripCarRecordRepository.saveAll(cTripCarRecordList);
|
jdbcCTripCarRecordRepository.saveAll(cTripCarRecordList);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CTripCarRecord findCarRecordByRecordId(String recordId) {
|
public CTripCarRecord findCarRecordByRecordId(String recordId) {
|
||||||
|
|
|
@ -184,6 +184,11 @@ public class LocationRepositoryImpl implements LocationRepository {
|
||||||
return jdbcLocationRepository.findByLocationNameAndLevelOrLocationNameAndLevel(localName, 3, localName, 4);
|
return jdbcLocationRepository.findByLocationNameAndLevelOrLocationNameAndLevel(localName, 3, localName, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Location> findByParentId(Long parentId) {
|
||||||
|
return jdbcLocationRepository.findByParentLocationId(parentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location findByDistrictShotName(String name) {
|
public Location findByDistrictShotName(String name) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
|
public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
|
||||||
|
List<Location> findByParentLocationId(Long parentLocationId);
|
||||||
|
|
||||||
Location findByCityIdAndLocationShortName(Long cityId, String locationShortName);
|
Location findByCityIdAndLocationShortName(Long cityId, String locationShortName);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class DateTimeUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LocalDateTime strToTimeYYYYMMDD(String input) {
|
public static LocalDateTime strToTimeYYYYMMDD(String input) {
|
||||||
return LocalDateTime.parse(input, formatterDateYYYYMMDD);
|
return LocalDate.parse(input, formatterDateYYYYMMDD).atStartOfDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LocalDateTime strToTime(String input) {
|
public static LocalDateTime strToTime(String input) {
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
package com.chint.interfaces.rest.ctrip.dto.order;
|
package com.chint.interfaces.rest.ctrip.dto.order;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.CarOrderDetail;
|
import com.chint.domain.aggregates.order.CarOrderDetail;
|
||||||
|
import com.chint.interfaces.rest.amap.BaseResponse;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OrderCarResponse {
|
public class OrderCarResponse extends BaseOrderResponse {
|
||||||
private List<CarOrderAccountSettlementDetail> CarOrderAccountSettlementList;
|
private List<CarOrderAccountSettlementDetail> CarOrderAccountSettlementList;
|
||||||
private ResponseStatus Status;
|
private ResponseStatus Status;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package com.chint.interfaces.rest.ctrip.dto.order;
|
package com.chint.interfaces.rest.ctrip.dto.order;
|
||||||
|
|
||||||
|
import com.chint.interfaces.rest.amap.BaseResponse;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OrderFlightResponse {
|
public class OrderFlightResponse extends BaseOrderResponse {
|
||||||
private List<FlightOrderAccountSettlementInfo> FlightOrderAccountSettlementList;
|
private List<FlightOrderAccountSettlementInfo> FlightOrderAccountSettlementList;
|
||||||
private Status Status;
|
private Status Status;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package com.chint.interfaces.rest.ctrip.dto.order;
|
package com.chint.interfaces.rest.ctrip.dto.order;
|
||||||
|
|
||||||
|
import com.chint.interfaces.rest.amap.BaseResponse;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OrderHotelResponse {
|
public class OrderHotelResponse extends BaseOrderResponse {
|
||||||
private List<HotelAccountSettlementInfo> LstHtlSettlement;
|
private List<HotelAccountSettlementInfo> LstHtlSettlement;
|
||||||
private Status Status;
|
private Status Status;
|
||||||
|
|
||||||
|
@ -80,6 +81,7 @@ public class OrderHotelResponse {
|
||||||
private BigDecimal averagePrice;
|
private BigDecimal averagePrice;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@lombok.Data
|
@lombok.Data
|
||||||
public static class SettlementOrderDetail {
|
public static class SettlementOrderDetail {
|
||||||
private long OrderId;
|
private long OrderId;
|
||||||
|
@ -246,7 +248,6 @@ public class OrderHotelResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@lombok.Data
|
@lombok.Data
|
||||||
public static class SettlementHotelDetail {
|
public static class SettlementHotelDetail {
|
||||||
private String HotelName;
|
private String HotelName;
|
||||||
|
|
|
@ -12,6 +12,11 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
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.*;
|
import static com.chint.infrastructure.constant.CTripConstant.*;
|
||||||
|
|
||||||
|
@ -59,17 +64,13 @@ public class CTripOrderDetailRequest {
|
||||||
public OrderFlightResponse getFlightOrder() {
|
public OrderFlightResponse getFlightOrder() {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime localDateTime = now.minusDays(1L);
|
LocalDateTime localDateTime = now.minusDays(1L);
|
||||||
return postRequest.post(flightOrderUrl,
|
return pageQueryFlightResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)));
|
||||||
getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)),
|
|
||||||
OrderFlightResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderFlightResponse getFlightOrder(String oneDate) {
|
public OrderFlightResponse getFlightOrder(String oneDate) {
|
||||||
LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate);
|
LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate);
|
||||||
LocalDateTime localDateTime = oneDateL.minusDays(1L);
|
LocalDateTime localDateTime = oneDateL.minusDays(1L);
|
||||||
return postRequest.post(flightOrderUrl,
|
return pageQueryFlightResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)));
|
||||||
getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)),
|
|
||||||
OrderFlightResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderFlightResponse getFlightOrderByDate(String date) {
|
public OrderFlightResponse getFlightOrderByDate(String date) {
|
||||||
|
@ -79,8 +80,8 @@ public class CTripOrderDetailRequest {
|
||||||
|
|
||||||
|
|
||||||
public OrderFlightResponse getFlightOrder(String dateFrom, String dateTo) {
|
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) {
|
public OrderHotelResponse getHotelOrderByDate(String date) {
|
||||||
|
@ -91,22 +92,17 @@ public class CTripOrderDetailRequest {
|
||||||
public OrderHotelResponse getHotelOrder() {
|
public OrderHotelResponse getHotelOrder() {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime localDateTime = now.minusDays(1L);
|
LocalDateTime localDateTime = now.minusDays(1L);
|
||||||
return postRequest.post(hotelOrderUrl,
|
return pageQueryHotelResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)));
|
||||||
getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)),
|
|
||||||
OrderHotelResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderHotelResponse getHotelOrder(String oneDate) {
|
public OrderHotelResponse getHotelOrder(String oneDate) {
|
||||||
LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate);
|
LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate);
|
||||||
LocalDateTime localDateTime = oneDateL.minusDays(1L);
|
LocalDateTime localDateTime = oneDateL.minusDays(1L);
|
||||||
return postRequest.post(hotelOrderUrl,
|
return pageQueryHotelResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)));
|
||||||
getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)),
|
|
||||||
OrderHotelResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderHotelResponse getHotelOrder(String dateFrom, String dateTo) {
|
public OrderHotelResponse getHotelOrder(String dateFrom, String dateTo) {
|
||||||
return postRequest.post(hotelOrderUrl, getParamByBatch(dateFrom, dateTo),
|
return pageQueryHotelResponse(getParamByBatch(dateFrom, dateTo));
|
||||||
OrderHotelResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderTrainResponse getTrainOrderByDate(String date) {
|
public OrderTrainResponse getTrainOrderByDate(String date) {
|
||||||
|
@ -145,22 +141,17 @@ public class CTripOrderDetailRequest {
|
||||||
public OrderCarResponse getCarOrder() {
|
public OrderCarResponse getCarOrder() {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime localDateTime = now.minusDays(1L);
|
LocalDateTime localDateTime = now.minusDays(1L);
|
||||||
return postRequest.post(carOrderUrl,
|
return pageQueryCarResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)));
|
||||||
getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(now)),
|
|
||||||
OrderCarResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderCarResponse getCarOrder(String oneDate) {
|
public OrderCarResponse getCarOrder(String oneDate) {
|
||||||
LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate);
|
LocalDateTime oneDateL = DateTimeUtil.strToTimeYYYYMMDD(oneDate);
|
||||||
LocalDateTime localDateTime = oneDateL.minusDays(1L);
|
LocalDateTime localDateTime = oneDateL.minusDays(1L);
|
||||||
return postRequest.post(carOrderUrl,
|
return pageQueryCarResponse(getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)));
|
||||||
getParamByDateFromAndDateTo(DateTimeUtil.timeToStr(localDateTime), DateTimeUtil.timeToStr(oneDateL)),
|
|
||||||
OrderCarResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderCarResponse getCarOrder(String dateFrom, String dateTo) {
|
public OrderCarResponse getCarOrder(String dateFrom, String dateTo) {
|
||||||
return postRequest.post(carOrderUrl, getParamByBatch(dateFrom, dateTo),
|
return pageQueryCarResponse(getParamByBatch(dateFrom, dateTo));
|
||||||
OrderCarResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderRecordParam getParamByDateFromAndDateTo(String dateFrom, String dateTo) {
|
private OrderRecordParam getParamByDateFromAndDateTo(String dateFrom, String dateTo) {
|
||||||
|
@ -191,4 +182,77 @@ public class CTripOrderDetailRequest {
|
||||||
orderFlightParam.setTicket(ticketRequest.loadTicket());
|
orderFlightParam.setTicket(ticketRequest.loadTicket());
|
||||||
return orderFlightParam;
|
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 extends BaseOrderResponse> T pageQueryResponse(OrderRecordParam param, String url, Class<T> responseType, BiConsumer<T, T> 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<CompletableFuture<T>> 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<T> future = CompletableFuture.supplyAsync(() -> {
|
||||||
|
param.setPageIndex(pageIndex);
|
||||||
|
return postRequest.post(url, param, responseType);
|
||||||
|
});
|
||||||
|
futures.add(future);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine all responses
|
||||||
|
CompletableFuture<Void> allOf = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||||
|
CompletableFuture<T> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.chint.interfaces.rest.ctrip.order;
|
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.aggregates.order.order_record.ctrip_order_record.*;
|
||||||
import com.chint.domain.repository.CTripOrderDetailRepository;
|
import com.chint.domain.repository.CTripOrderDetailRepository;
|
||||||
import com.chint.infrastructure.util.DateTimeUtil;
|
import com.chint.infrastructure.util.DateTimeUtil;
|
||||||
|
@ -42,31 +43,47 @@ public class CTripOrderRecordAutoSave {
|
||||||
this.cTripCarRecordAutoSave(Optional.of(date));
|
this.cTripCarRecordAutoSave(Optional.of(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void cTripFlightRecordAutoSave(Optional<String> date) {
|
public void cTripFlightRecordAutoSave(Optional<String> date) {
|
||||||
OrderFlightResponse flightOrder = date
|
OrderFlightResponse flightOrder = date
|
||||||
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getFlightOrderByDate(it)))
|
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getFlightOrderByDate(it)))
|
||||||
.orElseGet(() -> cTripOrderDetailRequest.getFlightOrder());
|
.orElseGet(() -> cTripOrderDetailRequest.getFlightOrder());
|
||||||
List<OrderFlightResponse.FlightOrderAccountSettlementInfo> flightOrderAccountSettlementList = flightOrder
|
cTripFlightRecordAutoSave(flightOrder);
|
||||||
.getFlightOrderAccountSettlementList();
|
}
|
||||||
|
|
||||||
|
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<OrderFlightResponse.FlightOrderAccountSettlementInfo> flightOrderAccountSettlementList = response.getFlightOrderAccountSettlementList();
|
||||||
if (flightOrderAccountSettlementList != null && !flightOrderAccountSettlementList.isEmpty()) {
|
if (flightOrderAccountSettlementList != null && !flightOrderAccountSettlementList.isEmpty()) {
|
||||||
List<OrderFlightResponse.FlightOrderSettlementInfo> flightOrderSettlementInfos = flightOrderAccountSettlementList
|
List<String> recordIds = flightOrderAccountSettlementList.stream()
|
||||||
.stream()
|
|
||||||
.flatMap(it -> it.getOrderSettlementList().stream())
|
.flatMap(it -> it.getOrderSettlementList().stream())
|
||||||
.toList();
|
|
||||||
List<String> recordIds = flightOrderSettlementInfos
|
|
||||||
.stream()
|
|
||||||
.map(it -> String.valueOf(it.getOrderSettlementBaseInfo().getRecordID()))
|
.map(it -> String.valueOf(it.getOrderSettlementBaseInfo().getRecordID()))
|
||||||
.toList();
|
.toList();
|
||||||
Map<String, CTripFlightRecord> cTripFlightRecordMap = cTripOrderDetailRepository.findFlightRecordByRecordIdIn(recordIds)
|
Map<String, CTripFlightRecord> cTripFlightRecordMap = cTripOrderDetailRepository.findFlightRecordByRecordIdIn(recordIds)
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toMap(CTripFlightRecord::getRecordId, Function.identity()));
|
.collect(Collectors.toMap(CTripFlightRecord::getRecordId, Function.identity()));
|
||||||
|
List<CTripFlightRecord> cTripFlightRecords = flightOrderAccountSettlementList.stream()
|
||||||
|
.flatMap(it -> it.getOrderSettlementList().stream())
|
||||||
|
.map(it -> createOrUpdateFlightRecord(it, cTripFlightRecordMap))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
cTripOrderDetailRepository.saveAllCTripFlightRecord(cTripFlightRecords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<CTripFlightRecord> cTripFlightRecords = flightOrderSettlementInfos.stream()
|
private CTripFlightRecord createOrUpdateFlightRecord(OrderFlightResponse.FlightOrderSettlementInfo it, Map<String, CTripFlightRecord> cTripFlightRecordMap) {
|
||||||
.map(it -> {
|
|
||||||
//对数据库进行查找 ,如果发现已经存在 , 就使用查找出来的
|
|
||||||
OrderFlightResponse.FlightOrderSettlementBaseInfo orderSettlementBaseInfo = it.getOrderSettlementBaseInfo();
|
OrderFlightResponse.FlightOrderSettlementBaseInfo orderSettlementBaseInfo = it.getOrderSettlementBaseInfo();
|
||||||
OrderFlightResponse.FlightTripRecordInfo flightTripRecordInfo = it.getFlightTripRecordInfo();
|
OrderFlightResponse.FlightTripRecordInfo flightTripRecordInfo = it.getFlightTripRecordInfo();
|
||||||
CTripFlightRecord record = cTripFlightRecordMap.get(String.valueOf(orderSettlementBaseInfo.getRecordID()));
|
CTripFlightRecord record = cTripFlightRecordMap.get(String.valueOf(orderSettlementBaseInfo.getRecordID()));
|
||||||
|
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
record = CTripFlightRecord.of(
|
record = CTripFlightRecord.of(
|
||||||
CTripFlightRecordBase.changeInfo(orderSettlementBaseInfo),
|
CTripFlightRecordBase.changeInfo(orderSettlementBaseInfo),
|
||||||
|
@ -82,14 +99,16 @@ public class CTripOrderRecordAutoSave {
|
||||||
CTripFlightTripInfo.of(flightTripRecordInfo));
|
CTripFlightTripInfo.of(flightTripRecordInfo));
|
||||||
record.setId(originId);
|
record.setId(originId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it.getOrderPrintDetailInfo() != null) {
|
if (it.getOrderPrintDetailInfo() != null) {
|
||||||
record.printInfo(CTripFlightPrintInfo.of(it.getOrderPrintDetailInfo()));
|
record.printInfo(CTripFlightPrintInfo.of(it.getOrderPrintDetailInfo()));
|
||||||
}
|
}
|
||||||
//补充额外的字段
|
|
||||||
|
// 补充额外的字段
|
||||||
OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo();
|
OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo();
|
||||||
record.setRouteOrderNo(orderBaseInfo.getJourneyID());
|
record.setRouteOrderNo(orderBaseInfo.getJourneyID());
|
||||||
OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo();
|
|
||||||
|
|
||||||
|
OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo();
|
||||||
if (orderPassengerInfo != null) {
|
if (orderPassengerInfo != null) {
|
||||||
record.setTicketNo(orderPassengerInfo.getTicketNo());
|
record.setTicketNo(orderPassengerInfo.getTicketNo());
|
||||||
record.setUserCode(orderPassengerInfo.getEmployeeID());
|
record.setUserCode(orderPassengerInfo.getEmployeeID());
|
||||||
|
@ -102,26 +121,29 @@ public class CTripOrderRecordAutoSave {
|
||||||
record.setBookingUserName(orderBaseInfo.getName());
|
record.setBookingUserName(orderBaseInfo.getName());
|
||||||
record.setBookingUserPhone("");
|
record.setBookingUserPhone("");
|
||||||
return record;
|
return record;
|
||||||
}).toList();
|
|
||||||
cTripOrderDetailRepository.saveAllCTripFlightRecord(cTripFlightRecords);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void cTripHotelRecordAutoSave(Optional<String> date) {
|
public void cTripHotelRecordAutoSave(Optional<String> date) {
|
||||||
|
|
||||||
OrderHotelResponse hotelOrder = date
|
OrderHotelResponse hotelOrder = date
|
||||||
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getHotelOrderByDate(it)))
|
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getHotelOrderByDate(it)))
|
||||||
.orElseGet(() -> cTripOrderDetailRequest.getHotelOrder());
|
.orElseGet(() -> cTripOrderDetailRequest.getHotelOrder());
|
||||||
|
cTripHotelRecordAutoSave(hotelOrder);
|
||||||
|
}
|
||||||
|
|
||||||
List<OrderHotelResponse.HotelAccountSettlementInfo> 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<OrderHotelResponse.HotelAccountSettlementInfo> lstHtlSettlement = response.getLstHtlSettlement();
|
||||||
if (lstHtlSettlement != null && !lstHtlSettlement.isEmpty()) {
|
if (lstHtlSettlement != null && !lstHtlSettlement.isEmpty()) {
|
||||||
List<OrderHotelResponse.LstHotelSettlementDetail> hotelSettlementDetailList = lstHtlSettlement.stream()
|
List<String> recordIds = lstHtlSettlement.stream()
|
||||||
.flatMap(it -> it.getLstHotelSettlementDetail().stream())
|
.flatMap(it -> it.getLstHotelSettlementDetail().stream())
|
||||||
.toList();
|
|
||||||
|
|
||||||
List<String> recordIds = hotelSettlementDetailList
|
|
||||||
.stream()
|
|
||||||
.map(it -> String.valueOf(it.getSettlementDetail().getRecordId()))
|
.map(it -> String.valueOf(it.getSettlementDetail().getRecordId()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
@ -129,24 +151,35 @@ public class CTripOrderRecordAutoSave {
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toMap(CTripHotelRecord::getRecordId, Function.identity()));
|
.collect(Collectors.toMap(CTripHotelRecord::getRecordId, Function.identity()));
|
||||||
|
|
||||||
List<CTripHotelRecord> list = hotelSettlementDetailList.stream()
|
List<CTripHotelRecord> list = lstHtlSettlement.stream()
|
||||||
.map(it -> {
|
.flatMap(it -> it.getLstHotelSettlementDetail().stream())
|
||||||
|
.map(it -> createOrUpdateHotelRecord(it, cTripHotelRecordMap))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
cTripOrderDetailRepository.saveAllCTripHotelRecord(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CTripHotelRecord createOrUpdateHotelRecord(OrderHotelResponse.LstHotelSettlementDetail it, Map<String, CTripHotelRecord> cTripHotelRecordMap) {
|
||||||
OrderHotelResponse.SettlementDetail settlementDetail = it.getSettlementDetail();
|
OrderHotelResponse.SettlementDetail settlementDetail = it.getSettlementDetail();
|
||||||
CTripHotelRecord record = cTripHotelRecordMap.get(String.valueOf(settlementDetail.getRecordId()));
|
CTripHotelRecord record = cTripHotelRecordMap.get(String.valueOf(settlementDetail.getRecordId()));
|
||||||
OrderHotelResponse.SettlementOrderDetail settlementOrderDetail = it.getOrderDetail();
|
OrderHotelResponse.SettlementOrderDetail settlementOrderDetail = it.getOrderDetail();
|
||||||
|
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail),
|
record = CTripHotelRecord.of(
|
||||||
|
CTripHotelRecordBase.changeInfo(settlementDetail),
|
||||||
CTripHotelInfo.of(it.getHotelDetail()),
|
CTripHotelInfo.of(it.getHotelDetail()),
|
||||||
CTripHotelOrderDetail.of(settlementOrderDetail));
|
CTripHotelOrderDetail.of(settlementOrderDetail));
|
||||||
} else {
|
} else {
|
||||||
Long originId = record.getId();
|
Long originId = record.getId();
|
||||||
record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail),
|
record = CTripHotelRecord.of(
|
||||||
|
CTripHotelRecordBase.changeInfo(settlementDetail),
|
||||||
CTripHotelInfo.of(it.getHotelDetail()),
|
CTripHotelInfo.of(it.getHotelDetail()),
|
||||||
CTripHotelOrderDetail.of(settlementOrderDetail));
|
CTripHotelOrderDetail.of(settlementOrderDetail));
|
||||||
record.setId(originId);
|
record.setId(originId);
|
||||||
}
|
}
|
||||||
//补充额外的字段
|
|
||||||
|
|
||||||
|
// 补充额外的字段
|
||||||
record.setRouteOrderNo(settlementOrderDetail.getHotelRelatedJourneyNo());
|
record.setRouteOrderNo(settlementOrderDetail.getHotelRelatedJourneyNo());
|
||||||
List<OrderHotelResponse.SettlementClientDetail> clientDetailList = settlementOrderDetail.getClientDetailList();
|
List<OrderHotelResponse.SettlementClientDetail> clientDetailList = settlementOrderDetail.getClientDetailList();
|
||||||
if (clientDetailList != null && !clientDetailList.isEmpty()) {
|
if (clientDetailList != null && !clientDetailList.isEmpty()) {
|
||||||
|
@ -158,11 +191,6 @@ public class CTripOrderRecordAutoSave {
|
||||||
record.setBookingUserName(settlementOrderDetail.getEmployeeName());
|
record.setBookingUserName(settlementOrderDetail.getEmployeeName());
|
||||||
record.setBookingUserPhone("");
|
record.setBookingUserPhone("");
|
||||||
return record;
|
return record;
|
||||||
}).toList();
|
|
||||||
Map<Boolean, List<CTripHotelRecord>> collect = list.stream()
|
|
||||||
.collect(Collectors.groupingBy(record -> record.getId() != null));
|
|
||||||
collect.values().forEach(it -> cTripOrderDetailRepository.saveAllCTripHotelRecord(it));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,33 +229,50 @@ public class CTripOrderRecordAutoSave {
|
||||||
OrderCarResponse carOrder = date
|
OrderCarResponse carOrder = date
|
||||||
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrderByDate(it)))
|
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrderByDate(it)))
|
||||||
.orElseGet(() -> cTripOrderDetailRequest.getCarOrder());
|
.orElseGet(() -> cTripOrderDetailRequest.getCarOrder());
|
||||||
|
cTripCarRecordAutoSave(carOrder);
|
||||||
|
}
|
||||||
|
|
||||||
List<OrderCarResponse.CarOrderAccountSettlementDetail> 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<OrderCarResponse.CarOrderAccountSettlementDetail> settlementList = response.getCarOrderAccountSettlementList();
|
||||||
if (settlementList != null && !settlementList.isEmpty()) {
|
if (settlementList != null && !settlementList.isEmpty()) {
|
||||||
List<OrderCarResponse.CarOrderSettlementDetail> carOrderSettlementDetailList = settlementList.stream()
|
// 使用流处理,减少中间集合
|
||||||
|
List<String> recordIds = settlementList.stream()
|
||||||
|
.distinct()
|
||||||
.flatMap(it -> it.getCarSettlementDetailList().stream())
|
.flatMap(it -> it.getCarSettlementDetailList().stream())
|
||||||
.toList();
|
|
||||||
|
|
||||||
List<String> recordIds = carOrderSettlementDetailList
|
|
||||||
.stream()
|
|
||||||
.map(it -> String.valueOf(it.getSettlementBaseInfo().getRecordId()))
|
.map(it -> String.valueOf(it.getSettlementBaseInfo().getRecordId()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
Map<String, CTripCarRecord> cTripCarRecordMap = cTripOrderDetailRepository
|
Map<String, CTripCarRecord> cTripCarRecordMap = cTripOrderDetailRepository
|
||||||
.findCarRecordByRecordIdIn(recordIds)
|
.findCarRecordByRecordIdIn(recordIds)
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toMap(CTripCarRecord::getRecordId, Function.identity()));
|
.collect(Collectors.toMap(CTripCarRecord::getRecordId, Function.identity(), (existing, replacement) -> existing));
|
||||||
|
|
||||||
|
List<CTripCarRecord> list = settlementList.stream()
|
||||||
|
.flatMap(it -> it.getCarSettlementDetailList().stream())
|
||||||
|
.map(it -> createOrUpdateRecord(it, cTripCarRecordMap))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
List<CTripCarRecord> list = carOrderSettlementDetailList.stream()
|
// 批量保存
|
||||||
.map(it -> {
|
cTripOrderDetailRepository.saveAllCTripCarRecord(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CTripCarRecord createOrUpdateRecord(OrderCarResponse.CarOrderSettlementDetail it, Map<String, CTripCarRecord> cTripCarRecordMap) {
|
||||||
OrderCarResponse.CarOrderDetail orderDetail = it.getOrderDetail();
|
OrderCarResponse.CarOrderDetail orderDetail = it.getOrderDetail();
|
||||||
OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = it.getSettlementBaseInfo();
|
OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = it.getSettlementBaseInfo();
|
||||||
CTripCarRecord record = cTripCarRecordMap.get(String.valueOf(settlementBaseInfo.getRecordId()));
|
CTripCarRecord record = cTripCarRecordMap.get(String.valueOf(settlementBaseInfo.getRecordId()));
|
||||||
|
|
||||||
List<OrderCarResponse.CarOrderPassengerInfo> passengerInfoList = orderDetail.getPassengerInfoList();
|
List<OrderCarResponse.CarOrderPassengerInfo> passengerInfoList = orderDetail.getPassengerInfoList();
|
||||||
OrderCarResponse.CarOrderPassengerInfo carOrderPassengerInfo = passengerInfoList.get(0);
|
OrderCarResponse.CarOrderPassengerInfo carOrderPassengerInfo = passengerInfoList.get(0);
|
||||||
|
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
record = CTripCarRecord.of(
|
record = CTripCarRecord.of(
|
||||||
CTripCarRecordBase.changeInfo(settlementBaseInfo),
|
CTripCarRecordBase.changeInfo(settlementBaseInfo),
|
||||||
|
@ -243,23 +288,17 @@ public class CTripOrderRecordAutoSave {
|
||||||
);
|
);
|
||||||
record.setId(originId);
|
record.setId(originId);
|
||||||
}
|
}
|
||||||
//补充额外的字段
|
// 补充额外的字段
|
||||||
OrderCarResponse.CarOrderCorpInfo corpInfo = orderDetail.getCorpInfo();
|
OrderCarResponse.CarOrderCorpInfo corpInfo = orderDetail.getCorpInfo();
|
||||||
record.setRouteOrderNo(corpInfo.getJouneryId());
|
record.setRouteOrderNo(corpInfo.getJouneryId());
|
||||||
OrderCarResponse.CarOrderBaseInfo orderBaseInfo = orderDetail.getOrderBaseInfo();
|
OrderCarResponse.CarOrderBaseInfo orderBaseInfo = orderDetail.getOrderBaseInfo();
|
||||||
|
|
||||||
String orderDate = orderBaseInfo.getOrderDate();
|
String orderDate = orderBaseInfo.getOrderDate();
|
||||||
record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate)));
|
record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate)));
|
||||||
|
|
||||||
|
|
||||||
record.setUserCode(carOrderPassengerInfo.getEmployeeID());
|
record.setUserCode(carOrderPassengerInfo.getEmployeeID());
|
||||||
record.setUserName(carOrderPassengerInfo.getPassengerName());
|
record.setUserName(carOrderPassengerInfo.getPassengerName());
|
||||||
record.setBookingUserCode(orderBaseInfo.getPreEmployeeID());
|
record.setBookingUserCode(orderBaseInfo.getPreEmployeeID());
|
||||||
record.setBookingUserName(orderBaseInfo.getUserName());
|
record.setBookingUserName(orderBaseInfo.getUserName());
|
||||||
record.setBookingUserPhone(orderBaseInfo.getContactMobile());
|
record.setBookingUserPhone(orderBaseInfo.getContactMobile());
|
||||||
return record;
|
return record;
|
||||||
}).toList();
|
|
||||||
cTripOrderDetailRepository.saveAllCTripCarRecord(list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ public class CTripTest {
|
||||||
@Test
|
@Test
|
||||||
void search() {
|
void search() {
|
||||||
BaseContext.setCurrentUser(user);
|
BaseContext.setCurrentUser(user);
|
||||||
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31592018105");
|
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31839097186");
|
||||||
System.out.println(response);
|
System.out.println(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +609,6 @@ public class CTripTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void pullCarRecord() {
|
void pullCarRecord() {
|
||||||
cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable("202405"));
|
cTripOrderRecordAutoSave.cTripHotelRecordAutoSave(Optional.ofNullable("202405"));
|
||||||
// cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(Optional.ofNullable("202405"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -828,7 +828,7 @@ public class LYTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void searchHotel() {
|
void searchHotel() {
|
||||||
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240417095100616718");
|
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240321165300961176");
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(hotelOrderDetail);
|
String json = gson.toJson(hotelOrderDetail);
|
||||||
System.out.println(json);
|
System.out.println(json);
|
||||||
|
@ -859,7 +859,7 @@ public class LYTest {
|
||||||
// System.out.println(json);
|
// System.out.println(json);
|
||||||
|
|
||||||
|
|
||||||
TrainDetailResponse trainDetailResponse = lySearchRequest.getTrainOrderDetail("DT24041069650132424");
|
TrainDetailResponse trainDetailResponse = lySearchRequest.getTrainOrderDetail("DT24051073034383248");
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String json = gson.toJson(trainDetailResponse);
|
String json = gson.toJson(trainDetailResponse);
|
||||||
System.out.println(json);
|
System.out.println(json);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class ManageTest {
|
||||||
@Test
|
@Test
|
||||||
void recordAdd(){
|
void recordAdd(){
|
||||||
OrderPageQuery dto=new OrderPageQuery();
|
OrderPageQuery dto=new OrderPageQuery();
|
||||||
dto.setOderNo("123");
|
// dto.setOderNo("123");
|
||||||
OrderDownloadRecord downloadRecord=OrderDownloadRecord.builder()
|
OrderDownloadRecord downloadRecord=OrderDownloadRecord.builder()
|
||||||
.fileUrl("url")
|
.fileUrl("url")
|
||||||
.status("已完成")
|
.status("已完成")
|
||||||
|
|
|
@ -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.aggregates.user.User;
|
||||||
import com.chint.domain.repository.*;
|
import com.chint.domain.repository.*;
|
||||||
import com.chint.domain.service.JTCompanyDomainService;
|
import com.chint.domain.service.JTCompanyDomainService;
|
||||||
|
import com.chint.domain.service.LocationDomainService;
|
||||||
import com.chint.domain.service.OrderDomainService;
|
import com.chint.domain.service.OrderDomainService;
|
||||||
import com.chint.domain.service.SystemDomainService;
|
import com.chint.domain.service.SystemDomainService;
|
||||||
import com.chint.domain.service.order_sync.LYOrderSyncAdapter;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
@ -110,6 +112,9 @@ class RouteApplicationTests {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LocationDomainService locationDomainService;
|
||||||
|
|
||||||
|
|
||||||
@Value("${FSSC.jt-baseUrl}")
|
@Value("${FSSC.jt-baseUrl}")
|
||||||
private String jtFSSCUrl;
|
private String jtFSSCUrl;
|
||||||
|
@ -316,7 +321,7 @@ class RouteApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginSignProd() {
|
void loginSignProd() {
|
||||||
String sfno = "240611055";
|
String sfno = "230228069";
|
||||||
String syscode = "FSSC";
|
String syscode = "FSSC";
|
||||||
String billcode = "CLSQ240225000099";
|
String billcode = "CLSQ240225000099";
|
||||||
String companycode = "正泰集团股份有限公司";
|
String companycode = "正泰集团股份有限公司";
|
||||||
|
@ -1472,4 +1477,18 @@ class RouteApplicationTests {
|
||||||
void roleTest() {
|
void roleTest() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void exposedLocation(){
|
||||||
|
List<Location> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue