main
gaoshuguang 1 year ago
parent 96f9969baa
commit 0c0ca2b421

@ -95,7 +95,8 @@ public class StringUtil {
*/ */
public static String sqliteInsert(BusinessTasks bt) { public static String sqliteInsert(BusinessTasks bt) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO business_tasks_info (id,fileName,size,recordCount,downStatus,protocolType,downloadTime,consumTime,version,newVersion,proStatus,middleDatabase,handleStatus,createTime) VALUES(") //sb.append("INSERT INTO business_tasks_info (id,fileName,size,recordCount,downStatus,protocolType,downloadTime,consumTime,version,newVersion,proStatus,middleDatabase,handleStatus,createTime) VALUES(")
sb.append("REPLACE INTO business_tasks_info (id,fileName,size,recordCount,downStatus,protocolType,downloadTime,consumTime,version,newVersion,proStatus,middleDatabase,handleStatus,createTime) VALUES(")
.append(bt.getId()).append(",") .append(bt.getId()).append(",")
.append("'").append(bt.getFileName()).append("'").append(",") .append("'").append(bt.getFileName()).append("'").append(",")
.append("'").append(bt.getSize()).append("'").append(",") .append("'").append(bt.getSize()).append("'").append(",")

@ -104,8 +104,8 @@ public class CreateSqbByDllServiceImpl implements CreateSqbByDllService {
//} else { //} else {
subComNO = String.valueOf(nameTable.getSubComNo()); subComNO = String.valueOf(nameTable.getSubComNo());
switch (subComNO) { switch (subComNO) {
case "38"://十大 case "37"://十大
subComNO = "37"; subComNO = "38";
break; break;
case "34"://大东 和城大 case "34"://大东 和城大
subComNO = "33"; subComNO = "33";
@ -113,11 +113,11 @@ public class CreateSqbByDllServiceImpl implements CreateSqbByDllService {
case "29"://东察 case "29"://东察
subComNO = "35"; subComNO = "35";
break; break;
case "48": //case "48":
case "50": //case "50":
case "59": //case "59":
subComNO = "53"; // subComNO = "53";
break; // break;
//} //}
} }
Integer staNo = nameTable.getStaNo(); Integer staNo = nameTable.getStaNo();

@ -114,88 +114,89 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
String domain1 = downloadNotify.getDOMAIN1(); String domain1 = downloadNotify.getDOMAIN1();
String md5 = downloadNotify.getDOMAIN2().trim(); String md5 = downloadNotify.getDOMAIN2().trim();
//先查询sqlite库中是否存在已下载的文件 //先查询sqlite库中是否存在已下载的文件
String sql = Constant.SELECT_BUSINESS_BY_ID + id; //String sql = Constant.SELECT_BUSINESS_BY_ID + id;
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql); //List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql);
//构建Ftp下载文件 //构建Ftp下载文件
String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH; String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH;
String fileName = domain1.substring(domain1.lastIndexOf("/") + 1); String fileName = domain1.substring(domain1.lastIndexOf("/") + 1);
String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING); String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING);
if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) { //if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) {
//log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType); //if (!FileUtil.fileExists(localPath + fileName)) {
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl"); //log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType);
boolean isDownload = false; LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl");
try { boolean isDownload = false;
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName); try {
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName);
} catch (Exception e) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName); } catch (Exception e) {
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl"); //log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage()); LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl");
} //throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
long end = System.currentTimeMillis(); }
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start); long end = System.currentTimeMillis();
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl"); //log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl");
if (isDownload) {
//校验md5 if (isDownload) {
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName); //校验md5
//log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5); String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5); //log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5, //log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5,
"FtpDownloadServiceImpl");
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5,
"FtpDownloadServiceImpl");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5, //获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
//if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
//}
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl");
}
}
} }
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
"FtpDownloadServiceImpl");
} }
//} else {
// //log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
// LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
// "FtpDownloadServiceImpl");
//}
} }
@ -239,78 +240,78 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
//FileUtil.delFile(new File(localPath+fileName)); //FileUtil.delFile(new File(localPath+fileName));
//先查询sqlite库中是否存在已下载的文件 //先查询sqlite库中是否存在已下载的文件
String sql = Constant.SELECT_BUSINESS_BY_ID + paramId + version; //String sql = Constant.SELECT_BUSINESS_BY_ID + paramId + version;
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql); //List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql);
if (businessTasks.size() == 0) { //if (!FileUtil.fileExists(localPath + fileName)) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
boolean isDownload = false; boolean isDownload = false;
try { try {
isDownload = FTPUtil.downloadFile(MDFtpIP, MDFtpUsername, MDPassword, Integer.parseInt(MDPort), ftpFilePath, localPath, fileName); isDownload = FTPUtil.downloadFile(MDFtpIP, MDFtpUsername, MDPassword, Integer.parseInt(MDPort), ftpFilePath, localPath, fileName);
} catch (Exception e) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询{}", uuid, paramName, paramId + version, fileName, e.getMessage(), e);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName, "FtpDownloadServiceImpl");
} } catch (Exception e) {
long end = System.currentTimeMillis(); //log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询{}", uuid, paramName, paramId + version, fileName, e.getMessage(), e);
if (isDownload) { LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName, "FtpDownloadServiceImpl");
//校验md5
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName); }
//log.info("[uuid:{}]-下载zip文件({}){},原MD5值为{}", uuid, paramId, fileName, md5); long end = System.currentTimeMillis();
//log.info("[uuid:{}]-下载zip文件({}){},下载的MD5值为{}", uuid, paramId, fileName, downlMd5); if (isDownload) {
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "原MD5值为" + md5, //校验md5
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName);
//log.info("[uuid:{}]-下载zip文件({}){},原MD5值为{}", uuid, paramId, fileName, md5);
//log.info("[uuid:{}]-下载zip文件({}){},下载的MD5值为{}", uuid, paramId, fileName, downlMd5);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "原MD5值为" + md5,
"FtpDownloadServiceImpl-getMdMdTask");
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "下载的MD5值为" + downlMd5,
"FtpDownloadServiceImpl-getMdMdTask");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, paramName, paramId, fileName);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验失败",
"FtpDownloadServiceImpl-getMdMdTask"); "FtpDownloadServiceImpl-getMdMdTask");
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "下载的MD5值为" + downlMd5, //throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, paramName, paramId, fileName);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验成功",
"FtpDownloadServiceImpl-getMdMdTask");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(paramId + Constant.STR_01, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(paramId + version);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(recordCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(paramId + Constant.STR_01);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(paramId));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(2);
//办理状态 0-未处理 1-已处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(paramNotify.getCREATE_TIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
//if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, paramId + version, paramId);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + paramId + version + "protocolType为" + paramId,
"FtpDownloadServiceImpl-getMdMdTask"); "FtpDownloadServiceImpl-getMdMdTask");
//}
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, paramName, paramId, fileName);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验失败",
"FtpDownloadServiceImpl-getMdMdTask");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, paramName, paramId, fileName);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验成功",
"FtpDownloadServiceImpl-getMdMdTask");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(paramId + Constant.STR_01, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(paramId + version);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(recordCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(paramId + Constant.STR_01);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(paramId));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(2);
//办理状态 0-未处理 1-已处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(paramNotify.getCREATE_TIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, paramId + version, paramId);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + paramId + version + "protocolType为" + paramId,
"FtpDownloadServiceImpl-getMdMdTask");
}
}
} }
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录,无需下载,跳过下载执行后面的处理程序,id为{}", uuid, paramId);
LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + paramId,
"FtpDownloadServiceImpl-getMdMdTask");
} }
//} else {
// //log.info("[uuid:{}]sqlite数据库中已存在下载的记录,无需下载,跳过下载执行后面的处理程序,id为{}", uuid, paramId);
// LogUtil.WriteLog_MDBlackCard("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + paramId,
// "FtpDownloadServiceImpl-getMdMdTask");
//}
} }
} }
@ -350,88 +351,89 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
String domain1 = downloadNotify.getDOMAIN1(); String domain1 = downloadNotify.getDOMAIN1();
String md5 = downloadNotify.getDOMAIN2().trim(); String md5 = downloadNotify.getDOMAIN2().trim();
//先查询sqlite库中是否存在已下载的文件 //先查询sqlite库中是否存在已下载的文件
String sql = Constant.SELECT_BUSINESS_BY_ID + id; //String sql = Constant.SELECT_BUSINESS_BY_ID + id;
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql); //List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql);
//构建Ftp下载文件 //构建Ftp下载文件
String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH; String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH;
String fileName = domain1.substring(domain1.lastIndexOf("/") + 1); String fileName = domain1.substring(domain1.lastIndexOf("/") + 1);
String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING); String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING);
if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) { //if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) {
//log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType); //if (!FileUtil.fileExists(localPath + fileName)) {
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl"); //log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType);
boolean isDownload = false; LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl");
try { boolean isDownload = false;
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName); try {
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName);
} catch (Exception e) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName); } catch (Exception e) {
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl"); //log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage()); LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl");
} //throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
long end = System.currentTimeMillis(); }
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start); long end = System.currentTimeMillis();
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl"); //log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl");
if (isDownload) {
//校验md5 if (isDownload) {
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName); //校验md5
//log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5); String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5); //log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5, //log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5,
"FtpDownloadServiceImpl");
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5,
"FtpDownloadServiceImpl");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5, //获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
//if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
//}
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl");
}
}
} }
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
"FtpDownloadServiceImpl");
} }
//} else {
// //log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
// LogUtil.WriteLog_HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
// "FtpDownloadServiceImpl");
//}
} }
@ -473,88 +475,88 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
String domain1 = downloadNotify.getDOMAIN1(); String domain1 = downloadNotify.getDOMAIN1();
String md5 = downloadNotify.getDOMAIN2().trim(); String md5 = downloadNotify.getDOMAIN2().trim();
//先查询sqlite库中是否存在已下载的文件 //先查询sqlite库中是否存在已下载的文件
String sql = Constant.SELECT_BUSINESS_BY_ID + id; //String sql = Constant.SELECT_BUSINESS_BY_ID + id;
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql); //List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql);
//构建Ftp下载文件 //构建Ftp下载文件
String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH; String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH;
String fileName = domain1.substring(domain1.lastIndexOf("/") + 1); String fileName = domain1.substring(domain1.lastIndexOf("/") + 1);
String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING); String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING);
if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) { //if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) {
//log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType); //log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl"); LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl");
boolean isDownload = false; boolean isDownload = false;
try { try {
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName); isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName);
} catch (Exception e) { } catch (Exception e) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName); //log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl"); LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage()); //throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start); //log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl"); LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl");
if (isDownload) { if (isDownload) {
//校验md5 //校验md5
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName); String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5); //log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5);
//log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5); //log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5, LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5,
"FtpDownloadServiceImpl");
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5,
"FtpDownloadServiceImpl");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5, //throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
//if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
//}
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl");
}
}
} }
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
"FtpDownloadServiceImpl");
} }
//} else {
// //log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
// LogUtil.WriteLog_241HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
// "FtpDownloadServiceImpl");
//}
} }
@ -587,88 +589,88 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
String domain1 = downloadNotify.getDOMAIN1(); String domain1 = downloadNotify.getDOMAIN1();
String md5 = downloadNotify.getDOMAIN2().trim(); String md5 = downloadNotify.getDOMAIN2().trim();
//先查询sqlite库中是否存在已下载的文件 //先查询sqlite库中是否存在已下载的文件
String sql = Constant.SELECT_BUSINESS_BY_ID + id; //String sql = Constant.SELECT_BUSINESS_BY_ID + id;
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql); //List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql);
//构建Ftp下载文件 //构建Ftp下载文件
String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH; String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH;
String fileName = domain1.substring(domain1.lastIndexOf("/") + 1); String fileName = domain1.substring(domain1.lastIndexOf("/") + 1);
String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING); String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING);
if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) { //if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) {
//log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType); //log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl"); LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl");
boolean isDownload = false; boolean isDownload = false;
try { try {
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName); isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName);
} catch (Exception e) { } catch (Exception e) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName); //log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl"); LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage()); //throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start); //log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl"); LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl");
if (isDownload) { if (isDownload) {
//校验md5 //校验md5
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName); String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5); //log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5);
//log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5); //log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5, LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5,
"FtpDownloadServiceImpl");
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5,
"FtpDownloadServiceImpl");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5, //获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
//if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
//}
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl");
}
}
} }
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
"FtpDownloadServiceImpl");
} }
//} else {
// //log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
// LogUtil.WriteLog_242HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
// "FtpDownloadServiceImpl");
//}
} }
@ -701,88 +703,88 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
String domain1 = downloadNotify.getDOMAIN1(); String domain1 = downloadNotify.getDOMAIN1();
String md5 = downloadNotify.getDOMAIN2().trim(); String md5 = downloadNotify.getDOMAIN2().trim();
//先查询sqlite库中是否存在已下载的文件 //先查询sqlite库中是否存在已下载的文件
String sql = Constant.SELECT_BUSINESS_BY_ID + id; //String sql = Constant.SELECT_BUSINESS_BY_ID + id;
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql); //List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql);
//构建Ftp下载文件 //构建Ftp下载文件
String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH; String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH;
String fileName = domain1.substring(domain1.lastIndexOf("/") + 1); String fileName = domain1.substring(domain1.lastIndexOf("/") + 1);
String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING); String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING);
if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) { //if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) {
//log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType); //log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl"); LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType, "FtpDownloadServiceImpl");
boolean isDownload = false; boolean isDownload = false;
try { try {
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName); isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName);
} catch (Exception e) { } catch (Exception e) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName); //log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl"); LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage()); //throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start); //log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl"); LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载耗时毫秒为" + (end - start), "FtpDownloadServiceImpl");
if (isDownload) { if (isDownload) {
//校验md5 //校验md5
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName); String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5); //log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5);
//log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5); //log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5, LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5,
"FtpDownloadServiceImpl");
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5,
"FtpDownloadServiceImpl");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5, //throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
//if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl"); "FtpDownloadServiceImpl");
//}
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"FtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"FtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"FtpDownloadServiceImpl");
}
}
} }
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
"FtpDownloadServiceImpl");
} }
//} else {
// //log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
// LogUtil.WriteLog_244HRZipDownloadFile("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id,
// "FtpDownloadServiceImpl");
//}
} }

