add onlyoffice接口
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.jero.modules.onlyoffice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.onlyoffice.entity.AttFileEO;
|
||||
import com.jero.modules.onlyoffice.entity.AttFileVo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface IAttFileEOService extends IService<AttFileEO> {
|
||||
|
||||
public AttFileVo saveFileInfo(File file);
|
||||
|
||||
public AttFileEO getFileInfo(String attId);
|
||||
|
||||
public AttFileEO updateFileInfo(String attId,String name);
|
||||
|
||||
void deleteById(String id);
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.jero.modules.onlyoffice.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.onlyoffice.entity.BusProcessModelHis;
|
||||
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程模块历史表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-09-17
|
||||
*/
|
||||
public interface IBusProcessModelHisService extends IService<BusProcessModelHis> {
|
||||
|
||||
BusProcessModelHis modelHisOneUpdStatusById(String id);
|
||||
|
||||
BusProcessModelHis modelHisOneUpdStatus(String pid,String taskId);
|
||||
|
||||
BusProcessModelHis modelHisOneCount(String pid);
|
||||
|
||||
BusProcessModelHis processEditFile(String id);
|
||||
|
||||
BusProcessModelHis modelHisOne(String pid,String taskId);
|
||||
|
||||
BusProcessModelHis saveEditFile(String model);
|
||||
|
||||
List<BusProcessModelHis> modelHisList(String pid);
|
||||
|
||||
OnlineFileLog selectOnlineFile(String onlineFileId);
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
package com.jero.modules.onlyoffice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.modules.onlyoffice.entity.AttFileEO;
|
||||
import com.jero.modules.onlyoffice.entity.AttFileVo;
|
||||
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
||||
import com.jero.modules.onlyoffice.mapper.AttFileEODao;
|
||||
import com.jero.modules.onlyoffice.mapper.BusProcessModelHisMapper;
|
||||
import com.jero.modules.onlyoffice.mapper.OnlineFileLogDao;
|
||||
import com.jero.modules.onlyoffice.service.impl.AttFileEOServiceImpl;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2023-09-14 11:13
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class LawsUserInfoService {
|
||||
@Value("${file.path}")
|
||||
private String standEditFilePath;
|
||||
@Autowired
|
||||
private IBusProcessModelHisService busProcessModelHisService;
|
||||
|
||||
@Autowired
|
||||
private BusProcessModelHisMapper busProcessModelHisMapper;
|
||||
@Autowired
|
||||
private AttFileEOServiceImpl attFileEOService;
|
||||
@Autowired
|
||||
private OnlineFileLogDao onlineFileLogDao;
|
||||
@Autowired
|
||||
private AttFileEODao attFileEODao;
|
||||
/**
|
||||
* 查找在线编辑文件
|
||||
* @param onlineFileId
|
||||
* @param standName
|
||||
* @param key
|
||||
*/
|
||||
public void selectOnlineFile(String onlineFileId, String standName, String key) {
|
||||
log.info("======================standName===============================!!!!!!!!!!!!!!!!!!!!!!"+standName);
|
||||
String path = standEditFilePath+"/hisFile/";
|
||||
File file = null;
|
||||
FileOutputStream fileOutputStream = null;
|
||||
BufferedOutputStream bufferedOutputStream = null;
|
||||
//下载位置
|
||||
OnlineFileLog onlineFileLog = busProcessModelHisService.selectOnlineFile(onlineFileId);
|
||||
long time = System.currentTimeMillis();
|
||||
if(onlineFileLog == null){
|
||||
return ;
|
||||
}
|
||||
try {
|
||||
file = new File(path+onlineFileLog.getOldFileName());
|
||||
boolean directory = file.isDirectory();
|
||||
//目录是否存在
|
||||
if(!directory){
|
||||
file.mkdirs();
|
||||
}
|
||||
file = new File(path+"/"+onlineFileLog.getOldFileName(),onlineFileLog.getOldFileName()+"."+onlineFileLog.getFileSuffix());
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
|
||||
fileOutputStream.write(onlineFileLog.getBytes());
|
||||
fileOutputStream.close();
|
||||
//把文件下载到本地 然后获得文件的名称 通过文件名称 调用 filesave接口 获取id 进行日志存入
|
||||
log.info("======================文件存储到本地成功,作为存储与Att表的桥梁===============================");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if(bufferedOutputStream!=null){
|
||||
bufferedOutputStream.close();
|
||||
}
|
||||
if(fileOutputStream!=null){
|
||||
fileOutputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//把文件放置到本地
|
||||
AttFileVo attFileVo = attFileEOService.saveFileInfo(file);
|
||||
log.info("======================文件成功存储到Att中==============================="+attFileVo.toString());
|
||||
//储存文件 一个文件夹 储存十个
|
||||
if(attFileVo!=null) {
|
||||
onlineFileLog.setAttFileId(attFileVo.getId());
|
||||
onlineFileLog.setUpdateTime(new Date());
|
||||
onlineFileLog.setCreateTime(new Date());
|
||||
onlineFileLog.setFileName(String.valueOf(time));
|
||||
onlineFileLog.setValidFlag("0");
|
||||
onlineFileLog.setFilekey(key);
|
||||
onlineFileLogDao.insert(onlineFileLog);
|
||||
log.info("======================日志存入成功==============================="+onlineFileLog.toString());
|
||||
if(StringUtils.isNotBlank(standName)) {
|
||||
AttFileEO attFileEO = new AttFileEO();
|
||||
attFileEO.setId(attFileVo.getId());
|
||||
attFileEO.setOldFileName(standName+".docx");
|
||||
attFileEODao.updateFileInfoById(attFileEO);
|
||||
log.info("======================文件名称修改成功==============================="+standName+".docx"+"======"+"传入对象为:"+attFileEO.getOldFileName());
|
||||
}
|
||||
//删除媒介桥梁文件
|
||||
if(file.delete()){
|
||||
//删除文件名称
|
||||
File fileTOW = new File(path+onlineFileLog.getOldFileName());
|
||||
if(fileTOW.delete()){
|
||||
File fileInfo = new File(path);
|
||||
if(fileInfo.delete()){
|
||||
log.info("======================桥梁文件删除成功===============================");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
log.info("======================桥梁文件删除失败!!!!!!!!===============================");
|
||||
}
|
||||
QueryWrapper<OnlineFileLog> onlineFileLogQueryWrapperHis = new QueryWrapper<>();
|
||||
onlineFileLogQueryWrapperHis.eq("HIS_ID",onlineFileId);
|
||||
onlineFileLogQueryWrapperHis.eq("VALID_FLAG","0");
|
||||
onlineFileLogQueryWrapperHis.orderByAsc("CREATE_TIME");
|
||||
List<OnlineFileLog> onlineFileLogs = onlineFileLogDao.selectList(onlineFileLogQueryWrapperHis);
|
||||
//建立删除
|
||||
// File deleteFileInfo = new File(path + onlineFileLog.getOLdFileName()+"/",onlineFileLogs.get(0).getFileName()+"."+onlineFileLogs.get(0).getFileSuffix());
|
||||
if(onlineFileLogs.size()>10){
|
||||
log.info("======================文件日志记录小于10==============================="+onlineFileLogs.size());
|
||||
QueryWrapper<OnlineFileLog> onlineFileLogQueryWrapper = new QueryWrapper<>();
|
||||
onlineFileLogQueryWrapper.eq("FILE_NAME",onlineFileLogs.get(0).getFileName());
|
||||
OnlineFileLog onlineFileLogIsNot = onlineFileLogDao.selectOne(onlineFileLogQueryWrapper);
|
||||
if(onlineFileLogIsNot!=null){
|
||||
//删除此处有关的数据
|
||||
AttFileEO fileInfo = attFileEOService.getFileInfo(onlineFileLogIsNot.getAttFileId());
|
||||
if(fileInfo!=null){
|
||||
File fileAtt = new File(standEditFilePath+fileInfo.getFilePath()+fileInfo.getFileName());
|
||||
if(fileAtt.delete()){
|
||||
attFileEOService.deleteById(onlineFileLogIsNot.getAttFileId());
|
||||
onlineFileLogDao.deleteById(onlineFileLogs.get(0).getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("删除成功"+onlineFileLogs.get(0).getId());
|
||||
}else {
|
||||
log.info("======================文件日志记录小于10==============================="+onlineFileLogs.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
package com.jero.modules.onlyoffice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.modules.ocr.util.UUIDUtils;
|
||||
import com.jero.modules.onlyoffice.entity.AttFileEO;
|
||||
import com.jero.modules.onlyoffice.entity.AttFileVo;
|
||||
import com.jero.modules.onlyoffice.mapper.AttFileEODao;
|
||||
import com.jero.modules.onlyoffice.service.IAttFileEOService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
@Service("attFileEOService")
|
||||
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
||||
@Slf4j
|
||||
public class AttFileEOServiceImpl extends ServiceImpl<AttFileEODao, AttFileEO> implements IAttFileEOService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AttFileEOServiceImpl.class);
|
||||
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
/**
|
||||
* 文件下载路径
|
||||
*/
|
||||
@Value("${file.downloadUrl}")
|
||||
private String downloadUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 保存文件并返回文件ID
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AttFileVo saveFileInfo(File file) {
|
||||
/**
|
||||
* 1、首先生成文件保存的主键ID
|
||||
* 2、根据文件ID生成随机路径
|
||||
* 3、生成文件名
|
||||
* 3、保存文件
|
||||
* 4、获取文件相关信息
|
||||
* 5、判断当前表是否有存在,如果存在则执行insert语句 如果不存在则创建表结构
|
||||
* 5、保存入库并返回主键ID
|
||||
*/
|
||||
AttFileVo attFileVo = new AttFileVo();
|
||||
String fileId = UUIDUtils.randomUUID20();
|
||||
try {
|
||||
String uuidPath = UUIDUtils.getUUIDPath(fileId);
|
||||
|
||||
String FileSavePath = filePath + uuidPath + "/";
|
||||
File dir = new File(FileSavePath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
String fileName = file.getName();
|
||||
String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1, fileName.length());
|
||||
String newFileName = fileId +"."+ fileSuffix;
|
||||
File saveFile = new File(FileSavePath + newFileName);
|
||||
FileUtils.copyFile(file,saveFile);
|
||||
//开始存储文件信息
|
||||
String tableName = UUIDUtils.getAttTable();
|
||||
int existTable = this.baseMapper.existTable(tableName);
|
||||
if (existTable == 0) {
|
||||
this.baseMapper.creatTableInfo(tableName);
|
||||
}
|
||||
fileId = tableName + "_" + fileId;
|
||||
AttFileEO attFileEO = new AttFileEO();
|
||||
attFileEO.setTableName(tableName);
|
||||
attFileEO.setId(fileId);
|
||||
attFileEO.setOldFileName(fileName);
|
||||
attFileEO.setFileSuffix(fileSuffix);
|
||||
attFileEO.setFilePath(uuidPath);
|
||||
attFileEO.setFileName(newFileName);
|
||||
attFileEO.setValidFlag(0);
|
||||
attFileEO.setCreationTime(new Date());
|
||||
attFileEO.setModifyTime(new Date());
|
||||
this.baseMapper.insertData(attFileEO);
|
||||
attFileVo.setId(fileId);
|
||||
attFileVo.setFileName(newFileName);
|
||||
attFileVo.setFilePath(uuidPath);
|
||||
attFileVo.setFileSuffix(fileSuffix);
|
||||
attFileVo.setOldFileName(fileName);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
return attFileVo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据文件ID获取文件信息
|
||||
*
|
||||
* @param attId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AttFileEO getFileInfo(String attId) {
|
||||
/**
|
||||
* 根据ID获取文件信息
|
||||
*/
|
||||
AttFileEO attFileEO = new AttFileEO();
|
||||
AttFileEO attFileInfo=null;
|
||||
try {
|
||||
attFileEO.setId(attId);
|
||||
attFileInfo = this.baseMapper.selectFileInfoById(attFileEO);
|
||||
return attFileInfo;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
return attFileEO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttFileEO updateFileInfo(String attId,String name) {
|
||||
/**
|
||||
* 根据ID获取文件信息
|
||||
*/
|
||||
AttFileEO attFileEO = new AttFileEO();
|
||||
AttFileEO attFileInfo=null;
|
||||
try {
|
||||
attFileEO.setId(attId);
|
||||
attFileInfo = this.baseMapper.selectFileInfoById(attFileEO);
|
||||
if (name.contains(".")) {
|
||||
int suffixIndex = name.lastIndexOf(".");
|
||||
String newSuffix = name.substring(suffixIndex+1).trim();
|
||||
if (StringUtils.equals(newSuffix.toUpperCase(),attFileInfo.getFileSuffix().toUpperCase())) {
|
||||
attFileInfo.setOldFileName(name);
|
||||
}else {
|
||||
String filename = name.substring(0,suffixIndex).trim();
|
||||
attFileInfo.setOldFileName(filename+"."+attFileInfo.getFileSuffix());
|
||||
}
|
||||
}else {
|
||||
attFileInfo.setOldFileName(name.trim()+"."+attFileEO.getFileSuffix());
|
||||
}
|
||||
this.baseMapper.updateFileInfoById(attFileInfo);
|
||||
return attFileInfo;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
return attFileInfo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
if(StringUtils.isNotBlank(id)){
|
||||
String[] s = id.split("_");
|
||||
List<String> asList = Arrays.asList(s);
|
||||
String str = "att_file_"+asList.get(2);
|
||||
baseMapper.deleteByIdInfo(str,id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyFile1(String srcPath, String destPath) throws IOException {
|
||||
// 打开输入流
|
||||
FileInputStream fis = new FileInputStream(srcPath);
|
||||
// 打开输出流
|
||||
FileOutputStream fos = new FileOutputStream(destPath);
|
||||
// 读取和写入信息
|
||||
int len = 0;
|
||||
while ((len = fis.read()) != -1) {
|
||||
fos.write(len);
|
||||
}
|
||||
// 关闭流 先开后关 后开先关
|
||||
fos.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
package com.jero.modules.onlyoffice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.modules.onlyoffice.entity.BusProcessModelHis;
|
||||
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
||||
import com.jero.modules.onlyoffice.mapper.BusProcessModelHisMapper;
|
||||
import com.jero.modules.onlyoffice.service.IBusProcessModelHisService;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程模块历史表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-09-17
|
||||
*/
|
||||
@Service
|
||||
public class BusProcessModelHisServiceImpl extends ServiceImpl<BusProcessModelHisMapper, BusProcessModelHis> implements IBusProcessModelHisService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BusProcessModelHisServiceImpl.class);
|
||||
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
/**
|
||||
* 文件下载路径
|
||||
*/
|
||||
@Value("${file.downloadUrl}")
|
||||
private String downloadUrl;
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis saveEditFile(String model){
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
try {
|
||||
|
||||
String preUuid2 = UUID.randomUUID().toString();
|
||||
String changUuid = preUuid2.substring(0,8);
|
||||
String taskId = "task_"+changUuid;
|
||||
String topId = "top_"+changUuid;
|
||||
|
||||
StringBuilder builderModel=new StringBuilder();
|
||||
builderModel.append("model").append("/");
|
||||
builderModel.append("model").append("/");
|
||||
|
||||
|
||||
File dir = new File(filePath+builderModel.toString());
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
String sourcePath = builderModel.toString()+model+".docx";
|
||||
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("model").append("/");
|
||||
builder.append(taskId).append("/");
|
||||
|
||||
File file = new File(filePath+builder.toString());
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
|
||||
String targetPath = builder.toString()+taskId+"_"+topId+"_node.docx";
|
||||
|
||||
File sourceFile = new File(filePath+sourcePath);
|
||||
File targetFile = new File(filePath+targetPath);
|
||||
FileUtils.copyFile(sourceFile, targetFile);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
||||
modelHis.setTaskId(taskId);
|
||||
modelHis.setPId(topId);
|
||||
modelHis.setEditFilePath(targetPath);
|
||||
modelHis.setCreateTime(sdf.format(new Date()));
|
||||
modelHis.setUpdateTime(sdf.format(new Date()));
|
||||
this.baseMapper.insert(modelHis);
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnlineFileLog selectOnlineFile(String onlineFileId) {
|
||||
BusProcessModelHis busProcessModelHis = baseMapper.selectById(onlineFileId);
|
||||
OnlineFileLog onlineFileLog = new OnlineFileLog();
|
||||
byte[] bytes = new byte[0];
|
||||
if(busProcessModelHis!=null){
|
||||
//获取当前文件路径 返回文件路径的数字组
|
||||
try {
|
||||
String editFilePath = busProcessModelHis.getEditFilePath();
|
||||
File file = new File(filePath+editFilePath);
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024);
|
||||
byte [] aByte = new byte[1024];
|
||||
int n;
|
||||
while ((n = fileInputStream.read(aByte)) != -1){
|
||||
byteArrayOutputStream.write(aByte,0,n);
|
||||
}
|
||||
bytes = byteArrayOutputStream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
onlineFileLog.setHisId(busProcessModelHis.getId());
|
||||
onlineFileLog.setFilePath(busProcessModelHis.getEditFilePath());
|
||||
if(StringUtils.isNotBlank(busProcessModelHis.getEditFilePath())){
|
||||
String[] split = busProcessModelHis.getEditFilePath().split("\\.");
|
||||
onlineFileLog.setFileSuffix(split[1]);
|
||||
}
|
||||
if(StringUtils.isNotBlank(busProcessModelHis.getEditFilePath())){
|
||||
String[] split = busProcessModelHis.getEditFilePath().split("/");
|
||||
String[] split1 = split[2].split("\\.");
|
||||
onlineFileLog.setOldFileName(split1[0]);
|
||||
}
|
||||
onlineFileLog.setBytes(bytes);
|
||||
}
|
||||
return onlineFileLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 企标流程文件存储
|
||||
* @param pid
|
||||
* @param taskId
|
||||
* @param fileSuffix
|
||||
* @param filePath 文件存储路径
|
||||
* @throws IOException
|
||||
*/
|
||||
public String saveProcessFile(String filePath,String pid,String taskId,String fileSuffix){
|
||||
|
||||
String fileSavePath = "bussEdit"+ getUUIDPath(pid,taskId);
|
||||
String newFileName = "";
|
||||
try {
|
||||
|
||||
File dir = new File(fileSavePath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
newFileName = fileSavePath + taskId + "_" + pid + "_node." + fileSuffix;
|
||||
File saveFile = new File(filePath + newFileName);
|
||||
FileUtils.write(saveFile, "","UTF-8");
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
public static String getUUIDPath(String pid,String taskId){
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append("/");
|
||||
builder.append(pid).append("/");
|
||||
// builder.append(taskId).append("/");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis modelHisOneUpdStatusById(String id){
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
modelHis.setId(id);
|
||||
modelHis.setEditStatus("1");
|
||||
this.baseMapper.updateById(modelHis);
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis modelHisOneUpdStatus(String pid,String taskId){
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("P_ID",pid);
|
||||
wrapper.eq("TASK_ID",taskId);
|
||||
List<BusProcessModelHis> hisList = this.baseMapper.selectList(wrapper);
|
||||
if(!hisList.isEmpty()){
|
||||
modelHis = hisList.get(0);
|
||||
modelHis.setEditStatus("1");
|
||||
this.baseMapper.updateById(modelHis);
|
||||
}
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis modelHisOneCount(String pid){
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("P_ID",pid);
|
||||
wrapper.eq("EDIT_TYPE","count");
|
||||
List<BusProcessModelHis> hisList = this.baseMapper.selectList(wrapper);
|
||||
if(!hisList.isEmpty()){
|
||||
modelHis = hisList.get(0);
|
||||
StringBuffer downloadFileUrl = new StringBuffer();
|
||||
downloadFileUrl.append(downloadUrl).append(modelHis.getEditFilePath() == null ? "" : modelHis.getEditFilePath());
|
||||
modelHis.setDownLoadUrl(downloadFileUrl.toString());
|
||||
}
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis processEditFile(String id){
|
||||
BusProcessModelHis modelHis = this.baseMapper.selectById(id);
|
||||
if(StringUtils.isNotBlank(modelHis.getId())){
|
||||
StringBuffer downloadFileUrl = new StringBuffer();
|
||||
downloadFileUrl.append(downloadUrl).append(modelHis.getEditFilePath() == null ? "" : modelHis.getEditFilePath());
|
||||
modelHis.setDownLoadUrl(downloadFileUrl.toString());
|
||||
}
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis modelHisOne(String pid,String taskId){
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("P_ID",pid);
|
||||
wrapper.eq("TASK_ID",taskId);
|
||||
List<BusProcessModelHis> hisList = this.baseMapper.selectList(wrapper);
|
||||
if(!hisList.isEmpty()){
|
||||
modelHis = hisList.get(0);
|
||||
StringBuffer downloadFileUrl = new StringBuffer();
|
||||
downloadFileUrl.append(downloadUrl).append(modelHis.getEditFilePath() == null ? "" : modelHis.getEditFilePath());
|
||||
modelHis.setDownLoadUrl(downloadFileUrl.toString());
|
||||
}
|
||||
return modelHis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BusProcessModelHis> modelHisList(String pid){
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("P_ID",pid);
|
||||
return this.baseMapper.selectList(wrapper);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user