@ -90,17 +90,17 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
@Override
@Override
public void getHrMdTask ( String uuid ) {
public void getHrMdTask ( String uuid ) {
//log.info("[uuid:{}]开始查询华软中介服务上的下载任务数据", uuid);
//log.info("[uuid:{}]开始查询华软中介服务上的下载任务数据", uuid);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-开始查询华软中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-开始查询华软中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//查询下载任务数据
//查询下载任务数据
List < DownloadNotify > downloadNotifys = DatabaseUtil . selectDownloadNotify ( driverName , HRConnectionStringOracle , HROracleName , HROraclePass , Constant . SELECT_TF_DOWNLOAD_NOTIFY_BLACK ) ;
List < DownloadNotify > downloadNotifys = DatabaseUtil . selectDownloadNotify ( driverName , HRConnectionStringOracle , HROracleName , HROraclePass , Constant . SELECT_TF_DOWNLOAD_NOTIFY_BLACK ) ;
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_HRZipDownloadFile ( "[uuid:" + uuid + "]-查询华软中介服务上的下载任务数据条数为" + downloadNotifys . size ( ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-查询华软中介服务上的下载任务数据条数为" + downloadNotifys . size ( ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( downloadNotifys . size ( ) = = 0 ) {
if ( downloadNotifys . size ( ) = = 0 ) {
//log.info("[uuid:{}]华软中介服务上无下载任务", uuid);
//log.info("[uuid:{}]华软中介服务上无下载任务", uuid);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-华软中介服务无下载任务" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-华软中介服务无下载任务" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
} else {
} else {
for ( DownloadNotify downloadNotify : downloadNotifys ) {
for ( DownloadNotify downloadNotify : downloadNotifys ) {
long start = System . currentTimeMillis ( ) ;
long start = System . currentTimeMillis ( ) ;
@ -123,40 +123,40 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
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_HRZipDownloadFile ( "[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType , "FtpDownloadServiceImpl-getHrMdTask" ) ;
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_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//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_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载耗时毫秒为" + ( end - start ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载耗时毫秒为" + ( end - start ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
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_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5 ,
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5 ,
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( StringUtils . isBlank ( downlMd5 ) | | ! md5 . equals ( downlMd5 ) ) {
if ( StringUtils . isBlank ( downlMd5 ) | | ! md5 . equals ( downlMd5 ) ) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败" ,
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败" ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功" ,
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功" ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
//获取新的版本号
//获取新的版本号
String newVersion = StringUtil . getNewVersion ( protocolType , version ) ;
String newVersion = StringUtil . getNewVersion ( protocolType , version ) ;
@ -183,7 +183,7 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
if ( businessTasks . size ( ) = = 0 ) {
if ( businessTasks . size ( ) = = 0 ) {
DatabaseUtil . insertSqlite ( sqliteDriverName , sqliteUrl , sqliteInsert ) ;
DatabaseUtil . insertSqlite ( sqliteDriverName , sqliteUrl , sqliteInsert ) ;
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}, protocolType为{}", uuid, id, protocolType);
//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 ,
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
}
}
@ -192,7 +192,7 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
}
}
} else {
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id ,
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
}
}
@ -213,19 +213,19 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
@Override
@Override
public void getMdMdTask ( String uuid ) {
public void getMdMdTask ( String uuid ) {
//log.info("[uuid:{}]开始查询迈道中介服务上的下载任务数据", uuid);
//log.info("[uuid:{}]开始查询迈道中介服务上的下载任务数据", uuid);
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-开始查询迈道中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-开始查询迈道中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//查询下载任务数据
//查询下载任务数据
List < ParamNotify > paramNotifyList = DatabaseUtil . selectParamNotify ( driverName , MDConnectionStringOracle , MDOracleName , MDOraclePass , Constant . SELECT_T_PARAM_NOTIFY ) ;
List < ParamNotify > paramNotifyList = DatabaseUtil . selectParamNotify ( driverName , MDConnectionStringOracle , MDOracleName , MDOraclePass , Constant . SELECT_T_PARAM_NOTIFY ) ;
String localPath = NFSFilePath + PathUtil . downFile ;
String localPath = NFSFilePath + PathUtil . downFile ;
FileUtil . fileCreat ( localPath ) ;
FileUtil . fileCreat ( localPath ) ;
//log.info("[uuid:{}]查询迈道中介服务上的下载任务数据条数为{}", uuid, paramNotifyList.size());
//log.info("[uuid:{}]查询迈道中介服务上的下载任务数据条数为{}", uuid, paramNotifyList.size());
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-查询迈道中介服务上的下载任务数据条数为" + paramNotifyList . size ( ) , "FtpDownloadServiceImpl-getMdMdTask" ) ;
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-查询迈道中介服务上的下载任务数据条数为" + paramNotifyList . size ( ) , "FtpDownloadServiceImpl-getMdMdTask" ) ;
if ( paramNotifyList . size ( ) = = 0 ) {
if ( paramNotifyList . size ( ) = = 0 ) {
//log.info("[uuid:{}]迈道中介服务上JSON无下载任务", uuid);
//log.info("[uuid:{}]迈道中介服务上JSON无下载任务", uuid);
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-迈道中介服务无下载任务" , "FtpDownloadServiceImpl-getMdMdTask" ) ;
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-迈道中介服务无下载任务" , "FtpDownloadServiceImpl-getMdMdTask" ) ;
} else {
} else {
for ( ParamNotify paramNotify : paramNotifyList ) {
for ( ParamNotify paramNotify : paramNotifyList ) {
String paramId = paramNotify . getPARAM_ID ( ) ;
String paramId = paramNotify . getPARAM_ID ( ) ;
String paramPath = paramNotify . getPARAM_PATH ( ) ;
String paramPath = paramNotify . getPARAM_PATH ( ) ;
@ -248,7 +248,7 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
} catch ( Exception e ) {
} catch ( Exception e ) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询{}", uuid, paramName, paramId + version, fileName, e.getMessage(), 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-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName , "FtpDownloadServiceImpl-getHrMdTask" ) ;
}
}
long end = System . currentTimeMillis ( ) ;
long end = System . currentTimeMillis ( ) ;
@ -257,20 +257,20 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
String downlMd5 = MD5Util . getMd5ByFilePath ( localPath + fileName ) ;
String downlMd5 = MD5Util . getMd5ByFilePath ( localPath + fileName ) ;
//log.info("[uuid:{}]-下载zip文件({}){},原MD5值为: {}", uuid, paramId, fileName, md5);
//log.info("[uuid:{}]-下载zip文件({}){},原MD5值为: {}", uuid, paramId, fileName, md5);
//log.info("[uuid:{}]-下载zip文件({}){},下载的MD5值为: {}", uuid, paramId, fileName, downlMd5);
//log.info("[uuid:{}]-下载zip文件({}){},下载的MD5值为: {}", uuid, paramId, fileName, downlMd5);
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "原MD5值为" + md5 ,
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "原MD5值为" + md5 ,
"FtpDownloadServiceImpl-getMdMdTask" ) ;
"FtpDownloadServiceImpl-getMdMdTask" ) ;
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "下载的MD5值为" + downlMd5 ,
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "下载的MD5值为" + downlMd5 ,
"FtpDownloadServiceImpl-getMdMdTask" ) ;
"FtpDownloadServiceImpl-getMdMdTask" ) ;
if ( StringUtils . isBlank ( downlMd5 ) | | ! md5 . equals ( downlMd5 ) ) {
if ( StringUtils . isBlank ( downlMd5 ) | | ! md5 . equals ( downlMd5 ) ) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, paramName, paramId, fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, paramName, paramId, fileName);
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验失败" ,
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验失败" ,
"FtpDownloadServiceImpl-getMdMdTask" ) ;
"FtpDownloadServiceImpl-getMdMdTask" ) ;
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, paramName, paramId, fileName);
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, paramName, paramId, fileName);
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验成功" ,
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-下载zip文件paramName为" + paramName + "paramId为" + paramId + "fileName" + fileName + "MD5校验成功" ,
"FtpDownloadServiceImpl-getMdMdTask" ) ;
"FtpDownloadServiceImpl-getMdMdTask" ) ;
//获取新的版本号
//获取新的版本号
String newVersion = StringUtil . getNewVersion ( paramId + Constant . STR_01 , version ) ;
String newVersion = StringUtil . getNewVersion ( paramId + Constant . STR_01 , version ) ;
@ -297,7 +297,7 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
if ( businessTasks . size ( ) = = 0 ) {
if ( businessTasks . size ( ) = = 0 ) {
DatabaseUtil . insertSqlite ( sqliteDriverName , sqliteUrl , sqliteInsert ) ;
DatabaseUtil . insertSqlite ( sqliteDriverName , sqliteUrl , sqliteInsert ) ;
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}, protocolType为{}", uuid, paramId + version, paramId);
//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 ,
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + paramId + version + "protocolType为" + paramId ,
"FtpDownloadServiceImpl-getMdMdTask" ) ;
"FtpDownloadServiceImpl-getMdMdTask" ) ;
}
}
@ -305,7 +305,7 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
}
}
} else {
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录,无需下载,跳过下载执行后面的处理程序,id为{}", uuid, paramId);
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录,无需下载,跳过下载执行后面的处理程序,id为{}", uuid, paramId);
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + paramId ,
LogUtil . WriteLog_MDBlackCard ( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + paramId ,
"FtpDownloadServiceImpl-getMdMdTask" ) ;
"FtpDownloadServiceImpl-getMdMdTask" ) ;
}
}
@ -323,17 +323,139 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
@Override
@Override
public void getHrInsertDBTask ( String uuid ) {
public void getHrInsertDBTask ( String uuid ) {
//log.info("[uuid:{}]开始查询华软中介服务上的下载任务数据", uuid);
//log.info("[uuid:{}]开始查询华软中介服务上的下载任务数据", uuid);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-开始查询华软中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-开始查询华软中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//查询下载任务数据
//查询下载任务数据
List < DownloadNotify > downloadNotifys = DatabaseUtil . selectDownloadNotify ( driverName , HRConnectionStringOracle , HROracleName , HROraclePass , Constant . SELECT_TF_DOWNLOAD_NOTIFY_INSERT_DB ) ;
List < DownloadNotify > downloadNotifys = DatabaseUtil . selectDownloadNotify ( driverName , HRConnectionStringOracle , HROracleName , HROraclePass , Constant . SELECT_TF_DOWNLOAD_NOTIFY_INSERT_DB ) ;
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_HRZipDownloadFile ( "[uuid:" + uuid + "]-查询华软中介服务上的下载任务数据条数为" + downloadNotifys . size ( ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-查询华软中介服务上的下载任务数据条数为" + downloadNotifys . size ( ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( downloadNotifys . size ( ) = = 0 ) {
//log.info("[uuid:{}]华软中介服务上无下载任务", uuid);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-华软中介服务无下载任务" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
} else {
for ( DownloadNotify downloadNotify : downloadNotifys ) {
long start = System . currentTimeMillis ( ) ;
String id = downloadNotify . getID ( ) ;
String tableName = downloadNotify . getTABLENAME ( ) ;
String version = downloadNotify . getVERSION ( ) ;
String protocolType = downloadNotify . getPROTOCOLTYPE ( ) ;
//Json文件记录数
String fileCount = downloadNotify . getRECORDNUM ( ) ;
//如果时黑名单 就是文件下载地址
String domain1 = downloadNotify . getDOMAIN1 ( ) ;
String md5 = downloadNotify . getDOMAIN2 ( ) . trim ( ) ;
//先查询sqlite库中是否存在已下载的文件
String sql = Constant . SELECT_BUSINESS_BY_ID + id ;
List < BusinessTasks > businessTasks = DatabaseUtil . selectBusines ( sqliteDriverName , sqliteUrl , sql ) ;
//构建Ftp下载文件
String ftpUrl = Constant . FTP_PREFIX + HRFtpIP + Constant . STR_COLON + HRPort + Constant . STR_SLASH ;
String fileName = domain1 . substring ( domain1 . lastIndexOf ( "/" ) + 1 ) ;
String ftpFilePath = domain1 . replace ( ftpUrl , Constant . NULL_STRING ) . replace ( fileName , Constant . NULL_STRING ) ;
if ( businessTasks . size ( ) = = 0 | | ! FileUtil . fileExists ( localPath + fileName ) ) {
//log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType , "FtpDownloadServiceImpl-getHrMdTask" ) ;
boolean isDownload = false ;
try {
isDownload = FTPUtil . downloadFile ( HRFtpIP , HRFtpUsername , HRPassword , Integer . parseInt ( HRPort ) , ftpFilePath , localPath , fileName ) ;
} catch ( Exception e ) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
}
long end = System . currentTimeMillis ( ) ;
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载耗时毫秒为" + ( end - start ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( isDownload ) {
//校验md5
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, downlMd5);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
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-getHrMdTask" ) ;
//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-getHrMdTask" ) ;
//获取新的版本号
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 ) ;
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-getHrMdTask" ) ;
}
}
}
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
}
}
}
}
/ * *
* 查 询 华 软 241 入 库 文 件 下 载 任 务
*
* @param uuid uuid
* @author shuguang
* @date 2024 - 06 - 17 10 : 03
* /
@Override
public void getHr241InsertDBTask ( String uuid ) {
//log.info("[uuid:{}]开始查询华软中介服务上的下载任务数据", uuid);
LogUtil . WriteLog_241HRZipDownloadFile ( "[uuid:" + uuid + "]-开始查询华软中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//查询下载任务数据
List < DownloadNotify > downloadNotifys = DatabaseUtil . selectDownloadNotify ( driverName , HRConnectionStringOracle , HROracleName , HROraclePass , Constant . SELECT_TF_DOWNLOAD_NOTIFY_INSERT_DB_241 ) ;
String localPath = NFSFilePath + PathUtil . downFile ;
FileUtil . fileCreat ( localPath ) ;
//log.info("[uuid:{}]查询华软中介服务上的下载任务数据条数为{}", uuid, downloadNotifys.size());
LogUtil . WriteLog_241HRZipDownloadFile ( "[uuid:" + uuid + "]-查询华软中介服务上的下载任务数据条数为" + downloadNotifys . size ( ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( downloadNotifys . size ( ) = = 0 ) {
if ( downloadNotifys . size ( ) = = 0 ) {
//log.info("[uuid:{}]华软中介服务上无下载任务", uuid);
//log.info("[uuid:{}]华软中介服务上无下载任务", uuid);
LogUtil . WriteLog_HRZipDownloadFile ( "[uuid:" + uuid + "]-华软中介服务无下载任务" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-华软中介服务无下载任务" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
} else {
} else {
for ( DownloadNotify downloadNotify : downloadNotifys ) {
for ( DownloadNotify downloadNotify : downloadNotifys ) {
long start = System . currentTimeMillis ( ) ;
long start = System . currentTimeMillis ( ) ;
@ -356,40 +478,40 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
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_ HRZipDownloadFile( "[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType , "FtpDownloadServiceImpl-getHrMdTask" ) ;
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_ HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//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_ HRZipDownloadFile( "[uuid:" + uuid + "]-下载耗时毫秒为" + ( end - start ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-下载耗时毫秒为" + ( end - start ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
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_ HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5 ,
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_ HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5 ,
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( StringUtils . isBlank ( downlMd5 ) | | ! md5 . equals ( downlMd5 ) ) {
if ( StringUtils . isBlank ( downlMd5 ) | | ! md5 . equals ( downlMd5 ) ) {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验失败", uuid, protocolType, id, tableName);
LogUtil . WriteLog_ HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败" ,
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验失败" ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
//throw new PPException(MessageEnum.MD5校验失败.getCode(), MessageEnum.MD5校验失败.getMessage());
} else {
} else {
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
//log.info("[uuid:{}]{}-下载zip文件({}){},MD5校验成功", uuid, protocolType, id, tableName);
LogUtil . WriteLog_ HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功" ,
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "MD5校验成功" ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
//获取新的版本号
//获取新的版本号
String newVersion = StringUtil . getNewVersion ( protocolType , version ) ;
String newVersion = StringUtil . getNewVersion ( protocolType , version ) ;
@ -416,7 +538,7 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
if ( businessTasks . size ( ) = = 0 ) {
if ( businessTasks . size ( ) = = 0 ) {
DatabaseUtil . insertSqlite ( sqliteDriverName , sqliteUrl , sqliteInsert ) ;
DatabaseUtil . insertSqlite ( sqliteDriverName , sqliteUrl , sqliteInsert ) ;
//log.info("[uuid:{}]插入sqlite数据库business_tasks_info表中任务数据,id为{}, protocolType为{}", uuid, id, protocolType);
//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 ,
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-插入sqlite数据库business_tasks_info表中任务数据,id为" + id + "protocolType为" + protocolType ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
}
}
@ -425,13 +547,125 @@ public class FtpDownloadServiceImpl implements FtpDownloadService {
}
}
} else {
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil . WriteLog_ HRZipDownloadFile( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id ,
LogUtil . WriteLog_ 241 HRZipDownloadFile( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
"FtpDownloadServiceImpl-getHrMdTask" ) ;
}
}
}
}
}
}
}
@Override
public void getHr242InsertDBTask ( String uuid ) {
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-开始查询华软中介服务上的下载任务数据" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//查询下载任务数据
List < DownloadNotify > downloadNotifys = DatabaseUtil . selectDownloadNotify ( driverName , HRConnectionStringOracle , HROracleName , HROraclePass , Constant . SELECT_TF_DOWNLOAD_NOTIFY_INSERT_DB_242 ) ;
String localPath = NFSFilePath + PathUtil . downFile ;
FileUtil . fileCreat ( localPath ) ;
//log.info("[uuid:{}]查询华软中介服务上的下载任务数据条数为{}", uuid, downloadNotifys.size());
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-查询华软中介服务上的下载任务数据条数为" + downloadNotifys . size ( ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( downloadNotifys . size ( ) = = 0 ) {
//log.info("[uuid:{}]华软中介服务上无下载任务", uuid);
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-华软中介服务无下载任务" , "FtpDownloadServiceImpl-getHrMdTask" ) ;
} else {
for ( DownloadNotify downloadNotify : downloadNotifys ) {
long start = System . currentTimeMillis ( ) ;
String id = downloadNotify . getID ( ) ;
String tableName = downloadNotify . getTABLENAME ( ) ;
String version = downloadNotify . getVERSION ( ) ;
String protocolType = downloadNotify . getPROTOCOLTYPE ( ) ;
//Json文件记录数
String fileCount = downloadNotify . getRECORDNUM ( ) ;
//如果时黑名单 就是文件下载地址
String domain1 = downloadNotify . getDOMAIN1 ( ) ;
String md5 = downloadNotify . getDOMAIN2 ( ) . trim ( ) ;
//先查询sqlite库中是否存在已下载的文件
String sql = Constant . SELECT_BUSINESS_BY_ID + id ;
List < BusinessTasks > businessTasks = DatabaseUtil . selectBusines ( sqliteDriverName , sqliteUrl , sql ) ;
//构建Ftp下载文件
String ftpUrl = Constant . FTP_PREFIX + HRFtpIP + Constant . STR_COLON + HRPort + Constant . STR_SLASH ;
String fileName = domain1 . substring ( domain1 . lastIndexOf ( "/" ) + 1 ) ;
String ftpFilePath = domain1 . replace ( ftpUrl , Constant . NULL_STRING ) . replace ( fileName , Constant . NULL_STRING ) ;
if ( businessTasks . size ( ) = = 0 | | ! FileUtil . fileExists ( localPath + fileName ) ) {
//log.info("[uuid:{}]开始下载华软中介服务上的任务数据,protocolType为{}", uuid, protocolType);
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-开始下载华软中介服务上的任务数据,protocolType为" + protocolType , "FtpDownloadServiceImpl-getHrMdTask" ) ;
boolean isDownload = false ;
try {
isDownload = FTPUtil . downloadFile ( HRFtpIP , HRFtpUsername , HRPassword , Integer . parseInt ( HRPort ) , ftpFilePath , localPath , fileName ) ;
} catch ( Exception e ) {
//log.error("[uuid:{}]{}-下载zip文件({}){}失败,等待下次轮询", uuid, protocolType, id, tableName);
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName , "FtpDownloadServiceImpl-getHrMdTask" ) ;
//throw new PPException(MessageEnum.FTP文件下载失败.getCode(), MessageEnum.FTP文件下载失败.getMessage());
}
long end = System . currentTimeMillis ( ) ;
//log.info("[uuid:{}]下载耗时:{}毫秒", uuid, end - start);
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-下载耗时毫秒为" + ( end - start ) , "FtpDownloadServiceImpl-getHrMdTask" ) ;
if ( isDownload ) {
//校验md5
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, downlMd5);
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "原MD5值为" + md5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-下载zip文件protocolType为" + protocolType + "id为" + id + "业务主表表名为" + tableName + "下载的MD5值为" + downlMd5 ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
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-getHrMdTask" ) ;
//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-getHrMdTask" ) ;
//获取新的版本号
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 ) ;
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-getHrMdTask" ) ;
}
}
}
} else {
//log.info("[uuid:{}]sqlite数据库中已存在下载的记录同时下载路径下存在该文件{},跳过下载执行后面的处理程序,id为{}", uuid, fileName, id);
LogUtil . WriteLog_242HRZipDownloadFile ( "[uuid:" + uuid + "]-sqlite数据库中已存在下载的记录同时下载路径下存在该文件" + fileName + "跳过下载执行后面的处理程序,id为" + id ,
"FtpDownloadServiceImpl-getHrMdTask" ) ;
}
}
}
}
}
}
}