Kaynağa Gözat

试车项目层面导入+概要

wangxuan 4 ay önce
ebeveyn
işleme
104898ebca

+ 5 - 1
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxCommissionCheckServiceImpl.java

@@ -1018,6 +1018,8 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
                 //摘要及图片
                 if (StringUtils.isNotBlank(res.getSummary())) {
                     buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_5, 10, false, res.getSummary(), null);
+                }else {
+                    buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_5, 10, false, "", null);
                 }
                 if (StringUtils.isNotBlank(res.getAnnex())) {
                     // 文件存储路径目录
@@ -1773,7 +1775,7 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
 
         final ZhcxProjectManageDo project = zhcxProjectManageService.getById(importDto.getProjectId());
         final Document doc = multipartFile2Doc(file);
-        List<SysDictDo> list = sysDictService.getDictsByType("test_address");
+        List<SysDictDo> list = sysDictService.getByRedis("test_address");
         Map<String, SysDictDo> dictMap = new HashMap<>(list.size());
         list.stream().forEach(item -> dictMap.put(item.getName(), item));
 
@@ -2327,6 +2329,8 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
                     //摘要及图片
                     if (StringUtils.isNotBlank(res.getSummary())) {
                         buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_5, 10, false, res.getSummary(), null);
+                    }else {
+                        buildTitleContent(builder, DEFAULT_FONT_NAME, StyleIdentifier.HEADING_5, 10, false, "", null);
                     }
                     if (StringUtils.isNotBlank(res.getAnnex())) {
                         // 文件存储路径目录

+ 41 - 40
business-common/src/main/java/com/rongwei/bscommon/sys/utils/ImportCommissionHelp.java

@@ -40,8 +40,9 @@ public class ImportCommissionHelp {
             final NodeCollection childNodes = body.getChildNodes();
             for(int m = 0, n = childNodes.getCount(); m < n; m++) {
                 Node node = childNodes.get(m);
-
-                if(node.getNodeType() == 5) { //表格
+                int nodeType = node.getNodeType();
+                String text = node.getText();
+                if(node.getNodeType() == NodeType.TABLE) { //表格
                     Table table = (Table) node;
                     //table转换成json结构
                     final List<JSONObject> treeDetailList = ImportCommissionHelp.table2Json(table);
@@ -51,42 +52,44 @@ public class ImportCommissionHelp {
                         detail.setId(SecurityUtil.getUUID());
                         detail.setDeleted("0");
                         detail.setPid(importDto.getId());
-                        if(ObjectUtil.isEmpty(rowJson.getString("NO."))){
-                            throw new CustomException("字段 'NO.' 不能为空");
-                        }
-                        detail.setChapterno(rowJson.getString("NO."));
-
-                        if(ObjectUtil.isEmpty(rowJson.getString("模式1"))){
-                            throw new CustomException("字段 '模式1' 不能为空");
-                        }
-                        detail.setClassification(rowJson.getString("模式1"));
-
-                        if(ObjectUtil.isEmpty(rowJson.getString("模式2"))){
-                            throw new CustomException("字段 '模式2' 不能为空");
-                        }
-                        detail.setClassificationtwo(rowJson.getString("模式2"));
-
-                        detail.setChtestcontent(rowJson.getString("测试内容中文"));
-                        detail.setEntestcontent(rowJson.getString("测试内容英文"));
-                        //detail.setTestmethod(rowJson.getString("标准测试方法"));
-
-                        if(ObjectUtil.isEmpty(rowJson.getString("标准测试时间"))){
-                            throw new CustomException("字段 '标准测试时间' 不能为空");
+                        // 表格的概要
+                        if(rowJson.size() == 1){
+                            detail.setTesttime("0");// 测试时间
+                            detail.setAcceptancecriteria("概要说明"); //接收标准
+                            detail.setClassification("铭牌参数"); // 模式一
+                            detail.setClassificationtwo("静态检查"); // 模式二
+                            detail.setChtestcontent(rowJson.getString("NO.")); //测试内容中文
+                        }else {
+                            if (ObjectUtil.isEmpty(rowJson.getString("NO."))) {
+                                throw new CustomException("字段 'NO.' 不能为空");
+                            }
+                            detail.setChapterno(rowJson.getString("NO."));
+                            if (ObjectUtil.isEmpty(rowJson.getString("模式1"))) {
+                                throw new CustomException("字段 '模式1' 不能为空");
+                            }
+                            detail.setClassification(rowJson.getString("模式1"));
+                            if (ObjectUtil.isEmpty(rowJson.getString("模式2"))) {
+                                throw new CustomException("字段 '模式2' 不能为空");
+                            }
+                            detail.setClassificationtwo(rowJson.getString("模式2"));
+                            detail.setChtestcontent(rowJson.getString("测试内容中文"));
+                            detail.setEntestcontent(rowJson.getString("测试内容英文"));
+                            if (ObjectUtil.isEmpty(rowJson.getString("标准测试时间"))) {
+                                throw new CustomException("字段 '标准测试时间' 不能为空");
+                            }
+                            detail.setTesttime(rowJson.getString("标准测试时间"));
+                            if (ObjectUtil.isEmpty(rowJson.getString("接收标准"))) {
+                                throw new CustomException("字段 '接收标准' 不能为空");
+                            }
+                            detail.setAcceptancecriteria(rowJson.getString("接收标准"));
+                            String testAddress = rowJson.getString("测试地点");
+                            if (ObjectUtil.isEmpty(testAddress) || ObjectUtil.isEmpty(importDto.getDictMap().get(testAddress))) {
+                                testAddress = "10";
+                            } else {
+                                testAddress = importDto.getDictMap().get(testAddress).getValue();
+                            }
+                            detail.setTestaddress(testAddress);
                         }
-                        detail.setTesttime(rowJson.getString("标准测试时间"));
-
-                        if(ObjectUtil.isEmpty(rowJson.getString("接收标准"))){
-                            throw new CustomException("字段 '接收标准' 不能为空");
-                        }
-                        detail.setAcceptancecriteria(rowJson.getString("接收标准"));
-
-                        String testAddress = rowJson.getString("测试地点");
-                        if(ObjectUtil.isEmpty(testAddress) || ObjectUtil.isEmpty(importDto.getDictMap().get(testAddress))) {
-                            testAddress = "10";
-                        } else {
-                            testAddress = importDto.getDictMap().get(testAddress).getValue();
-                        }
-                        detail.setTestaddress(testAddress);
                         if(ObjectUtil.isNotEmpty(treeDo.getFullpid())) {
                             detail.setTreefullid(treeDo.getFullpid().concat(",").concat(treeDo.getId()));
                         } else {
@@ -112,11 +115,9 @@ public class ImportCommissionHelp {
                             detail.setThreelevelclassification(fullpids[3]);
                             detail.setFouronelevelclassification(treeDo.getId());
                         }
-
                         detailList.add(detail);
                     }
-
-                } else if(node.getNodeType() == 8) { //段落
+                } else if(node.getNodeType() == NodeType.PARAGRAPH) { //段落
                     Paragraph paragraph = (Paragraph) node;
                     if(!paragraph.getParagraphFormat().isHeading()) { //标题
                         continue;