|  |  |  | @ -19,10 +19,12 @@ import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.web.multipart.MultipartFile; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  |  | import com.alibaba.fastjson.JSONObject; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.dao.idc.DbDao; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.idc.service.FileService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.idc.service.IdcService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.idc.utils.IDCUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.util.FileUtils; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -47,6 +49,8 @@ public class FileServiceImpl implements FileService { | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private DbDao dbDao; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private IdcService idcService; | 
			
		
	
		
			
				
					|  |  |  |  |     private String imagePath = "register/file/image2/"; | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse fileUpload(HttpServletRequest request,Map<String,Object> params) { | 
			
		
	
	
		
			
				
					|  |  |  | @ -83,9 +87,10 @@ public class FileServiceImpl implements FileService { | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if(!isExists) | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(9999,"文件不存在"); | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(9999,filePath + filePathSlash + imagePath + strs[0]); | 
			
		
	
		
			
				
					|  |  |  |  |             String result = relayFile(files,host); | 
			
		
	
		
			
				
					|  |  |  |  |             if (IDCUtils.isJson(result)&&!result.contains("<html")) { | 
			
		
	
		
			
				
					|  |  |  |  |             logger.error(result); | 
			
		
	
		
			
				
					|  |  |  |  |             if (IDCUtils.isJson(result)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 BaseResponse baseResponse = JSON.parseObject(result,BaseResponse.class); | 
			
		
	
		
			
				
					|  |  |  |  |                 return baseResponse; | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
	
		
			
				
					|  |  |  | @ -93,6 +98,19 @@ public class FileServiceImpl implements FileService { | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.error(9999,"失败"); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse fileDownload(HttpServletRequest request,Map<String,Object> params) { | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, Object> map = dbDao.get("select * from sync_data_set limit 1"); | 
			
		
	
		
			
				
					|  |  |  |  |         if(map!=null&&map.get("syncIp")!=null) { | 
			
		
	
		
			
				
					|  |  |  |  |             String result = IDCUtils.post(map.get("syncIp").toString()+"/spssync/file/downloadFile", params); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.error(9999,"中继服务地址未配置,请至同步设置中进行配置"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(null); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse receiveFile(HttpServletRequest request,String content,MultipartFile[] files) { | 
			
		
	
		
			
				
					|  |  |  |  |         boolean isRelay = false; | 
			
		
	
	
		
			
				
					|  |  |  | @ -111,7 +129,6 @@ public class FileServiceImpl implements FileService { | 
			
		
	
		
			
				
					|  |  |  |  |         ArrayList<String> saveFiles = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         Date startTime = new Date(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (files != null) { | 
			
		
	
		
			
				
					|  |  |  |  |             logger.debug(filePath + filePathSlash + imagePath); | 
			
		
	
		
			
				
					|  |  |  |  |             if(!FileUtils.makeDirectory(filePath + filePathSlash + imagePath)) | 
			
		
	
		
			
				
					|  |  |  |  |                 IDCUtils.createDirectory(filePath + filePathSlash + imagePath); | 
			
		
	
		
			
				
					|  |  |  |  |             try { | 
			
		
	
	
		
			
				
					|  |  |  | @ -132,10 +149,11 @@ public class FileServiceImpl implements FileService { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if(isRelay) { | 
			
		
	
		
			
				
					|  |  |  |  |             String result = relayFile(saveFiles,host); | 
			
		
	
		
			
				
					|  |  |  |  |             logger.info(result); | 
			
		
	
		
			
				
					|  |  |  |  |             if (IDCUtils.isJson(result)&&!result.contains("<html")) { | 
			
		
	
		
			
				
					|  |  |  |  |                 BaseResponse baseResponse = JSON.parseObject(result,BaseResponse.class); | 
			
		
	
		
			
				
					|  |  |  |  |                 return baseResponse; | 
			
		
	
		
			
				
					|  |  |  |  |             }else { | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 return ResultVOUtils.error(9999,"上传失败"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  |  | @ -197,4 +215,34 @@ public class FileServiceImpl implements FileService { | 
			
		
	
		
			
				
					|  |  |  |  |         return result; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse downloadFile(HttpServletRequest request,Map<String,Object> params) { | 
			
		
	
		
			
				
					|  |  |  |  |         String host = ""; | 
			
		
	
		
			
				
					|  |  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |  |             Map<String,Object> config =dbDao.get("select paramValue from system_param_config where paramKey='upper_server_ip'"); | 
			
		
	
		
			
				
					|  |  |  |  |             if(config!=null&&config.get("paramValue")!=null) | 
			
		
	
		
			
				
					|  |  |  |  |                 host = config.get("paramValue").toString(); | 
			
		
	
		
			
				
					|  |  |  |  |         } catch (Exception ex) { | 
			
		
	
		
			
				
					|  |  |  |  |              | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         if(!StringUtils.isEmpty(host)) { | 
			
		
	
		
			
				
					|  |  |  |  |             String result = IDCUtils.post(host+"/spssync/file/downloadFile", params);  | 
			
		
	
		
			
				
					|  |  |  |  |             JSONObject object = JSON.parseObject(result); | 
			
		
	
		
			
				
					|  |  |  |  |             boolean success = false; | 
			
		
	
		
			
				
					|  |  |  |  |             if(object.getInteger("code")==20000) { | 
			
		
	
		
			
				
					|  |  |  |  |                 String[] files = params.get("fileName").toString().split(","); | 
			
		
	
		
			
				
					|  |  |  |  |                 success = true; | 
			
		
	
		
			
				
					|  |  |  |  |                 for(String str:files) { | 
			
		
	
		
			
				
					|  |  |  |  |                     if(!idcService.signleDownloadFile(host, str)) | 
			
		
	
		
			
				
					|  |  |  |  |                         success = false; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             if(!success) | 
			
		
	
		
			
				
					|  |  |  |  |                 ResultVOUtils.error(9999,"失败");    | 
			
		
	
		
			
				
					|  |  |  |  |          | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return ResultVOUtils.success(null);  | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |      | 
			
		
	
		
			
				
					|  |  |  |  | } |