|
@@ -1473,7 +1473,8 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
|
|
|
@Override
|
|
|
public R wordExportStandard(Map<String, Object> map, HttpServletResponse response) throws Exception {
|
|
|
- SysFileItemDo fileItemDo = sysFileItemService.getById("a2ccde8da9ec485f83650b75429f0e78");
|
|
|
+ // a2ccde8da9ec485f83650b75429f0e78
|
|
|
+ SysFileItemDo fileItemDo = sysFileItemService.getById("52f8f612f1ab43e58d9e3b46ceef6c2c");
|
|
|
final Document[] indexDoc = {WordHelpUtils.getDoc(fileItemDo.getFullpath())};
|
|
|
FormData formData = new FormData();
|
|
|
List<Map<String, Object>> mainDataList = new ArrayList<>();
|
|
@@ -1486,7 +1487,8 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
List<ZhcxCommissionCheckBaseInfoTreeDo> treeList = zhcxCommissionCheckBaseInfoTreeDao.listTreeData(map);
|
|
|
Document doc = null;
|
|
|
DocumentBuilder builder = null;
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("template/试车标准内容明细.docx");
|
|
|
+ //ClassPathResource classPathResource = new ClassPathResource("template/试车标准内容明细.docx");
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("template/检查内容明细模版.doc");
|
|
|
try {
|
|
|
doc = new Document(classPathResource.getInputStream());
|
|
|
builder = new DocumentBuilder(doc);
|
|
@@ -1705,6 +1707,65 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
Document cloneDocA = indexDoc[0].deepClone();
|
|
|
// 在副本上合并文档B
|
|
|
cloneDocA.appendDocument(doc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
|
|
|
+ /*int beforePageCount = cloneDocA.getPageCount();
|
|
|
+ //刷新目录
|
|
|
+ cloneDocA.updateFields();
|
|
|
+ // 获取第一个文档的总页数
|
|
|
+ int firstDocPageCount = cloneDocA.getPageCount() - beforePageCount + 2;
|
|
|
+ // 获取第二部分的第一节
|
|
|
+ Section sectionPart2 = cloneDocA.getSections().get(cloneDocA.getSections().getCount() - 1);
|
|
|
+ // 设置第二部分的页码起始值为第一部分的页数加 1
|
|
|
+ sectionPart2.getPageSetup().setRestartPageNumbering(true);
|
|
|
+ sectionPart2.getPageSetup().setPageStartingNumber(firstDocPageCount + 1);
|
|
|
+
|
|
|
+ // 获取文档的第一节
|
|
|
+ Section firstSection = cloneDocA.getSections().get(0);
|
|
|
+ // 获取第一页的页眉
|
|
|
+ HeaderFooter firstPageHeader = firstSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_FIRST);
|
|
|
+ // 获取第一页的页脚
|
|
|
+ HeaderFooter firstPageFooter = firstSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_FIRST);
|
|
|
+ // 如果第一页没有单独的页眉,则使用主页眉
|
|
|
+ if (firstPageHeader == null) {
|
|
|
+ firstPageHeader = firstSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);
|
|
|
+ firstPageFooter = firstSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY);
|
|
|
+ }
|
|
|
+ // 遍历文档的所有节(从第二个节开始)
|
|
|
+ for (int i = 1; i < cloneDocA.getSections().getCount(); i++) {
|
|
|
+ Section currentSection = cloneDocA.getSections().get(i);
|
|
|
+ // 获取当前节的主页眉
|
|
|
+ HeaderFooter currentHeader = currentSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);
|
|
|
+ // 获取当前节的页脚
|
|
|
+ HeaderFooter footer = currentSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY);
|
|
|
+ // 清除当前页眉的内容
|
|
|
+ if(currentHeader != null){
|
|
|
+ currentHeader.removeAllChildren();
|
|
|
+ }
|
|
|
+ if(footer != null){
|
|
|
+ footer.removeAllChildren();
|
|
|
+ }
|
|
|
+ // 将第一页页眉的内容克隆到当前页眉
|
|
|
+ for (Node node : firstPageHeader.getChildNodes(NodeType.ANY, true).toArray()) {
|
|
|
+ Node clonedNode = node.deepClone(true);
|
|
|
+ if (node.getNodeType() == NodeType.PARAGRAPH || node.getNodeType() == NodeType.TABLE) {
|
|
|
+ currentHeader.appendChild(clonedNode);
|
|
|
+ }
|
|
|
+ if (node.getNodeType() == NodeType.TABLE) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 复制第一页页脚的内容到当前页脚
|
|
|
+ for (Node node : firstPageFooter.getChildNodes(NodeType.ANY, true).toArray()) {
|
|
|
+ Node clonedNode = node.deepClone(true);
|
|
|
+ if (node.getNodeType() == NodeType.PARAGRAPH || node.getNodeType() == NodeType.TABLE) {
|
|
|
+ footer.appendChild(clonedNode);
|
|
|
+ }
|
|
|
+ if (node.getNodeType() == NodeType.TABLE) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //刷新目录
|
|
|
+ cloneDocA.updateFields();*/
|
|
|
//导出world
|
|
|
exportWord(cloneDocA, response);
|
|
|
}
|
|
@@ -2900,7 +2961,6 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
@Override
|
|
|
public R wordExportPrj2(Map<String, Object> map, HttpServletResponse response) throws Exception{
|
|
|
// 前端传来模板id
|
|
|
- //String fileId = "7a3213f88d7146e88f1508b61dcb3202";
|
|
|
String fileId = "52f8f612f1ab43e58d9e3b46ceef6c2c";
|
|
|
Object projectObj = map.get("projectId");
|
|
|
Object machineNoObj = map.get("machineNo");
|