diff --git a/laws-base/laws-base-core/src/main/java/com/jero/common/util/CommonUtils.java b/laws-base/laws-base-core/src/main/java/com/jero/common/util/CommonUtils.java index a6287e09..cd3185eb 100644 --- a/laws-base/laws-base-core/src/main/java/com/jero/common/util/CommonUtils.java +++ b/laws-base/laws-base-core/src/main/java/com/jero/common/util/CommonUtils.java @@ -11,6 +11,7 @@ import java.util.regex.Pattern; import javax.sql.DataSource; +import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.asymmetric.KeyType; import cn.hutool.crypto.asymmetric.RSA; import com.jero.common.constant.CommonConstant; @@ -30,20 +31,20 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class CommonUtils { - private CommonUtils(){ + private CommonUtils() { } - //中文正则 + //中文正则 private static Pattern ZHONGWEN_PATTERN = Pattern.compile("[\u4e00-\u9fa5]"); - public static String uploadOnlineImage(byte[] data,String basePath,String bizPath,String uploadType){ + public static String uploadOnlineImage(byte[] data, String basePath, String bizPath, String uploadType) { String dbPath = null; String fileName = "image" + Math.round(Math.random() * 100000000000L); fileName += "." + PoiPublicUtil.getFileExtendName(data); try { - if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){ - File file = new File(basePath + File.separator + bizPath + File.separator ); + if (CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) { + File file = new File(basePath + File.separator + bizPath + File.separator); if (!file.exists()) { file.mkdirs();// 创建文件根目录 } @@ -51,13 +52,13 @@ public class CommonUtils { File savefile = new File(savePath); FileCopyUtils.copy(data, savefile); dbPath = bizPath + File.separator + fileName; - }else { + } else { InputStream in = new ByteArrayInputStream(data); - String relativePath = bizPath+ File.separator +fileName; - if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ - dbPath = MinioUtil.upload(in,relativePath); - }else if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){ - dbPath = OssBootUtil.upload(in,relativePath); + String relativePath = bizPath + File.separator + fileName; + if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) { + dbPath = MinioUtil.upload(in, relativePath); + } else if (CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)) { + dbPath = OssBootUtil.upload(in, relativePath); } } } catch (Exception e) { @@ -68,10 +69,14 @@ public class CommonUtils { /** * 判断文件名是否带盘符,重新处理 + * * @param fileName * @return */ - public static String getFileName(String fileName){ + public static String getFileName(String fileName) { + if (StrUtil.isBlank(fileName)) { + return ""; + } //判断是否带有盘符信息 // Check for Unix-style path int unixSep = fileName.lastIndexOf('/'); @@ -79,23 +84,23 @@ public class CommonUtils { int winSep = fileName.lastIndexOf('\\'); // Cut off at latest possible point int pos = (winSep > unixSep ? winSep : unixSep); - if (pos != -1) { + if (pos != -1) { // Any sort of path separator found... fileName = fileName.substring(pos + 1); } //替换上传文件名字的特殊字符 - fileName = fileName.replace("=","").replace(",","").replace("&","") + fileName = fileName.replace("=", "").replace(",", "").replace("&", "") .replace("#", "").replace("“", "").replace("”", ""); //替换上传文件名字中的空格 - fileName=fileName.replaceAll("\\s",""); + fileName = fileName.replaceAll("\\s", ""); return fileName; } // java 判断字符串里是否包含中文字符 public static boolean ifContainChinese(String str) { - if(str.getBytes().length == str.length()){ + if (str.getBytes().length == str.length()) { return false; - }else{ + } else { Matcher m = ZHONGWEN_PATTERN.matcher(str); return m.find(); } @@ -103,62 +108,66 @@ public class CommonUtils { /** * 统一全局上传 + * * @Return: java.lang.String */ public static String upload(MultipartFile file, String bizPath, String uploadType) { String url = ""; - if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ - url = MinioUtil.upload(file,bizPath); - }else{ - url = OssBootUtil.upload(file,bizPath); + if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) { + url = MinioUtil.upload(file, bizPath); + } else { + url = OssBootUtil.upload(file, bizPath); } return url; } /** * 统一全局上传 带桶 + * * @Return: java.lang.String */ public static String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) { String url = ""; - if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ - url = MinioUtil.upload(file,bizPath,customBucket); - }else{ - url = OssBootUtil.upload(file,bizPath,customBucket); + if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) { + url = MinioUtil.upload(file, bizPath, customBucket); + } else { + url = OssBootUtil.upload(file, bizPath, customBucket); } return url; } + /** * 本地文件上传 - * @param mf 文件 - * @param bizPath 自定义路径 + * + * @param mf 文件 + * @param bizPath 自定义路径 * @return */ - public static String uploadLocal(MultipartFile mf,String bizPath, String uploadpath){ + public static String uploadLocal(MultipartFile mf, String bizPath, String uploadpath) { try { //update-begin-author:liusq date:20210809 for: 过滤上传文件类型 FileTypeFilter.fileTypeFilter(mf); //update-end-author:liusq date:20210809 for: 过滤上传文件类型 String ctxPath = uploadpath; String fileName = null; - File file = new File(ctxPath + File.separator + bizPath + File.separator ); + File file = new File(ctxPath + File.separator + bizPath + File.separator); if (!file.exists()) { file.mkdirs();// 创建文件根目录 } String orgName = mf.getOriginalFilename();// 获取文件名 orgName = CommonUtils.getFileName(orgName); - if(orgName.indexOf(".")!=-1){ + if (orgName.indexOf(".") != -1) { fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf(".")); - }else{ - fileName = orgName+ "_" + System.currentTimeMillis(); + } else { + fileName = orgName + "_" + System.currentTimeMillis(); } String savePath = file.getPath() + File.separator + fileName; File savefile = new File(savePath); FileCopyUtils.copy(mf.getBytes(), savefile); String dbpath = null; - if(oConvertUtils.isNotEmpty(bizPath)){ + if (oConvertUtils.isNotEmpty(bizPath)) { dbpath = bizPath + File.separator + fileName; - }else{ + } else { dbpath = fileName; } if (dbpath.contains("\\")) { @@ -172,18 +181,22 @@ public class CommonUtils { } return ""; } - /** 当前系统数据库类型 */ + + /** + * 当前系统数据库类型 + */ private static String DB_TYPE = ""; private static DbType dbTypeEnum = null; /** * 全局获取平台数据库类型(作废了) - * @deprecated 不推荐 + * * @return + * @deprecated 不推荐 */ @Deprecated public static String getDatabaseType() { - if(oConvertUtils.isNotEmpty(DB_TYPE)){ + if (oConvertUtils.isNotEmpty(DB_TYPE)) { return DB_TYPE; } DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class); @@ -197,6 +210,7 @@ public class CommonUtils { /** * 全局获取平台数据库类型(对应mybaisPlus枚举) + * * @return */ public static DbType getDatabaseTypeEnum() { @@ -215,55 +229,60 @@ public class CommonUtils { /** * 获取数据库类型 + * * @param dataSource * @return * @throws SQLException */ - private static String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{ - if("".equals(DB_TYPE)) { + private static String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException { + if ("".equals(DB_TYPE)) { Connection connection = dataSource.getConnection(); try { DatabaseMetaData md = connection.getMetaData(); String dbType = md.getDatabaseProductName().toLowerCase(); - if(dbType.indexOf("mysql")>=0) { + if (dbType.indexOf("mysql") >= 0) { DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL; - }else if(dbType.indexOf("oracle")>=0 ||dbType.indexOf("dm")>=0) { + } else if (dbType.indexOf("oracle") >= 0 || dbType.indexOf("dm") >= 0) { DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE; - }else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) { + } else if (dbType.indexOf("sqlserver") >= 0 || dbType.indexOf("sql server") >= 0) { DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER; - }else if(dbType.indexOf("postgresql")>=0) { + } else if (dbType.indexOf("postgresql") >= 0) { DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL; - }else { - throw new JeroBootException("数据库类型:["+dbType+"]不识别!"); + } else { + throw new JeroBootException("数据库类型:[" + dbType + "]不识别!"); } } catch (Exception e) { log.error(e.getMessage(), e); - }finally { + } finally { connection.close(); } } return DB_TYPE; } + /** * 黑名单限制文件 - * @date 2021/4/14 6:18 + * * @param fileName 文件名 * @return boolean true:处于黑名单 false:不处于黑名单 + * @date 2021/4/14 6:18 */ - public static boolean limitFileSuffix(String fileName,String[] fileSuffixLimits){ + public static boolean limitFileSuffix(String fileName, String[] fileSuffixLimits) { final List fileNameList = Arrays.asList(fileSuffixLimits); - boolean isExists = fileNameList.stream().anyMatch(name -> fileName.substring(0,fileName.lastIndexOf('.')).contains(name)||fileName.substring(fileName.lastIndexOf('.')).contains(name)); + boolean isExists = fileNameList.stream().anyMatch(name -> fileName.substring(0, fileName.lastIndexOf('.')).contains(name) || fileName.substring(fileName.lastIndexOf('.')).contains(name)); return isExists; } + /** * RSA 使用私钥解密 - * @date 2021/4/15 16:11 - * @param str 待解密的字符串 + * + * @param str 待解密的字符串 * @param RSAPrivateKey 私钥 * @return String 解密后的字符串 + * @date 2021/4/15 16:11 */ - public static String decryptBtRsaPriKey(String str,String RSAPrivateKey){ + public static String decryptBtRsaPriKey(String str, String RSAPrivateKey) { RSA rsa = new RSA(RSAPrivateKey, null); byte[] decrypt = rsa.decrypt(str, KeyType.PrivateKey); return new String(decrypt); diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esChange/service/impl/ProcessEsChangeServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esChange/service/impl/ProcessEsChangeServiceImpl.java index 1ebea678..538fe68e 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esChange/service/impl/ProcessEsChangeServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esChange/service/impl/ProcessEsChangeServiceImpl.java @@ -31,6 +31,8 @@ import com.jero.modules.activiti.service.ProcessAllService; import com.jero.modules.activiti.service.ProcessNodeLinkService; import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard; import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService; +import com.jero.modules.onlyoffice.service.IBusProcessModelHisService; +import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.sys.utils.UserUtils; import com.jero.modules.system.service.ISysUserDepartService; import lombok.extern.slf4j.Slf4j; @@ -83,6 +85,9 @@ public class ProcessEsChangeServiceImpl extends ServiceImpl String saveProcessFileToOss(String hisId); BusProcessModelHis findEditFileByStandardNo(String standardNo); + + OSSFile findLastDocFileByStandardNo(String standardNo); } diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java index 10b77651..2dad01b1 100644 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java @@ -387,7 +387,7 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl esWrapper = new LambdaQueryWrapper<>(); esWrapper.eq(LawsEnterpriseStandard::getStandardNumber, standardNo); LawsEnterpriseStandard es = eSService.getOne(esWrapper);