diff --git a/laws-base/laws-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java b/laws-base/laws-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java index fbe4a373..e329c081 100644 --- a/laws-base/laws-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java +++ b/laws-base/laws-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java @@ -132,6 +132,9 @@ public class ShiroConfig { filterChainDefinitionMap.put("/newsWebsocket/**", "anon");//CMS模块 filterChainDefinitionMap.put("/vxeSocket/**", "anon");//JVxeTable无痕刷新示例 + //onlyoffice排除 + filterChainDefinitionMap.put("/onlyoffice/**", "anon"); + // 添加自己的过滤器并且取名为jwt Map filterMap = new HashMap<>(1); //如果cloudServer为空 则说明是单体 需要加载跨域配置【微服务跨域切换】 diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/BusProcessModelHisController.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/BusProcessModelHisController.java new file mode 100644 index 00000000..aada85a4 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/BusProcessModelHisController.java @@ -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; + +/** + *

+ * 流程模块历史表 前端控制器 + *

+ * + * @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 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 evaluationHisList(String pid) { + List processModelHisList = busProcessModelHisService.modelHisList(pid); + return processModelHisList; + } + + @PostMapping("/selectOnlineFile") + public OnlineFileLog selectOnlineFile(@RequestParam("onlineFileId") String onlineFileId) { + return busProcessModelHisService.selectOnlineFile(onlineFileId); + } + + + +} + 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 new file mode 100644 index 00000000..f46d3719 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileEO.java @@ -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; + +/** + * 功能:ATT_FILE AttFileEOEntity
+ * 作者:code generator
+ * 日期: 2018-09-07
+ * 版权所有:版权归北京卡达克数据技术中心所有。
+ */ +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 new file mode 100644 index 00000000..656d729b --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/AttFileVo.java @@ -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; + } +} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/BusProcessModelHis.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/BusProcessModelHis.java new file mode 100644 index 00000000..105e2618 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/BusProcessModelHis.java @@ -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; + +/** + *

    + * 流程模块历史表 + *

    + * + * @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; +} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/OnlineFileLog.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/OnlineFileLog.java new file mode 100644 index 00000000..b2582f42 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/OnlineFileLog.java @@ -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; + +} 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 new file mode 100644 index 00000000..6897cef2 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/AttFileEODao.java @@ -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; + +/** + * + *
    + * 功能: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/BusProcessModelHisMapper.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/BusProcessModelHisMapper.java new file mode 100644 index 00000000..60ddbce6 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/BusProcessModelHisMapper.java @@ -0,0 +1,16 @@ +package com.jero.modules.onlyoffice.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.jero.modules.onlyoffice.entity.BusProcessModelHis; + +/** + *

    + * 流程模块历史表 Mapper 接口 + *

    + * + * @author super_liu + * @since 2021-09-17 + */ +public interface BusProcessModelHisMapper extends BaseMapper { + +} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/OnlineFileLogDao.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/OnlineFileLogDao.java new file mode 100644 index 00000000..1202749d --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/OnlineFileLogDao.java @@ -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 { +} 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 new file mode 100644 index 00000000..3f88a2ae --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/xml/AttFileEOMapper.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + id, file_name, old_file_name, file_suffix, file_path, valid_flag, creation_time, modify_time + + + + 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 + + + + + + + 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/mapper/xml/BusProcessModelHisMapper.xml b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/xml/BusProcessModelHisMapper.xml new file mode 100644 index 00000000..a427d559 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/mapper/xml/BusProcessModelHisMapper.xml @@ -0,0 +1,5 @@ + + + + + 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 new file mode 100644 index 00000000..79ad2027 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IAttFileEOService.java @@ -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 { + + 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/IBusProcessModelHisService.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IBusProcessModelHisService.java new file mode 100644 index 00000000..64e249e1 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IBusProcessModelHisService.java @@ -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; + +/** + *

    + * 流程模块历史表 服务类 + *

    + * + * @author super_liu + * @since 2021-09-17 + */ +public interface IBusProcessModelHisService extends IService { + + 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 modelHisList(String pid); + + OnlineFileLog selectOnlineFile(String onlineFileId); +} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/LawsUserInfoService.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/LawsUserInfoService.java new file mode 100644 index 00000000..dc0c4816 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/LawsUserInfoService.java @@ -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 onlineFileLogQueryWrapperHis = new QueryWrapper<>(); + onlineFileLogQueryWrapperHis.eq("HIS_ID",onlineFileId); + onlineFileLogQueryWrapperHis.eq("VALID_FLAG","0"); + onlineFileLogQueryWrapperHis.orderByAsc("CREATE_TIME"); + List 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 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()); + } + } + } +} 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 new file mode 100644 index 00000000..8d480f68 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/AttFileEOServiceImpl.java @@ -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 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); + } + } + + 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(); // 先开后关 + } + + +} diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java new file mode 100644 index 00000000..49f90516 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java @@ -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; + +/** + *

    + * 流程模块历史表 服务实现类 + *

    + * + * @author super_liu + * @since 2021-09-17 + */ +@Service +public class BusProcessModelHisServiceImpl extends ServiceImpl 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 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 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 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 modelHisList(String pid){ + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("P_ID",pid); + return this.baseMapper.selectList(wrapper); + } +} diff --git a/laws-single-startup/src/main/resources/application-dev.yml b/laws-single-startup/src/main/resources/application-dev.yml index b5c20334..195058a3 100644 --- a/laws-single-startup/src/main/resources/application-dev.yml +++ b/laws-single-startup/src/main/resources/application-dev.yml @@ -384,4 +384,10 @@ OCR: # OCR接口超时时间 times: 20 # OCR转换类型 - convertType: BOTH \ No newline at end of file + convertType: BOTH + +file: + downloadUrl: a + split: + path: /data/slrs/file/splitImage/ + path: /data/slrs/file diff --git a/laws-single-startup/src/main/resources/application-prod.yml b/laws-single-startup/src/main/resources/application-prod.yml index fc1aa2f3..21f3a664 100644 --- a/laws-single-startup/src/main/resources/application-prod.yml +++ b/laws-single-startup/src/main/resources/application-prod.yml @@ -126,16 +126,16 @@ spring: poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 - filters: stat,wall,slf4j + filters: stat,slf4j # 通过connectProperties属性来打开mergeSql功能;慢SQL记录 connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000;druid.stat.logSlowSql\=true datasource: master: - url: jdbc:mysql://127.0.0.1:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai - username: root - password: 123456 - driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:p6spy:mysql://10.186.40.44:8921/laws_sinotrunk_grp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + username: law_dev + password: Lawdev!@#1234 + driver-class-name: com.p6spy.engine.spy.P6SpyDriver # url: jdbc:mysql://127.0.0.1:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai # username: root # password: 123456 @@ -148,8 +148,8 @@ spring: #driver-class-name: com.mysql.cj.jdbc.Driver #redis 配置 redis: - database: 3 - host: 121.36.69.172 + database: 2 + host: 10.186.42.77 lettuce: pool: max-active: 8 #最大连接数据库连接数,设 0 为没有限制 @@ -157,8 +157,8 @@ spring: max-wait: -1ms #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。 min-idle: 0 #最小等待连接中的数量,设 0 为没有限制 shutdown-timeout: 100ms - password: 'hzwlsoft.com' - port: 4780 + password: 'grp#Grp@2023.' + port: 31046 #rabbitmq 配置 rabbitmq: host: 121.36.69.172