Przeglądaj źródła

同步功能-只对表单进行同步

LHB 2 miesięcy temu
rodzic
commit
0a2624f8da

+ 54 - 61
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsSynchronousServiceImpl.java

@@ -233,6 +233,7 @@ public class WbsSynchronousServiceImpl {
                     LambdaQueryWrapper<WbsTree> wrapperTree = Wrappers.lambdaQuery();
                     wrapperTree
                             .eq(WbsTree::getIsDeleted, 0)
+                            .eq(WbsTree::getType, 2)
                             .apply("FIND_IN_SET({0},ancestors)", wbsTreePrivate.getTreePId());
                     //模板节点的所有子节点信息
                     List<WbsTree> wbsTrees = wbsTreeMapper.selectList(wrapperTree);
@@ -256,6 +257,7 @@ public class WbsSynchronousServiceImpl {
                     LambdaQueryWrapper<WbsTreePrivate> wrapperPrivate = Wrappers.lambdaQuery();
                     wrapperPrivate
                             .eq(WbsTreePrivate::getProjectId, wbsTreePrivateRoot.getProjectId())
+                            .eq(WbsTreePrivate::getType, 2)
                             .eq(WbsTreePrivate::getIsDeleted, 0);
                     //判断如果为顶级顶级节点
                     if (wbsTreePrivate.getTreePId() != 0) {
@@ -304,7 +306,7 @@ public class WbsSynchronousServiceImpl {
                 List<WbsTreePrivate> editPrivateNodes = new ArrayList<>();
                 for (WbsTreePrivate templateNode : templateNodes) {
                     //数据修复-----------------------------------------------------------------------------------------------------------------------------------开始
-                    if (!isPublic) {
+                    if (!isPublic && templateNode.getType() == 2) {
                         boolean isUpdate = false;
                         if (templateNode.getExcelId() != null) {
                             ExcelTab excelTab = excelTabMapper.selectOne(Wrappers.<ExcelTab>lambdaQuery()
@@ -376,68 +378,63 @@ public class WbsSynchronousServiceImpl {
                     //更新只跟新表单
                     for (WbsTreePrivate editPrivateNode : wbsTreePrivates) {
                         // 判断模板表与项目表 html是否一致
-                        if (ObjectUtils.equals(templateNode.getTreePId(), editPrivateNode.getTreePId())) {
-                            if (templateNode.getType() == 1) {
-                                editPrivateNode.setNodeName(templateNode.getNodeName());
-                                editPrivateNodes.add(editPrivateNode);
-                            } else {
-                                //清表
-                                if (collect.contains(2)) {
-                                    //绑定清表
-                                    editPrivateNode.setExcelId(templateNode.getExcelId());
-                                    //绑定实体表
-                                    editPrivateNode.setInitTableName(templateNode.getInitTableName());
-
-                                    if (StringUtil.isBlank(templateNode.getHtmlUrl())) {
-                                        throw new ServiceException(templateNode.getNodeName() + "HTML文件不存在");
-                                    }
-                                    //封装Html路径 根据模板html copy一份到自己项目节点上
-                                    String[] split = templateNode.getHtmlUrl().split("/");
-                                    String htmlUrl = file_path + "privateUrlCopy/" + projectInfo.getId() + "/" + split[split.length - 1];
-                                    File file_in = ResourceUtil.getFile(templateNode.getHtmlUrl());
-                                    if (!file_in.exists() || file_in.length() == 0) {
-                                        //如果本地服务器上没有
-                                        throw new ServiceException(templateNode.getNodeName() + "HTML文件不存在");
-                                    }
-                                    File file_out = ResourceUtil.getFile(htmlUrl);
-                                    //查询父级文件夹
-                                    File fileParent = file_out.getParentFile();
-                                    if (!fileParent.exists()) {
-                                        fileParent.mkdirs();
-                                    }
-                                    file_out.createNewFile();
-                                    FileUtil.copy(file_in, file_out);
-                                    editPrivateNode.setHtmlUrl(htmlUrl);
+                        if (ObjectUtils.equals(templateNode.getTreePId(), editPrivateNode.getTreePId()) && templateNode.getType() == 2) {
+                            //清表
+                            if (collect.contains(2)) {
+                                //绑定清表
+                                editPrivateNode.setExcelId(templateNode.getExcelId());
+                                //绑定实体表
+                                editPrivateNode.setInitTableName(templateNode.getInitTableName());
+
+                                if (StringUtil.isBlank(templateNode.getHtmlUrl())) {
+                                    throw new ServiceException(templateNode.getNodeName() + "HTML文件不存在");
+                                }
+                                //封装Html路径 根据模板html copy一份到自己项目节点上
+                                String[] split = templateNode.getHtmlUrl().split("/");
+                                String htmlUrl = file_path + "privateUrlCopy/" + projectInfo.getId() + "/" + split[split.length - 1];
+                                File file_in = ResourceUtil.getFile(templateNode.getHtmlUrl());
+                                if (!file_in.exists() || file_in.length() == 0) {
+                                    //如果本地服务器上没有
+                                    throw new ServiceException(templateNode.getNodeName() + "HTML文件不存在");
+                                }
+                                File file_out = ResourceUtil.getFile(htmlUrl);
+                                //查询父级文件夹
+                                File fileParent = file_out.getParentFile();
+                                if (!fileParent.exists()) {
+                                    fileParent.mkdirs();
                                 }
+                                file_out.createNewFile();
+                                FileUtil.copy(file_in, file_out);
+                                editPrivateNode.setHtmlUrl(htmlUrl);
+                            }
 
 
-                                if (templateNode.getExcelId() != null) {
-                                    editPrivateNode.setIsLinkTable(2);
-                                }
+                            if (templateNode.getExcelId() != null) {
+                                editPrivateNode.setIsLinkTable(2);
+                            }
 
-                                //元素 是与表绑定的
-                                if (collect.contains(3)) {
-                                    editPrivateNode.setInitTableName(templateNode.getInitTableName());
-                                }
+                            //元素 是与表绑定的
+                            if (collect.contains(3)) {
+                                editPrivateNode.setInitTableName(templateNode.getInitTableName());
+                            }
 
 
-                                //排序
-                                if (collect.contains(7)) {
-                                    editPrivateNode.setSort(templateNode.getSort());
-                                }
+                            //排序
+                            if (collect.contains(7)) {
+                                editPrivateNode.setSort(templateNode.getSort());
+                            }
 
-                                //手动选中的表单 进行筛选
-                                if (CollectionUtil.isNotEmpty(formList)) {
-                                    if (formList.contains(templateNode.getPKeyId())) {
-                                        if (collect.contains(2) || collect.contains(3) || collect.contains(4) || collect.contains(5) || collect.contains(6) || collect.contains(7)) {
-                                            editPrivateNodes.add(editPrivateNode);
-                                        }
-                                    }
-                                } else {
+                            //手动选中的表单 进行筛选
+                            if (CollectionUtil.isNotEmpty(formList)) {
+                                if (formList.contains(templateNode.getPKeyId())) {
                                     if (collect.contains(2) || collect.contains(3) || collect.contains(4) || collect.contains(5) || collect.contains(6) || collect.contains(7)) {
                                         editPrivateNodes.add(editPrivateNode);
                                     }
                                 }
+                            } else {
+                                if (collect.contains(2) || collect.contains(3) || collect.contains(4) || collect.contains(5) || collect.contains(6) || collect.contains(7)) {
+                                    editPrivateNodes.add(editPrivateNode);
+                                }
                             }
                         }
                     }
@@ -551,11 +548,9 @@ public class WbsSynchronousServiceImpl {
             LambdaQueryWrapper<WbsTreePrivate> wrapperPrivate = Wrappers.lambdaQuery();
             wrapperPrivate
                     .eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
-                    .eq(WbsTreePrivate::getIsDeleted, 0);
-            //判断如果为顶级顶级节点
-            if (wbsTreePrivate.getTreePId() != 0) {
-                wrapperPrivate.apply("FIND_IN_SET({0},ancestors_p_id)", wbsTreePrivate.getPKeyId());
-            }
+                    .eq(WbsTreePrivate::getType, 2)
+                    .eq(WbsTreePrivate::getIsDeleted, 0)
+                    .apply("FIND_IN_SET({0},ancestors_p_id)", wbsTreePrivate.getPKeyId());
             //当前项目的子节点数据
             List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectList(wrapperPrivate);
             wbsTreePrivates.add(wbsTreePrivate);
@@ -580,11 +575,9 @@ public class WbsSynchronousServiceImpl {
                     LambdaQueryWrapper<WbsTreeContract> wrapperContract = Wrappers.lambdaQuery();
                     wrapperContract
                             .eq(WbsTreeContract::getContractId, contractInfo.getId())
-                            .eq(WbsTreeContract::getIsDeleted, 0);
-                    //判断如果为顶级顶级节点
-                    if (wbsTreeContract.getTreePId() != 0) {
+                            .eq(WbsTreeContract::getIsDeleted, 0)
+                            .apply("FIND_IN_SET({0},ancestors_p_id)", wbsTreeContract.getPKeyId());
                         wrapperContract.apply("FIND_IN_SET({0},ancestors_p_id)", wbsTreeContract.getPKeyId());
-                    }
 
                     //当前合同的子节点数据
                     List<WbsTreeContract> wbsTreeContracts = wbsTreeContractMapper.selectList(wrapperContract);