结算明细字段映射调整

This commit is contained in:
dengwc 2024-04-07 09:29:48 +08:00
parent 8084bda3c0
commit 08b303b9a7
11 changed files with 317 additions and 84 deletions

View File

@ -1,18 +1,32 @@
package com.chint.application.in;
import com.alibaba.fastjson.JSON;
import com.chint.application.commands.LYOrderRecordGenerateCommand;
import com.chint.application.dtos.AuthenticationSignDto;
import com.chint.application.dtos.CTripRecordMonthSaveDTO;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.factoriy.order_record.LyStatementOrder;
import com.chint.infrastructure.config.LogConfig.Dto.LogPageDto;
import com.chint.infrastructure.config.LogConfig.SystemLog;
import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.application.commands.OrderRecordGenerateCommand;
import com.chint.domain.factoriy.order_record.LyStatementOrder;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
import com.chint.infrastructure.util.BeanCopyUtils;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo;
import com.google.gson.Gson;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -74,4 +88,21 @@ public class AutoWorkController {
return Result.Success(SUCCESS);
}
@Autowired
private JdbcRouteRepository jdbcRouteRepository;
@Transactional
@ApiOperation("临时接口查询订单数据")
@PostMapping("/routeOrder/pageQuery")
public Result<PageResult<RouteOrder>> routeOrderPageQuery(@RequestBody PageInfo pageInfo) {
PageRequest pageResult = PageRequest.of(
pageInfo.getPageIndex() - 1,
pageInfo.getPageSize()
);
Page<RouteOrder> res = jdbcRouteRepository.findAllBy(pageResult);
PageResult<RouteOrder> routeOrderPageResult = PageResult.totalPageNum(res.getTotalElements(), res.toList());
return Result.Success(SUCCESS, routeOrderPageResult);
}
}

View File

@ -0,0 +1,16 @@
package com.chint.application.in;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.infrastructure.util.PageResult;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
@Data
public class RouteOrderPageDto {
private String msg;
private String code;
private PageResult<RouteOrder> data;
}

View File

