liuyc 2 years ago
parent
commit
857ec97f5c

+ 12 - 7
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -853,17 +853,22 @@ public class InformationWriteQueryController extends BladeController {
     @ApiOperationSupport(order = 22)
     @ApiOperation(value = "填报页单个上报")
     public R<Boolean> taskOne(@RequestBody StartTaskVO startTaskVO) throws IOException {
+        InformationQuery businessData;
         //此时的ids是当前节点的primaryKeyId但并不是业务数据ID,需要根据ids和classify去查询具体的业务ID
-        InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, startTaskVO.getIds().replaceAll(",", "")).eq(InformationQuery::getClassify, startTaskVO.getClassify().toString()).eq(InformationQuery::getType, 1));
-
+        if (ObjectUtil.isNotEmpty(startTaskVO.getTrialSelfInspectionRecordId())) {
+            //试验
+            businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, startTaskVO.getIds().replaceAll(",", "")).eq(InformationQuery::getClassify, startTaskVO.getClassify().toString()).eq(InformationQuery::getType, 2));
+        } else { //质检
+            businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, startTaskVO.getIds().replaceAll(",", "")).eq(InformationQuery::getClassify, startTaskVO.getClassify().toString()).eq(InformationQuery::getType, 1));
+        }
         //处理上报信息
         if (businessData != null) {
             //设置业务数据ID
             startTaskVO.setIds(businessData.getId().toString());
             return this.batchTask(startTaskVO);
+        } else {
+            return R.data(300, false, "未查询到填报信息,上报失败");
         }
