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

This commit is contained in:
wangzhijiang
2022-10-11 09:55:59 +08:00
45 changed files with 1191 additions and 511 deletions
@@ -1263,6 +1263,9 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
}
List<String> configIdList = Arrays.asList(paramsReportDetailVO.getConfigIds().split(",")); // 需要导出的配置列
List<Map<String, Object>> dataList = paramsReportDetailEOMapper.listInfoForExport(idList, paramsReportDetailVO); // 查询需要导出的数据
dataList = dataList.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(p -> (String) p.get("id")))),
ArrayList::new)); // 去重
List<ParamsReportConfigEO> paramsConfigEOList = paramsReportConfigEOService.queryList(paramsReportDetailVO.getParamsManifestId()); // 查询所有配置列
@@ -8,8 +8,10 @@ public class SarFileCompareResultVO {
private String infoId;
private String serialNumberLeft;
private String fileNameLeft;
private String fileIdLeft;
private String serialNumberRight;
private String fileNameRight;
private String fileIdRight;
private List<SarFileCompareItemComVO> resList;
private String comments;
@@ -78,4 +80,20 @@ public class SarFileCompareResultVO {
public void setComments(String comments) {
this.comments = comments;
}
public String getFileIdLeft() {
return fileIdLeft;
}
public void setFileIdLeft(String fileIdLeft) {
this.fileIdLeft = fileIdLeft;
}
public String getFileIdRight() {
return fileIdRight;
}
public void setFileIdRight(String fileIdRight) {
this.fileIdRight = fileIdRight;
}
}
@@ -0,0 +1,21 @@
package com.jero.modules.compare.enums;
public enum AssessConsistencyEnum {
SAME("一致"),
DIFFERENT("差异");
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
AssessConsistencyEnum(String value) {
this.value = value;
}
}
@@ -7,6 +7,7 @@ import com.jero.common.constant.enums.CutEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.oss.CosBootUtil;
import com.jero.modules.compare.entity.*;
import com.jero.modules.compare.enums.AssessConsistencyEnum;
import com.jero.modules.compare.mapper.SarFileCompareItemCommentMapper;
import com.jero.modules.compare.service.ISarFileCompareInfoService;
import com.jero.modules.compare.service.ISarFileCompareItemCommentService;
@@ -143,8 +144,10 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
resultVO.setInfoId(infoId);
resultVO.setSerialNumberLeft(sfcInfo.getSerialNumberLeft());
resultVO.setFileNameLeft(sfcInfo.getFileNameLeft());
resultVO.setFileIdLeft(sfcInfo.getFileIdLeft());
resultVO.setSerialNumberRight(sfcInfo.getSerialNumberRight());
resultVO.setFileNameRight(sfcInfo.getFileNameRight());
resultVO.setFileIdRight(sfcInfo.getFileIdRight());
resultVO.setComments(sfcInfo.getComments());
List<SarFileCompareItemComment> list = queryListByInfoId(infoId,comment);
@@ -180,7 +183,11 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
public List<SarFileCompareItemComment> queryListByInfoId(String infoId,String comment) {
LambdaQueryWrapper<SarFileCompareItemComment> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtils.isNotEmpty(comment)) {
queryWrapper.eq(SarFileCompareItemComment::getComment, comment);
if (AssessConsistencyEnum.SAME.getValue().equals(comment)) {
queryWrapper.eq(SarFileCompareItemComment::getComment, comment);
} else if (AssessConsistencyEnum.DIFFERENT.getValue().equals(comment)) {
queryWrapper.ne(SarFileCompareItemComment::getComment, AssessConsistencyEnum.SAME.getValue());
}
}
queryWrapper.eq(SarFileCompareItemComment::getInfoId, infoId);
queryWrapper.orderBy(true, true, SarFileCompareItemComment::getCreateTime);
@@ -201,7 +208,11 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
queryWrapper.in(SarFileCompareItemComment::getId, Arrays.asList(selectIds.split(",")));
}
if (ObjectUtils.isNotEmpty(comment)) {
queryWrapper.eq(SarFileCompareItemComment::getComment, comment);
if (AssessConsistencyEnum.SAME.getValue().equals(comment)) {
queryWrapper.eq(SarFileCompareItemComment::getComment, comment);
} else if (AssessConsistencyEnum.DIFFERENT.getValue().equals(comment)) {
queryWrapper.ne(SarFileCompareItemComment::getComment, AssessConsistencyEnum.SAME.getValue());
}
}
queryWrapper.orderBy(true, true, SarFileCompareItemComment::getCreateTime);
list = this.list(queryWrapper);
@@ -288,9 +299,9 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
if (ObjectUtils.isEmpty(row2)) {
row2 = sheet.createRow(j + i);
}
imgToExcel(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row2, i, j, leftSplit[j], 3);
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row2, i, j, leftSplit[j], 3);
} else {
imgToExcel(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row, i, j, leftSplit[j], 3);
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row, i, j, leftSplit[j], 3);
}
}
}
@@ -322,9 +333,9 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
if (ObjectUtils.isEmpty(row2)) {
row2 = sheet.createRow(j + i);
}
imgToExcel(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row2, i, j, rightSplit[j], 7);
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row2, i, j, rightSplit[j], 7);
} else {
imgToExcel(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row, i, j, rightSplit[j], 7);
handleSpecificData(workbook, dir, patriarch, cellStyleLink, byteArrayOut, row, i, j, rightSplit[j], 7);
}
}
}
@@ -401,7 +412,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
}
/**
* 将图片添加到excel指定单元格中
* 处理图片跟表格类型的数据
* @param workbook
* @param dir
* @param patriarch
@@ -414,7 +425,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
* @param cellNum
* @throws IOException
*/
private void imgToExcel(Workbook workbook, String dir, HSSFPatriarch patriarch, CellStyle cellStyleLink, ByteArrayOutputStream byteArrayOut, Row row, int i, int j, String text, int cellNum) throws IOException {
private void handleSpecificData(Workbook workbook, String dir, HSSFPatriarch patriarch, CellStyle cellStyleLink, ByteArrayOutputStream byteArrayOut, Row row, int i, int j, String text, int cellNum) throws IOException {
if (text.contains("/upFiles")) {
row.setHeight((short) 3000); //设置行高
//先将图片下载到本地
@@ -439,7 +450,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
} else {
Cell cell = row.createCell(cellNum);
if (text.contains("<table")) {
tableAssociations(workbook, cellStyleLink, cell, text);
tableAssociate(workbook, cellStyleLink, cell, text);
} else {
cell.setCellValue(text);
}
@@ -453,7 +464,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
* @param cell
* @param tableHtml
*/
private void tableAssociations(Workbook workbook, CellStyle cellStyleLink, Cell cell, String tableHtml) {
private void tableAssociate(Workbook workbook, CellStyle cellStyleLink, Cell cell, String tableHtml) {
cell.setCellValue("点击查看详情");
//新开sheet生成表格
if (org.apache.commons.lang.StringUtils.isNotEmpty(tableHtml) && tableHtml.indexOf("<tbody>") < 0) {
@@ -487,7 +498,7 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
private String getSplitContent(HttpServletRequest request, String text) {
text = text.replace("<p>", "").replace("</p>", "\r\n");
//分割图片
addImgdata(text, request.getSession());
splitImg(text, request.getSession());
//分割表格
String txtAndImg = (String) request.getSession().getAttribute("txtAndImg");
txtAndImg = txtAndImg.replaceAll("table", "replaceTable");
@@ -514,18 +525,19 @@ public class SarFileCompareItemCommentServiceImpl extends ServiceImpl<SarFileCom
}
/**
* 提取字符串中<img>标签内容中的图片路径,并重新按顺序拼接
* 分割图片
* @param text
* @param session
* @return
*/
private void addImgdata(String text,HttpSession session) {
private void splitImg(String text,HttpSession session) {
if (text.contains("<img")) {
String txtLeft = text.substring(0, text.indexOf("<img"));
String txtRight = text.substring(text.indexOf("g\">") + 3);
String img = text.substring(text.indexOf("<img"), text.indexOf("g\">"));
String path = img.substring(img.lastIndexOf("=") + 1)+"g";
text = txtLeft + "---" + path + "---" + txtRight;
addImgdata(text, session);
splitImg(text, session);
} else {
session.setAttribute("txtAndImg", text);
}
@@ -25,6 +25,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
@@ -92,7 +93,11 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
queryWrapper.eq(ExtRepoData::getSupFolder, extRepoData.getSupFolder());
queryWrapper.orderBy(true, false, ExtRepoData::getCreateTime);
IPage<ExtRepoData> pageList = extRepoDataService.page(page, queryWrapper);
ExtRepoDataPage res = new ExtRepoDataPage(extRepoFolderService.haveManageAuth(extRepoData.getSupFolder()), pageList);
//判断当前文件夹或者上级文件夹是否有权限
HttpSession session = req.getSession();
session.setAttribute("haveSuperiorManageAuth", false);
extRepoFolderService.haveSuperiorManageAuth(extRepoData.getSupFolder(),session);
ExtRepoDataPage res = new ExtRepoDataPage((Boolean)session.getAttribute("haveSuperiorManageAuth"), pageList);
return Result.OK(res);
}
@@ -118,9 +123,12 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
@AutoLog(value = "对外报告数据表-添加")
@ApiOperation(value = "对外报告数据表-添加", notes = "对外报告数据表-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody ExtRepoData extRepoData) {
public Result<?> add(@Validated @RequestBody ExtRepoData extRepoData,HttpSession session) {
Result<ExtRepoData> result = new Result();
if (extRepoFolderService.haveManageAuth(extRepoData.getSupFolder())) {
//判断当前文件夹或者上级文件夹是否有权限
session.setAttribute("haveSuperiorManageAuth", false);
extRepoFolderService.haveSuperiorManageAuth(extRepoData.getSupFolder(),session);
if ((Boolean)session.getAttribute("haveSuperiorManageAuth")) {
log.info("对外报告数据表收到文件添加请求,开始处理文件:【" + sdf.format(new Date()) + "】");
int res = extRepoDataService.add(extRepoData);
if (CutEnum.CN.getValue().equals(extRepoData.getCut())) {
@@ -148,11 +156,14 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
@AutoLog(value = "对外报告数据表-编辑")
@ApiOperation(value = "对外报告数据表-编辑", notes = "对外报告数据表-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody ExtRepoData extRepoData) {
public Result<?> edit(@Validated @RequestBody ExtRepoData extRepoData,HttpSession session) {
Result<ExtRepoData> result = new Result();
ExtRepoData erd = extRepoDataService.queryById(extRepoData.getId());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (extRepoFolderService.isManager() || sysUser.getUsername().equals(erd.getCreateBy())) {
//LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//判断当前文件夹或者上级文件夹是否有权限
session.setAttribute("haveSuperiorManageAuth", false);
extRepoFolderService.haveSuperiorManageAuth(erd.getSupFolder(),session);
if (extRepoFolderService.isManager() || (Boolean)session.getAttribute("haveSuperiorManageAuth")) {
extRepoData.setSupFolder(erd.getSupFolder());
extRepoDataService.editById(extRepoData);
if (CutEnum.CN.getValue().equals(extRepoData.getCut())) {
@@ -180,12 +191,15 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
@ApiOperation(value = "对外报告数据表-通过id删除", notes = "对外报告数据表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam("id") String id,
@RequestParam(name = "cut", defaultValue = "cn") String cut) {
@RequestParam(name = "cut", defaultValue = "cn") String cut,HttpSession session) {
Result<ExtRepoData> result = new Result();
ExtRepoData erd = extRepoDataService.queryById(id);
if (null != erd) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (extRepoFolderService.isManager() || sysUser.getUsername().equals(erd.getCreateBy())) {
//LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//判断当前文件夹或者上级文件夹是否有权限
session.setAttribute("haveSuperiorManageAuth", false);
extRepoFolderService.haveSuperiorManageAuth(erd.getSupFolder(),session);
if (extRepoFolderService.isManager() || (Boolean)session.getAttribute("haveSuperiorManageAuth")) {
extRepoDataService.deleteById(id);
CosBootUtil.delete(erd.getFileKey());
if (CutEnum.CN.getValue().equals(cut)) {
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.base.controller.JeroController;
import com.jero.modules.extRepo.entity.ERFTreeDataVO;
import com.jero.modules.extRepo.entity.ExtRepoData;
@@ -66,11 +67,20 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
public Result<?> add(@Validated @RequestBody ExtRepoFolder extRepoFolder, HttpSession session) {
Result<ExtRepoFolder> result = new Result();
session.setAttribute("haveSuperiorManageAuth", false);
extRepoFolderService.haveSuperiorManageAuth(extRepoFolder.getSupFolder(),session);
if (ObjectUtils.isNotEmpty(session.getAttribute("haveSuperiorManageAuth"))&&(Boolean) session.getAttribute("haveSuperiorManageAuth")) {
ExtRepoFolder folder = extRepoFolderService.queryById(extRepoFolder.getSupFolder());
extRepoFolderService.haveSuperiorManageAuth(folder.getSupFolder(),session);
//上层是否有权限
boolean boo = (Boolean)session.getAttribute("haveSuperiorManageAuth");
if (boo||extRepoFolderService.haveManageAuth(extRepoFolder.getSupFolder())) {
if (!extRepoFolder.isAddSub()) {
//增加同级文件夹
ExtRepoFolder folder = extRepoFolderService.queryById(extRepoFolder.getSupFolder());
if (!boo) {
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
throw new JeroBootException("无法创建同级文件夹!请联系管理员!");
} else {
throw new JeroBootException("Unable to create a sibling folder ! Please Contact your administrator !");
}
}
extRepoFolder.setSupFolder(folder.getSupFolder());
}
extRepoFolderService.add(extRepoFolder);
@@ -89,6 +99,41 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
return result;
}
/**
* 是否允许增加同级文件夹
* @param extRepoFolder
* @return
*/
@AutoLog(value = "是否允许增加同级文件夹")
@ApiOperation(value = "是否允许增加同级文件夹", notes = "是否允许增加同级文件夹")
@PostMapping(value = "/isAllowSiblingFolder")
public Result<?> isAllowSiblingFolder(@Validated @RequestBody ExtRepoFolder extRepoFolder,
HttpSession session) {
Result<ExtRepoFolder> result = new Result();
session.setAttribute("haveSuperiorManageAuth", false);
ExtRepoFolder folder = extRepoFolderService.queryById(extRepoFolder.getId());
extRepoFolderService.haveSuperiorManageAuth(folder.getSupFolder(),session);
//上层是否有权限
boolean boo = (Boolean)session.getAttribute("haveSuperiorManageAuth");
if (boo || extRepoFolderService.haveManageAuth(extRepoFolder.getId())) {
if (!boo) {
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
return result.error500("无法创建同级文件夹!请联系管理员!");
} else {
return result.error500("Unable to create a sibling folder ! Please Contact your administrator !");
}
}
} else {
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
return result.error500("没有权限!");
} else {
return result.error500("You do not have permission !");
}
}
return result.success("");
}
/**
* 编辑
*
@@ -101,7 +146,7 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
public Result<?> edit(@Validated @RequestBody ExtRepoFolder extRepoFolder, HttpSession session) {
Result<ExtRepoFolder> result = new Result();
session.setAttribute("haveSuperiorManageAuth", false);
extRepoFolderService.haveSuperiorManageAuth(extRepoFolder.getSupFolder(),session);
extRepoFolderService.haveSuperiorManageAuth(extRepoFolder.getId(),session);
if (ObjectUtils.isNotEmpty(session.getAttribute("haveSuperiorManageAuth"))&&(Boolean) session.getAttribute("haveSuperiorManageAuth")) {
extRepoFolderService.editById(extRepoFolder);
if (CutEnum.CN.getValue().equals(extRepoFolder.getCut())) {
@@ -241,7 +241,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
List<ERFTreeData> resList = new ArrayList<>();
for (ExtRepoFolder erf : list) {
if (supId.equals(erf.getSupFolder())) {
int childLevel = level + 1;
//int childLevel = level + 1;
if (haveViewAuth(erf.getId())) {
ERFTreeData date = new ERFTreeData(erf.getFolderName(), erf.getId(), level, erf.getOrderId());
boolean parentRightClick = haveManageAuth(erf.getId());
@@ -252,11 +252,11 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
date.setAuthManageIds(erf.getAuthManageIds());
date.setAuthViewIdsName(erf.getAuthViewIdsName());
date.setAuthViewIds(erf.getAuthViewIds());
date.setChildren(subFolderTree(erf.getId(),new ArrayList<ERFTreeData>(),childLevel,parentRightClick));
date.setChildren(subFolderTree(erf.getId(),new ArrayList<ERFTreeData>(),level,parentRightClick));
date.sortChildren();
resList.add(date);
} else {
resList.addAll(getSubFolder(erf.getId(), list, childLevel));
resList.addAll(getSubFolder(erf.getId(), list, level));
}
}
}
@@ -189,7 +189,7 @@ public class WordUtil {
Drawing drawing = factory.createDrawing();
drawing.getAnchorOrInline().add(inline);
run.getContent().add(drawing);
replaceTextToImage(bm, text, wordMLPackage, bytes);
replaceTextToImage(bm, "\\$\\{" + key + "\\}", text, wordMLPackage, bytes);
}
}
} catch (Exception var17) {
@@ -218,7 +218,7 @@ public class WordUtil {
byte[] bytes = (byte[]) picMap.get("bytes");
for(Text bm : textList) {
if (bm.getValue().equals("${" + key + "}")) {
if (bm.getValue().contains("${" + key + "}")) {
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
Inline inline = imagePart.createImageInline("", "", 0, 1, true);
ObjectFactory factory = new ObjectFactory();
@@ -226,7 +226,7 @@ public class WordUtil {
Drawing drawing = factory.createDrawing();
drawing.getAnchorOrInline().add(inline);
run.getContent().add(drawing);
replaceTextToImage(bm, text, wordMLPackage, bytes);
replaceTextToImage(bm, "\\$\\{" + key + "\\}", text, wordMLPackage, bytes);
}
}
}
@@ -387,7 +387,7 @@ public class WordUtil {
* @throws Exception
* @author liyawei
*/
public static void replaceTextToImage(Text bm, Object object, WordprocessingMLPackage wordMLPackage , byte[] bytes) throws Exception {
public static void replaceTextToImage(Text bm, String key, Object object, WordprocessingMLPackage wordMLPackage , byte[] bytes) throws Exception {
if (wordMLPackage == null) {
return;
}
@@ -423,16 +423,49 @@ public class WordUtil {
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
Inline inline = imagePart.createImageInline("", "", 0, 1, true);
ObjectFactory factory = Context.getWmlObjectFactory();
R run = factory.createR();
// R run = factory.createR();
Drawing drawing = factory.createDrawing();
if(text != null){
Text txt = factory.createText();
txt.setValue(text);
run.getContent().add(txt);
for(int j=0;j<r.getContent().size();j++) {
r.getContent().remove(j);
}
run.getContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
theList.add(rangeStart, run); // 添加图片到原占位符位置
String values = bm.getValue().replaceAll(key,"#");
int length = values.length();
String[] valueStr = new String[length];
for(int v=0; v<length; v++) {
valueStr[v] = values.charAt(v) + "";
}
int index = 0;
for(int k=0;k<valueStr.length;k++){
if(valueStr[k].equals("#")){
if(k>0 && !valueStr[k-1].equals("#")) {
Text txt = factory.createText();
txt.setValue(values.substring(index, k));
r.getContent().add(txt);
}
if (text != null) {
Text txtp = factory.createText();
txtp.setValue(text);
r.getContent().add(txtp);
}
r.getContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
index = k + 1;
}
}
if(!values.endsWith("#")) {
Text txt = factory.createText();
txt.setValue(values.substring(index));
r.getContent().add(txt);
}
theList.add(rangeStart, r); // 添加图片到原占位符位置
} else {
return;
@@ -3754,7 +3754,26 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
@Override
public int insertForeach(List<SarFileSplitItemsEO> messageList) {
return dao.insertForeach(messageList);
// 解决一次批量插入太多 PacketTooBigException 异常
int total = messageList.size();
int count = 0;
int pageSum = 1;
if(total > 100) {
pageSum = total / 100; // 总页数
if ((total % 100) > 0) {
pageSum += 1;
}
}
List<SarFileSplitItemsEO> subList = new ArrayList<>();
for(int i = 0; i < pageSum; i++) {
int j = i*100+100;
if (i == pageSum -1) {
j = total;
}
subList = messageList.subList(i*100, j);
count += dao.insertForeach(subList);
}
return count;
}
/**
@@ -1784,7 +1784,7 @@ public class FileSplitPdfService {
if(StringUtils.isNotBlank(preName)) {
List<String> nowStartList = fileSpiltService.getNewNowStart(preName);
List<String> subList1 = startDigitList.subList(preNameNum, startDigitList.size()-1);
List<String> subList1 = startDigitList.subList(preNameNum, startDigitList.size());
// 后文有一级以下的标题
for (int i = nowStartList.size() - 1; i >= 1; i--) {
int index1 = subList1.indexOf(nowStartList.get(i));
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@@ -79,8 +80,26 @@ public class SarFileSplitItemsValEOServiceImpl extends ServiceImpl<SarFileSplitI
@Override
public int insertForeach(List<SarFileSplitItemsValEO> itemValList) {
return dao.insertForeach(itemValList);
// 解决一次批量插入太多 PacketTooBigException 异常
int total = itemValList.size();
int count = 0;
int pageSum = 1;
if(total > 100) {
pageSum = total / 100; // 总页数
if ((total % 100) > 0) {
pageSum += 1;
}
}
List<SarFileSplitItemsValEO> subList = new ArrayList<>();
for(int i = 0; i < pageSum; i++) {
int j = i*100+100;
if (i == pageSum -1) {
j = total;
}
subList = itemValList.subList(i*100, j);
count += dao.insertForeach(subList);
}
return count;
}
}