Browse Source

Merge branch 'dev' of huangwenjie/wlyy2.0 into dev

huangwenjie 5 years ago
parent
commit
e1d17af3cb

+ 15 - 4
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -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;

+ 4 - 2
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java

@ -58,7 +58,7 @@ public class WechatInfoService {
     */
    public String getJsapi_ticketByToken(String wxId) throws Exception {
        try {
            
            System.out.println("getJsapi_ticketByToken="+wxId);
            Iterable<JsApiTicket> jsapiTickets = null;
            WxWechatDO wxWechat = null;
            
@ -88,12 +88,13 @@ public class WechatInfoService {
            }else{
                token = wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
            }
            
            System.out.println("getticket_token:"+token);
            if (token != null) {
                String token_url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
                String params = "access_token=" + token + "&type=jsapi";
                String result = HttpUtil.sendGet(token_url, params);
                JSONObject json = new JSONObject(result);
                System.out.println("getticket:"+result);
                if (json.has("ticket")) {
                    String ticket = json.get("ticket").toString();
                    String expires_in = json.get("expires_in").toString();
@ -115,6 +116,7 @@ public class WechatInfoService {
                return null;
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
            throw new Exception(e.getMessage());
        }
    }

+ 2 - 2
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -634,9 +634,9 @@ public class ImService {
			String Mp3FilePath = tempPath+datePath+mp3FileName;
			System.out.println("amrFilePath:"+amrFilePath);
			System.out.println("Mp3FilePath:"+Mp3FilePath);
			fileUtil.changeToMp3(amrFilePath,Mp3FilePath);
//			fileUtil.changeToMp3(amrFilePath,Mp3FilePath);
			// 返回保存路径
			return Mp3FilePath;
			return amrFilePath;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {

+ 8 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -234,16 +234,19 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
		//处理语音文件
		if(!org.springframework.util.StringUtils.isEmpty(wechat_appid)){
			String path = imService.fetchWxVoices(wechat_appid);
			logger.info("voice_path:"+path);
			JSONObject obj = new JSONObject();
			String voiceurl = "";
			// 将临时语音拷贝到正式存储路径下
			if (org.apache.commons.lang3.StringUtils.isNotEmpty(path)) {
				if("xm_ihealth_wx".equals(wechat_appid)){
					content = fileUploadService.uploadWxVoice(path);
					logger.info("voice_wx_type:"+wechat_appid);
					voiceurl = fileUploadService.uploadWxVoice(path);
//					uploadVO.setFullUri(map.get("accessory").toString());
				}else{
					content = fileUtil.copyTempVoice(path,fastdfs_file_url);
					voiceurl = fileUtil.copyTempVoice(path,fastdfs_file_url);
				}
				obj.put("path", path);
				obj.put("path", voiceurl);
				obj.put("times", times);
				content = obj.toString();
			}
@ -488,7 +491,8 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	                       @RequestParam(value = "pageUrl", required = true)String pageUrl,
	                       @ApiParam(name = "wxId", value = "微信id")
	                       @RequestParam(value = "wxId", required = true)String wxId) throws Exception {
		
		logger.info("pageUrl="+pageUrl);
		logger.info("wxId="+wxId);
		String ticket = wechatInfoService.getJsapi_ticketByToken(wxId);
		WxWechatDO wxWechatDO = wechatDao.findById(wxId);
		Map<Object, Object> map = new HashMap<Object, Object>();