Browse Source

2023 09 13 bug修改

zhuwei 1 year ago
parent
commit
d78904e485

+ 4 - 4
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/EVisaServiceImpl.java

@@ -239,14 +239,14 @@ public class EVisaServiceImpl implements EVisaService {
                 String ids = String.join(",", eVisaConfigList);
                 String sqlinfo = "SELECT a.id,a.pyzbx,a.pyzby,b.signature_file_url,b.id as sfId,b.certificate_password,b.certificate_user_name from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + contractId + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + ids + ")";
                 List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlinfo);
-
+                System.out.println("合同-"+contractId+"--"+sqlinfo);
 
                 //准备签章策略
                 List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
                 for (Map<String, Object> eVisaConfig : maps) {
                     //设置签章策略
                     SealStrategyVO vo = new SealStrategyVO();
-                    vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + eVisaConfig.get("id"));
+                    vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + eVisaConfig.get("sfId"));
                     vo.setSealPassword(eVisaConfig.get("certificate_password")+"");
                     vo.setSealPerson(eVisaConfig.get("certificate_user_name")+"" + System.currentTimeMillis());
                     //设置签字文件
@@ -425,9 +425,9 @@ public class EVisaServiceImpl implements EVisaService {
                 }
                 String contractId = this.taskClient.queryTaskContractId(task.getParallelProcessInstanceId());
                 String ids = String.join(",", eVisaConfigList);
-                String sqlinfo = " SELECT a.id,a.pyzbx ,a.pyzby,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + task.getUserId() + "' and is_deleted=0  ) as signature_file_url from m_textdict_info a where a.id in (" + ids + ")  and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + contractId + " and user_id=" + task.getUserId() + " and a.is_deleted=0 )";
+                String sqlinfo = " SELECT a.id,a.pyzbx ,a.pyzby,(SELECT signature_file_url from m_sign_pfx_file where is_register=1 and certificate_user_id='" + task.getUserId() + "' and is_deleted=0  ) as signature_file_url from m_textdict_info a where  a.type =2 and a.id in (" + ids + ")  and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + contractId + " and user_id=" + task.getUserId() + " and c.is_deleted=0 )";
                 List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlinfo);
