@ -3,6 +3,8 @@ package com.glxp.api.idc.service.impl;
 
			
		
	
		
		
			
				
					
					import  java.io.File ; import  java.io.File ;  
			
		
	
		
		
			
				
					
					import  java.io.FileOutputStream ; import  java.io.FileOutputStream ;  
			
		
	
		
		
			
				
					
					import  java.io.IOException ; import  java.io.IOException ;  
			
		
	
		
		
			
				
					
					import  java.io.InputStream ;  
			
		
	
		
		
			
				
					
					import  java.io.OutputStream ;  
			
		
	
		
		
			
				
					
					import  java.util.ArrayList ; import  java.util.ArrayList ;  
			
		
	
		
		
			
				
					
					import  java.util.Date ; import  java.util.Date ;  
			
		
	
		
		
			
				
					
					import  java.util.HashMap ; import  java.util.HashMap ;  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -13,6 +15,7 @@ import java.util.concurrent.TimeUnit;
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					import  javax.annotation.Resource ; import  javax.annotation.Resource ;  
			
		
	
		
		
			
				
					
					import  javax.servlet.http.HttpServletRequest ; import  javax.servlet.http.HttpServletRequest ;  
			
		
	
		
		
			
				
					
					import  javax.servlet.http.HttpServletResponse ;  
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					import  org.apache.commons.lang3.StringUtils ; import  org.apache.commons.lang3.StringUtils ;  
			
		
	
		
		
			
				
					
					import  org.apache.commons.text.WordUtils ; import  org.apache.commons.text.WordUtils ;  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -142,8 +145,6 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
						@Override 
	@Override 
 
			
		
	
		
		
			
				
					
						public  void  asyncFetchTask ( )  { 
	public  void  asyncFetchTask ( )  { 
 
			
		
	
		
		
			
				
					
							fetchTask ( true ) ; 
		fetchTask ( true ) ; 
 
			
		
	
		
		
			
				
					
						
 
			
		
	
		
		
			
				
					
						
 
			
		
	
		
		
			
				
					
						} 
	} 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
						
	
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -210,7 +211,7 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							boolean  sync  =  true ; 
		boolean  sync  =  true ; 
 
			
		
	
		
		
			
				
					
							String [ ]  tnames  =  t . split ( "/" ) ; 
		String [ ]  tnames  =  t . split ( "/" ) ; 
 
			
		
	
		
		
			
				
					
						
	
 
			
		
	
		
		
			
				
					
							String  lastUpdateTime  =  getUpdateTime ( tnames [ 2 ] ) ; 
		String  lastUpdateTime  =  getUpdateTime ( tnames [ 3 ] ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
							Date  nowUpdateTime  =  new  Date ( ) ; 
		Date  nowUpdateTime  =  new  Date ( ) ; 
 
			
		
	
		
		
			
				
					
							if ( ! StringUtils . isEmpty ( tnames [ 0 ] ) )  { 
		if ( ! StringUtils . isEmpty ( tnames [ 0 ] ) )  { 
 
			
		
	
		
		
			
				
					
								
			
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -219,7 +220,7 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
								Map < String , Object >  map  =  new  HashMap < String , Object > ( ) ; 
			Map < String , Object >  map  =  new  HashMap < String , Object > ( ) ; 
 
			
		
	
		
		
			
				
					
								String  sqlWhere  =  "" ; 
			String  sqlWhere  =  "" ; 
 
			
		
	
		
		
			
				
					
								if ( ! StringUtils . isEmpty ( tnames [ 6 ] ) )  { 
			if ( ! StringUtils . isEmpty ( tnames [ 6 ] ) )  { 
 
			
		
	
		
		
			
				
					
									sqlWhere + = " " + tnames [ 6 ] + " >=cast('"+ lastUpdateTime  + "' as datetime)" ; 
				sqlWhere + = " " + tnames [ 6 ] + " between cast('"+ lastUpdateTime + "' as datetime) and cast('" + DateUtil . formatDate ( nowUpdateTime ,  "yyyy-MM-dd HH:mm:ss" )  + "' as datetime)" ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
								}  else  { 
			}  else  { 
 
			
		
	
		
		
			
				
					
									sqlWhere  =  "not exists (select fkId from idc_record where type='" + tnames [ 2 ] + "' and fkId=" + tnames [ 2 ] + "." + keyColumn + ")" ; 
				sqlWhere  =  "not exists (select fkId from idc_record where type='" + tnames [ 2 ] + "' and fkId=" + tnames [ 2 ] + "." + keyColumn + ")" ; 
 
			
		
	
		
		
			
				
					
									map . put ( "isEnd" ,  "1" ) ; 
				map . put ( "isEnd" ,  "1" ) ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -272,11 +273,12 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
								Response  response  =  client . newCall ( request ) . execute ( ) ; 
			Response  response  =  client . newCall ( request ) . execute ( ) ; 
 
			
		
	
		
		
			
				
					
								result  =  response . body ( ) . string ( ) ; 
			result  =  response . body ( ) . string ( ) ; 
 
			
		
	
		
		
			
				
					
								JSONObject  json  =  JSONObject . parseObject ( result ) ; 
			JSONObject  json  =  JSONObject . parseObject ( result ) ; 
 
			
		
	
		
		
			
				
					
								
 
			
		
	
		
		
			
				
					
								if ( isLastLevel ( ) )  { 
			if ( isLastLevel ( ) )  { 
 
			
		
	
		
		
			
				
					
									if ( json . get ( "code" ) ! = null )  { 
				if ( json . get ( "code" ) ! = null )  { 
 
			
		
	
		
		
			
				
					
										success  =  analyToDB ( . getJSONObject ( "data" ) , files ) ; 
					success  =  analyToDB ( host,  json. getJSONObject ( "data" ) , files , false ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
									}  else  { 
				}  else  { 
 
			
		
	
		
		
			
				
					
										success  =  analyToDB ( , files ) ; 
					success  =  analyToDB ( host,  json, files , false ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
									} 
				} 
 
			
		
	
		
		
			
				
					
									if ( ! success ) 
				if ( ! success ) 
 
			
		
	
		
		
			
				
					
										logger . info ( "fetchData-->解析失败" ) ; 
					logger . info ( "fetchData-->解析失败" ) ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -339,14 +341,15 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							String  secretKey  =  request . getHeader ( "secretKey" ) ; 
		String  secretKey  =  request . getHeader ( "secretKey" ) ; 
 
			
		
	
		
		
			
				
					
							/*******/ 
		/*******/ 
 
			
		
	
		
		
			
				
					
							JSONObject  json  =  JSONObject . parseObject ( content ) ; 
		JSONObject  json  =  JSONObject . parseObject ( content ) ; 
 
			
		
	
		
		
			
				
					
					
		String  filePathSlash  =  filePath . substring ( filePath . length ( )  - 1 ) . equals ( "/" )  ?  ""  :  "/" ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
							String  backFileSlash  =  backFilePath . substring ( filePath . length ( )  - 1 ) . equals ( "/" )  ?  ""  :  "/" ; 
 
			
		
	
		
		
			
				
					
							String  datePath  =  DateUtil . formatDate ( new  Date ( ) , "yyyy-MM-dd" ) ; 
		String  datePath  =  DateUtil . formatDate ( new  Date ( ) , "yyyy-MM-dd" ) ; 
 
			
		
	
		
		
			
				
					
							String  fileName  =  filePat h + datePath + "/" + json . getString ( "messageType" ) + "-" + json . getString ( "messageId" ) + ".udi" ; 
		String  fileName  = filePath + filePat hSlas h + datePath + "/" + json . getString ( "messageType" ) + "-" + json . getString ( "messageId" ) + ".udi" ; 
 
			
				
				
			
		
	
		
		
			
				
					
							String  backFileName  =  backFilePath  + datePath + "/" + json . getString ( "messageType" ) + "-" + json . getString ( "messageId" ) + ".udi" ; 
		String  backFileName  =  backFilePath   + backFileSlash   + datePath + "/" + json . getString ( "messageType" ) + "-" + json . getString ( "messageId" ) + ".udi" ; 
 
			
				
				
			
		
	
		
		
			
				
					
							if ( ! FileUtils . makeDirectory (  filePath  + ) ) 
		if ( ! FileUtils . makeDirectory (  filePath  + filePathSlash +  datePath) ) 
 
			
				
				
			
		
	
		
		
			
				
					
								IDCUtils . createDirectory ( filePath  + + "/" ) ; 
			IDCUtils . createDirectory ( filePath  + filePathSlash +  datePath+ "/" ) ; 
 
			
				
				
			
		
	
		
		
			
				
					
							if ( ! FileUtils . makeDirectory ( backFilePath  + ) ) 
		if ( ! FileUtils . makeDirectory ( backFilePath  + backFileSlash +  datePath) ) 
 
			
				
				
			
		
	
		
		
			
				
					
								IDCUtils . createDirectory ( filePath  + + "/" ) ; 
			IDCUtils . createDirectory ( filePath  + backFileSlash +  datePath+ "/" ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
							
		
 
			
		
	
		
		
			
				
					
							FileUtils . SaveFileAs ( content ,  fileName ) ; 
		FileUtils . SaveFileAs ( content ,  fileName ) ; 
 
			
		
	
		
		
			
				
					
					        FileUtils . SaveFileAs ( content ,  backFileName ) ; 
        FileUtils . SaveFileAs ( content ,  backFileName ) ; 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -356,9 +359,10 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
					        	int  n = 0 ; 
        	int  n = 0 ; 
 
			
		
	
		
		
			
				
					
					            try  { 
            try  { 
 
			
		
	
		
		
			
				
					
					        		for ( MultipartFile  file : files )  { 
        		for ( MultipartFile  file : files )  { 
 
			
		
	
		
		
			
				
					
					        			saveFiles [ n ]  =  filePath  + datePath + "/" + json . getString ( "messageId" ) + "/" + file . getOriginalFilename ( ) ; 
        			String  imageName  =  filePath  + filePathSlash + "register/file/image2/" + file . getOriginalFilename ( ) ; 
 
			
				
				
			
		
	
		
		
			
				
					
					        			writeFile ( file . getBytes ( ) ,  filePath  + datePath + "/" + json . getString ( "messageId" ) + "/" ,  file . getOriginalFilename ( ) ) ; 
        			saveFiles [ n ]  =  imageName ; 
 
			
				
				
			
		
	
		
		
			
				
					
					        			writeFile ( file . getBytes ( ) ,  backFilePath  + datePath + "/" + json . getString ( "messageId" ) + "/" ,  file . getOriginalFilename ( ) ) ; 
        			writeFile ( file . getBytes ( ) ,  filePath  + filePathSlash + "register/file/image2/" ,  file . getOriginalFilename ( ) ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					        			writeFile ( file . getBytes ( ) ,  backFilePath  + backFileSlash + datePath + "register/file/image2/" ,  file . getOriginalFilename ( ) ) ; 
 
			
		
	
		
		
			
				
					
					        			n + + ; 
        			n + + ; 
 
			
		
	
		
		
			
				
					
					        		} 
        		} 
 
			
		
	
		
		
			
				
					
								}  catch  ( IOException  e )  { 
			}  catch  ( IOException  e )  { 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -373,7 +377,7 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
					        syncAddTaskStatus ( json , true , true ) ; 
        syncAddTaskStatus ( json , true , true ) ; 
 
			
		
	
		
		
			
				
					
					        /*解析入库*/ 
        /*解析入库*/ 
 
			
		
	
		
		
			
				
					
					        if ( isLastLevel ( ) )  { 
        if ( isLastLevel ( ) )  { 
 
			
		
	
		
		
			
				
					
					        	if ( ! analyToDB ( json , files ) ) 
        	if ( ! analyToDB ( "" , json , files , true ) ) 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					        		return  ResultVOUtils . error ( 9000 ,  "解析失败" ) ; 
        		return  ResultVOUtils . error ( 9000 ,  "解析失败" ) ; 
 
			
		
	
		
		
			
				
					
					        }  else  { 
        }  else  { 
 
			
		
	
		
		
			
				
					
					        	//需要转发
 
        	//需要转发
 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -407,6 +411,21 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							return  ResultVOUtils . error ( 9999 ,  "" ) ; 
		return  ResultVOUtils . error ( 9999 ,  "" ) ; 
 
			
		
	
		
		
			
				
					
						} 
	} 
 
			
		
	
		
		
			
				
					
						
	
 
			
		
	
		
		
			
				
					
						@Override 
 
			
		
	
		
		
			
				
					
						public  void  downloadFile ( String  fileName , HttpServletResponse  response )  { 
 
			
		
	
		
		
			
				
					
							OutputStream  os ; 
 
			
		
	
		
		
			
				
					
							String  filePathSlash  =  filePath . substring ( filePath . length ( )  - 1 ) . equals ( "/" )  ?  ""  :  fileName . substring ( 0 , 1 ) . equals ( "/" )  ?  ""  :  "/" ; 
 
			
		
	
		
		
			
				
					
							try  { 
 
			
		
	
		
		
			
				
					
								byte [ ]  bytes  =  FileUtils . readFileByBytes ( filePath + filePathSlash + fileName ) ; 
 
			
		
	
		
		
			
				
					
								os  =  response . getOutputStream ( ) ; 
 
			
		
	
		
		
			
				
					
								os . write ( bytes ) ; 
 
			
		
	
		
		
			
				
					
					            os . flush ( ) ; 
 
			
		
	
		
		
			
				
					
					            os . close ( ) ; 
 
			
		
	
		
		
			
				
					
							}  catch  ( IOException  e )  { 
 
			
		
	
		
		
			
				
					
								// TODO Auto-generated catch block
 
 
			
		
	
		
		
			
				
					
								e . printStackTrace ( ) ; 
 
			
		
	
		
		
			
				
					
							} 
 
			
		
	
		
		
			
				
					
						} 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
						private  void  saveUploadStatus ( Map < String , Object >  params )  { 
	private  void  saveUploadStatus ( Map < String , Object >  params )  { 
 
			
		
	
		
		
			
				
					
							Map < String , Object >  map  =  new  HashMap < String , Object > ( ) ; 
		Map < String , Object >  map  =  new  HashMap < String , Object > ( ) ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -496,7 +515,7 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							orderNum + + ; 
		orderNum + + ; 
 
			
		
	
		
		
			
				
					
							String  messageType  =  params . get ( "messageType" ) . toString ( ) ; 
		String  messageType  =  params . get ( "messageType" ) . toString ( ) ; 
 
			
		
	
		
		
			
				
					
							saveIdcLog ( messageType , "" , tableName  + ">" + where , 0 , total ) ; 
		saveIdcLog ( messageType , "" , tableName  + ">" + where , 0 , total ) ; 
 
			
		
	
		
		
			
				
					
							
		String  filePathSlash  =  filePath . substring ( filePath . length ( )  - 1 ) . equals ( "/" )  ?  ""  :  "/" ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
						
	
 
			
		
	
		
		
			
				
					
							if ( total > 0 )  { 
		if ( total > 0 )  { 
 
			
		
	
		
		
			
				
					
								success  =  true ; 
			success  =  true ; 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -519,7 +538,7 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
										if ( list ! = null & & list . size ( ) > 0 )  { 
					if ( list ! = null & & list . size ( ) > 0 )  { 
 
			
		
	
		
		
			
				
					
											for ( int  m = 0 ; m < list . size ( ) ; m + + )  { 
						for ( int  m = 0 ; m < list . size ( ) ; m + + )  { 
 
			
		
	
		
		
			
				
					
												if ( ! StringUtils . isEmpty ( filePathColumn ) & & list . get ( m ) . get ( filePathColumn ) ! = null )  { 
							if ( ! StringUtils . isEmpty ( filePathColumn ) & & list . get ( m ) . get ( filePathColumn ) ! = null )  { 
 
			
		
	
		
		
			
				
					
													files [ m ]  =  . get ( m ) . get ( filePathColumn ) . toString ( ) ; 
								files [ m ]  =  filePath+ filePathSlash + "register/file/image2/" +  list. get ( m ) . get ( filePathColumn ) . toString ( ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
												} 
							} 
 
			
		
	
		
		
			
				
					
												recordSql + = ! StringUtils . isEmpty ( recordSql )  ?  ","  :  "" ; 
							recordSql + = ! StringUtils . isEmpty ( recordSql )  ?  ","  :  "" ; 
 
			
		
	
		
		
			
				
					
												recordSql + = "('" + UUID . randomUUID ( ) . toString ( ) . replaceAll ( "-" ,  "" ) + "','" + tableName + "','" + list . get ( m ) . get ( keyColumn ) + "','" + isEnd + "',now())" ; 
							recordSql + = "('" + UUID . randomUUID ( ) . toString ( ) . replaceAll ( "-" ,  "" ) + "','" + tableName + "','" + list . get ( m ) . get ( keyColumn ) + "','" + isEnd + "',now())" ; 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -533,7 +552,6 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
															List < Map < String , Object > >  childList  =  getList ( chidTnames [ 2 ] , childMap ) ; 
										List < Map < String , Object > >  childList  =  getList ( chidTnames [ 2 ] , childMap ) ; 
 
			
		
	
		
		
			
				
					
															list . get ( m ) . put ( "tableName" + z ,  chidTnames [ 2 ] ) ; 
										list . get ( m ) . put ( "tableName" + z ,  chidTnames [ 2 ] ) ; 
 
			
		
	
		
		
			
				
					
															list . get ( m ) . put ( "data" + z ,  childList ) ; 
										list . get ( m ) . put ( "data" + z ,  childList ) ; 
 
			
		
	
		
		
			
				
					
															logger . info ( "child-data-->" + JSON . toJSONString ( childList ) ) ; 
 
			
		
	
		
		
			
				
					
														} 
									} 
 
			
		
	
		
		
			
				
					
													} 
								} 
 
			
		
	
		
		
			
				
					
												} 
							} 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -554,6 +572,7 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
														if ( ! StringUtils . isEmpty ( recordSql ) )  { 
									if ( ! StringUtils . isEmpty ( recordSql ) )  { 
 
			
		
	
		
		
			
				
					
															dbDao . save ( "insert into idc_record (id,type,fkId,isEnd,createTime) values " + recordSql ) ; 
										dbDao . save ( "insert into idc_record (id,type,fkId,isEnd,createTime) values " + recordSql ) ; 
 
			
		
	
		
		
			
				
					
														} 
									} 
 
			
		
	
		
		
			
				
					
														saveDownloadStatus ( messageType , json . getString ( "reqNo" ) , messageType + " 记录数:" + list . size ( ) + "/" + total ) ; 
 
			
		
	
		
		
			
				
					
														saveIdcLog ( messageType , "" , tableName  + ">success" , i  * limit , total ) ; 
									saveIdcLog ( messageType , "" , tableName  + ">success" , i  * limit , total ) ; 
 
			
		
	
		
		
			
				
					
													}  else  { 
								}  else  { 
 
			
		
	
		
		
			
				
					
														success  =  false ; 
									success  =  false ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -610,27 +629,28 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
						
	
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
						/*解析到数据库*/ 
	/*解析到数据库*/ 
 
			
		
	
		
		
			
				
					
						private  boolean  analyToDB ( jsonObject , MultipartFile [ ]  files )  { 
	private  boolean  analyToDB ( String host ,  JSONObject jsonObject , MultipartFile [ ]  files , boolean  isUpload )  { 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
							
		
 
			
		
	
		
		
			
				
					
							if ( jsonObject . get ( "data" ) ! = null )  { 
		if ( jsonObject . get ( "data" ) ! = null )  { 
 
			
		
	
		
		
			
				
					
								logger . error ( "json>>>>>>>>>" ) ; 
 
			
		
	
		
		
			
				
					
								String  tableName  =  "" ; 
			String  tableName  =  "" ; 
 
			
		
	
		
		
			
				
					
								String  uniqueColumn  =  "" ; 
			String  uniqueColumn  =  "" ; 
 
			
		
	
		
		
			
				
					
								String  filePathColumn  =  "" ; 
 
			
		
	
		
		
			
				
					
								Object  object  =  jsonObject . get ( "data" ) ; 
			Object  object  =  jsonObject . get ( "data" ) ; 
 
			
		
	
		
		
			
				
					
								List < Map < String , Object > >  list  =  new  ArrayList < > ( ) ; 
			List < Map < String , Object > >  list  =  new  ArrayList < > ( ) ; 
 
			
		
	
		
		
			
				
					
								if ( object  instanceof  List < ? > )  { 
			if ( object  instanceof  List < ? > )  { 
 
			
		
	
		
		
			
				
					
									list  =  jsonObject . getObject ( "data" ,  List . class ) ; 
				list  =  jsonObject . getObject ( "data" ,  List . class ) ; 
 
			
		
	
		
		
			
				
					
									tableName  =  jsonObject . getString ( "tableName" ) ; 
				tableName  =  jsonObject . getString ( "tableName" ) ; 
 
			
		
	
		
		
			
				
					
									uniqueColumn  =  jsonObject . getString ( "uniqueColumn" ) ; 
				uniqueColumn  =  jsonObject . getString ( "uniqueColumn" ) ; 
 
			
		
	
		
		
			
				
					
									filePathColumn  =  jsonObject . getString ( "filePathColumn" ) ; 
 
			
		
	
		
		
			
				
					
								}  else  { 
			}  else  { 
 
			
		
	
		
		
			
				
					
									JSONObject  obj  =  jsonObject . getJSONObject ( "data" ) ; 
				JSONObject  obj  =  jsonObject . getJSONObject ( "data" ) ; 
 
			
		
	
		
		
			
				
					
									list  =  obj . getObject ( "data" ,  List . class ) ; 
				list  =  obj . getObject ( "data" ,  List . class ) ; 
 
			
		
	
		
		
			
				
					
									tableName  =  obj . getString ( "tableName" ) ; 
				tableName  =  obj . getString ( "tableName" ) ; 
 
			
		
	
		
		
			
				
					
									uniqueColumn  =  obj . getString ( "uniqueColumn" ) ; 
				uniqueColumn  =  obj . getString ( "uniqueColumn" ) ; 
 
			
		
	
		
		
			
				
					
									filePathColumn  =  obj . getString ( "filePathColumn" ) ; 
 
			
		
	
		
		
			
				
					
								} 
			} 
 
			
		
	
		
		
			
				
					
								logger . error ( "table-->" + tableName ) ; 
 
			
		
	
		
		
			
				
					
								if ( ! StringUtils . isEmpty ( tableName ) )  { 
			if ( ! StringUtils . isEmpty ( tableName ) )  { 
 
			
		
	
		
		
			
				
					
									return  analyData ( , uniqueColumn , ) ; 
				return  analyData ( host,  tableName, uniqueColumn , filePathColumn,  list, isUpload ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
								}  else  { 
			}  else  { 
 
			
		
	
		
		
			
				
					
									logger . error ( "数据格式错误:无数据标记" ) ; 
				logger . error ( "数据格式错误:无数据标记" ) ; 
 
			
		
	
		
		
			
				
					
								} 
			} 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -639,9 +659,8 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							return  false ; 
		return  false ; 
 
			
		
	
		
		
			
				
					
						} 
	} 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
						/*按表名解析数据到数据库,子表暂未处理*/ 
	/*按表名解析数据到数据库,子表暂未处理*/ 
 
			
		
	
		
		
			
				
					
						private  boolean  analyData ( String  , String  uniqueColumn , < Map < String , Object > >  list )  { 
	private  boolean  analyData ( String  host, String   tableName, String  uniqueColumn , String filePathColumn ,  List< Map < String , Object > >  list , boolean  isUpload )  { 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
							String  tName  =  DBAUtils . tableRealName ( tableName ) ; 
		String  tName  =  DBAUtils . tableRealName ( tableName ) ; 
 
			
		
	
		
		
			
				
					
							String  sql = "replace " + tName  + "(" ; 
		String  sql = "replace " + tName  + "(" ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -677,10 +696,15 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							if ( list ! = null & & list . size ( ) > 0 )  { 
		if ( list ! = null & & list . size ( ) > 0 )  { 
 
			
		
	
		
		
			
				
					
								int  n  =  0 ; 
			int  n  =  0 ; 
 
			
		
	
		
		
			
				
					
								int  d  =  0 ; 
			int  d  =  0 ; 
 
			
		
	
		
		
			
				
					
								String [ ]  files  =  new  String [ list . size ( ) ] ; 
 
			
		
	
		
		
			
				
					
								for ( int  i = 0 ; i < list . size ( ) ; i + + )  { 
			for ( int  i = 0 ; i < list . size ( ) ; i + + )  { 
 
			
		
	
		
		
			
				
					
									String  operateMode  =  list . get ( i ) . get ( "operateMode" )  ! = null  ?  list . get ( i ) . get ( "operateMode" ) . toString ( )  :  "A" ; 
				String  operateMode  =  list . get ( i ) . get ( "operateMode" )  ! = null  ?  list . get ( i ) . get ( "operateMode" ) . toString ( )  :  "A" ; 
 
			
		
	
		
		
			
				
					
									String  updateWhere  = "" ; 
				String  updateWhere  = "" ; 
 
			
		
	
		
		
			
				
					
									String  updateSet  =  "" ; 
				String  updateSet  =  "" ; 
 
			
		
	
		
		
			
				
					
									if ( ! StringUtils . isEmpty ( filePathColumn ) )  { 
 
			
		
	
		
		
			
				
					
										files [ i ]  =  list . get ( i ) . get ( filePathColumn )  ! = null  ?  list . get ( i ) . get ( filePathColumn ) . toString ( )  :  "" ; 
 
			
		
	
		
		
			
				
					
									} 
 
			
		
	
		
		
			
				
					
									
 
			
		
	
		
		
			
				
					
									if ( "A,D,U" . contains ( operateMode ) )  { 
				if ( "A,D,U" . contains ( operateMode ) )  { 
 
			
		
	
		
		
			
				
					
										for ( int  z = 0 ; z < keyColumn . length ; z + +  )  { 
					for ( int  z = 0 ; z < keyColumn . length ; z + +  )  { 
 
			
		
	
		
		
			
				
					
											if ( list . get ( i ) . get ( keyColumn [ z ] ) ! = null & & ! StringUtils . isEmpty ( list . get ( i ) . get ( keyColumn [ z ] ) . toString ( ) ) )  { 
						if ( list . get ( i ) . get ( keyColumn [ z ] ) ! = null & & ! StringUtils . isEmpty ( list . get ( i ) . get ( keyColumn [ z ] ) . toString ( ) ) )  { 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -747,7 +771,7 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
											for  ( Object  o  :  ( List < ? > )  obj )  { 
						for  ( Object  o  :  ( List < ? > )  obj )  { 
 
			
		
	
		
		
			
				
					
												chList . add ( ( Map < String , Object > ) o ) ; 
							chList . add ( ( Map < String , Object > ) o ) ; 
 
			
		
	
		
		
			
				
					
											} 
						} 
 
			
		
	
		
		
			
				
					
											analyData ( . get ( i ) . get ( "tableName" + m ) . toString ( ) , "" , chList ) ; 
						analyData ( host,  list. get ( i ) . get ( "tableName" + m ) . toString ( ) , "" , "" , chList , isUpload ) ; 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
										}  else  { 
					}  else  { 
 
			
		
	
		
		
			
				
					
											break ; 
						break ; 
 
			
		
	
		
		
			
				
					
										} 
					} 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -759,6 +783,9 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
									if ( ! result ) 
				if ( ! result ) 
 
			
		
	
		
		
			
				
					
										logger . error ( tableName + "-->fetchSave Fail" ) ; 
					logger . error ( tableName + "-->fetchSave Fail" ) ; 
 
			
		
	
		
		
			
				
					
								} 
			} 
 
			
		
	
		
		
			
				
					
								if ( ! isUpload & & ! StringUtils . isEmpty ( filePathColumn ) )  { 
 
			
		
	
		
		
			
				
					
									batchDownloadFile ( host , files ) ; 
 
			
		
	
		
		
			
				
					
								} 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
							} 
		} 
 
			
		
	
		
		
			
				
					
							return  result ; 
		return  result ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -818,6 +845,68 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							return  result ; 
		return  result ; 
 
			
		
	
		
		
			
				
					
						} 
	} 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
						/*下载文件*/ 
 
			
		
	
		
		
			
				
					
						private  boolean  batchDownloadFile ( String  syncIp , String [ ]  files )  { 
 
			
		
	
		
		
			
				
					
							boolean  success  =  true ; 
 
			
		
	
		
		
			
				
					
							for ( String  fileName : files )  { 
 
			
		
	
		
		
			
				
					
								if ( ! StringUtils . isEmpty ( fileName ) )  { 
 
			
		
	
		
		
			
				
					
									if ( ! signleDownloadFile ( syncIp , fileName ) ) 
 
			
		
	
		
		
			
				
					
										success  =  false ; 
 
			
		
	
		
		
			
				
					
								} 
 
			
		
	
		
		
			
				
					
							} 
 
			
		
	
		
		
			
				
					
							return  success ; 
 
			
		
	
		
		
			
				
					
						} 
 
			
		
	
		
		
			
				
					
						private  boolean  signleDownloadFile ( String  syncIp , String  fileName )  { 
 
			
		
	
		
		
			
				
					
							OkHttpClient  client  =  new  OkHttpClient ( ) ; 
 
			
		
	
		
		
			
				
					
							RequestBody  requestBody  =  new  MultipartBody . Builder ( ) 
 
			
		
	
		
		
			
				
					
									. setType ( MultipartBody . FORM ) 
 
			
		
	
		
		
			
				
					
									. addFormDataPart ( "fileName" ,  fileName ) 
 
			
		
	
		
		
			
				
					
									. build ( ) ; 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
									
 
			
		
	
		
		
			
				
					
							Request  request  =  new  Request . Builder ( ) 
 
			
		
	
		
		
			
				
					
									. url ( syncIp + "/spssync/common/downloadFile" ) 
 
			
		
	
		
		
			
				
					
									. post ( requestBody ) 
 
			
		
	
		
		
			
				
					
									. build ( ) ; 
 
			
		
	
		
		
			
				
					
							try  { 
 
			
		
	
		
		
			
				
					
								Response  result  =  client . newCall ( request ) . execute ( ) ; 
 
			
		
	
		
		
			
				
					
								
 
			
		
	
		
		
			
				
					
								
 
			
		
	
		
		
			
				
					
								
 
			
		
	
		
		
			
				
					
								if  ( MediaType . parse ( "application/force-download" ) . equals ( result . body ( ) . contentType ( ) ) )  { 
 
			
		
	
		
		
			
				
					
									try  ( InputStream  inputStream  =  result . body ( ) . byteStream ( ) )  { 
 
			
		
	
		
		
			
				
					
										String  filePathSlash  =  filePath . substring ( filePath . length ( )  - 1 ) . equals ( "/" )  ?  ""  :  "/" ; 
 
			
		
	
		
		
			
				
					
										
 
			
		
	
		
		
			
				
					
										FileOutputStream  outputStream  = new  FileOutputStream ( filePath  + filePathSlash + fileName ) ; 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
										byte  b [ ] = new  byte [ 1024 ] ; 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
										int  len = 0 ; 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
										while  ( ( len = inputStream . read ( b ) ) ! = - 1 ) { 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
											outputStream . write ( b , 0 , len ) ; 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
										} 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
										outputStream . flush ( ) ; 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
										
 
			
		
	
		
		
			
				
					
										
 
			
		
	
		
		
			
				
					
									}  catch  ( Exception  e )  { 
 
			
		
	
		
		
			
				
					
										
 
			
		
	
		
		
			
				
					
								
 
			
		
	
		
		
			
				
					
									} 
 
			
		
	
		
		
			
				
					
								}  
 
			
		
	
		
		
			
				
					
								
 
			
		
	
		
		
			
				
					
							}  catch  ( IOException  e )  { 
 
			
		
	
		
		
			
				
					
								// TODO Auto-generated catch block
 
 
			
		
	
		
		
			
				
					
								e . printStackTrace ( ) ; 
 
			
		
	
		
		
			
				
					
							} 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
							return  true ; 
 
			
		
	
		
		
			
				
					
						} 
 
			
		
	
		
		
			
				
					
						
 
			
		
	
		
		
			
				
					
						/*获取转发服务地址, ,  
	/*获取转发服务地址, ,  
 
			
		
	
		
		
			
				
					
						private  String  getNextHost ( )  { 
	private  String  getNextHost ( )  { 
 
			
		
	
		
		
			
				
					
							SystemParamConfigEntity  systemParamConfigEntity  =   systemParamConfigService . selectByParamKey ( "upper_server_ip" ) ; 
		SystemParamConfigEntity  systemParamConfigEntity  =   systemParamConfigService . selectByParamKey ( "upper_server_ip" ) ; 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -884,7 +973,6 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
								systemParamConfigEntity . setParamType ( 0 ) ; 
			systemParamConfigEntity . setParamType ( 0 ) ; 
 
			
		
	
		
		
			
				
					
								systemParamConfigService . insert ( systemParamConfigEntity ) ; 
			systemParamConfigService . insert ( systemParamConfigEntity ) ; 
 
			
		
	
		
		
			
				
					
							} 
		} 
 
			
		
	
		
		
			
				
					
							System . out . print ( JSON . toJSONString ( systemParamConfigEntity ) + "\n" ) ; 
 
			
		
	
		
		
			
				
					
							return  systemParamConfigEntity ; 
		return  systemParamConfigEntity ; 
 
			
		
	
		
		
			
				
					
						} 
	} 
 
			
		
	
		
		
			
				
					
						private  void  writeFile ( byte [ ]  file ,  String  filePath ,  String  fileName )  throws  Exception  { 
	private  void  writeFile ( byte [ ]  file ,  String  filePath ,  String  fileName )  throws  Exception  { 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -941,6 +1029,10 @@ public class IdcServiceImpl implements IdcService {
 
			
		
	
		
		
			
				
					
							if ( map ! = null & & map . get ( "id" ) ! = null )  { 
		if ( map ! = null & & map . get ( "id" ) ! = null )  { 
 
			
		
	
		
		
			
				
					
								updateTime  =  DateUtil . formatDate ( IDCUtils . parseDate ( map . get ( "statusTime" ) . toString ( ) ) , "yyyy-MM-dd HH:mm:ss" ) ; 
			updateTime  =  DateUtil . formatDate ( IDCUtils . parseDate ( map . get ( "statusTime" ) . toString ( ) ) , "yyyy-MM-dd HH:mm:ss" ) ; 
 
			
		
	
		
		
			
				
					
							}  else  { 
		}  else  { 
 
			
		
	
		
		
			
				
					
								//国家库数据
 
 
			
		
	
		
		
			
				
					
								if ( id . equals ( "productinfo" ) )  { 
 
			
		
	
		
		
			
				
					
									
 
			
		
	
		
		
			
				
					
								} 
 
			
		
	
		
		
			
				
					
								updateTime  =  "2000-01-01 00:00:00" ; 
			updateTime  =  "2000-01-01 00:00:00" ; 
 
			
		
	
		
		
			
				
					
								String  sql  =  "insert into idc_status (id,statusTime) values ('" + id + "',cast('" + updateTime + "' as datetime))" ; 
			String  sql  =  "insert into idc_status (id,statusTime) values ('" + id + "',cast('" + updateTime + "' as datetime))" ; 
 
			
		
	
		
		
			
				
					
								dbDao . save ( sql ) ; 
			dbDao . save ( sql ) ;