|
|
|
|
@ -18,6 +18,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author: shuguang
|
|
|
|
|
@ -85,31 +88,76 @@ public class MinFeeServiceImpl implements MinFeeService {
|
|
|
|
|
minFtpDownloadService.getMinFeeHrMdTask(uuid);
|
|
|
|
|
//开始查询sqlite任务表中华软未处理数据任务
|
|
|
|
|
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, Constant.SELECT_BUSINESS_HANDLER_HR_MIN_FEE);
|
|
|
|
|
|
|
|
|
|
// 创建线程池
|
|
|
|
|
ExecutorService executor = Executors.newFixedThreadPool(4); // 可以根据实际情况调整线程池的大小
|
|
|
|
|
if (businessTasks.size() > 0) {
|
|
|
|
|
//for (BusinessTasks businessTask : businessTasks) {
|
|
|
|
|
// String protocolType = businessTask.getProtocolType();
|
|
|
|
|
// String id = businessTask.getId();
|
|
|
|
|
// //是否处理完成
|
|
|
|
|
// boolean isFinished = false;
|
|
|
|
|
// //最小费额
|
|
|
|
|
// if (Constant.STR_SQB_250.equals(protocolType)) {
|
|
|
|
|
// createSqbByDllService.createMinFeeSqbByDll(uuid, businessTask);
|
|
|
|
|
// isFinished = true;
|
|
|
|
|
// }
|
|
|
|
|
// if (isFinished) {
|
|
|
|
|
// //更新中介库华软的下载状态
|
|
|
|
|
// //log.info("[uuid:{}]-更新中介库TF_DOWNLOAD_NOTIFY(id为:{})下载状态为1-已下载", uuid, id);
|
|
|
|
|
// LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-更新中介库TF_DOWNLOAD_NOTIFY(id为" +id+")下载状态为1-已下载", "MinFeeServiceImpl");
|
|
|
|
|
// DatabaseUtil.updateSql(driverName, HRConnectionStringOracle, HROracleName, HROraclePass, Constant.UPDATE_TF_DOWNLOAD_NOTIFY_HR + id, uuid);
|
|
|
|
|
// //删除下载的zip文件
|
|
|
|
|
// FileUtil.delete(new File(NFSFilePath + PathUtil.downFile + businessTask.getFileName()));
|
|
|
|
|
//
|
|
|
|
|
// } else {
|
|
|
|
|
// //log.info("[uuid:{}]最小费额文件数据处理失败,中介下载任务id{}不更新", uuid, id);
|
|
|
|
|
// LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-最小费额文件数据处理失败,中介下载任务(id为" +id+")不更新", "MinFeeServiceImpl");
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (BusinessTasks businessTask : businessTasks) {
|
|
|
|
|
String protocolType = businessTask.getProtocolType();
|
|
|
|
|
String id = businessTask.getId();
|
|
|
|
|
//是否处理完成
|
|
|
|
|
boolean isFinished = false;
|
|
|
|
|
//最小费额
|
|
|
|
|
if (Constant.STR_SQB_250.equals(protocolType)) {
|
|
|
|
|
createSqbByDllService.createMinFeeSqbByDll(uuid, businessTask);
|
|
|
|
|
isFinished = true;
|
|
|
|
|
}
|
|
|
|
|
if (isFinished) {
|
|
|
|
|
//更新中介库华软的下载状态
|
|
|
|
|
//log.info("[uuid:{}]-更新中介库TF_DOWNLOAD_NOTIFY(id为:{})下载状态为1-已下载", uuid, id);
|
|
|
|
|
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-更新中介库TF_DOWNLOAD_NOTIFY(id为" +id+")下载状态为1-已下载", "MinFeeServiceImpl");
|
|
|
|
|
DatabaseUtil.updateSql(driverName, HRConnectionStringOracle, HROracleName, HROraclePass, Constant.UPDATE_TF_DOWNLOAD_NOTIFY_HR + id, uuid);
|
|
|
|
|
//删除下载的zip文件
|
|
|
|
|
FileUtil.delete(new File(NFSFilePath + PathUtil.downFile + businessTask.getFileName()));
|
|
|
|
|
final String protocolType = businessTask.getProtocolType();
|
|
|
|
|
final String id = businessTask.getId();
|
|
|
|
|
executor.submit(() -> {
|
|
|
|
|
// 执行具体的任务
|
|
|
|
|
boolean isFinished = false;
|
|
|
|
|
if (Constant.STR_SQB_250.equals(protocolType)) {
|
|
|
|
|
createSqbByDllService.createMinFeeSqbByDll(uuid, businessTask);
|
|
|
|
|
isFinished = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
//log.info("[uuid:{}]最小费额文件数据处理失败,中介下载任务id{}不更新", uuid, id);
|
|
|
|
|
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-最小费额文件数据处理失败,中介下载任务(id为" +id+")不更新", "MinFeeServiceImpl");
|
|
|
|
|
if (isFinished) {
|
|
|
|
|
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-更新中介库TF_DOWNLOAD_NOTIFY(id为" + id + ")下载状态为1-已下载", "MinFeeServiceImpl");
|
|
|
|
|
DatabaseUtil.updateSql(driverName, HRConnectionStringOracle, HROracleName, HROraclePass, Constant.UPDATE_TF_DOWNLOAD_NOTIFY_HR + id, uuid);
|
|
|
|
|
FileUtil.delete(new File(NFSFilePath + PathUtil.downFile + businessTask.getFileName()));
|
|
|
|
|
} else {
|
|
|
|
|
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-最小费额文件数据处理失败,中介下载任务(id为" + id + ")不更新", "MinFeeServiceImpl");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关闭线程池
|
|
|
|
|
executor.shutdown();
|
|
|
|
|
|
|
|
|
|
// 等待所有任务完成
|
|
|
|
|
try {
|
|
|
|
|
// 设置一个合理的超时时间,例如6小时
|
|
|
|
|
if (!executor.awaitTermination(6, TimeUnit.HOURS)) {
|
|
|
|
|
// 如果超时,则取消当前执行的任务
|
|
|
|
|
executor.shutdownNow();
|
|
|
|
|
// 这里可以添加一些日志记录或者其他处理
|
|
|
|
|
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-最小费额文件数据处理任务执行超时,已尝试取消剩余任务" , "MinFeeServiceImpl");
|
|
|
|
|
}
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
// 如果等待过程中被中断,重新设置线程中断标志
|
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
|
// 取消当前执行的任务
|
|
|
|
|
executor.shutdownNow();
|
|
|
|
|
// 这里可以添加一些日志记录或者其他处理
|
|
|
|
|
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-最小费额文件数据处理等待任务执行过程中线程被中断" , "MinFeeServiceImpl");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sqliteBackupsService.buildBackups(uuid);
|
|
|
|
|
}
|
|
|
|
|
|