Browse Source

Merge branch 'master' of http://47.110.251.215:3000/java_org/bladex

“zhifk” 1 year ago
parent
commit
8a984a8145
15 changed files with 212 additions and 114 deletions
  1. 8 4
      blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/LargeFileEndpoint.java
  2. 2 2
      blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchivesAutoController.java
  3. 2 2
      blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchivesAutoService.java
  4. 16 7
      blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java
  5. 56 7
      blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java
  6. 4 0
      blade-service/blade-archive/src/main/java/org/springblade/archive/utils/FileUtils.java
  7. 18 9
      blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
  8. 2 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java
  9. 6 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeController.java
  10. 13 5
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/SaveUserInfoByProjectClientImpl.java
  11. 1 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/TableFileClientImpl.java
  12. 1 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.xml
  13. 17 9
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  14. 65 63
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java
  15. 1 1
      blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

+ 8 - 4
blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/LargeFileEndpoint.java

@@ -18,6 +18,7 @@ package org.springblade.resource.endpoint;
 
 import com.aliyun.oss.model.*;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.itextpdf.text.pdf.PdfReader;
 import io.swagger.annotations.Api;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
@@ -348,8 +349,8 @@ public class LargeFileEndpoint {
 		largeFile.setSuffix(param.getObjectType());
 		iLargeFileService.save(largeFile);
 
-		if(param.getTotalChunks()== param.getChunkNumber()){
-			Thread.sleep(400);
+		if((param.getTotalChunks()+"").equals(param.getChunkNumber()+"") ){
+			Thread.sleep(1000);
 		//第八步 检查文件是否全部完成上传
 		lock.lock();
 		try {
@@ -384,9 +385,11 @@ public class LargeFileEndpoint {
 				if(param.getFilename().contains("pdf")){
 //					FileInputStream inputStream1 = new FileInputStream(filePath + param.getFilename());
 					try {
-						PDDocument document = PDDocument.load(multipartFile.getInputStream());
+						//PDDocument document = PDDocument.load(multipartFile.getInputStream());
+						PdfReader pdfReader = new PdfReader(multipartFile.getInputStream());
+						int pages = pdfReader.getNumberOfPages();
 						//获取文件页数
-						newBladeFile.setPage(document.getPages().getCount());
+						newBladeFile.setPage(pages);
 					} catch (IOException e) {
 						e.printStackTrace();
 					}
@@ -601,4 +604,5 @@ public class LargeFileEndpoint {
 		return param.getIdentifier() + extension;
 	}
 
+
 }

+ 2 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchivesAutoController.java

@@ -337,9 +337,9 @@ public class ArchivesAutoController extends BladeController {
 			projectClient.updateIsArchivesAutoById(projectId,1);
 
 			//将项目未锁定案卷拆卷
-			archivesAutoService.splitArchvies(projectId);
+			archivesAutoService.splitArchvies(projectId,contractId,nodeId);
 			//项目自动组卷入口
-			archivesAutoService.archiveAutoMethod(projectId);
+			archivesAutoService.archiveAutoMethod(projectId,contractId,nodeId);
 			//刷新项目档号
 			archivesAutoService.refreshFileNumberNoSlipt(projectId,contractId,nodeId);
 			//设置自动组卷结束

+ 2 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchivesAutoService.java

@@ -59,9 +59,9 @@ public interface IArchivesAutoService extends BaseService<ArchivesAuto> {
 
 	void batchDestroyArchive(String ids);
 
-	void archiveAutoMethod(Long project);
+	void archiveAutoMethod(Long project,Long contractId,Long nodeId);
 
-	void splitArchvies(Long project);
+	void splitArchvies(Long project,Long contractId,Long nodeId);
 
 	public String getMergeArchivesFile(Long archiveId);
 

+ 16 - 7
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java

@@ -645,11 +645,13 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         for (ArchiveFile file : datas) {
             String fileTime = file.getFileTime();
-            if (minDate.isEmpty() || fileTime.compareTo(minDate) < 0) {
-                minDate = fileTime;
-            }
-            if (maxDate.isEmpty() || fileTime.compareTo(maxDate) > 0) {
-                maxDate = fileTime;
+            if(StringUtils.isNotEmpty(fileTime)){
+                if (minDate.isEmpty() || fileTime.compareTo(minDate) <= 0) {
+                    minDate = fileTime;
+                }
+                if (maxDate.isEmpty() || fileTime.compareTo(maxDate) >= 0) {
+                    maxDate = fileTime;
+                }
             }
         }
 
@@ -707,7 +709,10 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         //
         String url = file.getPdfFileUrl();
         if (StringUtil.isEmpty(url)) {
-            url = file.getFileUrl();
+            String fileUrl = file.getFileUrl();
+            if(fileUrl.endsWith(".pdf") || fileUrl.endsWith(".PDF")){
+                url = file.getFileUrl();
+            }
         }
 
         //todo 生成相册内容,待补充
@@ -726,7 +731,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
         List<String> fileUrls = new ArrayList<>();
         for (ArchiveFile file: datas) {
-            fileUrls.add(getPdfFileUrl(file));
+            String url = getPdfFileUrl(file);
+            if(StringUtils.isEmpty(url)){
+                continue;
+            }
+            fileUrls.add(url);
         }
 
         fileUrls.addAll(frontUrls);

+ 56 - 7
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -256,7 +256,7 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 	}
 
 	@Override
-	public void splitArchvies(Long projectId){
+	public void splitArchvies(Long projectId,Long contractId,Long nodeId){
 		List<String> removeFiles = new ArrayList<>();
 		//清除案卷封面等pdf
 		List<String> archivesOutUrlList = baseMapper.getArchivesOutUrlList(projectId);
@@ -289,16 +289,20 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 	}
 
 	@Override
-	public void archiveAutoMethod(Long projectId){
+	public void archiveAutoMethod(Long projectId,Long contractId,Long nodeId){
 		//步骤一:把档号集合初始化
 		indexMap = new HashMap<>();
 		//步骤二:查询归档树节点。存在未归档文件的节点。
 		List<ArchiveTreeContract> list = archiveTreeContractClient.getHavedFileNodeByProjectID(projectId);
+
+		//按合同段过滤
+		List<ArchiveTreeContract> authlist = authFilter(list, contractId, nodeId);
+
 		//步骤三:遍历归档树节点整理出 默认规则节点,分类并卷节点,单独组卷节点 三个集合。
 		List<ArchiveTreeContract> list1= new ArrayList<>();
 		List<ArchiveTreeContract> list2= new ArrayList<>();
 		List<ArchiveTreeContract> list3= new ArrayList<>();
-		for(ArchiveTreeContract treeContract:list){
+		for(ArchiveTreeContract treeContract:authlist){
 			Integer archiveAutoType = treeContract.getArchiveAutoType();
 			switch (archiveAutoType){
 				case 1:
@@ -520,11 +524,53 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 
 		//立卷人 从节点规格获取
 		String rollor = node.getRollor();
-		archivesAuto.setRollor(node.getRollor());
+		if(StringUtils.isEmpty(rollor)){
+			//节点没有值,就从合同段获取,没有合同段id的 用业主的合同段
+			Long nodeContractId = archivesAuto.getContractId();
+			if(nodeContractId!=null){
+				if(nodeContract==null){
+					nodeContract = contractClient.getContractById(nodeContractId);
+				}
+				rollor = nodeContract.getFiler();
+			}else{
+				List<Long> pids= new ArrayList<>();
+				pids.add(archivesAuto.getProjectId());
+				if(contracts==null){
+					contracts = contractClient.queryContractListByIds(pids);
+				}
+				for(ContractInfo c:contracts){
+					if(c.getContractType()==3){
+						rollor = c.getFiler();;
+					}
+				}
+			}
+		}
+		archivesAuto.setRollor(rollor);
 
 		//审核人 从节点规格获取
 		String reviewer = node.getReviewer();
-		archivesAuto.setReviewer(node.getReviewer());
+		if(StringUtils.isEmpty(reviewer)){
+			//节点没有值,就从合同段获取,没有合同段id的 用业主的合同段
+			Long nodeContractId = archivesAuto.getContractId();
+			if(nodeContractId!=null){
+				if(nodeContract==null){
+					nodeContract = contractClient.getContractById(nodeContractId);
+				}
+				reviewer = nodeContract.getReviewer();
+			}else{
+				List<Long> pids= new ArrayList<>();
+				pids.add(archivesAuto.getProjectId());
+				if(contracts==null){
+					contracts = contractClient.queryContractListByIds(pids);
+				}
+				for(ContractInfo c:contracts){
+					if(c.getContractType()==3){
+						reviewer = c.getReviewer();
+					}
+				}
+			}
+		}
+		archivesAuto.setReviewer(reviewer);
 
 		//载体类型
 		if (node.getStorageType()!= null){
@@ -534,7 +580,10 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		//archivesAuto.setStorageLocation();//存放位置
 		archivesAuto.setIsArchive(1);//已归档
 		//archivesAuto.setRemark();//备注
-		archivesAuto.setRollDate(LocalDateTime.now());//立卷日期
+		LocalDateTime now = LocalDateTime.now();
+		LocalDateTime nextday = now.plusDays(1);
+		archivesAuto.setRollDate(now);//立卷日期
+		archivesAuto.setReviewDate(nextday);//审核日期
 
 		archivesAuto.setNodeId(node.getId());//归档树节点
 		archivesAuto.setOutUrl("");//TODO 生成案卷的封面 目录 备考表,背级
@@ -1163,7 +1212,7 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 					}
 				}
 
-				String fileNumber = fileNumberPrefix + index;
+				String fileNumber = fileNumberPrefix +"_"+ index;
 				if (archiveAutoPdfService.refreshFileNumber(archivesAuto,fileNumber)){
 					changeList.add(archivesAuto);
 				}

+ 4 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/utils/FileUtils.java

@@ -433,6 +433,10 @@ public class FileUtils {
             for(String url:uris) {
                 try {
                     //todo 匿名访问特性
+                    if(StringUtils.isEmpty(url)){
+                        result.add("");
+                        continue;
+                    }
 
                     String fileNameWithExtension = url.substring(url.lastIndexOf("/") + 1); // 获取带有扩展名的文件名
 

+ 18 - 9
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1443,7 +1443,7 @@ public class InformationWriteQueryController extends BladeController {
                     }
                 });
             }
-
+            needCopyNode.setNodeName(vo.getNeedCopyNodeName());
             //复制保存节点、表信息
             R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 32, needCopyNode);
 
@@ -1636,8 +1636,15 @@ public class InformationWriteQueryController extends BladeController {
                         //更新redis缓存
                         informationQueryService.delAsyncWbsTree(contractId);
                     }
-
-                    return R.success("操作成功");
+                    StringBuilder addNames = new StringBuilder();
+                    addNames.append("[");
+                    for (WbsTreeContract node : toCopyNodes) {
+                        addNames.append(node.getNodeName()+"-");
+                    }
+                    String substring = addNames.substring(0, addNames.length() - 1);
+                    needCopyNodeRoot.setNodeName(substring+"]");
+//                    return R.success("操作成功");
+                    return this.saveOrCopyNodeTree(addNodeList, null, 32, needCopyNodeRoot);
                 } else {
                     throw new ServiceException("没有找到需要复制的节点信息,请联系管理员");
                 }
@@ -1716,7 +1723,9 @@ public class InformationWriteQueryController extends BladeController {
             }
 
             if (resultFileData.size() > 0) {
-                //入库
+                //先删除,在入库
+                List<String> tabIds = resultFileData.stream().map(TableFile::getTabId).distinct().collect(Collectors.toList());
+                jdbcTemplate.execute("delete from m_table_file WHERE tab_id in(" + StringUtils.join(tabIds, ",") + ")");
                 if (tableFileClient.saveBatch(resultFileData) && updatePKeyIds.size() > 0) {
                     //修改表的文件按钮状态
                     wbsTreeContractClient.updateTabFileTypeByPkeyIds(new ArrayList<>(updatePKeyIds));
@@ -2751,7 +2760,7 @@ public class InformationWriteQueryController extends BladeController {
                 }
             });
         }
-
+        treeContract.setNodeName(vo.getAllSelectedList().get(0).getNodeName());
         R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 2, treeContract);
 
         //更新redis
@@ -2807,8 +2816,8 @@ public class InformationWriteQueryController extends BladeController {
                     operationType, WbsTreeContract currentNode) {
 
         if (saveList.size() > 0) {
-            StringBuilder str = new StringBuilder();
-            str.append("-" + saveList.get(0).getFullName());
+//            StringBuilder str = new StringBuilder();
+//            str.append("-" + saveList.get(0).getFullName());
             //保存施工日志
             /*if (saveLedger.size() > 0) {
                 this.constructionLedgerService.saveBatch(saveLedger, 1000);
@@ -2826,11 +2835,11 @@ public class InformationWriteQueryController extends BladeController {
                 result.add(currentNode);
                 this.queryParentNode(currentNode, result);
                 StringBuilder pathName = new StringBuilder();
-                for (int i = 1, l = result.size(); i <= l; i++) {
+                for (int i = 1, l = result.size(); i < l; i++) {
                     WbsTreeContract node = result.get(result.size() - i);
                     pathName.append("-").append(StringUtils.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
                 }
-                pathName.append(str);
+                pathName.append("-"+currentNode.getNodeName());
                 JSONObject json = new JSONObject();
                 json.put("operationObjIds", JSONArray.parseArray(JSONObject.toJSONString(saveList.stream().map(WbsTreeContract::getPKeyId).distinct().collect(Collectors.toList())), String.class));
                 json.put("operationObjName", pathName.substring(1));

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -619,6 +619,7 @@ public class ExcelTabController extends BladeController {
             return R.fail("暂无表单!");
         }
         File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
+//        File file1 = ResourceUtil.getFile("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1578963584895942656.html");
         FileInputStream fileInputStream = new FileInputStream(file1);
 
         String htmlString = IoUtil.readToString(fileInputStream);
@@ -1659,9 +1660,7 @@ public class ExcelTabController extends BladeController {
         for (int i = 1; i < dataArray.size(); i++) {
             JSONObject jsonObject = dataArray.getJSONObject(i);
             pkeyIds += "," + jsonObject.getString("pkeyId");
-            ;
             groupIds += "," + jsonObject.getString("tabGroupId");
-            ;
         }
         /*全加载,或者可以优化成依赖加载*/
         List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
@@ -3042,6 +3041,7 @@ public class ExcelTabController extends BladeController {
         }
 
         File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
+//        File file1 = ResourceUtil.getFile("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1578963584895942656.html");
         FileInputStream fileInputStream = new FileInputStream(file1);
         String htmlString = IoUtil.readToString(fileInputStream);
         // 解析 style

+ 6 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeController.java

@@ -218,8 +218,12 @@ public class WbsTreeController extends BladeController {
                             .select(WbsTreePrivate::getPKeyId).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 2).eq(WbsTreePrivate::getId, id)).stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
                     List<Long> contractPKeyIds = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
                             .select(WbsTreeContract::getPKeyId).eq(WbsTreeContract::getStatus, 1).eq(WbsTreeContract::getType, 2).and(obj -> obj.eq(WbsTreeContract::getId, id).or().eq(WbsTreeContract::getOldId, id))).stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
-                    jdbcTemplate.execute("update m_wbs_tree_private set is_deleted = 1 where p_key_id in(" + StringUtils.join(projectPKeyIds, ",") + ")");
-                    jdbcTemplate.execute("update m_wbs_tree_contract set is_deleted = 1 where p_key_id in(" + StringUtils.join(contractPKeyIds, ",") + ")");
+                    if (projectPKeyIds.size()>0){
+                        jdbcTemplate.execute("update m_wbs_tree_private set is_deleted = 1 where p_key_id in(" + StringUtils.join(projectPKeyIds, ",") + ")");
+                    }
+                    if (contractPKeyIds.size()>0){
+                        jdbcTemplate.execute("update m_wbs_tree_contract set is_deleted = 1 where p_key_id in(" + StringUtils.join(contractPKeyIds, ",") + ")");
+                    }
 
                     return R.success("删除成功");
                 }

+ 13 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/SaveUserInfoByProjectClientImpl.java

@@ -55,11 +55,19 @@ public class SaveUserInfoByProjectClientImpl implements SaveUserInfoByProjectCli
         obj.setRoleId(String.valueOf(roleId));
         obj.setStatus(1);
 
-        saveUserInfoByProjectService.remove(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
-                        .eq(SaveUserInfoByProjectDTO::getUserId, userId)
-                        .eq(SaveUserInfoByProjectDTO::getRoleId, roleId)
-                        .eq(SaveUserInfoByProjectDTO::getContractId, contractId));
-        saveUserInfoByProjectService.save(obj);
+        List<SaveUserInfoByProjectDTO> saveUserInfozList = saveUserInfoByProjectService.getBaseMapper().selectList(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
+                .eq(SaveUserInfoByProjectDTO::getUserId, userId)
+                .isNull(SaveUserInfoByProjectDTO::getPostId)
+                .eq(SaveUserInfoByProjectDTO::getContractId, contractId));
+
+        if(saveUserInfozList ==null && saveUserInfozList.size()==0){
+            saveUserInfoByProjectService.getBaseMapper().delete(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
+                    .eq(SaveUserInfoByProjectDTO::getUserId, userId)
+                    .isNull(SaveUserInfoByProjectDTO::getPostId)
+                    .eq(SaveUserInfoByProjectDTO::getContractId, contractId));
+            saveUserInfoByProjectService.save(obj);
+        }
+
     }
 
 

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/TableFileClientImpl.java

@@ -39,6 +39,7 @@ public class TableFileClientImpl implements TableFileClient {
     public List<TableFile> getTabFilesByTabIds(String tabFileIds) {
         return tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>lambdaQuery()
                 .in(TableFile::getTabId, Func.toLongList(tabFileIds))
+                .ne(TableFile::getType,1) //排除源文件
                 .isNotNull(TableFile::getTabId)
         );
     }

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.xml

@@ -328,7 +328,7 @@
               AND ( is_archive = 0 OR is_archive IS NULL )
               AND node_id IS NOT NULL
         )
-        order by tree_sort asc
+        order by ancestors asc,tree_sort asc
     </select>
     <select id="getListByProjectId" resultType="org.springblade.manager.entity.ArchiveTreeContract">
         select id,project_id as projectId,parent_id as parentId,ancestors,node_name as nodeName,status,tree_code as treeCode, ext_type as extType,

+ 17 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -2,6 +2,7 @@ package org.springblade.manager.service.impl;
 
 import cn.hutool.core.date.StopWatch;
 import cn.hutool.log.StaticLog;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -309,6 +310,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     } else {
                         String dataVal = dataInfo2.getString(dataMap.get(k).get(0));
                         if (StringUtils.isNotEmpty(dataVal)) {
+                            if (dataVal.contains("Ljava")){
+                                Object o = dataInfo2.get(dataMap.get(k).get(0));
+                                dataVal = JSON.toJSONString(o).replace("\"","");
+                            }
                             dataMap2.put(k, dataVal + "_^_" + dataMap.get(k).get(0).split("__")[1]);
                         }
                     }
@@ -1240,7 +1245,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             tabPdf.delete();
         }
 
-        // 获取清表信息
+        //获取清表信息
         ExcelTab excelTab = this.getById(wbsTreeContract.getExcelId());
 
         if (excelTab == null) {
@@ -1249,7 +1254,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
         Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(pkeyId, 0).getData();
 
-        // 获取excel流 和 html流
+        //获取excel流 和 html流
         InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
         org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(exceInp);
 
@@ -1257,7 +1262,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         Sheet sheet = workbook.getSheetAt(0);
         sheet.setForceFormulaRecalculation(true);
 
-        // 标题添加
+        //标题添加
         ProjectInfo projectInfo = projectInfoService.getById(wbsTreeContract.getProjectId());
 
         int all = sheet.getRow(0).getLastCellNum();
@@ -1299,7 +1304,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             }
         }
 
-        // 数据不为空 &&
+        //数据不为空
         if (StringUtils.isNotEmpty(wbsTreeContract.getHtmlUrl())) {
             File htmlFile = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
             if (htmlFile.exists()) {
@@ -1488,11 +1493,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
         BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
 
+        //附件
         TableFile tableFile1 = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1)).stream().findAny().orElse(null);
         if (tableFile1 != null) {
             /*tableFile1.setDomainPdfUrl(bladeFile.getLink());
             tableFileService.saveOrUpdate(tableFile1);*/
-            tableFileService.update(Wrappers.<TableFile>lambdaUpdate().set(TableFile::getDomainPdfUrl,bladeFile.getLink()).eq(TableFile::getId,tableFile1.getId()));
+            tableFileService.update(Wrappers.<TableFile>lambdaUpdate().set(TableFile::getDomainPdfUrl, bladeFile.getLink()).eq(TableFile::getId, tableFile1.getId()));
         } else {
             TableFile tableFile = new TableFile();
             String fileExtension = FileUtil.getFileExtension(wbsTreeContract.getFullName() + ".pdf");
@@ -2299,12 +2305,14 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         FileOutputStream outputStream = new FileOutputStream(excelPath);
         workbook.write(outputStream);
         FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
-
         BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
-        TableFile tableFile1 = tableFileService.getBaseMapper().selectOne(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1).eq(TableFile::getTrialRecordId, id));
+
+        //附件
+        TableFile tableFile1 = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1)).stream().findAny().orElse(null);
         if (tableFile1 != null) {
-            tableFile1.setDomainPdfUrl(bladeFile.getLink());
-            tableFileService.saveOrUpdate(tableFile1);
+            /*tableFile1.setDomainPdfUrl(bladeFile.getLink());
+            tableFileService.saveOrUpdate(tableFile1);*/
+            tableFileService.update(Wrappers.<TableFile>lambdaUpdate().set(TableFile::getDomainPdfUrl, bladeFile.getLink()).eq(TableFile::getId, tableFile1.getId()));
         } else {
             TableFile tableFile = new TableFile();
             String fileExtension = FileUtil.getFileExtension(wbsTreePrivate.getFullName() + ".pdf");

+ 65 - 63
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -894,26 +894,26 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
 
     @Override
     public R<String> syncPrivateProjectFormula(Long projectId, Long pKeyId) {
-        if(projectId!=null&&pKeyId!=null){
+        if (projectId != null && pKeyId != null) {
             ProjectInfo projectInfo = projectInfoMapper.selectById(projectId);
-            ProjectInfo sourceProject=jdbcTemplate.queryForObject("select a.* from m_project_info a join m_wbs_tree_private b on a.id=b.project_id where b.p_key_id="+projectInfo.getReferenceWbsTemplateId()+" limit 1",new BeanPropertyRowMapper<>(ProjectInfo.class));
+            ProjectInfo sourceProject = jdbcTemplate.queryForObject("select a.* from m_project_info a join m_wbs_tree_private b on a.id=b.project_id where b.p_key_id=" + projectInfo.getReferenceWbsTemplateId() + " limit 1", new BeanPropertyRowMapper<>(ProjectInfo.class));
             /*只需要同步私有引用就可以了*/
-            if("private".equals(projectInfo.getReferenceWbsTemplateType())&&sourceProject!=null){
+            if ("private".equals(projectInfo.getReferenceWbsTemplateType()) && sourceProject != null) {
                 WbsTreePrivate selectNodeNow = baseMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pKeyId).eq(WbsTreePrivate::getStatus, 1));
                 if (selectNodeNow == null) {
                     throw new ServiceException("未获取到当前选择同步的节点信息,请联系管理员");
                 }
-                List<ElementFormulaMapping> insertList=new ArrayList<>();
-                List<Formula> insertFormulaList=new ArrayList<>();
-                List<Formula> updateFormulaList=new ArrayList<>();
+                List<ElementFormulaMapping> insertList = new ArrayList<>();
+                List<Formula> insertFormulaList = new ArrayList<>();
+                List<Formula> updateFormulaList = new ArrayList<>();
                 /*同步公共部分*/
-                global(sourceProject.getId(),projectInfo,insertList,insertFormulaList,updateFormulaList);
+                global(sourceProject.getId(), projectInfo, insertList, insertFormulaList, updateFormulaList);
                 /*同步节点部分,查找模版的叶子节点,查找目标叶子节点,id一样的是关联数据  */
-                part(sourceProject.getId(),projectInfo,insertList,insertFormulaList,updateFormulaList);
+                part(sourceProject.getId(), projectInfo, insertList, insertFormulaList, updateFormulaList);
                 /*保存记录*/
-                int n=saveAll(insertList,insertFormulaList,updateFormulaList);
-                if(n>0){
-                    R.success("成功同步"+n+"条公式");
+                int n = saveAll(insertList, insertFormulaList, updateFormulaList);
+                if (n > 0) {
+                    R.success("成功同步" + n + "条公式");
                 }
             }
             return R.success("引用公有模版无需同步");
@@ -921,73 +921,75 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         return R.fail("同步异常,请联系管理员");
     }
 
-    private int saveAll(List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList){
-        int n=0;
-        if(!insertList.isEmpty()) {
-            this.elementFormulaMappingService.saveBatch(insertList,1000);
+    private int saveAll(List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList) {
+        int n = 0;
+        if (!insertList.isEmpty()) {
+            this.elementFormulaMappingService.saveBatch(insertList, 1000);
         }
-        if(!insertFormulaList.isEmpty()) {
-            this.formulaService.saveBatch(insertFormulaList,1000);
-            n+=insertList.size();
+        if (!insertFormulaList.isEmpty()) {
+            this.formulaService.saveBatch(insertFormulaList, 1000);
+            n += insertList.size();
         }
-        if(!updateFormulaList.isEmpty()) {
-            this.formulaService.updateBatchById(updateFormulaList,1000);
-            n+=updateFormulaList.size();
+        if (!updateFormulaList.isEmpty()) {
+            this.formulaService.updateBatchById(updateFormulaList, 1000);
+            n += updateFormulaList.size();
         }
         return n;
     }
 
-    private void global(Long srcProjectId,ProjectInfo distProject,List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList){
-        this.check( srcProjectId, distProject, insertList,  insertFormulaList,  updateFormulaList,FormulaBean.PRO_GLOBAL);
+    private void global(Long srcProjectId, ProjectInfo distProject, List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList) {
+        this.check(srcProjectId, distProject, insertList, insertFormulaList, updateFormulaList, FormulaBean.PRO_GLOBAL);
     }
-    private void part(Long srcProjectId,ProjectInfo distProject,List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList){
-        this.check( srcProjectId, distProject, insertList,  insertFormulaList,  updateFormulaList,FormulaBean.PRO_PART);
+
+    private void part(Long srcProjectId, ProjectInfo distProject, List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList) {
+        this.check(srcProjectId, distProject, insertList, insertFormulaList, updateFormulaList, FormulaBean.PRO_PART);
     }
-    private void check(Long srcProjectId,ProjectInfo distProject,List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList,int model){
-        Map<String,ElementFormulaMapping> efmListScopeMap=new HashMap<>();
-        Map<String,ElementFormulaMapping> sourceEfmListScopeMap=new HashMap<>();
-        Map<Long,Formula> formulaScopeMap = new HashMap<>();
-        Map<Long,Formula> sourceFormulaScopeMap = new HashMap<>();
-        List<ElementFormulaMapping> efmListScope=this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId,distProject.getId()).eq(ElementFormulaMapping::getScope, model));
-        if(!efmListScope.isEmpty()){
+
+    private void check(Long srcProjectId, ProjectInfo distProject, List<ElementFormulaMapping> insertList, List<Formula> insertFormulaList, List<Formula> updateFormulaList, int model) {
+        Map<String, ElementFormulaMapping> efmListScopeMap = new HashMap<>();
+        Map<String, ElementFormulaMapping> sourceEfmListScopeMap = new HashMap<>();
+        Map<Long, Formula> formulaScopeMap = new HashMap<>();
+        Map<Long, Formula> sourceFormulaScopeMap = new HashMap<>();
+        List<ElementFormulaMapping> efmListScope = this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId, distProject.getId()).eq(ElementFormulaMapping::getScope, model));
+        if (!efmListScope.isEmpty()) {
             formulaScopeMap = this.formulaService.listByIds(efmListScope.stream().map(ElementFormulaMapping::getFormulaId).collect(Collectors.toList())).stream().collect(Collectors.toMap(Formula::getId, f -> f));
         }
-        List<ElementFormulaMapping>sourceEfmListScope=this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId,srcProjectId).eq(ElementFormulaMapping::getScope, model));
-        if(!sourceEfmListScope.isEmpty()){
+        List<ElementFormulaMapping> sourceEfmListScope = this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().eq(ElementFormulaMapping::getProjectId, srcProjectId).eq(ElementFormulaMapping::getScope, model));
+        if (!sourceEfmListScope.isEmpty()) {
             sourceFormulaScopeMap = this.formulaService.listByIds(sourceEfmListScope.stream().map(ElementFormulaMapping::getFormulaId).collect(Collectors.toList())).stream().collect(Collectors.toMap(Formula::getId, f -> f));
         }
-        if(FormulaBean.PRO_PART.equals(model)) {
+        if (FormulaBean.PRO_PART.equals(model)) {
             efmListScopeMap = efmListScope.stream().collect(Collectors.toMap(e -> e.getElementId() + "" + e.getNodeId(), t -> t));
             sourceEfmListScopeMap = sourceEfmListScope.stream().collect(Collectors.toMap(e -> e.getElementId() + "" + e.getNodeId(), t -> t));
-        }else{
+        } else {
             efmListScopeMap = efmListScope.stream().collect(Collectors.toMap(e -> e.getElementId().toString(), t -> t));
             sourceEfmListScopeMap = sourceEfmListScope.stream().collect(Collectors.toMap(e -> e.getElementId().toString(), t -> t));
         }
-        String[] exclude= new String[]{"id"};
+        String[] exclude = new String[]{"id"};
         Map<String, ElementFormulaMapping> finalEfmListScopeMap = efmListScopeMap;
         Map<Long, Formula> finalSourceFormulaScopeMap = sourceFormulaScopeMap;
         Map<Long, Formula> finalFormulaScopeMap = formulaScopeMap;
-        sourceEfmListScopeMap.forEach((k, v)->{
-            if(!finalEfmListScopeMap.containsKey(k)){
+        sourceEfmListScopeMap.forEach((k, v) -> {
+            if (!finalEfmListScopeMap.containsKey(k)) {
                 /*不存在*/
                 ElementFormulaMapping target = new ElementFormulaMapping();
-                BeanUtils.copyProperties(v,target,exclude);
+                BeanUtils.copyProperties(v, target, exclude);
                 target.setWbsId(distProject.getReferenceWbsTemplateId());
                 target.setProjectId(distProject.getId());
                 insertList.add(target);
-                Formula sf= finalSourceFormulaScopeMap.get(v.getFormulaId());
-                Formula target2= new Formula();
-                BeanUtils.copyProperties(sf,target2);
-                Long id=SnowFlakeUtil.getId();
+                Formula sf = finalSourceFormulaScopeMap.get(v.getFormulaId());
+                Formula target2 = new Formula();
+                BeanUtils.copyProperties(sf, target2);
+                Long id = SnowFlakeUtil.getId();
                 target.setFormulaId(id);
                 target2.setId(id);
                 insertFormulaList.add(target2);
-            }else{
+            } else {
                 /*存在则比较,有差异则覆盖*/
-                Formula sf= finalSourceFormulaScopeMap.get(v.getFormulaId());
-                Formula tf= finalFormulaScopeMap.get(finalEfmListScopeMap.get(k).getFormulaId());
-                if(!tf.getFormula().equals(sf.getFormula())){
-                    BeanUtils.copyProperties(sf,tf,exclude);
+                Formula sf = finalSourceFormulaScopeMap.get(v.getFormulaId());
+                Formula tf = finalFormulaScopeMap.get(finalEfmListScopeMap.get(k).getFormulaId());
+                if (!tf.getFormula().equals(sf.getFormula())) {
+                    BeanUtils.copyProperties(sf, tf, exclude);
                     updateFormulaList.add(tf);
                 }
 
@@ -1964,23 +1966,23 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
 
         //获取公式颜色
         String tabName = wbsTreePrivate.getInitTableName();
-        //字段查询 获取公式字段
-        String colKeys = "SELECT e_key from m_wbs_tree a ,m_wbs_form_element b WHERE a.init_table_name = '" + tabName + "' and a.id=b.f_id and b.id  in(SELECT element_id from m_formula c where c.is_deleted=0) ";
+        //字段查询获取公式字段
+        String colKeys = "SELECT e_key from m_table_info a ,m_wbs_form_element b WHERE a.tab_en_name = '" + tabName + "' and a.id=b.f_id and b.id  in(SELECT element_id from m_element_formula_mapping c where c.is_deleted=0) ";
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(colKeys);
-        for (Map<String, Object> keys : maps) {
-            String key = keys.get("e_key") + "__";
-            Elements gsColor = doc.select("el-input[keyname~=^" + key + "]");
-            for (Element element : gsColor) {
-                //System.out.println(element.parent());
-                element.parent().attr("gscolor", "11");
-            }
-            Elements dateColor = doc.select("el-date-picker[keyname~=^" + key + "]");
-            for (Element element : dateColor) {
-                //System.out.println(element.parent());
-                element.parent().attr("gscolor", "11");
+        if (maps.size() > 0) {
+            for (Map<String, Object> keys : maps) {
+                String key = keys.get("e_key") + "__";
+                Elements gsColor = doc.select("el-input[keyname~=^" + key + "]");
+                for (Element element : gsColor) {
+                    element.parent().attr("gscolor", "11");
+                }
+
+                Elements dateColor = doc.select("el-date-picker[keyname~=^" + key + "]");
+                for (Element element : dateColor) {
+                    element.parent().attr("gscolor", "11");
+                }
             }
         }
-
         doc.select("Col").remove();
         fileInputStream.close();
         return R.data(table + "");

+ 1 - 1
blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

@@ -455,7 +455,7 @@ public class UserController {
             }
             //获取用户list
             HttpClient httpClient = HttpClientBuilder.create().build();
-            HttpPost httpPost = new HttpPost("http://localhost:8090/blade-auth/oauth/token");
+            HttpPost httpPost = new HttpPost("http://172.31.222.127:8090/blade-auth/oauth/token");
             httpPost.setHeader("Authorization", "Basic Y2xpZW50OmNsaWVudF9zZWNyZXQ="); //这个需要 client:
             httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
             httpPost.setHeader("Tenant-Id", "000000");