Browse Source

委托单页面填报表单信息的页面材料信息基本数据回显修改,修复试验检测记录编号和报告编号与客户填写的编号不一致的情况 二次修复

DengLinLang 2 months ago
parent
commit
add5fc9b7b

+ 2 - 6
blade-ops/blade-resource/src/main/java/org/springblade/resource/builder/oss/AliOssBuilder.java

@@ -21,13 +21,9 @@ import com.aliyun.oss.OSSClient;
 import com.aliyun.oss.common.auth.CredentialsProvider;
 import com.aliyun.oss.common.auth.DefaultCredentialProvider;
 import lombok.SneakyThrows;
-import org.springblade.core.oss.AliossTemplate;
-import org.springblade.core.oss.OssTemplate;
 import org.springblade.core.oss.props.OssProperties;
 import org.springblade.core.oss.rule.BladeOssRule;
-import org.springblade.core.oss.rule.OssRule;
 import org.springblade.resource.builder.ossre.AliossTemplateRe;
-import org.springblade.resource.builder.ossre.OssTemplateRe;
 import org.springblade.resource.entity.Oss;
 
 /**
@@ -55,8 +51,8 @@ public class AliOssBuilder {
         conf.setMaxErrorRetry(5);
         OssProperties ossProperties = new OssProperties();
 
-        //ossProperties.setEndpoint(oss.getEndpoint());
-       ossProperties.setEndpoint("https://oss-cn-shenzhen.aliyuncs.com/");
+        ossProperties.setEndpoint(oss.getEndpoint());
+
 
         ossProperties.setAccessKey(oss.getAccessKey());
         ossProperties.setSecretKey(oss.getSecretKey());

+ 5 - 5
blade-ops/blade-resource/src/main/java/org/springblade/resource/builder/oss/OssBuilder.java

@@ -21,15 +21,15 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.springblade.core.cache.utils.CacheUtil;
 import org.springblade.core.log.exception.ServiceException;
-import org.springblade.core.oss.OssTemplate;
 import org.springblade.core.oss.enums.OssEnum;
 import org.springblade.core.oss.enums.OssStatusEnum;
 import org.springblade.core.oss.props.OssProperties;
 import org.springblade.core.oss.rule.BladeOssRule;
-import org.springblade.core.oss.rule.OssRule;
 import org.springblade.core.secure.utils.AuthUtil;
-import org.springblade.core.tool.utils.*;
-import org.springblade.resource.builder.ossre.AliossTemplateRe;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringPool;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.core.tool.utils.WebUtil;
 import org.springblade.resource.builder.ossre.OssTemplateRe;
 import org.springblade.resource.entity.Oss;
 import org.springblade.resource.service.IOssService;
@@ -38,7 +38,6 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE;
-import static org.springblade.resource.builder.oss.AliOssBuilder.*;
 
 /**
  * Oss云存储统一构建类
@@ -86,6 +85,7 @@ public class OssBuilder {
         String tenantId = AuthUtil.getTenantId();
         Oss oss = getOss(tenantId, code);
        // oss.setEndpoint("http://183.247.216.148:9000/");
+        //oss.setEndpoint("https://oss-cn-shenzhen.aliyuncs.com/");
         Oss ossCached = ossPool.get(tenantId);
         OssTemplateRe template = templatePool.get(tenantId);
         // 若为空或者不一致,则重新加载

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

@@ -975,12 +975,14 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
+
         //------初始当前填报的表pKeyIds------
         this.initTrialTabIds(dto);
 
-        //------初始编号信息------
-        this.initBuildNumber(dto);
-
+        if(!this.judgingParameters(dto)){
+            //------初始编号信息------
+            this.initBuildNumber(dto);
+        }
         //------新增或编辑------
         this.saveOrUpdate(dto);
 
@@ -990,7 +992,9 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             //如果传递了就修改对应记录的值
             this.updateRecordNoOrReportNo(obj, dto);
             //------编辑时记录表编号或报告单编号为Null的重新生成------
-            this.reBuildNumber(obj, dto);
+            if(this.judgingParameters(dto)){
+                this.reBuildNumber(obj, dto);
+            }
 
             //------保存实体表数据、试验记录信息、生成PDF------
             this.submitTrialData(obj, dto);
@@ -1039,15 +1043,65 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 if("1".equals(singleTableType[i])){
                     //记录表
                     this.updateRecordNoOrReportNo(dto,jsonObject,doc,"记录编 号:","record_no");
+                    this.updateRecordNoOrReportNo(dto,jsonObject,doc,"记录编号:","record_no");
                 }else if("2".equals(singleTableType[i])){
                     //报告单
                     this.updateRecordNoOrReportNo(dto,jsonObject,doc,"报告编号:","report_no");
                 }
             } catch (Exception e) {
-
+                log.error(e.getMessage());
             }
+        }
+    }
 
+    /**
+     * 判断入参中用户是否自己手动填写了 报告编号或者记录编号
+     * @param dto
+     * @return
+     */
+    private boolean judgingParameters(TrialSelfInspectionRecordDTO dto) {
+        JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
+        for (int i = 0; i < dataArray.size(); i++) {
+            JSONObject jsonObject = dataArray.getJSONObject(i);
+            String pkeyId = jsonObject.getString("pkeyId");
+            String sql = "select * from m_wbs_tree_private where p_key_id =" + pkeyId;
+            WbsTreePrivate table = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+            String fileUrl = table.getHtmlUrl();
+            try {
+                InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
+                String htmlString = IoUtil.readToString(fileInputStream);
+                htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
+                Document doc = Jsoup.parse(htmlString);
+                //可能出现的几种情况 4种情况 记录编 号: 记录编号: 报告编号: 编号:
+                Elements elementsWithPlaceholderxx = doc.select("[placeholderxx='记录编 号:']");
+                if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
+                    elementsWithPlaceholderxx = doc.select("[placeholderxx='记录编号:']");
+                    if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
+                        elementsWithPlaceholderxx = doc.select("[placeholderxx='报告编号:']");
+                        if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
+                            elementsWithPlaceholderxx = doc.select("[placeholderxx='编号:']");
+                        }
+                    }
+                }
+                //没找到直接返回false
+                if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
+                    log.error("方法:private boolean JudgingParameters(TrialSelfInspectionRecordDTO dto)中 未找到元素");
+                    return false;
+                }
+                Element first = elementsWithPlaceholderxx.first();
+                String key = first.attr("id");
+                //记录编号或者报告编号的值
+                String recordOrReportNo = jsonObject.getString(key);
+                if(recordOrReportNo != null || "".equals(recordOrReportNo)){
+                    return true;
+                }else {
+                    return false;
+                }
+            } catch (Exception e) {
+                log.error(e.getMessage());
+            }
         }
