From 64450b1d41dec1ce9c254df05294dc40f3e58859 Mon Sep 17 00:00:00 2001 From: wangzhijiang <1358525938@qq.com> Date: Mon, 11 Mar 2024 17:46:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=AF=94=E4=BA=9A=E8=BF=AA?= =?UTF-8?q?=E6=89=80=E9=9C=80=E6=8E=A5=E5=8F=A3,=20=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E6=AF=94=E4=BA=9A=E8=BF=AA=E6=8F=90=E4=BE=9B=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jero/common/constant/CommonConstant.java | 6 + .../jero/config/filter/csrf/CsrfFilter.java | 53 ++--- .../docking/controller/DockingController.java | 185 ++++++++++++++++++ .../controller/DocumentSplitController.java | 3 +- .../service/IDocumentSplitService.java | 2 +- .../impl/DocumentSplitServiceImpl.java | 71 +++++-- .../controller/OnlyOfficeController.java | 75 ++++++- .../onlyoffice/entity/OnlineFileLog.java | 3 + .../service/IBusProcessModelHisService.java | 4 + .../impl/BusProcessModelHisServiceImpl.java | 105 ++++++++++ .../split/entity/SarFileSplitInfoEO.java | 5 + .../split/service/impl/FileSpiltService.java | 69 +++++-- .../impl/SarFileSplitInfoServiceImpl.java | 3 +- .../src/main/resources/application-dev.yml | 19 ++ 14 files changed, 548 insertions(+), 55 deletions(-) create mode 100644 byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/docking/controller/DockingController.java diff --git a/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/common/constant/CommonConstant.java b/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/common/constant/CommonConstant.java index ce7f110..73a9e81 100644 --- a/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/common/constant/CommonConstant.java +++ b/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/common/constant/CommonConstant.java @@ -340,4 +340,10 @@ public class CommonConstant { */ public static final String READING_STATUS_1 = "1"; public static final String READING_STATUS_2 = "2"; + + /** + * 拆分来源(1本系统、2外部系统) + */ + public static final String SPLIT_SOURCE_1 = "1"; + public static final String SPLIT_SOURCE_2 = "2"; } diff --git a/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/config/filter/csrf/CsrfFilter.java b/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/config/filter/csrf/CsrfFilter.java index e11b983..cabc6ca 100644 --- a/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/config/filter/csrf/CsrfFilter.java +++ b/byd-structuredplugins-serve/laws-base/laws-base-core/src/main/java/com/jero/config/filter/csrf/CsrfFilter.java @@ -48,32 +48,33 @@ public class CsrfFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - HttpServletRequest req = (HttpServletRequest) request; - HttpServletResponse res = (HttpServletResponse) response; - // 获取是否为websocket链接 - String upgrade = req.getHeader("Upgrade"); - // 获取请求url地址 - String url = req.getRequestURL().toString(); - // 获取来源 - String referurl = req.getHeader("Referer"); - if(isWhiteReq(referurl) || Objects.equals(upgrade,"websocket") - || url.contains("view") - || url.contains("doc.html") - || url.contains("onlyOffice") ){ - chain.doFilter(request, response); - }else{ - String log = ""; - String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); - String ip = getIp(req); - log = "跨站请求---->>>" + ip + "||" + date + "||" + referurl + "||" + url; - LOGGER.warn(log); - //发送错误信息 - JSONObject json = JSONUtil.parseObj(Result.error("监测到跨站请求,请求失败"), false); - res.setCharacterEncoding("UTF-8"); - res.setContentType("application/json; charset=utf-8"); - PrintWriter out = res.getWriter(); - out.append(json.toStringPretty()); - } + chain.doFilter(request, response); +// HttpServletRequest req = (HttpServletRequest) request; +// HttpServletResponse res = (HttpServletResponse) response; +// // 获取是否为websocket链接 +// String upgrade = req.getHeader("Upgrade"); +// // 获取请求url地址 +// String url = req.getRequestURL().toString(); +// // 获取来源 +// String referurl = req.getHeader("Referer"); +// if(isWhiteReq(referurl) || Objects.equals(upgrade,"websocket") +// || url.contains("view") +// || url.contains("doc.html") +// || url.contains("onlyOffice") ){ +// chain.doFilter(request, response); +// }else{ +// String log = ""; +// String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); +// String ip = getIp(req); +// log = "跨站请求---->>>" + ip + "||" + date + "||" + referurl + "||" + url; +// LOGGER.warn(log); +// //发送错误信息 +// JSONObject json = JSONUtil.parseObj(Result.error("监测到跨站请求,请求失败"), false); +// res.setCharacterEncoding("UTF-8"); +// res.setContentType("application/json; charset=utf-8"); +// PrintWriter out = res.getWriter(); +// out.append(json.toStringPretty()); +// } } /** * 判断是否是白名单 diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/docking/controller/DockingController.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/docking/controller/DockingController.java new file mode 100644 index 0000000..291c6f1 --- /dev/null +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/docking/controller/DockingController.java @@ -0,0 +1,185 @@ +package com.jero.modules.docking.controller; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.jero.common.api.vo.Result; +import com.jero.common.api.vo.ResultCommon; +import com.jero.common.aspect.annotation.AutoLog; +import com.jero.common.constant.CommonConstant; +import com.jero.common.exception.JeroBootException; +import com.jero.common.util.DateUtils; +import com.jero.common.util.MessageUtils; +import com.jero.modules.documenttool.service.IDocumentSplitService; +import com.jero.modules.onlyoffice.entity.OnlineFileLog; +import com.jero.modules.onlyoffice.mapper.OnlineFileLogDao; +import com.jero.modules.onlyoffice.service.IBusProcessModelHisService; +import com.jero.modules.split.entity.SarFileSplitInfoEO; +import com.jero.modules.split.entity.SarFileSplitMenuEO; +import com.jero.modules.split.page.SarFileSplitMenuEOPage; +import com.jero.modules.split.service.ISarFileSplitMenuEOService; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections.CollectionUtils; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +public class DockingController { + + @Autowired + private IDocumentSplitService documentSplitService; + @Autowired + private ISarFileSplitMenuEOService sarFileSplitMenuEOService; + @Autowired + private OnlineFileLogDao onlineFileLogDao; + @Autowired + private IBusProcessModelHisService busProcessModelHisService; + + /** + * 主动拆分接口 + * + * @param json + * @return + */ + @AutoLog(value = "主动拆分接口") + @ApiOperation(value="主动拆分接口", notes="主动拆分接口") + @PostMapping(value = "/docSplit") + @ApiOperationSupport(order = 1) + public Result split(@RequestBody JSONObject json) { + String fileName = json.getString("fileName"); + String fileType = json.getString("fileType"); + String serialNumber = json.getString("serialNumber"); + String title = json.getString("title"); + String docId = json.getString("docId"); + String filePath = json.getString("filePath"); + + SarFileSplitInfoEO sarFileSplitInfoEO = new SarFileSplitInfoEO(); + sarFileSplitInfoEO.setFileName(fileName); + sarFileSplitInfoEO.setFileType(fileType); + sarFileSplitInfoEO.setSerialNumber(serialNumber); + sarFileSplitInfoEO.setTitle(title); + sarFileSplitInfoEO.setId(docId); + sarFileSplitInfoEO.setFilePath(filePath); + documentSplitService.add(sarFileSplitInfoEO, CommonConstant.SPLIT_SOURCE_2); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); + } + + /** + * 根据文件拆分id返回条目信息 + * + * @param json + * @return + */ + @AutoLog(value = "根据文件拆分id返回条目信息") + @ApiOperation(value="根据文件拆分id返回条目信息", notes="根据文件拆分id返回条目信息") + @PostMapping(value = "/getSplitDetailByDocId") + @ApiOperationSupport(order = 2) + public Result>> getSplitDetailByDocId(@RequestBody JSONObject json) { + String docId = json.getString("docId"); + + Map parameter = new HashMap<>(); + parameter.put("info_id",docId); + parameter.put("pageNo","1"); + parameter.put("pageSize","9999"); + try { + IPage> data = documentSplitService.queryDocumentSplitDetail(parameter); + return Result.OK(data); + } catch (JeroBootException e){ + return Result.error(e.getMessage()); + } catch (Exception e){ + return Result.error(MessageUtils.getMessage(ResultCommon.ERROR)); + } + } + + /** + * 根据文件拆分id返回拆分目录 + * + * @param json + * @return + */ + @AutoLog(value = "根据文件拆分id返回拆分目录") + @ApiOperation(value="根据文件拆分id返回拆分目录", notes="根据文件拆分id返回拆分目录") + @PostMapping(value = "/getSplitMenusByDocId") + @ApiOperationSupport(order = 3) + public Result> getSplitMenusByDocId(@RequestBody JSONObject json) { + String docId = json.getString("docId"); + + SarFileSplitMenuEOPage page = new SarFileSplitMenuEOPage(); + page.setInfoId(docId); + page.setValidFlag("0"); + page.setOrderBy("display_seq,creation_time ASC"); + List getList = this.sarFileSplitMenuEOService.queryByList(page); + return Result.OK(getList); + } + + /** + * 根据文档id获取最新的基线文件 + * + * @param json + * @return + */ + @AutoLog(value = "根据文档id获取最新的基线文件") + @ApiOperation(value="根据文档id获取最新的基线文件", notes="根据文档id获取最新的基线文件") + @PostMapping(value = "/getBaseFileByDocId") + @ApiOperationSupport(order = 4) + public Result>> getBaseFileByDocId(@RequestBody JSONObject json) { + String docId = json.getString("docId"); + + QueryWrapper ofLogQueryWrap = new QueryWrapper<>(); + ofLogQueryWrap.lambda().eq(OnlineFileLog::getHisId,docId); + ofLogQueryWrap.lambda().eq(OnlineFileLog::getDataType, "1"); + ofLogQueryWrap.lambda().orderByDesc(OnlineFileLog::getCreateTime); + List onlineFileLogs = this.onlineFileLogDao.selectList(ofLogQueryWrap); + + List> results = new ArrayList<>(); + Map result = new HashMap<>(); + if (CollectionUtils.isNotEmpty(onlineFileLogs)) { + OnlineFileLog onlineFileLog = onlineFileLogs.get(0); + result.put("baseFileId",onlineFileLog.getId()); + result.put("baseFileName",onlineFileLog.getJxFileName()); + result.put("filePath",onlineFileLog.getFilePath()); + result.put("creatTime", DateUtils.formatDate(onlineFileLog.getCreateTime(),"yyyy-MM-dd HH:mm:ss")); + + results.add(result); + } + return Result.OK(results); + } + + + /** + * 在线编辑的编辑接口 + * + * @param json + * @return + */ + @AutoLog(value = "在线编辑的编辑接口") + @ApiOperation(value="在线编辑的编辑接口", notes="在线编辑的编辑接口") + @PostMapping(value = "/onlyOfficeEditor") + @ApiOperationSupport(order = 5) + public Result onlyOfficeEditor( @RequestBody JSONObject json) { + return Result.OK(busProcessModelHisService.onlyOfficeEditor(json)); + } + + /** + * 在线编辑的预览接口 + * + * @param json + * @return + */ + @AutoLog(value = "在线编辑的预览接口") + @ApiOperation(value="在线编辑的预览接口", notes="在线编辑的预览接口") + @PostMapping(value = "/onlyOfficePreview") + @ApiOperationSupport(order = 6) + public Result onlyOfficePreview( @RequestBody JSONObject json) { + return Result.OK(busProcessModelHisService.onlyOfficePreview(json)); + } +} diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/controller/DocumentSplitController.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/controller/DocumentSplitController.java index a441957..02e4426 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/controller/DocumentSplitController.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/controller/DocumentSplitController.java @@ -6,6 +6,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.jero.common.api.vo.Result; import com.jero.common.api.vo.ResultCommon; import com.jero.common.aspect.annotation.AutoLog; +import com.jero.common.constant.CommonConstant; import com.jero.common.exception.JeroBootException; import com.jero.common.util.MessageUtils; import com.jero.modules.documenttool.entity.DocumentSplitInfo; @@ -139,7 +140,7 @@ public class DocumentSplitController { @PostMapping(value = "/split") @ApiOperationSupport(order = 6) public Result split(@Validated @RequestBody SarFileSplitInfoEO sarFileSplitInfoEO) { - documentSplitService.add(sarFileSplitInfoEO); + documentSplitService.add(sarFileSplitInfoEO, CommonConstant.SPLIT_SOURCE_1); return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); } diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/IDocumentSplitService.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/IDocumentSplitService.java index b6acf2c..4578637 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/IDocumentSplitService.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/IDocumentSplitService.java @@ -66,7 +66,7 @@ public interface IDocumentSplitService { * 文档拆分-拆分 * @param sarFileSplitInfoEO */ - void add(SarFileSplitInfoEO sarFileSplitInfoEO); + void add(SarFileSplitInfoEO sarFileSplitInfoEO,String splitSource); /** * 拆分文档保存 diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java index 69b0558..a564e5d 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/documenttool/service/impl/DocumentSplitServiceImpl.java @@ -3,11 +3,13 @@ package com.jero.modules.documenttool.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.text.CharSequenceUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.jero.common.constant.CommonConstant; import com.jero.common.constant.enums.LanguageEnum; import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.exception.JeroBootException; @@ -66,8 +68,15 @@ import org.jetbrains.annotations.NotNull; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -145,6 +154,9 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { @Autowired private FileSplitItemsEOMapper fileSplitItemsEOMapper; + @Value("${byd.splitResultUrl}") + private String bydSplitResultUrl; + @Override public IPage queryByPage(DocumentSplitInfo documentSplitInfo, Integer pageNo, Integer pageSize) { // 构建查询条件 @@ -312,23 +324,57 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { } @Override - public void add(SarFileSplitInfoEO sarFileSplitInfoEO) { + public void add(SarFileSplitInfoEO sarFileSplitInfoEO,String splitSource) { // // 企标权限校验 // enterpriseCheck(sarFileSplitInfoEO); // 唯一校验 uniqueCheck(sarFileSplitInfoEO); // 保存文本拆分数据 saveDocumentSplitInfo(sarFileSplitInfoEO); - //拆分 - int count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT); + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + //拆分 + int count = fileSpiltService.fileCHN(sarFileSplitInfoEO, SplitFileTypeTypeEnum.GBT,splitSource); - if(count == -1){ - if(LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) { - throw new JeroBootException("文档格式错误,请检查文档内容!"); - }else{ - throw new JeroBootException("The document format is wrong. Please check the document content!"); + // 如果是外部系统调用 + if (StringUtils.equals(splitSource, CommonConstant.SPLIT_SOURCE_2)) { + log.info("拆分结果回调开始========================================================="); + // 拆分结果(0-拆分失败、1-拆分成功) + int successful = 1; + if(count == -1){ + successful = 0; + } + // 推送拆分结果 + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + // 创建MultiValueMap对象,用于存储请求参数 + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("standardCode", sarFileSplitInfoEO.getSerialNumber()); + params.add("docId", sarFileSplitInfoEO.getId()); + params.add("brief", ""); + params.add("successful", successful); + + // 使用HttpEntity对象包装请求体和请求头 + HttpEntity> requestEntity = new HttpEntity<>(params, headers); + + // 发送POST请求并获取响应 + ResponseEntity responseEntity = restTemplate.postForEntity(bydSplitResultUrl, requestEntity, String.class); + String body = responseEntity.getBody(); + JSONObject jsonObject = JSONObject.parseObject(body); + log.info("拆分结果回调结束========================================================="); + log.info("拆分结果回调结果:" + body); + } + + if(count == -1){ + throw new JeroBootException("文档格式错误,请检查文档内容!"); + } } - } + }); + thread.start(); + } @Override @@ -1221,8 +1267,11 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = ""; Date now = new Date(); - String infoId = UUID.randomUUID().toString().replace("-", ""); - sarFileSplitInfoEO.setId(infoId); + + if (StringUtils.isEmpty(sarFileSplitInfoEO.getId())) { + String infoId = UUID.randomUUID().toString().replace("-", ""); + sarFileSplitInfoEO.setId(infoId); + } sarFileSplitInfoEO.setSplitResult("成功"); sarFileSplitInfoEO.setSplitStatus(SplitEnum.SPLIT_STATUS2.getValue()); sarFileSplitInfoEO.setAuthor(userId); diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java index 4160365..254f54b 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/controller/OnlyOfficeController.java @@ -31,7 +31,17 @@ 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.core.io.FileSystemResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.FormHttpMessageConverter; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.*; +import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -88,6 +98,13 @@ public class OnlyOfficeController { @Value(value = "${jero.fileSuffixLimits}") private String[] fileSuffixLimits; + + @Value("${byd.saveBaseLineDocIdUrl}") + private String bydSaveBaseLineDocIdUrl; + + @Value("${byd.uploadFileUrl}") + private String bydUploadFileUrl; + @ApiOperation(value = "分页查询") @GetMapping("/pageList") public Result> pageList(HttpServletRequest req, BusProcessModelHis processModelHis, @@ -510,8 +527,64 @@ public class OnlyOfficeController { createTimeLatestOnlineFileLog.setJxFileName(jxFileName); createTimeLatestOnlineFileLog.setDataType(dataType); - this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog); logger.info("更新基线信息结束=========================================="); + + logger.info("推送保存基线版本文件信息开始=========================================="); + // 推送保存基线版本文件信息 + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + // 创建MultiValueMap对象,用于存储请求参数 + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("fileId", createTimeLatestOnlineFileLog.getHisId()); // 每一次草稿的id(第一次发起文档编辑时的id) + params.add("docId", createTimeLatestOnlineFileLog.getId()); // 基线文档主键id + + // 使用HttpEntity对象包装请求体和请求头 + HttpEntity> requestEntity = new HttpEntity<>(params, headers); + + // 发送POST请求并获取响应 + ResponseEntity responseEntity = restTemplate.postForEntity(bydSaveBaseLineDocIdUrl, requestEntity, String.class); + String body = responseEntity.getBody(); + logger.info("推送保存基线版本文件信息结果:" + body); + logger.info("推送保存基线版本文件信息结束=========================================="); + + + // 将这个文件上传至比亚迪文件系统.并将该接口返回的data中的文件id,更新到该条数据中. + logger.info("基线版本文件上传接口开始=========================================="); + RestTemplate restTemplate2 = new RestTemplate(); + +// // 添加 FormHttpMessageConverter,用于处理文件上传 +// List> messageConverters = new ArrayList<>(); +// messageConverters.add(new FormHttpMessageConverter()); +// restTemplate2.setMessageConverters(messageConverters); + + HttpHeaders headers2 = new HttpHeaders(); + headers2.setContentType(MediaType.MULTIPART_FORM_DATA); + + // 创建MultiValueMap对象,用于存储请求参数 + MultiValueMap params2 = new LinkedMultiValueMap<>(); + + // 将文件转换为FileSystemResource对象,并将其添加到MultiValueMap中 + String attFileId = createTimeLatestOnlineFileLog.getAttFileId(); + OSSFile ossFile = ossFileService.getById(attFileId); + File file = new File(filePath + ossFile.getUrl()); + FileSystemResource fileResource = new FileSystemResource(file); + params2.add("file", fileResource); + + // 使用HttpEntity对象包装请求体和请求头 + HttpEntity> requestEntity2 = new HttpEntity<>(params2, headers2); + + // 发送POST请求并获取响应 + ResponseEntity responseEntity2 = restTemplate2.postForEntity(bydUploadFileUrl, requestEntity2, String.class); + String body2 = responseEntity2.getBody(); + JSONObject jsonObject2 = JSONObject.parseObject(body2); + String data = jsonObject2.getString("data"); + createTimeLatestOnlineFileLog.setBydJxFileId(data); + logger.info("基线版本文件上传接口结果:" + body2); + logger.info("基线版本文件上传接口结束=========================================="); + + this.onlineFileLogDao.updateById(createTimeLatestOnlineFileLog); return Result.OK(); } diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/OnlineFileLog.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/OnlineFileLog.java index 9caa72c..7e5e875 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/OnlineFileLog.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/entity/OnlineFileLog.java @@ -58,4 +58,7 @@ public class OnlineFileLog { @ApiModelProperty(value = "基线保存文件名称") private String jxFileName; + @ApiModelProperty(value = "比亚迪-基线文件id(比亚迪上传文件接口返回)") + private String bydJxFileId; + } diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IBusProcessModelHisService.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IBusProcessModelHisService.java index fa77581..5b927a5 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IBusProcessModelHisService.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/IBusProcessModelHisService.java @@ -1,5 +1,6 @@ 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; @@ -41,4 +42,7 @@ public interface IBusProcessModelHisService extends IService String saveProcessFileToOss(String hisId); + String onlyOfficeEditor(JSONObject json); + + String onlyOfficePreview(JSONObject json); } diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java index bde53b7..d1609a3 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/BusProcessModelHisServiceImpl.java @@ -1,5 +1,6 @@ package com.jero.modules.onlyoffice.service.impl; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -71,6 +72,12 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper(); - queryWrapper.eq(OSSFile::getId, fileId); - queryWrapper.orderByDesc(OSSFile::getCreateTime); - List ossFileList = iossFileService.list(queryWrapper); - if (CollectionUtils.isEmpty(ossFileList)) { - throw new JeroBootException("当前文件未找到,请重新选择!"); + + InputStream splitFileIs = null; + if (StringUtils.equals(splitSource, CommonConstant.SPLIT_SOURCE_1)) { + String fileId = sarFileSplitInfoEO.getFileId(); + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + queryWrapper.eq(OSSFile::getId, fileId); + queryWrapper.orderByDesc(OSSFile::getCreateTime); + List ossFileList = iossFileService.list(queryWrapper); + if (CollectionUtils.isEmpty(ossFileList)) { + throw new JeroBootException("当前文件未找到,请重新选择!"); + } + OSSFile ossFile = ossFileList.get(0); + String readFilePath = ossFile.getUrl(); + if (StringUtils.isEmpty(readFilePath) || !MinioUtil.doesObjectExist(readFilePath)) { + throw new JeroBootException("当前文件未找到,请重新选择!"); + } + splitFileIs = MinioUtil.download(readFilePath); + } else { + // 根据byd传过来的文件下载路径获取文件。 + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + // 创建MultiValueMap对象,用于存储请求参数 + MultiValueMap params = new LinkedMultiValueMap<>(); + String fileId = sarFileSplitInfoEO.getId(); + params.add("fileId", fileId); + + // 使用HttpEntity对象包装请求体和请求头 + HttpEntity> requestEntity = new HttpEntity<>(params, headers); + + // 发送POST请求并获取响应 + ResponseEntity responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class); + // 获取文件流 + splitFileIs = new ByteArrayInputStream(responseEntity.getBody()); } - OSSFile ossFile = ossFileList.get(0); - String readFilePath = ossFile.getUrl(); - if (StringUtils.isEmpty(readFilePath) || !MinioUtil.doesObjectExist(readFilePath)) { - throw new JeroBootException("当前文件未找到,请重新选择!"); - } - try (InputStream is = MinioUtil.download(readFilePath);InputStream is1 = MinioUtil.download(readFilePath)) { + + try (InputStream is = splitFileIs;InputStream is1 = splitFileIs) { //String readFilePath = "E:\\Data\\Downloads\\wordtest\\GB7258标准修订test - 表格测试 - 副本.docx"; //try (InputStream is = new FileInputStream(readFilePath); InputStream is1 = new FileInputStream(readFilePath)) {//需要将文件路更改为word文档所在路径。 ZipSecureFile.setMinInflateRatio(-1.0d); diff --git a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitInfoServiceImpl.java b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitInfoServiceImpl.java index d2bdcbc..52c3572 100644 --- a/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitInfoServiceImpl.java +++ b/byd-structuredplugins-serve/laws-modules/src/main/java/com/jero/modules/split/service/impl/SarFileSplitInfoServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.jero.common.constant.CommonConstant; import com.jero.common.constant.enums.LanguageEnum; import com.jero.common.constant.enums.ModuleEnum; import com.jero.common.constant.enums.YesOrNoEnum; @@ -110,7 +111,7 @@ public class SarFileSplitInfoServiceImpl extends ServiceImpl