Răsfoiți Sursa

数据修改

zhuwei 2 luni în urmă
părinte
comite
f508494e4f

+ 4 - 1
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaController.java

@@ -9,6 +9,8 @@ import org.apache.commons.lang.StringUtils;
 import org.springblade.business.entity.Task;
 import org.springblade.business.feign.TaskClient;
 import org.springblade.business.vo.TaskApprovalVO;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SystemUtils;
 import org.springblade.evisa.service.EVisaService;
 import org.springblade.evisa.vo.EVisaTaskApprovalVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -62,11 +64,12 @@ public class EVisaController {
     @Scheduled(cron = "0/10 * * * * ?")
     public void SignInfo() {
         //执行代码
+
         log.info("扫描开始");
         //String sql = "SELECT * from u_task_batch where json_data like '%1821798868568768512%' and is_deleted<>5  LIMIT 10";
         String sql = "SELECT * from u_task_batch where is_deleted<>5 LIMIT 10";
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
-        if (maps != null && maps.size() >= 1) {
+        if (maps != null && maps.size() >= 1 && SystemUtils.isLinux()) {
             for (Map<String, Object> dataInfo : maps) {
                 if (executor.getQueue().size()<=40 ) {
                     String jsonData = dataInfo.get("json_data") + "";

+ 213 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/CreateDashedLine.java

@@ -0,0 +1,213 @@
+package org.springblade.manager.utils;
+
+import com.spire.ms.System.Collections.ArrayList;
+import com.sun.xml.bind.v2.util.FlattenIterator;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.graphics.PDLineDashPattern;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.pdmodel.interactive.measurement.PDViewportDictionary;
+import org.apache.pdfbox.text.PDFTextStripper;
+import org.apache.pdfbox.text.PDFTextStripperByArea;
+import org.apache.pdfbox.text.TextPosition;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.FileUtils;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ResourceUtil;
+import org.springblade.manager.vo.PDFIndexInfo;
+
+import java.awt.geom.Point2D;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
+public class CreateDashedLine {
+
+    public static void mai1n(String[] args) throws Exception {
+        // 获取值的坐标
+      //  List<String> s_data39 = new java.util.ArrayList<>();
+
+        List<String> s_data34 = new java.util.ArrayList<>();
+        s_data34.add("2.8");
+        s_data34.add("7.66");
+/*        s_data34.add("14.03");
+        s_data34.add("14.56");
+        s_data34.add("16.28");
+        s_data34.add("");
+        s_data34.add("16.42");
+        s_data34.add("16.57");
+        s_data34.add("16.73");
+        s_data34.add("16.9");
+        s_data34.add("17.07");
+        s_data34.add("17.26");*/
+
+        String pdfUrl = "/Users/hongchuangyanfa/Desktop/excel/1750071431349174274.pdf";
+
+      //  getPDFInfo(pdfUrl,s_data39,"1");
+        getPDFInfo(pdfUrl,s_data34,"2");
+
+        System.out.println("");
+    }
+
+
+    public static void getPDFInfo(String pdfUrl,List<String> s_data,String type) throws Exception {
+        PDDocument document = PDDocument.load(new File(pdfUrl));
+        //获取文件流
+        InputStream inputStream = new FileInputStream(new File(pdfUrl));
+        //转换
+        byte[] bytes = CommonUtil.InputStreamToBytes(inputStream);
+        List<PDFIndexInfo> keywordPostions = PdfAddimgUtil.findKeywordPostions(bytes, "累计%");
+
+        // 获取  实际完成=累计% 的坐标
+        PDFIndexInfo pdfIndexInfo = keywordPostions.get(0);
+        float s_with = pdfIndexInfo.getDataInfo()[1];
+        float s_heiht = pdfIndexInfo.getDataInfo()[2];
+
+        // 获取  计划完成 = 累计% 的坐标
+        PDFIndexInfo jPdf = keywordPostions.get(1);
+        float j_with = jPdf.getDataInfo()[1];
+        float j_heiht = jPdf.getDataInfo()[2];
+
+        System.out.println(s_with+"__"+s_heiht);
+        System.out.println(j_with+"__"+j_heiht);
+
+        List<PDFIndexInfo> allwordPostions = PdfAddimgUtil.findAllwordPostions(bytes);
+        PDFIndexInfo pdfIndex = allwordPostions.get(0);
+        List<float[]> listData = pdfIndex.getListData();
+        String context = pdfIndex.getPkeyid();
+
+        // 获取月份的y轴
+        int moth_y = context.indexOf("1234567891011121");
+        float[] moth = listData.get(moth_y);
+        System.out.println(moth[2]);
+        List<PDFIndexInfo> bf_list = PdfAddimgUtil.findKeywordPostions(bytes, "%");
+         float bf_x = 0f;
+         float bf_y = 0f;
+        for(PDFIndexInfo bf:bf_list){
+           if(bf.getDataInfo()[2]==moth[2]){
+               bf_x =   bf.getDataInfo()[1];
+               bf_y =   bf.getDataInfo()[2];
+               break;
+           }
+        }
+        System.out.println("百分"+bf_x);
+        System.out.println("百分"+bf_y);
+
+        Map<String , float[]> data = new HashMap<>();
+        for(int i=20 ; i>=0 ; i--){
+            //测试数据
+            String key = i * 5 +"";
+            List<String> strList = Func.toStrList(key);
+            for (String text : strList) {
+                for (int pos = 0; pos < context.length(); ) {
+                    int positionIndex = context.indexOf(text, pos);
+                    if (positionIndex == -1) {
+                        break;
+                    }
+                    float[] postions = listData.get(positionIndex);
+                    if((postions[1]==bf_x || Math.abs(postions[1]-bf_x)<=0.002) && postions[2]>bf_y){
+                        data.put(key,postions);
+                        bf_y =postions[2];
+                        break;
+                    }
+                    pos = positionIndex + 1;
+                }
+            }
+        }
+
+
+
+        Map<String , float[]> s_data_xy = new HashMap<>();
+
+        for(String sval:s_data){
+            //测试数据
+            List<String> strList = Func.toStrList(sval);
+            for (String text : strList) {
+                for (int pos = 0; pos < context.length(); ) {
+                    int positionIndex = context.indexOf(text, pos);
+                    if (positionIndex == -1) {
+                        break;
+                    }
+                    float[] postions = listData.get(positionIndex);
+                    if("1".equals(type)){
+                        if((postions[2]==s_heiht || Math.abs(postions[2]-s_heiht)<=0.002 ) && postions[1]>s_with){
+                            s_data_xy.put(sval,postions);
+                            s_with = postions[1];
+                            break;
+                        }
+                    }
+                    if("2".equals(type)){
+                        if((postions[2]==j_heiht || Math.abs(postions[2]-j_heiht)<=0.002 ) && postions[1]>s_with){
+                            s_data_xy.put(sval,postions);
+                            s_with = postions[1];
+                            break;
+                        }
+                    }
+                    pos = positionIndex + 1;
+                }
+            }
+        }
+
+        float pageHeight = document.getPage(0).getMediaBox().getHeight();
+        float pageWidth = document.getPage(0).getMediaBox().getWidth();
+        float oney = (data.get("0")[2] -data.get("5")[2])/5 * pageHeight;
+        //实线坐标
+        List<Float> points = new ArrayList();
+        for(String sval:s_data){
+            float[] floats = s_data_xy.get(sval);
+            if(floats!=null){
+                points.add( pageWidth * (floats[1])+2);
+                Double floor = Math.floor(Func.toDouble(sval) / 5)*5;
+
+                float add = (float) ((Func.toDouble(sval)-floor ) * oney);
+
+                String da2 = floor.intValue()+"";
+                float[] floats1 = data.get(da2);
+                points.add( pageHeight- pageHeight * (floats1[2]) + add );
+            }
+        }
+        PDFFill(points,pdfUrl,type);
+    }
+
+    public static void PDFFill(List<Float> points,String fileUrl,String type) throws Exception {
+        // 创建一个PDF文档
+        PDDocument document = PDDocument.load(new File(fileUrl));
+
+        // 创建一个页面
+        PDPage page = document.getPage(0);
+        // 纸张大小
+
+        try (PDPageContentStream contentStream = new PDPageContentStream(document, page,PDPageContentStream.AppendMode.APPEND, true, true)) {
+            // 设置线宽和颜色
+            PDExtendedGraphicsState extendedGraphicsState = new PDExtendedGraphicsState();
+            extendedGraphicsState.setLineWidth(1f);
+            contentStream.setGraphicsStateParameters(extendedGraphicsState);
+            float[] a={4,2};
+            contentStream.setLineDashPattern(a, 2);
+
+            // 定义点集合,表示折线上的点
+            List<Point2D.Float> points1 = new java.util.ArrayList<>();
+            for (int i = 0; i < points.size(); i += 2) {
+                points1.add(new Point2D.Float(points.get(i), points.get(i + 1)));
+            }
+
+            // 绘制折线
+            Point2D.Float current = null;
+            for (Point2D.Float point : points1) {
+                if (current != null) {
+                    contentStream.drawLine(current.x, current.y, point.x, point.y);
+                }
+                current = point;
+            }
+        }
+
+        document.save("/Users/hongchuangyanfa/Desktop/excel/test_info.pdf");
+        document.close();
+        System.out.println("完成");
+    }
+}

+ 201 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/utils/CreateDashedLine.java

@@ -0,0 +1,201 @@
+package org.springblade.meter.utils;
+
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.manager.vo.PDFIndexInfo;
+
+import java.awt.geom.Point2D;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CreateDashedLine {
+
+/*    public static void main(String[] args) throws Exception {
+        // 获取值的坐标
+        List<String> s_data = new java.util.ArrayList<>();
+        s_data.add("0.01");
+        s_data.add("0.076");
+        s_data.add("1.08");
+        s_data.add("1.28");
+        s_data.add("2.76");
+        s_data.add("3.56");
+        s_data.add("4.8");
+        s_data.add("5.88");
+        s_data.add("7.46");
+        s_data.add("10.38");
+        s_data.add("13.85");
+        s_data.add("17.54");
+        s_data.add("22.88");
+        s_data.add("27.94");
+        String pdfUrl = "/Users/hongchuangyanfa/Desktop/excel/【2-4】施工进度表.pdf";
+
+        getPDFInfo(pdfUrl,s_data);
+
+        System.out.println("");
+    }*/
+
+
+    public static void getPDFInfo(String pdfUrl,List<String> s_data,String type) throws Exception {
+        PDDocument document = PDDocument.load(new File(pdfUrl));
+        //获取文件流
+        InputStream inputStream = new FileInputStream(new File(pdfUrl));
+        //转换
+        byte[] bytes = CommonUtil.InputStreamToBytes(inputStream);
+        List<PDFIndexInfo> keywordPostions = PdfAddimgUtil.findKeywordPostions(bytes, "累计%");
+
+        // 获取  实际完成=累计% 的坐标
+        PDFIndexInfo pdfIndexInfo = keywordPostions.get(0);
+        float s_with = pdfIndexInfo.getDataInfo()[1];
+        float s_heiht = pdfIndexInfo.getDataInfo()[2];
+
+        // 获取  计划完成 = 累计% 的坐标
+        PDFIndexInfo jPdf = keywordPostions.get(1);
+        float j_with = jPdf.getDataInfo()[1];
+        float j_heiht = jPdf.getDataInfo()[2];
+
+        System.out.println(s_with+"__"+s_heiht);
+        System.out.println(j_with+"__"+j_heiht);
+
+        List<PDFIndexInfo> allwordPostions = PdfAddimgUtil.findAllwordPostions(bytes);
+        PDFIndexInfo pdfIndex = allwordPostions.get(0);
+        List<float[]> listData = pdfIndex.getListData();
+        String context = pdfIndex.getPkeyid();
+
+        // 获取月份的y轴
+        int moth_y = context.indexOf("1234567891011121");
+        float[] moth = listData.get(moth_y);
+        System.out.println(moth[2]);
+        List<PDFIndexInfo> bf_list = PdfAddimgUtil.findKeywordPostions(bytes, "%");
+         float bf_x = 0f;
+         float bf_y = 0f;
+        for(PDFIndexInfo bf:bf_list){
+           if(bf.getDataInfo()[2]==moth[2]){
+               bf_x =   bf.getDataInfo()[1];
+               bf_y =   bf.getDataInfo()[2];
+               break;
+           }
+        }
+        System.out.println("百分"+bf_x);
+        System.out.println("百分"+bf_y);
+
+        Map<String , float[]> data = new HashMap<>();
+        for(int i=20 ; i>=0 ; i--){
+            //测试数据
+            String key = i * 5 +"";
+            List<String> strList = Func.toStrList(key);
+            for (String text : strList) {
+                for (int pos = 0; pos < context.length(); ) {
+                    int positionIndex = context.indexOf(text, pos);
+                    if (positionIndex == -1) {
+                        break;
+                    }
+                    float[] postions = listData.get(positionIndex);
+                    if((postions[1]==bf_x || Math.abs(postions[1]-bf_x)<=0.002) && postions[2]>bf_y){
+                        data.put(key,postions);
+                        bf_y =postions[2];
+                        break;
+                    }
+                    pos = positionIndex + 1;
+                }
+            }
+        }
+
+
+        Map<String , float[]> s_data_xy = new HashMap<>();
+
+        for(String sval:s_data){
+            //测试数据
+            List<String> strList = Func.toStrList(sval);
+            for (String text : strList) {
+                for (int pos = 0; pos < context.length(); ) {
+                    int positionIndex = context.indexOf(text, pos);
+                    if (positionIndex == -1) {
+                        break;
+                    }
+                    float[] postions = listData.get(positionIndex);
+                    if("1".equals(type)){ //实际
+                        if((postions[2]==s_heiht || Math.abs(postions[2]-s_heiht)<=0.01 ) && postions[1]>s_with){
+                            s_data_xy.put(sval,postions);
+                            s_with = postions[1];
+                            break;
+                        }
+                    }
+                    if("2".equals(type)){ //计划
+                        if((postions[2]==j_heiht || Math.abs(postions[2]-j_heiht)<=0.01 ) && postions[1]>j_with){
+                            s_data_xy.put(sval,postions);
+                            s_with = postions[1];
+                            break;
+                        }
+                    }
+                    pos = positionIndex + 1;
+                }
+            }
+        }
+
+        float pageHeight = document.getPage(0).getMediaBox().getHeight();
+        float pageWidth = document.getPage(0).getMediaBox().getWidth();
+        float oney = (data.get("0")[2] -data.get("5")[2])/5 * pageHeight;
+        //实线坐标
+        List<Float> points = new ArrayList<>();
+        for(String sval:s_data){
+            float[] floats = s_data_xy.get(sval);
+            if(floats!=null){
+                points.add( pageWidth * (floats[1])+2);
+                Double floor = Math.floor(Func.toDouble(sval) / 5)*5;
+                String da2 = floor.intValue()+"";
+                float add = (float) ((Func.toDouble(sval)-floor ) * oney);
+                float[] floats1 = data.get(da2);
+                points.add( pageHeight- pageHeight * (floats1[2])+add);
+            }
+        }
+        PDFFill(points,pdfUrl,type);
+    }
+
+    public static void PDFFill(List<Float> points,String fileUrl,String type) throws Exception {
+        // 创建一个PDF文档
+        PDDocument document = PDDocument.load(new File(fileUrl));
+
+        // 创建一个页面
+        PDPage page = document.getPage(0);
+        // 纸张大小
+
+        try (PDPageContentStream contentStream = new PDPageContentStream(document, page,PDPageContentStream.AppendMode.APPEND, true, true)) {
+            // 设置线宽和颜色
+            PDExtendedGraphicsState extendedGraphicsState = new PDExtendedGraphicsState();
+            extendedGraphicsState.setLineWidth(1f);
+            contentStream.setGraphicsStateParameters(extendedGraphicsState);
+            if(type.equals("2")){
+                float[] a={4,2};
+                contentStream.setLineDashPattern(a, 2);
+            }
+
+            // 定义点集合,表示折线上的点
+            List<Point2D.Float> points1 = new java.util.ArrayList<>();
+            for (int i = 0; i < points.size(); i += 2) {
+                points1.add(new Point2D.Float(points.get(i), points.get(i + 1)));
+            }
+
+            // 绘制折线
+            Point2D.Float current = null;
+            for (Point2D.Float point : points1) {
+                if (current != null) {
+                    contentStream.drawLine(current.x, current.y, point.x, point.y);
+                }
+                current = point;
+            }
+        }
+
+        document.save(fileUrl);
+        document.close();
+        System.out.println("完成");
+    }
+}