@ -103,7 +103,11 @@ public class Leg implements Serializable {
return this.eventList.isEmpty() ? null : this.eventList.get(this.eventList.size() - 1);
}
public OrderDetail getLastOrderDetail() {
if (this.orderDetails == null) {
return null;
}
return this.orderDetails.stream()
.max(Comparator.comparingLong(OrderDetail::getOrderId))
.orElse(null);
@ -222,7 +226,6 @@ public class Leg implements Serializable {
}
// 如果列表为空且新事件不是准备事件抛出异常
// if (eventList.isEmpty() && newEventType != LegConstant.LEG_EVENT_PREPARE) {
// throw new LegEventException("The first event must be a prepare event.");

View File

@ -34,7 +34,6 @@ public class LegExtensionField implements Serializable {
private String estimatedAmount;
public LegExtensionField addLocationIdsAsString(List<Long> locationIds) {
this.locationIds = Arrays.toString(locationIds.toArray());
return this;
@ -42,6 +41,9 @@ public class LegExtensionField implements Serializable {
public List<Long> getLocationIdsAsLong() {
// 去除字符串开头和结尾的方括号
if (this.locationIds == null) {
return null;
}
// this.locationIds = this.locationIds.substring(1, this.locationIds.length() - 1);
// 根据逗号分割字符串
String[] items = this.locationIds.split(",");
@ -49,22 +51,33 @@ public class LegExtensionField implements Serializable {
List<Long> result = new ArrayList<>();
// 将每个分割后的字符串转换为Long并添加到列表中
for (String item : items) {
if (!item.trim().isEmpty()) {
result.add(Long.parseLong(item.trim()));
}
}
return result;
}
public List<Long> getLocationIdsAsLongFromArray() {
// 去除字符串开头和结尾的方括号
if (this.locationIds == null) {
return null;
}
if (this.locationIds.length() >= 2) {
this.locationIds = this.locationIds.substring(1, this.locationIds.length() - 1);
}
// 根据逗号分割字符串
String[] items = this.locationIds.split(",");
// 创建一个Long类型的列表
List<Long> result = new ArrayList<>();
// 将每个分割后的字符串转换为Long并添加到列表中
for (String item : items) {
// 检查字符串是否为空或只包含空格
if (!item.trim().isEmpty()) {
result.add(Long.parseLong(item.trim()));
}
}
return result;
}

View File

@ -34,7 +34,8 @@ public class WebConfig implements WebMvcConfigurer {
//调用bean
registry.addInterceptor(getMyRequestLoggingInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/public/log/pageQuery", "/order/pageQuery", "/OrderDetail/query/**", "/order/query/**", "/location/**");
.excludePathPatterns("/public/**/pageQuery", "/order/pageQuery", "/OrderDetail/query/**",
"/order/query/**", "/location/**", "/OrderDetail/record/query");
}

View File

@ -17,11 +17,11 @@ public class RouteOrderCallBackImpl implements BeforeSaveCallback<RouteOrder> {
entity.setCreateTime(LocalDateTime.now());
}
if (entity.getCreateUser() == null) {
entity.setCreateUser(BaseContext.getCurrentUser().getUserId().toString());
entity.setCreateUser(BaseContext.getCurrentUser() != null ? BaseContext.getCurrentUser().getUserId().toString() : "");
}
entity.setUpdateTime(LocalDateTime.now());
if (BaseContext.getCurrentUser() != null) {
entity.setUpdateUser(BaseContext.getCurrentUser().getUserId().toString());
entity.setUpdateUser(BaseContext.getCurrentUser() != null ? BaseContext.getCurrentUser().getUserId().toString() : "");
}
return entity;
}

View File

@ -2,6 +2,7 @@ package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.RouteOrder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@ -39,4 +40,6 @@ public interface JdbcRouteRepository extends CrudRepository<RouteOrder, Long> {
List<RouteOrder> findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(String userId, String approveOrderNo_creator);
List<RouteOrder> findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2);
Page<RouteOrder> findAllBy(PageRequest pageResult);
}

View File

@ -122,6 +122,26 @@ public class PostRequest {
return gson.fromJson(responseBody, responseType);
}
public <T> T postJSON(String url, Object jsonRequest, Class<T> responseType) {
HttpPost post = new HttpPost(url);
String json = JSON.toJSONString(jsonRequest);
log.info(json);
post.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));
String responseBody = null;
HttpEntity responseEntity = null;
HttpResponse response = null;
try {
response = client.execute(post);
responseEntity = response.getEntity();
responseBody = EntityUtils.toString(responseEntity, "UTF-8");
log.info(responseBody);
} catch (IOException e) {
throw new RuntimeException(e);
}
return JSON.parseObject(responseBody, responseType);
}
public Gson gson() {
return gson;
}

View File

@ -5,15 +5,12 @@ 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.RouteOrder;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.*;
import com.chint.domain.service.order_sync.CTripOrderSyncAdapter;
import com.chint.domain.service.supplier.SupplierService;
import com.chint.domain.value_object.SupplierCallbackData;
import com.chint.infrastructure.repository.CTripOrderDetailImpl;
import com.chint.infrastructure.repository.OrderFlightRecordRepositoryImpl;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.PinyinUtil;
@ -40,7 +37,6 @@ import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification;
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.ctrip.order.CTripOrderRecordAutoSave;
import com.google.gson.Gson;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -125,15 +121,6 @@ public class CTripTest {
@Value("${cTrip.requestSecret}")
private String C_TRIP_REQUEST_SECRET;
@Autowired
private OrderFlightRecordRepository orderFlightRecordRepository;
@Autowired
private CTripOrderDetailImpl cTripOrderDetail;
@Autowired
private CTripOrderRecordAutoSave cTripOrderRecordAutoSave;
private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365", "A30000001");
@ -246,10 +233,10 @@ public class CTripTest {
System.out.println(gson.toJson(estimate));
}
// @Test
@Test
void search() {
BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31288249965");
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31108053999");
System.out.println(response);
}
@ -497,11 +484,11 @@ public class CTripTest {
OrderFlightResponse.FlightOrderSettlementInfo flightOrderSettlementInfo = orderSettlementList.get(0);
OrderFlightResponse.FlightOrderSettlementBaseInfo orderSettlementBaseInfo =
flightOrderSettlementInfo.getOrderSettlementBaseInfo();
if (orderSettlementBaseInfo != null) {
CTripFlightRecordBase ctripFlightOrderDetail = new CTripFlightRecordBase();
/*if (orderSettlementBaseInfo != null) {
CtripFlightOrderDetail ctripFlightOrderDetail = new CtripFlightOrderDetail();
ctripFlightOrderDetail = ctripFlightOrderDetail.changeInfo(orderSettlementBaseInfo);
ctripOrderDetailRepository.save(ctripFlightOrderDetail);
}
}*/
}
}
}
@ -519,11 +506,11 @@ public class CTripTest {
OrderTrainResponse.CorpTrainSettlementInfo corpTrainSettlementInfo = lstTrainSettlementDetail.get(0);
OrderTrainResponse.CorpTrainSettlementDetail trainSettlementDetail =
corpTrainSettlementInfo.getTrainSettlementDetail();
if (trainSettlementDetail != null) {
CTripTrainRecordBase ctripTrainOrderDetail = new CTripTrainRecordBase();
/*if (trainSettlementDetail != null) {
CtripTrainOrderDetail ctripTrainOrderDetail = new CtripTrainOrderDetail();
ctripTrainOrderDetail = ctripTrainOrderDetail.changeInfo(trainSettlementDetail);
ctripOrderDetailRepository.save(ctripTrainOrderDetail);
}
}*/
}
}
}
@ -540,11 +527,11 @@ public class CTripTest {
if (!LstHotelSettlementDetail.isEmpty()) {
OrderHotelResponse.LstHotelSettlementDetail hotelSettlementDetail = LstHotelSettlementDetail.get(0);
OrderHotelResponse.SettlementDetail settlementDetail = hotelSettlementDetail.getSettlementDetail();
if (settlementDetail != null) {
CTripHotelRecordBase ctripFlightOrderDetail = new CTripHotelRecordBase();
/*if (settlementDetail != null) {
CtripHotelOrderDetail ctripFlightOrderDetail = new CtripHotelOrderDetail();
ctripFlightOrderDetail = ctripFlightOrderDetail.changeInfo(settlementDetail);
ctripOrderDetailRepository.save(ctripFlightOrderDetail);
}
}*/
}
}
}
@ -562,11 +549,11 @@ public class CTripTest {
if (!carSettlementDetailList.isEmpty()) {
OrderCarResponse.CarOrderSettlementDetail carOrderSettlementDetail = carSettlementDetailList.get(0);
OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = carOrderSettlementDetail.getSettlementBaseInfo();
if (settlementBaseInfo != null) {
CTripCarRecordBase ctripCarOrderDetail = new CTripCarRecordBase();
/*if (settlementBaseInfo != null) {
CtripCarOrderDetail ctripCarOrderDetail = new CtripCarOrderDetail();
ctripCarOrderDetail = ctripCarOrderDetail.changeInfo(settlementBaseInfo);
ctripOrderDetailRepository.save(ctripCarOrderDetail);
}
}*/
}
}
}
@ -596,26 +583,4 @@ public class CTripTest {
}
// @Test
void findRecord(){
CTripFlightRecord byId = cTripOrderDetail.findFlightRecordById(14513L);
Gson gson = new Gson();
System.out.println(gson.toJson(byId));
}
// @Test
void findHotelRecord(){
CTripHotelRecord byId = cTripOrderDetail.findHotelRecordByRecordId("97211839");
Gson gson = new Gson();
System.out.println(gson.toJson(byId));
}
// @Test
void findCarRecord(){
CTripCarRecord byId = cTripOrderDetail.findCarRecordByRecordId("50597248");
Gson gson = new Gson();
System.out.println(gson.toJson(byId));
}
}

View File

@ -10,23 +10,25 @@ import com.authine.cloudpivot.opensdk.config.CloudpivotEnvConfig;
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.application.in.AutoWorkController;
import com.chint.application.in.RouteOrderPageDto;
import com.chint.application.services.login.strategy.ANFeiShuLoginStrategy;
import com.chint.application.services.login.strategy.FeishuLoginStrategy;
import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderCarRecord;
import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderHotelRecord;
import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderTrainRecord;
import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.standards.XNStaffRank;
import com.chint.domain.factoriy.order_record.OrderRecordBasic;
import com.chint.infrastructure.config.LogConfig.LogController;
import com.chint.infrastructure.config.LogConfig.RedisCache;
import com.chint.infrastructure.config.LogConfig.SystemLog;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.*;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.BeanCopyUtils;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.XNBPM.YSTokenDto;
@ -41,6 +43,7 @@ import com.chint.interfaces.rest.ctrip.dto.search.car.OrderFee;
import com.chint.interfaces.rest.ctrip.dto.search.flight.ChangeInfo;
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity;
import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.LYBaseRequest;
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse;
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
import com.chint.interfaces.rest.ly.reconciliation.dto.BaseDetailParam;
@ -48,16 +51,22 @@ import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.CarStateme
import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.FlightStatement;
import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.HotelStatement;
import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.TrainStatement;
import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo;
import com.chint.interfaces.rest.ly.reconciliation.dto.statementList.ResStatementList;
import com.chint.interfaces.rest.ly.reconciliation.dto.statementList.StatementList;
import com.chint.interfaces.rest.ly.reconciliation.dto.statementList.StatementPageList;
import com.chint.interfaces.rest.ly.reconciliation.request.ReqStatement;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.lang.reflect.Type;
@ -67,12 +76,11 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.chint.infrastructure.constant.BPMConstant.AN_FSSC;
import static com.chint.infrastructure.constant.BPMConstant.YSBPM_TOKEN_URL;
@Slf4j
@ -470,7 +478,7 @@ public class ExcelTest {
@Autowired
private ANFeiShuLoginStrategy anFeiShuLoginStrategy;
@Test
// @Test
void ssoLogin() {
String login = anFeiShuLoginStrategy.login("b28o253524f34b25bd4da9ed3a224548");
System.out.println(login);
@ -503,6 +511,12 @@ public class ExcelTest {
ResStatementList resStatementList = reqStatement.queryStatementList(statementList);
log.info("resStatementList: {}", resStatementList);
ArrayList<ResStatementList.OnlineStatementList> onlineStatementList = resStatementList.getData().getOnlineStatementList();
// 获取当前时间
LocalDate now = LocalDate.now();
LocalDate startDate = now.minusMonths(2).withDayOfMonth(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String startTime = startDate.atStartOfDay().format(formatter);
String endTime = LocalDateTime.now().format(formatter);
for (ResStatementList.OnlineStatementList onlineStatement : onlineStatementList) {
String statementCode = onlineStatement.getStatementCode();//对账单编码
@ -517,7 +531,7 @@ public class ExcelTest {
//保存数据
List<FlightStatement.StatementOrderList> statementOrderList = flightStatement.getData().getStatementOrderList();
//查询已经保存的数据
List<String> orderSerialNoList = jdbcLyOrderFlightRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
List<String> orderSerialNoList = jdbcLyOrderFlightRecord.queryBillOrderNo(startTime, endTime);
//过滤出已经保存的数据
List<FlightStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
!orderSerialNoList.contains(o.getBillOrderNo())
@ -537,7 +551,7 @@ public class ExcelTest {
//保存数据
List<HotelStatement.StatementOrderList> statementOrderList = hotelStatement.getData().getStatementOrderList();
//查询已经保存的数据
List<String> orderSerialNoList = jdbcLyOrderHotelRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
List<String> orderSerialNoList = jdbcLyOrderHotelRecord.queryBillOrderNo(startTime, endTime);
//过滤出已经保存的数据
List<HotelStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
!orderSerialNoList.contains(o.getBillOrderNo())
@ -557,7 +571,7 @@ public class ExcelTest {
//保存数据
List<TrainStatement.StatementOrderList> statementOrderList = trainStatement.getData().getStatementOrderList();
//查询已经保存的数据
List<String> orderSerialNoList = jdbcLyOrderTrainRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
List<String> orderSerialNoList = jdbcLyOrderTrainRecord.queryBillOrderNo(startTime, endTime);
//过滤出已经保存的数据
List<TrainStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
!orderSerialNoList.contains(o.getBillOrderNo())
@ -578,7 +592,7 @@ public class ExcelTest {
//保存数据
List<CarStatement.StatementOrderList> statementOrderList = carStatement.getData().getStatementOrderList();
//查询已经保存的数据
List<String> orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
List<String> orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo(startTime, endTime);
//过滤出已经保存的数据
List<CarStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
!orderSerialNoList.contains(o.getBillOrderNo())
@ -595,17 +609,184 @@ public class ExcelTest {
// @Test
void awwe1() {
int count = 0;//初始化变量
int pageSize = 10; // 假设每页大小为10
int LoopNum;//需要的循环数
do {
PageRequest pageResult = PageRequest.of(count, pageSize);
Page<LyOrderFlightRecord> lyOrderFlightRecordPage = jdbcLyOrderFlightRecord.findAllByStatusIsNull(pageResult);
long totalElements = lyOrderFlightRecordPage.getTotalElements();//总数
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
//数据
List<LyOrderFlightRecord> lyOrderFlightRecordPageList = lyOrderFlightRecordPage.toList();
count++;
} while (count < LoopNum);
//修改数据将状态为null的设置为1
jdbcLyOrderFlightRecord.updateStatusByNullStatus();
}
@Autowired
private ApplicationContext applicationContext;
// @Test
public void hauwsdhauh() {
String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
String jsonString = JSON.toJSONString(beanDefinitionNames);
System.out.println("beanDefinitionNames = " + jsonString);
Object bean = applicationContext.getBean("orderDomainService");
System.out.println("bean = " + bean);
}
@Test
public void testDto() {
AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>();
OrderRecordBasic orderRecordBasic = getOrderRecordBasic("123", orderDetailRef::set);
OrderDetail orderDetail = orderDetailRef.get();
String orderNo = orderDetail.getOrderNo();
System.out.println("orderNo = " + orderNo);
System.out.println("orderNo = " + orderDetail);
OrderRecordBasic orderRecordBasic22 = getOrderRecordBasic22("123", orderDetailRef::set);
OrderDetail orderDetail22 = orderDetailRef.get();
String orderNo22 = orderDetail22.getOrderNo();
System.out.println("orderNo = " + orderNo22);
System.out.println("orderNo = " + orderDetail);
if (orderDetail22.equals(orderDetail) || orderDetail == orderDetail22) {
System.out.println("orderNo22 = " + orderNo22);
}
}
public OrderRecordBasic getOrderRecordBasic(String orderSerialNo, Consumer<OrderDetail> consumer) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderNo("1234561");
consumer.accept(orderDetail);
return null;
}
public OrderRecordBasic getOrderRecordBasic22(String orderSerialNo, Consumer<OrderDetail> consumer) {
OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderNo("123456122");
consumer.accept(orderDetail);
return null;
}
@Test
public void testStrDto() {
String ab = "dadasd";
String[] split = ab.split("-");
System.out.println("split[0] = " + split[0]);
}
//获取账期号
@Test
public void getAccountPeriod() {
// 获取当前时间
LocalDate now = LocalDate.now();
LocalDate startDate = now.minusMonths(2).withDayOfMonth(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDate parse = LocalDate.parse("2024-01-04 00:00:00",formatter);
LocalDate firstDayOfLastMonth = parse.minusMonths(1).withDayOfMonth(1);
LocalDate lastDayOfLastMonth = parse.withDayOfMonth(1).minusDays(1);
String beginDate = firstDayOfLastMonth.atStartOfDay().format(formatter);
System.out.println("beginDate = " + beginDate);
String endDate = lastDayOfLastMonth.atTime(23, 59, 59).format(formatter);
System.out.println("endDate = " + endDate);
String startTime = startDate.atStartOfDay().format(formatter);
System.out.println("startTime = " + startTime);
String endTime = LocalDateTime.now().format(formatter);
System.out.println("endTime = " + endTime);
}
@Autowired
private JdbcRouteRepository repository;
// @Test
@Transactional
public void getRouteOrder() throws Exception {
int count = 0;//初始化变量
int pageSize = 100; // 假设每页大小为100
int LoopNum;//需要的循环数
PageInfo pageInfo = new PageInfo();
pageInfo.setPageSize(pageSize);
String url = "http://127.0.0.1:8081/public/routeOrder/pageQuery";
do {
pageInfo.setPageIndex(count + 1);
RouteOrderPageDto routeOrderPageDto = postRequest.postJSON(url, pageInfo, RouteOrderPageDto.class);
PageResult<RouteOrder> pageResult = routeOrderPageDto.getData();
long totalElements = pageResult.getTotal();//总数
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
//保存数据
List<RouteOrder> records = pageResult.getRecords();
for (RouteOrder record : records) {
record.setRouteId(null);
List<Leg> legItems = record.getLegItems();
for (Leg legItem : legItems) {
legItem.setLegId(null);
legItem.setRouteId(null);
List<LegEvent> eventList = legItem.getEventList();
for (LegEvent legEvent : eventList) {
legEvent.setLegEventId(null);
legEvent.setLegId(null);
}
LegExtensionField legExtensionField = legItem.getLegExtensionField();
if (legExtensionField != null) {
legExtensionField.setId(null);
legExtensionField.setLegId(null);
}
}
List<OrderDetail> orderDetails = record.getOrderDetails();
for (OrderDetail orderDetail : orderDetails) {
orderDetail.setOrderId(null);
orderDetail.setRouteId(null);
orderDetail.setLegId(null);
List<OrderEvent> orderEventList = orderDetail.getOrderEventList();
for (OrderEvent orderEvent : orderEventList) {
orderEvent.setOrderEventId(null);
orderEvent.setOrderId(null);
}
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
if (carOrderDetail != null) {
carOrderDetail.setId(null);
}
FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail();
if (flightOrderDetail != null) {
flightOrderDetail.setId(null);
}
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
if (hotelOrderDetail != null) {
hotelOrderDetail.setId(null);
List<HotelOrderDetailCustomer> customers = hotelOrderDetail.getCustomers();
for (HotelOrderDetailCustomer customer : customers) {
customer.setId(null);
}
}
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
if (trainOrderDetail != null) {
trainOrderDetail.setId(null);
}
OtherOrderDetail otherOrderDetail = orderDetail.getOtherOrderDetail();
if (otherOrderDetail != null) {
otherOrderDetail.setId(null);
}
}
List<ApprovalEvent> approveEvents = record.getApproveEvents();
for (ApprovalEvent approveEvent : approveEvents) {
approveEvent.setRouteId(null);
approveEvent.setApprovalEventId(null);
}
}
log.info(JSON.toJSONString(records));
repository.saveAll(pageResult.getRecords());
count++;
} while (count < LoopNum);
log.info("成功");
if (true) {
log.info("成功");
throw new Exception();
}
}
}

View File

@ -811,7 +811,7 @@ public class LYTest {
System.out.println(json);
}
@Test
// @Test
void searchTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DTC24032868398852849");
Gson gson = new Gson();
@ -921,14 +921,14 @@ public class LYTest {
}
@Test
// @Test
void syncToSupplierOne(){
RouteOrder routeOrder = routeRepository.queryById(665L);
lyOrderSyncAdapter.syncSupplierOrder(routeOrder);
}
@Test
// @Test
void queryHotelCustom(){
OrderDetail byId = orderDetailRepository.findById(2569L);
HotelOrderDetailDto hotelOrderDetailDto = HotelOrderDetailDto.copyFrom(byId.getHotelOrderDetail());