Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/main/java/com/chint/application/in/AutoWorkController.java # src/main/java/com/chint/domain/factoriy/order_record/LyStatementOrder.java
This commit is contained in:
commit
5ba9a05f34
|
@ -1,8 +1,6 @@
|
|||
package com.chint.application.in;
|
||||
|
||||
|
||||
import com.chint.application.commands.OrderRecordGenerateCommand;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -22,6 +20,9 @@ public class AutoWorkController {
|
|||
@Autowired
|
||||
private CTripOrderRecordAutoSave cTripOrderRecordAutoSave;
|
||||
|
||||
@Autowired
|
||||
private LyStatementOrder lyStatementOrder;
|
||||
|
||||
|
||||
@Transactional
|
||||
@ApiOperation("自动拉取昨天的流水号,每天晚上8点执行")
|
||||
|
@ -34,4 +35,12 @@ public class AutoWorkController {
|
|||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@ApiOperation("自动拉取同程上个月的流水号")
|
||||
@PostMapping("/ly/record/save")
|
||||
public Result<String> autoSaveLYRecord() {
|
||||
lyStatementOrder.saveAll();
|
||||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -49,6 +48,21 @@ public class LyStatementOrder {
|
|||
private JdbcLyOrderCarRecord jdbcLyOrderCarRecord;
|
||||
|
||||
|
||||
/**
|
||||
* 拉取保存数据
|
||||
*/
|
||||
@Transactional
|
||||
public void saveAll() {
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDate firstDayOfLastMonth = today.minusMonths(1).withDayOfMonth(1);
|
||||
LocalDate lastDayOfLastMonth = today.withDayOfMonth(1).minusDays(1);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String beginDate = firstDayOfLastMonth.atStartOfDay().format(formatter);
|
||||
String endDate = lastDayOfLastMonth.atTime(23, 59, 59).format(formatter);
|
||||
//同步
|
||||
statementOrder(beginDate, endDate);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同程账单数据拉取
|
||||
|
@ -56,6 +70,7 @@ public class LyStatementOrder {
|
|||
* @param beginDate 2024-03-01 00:00:00
|
||||
* @param endDate 2024-03-26 00:00:00
|
||||
*/
|
||||
|
||||
@Transactional
|
||||
public void statementOrder(String beginDate, String endDate) {
|
||||
StatementPageList param = new StatementPageList();
|
||||
|
@ -96,10 +111,10 @@ public class LyStatementOrder {
|
|||
//保存数据
|
||||
List<FlightStatement.StatementOrderList> statementOrderList = flightStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderFlightRecord.queryOrderSerialNo(beginDate, endDate);
|
||||
List<String> orderSerialNoList = jdbcLyOrderFlightRecord.queryBillOrderNo(beginDate, endDate);
|
||||
//过滤出已经保存的数据
|
||||
List<FlightStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderFlightRecord> lyOrderFlightRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderFlightRecord.class);
|
||||
jdbcLyOrderFlightRecord.saveAll(lyOrderFlightRecords);
|
||||
|
@ -120,10 +135,10 @@ public class LyStatementOrder {
|
|||
//保存数据
|
||||
List<HotelStatement.StatementOrderList> statementOrderList = hotelStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderHotelRecord.queryOrderSerialNo(beginDate, endDate);
|
||||
List<String> orderSerialNoList = jdbcLyOrderHotelRecord.queryBillOrderNo(beginDate, endDate);
|
||||
//过滤出已经保存的数据
|
||||
List<HotelStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderHotelRecord> lyOrderHotelRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderHotelRecord.class);
|
||||
jdbcLyOrderHotelRecord.saveAll(lyOrderHotelRecords);
|
||||
|
@ -144,10 +159,10 @@ public class LyStatementOrder {
|
|||
//保存数据
|
||||
List<TrainStatement.StatementOrderList> statementOrderList = trainStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderTrainRecord.queryOrderSerialNo(beginDate, endDate);
|
||||
List<String> orderSerialNoList = jdbcLyOrderTrainRecord.queryBillOrderNo(beginDate, endDate);
|
||||
//过滤出已经保存的数据
|
||||
List<TrainStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderTrainRecord> lyOrderTrainRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderTrainRecord.class);
|
||||
jdbcLyOrderTrainRecord.saveAll(lyOrderTrainRecords);
|
||||
|
@ -169,10 +184,10 @@ public class LyStatementOrder {
|
|||
//保存数据
|
||||
List<CarStatement.StatementOrderList> statementOrderList = carStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderCarRecord.queryOrderSerialNo(beginDate, endDate);
|
||||
List<String> orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo(beginDate, endDate);
|
||||
//过滤出已经保存的数据
|
||||
List<CarStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderCarRecord> lyOrderCarRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderCarRecord.class);
|
||||
jdbcLyOrderCarRecord.saveAll(lyOrderCarRecords);
|
||||
|
@ -180,4 +195,5 @@ public class LyStatementOrder {
|
|||
} while (carCount < carPageCount);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ import java.util.List;
|
|||
|
||||
@Repository
|
||||
public interface JdbcLyOrderCarRecord extends CrudRepository<LyOrderCarRecord, Long> {
|
||||
@Query(value = "SELECT order_serial_no FROM ly_order_car_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryOrderSerialNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
@Query(value = "SELECT bill_order_no FROM ly_order_car_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryBillOrderNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ import java.util.List;
|
|||
|
||||
@Repository
|
||||
public interface JdbcLyOrderFlightRecord extends CrudRepository<LyOrderFlightRecord, Long> {
|
||||
@Query(value = "SELECT order_serial_no FROM ly_order_flight_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryOrderSerialNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
@Query(value = "SELECT bill_order_no FROM ly_order_flight_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryBillOrderNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@ import java.util.List;
|
|||
|
||||
@Repository
|
||||
public interface JdbcLyOrderHotelRecord extends CrudRepository<LyOrderHotelRecord, Long> {
|
||||
@Query(value = "SELECT order_serial_no FROM ly_order_hotel_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryOrderSerialNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
@Query(value = "SELECT bill_order_no FROM ly_order_hotel_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryBillOrderNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@ import java.util.List;
|
|||
|
||||
@Repository
|
||||
public interface JdbcLyOrderTrainRecord extends CrudRepository<LyOrderTrainRecord, Long> {
|
||||
@Query(value = "SELECT order_serial_no FROM ly_order_train_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryOrderSerialNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
@Query(value = "SELECT bill_order_no FROM ly_order_train_record WHERE enter_account BETWEEN :beginDate AND :endDate")
|
||||
List<String> queryBillOrderNo(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ import java.io.File;
|
|||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
@ -491,13 +492,13 @@ public class ExcelTest {
|
|||
@Autowired
|
||||
private JdbcLyOrderCarRecord jdbcLyOrderCarRecord;
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
void statementTest() {
|
||||
StatementPageList param = new StatementPageList();
|
||||
param.setPageIndex(1)
|
||||
.setPageSize(10)
|
||||
.setBeginDate("2024-03-01 00:00:00")//2024-03-01 00:00:00
|
||||
.setEndDate("2024-03-26 00:00:00");
|
||||
.setEndDate("2024-03-31 23:59:59");
|
||||
StatementList statementList = new StatementList(param);
|
||||
ResStatementList resStatementList = reqStatement.queryStatementList(statementList);
|
||||
log.info("resStatementList: {}", resStatementList);
|
||||
|
@ -516,10 +517,10 @@ public class ExcelTest {
|
|||
//保存数据
|
||||
List<FlightStatement.StatementOrderList> statementOrderList = flightStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderFlightRecord.queryOrderSerialNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
List<String> orderSerialNoList = jdbcLyOrderFlightRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
//过滤出已经保存的数据
|
||||
List<FlightStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderFlightRecord> lyOrderFlightRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderFlightRecord.class);
|
||||
jdbcLyOrderFlightRecord.saveAll(lyOrderFlightRecords);
|
||||
|
@ -536,10 +537,10 @@ public class ExcelTest {
|
|||
//保存数据
|
||||
List<HotelStatement.StatementOrderList> statementOrderList = hotelStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderHotelRecord.queryOrderSerialNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
List<String> orderSerialNoList = jdbcLyOrderHotelRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
//过滤出已经保存的数据
|
||||
List<HotelStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderHotelRecord> lyOrderHotelRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderHotelRecord.class);
|
||||
jdbcLyOrderHotelRecord.saveAll(lyOrderHotelRecords);
|
||||
|
@ -556,10 +557,10 @@ public class ExcelTest {
|
|||
//保存数据
|
||||
List<TrainStatement.StatementOrderList> statementOrderList = trainStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderTrainRecord.queryOrderSerialNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
List<String> orderSerialNoList = jdbcLyOrderTrainRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
//过滤出已经保存的数据
|
||||
List<TrainStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderTrainRecord> lyOrderTrainRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderTrainRecord.class);
|
||||
jdbcLyOrderTrainRecord.saveAll(lyOrderTrainRecords);
|
||||
|
@ -577,10 +578,10 @@ public class ExcelTest {
|
|||
//保存数据
|
||||
List<CarStatement.StatementOrderList> statementOrderList = carStatement.getData().getStatementOrderList();
|
||||
//查询已经保存的数据
|
||||
List<String> orderSerialNoList = jdbcLyOrderCarRecord.queryOrderSerialNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
List<String> orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo("2024-03-01 00:00:00", "2024-03-26 23:00:00");
|
||||
//过滤出已经保存的数据
|
||||
List<CarStatement.StatementOrderList> statementOrderListNew = statementOrderList.stream().filter(o ->
|
||||
!orderSerialNoList.contains(o.getOrderSerialNo())
|
||||
!orderSerialNoList.contains(o.getBillOrderNo())
|
||||
).toList();
|
||||
List<LyOrderCarRecord> lyOrderCarRecords = BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderCarRecord.class);
|
||||
jdbcLyOrderCarRecord.saveAll(lyOrderCarRecords);
|
||||
|
@ -592,5 +593,19 @@ public class ExcelTest {
|
|||
|
||||
}
|
||||
|
||||
// @Test
|
||||
void awwe1() {
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue