浏览代码

2023 11 06 bug修改

zhuwei 1 年之前
父节点
当前提交
35065e5371

+ 2 - 2
blade-common/src/main/java/org/springblade/common/utils/AsyncConfigurer.java

@@ -15,7 +15,7 @@ public class AsyncConfigurer {
     /**
      * cpu 核心数量
      */
-    public static final int cpuNum = 6;//Runtime.getRuntime().availableProcessors();
+    public static final int cpuNum = 3;//Runtime.getRuntime().availableProcessors();
 
     /**
      * 线程池配置
@@ -25,7 +25,7 @@ public class AsyncConfigurer {
     @Bean("taskExecutor1")
     public ThreadPoolExecutor getAsyncExecutor() {
         return new ThreadPoolMonitor(cpuNum
-                , 12
+                , 6
                 , 60
                 , TimeUnit.SECONDS
                 , new LinkedBlockingQueue<>(2000)

+ 1 - 1
blade-ops/blade-flow/src/main/java/org/springblade/flow/business/feign/NewFlowClientImpl.java

@@ -70,7 +70,7 @@ public class NewFlowClientImpl implements NewFlowClient {
             }
         }
         //完成任务
-        this.taskService.complete(taskId, Kv.create());
+       // this.taskService.complete(taskId, Kv.create());
 
         return R.data(true);
     }

+ 1 - 3
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskBatchMapper.xml

@@ -26,9 +26,7 @@
     </delete>
 
     <select id="queryDataInfo" resultMap="taskBatchResultMap">
-        SELECT * from u_task_batch
-                 where id IN (SELECT max(id) from u_task_batch  WHERE is_deleted =0 GROUP BY JSON_EXTRACT(json_data,'$.formDataId')
-        ) LIMIT 100
+        SELECT * from u_task_batch where is_deleted not in(2,4) LIMIT 100
     </select>
 
 </mapper>

+ 13 - 10
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -63,6 +63,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.FileNotFoundException;
+import java.nio.file.Watchable;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -575,7 +576,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
     }
 
 
-    @Scheduled(cron = "0 */2 * * * ?")
+    @Scheduled(cron = "0 */1 * * * ?")
     public void SignInfo() {
         //执行代码
         logger.debug("扫描开始");
@@ -590,12 +591,13 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 
                 Boolean istrue = true;
                 try {
-                    Thread.sleep(200);
+                    Thread.sleep(500);
                 } catch (InterruptedException e) {
                     throw new RuntimeException(e);
                 }
+
                 Boolean aBoolean = RedisTemplate.hasKey("sign-" + taskApprovalVO.getFormDataId());
-                System.out.println(aBoolean);
+                System.out.println(taskApprovalVO.getFormDataId()+"---"+aBoolean);
                 if (aBoolean) {
                     istrue = false;
                 }
@@ -604,6 +606,8 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                     if (wtask >= 200) {
                         break;
                     }
+                    taskBatchService.update(Wrappers.<TaskBatch>update().set("is_deleted",2).eq("id",taskBatchId));
+                    RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1", 66, TimeUnit.SECONDS);
                     CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
                         try {
                             this.checkIsExsitTaskBatch(taskApprovalVO, taskBatchId, userId, nickName);
@@ -611,14 +615,14 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                             e.printStackTrace();
                         }
                     }, executor);
-                    runAsync.join();
+
                 }
             }
-            System.out.println("队列数量" + executor.getQueue().size());
-            System.out.println("活跃数量" + executor.getActiveCount());
-            System.out.println("总共数量" + executor.getTaskCount());
-            System.out.println("完成数量" + executor.getCompletedTaskCount());
         }
+        System.out.println("队列数量" + executor.getQueue().size());
+        System.out.println("活跃数量" + executor.getActiveCount());
+        System.out.println("总共数量" + executor.getTaskCount());
+        System.out.println("完成数量" + executor.getCompletedTaskCount());
     }
 
     private void checkIsExsitTaskBatch(TaskApprovalVO taskApprovalVO, String batchId, Long userId, String nickName) throws FileNotFoundException {
@@ -626,7 +630,6 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
         taskApprovalVO.setId(batchId);
         taskApprovalVO.setUserId(userId);
         taskApprovalVO.setNickName(nickName);
-        RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1", 125, TimeUnit.SECONDS);
 
         String pdfUrlEVisa = this.completeApprovalTask(taskApprovalVO);
 
@@ -684,7 +687,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
             } else if ("success".equals(eVisaStatus) || eVisaStatus.contains("success")) {
                 //审批通过会返回签章成功的文件,需要设置替换
                 //完成/审批当前分支流程
-                this.newFlowClient.completeApprovalTask(taskId, parallelProcessInstanceId, comment).getData();
+            //    this.newFlowClient.completeApprovalTask(taskId, parallelProcessInstanceId, comment).getData();
                 //修改分支状态,改为已完成
                 this.taskParallelService.update(Wrappers.<TaskParallel>lambdaUpdate()
                         .set(TaskParallel::getStatus, 2)

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

@@ -1,21 +1,28 @@
 package org.springblade.evisa.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springblade.business.entity.TaskBatch;
+import org.springblade.business.vo.TaskApprovalVO;
 import org.springblade.core.boot.ctrl.BladeController;
 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.*;
 
+import javax.annotation.Resource;
 import java.io.BufferedReader;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.util.List;
 import java.util.Set;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
 
 import java.lang.management.ManagementFactory;
 import java.lang.management.OperatingSystemMXBean;
@@ -29,71 +36,96 @@ import java.lang.management.OperatingSystemMXBean;
 @AllArgsConstructor
 @RequestMapping("/evisaInfo")
 @Api(value = "电签类", tags = "电签类接口")
+@Slf4j
 public class EVisaController {
 
     @Autowired
     StringRedisTemplate RedisTemplate;
 
-    // 线程池中初始线程个数
-    private final static Integer CORE_POOL_SIZE =20;
-    // 线程池中允许的最大线程数
-    private final static Integer MAXIMUM_POOL_SIZE = 30;
-    // 当线程数大于初始线程时。终止多余的空闲线程等待新任务的最长时间
-    private final static Long KEEP_ALIVE_TIME = 10L;
-    // 任务缓存队列 ,即线程数大于初始线程数时先进入队列中等待,此数字可以稍微设置大点,避免线程数超过最大线程数时报错。或者直接用无界队列
-    private final static LinkedBlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
-    ThreadPoolExecutor threadPoolExecutor = null;
-    // 自定义线程池,开发推荐使用
-    public static ThreadPoolExecutor ITDragonThreadPoolExecutor() {
-        // 构建一个,初始线程数量为3,最大线程数据为8,等待时间10分钟 ,队列长度为5 的线程池
-        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
-                CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.MINUTES, WORK_QUEUE);
-        return threadPoolExecutor;
-    }
-
-  //  @Scheduled(cron = "0 */3 * * * ?")
-    public void StartEvisInfo() {
-        if(threadPoolExecutor==null){
-            threadPoolExecutor = ITDragonThreadPoolExecutor();
-        }
-
-        for (int i = 0; i < 10; i++) {	// 执行8个任务,若超过MAXIMUM_POOL_SIZE则会报错 RejectedExecutionException
-            RedisTemplate.opsForValue().set("sign-" + i, "1", 63, TimeUnit.SECONDS);
-        }
-        System.out.println("完成");
-    }
-
-    @Scheduled(cron = "0 */1 * * * ?")
-    public void runEvisInfo() {
-
-        Set<String> keys = RedisTemplate.keys("sign-*");
-        System.out.println(keys.size());
-    }
-
-    static class MyRunnableTest implements Runnable {
-        private Integer num;	// 正在执行的任务数
-        public MyRunnableTest(Integer num) {
-            this.num = num;
-        }
-        public void run() {
-            System.out.println("正在执行的MyRunnable " + num);
-            try {
-                Thread.sleep(1000);// 模拟执行事务需要耗时
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-            System.out.println("MyRunnable " + num + "执行完毕");
-        }
-    }
-
-
-
-
-        public static void main2(String[] args) {
-            OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
-            double cpuUsage = operatingSystemMXBean.getSystemLoadAverage();
-            System.out.println("CPU Usage: " + cpuUsage);
-        }
-
-
+    private final JdbcTemplate jdbcTemplate;
+
+    // 线程池
+    @Resource(name = "taskExecutor1")
+    private ThreadPoolExecutor executor;
+
+    // 电签主类
+//    @Scheduled(cron = "0 */1 * * * ?")
+//    public void SignInfo() {
+//        //执行代码
+//        log.info("扫描开始");
+//        String sql = "SELECT * from u_task_batch where is_deleted not in(2,4) LIMIT 100";
+//        List<TaskBatch> maps = jdbcTemplate.queryForList(sql,TaskBatch.class);
+//        if (maps != null && maps.size() >= 1) {
+//            for (TaskBatch dataInfo : maps) {
+//                String jsonData = dataInfo.getJsonData();
+//                TaskApprovalVO taskApprovalVO = JSON.parseObject(jsonData, TaskApprovalVO.class);
+//                String taskBatchId = dataInfo.getId().toString();
+//                Long userId = dataInfo.getCreateUser();
+//                String nickName = dataInfo.getNickName();
+//
+//                Boolean istrue = true;
+//                try {
+//                    Thread.sleep(500);
+//                } catch (InterruptedException e) {
+//                    throw new RuntimeException(e);
+//                }
+//
+//                Boolean aBoolean = RedisTemplate.hasKey("sign-" + taskApprovalVO.getFormDataId());
+//                System.out.println(taskApprovalVO.getFormDataId()+"---"+aBoolean);
+//                if (aBoolean) {
+//                    istrue = false;
+//                }
+//                if (istrue) {
+//                    int wtask = executor.getQueue().size();
+//                    if (wtask >= 200) {
+//                        break;
+//                    }
+//                    jdbcTemplate.execute("update u_task_batch set is_deleted=2 where id="+taskBatchId+"");
+//                    RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1", 66, TimeUnit.SECONDS);
+//                    CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
+//                        try {
+//                            this.checkIsExsitTaskBatch(taskApprovalVO, taskBatchId, userId, nickName);
+//                        } catch (FileNotFoundException e) {
+//                            e.printStackTrace();
+//                        }
+//                    }, executor);
+//                }
+//            }
+//        }
+//    }
+//
+//    private void checkIsExsitTaskBatch(TaskApprovalVO taskApprovalVO, String batchId, Long userId, String nickName) throws FileNotFoundException {
+//        log.info("【任务审核】当前批次开始电签。批次ID:" + batchId);
+//        taskApprovalVO.setId(batchId);
+//        taskApprovalVO.setUserId(userId);
+//        taskApprovalVO.setNickName(nickName);
+//        String pdfUrlEVisa = this.completeApprovalTask(taskApprovalVO);
+//
+//        System.out.println("电签操作成功buss-----" + pdfUrlEVisa + "---batchId=" + batchId);
+//        //TODO ============== 电签成功,修改试验状态,关联工程部位信息pdf(只有电签成功,才修改) liuYc 2023-03-16 ==============
+//        if ("OK".equals(taskApprovalVO.getFlag()) && StringUtils.isNotEmpty(pdfUrlEVisa)) {
+//            //已审批
+//            this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatus(pdfUrlEVisa, taskApprovalVO);
+//            //executor删除掉对应批次
+//            this.taskBatchService.deletedById(batchId);
+//        }
+//
+//        if (!"OK".equals(taskApprovalVO.getFlag())) {
+//            //已废除
+//            this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatusFC(taskApprovalVO);
+//            //executor删除掉对应批次
+//            this.taskBatchService.deletedById(batchId);
+//        }
+//        RedisTemplate.delete("sign-" + taskApprovalVO.getFormDataId());
+//    }
+//
+//    private String completeApprovalTask(TaskApprovalVO taskApprovalVO) {
+//        if ("OK".equals(taskApprovalVO.getFlag())) { // 电签流程
+//
+//        }else { //任务废除
+//
+//        }
+//
+//        return "";
+//    }
 }

+ 11 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java

@@ -427,7 +427,7 @@ public class TextdictInfoController extends BladeController {
         String ids = StringUtils.join(pKeyIds, ",");
 
         //删除历史数据
-        String delSql = "delete from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or excel_id="+wbsTreePrivate.getExcelId()+") and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
+        String delSql = "delete from m_textdict_info where (tab_id in(SELECT p_key_id from m_wbs_tree_private where project_id='"+wbsTreePrivate.getProjectId()+"' and excel_id='"+wbsTreePrivate.getExcelId()+"' and type=2 and is_deleted=0) or (excel_id="+wbsTreePrivate.getExcelId()+" AND project_id='"+wbsTreePrivate.getProjectId()+"')) and project_id="+wbsTreePrivate.getProjectId()+" and type in(2,6) ";
         jdbcTemplate.execute(delSql);
 
         // ------- 查询数据库是否存在 该该电签信息 ---------
@@ -458,7 +458,15 @@ public class TextdictInfoController extends BladeController {
             textdictInfo.setPyzbx(jsonObject.getDouble("pyzbx"));
             textdictInfo.setPyzby(jsonObject.getDouble("pyzby"));
             textdictInfo.setProjectId(wbsTreePrivate.getProjectId());
-            textdictInfoService.saveOrUpdate(textdictInfo);
+
+            //由于使用联合主键
+            TextdictInfo one = textdictInfoService.getOne(Wrappers.<TextdictInfo>query().eq("id", textdictInfo.getId()).eq("project_id", textdictInfo.getProjectId()));
+            if(ObjectUtil.isNotEmpty(one)){
+                textdictInfoService.saveOrUpdate(textdictInfo);
+            }else{
+                textdictInfoService.save(textdictInfo);
+            }
+
             element.removeAttr("dqId");
             element.attr("dqId", textdictInfo.getId() + "");
             if (jsonObject.getInteger("type") == 2) { //个人签字 不能用户输入
@@ -561,6 +569,7 @@ public class TextdictInfoController extends BladeController {
             textDictBean.setColName(placeholder);
             textDictBean.setSigRoleName(textdictInfo.getTextId());
             textDictBean.setIsDeleted(0);
+            textDictBean.setProjectId(wbsTreePrivate.getProjectId());
 
             textDictInfosNew.add(textDictBean);
 

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.java

@@ -46,5 +46,5 @@ public interface TextdictInfoMapper extends EasyBaseMapper<TextdictInfo> {
 
 
     List<TextdictInfoVO> selectTextdictInfoByExcelId(IPage page, TextdictInfoVO textdictInfo);
-
+    List<TextdictInfoVO> selectTextdictBYIds(@Param("ids") List<String> ids);
 }

+ 11 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.xml

@@ -39,8 +39,16 @@
     </select>
 
     <select id="selectTextdictInfoByExcelId" resultMap="textdictInfoResultMap">
-        select distinct * from m_textdict_info where is_deleted = 0
-        and type in('2','6')
-        and id in( SELECT max(id) from m_textdict_info where excel_id=#{param2.excelId} and type in(2,6) GROUP BY col_key )
+        SELECT a.* from m_textdict_info a,
+                        (select tab_id,count(1) from m_textdict_info where is_deleted = 0 and type in('2','6') and excel_id=#{param2.excelId} GROUP BY tab_id ORDER BY count(tab_id) desc LIMIT 1) b
+        where a.tab_id=b.tab_id and a.is_deleted = 0 and a.type in('2','6') and a.excel_id=#{param2.excelId}
+    </select>
+
+    <select id="selectTextdictBYIds" resultMap="textdictInfoResultMap">
+        SELECT a.* from m_textdict_info a
+        where id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
     </select>
 </mapper>

+ 1 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1812,13 +1812,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         FileOutputStream outputStream = new FileOutputStream(excelPath);
         workbook.write(outputStream);
 
-        FileUtils.excelToPdf(excelPath, pdfPath);
-        //  com.spire.xls.Workbook workbook2 = new com.spire.xls.Workbook();
-
-        //  workbook2.loadFromFile(excelPath);
-        //设置转换后的PDF页面高宽适应工作表的内容大小
-        //workbook2.getConverterSetting().setSheetFitToPage(true);
-        // workbook2.saveToFile(pdfPath, FileFormat.PDF);
+        FileUtils.excel2pdf(excelPath, pdfPath);
 
         BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
 

+ 21 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TextdictInfoServiceImpl.java

@@ -23,6 +23,7 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.support.Try;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.IoUtil;
 import org.springblade.manager.entity.TextdictInfo;
@@ -44,6 +45,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 参数信息表 服务实现类
@@ -58,20 +60,30 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
     @Override
     public IPage<TextdictInfoVO> selectTextdictInfoPage(IPage<TextdictInfoVO> page, TextdictInfoVO textdictInfo) {
         List<TextdictInfoVO> textdict = new ArrayList<>();
-
         if(textdictInfo.getType()==2){
-            WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
-                    .eq(WbsTreePrivate::getPKeyId, Func.toLong(textdictInfo.getTabId()))
-                    .eq(WbsTreePrivate::getIsDeleted, 0));
-            // 通过项目Id 和excel 进行匹配
-            textdictInfo.setProjectId(wbsTreePrivate.getProjectId());
-            textdict = baseMapper.selectTextdictInfoPage(page, textdictInfo);
-            if(textdict==null || textdict.size()<=0){ //用excel 进行匹配
-                textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
+            WbsTreePrivate privateInfo = wbsTreePrivateMapper.getByPKeyId(Func.toLong(textdictInfo.getTabId() + ""));
+            String htmlUrl = privateInfo.getHtmlUrl();
+            try {
+                InputStream fileInputStream = FileUtils.getInputStreamByUrl(htmlUrl);
+                String htmlString = IoUtil.readToString(fileInputStream);
+                Document doc = Jsoup.parse(htmlString);
+                Elements table = doc.getElementsByAttribute("dqid");
+                if(table.size()>=1){
+                    List<String> dqid = table.stream().map(d -> d.attr("dqid")).distinct().collect(Collectors.toList());
+                    textdict = baseMapper.selectTextdictBYIds(dqid);
+                    if(textdict==null || textdict.size()<=0){
+                        textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
+                    }
+                }else{
+                    textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
+                }
+            } catch (Exception e) {
+                throw new RuntimeException(e);
             }
         }else{
             textdict = baseMapper.selectTextdictInfoPage(page, textdictInfo);
         }
+        System.out.println("+++++++++++++++"+textdict.size());
         return page.setRecords(textdict);
     }
 

+ 84 - 27
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java

@@ -1,6 +1,8 @@
 package org.springblade.manager.utils;
 
 import com.aliyun.oss.common.utils.DateUtil;
+import com.aspose.cells.License;
+import com.aspose.cells.PdfSaveOptions;
 import com.aspose.cells.SaveFormat;
 import com.aspose.cells.Workbook;
 import com.itextpdf.text.Document;
@@ -239,7 +241,7 @@ public class FileUtils {
                 sheet.setPrintGridlines(false);
                 //设置 整个工作表为一页
                 sheet.setFitToPage(true);
-
+                sheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
             }
             outReport = new ByteArrayOutputStream();
             ss.write(outReport);
@@ -425,32 +427,6 @@ public class FileUtils {
     }
 
 
-//    public static void main(String[] args) throws Exception {
-//       String excelUrl = "/Users/hongchuangyanfa/Downloads/D10.1表-隧道总体质量检验单 (1).xlsx";
-//        String old_html = "/Users/hongchuangyanfa/Desktop/pdf/old_html.html";
-//        String old_xlsx = "/Users/hongchuangyanfa/Desktop/pdf/old_html.xlsx";
-//
-//   //     excelInfo2(excelUrl,old_xlsx,old_html);
-//        com.spire.xls.Workbook wb = new com.spire.xls.Workbook();
-//        wb.loadFromMHtml(old_xlsx);
-//        Worksheet sheet = wb.getWorksheets().get(0);
-//        CellRange[] cells = sheet.getCells();
-//        for (int i = 0; i < cells.length; i++) {
-//            CellRange oldcell = cells[i];
-//            CellRange mergedCell = sheet.getCellRange(oldcell.getRow(), oldcell.getColumn());
-//            String data = mergedCell.getDataValidation().getErrorMessage();
-//            System.out.println(oldcell.getRow()+"--=--"+oldcell.getColumn()+"--=--"+data);
-//        }
-//
-///*        String new_html = "/Users/hongchuangyanfa/Desktop/pdf/new_html.html";
-//        String new_xlsx = "/Users/hongchuangyanfa/Desktop/pdf/new_html.xlsx";
-//
-//        File data = new File(old_xlsx);
-//        InputStream inputStream = new FileInputStream(data);
-//        excelInfo(inputStream,new_xlsx,new_html,"2");*/
-//    }
-
-
     /**
      * 在线编辑excel 操作
      *
@@ -789,4 +765,85 @@ public class FileUtils {
         }
     }
 
+
+
+
+    public static boolean getLicense() {
+        boolean result = false;
+        try {
+            InputStream is = test.class.getClassLoader().getResourceAsStream("\\license.xml");
+            License aposeLic = new License();
+            aposeLic.setLicense(is);
+            result = true;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    public static void excel2pdf(String sourceFilePath, String desFilePathd ){
+        // 验证License 若不验证则转化出的pdf文档会有水印产生
+        if (!getLicense()) {
+            return;
+        }
+        try {
+            Workbook wb = new Workbook(sourceFilePath);// 原始excel路径
+
+            PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
+            pdfSaveOptions.setOnePagePerSheet(true);
+            pdfSaveOptions.setEmbedStandardWindowsFonts(true);
+
+            com.aspose.cells.Worksheet worksheet = wb.getWorksheets().get(0);
+            worksheet.getPageSetup().setPaperSize(com.aspose.cells.PaperSizeType.PAPER_A_4);
+            worksheet.getPageSetup().setLeftMargin(1.9);
+            worksheet.getPageSetup().setRightMargin(1.9);
+            int[] autoDrawSheets={3};
+            //当excel中对应的sheet页宽度太大时,在PDF中会拆断并分页。此处等比缩放。
+            autoDraw(wb,autoDrawSheets);
+
+            int[] showSheets={0};
+            //隐藏workbook中不需要的sheet页。
+            printSheetPage(wb,showSheets);
+            wb.save(desFilePathd, pdfSaveOptions);
+            System.out.println("完毕");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * 设置打印的sheet 自动拉伸比例
+     * @param wb
+     * @param page 自动拉伸的页的sheet数组
+     */
+    public static void autoDraw(Workbook wb,int[] page){
+        if(null!=page&&page.length>0){
+            for (int i = 0; i < page.length; i++) {
+                wb.getWorksheets().get(i).getHorizontalPageBreaks().clear();
+                wb.getWorksheets().get(i).getVerticalPageBreaks().clear();
+            }
+        }
+    }
+
+
+    /**
+     * 隐藏workbook中不需要的sheet页。
+     * @param wb
+     * @param page 显示页的sheet数组
+     */
+    public static void printSheetPage(Workbook wb,int[] page){
+        for (int i= 1; i < wb.getWorksheets().getCount(); i++)  {
+            wb.getWorksheets().get(i).setVisible(false);
+        }
+        if(null==page||page.length==0){
+            wb.getWorksheets().get(0).setVisible(true);
+        }else{
+            for (int i = 0; i < page.length; i++) {
+                wb.getWorksheets().get(i).setVisible(true);
+            }
+        }
+    }
+
 }