diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyofficeController.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java similarity index 70% rename from laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyofficeController.java rename to laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java index f1954e8b..169ecfc5 100644 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyofficeController.java +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java @@ -1,6 +1,7 @@ package com.jero.modules.onlyoffice.controller; import cn.hutool.http.HttpUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -12,6 +13,7 @@ import com.jero.common.util.oConvertUtils; 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.mapper.OnlineFileLogDao; import com.jero.modules.onlyoffice.service.IBusProcessModelHisService; import com.jero.modules.onlyoffice.service.LawsUserInfoService; import com.jero.modules.oss.entity.OSSFile; @@ -21,7 +23,6 @@ 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 org.springframework.web.multipart.MultipartFile; @@ -33,51 +34,55 @@ import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URL; import java.net.URLConnection; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Scanner; +import java.text.SimpleDateFormat; +import java.util.*; /** *

* onlyoffice前端控制器 *

*/ -@Api(tags="onlyoffice操作") +@Api(tags = "onlyOffice操作") @RestController -@RequestMapping("/onlyoffice") -public class OnlyofficeController { +@RequestMapping("/onlyOffice") +public class OnlyOfficeController { - private static final Logger logger = LoggerFactory.getLogger(OnlyofficeController.class); + private static final Logger logger = LoggerFactory.getLogger(OnlyOfficeController.class); @Value("${file.path}") private String standEditFilePath;//文件存储路径 - @Autowired + @Resource private IBusProcessModelHisService busProcessModelHisService; - @Autowired + @Resource private LawsUserInfoService lawsUserInfoService; @Resource private BusProcessModelHisMapper busProcessModelHisMapper; @Resource private IOSSFileService ossFileService; + + @Resource + private OnlineFileLogDao onlineFileLogDao; + /** * 文件后缀黑名单 */ - @Value(value="${jero.fileSuffixLimits}") + @Value(value = "${jero.fileSuffixLimits}") private String[] fileSuffixLimits; + @ApiOperation(value = "分页查询") @GetMapping("/pageList") public Result> pageList(HttpServletRequest req, BusProcessModelHis processModelHis, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize){ + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(processModelHis, req.getParameterMap()); Page page = new Page<>(pageNo, pageSize); IPage pageList = busProcessModelHisService.page(page, queryWrapper); return Result.OK(pageList); } + /** * 删除 */ @@ -85,11 +90,11 @@ public class OnlyofficeController { @PostMapping("/delete") public Result delete(@RequestBody Map map) { String id = map.get("id"); - if(StringUtils.isBlank(id)){ + if (StringUtils.isBlank(id)) { return Result.error("参数不识别!"); } boolean ok = busProcessModelHisService.removeById(id); - if(ok) { + if (ok) { return Result.OK("删除成功!"); } return Result.OK(); @@ -102,9 +107,9 @@ public class OnlyofficeController { @PostMapping("/deleteBatch") public Result deleteBatch(@RequestBody Map map) { String ids = map.get("ids"); - if(StringUtils.isBlank(ids)) { + if (StringUtils.isBlank(ids)) { return Result.error("参数不识别!"); - }else { + } else { this.busProcessModelHisService.removeByIds(Arrays.asList(ids.split(","))); return Result.OK("删除成功!"); } @@ -112,16 +117,16 @@ public class OnlyofficeController { @ApiOperation(value = "|onlyOffice接收文件") - @PostMapping("/recieveFile") - public void recieveFile(HttpServletRequest request, HttpServletResponse response, String fileNm, String standNo, String fileId,String standName,String key){ - logger.info("**********进入recieveFile接收文档接口************"); - logger.info("**********fileNm************"+fileNm+"======="); - logger.info("**********standNo************"+standNo+"======="); - logger.info("**********fileId************"+fileId+"======="); - logger.info("**********standName************"+standName+"======="); - logger.info("**********key************"+key+"======="); + @PostMapping("/receiveFile") + public void receiveFile(HttpServletRequest request, HttpServletResponse response, String fileNm, String standNo, String fileId, String standName, String key) { + logger.info("**********进入receiveFile接收文档接口************"); + 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(); + PrintWriter writer = response.getWriter(); String body = ""; try { Scanner scanner = new Scanner(request.getInputStream()); @@ -150,32 +155,30 @@ public class OnlyofficeController { try { logger.info("**********onlyoffice接收文档接口获得downloadUri************" + downloadUri); if (StringUtils.isNotEmpty(downloadUri)) { - downloadUri = downloadUri.replace("laws.sinotruk.com","onlyoffice-sa2of.yf-grp:8080"); - downloadUri = downloadUri.replace("onlyoffice.sinotruk.com","onlyoffice-sa2of.yf-grp:8080"); + downloadUri = downloadUri.replace("laws.sinotruk.com", "onlyoffice-sa2of.yf-grp:8080"); + downloadUri = downloadUri.replace("onlyoffice.sinotruk.com", "onlyoffice-sa2of.yf-grp:8080"); BusProcessModelHis modelHis = busProcessModelHisService.getById(fileId); String editFilePath = modelHis.getEditFilePath(); - StringBuilder builder=new StringBuilder(); - builder.append(standEditFilePath); - builder.append(editFilePath); - String saveFileUrl = builder.toString(); + String saveFileUrl = standEditFilePath + + editFilePath; logger.info("**********onlyoffice文档下载路径************" + downloadUri); logger.info("**********onlyoffice文档保存本地路径************" + saveFileUrl); - HttpUtil.downloadFileFromUrl(downloadUri,saveFileUrl); + HttpUtil.downloadFileFromUrl(downloadUri, saveFileUrl); //File file = new File(saveFileUrl); //downloadNetFile(downloadUri, file); // 更新在线编辑当前节点编辑状态 busProcessModelHisService.modelHisOneUpdStatusById(fileId); - Object keyObj = jsonObj.get("key"); - if(keyObj!=null){ + Object keyObj = jsonObj.get("key"); + if (keyObj != null) { key = keyObj.toString(); - logger.info("**********key************"+key+"======="); - } - lawsUserInfoService.selectOnlineFile(fileId,standName,key); + logger.info("**********key************" + key + "======="); + } + lawsUserInfoService.selectOnlineFile(fileId, standName, key); } } catch (Exception ex) { saved = 1; logger.info("**********onlyoffice接收文档接口异常************" + ex.getMessage()); - logger.error(ex.getMessage(),ex); + logger.error(ex.getMessage(), ex); } } else if (status == 4) { logger.info("**********onlyoffice接收文档接口开始修改文件状态状态4************"); @@ -187,21 +190,21 @@ public class OnlyofficeController { } catch (IOException e) { logger.info("**********onlyoffice接收文档接口异常************" + e.getMessage()); - logger.error(e.getMessage(),e); + 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("**********进入recieveFileBefore接收文档接口************"); - logger.info("**********fileNm************"+fileNm+"======="); - logger.info("**********standNo************"+standNo+"======="); - logger.info("**********pid************"+pid+"======="); - logger.info("**********taskId************"+taskId+"======="); - logger.info("**********standName************"+standName+"======="); - logger.info("**********key************"+key+"======="); + @PostMapping("/receiveFileBefore") + public void receiveFileBefore(HttpServletRequest request, HttpServletResponse response, String key, String fileNm, String standNo, String pid, String taskId, String standName) { + logger.info("**********进入receiveFileBefore接收文档接口************"); + 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(); @@ -226,39 +229,37 @@ public class OnlyofficeController { int status = (Integer) jsonObj.get("status"); int saved = 0; - if (status == 2 || status == 3 ||status == 6)//MustSave, Corrupted + 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(); + String saveFileUrl = standEditFilePath + + standNo + "/" + + fileNm; File file = new File(saveFileUrl); downloadNetFile(downloadUri, file); // 更新在线编辑当前节点编辑状态 - busProcessModelHisService.modelHisOneUpdStatus(pid,taskId); + busProcessModelHisService.modelHisOneUpdStatus(pid, taskId); QueryWrapper objectQueryWrapper = new QueryWrapper<>(); - objectQueryWrapper.eq("P_ID",pid); - objectQueryWrapper.eq("TASK_ID",taskId); + objectQueryWrapper.eq("P_ID", pid); + objectQueryWrapper.eq("TASK_ID", taskId); BusProcessModelHis busProcessModelHis = busProcessModelHisMapper.selectOne(objectQueryWrapper); - if(busProcessModelHis!=null){ + if (busProcessModelHis != null) { Object keyObj = jsonObj.get("key"); - if(keyObj!=null){ + if (keyObj != null) { key = keyObj.toString(); - logger.info("**********key************"+key+"======="); + logger.info("**********key************" + key + "======="); } - lawsUserInfoService.selectOnlineFile(busProcessModelHis.getId(), standName,key); + lawsUserInfoService.selectOnlineFile(busProcessModelHis.getId(), standName, key); } } } catch (Exception ex) { saved = 1; logger.info("**********onlyoffice接收文档接口异常************" + ex.getMessage()); - logger.error(ex.getMessage(),ex); + logger.error(ex.getMessage(), ex); } } else if (status == 4) { logger.info("**********onlyoffice接收文档接口开始修改文件状态状态4************"); @@ -270,12 +271,11 @@ public class OnlyofficeController { } catch (IOException e) { logger.info("**********onlyoffice接收文档接口异常************" + e.getMessage()); - logger.error(e.getMessage(),e); - return; + logger.error(e.getMessage(), e); } } - public void downloadNetFile(String downloadUrl, File file) { + public void downloadNetFile(String downloadUrl, File file) { try { FileOutputStream fileOutputStream = new FileOutputStream(file); URL url = new URL(downloadUrl); @@ -295,8 +295,7 @@ public class OnlyofficeController { @GetMapping("/processEditFile") public BusProcessModelHis processEditFile(String id) { - BusProcessModelHis modelHisOne = busProcessModelHisService.processEditFile(id); - return modelHisOne; + return busProcessModelHisService.processEditFile(id); } @ApiOperation(value = "|model| 传入 模板文档名称(不带后缀)默认 docx") @@ -309,31 +308,27 @@ public class OnlyofficeController { @ApiOperation(value = "根据路径下载文件") @GetMapping("/downLoadFile") public void downLoadFile(@RequestParam(name = "path") String path, HttpServletResponse response) { - busProcessModelHisService.downLoadFile(path,response); + busProcessModelHisService.downLoadFile(path, response); } @GetMapping("/processModelHisOneUpdStatus") - public BusProcessModelHis modelHisOneUpdStatus(String pid,String taskId) { - BusProcessModelHis modelHisOne = busProcessModelHisService.modelHisOneUpdStatus(pid,taskId); - return modelHisOne; + public BusProcessModelHis modelHisOneUpdStatus(String pid, String taskId) { + return busProcessModelHisService.modelHisOneUpdStatus(pid, taskId); } @GetMapping("/processModelHisOneCount") public BusProcessModelHis modelHisOneCount(String pid) { - BusProcessModelHis modelHisOne = busProcessModelHisService.modelHisOneCount(pid); - return modelHisOne; + return busProcessModelHisService.modelHisOneCount(pid); } @GetMapping("/processModelHisOne") - public BusProcessModelHis modelHisOne(String pid,String taskId) { - BusProcessModelHis modelHisOne = busProcessModelHisService.modelHisOne(pid,taskId); - return modelHisOne; + public BusProcessModelHis modelHisOne(String pid, String taskId) { + return busProcessModelHisService.modelHisOne(pid, taskId); } @GetMapping("/processModelHisList") public List evaluationHisList(String pid) { - List processModelHisList = busProcessModelHisService.modelHisList(pid); - return processModelHisList; + return busProcessModelHisService.modelHisList(pid); } @PostMapping("/selectOnlineFile") @@ -341,8 +336,35 @@ public class OnlyofficeController { return busProcessModelHisService.selectOnlineFile(onlineFileId); } + @ApiOperation(value = "根据在线文件Id查询所有onlyoffice历史文件") + @GetMapping("/getAllOnlyOfficeHisFileById") + public Result>> getAllOnlyOfficeHisFileById(String fileId, String fileName) { + List> fileList = new ArrayList<>(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OnlineFileLog::getHisId, fileId); + wrapper.eq(OnlineFileLog::getValidFlag, "0"); + wrapper.orderByDesc(OnlineFileLog::getCreateTime); + List onlineFileLogList = onlineFileLogDao.selectList(wrapper); + if (!onlineFileLogList.isEmpty()) { + for (OnlineFileLog onlineFileLog : onlineFileLogList) { + Map map = new HashMap<>(); + map.put("id", onlineFileLog.getId()); + map.put("fileName", fileName); + map.put("attFileId", onlineFileLog.getAttFileId()); + map.put("createTime", sdf.format(onlineFileLog.getCreateTime())); + map.put("fileKey", onlineFileLog.getFileKey()); + fileList.add(map); + } + return Result.OK(fileList); + } + return Result.error("历史文件为空"); + } + + /** * 文件上传统一方法 + * * @param request * @param response * @return @@ -362,22 +384,22 @@ public class OnlyofficeController { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; // 获取上传文件对象 MultipartFile file = multipartRequest.getFile("file"); - if(file==null) { + if (file == null) { return result; } // 文件类型是否处于黑名单 - if(CommonUtils.limitFileSuffix(file.getOriginalFilename(),fileSuffixLimits)){ + if (CommonUtils.limitFileSuffix(file.getOriginalFilename(), fileSuffixLimits)) { result.setMessage("该文件类型不允许上传"); result.setSuccess(false); result.setCode(0); return result; } - if(oConvertUtils.isEmpty(bizPath)){ + if (oConvertUtils.isEmpty(bizPath)) { bizPath = ""; } // 本地上传 - savePath = CommonUtils.uploadLocal(file,bizPath,standEditFilePath); - if(oConvertUtils.isNotEmpty(savePath)){ + savePath = CommonUtils.uploadLocal(file, bizPath, standEditFilePath); + if (oConvertUtils.isNotEmpty(savePath)) { //上传成功 进行数据库存储 OSSFile ossFile = new OSSFile(); // 文件名 @@ -389,7 +411,7 @@ public class OnlyofficeController { result.setMessage(savePath); result.setResult(ossFile); result.setSuccess(true); - }else { + } else { result.setMessage("上传失败!"); result.setSuccess(false); } 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 index 8601210a..6ac45f3f 100644 --- 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 @@ -13,7 +13,7 @@ import java.util.Date; * 版权所有:版权归北京卡达克数据技术中心所有。
*/ // TODO 等在线编辑正式上线时,把该部分去掉,此部分在正式功能中无用 -public class AttFileEO implements Serializable{ +public class AttFileEO implements Serializable { private static final long serialVersionUID = 1284335706608668758L; @@ -25,9 +25,9 @@ public class AttFileEO implements Serializable{ private String fileSuffix; private String filePath; private Integer validFlag; - @org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @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") + @org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date modifyTime; private String tableName; @@ -53,19 +53,28 @@ public class AttFileEO implements Serializable{ *
  • modifyTime -> modify_time
  • */ public static String fieldToColumn(String fieldName) { - if (fieldName == null){ + 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; + 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; } } @@ -82,123 +91,164 @@ public class AttFileEO implements Serializable{ *
  • modify_time -> modifyTime
  • */ public static String columnToField(String columnName) { - if (columnName == null){ + 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; + 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() { + /** + * + **/ + public String getId() { int tableNameIndex = this.id.lastIndexOf("_"); - if(tableNameIndex!= -1){ + if (tableNameIndex != -1) { String tableName = this.id.substring(0, tableNameIndex); - this.tableName=tableName; - }else{ - logger.error("文件ID格式错误:"+this.id); + 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; + /** + * + **/ + public void setId(String id) { + if (tableName != null && !tableName.isEmpty()) { + this.id = tableName + "_" + id; } //此处注意保存时表结构是否存在 - this.id=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()){ + if (this.tableName != null && !this.tableName.isEmpty()) { return this.tableName; - }else{ + } else { int tableNameIndex = this.id.lastIndexOf("_"); - if(tableNameIndex !=-1){ + if (tableNameIndex != -1) { String tableName = this.id.substring(0, tableNameIndex); - this.tableName=tableName; - }else{ - logger.error("文件ID格式错误:"+this.id); + this.tableName = tableName; + } else { + logger.error("文件ID格式错误:" + this.id); } return this.tableName; } 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 index f196ea6c..2b3adbfb 100644 --- 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 @@ -66,10 +66,10 @@ public class AttFileEOServiceImpl extends ServiceImpl i } String fileName = file.getName(); - String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1, fileName.length()); - String newFileName = fileId +"."+ fileSuffix; + String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()); + String newFileName = fileId + "." + fileSuffix; File saveFile = new File(FileSavePath + newFileName); - FileUtils.copyFile(file,saveFile); + FileUtils.copyFile(file, saveFile); //开始存储文件信息 String tableName = UUIDUtils.getAttTable(); int existTable = this.baseMapper.existTable(tableName); @@ -94,9 +94,9 @@ public class AttFileEOServiceImpl extends ServiceImpl i attFileVo.setFileSuffix(fileSuffix); attFileVo.setOldFileName(fileName); } catch (IOException e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } return attFileVo; } @@ -114,43 +114,43 @@ public class AttFileEOServiceImpl extends ServiceImpl i * 根据ID获取文件信息 */ AttFileEO attFileEO = new AttFileEO(); - AttFileEO attFileInfo=null; + AttFileEO attFileInfo = null; try { attFileEO.setId(attId); - attFileInfo = this.baseMapper.selectFileInfoById(attFileEO); + attFileInfo = this.baseMapper.selectFileInfoById(attFileEO); return attFileInfo; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } return attFileEO; } @Override - public AttFileEO updateFileInfo(String attId,String name) { + public AttFileEO updateFileInfo(String attId, String name) { /** * 根据ID获取文件信息 */ AttFileEO attFileEO = new AttFileEO(); - AttFileEO attFileInfo=null; + 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())) { + 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 { + String filename = name.substring(0, suffixIndex).trim(); + attFileInfo.setOldFileName(filename + "." + attFileInfo.getFileSuffix()); } - }else { - attFileInfo.setOldFileName(name.trim()+"."+attFileEO.getFileSuffix()); + } else { + attFileInfo.setOldFileName(name.trim() + "." + attFileEO.getFileSuffix()); } this.baseMapper.updateFileInfoById(attFileInfo); return attFileInfo; } catch (Exception e) { - log.error(e.getMessage(),e); + log.error(e.getMessage(), e); } return attFileInfo; } @@ -158,28 +158,12 @@ public class AttFileEOServiceImpl extends ServiceImpl i @Override public void deleteById(String id) { - if(StringUtils.isNotBlank(id)){ - String[] s = id.split("_"); + if (StringUtils.isNotBlank(id)) { + String[] s = id.split("_"); List asList = Arrays.asList(s); - String str = "att_file_"+asList.get(2); - baseMapper.deleteByIdInfo(str,id); + 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 index 262c2f48..6ad45cdf 100644 --- 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 @@ -2,6 +2,7 @@ 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.common.util.MinioUtil; import com.jero.modules.onlyoffice.entity.BusProcessModelHis; import com.jero.modules.onlyoffice.entity.OnlineFileLog; import com.jero.modules.onlyoffice.mapper.BusProcessModelHisMapper; @@ -13,10 +14,11 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.nio.file.Files; import java.text.SimpleDateFormat; -import java.util.Date; import java.util.List; import java.util.UUID; @@ -46,40 +48,41 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl hisList = this.baseMapper.selectList(wrapper); - if(!hisList.isEmpty()){ + if (!hisList.isEmpty()) { modelHis = hisList.get(0); modelHis.setEditStatus("1"); this.baseMapper.updateById(modelHis); @@ -232,13 +235,13 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl hisList = this.baseMapper.selectList(wrapper); - if(!hisList.isEmpty()){ + if (!hisList.isEmpty()) { modelHis = hisList.get(0); StringBuffer downloadFileUrl = new StringBuffer(); downloadFileUrl.append(downloadUrl).append(modelHis.getEditFilePath() == null ? "" : modelHis.getEditFilePath()); @@ -248,9 +251,9 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl hisList = this.baseMapper.selectList(wrapper); - if(!hisList.isEmpty()){ + if (!hisList.isEmpty()) { modelHis = hisList.get(0); StringBuffer downloadFileUrl = new StringBuffer(); downloadFileUrl.append(downloadUrl).append(modelHis.getEditFilePath() == null ? "" : modelHis.getEditFilePath()); @@ -275,9 +278,9 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl modelHisList(String pid){ + public List modelHisList(String pid) { QueryWrapper wrapper = new QueryWrapper(); - wrapper.eq("P_ID",pid); + wrapper.eq("P_ID", pid); return this.baseMapper.selectList(wrapper); } }