结算明细字段映射调整
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,22 +93,11 @@ 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);
|
||||||
for (ResStatementList.OnlineStatementList onlineStatement : onlineStatementList) {
|
//创建一个线程池并行执行
|
||||||
String statementCode = onlineStatement.getStatementCode();//对账单编码
|
ThreadPoolExecutor executor = executeTask(onlineStatementList, startTime, endTime);
|
||||||
// 提交任务给线程池处理
|
try {
|
||||||
// 定义线程池,可以根据实际情况调整线程数量
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(4); // 创建一个包含4个线程的线程池
|
|
||||||
//1.查询机票账单详情
|
|
||||||
executor.submit(() -> flightStatement(statementCode, startTime, endTime));
|
|
||||||
//2.查询酒店账单详情
|
|
||||||
executor.submit(() -> hotelStatement(statementCode, startTime, endTime));
|
|
||||||
//3.查询火车票账单详情
|
|
||||||
executor.submit(() -> trainStatement(statementCode, startTime, endTime));
|
|
||||||
//4.查询用车账单详情
|
|
||||||
executor.submit(() -> carStatement(statementCode, startTime, endTime));
|
|
||||||
// 关闭线程池
|
// 关闭线程池
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
try {
|
|
||||||
// 等待所有任务执行完成或者超时时间到达(这里设置为一天)
|
// 等待所有任务执行完成或者超时时间到达(这里设置为一天)
|
||||||
boolean flag = executor.awaitTermination(1, TimeUnit.HOURS);
|
boolean flag = executor.awaitTermination(1, TimeUnit.HOURS);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -119,10 +106,31 @@ public class LyStatementOrder {
|
||||||
// 强制关闭线程池
|
// 强制关闭线程池
|
||||||
executor.shutdownNow();
|
executor.shutdownNow();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
log.info("保存成功!");
|
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) {
|
||||||
|
String statementCode = onlineStatement.getStatementCode();//对账单编码
|
||||||
|
//1.查询机票账单详情
|
||||||
|
executor.submit(() -> flightStatement(statementCode, startTime, endTime));
|
||||||
|
//2.查询酒店账单详情
|
||||||
|
executor.submit(() -> hotelStatement(statementCode, startTime, endTime));
|
||||||
|
//3.查询火车票账单详情
|
||||||
|
executor.submit(() -> trainStatement(statementCode, startTime, endTime));
|
||||||
|
//4.查询用车账单详情
|
||||||
|
executor.submit(() -> carStatement(statementCode, startTime, endTime));
|
||||||
|
}
|
||||||
|
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,11 +56,13 @@ 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;//需要的循环数
|
||||||
|
@ -72,19 +80,17 @@ public class LYOrderRecordDomainService {
|
||||||
}
|
}
|
||||||
//保存数据
|
//保存数据
|
||||||
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;//需要的循环数
|
||||||
|
@ -102,19 +108,17 @@ public class LYOrderRecordDomainService {
|
||||||
}
|
}
|
||||||
//保存数据
|
//保存数据
|
||||||
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;//需要的循环数
|
||||||
|
@ -132,20 +136,17 @@ public class LYOrderRecordDomainService {
|
||||||
}
|
}
|
||||||
//保存数据
|
//保存数据
|
||||||
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;//需要的循环数
|
||||||
|
@ -163,11 +164,29 @@ public class LYOrderRecordDomainService {
|
||||||
}
|
}
|
||||||
//保存数据
|
//保存数据
|
||||||
orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecords);
|
orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecords);
|
||||||
orderCarRecordsList.addAll(orderCarRecords);
|
|
||||||
count++;
|
count++;
|
||||||
} while (count < LoopNum);
|
} while (count < LoopNum);
|
||||||
//修改数据,将状态为null的设置为1
|
//修改数据,将状态为null的设置为1
|
||||||
jdbcLyOrderCarRecord.updateStatusByNullStatus();
|
jdbcLyOrderCarRecord.updateStatusByNullStatus();
|
||||||
return orderCarRecordsList;
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//使用线程并行执行
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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