Преглед изворни кода

:sparkles: 订单导出时增加导出任务列表功能

Twelve615 пре 1 година
родитељ
комит
af0fd38fa7

+ 15 - 1
airport-vue/src/views/admin/AdminFileExportList.vue

@@ -109,6 +109,9 @@
                 <a-icon type="check-circle" theme="filled"
                         style="color: #68cc3c" />&nbsp;{{ record.exportStatus_dictText }}
               </a-tag>
+              <a-tag v-if="record.exportStatus==='2'" color="red">
+                <a-icon type="exclamation-circle" style="color: #ff4d4f" />&nbsp;{{ record.exportStatus_dictText }}
+              </a-tag>
             </span>
         </template>
 
@@ -219,6 +222,7 @@ export default {
         exportXlsUrl: 'admin_file_export/adminFileExport/exportXls',
         importExcelUrl: 'admin_file_export/adminFileExport/importExcel',
         dcPDF: '/admin_order/adminOrder/exportPdf',
+        reExportPdf: '/admin_order/adminOrder/reExportPdfFilesTask'
       },
       queryParam: {
         exportType: 'AdminOrderList'
@@ -247,9 +251,19 @@ export default {
           } else {
             this.$message.warning(res.message)
           }
+          this.searchQuery();
         })
       } else  {
-
+        // zip 文件
+        postAction(this.url.reExportPdf + '/' + record.id, {}).then((res) => {
+          this.loading2 = !this.loading2;
+          if (res.success) {
+            this.$message.success('重新执行任务成功请手动下载');
+          } else {
+            this.$message.warning(res.message)
+          }
+          this.searchQuery();
+        })
       }
     }
   }

+ 1 - 1
airport-vue/src/views/admin/AdminOrderList.vue

