|
@ -3,7 +3,6 @@ package com.yihu.jw.file_upload;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.yihu.fastdfs.FastDFSUtil;
|
|
|
import com.yihu.jw.exception.business.file_upload.*;
|
|
|
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
|
|
|
import com.yihu.jw.restmodel.iot.common.UploadVO;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.HttpEntity;
|
|
@ -23,9 +22,8 @@ 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 javax.activation.MimetypesFileTypeMap;
|
|
|
import java.io.*;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.nio.charset.Charset;
|
|
@ -217,10 +215,21 @@ public class FileUploadService {
|
|
|
FastDFSUtil fastDFSUtil = new FastDFSUtil();
|
|
|
String fileUrls = "";
|
|
|
File f = new File(voices_Path);
|
|
|
logger.info("语音文件转换file");
|
|
|
if (f.exists()) {
|
|
|
logger.info("语音文件转换file-start");
|
|
|
FileInputStream input = new FileInputStream(f);
|
|
|
MultipartFile multipartFile = new MockMultipartFile("file", f.getName(), "text/plain", IOUtils.toByteArray(input));
|
|
|
String fileContenType = "text/plain";
|
|
|
try {
|
|
|
logger.info("获取文件类型--开始");
|
|
|
fileContenType = new MimetypesFileTypeMap().getContentType(f);
|
|
|
logger.info("获取文件类型--成功--fileContenType:"+fileContenType);
|
|
|
} catch (Exception e) {
|
|
|
logger.info("获取文件类型--失败:"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
MultipartFile multipartFile = new MockMultipartFile("file", f.getName(), fileContenType, IOUtils.toByteArray(input));
|
|
|
logger.info("语音文件转换file-转换-multipartFile");
|
|
|
long size = multipartFile.getSize();
|
|
|
if(size<=0){
|
|
|
// map.put("uploadStatus",1);//size小于0
|
|
@ -238,11 +247,13 @@ public class FileUploadService {
|
|
|
// map.put("accessoryUrl",null);//
|
|
|
// return map;
|
|
|
// }
|
|
|
logger.info("语音文件转换file-转换-multipartFile-成功,开始调用i健康接口上传文件");
|
|
|
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") + "";
|
|
|
logger.info("开始调用i健康接口上传文件成功:url:"+url);
|
|
|
// map.put("uploadStatus", 0);//文件类型正确
|
|
|
// map.put("accessory", url);//
|
|
|
return url;
|