Merge remote-tracking branch 'origin/dev_third_stage' into dev_third_stage

This commit is contained in:
高嵩
2022-10-19 18:02:51 +08:00
9 changed files with 86 additions and 18 deletions
@@ -17,6 +17,7 @@ import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.*;
import java.lang.reflect.Field;
@Slf4j
public class PDFUtils {
@@ -217,7 +218,10 @@ public class PDFUtils {
String path = uploadpath + File.separator + fileName;
newFilePath = path.replace(fileName, "transformation" + fileName);
reader = new PdfReader(byes);
//解密文件
Field f = PdfReader.class.getDeclaredField("ownerPasswordUsed");
f.setAccessible(true);
f.set(reader, Boolean.TRUE);
// 加完水印的文件
os = new FileOutputStream(newFilePath);
stamper = new PdfStamper(reader, os);
@@ -286,6 +290,11 @@ public class PDFUtils {
e.printStackTrace();
log.error(e.getMessage());
} catch (IllegalAccessException e) {
e.printStackTrace();
log.error(e.getMessage());
}catch (NoSuchFieldException e) {
e.printStackTrace();
} finally {
try {
stamper.close();
@@ -2,6 +2,7 @@ package com.jero.modules.compare.service.impl;
import com.aliyuncs.utils.IOUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.exception.JeroBootException;
@@ -14,13 +15,13 @@ import com.jero.modules.compare.service.ISarFileCompareItemCommentService;
import com.jero.modules.compare.service.ISarFileCompareItemService;
import com.jero.modules.compare.utils.ConvertHtml2Excel;
import com.jero.modules.system.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -36,8 +37,6 @@ import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Description: 文档对比信息条款评论表
@@ -46,6 +45,7 @@ import java.util.regex.Pattern;
* @Version: V1.0
*/
@Service
@Slf4j
public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCompareItemCommentMapper, SarFileCompareItemComment> implements ISarFileCompareItemCommentService {
@Autowired
@@ -102,7 +102,29 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
*/
@Override
public void deleteById(String id) {
//删除时需要判断左侧跟右侧是否还有评论,如果没有,将对应的reviewed改为0
String itemsIdLeft;
String itemsIdRight;
SarFileCompareItemComment sarFileCompareItemComment = queryById(id);
itemsIdLeft = sarFileCompareItemComment.getItemsIdLeft();
itemsIdRight = sarFileCompareItemComment.getItemsIdRight();
removeById(id);
QueryWrapper<SarFileCompareItemComment> left = new QueryWrapper<>();
left.eq("items_id_left", itemsIdLeft);
if (baseMapper.selectCount(left) == 0) {
SarFileCompareItem sarFileCompareItem = SarFileCompareItemServiceImpl.queryById(itemsIdLeft);
sarFileCompareItem.setReviewed(0);
SarFileCompareItemServiceImpl.saveOrUpdate(sarFileCompareItem);
}
QueryWrapper<SarFileCompareItemComment> right = new QueryWrapper<>();
right.eq("items_id_right", itemsIdRight);
if (baseMapper.selectCount(right) == 0) {
SarFileCompareItem sarFileCompareItem = SarFileCompareItemServiceImpl.queryById(itemsIdRight);
sarFileCompareItem.setReviewed(0);
SarFileCompareItemServiceImpl.saveOrUpdate(sarFileCompareItem);
}
}
/**
@@ -223,14 +245,16 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
OutputStream os = null;
Workbook workbook = new HSSFWorkbook();
log.info("-------------- workbook创建成功 -----------------");
//在本地创建图片文件夹
log.info("-------------- 在本地创建图片文件夹 -----------------");
String dir = filePath + File.separator + UUID.randomUUID().toString().replace("-", "");
File dirFile = new File(dir);
if (dirFile.exists()){
dirFile.delete();
}
dirFile.mkdirs();
log.info("-------------- 文件夹创建成功:"+ dirFile.getAbsolutePath() +" -----------------");
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String fileName = "导出对比结果 " + sdf.format(new Date()) + ".xlsx";
@@ -288,7 +312,9 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
row.createCell(1).setCellValue(itemLeft.getItemsNum());
row.createCell(2).setCellValue(itemLeft.getItemsName());
String text = itemLeft.getItemsText();
log.info("-------------- 开始开始拆分左侧图片、文字、表格 :" + text + "-----------------");
String rowDataAndPath = getSplitContent(request, text);
log.info("-------------- 左侧图片、文字、表格 拆分成功 :"+ rowDataAndPath +"-----------------");
leftSplit = rowDataAndPath.split("---");
if (leftSplit.length > 1) {
for (int j = 0; j < leftSplit.length; j++) {
@@ -299,9 +325,13 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
if (ObjectUtils.isEmpty(row2)) {
row2 = sheet.createRow(j + i);
}
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row2, i, j, leftSplit[j], 3);
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
} else {
log.info("-------------- 开始开始处理左侧图片、表格 -----------------");
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row, i, j, leftSplit[j], 3);
log.info("-------------- 左侧图片、表格 处理成功 -----------------");
}
}
}
@@ -322,7 +352,9 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
row.createCell(5).setCellValue(itemRight.getItemsNum());
row.createCell(6).setCellValue(itemRight.getItemsName());
String text = itemRight.getItemsText();
log.info("-------------- 开始开始拆分右侧图片、文字、表格 :"+ text +" -----------------");
String rowDataAndPath = getSplitContent(request, text);
log.info("-------------- 右侧图片、文字、表格 拆分成功 :"+ rowDataAndPath +" -----------------");
rightSplit = rowDataAndPath.split("---");
if (rightSplit.length > 1) {
for (int j = 0; j < rightSplit.length; j++) {
@@ -333,9 +365,13 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
if (ObjectUtils.isEmpty(row2)) {
row2 = sheet.createRow(j + i);
}
log.info("-------------- 开始处理右侧图片、表格 -----------------");
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row2, i, j, rightSplit[j], 7);
log.info("-------------- 右侧图片、表格 处理成功 -----------------");
} else {
log.info("-------------- 开始处理右侧图片、表格 -----------------");
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row, i, j, rightSplit[j], 7);
log.info("-------------- 右侧图片、表格 处理成功 -----------------");
}
}
}
@@ -372,12 +408,15 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
row.getCell(1).setCellStyle(cellStyle);
}
if (ObjectUtils.isNotEmpty(mergeCells)) {
log.info("-------------- 开始处理需要合并的单元格 -----------------");
Set<SarFileCompareExcelMergeCell> mergeCellSet = new HashSet<>(mergeCells);
for (SarFileCompareExcelMergeCell mergeCell : mergeCellSet) {
Integer leftCount = mergeCell.getLeftEnd() - mergeCell.getLeftStart() + 1;
Integer rightCount = mergeCell.getRightEnd() - mergeCell.getRightStart() + 1;
Integer start = leftCount - rightCount >= 0 ? mergeCell.getLeftStart() : mergeCell.getRightStart();
log.info("-------------- 合并开始行数:" + start + " -----------------");
Integer end = leftCount - rightCount >= 0 ? mergeCell.getLeftEnd() : mergeCell.getRightEnd();
log.info("-------------- 合并结束行数: " + end + " -----------------");
//合并
CellRangeAddress region0 = new CellRangeAddress(start, end, 0, 0);
sheet.addMergedRegion(region0);
@@ -394,6 +433,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
CellRangeAddress region7 = new CellRangeAddress(start, end, 8, 8);
sheet.addMergedRegion(region7);
}
log.info("-------------- 单元格合并成功 -----------------");
}
@@ -401,6 +441,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
workbook.write(os);
os.flush();
} catch (IOException e) {
e.printStackTrace();
if (CutEnum.CN.getValue().equals(cut)) {
throw new JeroBootException("下载文件失败");
} else {
@@ -429,6 +470,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
if (text.contains("/upFiles")) {
row.setHeight((short) 3000); //设置行高
//先将图片下载到本地
log.info("-------------------------将图片下载到本地文件夹中----------------------------");
String fileLastName = text.substring(text.lastIndexOf("/") + 1);
if (CosBootUtil.doesObjectExist(text)) {
try (InputStream in = CosBootUtil.download(text)) {
@@ -439,18 +481,22 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
}
}
File file = new File(dir + File.separator + fileLastName);
log.info("-------------------------图片下载成功:"+ file.getAbsolutePath() +"----------------------------");
if (file.exists()) {
log.info("-------------------------将图片插入excel指定单元格中----------------------------");
BufferedImage bufferImg = ImageIO.read(file);
ImageIO.write(bufferImg, "jpg", byteArrayOut);
//anchor主要用于设置图片的属性
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 600, 200, (short) cellNum, j + i, (short) cellNum, j + i);
patriarch.createPicture(anchor, workbook.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
log.info("-------------------------将图片插入成功----------------------------");
}
} else {
Cell cell = row.createCell(cellNum);
if (text.contains("<table")) {
log.info("-------------------------开始处理表格----------------------------");
tableAssociate(workbook, cellStyleLink, cell, text);
log.info("-------------------------表格处理完毕----------------------------");
} else {
cell.setCellValue(text);
}
@@ -467,6 +513,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
private void tableAssociate(Workbook workbook, CellStyle cellStyleLink, Cell cell, String tableHtml) {
cell.setCellValue("点击查看详情");
//新开sheet生成表格
log.info("-------------------------开始生成表格----------------------------");
if (org.apache.commons.lang.StringUtils.isNotEmpty(tableHtml) && tableHtml.indexOf("<tbody>") < 0) {
if (tableHtml.indexOf("<thead>") < 0) {
tableHtml = tableHtml.replaceFirst("<tr>", "<tbody><tr>");
@@ -480,13 +527,16 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
tableHtml = tableHtml.replaceAll("<[\\s]*?br[^>]*?>|<[\\s]*?\\/[\\s]*?br[\\s]*?>", cnt);
String tableSheetName = "表格" + System.currentTimeMillis();
ConvertHtml2Excel.table2Excel(tableHtml, (HSSFWorkbook) workbook, tableSheetName);
log.info("-------------------------表格生产完毕----------------------------");
//添加超链接
log.info("-------------------------开始添加超链接---------------------------");
CreationHelper createHelper = workbook.getCreationHelper();
Hyperlink hyperlink1 = createHelper.createHyperlink(HyperlinkType.DOCUMENT);
String tableName = "#\'" + tableSheetName + "\'!A1";
hyperlink1.setAddress(tableName);
cell.setHyperlink(hyperlink1);// 链接
cell.setCellStyle(cellStyleLink);
log.info("-------------------------超链接添加完毕---------------------------");
}
/**
@@ -498,11 +548,15 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
private String getSplitContent(HttpServletRequest request, String text) {
text = text.replace("<p>", "").replace("</p>", "\r\n");
//分割图片
log.info("-------------------------开始分割文字与图片---------------------------");
splitImg(text, request.getSession());
log.info("-------------------------文字与图片分割完毕---------------------------");
//分割表格
log.info("-------------------------从剩余文字中开始分割表格---------------------------");
String txtAndImg = (String) request.getSession().getAttribute("txtAndImg");
txtAndImg = txtAndImg.replaceAll("table", "replaceTable");
splitTable(txtAndImg, request.getSession());
log.info("-------------------------表格分割完毕---------------------------");
return (String) request.getSession().getAttribute("textAndTableAndImg");
}
@@ -116,7 +116,7 @@ public class LawsMonthlyReportWriteEO implements Serializable {
/**适用范围*/
@Excel(name = "适用范围", width = 15)
@ApiModelProperty(value = "适用范围")
@Dict(dicCode ="apply_scope")
@Dict(dicCode ="fa3_gui1_yue4_bao4_-_shi4_yong4_fan4_wei2")
private java.lang.String applyScope;
/**状态*/
@@ -8,7 +8,7 @@ package com.jero.modules.report.enums;
*/
public enum DictCodeReportEnum {
APPLYCAR("适用车型","car_type"),
APPLYSCOPE("适用范围","apply_scope"),
APPLYSCOPE("适用范围","fa3_gui1_yue4_bao4_-_shi4_yong4_fan4_wei2"),
STATE("状态","state"),
USEMETHOD("用法","yong4_fa3");
+1
View File
@@ -199,6 +199,7 @@ module.exports = {
OperationType: 'Operation Type',
selectOperationType: 'Please select Operation type',
selectProblemClassification:'Please select Problem Classification',
selectClassification:'Please select Classification',
selectTranslationResults:'Please select Translation results',
selectMarket:'Please select Market',
RequestMethod: 'Request Method',
+1
View File
@@ -201,6 +201,7 @@ module.exports = {
OperationType: '操作类型',
selectOperationType: '请选择操作类型',
selectProblemClassification:'请选择问题分类',
selectClassification:'请选择分类',
selectTranslationResults:'请选择翻译结果',
selectMarket:'请选择市场',
RequestMethod: '请求方法',
@@ -98,7 +98,7 @@
:placeholder="$t('PleaseSelect')+$t('scopeOfApplication')"
:type="'checkbox'"
:disabled="disabled"
:triggerChange="false" :dictCode="'apply_scope'"/>
:triggerChange="false" :dictCode="'fa3_gui1_yue4_bao4_-_shi4_yong4_fan4_wei2'"/>
</a-form-model-item>
</div>
</a-col>
@@ -4,8 +4,8 @@
<div class="text-left">
<div class="text-left-wrap">
<div class="text-left-select">
<span class="text-sel" :title="$t('problemClassification')">{{$t('problemClassification')}}</span>
<a-select :placeholder="$t('selectProblemClassification')"
<span class="text-sel" :title="$t('classification')">{{$t('classification')}}</span>
<a-select :placeholder="$t('selectClassification')"
class="text-select"
mode="multiple"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
@@ -1456,15 +1456,18 @@
this.selectedRowKeys = value
},
searchQuery() {
this.selectedRowKeys = []
this.getList()
},
searchReset() {
this.queryParam = {}
this.selectedRowKeys = []
this.$refs.globalAdvancedQueryRef.resetLine()
this.$refs.globalAdvancedQueryRef.emitCallback()
// this.getList()
},
addModelList() {
this.selectedRowKeys = []
this.getList()
},
handleSuperQuery(params, matchType) {
@@ -2130,7 +2133,7 @@
} else if (fileSuffix == '.xlsx' || fileSuffix == '.xls') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
}else if(fileSuffix == '.png' || fileSuffix == '.jpeg' || fileSuffix == '.gif' || fileSuffix == '.jpg'){
} else if (fileSuffix == '.png' || fileSuffix == '.jpeg' || fileSuffix == '.gif' || fileSuffix == '.jpg') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadImgUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else {
@@ -2151,7 +2154,7 @@
} else if (fileSuffix == '.xlsx' || fileSuffix == '.xls') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + id + fileSuffix)
window.open(url, '_blank')
}else if(fileSuffix == '.png' || fileSuffix == '.jpeg' || fileSuffix == '.gif' || fileSuffix == '.jpg'){
} else if (fileSuffix == '.png' || fileSuffix == '.jpeg' || fileSuffix == '.gif' || fileSuffix == '.jpg') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadImgUrl + '/' + id + fileSuffix)
window.open(url, '_blank')
} else {
@@ -2484,17 +2487,17 @@
}
::v-deep .ant-table-body-one {
padding-bottom: 0!important;
padding-bottom: 0 !important;
}
::v-deep .antfixedLeft {
padding-bottom: 0!important;
overflow: scroll!important;
padding-bottom: 0 !important;
overflow: scroll !important;
}
::v-deep .antfixedRight {
padding-bottom: 0!important;
overflow: scroll!important;
padding-bottom: 0 !important;
overflow: scroll !important;
}
</style>
<style>