@ -20,6 +20,8 @@ import java.io.File;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -83,13 +85,14 @@ public class MinFeeServiceImpl implements MinFeeService {
//如果是当前服务处理,继续下一步,否则程序定时任务不做处理,等待下次轮询 //如果是当前服务处理,继续下一步,否则程序定时任务不做处理,等待下次轮询
//log.info("[uuid:{}]验证是否当前服务程序处理事件{}", uuid, validateHR); //log.info("[uuid:{}]验证是否当前服务程序处理事件{}", uuid, validateHR);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-验证是否当前服务程序处理事件" +validateHR, "MinFeeServiceImpl"); LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-验证是否当前服务程序处理事件" +validateHR, "MinFeeServiceImpl");
if (validateHR) { //2024-10-24 主机生成黑名单,备机生成最小费额文件
if (!validateHR) {
//开始下载扫描华软最小费额下载任务 //开始下载扫描华软最小费额下载任务
minFtpDownloadService.getMinFeeHrMdTask(uuid); minFtpDownloadService.getMinFeeHrMdTask(uuid);
//开始查询sqlite任务表中华软未处理数据任务 //开始查询sqlite任务表中华软未处理数据任务
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, Constant.SELECT_BUSINESS_HANDLER_HR_MIN_FEE); List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, Constant.SELECT_BUSINESS_HANDLER_HR_MIN_FEE);
// 创建线程池
ExecutorService executor = Executors.newFixedThreadPool(2); // 可以根据实际情况调整线程池的大小
if (businessTasks.size() > 0) { if (businessTasks.size() > 0) {
//for (BusinessTasks businessTask : businessTasks) { //for (BusinessTasks businessTask : businessTasks) {
// String protocolType = businessTask.getProtocolType(); // String protocolType = businessTask.getProtocolType();
@ -116,6 +119,22 @@ public class MinFeeServiceImpl implements MinFeeService {
//} //}
//创建线程池
//ExecutorService executor = Executors.newFixedThreadPool(2); // 可以根据实际情况调整线程池的大小
int poolSize = 2; // 根据实际情况调整线程池大小
ExecutorService executor = new ThreadPoolExecutor(
poolSize,
poolSize,
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.AbortPolicy()
);
for (BusinessTasks businessTask : businessTasks) { for (BusinessTasks businessTask : businessTasks) {
final String protocolType = businessTask.getProtocolType(); final String protocolType = businessTask.getProtocolType();
final String id = businessTask.getId(); final String id = businessTask.getId();

@ -42,7 +42,6 @@ public class MinFtpDownloadServiceImpl implements MinFtpDownloadService {
private String HRPassword; private String HRPassword;
private static final String driverName = MyEnvironmentPostProcessor.driverClassName; private static final String driverName = MyEnvironmentPostProcessor.driverClassName;
/** /**
* *
@ -72,16 +71,16 @@ public class MinFtpDownloadServiceImpl implements MinFtpDownloadService {
@Override @Override
public void getMinFeeHrMdTask(String uuid) { public void getMinFeeHrMdTask(String uuid) {
//log.info("[uuid:{}]开始查询华软中介服务上的最小费额下载任务数据", uuid); //log.info("[uuid:{}]开始查询华软中介服务上的最小费额下载任务数据", uuid);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-开始查询华软中介服务上的最小费额下载任务数据" , "MinFtpDownloadServiceImpl"); LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-开始查询华软中介服务上的最小费额下载任务数据", "MinFtpDownloadServiceImpl");
//查询下载任务数据 //查询下载任务数据
List<DownloadNotify> downloadNotifys = DatabaseUtil.selectDownloadNotify(driverName, HRConnectionStringOracle, HROracleName, HROraclePass, Constant.SELECT_TF_DOWNLOAD_NOTIFY_MIN_FEE); List<DownloadNotify> downloadNotifys = DatabaseUtil.selectDownloadNotify(driverName, HRConnectionStringOracle, HROracleName, HROraclePass, Constant.SELECT_TF_DOWNLOAD_NOTIFY_MIN_FEE);
String localPath = NFSFilePath + PathUtil.downFile; String localPath = NFSFilePath + PathUtil.downFile;
FileUtil.fileCreat(localPath); FileUtil.fileCreat(localPath);
//log.info("[uuid:{}]查询华软中介服务上的最小费额下载任务数据条数为{}", uuid, downloadNotifys.size()); //log.info("[uuid:{}]查询华软中介服务上的最小费额下载任务数据条数为{}", uuid, downloadNotifys.size());
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-查询华软中介服务上的最小费额下载任务数据条数为"+downloadNotifys.size() , "MinFtpDownloadServiceImpl"); LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-查询华软中介服务上的最小费额下载任务数据条数为" + downloadNotifys.size(), "MinFtpDownloadServiceImpl");
if (downloadNotifys.size() == 0) { if (downloadNotifys.size() == 0) {
//log.info("[uuid:{}]华软中介服务上无最小费额下载任务", uuid); //log.info("[uuid:{}]华软中介服务上无最小费额下载任务", uuid);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-华软中介服务上无最小费额下载任务" , "MinFtpDownloadServiceImpl"); LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-华软中介服务上无最小费额下载任务", "MinFtpDownloadServiceImpl");
} else { } else {
for (DownloadNotify downloadNotify : downloadNotifys) { for (DownloadNotify downloadNotify : downloadNotifys) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
@ -95,84 +94,84 @@ public class MinFtpDownloadServiceImpl implements MinFtpDownloadService {
String domain1 = downloadNotify.getDOMAIN1(); String domain1 = downloadNotify.getDOMAIN1();
String md5 = downloadNotify.getDOMAIN2().trim(); String md5 = downloadNotify.getDOMAIN2().trim();
//先查询sqlite库中是否存在已下载的文件 //先查询sqlite库中是否存在已下载的文件
String sql = Constant.SELECT_BUSINESS_BY_ID + id; //String sql = Constant.SELECT_BUSINESS_BY_ID + id;
List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql); //List<BusinessTasks> businessTasks = DatabaseUtil.selectBusines(sqliteDriverName, sqliteUrl, sql);
//构建Ftp下载文件 //构建Ftp下载文件
String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH; String ftpUrl = Constant.FTP_PREFIX + HRFtpIP + Constant.STR_COLON + HRPort + Constant.STR_SLASH;
String fileName = domain1.substring(domain1.lastIndexOf("/") + 1); String fileName = domain1.substring(domain1.lastIndexOf("/") + 1);
String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING); String ftpFilePath = domain1.replace(ftpUrl, Constant.NULL_STRING).replace(fileName, Constant.NULL_STRING);
if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) { //if (businessTasks.size() == 0 || !FileUtil.fileExists(localPath + fileName)) {
//log.info("[uuid:{}]开始下载华软中介服务上的最小费额任务数据,protocolType为{}", uuid, protocolType); //log.info("[uuid:{}]开始下载华软中介服务上的最小费额任务数据,protocolType为{}", uuid, protocolType);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-开始下载华软中介服务上的最小费额任务数据,protocolType为"+protocolType , "MinFtpDownloadServiceImpl"); LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-开始下载华软中介服务上的最小费额任务数据,protocolType为" + protocolType, "MinFtpDownloadServiceImpl");
boolean isDownload = false; boolean isDownload = false;
try { try {
isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName); isDownload = FTPUtil.downloadFile(HRFtpIP, HRFtpUsername, HRPassword, Integer.parseInt(HRPort), ftpFilePath, localPath, fileName);
} catch (Exception e) { } catch (Exception e) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName); //log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为"+protocolType+"id为"+id+"业务主表表名为"+tableName , "MinFtpDownloadServiceImpl"); LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName, "MinFtpDownloadServiceImpl");
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage()); //throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start); //log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
if (isDownload) { if (isDownload) {
//校验md5 //校验md5
String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName); String downlMd5 = MD5Util.getMd5ByFilePath(localPath + fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5); //log.info("[uuid:{}]{}-下载zip文件({}){},原MD5值为{}", uuid, protocolType, id, tableName, md5);
//log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5); //log.info("[uuid:{}]{}-下载zip文件({}){},下载的MD5值为{}", uuid, protocolType, id, tableName, downlMd5);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为"+protocolType+"id为"+id+"业务主表表名为"+tableName +"原MD5值为"+md5, LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5,
"MinFtpDownloadServiceImpl");
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5,
"MinFtpDownloadServiceImpl");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败",
"MinFtpDownloadServiceImpl"); "MinFtpDownloadServiceImpl");
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为"+protocolType+"id为"+id+"业务主表表名为"+tableName +"下载的MD5值为"+downlMd5, //throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功",
"MinFtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
//if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType,
"MinFtpDownloadServiceImpl"); "MinFtpDownloadServiceImpl");
if (StringUtils.isBlank(downlMd5) || !md5.equals(downlMd5)) { //}
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为"+protocolType+"id为"+id+"业务主表表名为"+tableName +"MD5校验失败",
"MinFtpDownloadServiceImpl");
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-下载zip文件protocolType为"+protocolType+"id为"+id+"业务主表表名为"+tableName +"MD5校验成功",
"MinFtpDownloadServiceImpl");
//获取新的版本号
String newVersion = StringUtil.getNewVersion(protocolType, version);
//插入sqlite数据库任务表中
BusinessTasks bt = new BusinessTasks();
bt.setId(id);
bt.setFileName(fileName);
bt.setSize(FileUtil.formatFileSize(FileUtil.getFileSize(new File(localPath + fileName))));
bt.setRecordCount(Integer.parseInt(fileCount));
//1-已下载
bt.setDownStatus(1);
bt.setProtocolType(protocolType);
bt.setDownloadTime(DateTimeUtil.getFormateString(new Date(), Constant.YYYY_MM_DD_HH_MM_SS));
bt.setConsumTime(end - start);
bt.setVersion(version);
bt.setNewVersion(newVersion);
bt.setProStatus(StringUtil.turnProStatus(protocolType));
//中介库名称 1-华软 2-迈道
bt.setMiddleDatabase(1);
//办理状态 0-未处理 1-已处理 2-再次轮询处理
bt.setHandleStatus(0);
//增加部中心zip处理时间 yyyy-MM-dd HH:mm:ss
bt.setCreateTime(downloadNotify.getCREATETIME());
String sqliteInsert = StringUtil.sqliteInsert(bt);
if (businessTasks.size() == 0) {
DatabaseUtil.insertSqlite(sqliteDriverName, sqliteUrl, sqliteInsert);
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}protocolType为{}", uuid, id, protocolType);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为"+id+"protocolType为"+protocolType,
"MinFtpDownloadServiceImpl");
}
}
} }
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件"+fileName+"跳过下载执行后面的处理程序,id为"+id,
"MinFtpDownloadServiceImpl");
} }
//} else {
// //log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
// LogUtil.WriteLog_MinFee("[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件"+fileName+"跳过下载执行后面的处理程序,id为"+id,
// "MinFtpDownloadServiceImpl");
//}
} }

Loading…
Cancel
Save