修复行程区缺少的问题 , 同程酒店临时数据进行过滤

This commit is contained in:
lulz1 2024-03-16 18:21:29 +08:00
parent fd9c571c8c
commit 5eadbb1d40
16 changed files with 436 additions and 146 deletions

View File

@ -23,6 +23,7 @@ import java.util.List;
import java.util.stream.Stream;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
@Component
public class OrderDetailQuery {
@ -43,8 +44,7 @@ public class OrderDetailQuery {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter);
LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter);
List<OrderDetail> orderDetailList = orderDetailRepository.findByUpdateTimeBetween(targetTimeBegin,
targetTimeEnd);
List<OrderDetail> orderDetailList = orderDetailRepository.findByUpdateTimeBetween(targetTimeBegin, targetTimeEnd);
List<Object> orderDetailResList = new ArrayList<>();
for (OrderDetail orderDetail : orderDetailList) {
if (productType == 1) {
@ -52,7 +52,7 @@ public class OrderDetailQuery {
if (flightOrderDetail != null) {
String receiptsNum = flightOrderDetail.getReceiptsNum();
if (receiptsNum != null){
if (receiptsNum != null) {
flightOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (flightOrderDetail.getBelongSysType() != null && flightOrderDetail.getBelongSysType().equals(systemType)) {
@ -64,21 +64,22 @@ public class OrderDetailQuery {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
if (hotelOrderDetail != null) {
String receiptsNum = hotelOrderDetail.getReceiptsNum();
if (receiptsNum != null){
if (receiptsNum != null) {
hotelOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (hotelOrderDetail.getBelongSysType() != null && hotelOrderDetail.getBelongSysType().equals(systemType)) {
//这里添加过滤逻辑 如果该订单为同程酒店订单 并且金额为0 判断为 临时订单数据
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y) && Double.parseDouble(hotelOrderDetail.getOrderAmount()) == 0)
continue;
orderDetailResList.add(hotelOrderDetail);
}
}
}
if (productType == 3) {
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
if (trainOrderDetail != null) {
String receiptsNum = trainOrderDetail.getReceiptsNum();
if (receiptsNum != null){
if (receiptsNum != null) {
trainOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (trainOrderDetail.getBelongSysType() != null && trainOrderDetail.getBelongSysType().equals(systemType)) {
@ -90,7 +91,7 @@ public class OrderDetailQuery {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
if (carOrderDetail != null) {
String receiptsNum = carOrderDetail.getReceiptsNum();
if (receiptsNum != null){
if (receiptsNum != null) {
carOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (carOrderDetail.getBelongSysType() != null && carOrderDetail.getBelongSysType().equals(systemType)) {
@ -99,12 +100,9 @@ public class OrderDetailQuery {
}
}
}
List<Object> newres2 = orderDetailResList.stream().skip((long) (pageNum - 1) * pageSize)
.limit(pageSize).toList();
List<Object> newres2 = orderDetailResList.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).toList();
return Result.Success(SUCCESS, PageResult.totalPageNum(Long.parseLong(
String.valueOf(orderDetailResList.size())
), newres2));
return Result.Success(SUCCESS, PageResult.totalPageNum(Long.parseLong(String.valueOf(orderDetailResList.size())), newres2));
}
@ -114,19 +112,15 @@ public class OrderDetailQuery {
Integer ifNotStart = orderDetailQueryParam.getIfNotStart();
User currentUser = BaseContext.getCurrentUser();
List<RouteOrder> byEmployeeNo = routeRepository.findByEmployeeNo(currentUser.getEmployeeNo());
Stream<OrderDetail> details = byEmployeeNo
.stream()
.filter(it->it.getApproveOrderNo() != null && it.getApproveOrderNo().getActualOrderNo() != null)
.filter(it->it.getOrderDetails() != null)
.flatMap(it -> it.getOrderDetails().stream());
Stream<OrderDetail> details = byEmployeeNo.stream().filter(it -> it.getApproveOrderNo() != null && it.getApproveOrderNo().getActualOrderNo() != null).filter(it -> it.getOrderDetails() != null).flatMap(it -> it.getOrderDetails().stream());
List<Integer> productTypes = orderDetailQueryParam.getProductTypes();
if (productTypes != null && !productTypes.isEmpty()) {
details = details.filter(it -> productTypes.contains(it.getProductType()));
}
if(ifNotStart != null && ifNotStart.equals(1)){
details = details.filter(it->it.getStartTime() != null).filter(it->it.getStartTime().isAfter(LocalDateTime.now()));
if (ifNotStart != null && ifNotStart.equals(1)) {
details = details.filter(it -> it.getStartTime() != null).filter(it -> it.getStartTime().isAfter(LocalDateTime.now()));
}
// if(ifStart != null && ifStart.equals(1)){
@ -135,21 +129,16 @@ public class OrderDetailQuery {
List<OrderDetail> res = details.toList();
Integer total = res.size();
List<OrderDetailRes> OrderDetailResList = res.stream()
.sorted(Comparator.comparing(OrderDetail::getUpdateTime).reversed())
.skip((long) (pageNum - 1) * pageSize)
.limit(pageSize)
.map(OrderDetailMapper::copyFromExtension)
.toList();
List<OrderDetailRes> OrderDetailResList = res.stream().sorted(Comparator.comparing(OrderDetail::getUpdateTime).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(OrderDetailMapper::copyFromExtension).toList();
return new PageResult<>(total, OrderDetailResList);
}
private String regetReceiptsNum(String receiptsNum){
if (receiptsNum.contains("-")){
private String regetReceiptsNum(String receiptsNum) {
if (receiptsNum.contains("-")) {
String[] parts = receiptsNum.split("-");
String result = parts[1];
return result;
}else {
} else {
return receiptsNum;
}
}

View File

@ -0,0 +1,12 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import java.util.List;
public interface DistrictInfoRepository {
List<DistrictPOIInfoEntity> findAll();
DistrictPOIInfoEntity save(DistrictPOIInfoEntity districtPOIInfoEntity);
}

View File

@ -15,6 +15,9 @@ public interface LocationRepository {
List<Location> findAll();
Location findByCityId(Long cityId,String shortName);
List<Location> findAllLeverThreeAndIsInternal();
Location findById(Long id);
void saveAll(List<Location> locations);
@ -38,7 +41,7 @@ public interface LocationRepository {
List<Location> findByCityNameAndLevelThree(String localName);
Location findByCityName(String localName);
Location findByDistrictShotName(String name);
List<Location> findChinaCityByLevel(String locationNames,Integer level);

View File

@ -14,4 +14,9 @@ public interface PrefectureLevelRepository {
List<PrefectureLevelCityInfoEntity> findByCityName(String cityName);
PrefectureLevelCityInfoEntity findByCityId(Long cityId);
PrefectureLevelCityInfoEntity save(PrefectureLevelCityInfoEntity cityInfoEntity);
}

View File

@ -0,0 +1,30 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import com.chint.domain.repository.DistrictInfoRepository;
import com.chint.infrastructure.repository.jdbc.JdbcDistrictInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository
public class DistrictInfoRepositoryImpl implements DistrictInfoRepository {
@Autowired
private JdbcDistrictInfoRepository jdbcDistrictInfoRepository;
@Override
public List<DistrictPOIInfoEntity> findAll() {
List<DistrictPOIInfoEntity> res = new ArrayList<>();
jdbcDistrictInfoRepository.findAll().forEach(res::add);
return res;
}
@Override
public DistrictPOIInfoEntity save(DistrictPOIInfoEntity districtPOIInfoEntity) {
return jdbcDistrictInfoRepository.save(districtPOIInfoEntity);
}
}

View File

@ -59,6 +59,16 @@ public class LocationRepositoryImpl implements LocationRepository {
return res;
}
@Override
public Location findByCityId(Long cityId,String shortName) {
return jdbcLocationRepository.findByCityIdAndLocationShortName(cityId,shortName);
}
@Override
public List<Location> findAllLeverThreeAndIsInternal() {
return jdbcLocationRepository.findByLevelAndIsInternal(3,1);
}
@Cacheable(value = "Location-findById", key = "#id")
@Override
public Location findById(Long id) {
@ -132,6 +142,11 @@ public class LocationRepositoryImpl implements LocationRepository {
return jdbcLocationRepository.findByLocationNameAndLevelOrLocationNameAndLevel(localName, 3, localName, 4);
}
@Override
public Location findByDistrictShotName(String name) {
return jdbcLocationRepository.findByLocationShortName(name);
}
@Cacheable(value = "Location-findHotCitiesByCityName-localName", key = "#locationNames")
@Override

View File

@ -26,9 +26,16 @@ public class PrefectureLevelRepositoryImpl implements PrefectureLevelRepository
}
return prefectureLevelCityInfoEntities;
}
// public Location findByLocationId(Long locationId) {
// return jdbcLocationRepository.findByLocationId(locationId);
// }
@Override
public PrefectureLevelCityInfoEntity findByCityId(Long cityId) {
return jdbcPrefectureLevelRepository.findByCityId(cityId);
}
@Override
public PrefectureLevelCityInfoEntity save(PrefectureLevelCityInfoEntity cityInfoEntity) {
return jdbcPrefectureLevelRepository.save(cityInfoEntity);
}
}

View File

@ -0,0 +1,11 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcDistrictInfoRepository extends CrudRepository<DistrictPOIInfoEntity,Long> {
}

View File

@ -11,8 +11,12 @@ import java.util.List;
@Repository
public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
Location findByCityIdAndLocationShortName(Long cityId, String locationShortName);
Location findByLocationId(Long locationId);
Location findByLocationShortName(String locationShortName);
Page<Location> findAllByLocationPathContaining(String locationPath, Pageable pageable);
Page<Location> findAllByParentLocationId(Long parentLocationId, Pageable pageable);
@ -55,4 +59,6 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findAllByLocationPathNotContainingAndLevel(String locationPath, Integer level);
List<Location> findByLevelAndIsInternal(Integer level, Integer isInternal);
}

View File

@ -19,5 +19,5 @@ public interface JdbcPrefectureLevelRepository extends CrudRepository<Prefecture
List<PrefectureLevelCityInfoEntity> findByCityName(String cityName);
List<PrefectureLevelCityInfoEntity> findByCityNameContaining(String cityName);
PrefectureLevelCityInfoEntity findByCityId(Long cityId);
}

View File

@ -0,0 +1,25 @@
package com.chint.infrastructure.util;
import net.sourceforge.pinyin4j.PinyinHelper;
public class PinyinUtil {
public static String getFirstLetter(String chineseStr) {
if (chineseStr == null || chineseStr.isEmpty()) {
return "";
}
// 提取字符串的第一个字符
char firstChar = chineseStr.charAt(0);
// 使用pinyin4j库将字符转换为拼音数组
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(firstChar);
// 如果字符是中文则返回其拼音首字母否则直接返回该字符
if (pinyinArray != null) {
return String.valueOf(pinyinArray[0].charAt(0)).toUpperCase();
} else {
return String.valueOf(firstChar).toUpperCase();
}
}
}

View File

@ -105,9 +105,15 @@ public class PushUser {
Type type = new TypeToken<List<UserDataDTO>>() {
}.getType();
if (result.getData() == null) {
continue;
}
List<UserDataDTO> userDataDTOs = gson.fromJson(result.getData().toString(), type);
List<User> users = userDataDTOs.stream()
.filter(it-> !it.getStatus().equals("A"))
.filter(it -> it.getLoginUsername() != null)
.filter(it -> it.getCompany() != null)
.filter(it -> jtCompanyDomainService.ifCompanyInJT(null, it.getCompany())
@ -123,6 +129,7 @@ public class PushUser {
user.setManaLevel(userData.getCust_manaLevel());
user.setProfLevel(userData.getCust_profLevel());
user.setQualityLevel(userData.getCust_qualityLevel());
user.setEmployeeNo(userData.getLoginUsername());
return user;
})
.toList();
@ -138,6 +145,10 @@ public class PushUser {
}
}
// if(page == 4){
// break;
// }
users.forEach(user -> userHttpRequest.loadRankCode(user));
page++;
@ -147,8 +158,11 @@ public class PushUser {
list = list.stream().filter(user -> user.getEmployeeNo() != null).toList();
for (User user : list) {
Optional.ofNullable(userRepository.findByUserEmployeeNo(user.getEmployeeNo())).ifPresent(
this::asyncUser
Optional.ofNullable(userRepository.findByUserEmployeeNo(user.getEmployeeNo())).ifPresentOrElse(
this::asyncUser,()->{
userRepository.save(user);
asyncUser(user);
}
);
}

View File

@ -1,18 +1,19 @@
package com.chint;
import com.chint.domain.aggregates.location.basedata.*;
import com.chint.domain.aggregates.location.basedata.CountryInfoEntity;
import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.CityRepository;
import com.chint.domain.repository.CountryInfoEntityRepository;
import com.chint.domain.repository.CTripOrderDetailRepository;
import com.chint.domain.repository.POIDataInfoEntityRepository;
import com.chint.domain.repository.*;
import com.chint.domain.service.supplier.SupplierService;
import com.chint.domain.value_object.SupplierCallbackData;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.PinyinUtil;
import com.chint.interfaces.rest.ctrip.*;
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
import com.chint.interfaces.rest.ctrip.dto.country.CountryResponse;
@ -20,7 +21,10 @@ import com.chint.interfaces.rest.ctrip.dto.estimate.request.*;
import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiResponse;
import com.chint.interfaces.rest.ctrip.dto.location.CTripCity;
import com.chint.interfaces.rest.ctrip.dto.location.CTripCountry;
import com.chint.interfaces.rest.ctrip.dto.location.full.response.*;
import com.chint.interfaces.rest.ctrip.dto.location.full.response.DistrictPOIInfo;
import com.chint.interfaces.rest.ctrip.dto.location.full.response.POIData;
import com.chint.interfaces.rest.ctrip.dto.location.full.response.PrefectureLevelCityInfo;
import com.chint.interfaces.rest.ctrip.dto.location.full.response.QueryAllPOIInfoResponseType;
import com.chint.interfaces.rest.ctrip.dto.login.CTripLoginParam;
import com.chint.interfaces.rest.ctrip.dto.login.PCResponse;
import com.chint.interfaces.rest.ctrip.dto.order.OrderCarResponse;
@ -30,8 +34,6 @@ import com.chint.interfaces.rest.ctrip.dto.order.OrderTrainResponse;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
import com.chint.interfaces.rest.ctrip.in.CTripNoteController;
import com.chint.interfaces.rest.ctrip.order.CTripOrderDetailRequest;
import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
import com.google.gson.Gson;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -81,6 +83,8 @@ public class CTripTest {
@Autowired
private CountryInfoEntityRepository countryInfoEntityRepository;
@Autowired
private PrefectureLevelRepository prefectureLevelRepository;
@Autowired
private POIDataInfoEntityRepository poiDataInfoEntityRepository;
@ -92,10 +96,17 @@ public class CTripTest {
private CTripOrderDetailRepository ctripOrderDetailRepository;
@Autowired
private LYSearchRequest lySearchRequest;
private OrderDetailRepository orderDetailRepository;
@Autowired
private LocationRepository locationRepository;
@Autowired
private DistrictInfoRepository districtInfoRepository;
private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365", "A30000001");
//@Test
void locationCountry() {
System.out.println(cTripLocationHttpRequest.syncCountry());
@ -172,7 +183,7 @@ public class CTripTest {
System.out.println(gson.toJson(estimate));
}
// @Test
// @Test
void estimateTrain() {
BaseContext.setCurrentUser(user);
TrainProductInfo trainProductInfo = new TrainProductInfo();
@ -187,7 +198,7 @@ public class CTripTest {
System.out.println(gson.toJson(estimate));
}
// @Test
// @Test
void estimateHotel() {
BaseContext.setCurrentUser(user);
HotelProductInfo hotelProductInfo = new HotelProductInfo();
@ -199,7 +210,12 @@ public class CTripTest {
System.out.println(gson.toJson(estimate));
}
@Test
void search() {
BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("30352884087");
System.out.println(response);
}
// @Test
void searchAndHandlerData() {
@ -227,7 +243,7 @@ public class CTripTest {
}
// @Test
// @Test
void queryAllCountry() {
CountryResponse countryResponse = cTripCountryRequest.getCountry();
//获取国家信息
@ -312,14 +328,106 @@ public class CTripTest {
}
// @Test
void queryAllPOIInfo(){
// @Test
void queryAllPOIInfo() {
// QueryAllPOIInfoResponseType allPOIInfoQuery = cTripAllPOIInfoRequest.getAllPOIInfoQuery(1L);
QueryAllPOIInfoResponseType allPOIInfoQuery = cTripAllPOIInfoRequest.getAllPOIInfoQuery(536511L);
System.out.println(allPOIInfoQuery);
}
@Test
void queryDistrictByCountryId() {
// CountryInfoEntity countryInfoEntity = countryInfoEntityRepository.findById(336L);
QueryAllPOIInfoResponseType allPOIInfoQuery = cTripAllPOIInfoRequest.getAllPOIInfoQuery(1L);
Map<Long, POIData> poiDataByProvinceId = new HashMap<>();
for (POIData poiData : allPOIInfoQuery.getDataList()) {
poiDataByProvinceId.put(poiData.getProvinceId(), poiData);
}
List<PrefectureLevelCityInfo> list = allPOIInfoQuery.getDataList()
.stream()
.flatMap(it -> it.getPrefectureLevelCityInfoList().stream())
.toList();
for (PrefectureLevelCityInfo cityInfo : list) {
PrefectureLevelCityInfoEntity byCityId = prefectureLevelRepository
.findByCityId(cityInfo.getCityId());
if (cityInfo.getDistrictList() == null) continue;
List<DistrictPOIInfoEntity> districtPOIInfoEntities = getDistrictPOIInfoEntities(cityInfo);
byCityId.setDistrictPOIInfoEntities(districtPOIInfoEntities);
prefectureLevelRepository.save(byCityId);
}
}
@Test
void generateDistrictInLocation() {
List<Location> allLeverThree = locationRepository.findAllLeverThreeAndIsInternal();
List<Location> districtCities = new ArrayList<>();
for (Location location : allLeverThree) {
PrefectureLevelCityInfoEntity byCityId = prefectureLevelRepository.findByCityId(location.getCityId());
List<DistrictPOIInfoEntity> districtPOIInfoEntities = byCityId.getDistrictPOIInfoEntities();
for (DistrictPOIInfoEntity districtPOIInfoEntity : districtPOIInfoEntities) {
Location districtLocation = new Location();
districtLocation.setCityId(districtPOIInfoEntity.getDistrictId());
districtLocation.setLocationName(districtPOIInfoEntity.getDistrictName());
districtLocation.setLocationShortName(districtPOIInfoEntity.getDistrictName() + "D");
districtLocation.setFirstPinYin(PinyinUtil.getFirstLetter(districtPOIInfoEntity.getDistrictName()));
districtLocation.setParentLocationId(location.getLocationId());
districtLocation.setLocationPathName(location.getLocationPathName() + districtPOIInfoEntity.getDistrictName() + '_' );
districtLocation.setIsInternal(location.getIsInternal());
districtLocation.setIsHaveAirport(0);
districtLocation.setLocationPath(location.getLocationPath());
districtLocation.setLevel(location.getLevel() + 1);
districtCities.add(districtLocation);
}
}
locationRepository.saveAll(districtCities);
}
@Test
void updateDistrictInLocation() {
List<DistrictPOIInfoEntity> all = districtInfoRepository.findAll();
List<Location> districtCities = new ArrayList<>();
for (DistrictPOIInfoEntity districtPOIInfoEntity : all) {
Location byDistrictShotName = locationRepository
.findByCityId(districtPOIInfoEntity.getDistrictId(),districtPOIInfoEntity.getDistrictName()+"D");
if(byDistrictShotName == null) {
System.out.println(districtPOIInfoEntity.getDistrictId()+ districtPOIInfoEntity.getDistrictName()+"D");
continue;
}
Location location = locationRepository.findById(byDistrictShotName.getParentLocationId());
byDistrictShotName.setLocationPathName(location.getLocationPathName() + districtPOIInfoEntity.getDistrictName() + '_' );
byDistrictShotName.setLocationPath(location.getLocationPath() + byDistrictShotName.getLocationId() + '_');
districtCities.add(byDistrictShotName);
}
locationRepository.saveAll(districtCities);
}
private static List<DistrictPOIInfoEntity> getDistrictPOIInfoEntities(PrefectureLevelCityInfo cityInfo) {
List<DistrictPOIInfoEntity> districtPOIInfoEntities = new ArrayList<>();
for (DistrictPOIInfo districtPOIInfo : cityInfo.getDistrictList()) {
DistrictPOIInfoEntity districtPOIInfoEntity = new DistrictPOIInfoEntity();
districtPOIInfoEntity.setDistrictId(districtPOIInfo.getDistrictId());
districtPOIInfoEntity.setDistrictName(districtPOIInfo.getDistrictName());
districtPOIInfoEntity.setDistrictEnName(districtPOIInfo.getDistrictEnName());
districtPOIInfoEntities.add(districtPOIInfoEntity);
}
return districtPOIInfoEntities;
}
@Test
void deleteByCountryId() {
}
// @Test
void dist() {
CountryInfoEntity byId = countryInfoEntityRepository.findById(425L);
@ -338,22 +446,22 @@ public class CTripTest {
}
}
// @Test
void getFlightOrder(){
OrderFlightResponse orderFlightResponse = cTripOrderDetailRequest.getFlightOrder("2024-03-06","2024-03-07");
// @Test
void getFlightOrder() {
OrderFlightResponse orderFlightResponse = cTripOrderDetailRequest.getFlightOrder("2024-03-06", "2024-03-07");
List<OrderFlightResponse.FlightOrderAccountSettlementInfo> flightOrderAccountSettlementList =
orderFlightResponse.getFlightOrderAccountSettlementList();
if (!flightOrderAccountSettlementList.isEmpty()){
if (!flightOrderAccountSettlementList.isEmpty()) {
OrderFlightResponse.FlightOrderAccountSettlementInfo flightOrderAccountSettlementInfo =
flightOrderAccountSettlementList.get(0);
//这个数据会有很多
List<OrderFlightResponse.FlightOrderSettlementInfo> orderSettlementList =
flightOrderAccountSettlementInfo.getOrderSettlementList();
if (!orderSettlementList.isEmpty()){
if (!orderSettlementList.isEmpty()) {
OrderFlightResponse.FlightOrderSettlementInfo flightOrderSettlementInfo = orderSettlementList.get(0);
OrderFlightResponse.FlightOrderSettlementBaseInfo orderSettlementBaseInfo =
flightOrderSettlementInfo.getOrderSettlementBaseInfo();
if (orderSettlementBaseInfo != null){
if (orderSettlementBaseInfo != null) {
CtripFlightOrderDetail ctripFlightOrderDetail = new CtripFlightOrderDetail();
ctripFlightOrderDetail = ctripFlightOrderDetail.changeInfo(orderSettlementBaseInfo);
ctripOrderDetailRepository.save(ctripFlightOrderDetail);
@ -362,20 +470,20 @@ public class CTripTest {
}
}
// @Test
void getTRainOrder(){
OrderTrainResponse orderFlightResponse = cTripOrderDetailRequest.getTrainOrder("2024-03-06","2024-03-07");
// @Test
void getTRainOrder() {
OrderTrainResponse orderFlightResponse = cTripOrderDetailRequest.getTrainOrder("2024-03-06", "2024-03-07");
List<OrderTrainResponse.CorpTrainAccountSettlement> lstTrainSettlement =
orderFlightResponse.getLstTrainSettlement();
if (!lstTrainSettlement.isEmpty()){
if (!lstTrainSettlement.isEmpty()) {
OrderTrainResponse.CorpTrainAccountSettlement corpTrainAccountSettlement = lstTrainSettlement.get(0);
List<OrderTrainResponse.CorpTrainSettlementInfo> lstTrainSettlementDetail =
corpTrainAccountSettlement.getLstTrainSettlementDetail();
if (!lstTrainSettlementDetail.isEmpty()){
if (!lstTrainSettlementDetail.isEmpty()) {
OrderTrainResponse.CorpTrainSettlementInfo corpTrainSettlementInfo = lstTrainSettlementDetail.get(0);
OrderTrainResponse.CorpTrainSettlementDetail trainSettlementDetail =
corpTrainSettlementInfo.getTrainSettlementDetail();
if (trainSettlementDetail != null){
if (trainSettlementDetail != null) {
CtripTrainOrderDetail ctripTrainOrderDetail = new CtripTrainOrderDetail();
ctripTrainOrderDetail = ctripTrainOrderDetail.changeInfo(trainSettlementDetail);
ctripOrderDetailRepository.save(ctripTrainOrderDetail);
@ -383,19 +491,20 @@ public class CTripTest {
}
}
}
// @Test
void getHotelOrder(){
OrderHotelResponse orderFlightResponse = cTripOrderDetailRequest.getHotelOrder("2024-03-06","2024-03-07");
// @Test
void getHotelOrder() {
OrderHotelResponse orderFlightResponse = cTripOrderDetailRequest.getHotelOrder("2024-03-06", "2024-03-07");
List<OrderHotelResponse.HotelAccountSettlementInfo> lstHtlSettlement =
orderFlightResponse.getLstHtlSettlement();
if (!lstHtlSettlement.isEmpty()){
if (!lstHtlSettlement.isEmpty()) {
OrderHotelResponse.HotelAccountSettlementInfo hotelAccountSettlementInfo = lstHtlSettlement.get(0);
List<OrderHotelResponse.LstHotelSettlementDetail> LstHotelSettlementDetail =
hotelAccountSettlementInfo.getLstHotelSettlementDetail();
if(!LstHotelSettlementDetail.isEmpty()){
if (!LstHotelSettlementDetail.isEmpty()) {
OrderHotelResponse.LstHotelSettlementDetail hotelSettlementDetail = LstHotelSettlementDetail.get(0);
OrderHotelResponse.SettlementDetail settlementDetail = hotelSettlementDetail.getSettlementDetail();
if(settlementDetail != null){
if (settlementDetail != null) {
CtripHotelOrderDetail ctripFlightOrderDetail = new CtripHotelOrderDetail();
ctripFlightOrderDetail = ctripFlightOrderDetail.changeInfo(settlementDetail);
ctripOrderDetailRepository.save(ctripFlightOrderDetail);
@ -405,19 +514,19 @@ public class CTripTest {
}
// @Test
void getCarOrder(){
OrderCarResponse orderCarResponse = cTripOrderDetailRequest.getCarOrder("2024-03-01","2024-03-07");
// @Test
void getCarOrder() {
OrderCarResponse orderCarResponse = cTripOrderDetailRequest.getCarOrder("2024-03-01", "2024-03-07");
List<OrderCarResponse.CarOrderAccountSettlementDetail> carOrderAccountSettlementList =
orderCarResponse.getCarOrderAccountSettlementList();
if (!carOrderAccountSettlementList.isEmpty()){
if (!carOrderAccountSettlementList.isEmpty()) {
OrderCarResponse.CarOrderAccountSettlementDetail carOrderAccountSettlementDetail = carOrderAccountSettlementList.get(0);
List<OrderCarResponse.CarOrderSettlementDetail> carSettlementDetailList =
carOrderAccountSettlementDetail.getCarSettlementDetailList();
if (!carSettlementDetailList.isEmpty()){
if (!carSettlementDetailList.isEmpty()) {
OrderCarResponse.CarOrderSettlementDetail carOrderSettlementDetail = carSettlementDetailList.get(0);
OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = carOrderSettlementDetail.getSettlementBaseInfo();
if (settlementBaseInfo != null){
if (settlementBaseInfo != null) {
CtripCarOrderDetail ctripCarOrderDetail = new CtripCarOrderDetail();
ctripCarOrderDetail = ctripCarOrderDetail.changeInfo(settlementBaseInfo);
ctripOrderDetailRepository.save(ctripCarOrderDetail);
@ -425,48 +534,5 @@ public class CTripTest {
}
}
}
@Test
void queryDistrictByCountryId() {
CountryInfoEntity countryInfoEntity = countryInfoEntityRepository.findById(336L);
QueryAllPOIInfoResponseType allPOIInfoQuery = cTripAllPOIInfoRequest.getAllPOIInfoQuery(1L);
Map<Long, POIData> poiDataByProvinceId = new HashMap<>();
for (POIData poiData : allPOIInfoQuery.getDataList()) {
poiDataByProvinceId.put(poiData.getProvinceId(), poiData);
}
for (POIDataInfoEntity poiDataInfoEntity : countryInfoEntity.getPoiDataInfoEntities()) {
POIData poiData = poiDataByProvinceId.get(poiDataInfoEntity.getProvinceId());
if (poiData != null) {
Map<Long, PrefectureLevelCityInfo> cityInfoByCityId = new HashMap<>();
for (PrefectureLevelCityInfo cityInfo : poiData.getPrefectureLevelCityInfoList()) {
cityInfoByCityId.put(cityInfo.getCityId(), cityInfo);
}
for (PrefectureLevelCityInfoEntity cityInfoEntity : poiDataInfoEntity.getPrefectureLevelCityInfoEntities()) {
PrefectureLevelCityInfo cityInfo = cityInfoByCityId.get(cityInfoEntity.getCityId());
if (cityInfo != null) {
if(cityInfo.getDistrictList() == null) continue;
for (DistrictPOIInfo districtPOIInfo : cityInfo.getDistrictList()) {
DistrictPOIInfoEntity districtPOIInfoEntity = new DistrictPOIInfoEntity();
districtPOIInfoEntity.setDistrictId(districtPOIInfo.getDistrictId());
districtPOIInfoEntity.setDistrictName(districtPOIInfo.getDistrictName());
districtPOIInfoEntity.setDistrictEnName(districtPOIInfo.getDistrictEnName());
cityInfoEntity.addDistrict(districtPOIInfoEntity);
}
}
}
}
}
countryInfoEntityRepository.save(countryInfoEntity);
System.out.println(allPOIInfoQuery);
}
// @Test
void search() {
BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31100788726");
System.out.println(response);
}
}

View File

@ -46,4 +46,9 @@ public class CacheTest {
public void getRouteIdFromCache(){
RouteOrder routeById = routeCacheManage.getRouteById(1046L);
}
@Test
public void cancelCache(){
routeCacheService.invalidateRouteCache(null);
}
}

View File

@ -1,23 +1,24 @@
package com.chint;
import com.alibaba.fastjson.JSON;
import com.authine.cloudpivot.opensdk.ApiException;
import com.authine.cloudpivot.opensdk.CloudpivotOpenClient;
import com.authine.cloudpivot.opensdk.model.request.workflow.StartWorkflowRequest;
import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowResponse;
import com.chint.application.commands.RefundOrderGenerateCommand;
import com.chint.domain.aggregates.order.OrderTravel;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.infrastructure.constant.LYConstant;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository;
import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.BPMRequest;
import com.chint.interfaces.rest.bpm.XNBPM.ClientFactory;
import com.chint.interfaces.rest.bpm.XNBPM.YSTokenDto;
import com.chint.interfaces.rest.bpm.dot.*;
import com.chint.interfaces.rest.bpm.dot.BPMBaseResponse;
import com.chint.interfaces.rest.bpm.dto.*;
import com.chint.interfaces.rest.ly.*;
import com.chint.interfaces.rest.ly.dto.applyordersync.*;
@ -26,6 +27,7 @@ import com.chint.interfaces.rest.ly.dto.estimateprice.*;
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse;
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
import com.chint.interfaces.rest.ly.in.CommonController;
import com.chint.interfaces.rest.ly.vo.estimateprice.TrainPriceVo;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@ -40,7 +42,8 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static com.chint.infrastructure.constant.BPMConstant.*;
import static com.chint.infrastructure.constant.BPMConstant.H3BPM_EXCEED_STANDARD_URL;
import static com.chint.infrastructure.constant.BPMConstant.YSBPM_TOKEN_URL;
@SpringBootTest
public class LYTest {
@ -92,6 +95,9 @@ public class LYTest {
@Autowired
private JdbcOrderTravelRepository orderTravelRepository;
@Autowired
private CommonController commonController;
public static final String L_Y_BASE_URL = "https://api.qa.dttrip.cn/openapi";
public static final String L_Y_ORDER_PATH = "/openapi/api/TravelApplyOrder/ApplyOrderSync";
@ -759,7 +765,7 @@ public class LYTest {
}
// @Test
// @Test
void test11() {
List<OrderTravel> byOrderNo = orderTravelRepository.findByOrderNo(null);
System.out.println("byOrderNo = " + byOrderNo);
@ -769,7 +775,7 @@ public class LYTest {
}
// @Test
// @Test
void testClient() {
CloudpivotOpenClient xnInstance = ClientFactory.getXNInstance();
CloudpivotOpenClient zwInstance = ClientFactory.getZWInstance();
@ -777,7 +783,7 @@ public class LYTest {
System.out.println("zwInstance = " + zwInstance);
}
// @Test
// @Test
void removeDuplicates() {
StringBuilder stringBuilder = new StringBuilder();
String cityStr = stringBuilder.toString();
@ -787,8 +793,9 @@ public class LYTest {
System.out.println("join = " + join);
}
@Test
void search(){
void search() {
// FlightOrderResponse t1 = lySearchRequest
// .getFlightOrderDetail("DF24031466751565416");
// Gson gson = new Gson();
@ -806,4 +813,34 @@ public class LYTest {
String json = gson.toJson(trainDetailResponse);
System.out.println(json);
}
@Test
void conform() {
commonController.isOk(0, 9, "T24031566810476306");
}
@Test
void sendMsg() {
commonController.sendMsg("T24031566811702174");
}
// DTC24031466757493927
// DTC24031466757493927
// @Test
void generateLyTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DTC24031466757493927");
TrainDetailResponse.TrainDetailData data = trainOrderDetail.getData();
if (data != null && data.getOrderStatus().equals("T") && data.getItems() != null && !data.getItems().isEmpty()) {
TrainDetailResponse.Item item = data.getItems().get(0);
//状态为T说明该订单为退款订单 需要生成退款订单
Command.of(RefundOrderGenerateCommand.class).Info(
String.valueOf(item.getItemId()),
data.getOrderNo(),
"-" + item.getRefundAmount(),
"4",
data.getRefundTime()
).sendToQueue();
}
System.out.println(trainOrderDetail);
}
}

View File

@ -3,6 +3,7 @@ package com.chint;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chint.application.out.LoginController;
import com.chint.application.services.login.strategy.PailaLoginStrategy;
import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
@ -11,28 +12,30 @@ import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.*;
import com.chint.domain.service.JTCompanyDomainService;
import com.chint.infrastructure.util.Digest;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
import com.chint.interfaces.rest.ly.LYPostRequest;
import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.LYUserRequest;
import com.chint.interfaces.rest.ly.dto.flydatapushback.FlyOkDTO;
import com.chint.interfaces.rest.ly.dto.flydatapushback.ParamFly;
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.OrderInfo;
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
import com.chint.interfaces.rest.user.PushUser;
import com.chint.interfaces.rest.user.UserHttpRequest;
import com.chint.interfaces.rest.user.UserHttpRequestImpl;
import com.chint.interfaces.rest.user.UserSFRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@ -41,8 +44,6 @@ import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.FSSCConstant.FSSC_LOGIN_PATH_APPROVAL;
@Slf4j
@SpringBootTest
class RouteApplicationTests {
@ -68,13 +69,17 @@ class RouteApplicationTests {
@Autowired
private LegRepository legRepository;
@Autowired
private PrefectureLevelRepository prefectureLevelRepository;
@Autowired
private CountryLevelInfoRepository countryLevelInfoRepository;
@Autowired
private JTCompanyRepository jtCompanyRepository;
@Autowired
private JTCompanyDomainService jtCompanyDomainService;
@Value("${FSSC.jt-baseUrl}")
private String jtFSSCUrl;
@ -91,9 +96,28 @@ class RouteApplicationTests {
@Autowired
private PostRequest postRequest;
@Autowired
private LoginController loginController;
@Value("${chint.loginSecretKey}")
private String LOGIN_SECRET_KEY;
@Autowired
private UserHttpRequestImpl userHttpRequestImpl;
@Autowired
private UserSFRequest userSFRequest;
@Autowired
private PushUser pushUser;
@Autowired
private LYUserRequest lyUserRequest;
@Autowired
private CTripUserSaveRequest cTripUserSaveRequest;
void test3() {
FlyOkDTO freightDTO = new FlyOkDTO();
ParamFly param = new ParamFly();
@ -104,12 +128,26 @@ class RouteApplicationTests {
private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365");
// @Test
// @Test
void fsscLogin() {
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
System.out.println(postRequest.getReDirectUrl("http://10.10.100.129:8089" + "/MobileOA/api/FsscSSO?loginUser=230615020&data=%2F%23%2Fexpenseclaim%3FbillDefineId%3Dfcc76666fb1211e98e2019f4db5548fd%26scene%3DWRITE%26isNew%3Dtrue%26goback%3Dfalse"));
}
@Test
void syncUserTo(){
User user = new User();
user.setCompanyCode("A10000001");
user.setWorkStatus("A");
user.setGender("M");
user.setName("陈光金");
user.setCompanyName("正泰集团股份有限公司");
user.setEmployeeNo("605403");
lyUserRequest.saveCurrentUser(user);
cTripUserSaveRequest.saveUserToCTrip(user);
}
// @Test
@ -195,12 +233,12 @@ class RouteApplicationTests {
System.out.println(orderInfo.getOrderSerialNo());
}
// @Test
@Test
void loginSign() {
String sfno = "220324098";
String syscode = "XNFSSC";
String billcode = "CLSQ240311000011";
String companycode = "A70000056";
String sfno = "160601023";
String syscode = "FSSC";
String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司";
String timespan = "1708908662738";
String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan);
System.out.println(s);
@ -210,6 +248,22 @@ class RouteApplicationTests {
// log.trace("trace");
}
@Test
void loginSignProd() {
String sfno = "81001001";
String syscode = "FSSC";
String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司";
String timespan = "1708908662738";
String key = "ZhengTaiRoute";
String s = Digest.md5(sfno + syscode + billcode + companycode + key + timespan);
System.out.println(s);
// log.info("info");
// log.trace("trace");
// log.trace("trace");
// log.trace("trace");
}
// @Test
void queryUserInfo() {
User user2 = User.withEmployeeNo("180101001");
@ -234,7 +288,7 @@ class RouteApplicationTests {
locationRepository.saveAll(all);
}
// @Test
// @Test
void deleteRouteOrder() {
routeRepository.deleteById(875L);
}
@ -271,7 +325,7 @@ class RouteApplicationTests {
System.out.println(Arrays.toString(ids.toArray()));
}
// @Test
// @Test
void deleteRouteByEmployeeNo() {
List<RouteOrder> byEmployeeNo = routeRepository.findByEmployeeNo("230615020");
for (RouteOrder routeOrder : byEmployeeNo) {
@ -916,11 +970,22 @@ class RouteApplicationTests {
}
System.out.println(noCountryCity);
// System.out.println(newNoCountryCity);
System.out.println(locationList);
System.out.println(saveLocations);
}
@Test
void timeTest() {
DateTimeFormatter formatterWithT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//根据项目需求当传入的时间 使用该时间保存到订单当中
String startTime = "2024-05-31T00:00";
String substring = startTime.substring(0, 10);
System.out.println(LocalDate.parse(substring, formatterWithT));
}
@Test
void pushUserInfo() {
pushUser.getUserSFDataFromOpenApiBatch();
}
}