结算明细字段映射调整
This commit is contained in:
parent
a39f3e50af
commit
213e0c9f29
|
@ -29,9 +29,7 @@ import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@ -95,11 +93,32 @@ public class LyStatementOrder {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
String startTime = startDate.atStartOfDay().format(formatter);
|
String startTime = startDate.atStartOfDay().format(formatter);
|
||||||
String endTime = LocalDateTime.now().format(formatter);
|
String endTime = LocalDateTime.now().format(formatter);
|
||||||
|
//创建一个线程池并行执行
|
||||||
|
ThreadPoolExecutor executor = executeTask(onlineStatementList, startTime, endTime);
|
||||||
|
try {
|
||||||
|
// 关闭线程池
|
||||||
|
executor.shutdown();
|
||||||
|
// 等待所有任务执行完成或者超时时间到达(这里设置为一天)
|
||||||
|
boolean flag = executor.awaitTermination(1, TimeUnit.HOURS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// 处理中断异常
|
||||||
|
log.error(e.getMessage());
|
||||||
|
// 强制关闭线程池
|
||||||
|
executor.shutdownNow();
|
||||||
|
}
|
||||||
|
log.info("保存成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private ThreadPoolExecutor executeTask(ArrayList<ResStatementList.OnlineStatementList> onlineStatementList, String startTime, String endTime) {
|
||||||
|
ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
||||||
|
4, // 核心线程数
|
||||||
|
4, // 最大线程数
|
||||||
|
0L, // 空闲线程存活时间
|
||||||
|
TimeUnit.MILLISECONDS, // 存活时间单位
|
||||||
|
new LinkedBlockingQueue<>(100) // 任务队列,设置一个有限大小的队列
|
||||||
|
);
|
||||||
for (ResStatementList.OnlineStatementList onlineStatement : onlineStatementList) {
|
for (ResStatementList.OnlineStatementList onlineStatement : onlineStatementList) {
|
||||||
String statementCode = onlineStatement.getStatementCode();//对账单编码
|
String statementCode = onlineStatement.getStatementCode();//对账单编码
|
||||||
// 提交任务给线程池处理
|
|
||||||
// 定义线程池,可以根据实际情况调整线程数量
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(4); // 创建一个包含4个线程的线程池
|
|
||||||
//1.查询机票账单详情
|
//1.查询机票账单详情
|
||||||
executor.submit(() -> flightStatement(statementCode, startTime, endTime));
|
executor.submit(() -> flightStatement(statementCode, startTime, endTime));
|
||||||
//2.查询酒店账单详情
|
//2.查询酒店账单详情
|
||||||
|
@ -108,19 +127,8 @@ public class LyStatementOrder {
|
||||||
executor.submit(() -> trainStatement(statementCode, startTime, endTime));
|
executor.submit(() -> trainStatement(statementCode, startTime, endTime));
|
||||||
//4.查询用车账单详情
|
//4.查询用车账单详情
|
||||||
executor.submit(() -> carStatement(statementCode, startTime, endTime));
|
executor.submit(() -> carStatement(statementCode, startTime, endTime));
|
||||||
// 关闭线程池
|
|
||||||
executor.shutdown();
|
|
||||||
try {
|
|
||||||
// 等待所有任务执行完成或者超时时间到达(这里设置为一天)
|
|
||||||
boolean flag = executor.awaitTermination(1, TimeUnit.HOURS);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// 处理中断异常
|
|
||||||
log.error(e.getMessage());
|
|
||||||
// 强制关闭线程池
|
|
||||||
executor.shutdownNow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
log.info("保存成功!");
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.domain.service.order_record;
|
||||||
|
|
||||||
import com.chint.application.commands.LYOrderRecordGenerateCommand;
|
import com.chint.application.commands.LYOrderRecordGenerateCommand;
|
||||||
import com.chint.application.commands.OrderRecordGenerateCommand;
|
import com.chint.application.commands.OrderRecordGenerateCommand;
|
||||||
|
import com.chint.domain.aggregates.order.OrderDetail;
|
||||||
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
|
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
|
||||||
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
|
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
|
||||||
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
|
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
|
||||||
|
@ -19,14 +20,19 @@ import com.chint.infrastructure.util.PageResult;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
import org.springframework.transaction.TransactionStatus;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LYOrderRecordDomainService {
|
public class LYOrderRecordDomainService {
|
||||||
|
@ -50,124 +56,137 @@ public class LYOrderRecordDomainService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderDetailDomainService orderDetailDomainService;
|
private OrderDetailDomainService orderDetailDomainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSourceTransactionManager transactionManager;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 0)
|
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 0)
|
||||||
public List<OrderFlightRecord> generateFlightRecord(LYOrderRecordGenerateCommand command) {
|
public void generateFlightRecord(LYOrderRecordGenerateCommand command) {
|
||||||
ArrayList<OrderFlightRecord> orderFlightRecordList = new ArrayList<>();
|
useThread(() -> {
|
||||||
int count = 0;//初始化变量
|
int count = 0;//初始化变量
|
||||||
int pageSize = 100; // 假设每页大小为10
|
int pageSize = 100; // 假设每页大小为10
|
||||||
int LoopNum;//需要的循环数
|
int LoopNum;//需要的循环数
|
||||||
do {
|
do {
|
||||||
PageRequest pageResult = PageRequest.of(count, pageSize);
|
PageRequest pageResult = PageRequest.of(count, pageSize);
|
||||||
Page<LyOrderFlightRecord> lyOrderFlightRecordPage = jdbcLyOrderFlightRecord.findAllByStatusIsNull(pageResult);
|
Page<LyOrderFlightRecord> lyOrderFlightRecordPage = jdbcLyOrderFlightRecord.findAllByStatusIsNull(pageResult);
|
||||||
long totalElements = lyOrderFlightRecordPage.getTotalElements();//总数
|
long totalElements = lyOrderFlightRecordPage.getTotalElements();//总数
|
||||||
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
||||||
//数据
|
//数据
|
||||||
List<LyOrderFlightRecord> lyOrderFlightRecordPageList = lyOrderFlightRecordPage.toList();
|
List<LyOrderFlightRecord> lyOrderFlightRecordPageList = lyOrderFlightRecordPage.toList();
|
||||||
ArrayList<OrderFlightRecord> orderFlightRecords = new ArrayList<>(100);
|
ArrayList<OrderFlightRecord> orderFlightRecords = new ArrayList<>(100);
|
||||||
for (LyOrderFlightRecord lyOrderFlightRecord : lyOrderFlightRecordPageList) {
|
for (LyOrderFlightRecord lyOrderFlightRecord : lyOrderFlightRecordPageList) {
|
||||||
OrderFlightRecord orderFlightRecord = lyOrderRecordExtensionFactory.createFlightOrderRecord(lyOrderFlightRecord);//转换
|
OrderFlightRecord orderFlightRecord = lyOrderRecordExtensionFactory.createFlightOrderRecord(lyOrderFlightRecord);//转换
|
||||||
orderFlightRecords.add(orderFlightRecord);
|
orderFlightRecords.add(orderFlightRecord);
|
||||||
}
|
}
|
||||||
//保存数据
|
//保存数据
|
||||||
orderDetailDomainService.saveFlightOrderRecordBatch(orderFlightRecords);
|
orderDetailDomainService.saveFlightOrderRecordBatch(orderFlightRecords);
|
||||||
orderFlightRecordList.addAll(orderFlightRecords);
|
count++;
|
||||||
count++;
|
} while (count < LoopNum);
|
||||||
} while (count < LoopNum);
|
//修改数据,将状态为null的设置为1
|
||||||
//修改数据,将状态为null的设置为1
|
jdbcLyOrderFlightRecord.updateStatusByNullStatus();
|
||||||
jdbcLyOrderFlightRecord.updateStatusByNullStatus();
|
});
|
||||||
return orderFlightRecordList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 1)
|
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 1)
|
||||||
public List<OrderHotelRecord> generateHotelRecord(LYOrderRecordGenerateCommand command) {
|
public void generateHotelRecord(LYOrderRecordGenerateCommand command) {
|
||||||
ArrayList<OrderHotelRecord> orderHotelRecordList = new ArrayList<>();
|
useThread(() -> {
|
||||||
int count = 0;//初始化变量
|
int count = 0;//初始化变量
|
||||||
int pageSize = 100; // 假设每页大小为10
|
int pageSize = 100; // 假设每页大小为10
|
||||||
int LoopNum;//需要的循环数
|
int LoopNum;//需要的循环数
|
||||||
do {
|
do {
|
||||||
PageRequest pageResult = PageRequest.of(count, pageSize);
|
PageRequest pageResult = PageRequest.of(count, pageSize);
|
||||||
Page<LyOrderHotelRecord> lyOrderHotelRecordPage = jdbcLyOrderHotelRecord.findAllByStatusIsNull(pageResult);
|
Page<LyOrderHotelRecord> lyOrderHotelRecordPage = jdbcLyOrderHotelRecord.findAllByStatusIsNull(pageResult);
|
||||||
long totalElements = lyOrderHotelRecordPage.getTotalElements();//总数
|
long totalElements = lyOrderHotelRecordPage.getTotalElements();//总数
|
||||||
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
||||||
//数据
|
//数据
|
||||||
List<LyOrderHotelRecord> lyOrderHotelRecordPageList = lyOrderHotelRecordPage.toList();
|
List<LyOrderHotelRecord> lyOrderHotelRecordPageList = lyOrderHotelRecordPage.toList();
|
||||||
ArrayList<OrderHotelRecord> orderHotelRecords = new ArrayList<>(100);
|
ArrayList<OrderHotelRecord> orderHotelRecords = new ArrayList<>(100);
|
||||||
for (LyOrderHotelRecord lyOrderHotelRecord : lyOrderHotelRecordPageList) {
|
for (LyOrderHotelRecord lyOrderHotelRecord : lyOrderHotelRecordPageList) {
|
||||||
OrderHotelRecord orderHotelRecord = lyOrderRecordExtensionFactory.createHotelOrderRecord(lyOrderHotelRecord);//转换
|
OrderHotelRecord orderHotelRecord = lyOrderRecordExtensionFactory.createHotelOrderRecord(lyOrderHotelRecord);//转换
|
||||||
orderHotelRecords.add(orderHotelRecord);
|
orderHotelRecords.add(orderHotelRecord);
|
||||||
}
|
}
|
||||||
//保存数据
|
//保存数据
|
||||||
orderDetailDomainService.saveHotelOrderRecordBatch(orderHotelRecords);
|
orderDetailDomainService.saveHotelOrderRecordBatch(orderHotelRecords);
|
||||||
orderHotelRecordList.addAll(orderHotelRecords);
|
count++;
|
||||||
count++;
|
} while (count < LoopNum);
|
||||||
} while (count < LoopNum);
|
//修改数据,将状态为null的设置为1
|
||||||
//修改数据,将状态为null的设置为1
|
jdbcLyOrderHotelRecord.updateStatusByNullStatus();
|
||||||
jdbcLyOrderHotelRecord.updateStatusByNullStatus();
|
});
|
||||||
return orderHotelRecordList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 2)
|
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 2)
|
||||||
public List<OrderTrainRecord> generateTrainRecord(LYOrderRecordGenerateCommand command) {
|
public void generateTrainRecord(LYOrderRecordGenerateCommand command) {
|
||||||
ArrayList<OrderTrainRecord> orderTrainRecordsList = new ArrayList<>();
|
useThread(() -> {
|
||||||
int count = 0;//初始化变量
|
int count = 0;//初始化变量
|
||||||
int pageSize = 100; // 假设每页大小为10
|
int pageSize = 100; // 假设每页大小为10
|
||||||
int LoopNum;//需要的循环数
|
int LoopNum;//需要的循环数
|
||||||
do {
|
do {
|
||||||
PageRequest pageResult = PageRequest.of(count, pageSize);
|
PageRequest pageResult = PageRequest.of(count, pageSize);
|
||||||
Page<LyOrderTrainRecord> lyOrderTrainRecordPage = jdbcLyOrderTrainRecord.findAllByStatusIsNull(pageResult);
|
Page<LyOrderTrainRecord> lyOrderTrainRecordPage = jdbcLyOrderTrainRecord.findAllByStatusIsNull(pageResult);
|
||||||
long totalElements = lyOrderTrainRecordPage.getTotalElements();//总数
|
long totalElements = lyOrderTrainRecordPage.getTotalElements();//总数
|
||||||
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
||||||
//数据
|
//数据
|
||||||
List<LyOrderTrainRecord> lyOrderTrainRecordPageList = lyOrderTrainRecordPage.toList();
|
List<LyOrderTrainRecord> lyOrderTrainRecordPageList = lyOrderTrainRecordPage.toList();
|
||||||
ArrayList<OrderTrainRecord> orderTrainRecords = new ArrayList<>(100);
|
ArrayList<OrderTrainRecord> orderTrainRecords = new ArrayList<>(100);
|
||||||
for (LyOrderTrainRecord lyOrderTrainRecord : lyOrderTrainRecordPageList) {
|
for (LyOrderTrainRecord lyOrderTrainRecord : lyOrderTrainRecordPageList) {
|
||||||
OrderTrainRecord orderTrainRecord = lyOrderRecordExtensionFactory.createTrainOrderRecord(lyOrderTrainRecord);//转换
|
OrderTrainRecord orderTrainRecord = lyOrderRecordExtensionFactory.createTrainOrderRecord(lyOrderTrainRecord);//转换
|
||||||
orderTrainRecords.add(orderTrainRecord);
|
orderTrainRecords.add(orderTrainRecord);
|
||||||
}
|
}
|
||||||
//保存数据
|
//保存数据
|
||||||
orderDetailDomainService.saveTrainOrderRecordBatch(orderTrainRecords);
|
orderDetailDomainService.saveTrainOrderRecordBatch(orderTrainRecords);
|
||||||
orderTrainRecordsList.addAll(orderTrainRecords);
|
count++;
|
||||||
count++;
|
} while (count < LoopNum);
|
||||||
} while (count < LoopNum);
|
//修改数据,将状态为null的设置为1
|
||||||
//修改数据,将状态为null的设置为1
|
jdbcLyOrderTrainRecord.updateStatusByNullStatus();
|
||||||
jdbcLyOrderTrainRecord.updateStatusByNullStatus();
|
});
|
||||||
return orderTrainRecordsList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 3)
|
@ListenTo(command = "LYOrderRecordGenerateCommand", order = 3)
|
||||||
public List<OrderCarRecord> generateCarRecord(LYOrderRecordGenerateCommand command) {
|
public void generateCarRecord(LYOrderRecordGenerateCommand command) {
|
||||||
ArrayList<OrderCarRecord> orderCarRecordsList = new ArrayList<>();
|
useThread(() -> {
|
||||||
int count = 0;//初始化变量
|
int count = 0;//初始化变量
|
||||||
int pageSize = 100; // 假设每页大小为10
|
int pageSize = 100; // 假设每页大小为10
|
||||||
int LoopNum;//需要的循环数
|
int LoopNum;//需要的循环数
|
||||||
do {
|
do {
|
||||||
PageRequest pageResult = PageRequest.of(count, pageSize);
|
PageRequest pageResult = PageRequest.of(count, pageSize);
|
||||||
Page<LyOrderCarRecord> lyOrderCarRecordPage = jdbcLyOrderCarRecord.findAllByStatusIsNull(pageResult);
|
Page<LyOrderCarRecord> lyOrderCarRecordPage = jdbcLyOrderCarRecord.findAllByStatusIsNull(pageResult);
|
||||||
long totalElements = lyOrderCarRecordPage.getTotalElements();//总数
|
long totalElements = lyOrderCarRecordPage.getTotalElements();//总数
|
||||||
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
LoopNum = (int) Math.ceil((double) totalElements / pageSize); // 计算总页数并向上取整
|
||||||
//数据
|
//数据
|
||||||
List<LyOrderCarRecord> lyOrderCarRecordPageList = lyOrderCarRecordPage.toList();
|
List<LyOrderCarRecord> lyOrderCarRecordPageList = lyOrderCarRecordPage.toList();
|
||||||
ArrayList<OrderCarRecord> orderCarRecords = new ArrayList<>(100);
|
ArrayList<OrderCarRecord> orderCarRecords = new ArrayList<>(100);
|
||||||
for (LyOrderCarRecord lyOrderCarRecord : lyOrderCarRecordPageList) {
|
for (LyOrderCarRecord lyOrderCarRecord : lyOrderCarRecordPageList) {
|
||||||
OrderCarRecord orderCarRecord = lyOrderRecordExtensionFactory.createCarOrderRecord(lyOrderCarRecord);//转换
|
OrderCarRecord orderCarRecord = lyOrderRecordExtensionFactory.createCarOrderRecord(lyOrderCarRecord);//转换
|
||||||
orderCarRecords.add(orderCarRecord);
|
orderCarRecords.add(orderCarRecord);
|
||||||
|
}
|
||||||
|
//保存数据
|
||||||
|
orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecords);
|
||||||
|
count++;
|
||||||
|
} while (count < LoopNum);
|
||||||
|
//修改数据,将状态为null的设置为1
|
||||||
|
jdbcLyOrderCarRecord.updateStatusByNullStatus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//使用线程并行执行
|
||||||
|
public void useThread(Runnable runnable) {
|
||||||
|
new Thread(() -> {
|
||||||
|
// 开启事务
|
||||||
|
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||||
|
def.setPropagationBehaviorName("PROPAGATION_REQUIRED");
|
||||||
|
TransactionStatus status = transactionManager.getTransaction(def);
|
||||||
|
try {
|
||||||
|
runnable.run();//执行具体方法
|
||||||
|
// 提交事务
|
||||||
|
transactionManager.commit(status);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 发生异常时回滚事务
|
||||||
|
transactionManager.rollback(status);
|
||||||
}
|
}
|
||||||
//保存数据
|
}).start();
|
||||||
orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecords);
|
|
||||||
orderCarRecordsList.addAll(orderCarRecords);
|
|
||||||
count++;
|
|
||||||
} while (count < LoopNum);
|
|
||||||
//修改数据,将状态为null的设置为1
|
|
||||||
jdbcLyOrderCarRecord.updateStatusByNullStatus();
|
|
||||||
return orderCarRecordsList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,7 @@ public class WebConfig implements WebMvcConfigurer {
|
||||||
//调用bean
|
//调用bean
|
||||||
registry.addInterceptor(getMyRequestLoggingInterceptor())
|
registry.addInterceptor(getMyRequestLoggingInterceptor())
|
||||||
.addPathPatterns("/**")
|
.addPathPatterns("/**")
|
||||||
.excludePathPatterns("/public/**/pageQuery", "/order/pageQuery", "/OrderDetail/query/**",
|
.excludePathPatterns("/location/**", "/**/query/**", "/**/pageQuery/**");
|
||||||
"/order/query/**", "/location/**", "/OrderDetail/record/query");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue