fix: 82013 企标更改流程--流程阻塞

This commit is contained in:
2024-02-25 17:09:32 +08:00
parent 04cd2bea48
commit 836f4be2d2
4 changed files with 89 additions and 54 deletions
@@ -11,6 +11,7 @@ import java.util.regex.Pattern;
import javax.sql.DataSource; import javax.sql.DataSource;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.asymmetric.KeyType; import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA; import cn.hutool.crypto.asymmetric.RSA;
import com.jero.common.constant.CommonConstant; import com.jero.common.constant.CommonConstant;
@@ -30,20 +31,20 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class CommonUtils { public class CommonUtils {
private CommonUtils(){ private CommonUtils() {
} }
//中文正则 //中文正则
private static Pattern ZHONGWEN_PATTERN = Pattern.compile("[\u4e00-\u9fa5]"); 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 dbPath = null;
String fileName = "image" + Math.round(Math.random() * 100000000000L); String fileName = "image" + Math.round(Math.random() * 100000000000L);
fileName += "." + PoiPublicUtil.getFileExtendName(data); fileName += "." + PoiPublicUtil.getFileExtendName(data);
try { try {
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){ if (CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
File file = new File(basePath + File.separator + bizPath + File.separator ); File file = new File(basePath + File.separator + bizPath + File.separator);
if (!file.exists()) { if (!file.exists()) {
file.mkdirs();// 创建文件根目录 file.mkdirs();// 创建文件根目录
} }
@@ -51,13 +52,13 @@ public class CommonUtils {
File savefile = new File(savePath); File savefile = new File(savePath);
FileCopyUtils.copy(data, savefile); FileCopyUtils.copy(data, savefile);
dbPath = bizPath + File.separator + fileName; dbPath = bizPath + File.separator + fileName;
}else { } else {
InputStream in = new ByteArrayInputStream(data); InputStream in = new ByteArrayInputStream(data);
String relativePath = bizPath+ File.separator +fileName; String relativePath = bizPath + File.separator + fileName;
if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) {
dbPath = MinioUtil.upload(in,relativePath); dbPath = MinioUtil.upload(in, relativePath);
}else if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){ } else if (CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)) {
dbPath = OssBootUtil.upload(in,relativePath); dbPath = OssBootUtil.upload(in, relativePath);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@@ -68,10 +69,14 @@ public class CommonUtils {
/** /**
* 判断文件名是否带盘符,重新处理 * 判断文件名是否带盘符,重新处理
*
* @param fileName * @param fileName
* @return * @return
*/ */
public static String getFileName(String fileName){ public static String getFileName(String fileName) {
if (StrUtil.isBlank(fileName)) {
return "";
}
//判断是否带有盘符信息 //判断是否带有盘符信息
// Check for Unix-style path // Check for Unix-style path
int unixSep = fileName.lastIndexOf('/'); int unixSep = fileName.lastIndexOf('/');
@@ -79,23 +84,23 @@ public class CommonUtils {
int winSep = fileName.lastIndexOf('\\'); int winSep = fileName.lastIndexOf('\\');
// Cut off at latest possible point // Cut off at latest possible point
int pos = (winSep > unixSep ? winSep : unixSep); int pos = (winSep > unixSep ? winSep : unixSep);
if (pos != -1) { if (pos != -1) {
// Any sort of path separator found... // Any sort of path separator found...
fileName = fileName.substring(pos + 1); fileName = fileName.substring(pos + 1);
} }
//替换上传文件名字的特殊字符 //替换上传文件名字的特殊字符
fileName = fileName.replace("=","").replace(",","").replace("&","") fileName = fileName.replace("=", "").replace(",", "").replace("&", "")
.replace("#", "").replace("", "").replace("", ""); .replace("#", "").replace("", "").replace("", "");
//替换上传文件名字中的空格 //替换上传文件名字中的空格
fileName=fileName.replaceAll("\\s",""); fileName = fileName.replaceAll("\\s", "");
return fileName; return fileName;
} }
// java 判断字符串里是否包含中文字符 // java 判断字符串里是否包含中文字符
public static boolean ifContainChinese(String str) { public static boolean ifContainChinese(String str) {
if(str.getBytes().length == str.length()){ if (str.getBytes().length == str.length()) {
return false; return false;
}else{ } else {
Matcher m = ZHONGWEN_PATTERN.matcher(str); Matcher m = ZHONGWEN_PATTERN.matcher(str);
return m.find(); return m.find();
} }
@@ -103,62 +108,66 @@ public class CommonUtils {
/** /**
* 统一全局上传 * 统一全局上传
*
* @Return: java.lang.String * @Return: java.lang.String
*/ */
public static String upload(MultipartFile file, String bizPath, String uploadType) { public static String upload(MultipartFile file, String bizPath, String uploadType) {
String url = ""; String url = "";
if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) {
url = MinioUtil.upload(file,bizPath); url = MinioUtil.upload(file, bizPath);
}else{ } else {
url = OssBootUtil.upload(file,bizPath); url = OssBootUtil.upload(file, bizPath);
} }
return url; return url;
} }
/** /**
* 统一全局上传 带桶 * 统一全局上传 带桶
*
* @Return: java.lang.String * @Return: java.lang.String
*/ */
public static String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) { public static String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) {
String url = ""; String url = "";
if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) {
url = MinioUtil.upload(file,bizPath,customBucket); url = MinioUtil.upload(file, bizPath, customBucket);
}else{ } else {
url = OssBootUtil.upload(file,bizPath,customBucket); url = OssBootUtil.upload(file, bizPath, customBucket);
} }
return url; return url;
} }
/** /**
* 本地文件上传 * 本地文件上传
* @param mf 文件 *
* @param bizPath 自定义路径 * @param mf 文件
* @param bizPath 自定义路径
* @return * @return
*/ */
public static String uploadLocal(MultipartFile mf,String bizPath, String uploadpath){ public static String uploadLocal(MultipartFile mf, String bizPath, String uploadpath) {
try { try {
//update-begin-author:liusq date:20210809 for: 过滤上传文件类型 //update-begin-author:liusq date:20210809 for: 过滤上传文件类型
FileTypeFilter.fileTypeFilter(mf); FileTypeFilter.fileTypeFilter(mf);
//update-end-author:liusq date:20210809 for: 过滤上传文件类型 //update-end-author:liusq date:20210809 for: 过滤上传文件类型
String ctxPath = uploadpath; String ctxPath = uploadpath;
String fileName = null; 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()) { if (!file.exists()) {
file.mkdirs();// 创建文件根目录 file.mkdirs();// 创建文件根目录
} }
String orgName = mf.getOriginalFilename();// 获取文件名 String orgName = mf.getOriginalFilename();// 获取文件名
orgName = CommonUtils.getFileName(orgName); orgName = CommonUtils.getFileName(orgName);
if(orgName.indexOf(".")!=-1){ if (orgName.indexOf(".") != -1) {
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf(".")); fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
}else{ } else {
fileName = orgName+ "_" + System.currentTimeMillis(); fileName = orgName + "_" + System.currentTimeMillis();
} }
String savePath = file.getPath() + File.separator + fileName; String savePath = file.getPath() + File.separator + fileName;
File savefile = new File(savePath); File savefile = new File(savePath);
FileCopyUtils.copy(mf.getBytes(), savefile); FileCopyUtils.copy(mf.getBytes(), savefile);
String dbpath = null; String dbpath = null;
if(oConvertUtils.isNotEmpty(bizPath)){ if (oConvertUtils.isNotEmpty(bizPath)) {
dbpath = bizPath + File.separator + fileName; dbpath = bizPath + File.separator + fileName;
}else{ } else {
dbpath = fileName; dbpath = fileName;
} }
if (dbpath.contains("\\")) { if (dbpath.contains("\\")) {
@@ -172,18 +181,22 @@ public class CommonUtils {
} }
return ""; return "";
} }
/** 当前系统数据库类型 */
/**
* 当前系统数据库类型
*/
private static String DB_TYPE = ""; private static String DB_TYPE = "";
private static DbType dbTypeEnum = null; private static DbType dbTypeEnum = null;
/** /**
* 全局获取平台数据库类型(作废了) * 全局获取平台数据库类型(作废了)
* @deprecated 不推荐 *
* @return * @return
* @deprecated 不推荐
*/ */
@Deprecated @Deprecated
public static String getDatabaseType() { public static String getDatabaseType() {
if(oConvertUtils.isNotEmpty(DB_TYPE)){ if (oConvertUtils.isNotEmpty(DB_TYPE)) {
return DB_TYPE; return DB_TYPE;
} }
DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class); DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class);
@@ -197,6 +210,7 @@ public class CommonUtils {
/** /**
* 全局获取平台数据库类型(对应mybaisPlus枚举) * 全局获取平台数据库类型(对应mybaisPlus枚举)
*
* @return * @return
*/ */
public static DbType getDatabaseTypeEnum() { public static DbType getDatabaseTypeEnum() {
@@ -215,55 +229,60 @@ public class CommonUtils {
/** /**
* 获取数据库类型 * 获取数据库类型
*
* @param dataSource * @param dataSource
* @return * @return
* @throws SQLException * @throws SQLException
*/ */
private static String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{ private static String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException {
if("".equals(DB_TYPE)) { if ("".equals(DB_TYPE)) {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
try { try {
DatabaseMetaData md = connection.getMetaData(); DatabaseMetaData md = connection.getMetaData();
String dbType = md.getDatabaseProductName().toLowerCase(); String dbType = md.getDatabaseProductName().toLowerCase();
if(dbType.indexOf("mysql")>=0) { if (dbType.indexOf("mysql") >= 0) {
DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL; 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; 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; DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
}else if(dbType.indexOf("postgresql")>=0) { } else if (dbType.indexOf("postgresql") >= 0) {
DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL; DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
}else { } else {
throw new JeroBootException("数据库类型:["+dbType+"]不识别!"); throw new JeroBootException("数据库类型:[" + dbType + "]不识别!");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
}finally { } finally {
connection.close(); connection.close();
} }
} }
return DB_TYPE; return DB_TYPE;
} }
/** /**
* 黑名单限制文件 * 黑名单限制文件
* @date 2021/4/14 6:18 *
* @param fileName 文件名 * @param fileName 文件名
* @return boolean true:处于黑名单 false:不处于黑名单 * @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<String> fileNameList = Arrays.asList(fileSuffixLimits); final List<String> 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; return isExists;
} }
/** /**
* RSA 使用私钥解密 * RSA 使用私钥解密
* @date 2021/4/15 16:11 *
* @param str 待解密的字符串 * @param str 待解密的字符串
* @param RSAPrivateKey 私钥 * @param RSAPrivateKey 私钥
* @return String 解密后的字符串 * @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); RSA rsa = new RSA(RSAPrivateKey, null);
byte[] decrypt = rsa.decrypt(str, KeyType.PrivateKey); byte[] decrypt = rsa.decrypt(str, KeyType.PrivateKey);
return new String(decrypt); return new String(decrypt);
@@ -31,6 +31,8 @@ import com.jero.modules.activiti.service.ProcessAllService;
import com.jero.modules.activiti.service.ProcessNodeLinkService; import com.jero.modules.activiti.service.ProcessNodeLinkService;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard; import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService; 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.sys.utils.UserUtils;
import com.jero.modules.system.service.ISysUserDepartService; import com.jero.modules.system.service.ISysUserDepartService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -83,6 +85,9 @@ public class ProcessEsChangeServiceImpl extends ServiceImpl<ProcessEsChangeMappe
@Resource @Resource
private ProcessAllService processAllService; private ProcessAllService processAllService;
@Resource
private IBusProcessModelHisService busProcessModelHisService;
@Override @Override
public void startProcess(ESChangeDataVO changeData) { public void startProcess(ESChangeDataVO changeData) {
// 执行流程发起前的操作 // 执行流程发起前的操作
@@ -111,6 +116,13 @@ public class ProcessEsChangeServiceImpl extends ServiceImpl<ProcessEsChangeMappe
actFlowCommonService.setProcessVariables(processInstanceId, actVariables); actFlowCommonService.setProcessVariables(processInstanceId, actVariables);
// 设置流程实例Id // 设置流程实例Id
esChange.setProcessInstanceId(processInstanceId); esChange.setProcessInstanceId(processInstanceId);
// 设置替换文件id
OSSFile lastDocFileByStandardNo = busProcessModelHisService.findLastDocFileByStandardNo(esChange.getStandardNumber());
if (lastDocFileByStandardNo != null) {
esChange.setReplaceFileId(lastDocFileByStandardNo.getId());
} else {
esChange.setReplaceFileId(null);
}
// 保存到业务流程表 // 保存到业务流程表
saveOrUpdate(esChange); saveOrUpdate(esChange);
if (opinionList != null && !opinionList.isEmpty()) { if (opinionList != null && !opinionList.isEmpty()) {
@@ -3,6 +3,7 @@ package com.jero.modules.onlyoffice.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.onlyoffice.entity.BusProcessModelHis; import com.jero.modules.onlyoffice.entity.BusProcessModelHis;
import com.jero.modules.onlyoffice.entity.OnlineFileLog; import com.jero.modules.onlyoffice.entity.OnlineFileLog;
import com.jero.modules.oss.entity.OSSFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@@ -42,4 +43,6 @@ public interface IBusProcessModelHisService extends IService<BusProcessModelHis>
String saveProcessFileToOss(String hisId); String saveProcessFileToOss(String hisId);
BusProcessModelHis findEditFileByStandardNo(String standardNo); BusProcessModelHis findEditFileByStandardNo(String standardNo);
OSSFile findLastDocFileByStandardNo(String standardNo);
} }
@@ -387,7 +387,7 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl<BusProcessModelHi
MultipartFile multipartFile = BusProcessModelHisServiceImpl.convert(file); MultipartFile multipartFile = BusProcessModelHisServiceImpl.convert(file);
String savePath = CommonUtils.upload(multipartFile, "", uploadType); String savePath = CommonUtils.upload(multipartFile, "", uploadType);
OSSFile replaceFile = ossFileService.getById(replaceId); OSSFile replaceFile = ossFileService.getById(replaceId);
if (oConvertUtils.isNotEmpty(savePath)) { if (oConvertUtils.isNotEmpty(savePath) && replaceFile != null) {
// 文件名 // 文件名
String fileName = his.getFileName(); String fileName = his.getFileName();
fileName = CommonUtils.getFileName(fileName); fileName = CommonUtils.getFileName(fileName);
@@ -437,7 +437,8 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl<BusProcessModelHi
return this.saveEditFileWithOss(lastDocFileByStandardNo.getId()); return this.saveEditFileWithOss(lastDocFileByStandardNo.getId());
} }
private OSSFile findLastDocFileByStandardNo(String standardNo) { @Override
public OSSFile findLastDocFileByStandardNo(String standardNo) {
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
esWrapper.eq(LawsEnterpriseStandard::getStandardNumber, standardNo); esWrapper.eq(LawsEnterpriseStandard::getStandardNumber, standardNo);
LawsEnterpriseStandard es = eSService.getOne(esWrapper); LawsEnterpriseStandard es = eSService.getOne(esWrapper);