许鹏程
2023-06-13 c0b60dbd5791d499c037c2f7c8cdfc9760353bb3
套红文档,
已修改4个文件
53 ■■■■■ 文件已修改
src/main/java/com/product/file/controller/FileManagerController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/file/service/FileManagerService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/file/service/OnlineDocumentEditService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/file/util/AsposeUtil.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/file/controller/FileManagerController.java
@@ -33,6 +33,7 @@
    @Autowired
    public FileManagerService fileManagerService;
    /**
     * @param uuid
     * @param response
src/main/java/com/product/file/service/FileManagerService.java
@@ -524,6 +524,10 @@
     */
    public File getFile(String uuid) throws BaseException {
        FieldSetEntity attachmentFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ATTACHMENTS, uuid, false);
        return getFile(attachmentFse);
    }
    public File getFile(FieldSetEntity attachmentFse) throws BaseException {
        byte[] fileContent = getFileContent(attachmentFse);
        if (fileContent != null && fileContent.length > 0) {
            String localTempPath = Global.getSystemConfig("temp.dir", "") + File.separator + new Date().getTime() + attachmentFse.getString(CmnConst.ATTACHMENT_TITLE) + attachmentFse.getString("file_name");
src/main/java/com/product/file/service/OnlineDocumentEditService.java
@@ -167,6 +167,9 @@
                FieldSetEntity fse = dt.getFieldSetEntity(i);
                try {
                    String redisKey = this.DOCUMENT_EDIT_KEY + fse.getUUID() + "-" + userId;
                    if (!RedisUtil.exists(redisKey)) {
                        continue;
                    }
                    Map<String, Object> map = (Map<String, Object>) RedisUtil.get(redisKey);
                    if (map != null) {
                        String dir = fse.getString(CmnConst.ATTACHMENT_URL);
src/main/java/com/product/file/util/AsposeUtil.java
@@ -24,8 +24,10 @@
public class AsposeUtil {
    //是否初始了license
    private static boolean isInitLicense=false;
    /**
     * 获取license
     *
     * @return
     */
    public static boolean getLicense(int type)throws BaseException {
@@ -63,8 +65,8 @@
        }
        return result;
    }
    /**
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -99,6 +101,7 @@
            }
        }
    }
    public static void Excel2Html(String officePath,String OutPutPath)throws BaseException {
        // 验证License
        if (!getLicense(1)) {
@@ -131,28 +134,27 @@
            }
        }
    }
    /**
     * 设置单元格的自动适宽、高
     *
     * @param sheet
     * @throws Exception
     */
    public static void setAutoWithHeight(Worksheet sheet)throws Exception
    {
    public static void setAutoWithHeight(Worksheet sheet) throws Exception {
        Cells cells =sheet.getCells();
        int columnCount = cells.getMaxColumn();  //获取表页的最大列数
        int rowCount = cells.getMaxRow();        //获取表页的最大行数
        if(columnCount<0 ||rowCount<0 )return ;
        for (int col = 0; col < columnCount; col++)
        {
        for (int col = 0; col < columnCount; col++) {
            sheet.autoFitColumn(col, 0, rowCount);
        }
        for (int row = 0; row < rowCount; row++)
        {
        for (int row = 0; row < rowCount; row++) {
            sheet.autoFitRow(row, 0, columnCount);
        }
    }
    /**
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -184,8 +186,8 @@
            }
        }
    }
    /**
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -218,8 +220,10 @@
            }
        }
    }
    /**
     * 文档转换
     *
     * @param officePath
     * @param outFile
     * @return
@@ -249,8 +253,10 @@
        }
        return outFile;
    }
    /**
     * 文档转换
     *
     * @param officePath
     * @return
     */
@@ -304,8 +310,10 @@
        }
        return OutPutPath+officeName;
    }
    /**
     * word文档的合并
     *
     * @param targetWordFile
     * @param sourceWordFile
     * @return
@@ -316,8 +324,15 @@
        File source=new File(sourceWordFile);
        return mergeWord(target,source);
    }
    public static void main(String args[]) {
        String file = "E:/work/沄崃/FE6.6产品报价工具-新 - 副本.xlsx";
        AsposeUtil.OfficeToPdf(file);
    }
    /**
     * word文档的合并
     *
     * @param targetWordFile
     * @param sourceWordFile
     * @return
@@ -349,17 +364,15 @@
            targetDoc.appendDocument(sourceDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
            File dir=new File(temp);
            if(!dir.exists()) {
                if(dir.mkdirs()) {
                dir.mkdirs();
            }
                    if(temp_target.createNewFile()) {
                        out=new FileOutputStream(temp_target);
                        targetDoc.save(out, SaveFormat.DOCX);
                    }
                }
            }
        }catch(Exception e) {
            throw new BaseException(FileCode.DOC_MERGE_FALL,e);
        }
        finally{
        } finally {
            try {
                if(tin!=null) {
                    tin.close();
@@ -376,9 +389,5 @@
            }
        }
        return temp_target;
    }
    public static void main(String args[]) {
        String file="E:/work/沄崃/FE6.6产品报价工具-新 - 副本.xlsx";
        AsposeUtil.OfficeToPdf(file);
    }
}