feat: 在线编辑调整 无用代码删除

This commit is contained in:
2024-09-23 16:54:30 +08:00
parent 2446a51741
commit a7516d5b95
8 changed files with 19 additions and 714 deletions
@@ -1,280 +0,0 @@
package com.jero.modules.onlyoffice.entity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.util.Date;
/**
* <b>功能:</b>ATT_FILE AttFileEOEntity<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2018-09-07 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
// TODO 等在线编辑正式上线时,把该部分去掉,此部分在正式功能中无用
public class AttFileEO implements Serializable {
private static final long serialVersionUID = 1284335706608668758L;
private static final Logger logger = LoggerFactory.getLogger(AttFileEO.class);
private String id;
private String fileName;
private String oldFileName;
private String fileSuffix;
private String filePath;
private Integer validFlag;
@org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date creationTime;
@org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date modifyTime;
private String tableName;
private String resId;
/**
* 文件下载地址
*/
private String downLoadUrl;
/**
* java字段名转换为原始数据库列名。<b>如果不存在则返回null</b><br>
* <p>字段列表:</p>
* <li>id -> id</li>
* <li>fileName -> file_name</li>
* <li>oldFileName -> old_file_name</li>
* <li>fileSuffix -> file_suffix</li>
* <li>filePath -> file_path</li>
* <li>validFlag -> valid_flag</li>
* <li>creationTime -> creation_time</li>
* <li>modifyTime -> modify_time</li>
*/
public static String fieldToColumn(String fieldName) {
if (fieldName == null) {
return null;
}
switch (fieldName) {
case "id":
return "id";
case "fileName":
return "file_name";
case "oldFileName":
return "old_file_name";
case "fileSuffix":
return "file_suffix";
case "filePath":
return "file_path";
case "validFlag":
return "valid_flag";
case "creationTime":
return "creation_time";
case "modifyTime":
return "modify_time";
default:
return null;
}
}
/**
* 原始数据库列名转换为java字段名。<b>如果不存在则返回null</b><br>
* <p>字段列表:</p>
* <li>id -> id</li>
* <li>file_name -> fileName</li>
* <li>old_file_name -> oldFileName</li>
* <li>file_suffix -> fileSuffix</li>
* <li>file_path -> filePath</li>
* <li>valid_flag -> validFlag</li>
* <li>creation_time -> creationTime</li>
* <li>modify_time -> modifyTime</li>
*/
public static String columnToField(String columnName) {
if (columnName == null) {
return null;
}
switch (columnName) {
case "id":
return "id";
case "file_name":
return "fileName";
case "old_file_name":
return "oldFileName";
case "file_suffix":
return "fileSuffix";
case "file_path":
return "filePath";
case "valid_flag":
return "validFlag";
case "creation_time":
return "creationTime";
case "modify_time":
return "modifyTime";
default:
return null;
}
}
/**
*
**/
public String getId() {
int tableNameIndex = this.id.lastIndexOf("_");
if (tableNameIndex != -1) {
String tableName = this.id.substring(0, tableNameIndex);
this.tableName = tableName;
} else {
logger.error("文件ID格式错误:" + this.id);
}
return this.id;
}
/**
*
**/
public void setId(String id) {
if (tableName != null && !tableName.isEmpty()) {
this.id = tableName + "_" + id;
}
//此处注意保存时表结构是否存在
this.id = id;
}
/**
*
**/
public String getFileName() {
return this.fileName;
}
/**
*
**/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
*
**/
public String getOldFileName() {
return this.oldFileName;
}
/**
*
**/
public void setOldFileName(String oldFileName) {
this.oldFileName = oldFileName;
}
/**
*
**/
public String getFileSuffix() {
return this.fileSuffix;
}
/**
*
**/
public void setFileSuffix(String fileSuffix) {
this.fileSuffix = fileSuffix;
}
/**
*
**/
public String getFilePath() {
return this.filePath;
}
/**
*
**/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
/**
*
**/
public Integer getValidFlag() {
return this.validFlag;
}
/**
*
**/
public void setValidFlag(Integer validFlag) {
this.validFlag = validFlag;
}
/**
*
**/
public Date getCreationTime() {
return this.creationTime;
}
/**
*
**/
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
/**
*
**/
public Date getModifyTime() {
return this.modifyTime;
}
/**
*
**/
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getTableName() {
if (this.tableName != null && !this.tableName.isEmpty()) {
return this.tableName;
} else {
int tableNameIndex = this.id.lastIndexOf("_");
if (tableNameIndex != -1) {
String tableName = this.id.substring(0, tableNameIndex);
this.tableName = tableName;
} else {
logger.error("文件ID格式错误:" + this.id);
}
return this.tableName;
}
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getResId() {
return resId;
}
public void setResId(String resId) {
this.resId = resId;
}
public String getDownLoadUrl() {
return downLoadUrl;
}
public void setDownLoadUrl(String downLoadUrl) {
this.downLoadUrl = downLoadUrl;
}
}
@@ -1,91 +0,0 @@
package com.jero.modules.onlyoffice.entity;
// TODO 等在线编辑正式上线时,把该部分去掉,此部分在正式功能中无用
public class AttFileVo {
private String id;
private String fileName;
private String oldFileName;
private String fileSuffix;
private String filePath;
private String attId;
private String name;
//识别文件名中的标准号和名称
private String standNum;
private String standName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getOldFileName() {
return oldFileName;
}
public void setOldFileName(String oldFileName) {
this.oldFileName = oldFileName;
}
public String getFileSuffix() {
return fileSuffix;
}
public void setFileSuffix(String fileSuffix) {
this.fileSuffix = fileSuffix;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getName() {
this.name = this.oldFileName;
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getAttId() {
this.attId=this.id;
return this.attId;
}
public void setAttId(String attId) {
this.attId = attId;
}
public String getStandNum() {
return standNum;
}
public void setStandNum(String standNum) {
this.standNum = standNum;
}
public String getStandName() {
return standName;
}
public void setStandName(String standName) {
this.standName = standName;
}
}
@@ -10,14 +10,7 @@ import lombok.Getter;
public enum StandardFileType {
FILE_PUBLISH_OF_ORIGINAL("发布稿", "publish_of_original", 1), // 发布稿
FILE_MODIFICATION_LIST("修改单", "modification_list", 2), // 修改单
FILE_DRAFT_FOR_REVIEW("报批稿", "draft_for_review", 3), // 报批稿
FILE_DRAFT_FOR_APPROVAL("送审稿", "draft_for_approval", 4), // 送审稿
FILE_DRAFT_FOR_COMMENT("征求意见稿", "draft_for_comment", 5), // 征求意见稿
FILE_DRAFT("草稿", "draft", 6), // 草稿
TEST_PROCEDURES("测试规程", "test_procedures", 7), // 草稿
OTHER_FILES("其他文件", "other_files", 8), // 草稿
INTERPRET_DOCUMENT("解读文件", "interpret_document", 9); // 解读文件
FILE_DRAFT_FOR_COMMENT("征求意见稿", "draft_for_comment", 2); // 征求意见稿
private final String name;
@@ -1,28 +0,0 @@
package com.jero.modules.onlyoffice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.modules.onlyoffice.entity.AttFileEO;
import org.apache.ibatis.annotations.Param;
/**
*
* <br>
* <b>功能:</b>ATT_FILE AttFileEODao<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2018-09-07 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public interface AttFileEODao extends BaseMapper<AttFileEO> {
public void creatTableInfo(@Param("tableName") String tableName);
public int existTable(@Param("tableName") String tableName);
public AttFileEO selectFileInfoById(AttFileEO attFileEO);
public int updateFileInfoById(AttFileEO attFileEO);
public int insertData(AttFileEO attFileEO);
void deleteByIdInfo(String str, String id);
}
@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jero.modules.onlyoffice.mapper.AttFileEODao" >
<!-- Result Map-->
<resultMap id="BaseResultMap" type="com.jero.modules.onlyoffice.entity.AttFileEO" >
<id column="id" property="id" />
<result column="file_name" property="fileName" />
<result column="old_file_name" property="oldFileName" />
<result column="file_suffix" property="fileSuffix" />
<result column="file_path" property="filePath" />
<result column="valid_flag" property="validFlag" />
<result column="creation_time" property="creationTime" />
<result column="modify_time" property="modifyTime" />
</resultMap>
<!-- ATT_FILE table all fields -->
<sql id="Base_Column_List" >
id, file_name, old_file_name, file_suffix, file_path, valid_flag, creation_time, modify_time
</sql>
<update id="creatTableInfo" parameterType="java.lang.String">
create table ${tableName}
(
id varchar(100) not null primary key,
file_name varchar(255) null,
old_file_name varchar(255) null,
file_suffix varchar(30) null,
file_path varchar(255) null,
valid_flag int(1) null,
creation_time date null,
modify_time date null
)
</update>
<select id="existTable" parameterType="java.lang.String" resultType="java.lang.Integer">
select count(*) from information_schema.TABLES where table_name = #{tableName}
</select>
<!-- 查询条件 -->
<sql id="Base_Where_Clause">
where 1=1
<trim suffixOverrides="," >
<if test="id != null" >
and id ${idOperator} #{id}
</if>
<if test="fileName != null" >
and file_name ${fileNameOperator} #{fileName}
</if>
<if test="oldFileName != null" >
and old_file_name ${oldFileNameOperator} #{oldFileName}
</if>
<if test="fileSuffix != null" >
and file_suffix ${fileSuffixOperator} #{fileSuffix}
</if>
<if test="filePath != null" >
and file_path ${filePathOperator} #{filePath}
</if>
<if test="validFlag != null" >
and valid_flag ${validFlagOperator} #{validFlag}
</if>
<if test="creationTime != null" >
and creation_time ${creationTimeOperator} #{creationTime}
</if>
<if test="creationTime1 != null" >
and creation_time &gt;= #{creationTime1}
</if>
<if test="creationTime2 != null" >
and creation_time &lt;= #{creationTime2}
</if>
<if test="modifyTime != null" >
and modify_time ${modifyTimeOperator} #{modifyTime}
</if>
<if test="modifyTime1 != null" >
and modify_time &gt;= #{modifyTime1}
</if>
<if test="modifyTime2 != null" >
and modify_time &lt;= #{modifyTime2}
</if>
</trim>
</sql>
<!-- 插入记录 -->
<insert id="insertData" parameterType="com.jero.modules.onlyoffice.entity.AttFileEO" >
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
SELECT SEQ_ATT_FILE.NEXTVAL FROM DUAL
</selectKey> -->
insert into ${tableName}(<include refid="Base_Column_List" />)
values (#{id, jdbcType=VARCHAR}, #{fileName, jdbcType=VARCHAR}, #{oldFileName, jdbcType=VARCHAR}, #{fileSuffix, jdbcType=VARCHAR}, #{filePath, jdbcType=VARCHAR}, #{validFlag, jdbcType=INTEGER}, #{creationTime, jdbcType=TIMESTAMP}, #{modifyTime, jdbcType=TIMESTAMP})
</insert>
<select id="selectFileInfoById" resultMap="BaseResultMap" parameterType="com.jero.modules.onlyoffice.entity.AttFileEO">
select <include refid="Base_Column_List" />
from ${tableName}
where id = #{id}
</select>
<update id="updateFileInfoById">
update ${tableName} set OLD_FILE_NAME = #{oldFileName} where id = #{id}
</update>
<delete id="deleteByIdInfo" parameterType="java.lang.String">
delete from ${str} where id = #{id}
</delete>
</mapper>
@@ -1,22 +0,0 @@
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);
}
@@ -1,169 +0,0 @@
package com.jero.modules.onlyoffice.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.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);
}
}
}
@@ -12,11 +12,11 @@ import com.jero.common.util.oConvertUtils;
import com.jero.modules.laws.common.constant.FieldCommon;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.onlyoffice.entity.ProcessFile;
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
import com.jero.modules.onlyoffice.entity.ProcessFile;
import com.jero.modules.onlyoffice.entity.StandardFileType;
import com.jero.modules.onlyoffice.mapper.ProcessFileMapper;
import com.jero.modules.onlyoffice.mapper.OnlineFileLogDao;
import com.jero.modules.onlyoffice.mapper.ProcessFileMapper;
import com.jero.modules.onlyoffice.service.IProcessFileService;
import com.jero.modules.onlyoffice.utils.OnlyOfficePdfUtil;
import com.jero.modules.oss.entity.OSSFile;
@@ -92,7 +92,10 @@ public class ProcessFileServiceImpl extends ServiceImpl<ProcessFileMapper, Proce
File dir = new File(filePath + builderModel);
if (!dir.exists()) {
dir.mkdirs();
boolean mkdirs = dir.mkdirs();
if (!mkdirs) {
throw new JeroBootException("创建目录失败");
}
}
String fileName = model + ".docx";
modelHis.setFileName(fileName);
@@ -100,12 +103,15 @@ public class ProcessFileServiceImpl extends ServiceImpl<ProcessFileMapper, Proce
builder.append("model").append("/");
builder.append(taskId).append("/");
File file = new File(filePath + builder.toString());
File file = new File(filePath + builder);
if (!file.exists()) {
file.mkdirs();
boolean mkdirs = file.mkdirs();
if (!mkdirs) {
throw new JeroBootException("创建目录失败");
}
}
String targetPath = builder.toString() + taskId + "_" + topId + "_node.docx";
String targetPath = builder + taskId + "_" + topId + "_node.docx";
File sourceFile = new File(sourceFilePath);
File targetFile = new File(filePath + targetPath);
@@ -183,7 +189,10 @@ public class ProcessFileServiceImpl extends ServiceImpl<ProcessFileMapper, Proce
private void createDirectoryIfNotExists(String directoryPath) {
File dir = new File(directoryPath);
if (!dir.exists()) {
dir.mkdirs();
boolean mkdirs = dir.mkdirs();
if (!mkdirs) {
throw new JeroBootException("创建目录失败");
}
}
}
@@ -206,7 +215,7 @@ public class ProcessFileServiceImpl extends ServiceImpl<ProcessFileMapper, Proce
}
bytes = byteArrayOutputStream.toByteArray();
} catch (IOException e) {
e.printStackTrace();
log.error("文件读取失败:" + e.getMessage());
}
onlineFileLog.setHisId(ProcessFile.getId());
onlineFileLog.setFilePath(ProcessFile.getEditFilePath());
@@ -345,9 +354,7 @@ public class ProcessFileServiceImpl extends ServiceImpl<ProcessFileMapper, Proce
public ProcessFile processEditFile(String id) {
ProcessFile 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());
modelHis.setDownLoadUrl(downloadUrl + (modelHis.getEditFilePath() == null ? "" : modelHis.getEditFilePath()));
}
return modelHis;
}