9060 2 ماه پیش
والد
کامیت
7243a7fcce

+ 12 - 0
metadata/com/kingdee/eas/custom/esign/bizEnum/EsignConfigEnum.enum

@@ -176,6 +176,12 @@
             <userDefined>true</userDefined>
             <value>sign_templates_detail</value>
         </enumValue>
+        <enumValue>
+            <name>draft_detail</name>
+            <alias>bizEnum[com.kingdee.eas.custom.esign.bizEnum.EsignConfigEnum].enumValues.enumValue[draft_detail].alias</alias>
+            <userDefined>true</userDefined>
+            <value>draft_detail</value>
+        </enumValue>
     </enumValues>
     <resource>
         <rs key="bizEnum[com.kingdee.eas.custom.esign.bizEnum.EsignConfigEnum].alias">
@@ -262,6 +268,12 @@
             <lang locale="zh_HK" value="查詢合同範本中控件詳情" />
             <lang locale="zh_TW" value="查詢合同範本中控件詳情" />
         </rs>
+        <rs key="bizEnum[com.kingdee.eas.custom.esign.bizEnum.EsignConfigEnum].enumValues.enumValue[draft_detail].alias">
+            <lang locale="en_US" value="null" />
+            <lang locale="zh_CN" value="查询合同拟定详情" />
+            <lang locale="zh_HK" value="查詢合同擬定詳情" />
+            <lang locale="zh_TW" value="查詢合同擬定詳情" />
+        </rs>
         <rs key="bizEnum[com.kingdee.eas.custom.esign.bizEnum.EsignConfigEnum].enumValues.enumValue[file_download_url].alias">
             <lang locale="en_US" value="null" />
             <lang locale="zh_CN" value="下载已签署文件及附属材料" />

+ 171 - 1
src/com/kingdee/eas/custom/esign/util/EsignHttpUtil.java

@@ -1,6 +1,7 @@
 package com.kingdee.eas.custom.esign.util;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Maps;
 import com.kingdee.bos.BOSException;
@@ -171,6 +172,123 @@ public class EsignHttpUtil {
         String apiaddr = EsignConfig.getInstance().get(configEnum.getValue());
         return POST(ctx, apiaddr, json, sourceId, configEnum);
     }
