package com.chuangqi.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chuangqi.entity.*;
import com.chuangqi.mapper.ExperimentDesignMapper;
import com.chuangqi.mapper.IndexEvaluationMissionMapper;
import com.chuangqi.mapper.IndexEvaluationModelMapper;
import com.chuangqi.mapper.ProjectMapper;
import com.chuangqi.service.*;
import com.chuangqi.tools.DownloadUtils;
import com.cq.cloudsim.simtaskinfo.ExperimentDesignSpace.DesignSchemeSpaceProcesser;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.documents.HorizontalAlignment;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.fields.TableOfContent;
import com.spire.doc.fields.TextRange;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.apache.poi.xwpf.usermodel.*;
import org.apache.xmlbeans.impl.xb.xmlschema.SpaceAttribute;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import com.spire.doc.Document;
@Service
public class WordServiceImpl implements WordService {
@Autowired
private ProjectMapper projectMapper;
@Autowired
private DataService dataService;
@Autowired
private LogEvaluationService logEvaluationService;
@Autowired
private ModelService modelService;
@Autowired
private MethodService methodService;
@Autowired
private IndexEvaluationMissionMapper indexEvaluationMissionMapper;
@Autowired
private EquipmentTypeService equipmentTypeService;
@Autowired
private SecurityLevelService securityLevelService;
@Autowired
private IndexEvaluationModelMapper indexEvaluationModelMapper;
@Autowired
private ExperimentDesignMapper experimentDesignMapper;
@Autowired
private EquipmentCategoryService equipmentCategoryService;
@Autowired
private UserService userService;
@Autowired
private IndexService indexService;
@Override
public void ExportInterpretationSignsWordById(Integer id, HttpServletResponse response, HttpServletRequest request) throws IOException {
final Integer modelId = 64;
Project project = projectMapper.selectByPrimaryKey(id);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日EEEE");
String createTime = simpleDateFormat.format(new Date());
XWPFDocument document = new XWPFDocument();
addCustomHeadingStyle(document, "标题 1", 1);
addCustomHeadingStyle(document, "标题 2", 2);
addCustomHeadingStyle(document, "标题 3", 3);
XWPFParagraph titleParagraphXMBH = document.createParagraph();
CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
XWPFFooter footer = headerFooterPolicy.createFooter(STHdrFtr.DEFAULT);
System.out.println(footer);
List<XWPFParagraph> paragraphs = footer.getParagraphs();
System.out.println(paragraphs);
XWPFParagraph paragraph = footer.getParagraphArray(0);
System.out.println(paragraph);
paragraph.setAlignment(ParagraphAlignment.CENTER);
paragraph.setVerticalAlignment(TextAlignment.CENTER);
paragraph.setBorderTop(Borders.THICK);
CTTabStop tabStop = paragraph.getCTP().getPPr().addNewTabs().addNewTab();
tabStop.setVal(STTabJc.RIGHT);
int twipsPerInch = 1440;
tabStop.setPos(BigInteger.valueOf(6 * twipsPerInch));
XWPFRun run = paragraph.createRun();
setXWPFRunStyle(run, "宋体", 8);
run.addTab();
run = paragraph.createRun();
run.setText("第");
setXWPFRunStyle(run, "宋体", 8);
run = paragraph.createRun();
CTFldChar fldChar = run.getCTR().addNewFldChar();
fldChar.setFldCharType(STFldCharType.Enum.forString("begin"));
setXWPFRunStyle(run, "宋体", 8);
run = paragraph.createRun();
CTText ctText = run.getCTR().addNewInstrText();
ctText.setStringValue("PAGE \\* MERGEFORMAT");
ctText.setSpace(SpaceAttribute.Space.Enum.forString("preserve"));
setXWPFRunStyle(run, "宋体", 8);
fldChar = run.getCTR().addNewFldChar();
fldChar.setFldCharType(STFldCharType.Enum.forString("end"));
run = paragraph.createRun();
run.setText("页/共");
setXWPFRunStyle(run, "宋体", 8);
run = paragraph.createRun();
fldChar = run.getCTR().addNewFldChar();
fldChar.setFldCharType(STFldCharType.Enum.forString("begin"));
run = paragraph.createRun();
ctText = run.getCTR().addNewInstrText();
ctText.setStringValue("NUMPAGES \\* MERGEFORMAT ");
ctText.setSpace(SpaceAttribute.Space.Enum.forString("preserve"));
setXWPFRunStyle(run, "宋体", 8);
fldChar = run.getCTR().addNewFldChar();
fldChar.setFldCharType(STFldCharType.Enum.forString("end"));
run = paragraph.createRun();
run.setText("页");
setXWPFRunStyle(run, "宋体", 8);
titleParagraphXMBH.setAlignment(ParagraphAlignment.LEFT);
XWPFRun titleParagraphXMBHRun = titleParagraphXMBH.createRun();
titleParagraphXMBHRun.setText("项目编号____________ 密级__________");
titleParagraphXMBHRun.setFontFamily("宋体");
titleParagraphXMBHRun.setColor("000000");
titleParagraphXMBHRun.setFontSize(14);
for (int i = 0; i < 4; i++) {
titleParagraphXMBHRun.addCarriageReturn();
}
XWPFParagraph titleParagraph = document.createParagraph();
titleParagraph.setAlignment(ParagraphAlignment.CENTER);
XWPFRun titleParagraphRun = titleParagraph.createRun();
titleParagraphRun.setText("验 证 报 告");
titleParagraphRun.setBold(false);
titleParagraphRun.setFontFamily("黑体");
titleParagraphRun.setColor("000000");
titleParagraphRun.setFontSize(22);
XWPFParagraph titleParagraphKG = document.createParagraph();
titleParagraphKG.setAlignment(ParagraphAlignment.LEFT);
XWPFRun titleParagraphKGRun = titleParagraphKG.createRun();
titleParagraphKGRun.setText("");
titleParagraphKGRun.setFontFamily("宋体");
titleParagraphKGRun.setColor("000000");
titleParagraphKGRun.setFontSize(14);
for (int i = 0; i < 3; i++) {
titleParagraphKGRun.addCarriageReturn();
}
XWPFParagraph firstParagraph = document.createParagraph();
firstParagraph.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun = firstParagraph.createRun();
firstParagraphRun.setText("项目名称:");
firstParagraphRun.setColor("000000");
firstParagraphRun.setFontSize(16);
firstParagraphRun.setFontFamily("宋体");
XWPFRun firstParagraphRun1 = firstParagraph.createRun();
firstParagraphRun1.setText(project.getName());
firstParagraphRun1.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun1.setColor("000000");
firstParagraphRun1.setFontSize(16);
firstParagraphRun1.setFontFamily("宋体");
XWPFParagraph firstParagraph2 = document.createParagraph();
firstParagraph2.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun21 = firstParagraph2.createRun();
firstParagraphRun21.setText("报告版本:");
firstParagraphRun21.setColor("000000");
firstParagraphRun21.setFontSize(16);
firstParagraphRun21.setFontFamily("宋体");
XWPFRun firstParagraphRun22 = firstParagraph2.createRun();
firstParagraphRun22.setText("第一版本");
firstParagraphRun22.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun22.setColor("000000");
firstParagraphRun22.setFontSize(16);
firstParagraphRun22.setFontFamily("宋体");
XWPFParagraph firstParagraph3 = document.createParagraph();
firstParagraph3.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun31 = firstParagraph3.createRun();
firstParagraphRun31.setText("负责人:");
firstParagraphRun31.setColor("000000");
firstParagraphRun31.setFontSize(16);
firstParagraphRun31.setFontFamily("宋体");
XWPFRun firstParagraphRun32 = firstParagraph3.createRun();
Integer creatorId = project.getCreatorId();
User user = userService.selectByPrimaryKey(creatorId);
firstParagraphRun32.setText(user.getName());
firstParagraphRun32.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun32.setColor("000000");
firstParagraphRun32.setFontSize(16);
firstParagraphRun32.setFontFamily("宋体");
XWPFParagraph firstParagraph4 = document.createParagraph();
firstParagraph4.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun41 = firstParagraph4.createRun();
firstParagraphRun41.setText("编制:");
firstParagraphRun41.setColor("000000");
firstParagraphRun41.setFontSize(16);
firstParagraphRun41.setFontFamily("宋体");
XWPFRun firstParagraphRun42 = firstParagraph4.createRun();
firstParagraphRun42.setText("啦啦啦");
firstParagraphRun42.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun42.setColor("000000");
firstParagraphRun42.setFontSize(16);
firstParagraphRun42.setFontFamily("宋体");
XWPFParagraph firstParagraph5 = document.createParagraph();
firstParagraph5.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun51 = firstParagraph5.createRun();
firstParagraphRun51.setText("校对:");
firstParagraphRun51.setColor("000000");
firstParagraphRun51.setFontSize(16);
firstParagraphRun51.setFontFamily("宋体");
XWPFRun firstParagraphRun52 = firstParagraph5.createRun();
firstParagraphRun52.setText("聚聚聚");
firstParagraphRun52.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun52.setColor("000000");
firstParagraphRun52.setFontSize(16);
firstParagraphRun52.setFontFamily("宋体");
XWPFParagraph firstParagraph6 = document.createParagraph();
firstParagraph6.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun61 = firstParagraph6.createRun();
firstParagraphRun61.setText("审查:");
firstParagraphRun61.setColor("000000");
firstParagraphRun61.setFontSize(16);
firstParagraphRun61.setFontFamily("宋体");
XWPFRun firstParagraphRun62 = firstParagraph6.createRun();
firstParagraphRun62.setText("与玉玉");
firstParagraphRun62.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun62.setColor("000000");
firstParagraphRun62.setFontSize(16);
firstParagraphRun62.setFontFamily("宋体");
XWPFParagraph firstParagraph7 = document.createParagraph();
firstParagraph7.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun71 = firstParagraph7.createRun();
firstParagraphRun71.setText("会签:");
firstParagraphRun71.setColor("000000");
firstParagraphRun71.setFontSize(16);
firstParagraphRun71.setFontFamily("宋体");
XWPFRun firstParagraphRun72 = firstParagraph7.createRun();
firstParagraphRun72.setText("图图图");
firstParagraphRun72.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun72.setColor("000000");
firstParagraphRun72.setFontSize(16);
firstParagraphRun72.setFontFamily("宋体");
XWPFParagraph firstParagraph8 = document.createParagraph();
firstParagraph8.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun81 = firstParagraph8.createRun();
firstParagraphRun81.setText("批准:");
firstParagraphRun81.setColor("000000");
firstParagraphRun81.setFontSize(16);
firstParagraphRun81.setFontFamily("宋体");
XWPFRun firstParagraphRun82 = firstParagraph8.createRun();
firstParagraphRun82.setText("嘟嘟嘟");
firstParagraphRun82.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun82.setColor("000000");
firstParagraphRun82.setFontSize(16);
firstParagraphRun82.setFontFamily("宋体");
XWPFParagraph firstParagraph9 = document.createParagraph();
firstParagraph9.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun91 = firstParagraph9.createRun();
firstParagraphRun91.setText("完成单位:");
firstParagraphRun91.setColor("000000");
firstParagraphRun91.setFontSize(16);
firstParagraphRun91.setFontFamily("宋体");
XWPFRun firstParagraphRun92 = firstParagraph9.createRun();
firstParagraphRun92.setText("我我欧");
firstParagraphRun92.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun92.setColor("000000");
firstParagraphRun92.setFontSize(16);
firstParagraphRun92.setFontFamily("宋体");
XWPFParagraph firstParagraph10 = document.createParagraph();
firstParagraph10.setAlignment(ParagraphAlignment.CENTER);
XWPFRun firstParagraphRun101 = firstParagraph10.createRun();
firstParagraphRun101.setText("完成日期:");
firstParagraphRun101.setColor("000000");
firstParagraphRun101.setFontSize(16);
firstParagraphRun101.setFontFamily("宋体");
XWPFRun firstParagraphRun102 = firstParagraph10.createRun();
firstParagraphRun102.setText("服服服");
firstParagraphRun102.setUnderline(UnderlinePatterns.SINGLE);
firstParagraphRun102.setColor("000000");
firstParagraphRun102.setFontSize(16);
firstParagraphRun102.setFontFamily("宋体");
XWPFParagraph page0 = document.createParagraph();
page0.setPageBreak(true);
XWPFParagraph secondParagraph = document.createParagraph();
secondParagraph.setAlignment(ParagraphAlignment.CENTER);
XWPFRun secondParagraphRun = secondParagraph.createRun();
secondParagraphRun.setText("版本变更情况");
secondParagraphRun.setColor("000000");
secondParagraphRun.setFontSize(22);
secondParagraphRun.setFontFamily("黑体");
XWPFTable tableBanBen = document.createTable();
tableBanBen.setCellMargins(13, 5, 353, 5);
CTTblWidth tableBanBenWidth = tableBanBen.getCTTbl().addNewTblPr().addNewTblW();
tableBanBenWidth.setType(STTblWidth.DXA);
tableBanBenWidth.setW(BigInteger.valueOf(9972));
String[] titleBanBen = new String[]{"序号", "版本号", "版本问题", "变更内容", "描述", "审核人"};
for (int i = 0; i < 12; i++) {
if (i == 0) {
XWPFTableRow tableBanBenRowOne = tableBanBen.getRow(i);
XWPFTableCell xwpfTableCell0 = tableBanBenRowOne.getCell(0);
XWPFParagraph xwpfParagraph0 = xwpfTableCell0.addParagraph();
xwpfParagraph0.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph0.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run0 = xwpfParagraph0.createRun();
run0.setText(titleBanBen[0]);
run0.setFontSize(12);
run0.setBold(true);
for (int j = 1; j < 6; j++) {
XWPFTableCell xwpfTableCell1 = tableBanBenRowOne.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(titleBanBen[j]);
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
}
} else {
XWPFTableRow tableBanBenRowOne = tableBanBen.createRow();
for (int j = 0; j < 6; j++) {
XWPFTableCell xwpfTableCell1 = tableBanBenRowOne.getCell(j);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText("");
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
}
XWPFParagraph page1 = document.createParagraph();
page1.setPageBreak(true);
XWPFParagraph firstTitleParagraph = document.createParagraph();
XWPFRun firstTitleParagraphRun = firstTitleParagraph.createRun();
firstTitleParagraphRun.setText("摘 要");
firstTitleParagraph.setAlignment(ParagraphAlignment.CENTER);
firstTitleParagraphRun.setColor("000000");
firstTitleParagraphRun.setFontSize(22);
firstTitleParagraphRun.setFontFamily("华文中宋");
firstTitleParagraphRun.setBold(false);
XWPFParagraph firstTitleContentParagraph = document.createParagraph();
firstTitleContentParagraph.setIndentationFirstLine(2);
XWPFRun firstTitleContentParagraphRun = firstTitleContentParagraph.createRun();
firstTitleContentParagraphRun.setText(" cpu通过时间片循环执行线程任务,当线程的cpu时间片用完后会保存当前任务状态,方便下次获取到cpu时间片的时候能继续执行,当下次分配时间片后执行到该线程时,会重新加载该线程的任务状态,而这个从保存任务状态到重新加载的过程就叫上下文换。每次上下文切换也都要消耗cpu资源的,就好比看英文书一样,你边英文看边去看翻译,在你看翻译之前你必须要记住当前英文书看到了第几页,这样的切换是会影响读书的效率,同样上下文切换也会影响多线程的执行速度。");
firstTitleContentParagraphRun.setColor("000000");
firstTitleContentParagraphRun.setFontSize(12);
firstTitleContentParagraphRun.setFontFamily("宋体");
XWPFParagraph page2 = document.createParagraph();
page2.setPageBreak(true);
XWPFParagraph page3 = document.createParagraph();
page3.setPageBreak(true);
int biaoTi1 = 1;
XWPFParagraph secondTitleParagraph = document.createParagraph();
secondTitleParagraph.setStyle("标题 1");
XWPFRun secondTitleParagraphRun = secondTitleParagraph.createRun();
secondTitleParagraphRun.setText("1 项目名称");
secondTitleParagraphRun.setColor("000000");
secondTitleParagraphRun.setFontSize(18);
secondTitleParagraphRun.setFontFamily("黑体");
secondTitleParagraphRun.setBold(false);
XWPFParagraph secondTitleContentParagraph = document.createParagraph();
secondTitleContentParagraph.setIndentationFirstLine(2);
XWPFRun secondTitleContentParagraphRun = secondTitleContentParagraph.createRun();
secondTitleContentParagraphRun.setText(project.getName() + "工程");
secondTitleContentParagraphRun.setColor("000000");
secondTitleContentParagraphRun.setFontSize(12);
secondTitleContentParagraphRun.setFontFamily("宋体");
XWPFParagraph thirdTitleParagraph = document.createParagraph();
thirdTitleParagraph.setStyle("标题 1");
XWPFRun thirdTitleParagraphRun = thirdTitleParagraph.createRun();
thirdTitleParagraphRun.setText("2 项目目的");
thirdTitleParagraphRun.setColor("000000");
thirdTitleParagraphRun.setFontSize(18);
thirdTitleParagraphRun.setFontFamily("黑体");
thirdTitleParagraphRun.setBold(false);
XWPFParagraph thirdTitleContentParagraph = document.createParagraph();
thirdTitleContentParagraph.setIndentationFirstLine(2);
XWPFRun thirdTitleContentParagraphRun = thirdTitleContentParagraph.createRun();
thirdTitleContentParagraphRun.setText(project.getPurpose());
thirdTitleContentParagraphRun.setColor("000000");
thirdTitleContentParagraphRun.setFontSize(12);
thirdTitleContentParagraphRun.setFontFamily("宋体");
XWPFParagraph fourthTitleParagraph = document.createParagraph();
fourthTitleParagraph.setStyle("标题 1");
XWPFRun fourthTitleParagraphRun = fourthTitleParagraph.createRun();
fourthTitleParagraphRun.setText("3 活动日期");
fourthTitleParagraphRun.setColor("000000");
fourthTitleParagraphRun.setFontSize(18);
fourthTitleParagraphRun.setFontFamily("黑体");
fourthTitleParagraphRun.setBold(false);
XWPFParagraph fourthTitleContentParagraph = document.createParagraph();
fourthTitleContentParagraph.setIndentationFirstLine(4);
XWPFRun fourthTitleContentParagraphRun = fourthTitleContentParagraph.createRun();
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyy年MM月dd日");
Date createTime1 = project.getCreateTime();
Date actualFinishTime = project.getActualFinishTime();
String format = simpleDateFormat1.format(createTime1);
String format1 = simpleDateFormat1.format(actualFinishTime);
fourthTitleContentParagraphRun.setText(format + "-" + format1);
fourthTitleContentParagraphRun.setColor("000000");
fourthTitleContentParagraphRun.setFontSize(12);
fourthTitleContentParagraphRun.setFontFamily("宋体");
XWPFParagraph fourthTitleContentParagraphOne = document.createParagraph();
fourthTitleContentParagraphOne.setStyle("标题 1");
XWPFRun fourthTitleContentParagraphRunOne = fourthTitleContentParagraphOne.createRun();
fourthTitleContentParagraphRunOne.setText("4 人员分工");
fourthTitleContentParagraphRunOne.setColor("000000");
fourthTitleContentParagraphRunOne.setFontSize(18);
fourthTitleContentParagraphRunOne.setFontFamily("黑体");
XWPFTable tableUser = document.createTable();
tableUser.setCellMargins(3, 5, 253, 5);
CTTblWidth tableUserWidth = tableUser.getCTTbl().addNewTblPr().addNewTblW();
tableUserWidth.setType(STTblWidth.DXA);
tableUserWidth.setW(BigInteger.valueOf(9972));
String[] titleUser = new String[]{"姓名", "单位", "职务", "联系方式"};
for (int i = 0; i < 2; i++) {
if (i == 0) {
XWPFTableRow tableUserRowOne = tableUser.getRow(i);
XWPFTableCell xwpfTableCell0 = tableUserRowOne.getCell(0);
XWPFParagraph xwpfParagraph0 = xwpfTableCell0.addParagraph();
xwpfParagraph0.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph0.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run0 = xwpfParagraph0.createRun();
run0.setText(titleUser[0]);
run0.setFontSize(12);
run0.setBold(true);
run0.setFontFamily("宋体");
for (int j = 1; j < titleUser.length; j++) {
XWPFTableCell xwpfTableCell1 = tableUserRowOne.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(titleUser[j]);
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
}
} else {
String[] titleUserInfo = new String[]{user.getName(), user.getPassword(), user.getRole(), user.getEquipment()};
XWPFTableRow tableUserRowOne = tableUser.createRow();
for (int j = 0; j < titleUser.length; j++) {
XWPFTableCell xwpfTableCell1 = tableUserRowOne.getCell(j);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(titleUserInfo[j]);
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
}
XWPFParagraph fifthTitleParagraph = document.createParagraph();
fifthTitleParagraph.setStyle("标题 1");
XWPFRun fifthTitleParagraphRun = fifthTitleParagraph.createRun();
fifthTitleParagraphRun.setText("5 模型描述");
fifthTitleParagraphRun.setColor("000000");
fifthTitleParagraphRun.setFontSize(18);
fifthTitleParagraphRun.setFontFamily("黑体");
fifthTitleParagraphRun.setBold(false);
String t = " ";
Model model = modelService.selectByPrimaryKey(modelId);
Integer levelId = model.getLevelId();
String levelName = securityLevelService.selectByPrimaryKey(levelId).getName();
Integer equipmentTypeId = model.getEquipmentTypeId();
EquipmentType equipmentType = equipmentTypeService.selectByPrimaryKey(equipmentTypeId);
String equipmentTypeName = equipmentType.getName();
Integer categoryId = equipmentType.getCategoryId();
String equipmentCategoryName = equipmentCategoryService.selectByPrimaryKey(categoryId).getName();
String[] modelInfo = new String[]{
"模型名称:" + model.getName(),
"保密等级:" + levelName,
"模型编号:" + model.getId(),
"模型版本:" + model.getVersion(),
"装备型号:" + equipmentTypeName,
"装备类型:" + equipmentCategoryName,
"模型备注:" + model.getDescription()
};
for (int i = 0; i < modelInfo.length; i++) {
XWPFParagraph fifthTitleContentParagraph = document.createParagraph();
fifthTitleContentParagraph.setIndentationFirstLine(2);
XWPFRun fifthTitleContentParagraphRun = fifthTitleContentParagraph.createRun();
fifthTitleContentParagraphRun.setText(t + modelInfo[i]);
fifthTitleContentParagraphRun.setColor("000000");
fifthTitleContentParagraphRun.setFontSize(12);
fifthTitleContentParagraphRun.setFontFamily("宋体");
}
XWPFParagraph fifthTitleContentParagraphOne = document.createParagraph();
fifthTitleContentParagraphOne.setStyle("标题 1");
XWPFRun fifthTitleContentParagraphRunOne = fifthTitleContentParagraphOne.createRun();
fifthTitleContentParagraphRunOne.setText("6 指标体系");
fifthTitleContentParagraphRunOne.setColor("000000");
fifthTitleContentParagraphRunOne.setFontSize(18);
fifthTitleContentParagraphRunOne.setFontFamily("黑体");
Integer indexSystemId = project.getIndexSystemId();
Index index = indexService.selectByIndexSystemId(indexSystemId);
List<Index> indexList = Lists.newArrayList();
List<Index> indexList11 = Lists.newArrayList();
Index index11 = indexService.selectByIndexSystemId(indexSystemId);
Integer id11 = index11.getId();
List<Index> indexList111 = indexService.selectSunIndexById(id11);
getIndexChildren1(indexList111, indexList11);
indexList11.add(index11);
int a = 0;
Integer id2 = index.getId();
List<Index> indexList1 = indexService.selectSunIndexById(id2);
getIndexChildren(indexList1, indexList, a);
index.setId(0);
indexList.add(index);
XWPFTable tableStatisticsResult = document.createTable();
tableStatisticsResult.setCellMargins(3, 5, 253, 5);
CTTblWidth tableStatisticsResultWidth = tableStatisticsResult.getCTTbl().addNewTblPr().addNewTblW();
tableStatisticsResultWidth.setType(STTblWidth.DXA);
tableStatisticsResultWidth.setW(BigInteger.valueOf(9932));
String[] indexResult = new String[]{"指标名称", "层级深度", "上下限", "权重"};
for (int i = 0; i < indexList.size() + 1; i++) {
if (i == 0) {
XWPFTableRow tableIndexRowOne0 = tableStatisticsResult.getRow(0);
XWPFTableCell xwpfTableCell10 = tableIndexRowOne0.getCell(0);
XWPFParagraph xwpfParagraph10 = xwpfTableCell10.addParagraph();
xwpfParagraph10.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph10.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph10.createRun();
run1.setText(indexResult[0]);
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
for (int j = 1; j < indexResult.length; j++) {
XWPFTableCell xwpfTableCell11 = tableIndexRowOne0.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell11.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run11 = xwpfParagraph1.createRun();
run11.setText(indexResult[j]);
run11.setFontSize(12);
run11.setBold(true);
run11.setFontFamily("宋体");
}
} else {
String[] titleIndexInfo = new String[]{
indexList.get(indexList.size() - i).getName() + "指标体系",
indexList.get(indexList.size() - i).getId().toString(),
indexList.get(indexList.size() - i).getUpperBound() + "-" + indexList.get(indexList.size() - i).getLowerBound(),
indexList.get(indexList.size() - i).getWeight()
};
XWPFTableRow tableIndexRowOne = tableStatisticsResult.createRow();
for (int j = 0; j < indexResult.length; j++) {
XWPFTableCell xwpfTableCell1 = tableIndexRowOne.getCell(j);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(titleIndexInfo[j]);
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
}
XWPFParagraph sixthTitleParagraph = document.createParagraph();
sixthTitleParagraph.setStyle("标题 1");
XWPFRun sixthTitleParagraphRun = sixthTitleParagraph.createRun();
sixthTitleParagraphRun.setText("7 任务列表");
sixthTitleParagraphRun.setColor("000000");
sixthTitleParagraphRun.setFontSize(18);
sixthTitleParagraphRun.setFontFamily("黑体");
sixthTitleParagraphRun.setBold(false);
List<Index> indexList12 = Lists.newArrayList();
for (Index index1 : indexList11) {
Integer id1 = index1.getId();
List<Index> indexList2 = indexService.selectSunIndexById(id1);
if (indexList2.size() == 0) {
indexList12.add(index1);
}
}
int biaoTI2 = 1;
for (Index index111 : indexList12) {
String name1 = index111.getName();
XWPFParagraph sixthTitleContentParagraph = document.createParagraph();
sixthTitleContentParagraph.setStyle("标题 2");
sixthTitleContentParagraph.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun = sixthTitleContentParagraph.createRun();
sixthTitleContentParagraphRun.setText("7." + biaoTI2 + " 系统设计" + name1 + "指标");
sixthTitleContentParagraphRun.setColor("000000");
sixthTitleContentParagraphRun.setFontSize(16);
sixthTitleContentParagraphRun.setFontFamily("黑体");
List<ExperimentDesign> experimentDesignList = Lists.newArrayList();
Integer id1 = index111.getId();
IndexEvaluationMission indexEvaluationMission = indexEvaluationMissionMapper.selectByIndexId(id1);
if (indexEvaluationMission != null) {
Integer id3 = indexEvaluationMission.getId();
List<ExperimentDesign> experimentDesigns = experimentDesignMapper.selectExperimentDesignByMissionId(id3);
experimentDesignList.addAll(experimentDesigns);
}
if (experimentDesignList.size() > 0) {
for (ExperimentDesign experimentDesign : experimentDesignList) {
XWPFTable experimentDesignResult = document.createTable();
experimentDesignResult.setCellMargins(3, 5, 153, 5);
CTTblWidth experimentDesignResultWidth = experimentDesignResult.getCTTbl().addNewTblPr().addNewTblW();
experimentDesignResultWidth.setType(STTblWidth.DXA);
experimentDesignResultWidth.setW(BigInteger.valueOf(9932));
String samplespacePath = experimentDesign.getSamplespacePath();
DesignSchemeSpaceProcesser designSchemeSpaceProcesser = new DesignSchemeSpaceProcesser();
designSchemeSpaceProcesser.loadDesignSchemeSpaceFile(samplespacePath);
String designSchemeSpaceJson = designSchemeSpaceProcesser.getDesignSchemeSpaceJson();
JSONObject jsonObject = JSON.parseObject(designSchemeSpaceJson);
String sampleSpaceItems1 = jsonObject.getString("SampleSpaceItems");
JSONObject jsonObject1 = JSON.parseObject(sampleSpaceItems1);
JSONArray sampleSpaceItem = jsonObject1.getJSONArray("SampleSpaceItem");
String s = sampleSpaceItem.get(0).toString();
JSONObject jsonObject2 = JSON.parseObject(s);
String entitiesSampleSpace = jsonObject2.getString("EntitiesSampleSpace");
JSONObject jsonObject3 = JSON.parseObject(entitiesSampleSpace.toString());
JSONArray jsonObject31 = jsonObject3.getJSONArray("EntityFactor");
List<String> nameList = Lists.newArrayList();
nameList.add("序号");
for (Object o : jsonObject31) {
JSONObject jsonObject21 = JSON.parseObject(o.toString());
String name = jsonObject21.getString("name");
nameList.add(name);
}
for (int i = 0; i < sampleSpaceItem.size() + 1; i++) {
if (i == 0) {
XWPFTableRow tableExperimentDesignRowOne0 = experimentDesignResult.getRow(0);
tableExperimentDesignRowOne0.setHeight(150);
XWPFTableCell xwpfTableCell10 = tableExperimentDesignRowOne0.getCell(0);
XWPFParagraph xwpfParagraph10 = xwpfTableCell10.addParagraph();
xwpfParagraph10.setAlignment(ParagraphAlignment.CENTER);
XWPFRun run1 = xwpfParagraph10.createRun();
run1.setText(nameList.get(0));
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
for (int j = 1; j < nameList.size(); j++) {
XWPFTableCell xwpfTableCell11 = tableExperimentDesignRowOne0.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell11.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
XWPFRun run11 = xwpfParagraph1.createRun();
run11.setText(nameList.get(j));
run11.setFontSize(12);
run11.setBold(true);
run11.setFontFamily("宋体");
}
} else {
List<String> valueList = Lists.newArrayList();
JSONObject jsonObjectT = JSON.parseObject(sampleSpaceItem.get(i - 1).toString());
String id111 = jsonObjectT.getString("ID");
valueList.add(id111);
JSONObject entitiesSampleSpace1 = jsonObjectT.getJSONObject("EntitiesSampleSpace");
JSONArray jsonObjectEntityFactor31 = entitiesSampleSpace1.getJSONArray("EntityFactor");
for (Object o : jsonObjectEntityFactor31) {
JSONObject jsonObject21 = JSON.parseObject(o.toString());
String value = jsonObject21.getString("value");
valueList.add(value);
}
XWPFTableRow tableExperimentDesignRowOne = experimentDesignResult.createRow();
tableExperimentDesignRowOne.setHeight(150);
for (int j = 0; j < nameList.size(); j++) {
XWPFTableCell xwpfTableCell1 = tableExperimentDesignRowOne.getCell(j);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(valueList.get(j));
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
}
}
} else {
XWPFParagraph sixthTitleContentParagraphOne2 = document.createParagraph();
XWPFRun sixthTitleContentParagraphRunOne2 = sixthTitleContentParagraphOne2.createRun();
sixthTitleContentParagraphRunOne2.setText("无");
sixthTitleContentParagraphRunOne2.setColor("000000");
sixthTitleContentParagraphRunOne2.setFontSize(12);
sixthTitleContentParagraphRunOne2.setFontFamily("宋体");
}
biaoTI2++;
}
XWPFParagraph sixthTitleContentParagraph2 = document.createParagraph();
sixthTitleContentParagraph2.setStyle("标题 1");
sixthTitleContentParagraph2.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun2 = sixthTitleContentParagraph2.createRun();
sixthTitleContentParagraphRun2.setText("8 结果");
sixthTitleContentParagraphRun2.setColor("000000");
sixthTitleContentParagraphRun2.setFontSize(18);
sixthTitleContentParagraphRun2.setFontFamily("黑体");
String[] titleSimulation = new String[]{"指标名称", "处理分析方法", "结果"};
XWPFTable tableStatisticsResult1 = document.createTable();
tableStatisticsResult1.setCellMargins(3, 5, 153, 5);
CTTblWidth tableStatisticsResultWidth1 = tableStatisticsResult1.getCTTbl().addNewTblPr().addNewTblW();
tableStatisticsResultWidth1.setType(STTblWidth.DXA);
tableStatisticsResultWidth1.setW(BigInteger.valueOf(9032));
int heBing = 1;
for (int i = 0; i < indexList12.size() + 1; i++) {
if (i == 0) {
XWPFTableRow tableExperimentDesignRowOne0 = tableStatisticsResult1.getRow(0);
tableExperimentDesignRowOne0.setHeight(150);
XWPFTableCell xwpfTableCell10 = tableExperimentDesignRowOne0.getCell(0);
XWPFParagraph xwpfParagraph10 = xwpfTableCell10.addParagraph();
xwpfParagraph10.setAlignment(ParagraphAlignment.CENTER);
XWPFRun run1 = xwpfParagraph10.createRun();
run1.setText(titleSimulation[0]);
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
for (int j = 1; j < titleSimulation.length; j++) {
XWPFTableCell xwpfTableCell11 = tableExperimentDesignRowOne0.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell11.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
XWPFRun run11 = xwpfParagraph1.createRun();
run11.setText(titleSimulation[j]);
run11.setFontSize(12);
run11.setBold(true);
run11.setFontFamily("宋体");
}
} else {
Index index1 = indexList12.get(i - 1);
Integer id1 = index1.getId();
List<LogEvaluation> logEvaluationList = logEvaluationService.selectByIndexIdAndMethodId(id1);
int size = logEvaluationList.size();
for (int j = 0; j < size; j++) {
LogEvaluation logEvaluation = logEvaluationList.get(j);
Integer methodId = logEvaluation.getMethodId();
Method method = methodService.selectByPrimaryKey(methodId);
String[] logEvaluationListInfo = new String[]{
index1.getName() + "指标",
method.getName(),
logEvaluation.getContent()
};
XWPFTableRow tableExperimentDesignRowOne = tableStatisticsResult1.createRow();
tableExperimentDesignRowOne.setHeight(150);
for (int k = 0; k < logEvaluationListInfo.length; k++) {
XWPFTableCell xwpfTableCell1 = tableExperimentDesignRowOne.getCell(k);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(logEvaluationListInfo[k]);
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
int q = heBing;
heBing = heBing + size - 1;
mergeCellsVertically(tableStatisticsResult1, 0, q, heBing);
heBing++;
}
}
XWPFParagraph sixthTitleContentParagraph3 = document.createParagraph();
sixthTitleContentParagraph3.setStyle("标题 1");
sixthTitleContentParagraph3.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun3 = sixthTitleContentParagraph3.createRun();
sixthTitleContentParagraphRun3.setText("9 建议");
sixthTitleContentParagraphRun3.setColor("000000");
sixthTitleContentParagraphRun3.setFontSize(18);
sixthTitleContentParagraphRun3.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraphOne3 = document.createParagraph();
XWPFRun sixthTitleContentParagraphRunOne3 = sixthTitleContentParagraphOne3.createRun();
sixthTitleContentParagraphRunOne3.setText("土豆泥辅导书");
sixthTitleContentParagraphRunOne3.setColor("000000");
sixthTitleContentParagraphRunOne3.setFontSize(12);
sixthTitleContentParagraphRunOne3.setFontFamily("宋体");
XWPFParagraph sixthTitleContentParagraph4 = document.createParagraph();
sixthTitleContentParagraph4.setStyle("标题 1");
sixthTitleContentParagraph4.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun4 = sixthTitleContentParagraph4.createRun();
sixthTitleContentParagraphRun4.setText("10 任务详情");
sixthTitleContentParagraphRun4.setColor("000000");
sixthTitleContentParagraphRun4.setFontSize(18);
sixthTitleContentParagraphRun4.setFontFamily("黑体");
int biaoTi3 = 1;
for (Index index111 : indexList12) {
String name = index111.getName();
XWPFParagraph sixthTitleContentParagraph5 = document.createParagraph();
sixthTitleContentParagraph5.setStyle("标题 2");
sixthTitleContentParagraph5.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun5 = sixthTitleContentParagraph5.createRun();
sixthTitleContentParagraphRun5.setText("11." + biaoTi3 + " 系统设计" + name + "指标");
sixthTitleContentParagraphRun5.setColor("000000");
sixthTitleContentParagraphRun5.setFontSize(16);
sixthTitleContentParagraphRun5.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraph51 = document.createParagraph();
sixthTitleContentParagraph51.setStyle("标题 3");
sixthTitleContentParagraph51.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun51 = sixthTitleContentParagraph51.createRun();
sixthTitleContentParagraphRun51.setText("11." + biaoTi3 + ".1 方法");
sixthTitleContentParagraphRun51.setColor("000000");
sixthTitleContentParagraphRun51.setFontSize(14);
sixthTitleContentParagraphRun51.setFontFamily("黑体");
Integer id1 = index111.getId();
List<LogEvaluation> logEvaluationList = logEvaluationService.selectByIndexIdAndMethodId(id1);
Set<Integer> methodIdList = Sets.newHashSet();
Set<Integer> dataListSet = Sets.newHashSet();
if (logEvaluationList.size() > 0) {
for (LogEvaluation logEvaluation : logEvaluationList) {
Integer methodId = logEvaluation.getMethodId();
Integer dataId = logEvaluation.getDataId();
dataListSet.add(dataId);
methodIdList.add(methodId);
}
List<Integer> dataList = Lists.newArrayList();
for (Integer integer : dataListSet) {
dataList.add(integer);
}
String methodNameList = "";
for (Integer integer : methodIdList) {
Method method = methodService.selectByPrimaryKey(integer);
String name1 = method.getName();
methodNameList = methodNameList + name1 + "、";
}
methodNameList = methodNameList.substring(0, methodNameList.length() - 1);
XWPFParagraph sixthTitleContentParagraph511 = document.createParagraph();
sixthTitleContentParagraph511.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun511 = sixthTitleContentParagraph511.createRun();
sixthTitleContentParagraphRun511.setText(methodNameList);
sixthTitleContentParagraphRun511.setColor("000000");
sixthTitleContentParagraphRun511.setFontSize(12);
sixthTitleContentParagraphRun511.setFontFamily("宋体");
XWPFParagraph sixthTitleContentParagraph52 = document.createParagraph();
sixthTitleContentParagraph52.setStyle("标题 3");
sixthTitleContentParagraph52.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun52 = sixthTitleContentParagraph52.createRun();
sixthTitleContentParagraphRun52.setText("11." + biaoTi3 + ".2 使用的验证数据");
sixthTitleContentParagraphRun52.setColor("000000");
sixthTitleContentParagraphRun52.setFontSize(14);
sixthTitleContentParagraphRun52.setFontFamily("黑体");
XWPFTable tableStatisticsResult52 = document.createTable();
tableStatisticsResult52.setCellMargins(3, 5, 253, 5);
CTTblWidth tableStatisticsResultWidth52 = tableStatisticsResult52.getCTTbl().addNewTblPr().addNewTblW();
tableStatisticsResultWidth52.setType(STTblWidth.DXA);
tableStatisticsResultWidth52.setW(BigInteger.valueOf(9032));
String[] dataResult = new String[]{"序号", "数据文件名", "来源"};
for (int i = 0; i < dataList.size() + 1; i++) {
if (i == 0) {
XWPFTableRow tableIndexRowOne0 = tableStatisticsResult52.getRow(0);
XWPFTableCell xwpfTableCell10 = tableIndexRowOne0.getCell(0);
XWPFParagraph xwpfParagraph10 = xwpfTableCell10.addParagraph();
xwpfParagraph10.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph10.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph10.createRun();
run1.setText(dataResult[0]);
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
for (int j = 1; j < dataResult.length; j++) {
XWPFTableCell xwpfTableCell11 = tableIndexRowOne0.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell11.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run11 = xwpfParagraph1.createRun();
run11.setText(dataResult[j]);
run11.setFontSize(12);
run11.setBold(true);
run11.setFontFamily("宋体");
}
} else {
Integer integer = dataList.get(i - 1);
Data data = dataService.selectByPrimaryKey(integer);
String[] titleDataInfo = new String[]{
i + "",
data.getFileName(),
data.getSource()
};
XWPFTableRow tableIndexRowOne = tableStatisticsResult52.createRow();
for (int j = 0; j < titleDataInfo.length; j++) {
XWPFTableCell xwpfTableCell1 = tableIndexRowOne.getCell(j);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(titleDataInfo[j]);
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
}
} else {
XWPFParagraph sixthTitleContentParagraph511 = document.createParagraph();
sixthTitleContentParagraph511.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun511 = sixthTitleContentParagraph511.createRun();
sixthTitleContentParagraphRun511.setText("无");
sixthTitleContentParagraphRun511.setColor("000000");
sixthTitleContentParagraphRun511.setFontSize(12);
sixthTitleContentParagraphRun511.setFontFamily("宋体");
}
}
XWPFParagraph sixthTitleContentParagraph6 = document.createParagraph();
sixthTitleContentParagraph6.setStyle("标题 1");
sixthTitleContentParagraph6.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun6 = sixthTitleContentParagraph6.createRun();
sixthTitleContentParagraphRun6.setText("12 结论和建议");
sixthTitleContentParagraphRun6.setColor("000000");
sixthTitleContentParagraphRun6.setFontSize(18);
sixthTitleContentParagraphRun6.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraph61 = document.createParagraph();
sixthTitleContentParagraph61.setStyle("标题 2");
sixthTitleContentParagraph61.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun61 = sixthTitleContentParagraph61.createRun();
sixthTitleContentParagraphRun61.setText("12.1 结论");
sixthTitleContentParagraphRun61.setColor("000000");
sixthTitleContentParagraphRun61.setFontSize(16);
sixthTitleContentParagraphRun61.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraph62 = document.createParagraph();
sixthTitleContentParagraph62.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun62 = sixthTitleContentParagraph62.createRun();
sixthTitleContentParagraphRun62.setText("等级:" + "XXX");
sixthTitleContentParagraphRun62.setColor("000000");
sixthTitleContentParagraphRun62.setFontSize(12);
sixthTitleContentParagraphRun62.setFontFamily("宋体");
XWPFParagraph sixthTitleContentParagraph63 = document.createParagraph();
sixthTitleContentParagraph63.setStyle("标题 2");
sixthTitleContentParagraph63.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun63 = sixthTitleContentParagraph63.createRun();
sixthTitleContentParagraphRun63.setText("12.2 层次分析法");
sixthTitleContentParagraphRun63.setColor("000000");
sixthTitleContentParagraphRun63.setFontSize(16);
sixthTitleContentParagraphRun63.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraph64 = document.createParagraph();
sixthTitleContentParagraph64.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun64 = sixthTitleContentParagraph64.createRun();
sixthTitleContentParagraphRun64.setText("层次分析法结果具体如下:");
sixthTitleContentParagraphRun64.setColor("000000");
sixthTitleContentParagraphRun64.setFontSize(12);
sixthTitleContentParagraphRun64.setFontFamily("宋体");
XWPFTable tableStatisticsResult62 = document.createTable();
tableStatisticsResult62.setCellMargins(3, 5, 3, 5);
CTTblWidth tableStatisticsResultWidth62 = tableStatisticsResult62.getCTTbl().addNewTblPr().addNewTblW();
tableStatisticsResultWidth62.setType(STTblWidth.DXA);
tableStatisticsResultWidth62.setW(BigInteger.valueOf(9032));
String[] indexResult62 = new String[]{"指标名称", "层级深度", "权重", "评估结果"};
for (int i = 0; i < indexList.size() + 1; i++) {
if (i == 0) {
XWPFTableRow tableIndexRowOne0 = tableStatisticsResult62.getRow(0);
XWPFTableCell xwpfTableCell10 = tableIndexRowOne0.getCell(0);
XWPFParagraph xwpfParagraph10 = xwpfTableCell10.addParagraph();
xwpfParagraph10.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph10.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph10.createRun();
run1.setText(indexResult62[0]);
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
for (int j = 1; j < indexResult62.length; j++) {
XWPFTableCell xwpfTableCell11 = tableIndexRowOne0.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell11.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run11 = xwpfParagraph1.createRun();
run11.setText(indexResult62[j]);
run11.setFontSize(12);
run11.setBold(true);
run11.setFontFamily("宋体");
}
} else {
Index index1 = indexList.get(indexList.size() - i);
Index index2 = indexList11.get(indexList.size() - i);
Integer id3 = index2.getId();
String result = logEvaluationService.getIndexAssessmentResultId(id3);
String[] titleIndexInfo = new String[]{
index1.getName() + "指标体系",
index1.getId().toString(),
index1.getWeight(),
result
};
XWPFTableRow tableIndexRowOne = tableStatisticsResult62.createRow();
for (int j = 0; j < titleIndexInfo.length; j++) {
XWPFTableCell xwpfTableCell1 = tableIndexRowOne.getCell(j);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(titleIndexInfo[j]);
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
}
XWPFParagraph sixthTitleContentParagraph7 = document.createParagraph();
sixthTitleContentParagraph7.setStyle("标题 2");
sixthTitleContentParagraph7.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun7 = sixthTitleContentParagraph7.createRun();
sixthTitleContentParagraphRun7.setText("12.3 模糊评判法");
sixthTitleContentParagraphRun7.setColor("000000");
sixthTitleContentParagraphRun7.setFontSize(16);
sixthTitleContentParagraphRun7.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraph71 = document.createParagraph();
sixthTitleContentParagraph71.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun71 = sixthTitleContentParagraph71.createRun();
sixthTitleContentParagraphRun71.setText("模糊评判法结果具体如下:");
sixthTitleContentParagraphRun71.setColor("000000");
sixthTitleContentParagraphRun71.setFontSize(12);
sixthTitleContentParagraphRun71.setFontFamily("宋体");
XWPFTable tableStatisticsResult72 = document.createTable();
tableStatisticsResult72.setCellMargins(3, 5, 3, 5);
CTTblWidth tableStatisticsResultWidth72 = tableStatisticsResult72.getCTTbl().addNewTblPr().addNewTblW();
tableStatisticsResultWidth72.setType(STTblWidth.DXA);
tableStatisticsResultWidth72.setW(BigInteger.valueOf(9032));
String[] indexResult72 = new String[]{"工程名称", "评估结果"};
for (int i = 0; i < 2; i++) {
if (i == 0) {
XWPFTableRow tableIndexRowOne0 = tableStatisticsResult72.getRow(0);
XWPFTableCell xwpfTableCell10 = tableIndexRowOne0.getCell(0);
XWPFParagraph xwpfParagraph10 = xwpfTableCell10.addParagraph();
xwpfParagraph10.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph10.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph10.createRun();
run1.setText(indexResult72[0]);
run1.setFontSize(12);
run1.setBold(true);
run1.setFontFamily("宋体");
for (int j = 1; j < indexResult72.length; j++) {
XWPFTableCell xwpfTableCell11 = tableIndexRowOne0.addNewTableCell();
XWPFParagraph xwpfParagraph1 = xwpfTableCell11.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run11 = xwpfParagraph1.createRun();
run11.setText(indexResult72[j]);
run11.setFontSize(12);
run11.setBold(true);
run11.setFontFamily("宋体");
}
} else {
String name1 = project.getName();
String fceResult = project.getFceResult();
if (fceResult != null && fceResult != "") {
} else {
fceResult = "未进行模糊评判法";
}
String[] titleIndexInfo = new String[]{
name1,
fceResult
};
XWPFTableRow tableIndexRowOne = tableStatisticsResult72.createRow();
for (int j = 0; j < titleIndexInfo.length; j++) {
XWPFTableCell xwpfTableCell1 = tableIndexRowOne.getCell(j);
XWPFParagraph xwpfParagraph1 = xwpfTableCell1.addParagraph();
xwpfParagraph1.setAlignment(ParagraphAlignment.CENTER);
xwpfParagraph1.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun run1 = xwpfParagraph1.createRun();
run1.setText(titleIndexInfo[j]);
run1.setFontSize(12);
run1.setBold(false);
run1.setFontFamily("宋体");
}
}
}
XWPFParagraph sixthTitleContentParagraph73 = document.createParagraph();
sixthTitleContentParagraph73.setStyle("标题 2");
sixthTitleContentParagraph73.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun73 = sixthTitleContentParagraph73.createRun();
sixthTitleContentParagraphRun73.setText("12.4 综合评估建议");
sixthTitleContentParagraphRun73.setColor("000000");
sixthTitleContentParagraphRun73.setFontSize(16);
sixthTitleContentParagraphRun73.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraph8 = document.createParagraph();
sixthTitleContentParagraph8.setStyle("标题 1");
sixthTitleContentParagraph8.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun8 = sixthTitleContentParagraph8.createRun();
sixthTitleContentParagraphRun8.setText("13 风险分析及解决措施");
sixthTitleContentParagraphRun8.setColor("000000");
sixthTitleContentParagraphRun8.setFontSize(18);
sixthTitleContentParagraphRun8.setFontFamily("黑体");
XWPFParagraph sixthTitleContentParagraph9 = document.createParagraph();
sixthTitleContentParagraph9.setStyle("标题 1");
sixthTitleContentParagraph9.setIndentationFirstLine(4);
XWPFRun sixthTitleContentParagraphRun9 = sixthTitleContentParagraph9.createRun();
sixthTitleContentParagraphRun9.setText("14 后续工作");
sixthTitleContentParagraphRun9.setColor("000000");
sixthTitleContentParagraphRun9.setFontSize(18);
sixthTitleContentParagraphRun9.setFontFamily("黑体");
String fileName = "模板生成.docx";
String path = "C:\\Resources\\";
String uuid = UUID.randomUUID().toString().substring(6);
File folder = new File(path + uuid);
if (!folder.exists() && !folder.isDirectory()) {
folder.mkdirs();
}
String pathDoc = folder + "\\" + fileName;
File templateFile = new File(pathDoc);
FileOutputStream os = new FileOutputStream(templateFile);
document.write(os);
Document doc = new Document(pathDoc);
Paragraph parainserted = new Paragraph(doc);
TextRange tr = parainserted.appendText("目 录");
tr.getCharacterFormat().setBold(false);
tr.getCharacterFormat().setFontSize(14);
tr.getCharacterFormat().setTextColor(Color.BLACK);
doc.getSections().get(0).getParagraphs().insert(20, parainserted);
parainserted.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
TableOfContent toc1 = new TableOfContent(doc, "{\\o \"1-3\" \\h \\z \\u}");
doc.getSections().get(0).getParagraphs().get(19).appendTOC(1, 3);
doc.updateTableOfContents();
doc.saveToFile(pathDoc, FileFormat.Docx_2010);
if (isMSBrowser(request)) {
fileName = URLEncoder.encode(fileName, "UTF-8");
}
DownloadUtils.downLoadFile(response, fileName, templateFile);
}
private void setXWPFRunStyle(XWPFRun r1, String font, int fontSize) {
r1.setFontSize(fontSize);
CTRPr rpr = r1.getCTR().isSetRPr() ? r1.getCTR().getRPr() : r1.getCTR().addNewRPr();
CTFonts fonts = rpr.isSetRFonts() ? rpr.getRFonts() : rpr.addNewRFonts();
fonts.setAscii(font);
fonts.setEastAsia(font);
fonts.setHAnsi(font);
}
private List<Index> getIndexChildren1(List<Index> indexList, List<Index> list) {
for (Index index : indexList) {
Integer id = index.getId();
List<Index> selectSunIndexById = indexService.selectSunIndexById(id);
getIndexChildren1(selectSunIndexById, list);
list.add(index);
}
return list;
}
private List<Index> getIndexChildren(List<Index> indexList, List<Index> list, int a) {
a++;
for (Index index : indexList) {
Integer id = index.getId();
List<Index> selectSunIndexById = indexService.selectSunIndexById(id);
getIndexChildren(selectSunIndexById, list, a);
index.setId(a);
list.add(index);
}
return list;
}
private static void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
CTStyle ctStyle = CTStyle.Factory.newInstance();
ctStyle.setStyleId(strStyleId);
CTString styleName = CTString.Factory.newInstance();
styleName.setVal(strStyleId);
ctStyle.setName(styleName);
CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance();
indentNumber.setVal(BigInteger.valueOf(headingLevel));
ctStyle.setUiPriority(indentNumber);
CTOnOff onoffnull = CTOnOff.Factory.newInstance();
ctStyle.setUnhideWhenUsed(onoffnull);
ctStyle.setQFormat(onoffnull);
CTPPr ppr = CTPPr.Factory.newInstance();
ppr.setOutlineLvl(indentNumber);
ctStyle.setPPr(ppr);
XWPFStyle style = new XWPFStyle(ctStyle);
XWPFStyles styles = docxDocument.createStyles();
style.setType(STStyleType.PARAGRAPH);
styles.addStyle(style);
}
public boolean isMSBrowser(HttpServletRequest request) {
String[] IEBrowserSignals = {"MSIE", "Trident", "Edge"};
String userAgent = request.getHeader("User-Agent");
for (String signal : IEBrowserSignals) {
if (userAgent.contains(signal)) {
return true;
}
}
return false;
}
public void mergeCellsHorizontal(XWPFTable table, int row, int fromCell, int toCell) {
for (int cellIndex = fromCell; cellIndex <= toCell; cellIndex++) {
XWPFTableCell cell = table.getRow(row).getCell(cellIndex);
if (cellIndex == fromCell) {
cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);
} else {
cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
}
}
}
public void mergeCellsVertically(XWPFTable table, int col, int fromRow, int toRow) {
for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {
XWPFTableCell cell = table.getRow(rowIndex).getCell(col);
if (rowIndex == fromRow) {
cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART);
} else {
cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
}
}
}
}