-
-        return R.data(300, false, "上报失败");
     }
 
     /**
@@ -1639,10 +1644,10 @@ public class InformationWriteQueryController extends BladeController {
                     StringBuilder addNames = new StringBuilder();
                     addNames.append("[");
                     for (WbsTreeContract node : toCopyNodes) {
-                        addNames.append(node.getNodeName()+"-");
+                        addNames.append(node.getNodeName() + "-");
                     }
                     String substring = addNames.substring(0, addNames.length() - 1);
-                    needCopyNodeRoot.setNodeName(substring+"]");
+                    needCopyNodeRoot.setNodeName(substring + "]");
 //                    return R.success("操作成功");
                     return this.saveOrCopyNodeTree(addNodeList, null, 32, needCopyNodeRoot);
                 } else {
@@ -2839,7 +2844,7 @@ public class InformationWriteQueryController extends BladeController {
                     WbsTreeContract node = result.get(result.size() - i);
                     pathName.append("-").append(StringUtils.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
                 }
-                pathName.append("-"+currentNode.getNodeName());
+                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));

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

@@ -300,14 +300,15 @@ public class TrialDetectionController extends BladeController {
                 if (trialPdf2.exists()) {
                     trialPdf2.delete();
                 }
-                //合并当前所有选择的试验pdf
-                FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
-                BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
-                if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
-                    pdfUrl = bladeFile.getLink();
+                if (pdfList.size() > 0){
+                    //合并当前所有选择的试验pdf
+                    FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
+                    BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
+                    if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                        pdfUrl = bladeFile.getLink();
+                    }
                 }
             }
-
             return R.data(pdfUrl);
         } else {
             return R.fail("无历史数据预览,请保存数据");

+ 69 - 61
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -217,12 +217,14 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 if (trialPdf2.exists()) {
                     trialPdf2.delete();
                 }
-                //合并当前所有选择的试验pdf
-                FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
-                BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
-                if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
-                    pdfUrl = bladeFile.getLink();
-                    return pdfUrl.toString();
+                if (pdfList.size() > 0) {
+                    //合并当前所有选择的试验pdf
+                    FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
+                    BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
+                    if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                        pdfUrl = bladeFile.getLink();
+                        return pdfUrl.toString();
+                    }
                 }
             }
             assert pdfUrl != null;
@@ -608,18 +610,20 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             }
         }
 
-        //合并pdf
-        Long id = SnowFlakeUtil.getId();
-        String pdfPath2 = file_path + "/pdf//" + id + "_2.pdf";
-        File tabPdf2 = ResourceUtil.getFile(pdfPath2);
-        if (tabPdf2.exists()) {
-            tabPdf2.delete();
-        }
-        FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
+        if (dataListPdf.size() > 0) {
+            //合并pdf
+            Long id = SnowFlakeUtil.getId();
+            String pdfPath2 = file_path + "/pdf//" + id + "_2.pdf";
+            File tabPdf2 = ResourceUtil.getFile(pdfPath2);
+            if (tabPdf2.exists()) {
+                tabPdf2.delete();
+            }
+            FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
 
-        BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath2);
-        if (bladeFile != null) {
-            return bladeFile.getLink();
+            BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath2);
+            if (bladeFile != null) {
+                return bladeFile.getLink();
+            }
         }
         return null;
     }
@@ -689,19 +693,20 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                                         //如果当前工程部位节点的关联试验记录id有多条,那么合并
                                         List<TrialSelfInspectionRecord> pdfUrlList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getPdfUrl).in(TrialSelfInspectionRecord::getId, trialRecordIds));
                                         List<String> pdfS = pdfUrlList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
-
-                                        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                                        String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
-                                        File tabPDF = ResourceUtil.getFile(listPdf);
-                                        if (tabPDF.exists()) {
-                                            tabPDF.delete();
-                                        }
-
-                                        FileUtils.mergePdfPublicMethods(pdfS, listPdf);
-                                        BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
-                                        if (bladeFile != null) {
-                                            //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
-                                            baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
+                                        if (ObjectUtil.isNotEmpty(pdfS) && pdfS.size() > 0) {
+                                            String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                                            String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
+                                            File tabPDF = ResourceUtil.getFile(listPdf);
+                                            if (tabPDF.exists()) {
+                                                tabPDF.delete();
+                                            }
+
+                                            FileUtils.mergePdfPublicMethods(pdfS, listPdf);
+                                            BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
+                                            if (bladeFile != null) {
+                                                //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
+                                                baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
+                                            }
                                         }
                                     }
                                 }
@@ -1342,22 +1347,24 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 if (pdfList.size() > 0) {
                     //合并试验自检、第三方、外委的pdf
                     List<String> collect = pdfList.stream().filter(Objects::nonNull).collect(Collectors.toList());
-                    String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                    String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
-                    File tabPDF = ResourceUtil.getFile(listPdf);
-                    if (tabPDF.exists()) {
-                        tabPDF.delete();
-                    }
-                    FileUtils.mergePdfPublicMethods(collect, listPdf);
-                    BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getId() + ".pdf", listPdf);
-                    if (bladeFile != null) {
-                        //修改当前节点的pdfTrialURL地址
-                        if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
-                            for (String recordId : Func.toStrList(dto.getIds())) {
-                                baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), recordId); //先删除对应记录
-                                baseMapper.insertSeletedStatus(SnowFlakeUtil.getId(), dto.getNodeId(), dto.getType(), recordId); //新增该类型选中的记录信息
+                    if (ObjectUtil.isNotEmpty(collect) && collect.size() > 0) {
+                        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                        String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
+                        File tabPDF = ResourceUtil.getFile(listPdf);
+                        if (tabPDF.exists()) {
+                            tabPDF.delete();
+                        }
+                        FileUtils.mergePdfPublicMethods(collect, listPdf);
+                        BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getId() + ".pdf", listPdf);
+                        if (bladeFile != null) {
+                            //修改当前节点的pdfTrialURL地址
+                            if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
+                                for (String recordId : Func.toStrList(dto.getIds())) {
+                                    baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), recordId); //先删除对应记录
+                                    baseMapper.insertSeletedStatus(SnowFlakeUtil.getId(), dto.getNodeId(), dto.getType(), recordId); //新增该类型选中的记录信息
+                                }
+                                return true;
                             }
-                            return true;
                         }
                     }
                 }
@@ -1398,26 +1405,27 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 if (pdfList.size() > 0 && informationQuery != null) {
                     //重新合并
                     List<String> collect = pdfList.stream().filter(Objects::nonNull).collect(Collectors.toList());
-                    String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                    String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
-                    File tabPDF = ResourceUtil.getFile(listPdf);
-                    if (tabPDF.exists()) {
-                        tabPDF.delete();
-                    }
-                    FileUtils.mergePdfPublicMethods(collect, listPdf);
-                    BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getId() + ".pdf", listPdf);
-                    if (bladeFile != null) {
-                        //修改当前节点最新的pdfTrialURL地址
-                        if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
-                            for (String recordId : recordIds) {
-                                baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), recordId); //先删除对应记录
-                                baseMapper.insertSeletedStatus(SnowFlakeUtil.getId(), dto.getNodeId(), dto.getType(), recordId); //新增该类型选中的记录信息
+                    if (ObjectUtil.isNotEmpty(collect) && collect.size() > 0) {
+                        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                        String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
+                        File tabPDF = ResourceUtil.getFile(listPdf);
+                        if (tabPDF.exists()) {
+                            tabPDF.delete();
+                        }
+                        FileUtils.mergePdfPublicMethods(collect, listPdf);
+                        BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getId() + ".pdf", listPdf);
+                        if (bladeFile != null) {
+                            //修改当前节点最新的pdfTrialURL地址
+                            if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
+                                for (String recordId : recordIds) {
+                                    baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), recordId); //先删除对应记录
+                                    baseMapper.insertSeletedStatus(SnowFlakeUtil.getId(), dto.getNodeId(), dto.getType(), recordId); //新增该类型选中的记录信息
+                                }
+                                return true;
                             }
-                            return true;
                         }
                     }
                 }
-
             } else {
                 //修改pdfTrialUrl=null
                 if (informationQuery != null) {

+ 18 - 28
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -2,22 +2,15 @@ package org.springblade.manager.feign;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import feign.FeignException;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.business.entity.InformationQuery;
-import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.feign.InformationQueryClient;
-import org.springblade.business.vo.TrialRawMaterialSelfRecord;
 import org.springblade.common.constant.CommonConstant;
-import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.oss.model.BladeFile;
-import org.springblade.core.tool.beans.BeanProperty;
-import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.bean.TableInfo;
@@ -28,17 +21,12 @@ import org.springblade.manager.service.IExcelTabService;
 import org.springblade.manager.utils.FileUtils;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.cache.ParamCache;
-import org.springframework.beans.BeanUtils;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @RestController
@@ -85,23 +73,25 @@ public class ExcelTabClientImpl implements ExcelTabClient {
                         //重新合并pdf
                         List<TrialSelfDataRecord> query = jdbcTemplate.query("select pdf_url from u_trial_self_data_record where record_id = " + id, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
                         List<String> pdfList = query.stream().map(TrialSelfDataRecord::getPdfUrl).collect(Collectors.toList());
-                        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                        String pdfPath = file_path + "/pdf//" + id + "_2.pdf";
-                        File tabPdf = ResourceUtil.getFile(pdfPath);
-                        if (tabPdf.exists()) {
-                            tabPdf.delete();
-                        }
-                        FileUtils.mergePdfPublicMethods(pdfList, pdfPath);
-                        BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath);
-                        if (bladeFile != null) {
-                            //重新合并pdf集合(解决单表保存后上报找不到题名问题)
-                            List<InformationQuery> query2 = jdbcTemplate.query("select id from u_information_query where classify ='" + type + "' and wbs_id ='" + id + "' and contract_id ='" + contractId + "'", new BeanPropertyRowMapper<>(InformationQuery.class));
-                            if (query2.size() > 0) {
-                                jdbcTemplate.execute("update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name ='" + (StringUtils.isNotEmpty(dto.getTrialProjectName()) ? dto.getTrialProjectName() : "") + "'  where classify='" + type + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'");
-                            } else {
-                                informationQueryClient.saveData(id.toString(), projectId, contractId, type.toString(), bladeFile.getLink(), (StringUtils.isNotEmpty(dto.getTrialProjectName()) ? dto.getTrialProjectName() : ""));
+                        if (ObjectUtil.isNotEmpty(pdfList) && pdfList.size() > 0) {
+                            String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                            String pdfPath = file_path + "/pdf//" + id + "_2.pdf";
+                            File tabPdf = ResourceUtil.getFile(pdfPath);
+                            if (tabPdf.exists()) {
+                                tabPdf.delete();
+                            }
+                            FileUtils.mergePdfPublicMethods(pdfList, pdfPath);
+                            BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath);
+                            if (bladeFile != null) {
+                                //重新合并pdf集合(解决单表保存后上报找不到题名问题)
+                                List<InformationQuery> query2 = jdbcTemplate.query("select id from u_information_query where classify ='" + type + "' and wbs_id ='" + id + "' and contract_id ='" + contractId + "'", new BeanPropertyRowMapper<>(InformationQuery.class));
+                                if (query2.size() > 0) {
+                                    jdbcTemplate.execute("update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name ='" + (StringUtils.isNotEmpty(dto.getTrialProjectName()) ? dto.getTrialProjectName() : "") + "'  where classify='" + type + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'");
+                                } else {
+                                    informationQueryClient.saveData(id.toString(), projectId, contractId, type.toString(), bladeFile.getLink(), (StringUtils.isNotEmpty(dto.getTrialProjectName()) ? dto.getTrialProjectName() : ""));
+                                }
+                                pdfUrl = bladeFile.getLink();
                             }
-                            pdfUrl = bladeFile.getLink();
                         }
                     }
                 }