liuyc преди 2 години
родител
ревизия
61fdc89121

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/ExcelTabClient.java

@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_PREFIX;
 
-@FeignClient(value = APPLICATION_NAME_PREFIX + "manager")
+@FeignClient(value = APPLICATION_NAME_PREFIX + "manager", fallback = ExcelTabClientFallBack.class)
 public interface ExcelTabClient {
 
     /**

+ 28 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/ExcelTabClientFallBack.java

@@ -0,0 +1,28 @@
+package org.springblade.manager.feign;
+
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
+import org.springblade.manager.entity.ExcelTab;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ExcelTabClientFallBack implements ExcelTabClient {
+
+    @Override
+    public ExcelTab getById(String id) {
+        return null;
+    }
+
+    @Override
+    public String saveTabData(TrialSelfInspectionRecordDTO dto, Integer isBatchSave, Integer type, String tableType, Long id, String tabIds) throws RuntimeException {
+        throw new RuntimeException("试验数据保存失败,原因:ExcelTabClient#saveTabDataError...");
+    }
+
+    @Override
+    public void getBussPDFTrial(Long pkeyId, String contractId, String id) throws Exception {
+    }
+
+    @Override
+    public String getBussPDFSTrial(String nodeId, String tableType, String classify, String contractId, String projectId, String id, String tabIds) throws Exception {
+        return null;
+    }
+}

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -139,7 +139,7 @@ public class TrialDetectionController extends BladeController {
     @PostMapping("/self/submit")
     @ApiOperationSupport(order = 11)
     @ApiOperation(value = "自检记录新增或修改", notes = "传入TrialSelfInspectionRecordDTO")
-    public R<Object> selfSubmit(@Valid @RequestBody TrialSelfInspectionRecordDTO dto){
+    public R<Object> selfSubmit(@Valid @RequestBody TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
         return R.data(iTrialSelfInspectionRecordService.selfSubmit(dto));
     }
 

+ 1 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java

@@ -5,7 +5,6 @@ import org.springblade.business.dto.*;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.vo.*;
 import org.springblade.core.mp.base.BaseService;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.FileNotFoundException;
@@ -15,7 +14,7 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) throws FileNotFoundException;
 
-    String selfSubmit(TrialSelfInspectionRecordDTO dto);
+    String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException;
 
     List<TrialSampleInfoVO> selfSampleList(String id);
 

+ 14 - 30
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -873,7 +873,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String selfSubmit(TrialSelfInspectionRecordDTO dto) {
+    public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
         //------初始当前填报的表pKeyIds------
         this.initTrialTabIds(dto);
 
@@ -886,29 +886,21 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         if (ObjectUtil.isNotEmpty(dto.getId())) {
             //------获取最新试验记录------
             TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
-            try {
-                //------编辑时记录表编号或报告单编号为Null的重新生成------
-                this.reBuildNumber(obj, dto);
 
-                //------保存实体表数据、试验记录信息、生成PDF------
-                this.submitTrialData(obj, dto);
+            //------编辑时记录表编号或报告单编号为Null的重新生成------
+            this.reBuildNumber(obj, dto);
 
-                //------关联原材料检测报告------
-                this.rawMaterialSubmitRelation(dto, obj);
+            //------保存实体表数据、试验记录信息、生成PDF------
+            this.submitTrialData(obj, dto);
 
-                //------关联取样信息------
-                this.recordSampleSubmit(dto, obj);
+            //------关联原材料检测报告------
+            this.rawMaterialSubmitRelation(dto, obj);
 
-                //------关联新增设备使用记录信息------
-                this.trialDeviceUseService.addDeviceUseInfo(dto);
+            //------关联取样信息------
+            this.recordSampleSubmit(dto, obj);
 
-            } catch (RuntimeException e) {
-                e.printStackTrace();
-                throw new RuntimeException("保存实体表数据、试验记录信息、生成PDF失败:" + e.getMessage());
-            } catch (FileNotFoundException e) {
-                e.printStackTrace();
-                throw new RuntimeException("关联原材料检测报告失败:" + e.getMessage());
-            }
+            //------关联新增设备使用记录信息------
+            this.trialDeviceUseService.addDeviceUseInfo(dto);
         }
         return dto.getId().toString();
     }
@@ -944,17 +936,9 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     }
 
     public void submitTrialData(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) throws RuntimeException {
-        try {
-            String pdfURL = excelTabClient.saveTabData(dto, dto.getIsBatchSave(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
-            if (StringUtils.isNotEmpty(pdfURL)) {
-                this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
-            }
-        } catch (RuntimeException e) {
-            if (e.getMessage().contains("字段过长")) {
-                //字段过长,新增失败的异常处理
-                jdbcTemplate.execute("delete from u_trial_self_inspection_record where id = " + dto.getId());
-            }
-            throw new RuntimeException("原因:" + e.getMessage());
+        String pdfURL = excelTabClient.saveTabData(dto, dto.getIsBatchSave(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
+        if (StringUtils.isNotEmpty(pdfURL)) {
+            this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
         }
     }
 

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

@@ -676,7 +676,7 @@ public class WbsTreePrivateController extends BladeController {
     @GetMapping("/get-excel-html")
     @ApiOperationSupport(order = 23)
     @ApiOperation(value = "试验-客户端获取表的HTML", notes = "传入节点primaryKeyId")
-    public Object getExcelHtml(@RequestParam String primaryKeyId) throws IOException {
+    public Object getExcelHtml(@RequestParam String primaryKeyId) throws Exception {
         return wbsTreePrivateService.getExcelHtml(primaryKeyId);
     }
 

+ 15 - 14
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -53,16 +53,23 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         String nodeId = table.getString("nodeId");
         String projectId = table.getString("projectId");
         String contractId = table.getString("contractId");
+        //获取表模板,已处理隐藏表问题
+        List<TableInfo> tableInfoList = this.excelTabService.getTableInfoListTrial(dataArray, tabIds);
         try {
-            //获取表模板,已处理隐藏表问题
-            List<TableInfo> tableInfoList = this.excelTabService.getTableInfoListTrial(dataArray, tabIds);
-
             //------公式填充------
-            //this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId), ExecuteType.TESTING);
-
+            this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId), ExecuteType.TESTING);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("试验公式执行异常,操作失败");
+        }
+        try {
             //------试验填报数据保存,当前记录id作为groupId------
             this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
-
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("试验填报数据保存异常,操作失败");
+        }
+        try {
             if (isBatchSave == 0) {
                 //------单表PDF保存------
                 TableInfo tableInfo = tableInfoList.stream().findAny().orElse(null);
@@ -101,14 +108,8 @@ public class ExcelTabClientImpl implements ExcelTabClient {
                 pdfUrl = excelTabService.getBussPDFSTrial(nodeId, tableType, String.valueOf(type), contractId, projectId, id, tabIds, dto);
             }
         } catch (Exception e) {
-            if (e.getMessage().contains("字段过长")) {
-                //字段过长,新增失败的异常处理
-                throw new RuntimeException("字段过长,操作失败");
-            } else {
-                //其他类型的异常处理
-                e.printStackTrace();
-                throw new RuntimeException("公式执行异常,操作失败");
-            }
+            e.printStackTrace();
+            throw new RuntimeException("试验PDF保存异常,操作失败");
         }
 
         return pdfUrl;

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

@@ -80,7 +80,7 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
 
     List<WbsTreePrivateVO4> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId, Integer isAdd, Long id);
 
-    Object getExcelHtml(String primaryKeyId) throws IOException;
+    Object getExcelHtml(String primaryKeyId) throws Exception;
 
     //批量重新保存文件htmlUrl
     void batchResetHtmlUrl(List<WbsTreePrivate> wbsTreePrivateList) throws IOException, InterruptedException;

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

@@ -1749,6 +1749,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
      */
     @Override
     public List<Map<String, Object>> getBussDataInfoTrial(Long groupId, Long pkeyId, Long contractId) {
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
         List<Map<String, Object>> list = new ArrayList<>();
         Map<String, Object> reData = new HashMap<>();
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
@@ -1775,8 +1777,19 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
         // 匹配关联
         try {
-            File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
-            String htmlString = IoUtil.readToString(new FileInputStream(file1));
+            /*File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());*/
+            String fileUrl = wbsTreePrivate.getHtmlUrl();
+            File file1 = ResourceUtil.getFile(fileUrl);
+            InputStream fileInputStream = null;
+            if (file1.exists()) {
+                fileInputStream = new FileInputStream(file1);
+            } else {
+                String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
+                fileInputStream = CommonUtil.getOSSInputStream(path);
+            }
+
+            String htmlString = IoUtil.readToString(fileInputStream);
+
             Document doc = Jsoup.parse(htmlString);
             //匹配
             Elements bgHB = doc.select("el-input[placeholder~=报告编号.*]");
@@ -1903,6 +1916,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             }
         } catch (FileNotFoundException e) {
             e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
         }
 
         // 获取默认值

+ 14 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -44,15 +44,10 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
+import java.io.*;
 import java.util.*;
 import java.util.function.Function;
-import java.util.stream.Collector;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 @Service
 @AllArgsConstructor
@@ -1909,7 +1904,9 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
     }
 
     @Override
-    public Object getExcelHtml(String primaryKeyId) throws IOException {
+    public Object getExcelHtml(String primaryKeyId) throws Exception {
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
         WbsTreePrivate wbsTreePrivate = baseMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
                 .eq(WbsTreePrivate::getPKeyId, primaryKeyId));
         if (wbsTreePrivate == null) {
@@ -1918,8 +1915,16 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         if (wbsTreePrivate.getHtmlUrl() == null) {
             throw new ServiceException("暂无表单!");
         }
-        File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
-        FileInputStream fileInputStream = new FileInputStream(file1);
+
+        String fileUrl = wbsTreePrivate.getHtmlUrl();
+        File file1 = ResourceUtil.getFile(fileUrl);
+        InputStream fileInputStream = null;
+        if (file1.exists()) {
+            fileInputStream = new FileInputStream(file1);
+        } else {
+            String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
+            fileInputStream = CommonUtil.getOSSInputStream(path);
+        }
 
         String htmlString = IoUtil.readToString(fileInputStream);
         htmlString = htmlString.replaceAll("placeholder", "placeholderxx");