|  | @ -14,19 +14,19 @@ import org.apache.http.entity.mime.MultipartEntityBuilder;
 | 
	
		
			
				|  |  | import org.apache.http.impl.client.CloseableHttpClient;
 | 
	
		
			
				|  |  | import org.apache.http.impl.client.HttpClientBuilder;
 | 
	
		
			
				|  |  | import org.apache.http.util.EntityUtils;
 | 
	
		
			
				|  |  | import org.apache.poi.util.IOUtils;
 | 
	
		
			
				|  |  | import org.csource.common.MyException;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.mock.web.MockMultipartFile;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.web.multipart.MultipartFile;
 | 
	
		
			
				|  |  | import org.springframework.web.multipart.MultipartHttpServletRequest;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  | import java.io.ByteArrayInputStream;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.io.InputStream;
 | 
	
		
			
				|  |  | import java.io.*;
 | 
	
		
			
				|  |  | import java.net.URLDecoder;
 | 
	
		
			
				|  |  | import java.nio.charset.Charset;
 | 
	
		
			
				|  |  | import java.security.NoSuchAlgorithmException;
 | 
	
	
		
			
				|  | @ -203,6 +203,54 @@ public class FileUploadService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         throw new Exception();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 调用健康上传语音文件
 | 
	
		
			
				|  |  |      * @param voices_Path
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String uploadWxVoice(String voices_Path) throws Exception {
 | 
	
		
			
				|  |  |         String url = "";
 | 
	
		
			
				|  |  |         // 文件保存的临时路径
 | 
	
		
			
				|  |  |         FastDFSUtil fastDFSUtil = new FastDFSUtil();
 | 
	
		
			
				|  |  |         String fileUrls = "";
 | 
	
		
			
				|  |  |         File f = new File(voices_Path);
 | 
	
		
			
				|  |  |         if (f.exists()) {
 | 
	
		
			
				|  |  |             FileInputStream input = new FileInputStream(f);
 | 
	
		
			
				|  |  |             MultipartFile multipartFile = new MockMultipartFile("file", f.getName(), "text/plain", IOUtils.toByteArray(input));
 | 
	
		
			
				|  |  |             
 | 
	
		
			
				|  |  |             long size = multipartFile.getSize();
 | 
	
		
			
				|  |  |             if(size<=0){
 | 
	
		
			
				|  |  | //                map.put("uploadStatus",1);//size小于0
 | 
	
		
			
				|  |  | //                map.put("accessoryUrl",null);//
 | 
	
		
			
				|  |  |                 return url;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String fileName = multipartFile.getOriginalFilename();
 | 
	
		
			
				|  |  |             String[] fs = fileName.split("\\.");
 | 
	
		
			
				|  |  |             String type = fs[1];
 | 
	
		
			
				|  |  |             logger.info("uploadImg type:"+type);
 | 
	
		
			
				|  |  |             //图片常见格式:bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp
 | 
	
		
			
				|  |  | //        List img = new ArrayList(Arrays.asList("bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp"));
 | 
	
		
			
				|  |  | //        if (!img.contains(type)) {
 | 
	
		
			
				|  |  | //            map.put("uploadStatus",2);//文件类型不对
 | 
	
		
			
				|  |  | //            map.put("accessoryUrl",null);//
 | 
	
		
			
				|  |  | //            return map;
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |             String response = request(wlyyUrl + "/upload/chat", multipartFile, null);
 | 
	
		
			
				|  |  |             org.json.JSONObject rs = new org.json.JSONObject(response);
 | 
	
		
			
				|  |  |             Integer status = (Integer) rs.get("status");
 | 
	
		
			
				|  |  |             if (status == 200) {
 | 
	
		
			
				|  |  |                 url = rs.get("urls") + "";
 | 
	
		
			
				|  |  | //                map.put("uploadStatus", 0);//文件类型正确
 | 
	
		
			
				|  |  | //                map.put("accessory", url);//
 | 
	
		
			
				|  |  |                 return url;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             throw new Exception();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return url;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String request(String remote_url, MultipartFile file, String type) {
 | 
	
		
			
				|  |  |         CloseableHttpClient httpClient = HttpClientBuilder.create().build();
 |