-                System.out.println("user-id"+task.getUserId()+"--SQL="+sqlinfo);
+                System.out.println("个人-user-id"+task.getUserId()+"--SQL="+sqlinfo);
                 if (maps == null || maps.size() <= 0) {
                     //没有签章,不执行电签
                     RedisTemplate.delete("sign-" + task.getFormDataId());

+ 59 - 7
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PDFUtils.java

@@ -1,6 +1,9 @@
 package org.springblade.evisa.utils;
 
 import com.spire.pdf.PdfDocument;
+import com.spire.pdf.PdfPageBase;
+import com.spire.pdf.general.find.PdfTextFind;
+import com.spire.pdf.general.find.PdfTextFindCollection;
 import com.spire.pdf.utilities.PdfTable;
 import com.spire.pdf.utilities.PdfTableExtractor;
 
@@ -13,6 +16,7 @@ import java.util.List;
 
 
 public class PDFUtils {
+/*
     public static List<String> getPdfSignIds(String pdfUrl) {
         PdfDocument pdf = new PdfDocument();
         List<String> eVisaConfigList = new ArrayList<>();
@@ -35,6 +39,7 @@ public class PDFUtils {
                             for (int j = 0; j < column; j++) {
                                 //获取表格中的文本内容
                                 String text = table.getText(i, j);
+                                System.out.println(text);
                                 String textVal[] = text.split(" ");
                                 for (String textStr : textVal) {
                                     if (textStr.length() >= 15 && Func.isNumeric(textStr)) {
@@ -52,14 +57,61 @@ public class PDFUtils {
         }
         return eVisaConfigList;
     }
+*/
 
-    public static void main1231(String[] args) {
-        //getPdfSignIds("https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230911/c8cab7dd0eebf9b11579223e860d0320.pdf");
+
+    public static List<String> getPdfSignIds(String pdfUrl) {
+        PdfDocument pdf = new PdfDocument();
+        List<String> eVisaConfigList = new ArrayList<>();
+        try {
+            InputStream ossInputStream = CommonUtil.getOSSInputStream(pdfUrl);
+            //加载PDF文档
+            pdf.loadFromStream(ossInputStream);
+
+            for(int i= 0;i<pdf.getPages().getCount();i++){
+                PdfPageBase page = pdf.getPages().get(i);
+                PdfTextFindCollection allText = page.findAllText();
+                PdfTextFind[] finds = allText.getFinds();
+                for(int k=0;k<finds.length;k++){
+                    String textStr = finds[k].getMatchText();
+                    if (textStr.length() >= 15 && Func.isNumeric(textStr)) {
+                        System.out.println(textStr);
+                        eVisaConfigList.add(textStr);
+                    }
+                }
+            }
+            ossInputStream.close();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return eVisaConfigList;
+    }
+
+    public static void main123(String[] args) {
+        String pdfUrl= "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230913/0193a0611867a1828164bb0abc65584c.pdf";
         List<String> eVisaConfigList = new ArrayList<>();
-        eVisaConfigList.add("1235677");
-        eVisaConfigList.add("123567722");
-        System.out.println(eVisaConfigList.toArray());
-        System.out.println(Func.toStr(eVisaConfigList));
-        System.out.println(String.join(",", eVisaConfigList));
+        try {
+            PdfDocument pdf = new PdfDocument();
+            InputStream ossInputStream = CommonUtil.getOSSInputStream(pdfUrl);
+            //加载PDF文档
+            pdf.loadFromStream(ossInputStream);
+
+            for(int i= 0;i<pdf.getPages().getCount();i++){
+                PdfPageBase page = pdf.getPages().get(i);
+               // System.out.println( page.extractText(true));
+                String text= page.extractText(false);
+                PdfTextFindCollection allText = page.findAllText();
+                PdfTextFind[] finds = allText.getFinds();
+                for(int k=0;k<finds.length;k++){
+                    String textStr = finds[k].getMatchText();
+                    if (textStr.length() >= 15 && Func.isNumeric(textStr)) {
+                        System.out.println(textStr);
+                        eVisaConfigList.add(textStr);
+                    }
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
     }
 }

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

@@ -15,17 +15,19 @@ import com.mixsmart.utils.FormulaUtils;
 import com.mixsmart.utils.ListUtils;
 import com.mixsmart.utils.RegexUtils;
 import com.spire.xls.FileFormat;
-import com.spire.xls.Worksheet;
 import lombok.AllArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.poi.hssf.usermodel.HSSFRichTextString;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.IOUtils;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -1403,7 +1405,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
         //获取excel流 和 html流
         InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
-        Workbook workbook = WorkbookFactory.create(exceInp);
+
+        Workbook workbook=null;
+        int index = excelTab.getFileUrl().lastIndexOf(".");
+        String suffix = excelTab.getFileUrl().substring(index);
+
+        if (".xls".equals(suffix)) {
+            workbook = new HSSFWorkbook(exceInp);
+        } else if (".xlsx".equals(suffix)) {
+            workbook = new XSSFWorkbook(exceInp);
+        }
 
         //获取工作表
         Sheet sheet = workbook.getSheetAt(0);
@@ -1633,12 +1644,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                 redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
                                 redFont.setFontHeightInPoints(Short.valueOf("1"));//设置字体大小
                                 redFont.setFontName(oldfontAt.getFontName());//设置字体
-                                CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
-                                newStyle.cloneStyleFrom(cell.getCellStyle());
-                                newStyle.setFont(redFont);
-                                newStyle.setShrinkToFit(true);
-                                cell.setCellStyle(newStyle);
-                                cell.setCellValue(dqid);
+                                String CellValue = cell.getStringCellValue().trim();
+
+                                if(CellValue!=null && StringUtils.isNotEmpty(CellValue)){
+                                    RichTextString ts= new HSSFRichTextString(CellValue + "--"+dqid);
+                                   // ts.applyFont(0,CellValue.length(),oldfontAt);
+                                 //   ts.applyFont(10,ts.length(),redFont);
+                                    cell.setCellValue(ts);
+                                }else{
+                                    CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+                                    newStyle.cloneStyleFrom(cell.getCellStyle());
+                                    newStyle.setFont(redFont);
+                                    newStyle.setShrinkToFit(true);
+                                    cell.setCellStyle(newStyle);
+                                    cell.setCellValue(dqid);
+                                }
                             }
                         }
                     }

+ 0 - 65
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/ExcelInfoUtils.java

@@ -9,7 +9,6 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -32,70 +31,6 @@ import java.util.Map;
 
 public class ExcelInfoUtils {
 
-    public static void main1234(String[] args) throws Exception {
-        String fileUrl = "/Users/hongchuangyanfa/Downloads/29ed5438d62d301bf290b908acf3bdbb.xlsx";
-        InputStream exceInp = new FileInputStream(new File(fileUrl));
-
-        org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(exceInp);
-
-        //获取工作表
-        Sheet sheet = workbook.getSheetAt(0);
-        sheet.setForceFormulaRecalculation(true);
-
-        Row row = sheet.getRow(34);
-
-        Cell cell = sheet.getRow(34).getCell(1);
-
-        System.out.println(cell.getStringCellValue());
-        // 解析原始excel
-        Workbook wb = new Workbook();
-        wb.loadFromMHtml(fileUrl);
-        Worksheet sheet2 = wb.getWorksheets().get(0);
-
-        CellRange cellRange = sheet2.getCellRange(35, 2);
-        System.out.println(cellRange.getText());
-
-        //sheet.saveToHtml("/Users/hongchuangyanfa/Desktop/pdf/test.html");
-    }
-
-    public static void main123(String[] args) throws FileNotFoundException {
-        String excelUrl = "/Users/hongchuangyanfa/Downloads/C10.28隧道注浆施工记录表(1).xlsx";
-        String old_html = "/Users/hongchuangyanfa/Desktop/pdf/old_html.html";
-        String old_xlsx = "/Users/hongchuangyanfa/Desktop/pdf/old_html.xlsx";
-        File file = new File(excelUrl);
-        InputStream fileInputStream = new FileInputStream(file);
-      //  excelInfo(fileInputStream,old_xlsx,old_html,"1");
-
-
-        // 解析原始excel
-        Workbook wb = new Workbook();
-        wb.loadFromMHtml(excelUrl);
-        Worksheet sheet = wb.getWorksheets().get(0);
-
-        CellRange[] mergedCells = sheet.getCells();
-        for(int i=0;i<mergedCells.length;i++){
-            CellRange oldcell =mergedCells[i];
-           // sheet.get(oldcell.getRow(),oldcell.getColumn()).getDataValidation().setErrorMessage("");
-          //  sheet.get(oldcell.getRow(),oldcell.getColumn(),oldcell.getLastRow(),oldcell.getLastColumn()).getDataValidation().setErrorMessage("");
-            oldcell.getDataValidation().setErrorMessage("");
-        }
-
-        CellRange[] mergedCells1 = sheet.getMergedCells();
-        for(int i=0;i<mergedCells1.length;i++) {
-            CellRange oldcell = mergedCells1[i];
-            oldcell.getDataValidation().setErrorMessage(i+"");
-        }
-
-        CellRange[] cells = sheet.getCells();
-        for(int i=0;i< cells.length;i++){
-            CellRange oldcell = cells[i];
-            System.out.println(oldcell.getRow()+"---"+oldcell.getColumn()+"---="+oldcell.getText()+"---x="+oldcell.getDataValidation().getErrorMessage());
-        }
-
-        String new_html = "/Users/hongchuangyanfa/Desktop/pdf/new_html.html";
-        String new_xlsx = "/Users/hongchuangyanfa/Desktop/pdf/new_html.xlsx";
-       // excelInfo(old_xlsx,new_xlsx,new_html);
-    }
 
     public static void excelInfo(InputStream inputStream, String excelURL, String htmlUrl,String type) {
         try {