|
@@ -179,34 +179,8 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
queryWrapper.eq(ZhcxCommissionCheckBaseInfoTreeDo::getDeleted, "0")
|
|
|
.eq(ZhcxCommissionCheckBaseInfoTreeDo::getBaseinfoid, productTypeId);
|
|
|
List<ZhcxCommissionCheckBaseInfoTreeDo> treeList = zhcxCommissionCheckBaseInfoTreeService.list(queryWrapper);
|
|
|
- /*if(!list.isEmpty()){
|
|
|
- List<ZhcxCommissionCheckDetailTreeDo> targetList = new ArrayList<>();
|
|
|
- list.forEach(tree -> {
|
|
|
- tree.setId(tree.getId()+check.getProjectcode()).setBaseinfoid(check.getProjectcode());
|
|
|
- if(!tree.getPid().equals("-1")){
|
|
|
- tree.setPid(tree.getPid()+check.getProjectcode());
|
|
|
- }
|
|
|
- ZhcxCommissionCheckDetailTreeDo target = new ZhcxCommissionCheckDetailTreeDo(); // 初始化一个目标对象
|
|
|
- BeanUtils.copyProperties(tree, target);
|
|
|
- targetList.add(target);
|
|
|
- });
|
|
|
- LambdaQueryWrapper<ZhcxCommissionCheckDetailTreeDo> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper2.eq(ZhcxCommissionCheckDetailTreeDo::getDeleted,"0")
|
|
|
- .eq(ZhcxCommissionCheckDetailTreeDo::getBaseinfoid,check.getProjectcode());
|
|
|
- List<ZhcxCommissionCheckDetailTreeDo> listed = zhcxCommissionCheckDetailTreeService.list(queryWrapper2);
|
|
|
- if(listed.isEmpty()){
|
|
|
- zhcxCommissionCheckDetailTreeService.saveBatch(targetList);
|
|
|
- }else{
|
|
|
- return R.error("该项目已创建,请选择相同的试车标准库");
|
|
|
- }
|
|
|
- }*/
|
|
|
// 试车子表
|
|
|
List<ZhcxCommissionCheckDetailDo> checkDetails = checkDTO.getCheckDetails();
|
|
|
- // 查询已保存过的子表数据(平台bug,已保存的数据只能去数据库中查)
|
|
|
-/* List<ZhcxCommissionCheckDetailDo> savedcheckDetails = getSavedDataByPid(check.getId());
|
|
|
- if(!savedcheckDetails.isEmpty()){
|
|
|
- checkDetails.addAll(savedcheckDetails);
|
|
|
- }*/
|
|
|
// 创建新增集合
|
|
|
// 试车主子表
|
|
|
List<ZhcxCommissionCheckDo> resultCheckDo = new ArrayList<>();
|
|
@@ -398,10 +372,6 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
}
|
|
|
return R.ok("同步成功");
|
|
|
}
|
|
|
- /*@Async("batchSaveThreadPool")
|
|
|
- public void saveCheckDetailBatch(List<ZhcxCommissionCheckDetailDo> resultCheckDetailDo) {
|
|
|
- commissionCheckDetailService.saveBatch(resultCheckDetailDo);
|
|
|
- }*/
|
|
|
|
|
|
/**
|
|
|
* 构建一条新的试车检查内容数据
|
|
@@ -456,28 +426,6 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
detailVo.setTreefullid(detailDo.getTreefullid());
|
|
|
// 接收标准
|
|
|
detailVo.setAcceptancecriteria(detailDo.getAcceptancecriteria());
|
|
|
- /*if(Objects.nonNull(detailDo.getChapterno())) {
|
|
|
- List<ZhcxCommissionCheckDetailDo> doList = baseMapper.selectDetailListByPidAndChapterno(pid,detailDo.getChapterno());
|
|
|
- if (!doList.isEmpty()) {
|
|
|
- ZhcxCommissionCheckDetailDo checkDetailDo = doList.get(0);
|
|
|
- // 用户填选填充
|
|
|
- detailVo.setDebuggerresult(checkDetailDo.getDebuggerresult());
|
|
|
- detailVo.setDebuggerdate(checkDetailDo.getDebuggerdate());
|
|
|
- detailVo.setDebuggerdata(checkDetailDo.getDebuggerdata());
|
|
|
- detailVo.setSelftester(checkDetailDo.getSelftester());
|
|
|
- detailVo.setSelftesterid(checkDetailDo.getSelftesterid());
|
|
|
- detailVo.setDebuggerpic(checkDetailDo.getDebuggerpic());
|
|
|
- detailVo.setDebuggernotes(checkDetailDo.getDebuggernotes());
|
|
|
-
|
|
|
- detailVo.setTestresult(checkDetailDo.getTestresult());
|
|
|
- detailVo.setTestdata(checkDetailDo.getTestdata());
|
|
|
- detailVo.setQa(checkDetailDo.getQa());
|
|
|
- detailVo.setQaid(checkDetailDo.getQaid());
|
|
|
- detailVo.setTestdate(checkDetailDo.getTestdate());
|
|
|
- detailVo.setTestpic(checkDetailDo.getTestpic());
|
|
|
- detailVo.setTestnotes(checkDetailDo.getTestnotes());
|
|
|
- }
|
|
|
- }*/
|
|
|
return detailVo;
|
|
|
}
|
|
|
|
|
@@ -828,9 +776,6 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
// 首页模板地址: d1b3271ce2ec45c2915f2dbcd819f45a
|
|
|
SysFileItemDo fileItemDo = sysFileItemService.getById(fileId);
|
|
|
final Document[] indexDoc = {WordHelpUtils.getDoc(fileItemDo.getFullpath())};
|
|
|
- //Document indexDoc = WordHelpUtils.getDoc(fileItemDo.getFullpath());
|
|
|
- // 分割文档
|
|
|
- //Document[] splitDocs = splitDocumentByPages(indexDoc, 2);
|
|
|
|
|
|
FormData formData = new FormData();
|
|
|
List<Map<String, Object>> mainDataList = new ArrayList<>();
|
|
@@ -848,7 +793,6 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
formData.setMainDataList(mainDataList);
|
|
|
// 历史版本
|
|
|
indexDoc[0] = ExcelExportUtil.fillWordDataByMap(fileItemDo.getFullpath(), formData);
|
|
|
- //splitDocs[0] = ExcelExportUtil.fillWordDataByMap(fileItemDo.getFullpath(), formData);
|
|
|
List<ZhcxCommissionCheckDetailDo> list = zhcxCommissionCheckDetailDao.listData(map);
|
|
|
List<ZhcxCommissionCheckDetailTreeDo> checkTreeList = zhcxCommissionCheckDetailTreeService.listCheckDetailTreeData(map);
|
|
|
Document doc = null;
|
|
@@ -1019,19 +963,20 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
}
|
|
|
//摘要及图片
|
|
|
if (StringUtils.isNotBlank(res.getSummary())) {
|
|
|
- buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_5, 10, false, res.getSummary(), null);
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL, 10, false, res.getSummary(), null);
|
|
|
}else {
|
|
|
- buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_5, 10, false, "", null);
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL, 10, false, "", null);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(res.getAnnex())) {
|
|
|
// 文件存储路径目录
|
|
|
String filePath = sysConfigService.getContentByConfigCode(Constants.CONFIG_FILE_ROOT_PATH);
|
|
|
String outputDir = filePath + "\\by_files\\driveinspection_files\\"; // 写死
|
|
|
- String[] annexArr = res.getAnnex().split("\\^\\_\\^");
|
|
|
+ String[] annexArr = res.getAnnex().split("\\^_\\^");
|
|
|
for (String imginfo : annexArr) {
|
|
|
String[] imgArr = imginfo.split("-;-");
|
|
|
- String imgFullName = imgArr[1] + "." + imgArr[0].split("\\.")[1];
|
|
|
- String imgPath = outputDir + imgFullName;
|
|
|
+ //String imgFullName = imgArr[1] + "." + imgArr[0].split("\\.")[1];
|
|
|
+ //String imgPath = outputDir + imgFullName;
|
|
|
+ String imgPath = sysFileItemService.getById(imgArr[1]).getFullpath();
|
|
|
Shape shape = builder.insertImage(imgPath);
|
|
|
shape.setWidth(80); // 宽度 200 磅
|
|
|
shape.setHeight(80); // 高度 150 磅
|
|
@@ -1339,8 +1284,10 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
* @param prefixContent 内容前缀 此处用来做首行缩进
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- private void buildTitleContent(DocumentBuilder builder, String fontName, int styleIdentifier, int fontSize,
|
|
|
- boolean isBold, String content, String prefixContent) throws Exception {
|
|
|
+ private static void buildTitleContent(DocumentBuilder builder, String fontName, int styleIdentifier, int fontSize,
|
|
|
+ boolean isBold, String content, String prefixContent) throws Exception {
|
|
|
+ // 设置样式
|
|
|
+ builder.getParagraphFormat().setStyleIdentifier(styleIdentifier);
|
|
|
// 设置字体
|
|
|
builder.getFont().setName(fontName);
|
|
|
// 是否倾斜
|
|
@@ -1351,8 +1298,6 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
builder.getFont().setBold(isBold);
|
|
|
// 设置对齐方式
|
|
|
builder.getParagraphFormat().setAlignment(ParagraphAlignment.LEFT);
|
|
|
- // 设置样式
|
|
|
- builder.getParagraphFormat().setStyleIdentifier(styleIdentifier);
|
|
|
// 设置前缀 此处作为 首行缩进
|
|
|
if (prefixContent != null) {
|
|
|
builder.write(prefixContent);
|
|
@@ -2145,6 +2090,7 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
String exportType = (String) exportObj;
|
|
|
ZhcxProjectManageDo projectManageDo = zhcxProjectManageService.getById(projectId);
|
|
|
SysFileItemDo fileItemDo = sysFileItemService.getById("52f8f612f1ab43e58d9e3b46ceef6c2c");
|
|
|
+ //fileItemDo.setFullpath("E:\\xuan\\111.doc");
|
|
|
final Document[] indexDoc = {WordHelpUtils.getDoc(fileItemDo.getFullpath())};
|
|
|
FormData formData = new FormData();
|
|
|
List<Map<String, Object>> mainDataList = new ArrayList<>();
|
|
@@ -2173,7 +2119,7 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
return R.error("空模板获取出现异常");
|
|
|
}
|
|
|
//移动到页眉
|
|
|
- try {
|
|
|
+ /*try {
|
|
|
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); // 主页眉
|
|
|
// 如果有多个页眉,可以选择HeaderFooterType.HEADER_FIRST, HeaderFooterType.HEADER_EVEN等
|
|
|
for (com.aspose.words.Field field : doc.getRange().getFields()) {
|
|
@@ -2187,7 +2133,7 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
} catch (Exception e) {
|
|
|
ExceptionUtils.printExceptionDetail(e, "页面参数赋值异常");
|
|
|
return R.error("页面参数赋值异常");
|
|
|
- }
|
|
|
+ }*/
|
|
|
if (list.isEmpty() || checkTreeList.isEmpty()) {
|
|
|
return R.error("该检查内容没有数据");
|
|
|
} else {
|
|
@@ -2326,9 +2272,9 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_1, 15, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
} else {
|
|
|
if (res.getLevel() == 2) {
|
|
|
- buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_2, 15, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_3, 14, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
} else {
|
|
|
- buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_3, 15, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_3, 12, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
}
|
|
|
}
|
|
|
//摘要及图片
|
|
@@ -2344,8 +2290,9 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
String[] annexArr = res.getAnnex().split("\\^\\_\\^");
|
|
|
for (String imginfo : annexArr) {
|
|
|
String[] imgArr = imginfo.split("-;-");
|
|
|
- String imgFullName = imgArr[1] + "." + imgArr[0].split("\\.")[1];
|
|
|
- String imgPath = outputDir + imgFullName;
|
|
|
+ //String imgFullName = imgArr[1] + "." + imgArr[0].split("\\.")[1];
|
|
|
+ //String imgPath = outputDir + imgFullName;
|
|
|
+ String imgPath = sysFileItemService.getById(imgArr[1]).getFullpath();
|
|
|
Shape shape = builder.insertImage(imgPath);
|
|
|
shape.setWidth(80); // 宽度 200 磅
|
|
|
shape.setHeight(80); // 高度 150 磅
|
|
@@ -2450,6 +2397,7 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
// 在副本上合并文档B
|
|
|
try {
|
|
|
cloneDocA.appendDocument(doc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
|
|
|
+ cloneDocA.updateFields();
|
|
|
if ("export".equals(exportType)) {
|
|
|
exportWord(cloneDocA, response);
|
|
|
} else {
|
|
@@ -2496,13 +2444,18 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
imgList = new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
- //图片名称
|
|
|
+ //图片名称 \by_files\driveinspection_files
|
|
|
SysFileItemParamDto itemParamDto = SysFileItemParamDto.builder()
|
|
|
.fileName("img_word_".concat(String.valueOf(i)).concat(FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType())))
|
|
|
.folderCode("driveinspection_files")
|
|
|
.build();
|
|
|
final SysFileItemDo fileItemDo = sysFileItemService.assembleItem(itemParamDto, null);
|
|
|
fileItemDo.setFilename(String.format("img_word_%s.%s", fileItemDo.getId(), FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType())));
|
|
|
+ fileItemDo.setFilename(fileItemDo.getFilename().replaceAll("\\.\\.","."));
|
|
|
+ // 设置图片的路径
|
|
|
+ String filePath = sysConfigService.getContentByConfigCode(Constants.CONFIG_FILE_ROOT_PATH);
|
|
|
+ fileItemDo.setFullpath(filePath+"\\by_files\\driveinspection_files\\"+fileItemDo.getFilename());
|
|
|
+ fileItemDo.setUrlpath("\\files\\by_files\\driveinspection_files\\"+fileItemDo.getFilename());
|
|
|
FileOutputStream out = new FileOutputStream(fileItemDo.getFullpath());
|
|
|
out.write(shape.getImageData().getImageBytes());
|
|
|
out.close();
|
|
@@ -2943,4 +2896,370 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
return R.error("核心检验指标导入失败");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @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");
|
|
|
+ Object exportObj = map.get("exportType");
|
|
|
+ String day = DateUtils.format(new Date());
|
|
|
+ String projectId = (String) projectObj;
|
|
|
+ String machineNo = (String) machineNoObj;
|
|
|
+ String exportType = (String) exportObj;
|
|
|
+ ZhcxProjectManageDo projectManageDo = zhcxProjectManageService.getById(projectId);
|
|
|
+ // 首页模板地址
|
|
|
+ SysFileItemDo fileItemDo = sysFileItemService.getById(fileId);
|
|
|
+ final Document[] indexDoc = {WordHelpUtils.getDoc(fileItemDo.getFullpath())};
|
|
|
+ FormData formData = new FormData();
|
|
|
+ List<Map<String, Object>> mainDataList = new ArrayList<>();
|
|
|
+ Map<String, Object> mainMap = new HashMap<>(16);
|
|
|
+ String projectEnName = "";
|
|
|
+ if (StringUtils.isNotBlank(projectManageDo.getProjectEnName())) {
|
|
|
+ projectEnName = projectManageDo.getProjectEnName();
|
|
|
+ }
|
|
|
+ mainMap.put("projectNames", projectManageDo.getProjectName() + projectEnName);
|
|
|
+ mainMap.put("projectCode", projectManageDo.getProjectCode());
|
|
|
+ mainMap.put("projectName", projectManageDo.getProjectName());
|
|
|
+ mainMap.put("currentDate", day);
|
|
|
+ mainMap.put("machineNo", machineNo);
|
|
|
+ mainDataList.add(mainMap);
|
|
|
+ formData.setMainDataList(mainDataList);
|
|
|
+ // 历史版本
|
|
|
+ indexDoc[0] = ExcelExportUtil.fillWordDataByMap(fileItemDo.getFullpath(), formData);
|
|
|
+ List<ZhcxCommissionCheckDetailDo> list = zhcxCommissionCheckDetailDao.listData(map);
|
|
|
+ List<ZhcxCommissionCheckDetailTreeDo> checkTreeList = zhcxCommissionCheckDetailTreeService.listCheckDetailTreeData(map);
|
|
|
+ Document doc = null;
|
|
|
+ DocumentBuilder builder = null;
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("template/检查内容明细模版.doc");
|
|
|
+ try {
|
|
|
+ // 历史版本
|
|
|
+ doc = new Document(classPathResource.getInputStream());
|
|
|
+ builder = new DocumentBuilder(doc);
|
|
|
+ } catch (Exception e) {
|
|
|
+ ExceptionUtils.printExceptionDetail(e, "空模板获取出现异常");
|
|
|
+ return R.error("空模板获取出现异常");
|
|
|
+ }
|
|
|
+ //移动到页眉
|
|
|
+ builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY); // 主页眉
|
|
|
+ List<JSONObject> resultType = zhcxCommissionCheckDetailDao.getResultDictList();
|
|
|
+ if (list.isEmpty() || checkTreeList.isEmpty()) {
|
|
|
+ return R.error("该检查内容没有数据");
|
|
|
+ } else {
|
|
|
+ //设置word导出目录
|
|
|
+ Map<String, ZhcxCommissionCheckDetailWordVO> resMap = new HashMap<>();
|
|
|
+ for (ZhcxCommissionCheckDetailTreeDo item : checkTreeList) {
|
|
|
+ ZhcxCommissionCheckDetailWordVO checkDetailWordVO = new ZhcxCommissionCheckDetailWordVO();
|
|
|
+ checkDetailWordVO.setTitleContent(item.getName());
|
|
|
+ checkDetailWordVO.setLevel(item.getLevel());
|
|
|
+ checkDetailWordVO.setSummary(item.getSummary());
|
|
|
+ checkDetailWordVO.setAnnex(item.getAnnex());
|
|
|
+ checkDetailWordVO.setDetailList(new LinkedList<>());
|
|
|
+ if (!"-1".equals(item.getPid())) {
|
|
|
+ //目前标题最多到三级
|
|
|
+ if (item.getLevel() == 2) {
|
|
|
+ String oldPid = item.getPid();
|
|
|
+ //树等级为二级处理章节号
|
|
|
+ List<ZhcxCommissionCheckDetailTreeDo> parentList = checkTreeList.stream().filter(info -> info.getId().split("_")[0].equals(oldPid.split("_")[0])).collect(Collectors.toList());
|
|
|
+ if (!parentList.isEmpty()) {
|
|
|
+ String parentTreeCode = parentList.get(0).getTreecode();
|
|
|
+ if (StringUtils.isBlank(parentTreeCode)) {
|
|
|
+ return R.error(item.getName() + "该树的父节点的编码不能为空");
|
|
|
+ } else {
|
|
|
+ //设置二级树节点的章节号规则:取出一级树编码.号后面的放在二级编码的第一位
|
|
|
+ int i = parentTreeCode.indexOf(".");
|
|
|
+ if (i != -1) {
|
|
|
+ String key = parentTreeCode.substring(i + 1);
|
|
|
+ String result = item.getTreecode().replaceAll(".*\\.", key + ".");
|
|
|
+ checkDetailWordVO.setChapterno(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] fullIds = item.getFullpid().split(",");
|
|
|
+ if (fullIds.length > 2) {
|
|
|
+ //树等级为三级处理章节号
|
|
|
+ String oneLevelKey = "";
|
|
|
+ //根据当前节点过滤出一级树的列表
|
|
|
+ List<ZhcxCommissionCheckDetailTreeDo> oneLevelList = checkTreeList.stream().filter(info -> info.getId().split("_")[0].equals(fullIds[1])).collect(Collectors.toList());
|
|
|
+ if (!oneLevelList.isEmpty()) {
|
|
|
+ //取出一级树节点编码
|
|
|
+ String oneLevelTreeCode = oneLevelList.get(0).getTreecode();
|
|
|
+ if (StringUtils.isBlank(oneLevelTreeCode)) {
|
|
|
+ return R.error(item.getName() + "该树的一级节点的编码不能为空");
|
|
|
+ } else {
|
|
|
+ String oldPid = item.getPid();
|
|
|
+ //设置三级树节点的章节号规则:取出一级树编码.号后面的加上二级树编码.号后面的再加上自身.号后面的数据
|
|
|
+ int i = oneLevelTreeCode.indexOf(".");
|
|
|
+ if (i != -1) {
|
|
|
+ oneLevelKey = oneLevelTreeCode.substring(i + 1);
|
|
|
+ String twoLevelKey = "";
|
|
|
+ List<ZhcxCommissionCheckDetailTreeDo> parentList = checkTreeList.stream().filter(info -> info.getId().split("_")[0].equals(oldPid.split("_")[0])).collect(Collectors.toList());
|
|
|
+ if (!parentList.isEmpty()) {
|
|
|
+ //取出父树节点编码
|
|
|
+ String parentTreeCode = parentList.get(0).getTreecode();
|
|
|
+ if (StringUtils.isBlank(parentTreeCode)) {
|
|
|
+ return R.error(item.getName() + "该树的父节点的编码不能为空");
|
|
|
+ }
|
|
|
+ int j = parentTreeCode.indexOf(".");
|
|
|
+ if (j != -1) {
|
|
|
+ twoLevelKey = parentTreeCode.substring(j + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String result = item.getTreecode().replaceAll(".*\\.", oneLevelKey + "." + twoLevelKey + ".");
|
|
|
+ checkDetailWordVO.setChapterno(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String oldPid = item.getPid();
|
|
|
+ String oldId = item.getId();
|
|
|
+ resMap.put(oldPid.split("_")[0] + "," + oldId.split("_")[0], checkDetailWordVO);
|
|
|
+ } else {
|
|
|
+ String oldId = item.getId();
|
|
|
+ //树等级为一级处理章节号
|
|
|
+ if (StringUtils.isBlank(item.getTreecode())) {
|
|
|
+ return R.error(item.getName() + "树编码不能为空");
|
|
|
+ } else {
|
|
|
+ //设置一级树节点的章节号规则:去除.号前面的就行
|
|
|
+ int i = item.getTreecode().indexOf(".");
|
|
|
+ if (i != -1) {
|
|
|
+ String key = item.getTreecode().substring(i + 1);
|
|
|
+ checkDetailWordVO.setChapterno(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resMap.put(oldId.split("_")[0], checkDetailWordVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //子表数据
|
|
|
+ for (ZhcxCommissionCheckDetailDo item : list) {
|
|
|
+ String key = "";
|
|
|
+ String treeFullId = item.getTreefullid();
|
|
|
+ if (StringUtils.isBlank(treeFullId)) {
|
|
|
+ log.error("该内容节点treeFullId值为空:{}", item.getChtestcontent());
|
|
|
+ return R.error(item.getChtestcontent() + "该内容节点数据有误");
|
|
|
+ }
|
|
|
+ int fillIdLength = treeFullId.split(",").length;
|
|
|
+ int i = treeFullId.indexOf(",");
|
|
|
+ if (fillIdLength <= 3) {
|
|
|
+ key = treeFullId.substring(i + 1);
|
|
|
+ if (!resMap.containsKey(key)) {
|
|
|
+ log.error("不能导出树表的id:{}的报告", treeFullId);
|
|
|
+ log.error("不能导出树表的key:{}的报告", key);
|
|
|
+ log.error("该内容节点有错误:{}的报告", item.getChtestcontent());
|
|
|
+ return R.error(item.getChtestcontent() + "该内容节点数据有误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 从第一个逗号之后开始找第二个逗号
|
|
|
+ int j = treeFullId.indexOf(',', i + 1);
|
|
|
+ key = treeFullId.substring(j + 1);
|
|
|
+ if (!resMap.containsKey(key)) {
|
|
|
+ log.error("不能导出树表的id:{}的报告", treeFullId);
|
|
|
+ log.error("不能导出树表的key:{}的报告", key);
|
|
|
+ log.error("章节号有无误:{}的报告", item.getChapterno());
|
|
|
+ return R.error(item.getChtestcontent() + "该内容节点数据有误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ZhcxCommissionCheckDetailWordVO checkDetailWordVO = resMap.get(key);
|
|
|
+ List<ZhcxCommissionCheckDetailDo> detailList = checkDetailWordVO.getDetailList();
|
|
|
+ detailList.add(item);
|
|
|
+ }
|
|
|
+ List<ZhcxCommissionCheckDetailWordVO> resList = new LinkedList<>();
|
|
|
+ for (String s : resMap.keySet()) {
|
|
|
+ resList.add(resMap.get(s));
|
|
|
+ }
|
|
|
+ resList.sort((a, b) -> {
|
|
|
+ LinkedList<String> a1 = new LinkedList<>(Arrays.asList(a.getChapterno().split("\\.")));
|
|
|
+ LinkedList<String> b1 = new LinkedList<>(Arrays.asList(b.getChapterno().split("\\.")));
|
|
|
+ return sort1(a1, b1);
|
|
|
+ });
|
|
|
+ builder.moveToDocumentStart();
|
|
|
+ for (ZhcxCommissionCheckDetailWordVO res : resList) {
|
|
|
+ if (res.getLevel() == 1) {
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_1, 15, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
+ } else {
|
|
|
+ if (res.getLevel() == 2) {
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_3, 14, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
+ } else {
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_3, 12, true, res.getChapterno() + "." + res.getTitleContent(), null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //摘要及图片
|
|
|
+ if (StringUtils.isNotBlank(res.getSummary())) {
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL, 10, false, res.getSummary(), null);
|
|
|
+ }else {
|
|
|
+ buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL, 10, false, "", null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(res.getAnnex())) {
|
|
|
+ // 文件存储路径目录
|
|
|
+ String filePath = sysConfigService.getContentByConfigCode(Constants.CONFIG_FILE_ROOT_PATH);
|
|
|
+ String outputDir = filePath + "\\by_files\\driveinspection_files\\"; // 写死
|
|
|
+ String[] annexArr = res.getAnnex().split("\\^\\_\\^");
|
|
|
+ for (String imginfo : annexArr) {
|
|
|
+ String[] imgArr = imginfo.split("-;-");
|
|
|
+ //String imgFullName = imgArr[1] + "." + imgArr[0].split("\\.")[1];
|
|
|
+ //String imgPath = outputDir + imgFullName;
|
|
|
+ String imgPath = sysFileItemService.getById(imgArr[1]).getFullpath();
|
|
|
+ Shape shape = builder.insertImage(imgPath);
|
|
|
+ shape.setWidth(80); // 宽度 200 磅
|
|
|
+ shape.setHeight(80); // 高度 150 磅
|
|
|
+ }
|
|
|
+ builder.writeln();//换行
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(res.getDetailList())) {
|
|
|
+ // 插入表头
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 10, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "NO.", null);
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 40, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "模式1", null);
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 40, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "模式2", null);
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 50, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "测试内容中文", null);
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 50, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "测试内容英文", null);
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 50, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "标准测试时间", null);
|
|
|
+ // 接收标准
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 50, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "接收标准", null);
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTitleContent(builder, 60, 20, HeightRule.EXACTLY, TextOrientation.HORIZONTAL, DEFAULT_FONT_NAME, StyleIdentifier.NORMAL,
|
|
|
+ 9, true, "测试地点", null);
|
|
|
+ builder.endRow();
|
|
|
+ int count = 0;
|
|
|
+ for (ZhcxCommissionCheckDetailDo detailWordVO : res.getDetailList()) {
|
|
|
+ String chtestcontent = "";
|
|
|
+ builder.insertCell();
|
|
|
+ //合并单元格
|
|
|
+ if (detailWordVO.getIstitle() != null && detailWordVO.getIstitle().equals("y")) {
|
|
|
+ if (StringUtils.isNotBlank(detailWordVO.getChtestcontent())) {
|
|
|
+ chtestcontent = detailWordVO.getChtestcontent();
|
|
|
+ }
|
|
|
+ buildTableTextContent(builder, 350, 9, DEFAULT_FONT_NAME, true, chtestcontent);
|
|
|
+ builder.getCurrentParagraph().getParagraphFormat().setAlignment(ParagraphAlignment.LEFT); // 内容靠左
|
|
|
+ builder.getCellFormat().setHorizontalMerge(CellMerge.FIRST); // 设置为合并起始单元格
|
|
|
+ for (int col = 1; col < 8; col++) {
|
|
|
+ builder.insertCell();
|
|
|
+ builder.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS); // 设置为合并到前一个单元格
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ count++;
|
|
|
+ // 插入表格的第一行
|
|
|
+ //builder.insertCell();
|
|
|
+ buildTableTextContent(builder, 10, 9, DEFAULT_FONT_NAME, false, String.valueOf(count));
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTextContent(builder, 40, 9, DEFAULT_FONT_NAME, false, detailWordVO.getClassification());
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTextContent(builder, 40, 9, DEFAULT_FONT_NAME, false, detailWordVO.getClassificationtwo());
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTextContent(builder, 50, 9, DEFAULT_FONT_NAME, false, detailWordVO.getChtestcontent());
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTextContent(builder, 50, 9, DEFAULT_FONT_NAME, false, detailWordVO.getEntestcontent());
|
|
|
+ builder.insertCell();
|
|
|
+ // 标准测试时间
|
|
|
+ buildTableTextContent(builder, 50, 9, DEFAULT_FONT_NAME, false,
|
|
|
+ (detailWordVO.getTesttime() != null ? detailWordVO.getTesttime() : "").replace(".0", ""));
|
|
|
+ // 接收标准
|
|
|
+ builder.insertCell();
|
|
|
+ buildTableTextContent(builder, 50, 9, DEFAULT_FONT_NAME, false, detailWordVO.getAcceptancecriteria());
|
|
|
+ builder.insertCell();
|
|
|
+ String testAddress = "";
|
|
|
+ if (StringUtils.isNotBlank(detailWordVO.getTestaddress())) {
|
|
|
+ // 10-> CX BASE长兴基地 20-> USER SITE码头现场
|
|
|
+ if ("20".equals(detailWordVO.getTestaddress())) {
|
|
|
+ testAddress = "USER SITE码头现场";
|
|
|
+ }
|
|
|
+ if ("10".equals(detailWordVO.getTestaddress())) {
|
|
|
+ testAddress = "CX BASE长兴基地";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ buildTableTextContent(builder, 60, 9, DEFAULT_FONT_NAME, false, testAddress);
|
|
|
+ }
|
|
|
+ builder.endRow();
|
|
|
+ // 设置行高为自适应
|
|
|
+ builder.getRowFormat().setHeightRule(HeightRule.AUTO);
|
|
|
+ }
|
|
|
+ // 结束表格
|
|
|
+ builder.endTable();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 创建模板A的副本
|
|
|
+ Document cloneDocA = indexDoc[0].deepClone();
|
|
|
+ //Document cloneDocA = splitDocs[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);
|
|
|
+ // 清除当前页眉的内容
|
|
|
+ currentHeader.removeAllChildren();
|
|
|
+ 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();
|
|
|
+ if ("export".equals(exportType)) {
|
|
|
+ exportWord(cloneDocA, response);
|
|
|
+ } else {
|
|
|
+ previewWord(cloneDocA, response);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
}
|