| 
															
																@ -2,6 +2,7 @@ package com.yihu.ehr.iot.controller.common; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.fasterxml.jackson.databind.node.ObjectNode; 
															 | 
															
															 | 
															
																import com.fasterxml.jackson.databind.node.ObjectNode; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.base.fastdfs.FastDFSHelper; 
															 | 
															
															 | 
															
																import com.yihu.base.fastdfs.FastDFSHelper; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.yihu.ehr.iot.service.common.FileUploadService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.restmodel.common.Envelop; 
															 | 
															
															 | 
															
																import com.yihu.jw.restmodel.common.Envelop; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.restmodel.iot.common.UploadVO; 
															 | 
															
															 | 
															
																import com.yihu.jw.restmodel.iot.common.UploadVO; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import com.yihu.jw.rm.iot.IotRequestMapping; 
															 | 
															
															 | 
															
																import com.yihu.jw.rm.iot.IotRequestMapping; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -13,11 +14,13 @@ import org.springframework.beans.factory.annotation.Autowired; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.springframework.beans.factory.annotation.Value; 
															 | 
															
															 | 
															
																import org.springframework.beans.factory.annotation.Value; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.springframework.web.bind.annotation.*; 
															 | 
															
															 | 
															
																import org.springframework.web.bind.annotation.*; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.springframework.web.multipart.MultipartFile; 
															 | 
															
															 | 
															
																import org.springframework.web.multipart.MultipartFile; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import org.springframework.web.multipart.MultipartHttpServletRequest; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import java.io.ByteArrayInputStream; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import java.io.InputStream; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import javax.servlet.http.HttpServletRequest; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import java.io.*; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import java.net.URLDecoder; 
															 | 
															
															 | 
															
																import java.net.URLDecoder; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import java.util.Base64; 
															 | 
															
															 | 
															
																import java.util.Base64; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import java.util.Map; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																/** 
															 | 
															
															 | 
															
																/** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 * @author yeshijie on 2017/12/7. 
															 | 
															
															 | 
															
																 * @author yeshijie on 2017/12/7. 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -31,6 +34,10 @@ public class FileUploadController extends BaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    private FastDFSHelper fastDFSHelper; 
															 | 
															
															 | 
															
																    private FastDFSHelper fastDFSHelper; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @Value("${fast-dfs.public-server}") 
															 | 
															
															 | 
															
																    @Value("${fast-dfs.public-server}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    private String fastdfs_file_url; 
															 | 
															
															 | 
															
																    private String fastdfs_file_url; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @Autowired 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private FileUploadService fileUploadService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @Value("${neiwang.enable}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private Boolean isneiwang;  //如果不是内网项目要转到到内网在上传 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @PostMapping(value = IotRequestMapping.FileUpload.api_upload_stream_img) 
															 | 
															
															 | 
															
																    @PostMapping(value = IotRequestMapping.FileUpload.api_upload_stream_img) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片") 
															 | 
															
															 | 
															
																    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片") 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -56,13 +63,22 @@ public class FileUploadController extends BaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String fileName = fullName.substring(0, fullName.lastIndexOf(".")); 
															 | 
															
															 | 
															
																            String fileName = fullName.substring(0, fullName.lastIndexOf(".")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //上传到fastdfs 
															 | 
															
															 | 
															
																            //上传到fastdfs 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, ""); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            ObjectNode objectNode = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //解析返回的objectNode 
															 | 
															
															 | 
															
																            //解析返回的objectNode 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            UploadVO uploadVO = new UploadVO(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileName(fileName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileType(fileType); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            UploadVO uploadVO = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if(isneiwang){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, ""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = new UploadVO(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileName(fileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileType(fileType); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            }else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = fileUploadService.request(request,file.getInputStream(),fullName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                if(uploadVO==null){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    return Envelop.getError("文件上传失败",IotRequestMapping.api_iot_fail); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO); 
															 | 
															
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        }catch (Exception e){ 
															 | 
															
															 | 
															
																        }catch (Exception e){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            e.printStackTrace(); 
															 | 
															
															 | 
															
																            e.printStackTrace(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -95,13 +111,23 @@ public class FileUploadController extends BaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String fileName = fullName.substring(0, fullName.lastIndexOf(".")); 
															 | 
															
															 | 
															
																            String fileName = fullName.substring(0, fullName.lastIndexOf(".")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //上传到fastdfs 
															 | 
															
															 | 
															
																            //上传到fastdfs 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, ""); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            ObjectNode objectNode = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //解析返回的objectNode 
															 | 
															
															 | 
															
																            //解析返回的objectNode 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            UploadVO uploadVO = new UploadVO(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileName(fileName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileType(fileType); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            UploadVO uploadVO = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if(isneiwang){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, ""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = new UploadVO(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileName(fileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileType(fileType); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            }else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = fileUploadService.request(request,file.getInputStream(),fullName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                if(uploadVO==null){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    return Envelop.getError("文件上传失败",IotRequestMapping.api_iot_fail); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO); 
															 | 
															
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        }catch (Exception e){ 
															 | 
															
															 | 
															
																        }catch (Exception e){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            e.printStackTrace(); 
															 | 
															
															 | 
															
																            e.printStackTrace(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -119,13 +145,23 @@ public class FileUploadController extends BaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase(); 
															 | 
															
															 | 
															
																            String fileType = fullName.substring(fullName.lastIndexOf(".") + 1).toLowerCase(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String fileName = fullName.substring(0, fullName.lastIndexOf(".")); 
															 | 
															
															 | 
															
																            String fileName = fullName.substring(0, fullName.lastIndexOf(".")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //上传到fastdfs 
															 | 
															
															 | 
															
																            //上传到fastdfs 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            ObjectNode objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, ""); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            ObjectNode objectNode = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //解析返回的objectNode 
															 | 
															
															 | 
															
																            //解析返回的objectNode 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            UploadVO uploadVO = new UploadVO(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileName(fileName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileType(fileType); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            UploadVO uploadVO = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if(isneiwang){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                objectNode = fastDFSHelper.upload(file.getInputStream(), fileType, ""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = new UploadVO(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileName(fileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileType(fileType); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            }else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = fileUploadService.request(request,file.getInputStream(),fullName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                if(uploadVO==null){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    return Envelop.getError("文件上传失败",IotRequestMapping.api_iot_fail); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO); 
															 | 
															
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } catch (Exception e) { 
															 | 
															
															 | 
															
																        } catch (Exception e) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            e.printStackTrace(); 
															 | 
															
															 | 
															
																            e.printStackTrace(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -143,25 +179,28 @@ public class FileUploadController extends BaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String is = URLDecoder.decode(fileStreams[1],"UTF-8").replace(" ","+"); 
															 | 
															
															 | 
															
																            String is = URLDecoder.decode(fileStreams[1],"UTF-8").replace(" ","+"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            byte[] in = Base64.getDecoder().decode(is); 
															 | 
															
															 | 
															
																            byte[] in = Base64.getDecoder().decode(is); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String pictureName = fileStreams[0].substring(0,fileStreams[0].length()-1); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String fileExtension = pictureName.substring(pictureName.lastIndexOf(".") + 1).toLowerCase(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String description = null; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            if ((pictureName != null) && (pictureName.length() > 0)) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                int dot = pictureName.lastIndexOf('.'); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                if ((dot > -1) && (dot < (pictureName.length()))) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    description = pictureName.substring(0, dot); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                } 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            InputStream inputStream = new ByteArrayInputStream(in); 
															 | 
															
															 | 
															
																            InputStream inputStream = new ByteArrayInputStream(in); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            ObjectNode objectNode = fastDFSHelper.upload(inputStream, "png", ""); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String groupName = objectNode.get("groupName").toString(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String remoteFileName = objectNode.get("remoteFileName").toString(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            ObjectNode objectNode = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            //上传到fastdfs 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            String fileType = "png"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //解析返回的objectNode 
															 | 
															
															 | 
															
																            //解析返回的objectNode 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            UploadVO uploadVO = new UploadVO(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileName(remoteFileName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFileType(groupName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            UploadVO uploadVO = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if(isneiwang){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                objectNode = fastDFSHelper.upload(inputStream, fileType, ""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                String groupName = objectNode.get("groupName").toString(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                String remoteFileName = objectNode.get("remoteFileName").toString(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = new UploadVO(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileName(remoteFileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFileType(groupName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            }else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                uploadVO = fileUploadService.request(request,inputStream,""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                if(uploadVO ==null){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    return Envelop.getError("文件上传失败",IotRequestMapping.api_iot_fail); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //返回文件路径 
															 | 
															
															 | 
															
																            //返回文件路径 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.FileUpload.message_success_upload, uploadVO); 
															 | 
															
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.FileUpload.message_success_upload, uploadVO); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        }catch (Exception e){ 
															 | 
															
															 | 
															
																        }catch (Exception e){ 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -170,4 +209,57 @@ public class FileUploadController extends BaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @RequestMapping(value = "commonUpload", method = RequestMethod.POST) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @ResponseBody 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @ApiOperation("公共的文件上传") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public Envelop<UploadVO> commonUpload(HttpServletRequest request) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        InputStream in = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            String paths = request.getParameter("filePaths"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            ObjectNode result = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if (StringUtils.isBlank(paths)) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                //为空是文件上传 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                // 文件保存的临时路径 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                String fileName = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    // 上传文件 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    MultipartFile mf = entity.getValue(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    fileName = mf.getOriginalFilename(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    in = mf.getInputStream(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    result = fastDFSHelper.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), ""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                String[] pathArr = paths.split(","); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                for (String path : pathArr) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    //传路径自己去路径上传 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    File file = new File(path); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    String fileName = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    if (file.exists()) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                        fileName = file.getName(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                        in = new FileInputStream(file); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                        result = fastDFSHelper.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), ""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            //解析返回的objectNode 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            UploadVO uploadVO = new UploadVO(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            uploadVO.setFullUri(result.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            uploadVO.setFullUrl(fastdfs_file_url + result.get("fid").toString().replaceAll("\"", "")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            return Envelop.getSuccess(IotRequestMapping.FileUpload.message_success_upload, result); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } catch (Exception e) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            e.printStackTrace(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            return Envelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        }finally { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if(in!=null){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    in.close(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } catch (IOException e) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    e.printStackTrace(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																} 
															 | 
															
															 | 
															
																} 
															 |