+        return false;
     }
 
     /**
@@ -1060,10 +1114,14 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
      */
     private void updateRecordNoOrReportNo(TrialSelfInspectionRecord dto,JSONObject jsonObject,Document doc,String  value, String fileVlue) {
         Elements elementsWithPlaceholderxx = doc.select("[placeholderxx="+value+"]");
-        if((elementsWithPlaceholderxx.size() == 0 ||elementsWithPlaceholderxx == null) && value.equals("报告编号:")){
+        if((elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null) && value.equals("报告编号:")){
+            //特殊情况
             value = "编号:";
             elementsWithPlaceholderxx = doc.select("[placeholderxx="+value+"]");
         }
+        if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
+            return;
+        }
         Element first = elementsWithPlaceholderxx.first();
         String key = first.attr("id");
         //记录编号或者报告编号的值

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

@@ -22,7 +22,6 @@ import org.apache.commons.codec.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
-import org.jetbrains.annotations.TestOnly;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -4093,7 +4092,6 @@ public class ExcelTabController extends BladeController {
             @ApiImplicitParam(name = "contractId", value = "合同段id", required = true)
     })
     public R<List<Map<String, Object>>> getBussDataInfoTrialentrust(Long id, Long pkeyId, Long contractId, Long sampleId) {
-
         List<Map<String, Object>> bussDataInfoTrial = excelTabService.getBussDataInfoTrialentrust(id, pkeyId, contractId,sampleId);
         return R.data(bussDataInfoTrial);
     }

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

