From a7516d5b957995710a4f4bf3de8f790f6a2aa125 Mon Sep 17 00:00:00 2001 From: caihaohan Date: Tue, 10 Sep 2024 17:37:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E7=BA=BF=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4=20=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/onlyoffice/entity/AttFileEO.java | 280 ------------------ .../modules/onlyoffice/entity/AttFileVo.java | 91 ------ .../onlyoffice/entity/StandardFileType.java | 9 +- .../onlyoffice/mapper/AttFileEODao.java | 28 -- .../onlyoffice/mapper/xml/AttFileEOMapper.xml | 105 ------- .../onlyoffice/service/IAttFileEOService.java | 22 -- .../service/impl/AttFileEOServiceImpl.java | 169 ----------- .../service/impl/ProcessFileServiceImpl.java | 29 +- 8 files changed, 19 insertions(+), 714 deletions(-) delete mode 100644 laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileEO.java delete mode 100644 laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileVo.java delete mode 100644 laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/AttFileEODao.java delete mode 100644 laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/xml/AttFileEOMapper.xml delete mode 100644 laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IAttFileEOService.java delete mode 100644 laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/AttFileEOServiceImpl.java diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileEO.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileEO.java deleted file mode 100644 index 6ac45f3f..00000000 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileEO.java +++ /dev/null @@ -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; - -/** - * 功能:ATT_FILE AttFileEOEntity
- * 作者:code generator
- * 日期: 2018-09-07
- * 版权所有:版权归北京卡达克数据技术中心所有。
- */ -// 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字段名转换为原始数据库列名。如果不存在则返回null
- *

字段列表:

- *
  • id -> id
  • - *
  • fileName -> file_name
  • - *
  • oldFileName -> old_file_name
  • - *
  • fileSuffix -> file_suffix
  • - *
  • filePath -> file_path
  • - *
  • validFlag -> valid_flag
  • - *
  • creationTime -> creation_time
  • - *
  • modifyTime -> modify_time
  • - */ - 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字段名。如果不存在则返回null
    - *

    字段列表:

    - *
  • id -> id
  • - *
  • file_name -> fileName
  • - *
  • old_file_name -> oldFileName
  • - *
  • file_suffix -> fileSuffix
  • - *
  • file_path -> filePath
  • - *
  • valid_flag -> validFlag
  • - *
  • creation_time -> creationTime
  • - *
  • modify_time -> modifyTime
  • - */ - 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; - } -} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileVo.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileVo.java deleted file mode 100644 index 97c03bc9..00000000 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileVo.java +++ /dev/null @@ -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; - } -} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/StandardFileType.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/StandardFileType.java index 33ecd7f7..e59dfa22 100644 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/StandardFileType.java +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/StandardFileType.java @@ -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; diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/AttFileEODao.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/AttFileEODao.java deleted file mode 100644 index 6897cef2..00000000 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/AttFileEODao.java +++ /dev/null @@ -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; - -/** - * - *
    - * 功能:ATT_FILE AttFileEODao
    - * 作者:code generator
    - * 日期: 2018-09-07
    - * 版权所有:版权归北京卡达克数据技术中心所有。
    - */ -public interface AttFileEODao extends BaseMapper { - - 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); -} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/xml/AttFileEOMapper.xml b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/xml/AttFileEOMapper.xml deleted file mode 100644 index 26f6c685..00000000 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/xml/AttFileEOMapper.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - id, file_name, old_file_name, file_suffix, file_path, valid_flag, creation_time, modify_time - - - - 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 - ) - - - - - - - where 1=1 - - - and id ${idOperator} #{id} - - - and file_name ${fileNameOperator} #{fileName} - - - and old_file_name ${oldFileNameOperator} #{oldFileName} - - - and file_suffix ${fileSuffixOperator} #{fileSuffix} - - - and file_path ${filePathOperator} #{filePath} - - - and valid_flag ${validFlagOperator} #{validFlag} - - - and creation_time ${creationTimeOperator} #{creationTime} - - - and creation_time >= #{creationTime1} - - - and creation_time <= #{creationTime2} - - - and modify_time ${modifyTimeOperator} #{modifyTime} - - - and modify_time >= #{modifyTime1} - - - and modify_time <= #{modifyTime2} - - - - - - - - insert into ${tableName}() - 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}) - - - - - update ${tableName} set OLD_FILE_NAME = #{oldFileName} where id = #{id} - - - - delete from ${str} where id = #{id} - - - diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IAttFileEOService.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IAttFileEOService.java deleted file mode 100644 index 79ad2027..00000000 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IAttFileEOService.java +++ /dev/null @@ -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 { - - public AttFileVo saveFileInfo(File file); - - public AttFileEO getFileInfo(String attId); - - public AttFileEO updateFileInfo(String attId,String name); - - void deleteById(String id); - -} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/AttFileEOServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/AttFileEOServiceImpl.java deleted file mode 100644 index 2b3adbfb..00000000 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/AttFileEOServiceImpl.java +++ /dev/null @@ -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 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 asList = Arrays.asList(s); - String str = "att_file_" + asList.get(2); - baseMapper.deleteByIdInfo(str, id); - } - } - -} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java index 2c8d757e..bb90a094 100644 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java @@ -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