Переглянути джерело

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

Conflicts:
	patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendP2PUtil.java
8 роки тому
батько
коміт
a0853d3e1c

+ 11 - 3
patient-co-wlyy/pom.xml

@ -50,18 +50,18 @@
        <maven>3.0.0</maven>
        <maven>3.0.0</maven>
    </prerequisites>
    </prerequisites>
    <!-- 设定插件仓库, 如有Nexus私服, 取消注释并指向正确的服务器地址.
    <!-- 设定插件仓库, 如有Nexus私服, 取消注释并指向正确的服务器地址. -->
    <pluginRepositories>
    <pluginRepositories>
        <pluginRepository>
        <pluginRepository>
            <id>nexus</id>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <name>Team Nexus Repository</name>
            <url>http://localhost:8081/nexus/content/groups/public</url>
            <url>http://172.19.103.47:8081/nexus/content/groups/public</url>
            <snapshots>
            <snapshots>
                <enabled>false</enabled>
                <enabled>false</enabled>
            </snapshots>
            </snapshots>
        </pluginRepository>
        </pluginRepository>
    </pluginRepositories>
    </pluginRepositories>
    -->
    <!-- 依赖项定义 -->
    <!-- 依赖项定义 -->
    <dependencies>
    <dependencies>
@ -71,6 +71,14 @@
            <artifactId>springfox-swagger2</artifactId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
            <version>2.4.0</version>
        </dependency>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>java-ffmpegjave</artifactId>
            <version>1.0.3</version>
        </dependency>
        <dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <artifactId>springfox-swagger-ui</artifactId>

+ 6 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1740,7 +1740,12 @@ public class FamilyContractService extends BaseService {
                    return result;
                    return result;
                }
                }
                try{
                try{
                    ImUtill.deleteMucUser(healthDoctor,signFamily.getDoctorHealth(),patient+"_consult_2");
                    if(signFamily.getDoctorHealth().equals(signFamily.getDoctor())){
                        ImUtill.deleteMucUser(healthDoctor,"",patient+"_consult_2");
                    }else{
                        ImUtill.deleteMucUser(healthDoctor,signFamily.getDoctorHealth(),patient+"_consult_2");
                    }
                }catch (Exception e){
                }catch (Exception e){
                    result.put("status", -1);
                    result.put("status", -1);
                    result.put("msg", e.getMessage());
                    result.put("msg", e.getMessage());

+ 68 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -1,10 +1,13 @@
package com.yihu.wlyy.util;
package com.yihu.wlyy.util;
import java.io.*;
import java.io.*;
import java.util.Date;
import java.util.Random;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.config.FastDFSConfig;
import com.yihu.wlyy.config.FastDFSConfig;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import it.sauronsoftware.jave.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
@ -253,4 +256,69 @@ public class CommonUtil {
        return fileUrls;
        return fileUrls;
    }
    }
    public static void changeToMp3(String sourcePath, String targetPath) {
        File source = new File(sourcePath);
        File target = new File(targetPath);
        AudioAttributes audio = new AudioAttributes();
        Encoder encoder = new Encoder();
        audio.setCodec("libmp3lame");
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("mp3");
        attrs.setAudioAttributes(audio);
        try {
            encoder.encode(source, target, attrs);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InputFormatException e) {
            e.printStackTrace();
        } catch (EncoderException e) {
            e.printStackTrace();
        }
    }
    public static String  saveVoiceToDisk(InputStream inputStream,String newFileName) throws Exception {
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        // 拼接年月日路径
        String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
        // 保存路径
        File uploadFile = new File(tempPath + datePath + newFileName);
        FileOutputStream fileOutputStream = null;
        try {
            if (!uploadFile.getParentFile().exists()) {
                uploadFile.getParentFile().mkdirs();
            }
            byte[] data = new byte[1024];
            int len = 0;
            fileOutputStream = new FileOutputStream(uploadFile);
            while ((len = inputStream.read(data)) != -1) {
                fileOutputStream.write(data, 0, len);
            }
            // 返回保存路径
            return tempPath+datePath + newFileName;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}
}

+ 8 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/WeixinBaseController.java

@ -420,7 +420,9 @@ public class WeixinBaseController extends BaseController {
		// 拼接年月日路径
		// 拼接年月日路径
		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
		String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
		// 重命名文件
		// 重命名文件
		String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".mp3";
		String fileBase =  DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000);
		String newFileName = fileBase+ ".amr";
		String mp3FileName  = fileBase + ".mp3";
		// 保存路径
		// 保存路径
		File uploadFile = new File(tempPath + datePath + newFileName);
		File uploadFile = new File(tempPath + datePath + newFileName);
@ -437,8 +439,12 @@ public class WeixinBaseController extends BaseController {
			while ((len = inputStream.read(data)) != -1) {
			while ((len = inputStream.read(data)) != -1) {
				fileOutputStream.write(data, 0, len);
				fileOutputStream.write(data, 0, len);
			}
			}
			String amrFilePath = tempPath+datePath+newFileName;
			String Mp3FilePath = tempPath+datePath+mp3FileName;
			CommonUtil.changeToMp3(amrFilePath,Mp3FilePath);
			System.out.print("");
			// 返回保存路径
			// 返回保存路径
			return datePath + newFileName;
			return datePath + Mp3FilePath;
		} catch (IOException e) {
		} catch (IOException e) {
			e.printStackTrace();
			e.printStackTrace();
		} finally {
		} finally {

+ 21 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -13,6 +13,7 @@ import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioSystem;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
@ -174,25 +175,29 @@ public class FileUploadController extends BaseController {
                // 上传文件
                // 上传文件
                MultipartFile mf = entity.getValue();
                MultipartFile mf = entity.getValue();
                //byte audioData[] = mf.getBytes();
                //AudioFormat af = getAudioFormat();
                //ByteArrayInputStream bais = new ByteArrayInputStream(audioData);
                //AudioInputStream ais = new AudioInputStream(bais,af, audioData.length / af.getFrameSize());
                //File file = new File("temp.wav");
                //InputStream in = new FileInputStream(file);
                //AudioSystem.write(ais, AudioFileFormat.Type.WAVE,file);
                fileName = mf.getOriginalFilename();
                fileName = mf.getOriginalFilename();
                String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                if("3".equals(type)){
                if("3".equals(type)){
                    fileExt ="mp3";
                    String tempPath  =  CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
                    String map3Path = tempPath.substring(0,tempPath.lastIndexOf("."));
                    CommonUtil.changeToMp3(tempPath,map3Path);
                    File tempFile = new File(tempPath);
                    File mp3File = new File(map3Path);
                    ObjectNode objectNode = fastDFSUtil.upload(new FileInputStream(mp3File),".mp3","");
                    tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                    if(tempFile!=null){
                        tempFile.delete();
                    }
                    if(mp3File!=null){
                        mp3File.delete();
                    }
                }else{
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
                    tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                }
                }
                ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
                tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
                        + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
            }
            }
            String urls = String.join(",", tempPaths);
            String urls = String.join(",", tempPaths);
            JSONObject json = new JSONObject();
            JSONObject json = new JSONObject();