|  | @ -1,11 +1,15 @@
 | 
	
		
			
				|  |  | package com.yihu.wlyy.web.patient.archives;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.node.ObjectNode;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.config.FastDFSConfig;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.app.archives.PatientEventService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.app.archives.PatientRecordService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.web.BaseController;
 | 
	
		
			
				|  |  | import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiParam;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.json.JSONObject;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.http.MediaType;
 | 
	
	
		
			
				|  | @ -14,7 +18,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RequestMethod;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RequestParam;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.ResponseBody;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import org.springframework.web.multipart.MultipartFile;
 | 
	
		
			
				|  |  | import org.springframework.web.multipart.MultipartHttpServletRequest;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | import java.io.ByteArrayInputStream;
 | 
	
		
			
				|  |  | import java.io.InputStream;
 | 
	
		
			
				|  |  | import java.util.ArrayList;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -149,4 +160,44 @@ public class PatientArchivesController extends BaseController {
 | 
	
		
			
				|  |  |             return invalidUserException(e, -1, "保存就诊事件失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/event/uploadImg", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     @ApiOperation("上传图片")
 | 
	
		
			
				|  |  |     public String uploadImg(HttpServletRequest request, HttpServletResponse response)
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         //图片路径
 | 
	
		
			
				|  |  |         List<String> tempPaths = new ArrayList<String>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
 | 
	
		
			
				|  |  |             Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
 | 
	
		
			
				|  |  |             FastDFSUtil fastDFSUtil = new FastDFSConfig().fastDFSUtil();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String fileName = null;
 | 
	
		
			
				|  |  |             for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
 | 
	
		
			
				|  |  |                 // 上传文件
 | 
	
		
			
				|  |  |                 MultipartFile mf = entity.getValue();
 | 
	
		
			
				|  |  |                 fileName = mf.getOriginalFilename();
 | 
	
		
			
				|  |  |                 String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
 | 
	
		
			
				|  |  |                 InputStream in = new ByteArrayInputStream(mf.getBytes());
 | 
	
		
			
				|  |  |                 ObjectNode result = fastDFSUtil.upload(in, fileExt, "");
 | 
	
		
			
				|  |  |                 in.close();
 | 
	
		
			
				|  |  |                 if (result != null) {
 | 
	
		
			
				|  |  |                     tempPaths.add(result.get("fileUrl").toString().replaceAll("\"", ""));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String urls = "";
 | 
	
		
			
				|  |  |             for (String image : tempPaths) {
 | 
	
		
			
				|  |  |                 if (urls.length() == 0) {
 | 
	
		
			
				|  |  |                     urls = image;
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     urls += "," + image;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return write(200, "图片上传成功!","urls", urls);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             return invalidUserException(e,-1, "图片上传失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |