Prechádzať zdrojové kódy

根据订单明细计算盖章位置

zhangding 4 rokov pred
rodič
commit
8dcb0c7698

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

@@ -89,16 +89,19 @@ public class EsignController extends ApiBaseController {
             signerAccountId=sysUser.getAccountId();
         }
         /*根据订单id关联查询企业注册后id*/
-        String authorizedAccountId =customersExtService.selectOrgIdByOrderId(orderId);
+//        String authorizedAccountId =customersExtService.selectOrgIdByOrderId(orderId);
+        String authorizedAccountId =signerAccountId;
         /* 根据订单id关联查询企业代号*/
         String chainsCode = customersExtService.selectchainsCodeByOrderId(orderId);
         /*首先根据订单id-orderId查询订单是否已被签署*/
         OrderFile orderFlag = orderFileService.selectOrderFileById(orderId);
         if (orderFlag==null) {
+            Map<String,Object> map = eSignService.upload(orderId);
             /*1、根据传入订单id,查询订单相关信息生成PDF,调用e签宝上传方法返回文件fileId*/
-            String fileId = eSignService.upload(orderId);
+            Object fileId = map.get("fileId");
+            Object size = map.get("size");
             /*2、调用E签宝接口一步发起流程,得到返回的流程id*/
-            String flowId = signService.oneStepFlow(businessScene, fileId, fileName, signerAccountId, authorizedAccountId);
+            String flowId = signService.oneStepFlow(businessScene, fileId.toString(),(int)size, fileName, signerAccountId, authorizedAccountId);
             /*3、调用E签宝获取签署地址*/
             String result = signService.processExecuteUrl(flowId, signerAccountId, authorizedAccountId);
             /*4、保存订单id和flowId*/
@@ -118,8 +121,8 @@ public class EsignController extends ApiBaseController {
 
     @PostMapping("/testPDF")
     @ResponseBody
-    public void aaa(){
-        String fileId = eSignService.upload("0583133446");
+    public Map<String,Object> aaa(){
+       return eSignService.upload("0583133446");
     }
 
 

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

@@ -4,8 +4,12 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.dgtly.system.domain.CustomersExt;
 import com.dgtly.system.domain.SysUser;
+import com.dgtly.wxportal.domain.EMetaHanaSalesOrder;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author ZhangDing
  * @version 1.0
@@ -23,7 +27,7 @@ public interface ESignService {
      * @auther: ZhangDing
      * @date: 2020-10-10 11:31
      */
-     String upload(String orderId);
+     Map<String,Object> upload(String orderId);
 
 
      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, String fileName, String signerAccountId, String authorizedAccountId);
+    public String oneStepFlow(String businessScene, String fileId,int size, String fileName, String signerAccountId, String authorizedAccountId);
 
     /**
      * @description: 开启签署流程

+ 14 - 9
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/service/impl/ESignServiceImpl.java

@@ -22,7 +22,9 @@ import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author ZhangDing
@@ -48,9 +50,14 @@ public class ESignServiceImpl implements ESignService {
     private IEMetaHanaSalesOrderService iMetaHanaSalesOrderService;
 
     @Override
-    public String upload(String orderId) {
+    public Map<String,Object> upload(String orderId) {
         //根据订单id生成pdf文件
-        String filePath = creatPdf(orderId);
+        EMetaHanaSalesOrder order = new EMetaHanaSalesOrder();
+        order.setDocNumber(orderId);
+        List<EMetaHanaSalesOrder> metaHanaSalesOrders = iMetaHanaSalesOrderService.selectDistinctMetaHanaSalesOrder(order);
+        Map<String,Object> map = new HashMap<>();
+        //创建PDF
+        String filePath = creatPdf(metaHanaSalesOrders);
         String md5 = ESignUploadUtil.getStringContentMD5(filePath);
         String contentTtpe = "application/pdf";
         int fileLength = ESignUploadUtil.getFileSize(filePath);
@@ -63,7 +70,9 @@ public class ESignServiceImpl implements ESignService {
         //上传文件
         String res = eSignHttpUtil.upLoadFile(uploadUrl,filePath,md5,contentTtpe,fileLength);
 
-        return fileId;
+        map.put("fileId",fileId);
+        map.put("size",metaHanaSalesOrders.size());
+        return map;
     }
 
     @Override
@@ -166,10 +175,10 @@ public class ESignServiceImpl implements ESignService {
 
     /**
      * 创建收货单pdf文件
-     * @param orderId
+     * @param
      * @return
      */
-    private String creatPdf(String orderId){
+    private String creatPdf(List<EMetaHanaSalesOrder> metaHanaSalesOrders){
 
         String fileUrl = "";
         try {
@@ -193,10 +202,6 @@ public class ESignServiceImpl implements ESignService {
             document.addSubject("");// 主题
             document.addKeywords("");// 关键字
             document.addCreator("");// 创建者
-            EMetaHanaSalesOrder order = new EMetaHanaSalesOrder();
-            order.setDocNumber(orderId);
-            List<EMetaHanaSalesOrder> metaHanaSalesOrders = iMetaHanaSalesOrderService.selectDistinctMetaHanaSalesOrder(order);
-
             // 4.向文档中添加内容
             PDFUtil.generateEPDF(document,metaHanaSalesOrders.get(0).getCustomerName()
             ,metaHanaSalesOrders.get(0).getDocNumber(),

+ 10 - 4
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, String fileName, String signerAccountId,String authorizedAccountId) {
-        JSONObject json = buildParam(businessScene, fileId, fileName, signerAccountId,authorizedAccountId);
+    public String oneStepFlow(String businessScene, String fileId,int size, String fileName, String signerAccountId,String authorizedAccountId) {
+        JSONObject json = buildParam(businessScene, fileId,size, 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, String fileName, String signerAccountId,String authorizedAccountId) {
+    private  JSONObject buildParam(String businessScene, String fileId,int size, String fileName, String signerAccountId,String authorizedAccountId) {
         // 附件信息列表 这里模拟没有附件的情况
         List<Attachment> attachments = new ArrayList<>();
 
@@ -155,7 +155,13 @@ public class EsignSignServiceImpl implements IEsignSignService {
 
         // 签署方信息
         // 平台方
-        PosBeanInfo posBean1 = new PosBeanInfo("1", 100F, 100F); // 签署位置
+        //签署位置
+        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); // 签署区(个人签署)
         List<SignfieldInfo> signfields = new ArrayList<>();

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

@@ -306,7 +306,7 @@ public class PDFUtil {
         paragraph = new Paragraph("收货单位及经办人(盖章):", namefont);
         paragraph.setAlignment(0); //设置文字居中 0靠左   1,居中     2,靠右
         paragraph.setLeading(20f); //行间距
-        paragraph.setSpacingBefore(10f); //设置段落上空白
+        paragraph.setSpacingBefore(20f); //设置段落上空白
         paragraph.setSpacingAfter(10f); //设置段落下空白
         document.add(paragraph);