开发比亚迪所需接口, 对接比亚迪提供的接口
This commit is contained in:
+6
@@ -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";
|
||||
}
|
||||
|
||||
+27
-26
@@ -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());
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* 判断是否是白名单
|
||||
|
||||
+185
@@ -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<T> 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<IPage<Map<String,Object>>> getSplitDetailByDocId(@RequestBody JSONObject json) {
|
||||
String docId = json.getString("docId");
|
||||
|
||||
Map<String, Object> parameter = new HashMap<>();
|
||||
parameter.put("info_id",docId);
|
||||
parameter.put("pageNo","1");
|
||||
parameter.put("pageSize","9999");
|
||||
try {
|
||||
IPage<Map<String, Object>> 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<List<SarFileSplitMenuEO>> 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<SarFileSplitMenuEO> 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<List<Map<String,Object>>> getBaseFileByDocId(@RequestBody JSONObject json) {
|
||||
String docId = json.getString("docId");
|
||||
|
||||
QueryWrapper<OnlineFileLog> ofLogQueryWrap = new QueryWrapper<>();
|
||||
ofLogQueryWrap.lambda().eq(OnlineFileLog::getHisId,docId);
|
||||
ofLogQueryWrap.lambda().eq(OnlineFileLog::getDataType, "1");
|
||||
ofLogQueryWrap.lambda().orderByDesc(OnlineFileLog::getCreateTime);
|
||||
List<OnlineFileLog> onlineFileLogs = this.onlineFileLogDao.selectList(ofLogQueryWrap);
|
||||
|
||||
List<Map<String,Object>> results = new ArrayList<>();
|
||||
Map<String,Object> 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<String> 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<String> onlyOfficePreview( @RequestBody JSONObject json) {
|
||||
return Result.OK(busProcessModelHisService.onlyOfficePreview(json));
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -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<T> split(@Validated @RequestBody SarFileSplitInfoEO sarFileSplitInfoEO) {
|
||||
documentSplitService.add(sarFileSplitInfoEO);
|
||||
documentSplitService.add(sarFileSplitInfoEO, CommonConstant.SPLIT_SOURCE_1);
|
||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public interface IDocumentSplitService {
|
||||
* 文档拆分-拆分
|
||||
* @param sarFileSplitInfoEO
|
||||
*/
|
||||
void add(SarFileSplitInfoEO sarFileSplitInfoEO);
|
||||
void add(SarFileSplitInfoEO sarFileSplitInfoEO,String splitSource);
|
||||
|
||||
/**
|
||||
* 拆分文档保存
|
||||
|
||||
+60
-11
@@ -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<DocumentSplitInfo> 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<String, Object> params = new LinkedMultiValueMap<>();
|
||||
params.add("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
params.add("docId", sarFileSplitInfoEO.getId());
|
||||
params.add("brief", "");
|
||||
params.add("successful", successful);
|
||||
|
||||
// 使用HttpEntity对象包装请求体和请求头
|
||||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
|
||||
|
||||
// 发送POST请求并获取响应
|
||||
ResponseEntity<String> 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);
|
||||
|
||||
+74
-1
@@ -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<IPage<BusProcessModelHis>> 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<String, Object> params = new LinkedMultiValueMap<>();
|
||||
params.add("fileId", createTimeLatestOnlineFileLog.getHisId()); // 每一次草稿的id(第一次发起文档编辑时的id)
|
||||
params.add("docId", createTimeLatestOnlineFileLog.getId()); // 基线文档主键id
|
||||
|
||||
// 使用HttpEntity对象包装请求体和请求头
|
||||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
|
||||
|
||||
// 发送POST请求并获取响应
|
||||
ResponseEntity<String> 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<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
|
||||
// messageConverters.add(new FormHttpMessageConverter());
|
||||
// restTemplate2.setMessageConverters(messageConverters);
|
||||
|
||||
HttpHeaders headers2 = new HttpHeaders();
|
||||
headers2.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
|
||||
// 创建MultiValueMap对象,用于存储请求参数
|
||||
MultiValueMap<String, Object> 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<MultiValueMap<String, Object>> requestEntity2 = new HttpEntity<>(params2, headers2);
|
||||
|
||||
// 发送POST请求并获取响应
|
||||
ResponseEntity<String> 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();
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -58,4 +58,7 @@ public class OnlineFileLog {
|
||||
@ApiModelProperty(value = "基线保存文件名称")
|
||||
private String jxFileName;
|
||||
|
||||
@ApiModelProperty(value = "比亚迪-基线文件id(比亚迪上传文件接口返回)")
|
||||
private String bydJxFileId;
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -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<BusProcessModelHis>
|
||||
|
||||
String saveProcessFileToOss(String hisId);
|
||||
|
||||
String onlyOfficeEditor(JSONObject json);
|
||||
|
||||
String onlyOfficePreview(JSONObject json);
|
||||
}
|
||||
|
||||
+105
@@ -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<BusProcessModelHi
|
||||
@Value(value = "${jero.uploadType}")
|
||||
private String uploadType;
|
||||
|
||||
@Value("${onlyOffice.editorUrl}")
|
||||
private String onlyOfficeEditorUrl;
|
||||
|
||||
@Value("${onlyOffice.previewUrl}")
|
||||
private String onlyOfficePreviewUrl;
|
||||
|
||||
@Override
|
||||
public BusProcessModelHis saveEditFile(String model) {
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
@@ -435,4 +442,102 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl<BusProcessModelHi
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String onlyOfficeEditor(JSONObject json) {
|
||||
StringBuilder resultSb = new StringBuilder();
|
||||
String fileId = json.getString("fileId");
|
||||
String userName = json.getString("userName");
|
||||
String standName = json.getString("standName");
|
||||
String serialNumber = json.getString("serialNumber");
|
||||
String replaceStand = json.getString("replaceStand");
|
||||
String estDepart = json.getString("estDepart");
|
||||
String drafts = json.getString("drafts");
|
||||
|
||||
String model = json.getString("model");
|
||||
|
||||
BusProcessModelHis modelHis = new BusProcessModelHis();
|
||||
modelHis.setId(fileId);
|
||||
try {
|
||||
String preUuid2 = UUID.randomUUID().toString();
|
||||
String changUuid = preUuid2.substring(0, 8);
|
||||
String taskId = "task_" + changUuid;
|
||||
String topId = "top_" + changUuid;
|
||||
|
||||
String builderModel = "model" + "/";
|
||||
|
||||
File dir = new File(filePath + builderModel);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
String fileName = model + ".docx";
|
||||
modelHis.setFileName(fileName);
|
||||
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(sourceFilePath);
|
||||
File targetFile = new File(filePath + targetPath);
|
||||
FileUtils.copyFile(sourceFile, targetFile);
|
||||
|
||||
modelHis.setTaskId(taskId);
|
||||
modelHis.setPId(topId);
|
||||
modelHis.setEditFilePath(targetPath);
|
||||
modelHis.setDownLoadUrl(downloadUrl + targetPath);
|
||||
this.baseMapper.insert(modelHis);
|
||||
|
||||
resultSb.append(onlyOfficeEditorUrl);
|
||||
resultSb.append("fileId=").append(fileId).append("&");
|
||||
resultSb.append("pid=").append(modelHis.getPId()).append("&");
|
||||
resultSb.append("taskIds=").append(modelHis.getTaskId()).append("&");
|
||||
// resultSb.append("editType=").append("null").append("&");
|
||||
resultSb.append("oldFileName=").append(modelHis.getFileName()).append("&");
|
||||
// resultSb.append("fileType=").append("docx").append("&");
|
||||
resultSb.append("attId=").append(fileId).append("&");
|
||||
resultSb.append("fileUrl=").append(modelHis.getDownLoadUrl()).append("&");
|
||||
// resultSb.append("key=").append("key").append("&");
|
||||
resultSb.append("filePath=").append(modelHis.getEditFilePath()).append("&");
|
||||
resultSb.append("fileName=").append(modelHis.getFileName()).append("&");
|
||||
// resultSb.append("userId=").append("null").append("&");
|
||||
resultSb.append("userName=").append(userName).append("&");
|
||||
// resultSb.append("isEdit=").append("123").append("&");
|
||||
resultSb.append("standCode=").append(serialNumber).append("&");
|
||||
resultSb.append("standName=").append(standName).append("&");
|
||||
resultSb.append("draftingDepartment=").append(estDepart).append("&");
|
||||
resultSb.append("draftsman=").append(drafts).append("&");
|
||||
// resultSb.append("assessor=").append("").append("&");
|
||||
// resultSb.append("focalUnit=").append("").append("&");
|
||||
resultSb.append("replaceStand=").append(replaceStand);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
return resultSb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onlyOfficePreview(JSONObject json) {
|
||||
StringBuilder resultSb = new StringBuilder();
|
||||
String fileId = json.getString("fileId");
|
||||
String watermark = json.getString("watermark");
|
||||
|
||||
BusProcessModelHis busProcessModelHis = this.processEditFile(fileId);
|
||||
|
||||
resultSb.append(onlyOfficePreviewUrl);
|
||||
resultSb.append("oldFileName=").append(busProcessModelHis.getFileName()).append("&");
|
||||
resultSb.append("fileType=").append("docx").append("&");
|
||||
resultSb.append("attId=").append(busProcessModelHis.getId()).append("&");
|
||||
resultSb.append("fileUrl=").append(busProcessModelHis.getDownLoadUrl()).append("&");
|
||||
resultSb.append("key=").append("key").append("&");
|
||||
resultSb.append("filePath=").append(busProcessModelHis.getEditFilePath()).append("&");
|
||||
resultSb.append("fileName=").append(busProcessModelHis.getFileName());
|
||||
return resultSb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -150,4 +150,9 @@ public class SarFileSplitInfoEO implements Serializable {
|
||||
@ApiModelProperty("ids")
|
||||
@TableField(exist = false)
|
||||
private String ids;
|
||||
|
||||
/**文件路径-BYD调用主动拆分接口传过来的文件路径*/
|
||||
@ApiModelProperty("ids")
|
||||
@TableField(exist = false)
|
||||
private String filePath;
|
||||
}
|
||||
|
||||
+55
-14
@@ -2,6 +2,7 @@ package com.jero.modules.split.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.MinioUtil;
|
||||
import com.jero.common.util.UUIDUtils;
|
||||
@@ -46,9 +47,17 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr;
|
||||
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.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
@@ -102,6 +111,13 @@ public class FileSpiltService {
|
||||
|
||||
@Value("${mathToImg.url}")
|
||||
private String mathToImgUrl;
|
||||
|
||||
/**
|
||||
* 比亚迪-下载文件url
|
||||
*/
|
||||
@Value("${byd.downLoadFileUrl}")
|
||||
private String bydDownLoadFileUrl;
|
||||
|
||||
/**
|
||||
* 中国标准数据拆分
|
||||
*
|
||||
@@ -109,7 +125,7 @@ public class FileSpiltService {
|
||||
* @param enumByValue
|
||||
* @return
|
||||
*/
|
||||
public int fileCHN(SarFileSplitInfoEO sarFileSplitInfoEO, SplitFileTypeTypeEnum enumByValue) {
|
||||
public int fileCHN(SarFileSplitInfoEO sarFileSplitInfoEO, SplitFileTypeTypeEnum enumByValue,String splitSource) {
|
||||
if (sarFileSplitInfoEO.getStopNumber() <= 0) {
|
||||
sarFileSplitInfoEO.setStopNumber(200);
|
||||
}
|
||||
@@ -157,20 +173,45 @@ public class FileSpiltService {
|
||||
// nowStart.add(String.valueOf(sarFileSplitInfoEO.getStartNumber()));
|
||||
// }
|
||||
// 获取文件地址
|
||||
String fileId = sarFileSplitInfoEO.getFileId();
|
||||
LambdaQueryWrapper<OSSFile> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.eq(OSSFile::getId, fileId);
|
||||
queryWrapper.orderByDesc(OSSFile::getCreateTime);
|
||||
List<OSSFile> 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<OSSFile> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.eq(OSSFile::getId, fileId);
|
||||
queryWrapper.orderByDesc(OSSFile::getCreateTime);
|
||||
List<OSSFile> 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<String, String> params = new LinkedMultiValueMap<>();
|
||||
String fileId = sarFileSplitInfoEO.getId();
|
||||
params.add("fileId", fileId);
|
||||
|
||||
// 使用HttpEntity对象包装请求体和请求头
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
||||
|
||||
// 发送POST请求并获取响应
|
||||
ResponseEntity<byte[]> 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);
|
||||
|
||||
+2
-1
@@ -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<SarFileSplitInfoMap
|
||||
}*/
|
||||
|
||||
int result = 0;
|
||||
result = fileSpiltService.fileCHN(sarFileSplitInfoEO,SplitFileTypeTypeEnum.GBT);
|
||||
result = fileSpiltService.fileCHN(sarFileSplitInfoEO,SplitFileTypeTypeEnum.GBT, CommonConstant.SPLIT_SOURCE_1);
|
||||
|
||||
if(result == -1){
|
||||
if(LanguageEnum.CN.equals(MessageUtils.getLanguage())) {
|
||||
|
||||
+19
@@ -486,3 +486,22 @@ watermark:
|
||||
# 特殊公式处理服务URL
|
||||
mathToImg:
|
||||
url: http://127.0.0.1:9998/mathToImg
|
||||
|
||||
# onlyOffice在线编辑页Url
|
||||
onlyOffice:
|
||||
editorUrl: http://39.98.140.126:8999/editor?
|
||||
previewUrl: http://39.98.140.126:8889/onlyOffice?
|
||||
|
||||
# 与比亚迪对接,调用的URL地址
|
||||
byd:
|
||||
# uploadFileUrl: http://127.0.0.1:9998/ipd-files/file/v1/upload
|
||||
# saveBaseLineDocIdUrl: http://127.0.0.1:9998/api/qbp/organization/saveBaseLineDocId
|
||||
# splitResultUrl: http://127.0.0.1:9998/api/qbp/library/structured
|
||||
# downLoadFileUrl: http://127.0.0.1:9998/ipd-files/file/downLoad
|
||||
|
||||
# 开发环境
|
||||
uploadFileUrl: http://127.0.0.1:9998/uploadFileUrl
|
||||
saveBaseLineDocIdUrl: http://127.0.0.1:9998/saveBaseLineDocIdUrl
|
||||
splitResultUrl: http://127.0.0.1:9998/splitResultUrl
|
||||
downLoadFileUrl: http://127.0.0.1:9998/downLoadFileUrl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user