zhuwei 2 жил өмнө
parent
commit
70b8068088

+ 83 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/test.java

@@ -5,25 +5,101 @@ import cn.hutool.extra.pinyin.PinyinUtil;
 import cn.hutool.extra.pinyin.engine.pinyin4j.Pinyin4jEngine;
 import com.alibaba.druid.sql.repository.SchemaObjectType;
 import com.alibaba.excel.util.DateUtils;
+import com.aspose.cells.HtmlSaveOptions;
+import com.spire.xls.*;
+import com.spire.xls.collections.PicturesCollection;
+import com.spire.xls.core.spreadsheet.HTMLOptions;
+import io.swagger.models.auth.In;
+import org.apache.commons.lang.StringUtils;
 import org.jsoup.Connection;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.tool.utils.IoUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
 
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 public class test {
 
-    /*public static void main(String[] args) {
-        Map<String, Map<String, String>> map = getWeather("chongqing", "202304");
-//        String str = LocalDateTime.now().minusDays(1L).format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
-//        System.out.println(map.get(str));
-    }*/
+    public static void main1231(String[] args) throws Exception {
+
+        List<String> data = new ArrayList<>();
+
+        data.add("12_0");
+        data.add("13_0");
+        data.add("14_0");
+        data.add("15_0");
+        data.add("16_0");
+        data.add("10_0");
+        data.add("11_0");
+
+        int yindex;
+        int xindex;
+        if(false){ //纵向
+            yindex = 1;
+            xindex = 0;
+        } else { //横向
+            xindex = 1;
+            yindex = 0;
+        }
+
+        String dw[] = data.toArray(new String[data.size()]);
+        Map<Integer, List<String>> result = data.stream().filter(s -> s.indexOf("_")>=0).collect(Collectors.groupingBy(s -> Integer.parseInt(s.split("_")[yindex])));
+
+        Map<Integer, List<String>> collect = new LinkedHashMap<>();
+        result.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered(x -> collect.put(x.getKey(), x.getValue()));
+        int j=0;
+        for(Integer key: collect.keySet()){
+            List<String> datakey = collect.get(key);
+            List<String> ordList = datakey.stream().filter(s -> s.indexOf("_")>=0).sorted(Comparator.comparing(s -> Integer.parseInt(s.split("_")[xindex]))).collect(Collectors.toList());
+            for (String ord:ordList){
+                dw[j]=ord;
+                j++;
+            }
+        }
+
+        for (String da:dw){
+            System.out.println(da);
+        }
+
+
+      /*  String file_path = FileUtils.getSysLocalFileUrl()+"/pdf/";
+
+        String filecode = SnowFlakeUtil.getId() + "";
+        String thmlUrl = file_path + filecode + ".html";
+
+        InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl("/Users/hongchuangyanfa/Desktop/pdf/1688448159421825025.xlsx");
+        // 解析excel
+        Workbook wb = new Workbook();
+        wb.loadFromMHtml(inputStreamByUrl);
+        Worksheet sheet = wb.getWorksheets().get(0);
+
+
+
+
+        CellRange[] mergedCells = sheet.getMergedCells();
+        for (int i=0;i<mergedCells.length;i++){
+            CellRange mergedCell = mergedCells[i];
+
+            CellRange data = sheet.getCellRange(mergedCell.getRow(),mergedCell.getColumn());
+
+            System.out.println(data.getValue());
+            System.out.println(mergedCell.getRow()+"--=--"+mergedCell.getColumn());
+
+        }*/
+
+    }
     public static Map<String, Map<String, String>> getWeather(String city, String month) {
         String html = "http://www.tianqihoubao.com/lishi/" + city + "/month/" + month + ".html";
         System.out.println(html);