liuyc 2 лет назад
Родитель
Сommit
3600c869fd

+ 5 - 4
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialLaboratoryController.java

@@ -16,6 +16,8 @@ import org.springblade.core.tool.utils.Func;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.io.FileNotFoundException;
+import java.io.IOException;
 
 @RestController
 @RequestMapping("/laboratory")
@@ -55,10 +57,9 @@ public class TrialLaboratoryController extends BladeController {
 
     @PostMapping("/print/null-pdf")
     @ApiOperationSupport(order = 5)
-    @ApiOperation(value = "打印空表", notes = "传入ids")
-    public R<Object> printNullPDF(String ids) {
-        return R.data(iTrialLaboratoryUserArchivesService.printNullPDF(ids));
+    @ApiOperation(value = "打印空表", notes = "传入表的pKeyIds")
+    public R<Object> printNullPDF(@RequestParam String pKeyIds) throws Exception {
+        return R.data(iTrialLaboratoryUserArchivesService.printNullPDF(pKeyIds));
     }
 
-
 }

+ 4 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialLaboratoryUserArchivesService.java

@@ -5,6 +5,9 @@ import org.springblade.business.entity.TrialLaboratoryUserArchives;
 import org.springblade.business.vo.TrialLaboratoryUserArchivesPageVO;
 import org.springblade.core.mp.base.BaseService;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
 public interface ITrialLaboratoryUserArchivesService extends BaseService<TrialLaboratoryUserArchives> {
 
     TrialLaboratoryUserArchives archivesDetail(Long id);
@@ -13,6 +16,6 @@ public interface ITrialLaboratoryUserArchivesService extends BaseService<TrialLa
 
     IPage<TrialLaboratoryUserArchivesPageVO> archivesPage(IPage<TrialLaboratoryUserArchives> page, TrialLaboratoryUserArchivesPageVO pageVO);
 
-    String printNullPDF(String ids);
+    String printNullPDF(String pKeyIds) throws Exception;
 
 }

+ 78 - 8
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialLaboratoryUserArchivesServiceImpl.java

@@ -2,21 +2,46 @@ package org.springblade.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.AllArgsConstructor;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.util.IOUtils;
 import org.springblade.business.entity.TrialLaboratoryUserArchives;
 import org.springblade.business.mapper.TrialLaboratoryUserArchivesMapper;
 import org.springblade.business.service.ITrialLaboratoryUserArchivesService;
+import org.springblade.business.utils.FileUtils;
+import org.springblade.business.utils.FileUtils2;
 import org.springblade.business.vo.TrialLaboratoryUserArchivesPageVO;
 import org.springblade.business.wrapper.TrialLaboratoryUserArchivesWarpper;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.common.utils.SystemUtils;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Condition;
+import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ResourceUtil;
+import org.springblade.manager.entity.ExcelTab;
+import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.resource.feign.CommonFileClient;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springblade.resource.vo.NewBladeFile;
+import org.springblade.system.cache.ParamCache;
 import org.springblade.system.entity.Dict;
 import org.springblade.system.feign.IDictClient;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.*;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 @AllArgsConstructor
@@ -25,6 +50,9 @@ public class TrialLaboratoryUserArchivesServiceImpl
         implements ITrialLaboratoryUserArchivesService {
 
     private final IDictClient dictClient;
+    private final JdbcTemplate jdbcTemplate;
+    private final NewIOSSClient newIOSSClient;
+    private final CommonFileClient commonFileClient;
 
     @Override
     public TrialLaboratoryUserArchives archivesDetail(Long id) {
@@ -49,7 +77,7 @@ public class TrialLaboratoryUserArchivesServiceImpl
 
         for (TrialLaboratoryUserArchivesPageVO record : records) {
             for (Dict datum : trialUserEducation.getData()) {
-                if (record.getEducation().equals(Integer.parseInt(datum.getDictKey()))) {
+                if (ObjectUtils.isNotEmpty(record.getEducation()) && record.getEducation().equals(Integer.parseInt(datum.getDictKey()))) {
                     record.setEducationName(datum.getDictValue());
                 }
             }
@@ -58,14 +86,56 @@ public class TrialLaboratoryUserArchivesServiceImpl
     }
 
     @Override
-    public String printNullPDF(String ids) {
-        if (StringUtils.isNotEmpty(ids)) {
-            //选择打印 TODO
-        } else {
-            //全部打印
+    public String printNullPDF(String pKeyIds) throws Exception {
+        if (StringUtils.isNotEmpty(pKeyIds)) {
+            List<WbsTreePrivate> query = jdbcTemplate.query("select excel_id from m_wbs_tree_private where excel_id is not null and p_key_id in (" + pKeyIds + ")", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+            List<Long> excelIds = query.stream().map(WbsTreePrivate::getExcelId).collect(Collectors.toList());
+            if (excelIds.size() > 0) {
+                List<ExcelTab> excelUrls = jdbcTemplate.query("select file_url from m_excel_tab where file_url is not null and id in(" + org.apache.commons.lang.StringUtils.join(excelIds, ",") + ")", new BeanPropertyRowMapper<>(ExcelTab.class));
+                if (excelUrls.size() > 0) {
+                    List<String> pdfUrls = new ArrayList<>();
+                    for (ExcelTab excel : excelUrls) {
+                        //将excel转为pdf
+                        InputStream ossInputStream = CommonUtil.getOSSInputStream(excel.getFileUrl()); //获取OSS文件输入流
+                        MultipartFile files = new MockMultipartFile("file", excel.getName(), "text/plain", IOUtils.toByteArray(ossInputStream));
+                        NewBladeFile bladeFile = this.commonFileClient.excelToPdf(files);
+                        if (bladeFile != null) {
+                            pdfUrls.add(bladeFile.getPdfUrl());
+                        }
+                    }
+
+                    //合并
+                    if (pdfUrls.size() > 0) {
+                        String file_path = "";
+                        if (SystemUtils.isLinux()) {
+                            file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                        }
+                        if (SystemUtils.isWindows()) {
+                            file_path = "C:\\pdfFiles\\pdf";
+                            File file = new File(file_path);
+                            if (!file.exists()) {
+                                file.mkdirs();
+                            }
+                        }
+                        if (StringUtils.isNotEmpty(file_path)) {
+                            Long idRoot = SnowFlakeUtil.getId();
+                            String listPdfAll = file_path + "" + idRoot + ".pdf";
+                            File tabPDFAll = ResourceUtil.getFile(listPdfAll);
+                            if (tabPDFAll.exists()) {
+                                tabPDFAll.delete();
+                            }
+                            FileUtils.mergePdfPublicMethods(pdfUrls, listPdfAll);
+                            BladeFile bladeFile = this.newIOSSClient.uploadFile(idRoot + ".pdf", listPdfAll);
+                            if (bladeFile != null) {
+                                CommonUtil.removeFile(Func.toStrList(listPdfAll));
+                                return bladeFile.getLink();
+                            }
+                        }
+                    }
+                }
+            }
         }
-        return "功能未开放";
+        return "";
     }
 
-
 }

+ 6 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -417,7 +417,11 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
                 .select(TrialSelfInspectionRecord::getReportNo, TrialSelfInspectionRecord::getRecordNo)
                 .and(obj -> obj.like(TrialSelfInspectionRecord::getReportNo, "BG-").or().like(TrialSelfInspectionRecord::getRecordNo, "JL-"))
-                .eq(TrialSelfInspectionRecord::getContractId, trialSelfInspectionRecord.getContractId()).eq(TrialSelfInspectionRecord::getNodeId, trialSelfInspectionRecord.getNodeId()));
+                .eq(TrialSelfInspectionRecord::getContractId, trialSelfInspectionRecord.getContractId())
+                .eq(TrialSelfInspectionRecord::getNodeId, trialSelfInspectionRecord.getNodeId())
+                .isNotNull(TrialSelfInspectionRecord::getRecordNo)
+                .isNotNull(TrialSelfInspectionRecord::getReportNo)
+        );
 
         List<TrialSelfInspectionRecord> bg = recordList.stream().filter(f -> f.getReportNo().contains("BG-")).collect(Collectors.toList());
         List<TrialSelfInspectionRecord> jl = recordList.stream().filter(f -> f.getRecordNo().contains("JL-")).collect(Collectors.toList());
@@ -589,7 +593,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         if (ObjectUtil.isNotEmpty(obj.getParallelProcessInstanceId())) {
             String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";
             TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
-            if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
+            if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId()) && (new Integer(1).equals(taskParallel.getEVisaStatus()))) {
                 String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
                 if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
                     this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()

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

@@ -1852,7 +1852,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
         //获取工作表
         Worksheet sheet = wb.getWorksheets().get(0);
-        //标题添加
+        /*//标题添加
         ProjectInfo projectInfo = projectInfoService.getById(wbsTreePrivate.getProjectId());
         CellRange[] columns = sheet.getMergedCells();
         for (CellRange cellRange : columns) {
@@ -1861,7 +1861,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 cellRange.getStyle().getFont().setSize(20);
                 break;
             }
-        }
+        }*/
 
         //数据不为空
         if (StringUtils.isNotEmpty(wbsTreePrivate.getHtmlUrl())) {

+ 40 - 88
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -500,37 +500,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 }
             }
 
-           /*for (WbsTreePrivate treePrivateNow : wbsTreePrivatesAllNow) {
-                //判断相同节点基础信息、元素表类型、元素表所属方 是否发生改变
-                if (wbsTreePrivate.getId().equals(treePrivateNow.getId()) &&
-                        (!wbsTreePrivate.getNodeName().equals(treePrivateNow.getNodeName())
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getNodeType()) && !wbsTreePrivate.getNodeType().equals(treePrivateNow.getNodeType()))
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getMajorDataType()) && !wbsTreePrivate.getMajorDataType().equals(treePrivateNow.getMajorDataType()))
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getTableType()) && !wbsTreePrivate.getTableType().equals(treePrivateNow.getTableType()))
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getTableOwner()) && !wbsTreePrivate.getTableOwner().equals(treePrivateNow.getTableOwner()))
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getImportMatchingInfo()) && !wbsTreePrivate.getImportMatchingInfo().equals(treePrivateNow.getImportMatchingInfo()))
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getMixRatioTestIds()) && !wbsTreePrivate.getMixRatioTestIds().equals(treePrivateNow.getMixRatioTestIds()))
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getInitTableId()) && !wbsTreePrivate.getInitTableId().equals(treePrivateNow.getInitTableId()))
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getInitTableName()) && !wbsTreePrivate.getInitTableName().equals(treePrivateNow.getInitTableName())
-                                || (ObjectUtils.isNotEmpty(wbsTreePrivate.getHtmlUrl()) && !wbsTreePrivate.getHtmlUrl().equals(treePrivateNow.getHtmlUrl()))))) {
-                    //修改项目wbs信息
-                    WbsTreePrivate wbsPrivate = BeanUtil.copyProperties(wbsTreePrivate, WbsTreePrivate.class);
-                    if (wbsPrivate != null) {
-                        wbsPrivate.setWbsId(wbsId);
-                        wbsPrivate.setProjectId(projectId);
-                        listPrivate.add(wbsPrivate);
-                    }
-                    for (ContractInfo contractInfo : contractInfos) {
-                        //修改合同段wbs信息
-                        WbsTreeContract wbsContract = BeanUtil.copyProperties(wbsTreePrivate, WbsTreeContract.class);
-                        if (wbsContract != null) {
-                            wbsContract.setContractId(String.valueOf(contractInfo.getId()));
-                            wbsContract.setProjectId(projectId);
-                            listContract.add(wbsContract);
-                        }
-                    }
-                }
-            }*/
         }
 
         //修改到项目
@@ -544,22 +513,11 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
             String sql = "select id,old_id,project_id,contract_id from m_wbs_tree_contract where project_id = " + projectId + " and contract_id in(" + org.apache.commons.lang.StringUtils.join(contractInfosIds, ",") + ") and wbs_type = " + wbsType + " and type = 1 and status = 1 and is_deleted = 0 and old_id is not null";
             List<WbsTreeContract> wbsTreeContractsCopyOrAddAll = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
             Map<String, List<WbsTreeContract>> copyAddNodes = wbsTreeContractsCopyOrAddAll.stream().collect(Collectors.groupingBy(WbsTreeContract::getOldId));
-            /*for (ContractInfo contractInfo : contractInfos) {
-                List<WbsTreeContract> wbsTreeContractsCopyOrAdd = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
-                        .select(WbsTreeContract::getId, WbsTreeContract::getOldId, WbsTreeContract::getProjectId, WbsTreeContract::getContractId)
-                        .eq(WbsTreeContract::getProjectId, projectId)
-                        .eq(WbsTreeContract::getContractId, contractInfo.getId())
-                        .eq(WbsTreeContract::getWbsType, wbsType)
-                        .eq(WbsTreeContract::getType, 1)
-                        .isNotNull(WbsTreeContract::getOldId)
-                );
-                wbsTreeContractsCopyOrAddAll.addAll(wbsTreeContractsCopyOrAdd);
-            }*/
 
             List<WbsTreeContract> listContractAdd = new ArrayList<>();
             for (WbsTreeContract obj1 : listContract) {
                 List<WbsTreeContract> copyAddNodesNow = copyAddNodes.get(obj1.getId().toString());
-                if (copyAddNodesNow.size() > 0) {
+                if (ObjectUtils.isNotEmpty(copyAddNodesNow) && copyAddNodesNow.size() > 0) {
                     WbsTreeContract obj2 = copyAddNodesNow.stream().filter(f -> f.getContractId().equals(obj1.getContractId()) && f.getProjectId().equals(obj1.getProjectId())).findAny().orElse(null);
                     if (obj2 != null) {
                         obj2.setNodeName(obj1.getNodeName());
@@ -571,17 +529,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                         listContractAdd.add(obj2);
                     }
                 }
-                /*for (WbsTreeContract obj2 : wbsTreeContractsCopyOrAddAll) {
-                    if (obj1.getId().toString().equals(obj2.getOldId()) && obj1.getProjectId().equals(obj2.getProjectId()) && obj1.getContractId().equals(obj2.getContractId())) {
-                        obj2.setNodeName(obj1.getNodeName());
-                        obj2.setNodeType(obj1.getNodeType());
-                        obj2.setMajorDataType(obj1.getMajorDataType());
-                        obj2.setTableType(obj1.getTableType());
-                        obj2.setTableOwner(obj1.getTableOwner());
-                        obj2.setHtmlUrl(obj1.getHtmlUrl());
-                        listContractAdd.add(obj2);
-                    }
-                }*/
             }
 
             listContractAdd.addAll(listContract);
@@ -1516,6 +1463,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
 
     /**
      * 批量重新保存文件htmlUrl
+     *
      * @param wbsTreePrivateList
      */
     @Async
@@ -1590,49 +1538,53 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                     .last("limit 1"));
             //如果存在则复制最新表的配置,调整表单的值
             if (wbsTreePrivate != null) {
+
                 if (wbsPrivate.getExcelId() != null) {
-                    wbsPrivate.setExcelId(wbsTreePrivate.getExcelId());
-                }
-                if (StringUtils.isNotEmpty(wbsTreePrivate.getHtmlUrl())){
-                    //复制生成html
-                    String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                    File file_in = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
+                    if (StringUtils.isNotEmpty(wbsTreePrivate.getExcelId() + "")) {
+                        wbsPrivate.setExcelId(wbsTreePrivate.getExcelId());
+                    }
+                    if (StringUtils.isNotEmpty(wbsTreePrivate.getHtmlUrl())) {
+                        //复制生成html
+                        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                        File file_in = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
 //                    File file_in = ResourceUtil.getFile("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1636553444422582272.html");
-                    String filecode = SnowFlakeUtil.getId() + "";
-                    String thmlUrl = file_path + "/privateUrl/" + filecode + ".html";
+                        String filecode = SnowFlakeUtil.getId() + "";
+                        String thmlUrl = file_path + "/privateUrl/" + filecode + ".html";
 //                    String thmlUrl =  "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\9527.html";
-                    File file_out = ResourceUtil.getFile(thmlUrl);
-                    FileUtil.copy(file_in, file_out);
-                    wbsPrivate.setHtmlUrl(thmlUrl);
-                }
-                List<TextdictInfo> list = textDictInfoService.list(new LambdaQueryWrapper<TextdictInfo>()
-                        .eq(TextdictInfo::getTabId, wbsTreePrivate.getPKeyId()));
-                if (list.size() >= 0 ){
-                    list.stream().forEach(l->{
-                        l.setId(SnowFlakeUtil.getId());
-                        l.setTabId(wbsPrivate.getPKeyId().toString());
-                    });
-                    textDictInfoService.saveBatch(list);
+                        File file_out = ResourceUtil.getFile(thmlUrl);
+                        FileUtil.copy(file_in, file_out);
+                        wbsPrivate.setHtmlUrl(thmlUrl);
+                    }
+                    List<TextdictInfo> list = textDictInfoService.list(new LambdaQueryWrapper<TextdictInfo>()
+                            .eq(TextdictInfo::getTabId, wbsTreePrivate.getPKeyId()));
+                    if (list.size() >= 0) {
+                        list.stream().forEach(l -> {
+                            l.setId(SnowFlakeUtil.getId());
+                            l.setTabId(wbsPrivate.getPKeyId().toString());
+                        });
+                        textDictInfoService.saveBatch(list);
+                    }
                 }
-            }
 
-            wbsPrivate.setTableOwner(tableInfo.getTableOwner());
-            wbsPrivate.setInitTableId(tableInfo.getId() + "");
-            wbsPrivate.setTableType(tableInfo.getTabType());
-            wbsPrivate.setInitTableName(tableInfo.getTabEnName());
-            wbsPrivate.setNodeName(tableInfo.getTabChName());
-            wbsPrivate.setFullName(tableInfo.getTabChName());
-            wbsPrivate.setFillRate(tableInfo.getFillRate());
-            wbsPrivate.setProjectId(projectId);
-            wbsPrivate.setType(10);//带过来的元素信息
-            wbsPrivate.setParentId(-10L);
-            wbsPrivate.setStatus(1);
-            wbsTreePrivateMapper.insert(wbsPrivate);
+                wbsPrivate.setTableOwner(tableInfo.getTableOwner());
+                wbsPrivate.setInitTableId(tableInfo.getId() + "");
+                wbsPrivate.setTableType(tableInfo.getTabType());
+                wbsPrivate.setInitTableName(tableInfo.getTabEnName());
+                wbsPrivate.setNodeName(tableInfo.getTabChName());
+                wbsPrivate.setFullName(tableInfo.getTabChName());
+                wbsPrivate.setFillRate(tableInfo.getFillRate());
+                wbsPrivate.setProjectId(projectId);
+                wbsPrivate.setType(10);//带过来的元素信息
+                wbsPrivate.setParentId(-10L);
+                wbsPrivate.setStatus(1);
+                wbsTreePrivateMapper.insert(wbsPrivate);
            /* }else{
                 return R.success("没有查到主库信息");
             }*/
+            }
+            return R.success("添加成功");
         }
-        return R.success("添加成功");
+        return R.fail("添加失败");
     }
 
     @Override