@ -87,6 +87,7 @@ public class IdcServiceImpl implements IdcService {
private ScheduledDao scheduledDao ;
private String imagePath = FileConstant . COMMON_FILE_PATH ;
/*获取拉取任务列表*/
@Override
public BaseResponse taskList ( HttpServletRequest request , Map < String , Object > params ) {
@ -206,11 +207,11 @@ public class IdcServiceImpl implements IdcService {
private void fetchFailFile ( String host ) {
Map < String , Object > map = new HashMap < String , Object > ( ) ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
map . put ( "sql" , "select * from idc_file where createTime<date_sub(now(),interval 30 minute) order by createTime" ) ;
List < Map < String , Object > > list = dbDao . list ( map ) ;
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
signleDownloadFile ( host , list . get ( i ) . get ( "filePath" ) . toString ( ) ) ;
List < Map < String , Object > > list = dbDao . list ( map ) ;
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
signleDownloadFile ( host , list . get ( i ) . get ( "filePath" ) . toString ( ) ) ;
}
}
@ -230,7 +231,7 @@ public class IdcServiceImpl implements IdcService {
String [ ] syncTables = TableUtils . syncTables ( ) ;
for ( int i = 0 ; i < syncTables . length ; i + + ) {
String [ ] tnames = syncTables [ i ] . split ( "/" ) ;
boolean sync = ( StringUtils . isEmpty ( tnames [ 0 ] ) & & StringUtils . isEmpty ( tnames [ 1 ] ) ) | |
boolean sync = ( StringUtils . isEmpty ( tnames [ 0 ] ) & & StringUtils . isEmpty ( tnames [ 1 ] ) ) | |
( ! StringUtils . isEmpty ( tnames [ 0 ] ) & & map ! = null & & map . get ( tnames [ 0 ] ) ! = null & & map . get ( tnames [ 0 ] ) . toString ( ) . equals ( "1" ) ) ;
saveIdcLog ( "---" , "" , map . get ( tnames [ 0 ] ) + syncTables [ i ] , 0 , 0 ) ;
if ( sync ) {
@ -245,21 +246,20 @@ public class IdcServiceImpl implements IdcService {
/*上传失败重新上传*/
private void asyncFailTask ( String host ) {
try
{
try {
String filePathSlash = filePath . substring ( filePath . length ( ) - 1 ) . equals ( "/" ) ? "" : "/" ;
String sql = "select * from basic_export_status where status='1' and receiveStatus='0' where updateTime<date_sub(now(),interval 6 minute) order by updateTime" ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
map . put ( "sql" , sql ) ;
List < Map < String , Object > > list = dbDao . list ( map ) ;
List < Map < String , Object > > list = dbDao . list ( map ) ;
ArrayList < String > files = new ArrayList < > ( ) ;
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
String json = FileUtils . readFileAll ( list . get ( i ) . get ( "cacheFilePath" ) . toString ( ) ) ;
JSONObject object = JSONObject . parseObject ( json ) ;
List < Map > dataList = JSONObject . parseArray ( JSON . toJSONString ( object . get ( "data" ) ) , Map . class ) ;
for ( int m = 0 ; m < dataList . size ( ) ; m + + ) {
if ( object . get ( "filePathColumn" ) ! = null & & ! StringUtils . isEmpty ( object . get ( "filePathColumn" ) . toString ( ) ) & &
dataList . get ( m ) . get ( object . get ( "filePathColumn" ) . toString ( ) ) ! = null ) {
if ( object . get ( "filePathColumn" ) ! = null & & ! StringUtils . isEmpty ( object . get ( "filePathColumn" ) . toString ( ) ) & &
dataList . get ( m ) . get ( object . get ( "filePathColumn" ) . toString ( ) ) ! = null ) {
String fileNames = dataList . get ( m ) . get ( object . get ( "filePathColumn" ) . toString ( ) ) . toString ( ) ;
String [ ] str = fileNames . split ( "," ) ;
for ( int r = 0 ; r < str . length ; r + + ) {
@ -267,14 +267,14 @@ public class IdcServiceImpl implements IdcService {
files . add ( filePath + filePathSlash + imagePath + str [ r ] ) ;
}
}
for ( int k = 0 ; k < 30 ; k + + ) {
if ( dataList . get ( k ) . get ( "tableName" + k ) = = null )
for ( int k = 0 ; k < 30 ; k + + ) {
if ( dataList . get ( k ) . get ( "tableName" + k ) = = null )
break ;
if ( dataList . get ( k ) . get ( "data" + k ) ! = null & & dataList . get ( k ) . get ( "filePathColumn" + k ) ! = null ) {
List < Map > childList = JSONObject . parseArray ( JSON . toJSONString ( dataList . get ( i ) . get ( "data" + k ) ) , Map . class ) ;
for ( int x = 0 ; x < childList . size ( ) ; x + + ) {
if ( childList . get ( x ) . get ( dataList . get ( k ) . get ( "filePathColumn" + k ) . toString ( ) ) ! = null ) {
String [ ] str = childList . get ( x ) . get ( dataList . get ( k ) . get ( "filePathColumn" + k ) . toString ( ) ) . toString ( ) . split ( "," ) ;
if ( dataList . get ( k ) . get ( "data" + k ) ! = null & & dataList . get ( k ) . get ( "filePathColumn" + k ) ! = null ) {
List < Map > childList = JSONObject . parseArray ( JSON . toJSONString ( dataList . get ( i ) . get ( "data" + k ) ) , Map . class ) ;
for ( int x = 0 ; x < childList . size ( ) ; x + + ) {
if ( childList . get ( x ) . get ( dataList . get ( k ) . get ( "filePathColumn" + k ) . toString ( ) ) ! = null ) {
String [ ] str = childList . get ( x ) . get ( dataList . get ( k ) . get ( "filePathColumn" + k ) . toString ( ) ) . toString ( ) . split ( "," ) ;
for ( int s = 0 ; s < str . length ; s + + ) {
if ( ! StringUtils . isEmpty ( str [ s ] ) & & FileUtils . isFileExist ( filePath + filePathSlash + imagePath + str [ s ] ) )
files . add ( filePath + filePathSlash + imagePath + str [ s ] ) ;
@ -293,7 +293,7 @@ public class IdcServiceImpl implements IdcService {
if ( IDCUtils . isJson ( result ) ) {
JSONObject res = JSON . parseObject ( result ) ;
if ( res . getInteger ( "code" ) = = 20000 ) {
executeSql ( "update basic_export_status set receiveStatus='1',endTime=now() where id='" + list . get ( i ) . get ( "id" ) + "'" ) ;
executeSql ( "update basic_export_status set receiveStatus='1',endTime=now() where id='" + list . get ( i ) . get ( "id" ) + "'" ) ;
saveIdcLog ( object . getString ( "messageType" ) , list . get ( i ) . get ( "id" ) . toString ( ) , object . getString ( "tableName" ) + ">reUpload->success" , 0 , 0 ) ;
} else {
saveIdcLog ( object . getString ( "messageType" ) , list . get ( i ) . get ( "id" ) . toString ( ) , object . getString ( "tableName" ) + ">reUpload->fail" , 0 , 0 ) ;
@ -308,42 +308,42 @@ public class IdcServiceImpl implements IdcService {
}
/*数据删除同步*/
private void asyncDelete ( String tname , boolean isUpload , String syncIp ) {
private void asyncDelete ( String tname , boolean isUpload , String syncIp ) {
String [ ] tnames = tname . split ( "/" ) ;
String lastUpdateTime = getUpdateTime ( tnames [ 2 ] + "." + tnames [ 0 ] + "." + tnames [ 1 ] + ".delete" ) ;
String lastUpdateTime = getUpdateTime ( tnames [ 2 ] + "." + tnames [ 0 ] + "." + tnames [ 1 ] + ".delete" ) ;
Date nowUpdateTime = new Date ( ) ;
String where = "tableName='" + tnames [ 2 ] . toLowerCase ( ) + "' and updateTime between cast('" + lastUpdateTime + "' as datetime) " +
" and cast('" + DateUtil . formatDate ( nowUpdateTime , "yyyy-MM-dd HH:mm:ss" ) + "' as datetime)" ;
Map < String , Object > count = new HashMap < String , Object > ( ) ;
count . put ( "sql" , "select count(*) from idc_delete where " + where ) ;
String where = "tableName='" + tnames [ 2 ] . toLowerCase ( ) + "' and updateTime between cast('" + lastUpdateTime + "' as datetime) " +
" and cast('" + DateUtil . formatDate ( nowUpdateTime , "yyyy-MM-dd HH:mm:ss" ) + "' as datetime)" ;
Map < String , Object > count = new HashMap < String , Object > ( ) ;
count . put ( "sql" , "select count(*) from idc_delete where " + where ) ;
int total = dbDao . count ( count ) ;
int limit = 50 ;
if ( total > 0 ) {
boolean success = true ;
for ( int i = 0 ; i < Math . ceil ( total / limit ) + 1 ; i + + ) {
Date startTime = new Date ( ) ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
map . put ( "sql" , "select * from idc_delete" ) ;
map . put ( "sqlWhere" , where ) ;
map . put ( "limit" , limit ) ;
map . put ( "page" , i * limit ) ;
List < Map < String , Object > > list = dbDao . list ( map ) ;
if ( list ! = null & & map . size ( ) > 0 ) {
List < Map < String , Object > > data = new ArrayList < > ( ) ;
for ( int k = 0 ; i < list . size ( ) ; k + + ) {
List < Map < String , Object > > list = dbDao . list ( map ) ;
if ( list ! = null & & map . size ( ) > 0 ) {
List < Map < String , Object > > data = new ArrayList < > ( ) ;
for ( int k = 0 ; i < list . size ( ) ; k + + ) {
String line = list . get ( k ) . get ( "uniqueValue" ) . toString ( ) ;
JSONObject obj = JSON . parseObject ( line ) ;
String uniqueColumn = "" ;
for ( String key : obj . keySet ( ) ) {
uniqueColumn + = uniqueColumn . length ( ) > 0 ? "," + key : key ;
for ( String key : obj . keySet ( ) ) {
uniqueColumn + = uniqueColumn . length ( ) > 0 ? "," + key : key ;
}
obj . put ( "uniqueColumn" , uniqueColumn ) ;
obj . put ( "operateMode" , "D" ) ;
data . add ( obj ) ;
}
Map < String , Object > msg = new HashMap < String , Object > ( ) ;
Map < String , Object > msg = new HashMap < String , Object > ( ) ;
msg . put ( "messageId" , CustomUtil . getId ( ) ) ;
msg . put ( "messageType" , tnames [ 9 ] + "(删除)" ) ;
msg . put ( "messageType" , tnames [ 9 ] + "(删除)" ) ;
msg . put ( "apiCode" , "common" ) ;
msg . put ( "tableName" , DBAUtils . tableAliasName ( tnames [ 2 ] ) ) ;
msg . put ( "sendTime" , new Date ( ) ) ;
@ -374,7 +374,7 @@ public class IdcServiceImpl implements IdcService {
} else {
saveIdcLog ( tnames [ 9 ] , "" , tnames [ 2 ] + ">success(delete)" , i * limit , total ) ;
}
syncAddTaskStatus ( msg , isUpload ? 1 : 0 , true , startTime , isUpload , success ) ;
syncAddTaskStatus ( msg , isUpload ? 1 : 0 , true , startTime , isUpload , success ) ;
}
}
}
@ -409,7 +409,7 @@ public class IdcServiceImpl implements IdcService {
try {
String [ ] tnames = t . split ( "/" ) ;
String lastUpdateTime = getUpdateTime ( tnames [ 2 ] + "." + tnames [ 0 ] + "." + tnames [ 1 ] ) ;
String lastUpdateTime = getUpdateTime ( tnames [ 2 ] + "." + tnames [ 0 ] + "." + tnames [ 1 ] ) ;
Date nowUpdateTime = new Date ( ) ;
// if (!StringUtils.isEmpty(tnames[0])) {
@ -425,7 +425,7 @@ public class IdcServiceImpl implements IdcService {
if ( ! StringUtils . isEmpty ( updateTimeColumn ) ) {
sqlWhere + = " " + updateTimeColumn + " between cast('" + lastUpdateTime + "' as datetime) and cast('" + DateUtil . formatDate ( nowUpdateTime , "yyyy-MM-dd HH:mm:ss" ) + "' as datetime)" ;
sqlWhere + = " " + updateTimeColumn + " between cast('" + lastUpdateTime + "' as datetime) and cast('" + DateUtil . formatDate ( nowUpdateTime , "yyyy-MM-dd HH:mm:ss" ) + "' as datetime)" ;
//sqlWhere += " and not exists (select fkId from idc_record where type='" + tnames[2] + "' and fkId=" + tnames[2] + "." + keyColumn + " and createTime>date_sub(now(),interval 15 MINUTE))";
} else {
sqlWhere = "not exists (select fkId from idc_record where type='" + tnames [ 2 ] + "' and fkId=" + tnames [ 2 ] + "." + keyColumn + ")" ;
@ -455,7 +455,7 @@ public class IdcServiceImpl implements IdcService {
if ( sync ) {
result = syncMasterData ( map , isUpload , syncIp ) ;
if ( result ) {
setUpdateTime ( tnames [ 2 ] + "." + tnames [ 0 ] + "." + tnames [ 1 ] , DateUtil . formatDate ( nowUpdateTime , "yyyy-MM-dd HH:mm:ss" ) ) ;
setUpdateTime ( tnames [ 2 ] + "." + tnames [ 0 ] + "." + tnames [ 1 ] , DateUtil . formatDate ( nowUpdateTime , "yyyy-MM-dd HH:mm:ss" ) ) ;
}
}
//}
@ -493,11 +493,11 @@ public class IdcServiceImpl implements IdcService {
} else {
success = false ;
}
syncAddTaskStatus ( json . getJSONObject ( "data" ) , 3 , true , startTime , true , success ) ;
syncAddTaskStatus ( json . getJSONObject ( "data" ) , 3 , true , startTime , true , success ) ;
} else {
if ( json . get ( "code" ) ! = null & & json . get ( "data" ) ! = null ) {
//logger.info("res1-->"+JSON.toJSONString(json));
syncAddTaskStatus ( json . getJSONObject ( "data" ) , 0 , true , startTime , true , success ) ;
syncAddTaskStatus ( json . getJSONObject ( "data" ) , 0 , true , startTime , true , success ) ;
analyMiddle ( host , json . getJSONObject ( "data" ) , files , false , false ) ;
}
}
@ -553,7 +553,7 @@ public class IdcServiceImpl implements IdcService {
IDCUtils . createDirectory ( filePath + filePathSlash + datePath + "/" ) ;
if ( ! FileUtils . makeDirectory ( backFilePath + backFileSlash + datePath ) )
IDCUtils . createDirectory ( filePath + backFileSlash + datePath + "/" ) ;
if ( ! FileUtils . makeDirectory ( filePath + filePathSlash + imagePath ) )
if ( ! FileUtils . makeDirectory ( filePath + filePathSlash + imagePath ) )
IDCUtils . createDirectory ( filePath + filePathSlash + imagePath ) ;
FileUtils . SaveFileAs ( content , fileName ) ;
FileUtils . SaveFileAs ( content , backFileName ) ;
@ -585,7 +585,7 @@ public class IdcServiceImpl implements IdcService {
boolean success = false ;
if ( isLastLevel ( ) ) {
success = analyMiddle ( "" , json , files , true , true ) ;
syncAddTaskStatus ( json , 3 , true , startTime , true , success ) ;
syncAddTaskStatus ( json , 3 , true , startTime , true , success ) ;
if ( ! success ) {
return ResultVOUtils . error ( 9000 , "解析失败" ) ;
@ -596,11 +596,11 @@ public class IdcServiceImpl implements IdcService {
String host = getNextHost ( ) ;
String result = relay ( request . getHeader ( "reqNo" ) , content , saveFiles , host ) ;
if ( IDCUtils . isJson ( result ) ) {
syncAddTaskStatus ( json , 2 , true , startTime , true , true ) ;
syncAddTaskStatus ( json , 2 , true , startTime , true , true ) ;
BaseResponse object = JSON . parseObject ( result , BaseResponse . class ) ;
return object ;
} else {
syncAddTaskStatus ( json , 2 , true , startTime , false , false ) ;
syncAddTaskStatus ( json , 2 , true , startTime , false , false ) ;
return ResultVOUtils . error ( 9000 , "转发失败" ) ;
}
@ -630,7 +630,7 @@ public class IdcServiceImpl implements IdcService {
public void downloadFile ( String fileName , HttpServletResponse response ) {
OutputStream os ;
String filePathSlash = filePath . substring ( filePath . length ( ) - 1 ) . equals ( "/" ) ? "" : fileName . substring ( 0 , 1 ) . equals ( "/" ) ? "" : "/" ;
String sourceFileName = filePath + filePathSlash + imagePath + fileName ;
String sourceFileName = filePath + filePathSlash + imagePath + fileName ;
try {
if ( FileUtils . isFileExist ( sourceFileName ) ) {
byte [ ] bytes = FileUtils . readFileByBytes ( sourceFileName ) ;
@ -639,7 +639,7 @@ public class IdcServiceImpl implements IdcService {
os . flush ( ) ;
os . close ( ) ;
} else {
logger . error ( "file not exists:" + sourceFileName ) ;
logger . error ( "file not exists:" + sourceFileName ) ;
}
} catch ( IOException e ) {
// TODO Auto-generated catch block
@ -718,7 +718,7 @@ public class IdcServiceImpl implements IdcService {
Map < String , Object > whereParams = new HashMap < String , Object > ( ) ;
whereParams . put ( "sqlWhere" , params . get ( "sqlWhere" ) ) ;
String dataWhere = params . get ( "dataWhere" ) ! = null ? params . get ( "dataWhere" ) . toString ( ) : "" ;
String dataWhere = params . get ( "dataWhere" ) ! = null ? params . get ( "dataWhere" ) . toString ( ) : "" ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
String where = DBAUtils . convertWhere ( column , whereParams , dataWhere ) ;
sql + = ! StringUtils . isEmpty ( where ) ? " where " + where : "" ;
@ -827,7 +827,7 @@ public class IdcServiceImpl implements IdcService {
}
saveIdcLog ( messageType , "" , tableName + ">success" , i * limit , total ) ;
}
syncAddTaskStatus ( data , isUpload ? 1 : 0 , true , startTime , isUpload , success ) ;
syncAddTaskStatus ( data , isUpload ? 1 : 0 , true , startTime , isUpload , success ) ;
}
}
}
@ -839,7 +839,7 @@ public class IdcServiceImpl implements IdcService {
/*增加同步任务状态*/
private void syncAddTaskStatus ( Map < String , Object > json , int scheduleType , boolean success , Date startTime ,
boolean isEnd , boolean isReceive ) {
boolean isEnd , boolean isReceive ) {
try {
String content = JSON . toJSONString ( json ) ;
String datePath = DateUtil . formatDate ( new Date ( ) , "yyyy-MM-dd" ) ;
@ -866,7 +866,7 @@ public class IdcServiceImpl implements IdcService {
map . put ( "status" , success ? "1" : "0" ) ;
map . put ( "receiveStatus" , isReceive ? "1" : "0" ) ;
map . put ( "startTime" , startTime ! = null ? startTime : new Date ( ) ) ;
if ( isReceive )
if ( isReceive )
map . put ( "endTime" , new Date ( ) ) ;
map . put ( "updateTime" , new Date ( ) ) ;
map . put ( "remark" , json . get ( "messageType" ) + ": " + json . get ( "total" ) + "条" ) ;
@ -928,7 +928,7 @@ public class IdcServiceImpl implements IdcService {
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
if ( ! StringUtils . isEmpty ( filePathColumn ) ) {
files [ i ] = list . get ( i ) . get ( filePathColumn ) ! = null ? list . get ( i ) . get ( filePathColumn ) . toString ( ) : "" ;
logger . info ( "file-->" + files [ i ] ) ;
logger . info ( "file-->" + files [ i ] ) ;
}
for ( int z = 0 ; z < 30 ; z + + ) {
if ( list . get ( i ) . get ( "data" + z ) ! = null ) {
@ -960,7 +960,7 @@ public class IdcServiceImpl implements IdcService {
String [ ] keyColumn = new String [ 30 ] ;
String [ ] keyDataType = new String [ 30 ] ;
List < Map < String , String > > columnList = dbDao . listColumnsMysql ( tName ) ;
Map < String , Object > column = getColumn ( tName ) ;
Map < String , Object > column = getColumn ( tName ) ;
boolean result = false ;
int key = 0 ;
int col = 0 ;
@ -968,7 +968,7 @@ public class IdcServiceImpl implements IdcService {
if ( col > 0 )
sql + = "," ;
columnList . get ( i ) . put ( "attrName" , columnList . get ( i ) . get ( "columnName" ) ) ;
sql + = "`" + columnList . get ( i ) . get ( "columnName" ) . toString ( ) + "`" ;
sql + = "`" + columnList . get ( i ) . get ( "columnName" ) . toString ( ) + "`" ;
col + + ;
if ( uniqueColumn ! = null & & columnList . get ( i ) . get ( "columnKey" ) ! = null & & ( "," + uniqueColumn + "," ) . contains ( "," + columnList . get ( i ) . get ( "columnName" ) + "," ) ) {
keyColumn [ key ] = columnList . get ( i ) . get ( "columnName" ) . toString ( ) ;
@ -998,13 +998,13 @@ public class IdcServiceImpl implements IdcService {
}
if ( "A,D,U" . contains ( operateMode ) ) {
if ( operateMode . equals ( "D" ) & & list . get ( i ) . get ( "uniqueColumn" ) ! = null ) {
if ( operateMode . equals ( "D" ) & & list . get ( i ) . get ( "uniqueColumn" ) ! = null ) {
String [ ] ucs = list . get ( i ) . get ( "uniqueColumn" ) . toString ( ) . split ( "," ) ;
for ( String str : ucs ) {
Map < String , Object > map = ( Map < String , Object > ) column . get ( str ) ;
for ( String str : ucs ) {
Map < String , Object > map = ( Map < String , Object > ) column . get ( str ) ;
String dataType = map . get ( "dataType" ) . toString ( ) ;
updateWhere + = ! StringUtils . isEmpty ( updateWhere ) ? " and " : " " ;
updateWhere + = str + " = " + ( dataType . equals ( "C" ) ? "'" : "" ) + list . get ( i ) . get ( str ) + ( dataType . equals ( "C" ) ? "'" : "" ) ;
updateWhere + = str + " = " + ( dataType . equals ( "C" ) ? "'" : "" ) + list . get ( i ) . get ( str ) + ( dataType . equals ( "C" ) ? "'" : "" ) ;
}
} else {
for ( int z = 0 ; z < keyColumn . length ; z + + ) {
@ -1166,7 +1166,7 @@ public class IdcServiceImpl implements IdcService {
@Override
public boolean signleDownloadFile ( String syncIp , String fileName ) {
String filePathSlash = filePath . substring ( filePath . length ( ) - 1 ) . equals ( "/" ) ? "" : "/" ;
if ( ! FileUtils . makeDirectory ( filePath + filePathSlash + imagePath ) )
if ( ! FileUtils . makeDirectory ( filePath + filePathSlash + imagePath ) )
IDCUtils . createDirectory ( filePath + filePathSlash + imagePath ) ;
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. build ( ) ;
@ -1183,13 +1183,13 @@ public class IdcServiceImpl implements IdcService {
int total = 0 ;
try {
Response result = client . newCall ( request ) . execute ( ) ;
String msg = result ! = null ? result . message ( ) . length ( ) > 200 ? result . message ( ) . substring ( 0 , 200 ) : result . message ( ) : "" ;
String msg = result ! = null ? result . message ( ) . length ( ) > 200 ? result . message ( ) . substring ( 0 , 200 ) : result . message ( ) : "" ;
if ( result ! = null & & result . isSuccessful ( ) & & MediaType . parse ( "application/force-download" ) . equals ( result . body ( ) . contentType ( ) ) ) {
if ( result ! = null & & result . isSuccessful ( ) & & MediaType . parse ( "application/force-download" ) . equals ( result . body ( ) . contentType ( ) ) ) {
try ( InputStream inputStream = result . body ( ) . byteStream ( ) ) {
FileOutputStream outputStream = new FileOutputStream ( filePath + filePathSlash + imagePath + fileName ) ;
FileOutputStream outputStream = new FileOutputStream ( filePath + filePathSlash + imagePath + fileName ) ;
byte b [ ] = new byte [ 1024 ] ;
@ -1202,18 +1202,17 @@ public class IdcServiceImpl implements IdcService {
outputStream . flush ( ) ;
outputStream . close ( ) ;
if ( ! ( total > 0 ) ) {
new File ( filePath + filePathSlash + imagePath + fileName ) . delete ( ) ;
executeSql ( "delete from idc_file where filePath='" + fileName + "'" ) ;
if ( ! ( total > 0 ) ) {
new File ( filePath + filePathSlash + imagePath + fileName ) . delete ( ) ;
executeSql ( "delete from idc_file where filePath='" + fileName + "'" ) ;
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
}
if ( ! ( total > 0 ) ) {
String sql = "replace idc_file (filePath,createTime,msg) values ('" + fileName + "',now(),'" + msg + "')" ;
if ( ! ( total > 0 ) ) {
String sql = "replace idc_file (filePath,createTime,msg) values ('" + fileName + "',now(),'" + msg + "')" ;
executeSql ( sql ) ;
}
@ -1221,7 +1220,7 @@ public class IdcServiceImpl implements IdcService {
// TODO Auto-generated catch block
e . printStackTrace ( ) ;
}
return ( total > 0 ) ;
return ( total > 0 ) ;
}
// @Override
// public boolean signleDownloadFile(String syncIp, String fileName) {
@ -1357,8 +1356,6 @@ public class IdcServiceImpl implements IdcService {
}
/*把列数据转Map*/
private Map < String , Object > getColumn ( String tableName ) {
Map < String , Object > map = new HashMap < String , Object > ( ) ;
@ -1465,6 +1462,7 @@ public class IdcServiceImpl implements IdcService {
}
}
private void writeFile ( byte [ ] file , String filePath , String fileName ) throws Exception {
File targetFile = new File ( filePath ) ;
if ( ! targetFile . exists ( ) ) {