add onlyoffice接口
This commit is contained in:
+272
@@ -0,0 +1,272 @@
|
||||
package com.jero.modules.onlyoffice.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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 com.jero.modules.onlyoffice.service.LawsUserInfoService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程模块历史表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-09-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/onlyoffice")
|
||||
public class BusProcessModelHisController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BusProcessModelHisController.class);
|
||||
|
||||
@Value("${file.path}")
|
||||
private String standEditFilePath;//文件存储路径
|
||||
|
||||
@Autowired
|
||||
private IBusProcessModelHisService busProcessModelHisService;
|
||||
|
||||
@Autowired
|
||||
private LawsUserInfoService lawsUserInfoService;
|
||||
|
||||
@Autowired
|
||||
private BusProcessModelHisMapper busProcessModelHisMapper;
|
||||
|
||||
@ApiOperation(value = "|onlyOffice接收文件")
|
||||
@PostMapping("/recieveFile")
|
||||
public void recieveFile(HttpServletRequest request, HttpServletResponse response, String fileNm, String standNo, String fileId,String standName,String key){
|
||||
logger.info("**********进入onlyoffice接收文档接口************");
|
||||
logger.info("**********fileNm************"+fileNm+"=======");
|
||||
logger.info("**********standNo************"+standNo+"=======");
|
||||
logger.info("**********fileId************"+fileId+"=======");
|
||||
logger.info("**********standName************"+standName+"=======");
|
||||
logger.info("**********key************"+key+"=======");
|
||||
try {
|
||||
PrintWriter writer = response.getWriter();
|
||||
String body = "";
|
||||
try {
|
||||
Scanner scanner = new Scanner(request.getInputStream());
|
||||
scanner.useDelimiter("\\A");
|
||||
body = scanner.hasNext() ? scanner.next() : "";
|
||||
scanner.close();
|
||||
} catch (Exception ex) {
|
||||
writer.write("get request.getInputStream error:" + ex.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (body.isEmpty()) {
|
||||
writer.write("empty request.getInputStream");
|
||||
return;
|
||||
}
|
||||
|
||||
net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(body);
|
||||
logger.info("**********onlyoffice接收文档接口获得结果body************" + body);
|
||||
int status = (Integer) jsonObj.get("status");
|
||||
|
||||
int saved = 0;
|
||||
if (status == 2 || status == 3 || status == 6)//MustSave, Corrupted
|
||||
{
|
||||
String downloadUri = (String) jsonObj.get("url");
|
||||
|
||||
try {
|
||||
logger.info("**********onlyoffice接收文档接口获得downloadUri************" + downloadUri);
|
||||
if (StringUtils.isNotEmpty(downloadUri)) {
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append(standEditFilePath);
|
||||
builder.append(standNo).append("/");
|
||||
builder.append(fileNm);
|
||||
String saveFileUrl = builder.toString();
|
||||
File file = new File(saveFileUrl);
|
||||
downloadNetFile(downloadUri, file);
|
||||
// 更新在线编辑当前节点编辑状态
|
||||
busProcessModelHisService.modelHisOneUpdStatusById(fileId);
|
||||
Object keyObj = jsonObj.get("key");
|
||||
if(keyObj!=null){
|
||||
key = keyObj.toString();
|
||||
logger.info("**********key************"+key+"=======");
|
||||
}
|
||||
lawsUserInfoService.selectOnlineFile(fileId,standName,key);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
saved = 1;
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + ex.getMessage());
|
||||
logger.error(ex.getMessage(),ex);
|
||||
}
|
||||
} else if (status == 4) {
|
||||
logger.info("**********onlyoffice接收文档接口开始修改文件状态状态4************");
|
||||
|
||||
logger.info("**********onlyoffice接收文档接口修改文件状态成功状态4************");
|
||||
}
|
||||
logger.info("onlyoffice编辑完成--------------");
|
||||
writer.write("{\"error\":" + saved + "}");
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + e.getMessage());
|
||||
logger.error(e.getMessage(),e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|onlyOffice接收文件")
|
||||
@PostMapping("/recieveFileBefore")
|
||||
public void recieveFileBefore(HttpServletRequest request, HttpServletResponse response,String key, String fileNm, String standNo, String pid, String taskId ,String standName){
|
||||
logger.info("**********进入onlyoffice接收文档接口************");
|
||||
logger.info("**********fileNm************"+fileNm+"=======");
|
||||
logger.info("**********standNo************"+standNo+"=======");
|
||||
logger.info("**********pid************"+pid+"=======");
|
||||
logger.info("**********taskId************"+taskId+"=======");
|
||||
logger.info("**********standName************"+standName+"=======");
|
||||
logger.info("**********key************"+key+"=======");
|
||||
|
||||
try {
|
||||
PrintWriter writer = response.getWriter();
|
||||
String body = "";
|
||||
try {
|
||||
Scanner scanner = new Scanner(request.getInputStream());
|
||||
scanner.useDelimiter("\\A");
|
||||
body = scanner.hasNext() ? scanner.next() : "";
|
||||
scanner.close();
|
||||
} catch (Exception ex) {
|
||||
writer.write("get request.getInputStream error:" + ex.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (body.isEmpty()) {
|
||||
writer.write("empty request.getInputStream");
|
||||
return;
|
||||
}
|
||||
|
||||
net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(body);
|
||||
logger.info("**********onlyoffice接收文档接口获得结果body************" + body);
|
||||
int status = (Integer) jsonObj.get("status");
|
||||
|
||||
int saved = 0;
|
||||
if (status == 2 || status == 3 ||status == 6)//MustSave, Corrupted
|
||||
{
|
||||
String downloadUri = (String) jsonObj.get("url");
|
||||
|
||||
try {
|
||||
logger.info("**********onlyoffice接收文档接口获得downloadUri************" + downloadUri);
|
||||
if (StringUtils.isNotEmpty(downloadUri)) {
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append(standEditFilePath);
|
||||
builder.append(standNo).append("/");
|
||||
builder.append(fileNm);
|
||||
String saveFileUrl = builder.toString();
|
||||
File file = new File(saveFileUrl);
|
||||
downloadNetFile(downloadUri, file);
|
||||
// 更新在线编辑当前节点编辑状态
|
||||
busProcessModelHisService.modelHisOneUpdStatus(pid,taskId);
|
||||
QueryWrapper<BusProcessModelHis> objectQueryWrapper = new QueryWrapper<>();
|
||||
objectQueryWrapper.eq("P_ID",pid);
|
||||
objectQueryWrapper.eq("TASK_ID",taskId);
|
||||
BusProcessModelHis busProcessModelHis = busProcessModelHisMapper.selectOne(objectQueryWrapper);
|
||||
if(busProcessModelHis!=null){
|
||||
Object keyObj = jsonObj.get("key");
|
||||
if(keyObj!=null){
|
||||
key = keyObj.toString();
|
||||
logger.info("**********key************"+key+"=======");
|
||||
}
|
||||
lawsUserInfoService.selectOnlineFile(busProcessModelHis.getId(), standName,key);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
saved = 1;
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + ex.getMessage());
|
||||
logger.error(ex.getMessage(),ex);
|
||||
}
|
||||
} else if (status == 4) {
|
||||
logger.info("**********onlyoffice接收文档接口开始修改文件状态状态4************");
|
||||
|
||||
logger.info("**********onlyoffice接收文档接口修改文件状态成功状态4************");
|
||||
}
|
||||
logger.info("onlyoffice编辑完成--------------");
|
||||
writer.write("{\"error\":" + saved + "}");
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + e.getMessage());
|
||||
logger.error(e.getMessage(),e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void downloadNetFile(String downloadUrl, File file) {
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
URL url = new URL(downloadUrl);
|
||||
URLConnection connection = url.openConnection();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
int length = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((length = inputStream.read(bytes)) != -1) {
|
||||
fileOutputStream.write(bytes, 0, length);
|
||||
}
|
||||
fileOutputStream.close();
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("download error ! url :{}, exception:{}", downloadUrl, e);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/processEditFile")
|
||||
public BusProcessModelHis processEditFile(String id) {
|
||||
BusProcessModelHis modelHisOne = busProcessModelHisService.processEditFile(id);
|
||||
return modelHisOne;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|model| 传入 模板文档名称(不带后缀)默认 docx")
|
||||
@GetMapping("/saveEditFile")
|
||||
public BusProcessModelHis saveEditFile(String model) {
|
||||
return busProcessModelHisService.saveEditFile(model);
|
||||
}
|
||||
|
||||
@GetMapping("/processModelHisOneUpdStatus")
|
||||
public BusProcessModelHis modelHisOneUpdStatus(String pid,String taskId) {
|
||||
BusProcessModelHis modelHisOne = busProcessModelHisService.modelHisOneUpdStatus(pid,taskId);
|
||||
return modelHisOne;
|
||||
}
|
||||
|
||||
@GetMapping("/processModelHisOneCount")
|
||||
public BusProcessModelHis modelHisOneCount(String pid) {
|
||||
BusProcessModelHis modelHisOne = busProcessModelHisService.modelHisOneCount(pid);
|
||||
return modelHisOne;
|
||||
}
|
||||
|
||||
@GetMapping("/processModelHisOne")
|
||||
public BusProcessModelHis modelHisOne(String pid,String taskId) {
|
||||
BusProcessModelHis modelHisOne = busProcessModelHisService.modelHisOne(pid,taskId);
|
||||
return modelHisOne;
|
||||
}
|
||||
|
||||
@GetMapping("/processModelHisList")
|
||||
public List<BusProcessModelHis> evaluationHisList(String pid) {
|
||||
List<BusProcessModelHis> processModelHisList = busProcessModelHisService.modelHisList(pid);
|
||||
return processModelHisList;
|
||||
}
|
||||
|
||||
@PostMapping("/selectOnlineFile")
|
||||
public OnlineFileLog selectOnlineFile(@RequestParam("onlineFileId") String onlineFileId) {
|
||||
return busProcessModelHisService.selectOnlineFile(onlineFileId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
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>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.jero.modules.onlyoffice.entity;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.jero.modules.onlyoffice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程模块历史表
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-09-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="BusProcessModelHis对象", description="流程模块历史表")
|
||||
public class BusProcessModelHis implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "标准id")
|
||||
@TableField("STAND_ID")
|
||||
private String standId;
|
||||
|
||||
@ApiModelProperty(value = "处理人")
|
||||
@TableField("USER_ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "信息")
|
||||
@TableField("MESG")
|
||||
private String mesg;
|
||||
|
||||
@ApiModelProperty(value = "节点信息")
|
||||
@TableField("TASK_INFO")
|
||||
private String taskInfo;
|
||||
|
||||
@ApiModelProperty(value = "任务id")
|
||||
@TableField("TASK_ID")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty(value = "流程实例id")
|
||||
@TableField("P_ID")
|
||||
private String pId;
|
||||
|
||||
@ApiModelProperty(value = "流程名称")
|
||||
@TableField("PRC_NAME")
|
||||
private String prcName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField("CREATE_TIME")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField("UPDATE_TIME")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "onlyOffice 是否编辑 0 未编辑 1 已编辑")
|
||||
@TableField("EDIT_STATUS")
|
||||
private String editStatus;
|
||||
|
||||
@ApiModelProperty(value = "onlyOffice 编辑文件存储路径")
|
||||
@TableField("EDIT_FILE_PATH")
|
||||
private String editFilePath;
|
||||
|
||||
@ApiModelProperty(value = "onlyOffice 编辑类型 node 节点编辑 count 汇总编辑")
|
||||
@TableField("EDIT_TYPE")
|
||||
private String editType;
|
||||
|
||||
@ApiModelProperty(value = "逻辑状态")
|
||||
@TableField("FLAG")
|
||||
private String flag;
|
||||
|
||||
@ApiModelProperty(value = "onlyOffice 访问编辑文件全路径")
|
||||
@TableField(exist = false)
|
||||
private String downLoadUrl;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.jero.modules.onlyoffice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class OnlineFileLog {
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@TableField("HIS_ID")
|
||||
private String hisId;
|
||||
|
||||
@TableField("ATT_FILE_ID")
|
||||
private String attFileId;
|
||||
|
||||
@TableField("FILE_NAME")
|
||||
private String fileName;
|
||||
|
||||
@TableField("DLD_FILE_NAME")
|
||||
private String oldFileName;
|
||||
|
||||
@TableField("FILE_SUFFIX")
|
||||
private String fileSuffix;
|
||||
|
||||
@TableField("FILE_PATH")
|
||||
private String filePath;
|
||||
|
||||
@TableField("COUNT")
|
||||
private Integer count;
|
||||
|
||||
@TableField("CREATE_TIME")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@TableField("UPDATE_TIME")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private byte[] bytes;
|
||||
|
||||
@ApiModelProperty(value = "是否有效")
|
||||
@TableField("VALID_FLAG")
|
||||
private String validFlag;
|
||||
|
||||
@ApiModelProperty(value = "文件key")
|
||||
@TableField("FILE_KEY")
|
||||
private String filekey;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.jero.modules.onlyoffice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.jero.modules.onlyoffice.entity.BusProcessModelHis;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程模块历史表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-09-17
|
||||
*/
|
||||
public interface BusProcessModelHisMapper extends BaseMapper<BusProcessModelHis> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.jero.modules.onlyoffice.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
||||
|
||||
public interface OnlineFileLogDao extends BaseMapper<OnlineFileLog> {
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
<?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" VARCHAR2(100 CHAR) NOT NULL PRIMARY KEY,
|
||||
"FILE_NAME" VARCHAR2(255 CHAR) NULL ,
|
||||
"OLD_FILE_NAME" VARCHAR2(255 CHAR) NULL ,
|
||||
"FILE_SUFFIX" VARCHAR2(30 CHAR) NULL ,
|
||||
"FILE_PATH" VARCHAR2(255 CHAR) NULL ,
|
||||
"VALID_FLAG" NUMBER(1) NULL ,
|
||||
"CREATION_TIME" DATE NULL ,
|
||||
"MODIFY_TIME" DATE NULL
|
||||
)
|
||||
LOGGING
|
||||
NOCOMPRESS
|
||||
NOCACHE
|
||||
</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 >= #{creationTime1}
|
||||
</if>
|
||||
<if test="creationTime2 != null" >
|
||||
and creation_time <= #{creationTime2}
|
||||
</if>
|
||||
<if test="modifyTime != null" >
|
||||
and modify_time ${modifyTimeOperator} #{modifyTime}
|
||||
</if>
|
||||
<if test="modifyTime1 != null" >
|
||||
and modify_time >= #{modifyTime1}
|
||||
</if>
|
||||
<if test="modifyTime2 != null" >
|
||||
and modify_time <= #{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>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?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.BusProcessModelHisMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -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