zhangding 4 vuotta sitten
vanhempi
commit
5dec86260f

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

@@ -13,6 +13,7 @@ import com.dgtly.system.service.ICustomersExtService;
 import com.dgtly.system.service.ISysUserExtService;
 import com.dgtly.system.service.ISysUserService;
 import com.dgtly.wxportal.config.ESignConfig;
+import com.dgtly.wxportal.domain.ESignUpPDFModal;
 import com.dgtly.wxportal.domain.OrderFile;
 import com.dgtly.wxportal.service.*;
 import com.dgtly.wxportal.utils.file.fileDownloadUtil;
@@ -101,12 +102,11 @@ public class EsignController extends ApiBaseController {
         String chainsCode = customersExtService.selectchainsCodeByOrderId(orderId);
         /*首先根据订单id-orderId查询订单是否已被签署*/
 //        OrderFile orderFlag = orderFileService.selectOrderFileById(orderId);
-            Map<String,Object> map = eSignService.upload(deliveryNumber,shipmentNumber,belongTo,sysUser.getSysUserExt().getOrgName());
+             ESignUpPDFModal fileModal = eSignService.upload(deliveryNumber,shipmentNumber,belongTo,sysUser.getSysUserExt().getOrgName());
             /*1、根据传入订单id,查询订单相关信息生成PDF,调用e签宝上传方法返回文件fileId*/
-            Object fileId = map.get("fileId");
-            Object size = map.get("size");
+            Object fileId =fileModal.getFileId();
             /*2、调用E签宝接口一步发起流程,得到返回的流程id*/
-            String flowId = signService.oneStepFlow(businessScene, fileId.toString(),(int)size, fileName, signerAccountId, authorizedAccountId);
+            String flowId = signService.oneStepFlow(businessScene, fileId.toString(),fileModal.getX(),fileModal.getY(), fileName, signerAccountId, authorizedAccountId);
             /*3、调用E签宝获取签署地址*/
             String result = signService.processExecuteUrl(flowId, signerAccountId, authorizedAccountId);
             /*4、保存订单id和flowId*/

+ 58 - 0
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/domain/ESignUpPDFModal.java

@@ -0,0 +1,58 @@
+package com.dgtly.wxportal.domain;
+
+/**
+ * @author ZhangDing
+ * @version 1.0
+ * @descption: TODO
+ * @company 神州数码通用软件(洛阳)有限公司
+ * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
+ * @date 2020-10-22 16:20
+ * @since JDK1.8
+ */
+public class ESignUpPDFModal {
+     private String filePath;
+     private String fileId;
+     private float X;
+     private float Y;
+     private String page;
+
+    public String getFilePath() {
+        return filePath;
+    }
+
+    public void setFilePath(String filePath) {
+        this.filePath = filePath;
+    }
+
+    public String getFileId() {
+        return fileId;
+    }
+
+    public void setFileId(String fileId) {
+        this.fileId = fileId;
+    }
+
+    public float getX() {
+        return X;
+    }
+
+    public void setX(float x) {
+        X = x;
+    }
+
+    public float getY() {
+        return Y;
+    }
+
+    public void setY(float y) {
+        Y = y;
+    }
+
+    public String getPage() {
+        return page;
+    }
+
+    public void setPage(String page) {
+        this.page = page;
+    }
+}

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

@@ -2,6 +2,7 @@ package com.dgtly.wxportal.service;
 
 import com.dgtly.system.domain.CustomersExt;
 import com.dgtly.system.domain.SysUser;
+import com.dgtly.wxportal.domain.ESignUpPDFModal;
 
 import java.util.Map;
 
@@ -24,7 +25,7 @@ public interface ESignService {
    * @param customerName 经销商名和曾
    * @return
    */
-  Map<String,Object> upload(String deliveryNumber,String shipmentNumber,String belongTo,String customerName);
+  ESignUpPDFModal upload(String deliveryNumber, String shipmentNumber, String belongTo, String customerName);
 
 
      String verificationUser();

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

@@ -13,7 +13,7 @@ public interface IEsignSignService {
      * @author: qxm
      * @date: 2020/10/12 16:05
      */
-    public String oneStepFlow(String businessScene, String fileId,int size, String fileName, String signerAccountId, String authorizedAccountId);
+    public String oneStepFlow(String businessScene, String fileId,float posX,float posY, String fileName, String signerAccountId, String authorizedAccountId);
 
     /**
      * @description: 开启签署流程

+ 24 - 16
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/service/impl/ESignServiceImpl.java

@@ -5,6 +5,7 @@ import com.dgtly.system.domain.CustomersExt;
 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.service.IEReceivingNoteService;
 import com.dgtly.system.service.ISysUserService;
 import com.dgtly.wxportal.config.ESignConfig;
@@ -51,27 +52,25 @@ public class ESignServiceImpl implements ESignService {
     private IEReceivingNoteService iMetaHanaSalesOrderService;
 
     @Override
-    public Map<String,Object> upload(String deliveryNumber,String shipmentNumber,String belongTo,String customerName) {
+    public ESignUpPDFModal upload(String deliveryNumber,String shipmentNumber,String belongTo,String customerName) {
 
         EReceivingNote receivingNote = iMetaHanaSalesOrderService.selectEReceivingNote(deliveryNumber,shipmentNumber,belongTo,customerName);
         Map<String,Object> map = new HashMap<>();
         //创建PDF
-        String filePath = creatPdf(receivingNote);
-        String md5 = ESignUploadUtil.getStringContentMD5(filePath);
+        ESignUpPDFModal fileModal = creatPdf(receivingNote);
+        String md5 = ESignUploadUtil.getStringContentMD5(fileModal.getFilePath());
         String contentTtpe = "application/pdf";
-        int fileLength = ESignUploadUtil.getFileSize(filePath);
+        int fileLength = ESignUploadUtil.getFileSize(fileModal.getFilePath());
         //根据文件获取上传路径
-        JSONObject urlData =  getUpUrl(filePath,md5,contentTtpe,fileLength).getJSONObject("data");
+        JSONObject urlData =  getUpUrl(fileModal.getFilePath(),md5,contentTtpe,fileLength).getJSONObject("data");
         //文件id
         String fileId = urlData.getString("fileId");
         //文件上传路径
         String uploadUrl = urlData.getString("uploadUrl");
         //上传文件
-        String res = eSignHttpUtil.upLoadFile(uploadUrl,filePath,md5,contentTtpe,fileLength);
-
-        map.put("fileId",fileId);
-        map.put("size",10);
-        return map;
+        String res = eSignHttpUtil.upLoadFile(uploadUrl,fileModal.getFilePath(),md5,contentTtpe,fileLength);
+        fileModal.setFileId(fileId);
+        return fileModal;
     }
 
     @Override
@@ -177,9 +176,10 @@ public class ESignServiceImpl implements ESignService {
      * @param
      * @return
      */
-    private String creatPdf(EReceivingNote receivingNote){
-
+    private ESignUpPDFModal creatPdf(EReceivingNote receivingNote){
+        ESignUpPDFModal res = new ESignUpPDFModal();
         String fileUrl = "";
+        int size = 0;
         try {
             // 1.新建document对象
             Document document = new Document(PageSize.A4);// 建立一个Document对象
@@ -202,17 +202,25 @@ public class ESignServiceImpl implements ESignService {
             document.addSubject("");// 主题
             document.addKeywords("");// 关键字
             document.addCreator("");// 创建者
+
             // 4.向文档中添加内容
-            PDFUtil.generateEPDF(document,receivingNote
-                    );
+            size = PDFUtil.generateEPDF(document,receivingNote);
 
             // 5.关闭文档
             document.close();
         } catch (Exception e) {
             e.printStackTrace();
         }
-
-        return fileUrl;
+        //计算宽高
+        Float fosX = 240F;
+        Float fosY = 620F;
+        for (int i =0;i<size;i++){
+           fosY = fosY-11f;
+        }
+        res.setX(fosX);
+        res.setY(fosY);
+        res.setFilePath(fileUrl);
+        return res;
     }
     /**
      * 获取文件上传路径

+ 3 - 9
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/service/impl/EsignSignServiceImpl.java

@@ -37,8 +37,8 @@ public class EsignSignServiceImpl implements IEsignSignService {
      * @date: 2020/10/13 9:15
      */
     @Override
-    public String oneStepFlow(String businessScene, String fileId,int size, String fileName, String signerAccountId,String authorizedAccountId) {
-        JSONObject json = buildParam(businessScene, fileId,size, fileName, signerAccountId,authorizedAccountId);
+    public String oneStepFlow(String businessScene, String fileId,float posX,float posY, String fileName, String signerAccountId,String authorizedAccountId) {
+        JSONObject json = buildParam(businessScene, fileId,posX,posY, fileName, signerAccountId,authorizedAccountId);
         JSONObject jsonObject = eSignHttpUtil.doPostGetJson(ESignUrl.CreateFlowOneStepUrl,json);
         JSONObject result = (JSONObject)jsonObject.get("data");
         return result.get("flowId").toString();
@@ -133,7 +133,7 @@ public class EsignSignServiceImpl implements IEsignSignService {
      *              <p>
      *
      */
-    private  JSONObject buildParam(String businessScene, String fileId,int size, String fileName, String signerAccountId,String authorizedAccountId) {
+    private  JSONObject buildParam(String businessScene, String fileId,float posX,float posY, String fileName, String signerAccountId,String authorizedAccountId) {
         // 附件信息列表 这里模拟没有附件的情况
         List<Attachment> attachments = new ArrayList<>();
 
@@ -155,12 +155,6 @@ public class EsignSignServiceImpl implements IEsignSignService {
 
         // 签署方信息
         // 平台方
-        //签署位置
-        Float posX = 240F;
-        Float posY = 620F;
-        for (int i = 0;i<size;i++) {
-            posY =posY-11F;
-        }
         PosBeanInfo posBean1 = new PosBeanInfo("1", posX, posY); // 签署位置
         SignfieldInfo signfield1 = new SignfieldInfo(false,"2", fileId, null, null, null, posBean1, null); // 签署区(签署主体是公司)
 //        SignfieldInfo signfield1 = new SignfieldInfo(false, fileId, null, null, null, posBean1, null); // 签署区(个人签署)

+ 19 - 14
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/utils/pdf/PDFUtil.java

@@ -228,7 +228,7 @@ public class PDFUtil {
 
 
 
-    public  static void generateEPDF(Document document,EReceivingNote receivingNote) throws Exception {
+    public  static int generateEPDF(Document document,EReceivingNote receivingNote) throws Exception {
         // 段落
         Paragraph paragraph = new Paragraph("立    邦   随   身  邦  收  货  单", titlefont);
         paragraph.setAlignment(1); //设置文字居中 0靠左   1,居中     2,靠右
@@ -286,6 +286,7 @@ public class PDFUtil {
         image.setAlignment(Image.ALIGN_CENTER);
         image.scalePercent(40); //依照比例缩放
         //document.add(image);
+        int size = 0;
         // 表格
         PdfPTable table = createTable(new float[] { 100, 80, 80,80});
         table.addCell(createCell("物品明细", headfont, Element.ALIGN_CENTER, 8, false));
@@ -296,21 +297,25 @@ public class PDFUtil {
 //        table.addCell(createCell("未交货数量", keyfont, Element.ALIGN_CENTER));
 //        table.addCell(createCell("发货数量", keyfont, Element.ALIGN_CENTER));
 //        table.addCell(createCell("已收货数量", keyfont, Element.ALIGN_CENTER));
-        for (ConfirmCollectLineDetailModel line:receivingNote.getDeliveryLineDetail()) {
-            table.addCell(createCell(line.getMaterialName(), textfont));
-            table.addCell(createCell(line.getSizeDim(), textfont));
-            table.addCell(createCell(line.getConfirmQuantity().toString(), textfont));
-            table.addCell(createCell(line.getDeliveryCount().toString(), textfont));
-        }
-        for(ConfirmCollectOtherDeliveryModel otherLine:receivingNote.getOtherDeliveryModels()){
-            table.addCell(createCell("同运单交货单:"+otherLine.getDeliveryNumber()+"   重量:"+otherLine.getWeight(), keyfont, Element.ALIGN_CENTER,4));
-            for (ConfirmCollectLineDetailModel line:otherLine.getDeliveryLineDetail()) {
+
+            for (ConfirmCollectLineDetailModel line : receivingNote.getDeliveryLineDetail()) {
                 table.addCell(createCell(line.getMaterialName(), textfont));
                 table.addCell(createCell(line.getSizeDim(), textfont));
-                table.addCell(createCell(line.getConfirmQuantity().toString(), textfont));
-                table.addCell(createCell(line.getDeliveryCount().toString(), textfont));
+                table.addCell(createCell(line.getConfirmQuantity(), textfont));
+                table.addCell(createCell(line.getDeliveryCount(), textfont));
+                size += line.getMaterialName().length() / 12 + 1;
+
+            }
+            for (ConfirmCollectOtherDeliveryModel otherLine : receivingNote.getOtherDeliveryModels()) {
+                table.addCell(createCell("同运单交货单:" + otherLine.getDeliveryNumber() + "   重量:" + otherLine.getWeight(), keyfont, Element.ALIGN_CENTER, 4));
+                for (ConfirmCollectLineDetailModel line : otherLine.getDeliveryLineDetail()) {
+                    table.addCell(createCell(line.getMaterialName(), textfont));
+                    table.addCell(createCell(line.getSizeDim(), textfont));
+                    table.addCell(createCell(line.getConfirmQuantity(), textfont));
+                    table.addCell(createCell(line.getDeliveryCount(), textfont));
+                    size += line.getMaterialName().length() / 12 + 1;
+                }
             }
-        }
 
         document.add(table);
 
@@ -324,7 +329,7 @@ public class PDFUtil {
         paragraph.setSpacingAfter(10f); //设置段落下空白
         document.add(paragraph);
 
-
+        return size;
     }
 
         // 生成PDF文件