@ -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 ;
@ -74,7 +77,7 @@ public class IdcServiceImpl implements IdcService {
"basicCorp//basic_corp/id///updateTime///往来单位" , "typeThird//thr_bustype_origin/id///updateTime///第三方单据类型" ,
"basicCorp//basic_corp/id///updateTime///往来单位" , "typeThird//thr_bustype_origin/id///updateTime///第三方单据类型" ,
"basicThirdCorp//thr_corp/id///updateTime///第三方往来单位" , "//thr_dept/id///updateTime///第三方部门" ,
"basicThirdCorp//thr_corp/id///updateTime///第三方往来单位" , "//thr_dept/id///updateTime///第三方部门" ,
"//thr_inv_products/id///updateTime///第三方库存" , "basicThirdInv//thr_inv_warehouse/id//////第三方仓库" ,
"//thr_inv_products/id///updateTime///第三方库存" , "basicThirdInv//thr_inv_warehouse/id//////第三方仓库" ,
"basicThirdBusOrder//thr_order/id///updateTime///第三方业务单据" , "/basicThirdBusOrder/thr_order_detail/orderIdFk/ //updateTime///第三方单据详情",
"basicThirdBusOrder//thr_order/id///updateTime///第三方业务单据" , "/basicThirdBusOrder/thr_order_detail/orderIdFk/ id /orderIdFk /updateTime///第三方单据详情",
"basicThirdProducts//thr_products/id///updateTime///第三方产品信息" , "//sup_cert/id///updateTime/filePath//资质证书信息" ,
"basicThirdProducts//thr_products/id///updateTime///第三方产品信息" , "//sup_cert/id///updateTime/filePath//资质证书信息" ,
"//sup_cert_set/id///updateTime///供应商资质证书设置" , "companyCert//sup_company/customerId///updateTime///配送企业" ,
"//sup_cert_set/id///updateTime///供应商资质证书设置" , "companyCert//sup_company/customerId///updateTime///配送企业" ,
"manufacturerCert//sup_manufacturer/id///updateTime///生产企业" , "productCert//sup_product/id///updateTime///产品资质信息" ,
"manufacturerCert//sup_manufacturer/id///updateTime///生产企业" , "productCert//sup_product/id///updateTime///产品资质信息" ,
@ -125,7 +128,6 @@ public class IdcServiceImpl implements IdcService {
logger . info ( "UDI管理系统同步任务开始--------" ) ;
logger . info ( "UDI管理系统同步任务开始--------" ) ;
asyncDataTask ( true ) ;
asyncDataTask ( true ) ;
}
}
/*自助平台生成任务,不上传*/
/*自助平台生成任务,不上传*/
@Override
@Override
public void asyncSpsTask ( ) {
public void asyncSpsTask ( ) {
@ -139,13 +141,10 @@ public class IdcServiceImpl implements IdcService {
public void asyncFetchUdiTask ( ) {
public void asyncFetchUdiTask ( ) {
fetchTask ( false ) ;
fetchTask ( false ) ;
}
}
@Async
@Async
@Override
@Override
public void asyncFetchTask ( ) {
public void asyncFetchTask ( ) {
fetchTask ( true ) ;
fetchTask ( true ) ;
}
}
@ -212,17 +211,16 @@ 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 ] ) ) {
List < Map < String , String > > keyList = dbDao . listKeyMysql ( tnames [ 2 ] ) ;
List < Map < String , String > > keyList = dbDao . listKeyMysql ( tnames [ 2 ] ) ;
String keyColumn = keyList ! = null & & keyList . size ( ) > 0 ? keyList . get ( 0 ) . get ( "columnName" ) . toString ( ) : "id" ;
String keyColumn = keyList ! = null & & keyList . size ( ) > 0 ? keyList . get ( 0 ) . get ( "columnName" ) . toString ( ) : "id" ;
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" ) ;
@ -257,6 +255,7 @@ public class IdcServiceImpl implements IdcService {
}
}
private String fetchData ( String host , Map < String , Object > params ) {
private String fetchData ( String host , Map < String , Object > params ) {
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
OkHttpClient client = new OkHttpClient ( ) . newBuilder ( )
. build ( ) ;
. build ( ) ;
@ -277,9 +276,9 @@ public class IdcServiceImpl implements IdcService {
if ( isLastLevel ( ) ) {
if ( isLastLevel ( ) ) {
if ( json . get ( "code" ) ! = null ) {
if ( json . get ( "code" ) ! = null ) {
success = analyToDB ( json . getJSONObject ( "data" ) , files ) ;
success = analyToDB ( host , json . getJSONObject ( "data" ) , files , false ) ;
} else {
} else {
success = analyToDB ( json , files ) ;
success = analyToDB ( host , json , files , false ) ;
}
}
if ( ! success )
if ( ! success )
logger . info ( "fetchData-->解析失败" ) ;
logger . info ( "fetchData-->解析失败" ) ;
@ -333,7 +332,6 @@ public class IdcServiceImpl implements IdcService {
dbDao . update ( sql ) ;
dbDao . update ( sql ) ;
return ResultVOUtils . success ( ) ;
return ResultVOUtils . success ( ) ;
}
}
/****/
/****/
@Override
@Override
public BaseResponse receive ( HttpServletRequest request ,
public BaseResponse receive ( HttpServletRequest request ,
@ -343,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 = filePath + datePath + "/" + json . getString ( "messageType" ) + "-" + json . getString ( "messageId" ) + ".udi" ;
String fileName = filePath + filePathSlash + 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 + datePath ) )
if ( ! FileUtils . makeDirectory ( filePath + filePathSlash + datePath ) )
IDCUtils . createDirectory ( filePath + datePath + "/" ) ;
IDCUtils . createDirectory ( filePath + filePathSlash + datePath + "/" ) ;
if ( ! FileUtils . makeDirectory ( backFilePath + datePath ) )
if ( ! FileUtils . makeDirectory ( backFilePath + backFileSlash + datePath ) )
IDCUtils . createDirectory ( filePath + datePath + "/" ) ;
IDCUtils . createDirectory ( filePath + backFileSlash + datePath + "/" ) ;
FileUtils . SaveFileAs ( content , fileName ) ;
FileUtils . SaveFileAs ( content , fileName ) ;
FileUtils . SaveFileAs ( content , backFileName ) ;
FileUtils . SaveFileAs ( content , backFileName ) ;
@ -360,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 ) {
@ -377,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 {
//需要转发
//需要转发
@ -405,13 +405,27 @@ public class IdcServiceImpl implements IdcService {
}
}
@Override
@Override
public BaseResponse send ( String messageType , String tableName , Map < String , Object > params ) {
public BaseResponse send ( String messageType , String tableName , Map < String , Object > params ) {
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 > ( ) ;
@ -435,7 +449,6 @@ public class IdcServiceImpl implements IdcService {
dbDao . save ( sql ) ;
dbDao . save ( sql ) ;
}
}
private void saveDownloadStatus ( String messageType , String taskId , String remark ) {
private void saveDownloadStatus ( String messageType , String taskId , String remark ) {
Map < String , Object > map = new HashMap < String , Object > ( ) ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
map . put ( "id" , CustomUtil . getId ( ) ) ;
map . put ( "id" , CustomUtil . getId ( ) ) ;
@ -449,7 +462,6 @@ public class IdcServiceImpl implements IdcService {
dbDao . save ( sql ) ;
dbDao . save ( sql ) ;
}
}
private void saveIdcLog ( String messageType , String taskId , String content , int offset , int total ) {
private void saveIdcLog ( String messageType , String taskId , String content , int offset , int total ) {
Map < String , Object > map = new HashMap < String , Object > ( ) ;
Map < String , Object > map = new HashMap < String , Object > ( ) ;
map . put ( "id" , CustomUtil . getId ( ) ) ;
map . put ( "id" , CustomUtil . getId ( ) ) ;
@ -503,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 ;
@ -526,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 ] = list . 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())" ;
@ -615,28 +627,30 @@ public class IdcServiceImpl implements IdcService {
}
}
/*解析到数据库*/
/*解析到数据库*/
private boolean analyToDB ( JSONObject 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 ( tableName , uniqueColumn , list ) ;
return analyData ( host , tableName , uniqueColumn , filePathColumn , list , isUpload ) ;
} else {
} else {
logger . error ( "数据格式错误:无数据标记" ) ;
logger . error ( "数据格式错误:无数据标记" ) ;
}
}
@ -646,8 +660,8 @@ public class IdcServiceImpl implements IdcService {
}
}
/*按表名解析数据到数据库,子表暂未处理*/
/*按表名解析数据到数据库,子表暂未处理*/
private boolean analyData ( String tableName, String uniqueColumn , List< Map < String , Object > > list ) {
private boolean analyData ( String host, String tableName, String uniqueColumn , String filePathColumn, List< Map < String , Object > > list , boolean isUpload ) {
logger . error ( "ana-->" + tableName + "--list-->" + JSON . toJSONString ( list ) ) ;
String tName = DBAUtils . tableRealName ( tableName ) ;
String tName = DBAUtils . tableRealName ( tableName ) ;
String sql = "replace " + tName + "(" ;
String sql = "replace " + tName + "(" ;
String del = "delete from " + tName + " where " ;
String del = "delete from " + tName + " where " ;
@ -682,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 ( ) ) ) {
@ -752,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 ( list . get ( i ) . get ( "tableName" + m ) . toString ( ) , "" , chList ) ;
analyData ( host , list . get ( i ) . get ( "tableName" + m ) . toString ( ) , "" , "" , chList , isUpload ) ;
} else {
} else {
break ;
break ;
}
}
@ -764,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 ;
@ -823,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 ;
}
/*获取转发服务地址, 当前值允许单向, 只使用参数upper_server_ip*/
/*获取转发服务地址, 当前值允许单向, 只使用参数upper_server_ip*/
private String getNextHost ( ) {
private String getNextHost ( ) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService . selectByParamKey ( "upper_server_ip" ) ;
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService . selectByParamKey ( "upper_server_ip" ) ;
@ -856,7 +940,6 @@ public class IdcServiceImpl implements IdcService {
List < Map < String , Object > > list = dbDao . list ( map ) ;
List < Map < String , Object > > list = dbDao . list ( map ) ;
return list ;
return list ;
}
}
/*由表名获取数据*/
/*由表名获取数据*/
private Map < String , Object > getData ( String messageType , String tableName , Map < String , Object > params , Map < String , Object > whereParams ) {
private Map < String , Object > getData ( String messageType , String tableName , Map < String , Object > params , Map < String , Object > whereParams ) {
List < Map < String , Object > > list = getList ( tableName , whereParams ) ;
List < Map < String , Object > > list = getList ( tableName , whereParams ) ;
@ -875,6 +958,8 @@ public class IdcServiceImpl implements IdcService {
}
}
private SystemParamConfigEntity getSystemParamConfig ( String paramKey , String paramName , String defaultValue , String paramExplain ) {
private SystemParamConfigEntity getSystemParamConfig ( String paramKey , String paramName , String defaultValue , String paramExplain ) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService . selectByParamKey ( paramKey ) ;
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService . selectByParamKey ( paramKey ) ;
if ( systemParamConfigEntity = = null | | ( systemParamConfigEntity ! = null & & StringUtils . isEmpty ( systemParamConfigEntity . getParamKey ( ) ) ) ) {
if ( systemParamConfigEntity = = null | | ( systemParamConfigEntity ! = null & & StringUtils . isEmpty ( systemParamConfigEntity . getParamKey ( ) ) ) ) {
@ -888,10 +973,8 @@ 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 {
File targetFile = new File ( filePath ) ;
File targetFile = new File ( filePath ) ;
if ( ! targetFile . exists ( ) ) {
if ( ! targetFile . exists ( ) ) {
@ -916,8 +999,7 @@ public class IdcServiceImpl implements IdcService {
for ( int i = 0 ; i < columnList . size ( ) ; i + + ) {
for ( int i = 0 ; i < columnList . size ( ) ; i + + ) {
Map < String , Object > column = new HashMap < String , Object > ( ) ;
Map < String , Object > column = new HashMap < String , Object > ( ) ;
String dataType = columnList . get ( i ) . get ( "dataType" ) . toLowerCase ( ) . contains ( "char" ) | | columnList . get ( i ) . get ( "dataType" ) . toLowerCase ( ) . contains ( "text" ) ?
String dataType = columnList . get ( i ) . get ( "dataType" ) . toLowerCase ( ) . contains ( "char" ) | | columnList . get ( i ) . get ( "dataType" ) . toLowerCase ( ) . contains ( "text" ) ?
"C" : columnList . get ( i ) . get ( "dataType" ) . toLowerCase ( ) . contains ( "date" ) ? "D" : "N" ;
"C" : columnList . get ( i ) . get ( "dataType" ) . toLowerCase ( ) . contains ( "date" ) ? "D" : "N" ; ;
;
String attrName = columnList . get ( i ) . get ( "columnName" ) . toString ( ) ;
String attrName = columnList . get ( i ) . get ( "columnName" ) . toString ( ) ;
if ( map . get ( attrName ) = = null ) {
if ( map . get ( attrName ) = = null ) {
column . put ( "tableName" , tname ) ;
column . put ( "tableName" , tname ) ;
@ -947,13 +1029,16 @@ 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 ) ;
}
}
return updateTime ;
return updateTime ;
}
}
private String setUpdateTime ( String id , String updateTime ) {
private String setUpdateTime ( String id , String updateTime ) {
String sql = "" ;
String sql = "" ;
Map < String , Object > map = dbDao . get ( "select * from idc_status where id='" + id + "'" ) ;
Map < String , Object > map = dbDao . get ( "select * from idc_status where id='" + id + "'" ) ;
@ -966,7 +1051,6 @@ public class IdcServiceImpl implements IdcService {
}
}
return updateTime ;
return updateTime ;
}
}
private void initTable ( ) {
private void initTable ( ) {
alterTable ( "idc_var" , "create table idc_var (code varchar(60),content varchar(200),PRIMARY KEY (code))" ) ;
alterTable ( "idc_var" , "create table idc_var (code varchar(60),content varchar(200),PRIMARY KEY (code))" ) ;
alterTable ( "idc_status" , "create table idc_status (id varchar(36),statusTime datetime,PRIMARY KEY (id))" ) ;
alterTable ( "idc_status" , "create table idc_status (id varchar(36),statusTime datetime,PRIMARY KEY (id))" ) ;
@ -980,7 +1064,6 @@ public class IdcServiceImpl implements IdcService {
}
}
}
}
private void alterTable ( String tableName , String sql ) {
private void alterTable ( String tableName , String sql ) {
Map < String , String > map = dbDao . getMysql ( tableName ) ;
Map < String , String > map = dbDao . getMysql ( tableName ) ;
if ( ! ( map ! = null & & map . get ( "tableName" ) ! = null ) ) {
if ( ! ( map ! = null & & map . get ( "tableName" ) ! = null ) ) {