|  |  |  | @ -116,9 +116,13 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 		Map<String,Object> map = dbDao.get("select * from basic_export_status where id='"+params.get("taskId")+"'"); | 
			
		
	
		
			
				
					|  |  |  |  | 		if(map==null) | 
			
		
	
		
			
				
					|  |  |  |  | 			ResultVOUtils.error(9000, "下载任务不存在"); | 
			
		
	
		
			
				
					|  |  |  |  | 		if(!FileUtils.isFileExist(map.get("cacheFilePath").toString())) | 
			
		
	
		
			
				
					|  |  |  |  | 			ResultVOUtils.error(9000, "下载文件不存在"); | 
			
		
	
		
			
				
					|  |  |  |  | 		String json = FileUtils.readFileAll(map.get("cacheFilePath").toString()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		 | 
			
		
	
		
			
				
					|  |  |  |  | 		JSONObject object = JSON.parseObject(json); | 
			
		
	
		
			
				
					|  |  |  |  | 		if(object==null) | 
			
		
	
		
			
				
					|  |  |  |  | 			ResultVOUtils.error(9000, "任务下载失败"); | 
			
		
	
		
			
				
					|  |  |  |  | 		if(object!=null&&object.getInteger("code")!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 			BaseResponse response = JSON.parseObject(json,BaseResponse.class); | 
			
		
	
		
			
				
					|  |  |  |  | 			return response; | 
			
		
	
	
		
			
				
					|  |  |  | @ -147,14 +151,20 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 	public void asyncFetchUdiTask() { | 
			
		
	
		
			
				
					|  |  |  |  | 		fetchTask(false); | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	@Async | 
			
		
	
		
			
				
					|  |  |  |  | 	@Async  | 
			
		
	
		
			
				
					|  |  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  |  | 	public void asyncFetchTask() { | 
			
		
	
		
			
				
					|  |  |  |  | 		initTable(); | 
			
		
	
		
			
				
					|  |  |  |  | 		Map<String,Object> map = dbDao.get("select * from idc_var where code='system_type'"); | 
			
		
	
		
			
				
					|  |  |  |  | 		if(map==null) { | 
			
		
	
		
			
				
					|  |  |  |  | 			dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')"); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		fetchTask(true); | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	private void fetchTask(boolean isIdc) { | 
			
		
	
		
			
				
					|  |  |  |  | 		 | 
			
		
	
		
			
				
					|  |  |  |  | 		String host = getNextHost(); | 
			
		
	
		
			
				
					|  |  |  |  | 		if(!isIdc) { | 
			
		
	
		
			
				
					|  |  |  |  | 			Map<String,Object> map = dbDao.get("select * from sync_data_set limit 1"); | 
			
		
	
	
		
			
				
					|  |  |  | @ -284,22 +294,20 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 			JSONObject json = JSONObject.parseObject(result); | 
			
		
	
		
			
				
					|  |  |  |  | 			 | 
			
		
	
		
			
				
					|  |  |  |  | 			if(isLastLevel()) { | 
			
		
	
		
			
				
					|  |  |  |  | 				if(json.get("code")!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 				if(json.get("code")!=null&&json.getInteger("code")==2000) { | 
			
		
	
		
			
				
					|  |  |  |  | 					success = analyMiddle(host,json.getJSONObject("data"),files,false,true); | 
			
		
	
		
			
				
					|  |  |  |  | 					if(!success) | 
			
		
	
		
			
				
					|  |  |  |  | 						logger.info("fetchData-->解析失败"); | 
			
		
	
		
			
				
					|  |  |  |  | 				} else { | 
			
		
	
		
			
				
					|  |  |  |  | 					success = analyMiddle(host,json,files,false,true); | 
			
		
	
		
			
				
					|  |  |  |  | 					success = false; | 
			
		
	
		
			
				
					|  |  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  |  | 				if(!success) | 
			
		
	
		
			
				
					|  |  |  |  | 					logger.info("fetchData-->解析失败"); | 
			
		
	
		
			
				
					|  |  |  |  | 				 | 
			
		
	
		
			
				
					|  |  |  |  | 			} else { | 
			
		
	
		
			
				
					|  |  |  |  | 				if(json.get("code")!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 					 | 
			
		
	
		
			
				
					|  |  |  |  | 				if(json.get("code")!=null&&json.get("data")!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 					logger.info("res1-->"+JSON.toJSONString(json)); | 
			
		
	
		
			
				
					|  |  |  |  | 					syncAddTaskStatus(json.getJSONObject("data"),false,success); | 
			
		
	
		
			
				
					|  |  |  |  | 					analyMiddle(host,json.getJSONObject("data"),files,false,false); | 
			
		
	
		
			
				
					|  |  |  |  | 				} else { | 
			
		
	
		
			
				
					|  |  |  |  | 					syncAddTaskStatus(json,false,success); | 
			
		
	
		
			
				
					|  |  |  |  | 					analyMiddle(host,json,files,false,false); | 
			
		
	
		
			
				
					|  |  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  |  | 				}  | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 			 | 
			
		
	
		
			
				
					|  |  |  |  | 			if(success) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -425,10 +433,12 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 		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 { | 
			
		
	
		
			
				
					|  |  |  |  | 			if(FileUtils.isFileExist(filePath+filePathSlash+fileName)) { | 
			
		
	
		
			
				
					|  |  |  |  | 				byte[] bytes = FileUtils.readFileByBytes(filePath+filePathSlash+fileName); | 
			
		
	
	
		
			
				
					|  |  |  | @ -554,8 +564,14 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 					List<Map> list = JSONObject.parseArray(JSON.toJSONString(data.get("data")), Map.class); | 
			
		
	
		
			
				
					|  |  |  |  | 					if(list!=null&&list.size()>0) { | 
			
		
	
		
			
				
					|  |  |  |  | 						for(int m=0;m<list.size();m++) { | 
			
		
	
		
			
				
					|  |  |  |  | 							 | 
			
		
	
		
			
				
					|  |  |  |  | 							if(!StringUtils.isEmpty(filePathColumn)&&list.get(m).get(filePathColumn)!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 								files.add(filePath+filePathSlash+"register/file/image2/"+list.get(m).get(filePathColumn).toString()); | 
			
		
	
		
			
				
					|  |  |  |  | 								String fileNames = list.get(m).get(filePathColumn).toString(); | 
			
		
	
		
			
				
					|  |  |  |  | 								String[] str = fileNames.split(","); | 
			
		
	
		
			
				
					|  |  |  |  | 								for(int r=0;r<str.length;r++) { | 
			
		
	
		
			
				
					|  |  |  |  | 									if(!StringUtils.isEmpty(str[r])) | 
			
		
	
		
			
				
					|  |  |  |  | 										files.add(filePath+filePathSlash+"register/file/image2/"+str[r]); | 
			
		
	
		
			
				
					|  |  |  |  | 								} | 
			
		
	
		
			
				
					|  |  |  |  | 							} | 
			
		
	
		
			
				
					|  |  |  |  | 							recordSql+=!StringUtils.isEmpty(recordSql) ? "," : ""; | 
			
		
	
		
			
				
					|  |  |  |  | 							recordSql+="('"+UUID.randomUUID().toString().replaceAll("-", "")+"','"+tableName+"','"+list.get(m).get(keyColumn)+"','"+isEnd+"',now())"; | 
			
		
	
	
		
			
				
					|  |  |  | @ -573,7 +589,10 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 										if(!StringUtils.isEmpty(chidTnames[7])&&childList.size()>0) { | 
			
		
	
		
			
				
					|  |  |  |  | 											for(int x=0;x<childList.size();x++) { | 
			
		
	
		
			
				
					|  |  |  |  | 												if(childList.get(i).get(chidTnames[7])!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 													files.add(filePath+filePathSlash+"register/file/image2/"+childList.get(i).get(chidTnames[7])); | 
			
		
	
		
			
				
					|  |  |  |  | 													String[] str = childList.get(i).get(chidTnames[7]).toString().split(","); | 
			
		
	
		
			
				
					|  |  |  |  | 													for(int s=0;s<str.length;s++) { | 
			
		
	
		
			
				
					|  |  |  |  | 														files.add(filePath+filePathSlash+"register/file/image2/"+str[s]); | 
			
		
	
		
			
				
					|  |  |  |  | 													} | 
			
		
	
		
			
				
					|  |  |  |  | 												} | 
			
		
	
		
			
				
					|  |  |  |  | 											} | 
			
		
	
		
			
				
					|  |  |  |  | 										} | 
			
		
	
	
		
			
				
					|  |  |  | @ -626,28 +645,33 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	/*增加同步任务状态*/ | 
			
		
	
		
			
				
					|  |  |  |  | 	private void syncAddTaskStatus(Map<String,Object> json,boolean isUpload,boolean success) { | 
			
		
	
		
			
				
					|  |  |  |  | 		String content = JSON.toJSONString(json); | 
			
		
	
		
			
				
					|  |  |  |  | 		String datePath = DateUtil.formatDate(new Date(),"yyyy-MM-dd"); | 
			
		
	
		
			
				
					|  |  |  |  | 		String fileName = filePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi"; | 
			
		
	
		
			
				
					|  |  |  |  | 		String backFileName = backFilePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi"; | 
			
		
	
		
			
				
					|  |  |  |  | 		if(!FileUtils.makeDirectory( filePath +datePath)) | 
			
		
	
		
			
				
					|  |  |  |  | 			IDCUtils.createDirectory(filePath +datePath+"/"); | 
			
		
	
		
			
				
					|  |  |  |  | 		if(!FileUtils.makeDirectory(backFilePath +datePath)) | 
			
		
	
		
			
				
					|  |  |  |  | 			IDCUtils.createDirectory(filePath +datePath+"/"); | 
			
		
	
		
			
				
					|  |  |  |  | 		 | 
			
		
	
		
			
				
					|  |  |  |  | 		FileUtils.SaveFileAs(content, fileName); | 
			
		
	
		
			
				
					|  |  |  |  |         FileUtils.SaveFileAs(content, backFileName); | 
			
		
	
		
			
				
					|  |  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |  |         //type,transportType,superiorService,subordinateService,cacheFilePath
 | 
			
		
	
		
			
				
					|  |  |  |  |         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); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("status", success ? "1" : "0"); | 
			
		
	
		
			
				
					|  |  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |  |         saveExportStatus(map); | 
			
		
	
		
			
				
					|  |  |  |  | 		try | 
			
		
	
		
			
				
					|  |  |  |  | 		{ | 
			
		
	
		
			
				
					|  |  |  |  | 			String content = JSON.toJSONString(json); | 
			
		
	
		
			
				
					|  |  |  |  | 			String datePath = DateUtil.formatDate(new Date(),"yyyy-MM-dd"); | 
			
		
	
		
			
				
					|  |  |  |  | 			String fileName = filePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi"; | 
			
		
	
		
			
				
					|  |  |  |  | 			String backFileName = backFilePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi"; | 
			
		
	
		
			
				
					|  |  |  |  | 			if(!FileUtils.makeDirectory( filePath +datePath)) | 
			
		
	
		
			
				
					|  |  |  |  | 				IDCUtils.createDirectory(filePath +datePath+"/"); | 
			
		
	
		
			
				
					|  |  |  |  | 			if(!FileUtils.makeDirectory(backFilePath +datePath)) | 
			
		
	
		
			
				
					|  |  |  |  | 				IDCUtils.createDirectory(filePath +datePath+"/"); | 
			
		
	
		
			
				
					|  |  |  |  | 			 | 
			
		
	
		
			
				
					|  |  |  |  | 			FileUtils.SaveFileAs(content, fileName); | 
			
		
	
		
			
				
					|  |  |  |  | 	        FileUtils.SaveFileAs(content, backFileName); | 
			
		
	
		
			
				
					|  |  |  |  | 	         | 
			
		
	
		
			
				
					|  |  |  |  | 	        //type,transportType,superiorService,subordinateService,cacheFilePath
 | 
			
		
	
		
			
				
					|  |  |  |  | 	        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); | 
			
		
	
		
			
				
					|  |  |  |  | 	        map.put("status", success ? "1" : "0"); | 
			
		
	
		
			
				
					|  |  |  |  | 	         | 
			
		
	
		
			
				
					|  |  |  |  | 	        saveExportStatus(map); | 
			
		
	
		
			
				
					|  |  |  |  | 		} catch (Exception ex) { | 
			
		
	
		
			
				
					|  |  |  |  | 			logger.error(ex.getMessage()); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
	
		
			
				
					|  |  |  | @ -698,7 +722,7 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 				for(int z=0;z<30;z++) { | 
			
		
	
		
			
				
					|  |  |  |  | 					if(list.get(i).get("data"+z)!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 						if(list.get(i).get("filePathColumn"+z)!=null) { | 
			
		
	
		
			
				
					|  |  |  |  | 							List<Map<String,Object>> childList = (ArrayList<Map<String,Object>>)list.get(i).get("data"+z); | 
			
		
	
		
			
				
					|  |  |  |  | 							List<Map<String,Object>> childList = (List<Map<String,Object>>)list.get(i).get("data"+z); | 
			
		
	
		
			
				
					|  |  |  |  | 							analyToFile(host,list.get(i).get("filePathColumn"+z).toString(),childList); | 
			
		
	
		
			
				
					|  |  |  |  | 						} | 
			
		
	
		
			
				
					|  |  |  |  | 					} else { | 
			
		
	
	
		
			
				
					|  |  |  | @ -903,29 +927,34 @@ public class IdcServiceImpl implements IdcService { | 
			
		
	
		
			
				
					|  |  |  |  | 		boolean success = true; | 
			
		
	
		
			
				
					|  |  |  |  | 		for(String fileName:files) { | 
			
		
	
		
			
				
					|  |  |  |  | 			if(!StringUtils.isEmpty(fileName)) { | 
			
		
	
		
			
				
					|  |  |  |  | 				if(!signleDownloadFile(syncIp,fileName)) | 
			
		
	
		
			
				
					|  |  |  |  | 					success = false; | 
			
		
	
		
			
				
					|  |  |  |  | 				String[] str = fileName.split(","); | 
			
		
	
		
			
				
					|  |  |  |  | 				for(int i=0;i<str.length;i++) { | 
			
		
	
		
			
				
					|  |  |  |  | 					if(!StringUtils.isEmpty(str[i])) { | 
			
		
	
		
			
				
					|  |  |  |  | 						logger.info("downloadFile-->"+str[i]); | 
			
		
	
		
			
				
					|  |  |  |  | 						if(!signleDownloadFile(syncIp,str[i])) | 
			
		
	
		
			
				
					|  |  |  |  | 							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(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		OkHttpClient client = new OkHttpClient().newBuilder() | 
			
		
	
		
			
				
					|  |  |  |  | 				  .build();; | 
			
		
	
		
			
				
					|  |  |  |  | 		MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); | 
			
		
	
		
			
				
					|  |  |  |  | 		 | 
			
		
	
		
			
				
					|  |  |  |  | 		RequestBody body = RequestBody.create(mediaType, "fileName="+fileName); | 
			
		
	
		
			
				
					|  |  |  |  | 				 | 
			
		
	
		
			
				
					|  |  |  |  | 		Request request = new Request.Builder() | 
			
		
	
		
			
				
					|  |  |  |  | 				.url(syncIp+"/spssync/common/downloadFile") | 
			
		
	
		
			
				
					|  |  |  |  | 				.post(requestBody) | 
			
		
	
		
			
				
					|  |  |  |  | 				.post(body) | 
			
		
	
		
			
				
					|  |  |  |  | 				.addHeader("Content-Type", "application/x-www-form-urlencoded") | 
			
		
	
		
			
				
					|  |  |  |  | 				.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("/") ? "" : "/"; | 
			
		
	
	
		
			
				
					|  |  |  | 
 |