@@ -4530,7 +4530,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     }
 
     private static void setBasicFormData(Document doc, Map<String, Object> reData, TrialSampleInfo sampleInfo ,TrialMaterialMobilization trialMaterialMobilization, EntrustInfo entrustInfo) {
-        setFirstData(doc,"委托编号",entrustInfo.getEntrustNo(),reData);
+        if(entrustInfo != null){
+            setFirstData(doc,"委托编号",entrustInfo.getEntrustNo(),reData);
+        }
         setFirstData(doc,"样品编号",sampleInfo.getSpecificationNumber(),reData);
         setFirstData(doc,"取样地点",sampleInfo.getSamplingLocation(),reData);
         setFirstData(doc,"样品描述",sampleInfo.getSampleDescription(),reData);

+ 18 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java

@@ -1,22 +1,23 @@
 package org.springblade.manager.utils;
 
-import com.aliyun.oss.common.utils.DateUtil;
-import com.aspose.cells.License;
 import com.aspose.cells.PdfSaveOptions;
 import com.aspose.cells.SaveFormat;
 import com.aspose.cells.Workbook;
 import com.itextpdf.text.Document;
 import com.itextpdf.text.pdf.PdfCopy;
 import com.itextpdf.text.pdf.PdfReader;
-import com.spire.xls.*;
 import com.spire.xls.CellRange;
+import com.spire.xls.FileFormat;
+import com.spire.xls.Worksheet;
 import com.spire.xls.core.spreadsheet.HTMLOptions;
 import com.sun.image.codec.jpeg.JPEGCodec;
 import com.sun.image.codec.jpeg.JPEGImageEncoder;
 import org.apache.commons.lang.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.Units;
 import org.apache.poi.xssf.usermodel.XSSFPrintSetup;
@@ -30,16 +31,20 @@ import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.common.utils.SystemUtils;
 import org.springblade.common.vo.DataVO;
-import org.springblade.core.tool.utils.*;
+import org.springblade.core.tool.utils.FileUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.IoUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.system.cache.ParamCache;
+
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URLEncoder;
-import java.util.*;
 import java.util.List;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
@@ -399,6 +404,12 @@ public class FileUtils {
         if(fileUrl.indexOf("/www/wwwroot")>=0){
             file_path2 = file_path;
         }
+        File file = new File(fileUrl);
+
+        if(file.exists()){
+            //存在
+            return fileUrl;
+        }
        String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path2, "");
         return path;
     }

+ 8 - 22
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/PdfAddimgUtil.java

@@ -1,37 +1,22 @@
 package org.springblade.manager.utils;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import com.itextpdf.text.BaseColor;
 import com.itextpdf.text.Element;
 import com.itextpdf.text.Image;
 import com.itextpdf.text.Rectangle;
-import com.itextpdf.text.pdf.BaseFont;
-import com.itextpdf.text.pdf.PdfContentByte;
-import com.itextpdf.text.pdf.PdfDictionary;
-import com.itextpdf.text.pdf.PdfName;
-import com.itextpdf.text.pdf.PdfReader;
-import com.itextpdf.text.pdf.PdfStamper;
-import com.itextpdf.text.pdf.parser.ContentByteUtils;
-import com.itextpdf.text.pdf.parser.ImageRenderInfo;
-import com.itextpdf.text.pdf.parser.PdfContentStreamProcessor;
-import com.itextpdf.text.pdf.parser.RenderListener;
-import com.itextpdf.text.pdf.parser.TextRenderInfo;
+import com.itextpdf.text.pdf.*;
+import com.itextpdf.text.pdf.parser.*;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.entity.TextdictInfo;
 import org.springblade.manager.vo.PDFIndexInfo;
-import org.springblade.manager.vo.TextdictInfoVO;
 import org.springblade.system.cache.ParamCache;
 
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 public class PdfAddimgUtil {
 
     public static void pdfAddImgInfo(String pdfUrl, String keyword, Map<Long, TextdictInfo> textMap) throws Exception {
@@ -51,6 +36,7 @@ public class PdfAddimgUtil {
                 try {
                     inputStream.close();
                 } catch (IOException e) {
+                    inputStream.close();
                 }
             }
         }