@@ -323,7 +323,7 @@ export default {
         postAction(this.url.addExportPdfFilesTaskUrl, this.selectedRowKeys).then((res) => {
           this.loading2 = !this.loading2
           if (res.success) {
-            this.$message.success('已经添加导出任务,请在下载列表中查看')
+            this.$message.success('正在导出,请在导出任务中查看')
           } else {
             this.$message.warning(res.message)
           }

+ 3 - 6
airport/jeecg-boot-base/jeecg-boot-base-tools/pom.xml

@@ -29,11 +29,8 @@
         <!--加载hutool-->
         <dependency>
             <groupId>cn.hutool</groupId>
-            <artifactId>hutool-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>cn.hutool</groupId>
-            <artifactId>hutool-crypto</artifactId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.8.22</version>
         </dependency>
         <!--加载beanutils-->
         <dependency>
@@ -42,4 +39,4 @@
         </dependency>
     </dependencies>
 
-</project>
+</project>

+ 10 - 2
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_file_export/entity/AdminFileExport.java

@@ -32,7 +32,7 @@ public class AdminFileExport {
 	/**id*/
 	@TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "id")
-	private java.lang.Integer id;
+	private java.lang.Long id;
 	/**文件名*/
 	@Excel(name = "文件名", width = 15)
     @ApiModelProperty(value = "文件名")
@@ -62,7 +62,11 @@ public class AdminFileExport {
 	@Excel(name = "导出时的参数", width = 15)
     @ApiModelProperty(value = "导出时的参数")
 	private java.lang.String exportParam;
-	/**记录在哪个功能模块下导出*/
+	/**导出描述*/
+	@Excel(name = "导出描述", width = 90)
+	@ApiModelProperty(value = "导出描述")
+	private java.lang.String exportDesc;
+	/**记录在哪个功能模块下导出,见枚举 EXPORT_FILE_TYPE*/
 	@Excel(name = "记录在哪个功能模块下导出", width = 15)
 	@Dict(dicCode = "EXPORT_FILE_TYPE")
 	@ApiModelProperty(value = "记录在哪个功能模块下导出")
@@ -71,10 +75,14 @@ public class AdminFileExport {
 	@Excel(name = "导出人", width = 15)
     @ApiModelProperty(value = "导出人")
 	private java.lang.String exportUser;
+	@ApiModelProperty(value = "导出人id")
+	private java.lang.String exportUserId;
 	/**更新人*/
 	@Excel(name = "更新人", width = 15)
     @ApiModelProperty(value = "更新人")
 	private java.lang.String updateBy;
+	@ApiModelProperty(value = "更新人")
+	private java.lang.String updateById;
 	/**导出时间*/
     @ApiModelProperty(value = "导出时间")
 	private java.util.Date createTime;

+ 14 - 0
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_file_export/service/IAdminFileExportService.java

@@ -18,4 +18,18 @@ public interface IAdminFileExportService extends IService<AdminFileExport> {
     boolean updateById(AdminFileExport adminFileExport);
 
     boolean saveOrUpdate(AdminFileExport adminFileExport);
+
+    /**
+     * 原封不动保存修改不添加信息
+     * @param adminFileExport
+     * @return
+     */
+    boolean saveOrUpdateNoInfo(AdminFileExport adminFileExport);
+
+    /**
+     * 从表中获取一个文件导出记录,如果没有则新建一个
+     * @param id
+     * @return
+     */
+    AdminFileExport getAdminFileExport(String id);
 }

+ 23 - 0
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_file_export/service/impl/AdminFileExportServiceImpl.java

@@ -1,11 +1,13 @@
 package org.jeecg.modules.admin_file_export.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.base.Strings;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.admin_file_export.entity.AdminFileExport;
 import org.jeecg.modules.admin_file_export.mapper.AdminFileExportMapper;
 import org.jeecg.modules.admin_file_export.service.IAdminFileExportService;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -25,8 +27,10 @@ public class AdminFileExportServiceImpl extends ServiceImpl<AdminFileExportMappe
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         if(sysUser!=null){
             adminFileExport.setUpdateBy(sysUser.getUsername());
+            adminFileExport.setUpdateById(sysUser.getId());
             if (Strings.isNullOrEmpty(adminFileExport.getExportUser())){
                 adminFileExport.setExportUser(sysUser.getUsername());
+                adminFileExport.setExportUserId(sysUser.getId());
             }
         }
         //文件信息
@@ -58,4 +62,23 @@ public class AdminFileExportServiceImpl extends ServiceImpl<AdminFileExportMappe
         this.setUpdateInfo(adminFileExport);
         return super.saveOrUpdate(adminFileExport);
     }
+
+    @Override
+    public boolean saveOrUpdateNoInfo(AdminFileExport adminFileExport) {
+        return super.saveOrUpdate(adminFileExport);
+    }
+
+    @Override
+    @NotNull
+    public AdminFileExport getAdminFileExport(String id) {
+        LambdaQueryWrapper<AdminFileExport> adminFileExportQueryWrapper = new LambdaQueryWrapper<>(AdminFileExport.class);
+        adminFileExportQueryWrapper.eq(AdminFileExport::getExportParam, id)
+                .eq(AdminFileExport::getFileType,"pdf")
+                .eq(AdminFileExport::getExportType,"AdminOrderList");
+        AdminFileExport adminFileExport = this.getOne(adminFileExportQueryWrapper);
+        if (adminFileExport == null) {
+            adminFileExport = new AdminFileExport();
+        }
+        return adminFileExport;
+    }
 }

+ 29 - 25
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_order/controller/AdminOrderController.java

@@ -231,7 +231,7 @@ public class AdminOrderController {
         String fileName = "";
         String fileNameQ = "";
         String fileNameHtml = "";
-        AdminFileExport adminFileExport = getAdminFileExport(id);
+        AdminFileExport adminFileExport = adminFileExportService.getAdminFileExport(id);
         adminFileExport.setExportParam(id);
         adminFileExport.setExportStatus("1");
         adminFileExport.setExportType("AdminOrderList");
@@ -304,6 +304,7 @@ public class AdminOrderController {
             HtmlToPdf.convert(outputFolderHtml, outputFolder);
             File file = new File(outputFolder);
             adminFileExport.setFileSize(file.exists() ? file.length() : 0);
+            deleteFile(outputFolderHtml);
 
 //            AddWatermarkToPDF.convert(fileName,"temp\\sy.png");
             Date qifeiTime = byId.getQifeiTime();
@@ -319,6 +320,7 @@ public class AdminOrderController {
             if (after24Hours.before(new Date())) {
                 //打印加水印
                 AddWatermarkToPDF.convert(fileName, adminPlatform.getSy());
+                deleteFile(outputFolder);
             } else {
                 fileName = systemHost + "/sys/common/static/tempFile/" + fileName;
                 adminFileExport.setUrl(fileName);
@@ -328,6 +330,7 @@ public class AdminOrderController {
 
         } catch (Exception e) {
             adminFileExport.setExportStatus("2");
+            adminFileExport.setExportDesc("导出时发生错误!");
             adminFileExportService.saveOrUpdate(adminFileExport);
             return Result.error("导出错误");
         }
@@ -339,40 +342,41 @@ public class AdminOrderController {
         return Result.OK(fileName);
     }
 
-    @NotNull
-    private AdminFileExport getAdminFileExport(String id) {
-        LambdaQueryWrapper<AdminFileExport> adminFileExportQueryWrapper = new LambdaQueryWrapper<>(AdminFileExport.class);
-        adminFileExportQueryWrapper.eq(AdminFileExport::getExportParam, id)
-                .eq(AdminFileExport::getFileType,"pdf")
-                .eq(AdminFileExport::getExportType,"AdminOrderList");
-        AdminFileExport adminFileExport = adminFileExportService.getOne(adminFileExportQueryWrapper);
-        if (adminFileExport == null) {
-            adminFileExport = new AdminFileExport();
+    private void deleteFile(String outputFolderHtml) {
+        File file1 = new File(outputFolderHtml);
+        if (file1.exists()){
+            file1.delete();
         }
-        return adminFileExport;
     }
 
     @AutoLog(value = "订单管理-分页列表添加导出多个PDF任务")
     @ApiOperation(value = "订单管理-分页列表添加导出多个PDF任务", notes = "订单管理-分页列表查询")
     @RequestMapping(value = "/addExportPdfFilesTask", method = {RequestMethod.POST})
     public Result<?> addExportPdfFilesTask(@RequestBody String[] orderIds) {
-        /*
-         * id,文件名,任务参数(orderIds),文件url,文件类型,文件大小,导出状态(0:正在导出,1:导出完成),导出文件数量,导出人,导出时间,修改时间
-         * */
-        String fileName = "";
-        String fileNameQ = "";
-        String fileNameHtml = "";
-
-        fileName = fileNameQ + ".pdf";
-        fileNameHtml = fileNameQ + ".html";
-
-        String outputFolder = AirportUtil.getLocalUploadTempPath() + "/" + fileName;
-        String outputFolderHtml = AirportUtil.getLocalUploadTempPath() + "/" + fileNameHtml;
-
-        fileName = systemHost + "/sys/common/static/tempFile/sy_" + fileName;
+        if (orderIds == null || orderIds.length <=0) {
+            return Result.error("请选择订单");
+        }
+        boolean r = adminOrderService.addExportPdfFilesTask(Arrays.asList(orderIds));
+        if (r) {
+            log.info("添加导出任务成功!");
+        }
         return Result.OK("任务已添加到下载列表", orderIds);
     }
 
+    @AutoLog(value = "订单管理-分页列表重新导出多个PDF任务")
+    @ApiOperation(value = "订单管理-分页列表重新导出多个PDF任务", notes = "订单管理-分页列表查询")
+    @RequestMapping(value = "/reExportPdfFilesTask/{id}", method = {RequestMethod.POST})
+    public Result<?> reExportPdfFilesTask(@PathVariable(required = true) String id) {
+        if (Strings.isNullOrEmpty(id)) {
+            return Result.error("请选择导出任务");
+        }
+        boolean r = adminOrderService.reExportPdfFilesTask(id);
+        if (r) {
+            log.info("重新执行导出任务成功!");
+        }
+        return Result.OK("任务已重新开始执行", id);
+    }
+
     /**
      * 添加
      *

+ 20 - 5
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_order/service/IAdminOrderService.java

@@ -18,21 +18,21 @@ public interface IAdminOrderService extends IService<AdminOrder> {
 
 	/**
 	 * 添加一对多
-	 * 
+	 *
 	 */
 	public void saveMain(AdminOrder adminOrder, List<AdminOrderExamine> adminOrderExamineList) ;
-	
+
 	/**
 	 * 修改一对多
-	 * 
+	 *
 	 */
 	public void updateMain(AdminOrder adminOrder, List<AdminOrderExamine> adminOrderExamineList);
-	
+
 	/**
 	 * 删除一对多
 	 */
 	public void delMain(String id);
-	
+
 	/**
 	 * 批量删除一对多
 	 */
@@ -46,4 +46,19 @@ public interface IAdminOrderService extends IService<AdminOrder> {
 	 * @return
 	 */
     Result<Boolean> recoveryOrder(AdminOrder adminOrder, String name);
+
+	/**
+	 * 创建导出任务
+	 * @param orderIdList
+	 * @return
+	 */
+    boolean addExportPdfFilesTask(List<String> orderIdList);
+
+	/**
+	 * 重新执行导出任务
+	 * @param id
+	 * @return
+	 */
+	boolean reExportPdfFilesTask(String id);
+
 }

+ 287 - 8
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_order/service/impl/AdminOrderServiceImpl.java

@@ -1,29 +1,50 @@
 package org.jeecg.modules.admin_order.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.thread.ThreadFactoryBuilder;
+import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.core.util.ZipUtil;
+import cn.hutool.json.JSON;
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.base.Strings;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.admin.entity.AdminPlatform;
+import org.jeecg.modules.admin.service.IAdminPlatformService;
 import org.jeecg.modules.admin_aircraft_position.entity.AdminAircraftPosition;
 import org.jeecg.modules.admin_aircraft_position.service.IAdminAircraftPositionService;
+import org.jeecg.modules.admin_file_export.entity.AdminFileExport;
+import org.jeecg.modules.admin_file_export.service.IAdminFileExportService;
 import org.jeecg.modules.admin_order.entity.AdminOrder;
 import org.jeecg.modules.admin_order.entity.AdminOrderExamine;
+import org.jeecg.modules.admin_order.entity.AdminOrderExamine2;
 import org.jeecg.modules.admin_order.mapper.AdminOrderExamineMapper;
 import org.jeecg.modules.admin_order.mapper.AdminOrderMapper;
 import org.jeecg.modules.admin_order.service.IAdminOrderExamineService;
 import org.jeecg.modules.admin_order.service.IAdminOrderService;
 import org.jeecg.modules.admin_security_check.entity.AdminSecurityCheck;
 import org.jeecg.modules.admin_security_check.service.IAdminSecurityCheckService;
-import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.api.AddWatermarkToPDF;
+import org.jeecg.modules.api.HtmlToPdf;
+import org.jeecg.modules.utils.AirportUtil;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.thymeleaf.TemplateEngine;
+import org.thymeleaf.context.Context;
 
+import java.io.File;
+import java.io.FileWriter;
 import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-import java.util.Collection;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.Future;
 
 /**
  * @Description: 订单管理
@@ -44,6 +65,21 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, AdminOr
     @Autowired
     private IAdminSecurityCheckService adminSecurityCheckService;
 
+    @Value("${airport.system.host:http://120.79.86.50:9999/airport}")
+    private String systemHost;
+
+    @Autowired
+    private IAdminFileExportService adminFileExportService;
+
+    @Autowired
+    private IAdminOrderExamineService adminOrderExamineService;
+
+    @Autowired
+    private IAdminPlatformService adminPlatformService;
+
+    @Autowired
+    private TemplateEngine templateEngine;
+
     @Override
     @Transactional
     public void saveMain(AdminOrder adminOrder, List<AdminOrderExamine> adminOrderExamineList) {
@@ -100,8 +136,8 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, AdminOr
         adminAircaftQueryWarpper
                 //.eq("aircraft_position_num", adminOrder.getAircraftPositionNum())
                 .eq("aircraft_num", adminOrder.getAircraftNum())
-                //.eq("drop_time", adminOrder.getDropTime())
-                //.eq("flight_num", adminOrder.getFlightNum())
+        //.eq("drop_time", adminOrder.getDropTime())
+        //.eq("flight_num", adminOrder.getFlightNum())
         ;
         AdminAircraftPosition adminAircraftPosition = adminAircraftPositionService.getOne(adminAircaftQueryWarpper);
         if (adminAircraftPosition == null || Strings.isNullOrEmpty(adminAircraftPosition.getAircraftNum())) {
@@ -158,4 +194,247 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, AdminOr
         return result;
     }
 
+    @Override
+    public boolean addExportPdfFilesTask(List<String> orderIdList) {
+        String folderName = String.valueOf(DateUtils.getCurrentTimestamp());
+
+        // 添加导出任务
+        AdminFileExport adminFileExport = new AdminFileExport();
+        adminFileExport.setName(folderName + ".zip");
+        adminFileExport.setExportType("AdminOrderList");
+        adminFileExport.setExportStatus("0");
+        adminFileExport.setExportParam(JSONUtil.toJsonStr(orderIdList));
+        boolean save = adminFileExportService.save(adminFileExport);
+        if (save) {
+            // 创建线程生成文件
+            ThreadUtil.execAsync(() -> {
+                // 生成文件
+                generateZipFile(adminFileExport);
+            });
+
+        }
+        return save;
+    }
+
+    @Override
+    public boolean reExportPdfFilesTask(String id) {
+        AdminFileExport adminFileExport = adminFileExportService.getById(id);
+        if (adminFileExport != null) {
+            adminFileExport.setExportStatus("0");
+            boolean save = adminFileExportService.saveOrUpdate(adminFileExport);
+            if (save) {
+                // 创建线程生成文件
+                ThreadUtil.execAsync(() -> {
+                    // 生成文件
+                    generateZipFile(adminFileExport);
+                });
+            }
+            return true;
+        }else {
+            return false;
+        }
+    }
+
+    /**
+     * 生成zip文件
+     *
+     * @param adminFileExport
+     */
+    private synchronized void generateZipFile(AdminFileExport adminFileExport) {
+        // 文件夹名称
+        String folderName = createFolder(adminFileExport);
+        // 输出的文件夹
+        String outputFolder = AirportUtil.getLocalUploadTempPath() + "/" + folderName;
+        File outputFolderFile = new File(outputFolder);
+        if (!outputFolderFile.exists()) {
+            outputFolderFile.mkdirs();
+        }
+        // 生成文件
+        String exportParam = adminFileExport.getExportParam();
+        if (Strings.isNullOrEmpty(exportParam) || "[]".equals(exportParam)) {
+            // 参数是空的
+            File file1 = new File(AirportUtil.getLocalUploadTempPath() + "/" + adminFileExport.getName());
+            if (!file1.exists()) {
+                file1.mkdirs();
+            }
+            adminFileExport.setFileNum(0);
+            adminFileExport.setFileSize(0L);
+            adminFileExport.setExportStatus("2");
+            adminFileExport.setExportDesc("没有选择要导出的订单");
+            adminFileExport.setUrl(systemHost + "/sys/common/static/tempFile/" + adminFileExport.getName());
+            adminFileExportService.saveOrUpdateNoInfo(adminFileExport);
+            return;
+        }
+        JSONArray jsonArray = JSONUtil.parseArray(exportParam);
+        List<String> orderIdList = jsonArray.toList(String.class);
+        // 生成zip文件中的内容
+        List<String> genFileNameList = generatePdfFileByOrderList(orderIdList, outputFolder);
+        // 生成zip文件
+        File zip = ZipUtil.zip(outputFolder);
+        adminFileExport.setFileNum(genFileNameList.size());
+        adminFileExport.setFileSize(zip.length());
+        adminFileExport.setUrl(systemHost + "/sys/common/static/tempFile/" + adminFileExport.getName());
+        if (orderIdList.size() == genFileNameList.size()) {
+            adminFileExport.setExportDesc("已完成导出");
+            adminFileExport.setExportStatus("1");
+
+        } else {
+            if (genFileNameList.size() == 0) {
+                adminFileExport.setExportStatus("2");
+            } else {
+                adminFileExport.setExportStatus("1");
+            }
+            adminFileExport.setExportDesc("共" + orderIdList.size() + "个订单," + (orderIdList.size() - genFileNameList.size()) + "个未找到数据");
+        }
+        adminFileExportService.saveOrUpdateNoInfo(adminFileExport);
+        // 删除多余文件
+        FileUtil.del(outputFolderFile);
+    }
+
+    /**
+     * 根据订单列表向指定文件夹中生成pdf文件
+     *
+     * @param orderIdList
+     * @param outputFolder
+     * @return
+     */
+    private List<String> generatePdfFileByOrderList(List<String> orderIdList, String outputFolder) {
+        if (orderIdList == null || orderIdList.isEmpty()) {
+            return new ArrayList<>();
+        }
+        ArrayList<String> genFileNameList = new ArrayList<>();
+        for (String orderId : orderIdList) {
+            String fileName = generatePdfFile(orderId, outputFolder);
+            if (Strings.isNullOrEmpty(fileName)) continue;
+            genFileNameList.add(fileName);
+        }
+        return genFileNameList;
+    }
+
+    private String generatePdfFile(String id, String path) {
+        String fileName = "";
+        String fileNameQ = "";
+        String fileNameHtml = "";
+
+        try {
+            QueryWrapper<AdminOrderExamine> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("order_id", id);
+            List<AdminOrderExamine> list = adminOrderExamineService.list(queryWrapper);
+            if (list.size() == 0) {
+                return null;
+            }
+            SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMddHHmmss");
+            AdminOrder byId = this.getById(id);
+
+            //fileNameQ = id + "_" + System.currentTimeMillis();
+            fileNameQ = yyyyMMdd.format(byId.getCreateTime()) + "-" + byId.getAircraftNum();
+            fileName = fileNameQ + ".pdf";
+            fileNameHtml = fileNameQ + ".html";
+
+
+            String outputFolder = path + "/" + fileName;
+            String outputFolderHtml = path + "/" + fileNameHtml;
+
+            //获取水印
+            List<AdminPlatform> adminPlatformList = adminPlatformService.list();
+            AdminPlatform adminPlatform = adminPlatformList.get(0);
+
+            Context context = new Context();
+            //订单号
+            context.setVariable("OrderNum", byId.getOrderNum());
+            //飞机号
+            context.setVariable("AircraftNum", byId.getAircraftNum());
+            //航班号
+            context.setVariable("FlightNum", byId.getFlightNum());
+            //落地机位
+            context.setVariable("AircraftPositionNum", byId.getAircraftPositionNum());
+
+//            context.setVariable( "sy", "temp/sy.png" );
+            //创建时间
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            context.setVariable("Time", sdf.format(byId.getCreateTime()));
+//            context.setVariable( "order", byId );
+            //阶段数据
+            List<AdminOrderExamine2> list2 = new ArrayList<>();
+            for (AdminOrderExamine main : list) {
+                AdminOrderExamine2 vo = new AdminOrderExamine2();
+                BeanUtils.copyProperties(main, vo);
+                String[] arrPic = main.getPic().split(",");
+                String[] arrExamineYes = main.getExamineYes().split(",");
+                vo.setPic(arrPic);
+                vo.setExamineYes(arrExamineYes);
+                list2.add(vo);
+            }
+            context.setVariable("date", list2);
+            context.setVariable("SystemHost", systemHost);
+
+            String htmlStr = templateEngine.process("template", context);
+
+//            // 创建一个新的HTML文件
+            FileWriter writer = new FileWriter(outputFolderHtml);
+            // 写入HTML代码
+            writer.write(htmlStr);
+            // 关闭文件写入器
+            writer.close();
+            HtmlToPdf.convert(outputFolderHtml, outputFolder);
+            // 删除html文件
+            File htmlFile = new File(outputFolderHtml);
+            if (htmlFile.exists()) {
+                htmlFile.delete();
+            }
+            Date qifeiTime = byId.getQifeiTime();
+            if (qifeiTime == null) {
+                if ("交接结束".equals(byId.getType())) {
+                    qifeiTime = byId.getUpdateTime();
+                } else {
+                    qifeiTime = byId.getUpdateTime();
+                }
+            }
+            long after24HoursInMillis = qifeiTime.getTime() + 24 * 60 * 60 * 1000; // 将毫秒数增加 24 小时
+            Date after24Hours = new Date(after24HoursInMillis);
+            if (after24Hours.before(new Date())) {
+                //打印加水印
+                AddWatermarkToPDF.convert(fileName, adminPlatform.getSy(),path);
+                // 删除旧文件
+                File oldFile = new File(outputFolder);
+                if (oldFile.exists()) {
+                    oldFile.delete();
+                }
+                return "sy_" + fileName;
+            } else {
+                return fileName;
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 创建存放 zip中的文件的文件夹
+     * 如果名称为空则补全
+     *
+     * @param adminFileExport
+     * @return
+     */
+    private String createFolder(AdminFileExport adminFileExport) {
+        String name = adminFileExport.getName();
+        String folderName;
+        if (!Strings.isNullOrEmpty(name)) {
+            if (name.contains(".")) {
+                String[] split = name.split("\\.");
+                folderName = split[0];
+            } else {
+                folderName = name;
+                adminFileExport.setName(folderName + ".zip");
+            }
+        } else {
+            //名字是空的
+            folderName = String.valueOf(DateUtils.getCurrentTimestamp());
+            adminFileExport.setName(folderName + ".zip");
+        }
+        return folderName;
+    }
+
 }

+ 7 - 3
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/AddWatermarkToPDF.java

@@ -34,15 +34,19 @@ import org.jeecg.modules.utils.AirportUtil;
 public class AddWatermarkToPDF {
 
     public static void convert(String fileName, String syPath) {
+        convert(fileName, syPath,AirportUtil.getLocalUploadTempPath());
+    }
+
+    public static void convert(String fileName, String syPath, String filePath) {
 //        String inputPdfPath = "D:\\AJeecgBootFiles\\"+fileName;
 //        String watermarkImagePath = "D:\\AJeecgBootFiles\\"+syPath;
 //        String syFileName = "sy_"+fileName;
 //        String outputPdf = "D:\\AJeecgBootFiles\\"+syFileName;
 
-        String inputPdfPath = AirportUtil.getLocalUploadTempPath() + "/"+fileName;
+        String inputPdfPath = filePath + "/"+fileName;
         String watermarkImagePath = AirportUtil.getLocalUploadPath()+"/"+syPath;
         String syFileName = "sy_"+fileName;
-        String outputPdf = AirportUtil.getLocalUploadTempPath()+"/"+syFileName;
+        String outputPdf = filePath+"/"+syFileName;
 
         try {
             PDDocument document = PDDocument.load( new File( inputPdfPath ) );
@@ -156,4 +160,4 @@ public class AddWatermarkToPDF {
 //            e.printStackTrace();
 //        }
 //    }
-}
+}