|  | @@ -1,181 +0,0 @@
 | 
	
		
			
				|  |  | -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);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -}
 |