Browse Source

Merge remote-tracking branch 'origin/master' into master

yangyj 1 year ago
parent
commit
f40174fe9e

+ 3 - 1
blade-ops/blade-resource/src/main/java/org/springblade/resource/feign/CommonFileClientImpl.java

@@ -12,6 +12,7 @@ import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tenant.annotation.NonDS;
+import org.springblade.core.tool.utils.FileUtil;
 import org.springblade.core.tool.utils.IoUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.resource.builder.oss.OssBuilder;
@@ -56,8 +57,9 @@ public class CommonFileClientImpl implements CommonFileClient {
             document.close();
 
             //上传文件
+            String fileExtension =  "."+FileUtil.getFileExtension(file.getOriginalFilename());
             pdfInput = new ByteArrayInputStream(bos.toByteArray());
-            String originalFilename = Objects.requireNonNull(file.getOriginalFilename()).replaceAll(".png", ".pdf").replaceAll(".jpg", ".pdf");
+            String originalFilename = Objects.requireNonNull(file.getOriginalFilename()).replaceAll(fileExtension, ".pdf");
 
             BladeFile bladeFile = this.ossBuilder.template().putFile(originalFilename, pdfInput);
             pdfFileUrl = bladeFile.getLink();

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java

@@ -61,6 +61,9 @@ public interface InformationQueryClient {
     @PostMapping(API_PREFIX + "/informationQuerySaveData")
     void saveData(@RequestParam String id, @RequestParam String projectId, @RequestParam String contractId, @RequestParam String classify, @RequestParam String link, @RequestParam String trialProjectName);
 
+    @PostMapping(API_PREFIX + "/informationQuerySaveInfo")
+    void saveInfo(@RequestBody InformationQuery info);
+
     @PostMapping(API_PREFIX + "/updateInformationQuery")
     void updateInformationQuery(@RequestParam String link, @RequestParam String classify, @RequestParam String nodeId, @RequestParam String contractId);
 

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java

@@ -71,6 +71,11 @@ public class InformationQueryClientImpl implements InformationQueryClient {
         iInformationQueryService.save(obj);
     }
 
+    @Override
+    public void saveInfo(InformationQuery info) {
+        iInformationQueryService.save(info);
+    }
+
     @Override
     public void updateInformationQuery(String link, String classify, String nodeId, String contractId) {
         LambdaUpdateWrapper<InformationQuery> updateWrapper = new LambdaUpdateWrapper<>();

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

@@ -16,7 +16,6 @@ import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import org.apache.commons.codec.Charsets;
-import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -25,6 +24,7 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springblade.business.entity.ContractLog;
+import org.springblade.business.entity.InformationQuery;
 import org.springblade.business.feign.ContractLogClient;
 import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.business.vo.SaveContractLogVO;
@@ -74,6 +74,7 @@ import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.*;
 import java.util.regex.Matcher;
@@ -301,9 +302,9 @@ public class ExcelTabController extends BladeController {
         String filecode = SnowFlakeUtil.getId() + "";
         String thmlUrl = file_path + filecode + ".html";
         String exceUrl = file_path + filecode + "123.xlsx";
-        ExcelInfoUtils.excelInfo(file.getInputStream(),exceUrl,thmlUrl,"1");
+        ExcelInfoUtils.excelInfo(file.getInputStream(), exceUrl, thmlUrl, "1");
         // 上传excel文件
-         BladeFile bladeFile = newIOSSClient.uploadFile(file.getOriginalFilename(),exceUrl);
+        BladeFile bladeFile = newIOSSClient.uploadFile(file.getOriginalFilename(), exceUrl);
         // 解析原始excel
 
         BladeFile bladeFileR = newIOSSClient.uploadFileByInputStream(file);
@@ -1912,7 +1913,7 @@ public class ExcelTabController extends BladeController {
         R<BladeFile> bladeFile = iossClient.addFileInfo(file);
         BladeFile bladeFile1 = bladeFile.getData();
         TableFile tableFile = new TableFile();
-        String fileExtension = FileUtil.getFileExtension(bladeFile1.getName());
+        String fileExtension = FileUtil.getFileExtension(bladeFile1.getName()).toLowerCase();
         tableFile.setTabId(pkeyId + "");
         tableFile.setName(file.getOriginalFilename());
         tableFile.setType(2);
@@ -1931,7 +1932,8 @@ public class ExcelTabController extends BladeController {
         } else if (fileExtension.contains("docx")) {
             newBladeFile = this.commonFileClient.wordToPdf(file);
             tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
-        } else if (fileExtension.contains("png") || file.getOriginalFilename().contains("jpg")) {
+        } else if (fileExtension.contains("png") || fileExtension.contains("jpg") || fileExtension.contains("webp") || fileExtension.contains("apng") ||
+                fileExtension.contains("bmp") || fileExtension.contains("jepg") || fileExtension.contains("tif") || fileExtension.contains("gif")) {
             newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
             tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
         } else if (fileExtension.contains("pdf")) {
@@ -1950,7 +1952,21 @@ public class ExcelTabController extends BladeController {
         updateWrapper.set("is_tab_pdf", 2);
         wbsTreeContractService.update(updateWrapper);
         // 合并后
-
+        //如果上传文件前没有保存过,则直接生成一条基础数据
+        String sql = "select pdf_url,e_visa_pdf_url,pdf_trial_url,pdf_trial_url_position,status from u_information_query where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'";
+        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
+        if (maps == null || maps.size() == 0) {
+            WbsTreeContract contract = wbsTreeContractService.getById(pkeyId);
+            InformationQuery query = new InformationQuery();
+            query.setId(SnowFlakeUtil.getId());
+            query.setWbsId(Long.parseLong(nodeId));
+            query.setContractId(Long.parseLong(contractId));
+            query.setProjectId(Long.parseLong(projectId));
+            query.setClassify(Integer.parseInt(classify));
+            query.setCategory(contract.getNodeType());
+            query.setType((contract.getIsExpernode() == null || contract.getIsExpernode() <= 0) ? 1 : 2);
+            informationQueryClient.saveInfo(query);
+        }
         excelTabService.getBussPdfs(nodeId, classify, contractId, projectId);
 
         return R.data(tableFile.getId());
@@ -1964,7 +1980,7 @@ public class ExcelTabController extends BladeController {
             @ApiImplicitParam(name = "status", value = "状态(1显示 2隐藏)", required = true)
     })
     @Transactional
-    public R showBussTab(Long pkeyId, int status,String nodeId,String classify) throws Exception {
+    public R showBussTab(Long pkeyId, int status, String nodeId, String classify) throws Exception {
         WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
                 .eq(WbsTreeContract::getPKeyId, pkeyId));
         UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
@@ -2083,35 +2099,36 @@ public class ExcelTabController extends BladeController {
     @PostMapping("/save_buss_data")
     @ApiOperationSupport(order = 13)
     @ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存")
-    public R<String> saveBussData(@Valid @RequestBody JSONObject dataInfo, BladeUser bladeUser) throws Exception {
+    public R saveBussData(@Valid @RequestBody JSONObject dataInfo) throws Exception {
         JSONArray dataArray = new JSONArray();
-        if (dataInfo.containsKey("dataInfo")) { // 节点保存
+        if (dataInfo.containsKey("dataInfo")) { //节点保存
             JSONObject jsonObject = dataInfo.getJSONObject("dataInfo");
             dataArray = jsonObject.getJSONArray("orderList");
-        } else { // 单个保存
+        } else { //单个保存
             dataArray.add(dataInfo);
         }
 
         JSONObject tableInfo1 = dataArray.getJSONObject(0);
-        String nodeid = tableInfo1.getString("nodeId");
+        String nodeId = tableInfo1.getString("nodeId");
         String contractId = tableInfo1.getString("contractId");
         String projectId = tableInfo1.getString("projectId");
         String classify = tableInfo1.getString("classify");
-        String groupId = tableInfo1.getString("tabGroupId");
-        String pkeyId = tableInfo1.getString("pkeyId");
 
-        //
+        /*String groupId = tableInfo1.getString("tabGroupId");
+        String pkeyId = tableInfo1.getString("pkeyId");
         String pkeyIds = pkeyId;
         String groupIds = groupId;
         for (int i = 1; i < dataArray.size(); i++) {
             JSONObject jsonObject = dataArray.getJSONObject(i);
             pkeyIds += "," + jsonObject.getString("pkeyId");
             groupIds += "," + jsonObject.getString("tabGroupId");
-        }
+        }*/
+
         /*全加载,或者可以优化成依赖加载*/
+        List<AppWbsTreeContractVO> tableAll = new ArrayList<>();
         List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
         if (tableInfoList != null) {
-            List<AppWbsTreeContractVO> tableAll = wbsTreeContractService.searchNodeAllTable(nodeid, "1", contractId, projectId);
+            tableAll = wbsTreeContractService.searchNodeAllTable(nodeId, "1", contractId, projectId);
             List<Long> tableAllIds = tableAll.stream().map(AppWbsTreeContractVO::getPKeyId).collect(Collectors.toList());
             if (tableAll.size() > tableInfoList.size()) {
                 List<Long> exclude = tableInfoList.stream().map(TableInfo::getPkeyId).map(Long::parseLong).collect(Collectors.toList());
@@ -2121,7 +2138,7 @@ public class ExcelTabController extends BladeController {
                         R bussDataInfo = this.excelTabService.getBussDataInfo(pk, 1);
                         @SuppressWarnings("unchecked")
                         Map<String, Object> jo = (Map<String, Object>) bussDataInfo.getData();
-                        if(jo!=null && ObjectUtils.isNotEmpty(jo)){
+                        if (jo != null && ObjectUtils.isNotEmpty(jo)) {
                             jo.put("pkeyId", pk);
                             extra.add(jo);
                         }
@@ -2143,27 +2160,48 @@ public class ExcelTabController extends BladeController {
                 tableInfoList.sort(Comparator.comparingInt(a -> tableAllIds.indexOf(Long.parseLong(a.getPkeyId()))));
             }
         }
+
         //公式填充
-        this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeid), ExecuteType.INSPECTION);
-        // 保存数据到数据库
-        R info = this.excelTabService.saveOrUpdateInfo(tableInfoList);
-        if (!info.isSuccess()) {
-            return info;
+        this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId), ExecuteType.INSPECTION);
+
+        //保存数据到数据库
+        R<Object> result = this.excelTabService.saveOrUpdateInfo(tableInfoList);
+        if (!result.isSuccess()) {
+            return R.fail("以下的表在保存数据时发生了异常【" + result.getMsg() + "】");
         }
-        try {
-            //单个 pdf加载
-            if (tableInfoList != null) {
-                for (TableInfo tableInfo : tableInfoList) {
-                    excelTabService.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
+
+        List<String> errorPKeyIds = new ArrayList<>();
+        //单个pdf加载
+        if (tableInfoList != null) {
+            for (TableInfo tableInfo : tableInfoList) {
+                R bussPdfInfo = excelTabService.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
+                if (ObjectUtil.isEmpty(bussPdfInfo) || bussPdfInfo.getCode() != 200 || ObjectUtil.isEmpty(bussPdfInfo.getData())) {
+                    //如果返回的单张pdfUrl为空,那么表示发生异常,返回异常信息
+                    errorPKeyIds.add(tableInfo.getPkeyId());
                 }
             }
-            // 合并pdf加载
-            excelTabService.getBussPdfs(nodeid, classify, contractId, projectId);
-        } catch (Exception e) {
-            e.printStackTrace();
         }
+
+        //发生异常后直接返回,不进行合并
+        if (errorPKeyIds.size() > 0) {
+            List<AppWbsTreeContractVO> errorTabs = new LinkedList<>();
+            for (AppWbsTreeContractVO appWbsTreeContractVO : tableAll) {
+                if (errorPKeyIds.contains(appWbsTreeContractVO.getPKeyId().toString())){
+                    errorTabs.add(appWbsTreeContractVO);
+                }
+            }
+            if (errorTabs.size() > 0) {
+                List<String> names = errorTabs.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
+                return R.fail("以下的表在生成pdf文件时发生了异常【" + StringUtils.join(names, "、") + "】");
+            }
+        }
+
+        //合并pdf加载
+        excelTabService.getBussPdfs(nodeId, classify, contractId, projectId);
+
         //更新缓存
         informationQueryClient.delAsyncWbsTree(contractId);
+
         return R.data("操作成功");
     }
 
@@ -2328,16 +2366,19 @@ public class ExcelTabController extends BladeController {
                                                 x1 = 1;
                                             }
                                             String myData = dataMap.get(val) + "";
-                                            if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
+                                            if ((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0)) {
+                                                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+                                                sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
+                                                SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
                                                 if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
-                                                    myData = myData.replace("[", "").replace("]", "");
-                                                    String[] dataVal = myData.split(",");
-                                                    String[] Start_dataStr = dataVal[0].split("T")[0].split("-");
-                                                    String StartDate = StringUtil.format("{}年{}月{}日", Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1);
 
-                                                    String[] end_dataStr = dataVal[1].split("T")[0].split("-");
-                                                    String endDate = StringUtil.format("{}年{}月{}日", end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1);
+                                                    myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
+                                                    String[] dataVal = myData.split(",");
 
+                                                    Date Start_dataStr = sdf.parse(dataVal[0]);
+                                                    Date end_dataStr = sdf.parse(dataVal[1]);
+                                                    String StartDate = formatStr.format(Start_dataStr);
+                                                    String endDate = formatStr.format(end_dataStr);
                                                     if (StartDate.equals(endDate)) {
                                                         myData = StartDate;
                                                     } else {
@@ -2345,7 +2386,9 @@ public class ExcelTabController extends BladeController {
                                                     }
                                                 } else {
                                                     String[] dataStr = myData.split("T")[0].split("-");
-                                                    myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
+                                                    if (dataStr.length == 3) {
+                                                        myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
+                                                    }
                                                 }
                                             }
 
@@ -2364,6 +2407,11 @@ public class ExcelTabController extends BladeController {
                                                 pic.setHeight(Height);
                                                 sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
 
+                                            } else if (myData.equals("1") && data.html().indexOf("hc-form-checkbox-group") >= 0) {
+                                                CellRange cell = sheet.getCellRange(y1, x1);
+                                                String exceVal = cell.getText().replaceAll(" ", "");
+                                                cell.getCellStyle().getExcelFont().setFontName("EUDC");
+                                                cell.setText(exceVal.replace("□", "\u2611"));
                                             } else {
                                                 final CellRange cellRange = sheet.getCellRange(y1, x1);
                                                 cellRange.setText(myData);

+ 22 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java

@@ -325,25 +325,41 @@ public class FormulaController {
                 }
             }
             String[] dw2 = keymap.get(info.getKey()).split(StringPool.SEMICOLON);
-            // 排序
-            String dw[] = new String[dw2.length];
+            //排序
+            String[] dw = new String[dw2.length];
             int start=0;
             List<String> list = Arrays.asList(dw2);
-            // 横向排序
+            //横向排序
             int yindex;
             int xindex;
             if(info.getDirection().equals("2")){ //纵向
                 yindex = 1;
                 xindex = 0;
-            } else { //横向
+            } else {//横向
                 xindex = 1;
                 yindex = 0;
             }
-            Map<Integer, List<String>> collect = list.stream().filter(s -> s.indexOf("_")>=0).collect(Collectors.groupingBy(s -> Integer.parseInt(s.split("_")[yindex])));
+
+            //Map<Integer, List<String>> collect = list.stream().filter(s -> s.contains("_")).collect(Collectors.groupingBy(s -> Integer.parseInt(s.split("_")[yindex])));
+
+            //转为LinkedHashMap并保持List<String>顺序
+            Map<Integer, List<String>> collect = list.stream()
+                    .filter(s -> s.contains("_"))
+                    .collect(Collectors.toMap(
+                            s -> Integer.parseInt(s.split("_")[yindex]),
+                            Collections::singletonList,
+                            (obj1, obj2) -> {
+                                List<String> mergedList = new ArrayList<>(obj1);
+                                mergedList.addAll(obj2);
+                                return mergedList;
+                            },
+                            LinkedHashMap::new
+                    ));
+
             int j=0;
             for(Integer key: collect.keySet()){
                 List<String> datakey = collect.get(key);
-                List<String> ordList = datakey.stream().filter(s -> s.indexOf("_")>=0).sorted(Comparator.comparing(s -> Integer.parseInt(s.split("_")[xindex]))).collect(Collectors.toList());
+                List<String> ordList = datakey.stream().filter(s -> s.contains("_")).sorted(Comparator.comparing(s -> Integer.parseInt(s.split("_")[xindex]))).collect(Collectors.toList());
                 for (String ord:ordList){
                     dw[j]=ord;
                     j++;

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IExcelTabService.java

@@ -104,7 +104,7 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
     /**
      * 结果信息持久化
      */
-    R saveOrUpdateInfo(List<TableInfo> tableInfoList) throws SQLException;
+    R<Object> saveOrUpdateInfo(List<TableInfo> tableInfoList) throws SQLException;
 
     Map<String, String> getTablbCols(String pkeyid, String colkey) throws FileNotFoundException;
 

+ 48 - 50
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -335,7 +335,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         if (Func.isNotEmpty(tableInfoList)) {
             try {
                 /*用来保存日志执行情况*/
-                FormulaLog log =new FormulaLog();
+                FormulaLog log = new FormulaLog();
                 /*每次都是部分表单提交,保证跨节点跨表取数正常,其次是反向依赖的被动刷新*/
                 List<NodeTable> tableAll = createNodeTables(nodeId, tableInfoList.get(0).getContractId(), tableInfoList.get(0).getProjectId(), type);
                 StopWatch stopWatch = new StopWatch();
@@ -371,11 +371,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                             this.formulaService.execute(tec);
                             tec.after();
                         } else {
-                            tec.getLog().put(FormulaLog.OTHER,"没有执行任何公式");
+                            tec.getLog().put(FormulaLog.OTHER, "没有执行任何公式");
                         }
                         stopWatch.stop();
                         long totalTime = stopWatch.getTotalTimeMillis();
-                        log.put(FormulaLog.PF,"公式执行消耗时间:"+totalTime/1000+"秒");
+                        log.put(FormulaLog.PF, "公式执行消耗时间:" + totalTime / 1000 + "秒");
                         StaticLog.info("公式执行用时:{}", totalTime);
                         updateFormulaLog(log.toJsonString(), pKeyId);
                     }
@@ -491,13 +491,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             recordTime = DateUtil.format(new Date(), "yyyy-MM-dd");
         }
         // 为数据集
-        String businessIds = tableInfoList.stream().map(TableInfo::getBusinessId).filter(Objects::nonNull).collect(Collectors.joining(","));
+        String businessIds = tableInfoList.stream().map(TableInfo::getBusinessId).filter(ObjectUtils::isNotEmpty).collect(Collectors.joining(","));
         String ids = "";
         if (StringUtils.isEmpty(businessIds)) {
             //检查是否存在原本的数据
             List<ContractLog> contractLogs = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTimeList(parentNode.getPKeyId().toString(), recordTime, tableInfoList.get(0).getContractId());
             if (contractLogs.size() > 0) {
-                businessIds = contractLogs.stream().map(ContractLog::getDataId).map(String::valueOf).collect(Collectors.joining(","));
+                businessIds = contractLogs.stream().map(ContractLog::getDataId).filter(ObjectUtils::isNotEmpty).map(String::valueOf).collect(Collectors.joining(","));
                 ids = contractLogs.stream().map(ContractLog::getId).map(String::valueOf).collect(Collectors.joining(","));
             }
         } else {
@@ -955,8 +955,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     }
 
     @Override
-    public R saveOrUpdateInfo(List<TableInfo> tableInfoList) {
-
+    public R<Object> saveOrUpdateInfo(List<TableInfo> tableInfoList) {
         if (ListUtils.isNotEmpty(tableInfoList)) {
             //施工资料填报
             String pkids = "";
@@ -1359,10 +1358,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 .eq(WbsTreeContract::getPKeyId, pkeyId));
 
         if (wbsTreeContract == null) {
-            return R.fail("该数据下无此节点!");
+            return R.fail("未获取到该表单的信息");
         }
         if (wbsTreeContract.getHtmlUrl() == null) {
-            return R.fail("请关联清表!");
+            return R.fail("htmlUrl is null");
         }
 
         String pdfPath = file_path + "/pdf//" + pkeyId + ".pdf";
@@ -1376,7 +1375,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         //获取清表信息
         ExcelTab excelTab = this.getById(wbsTreeContract.getExcelId());
         if (excelTab == null) {
-            return R.fail("失败");
+            return R.fail("未获取到清表信息");
         }
 
         Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(pkeyId, 0).getData();
@@ -1403,8 +1402,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         for (int i = 0; i < 10; i++) {
             CellRangeAddress mergedCell = sheet.getMergedRegion(i);
             int xx = mergedCell.getNumberOfCells();
-            if(xx>=all){
-                all=xx;
+            if (xx >= all) {
+                all = xx;
             }
         }
 
@@ -1444,7 +1443,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             }
         }
 
-
         //数据不为空
         if (StringUtils.isNotEmpty(wbsTreeContract.getHtmlUrl())) {
             InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(wbsTreeContract.getHtmlUrl());
@@ -1453,7 +1451,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             Document doc = Jsoup.parse(htmlString);
             Element table = doc.select("table").first();
             Elements trs = table.select("tr");
-            Elements cols = table.select("col");
+            //Elements cols = table.select("col");
 
             if (ObjectUtil.isNotEmpty(DataInfo)) {
                 for (String val : DataInfo.keySet()) {
@@ -1508,9 +1506,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                 Object obj = DataInfo.get(val);
                                 if (obj instanceof String[]) {
                                     String[] dataDate = (String[]) obj;
-                                    if((dataDate[0].trim()).equals((dataDate[1].trim()))){
+                                    if ((dataDate[0].trim()).equals((dataDate[1].trim()))) {
                                         myData = dataDate[0];
-                                    }else{
+                                    } else {
                                         myData = dataDate[0] + "-" + dataDate[1].trim();
                                     }
 
@@ -1598,7 +1596,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             queryWrapper.eq("tab_id", wbsTreeContract.getIsTypePrivatePid());
             List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
 
-           // table.getElementsByAttribute("dq")
+            // table.getElementsByAttribute("dq")
 
             if (textdictInfos != null && !textdictInfos.isEmpty()) {
                 for (TextdictInfo e : textdictInfos) {
@@ -1648,8 +1646,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 }
             }
         }
-        //输出流
 
+        //输出流
         FileOutputStream outputStream = new FileOutputStream(excelPath);
         workbook.write(outputStream);
 
@@ -1683,12 +1681,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         tableFileList.sort(Comparator.comparing(TableFile::getType));
 
         List<String> dataListPdf = new ArrayList<>();
-        if(wbsTreeContract.getIsBussShow() == 1){
+        if (wbsTreeContract.getIsBussShow() == 1) {
             dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && (tableFile.getType() == 1 || tableFile.getType() == 2)).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
-        }else{
+        } else {
             dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && tableFile.getType() == 2).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
         }
-//        List<String> dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && (tableFile.getType() == 1 || tableFile.getType() == 2)).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
+        //List<String> dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && (tableFile.getType() == 1 || tableFile.getType() == 2)).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
 
         String pdfPath2 = file_path + "/pdf//" + pkeyId + "_2.pdf";
 
@@ -1696,7 +1694,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         if (tabPdf2.exists()) {
             tabPdf2.delete();
         }
-        String fileUrl ="";
+        String fileUrl = "";
         if (dataListPdf.size() > 0) {
             FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
             BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
@@ -1708,14 +1706,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         updateWrapper.set("pdf_url", fileUrl);
         wbsTreeContractService.update(updateWrapper);
 
-        if (outputStream != null) {
-            IoUtil.closeQuietly(outputStream);
-        }
-        if (exceInp != null) {
-            IoUtil.closeQuietly(exceInp);
-        }
-        return R.data(fileUrl);
+        //关闭流
+        IoUtil.closeQuietly(outputStream);
+        IoUtil.closeQuietly(exceInp);
 
+        return R.data(fileUrl);
     }
 
     @Override
@@ -1728,14 +1723,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             for (WbsTreeContract wbsInfo : wbsTreeContractList) {
                 // 隐藏的不生成pdf
 //                if (wbsInfo.getIsBussShow() == null || wbsInfo.getIsBussShow() != 2) { //
-                    if (StringUtils.isNotEmpty(wbsInfo.getPdfUrl())) {
-                        data.add(wbsInfo.getPdfUrl());
-                    } else {
-                        R bussPdfInfo = this.getBussPdfInfo(wbsInfo.getPKeyId());
-                        if (bussPdfInfo.getCode() == 200) {
+                if (StringUtils.isNotEmpty(wbsInfo.getPdfUrl())) {
+                    data.add(wbsInfo.getPdfUrl());
+                } else {
+                    R bussPdfInfo = this.getBussPdfInfo(wbsInfo.getPKeyId());
+                    if (bussPdfInfo.getCode() == 200) {
+                        if (StringUtils.isNotBlank(bussPdfInfo.getData()+"")) {
                             data.add(bussPdfInfo.getData() + "");
                         }
                     }
+                }
 //                }
             }
         }
@@ -1745,24 +1742,25 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         if (tabpdf2.exists()) {
             tabpdf2.delete();
         }
-
-        //资料填报原始pdf合并
-        FileUtils.mergePdfPublicMethods(data, listPdf);
-        BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
-
-        //获取当前填报节点sort
-        WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
-        System.out.println("wbsTreeContract==" + wbsTreeContract);
-        //获取顺序
-        int sort = 0;
-        if (ObjectUtil.isNotEmpty(wbsTreeContract)) {
-            if (wbsTreeContract.getSort() != null) {
-                sort = wbsTreeContract.getSort();
-                contractId = wbsTreeContract.getContractId();
+        if (data.size() >= 1) {
+            //资料填报原始pdf合并
+            FileUtils.mergePdfPublicMethods(data, listPdf);
+            BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
+
+            //获取当前填报节点sort
+            WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
+            System.out.println("wbsTreeContract==" + wbsTreeContract);
+            //获取顺序
+            int sort = 0;
+            if (ObjectUtil.isNotEmpty(wbsTreeContract)) {
+                if (wbsTreeContract.getSort() != null) {
+                    sort = wbsTreeContract.getSort();
+                    contractId = wbsTreeContract.getContractId();
+                }
             }
+            String sql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "' , sort = " + sort + " where classify='" + classify + "' and  wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
+            jdbcTemplate.execute(sql);
         }
-        String sql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "' , sort = " + sort + " where classify='" + classify + "' and  wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
-        jdbcTemplate.execute(sql);
     }
 
     @Override

+ 7 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -432,7 +432,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         //当前项目合同段只会存在一个角色roleId
         SaveUserInfoByProject userInfo = baseMapper.selectRoleInfo(userId, contractId, projectId);
         if (userInfo == null) {
-            throw new ServiceException("请先分配当前用户对该合同段的角色信息=" + SecureUtil.getUserId());
+            throw new ServiceException("请先分配当前用户对该合同段的角色信息");
         }
         String roleId = userInfo.getRoleId();
 
@@ -446,8 +446,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
 
         List<String> tableOwnerList = null;
         if (StringUtils.isNotEmpty(tableOwner)) {
-            String tableOwners = "";
-            //此处加载字典owner_type 固定写死 施工质检1= 1 2 3 , 监理抽检2= 4 5 6
+            String tableOwners;
+            //字典owner_type
             if (tableOwner.equals("1")) {
                 tableOwners = "1,2,3";
             } else if (tableOwner.equals("2")) {
@@ -457,10 +457,11 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
             }
             tableOwnerList = Func.toStrList(tableOwners);
         }
+
         List<AppWbsTreeContractVO> resultTabs = baseMapper.selectWbsTreeContractList(tableOwnerNumbers, wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(), wbsTreeContract.getContractId(), wbsTreeContract.getId(), wbsTreeContract.getContractIdRelation(), tableOwnerList);
 
         //表单排序
-        List<AppWbsTreeContractVO> resultTabsToCopy = sortTabs(resultTabs, "__");
+        List<AppWbsTreeContractVO> resultTabsToCopy = this.sortTabs(resultTabs, "__");
         return this.sortTabs(resultTabsToCopy, "_PL_");
     }
 
@@ -486,6 +487,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         if (tabsWithKeyword.isEmpty()) {
             return tabsWithoutKeyword;
         }
+        //对带有关键字的数据按照特定顺序排序
+        tabsWithKeyword.sort(Comparator.comparing(AppWbsTreeContractVO::getNodeName));
         //将带有关键字的数据插入到对应表名后面
         List<AppWbsTreeContractVO> sortedTabs = new ArrayList<>();
         for (AppWbsTreeContractVO tabWithoutKeyword : tabsWithoutKeyword) {