|
|
|
@ -79,7 +79,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
"//sup_cert_set/id///updateTime///供应商资质证书设置","companyCert//sup_company/customerId///updateTime///配送企业",
|
|
|
|
|
"manufacturerCert//sup_manufacturer/id///updateTime///生产企业","productCert//sup_product/id///updateTime///产品资质信息",
|
|
|
|
|
"dbDiProducts//productinfo/id///updateTime///DI产品信息","//udicompany/id///updateTime///国际库医疗器械注册人信息"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int orderNum=0;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@ -102,6 +102,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
return ResultVOUtils.success(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
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")+"'");
|
|
|
|
@ -112,7 +113,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
return ResultVOUtils.success(object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*UDI系统上传自助平台*/
|
|
|
|
|
@Override
|
|
|
|
|
public void asyncUdiTask() {
|
|
|
|
@ -125,12 +126,12 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
logger.info("自助平台同步任务开始--------");
|
|
|
|
|
asyncDataTask(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*拉取前一级中继服务数据*/
|
|
|
|
|
@Async
|
|
|
|
|
@Override
|
|
|
|
|
public void asyncFetchTask() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> query = new HashMap<String,Object>();
|
|
|
|
|
String host = getNextHost();
|
|
|
|
|
if(!StringUtils.isEmpty(host)) {
|
|
|
|
@ -149,7 +150,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
@ -161,7 +162,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void asyncDataTask(boolean isUpload) {
|
|
|
|
|
initTable();
|
|
|
|
@ -175,15 +176,15 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void syncData(String t,boolean isUpload) {
|
|
|
|
|
boolean sync = true;
|
|
|
|
|
String[] tnames = t.split("/");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String lastUpdateTime = getUpdateTime(tnames[0]);
|
|
|
|
|
Date nowUpdateTime = new Date();
|
|
|
|
|
if(!StringUtils.isEmpty(tnames[0])) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> keyList = dbDao.listKeyMysql(tnames[2]);
|
|
|
|
|
String keyColumn = keyList!=null&&keyList.size()>0 ? keyList.get(0).get("columnName").toString() : "id";
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
@ -194,7 +195,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
map.put("isEnd", "1");
|
|
|
|
|
}
|
|
|
|
|
map.put("sqlWhere", sqlWhere);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.put("tableKey", tnames[0]);
|
|
|
|
|
map.put("tableName", tnames[2]);
|
|
|
|
|
map.put("uniqueColumn", tnames[3]);
|
|
|
|
@ -208,7 +209,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
scheduledRequest.setCronName("sync"+WordUtils.capitalizeFully(tnames[2], new char[]{'_'}).replace("_", ""));
|
|
|
|
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
|
|
|
|
String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!StringUtils.isEmpty(cron)) {
|
|
|
|
|
CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron);
|
|
|
|
|
Date nextTimePoint = cronSequenceGenerator.next(DateUtil.parseDate(lastUpdateTime));
|
|
|
|
@ -221,8 +222,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String fetchData(String url,Map<String,Object> params) {
|
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
@ -330,14 +331,14 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
/*数据同步,从数据库获取数据下发或上传下级中继服务*/
|
|
|
|
|
@Override
|
|
|
|
|
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
|
|
|
|
|
public BaseResponse send(String messageType,String tableName,Map<String,Object> params) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResultVOUtils.error(9999, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -355,7 +356,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void saveExportStatus(String messageType,String taskId,String fileName) {
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
@ -397,8 +398,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean syncMasterData(Map<String,Object> params,boolean isUplaod) {
|
|
|
|
|
boolean success=false;
|
|
|
|
|
String tableName = params.get("tableName").toString();
|
|
|
|
@ -421,13 +422,13 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
Map<String,Object> whereParams = new HashMap<String,Object>();
|
|
|
|
|
whereParams.put("sqlWhere", params.get("sqlWhere"));
|
|
|
|
|
whereParams.put("dataWhere", params.get("dataWhere"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String where = DBAUtils.convertWhere(column,whereParams,"");
|
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
|
map.put("sql", sql);
|
|
|
|
|
int total = dbDao.count(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String isEnd = params.get("isEnd")!=null ? params.get("isEnd").toString() : "0";
|
|
|
|
|
int limit = 50;
|
|
|
|
|
String[] files = new String[limit];
|
|
|
|
@ -435,14 +436,14 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
orderNum++;
|
|
|
|
|
String messageType = params.get("messageType").toString();
|
|
|
|
|
saveIdcLog(messageType,"",tableName +">"+where,0,total);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(total>0) {
|
|
|
|
|
success = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
whereParams.put("page", 0);
|
|
|
|
|
whereParams.put("limit", limit);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> keyList = dbDao.listKeyMysql(tableName);
|
|
|
|
|
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++) {
|
|
|
|
@ -477,13 +478,13 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
orderNum++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isUplaod) {
|
|
|
|
|
String result = "";
|
|
|
|
|
try {
|
|
|
|
|
result = relay("",JSON.toJSONString(data),files);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
|
@ -512,12 +513,12 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*增加同步任务*/
|
|
|
|
|
private void syncAddTask(Map<String,Object> json) {
|
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
|
@ -529,12 +530,12 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
String backFileName = backFilePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi";
|
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveExportStatus(json.get("messageType").toString(),json.get("messageId").toString(),fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*解析到数据库*/
|
|
|
|
|
private void analyToDB(JSONObject jsonObject,MultipartFile[] files) {
|
|
|
|
@ -594,7 +595,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
updateWhere+=keyColumn[z]+" = "+(keyDataType[z].equals("C") ? "'" :"") +value +(keyDataType[z].equals("C") ? "'" :"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if("A,D".contains(operateMode)&&!StringUtils.isEmpty(updateWhere))
|
|
|
|
|
dbDao.delete(del+updateWhere);
|
|
|
|
|
}
|
|
|
|
@ -611,7 +612,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
value = DBAUtils.escape(value);
|
|
|
|
|
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" ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql+=m>0 ? "," : "";
|
|
|
|
|
boolean ups = list.get(i).containsKey(attrName) ? true : false ;
|
|
|
|
|
updateSet+=ups&&h>0 ? "," : "";
|
|
|
|
@ -639,11 +640,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
dbDao.update(upd + updateSet+" where "+updateWhere);
|
|
|
|
|
h+=ups ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql+=")";
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int m=0;m<30;m++) {
|
|
|
|
|
if(list.get(i).get("tableName"+m)!=null&&list.get(i).get("data"+m)!=null) {
|
|
|
|
|
Object obj = list.get(i).get("data"+m);
|
|
|
|
@ -656,7 +657,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(n>0)
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
@ -732,7 +733,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
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")) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*是否需要转发*/
|
|
|
|
|
private boolean isRelay() {
|
|
|
|
|
String relayHost = getNextHost();
|
|
|
|
@ -743,7 +744,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
private List<Map<String,Object>> getList(String tableName,Map<String,Object> params) {
|
|
|
|
|
String sql = "select "+tableName+".*,'A' as operateMode from "+tableName;
|
|
|
|
|
Map<String,Object> column = getColumn(tableName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String where = DBAUtils.convertWhere(column,params,"");
|
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
@ -869,7 +870,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
jdbcTemplate.execute("alter table basic_export_status add column cacheFilePath varchar(255)");
|
|
|
|
|
jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void alterTable(String tableName,String sql) {
|
|
|
|
|