+    public static EsignHttpResponse createBySignTemplate(Context ctx, String personId, String fileName, String operatorId, String efileId,
+                                                   String json) throws BOSException {
+        EsignHttpResponse resp = createBySignTemplate(ctx, personId, fileName, operatorId, efileId, EsignStatusEnum.SIGNING, json);
+        return resp;
+    }
+    /**
+     * 通过流程模板创建合同拟定和签署流程
+     * 参考文档:https://open.esign.cn/doc/opendoc/file-and-template3/megwsgkmpbg1tec1
+     * 接口地址:https://{host}/v3/sign-flow/create-by-sign-template
+     * 请求方法:POST
+     * 注意事项:componentId与componentKey两个字段不能同时传值,只能一个有值
+     *
+     * @param ctx        上下文
+     * @param personId   签署员工id
+     * @param fileName   签署文件名称
+     * @param operatorId 操作人
+     * @param efileId    发起单据id
+     * @param json       签署信息
+     * @return
+     * @throws EsignException
+     */
+    public static EsignHttpResponse createBySignTemplate(Context ctx, String personId, String fileName, String operatorId, String efileId,
+                                                   EsignStatusEnum esignStatus,
+                                                   String json) throws BOSException {
+        EsignConfigEnum configEnum = EsignConfigEnum.createBySignTemplate;
+        String apiaddr = EsignConfig.getInstance().get(configEnum.getValue());
+        EsignHttpResponse resp = new EsignHttpResponse();
+        resp.setStatus(500);
+
+        /**
+         * 发起签署前需要新增电子签全域状态总览表
+         */
+        IESignGlobalStatusOverview globalStatusOverview = ESignGlobalStatusOverviewFactory.getLocalInstance(ctx);
+        ESignGlobalStatusOverviewInfo info = new ESignGlobalStatusOverviewInfo();
+//        try {
+//            String str = "select fid from CT_ESI_ESGSO where cfefileId=?";
+//            IRowSet rs = DbUtil.executeQuery(ctx, str, new Object[]{efileId});
+//            if (rs.next()) {
+//                String fid = rs.getString("fid");
+//                info = globalStatusOverview.getESignGlobalStatusOverviewInfo(new ObjectUuidPK(fid));
+//            }
+//        } catch (SQLException | EASBizException e) {
+//            e.printStackTrace();
+//        }
+
+        info.setEsignStatus(EsignStatusEnum.DRAFT);
+        info.setSendStatus(SendStatusEnum.FAILURE);
+        if (StringUtils.isNotBlank(personId)) {
+            PersonInfo personInfo = new PersonInfo();
+            personInfo.setId(BOSUuid.read(personId));
+            info.setPerson(personInfo);
+        }
+        if (StringUtils.isNotBlank(operatorId)) {
+            PersonInfo operator = new PersonInfo();
+            operator.setId(BOSUuid.read(operatorId));
+            info.setOperator(operator);
+        }
+        info.setFileName(fileName);
+
+        info.setEfileId(efileId);
+
+        info.setRequestParams(json);
+        StringBuilder cum = new StringBuilder();
+        JSONObject jsonObject = JSON.parseObject(json);
+        if(null!=jsonObject) {
+            JSONArray participants = jsonObject.getJSONArray("participants");
+            if (null!=participants){
+                for(int i=0;i<participants.size();i++ ){
+                    JSONObject participant = participants.getJSONObject(i);
+                    String participantFlag = participant.getString("participantFlag");
+                    JSONObject orgParticipant = participant.getJSONObject("orgParticipant");
+                    if(null!=orgParticipant) {
+                        String orgName = orgParticipant.getString("orgName");
+                        JSONObject transactor=orgParticipant.getJSONObject("transactor");
+                        if(null!=transactor) {
+                            String psnAccount = transactor.getString("transactorPsnAccount");
+                            String transactorName = transactor.getString("transactorName");
+                            cum.append(participantFlag + ":" + transactorName + "(" + psnAccount + ");");
+                        }
+                    }
+                    JSONObject psnParticipant = participant.getJSONObject("psnParticipant");
+                    if(null!=psnParticipant) {
+                        String psnName = psnParticipant.getString("psnName");
+                        String psnAccount = psnParticipant.getString("psnAccount");
+                        cum.append(participantFlag+":"+psnName+"("+psnAccount+");");
+                    }
+                }
+                cum.delete(cum.length()-1,cum.length());
+                info.setDescription(cum.toString());
+            }
+        }
+
+        info.setEsignName(configEnum);
+        try {
+            resp = POST(ctx, apiaddr, json, efileId, configEnum);
+            if (resp.getStatus() >= 200 && resp.getStatus() < 300) {
+                JSONObject object = JSON.parseObject(resp.getBody());
+                if ("0".equals(String.valueOf(object.get("code")))) {
+                    JSONObject data = object.getJSONObject("data");
+                    info.setSignFlowId(data.getString("signFlowId"));
+                    info.setSendStatus(SendStatusEnum.SUCCESS);
+                    info.setEsignStatus(esignStatus);
+                }
+            }
+            info.setSourceBillId(resp.getLogId());
+        } catch (Exception e) {
+            e.printStackTrace();
+            info.setSendStatus(SendStatusEnum.FAILURE);
+        } finally {
+            try {
+                globalStatusOverview.save(info);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return resp;
+    }
 
 
     /**
@@ -484,8 +602,35 @@ public class EsignHttpUtil {
             info.setOperator(operator);
         }
         info.setFileName(fileName);
-
+        StringBuilder cum = new StringBuilder();
         info.setEfileId(efileId);
+        JSONObject jsonObject = JSON.parseObject(json);
+        if(null!=jsonObject) {
+            JSONArray participants = jsonObject.getJSONArray("participants");
+            if (null!=participants){
+                for(int i=0;i<participants.size();i++ ){
+                    JSONObject participant = participants.getJSONObject(i);
+                    String participantFlag = participant.getString("participantFlag");
+                    JSONObject orgParticipant = participant.getJSONObject("orgParticipant");
+                    if(null!=orgParticipant) {
+                        String orgName = orgParticipant.getString("orgName");
+                        JSONObject transactor=orgParticipant.getJSONObject("transactor");
+                        if(null!=transactor) {
+                            String psnAccount = orgParticipant.getString("transactorPsnAccount");
+                            String transactorName = orgParticipant.getString("transactorName");
+                            cum.append(participantFlag + ":" + transactorName + "(" + psnAccount + ");");
+                        }
+                    }
+                    JSONObject psnParticipant = participant.getJSONObject("psnParticipant");
+                    if(null!=psnParticipant) {
+                        String psnName = psnParticipant.getString("psnName");
+                        String psnAccount = psnParticipant.getString("psnAccount");
+                        cum.append(participantFlag+":"+psnName+"("+psnAccount+");");
+                    }
+                }
+                info.setDescription(cum.toString());
+            }
+        }
 
         info.setRequestParams(json);
         info.setEsignName(configEnum);
@@ -768,4 +913,29 @@ public class EsignHttpUtil {
         //发起接口请求
         return POST(ctx, apiaddr, json, sourceId, configEnum);
     }
+    /**
+     * 查询流程模板详情
+     * 参考文档:https://open.esign.cn/doc/opendoc/pdf-sign3/kq4b2e
+     * 接口地址:https://{host}/v3/sign-templates/detail
+     * @param ctx
+     * @param signTemplateId
+     * @param orgId
+     * @param queryComponents
+     * @param sourceId
+     * 请求方法:GET
+     */
+    public static EsignHttpResponse getSign_templates_detail(Context ctx, String signTemplateId,String orgId,Boolean queryComponents, String sourceId) throws EsignException, URISyntaxException {
+        EsignConfigEnum configEnum = EsignConfigEnum.sign_templates_detail;
+        String apiaddr = EsignConfig.getInstance().get(configEnum.getValue());
+        URIBuilder uriBuilder = new URIBuilder(apiaddr);
+        uriBuilder.addParameter("signTemplateId", signTemplateId);
+        uriBuilder.addParameter("orgId", orgId);
+        if(null!=queryComponents) {
+            uriBuilder.addParameter("queryComponents", queryComponents.toString());
+        }
+        URI uri = uriBuilder.build(); // 自动编码
+        apiaddr = uri.toString();
+        //发起接口请求
+        return GET(ctx, apiaddr, null, sourceId, configEnum);
+    }
 }

+ 48 - 33
websrc/com/kingdee/eas/custom/esign/handler/ESignGlobalStatusOverviewListHandler.java

@@ -42,6 +42,7 @@ import org.springframework.ui.ModelMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.Map;
@@ -371,40 +372,16 @@ public class ESignGlobalStatusOverviewListHandler extends ListHandler {
             if (canLive) {
                 EsignHttpResponse response1 = null;
                 if (EsignStatusEnum.COMPLETED.equals(info.getEsignStatus())) {
-                    response1 = EsignHttpUtil.getFile_download_url(this.getCtx(), info.getSignFlowId(), 3600, info.getEfileId());
-                    JSONObject jsonObject = JSON.parseObject(response1.getBody());
-                    Integer code = (Integer) jsonObject.get("code");
-                    if (code == 0) {
-                        JSONObject jsonData = jsonObject.getJSONObject("data");
-                        JSONArray files = jsonData.getJSONArray("files");
-                        if(null!=files) {
-                            for (int i = 0; i < files.size(); i++) {
-                                JSONObject fileMap = files.getJSONObject(i);
-                                this.saveAttachment(this.getCtx(), info, fileMap, "com.kingdee.eas.custom.esign.app.ESignGlobalStatusOverview.list", "files");
-                            }
-                        }
-                        JSONArray attachments = jsonData.getJSONArray("attachments");
-                        if(null!=attachments) {
-                            for (int i = 0; i < attachments.size(); i++) {
-                                JSONObject fileMap = attachments.getJSONObject(i);
-                                this.saveAttachment(this.getCtx(), info, fileMap, "com.kingdee.eas.custom.esign.app.ESignGlobalStatusOverview.list", "attachments");
-                            }
-                        }
-                    }
+                    this.saveDocsFile(info);
                 } else {
-                    String json = info.getRequestParams();
-                    JSONObject params = JSON.parseObject(json);
-                    JSONArray docs = params.getJSONArray("docs");
-                    for (int i = 0; i < docs.size(); i++) {
-                        JSONObject doc = docs.getJSONObject(i);
-                        String fileId = doc.getString("fileId");
-                        response1 = EsignHttpUtil.getPreview_file_download_url(this.getCtx(), info.getSignFlowId(),fileId, info.getEfileId());
-                        JSONObject jsonObject = JSON.parseObject(response1.getBody());
-                        Integer code = (Integer) jsonObject.get("code");
-                        if (code == 0) {
-                            JSONObject fileMap = jsonObject.getJSONObject("data");
-                            this.saveAttachment(this.getCtx(), info, fileMap, "com.kingdee.eas.custom.esign.app.ESignGlobalStatusOverview.list", "files");
-                        }
+                    EsignHttpResponse responsesf = EsignHttpUtil.getSign_fields(this.getCtx(), info.getSignFlowId(), info.getEfileId());
+                    JSONObject params = JSON.parseObject(responsesf.getBody());
+                    if ( 0 == params.getInteger("code")) {
+                        JSONObject data = params.getJSONObject("data");
+                        JSONArray docs = data.getJSONArray("docs");
+                        this.saveDocsPreviewFile(info, docs);
+                        JSONArray attachments = data.getJSONArray("attachments");
+                        this.saveDocsPreviewFile(info, attachments);
                     }
                 }
             }
@@ -427,6 +404,44 @@ public class ESignGlobalStatusOverviewListHandler extends ListHandler {
         this.writeSuccessData(batchMessageTipsHeader);
         return null;
     }
+    public void saveDocsFile(ESignGlobalStatusOverviewInfo info) throws EsignException, URISyntaxException, IOException, ShrWebBizException, BOSException, EASBizException {
+        EsignHttpResponse response1;
+        response1 = EsignHttpUtil.getFile_download_url(this.getCtx(), info.getSignFlowId(), 3600, info.getEfileId());
+        JSONObject jsonObject = JSON.parseObject(response1.getBody());
+        Integer code = (Integer) jsonObject.get("code");
+        if (code == 0) {
+            JSONObject jsonData = jsonObject.getJSONObject("data");
+            JSONArray files = jsonData.getJSONArray("files");
+            if(null!=files) {
+                for (int i = 0; i < files.size(); i++) {
+                    JSONObject fileMap = files.getJSONObject(i);
+                    this.saveAttachment(this.getCtx(), info, fileMap, "com.kingdee.eas.custom.esign.app.ESignGlobalStatusOverview.list", "files");
+                }
+            }
+            JSONArray attachments = jsonData.getJSONArray("attachments");
+            if(null!=attachments) {
+                for (int i = 0; i < attachments.size(); i++) {
+                    JSONObject fileMap = attachments.getJSONObject(i);
+                    this.saveAttachment(this.getCtx(), info, fileMap, "com.kingdee.eas.custom.esign.app.ESignGlobalStatusOverview.list", "attachments");
+                }
+            }
+        }
+    }
+    public void saveDocsPreviewFile(ESignGlobalStatusOverviewInfo info, JSONArray docs) throws EsignException, URISyntaxException, IOException, ShrWebBizException, BOSException, EASBizException {
+        EsignHttpResponse response1;
+        for (int i = 0; i < docs.size(); i++) {
+            JSONObject doc = docs.getJSONObject(i);
+            String fileId = doc.getString("fileId");
+            response1 = EsignHttpUtil.getPreview_file_download_url(this.getCtx(), info.getSignFlowId(), fileId, info.getEfileId());
+            JSONObject jsonObject = JSON.parseObject(response1.getBody());
+            Integer code = (Integer) jsonObject.get("code");
+            if (code == 0) {
+                JSONObject fileMap = jsonObject.getJSONObject("data");
+                this.saveAttachment(this.getCtx(), info, fileMap, "com.kingdee.eas.custom.esign.app.ESignGlobalStatusOverview.list", "files");
+            }
+        }
+    }
+
     /**
      *  ͬ²½Ç©Êð״̬ÐÅÏ¢
      * @param request

+ 362 - 101
websrc/com/kingdee/eas/custom/esign/osf/Create_by_fileOSFService.java

@@ -15,6 +15,7 @@ import com.kingdee.bos.metadata.entity.SelectorItemInfo;
 import com.kingdee.eas.common.EASBizException;
 import com.kingdee.eas.custom.esign.*;
 import com.kingdee.eas.custom.esign.bizEnum.ComponentTypeEnum;
+import com.kingdee.eas.custom.esign.bizEnum.EsignConfigEnum;
 import com.kingdee.eas.custom.esign.bizEnum.EsignStatusEnum;
 import com.kingdee.eas.custom.esign.tsign.hz.comm.EsignHttpResponse;
 import com.kingdee.eas.custom.esign.tsign.hz.exception.EsignException;
@@ -70,10 +71,23 @@ public class Create_by_fileOSFService implements IHRMsfService {
                 String operatorId = jsonObject.getString("operatorId");
                 //文件
                 JSONObject templateInfo = jsonObject.getJSONObject("templateInfo");
-                //设置待签署文件信息
-                List<Map<String, Object>> docs = null;
-
-                    docs = this.addDocs(context, jsonObject, templateInfo);
+                //签署方信息
+                JSONObject signInfo = jsonObject.getJSONObject("signInfo");
+                JSONArray signs = signInfo.getJSONArray("signers");
+                Boolean isRadio = false;
+                for (int i = 0; i < signs.size(); i++) {
+                    Map<String, Object> signMapInfo = Maps.newHashMap();
+                    JSONObject sign = signs.getJSONObject(i);
+                    Map<String, Object> orgPsnSignMap = Maps.newHashMap();
+                    JSONObject orgSignerInfo = sign.getJSONObject("orgSignerInfo");
+                    JSONObject psnSignerInfo = sign.getJSONObject("psnSignerInfo");
+                    //企业/机构签署方信息
+                    if (null != orgSignerInfo) {
+                        //isRadio = orgSignerInfo.getBoolean("isRadio");
+                    }
+                }
+                if (isRadio) {
+                    List<Map<String, Object>> docs = this.addDocs(context, jsonObject, templateInfo);
                     List<Map<String, Object>> signDocs = Lists.newArrayList();
                     for (Map<String, Object> doc : docs) {
                         Map<String, Object> docNew = new HashMap<>(doc);
@@ -81,25 +95,19 @@ public class Create_by_fileOSFService implements IHRMsfService {
                         signDocs.add(docNew);
                     }
                     signMap.put("docs", signDocs);
-
-                if (null != docs) {
-                    //签署流程配置项
-                    Map<String, Object> signFlowConfig = this.addSignFlowConfig(context, signFlowTitle, jsonObject);
-                    signMap.put("signFlowConfig", signFlowConfig);
-                    //签署方信息
-                    JSONObject signInfo = jsonObject.getJSONObject("signInfo");
-                    JSONArray signs = signInfo.getJSONArray("signers");
-                    List<Map<String, Object>> signers = this.addSigners(context, signs, docs, sourceId);
-                    signMap.put("signers", signers);
-                    //抄送方信息
-                    JSONArray copis = signInfo.getJSONArray("copiers");
-                    List<Map<String, Object>> copiers = this.addCopiers(context, copis);
-                    if (copiers.size() > 0) {
-                        signMap.put("copiers", copiers);
-                    }
-                    //必须要存在签署文件才能签署
-
-                    if (docs.size() > 0) {
+                    if (null != docs && docs.size() > 0) {
+                        //签署流程配置项
+                        Map<String, Object> signFlowConfig = this.addSignFlowConfig(context, signFlowTitle, jsonObject);
+                        signMap.put("signFlowConfig", signFlowConfig);
+                        //签署方信息
+                        List<Map<String, Object>> signers = this.addSigners(context, signs, docs, sourceId);
+                        signMap.put("signers", signers);
+                        //抄送方信息
+                        JSONArray copis = signInfo.getJSONArray("copiers");
+                        List<Map<String, Object>> copiers = this.addCopiers(context, copis);
+                        if (copiers.size() > 0) {
+                            signMap.put("copiers", copiers);
+                        }
                         System.out.println("--------------------------------------------------------------------------------------");
                         System.out.println("signMap:" + JSON.toJSONString(signMap));
                         System.out.println("--------------------------------------------------------------------------------------");
@@ -108,11 +116,81 @@ public class Create_by_fileOSFService implements IHRMsfService {
                             JSONObject body = JSON.parseObject(response.getBody());
                             resul.putAll(body);
                         } else {
-                            resul.put("code", response.getStatus());
-                            resul.put("message", "网络异常");
+                            resul.put("code", 403);
+                            resul.put("message", "参数异常,没有模版id");
                             resul.put("data", null);
                         }
                     }
+                } else {
+                    //处理文件字段
+                    Map<String, List<Map<String, Object>>> pDocs = this.addPreviewDocs(context, jsonObject, templateInfo);
+
+                    List<Map<String, Object>> components = pDocs.get("components");
+                    //设置待签署文件信息
+                    List<Map<String, Object>> docs = pDocs.get("docs");
+
+                    List<Map<String, Object>> signDocs = Lists.newArrayList();
+                    for (Map<String, Object> doc : docs) {
+                        Map<String, Object> docNew = new HashMap<>(doc);
+                        docNew.remove("signListGroup");
+                        signDocs.add(docNew);
+                    }
+                    signMap.put("docs", signDocs);
+                    String eSignTemplateNum = jsonObject.getString("eSignTemplateNum");
+                    if (null != docs) {
+                        //签署流程配置项
+                        Map<String, Object> signFlowConfig = this.addSignFlowConfig(context, signFlowTitle, jsonObject);
+                        signMap.put("signFlowConfig", signFlowConfig);
+//                    //签署方信息
+//                    JSONObject signInfo = jsonObject.getJSONObject("signInfo");
+//                    JSONArray signs = signInfo.getJSONArray("signers");
+//                    List<Map<String, Object>> signers = this.addSigners(context, signs, docs, sourceId);
+//                    signMap.put("signers", signers);
+//                    //抄送方信息
+//                    JSONArray copis = signInfo.getJSONArray("copiers");
+//                    List<Map<String, Object>> copiers = this.addCopiers(context, copis);
+//                    if (copiers.size() > 0) {
+//                        signMap.put("copiers", copiers);
+//                    }
+                        //
+
+                        //必须要存在签署文件才能签署
+
+                        if (docs.size() > 0) {
+                            if (StringUtils.isNotBlank(eSignTemplateNum)) {
+                                String sealId = "";
+                                Map<String, List<Map<String, Object>>> pMap = this.addParticipants(context, signInfo, eSignTemplateNum, sealId, sourceId);
+                                signMap.put("signTemplateId", eSignTemplateNum);
+                                signMap.put("components", components);
+                                signMap.putAll(pMap);
+                                System.out.println("--------------------------------------------------------------------------------------");
+                                System.out.println("signMap:" + JSON.toJSONString(signMap));
+                                System.out.println("--------------------------------------------------------------------------------------");
+                                EsignHttpResponse response = EsignHttpUtil.createBySignTemplate(context, personId, signFlowTitle, operatorId, sourceId, JSON.toJSONString(signMap));
+                                if (response.getStatus() >= 200 && response.getStatus() < 300) {
+                                    JSONObject body = JSON.parseObject(response.getBody());
+                                    resul.putAll(body);
+                                } else {
+                                    resul.put("code", response.getStatus());
+                                    resul.put("message", "网络异常");
+                                    resul.put("data", null);
+                                }
+                            } else {
+//                            System.out.println("--------------------------------------------------------------------------------------");
+//                            System.out.println("signMap:" + JSON.toJSONString(signMap));
+//                            System.out.println("--------------------------------------------------------------------------------------");
+//                            EsignHttpResponse response = EsignHttpUtil.create_by_file(context, personId, signFlowTitle, operatorId, sourceId, JSON.toJSONString(signMap));
+//                            if (response.getStatus() >= 200 && response.getStatus() < 300) {
+//                                JSONObject body = JSON.parseObject(response.getBody());
+//                                resul.putAll(body);
+//                            } else {
+                                resul.put("code", 403);
+                                resul.put("message", "参数异常,没有模版id");
+                                resul.put("data", null);
+//                            }
+                            }
+                        }
+                    }
                 }
             }
         } catch (EsignException | URISyntaxException | SQLException e) {
@@ -280,7 +358,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
      * @return
      * @throws EsignException
      */
-    public Map<String, Map<String, Map<String, Object>>> addsignAreaList(Context context, Map<String, Object> fields, String fileId, String sourceId,String docTemplateId) throws EsignException, BOSException, EASBizException, SQLException {
+    public Map<String, Map<String, Map<String, Object>>> addsignAreaList(Context context, Map<String, Object> fields, String fileId, String sourceId, String docTemplateId) throws EsignException, BOSException, EASBizException, SQLException {
         //Map<String, List<Map<String, Object>>> signListGroup = Maps.newHashMap();
         Map<String, Map<String, Map<String, Object>>> signMapGroup = Maps.newHashMap();
         //获取文件模版字段
@@ -290,26 +368,26 @@ public class Create_by_fileOSFService implements IHRMsfService {
         selColl.add(new SelectorItemInfo("fields.*"));
         selColl.add(new SelectorItemInfo("fields.relatedControl.*"));
         String sel = "select fid from CT_ESI_ESignTemplateFileEntry where cfeSignTemplateId = ?";
-        IRowSet rs = DbUtil.executeQuery(context,sel.toString(),new Object[]{docTemplateId});
-        String Entryid="";
-        if(rs.next()){
-            Entryid=rs.getString("fid");
+        IRowSet rs = DbUtil.executeQuery(context, sel.toString(), new Object[]{docTemplateId});
+        String Entryid = "";
+        if (rs.next()) {
+            Entryid = rs.getString("fid");
         }
-        ESignTemplateFileEntryInfo eSignTemplateFileEntry = ieSignTemplateFileEntry.getESignTemplateFileEntryInfo(new ObjectUuidPK(Entryid),selColl);
-        Map<String,ESignTemplateFileEntryFieldInfo> fieldsMap = Maps.newHashMap();
+        ESignTemplateFileEntryInfo eSignTemplateFileEntry = ieSignTemplateFileEntry.getESignTemplateFileEntryInfo(new ObjectUuidPK(Entryid), selColl);
+        Map<String, ESignTemplateFileEntryFieldInfo> fieldsMap = Maps.newHashMap();
         ESignTemplateFileEntryFieldCollection entryFieldCollection = eSignTemplateFileEntry.getFields();
-        for(int i=0;i<entryFieldCollection.size();i++){
-            ESignTemplateFileEntryFieldInfo fieldInfo=entryFieldCollection.get(i);
+        for (int i = 0; i < entryFieldCollection.size(); i++) {
+            ESignTemplateFileEntryFieldInfo fieldInfo = entryFieldCollection.get(i);
             //失效的控件跳过
-            if(fieldInfo.isInvalid()){
-               continue;
+            if (fieldInfo.isInvalid()) {
+                continue;
             }
-            String fieldId =fieldInfo.getTemplateFieldId().toString();
+            String fieldId = fieldInfo.getTemplateFieldId().toString();
 
-            JSONObject field= (JSONObject) fields.get(fieldId);
+            JSONObject field = (JSONObject) fields.get(fieldId);
             if (ComponentTypeEnum.SIGN_AREA.equals(fieldInfo.getComponentType())) {
                 Map<String, Object> signMap = Maps.newHashMap();
-                if(StringUtils.isBlank(fieldInfo.getSigningParty())){
+                if (StringUtils.isBlank(fieldInfo.getSigningParty())) {
                     Map<String, Object> errMap = Maps.newHashMap();
                     errMap.put("模版", eSignTemplateFileEntry.getName());
                     errMap.put("控件", fieldInfo.getTemplateFieldName());
@@ -320,16 +398,16 @@ public class Create_by_fileOSFService implements IHRMsfService {
                 signMap.put("fileId", fileId);
                 signMap.put("fieldId", fieldInfo.getTemplateFieldId());
                 signMap.put("signFieldType", 0);
-                String keyword =fieldInfo.getTemplateFieldName();
+                String keyword = fieldInfo.getTemplateFieldName();
                 if (keyword.indexOf("骑缝") >= 0) {
                     signMap.put("signFieldStyle", 2);
                     signMap.put("positionX", fieldInfo.getPositionX());
                     signMap.put("positionY", fieldInfo.getPositionY());
                     signMap.put("positionPage", fieldInfo.getPageNum());
 
-                }else {
+                } else {
                     signMap.put("signFieldStyle", 1);
-                    if(null==fieldInfo.getPositionX()&&null==fieldInfo.getPositionY()){
+                    if (null == fieldInfo.getPositionX() && null == fieldInfo.getPositionY()) {
                         Map<String, Object> errMap = Maps.newHashMap();
                         errMap.put("模版", eSignTemplateFileEntry.getName());
                         errMap.put("控件", fieldInfo.getTemplateFieldName());
@@ -345,27 +423,27 @@ public class Create_by_fileOSFService implements IHRMsfService {
                     skMap = Maps.newHashMap();
                     signMapGroup.put((String) signMap.get("key"), skMap);
                 }
-                skMap.put(fieldInfo.getTemplateFieldId(),signMap);
+                skMap.put(fieldInfo.getTemplateFieldId(), signMap);
             }
             //签署日期
-            if(ComponentTypeEnum.DATESIGNATURE.equals(fieldInfo.getComponentType())) {
+            if (ComponentTypeEnum.DATESIGNATURE.equals(fieldInfo.getComponentType())) {
                 fieldsMap.put(fieldId, fieldInfo);
             }
         }
         //签署日期
-        for(Map.Entry<String,ESignTemplateFileEntryFieldInfo> fieldLinkEntry : fieldsMap.entrySet()){
+        for (Map.Entry<String, ESignTemplateFileEntryFieldInfo> fieldLinkEntry : fieldsMap.entrySet()) {
             //签署日期
-            ESignTemplateFileEntryFieldInfo fieldLink=fieldLinkEntry.getValue();
+            ESignTemplateFileEntryFieldInfo fieldLink = fieldLinkEntry.getValue();
             //签署方
-            ESignTemplateFileEntryFieldInfo fieldInfo=fieldLink.getRelatedControl();
-            if(null==fieldInfo){
+            ESignTemplateFileEntryFieldInfo fieldInfo = fieldLink.getRelatedControl();
+            if (null == fieldInfo) {
                 Map<String, Object> errMap = Maps.newHashMap();
                 errMap.put("模版", eSignTemplateFileEntry.getName());
                 errMap.put("控件", fieldLink.getTemplateFieldName());
                 errMap.put("内容", "签署方关联关系为空请维护!");
                 throw new EsignException(JSON.toJSONString(errMap));
             }
-            if(!ComponentTypeEnum.SIGN_AREA.equals(fieldInfo.getComponentType())){
+            if (!ComponentTypeEnum.SIGN_AREA.equals(fieldInfo.getComponentType())) {
                 Map<String, Object> errMap = Maps.newHashMap();
                 errMap.put("模版", eSignTemplateFileEntry.getName());
                 errMap.put("控件", fieldLink.getTemplateFieldName());
@@ -376,29 +454,29 @@ public class Create_by_fileOSFService implements IHRMsfService {
             //签署日期坐标
             Map<String, Object> signDateConfig = Maps.newHashMap();
             signDateConfig.put("showSignDate", 1);
-            if (null!=fieldLink.getPositionX()&&null!=fieldLink.getPositionY()) {
+            if (null != fieldLink.getPositionX() && null != fieldLink.getPositionY()) {
                 signDateConfig.put("signDatePositionX", fieldLink.getPositionX());
                 signDateConfig.put("signDatePositionY", fieldLink.getPositionY());
             }
-            if (null!=fieldLink.get("fontSize")) {
+            if (null != fieldLink.get("fontSize")) {
                 signDateConfig.put("fontSize", fieldLink.get("fontSize"));
             }
-            if (null!=fieldLink.get("dateFormat")) {
+            if (null != fieldLink.get("dateFormat")) {
                 signDateConfig.put("dateFormat", fieldLink.get("dateFormat"));
             }
             signMap.put("signDateConfig", signDateConfig);
             signMap.put("key", fieldInfo.getSigningParty());
             signMap.put("fileId", fileId);
             signMap.put("signFieldType", 0);
-            String keyword =fieldInfo.getTemplateFieldName();
+            String keyword = fieldInfo.getTemplateFieldName();
             if (keyword.indexOf("骑缝") >= 0) {
                 signMap.put("signFieldStyle", 2);
                 signMap.put("positionX", fieldInfo.getPositionX());
                 signMap.put("positionY", fieldInfo.getPositionY());
                 signMap.put("positionPage", fieldInfo.getPageNum());
-            }else {
+            } else {
                 signMap.put("signFieldStyle", 1);
-                if(null==fieldInfo.getPositionX()&&null==fieldInfo.getPositionY()){
+                if (null == fieldInfo.getPositionX() && null == fieldInfo.getPositionY()) {
                     Map<String, Object> errMap = Maps.newHashMap();
                     errMap.put("模版", eSignTemplateFileEntry.getName());
                     errMap.put("控件", fieldInfo.getTemplateFieldName());
@@ -415,7 +493,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                 signMapGroup.put((String) signMap.get("key"), skMap);
             }
             skMap.remove(fieldInfo.getTemplateFieldId());
-            skMap.put(fieldLink.getTemplateFieldId(),signMap);
+            skMap.put(fieldLink.getTemplateFieldId(), signMap);
         }
 
         System.out.println("signMapGroup:" + signMapGroup);
@@ -439,45 +517,122 @@ public class Create_by_fileOSFService implements IHRMsfService {
             JSONObject fieldObject = (JSONObject) fileEntry.getValue();
             String docTemplateId = fieldObject.getString("id");
             String fileName = fieldObject.getString("name");
+            String eSignTemplateNum = fieldObject.getString("eSignTemplateNum");
+            if (StringUtils.isBlank(docTemplateId)) {
+                docTemplateId = fieldObject.getString("tableId");
+            }
+            if (StringUtils.isBlank(fileName)) {
+                fileName = fieldObject.getString("tableName");
+            }
+            if (StringUtils.isNotBlank(eSignTemplateNum)) {
+                jsonObject.put("eSignTemplateNum", eSignTemplateNum);
+            }
+
+            Object order = fieldObject.get("order");
+            String sourceId = jsonObject.getString("sourceId");
 
+            this.initDocAndSignAreaList(context, resul, docs, fieldObject, docTemplateId, fileName, order, sourceId);
+        }
+        return docs;
+    }
+
+    /**
+     * 设置待签署文件信息
+     *
+     * @param context
+     * @param jsonObject
+     * @param templateInfo
+     * @return
+     * @throws EsignException
+     */
+    public Map<String, List<Map<String, Object>>> addPreviewDocs(Context context, JSONObject jsonObject, JSONObject templateInfo) throws EsignException, EASBizException, BOSException, SQLException {
+        //设置待签署文件信息
+        Map<String, List<Map<String, Object>>> resul = Maps.newHashMap();
+        List<Map<String, Object>> docs = Lists.newArrayList();
+        List<Map<String, Object>> components = Lists.newArrayList();
+        for (Map.Entry<String, Object> fileEntry : templateInfo.entrySet()) {
+            JSONObject fieldObject = (JSONObject) fileEntry.getValue();
+            String docTemplateId = fieldObject.getString("id");
+            String fileName = fieldObject.getString("name");
+            String eSignTemplateNum = fieldObject.getString("eSignTemplateNum");
             if (StringUtils.isBlank(docTemplateId)) {
                 docTemplateId = fieldObject.getString("tableId");
             }
             if (StringUtils.isBlank(fileName)) {
                 fileName = fieldObject.getString("tableName");
             }
+            if (StringUtils.isNotBlank(eSignTemplateNum)) {
+                jsonObject.put("eSignTemplateNum", eSignTemplateNum);
+            }
+
             Object order = fieldObject.get("order");
             String sourceId = jsonObject.getString("sourceId");
+            Map<String, Object> doc = Maps.newHashMap();
+            doc.put("fileId", docTemplateId);
+            doc.put("fileName", fileName);
+            if (null != order) {
+                doc.put("order", Integer.parseInt(String.valueOf(order)));
+            }
+            System.out.println("addDocs:" + fieldObject);
+            JSONObject fields = fieldObject.getJSONObject("fields");
 
-            EsignHttpResponse response = this.previewFile(context, fieldObject, sourceId);
-            resul.put("id", docTemplateId);
-            resul.put("name", fileName);
-            if (response.getStatus() >= 200 && response.getStatus() < 300) {
-                Map<String, Object> body = this.processFileResponse(response, context);
-                if ("0".equals(String.valueOf(body.get("code")))) {
-                    JSONObject file = (JSONObject) body.get("data");
-                    Map<String, Object> doc = Maps.newHashMap();
-                    doc.put("fileId", file.get("fileId"));
-                    doc.put("fileName", fileName);
-                    if (null != order) {
-                        doc.put("order", Integer.parseInt(String.valueOf(order)));
-                    }
-                    System.out.println("addDocs:" + fieldObject);
-                    JSONObject fields = fieldObject.getJSONObject("fields");
-                    //取得这个文件的签署人的签署区
-                    Map<String,  Map<String, Map<String, Object>>> signAreaList = this.addsignAreaList(context, fields, (String) file.get("fileId"), sourceId,docTemplateId);
-                    doc.put("signListGroup", signAreaList);
-                    docs.add(doc);
-                } else {
-                    //文件模板生成失败
-                    resul.putAll(body);
-                    throw new EsignException(JSON.toJSONString(resul));
+            for (Map.Entry<String, Object> field : fields.entrySet()) {
+
+                Map<String, Object> component = Maps.newHashMap();
+                component.put("componentId", field.getKey());
+                component.put("fileId", docTemplateId);
+                JSONObject fieldInfo = (JSONObject) field.getValue();
+                String dataType = (String) fieldInfo.get("dataType");
+                if (ComponentTypeEnum.SIGN_AREA.getAlias().equals(dataType)) {
+                    continue;
                 }
+                if (ComponentTypeEnum.DATESIGNATURE.getAlias().equals(dataType)) {
+                    continue;
+                }
+                if (null == fieldInfo.get("value")) {
+                    continue;
+                }
+                component.put("componentValue", fieldInfo.get("value"));
+                components.add(component);
+            }
+            //取得这个文件的签署人的签署区
+            Map<String, Map<String, Map<String, Object>>> signAreaList = this.addsignAreaList(context, fields, (String) docTemplateId, sourceId, docTemplateId);
+            doc.put("signListGroup", signAreaList);
+            docs.add(doc);
+        }
+        resul.put("docs", docs);
+        resul.put("components", components);
+        return resul;
+    }
+
+    private void initDocAndSignAreaList(Context context, Map<String, Object> resul, List<Map<String, Object>> docs, JSONObject fieldObject, String docTemplateId, String fileName, Object order, String sourceId) throws EsignException, BOSException, EASBizException, SQLException {
+        EsignHttpResponse response = this.previewFile(context, fieldObject, sourceId);
+        resul.put("id", docTemplateId);
+        resul.put("name", fileName);
+        if (response.getStatus() >= 200 && response.getStatus() < 300) {
+            Map<String, Object> body = this.processFileResponse(response, context);
+            if ("0".equals(String.valueOf(body.get("code")))) {
+                JSONObject file = (JSONObject) body.get("data");
+                Map<String, Object> doc = Maps.newHashMap();
+                doc.put("fileId", file.get("fileId"));
+                doc.put("fileName", fileName);
+                if (null != order) {
+                    doc.put("order", Integer.parseInt(String.valueOf(order)));
+                }
+                System.out.println("addDocs:" + fieldObject);
+                JSONObject fields = fieldObject.getJSONObject("fields");
+                //取得这个文件的签署人的签署区
+                Map<String, Map<String, Map<String, Object>>> signAreaList = this.addsignAreaList(context, fields, (String) file.get("fileId"), sourceId, docTemplateId);
+                doc.put("signListGroup", signAreaList);
+                docs.add(doc);
             } else {
-                throw new EsignException(JSON.toJSONString(response));
+                //文件模板生成失败
+                resul.putAll(body);
+                throw new EsignException(JSON.toJSONString(resul));
             }
+        } else {
+            throw new EsignException(JSON.toJSONString(response));
         }
-        return docs;
     }
 
     /**
@@ -570,11 +725,11 @@ public class Create_by_fileOSFService implements IHRMsfService {
         }
         List<Map<String, Object>> signFields = Lists.newArrayList();
         for (Map<String, Object> doc : docs) {
-            Map<String, Map<String, Map<String, Object>>> signListGroup = (Map<String,Map<String, Map<String, Object>>>) doc.get("signListGroup");
+            Map<String, Map<String, Map<String, Object>>> signListGroup = (Map<String, Map<String, Map<String, Object>>>) doc.get("signListGroup");
             //判断是否存在签署区
-            if(null!=signListGroup && signListGroup.size()>0){
+            if (null != signListGroup && signListGroup.size() > 0) {
                 Map<String, Map<String, Object>> fieldList = signListGroup.get(signName);
-                if(null!=fieldList) {
+                if (null != fieldList) {
                     for (Map<String, Object> fieldMap : fieldList.values()) {
                         Map<String, Object> field = Maps.newHashMap();
                         field.put("fileId", fieldMap.get("fileId"));
@@ -601,7 +756,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                                         signFieldPosition.put("positionX", fieldMap.get("positionX"));
                                         signFieldPosition.put("positionY", fieldMap.get("positionY"));
                                         Map<String, Object> signDateConfig = (Map<String, Object>) fieldMap.get("signDateConfig");
-                                        if(null==signDateConfig) {
+                                        if (null == signDateConfig) {
                                             signDateConfig = Maps.newHashMap();
                                             //signDateConfig.put("showSignDate", 1);
                                         }
@@ -609,7 +764,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                                     } else {
                                         Map<String, Object> res = Maps.newHashMap();
                                         //失败
-                                        res.put("文件模板:"+doc.get("fileName"),signName+",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
+                                        res.put("文件模板:" + doc.get("fileName"), signName + ",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
                                         resulErrList.add(res);
                                     }
                                 } else {
@@ -634,7 +789,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                                         signFieldPosition.put("positionX", fieldMap.get("positionX"));
                                         signFieldPosition.put("positionY", fieldMap.get("positionY"));
                                         Map<String, Object> signDateConfig = (Map<String, Object>) fieldMap.get("signDateConfig");
-                                        if(null==signDateConfig) {
+                                        if (null == signDateConfig) {
                                             signDateConfig = Maps.newHashMap();
                                             //signDateConfig.put("showSignDate", 1);
                                         }
@@ -642,7 +797,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                                     } else {
                                         Map<String, Object> res = Maps.newHashMap();
                                         //失败
-                                        res.put("文件模板:"+doc.get("fileName"),signName+",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
+                                        res.put("文件模板:" + doc.get("fileName"), signName + ",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
                                         resulErrList.add(res);
                                     }
                                 } else {
@@ -663,19 +818,18 @@ public class Create_by_fileOSFService implements IHRMsfService {
                         }
                         signFields.add(field);
                     }
-                }
-                else {
+                } else {
                     Map<String, Object> res = Maps.newHashMap();
                     //失败
-                    res.put("文件模板:"+doc.get("fileName"),signName+",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
+                    res.put("文件模板:" + doc.get("fileName"), signName + ",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
                     resulList.add(res);
                 }
             }
         }
-        if(signFields.size()<=0) {
+        if (signFields.size() <= 0) {
             throw new EsignException(JSON.toJSONString(resulList));
         }
-        if(resulErrList.size()>0) {
+        if (resulErrList.size() > 0) {
             throw new EsignException(JSON.toJSONString(resulErrList));
         }
 
@@ -696,7 +850,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
      * @throws URISyntaxException
      */
     public Map<String, Object> addPsnSignerInfo(Context context, JSONObject psnSignerInfo, List<Map<String, Object>> docs, String sourceId) throws EsignException, URISyntaxException {
-        List< Map<String, Object>> resulList = Lists.newArrayList();
+        List<Map<String, Object>> resulList = Lists.newArrayList();
         Map<String, Object> resul = Maps.newHashMap();
         Map<String, Object> signMapInfo = Maps.newHashMap();
         Map<String, Object> orgPsnSignMap = Maps.newHashMap();
@@ -746,9 +900,9 @@ public class Create_by_fileOSFService implements IHRMsfService {
             signName = "签署方" + signOrder;
         }
         for (Map<String, Object> doc : docs) {
-            Map<String,  Map<String, Map<String, Object>>> signListGroup = (Map<String, Map<String, Map<String, Object>>>) doc.get("signListGroup");
-             Map<String, Map<String, Object>> fieldList = signListGroup.get(signName);
-            if(null!=fieldList) {
+            Map<String, Map<String, Map<String, Object>>> signListGroup = (Map<String, Map<String, Map<String, Object>>>) doc.get("signListGroup");
+            Map<String, Map<String, Object>> fieldList = signListGroup.get(signName);
+            if (null != fieldList) {
                 for (Map<String, Object> fieldMap : fieldList.values()) {
                     Map<String, Object> field = Maps.newHashMap();
                     field.put("fileId", fieldMap.get("fileId"));
@@ -772,7 +926,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                                 signFieldPosition.put("positionX", fieldMap.get("positionX"));
                                 signFieldPosition.put("positionY", fieldMap.get("positionY"));
                                 Map<String, Object> signDateConfig = (Map<String, Object>) fieldMap.get("signDateConfig");
-                                if(null==signDateConfig) {
+                                if (null == signDateConfig) {
                                     signDateConfig = Maps.newHashMap();
                                 }
                                 field.put("signDateConfig", signDateConfig);
@@ -797,11 +951,11 @@ public class Create_by_fileOSFService implements IHRMsfService {
             } else {
                 Map<String, Object> res = Maps.newHashMap();
                 //失败
-                res.put("文件模板:"+doc.get("fileName"),signName+",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
+                res.put("文件模板:" + doc.get("fileName"), signName + ",未匹配到签署区,请检查模板的签署区命名规范。签署区命名规则:如(“甲方:(盖章)_签署方1_X50_Y50“)根据“_”分割字符串,第一个是要盖章的内容位置标识;第二个是签署方用来判断这个签署区是谁的;X50表示:印章位置向右移动50;Y50表示:印章位置向上移动50");
                 resulList.add(res);
             }
         }
-        if(signFields.size()<=0) {
+        if (signFields.size() <= 0) {
             throw new EsignException(JSON.toJSONString(resulList));
         }
         signMapInfo.put("signFields", signFields);
@@ -842,6 +996,104 @@ public class Create_by_fileOSFService implements IHRMsfService {
         return signers;
     }
 
+    /**
+     * todo查询流程模板详情 https://open.esign.cn/doc/opendoc/file-and-template3/pfzut7ho9obc7c5r
+     * 处理签署方信息
+     *
+     * @param context
+     * @param signTemplateId
+     * @param sealOwnerId
+     * @param sourceId
+     * @return
+     * @throws EsignException
+     * @throws URISyntaxException
+     */
+    public Map<String, List<Map<String, Object>>> addParticipants(Context context, JSONObject signInfo, String signTemplateId, String sealOwnerId, String sourceId) throws EsignException, URISyntaxException {
+        Map<String, List<Map<String, Object>>> participants_addCopiers = Maps.newHashMap();
+        List<Map<String, Object>> participants = Lists.newArrayList();
+        List<Map<String, Object>> addCopiers = Lists.newArrayList();
+        String orgName = EsignConfig.getInstance().get("orgName");
+        EsignHttpResponse response = EsignHttpUtil.getOrgIdentity_infoByOrgName(context, orgName);
+        if (response.getStatus() >= 200 && response.getStatus() < 300) {
+            JSONObject body = JSON.parseObject(response.getBody());
+            if ("0".equals(String.valueOf(body.get("code")))) {
+                JSONObject orgPsn = body.getJSONObject("data");
+                String orgId = orgPsn.getString("orgId");
+                orgName = orgPsn.getString("orgName");
+                //自动落章只能传orgId
+                EsignHttpResponse std = EsignHttpUtil.getSign_templates_detail(context, signTemplateId, orgId, false, sourceId);
+                if (std.getStatus() >= 200 && std.getStatus() < 300) {
+                    JSONObject bodyStd = JSON.parseObject(std.getBody());
+                    if ("0".equals(String.valueOf(bodyStd.get("code")))) {
+                        JSONObject orgPsnStd = bodyStd.getJSONObject("data");
+                        JSONArray parts = orgPsnStd.getJSONArray("participants");
+                        if (null != parts) {
+                            for (int i = 0; i < parts.size(); i++) {
+                                JSONObject p = parts.getJSONObject(i);
+                                JSONObject orgParticipant = p.getJSONObject("orgParticipant");
+
+                                JSONObject psnParticipant = p.getJSONObject("psnParticipant");
+
+                                String participantFlag = p.getString("participantFlag");
+                                JSONArray signs = signInfo.getJSONArray("signers");
+                                for (int x = 0; x < signs.size(); x++) {
+                                    JSONObject sign = signs.getJSONObject(x);
+                                    JSONObject orgSignerInfo = sign.getJSONObject("orgSignerInfo");
+                                    if (null != orgSignerInfo) {
+                                        String signName = orgSignerInfo.getString("signName");
+                                        if (participantFlag.equals(signName)) {
+                                            orgParticipant = new JSONObject();
+                                            p.put("orgParticipant", orgParticipant);
+                                            //orgParticipant.put("sealOwnerId",sealOwnerId);
+                                            //orgParticipant.put("orgId",orgId);
+                                            orgParticipant.put("orgName", orgSignerInfo.getString("orgName"));
+                                            JSONObject transactor = new JSONObject();
+                                            transactor.put("transactorName", orgSignerInfo.getString("psnName"));
+                                            transactor.put("transactorPsnAccount", orgSignerInfo.getString("psnAccount"));
+                                            orgParticipant.put("transactor", transactor);
+                                            //orgParticipant.put("sealOwnerId",sealOwnerId);
+                                            //orgParticipant.put("sealOwnerId",sealOwnerId);
+                                        }
+                                    } else {
+                                        JSONObject psnSignerInfo = sign.getJSONObject("psnSignerInfo");
+                                        if (null != psnSignerInfo) {
+                                            String signName = psnSignerInfo.getString("signName");
+                                            if (participantFlag.equals(signName)) {
+                                                if (null == psnParticipant) {
+                                                    psnParticipant = new JSONObject();
+                                                }
+                                                p.put("psnParticipant", psnParticipant);
+                                                //orgParticipant.put("sealOwnerId",sealOwnerId);
+                                                psnParticipant.put("psnAccount", psnSignerInfo.get("psnAccount"));
+                                                psnParticipant.put("psnName", psnSignerInfo.get("psnName"));
+
+                                                //orgParticipant.put("orgName",orgName);
+                                                //orgParticipant.put("sealOwnerId",sealOwnerId);
+                                                //orgParticipant.put("sealOwnerId",sealOwnerId);
+                                            }
+                                        }
+                                    }
+                                }
+
+                                participants.add(p);
+                            }
+                        }
+                        JSONArray copiers = orgPsnStd.getJSONArray("copiers");
+                        if (null != copiers) {
+
+                            for (int i = 0; i < copiers.size(); i++) {
+                                addCopiers.add((Map<String, Object>) copiers.get(i));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        participants_addCopiers.put("participants", participants);
+        participants_addCopiers.put("addCopiers", addCopiers);
+        return participants_addCopiers;
+    }
+
     /**
      * 签署流程配置项
      *
@@ -872,6 +1124,15 @@ public class Create_by_fileOSFService implements IHRMsfService {
             notifyUrl = EsignConfig.getInstance().get("notifyUrl");
             signFlowConfig.put("notifyUrl", notifyUrl);
         }
+        Map<String, Object> signConfig = Maps.newHashMap();
+        signConfig.put("availableSignClientTypes", "1,2");
+        signConfig.put("autoFillAndSubmit", "false");
+        signConfig.put("editComponentValue", "true");
+        Map<String, Object> noticeConfig = Maps.newHashMap();
+        noticeConfig.put("noticeTypes", "1,2");
+        noticeConfig.put("examineNotice", "true");
+        signFlowConfig.put("signConfig", signConfig);
+        signFlowConfig.put("noticeConfig", noticeConfig);
         return signFlowConfig;
     }
 
@@ -908,7 +1169,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
             if (ComponentTypeEnum.DATESIGNATURE.getAlias().equals(dataType)) {
                 continue;
             }
-            if (null==fieldInfo.get("value")) {
+            if (null == fieldInfo.get("value")) {
                 continue;
             }
             component.put("componentValue", fieldInfo.get("value"));

+ 16 - 7
websrc/com/kingdee/eas/custom/esign/osf/EsignFlowListOSFService.java

@@ -9,6 +9,9 @@ import com.kingdee.bos.Context;
 import com.kingdee.bos.bsf.service.app.IHRMsfService;
 import com.kingdee.bos.dao.IObjectPK;
 import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.metadata.entity.FilterInfo;
+import com.kingdee.bos.metadata.entity.FilterItemInfo;
+import com.kingdee.bos.metadata.query.util.CompareType;
 import com.kingdee.bos.rabbitmq.guava.Lists;
 import com.kingdee.bos.util.BOSUuid;
 import com.kingdee.eas.basedata.person.PersonInfo;
@@ -212,7 +215,7 @@ public class EsignFlowListOSFService implements IHRMsfService {
                     }
                 }
                 oldInfo.setEsignStatus(EsignStatusEnum.getEnum(signFlowStatus));
-                oldInfo.setDescription(statusDescription);
+                //oldInfo.setDescription(statusDescription);
                 oldInfo.setNowOperator("");
                 if (signFieldBool) {
                     signNames = getPsnName(context, signNames, psnSigner);
@@ -231,8 +234,8 @@ public class EsignFlowListOSFService implements IHRMsfService {
             String signFlowDescription = datasf.getString("signFlowDescription");
             String revokeReason = datasf.getString("revokeReason");
             oldInfo.setNowOperator("");
-            oldInfo.setDescription(signFlowDescription);
-            oldInfo.setDescription(revokeReason);
+            oldInfo.setErrorMsg(signFlowDescription);
+            oldInfo.setErrorMsg(revokeReason);
         }
         overview.save(oldInfo);
         return false;
@@ -436,9 +439,15 @@ public class EsignFlowListOSFService implements IHRMsfService {
 //                e.printStackTrace();
 //            }
 //        } while (pageNum<totalNum);
-        System.out.println(12 + (3 - 1) / 2 * 1);
-        EsignHttpResponse r = EsignHttpUtil.getSign_fields(null,"d4d12e6ed7374775a9dcb4747e1e5e59");
-        System.out.println(r.getBody());
-
+//        System.out.println(12 + (3 - 1) / 2 * 1);
+//        EsignHttpResponse r = EsignHttpUtil.getSign_fields(null,"d4d12e6ed7374775a9dcb4747e1e5e59");
+//        System.out.println(r.getBody());
+        FilterInfo filterInfo2 = new FilterInfo();
+        FilterItemInfo f = new FilterItemInfo();
+        f.setPropertyName("isnull(t.fid,'2199-12-30')");
+        f.setCompareValue("1");
+        f.setCompareType(CompareType.EQUALS);
+        filterInfo2.getFilterItems().add(f);
+        System.out.println(filterInfo2.toSql());
     }
 }