浏览代码

Merge branch 'dev' of lyr/patient-co-management into dev

lyr 8 年之前
父节点
当前提交
41d96445b9

+ 38 - 33
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -132,37 +132,37 @@ public class CommonUtil {
     * @return
     * @throws IOException
     */
    public static String copyTempImage(String images) throws IOException {
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        // 图片保存路径
        String imagePath = SystemConf.getInstance().getImagePath() + File.separator;
        String[] tempImages = images.split(",");
        String temp = "";
        for (String image : tempImages) {
            File file = new File(tempPath + image);
            File smallFile = new File(tempPath + image + "_small");
            if (file.exists() && smallFile.exists()) {
                // 原图拷贝路径
                File targetFile = new File(imagePath + image);
                // 缩略图拷贝路径
                File targetSmallFile = new File(imagePath + image + "_small");
                // 拷贝原图
                FileUtils.copyFile(file, targetFile);
                // 拷贝缩略图
                FileUtils.copyFile(smallFile, targetSmallFile);
                // 删除临时文件
                FileUtils.forceDelete(file);
                FileUtils.forceDelete(smallFile);
                if (temp.length() == 0) {
                    temp = SystemConf.getInstance().getImageServer() + image;
                } else {
                    temp += "," + SystemConf.getInstance().getImageServer() + image;
                }
            }
        }
        return temp;
    }
//    public static String copyTempImage(String images) throws IOException {
//        // 文件保存的临时路径
//        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
//        // 图片保存路径
//        String imagePath = SystemConf.getInstance().getImagePath() + File.separator;
//        String[] tempImages = images.split(",");
//        String temp = "";
//        for (String image : tempImages) {
//            File file = new File(tempPath + image);
//            File smallFile = new File(tempPath + image + "_small");
//            if (file.exists() && smallFile.exists()) {
//                // 原图拷贝路径
//                File targetFile = new File(imagePath + image);
//                // 缩略图拷贝路径
//                File targetSmallFile = new File(imagePath + image + "_small");
//                // 拷贝原图
//                FileUtils.copyFile(file, targetFile);
//                // 拷贝缩略图
//                FileUtils.copyFile(smallFile, targetSmallFile);
//                // 删除临时文件
//                FileUtils.forceDelete(file);
//                FileUtils.forceDelete(smallFile);
//                if (temp.length() == 0) {
//                    temp = SystemConf.getInstance().getImageServer() + image;
//                } else {
//                    temp += "," + SystemConf.getInstance().getImageServer() + image;
//                }
//            }
//        }
//        return temp;
//    }
    /**
     * 拷贝临时语音文件到存储目录
@ -227,7 +227,7 @@ public class CommonUtil {
     * @return
     * @throws Exception
     */
    public static String copyTempFilesToFastDFS(String files) throws Exception {
    public static String copyTempImage(String files) throws Exception {
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        String[] fileArray = files.split(",");
@ -236,13 +236,18 @@ public class CommonUtil {
        for (String file : fileArray) {
            File f = new File(tempPath + file);
            File fs = new File(tempPath + file + "_small");
            if (f.exists()) {
                String fileName = f.getName();
                InputStream in = new FileInputStream(f);
                ObjectNode result = fastDFSUtil.upload(in, fileName.substring(fileName.lastIndexOf(".") + 1), "");
                in.close();
                if (result != null) {
                    fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",") + result.get("fileUrl").toString().replaceAll("\"","");
                    fileUrls += (StringUtils.isEmpty(fileUrls) ? "" : ",") + result.get("fileUrl").toString().replaceAll("\"", "");
                    f.delete();
                    if (fs.exists()) {
                        fs.delete();
                    }
                }
            }
        }

+ 1 - 2
patient-co-wlyy/src/main/resources/config/fdfs_client.conf

@ -6,5 +6,4 @@ http.anti_steal_token = no
http.secret_key = FastDFS1234567890
#tracker_server = 172.19.103.13:22122
tracker_server = 192.168.131.127:22122
#172.19.103.54:22122
tracker_server = 172.19.103.54:22122