|
|
@ -78,8 +78,9 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
"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///产品资质信息",
|
|
|
|
"dbDiProducts//productinfo/id///updateTime///DI产品信息","//udicompany/id///updateTime///国际库医疗器械注册人信息"};
|
|
|
|
"//udicompany/id///updateTime///国际库医疗器械注册人信息"};
|
|
|
|
|
|
|
|
//"dbDiProducts//productinfo/id///updateTime///DI产品信息",
|
|
|
|
|
|
|
|
|
|
|
|
private int orderNum=0;
|
|
|
|
private int orderNum=0;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -102,7 +103,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
return ResultVOUtils.success(list);
|
|
|
|
return ResultVOUtils.success(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public BaseResponse download(HttpServletRequest request,Map<String,Object> params) {
|
|
|
|
public BaseResponse download(HttpServletRequest request,Map<String,Object> params) {
|
|
|
|
Map<String,Object> map = dbDao.get("select * from basic_upload_status where taskId='"+params.get("taskId")+"'");
|
|
|
|
Map<String,Object> map = dbDao.get("select * from basic_upload_status where taskId='"+params.get("taskId")+"'");
|
|
|
@ -113,7 +113,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
return ResultVOUtils.success(object);
|
|
|
|
return ResultVOUtils.success(object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*UDI系统上传自助平台*/
|
|
|
|
/*UDI系统上传自助平台*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void asyncUdiTask() {
|
|
|
|
public void asyncUdiTask() {
|
|
|
@ -126,12 +126,12 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
logger.info("自助平台同步任务开始--------");
|
|
|
|
logger.info("自助平台同步任务开始--------");
|
|
|
|
asyncDataTask(false);
|
|
|
|
asyncDataTask(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*拉取前一级中继服务数据*/
|
|
|
|
/*拉取前一级中继服务数据*/
|
|
|
|
@Async
|
|
|
|
@Async
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void asyncFetchTask() {
|
|
|
|
public void asyncFetchTask() {
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> query = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> query = new HashMap<String,Object>();
|
|
|
|
String host = getNextHost();
|
|
|
|
String host = getNextHost();
|
|
|
|
if(!StringUtils.isEmpty(host)) {
|
|
|
|
if(!StringUtils.isEmpty(host)) {
|
|
|
@ -150,7 +150,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
@Async
|
|
|
@ -162,29 +162,37 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')");
|
|
|
|
dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void asyncDataTask(boolean isUpload) {
|
|
|
|
private void asyncDataTask(boolean isUpload) {
|
|
|
|
initTable();
|
|
|
|
initTable();
|
|
|
|
Map<String,Object> map = dbDao.get("select * from sync_data_set limit 1");
|
|
|
|
Map<String,Object> map = dbDao.get("select * from sync_data_set limit 1");
|
|
|
|
if(map!=null&&map.get("downstreamEnable")!=null&&map.get("downstreamEnable").toString().equals("1")) {
|
|
|
|
if(map!=null&&map.get("downstreamEnable")!=null&&map.get("downstreamEnable").toString().equals("1")) {
|
|
|
|
|
|
|
|
if(isUpload) {
|
|
|
|
|
|
|
|
if(!(map.get("syncIp")!=null&&!StringUtils.isEmpty(map.get("syncIp").toString()))) {
|
|
|
|
|
|
|
|
logger.error("中继服务地址未配置");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
for(int i=0;i<SYNC_TABLES.length;i++) {
|
|
|
|
for(int i=0;i<SYNC_TABLES.length;i++) {
|
|
|
|
String[] tnames = SYNC_TABLES[i].split("/");
|
|
|
|
String[] tnames = SYNC_TABLES[i].split("/");
|
|
|
|
saveIdcLog("---","",map.get(tnames[0])+SYNC_TABLES[i],0,0);
|
|
|
|
saveIdcLog("---","",map.get(tnames[0])+SYNC_TABLES[i],0,0);
|
|
|
|
if(!StringUtils.isEmpty(tnames[0])&&map!=null&&map.get(tnames[0])!=null&&map.get(tnames[0]).toString().equals("1"))
|
|
|
|
if(!StringUtils.isEmpty(tnames[0])&&map!=null&&map.get(tnames[0])!=null&&map.get(tnames[0]).toString().equals("1")) {
|
|
|
|
syncData(SYNC_TABLES[i],isUpload);
|
|
|
|
String syncIp = map.get("syncIp")!=null ? map.get("syncIp").toString() : "";
|
|
|
|
|
|
|
|
syncData(SYNC_TABLES[i],isUpload,syncIp);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void syncData(String t,boolean isUpload) {
|
|
|
|
private void syncData(String t,boolean isUpload,String syncIp) {
|
|
|
|
boolean sync = true;
|
|
|
|
boolean sync = true;
|
|
|
|
String[] tnames = t.split("/");
|
|
|
|
String[] tnames = t.split("/");
|
|
|
|
|
|
|
|
|
|
|
|
String lastUpdateTime = getUpdateTime(tnames[0]);
|
|
|
|
String lastUpdateTime = getUpdateTime(tnames[0]);
|
|
|
|
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>();
|
|
|
@ -195,7 +203,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
map.put("isEnd", "1");
|
|
|
|
map.put("isEnd", "1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map.put("sqlWhere", sqlWhere);
|
|
|
|
map.put("sqlWhere", sqlWhere);
|
|
|
|
|
|
|
|
|
|
|
|
map.put("tableKey", tnames[0]);
|
|
|
|
map.put("tableKey", tnames[0]);
|
|
|
|
map.put("tableName", tnames[2]);
|
|
|
|
map.put("tableName", tnames[2]);
|
|
|
|
map.put("uniqueColumn", tnames[3]);
|
|
|
|
map.put("uniqueColumn", tnames[3]);
|
|
|
@ -209,21 +217,21 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
scheduledRequest.setCronName("sync"+WordUtils.capitalizeFully(tnames[2], new char[]{'_'}).replace("_", ""));
|
|
|
|
scheduledRequest.setCronName("sync"+WordUtils.capitalizeFully(tnames[2], new char[]{'_'}).replace("_", ""));
|
|
|
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
|
|
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
|
|
|
String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "";
|
|
|
|
String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "";
|
|
|
|
|
|
|
|
|
|
|
|
if(!StringUtils.isEmpty(cron)) {
|
|
|
|
if(!StringUtils.isEmpty(cron)) {
|
|
|
|
CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron);
|
|
|
|
CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron);
|
|
|
|
Date nextTimePoint = cronSequenceGenerator.next(DateUtil.parseDate(lastUpdateTime));
|
|
|
|
Date nextTimePoint = cronSequenceGenerator.next(DateUtil.parseDate(lastUpdateTime));
|
|
|
|
sync = nextTimePoint.before(nowUpdateTime);
|
|
|
|
sync = nextTimePoint.before(nowUpdateTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(sync) {
|
|
|
|
if(sync) {
|
|
|
|
if(syncMasterData(map,isUpload)) {
|
|
|
|
if(syncMasterData(map,isUpload,syncIp)) {
|
|
|
|
setUpdateTime(tnames[2],DateUtil.formatDate(nowUpdateTime,"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
setUpdateTime(tnames[2],DateUtil.formatDate(nowUpdateTime,"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String fetchData(String url,Map<String,Object> params) {
|
|
|
|
private String fetchData(String url,Map<String,Object> params) {
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
@ -287,11 +295,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
JSONObject json = JSONObject.parseObject(content);
|
|
|
|
JSONObject json = JSONObject.parseObject(content);
|
|
|
|
|
|
|
|
|
|
|
|
String datePath = DateUtil.formatDate(new Date(),"yyyy-MM-dd");
|
|
|
|
String datePath = DateUtil.formatDate(new Date(),"yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
|
|
FileUtils.makeDirectory(filePath +datePath+"/");
|
|
|
|
|
|
|
|
FileUtils.makeDirectory(backFilePath +datePath+"/");
|
|
|
|
|
|
|
|
String fileName = filePath +datePath+"/"+json.getString("messageType")+"-"+json.getString("messageId")+".udi";
|
|
|
|
String fileName = filePath +datePath+"/"+json.getString("messageType")+"-"+json.getString("messageId")+".udi";
|
|
|
|
String backFileName = backFilePath +datePath+"/"+json.getString("messageType")+"-"+json.getString("messageId")+".udi";
|
|
|
|
String backFileName = backFilePath +datePath+"/"+json.getString("messageType")+"-"+json.getString("messageId")+".udi";
|
|
|
|
|
|
|
|
FileUtils.makeDirectory( filePath +datePath+"/");
|
|
|
|
|
|
|
|
FileUtils.makeDirectory(backFilePath +datePath+"/");
|
|
|
|
|
|
|
|
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
String[] saveFiles= {};
|
|
|
|
String[] saveFiles= {};
|
|
|
@ -317,11 +325,20 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
saveUploadStatus(json.getString("messageType"),json.getString("messageId"),fileName);
|
|
|
|
saveUploadStatus(json.getString("messageType"),json.getString("messageId"),fileName);
|
|
|
|
/*解析入库*/
|
|
|
|
/*解析入库*/
|
|
|
|
if(isLastLevel()) {
|
|
|
|
if(isLastLevel()) {
|
|
|
|
analyToDB(json,files);
|
|
|
|
if(!analyToDB(json,files))
|
|
|
|
|
|
|
|
return ResultVOUtils.error(9000, "解析失败");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
//需要转发
|
|
|
|
//需要转发
|
|
|
|
if(isRelay()) {
|
|
|
|
if(isRelay()) {
|
|
|
|
relay(request.getHeader("reqNo"),content,saveFiles);
|
|
|
|
String host = getNextHost();
|
|
|
|
|
|
|
|
String result = relay(request.getHeader("reqNo"),content,saveFiles,host);
|
|
|
|
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
|
|
|
|
BaseResponse object = JSON.parseObject(result,BaseResponse.class);
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return ResultVOUtils.error(9000, "转发失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
return ResultVOUtils.success();
|
|
|
@ -331,14 +348,14 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
/*数据同步,从数据库获取数据下发或上传下级中继服务*/
|
|
|
|
/*数据同步,从数据库获取数据下发或上传下级中继服务*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public BaseResponse send(Map<String,Object> params) {
|
|
|
|
public BaseResponse send(Map<String,Object> params) {
|
|
|
|
|
|
|
|
|
|
|
|
return send(params.get("messageType").toString(),params.get("tableName").toString(),params);
|
|
|
|
return send(params.get("messageType").toString(),params.get("tableName").toString(),params);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@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, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -356,14 +373,12 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
dbDao.save(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void saveExportStatus(String messageType,String taskId,String fileName) {
|
|
|
|
private void saveExportStatus(Map<String,Object> params) {
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
|
|
|
|
map.put("taskId", taskId);
|
|
|
|
|
|
|
|
map.put("cacheFilePath", fileName);
|
|
|
|
|
|
|
|
map.put("status", "0");
|
|
|
|
map.put("status", "0");
|
|
|
|
map.put("type", messageType);
|
|
|
|
map.putAll(params);
|
|
|
|
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
Map<String,Object> columns = getColumn("basic_export_status");
|
|
|
|
Map<String,Object> columns = getColumn("basic_export_status");
|
|
|
|
String sql = "insert into basic_export_status "+DBAUtils.parseInsert(map, columns);
|
|
|
|
String sql = "insert into basic_export_status "+DBAUtils.parseInsert(map, columns);
|
|
|
@ -398,9 +413,9 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
dbDao.save(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean syncMasterData(Map<String,Object> params,boolean isUplaod) {
|
|
|
|
private boolean syncMasterData(Map<String,Object> params,boolean isUplaod,String syncIp) {
|
|
|
|
boolean success=false;
|
|
|
|
boolean success=false;
|
|
|
|
String tableName = params.get("tableName").toString();
|
|
|
|
String tableName = params.get("tableName").toString();
|
|
|
|
String tableKey = params.get("tableKey").toString();
|
|
|
|
String tableKey = params.get("tableKey").toString();
|
|
|
@ -422,13 +437,13 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
Map<String,Object> whereParams = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> whereParams = new HashMap<String,Object>();
|
|
|
|
whereParams.put("sqlWhere", params.get("sqlWhere"));
|
|
|
|
whereParams.put("sqlWhere", params.get("sqlWhere"));
|
|
|
|
whereParams.put("dataWhere", params.get("dataWhere"));
|
|
|
|
whereParams.put("dataWhere", params.get("dataWhere"));
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
String where = DBAUtils.convertWhere(column,whereParams,"");
|
|
|
|
String where = DBAUtils.convertWhere(column,whereParams,"");
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
map.put("sql", sql);
|
|
|
|
map.put("sql", sql);
|
|
|
|
int total = dbDao.count(map);
|
|
|
|
int total = dbDao.count(map);
|
|
|
|
|
|
|
|
|
|
|
|
String isEnd = params.get("isEnd")!=null ? params.get("isEnd").toString() : "0";
|
|
|
|
String isEnd = params.get("isEnd")!=null ? params.get("isEnd").toString() : "0";
|
|
|
|
int limit = 50;
|
|
|
|
int limit = 50;
|
|
|
|
String[] files = new String[limit];
|
|
|
|
String[] files = new String[limit];
|
|
|
@ -436,14 +451,14 @@ 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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(total>0) {
|
|
|
|
if(total>0) {
|
|
|
|
success = true;
|
|
|
|
success = true;
|
|
|
|
|
|
|
|
|
|
|
|
whereParams.put("page", 0);
|
|
|
|
whereParams.put("page", 0);
|
|
|
|
whereParams.put("limit", limit);
|
|
|
|
whereParams.put("limit", limit);
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> keyList = dbDao.listKeyMysql(tableName);
|
|
|
|
List<Map<String, String>> keyList = dbDao.listKeyMysql(tableName);
|
|
|
|
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";
|
|
|
|
for(int i=0;i<Math.ceil(total/limit)+1;i++) {
|
|
|
|
for(int i=0;i<Math.ceil(total/limit)+1;i++) {
|
|
|
@ -478,13 +493,13 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
orderNum++;
|
|
|
|
orderNum++;
|
|
|
|
|
|
|
|
|
|
|
|
if(isUplaod) {
|
|
|
|
if(isUplaod) {
|
|
|
|
String result = "";
|
|
|
|
String result = "";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
result = relay("",JSON.toJSONString(data),files);
|
|
|
|
result = relay("",JSON.toJSONString(data),files,syncIp);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
@ -504,58 +519,66 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
saveIdcLog(messageType,"",tableName +">fail:上传地址未连通",i *limit,total);
|
|
|
|
saveIdcLog(messageType,"",tableName +">fail:上传地址未连通",i *limit,total);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
syncAddTask(data);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
saveIdcLog(messageType,"",tableName +">success",i *limit,total);
|
|
|
|
saveIdcLog(messageType,"",tableName +">success",i *limit,total);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
syncAddTask(data,isUplaod);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*增加同步任务*/
|
|
|
|
/*增加同步任务*/
|
|
|
|
private void syncAddTask(Map<String,Object> json) {
|
|
|
|
private void syncAddTask(Map<String,Object> json,boolean isUpload) {
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
|
String datePath = DateUtil.formatDate(new Date(),"yyyy-MM-dd");
|
|
|
|
String datePath = DateUtil.formatDate(new Date(),"yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
|
|
FileUtils.makeDirectory(filePath +datePath+"/");
|
|
|
|
|
|
|
|
FileUtils.makeDirectory(backFilePath +datePath+"/");
|
|
|
|
|
|
|
|
String fileName = filePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi";
|
|
|
|
String fileName = filePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi";
|
|
|
|
String backFileName = backFilePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi";
|
|
|
|
String backFileName = backFilePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi";
|
|
|
|
|
|
|
|
FileUtils.makeDirectory(filePath +datePath+"/");
|
|
|
|
|
|
|
|
FileUtils.makeDirectory(backFilePath +datePath+"/");
|
|
|
|
|
|
|
|
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//type,transportType,superiorService,subordinateService,cacheFilePath
|
|
|
|
saveExportStatus(json.get("messageType").toString(),json.get("messageId").toString(),fileName);
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
}
|
|
|
|
map.put("type", json.get("messageType"));
|
|
|
|
|
|
|
|
map.put("transportType", isUpload ? "1" : "2");
|
|
|
|
|
|
|
|
map.put("scheduleType", isUpload ? "1" : "0");
|
|
|
|
|
|
|
|
map.put("taskId", json.get("messageId"));
|
|
|
|
|
|
|
|
map.put("cacheFilePath", fileName);
|
|
|
|
|
|
|
|
saveExportStatus(map);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*解析到数据库*/
|
|
|
|
/*解析到数据库*/
|
|
|
|
private void analyToDB(JSONObject jsonObject,MultipartFile[] files) {
|
|
|
|
private boolean analyToDB(JSONObject jsonObject,MultipartFile[] files) {
|
|
|
|
if(!StringUtils.isEmpty(jsonObject.getString("tableName"))) {
|
|
|
|
if(!StringUtils.isEmpty(jsonObject.getString("tableName"))) {
|
|
|
|
List<Map<String,Object>> list = jsonObject.getObject("data", List.class);
|
|
|
|
List<Map<String,Object>> list = jsonObject.getObject("data", List.class);
|
|
|
|
analyData(jsonObject.getString("tableName"),jsonObject.getString("uniqueColumn"),list);
|
|
|
|
return analyData(jsonObject.getString("tableName"),jsonObject.getString("uniqueColumn"),list);
|
|
|
|
//图片处理
|
|
|
|
//图片处理
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*按表名解析数据到数据库,子表暂未处理*/
|
|
|
|
/*按表名解析数据到数据库,子表暂未处理*/
|
|
|
|
private void analyData(String tableName,String uniqueColumn,List<Map<String,Object>> list) {
|
|
|
|
private boolean analyData(String tableName,String uniqueColumn,List<Map<String,Object>> 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 ";
|
|
|
|
String upd="update "+tName+" set ";
|
|
|
|
String upd="update "+tName+" set ";
|
|
|
|
String[] keyColumn=new String[30];
|
|
|
|
String[] keyColumn=new String[30];
|
|
|
|
String[] keyDataType=new String[30];
|
|
|
|
String[] keyDataType=new String[30];
|
|
|
|
List<Map<String,String>> columnList = dbDao.listColumnsMysql(tName);
|
|
|
|
List<Map<String,String>> columnList = dbDao.listColumnsMysql(tName);
|
|
|
|
|
|
|
|
boolean result = false;
|
|
|
|
int key=0;
|
|
|
|
int key=0;
|
|
|
|
int col=0;
|
|
|
|
int col=0;
|
|
|
|
for(int i=0;i<columnList.size();i++) {
|
|
|
|
for(int i=0;i<columnList.size();i++) {
|
|
|
@ -595,7 +618,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
updateWhere+=keyColumn[z]+" = "+(keyDataType[z].equals("C") ? "'" :"") +value +(keyDataType[z].equals("C") ? "'" :"");
|
|
|
|
updateWhere+=keyColumn[z]+" = "+(keyDataType[z].equals("C") ? "'" :"") +value +(keyDataType[z].equals("C") ? "'" :"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if("A,D".contains(operateMode)&&!StringUtils.isEmpty(updateWhere))
|
|
|
|
if("A,D".contains(operateMode)&&!StringUtils.isEmpty(updateWhere))
|
|
|
|
dbDao.delete(del+updateWhere);
|
|
|
|
dbDao.delete(del+updateWhere);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -612,7 +635,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
value = DBAUtils.escape(value);
|
|
|
|
value = DBAUtils.escape(value);
|
|
|
|
String dataType = columnList.get(k).get("dataType").toLowerCase().contains("char") || columnList.get(k).get("dataType").toLowerCase().contains("text") ?
|
|
|
|
String dataType = columnList.get(k).get("dataType").toLowerCase().contains("char") || columnList.get(k).get("dataType").toLowerCase().contains("text") ?
|
|
|
|
"C" : columnList.get(k).get("dataType").toLowerCase().contains("date") ? "D" : "N" ;
|
|
|
|
"C" : columnList.get(k).get("dataType").toLowerCase().contains("date") ? "D" : "N" ;
|
|
|
|
|
|
|
|
|
|
|
|
sql+=m>0 ? "," : "";
|
|
|
|
sql+=m>0 ? "," : "";
|
|
|
|
boolean ups = list.get(i).containsKey(attrName) ? true : false ;
|
|
|
|
boolean ups = list.get(i).containsKey(attrName) ? true : false ;
|
|
|
|
updateSet+=ups&&h>0 ? "," : "";
|
|
|
|
updateSet+=ups&&h>0 ? "," : "";
|
|
|
@ -640,11 +663,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
dbDao.update(upd + updateSet+" where "+updateWhere);
|
|
|
|
dbDao.update(upd + updateSet+" where "+updateWhere);
|
|
|
|
h+=ups ? 1 : 0;
|
|
|
|
h+=ups ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sql+=")";
|
|
|
|
sql+=")";
|
|
|
|
n++;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(int m=0;m<30;m++) {
|
|
|
|
for(int m=0;m<30;m++) {
|
|
|
|
if(list.get(i).get("tableName"+m)!=null&&list.get(i).get("data"+m)!=null) {
|
|
|
|
if(list.get(i).get("tableName"+m)!=null&&list.get(i).get("data"+m)!=null) {
|
|
|
|
Object obj = list.get(i).get("data"+m);
|
|
|
|
Object obj = list.get(i).get("data"+m);
|
|
|
@ -657,19 +680,20 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(n>0) {
|
|
|
|
|
|
|
|
result = (dbDao.save(sql)>0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(n>0)
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*转发下级或上级中继服务*/
|
|
|
|
/*转发下级或上级中继服务*/
|
|
|
|
private String relay(String reqNo,String content,String[] files) {
|
|
|
|
private String relay(String reqNo,String content,String[] files,String ip) {
|
|
|
|
String host = getNextHost();
|
|
|
|
String host = ip;
|
|
|
|
String result="";
|
|
|
|
String result="";
|
|
|
|
if(StringUtils.isEmpty(reqNo))
|
|
|
|
if(StringUtils.isEmpty(reqNo))
|
|
|
|
reqNo = UUID.randomUUID().toString();
|
|
|
|
reqNo = UUID.randomUUID().toString();
|
|
|
@ -733,18 +757,18 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
Map<String,Object> map = dbDao.get("select * from idc_var where code='system_type'");
|
|
|
|
Map<String,Object> map = dbDao.get("select * from idc_var where code='system_type'");
|
|
|
|
return !(map!=null&&map.get("content")!=null&&map.get("content").toString().equals("IDC")) ;
|
|
|
|
return !(map!=null&&map.get("content")!=null&&map.get("content").toString().equals("IDC")) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*是否需要转发*/
|
|
|
|
/*是否需要转发*/
|
|
|
|
private boolean isRelay() {
|
|
|
|
private boolean isRelay() {
|
|
|
|
String relayHost = getNextHost();
|
|
|
|
String relayHost = getNextHost();
|
|
|
|
return !StringUtils.isEmpty(relayHost);
|
|
|
|
return StringUtils.isEmpty(relayHost) ? false : true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Map<String,Object>> getList(String tableName,Map<String,Object> params) {
|
|
|
|
private List<Map<String,Object>> getList(String tableName,Map<String,Object> params) {
|
|
|
|
String sql = "select "+tableName+".*,'A' as operateMode from "+tableName;
|
|
|
|
String sql = "select "+tableName+".*,'A' as operateMode from "+tableName;
|
|
|
|
Map<String,Object> column = getColumn(tableName);
|
|
|
|
Map<String,Object> column = getColumn(tableName);
|
|
|
|
|
|
|
|
|
|
|
|
String where = DBAUtils.convertWhere(column,params,"");
|
|
|
|
String where = DBAUtils.convertWhere(column,params,"");
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
@ -762,6 +786,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
map.put("apiCode", "common");
|
|
|
|
map.put("apiCode", "common");
|
|
|
|
map.put("tableName", DBAUtils.tableAliasName(tableName));
|
|
|
|
map.put("tableName", DBAUtils.tableAliasName(tableName));
|
|
|
|
map.put("uniqueColumn", params.get("uniqueColumn"));
|
|
|
|
map.put("uniqueColumn", params.get("uniqueColumn"));
|
|
|
|
|
|
|
|
map.put("filePathColumn", params.get("filePathColumn"));
|
|
|
|
map.put("sendTime", new Date());
|
|
|
|
map.put("sendTime", new Date());
|
|
|
|
map.put("version", "1.0");
|
|
|
|
map.put("version", "1.0");
|
|
|
|
map.put("total", list.size());
|
|
|
|
map.put("total", list.size());
|
|
|
@ -870,7 +895,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
jdbcTemplate.execute("alter table basic_export_status add column cacheFilePath varchar(255)");
|
|
|
|
jdbcTemplate.execute("alter table basic_export_status add column cacheFilePath varchar(255)");
|
|
|
|
jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)");
|
|
|
|
jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)");
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void alterTable(String tableName,String sql) {
|
|
|
|
private void alterTable(String tableName,String sql) {
|
|
|
@ -880,4 +905,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|