Эх сурвалжийг харах

Merge branch 'zhuwei' into dev

zhuwei 4 өдөр өмнө
parent
commit
9b61268d4e

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

@@ -91,13 +91,13 @@ public class OssBuilder {
 		String tenantId = AuthUtil.getTenantId();
 		Oss oss = getOss(tenantId, code);
         String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
-        if(SystemUtils.isMacOs()||SystemUtils.isWindows()){
+       /* if(SystemUtils.isMacOs()||SystemUtils.isWindows()){
             if("20".equals(sys_isonline)){
                 oss.setEndpoint("http://183.247.216.148:9000/");
             }else {
                 oss.setEndpoint("https://xinan1.zos.ctyun.cn");
             }
-        }
+        }*/
 		//oss.setEndpoint("https://xinan1.zos.ctyun.cn");
 		System.out.println("oss111="+oss.getEndpoint());
 		Oss ossCached = ossPool.get(tenantId);

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

@@ -59,7 +59,7 @@ public class Archive2Controller {
     @Resource(name = "archivePoolExecutor")
     private ThreadPoolExecutor archExecutor;
 
-    @Scheduled(cron = "0/30 * * * * ?")
+    //@Scheduled(cron = "0/30 * * * * ?")
     public void SignTaskBatchPng() {
         //执行代码
         log.info("分解pdf专图片");

+ 181 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/testTaskInfo.java

@@ -0,0 +1,181 @@
+package org.springblade.evisa.controller;
+
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.rendering.PDFRenderer;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.launch.StartEventListener;
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.IoUtil;
+import org.springblade.evisa.utils.FileUtils;
+import org.springblade.evisa.vo.ArchivesSplitInfoVO;
+import org.springblade.evisa.vo.TaskArchiveSplitVO;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+
+/**
+ * 清表基础数据表 控制器
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@RestController
+@AllArgsConstructor
+@Api(value = "电签类", tags = "电签类接口")
+@Slf4j
+public class testTaskInfo {
+
+    private final StringRedisTemplate RedisTemplate;
+
+    private final JdbcTemplate jdbcTemplate;
+
+    private final NewIOSSClient newIOSSClient;
+
+    // 线程池
+    @Resource(name = "archivePoolExecutor")
+    private ThreadPoolExecutor archExecutor;
+    @Autowired
+    private StartEventListener startEventListener;
+
+    //@Scheduled(cron = "0/20 * * * * ?")
+    public void SignTaskBatchPng() {
+        //执行代码
+        log.info("分解pdf专图片");
+     
+        String sql = "select * from u_information_query_zhu where is_deleted=0 and wbs_id=1932616157764780032 ";
+        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
+        if (mapList != null && mapList.size() >= 1) {
+            for (Map<String, Object> dataInfo : mapList) {
+
+                String ndid=dataInfo.get("id")+"";
+                String contractId=dataInfo.get("contract_id")+"";
+                String projectId=dataInfo.get("project_id")+"";
+                String classify=dataInfo.get("classify")+"";
+                String wbs_id=dataInfo.get("wbs_id")+"";
+
+
+                if (archExecutor.getQueue().size() <= 30) {
+                    Boolean aBoolean = RedisTemplate.hasKey("taskIdxx-" + ndid);
+                    if (!aBoolean) {
+                        RedisTemplate.opsForValue().setIfAbsent("taskIdxx-" + ndid, "1", 600, TimeUnit.SECONDS);
+                        CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
+                            try {
+                                signTaskBatchpngToHtml(ndid,contractId,projectId,classify,wbs_id);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }, archExecutor);
+                    }
+                }
+            }
+        }
+        System.out.println("队列数量_img" + archExecutor.getQueue().size());
+        System.out.println("活跃数量_img" + archExecutor.getActiveCount());
+        System.out.println("总共数量_img" + archExecutor.getTaskCount());
+        System.out.println("完成数量_img" + archExecutor.getCompletedTaskCount());
+    }
+
+    // 分解第一页的任务
+
+    public void signTaskBatchpngToHtml(String ndid,String contractId,String projectId,String classify,String wbs_id) {
+        //
+
+        String taownInfo = "";
+        if(classify.equals("1")){
+            taownInfo="1,2,3";
+        }
+        if(classify.equals("2")){
+            taownInfo="4,5,6";
+        }
+        String  node_info = "select * from m_wbs_tree_contract where is_deleted=0 and table_owner in("+taownInfo+") and p_id = '" + wbs_id + "'";
+        List<Map<String, Object>> nodeInfoList = jdbcTemplate.queryForList(node_info);
+        if(nodeInfoList!=null && nodeInfoList.size()>=1){
+          String priIds = nodeInfoList.stream().map(m -> m.get("is_type_private_pid")).map(Object::toString).collect(Collectors.joining(","));
+            String qweq = nodeInfoList.get(0).get("ancestors_p_id")+"";
+            System.out.println("qweq"+qweq);
+            List<String> str = Func.toStrList(qweq);
+
+            for(int i=1;i<=5;i++){
+                String anId = str.get(str.size() - i-1);
+                String sqldat ="";
+                if(i==5){
+                    sqldat= " SELECT c.p_id, c.aaCount,(SELECT b.id from u_information_query a ,u_task b where a.id=b.form_data_id and a.wbs_id=c.p_id and b.contract_id="+contractId+"  and  a.is_deleted=0 and b.is_deleted=0 ORDER BY a.`status` desc LIMIT 1) as taskId from ("+
+                            "select p_id,count(1) as aaCount from m_wbs_tree_contract where is_deleted=0 and contract_id = '" + contractId + "' and table_owner in ( " + taownInfo + " ) and is_type_private_pid in("+priIds+") and p_id<>"+wbs_id+" group by p_id "+
+                            " ) c ";
+                }else{
+                    sqldat= " SELECT c.p_id, c.aaCount,(SELECT b.id from u_information_query a ,u_task b where a.id=b.form_data_id and a.wbs_id=c.p_id and a.is_deleted=0 and b.contract_id="+contractId+"  and b.is_deleted=0 ORDER BY a.`status` desc LIMIT 1) as taskId from ("+
+                            "select p_id,count(1) as aaCount from m_wbs_tree_contract where is_deleted=0 and contract_id = '" + contractId + "' and table_owner in ( " + taownInfo + " ) and is_type_private_pid in("+priIds+") and ancestors_p_id like '%"+anId+"%' and p_id<>"+wbs_id+" group by p_id "+
+                            " ) c ";
+                }
+
+                List<Map<String, Object>> noInfoList = jdbcTemplate.queryForList(sqldat);
+                if(noInfoList!=null && noInfoList.size()>=1){
+                    for(Map<String, Object> noInfo : noInfoList) {
+                        Integer exceptxx = Integer.parseInt(noInfo.get("aaCount")+"");
+                        String taskId = noInfo.get("taskId")+"";
+                        if(exceptxx >= nodeInfoList.size() && taskId.length()>4){
+                            long newPkId = SnowFlakeUtil.getId();
+                            long projInstand = SnowFlakeUtil.getId();
+                            String dataInfo = " insert into u_task(id,process_definition_id,process_instance_id,project_id,contract_id,start_time,end_time,report_user,report_user_name,task_name,task_content,task_user,fixed_flow_id,form_data_id,batch,type,approval_type,create_user,create_dept,create_time,update_user,update_time,status,is_deleted,trial_self_inspection_record_id,archive_ids,attachment_pdf_url,task_create_timestamp,meter_task_type,meter_task_repeal_desc,task_common_money,is_build_audit) " +
+                                    "SELECT "+newPkId+",process_definition_id,"+projInstand+",project_id,contract_id,start_time,end_time,report_user,report_user_name,task_name,task_content,task_user,fixed_flow_id,"+ndid+",batch,type,approval_type,create_user,create_dept,create_time,update_user,update_time,status,is_deleted,trial_self_inspection_record_id,archive_ids,attachment_pdf_url,task_create_timestamp,meter_task_type,meter_task_repeal_desc,task_common_money,is_build_audit from u_task where id="+taskId;
+
+                            // 添加任务
+
+                            String peall = "SELECT a.* from u_task_parallel a ,u_task b  where a.process_instance_id=b.process_instance_id and b.id='"+taskId+"' and a.is_deleted=0 and b.is_deleted=0 ";
+                            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(peall);
+                            if(mapList!=null && mapList.size()>=1){
+                                for (Map<String, Object> mapData : mapList){
+                                    String pallId= mapData.get("id")+"";
+                                    long projInstaxnd = SnowFlakeUtil.getId();
+                                    String datadx = " insert into u_task_parallel(id,process_instance_id,parallel_process_instance_id,e_visa_status,e_visa_content,task_user,task_user_name,initiative,create_user,create_dept,create_time,update_user,update_time,status,is_deleted,sort,exe_count) " +
+                                             " SELECT "+projInstaxnd+","+projInstand+","+projInstaxnd+",e_visa_status,e_visa_content,task_user,task_user_name,initiative,create_user,create_dept,create_time,update_user,update_time,status,is_deleted,sort,exe_count from u_task_parallel where id='"+pallId+"'";
+
+                                    jdbcTemplate.execute(datadx);
+                                }
+                            }
+
+                            jdbcTemplate.execute(dataInfo);
+                            String updateSql = "update u_information_query_zhu set is_deleted=1 where id="+ndid;
+                            jdbcTemplate.execute(updateSql);
+                            // 修改完成情况
+                            RedisTemplate.delete("taskIdxx-" + ndid);
+                            return;
+                        }
+                    }
+                }
+            }
+        }
+
+        String updatel = "update u_information_query_zhu set is_deleted=5 where id="+ndid;
+        jdbcTemplate.execute(updatel);
+        RedisTemplate.delete("taskIdxx-" + ndid);
+    }
+
+}

+ 99 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/testTaskInfo222.java

@@ -0,0 +1,99 @@
+package org.springblade.evisa.controller;
+
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.launch.StartEventListener;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.resource.feign.NewIOSSClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+
+/**
+ * 清表基础数据表 控制器
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@RestController
+@AllArgsConstructor
+@Api(value = "电签类", tags = "电签类接口")
+@Slf4j
+public class testTaskInfo222 {
+
+    private final StringRedisTemplate RedisTemplate;
+
+    private final JdbcTemplate jdbcTemplate;
+
+    private final NewIOSSClient newIOSSClient;
+
+    // 线程池
+    @Resource(name = "archivePoolExecutor")
+    private ThreadPoolExecutor archExecutor;
+    @Autowired
+    private StartEventListener startEventListener;
+
+  //  @Scheduled(cron = "0/10 * * * * ?")
+    public void SignTaskBatchPng() {
+        //执行代码
+        log.info("分解pdf专图片");
+     
+      //  String sql = "select * from u_information_query where is_deleted=0 and  id=1614886382873305090";
+        String sql = "SELECT * from u_task22 where is_deleted=0 LIMIT 900" ;
+        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
+        System.out.println(mapList.size());
+
+
+        if (mapList != null && mapList.size() >= 1) {
+            for (Map<String, Object> dataInfo : mapList) {
+
+                String id=dataInfo.get("id")+"";
+                String ndid=dataInfo.get("form_data_id")+"";
+
+                if (archExecutor.getQueue().size() <= 1000) {
+                    Boolean aBoolean = RedisTemplate.hasKey("taskIdxx-" + id);
+                    if (!aBoolean) {
+                        RedisTemplate.opsForValue().setIfAbsent("taskIdxx-" + id, "1", 100, TimeUnit.SECONDS);
+                        CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
+                            try {
+                                signTaskBatchpngToHtml(id,ndid);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }, archExecutor);
+                    }
+                }
+            }
+        }
+        System.out.println("队列数量_img" + archExecutor.getQueue().size());
+        System.out.println("活跃数量_img" + archExecutor.getActiveCount());
+        System.out.println("总共数量_img" + archExecutor.getTaskCount());
+        System.out.println("完成数量_img" + archExecutor.getCompletedTaskCount());
+    }
+
+    // 分解第一页的任务
+
+    public void signTaskBatchpngToHtml(String id,String ndid) {
+        //
+        String UPdate = "delete from  u_information_query_zhu where id='"+ndid+"'";
+        jdbcTemplate.execute(UPdate);
+
+        String UPdat2e = "update u_task22 set is_deleted=10 where id='"+id+"'";
+        jdbcTemplate.execute(UPdat2e);
+        RedisTemplate.delete("taskIdxx-" + id);
+    }
+
+}

+ 2 - 2
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/ArchivePoolExecutorConfig.java

@@ -15,7 +15,7 @@ public class ArchivePoolExecutorConfig {
     /**
      * cpu 核心数量
      */
-    public static final int cpuNum = 5 ;//Runtime.getRuntime().availableProcessors();
+    public static final int cpuNum = 1 ;//Runtime.getRuntime().availableProcessors();
 
     /**
      * 线程池配置
@@ -28,7 +28,7 @@ public class ArchivePoolExecutorConfig {
                 , 10
                 , 180
                 , TimeUnit.SECONDS
-                , new LinkedBlockingQueue<>(200)
+                , new LinkedBlockingQueue<>(500)
                 , new ThreadPoolExecutor.DiscardOldestPolicy(), "ArchivePoolExecutor-pool");
     }