|
@@ -1,541 +1,166 @@
|
|
package org.springblade.manager.controller;
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
-import com.aspose.cells.SaveFormat;
|
|
|
|
-import com.spire.xls.CellRange;
|
|
|
|
-import com.spire.xls.Workbook;
|
|
|
|
-import com.spire.xls.Worksheet;
|
|
|
|
-import com.sun.image.codec.jpeg.JPEGCodec;
|
|
|
|
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
|
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
-import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
|
|
|
|
+
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.select.Elements;
|
|
import org.jsoup.select.Elements;
|
|
-import org.springblade.common.utils.CommonUtil;
|
|
|
|
import org.springblade.core.tool.utils.FileUtil;
|
|
import org.springblade.core.tool.utils.FileUtil;
|
|
import org.springblade.core.tool.utils.IoUtil;
|
|
import org.springblade.core.tool.utils.IoUtil;
|
|
-import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
|
|
|
|
|
-import javax.imageio.ImageIO;
|
|
|
|
-import java.awt.image.BufferedImage;
|
|
|
|
-import java.io.*;
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.regex.Matcher;
|
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileInputStream;
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class ExpaileHtml {
|
|
public class ExpaileHtml {
|
|
|
|
|
|
|
|
+ public static void main11(String[] args) throws FileNotFoundException {
|
|
|
|
+ List<File> list = FileUtil.list("/Users/hongchuangyanfa/Desktop/123456/");
|
|
|
|
+ int i = 0;
|
|
|
|
+ for(File file:list){
|
|
|
|
|
|
- public static void excelToPdf(String exUrl,String pdfUrl){
|
|
|
|
-
|
|
|
|
- org.apache.poi.ss.usermodel.Workbook ss = null;
|
|
|
|
- ByteArrayInputStream byteArrayInputStream = null;
|
|
|
|
- InputStream pdfInput = null;
|
|
|
|
- ByteArrayOutputStream outReport = null, bos = null;
|
|
|
|
- try{
|
|
|
|
- File file1 = ResourceUtil.getFile(exUrl);
|
|
|
|
- InputStream inputStream = new FileInputStream(file1);
|
|
|
|
- ss = WorkbookFactory.create(inputStream);
|
|
|
|
- for(int i = 0, l = ss.getNumberOfSheets(); i < l; i ++){
|
|
|
|
- Sheet sheet = ss.getSheetAt(i);
|
|
|
|
- //去掉表格虚线
|
|
|
|
- sheet.setPrintGridlines(false);
|
|
|
|
- //设置 整个工作表为一页
|
|
|
|
- sheet.setFitToPage(true);
|
|
|
|
- }
|
|
|
|
- outReport = new ByteArrayOutputStream();
|
|
|
|
- ss.write(outReport);
|
|
|
|
- byteArrayInputStream = new ByteArrayInputStream(outReport.toByteArray());
|
|
|
|
- com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(byteArrayInputStream);
|
|
|
|
- wb.save(pdfUrl,SaveFormat.PDF);
|
|
|
|
-
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } finally {
|
|
|
|
- if(bos != null){
|
|
|
|
- IoUtil.closeQuietly(bos);
|
|
|
|
- }
|
|
|
|
- if(outReport != null){
|
|
|
|
- IoUtil.closeQuietly(outReport);
|
|
|
|
- }
|
|
|
|
- if(pdfInput != null){
|
|
|
|
- IoUtil.closeQuietly(pdfInput);
|
|
|
|
- }
|
|
|
|
- if(byteArrayInputStream != null){
|
|
|
|
- IoUtil.closeQuietly(byteArrayInputStream);
|
|
|
|
- }
|
|
|
|
- if(ss != null){
|
|
|
|
- IoUtil.closeQuietly(ss);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //图片压缩
|
|
|
|
- public static void CompressImage(String imgUrl){
|
|
|
|
- try {
|
|
|
|
- //图片所在路径
|
|
|
|
- BufferedImage templateImage = ImageIO.read(new File(imgUrl));
|
|
|
|
- //原始图片的长度和宽度
|
|
|
|
- int height = templateImage.getHeight();
|
|
|
|
- int width = templateImage.getWidth();
|
|
|
|
-
|
|
|
|
- //通过比例压缩
|
|
|
|
- float scale = 0.5f;
|
|
|
|
-
|
|
|
|
- //通过固定长度压缩
|
|
|
|
- /*int doWithHeight = 100;
|
|
|
|
- int dowithWidth = 300;*/
|
|
|
|
-
|
|
|
|
- //压缩之后的长度和宽度
|
|
|
|
- int doWithHeight = (int) (scale * height);
|
|
|
|
- int dowithWidth = (int) (scale * width);
|
|
|
|
-
|
|
|
|
- BufferedImage finalImage = new BufferedImage(dowithWidth, doWithHeight, BufferedImage.TYPE_INT_RGB);
|
|
|
|
-
|
|
|
|
- finalImage.getGraphics().drawImage(templateImage.getScaledInstance(dowithWidth, doWithHeight, java.awt.Image.SCALE_SMOOTH), 0, 0, null);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //图片输出路径,以及图片名
|
|
|
|
- FileOutputStream fileOutputStream = new FileOutputStream(imgUrl);
|
|
|
|
- JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fileOutputStream);
|
|
|
|
- encoder.encode(finalImage);
|
|
|
|
- fileOutputStream.close();
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static void main11(String[] args) throws Exception {
|
|
|
|
- Workbook wb = new Workbook();
|
|
|
|
- String excelUrl = "/Users/hongchuangyanfa/Downloads/A15 检验申请批复单.xlsx";
|
|
|
|
- wb.loadFromMHtml(excelUrl);
|
|
|
|
- //获取工作表
|
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // sheet.saveToFile(thmlUrl3,"UTF-8");
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // sheet.saveToFile(thmlUrl3, FileFormat.PDF);
|
|
|
|
- // sheet.
|
|
|
|
-
|
|
|
|
- //获取工作表
|
|
|
|
-
|
|
|
|
- // wb.saveToFile(thmlUrl3, FileFormat.PDF);
|
|
|
|
-
|
|
|
|
- // byteArrayInputStream = new ByteArrayInputStream(outReport.toByteArray());
|
|
|
|
- /*com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(byteArrayInputStream);
|
|
|
|
-
|
|
|
|
- bos = new ByteArrayOutputStream();
|
|
|
|
- wb.save(bos, SaveFormat.PDF);
|
|
|
|
- bos.flush();*/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-/*
|
|
|
|
- System.out.println("xcc");
|
|
|
|
- File file1 = ResourceUtil.getFile("/Users/hongchuangyanfa/Desktop/privateUrl/1572868137710256128.html");
|
|
|
|
- String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
|
- Document doc = Jsoup.parse(htmlString);
|
|
|
|
-
|
|
|
|
- //解析
|
|
|
|
- Element table = doc.select("table").first();
|
|
|
|
- Elements trs = table.select("tr");
|
|
|
|
- Element element = trs.get(4).select("td").get(1);
|
|
|
|
- JSONArray objs = new JSONArray();
|
|
|
|
- Integer [] data= new Integer[2];
|
|
|
|
- data[0]=1;
|
|
|
|
- data[1]=2;
|
|
|
|
-
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- jsonObject.put("key",1);
|
|
|
|
- jsonObject.put("name","小明");
|
|
|
|
- objs.add(jsonObject);
|
|
|
|
- String checkbox = "<hc-form-checkbox-group :datas='"+Arrays.asList(data)+"' :objs="+objs+" > </hc-form-checkbox-group>";
|
|
|
|
- // element.empty().append(checkbox);
|
|
|
|
-
|
|
|
|
- System.out.println(Arrays.asList(data));
|
|
|
|
- System.out.println(objs);
|
|
|
|
- System.out.println(checkbox);
|
|
|
|
- element.empty().append(checkbox);
|
|
|
|
- File writefile = new File("/Users/hongchuangyanfa/Desktop/123654.html");
|
|
|
|
- FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
|
-*/
|
|
|
|
-
|
|
|
|
-/* List<String> data = new ArrayList<>();
|
|
|
|
- List<String> data2 = new ArrayList<>();
|
|
|
|
- data.add("1:2");
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- String[] intArray = new String[data.size()];
|
|
|
|
- int lastMax = 0;
|
|
|
|
- for (int h = 0; h < data.size() ; h++) {
|
|
|
|
- int mx1 = Integer.parseInt(data.get(h).split(":")[0]);
|
|
|
|
- int mx2 = Integer.parseInt(data.get(h).split(":")[1]);
|
|
|
|
- if(data2.size()==0){
|
|
|
|
- data2.add(data.get(0));
|
|
|
|
-
|
|
|
|
- }else{
|
|
|
|
- if(lastMax+1==mx1){
|
|
|
|
- int minVal = Integer.parseInt(data2.get(data2.size()-1).split(":")[0]);
|
|
|
|
- data2.remove(data2.size()-1);
|
|
|
|
- data2.add(minVal+":"+mx2);
|
|
|
|
- }else{
|
|
|
|
- data2.add(data.get(h));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- lastMax = mx2;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- System.out.println("开始");
|
|
|
|
- for (String s : data2) {
|
|
|
|
- System.out.println(s);
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /* String thmlUrl = "/Users/hongchuangyanfa/Desktop/C10.1.xlsx" ;
|
|
|
|
- String thmlUrl2 = "/Users/hongchuangyanfa/Desktop/C10.2.pdf" ;
|
|
|
|
- File file1 = ResourceUtil.getFile(thmlUrl);
|
|
|
|
-
|
|
|
|
- Workbook wb = new Workbook();
|
|
|
|
- wb.loadFromMHtml(new FileInputStream(file1));
|
|
|
|
- //获取工作表
|
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
|
- // System.out.println(sheet.getLastColumn());
|
|
|
|
- sheet.getCellRange(20,1).setText("1111");
|
|
|
|
- System.out.println(sheet.getCellRange(20,1).getText());
|
|
|
|
- sheet.saveToPdf(thmlUrl2);*/
|
|
|
|
-
|
|
|
|
- //指定URL路径
|
|
|
|
- // String url = "/Users/hongchuangyanfa/Desktop/privateUrl/1560160597855698944.html";
|
|
|
|
- //String url = "/Users/hongchuangyanfa/Desktop/privateUrl/1560108472350015488.html";
|
|
|
|
-
|
|
|
|
- //指定输出文档路径
|
|
|
|
- // String fileName = "/Users/hongchuangyanfa/Desktop/pdf/UrlToPdf.pdf";
|
|
|
|
-
|
|
|
|
- //指定插件路径
|
|
|
|
- // String pluginPath = "/Users/hongchuangyanfa/tool/plugins_mac";
|
|
|
|
-
|
|
|
|
- //设置插件路径
|
|
|
|
- // HtmlConverter.setPluginPath(pluginPath);
|
|
|
|
- //将URL转换为PDF595×842
|
|
|
|
- // HtmlConverter.convert(url, fileName, true, 1000000, new Size(842,595), new PdfMargins(0));
|
|
|
|
- // HtmlConverter.convert(url, fileName, true, 1000000, new Size(595,842), new PdfMargins(50,0,50,50 ));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //
|
|
|
|
- // HTMLOptions options = new HTMLOptions();
|
|
|
|
- // options.setTextMode();
|
|
|
|
-/* Workbook wb = new Workbook();
|
|
|
|
- wb.loadFromMHtml(file.getInputStream());
|
|
|
|
- //获取工作表
|
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
|
- Workbook wb = new Workbook();
|
|
|
|
- wb.loadFromMHtml(file.getInputStream());
|
|
|
|
- //获取工作表
|
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
|
- sheet.saveToHtml(thmlUrl);
|
|
|
|
- sheet.saveToHtml(thmlUrl);
|
|
|
|
-
|
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
|
- HTMLOptions options = new HTMLOptions();
|
|
|
|
- options.setImageEmbedded(true);
|
|
|
|
- sheet.saveToHtml("F:\\ToHtmlWithImageEmbeded.html", options);*/
|
|
|
|
|
|
+ System.out.println(file.getName());
|
|
|
|
+ if(file.getName().length()>=16 ){
|
|
|
|
+ System.out.println(file.getPath()+"__"+(i++));
|
|
|
|
+ EexpaileInfo(file.getPath());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /* String html_url = "/Users/hongchuangyanfa/Desktop/123456/1582973763253698560.html";
|
|
|
|
+ EexpaileInfo(html_url);*/
|
|
}
|
|
}
|
|
|
|
|
|
- // 清表上传解析方案
|
|
|
|
- public static void expailHtmlInfo(String thmlUrl) throws FileNotFoundException {
|
|
|
|
-
|
|
|
|
- // 读取
|
|
|
|
- File file1 = ResourceUtil.getFile(thmlUrl);
|
|
|
|
- String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- 解析
|
|
|
|
- 1 解析样式
|
|
|
|
- 2 计算坐标
|
|
|
|
- 3 计算区域位置
|
|
|
|
- */
|
|
|
|
|
|
+ public static void EexpaileInfo(String htmlUrl) throws FileNotFoundException {
|
|
|
|
+ // String html_url = "/Users/hongchuangyanfa/Desktop/1582973587797573632.html";
|
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(htmlUrl));
|
|
// 样式集合
|
|
// 样式集合
|
|
Document doc = Jsoup.parse(htmlString);
|
|
Document doc = Jsoup.parse(htmlString);
|
|
- // 解析 style
|
|
|
|
- Map<String, String> styleMap = getHtmlStyle(doc);
|
|
|
|
-
|
|
|
|
//解析
|
|
//解析
|
|
Element table = doc.select("table").first();
|
|
Element table = doc.select("table").first();
|
|
Elements trs = table.select("tr");
|
|
Elements trs = table.select("tr");
|
|
|
|
|
|
- // 获取总行列数
|
|
|
|
- int maxCol = doc.select("Col").size();
|
|
|
|
- String[] rowData = new String[trs.size() + 1];
|
|
|
|
-
|
|
|
|
- // 行的状态
|
|
|
|
- boolean index_state = false;
|
|
|
|
- // 区域划分表示
|
|
|
|
- int xy_type = 1;
|
|
|
|
|
|
+ int sgY = 0;
|
|
|
|
+ int sgY_st = 0;
|
|
|
|
+ int jlY = 0;
|
|
|
|
|
|
- // 解析 excel元素集合
|
|
|
|
- Set<String> colTitleSet = new HashSet<>();
|
|
|
|
-
|
|
|
|
-// 标题集合信息
|
|
|
|
- List<Map<String, String>> zikey = new ArrayList<>();
|
|
|
|
- for (int i = 0; i <= trs.size() - 1; i++) {
|
|
|
|
|
|
+ String titt = "";
|
|
|
|
+ String first = "";
|
|
|
|
+ String end = "";
|
|
|
|
+ for (int i = 6; i <= trs.size() - 1; i++) {
|
|
Element tr = trs.get(i);
|
|
Element tr = trs.get(i);
|
|
Elements tds = tr.select("td");
|
|
Elements tds = tr.select("td");
|
|
- String xyInof = getTrInfo(tds, styleMap, index_state, xy_type, maxCol);
|
|
|
|
- xy_type = Integer.parseInt(xyInof.split(",")[0]);
|
|
|
|
- tr.attr("xy_type", xyInof);
|
|
|
|
- index_state = Boolean.parseBoolean(xyInof.split(",")[1]);
|
|
|
|
- boolean isMaxCol = Integer.parseInt(xyInof.split(",")[2]) == maxCol;
|
|
|
|
- // 计算单元格坐标
|
|
|
|
- int x = 0;
|
|
|
|
- for (int j = 0; j < tds.size(); j++) {
|
|
|
|
- {
|
|
|
|
- Element data = tds.get(j);
|
|
|
|
- int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
|
|
|
|
- int rowspan = data.attr("ROWSPAN").equals("") ? 0 : Integer.parseInt(data.attr("ROWSPAN"));
|
|
|
|
- Map<String, String> textObject = new HashMap<>();
|
|
|
|
- // 计算
|
|
|
|
- int x1 = 0;
|
|
|
|
- int x2 = 0;
|
|
|
|
- int y1 = 0;
|
|
|
|
- int y2 = 0;
|
|
|
|
|
|
+ if (tds.size() >= 1) {
|
|
|
|
+ String titName = tds.get(0).text().replaceAll(" ", "");
|
|
|
|
+ if (titName.equals("施工单位自评意见")) {
|
|
|
|
+ sgY = i + Integer.parseInt(tds.get(0).attr("rowspan"));
|
|
|
|
+ titt = "施工单位自评意见";
|
|
|
|
+ }
|
|
|
|
|
|
- String textInfo = data.text().trim().replaceAll(" ", "");
|
|
|
|
|
|
+ if (titName.equals("监理单位复核意见")) {
|
|
|
|
+ sgY = i + Integer.parseInt(tds.get(0).attr("rowspan"));
|
|
|
|
+ titt = "监理单位复核意见";
|
|
|
|
+ }
|
|
|
|
|
|
- y1 = i + 1;
|
|
|
|
- //x 移位 算法
|
|
|
|
- String getRowInfo = rowData[y1];
|
|
|
|
- if (getRowInfo != null) {
|
|
|
|
- String[] dataInfo2 = getRowInfo.split(",");
|
|
|
|
- if (getRowInfo.indexOf("1") >= 0 && j == 0) {
|
|
|
|
- x = Integer.parseInt(dataInfo2[0].split(":")[1]);
|
|
|
|
- } else {
|
|
|
|
- for (int m = 0; m < dataInfo2.length; m++) {
|
|
|
|
- int mx1 = Integer.parseInt(dataInfo2[m].split(":")[0]);
|
|
|
|
- int mx2 = Integer.parseInt(dataInfo2[m].split(":")[1]);
|
|
|
|
- if ((mx1 - x) == 1 && mx1 > x) {
|
|
|
|
- x = mx2;
|
|
|
|
|
|
+ if (sgY >= 1 && i < sgY - 1) {
|
|
|
|
+ for (int j = 0; j < tds.size(); j++) {
|
|
|
|
+ String tdStr = "";
|
|
|
|
+ String trTitleName = "";
|
|
|
|
+ Element element = tds.get(j);
|
|
|
|
+
|
|
|
|
+ first +=element.text();
|
|
|
|
+
|
|
|
|
+ // 中间计算方式
|
|
|
|
+ if (element.html().indexOf("el-input") >= 0) {
|
|
|
|
+ // 获取开始的标题
|
|
|
|
+
|
|
|
|
+ for(int k=i ;k<sgY ; k++){
|
|
|
|
+ Element atr = trs.get(k);
|
|
|
|
+ Elements atds = atr.select("td");
|
|
|
|
+ int m = 0;
|
|
|
|
+ if(k==i){
|
|
|
|
+ m=j+1;
|
|
|
|
+ }else{
|
|
|
|
+ m = 0;
|
|
|
|
+ }
|
|
|
|
+ for(int l=m;l<atds.size();l++){
|
|
|
|
+ Element element1 = atds.get(l);
|
|
|
|
+ if(element1.html().indexOf("el-input")>=0){
|
|
|
|
+ break;
|
|
|
|
+ }else{
|
|
|
|
+ end = end+element1.text();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // X 坐标
|
|
|
|
- if (colspan == 0) {
|
|
|
|
- x1 = x + 1;
|
|
|
|
- x2 = x + 1;
|
|
|
|
- x = x + 1;
|
|
|
|
- } else {
|
|
|
|
- x1 = x + 1;
|
|
|
|
- x2 = x + colspan;
|
|
|
|
- x = x + colspan;
|
|
|
|
- }
|
|
|
|
|
|
+ tdStr = first+end;
|
|
|
|
|
|
- //x y 坐标
|
|
|
|
- if (rowspan == 0) {
|
|
|
|
- y2 = i + 1;
|
|
|
|
- } else {
|
|
|
|
- y2 = i + rowspan;
|
|
|
|
- for (int k = 0; k < rowspan - 1; k++) {
|
|
|
|
- String dataInfo = rowData[k + 2 + i];
|
|
|
|
- if (dataInfo == null) {
|
|
|
|
- dataInfo = x1 + ":" + x2;
|
|
|
|
- } else {
|
|
|
|
- String[] dataInfo2 = dataInfo.split(",");
|
|
|
|
- String dataInfo3 = dataInfo2[dataInfo2.length - 1];
|
|
|
|
- int mx1 = Integer.parseInt(dataInfo3.split(":")[0]);
|
|
|
|
- int mx2 = Integer.parseInt(dataInfo3.split(":")[1]);
|
|
|
|
- if (mx2 + 1 == x1) {
|
|
|
|
- dataInfo = dataInfo + "," + mx1 + ":" + x2;
|
|
|
|
- } else {
|
|
|
|
- dataInfo = dataInfo + "," + x1 + ":" + x2;
|
|
|
|
- }
|
|
|
|
|
|
+ if ( first.indexOf("检验点") >= 0 && first.indexOf("合格率均不小于") >= 0 && end.indexOf("%") >= 0) {
|
|
|
|
+ trTitleName = titt + "_合格率";
|
|
}
|
|
}
|
|
- rowData[k + 2 + i] = dataInfo;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
- // System.out.println(x1+"_"+x2+"_"+y1+"_"+y2+"_"+textInfo);
|
|
|
|
- // data.text(textInfo.replaceAll(" ",""));
|
|
|
|
- if (!textInfo.isEmpty() && !textInfo.equals("/") && !(textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0) && !textInfo.equals("—") && !textInfo.equals("-")) { // 标题区域
|
|
|
|
- Map<String, String> dataInfo = new HashMap<String, String>();
|
|
|
|
- dataInfo.put("name", textInfo);
|
|
|
|
- dataInfo.put("x1", x1 + "");
|
|
|
|
- dataInfo.put("x2", x2 + "");
|
|
|
|
- dataInfo.put("y1", y1 + "");
|
|
|
|
- dataInfo.put("y2", y2 + "");
|
|
|
|
- dataInfo.put("xytype", xy_type + "");
|
|
|
|
- zikey.add(dataInfo);
|
|
|
|
- } else { //空行
|
|
|
|
- List<Map<String, String>> left = new ArrayList<>();
|
|
|
|
- List<Map<String, String>> top = new ArrayList<>();
|
|
|
|
- for (int k = 0; k < zikey.size(); k++) {
|
|
|
|
- String name = zikey.get(k).get("name");
|
|
|
|
- // String name2 = zikey.get(k).get("name").replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
|
- int xx1 = Integer.parseInt(zikey.get(k).get("x1"));
|
|
|
|
- int xx2 = Integer.parseInt(zikey.get(k).get("x2"));
|
|
|
|
- int yy1 = Integer.parseInt(zikey.get(k).get("y1"));
|
|
|
|
- int yy2 = Integer.parseInt(zikey.get(k).get("y2"));
|
|
|
|
- int xytype2 = Integer.parseInt(zikey.get(k).get("xytype"));
|
|
|
|
- // 左匹配
|
|
|
|
- if (yy1 <= y1 && yy2 >= y2 && xx2 < x1 && xytype2 == xy_type) {
|
|
|
|
- left.add(zikey.get(k));
|
|
|
|
|
|
+ if (first.indexOf("不合格点的质量") >= 0 && end.indexOf("有关规范或设计要求") >= 0) {
|
|
|
|
+ trTitleName = titt + "_是否符合有关规范或设计要求的限值";
|
|
}
|
|
}
|
|
- //向 上 匹配
|
|
|
|
- if (index_state) {
|
|
|
|
- if (xx1 <= x1 && xx2 >= x2 && yy2 < y1 && xytype2 == xy_type) {
|
|
|
|
- top.add(zikey.get(k));
|
|
|
|
|
|
+
|
|
|
|
+ if (first.indexOf("各项报验资料") >= 0 && end.indexOf("的要求") >= 0 && end.indexOf("SL") >= 0) {
|
|
|
|
+ if(end.indexOf("。")>=0){
|
|
|
|
+ end= end.substring(0,end.indexOf("。"));
|
|
}
|
|
}
|
|
|
|
+ trTitleName = titt + "_报验资料是否满足" + end;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- String inputText = "";
|
|
|
|
- // 特征值赛选 规则
|
|
|
|
- for (int k = 0; k < left.size(); k++) { // 左计算
|
|
|
|
- String name = left.get(k).get("name");//.replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
|
- int xx1 = Integer.parseInt(left.get(k).get("x1"));
|
|
|
|
- int xx2 = Integer.parseInt(left.get(k).get("x2"));
|
|
|
|
- int yy1 = Integer.parseInt(left.get(k).get("y1"));
|
|
|
|
- int yy2 = Integer.parseInt(left.get(k).get("y2"));
|
|
|
|
- if (index_state) { // 正向规则匹配
|
|
|
|
- inputText += name + "_";
|
|
|
|
- } else {
|
|
|
|
- if (x1 - xx2 <= 1 && y1 == yy2) {
|
|
|
|
- inputText = name;
|
|
|
|
|
|
+
|
|
|
|
+ if (first.indexOf("质量等级评定为") >= 0 && end.indexOf("。") >= 0) {
|
|
|
|
+ if(first.indexOf("。")>=0){
|
|
|
|
+ first= first.substring(first.indexOf("。")+1,first.length());
|
|
}
|
|
}
|
|
|
|
+ trTitleName = titt + "_" + first.substring(0, first.length() - 2);
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- // 特征值赛选 规则
|
|
|
|
- if (top != null && top.size() >= 1) {
|
|
|
|
- for (int k = 0; k < top.size(); k++) { // 向上计算
|
|
|
|
- String name = top.get(k).get("name");//.replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
|
- int xx1 = Integer.parseInt(top.get(k).get("x1"));
|
|
|
|
- int xx2 = Integer.parseInt(top.get(k).get("x2"));
|
|
|
|
- int yy1 = Integer.parseInt(top.get(k).get("y1"));
|
|
|
|
- int yy2 = Integer.parseInt(top.get(k).get("y2"));
|
|
|
|
- inputText += name + "_";
|
|
|
|
|
|
+ // 2
|
|
|
|
+ if (first.indexOf("合格")>=0 &&first.indexOf("其中优良") >= 0 && end.indexOf("%") >= 0) {
|
|
|
|
+ trTitleName = titt + "_"+first.substring(first.indexOf("其中优良")+2,first.indexOf("占")+1)+"比";
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- if (inputText != null && inputText != "" && inputText.indexOf("_") >= 0) {
|
|
|
|
- inputText = inputText.substring(0, inputText.lastIndexOf("_"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 计算当前 输入框 标题匹配原则(左 - 上- 下)
|
|
|
|
- // System.out.println(x1+"_"+x2+","+y1+"_"+y2+"=="+textInfo+"=left"+left.toString() +"===top"+top.toString()+"__index_state="+index_state+"inputtext="+inputText);
|
|
|
|
-
|
|
|
|
- // 设置文本信息
|
|
|
|
- if (textInfo.indexOf("年") >= 0 && textInfo.indexOf("月") >= 0 && textInfo.indexOf("日") >= 0) {
|
|
|
|
- data.empty().append("<input type='time' style='width:100%;height:100%' placeholder=''> </input>");
|
|
|
|
- colTitleSet.add(inputText + "签字时间");
|
|
|
|
- } else {
|
|
|
|
- if (index_state) {
|
|
|
|
- data.empty().append("<input type='text' style='width:100%;height:100%' placeholder='" + inputText + "' > </input>");
|
|
|
|
- } else {
|
|
|
|
- if (j == 0) {
|
|
|
|
- if (colspan == maxCol && i >= 1 && i <= 2) {
|
|
|
|
- data.empty().append("<input type='text' style='width:100%;height:100%' placeholder='" + inputText + "'> </input>");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Element bforData = tds.get(j - 1);
|
|
|
|
- if (!bforData.text().isEmpty()) {
|
|
|
|
- data.empty().append("<input type='text' style='width:100%;height:100%' placeholder='" + inputText + "'> </input>");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (first.indexOf("主要工序达到") >= 0 && end.indexOf("等级") >= 0) {
|
|
|
|
+ trTitleName = titt + "工序等级";
|
|
|
|
+ }
|
|
|
|
+ // 3
|
|
|
|
+ if (first.indexOf("单元工程") >= 0 && end.indexOf("要求") >= 0 && first.indexOf("符合") >= 0) {
|
|
|
|
+ trTitleName = titt + "_设计要求";
|
|
|
|
+ }
|
|
|
|
+ if (end.indexOf("100%合格") >= 0 ) {
|
|
|
|
+ trTitleName = titt + "_合格数量";
|
|
}
|
|
}
|
|
- colTitleSet.add(inputText);
|
|
|
|
|
|
+
|
|
|
|
+ System.out.println(i+","+j+"="+trTitleName);
|
|
|
|
+ first="";
|
|
|
|
+ end = "";
|
|
}
|
|
}
|
|
|
|
+ element.removeAttr("title");
|
|
|
|
+ element.attr("title", trTitleName);
|
|
}
|
|
}
|
|
- // data.text(textInfo.replaceAll(" ",""));
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (String keys : colTitleSet) {
|
|
|
|
- System.out.println(keys.replaceAll("[^(\u4E00-\u9FA5_)]", ""));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 保存
|
|
|
|
- File writefile = new File("/Users/hongchuangyanfa/Desktop/123654.html");
|
|
|
|
- FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //计算区域坐标
|
|
|
|
- public static String getTrInfo(Elements tds, Map<String, String> styleMap, boolean index_state, Integer xy_type, int maxCol) {
|
|
|
|
-
|
|
|
|
- int x_width = 0;
|
|
|
|
- int y_width = 0;
|
|
|
|
- int text_width = 0;
|
|
|
|
- int width = 0;
|
|
|
|
-
|
|
|
|
- //区域计算
|
|
|
|
- for (int j = 0; j < tds.size(); j++) {
|
|
|
|
- Element data = tds.get(j);
|
|
|
|
- String keyId = data.attr("class");
|
|
|
|
-
|
|
|
|
- int colspan = data.attr("COLSPAN").equals("") ? 1 : Integer.parseInt(data.attr("COLSPAN"));
|
|
|
|
- String classInfo = styleMap.get(keyId);
|
|
|
|
- if (classInfo == null) {
|
|
|
|
- classInfo = data.attr("style");
|
|
|
|
- } else {
|
|
|
|
- data.removeAttr("class");
|
|
|
|
- data.attr("style", styleMap.get(keyId).replaceAll("break-word", "inherit"));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 计算线开始
|
|
|
|
- if (classInfo.indexOf("border-left-style") >= 0 && classInfo.indexOf("border-top-style") >= 0 && classInfo.indexOf("border-bottom-style") >= 0 && classInfo.indexOf("border-right-style") >= 0) {
|
|
|
|
- x_width += colspan;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 计算结束
|
|
|
|
- if (classInfo.indexOf("border-left-style") < 0 && (classInfo.indexOf("border-top-style") < 0 || classInfo.indexOf("border-top-style") >= 0) && classInfo.indexOf("border-bottom-style") < 0 && classInfo.indexOf("border-right-style") < 0) {
|
|
|
|
- y_width += colspan;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String name = data.text().replaceAll("[^\u4E00-\u9FA5]", "");
|
|
|
|
- if (!name.isEmpty()) {
|
|
|
|
- text_width += colspan;
|
|
|
|
- }
|
|
|
|
- width += colspan;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 在区域内
|
|
|
|
- if (index_state) {
|
|
|
|
- //是否需要改变
|
|
|
|
- if (maxCol == y_width) {
|
|
|
|
- index_state = false;
|
|
|
|
- xy_type += 1;
|
|
|
|
- }
|
|
|
|
- if (maxCol == text_width) {
|
|
|
|
- xy_type += 1;
|
|
|
|
- }
|
|
|
|
- } else { // 区域外
|
|
|
|
- if (maxCol == x_width) {
|
|
|
|
- index_state = true;
|
|
|
|
- xy_type += 1;
|
|
|
|
|
|
+ if ((sgY >= 1 && i == sgY - 1) || (jlY >= 1 && i == jlY - 1)) {
|
|
|
|
+ if (tds.get(0).html().indexOf("el-input") >= 0) {
|
|
|
|
+ tds.get(0).removeAttr("title");
|
|
|
|
+ tds.get(0).attr("title", "施工单位合同章");
|
|
|
|
+ }
|
|
|
|
+ if (tds.get(1).html().indexOf("el-input") >= 0) {
|
|
|
|
+ tds.get(1).removeAttr("title");
|
|
|
|
+ tds.get(1).attr("title", "施工单位个人签字");
|
|
|
|
+ }
|
|
|
|
+ if (tds.get(2).html().indexOf("el-date-picker") >= 0) {
|
|
|
|
+ tds.get(2).removeAttr("title");
|
|
|
|
+ tds.get(2).attr("title", "日期施工单位");
|
|
|
|
+ }
|
|
|
|
+ titt = "";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return xy_type + "," + index_state + "," + width;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 获取解析样式
|
|
|
|
- public static Map<String, String> getHtmlStyle(Document doc) {
|
|
|
|
- Map<String, String> styleMap = new HashMap<>();
|
|
|
|
- Element style = doc.select("style").first();
|
|
|
|
- Matcher cssMatcher = Pattern.compile("(\\w+)\\s*[{]([^}]+)[}]").matcher(style.html());
|
|
|
|
- while (cssMatcher.find()) {
|
|
|
|
- styleMap.put(cssMatcher.group(1), cssMatcher.group(2));
|
|
|
|
- }
|
|
|
|
- return styleMap;
|
|
|
|
|
|
+ // File writefile = new File(htmlUrl);
|
|
|
|
+ // FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
|
+ System.out.println("完成");
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|