Browse Source

订单自提样式

njs 3 years ago
parent
commit
469bb6497c

+ 20 - 32
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/EsignController.java

@@ -170,7 +170,7 @@ public class EsignController extends ApiBaseController {
     /**
      * 指派司机授权
      */
-    @ApiOperation(value = "指派司机授权", notes = "参数:{'orderId':'xxx','userId':'xxx','customerCode':'xxx','entrustName':'xxx','beentrustName':'xxx','bId':'xxx','carNumber':'xxx','deliveryNumber':'','year':'xxx','month':'xxx','day':'xxx','redirectUrl':'xxx'}"+
+    @ApiOperation(value = "指派司机授权", notes = "参数:{'orderId':'xxx','userId':'xxx','customerCode':'xxx','entrustName':'xxx','beentrustName':'xxx','bId':'xxx','carNumber':'xxx','deliveryNumber':'xxx','runTime':'xxx','redirectUrl':'xxx'}"+
             "\n(orderId:订单编号" +
             "\n(userId: 用户id" +
             "\n(customerCode: 经销商编号" +
@@ -179,9 +179,7 @@ public class EsignController extends ApiBaseController {
             "\n(bId:身份证号码" +
             "\n(carNumber:车牌" +
             "\n(deliveryNumber:交货单号" +
-            "\n(year:年" +
-            "\n(month:月" +
-            "\n(day:日" +
+            "\n(runTime:提货时间"+
             "\n redirectUrl:签署完成跳转地址")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "params", paramType = "body")
@@ -190,34 +188,26 @@ public class EsignController extends ApiBaseController {
     public Object dealerSignDriver() {
 
         ParameterObject obj = getParameterObject();
-        Calendar now = Calendar.getInstance();
-        //获取当前时间的年
-        int nowYear = now.get(Calendar.YEAR);
-        int nowMonth=now.get(Calendar.MONTH);
-        int nowDay=now.get(Calendar.DATE);
         obj.checkParameterNotNull("orderId,entrustName,beentrustName,bId,carNumber,deliveryNumber,year,month,day,redirectUrl");
-        String orderIds = obj.getString("orderId");
-        String[] s = orderIds.split(",");
+        String orderId = obj.getString("orderId");
+       // String[] s = orderIds.split(",");
         try {
-        for(String orderId : s) {
+       /* for(String orderId : s) {*/
         String userId = obj.getString("userId");
         String customerCode = obj.getString("customerCode");
         String entrustName = obj.getString("entrustName");
         String beentrustName = obj.getString("beentrustName");
         String bId = obj.getString("bId");
+        String runTime=obj.getString("runTime");
         String carNumber = obj.getString("carNumber");
-        String deliveryNumbers = obj.getString("deliveryNumber");
-        String[] d= deliveryNumbers.split(",");
-        for(String deliveryNumber : d) {
-        String year = String.valueOf(nowYear);
-        String month = String.valueOf(nowMonth);
-        String day = String.valueOf(nowDay);
+        String deliveryNumber = obj.getString("deliveryNumber");
+     /*   String[] d= deliveryNumbers.split(",");
+        for(String deliveryNumber : d) {*/
         String redirectUrl = obj.getString("redirectUrl");
         logger.info("签署完成跳转地址:{}",redirectUrl);
 
 
         String businessScene = "司机授权";
-        //String fileName = orderId+"_签收订单.pdf";
         String fileName = deliveryNumber+"_签收订单.pdf";
         /*根据userId查询个人注册后accountId*/
         String signerAccountId = "";
@@ -234,13 +224,6 @@ public class EsignController extends ApiBaseController {
 //        String chainsCode = customersExtService.selectChainsCodeByOrderId(orderId);
             /*首先根据订单id-orderId查询订单是否已被签署*/
 //        OrderFile orderFlag = orderFileService.selectOrderFileById(orderId);
-            ESignUpPDFModal fileModal = eSignService.upload(orderId,deliveryNumber,customerCode,sysUser.getSysUserExt().getOrgName(),sysUser.getUserName());
-            /*1、根据传入订单id,查询订单相关信息生成PDF,调用e签宝上传方法返回文件fileId*/
-            Object fileId = fileModal.getFileId();
-            logger.info("签署订单返回文件id:{}",fileId);
-            /*2、调用E签宝接口一步发起流程,得到返回的流程id*/
-            String flowId = signService.oneStepFlow(businessScene, fileId.toString(),fileModal.getX(),fileModal.getY(), fileName, signerAccountId, authorizedAccountId,redirectUrl);
-            logger.info("签署订单一步发起完成流程id:{}",flowId);
             /*3、调用E签宝获取签署地址*/
 //            String result = signService.processExecuteUrl(flowId, signerAccountId, authorizedAccountId);
             /*4、保存订单id和flowId*/
@@ -251,20 +234,25 @@ public class EsignController extends ApiBaseController {
                 orderFile.setCustomersCode(authorizedAccountId);
                 orderFile.setSignerId(signerAccountId);
                 orderFile.setSignerName(sysUser.getUserName());
-                orderFile.setFlowId(flowId);
                 orderFile.setBeentrustName(beentrustName);
                 orderFile.setCarNumber(carNumber);
                 orderFile.setbId(bId);
                 orderFile.setEntrustName(entrustName);
-                orderFile.setDay(day);
-                orderFile.setMonth(month);
-                orderFile.setYear(year);
+                orderFile.setRunTime(runTime);
+                ESignUpPDFModal fileModal = eSignService.uploadDriver(orderFile);
+                /*1、根据传入订单id,查询订单相关信息生成PDF,调用e签宝上传方法返回文件fileId*/
+                Object fileId = fileModal.getFileId();
+                logger.info("签署订单返回文件id:{}",fileId);
+                /*2、调用E签宝接口一步发起流程,得到返回的流程id*/
+                String flowId = signService.oneStepFlow(businessScene, fileId.toString(),fileModal.getX(),fileModal.getY(), fileName, signerAccountId, authorizedAccountId,redirectUrl);
+                logger.info("签署订单一步发起完成流程id:{}",flowId);
+                orderFile.setFlowId(flowId);
                 orderFileService.insertOrderFile(orderFile);
                 logger.info("保存签署订单附件");
                 File f = new File(fileModal.getFilePath());
                 f.delete();
-            }
-            }
+            //}
+           // }
             logger.info("签署订单完成");
             return AjaxResult.success("签收成功");
         } catch (Exception e) {

+ 7 - 31
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/domain/OrderFile.java

@@ -90,41 +90,17 @@ public class OrderFile extends BaseEntity
     @Excel(name = "车牌号")
     private String carNumber;
 
-    /**  */
-    @Excel(name = "")
-    private String year;
+    /** 提货时间 */
+    @Excel(name = "提货时间")
+    private String runTime;
 
-    /** 月 */
-    @Excel(name = "月")
-    private String month;
 
-    /** 日 */
-    @Excel(name = "日")
-    private String day;
-
-
-    public String getYear() {
-        return year;
-    }
-
-    public void setYear(String year) {
-        this.year = year;
-    }
-
-    public String getMonth() {
-        return month;
-    }
-
-    public void setMonth(String month) {
-        this.month = month;
-    }
-
-    public String getDay() {
-        return day;
+    public String getRunTime() {
+        return runTime;
     }
 
-    public void setDay(String day) {
-        this.day = day;
+    public void setRunTime(String runTime) {
+        this.runTime = runTime;
     }
 
     public String getEntrustName() {

+ 121 - 0
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/domain/OrderSelfNote.java

@@ -0,0 +1,121 @@
+package com.dgtly.wxportal.domain;
+
+import com.dgtly.common.core.domain.BaseEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 收货单
+ * </p>
+ *
+ * @author csz
+ * @since 2020-07-30
+ */
+public class OrderSelfNote extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+
+    //    订单号
+    private String orderNumber;
+    //    订单创建时间
+    private String orderCreationTime;
+    //    交货单号
+    private String deliveryNumber;
+    //    委托人
+    private String entrustName;
+    //    受托人
+    private String beentrustName ;
+    //    身份证号
+    private String bId ;
+    //    车牌
+    private String carNumber ;
+
+    //经销商代号
+    private String belongTo;
+    //  经销商名称
+    private String customerName;
+    private String agent;
+
+    public String getOrderNumber() {
+        return orderNumber;
+    }
+
+    public void setOrderNumber(String orderNumber) {
+        this.orderNumber = orderNumber;
+    }
+
+    public String getOrderCreationTime() {
+        return orderCreationTime;
+    }
+
+    public void setOrderCreationTime(String orderCreationTime) {
+        this.orderCreationTime = orderCreationTime;
+    }
+
+    public String getDeliveryNumber() {
+        return deliveryNumber;
+    }
+
+    public void setDeliveryNumber(String deliveryNumber) {
+        this.deliveryNumber = deliveryNumber;
+    }
+
+    public String getEntrustName() {
+        return entrustName;
+    }
+
+    public void setEntrustName(String entrustName) {
+        this.entrustName = entrustName;
+    }
+
+    public String getBeentrustName() {
+        return beentrustName;
+    }
+
+    public void setBeentrustName(String beentrustName) {
+        this.beentrustName = beentrustName;
+    }
+
+    public String getbId() {
+        return bId;
+    }
+
+    public void setbId(String bId) {
+        this.bId = bId;
+    }
+
+    public String getCarNumber() {
+        return carNumber;
+    }
+
+    public void setCarNumber(String carNumber) {
+        this.carNumber = carNumber;
+    }
+
+    public String getBelongTo() {
+        return belongTo;
+    }
+
+    public void setBelongTo(String belongTo) {
+        this.belongTo = belongTo;
+    }
+
+    public String getCustomerName() {
+        return customerName;
+    }
+
+    public void setCustomerName(String customerName) {
+        this.customerName = customerName;
+    }
+
+    public String getAgent() {
+        return agent;
+    }
+
+    public void setAgent(String agent) {
+        this.agent = agent;
+    }
+}

+ 2 - 1
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/service/ESignService.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.dgtly.system.domain.CustomersExt;
 import com.dgtly.system.domain.SysUser;
 import com.dgtly.wxportal.domain.ESignUpPDFModal;
+import com.dgtly.wxportal.domain.OrderFile;
 
 import java.util.Map;
 
@@ -28,7 +29,7 @@ public interface ESignService {
    */
   ESignUpPDFModal upload(String orderId,String tmsShipNumber,String customerCode, String customerName,String userName);
 
-  ESignUpPDFModal uploadDriver(String orderId,String tmsShipNumber,String customerCode, String customerName,String userName);
+  ESignUpPDFModal uploadDriver(OrderFile orderFile);
 
 
      String verificationUser();

+ 2 - 1
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/service/IEReceivingNoteService.java

@@ -2,6 +2,7 @@ package com.dgtly.wxportal.service;
 
 
 import com.dgtly.wxportal.domain.EReceivingNote;
+import com.dgtly.wxportal.domain.OrderSelfNote;
 
 import java.util.List;
 
@@ -24,7 +25,7 @@ public interface IEReceivingNoteService {
      * @param customerName  经销商名称
      * @return
      */
-    EReceivingNote selectEReceivingNote(String orderId,String tmsShipNumber,String customerCode,String customerName,String userName);
 
+    EReceivingNote selectEReceivingNote(String orderId,String tmsShipNumber,String customerCode,String customerName,String userName);
 
 }

+ 3 - 0
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/service/impl/EReceivingNoteServiceImpl.java

@@ -3,6 +3,7 @@ package com.dgtly.wxportal.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.dgtly.common.exception.base.BaseException;
 import com.dgtly.wxportal.domain.EReceivingNote;
+import com.dgtly.wxportal.domain.OrderSelfNote;
 import com.dgtly.wxportal.service.IEReceivingNoteService;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
@@ -72,4 +73,6 @@ public class EReceivingNoteServiceImpl implements IEReceivingNoteService {
     }
 
 
+
+
 }

+ 15 - 4
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/service/impl/ESignServiceImpl.java

@@ -6,6 +6,8 @@ import com.dgtly.wxportal.domain.EReceivingNote;
 import com.dgtly.system.domain.SysUser;
 import com.dgtly.system.service.ICustomersExtService;
 import com.dgtly.wxportal.domain.ESignUpPDFModal;
+import com.dgtly.wxportal.domain.OrderFile;
+import com.dgtly.wxportal.domain.OrderSelfNote;
 import com.dgtly.wxportal.service.IEReceivingNoteService;
 import com.dgtly.system.service.ISysUserService;
 import com.dgtly.wxportal.config.ESignConfig;
@@ -13,6 +15,7 @@ import com.dgtly.wxportal.service.ESignService;
 import com.dgtly.wxportal.utils.ESign.ESignHttpUtil;
 import com.dgtly.wxportal.utils.ESign.ESignUploadUtil;
 import com.dgtly.wxportal.utils.ESign.ESignUrl;
+import com.dgtly.wxportal.utils.pdf.PDFSelfUtil;
 import com.dgtly.wxportal.utils.pdf.PDFUtil;
 import com.dgtly.wxportal.utils.pdf.Watermark;
 import com.itextpdf.text.Document;
@@ -79,9 +82,16 @@ public class ESignServiceImpl implements ESignService {
     }
 
     @Override
-    public ESignUpPDFModal uploadDriver(String orderId,String tmsShipNumber,String customerCode,String customerName,String userName) {
+    public ESignUpPDFModal uploadDriver(OrderFile orderFile) {
+
+        OrderSelfNote receivingNote =new OrderSelfNote();
+        receivingNote.setBeentrustName(orderFile.getBeentrustName());
+        receivingNote.setOrderCreationTime(orderFile.getRunTime());
+        receivingNote.setbId(orderFile.getbId());
+        receivingNote.setCarNumber(orderFile.getCarNumber());
+        receivingNote.setDeliveryNumber(orderFile.getDeliveryNumber());
+        receivingNote.setEntrustName(orderFile.getEntrustName());
 
-        EReceivingNote receivingNote = iMetaHanaSalesOrderService.selectEReceivingNote(orderId,tmsShipNumber,customerCode,customerName,userName);
         Map<String,Object> map = new HashMap<>();
         //创建PDF
         ESignUpPDFModal fileModal = creatDriverPdf(receivingNote);
@@ -297,7 +307,7 @@ public class ESignServiceImpl implements ESignService {
      * @param
      * @return
      */
-    private ESignUpPDFModal creatDriverPdf(EReceivingNote receivingNote){
+    private ESignUpPDFModal creatDriverPdf(OrderSelfNote receivingNote){
         ESignUpPDFModal res = new ESignUpPDFModal();
         String fileUrl = "";
         int size = 0;
@@ -329,7 +339,7 @@ public class ESignServiceImpl implements ESignService {
             document.addCreator("");// 创建者
 
             // 4.向文档中添加内容
-            size = PDFUtil.generateEPDF(document,receivingNote, false);
+            size = PDFSelfUtil.generateEPDF(document,receivingNote, false);
             writer.flush();
             // 5.关闭文档
             document.close();
@@ -349,6 +359,7 @@ public class ESignServiceImpl implements ESignService {
         return res;
     }
 
+
     /**
      * 获取文件上传路径
      * @param filePath

+ 789 - 0
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/utils/pdf/PDFSelfUtil.java

@@ -0,0 +1,789 @@
+package com.dgtly.wxportal.utils.pdf;
+
+import com.dgtly.wxportal.domain.ConfirmCollectQueryDeliverLineModel;
+import com.dgtly.wxportal.domain.ConfirmCollectQueryDeliverModel;
+import com.dgtly.wxportal.domain.EReceivingNote;
+import com.dgtly.wxportal.domain.OrderSelfNote;
+import com.itextpdf.text.*;
+import com.itextpdf.text.pdf.*;
+import com.itextpdf.text.pdf.draw.DottedLineSeparator;
+import com.itextpdf.text.pdf.draw.LineSeparator;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @description: PDF相关处理
+ * @author: qxm
+ * @date: 2020/10/13 17:37
+ */
+public class PDFSelfUtil {
+    /**
+     * 建立第一个PDF文档:
+     * 一、主要步骤(5个):
+     *
+     * 1.新建document对象,可通过一下三种任意一种
+     * Document document =new Document(); // 默认页面大小是A4
+     * Document document =new Document(PageSize.A4); // 指定页面大小为A4
+     * Document document =new Document(PageSize.A4,50,50,30,20); // 指定页面大小为A4,且自定义页边距(marginLeft、marginRight、marginTop、marginBottom)
+     * 其中页面大小PageSize也可自定义大小,例:new Document(new Rectangle(400, 500));
+     *
+     * 2.建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中。
+     * 创建 PdfWriter 对象 第一个参数是对文档对象的引用,第二个参数是文件的实际名称,在该名称中还会给出其输出路径
+     * PdfWriter writer =PdfWriter.getInstance(document,new FileOutputStream(filePath));
+     *
+     * 3.打开文档
+     * 写入数据之前要打开文档
+     * document.open();
+     *
+     * 4.向文档中添加内容
+     * document.add();
+     *
+     * 5.关闭文档
+     * document.close();
+     *
+     *
+     * 二、字体
+     *
+     * 新建一个字体,iText的方法
+     * BaseFont bfChinese;
+     * bfChinese=BaseFont.createFont("STSongStd-Light","UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);//jar包
+     * bfChinese=BaseFont.createFont("C:/Windows/Fonts/msyh.ttf",BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED); //系统字体,其实5.0版以后的iText加入字体还是很方便的。
+     * STSongStd-Light 是字体,在jar 中以property为后缀
+     * UniGB-UCS2-H 是编码,在jar 中以cmap为后缀
+     * H 代表文字版式是横版,相应的 V 代表竖版
+     *
+     * 字体设置
+     * 参数一:新建好的字体;参数二:字体大小,参数三:字体样式,多个样式用“|”分隔
+     * Font topfont = new Font(bfChinese,14,Font.BOLD);
+     * Font textfont =new Font(bfChinese,10,,Font.BOLD|Font.UNDERLINE);
+     *
+     *
+     * 三、添加文本的对象:块、短句和段落
+     *
+     * Chunk:块(Chunk)是能被添加到文档的文本的最小单位。
+     * Phrase:短句(Phrase)是一系列以特定间距(两行之间的距离)作为参数的块。
+     * Paragraph:段落是一系列块和(或)短句。同短句一样,段落有确定的间距。用户还可以指定缩排;在边和(或)右边保留一定空白,段落可以左对齐、右对齐和居中对齐。添加到文档中的每一个段落将自动另起一行。
+     *
+     *
+     * 四、步骤2书写器创建之后,步骤3文档打开之前
+     * 以下项只可在文档关闭状态执行 ,包括水印、页眉、页脚
+     *
+     * 水印
+     * Watermark内部类,需要继承 PdfPageEventHelper类
+     * writer.setPageEvent(new Watermark());
+     *
+     * 页眉/页脚
+     * iText5中并没有之前版本HeaderFooter对象设置页眉和页脚,可以利用PdfPageEvent来完成页眉页脚的设置工作。
+     * PdfPageEvent提供了几个pdf在创建时的事件,页眉页脚就是在每页加载完写入的。
+     * 每一页加个页码还是很简单的,但是总页码就麻烦了,iText是流模式的写入内容,只有写到最后,才能知道有多少页,那么显示总页数就麻烦了,不过麻烦不代表不可能。
+     * 其实iText仅在调用释放模板方法后才将PdfTemplate写入到OutputStream中,否则对象将一直保存在内存中,直到关闭文档。
+     * 所以我们可以在最后关闭文档前,使用PdfTemplate写入总页码。可以理解成先写个占位符,然后统一替换。
+     *
+     *
+     * 五、设置文档属性  (与文档是否打开没有关联)
+     *
+     * document.addTitle("Title@PDF-Java");// 标题
+     * document.addAuthor("Author@umiz");// 作者
+     * document.addSubject("Subject@iText pdf sample");// 主题
+     * document.addKeywords("Keywords@iTextpdf");// 关键字
+     * document.addCreator("Creator@umiz`s");// 创建者
+     *
+     *
+     * 六、文档内容
+     *
+     * 段落Paragraph
+     * Paragraph pt=new Paragraph(name,headfont);//设置字体样式
+     * pt.setAlignment(1);//设置文字居中 0靠左   1,居中     2,靠右
+     * pt.setIndentationLeft(12);// 左缩进
+     * pt.setIndentationRight(12);// 右缩进
+     * pt.setFirstLineIndent(24);// 首行缩进
+     * paragraph.setLeading(20f); //行间距
+     * paragraph.setSpacingBefore(5f); //设置段落上空白
+     * paragraph.setSpacingAfter(10f); //设置段落下空白
+     *
+     * 表格table
+     * Table table =new Table(3);//括号参数表示列
+     * int width[] = {10,45,45};//设置每列宽度比例
+     * table.setWidths(width);
+     * table.setWidth(95);//占页面宽度比例
+     * table.setAlignment(Element.ALIGN_CENTER);//居中
+     * table.setAutoFillEmptyCells(true);//自动填满
+     * table.setBorderWidth((float)0.1);//表格边框线条宽度
+     * table.setPadding(1);//边距:单元格的边线与单元格内容的边距
+     * table.setSpacing(0);//间距:单元格与单元格之间的距离
+     * table.addCell(new Paragraph("name"),textfont));//添加单元格内容
+     * table.endHeaders();//每页都会显示表头
+     *
+     * 单元格内容样式cell
+     * Cell cell=new Cell(new Paragraph("序号",keyfont));
+     * cell.setHorizontalAlignment(Element.ALIGN_CENTER);//水平居中
+     * cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中
+     * table.addCell(cell);
+     *
+     * 表格嵌套
+     *   最外层表格
+     * PdfPTable table =new PdfPTable(3);
+     * table.setTotalWidth(300);
+     * table.setLockedWidth(true);
+     *
+     * PdfPCell cell;
+     * cell =new PdfPCell(new Phrase("Table 5"));
+     * cell.setColspan(3);
+     * cell.setBorderWidth(0);//设置表格的边框宽度为0
+     * table.addCell(cell);
+     *
+     *   嵌套表格
+     * PdfPTable celltable =new PdfPTable(2);
+     * cell =new PdfPCell(celltable);
+     * cell.setRowspan(2);
+     * cell.setBorderWidth(1);//设置表格的边框宽度为1
+     * cell.setPadding(10);//设置表格与上一个表格的填充为10
+     * table.addCell(cell);
+     *
+     * 直线
+     * Paragraph p1 =new Paragraph();
+     * p1.add(new Chunk(new LineSeparator()));
+     * doc.add(p1);
+     *
+     * 点线
+     * Paragraph p2 =new Paragraph();
+     * p2.add(new Chunk(new DottedLineSeparator()));
+     *
+     * 超链接
+     * Anchor anchor =new Anchor("this is anchor");
+     *
+     * 定位
+     * 点击后,跳到topline的位置
+     * Anchor gotop =new Anchor("go top");
+     * gotop.setReference("#us");
+     *
+     * 添加图片
+     * Image image =Image.getInstance(imgPath);
+     * image.setAlignment(Image.ALIGN_CENTER);
+     * image.scalePercent(40);//依照比例缩放
+     */
+
+
+    // main测试
+        public static void main(String[] args) throws Exception {
+
+            try {
+
+                // 1.新建document对象
+                Document document = new Document(PageSize.A4);// 建立一个Document对象
+
+                // 2.建立一个书写器(Writer)与document对象关联
+                String uploadPath = "D:/szsm/uploadPath";
+                File file = new File(uploadPath+File.separator+"PDFDemo.pdf");
+                file.createNewFile();
+
+                PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
+                writer.setPageEvent(new Watermark("我是水印"));// 水印
+//                writer.setPageEvent(new MyHeaderFooter());// 页眉/页脚
+
+                // 3.打开文档
+                document.open();
+                document.addTitle("随  身  邦  收  货  单");// 标题
+                document.addAuthor("");// 作者
+                document.addSubject("");// 主题
+                document.addKeywords("");// 关键字
+                document.addCreator("");// 创建者
+
+
+                // 4.向文档中添加内容
+//                PDFUtil.generateEPDF(document,"XXX公司",null,null);
+
+                // 5.关闭文档
+                document.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        // 定义全局的字体静态变量
+        private static Font titlefont;
+        private static Font headfont;
+        private static Font namefont;
+        private static Font keyfont;
+        private static Font textfont;
+        // 最大宽度
+        private static int maxWidth = 520;
+        // 静态代码块
+        static {
+            try {
+                // 不同字体(这里定义为同一种字体:包含不同字号、不同style)
+                BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+                titlefont = new Font(bfChinese, 16, Font.BOLD);
+                headfont = new Font(bfChinese, 14, Font.BOLD);
+                keyfont = new Font(bfChinese, 10, Font.BOLD);
+                namefont = new Font(bfChinese, 12, Font.BOLD);
+                textfont = new Font(bfChinese, 10, Font.NORMAL);
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+
+
+
+    public  static int generateEPDF(Document document, OrderSelfNote receivingNote, boolean flag) throws Exception {
+        // 段落
+        Paragraph paragraph;
+        if (flag) {
+            paragraph = new Paragraph("客  户  自  提  委  托  书", titlefont);
+        } else {
+            paragraph = new Paragraph("客  户  自  提  委  托  书", titlefont);
+        }
+        paragraph.setAlignment(1); //设置文字居中 0靠左   1,居中     2,靠右
+        paragraph.setIndentationLeft(12); //设置左缩进
+        paragraph.setIndentationRight(12); //设置右缩进
+        paragraph.setFirstLineIndent(24); //设置首行缩进
+        paragraph.setLeading(20f); //行间距
+        paragraph.setSpacingBefore(5f); //设置段落上空白
+        paragraph.setSpacingAfter(10f); //设置段落下空白
+        document.add(paragraph);
+
+        /*Paragraph paragraph2 = new Paragraph("发呢五分范文芳你得请我的飒",textfont);
+        paragraph2.setAlignment(1); //设置文字居中 0靠左   1,居中     2,靠右
+        paragraph2.setIndentationLeft(12); //设置左缩进
+        paragraph2.setIndentationRight(12); //设置右缩进
+        paragraph2.setFirstLineIndent(24); //设置首行缩进
+        paragraph2.setLeading(10f); //行间距
+        paragraph2.setSpacingBefore(5f); //设置段落上空白
+        paragraph2.setSpacingAfter(5f); //设置段落下空白
+        document.add(paragraph2);*/
+        // 直线
+        Paragraph p1 = new Paragraph();
+        p1.add(new Chunk(new LineSeparator()));
+        document.add(p1);
+        PdfPTable table1 = createTable(new float[] { 240, 100});
+        table1.addCell(createCell("委托人(名称): " +receivingNote.getEntrustName(), headfont, Element.ALIGN_LEFT, 1, false));
+        table1.addCell(createCell("受托(提货)人:姓名: " +receivingNote.getBeentrustName(), headfont, Element.ALIGN_LEFT, 2, false));
+        table1.addCell(createCell("身份证号码: " +receivingNote.getbId(), headfont, Element.ALIGN_RIGHT, 2, false));
+        table1.addCell(createCell("车牌: " +receivingNote.getCarNumber(), headfont, Element.ALIGN_RIGHT, 3, false));
+        document.add(table1);
+//        Paragraph paragraph1 = new Paragraph("客户名称: " +receivingNote.getCustomerName() +"                           " +
+//        "                                                     运单号: " +receivingNote.getShipmentNumber(), namefont);
+        Paragraph paragraph1 = new Paragraph();
+     /*   paragraph1.setLeading(20f); //行间距*/
+        paragraph1.setSpacingBefore(2f); //设置段落上空白
+        paragraph1.setSpacingAfter(2f); //设置段落下空白
+        document.add(paragraph1);
+
+        // 点线
+    /*    Paragraph p2 = new Paragraph();
+        p2.add(new Chunk(new DottedLineSeparator()));*/
+        //document.add(p2);
+
+        //添加空行
+        Paragraph p3 = new Paragraph();
+        p3.setSpacingBefore(2f); //设置段落上空白
+        p3.setSpacingAfter(2f); //设置段落下空白
+        // 超链接
+//        Anchor anchor = new Anchor("baidu");
+//        anchor.setReference("www.baidu.com");
+        //document.add(anchor);
+        // 定位
+        Anchor gotoP = new Anchor("goto");
+        gotoP.setReference("#top");
+        //document.add(gotoP);
+        // 添加图片
+//        Image image = Image.getInstance("https://img-blog.csdn.net/20180801174617455?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zNzg0ODcxMA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70");
+//        image.setAlignment(Image.ALIGN_CENTER);
+//        image.scalePercent(40); //依照比例缩放
+        //document.add(image);
+        int size = 0;
+        //时间格式校验
+        String str=receivingNote.getOrderCreationTime();
+        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
+        Date date =sdf.parse(str);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        // 表格
+        PdfPTable table = createTable(new float[] { 160, 60, 60,60});
+        table.addCell(createCell("委托人委托受托人于"+calendar.get(Calendar.YEAR), headfont, Element.ALIGN_LEFT, 4, false));
+        table.addCell(createCell("年"+(calendar.get(Calendar.MONTH)+1), headfont, Element.ALIGN_RIGHT, 4, false));
+        table.addCell(createCell("月"+calendar.get(Calendar.DATE), headfont, Element.ALIGN_RIGHT, 4, false));
+        table.addCell(createCell("日来贵司提取交货单号为"+receivingNote.getDeliveryNumber(), headfont, Element.ALIGN_LEFT, 5, false));
+        table.addCell(createCell("上所载明的货物。", headfont, Element.ALIGN_RIGHT, 5, false));
+        table.addCell(createCell("   特此委托!。", headfont, Element.ALIGN_LEFT, 6, false));
+        document.add(paragraph1);
+        table.addCell(createCell("   委托人:"+receivingNote.getEntrustName(), headfont, Element.ALIGN_LEFT, 7, false));
+        table.addCell(createCell("   受托(提货)人:"+receivingNote.getBeentrustName(), headfont, Element.ALIGN_LEFT, 8, false));
+        table.addCell(createCell(calendar.get(Calendar.YEAR)+"年"+calendar.get(Calendar.MONTH)+"月"+calendar.get(Calendar.DATE)+"日", headfont, Element.ALIGN_CENTER, 9, false));
+        table.addCell(createCell("委托人盖章:", headfont, Element.ALIGN_RIGHT, 10, false));
+        document.add(paragraph1);
+        table.addCell(createCell("委托人盖章:", headfont, Element.ALIGN_RIGHT, 10, false));
+        table.addCell(createCell("注意事项:\n" +
+                "1、受托(提货)人须携带身份证或驾驶证原件。\n" +
+                "2、本委托书必须注明立邦公司交货单号。\n" +
+                "3、本委托书必须盖有与销售合同中预留相一致的印章。\n" +
+                "4、仓库不接受传真的公章印鉴(外埠客户因特殊原因自提时,携带的传真件必须得到当地办事处相关人员确认后方为有效)。\n" +
+                "5、本委托书自委托人确定的提货日期后的十日内有效。", headfont, Element.ALIGN_LEFT, 11, false));
+
+
+        document.add(table);
+
+
+
+
+        /*paragraph = new Paragraph("收货单位及经办人(盖章):", namefont);
+        paragraph.setAlignment(0); //设置文字居中 0靠左   1,居中     2,靠右
+        paragraph.setLeading(20f); //行间距
+        paragraph.setSpacingBefore(20f); //设置段落上空白
+        paragraph.setSpacingAfter(10f); //设置段落下空白
+        document.add(paragraph);*/
+
+        return size;
+    }
+
+        // 生成PDF文件
+        public  static void generatePDF(Document document) throws Exception {
+
+            // 段落
+            Paragraph paragraph = new Paragraph("E    签   宝   租  铺  合  同 ", titlefont);
+            paragraph.setAlignment(1); //设置文字居中 0靠左   1,居中     2,靠右
+            paragraph.setIndentationLeft(12); //设置左缩进
+            paragraph.setIndentationRight(12); //设置右缩进
+            paragraph.setFirstLineIndent(24); //设置首行缩进
+            paragraph.setLeading(20f); //行间距
+            paragraph.setSpacingBefore(5f); //设置段落上空白
+            paragraph.setSpacingAfter(10f); //设置段落下空白
+            document.add(paragraph);
+            // 直线
+            Paragraph p1 = new Paragraph();
+            p1.add(new Chunk(new LineSeparator()));
+            document.add(p1);
+            Paragraph paragraph1 = new Paragraph("业 主: 杭州天谷信息科技有限公司\n" +
+                    "租用者: 赵某某\n" +
+                    "\t甲方将布吉长龙一区二巷五号1楼(西边)地下铺位租给乙方作旧\n" +
+                    "货店使用,经双方协商,订立如下协议:\n" +
+                    "一、 租用期为壹年,即 2012  年 3 月 1  日起至 2013  年2 月 30日止。\n" +
+                    "二、 租金为每月人民币柒佰伍拾元正。按每月1-3号为收租期。\n" +
+                    "三、 付款方法:签订合同后,甲方向乙方收取一个月押金柒佰伍十\n" +
+                    "\t 元正,而押金不能作租金用途。\n" +
+                    "四、 电费、水费、卫生费、治安费等一切杂费皆由乙方负责。\n" +
+                    "五、 乙方如中途退房,应提前一个月通知甲方,否则不退押金,不\n" +
+                    "\t 能私自转租他人及更改用途,否则甲方有权收回此铺位,押金\n" +
+                    "\t 不退。\n" +
+                    "六、 乙方要遵守法律制度及治安管理条例,如有违法乙方自行解决\n" +
+                    "\t 与甲方无关。\n" +
+                    "七、 乙方要自觉爱护甲方财物,如有损坏,则要按价赔偿。\n" +
+                    "八、 乙方如违反合约或有违法行为,甲方有权提前收回此铺位,押\n" +
+                    "\t 金不退。\n" +
+                    "九、 乙方在铺位内装修一切东西甲方全不负责。\n" +
+                    "十、 此合同一式两份,双方各执一份,双方签字后生效。(另外:\n" +
+                    "\t 乙方给甲方身份证复印件一份)\n" +
+                    "\t 甲方签名: 金某某 乙方签名:赵某某\n" +
+                    "\t 日 期:9日1 4 日   身份证号码:430***********18", textfont);
+            paragraph1.setLeading(20f); //行间距
+            paragraph1.setSpacingBefore(5f); //设置段落上空白
+            paragraph1.setSpacingAfter(10f); //设置段落下空白
+            document.add(paragraph1);
+            // 点线
+            Paragraph p2 = new Paragraph();
+            p2.add(new Chunk(new DottedLineSeparator()));
+            //document.add(p2);
+
+            //添加空行
+            Paragraph p3 = new Paragraph();
+            p3.setSpacingBefore(5f); //设置段落上空白
+            p3.setSpacingAfter(5f); //设置段落下空白
+            // 超链接
+            Anchor anchor = new Anchor("baidu");
+            anchor.setReference("www.baidu.com");
+            //document.add(anchor);
+            // 定位
+            Anchor gotoP = new Anchor("goto");
+            gotoP.setReference("#top");
+            //document.add(gotoP);
+            // 添加图片
+            Image image = Image.getInstance("https://img-blog.csdn.net/20180801174617455?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zNzg0ODcxMA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70");
+            image.setAlignment(Image.ALIGN_CENTER);
+            image.scalePercent(40); //依照比例缩放
+            //document.add(image);
+            // 表格
+            PdfPTable table = createTable(new float[] { 80, 80, 80, 80, 80, 80 ,80,80});
+            table.addCell(createCell("采购单信息", headfont, Element.ALIGN_LEFT, 8, false));
+            table.addCell(createCell("采购单号", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("项目名称", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("采购分类", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("申请人", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("申请部门", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("采购员", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("预估总价", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("申请日期", keyfont, Element.ALIGN_CENTER));
+
+
+            table.addCell(createCell("20200813131", textfont));
+            table.addCell(createCell("丁小改测试数据01", textfont));
+            table.addCell(createCell("打印机", textfont));
+            table.addCell(createCell("业务用户1", textfont));
+            table.addCell(createCell("南京工厂", textfont));
+            table.addCell(createCell("cg000005", textfont));
+            table.addCell(createCell("100000", textfont));
+            table.addCell(createCell("2020-08-13", textfont));
+//            document.add(table);
+
+            table = createTable(new float[] { 80, 80, 80, 80, 80, 80 ,80});
+            table.addCell(createCell("明细名称", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("采购数量", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("单位", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("预估单价", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("金额小计", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("规格", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("采购时间", keyfont, Element.ALIGN_CENTER));
+
+            table.addCell(createCell("笔记本", textfont));
+            table.addCell(createCell("5", textfont));
+            table.addCell(createCell("台", textfont));
+            table.addCell(createCell("2490", textfont));
+            table.addCell(createCell("12450", textfont));
+            table.addCell(createCell("适配", textfont));
+            table.addCell(createCell("2020-08-13",textfont));
+
+//            document.add(table);
+            document.add(p1);
+
+            paragraph = new Paragraph("中标供应商信息", titlefont);
+            paragraph.setAlignment(0); //设置文字居中 0靠左   1,居中     2,靠右
+            paragraph.setIndentationLeft(12); //设置左缩进
+            paragraph.setIndentationRight(12); //设置右缩进
+            paragraph.setFirstLineIndent(24); //设置首行缩进
+            paragraph.setLeading(20f); //行间距
+            paragraph.setSpacingBefore(5f); //设置段落上空白
+            paragraph.setSpacingAfter(10f); //设置段落下空白
+//            document.add(paragraph);
+
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("测试供应商", textfont));
+            table.addCell(createCell("张三", textfont));
+            table.addCell(createCell("8337971871", textfont));
+            table.addCell(createCell("langss@dgtis.com", textfont));
+//            document.add(table);
+
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已报价", textfont));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已作废", textfont));
+//            document.add(table);
+//            document.add(p3);
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("测试供应商", textfont));
+            table.addCell(createCell("张三", textfont));
+            table.addCell(createCell("8337971871", textfont));
+            table.addCell(createCell("langss@dgtis.com", textfont));
+//            document.add(table);
+
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已报价", textfont));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已作废", textfont));
+//            document.add(table);
+
+            document.add(p1);//添加实线
+
+            paragraph = new Paragraph("未中标供应商信息", titlefont);
+            paragraph.setAlignment(0); //设置文字居中 0靠左   1,居中     2,靠右
+            paragraph.setIndentationLeft(12); //设置左缩进
+            paragraph.setIndentationRight(12); //设置右缩进
+            paragraph.setFirstLineIndent(24); //设置首行缩进
+            paragraph.setLeading(20f); //行间距
+            paragraph.setSpacingBefore(5f); //设置段落上空白
+            paragraph.setSpacingAfter(10f); //设置段落下空白
+            document.add(paragraph);
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("测试供应商", textfont));
+            table.addCell(createCell("张三", textfont));
+            table.addCell(createCell("8337971871", textfont));
+            table.addCell(createCell("langss@dgtis.com", textfont));
+//            document.add(table);
+
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已报价", textfont));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已作废", textfont));
+//            document.add(table);
+
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("供应商名称", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系人", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("联系方式", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("邮箱", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("测试供应商", textfont));
+            table.addCell(createCell("张三", textfont));
+            table.addCell(createCell("8337971871", textfont));
+            table.addCell(createCell("langss@dgtis.com", textfont));
+//            document.add(table);
+            document.add(p3);
+            table = createTable(new float[] { 80, 80, 80, 80});
+            table.addCell(createCell("报价编号", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("总价", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("报价时间", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("状态", keyfont, Element.ALIGN_CENTER));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已报价", textfont));
+            table.addCell(createCell("P20200812104", textfont));
+            table.addCell(createCell("70000.0", textfont));
+            table.addCell(createCell("2020-08-12", textfont));
+            table.addCell(createCell("已作废", textfont));
+//            document.add(table);
+        }
+
+
+/**------------------------创建表格单元格的方法start----------------------------*/
+        /**
+         * 创建单元格(指定字体)
+         * @param value
+         * @param font
+         * @return
+         */
+        public static PdfPCell createCell(String value, Font font) {
+            PdfPCell cell = new PdfPCell();
+            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
+            cell.setPhrase(new Phrase(value, font));
+            return cell;
+        }
+        /**
+         * 创建单元格(指定字体、水平..)
+         * @param value
+         * @param font
+         * @param align
+         * @return
+         */
+        public static PdfPCell createCell(String value, Font font, int align) {
+            PdfPCell cell = new PdfPCell();
+            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+            cell.setHorizontalAlignment(align);
+            cell.setPhrase(new Phrase(value, font));
+            return cell;
+        }
+        /**
+         * 创建单元格(指定字体、水平居..、单元格跨x列合并)
+         * @param value
+         * @param font
+         * @param align
+         * @param colspan
+         * @return
+         */
+        public static PdfPCell createCell(String value, Font font, int align, int colspan) {
+            PdfPCell cell = new PdfPCell();
+            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+            cell.setHorizontalAlignment(align);
+            cell.setColspan(colspan);
+            cell.setPhrase(new Phrase(value, font));
+            return cell;
+        }
+        /**
+         * 创建单元格(指定字体、水平居..、单元格跨x列合并、设置单元格内边距)
+         * @param value
+         * @param font
+         * @param align
+         * @param colspan
+         * @param boderFlag
+         * @return
+         */
+        public static PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) {
+            PdfPCell cell = new PdfPCell();
+            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+            cell.setHorizontalAlignment(align);
+            cell.setColspan(colspan);
+            cell.setPhrase(new Phrase(value, font));
+            cell.setPadding(3.0f);
+            if (!boderFlag) {
+                cell.setBorder(0);
+                cell.setPaddingTop(15.0f);
+                cell.setPaddingBottom(8.0f);
+            } else if (boderFlag) {
+                cell.setBorder(0);
+                cell.setPaddingTop(0.0f);
+                cell.setPaddingBottom(15.0f);
+            }
+            return cell;
+        }
+        /**
+         * 创建单元格(指定字体、水平..、边框宽度:0表示无边框、内边距)
+         * @param value
+         * @param font
+         * @param align
+         * @param borderWidth
+         * @param paddingSize
+         * @param flag
+         * @return
+         */
+        public PdfPCell createCell(String value, Font font, int align, float[] borderWidth, float[] paddingSize, boolean flag) {
+            PdfPCell cell = new PdfPCell();
+            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+            cell.setHorizontalAlignment(align);
+            cell.setPhrase(new Phrase(value, font));
+            cell.setBorderWidthLeft(borderWidth[0]);
+            cell.setBorderWidthRight(borderWidth[1]);
+            cell.setBorderWidthTop(borderWidth[2]);
+            cell.setBorderWidthBottom(borderWidth[3]);
+            cell.setPaddingTop(paddingSize[0]);
+            cell.setPaddingBottom(paddingSize[1]);
+            if (flag) {
+                cell.setColspan(2);
+            }
+            return cell;
+        }
+/**------------------------创建表格单元格的方法end----------------------------*/
+
+
+/**--------------------------创建表格的方法start------------------- ---------*/
+        /**
+         * 创建默认列宽,指定列数、水平(居中、右、左)的表格
+         * @param colNumber
+         * @param align
+         * @return
+         */
+        public PdfPTable createTable(int colNumber, int align) {
+            PdfPTable table = new PdfPTable(colNumber);
+            try {
+                table.setTotalWidth(maxWidth);
+                table.setLockedWidth(true);
+                table.setHorizontalAlignment(align);
+                table.getDefaultCell().setBorder(1);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return table;
+        }
+        /**
+         * 创建指定列宽、列数的表格
+         * @param widths
+         * @return
+         */
+        public static PdfPTable createTable(float[] widths) {
+            PdfPTable table = new PdfPTable(widths);
+            try {
+                table.setTotalWidth(maxWidth);
+                table.setLockedWidth(true);
+                table.setHorizontalAlignment(Element.ALIGN_CENTER);
+                table.getDefaultCell().setBorder(1);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return table;
+        }
+        /**
+         * 创建空白的表格
+         * @return
+         */
+        public PdfPTable createBlankTable() {
+            PdfPTable table = new PdfPTable(1);
+            table.getDefaultCell().setBorder(0);
+            table.addCell(createCell("", keyfont));
+            table.setSpacingAfter(20.0f);
+            table.setSpacingBefore(20.0f);
+            return table;
+        }
+/**--------------------------创建表格的方法end------------------- ---------*/
+
+
+    /**
+     * 给pdf文件加水印
+     * @param inputFile 源文件路径
+     * @param outputFile 输出文件路径
+     * @param waterMarkName 水印内容
+     * @return
+     */
+    public static boolean waterMark(String inputFile,String outputFile, String waterMarkName) {
+        try {
+            PdfReader reader = new PdfReader(inputFile);
+            PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputFile));
+            //这里的字体设置比较关键,这个设置是支持中文的写法
+            BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);// 使用系统字体
+            int total = reader.getNumberOfPages() + 1;
+
+            PdfContentByte under;
+            Rectangle pageRect = null;
+            for (int i = 1; i < total; i++) {
+                pageRect = stamper.getReader().
+                        getPageSizeWithRotation(i);
+                // 计算水印X,Y坐标
+                float x = 290;//pageRect.getWidth() / 2;
+                float y = 400;//pageRect.getHeight() / 2;
+                // 获得PDF最顶层
+                under = stamper.getOverContent(i);//在内容上方加水印
+                //under = stamper.getUnderContent(i);// 在内容下方加水印
+                under.saveState();
+                // set Transparency
+                PdfGState gs = new PdfGState();
+                // 设置透明度范围为0到1
+                gs.setFillOpacity(0.3f);
+                under.setGState(gs);
+                under.beginText();
+                under.setFontAndSize(base, 35);//字体大小
+                under.setColorFill(BaseColor.BLACK);//字体颜色
+                // 水印文字成45度角倾斜
+                under.showTextAligned(Element.ALIGN_CENTER, waterMarkName, x, y, 45);
+                // 添加水印文字
+                under.endText();
+                under.setLineWidth(1f);
+                under.stroke();
+            }
+            stamper.close();
+            reader.close();
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 方法调试
+     */
+    /*public static void main(String[] args) throws Exception {
+        waterMark("E:/szsm/uploadPath/test.pdf","E:/szsm/uploadPath/testNew.pdf","水印内容");
+    }*/
+
+}

+ 5 - 13
suishenbang-wxportal/suishenbang-wxportal-common/src/main/resources/mapper/wxportal/OrderFileMapper.xml

@@ -28,13 +28,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="beentrustName"    column="beentrust_Name"    />
         <result property="bId"    column="b_Id"    />
         <result property="carNumber"    column="car_Number"    />
-        <result property="year"    column="year"    />
-        <result property="month"    column="month"    />
-        <result property="day"    column="day"    />
+        <result property="run_time"    column="run_time"    />
     </resultMap>
 
     <sql id="selectOrderFileVo">
-        select order_id,delivery_number,shipment_number,ware_house_code,ware_house_name,code,message, flow_id,chains_code,customers_code,signer_id,signer_name, file_url, create_by, create_time, update_by, update_time, is_delete ,entrust_Name,beentrust_Name,b_Id,car_Number from ssb_order_file
+        select order_id,delivery_number,shipment_number,ware_house_code,ware_house_name,code,message, flow_id,chains_code,customers_code,signer_id,signer_name, file_url, create_by, create_time, update_by, update_time, is_delete ,entrust_Name,beentrust_Name,b_Id,car_Number,run_time from ssb_order_file
     </sql>
 
     <select id="selectOrderFileList" parameterType="OrderFile" resultMap="OrderFileResult">
@@ -55,9 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         of.beentrust_Name,
         of.b_Id,
         of.car_Number,
-        of.year,
-        of.month,
-        of.day,
+        of.run_time,
         c.chains_name AS chainsName
         FROM
         ssb_order_file AS of
@@ -114,9 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="beentrustName != null">beentrust_Name,</if>
             <if test="bId != null">b_Id,</if>
             <if test="carNumber != null">car_Number,</if>
-            <if test="year != null">#{year},</if>
-            <if test="month != null">#{month},</if>
-            <if test="day != null">#{day},</if>
+            <if test="run_time != null">#{run_time},</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderId != null">#{orderId},</if>
@@ -141,9 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="beentrustName != null">#{beentrustName},</if>
             <if test="bId != null">#{bId},</if>
             <if test="carNumber != null">#{carNumber},</if>
-            <if test="year != null">#{year},</if>
-            <if test="month != null">#{month},</if>
-            <if test="day != null">#{day},</if>
+            <if test="run_time != null">#{run_time},</if>
          </trim>
     </insert>