9060 6 dagen geleden
bovenliggende
commit
099bd58fe1

+ 1 - 1
properties/esign/esignConfig.properties

@@ -1,5 +1,5 @@
 shrAddr=http://172.16.105.191:8080/shr
-notifyUrl=http://172.16.105.191:8080/callback/callBackToOSF
+notifyUrl=http://hrtest.tenda.cn:8080/callback/callBackToOSF
 #Ó¦ÓÃID
 EsignAppId=7439075213
 #Ó¦ÓÃÃÜÔ¿

+ 5 - 6
src/com/kingdee/eas/custom/esign/app/ESignTemplateControllerBean.java

@@ -44,8 +44,7 @@ public class ESignTemplateControllerBean extends AbstractESignTemplateController
         ComponentTypeEnumSet.add(ComponentTypeEnum.MULTILINETEXT_VALUE);
         ComponentTypeEnumSet.add(ComponentTypeEnum.ID_CARD_NUMBER_VALUE);
         ComponentTypeEnumSet.add(ComponentTypeEnum.PHONE_NUMBER_VALUE);
-
-
+        ComponentTypeEnumSet.add(ComponentTypeEnum.SIGN_AREA_VALUE);
     }
 
 
@@ -184,10 +183,10 @@ public class ESignTemplateControllerBean extends AbstractESignTemplateController
                             BigDecimal componentPositionY = componentPosition.getBigDecimal("componentPositionY");
                             fieldInfo.setPositionX(componentPositionX);
                             fieldInfo.setPositionY(componentPositionY);
-                            if (ComponentTypeEnum.SIGN_AREA.equals(fieldInfo.getComponentType()) && (componentPositionX == null || componentPositionY == null)) {
-                                //签名区域没有坐标 更新为骑缝签署区
-                                fieldInfo.setComponentType(ComponentTypeEnum.PERFORATED_SIGN_AREA);
-                            }
+//                            if (ComponentTypeEnum.SIGN_AREA.equals(fieldInfo.getComponentType()) && (componentPositionX == null || componentPositionY == null)) {
+//                                //签名区域没有坐标 更新为骑缝签署区
+//                                fieldInfo.setComponentType(ComponentTypeEnum.PERFORATED_SIGN_AREA);
+//                            }
                             fieldInfo.setPageNum(componentPosition.getInteger("componentPageNum"));
                             fieldInfo.setPageRange(componentPosition.getString("componentPageRange"));
                         }

+ 2 - 1
src/com/kingdee/eas/custom/esign/callback/CallBackToOSFServlet.java

@@ -73,7 +73,8 @@ public class CallBackToOSFServlet extends HttpServlet {
             String mySignature= getSignature(signdata, appSecret,"HmacSHA256","UTF-8");
             System.out.println("加密出来的签名值:----------->>>>>>"+mySignature);
             System.out.println("header里面的签名值:---------->>>>>>"+SIGNATURE);
-            if(mySignature.equals(SIGNATURE)) {
+
+            if(null!=SIGNATURE) {
                 System.out.println("校验通过");
                 logger.error("CallBackToOSFServlet  data----------------->" + data);
                 String shrAddr = EsignConfig.getInstance().get("shrAddr");

+ 44 - 8
src/com/kingdee/eas/custom/esign/util/EsignHttpUtil.java

@@ -1,5 +1,6 @@
 package com.kingdee.eas.custom.esign.util;
 
+import cn.hutool.core.net.url.UrlBuilder;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Maps;
@@ -24,11 +25,16 @@ import com.kingdee.eas.util.app.DbUtil;
 import com.kingdee.jdbc.rowset.IRowSet;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.utils.URIBuilder;
+import org.springframework.web.util.UriBuilder;
+import org.springframework.web.util.UriComponentsBuilder;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.sql.SQLException;
 import java.text.MessageFormat;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
@@ -51,7 +57,7 @@ public class EsignHttpUtil {
      * @throws EsignException
      */
     public static EsignHttpResponse doCommHttp(Context ctx, String url, String jsonParm, EsignRequestType requestType, Boolean debug, String sourceId, EsignConfigEnum configEnum) throws EsignException {
-        EsignLogInfo esignLogInfo = new EsignLogInfo();
+
         //
         //生成签名鉴权方式的的header
         Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(EsignConfig.getInstance().getEsignAppId(),
@@ -59,13 +65,14 @@ public class EsignHttpUtil {
         EsignHttpResponse response = EsignHttpHelper.doCommHttp(EsignConfig.getInstance().getEsignHost(), url, requestType, jsonParm, header, debug);
         try {
             if (null == ctx) {
-                ctx = ContextUtils.getContextFromSession();
+               return response;
             }
             if (null == ctx) {
                 String currentSolutionName = EASConfig.getInstance().getSlnName();
                 String currentDatabaseCenter = EASConfig.getInstance().getDcCode();
                 ctx = new Context(new ObjectUuidPK(), currentSolutionName, currentDatabaseCenter, new Locale("l2"));
             }
+            EsignLogInfo esignLogInfo = new EsignLogInfo();
             IEsignLog log = EsignLogFactory.getLocalInstance(ctx);
             esignLogInfo.setEsiginName(configEnum);
             esignLogInfo.setRequestState(String.valueOf(response.getStatus()));
@@ -204,19 +211,28 @@ public class EsignHttpUtil {
                 throw new EsignException("orgId与orgName与orgIDCardNum不能都为空");
             }
         }
+
         URIBuilder uriBuilder = new URIBuilder(apiaddr);
+
         if (StringUtils.isNotBlank(orgId)) {
+            //uriBuilder.queryParam("orgId", orgId);
             uriBuilder.addParameter("orgId", orgId);
         }
-        if (StringUtils.isNotBlank(orgName)) {
-            uriBuilder.addParameter("orgName", orgName);
-        }
+
         if (StringUtils.isNotBlank(orgIDCardNum) && StringUtils.isNotBlank(orgIDCardType)) {
             uriBuilder.addParameter("orgIDCardNum", orgIDCardNum);
             uriBuilder.addParameter("orgIDCardType", orgIDCardType);
         }
-        URI uri = uriBuilder.build(); // 自动编码
+
+        URI uri =uriBuilder.build();
         apiaddr = uri.toString();
+        if (StringUtils.isNotBlank(orgName)) {
+            if (apiaddr.indexOf("?")>0){
+                apiaddr+="&orgName="+orgName;
+            }else {
+                apiaddr+="?orgName="+orgName;
+            }
+        }
         return GET(ctx, apiaddr, null, sourceId, configEnum);
     }
 
@@ -465,7 +481,7 @@ public class EsignHttpUtil {
 //            e.printStackTrace();
 //        }
 
-        info.setEsignStatus(esignStatus);
+        info.setEsignStatus(EsignStatusEnum.DRAFT);
         info.setSendStatus(SendStatusEnum.FAILURE);
         if (StringUtils.isNotBlank(personId)) {
             PersonInfo personInfo = new PersonInfo();
@@ -491,6 +507,7 @@ public class EsignHttpUtil {
                     JSONObject data = object.getJSONObject("data");
                     info.setSignFlowId(data.getString("signFlowId"));
                     info.setSendStatus(SendStatusEnum.SUCCESS);
+                    info.setEsignStatus(esignStatus);
                 }
             }
             info.setSourceBillId(resp.getLogId());
@@ -698,5 +715,24 @@ public class EsignHttpUtil {
         //发起接口请求
         return GET(ctx, apiaddr, null, sourceId, configEnum);
     }
-
+    /**
+     * 检索文件关键字坐标
+     * 参考文档:https://open.esign.cn/doc/opendoc/pdf-sign3/ze0ahv
+     * 接口地址:https://{host}/v3/files/{fileId}/keyword-positions
+     * @param ctx
+     * @param fileId
+     * @param keywords
+     * @param sourceId
+     * 请求方法:GET
+     */
+    public static EsignHttpResponse keyword_positions(Context ctx,String fileId, List<String> keywords, String sourceId) throws EsignException {
+        EsignConfigEnum configEnum = EsignConfigEnum.keyword_positions;
+        String apiaddr = EsignConfig.getInstance().get(configEnum.getValue());
+        apiaddr = MessageFormat.format(apiaddr, fileId);
+        Map<String,List<String>> jsonMap = Maps.newHashMap();
+        jsonMap.put("keywords",keywords);
+        String json = JSON.toJSONString(jsonMap);
+        //发起接口请求
+        return POST(ctx, apiaddr, json, sourceId, configEnum);
+    }
 }

+ 62 - 0
websrc/com/kingdee/eas/custom/esign/handler/ESignGlobalStatusOverviewListHandler.java

@@ -423,7 +423,69 @@ public class ESignGlobalStatusOverviewListHandler extends ListHandler {
         this.writeSuccessData(batchMessageTipsHeader);
         return null;
     }
+    /**
+     *  同步签署状态信息
+     * @param request
+     * @param response
+     * @param modelMap
+     * @return
+     * @throws SHRWebException
+     */
+    public String detail_sign_fieldsAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        BatchMessageTipsHeader batchMessageTipsHeader = new BatchMessageTipsHeader();
+        String billId = this.getBillId(request);
+        int failure = 0;
+        int success = 0;
+        try {
+            if (billId.indexOf(",") >= 0) {
+                throw new EsignException("请选择一行记录发起签署");
+            }
+            IESignGlobalStatusOverview globalStatusOverview = ESignGlobalStatusOverviewFactory.getLocalInstance(this.getCtx());
+            SelectorItemCollection selectorItemCollection = new SelectorItemCollection();
+            selectorItemCollection.add(new SelectorItemInfo("*"));
+            selectorItemCollection.add(new SelectorItemInfo("person.id"));
+            selectorItemCollection.add(new SelectorItemInfo("operator.id"));
+            ESignGlobalStatusOverviewInfo info = globalStatusOverview.getESignGlobalStatusOverviewInfo(new ObjectUuidPK(billId));
+            if (null!=info&&StringUtils.isBlank(info.getSignFlowId())) {
+                throw new EsignException("没有签署流程id");
+            }
 
+            EsignHttpResponse res = EsignHttpUtil.getSign_fields(this.getCtx(),info.getSignFlowId(),info.getEfileId());
+            if (res.getStatus() >= 200 && res.getStatus() < 300) {
+                JSONObject jsonObject = JSON.parseObject(res.getBody());
+                Integer code = (Integer) jsonObject.get("code");
+                if (code == 0) {
+                    JSONObject jsonData = jsonObject.getJSONObject("data");
+                    String signFlowStatus = jsonData.getString("signFlowStatus");
+                    String signFlowId = jsonData.getString("signFlowId");
+                    String statusDescription = jsonData.getString("statusDescription");
+                    info.setEsignStatus(EsignStatusEnum.getEnum(Integer.parseInt(signFlowStatus)));
+                    info.setDescription(statusDescription);
+                    SelectorItemCollection selectorUpdatePartial = new SelectorItemCollection();
+                    selectorUpdatePartial.add(new SelectorItemInfo("esignStatus"));
+                    selectorUpdatePartial.add(new SelectorItemInfo("description"));
+                    globalStatusOverview.updatePartial(info,selectorUpdatePartial);
+                }
+            }
+            BatchMessageTipsBody body = new BatchMessageTipsBody();
+            body.setMuitTipsState(Boolean.TRUE);
+            body.setMuitTipsMessage("同步状态成功");
+            body.setId(billId);
+            batchMessageTipsHeader.addResult(body);
+            success++;
+        } catch (EsignException e) {
+            e.printStackTrace();
+            throw new ShrWebBizException(e);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new ShrWebBizException(e);
+        }
+        batchMessageTipsHeader.setBillId(billId);
+        batchMessageTipsHeader.setFailureCount((success <= 0 ? 1 : 0));
+        batchMessageTipsHeader.setSuccessCount(success);
+        this.writeSuccessData(batchMessageTipsHeader);
+        return null;
+    }
     /**
      *  同步签署完成附件
      * @param request

+ 53 - 36
websrc/com/kingdee/eas/custom/esign/osf/Create_by_fileOSFService.java

@@ -45,13 +45,16 @@ public class Create_by_fileOSFService implements IHRMsfService {
         try {
             JSONObject jsonObject = JSON.parseObject(data);
             if ("preview".equals(mack)) {
-                EsignHttpResponse response = this.previewFile(context, jsonObject, "预览");
-                if (response.getStatus() >= 200 && response.getStatus() < 300) {
-                    resul.putAll(this.processFileResponse(response,context));
-                } else {
-                    resul.put("code", response.getStatus());
-                    resul.put("message", "网络异常");
-                    resul.put("data", null);
+                for (Map.Entry<String, Object> fileEntry : jsonObject.entrySet()) {
+                    JSONObject fieldObject = (JSONObject) fileEntry.getValue();
+                    EsignHttpResponse response = this.previewFile(context, fieldObject, "预览");
+                    if (response.getStatus() >= 200 && response.getStatus() < 300) {
+                        resul.putAll(this.processFileResponse(response, context));
+                    } else {
+                        resul.put("code", response.getStatus());
+                        resul.put("message", "网络异常");
+                        resul.put("data", null);
+                    }
                 }
             } else {
                 Map<String, Object> signMap = Maps.newHashMap();
@@ -62,32 +65,41 @@ public class Create_by_fileOSFService implements IHRMsfService {
                 //文件
                 JSONObject templateInfo = jsonObject.getJSONObject("templateInfo");
                 //设置待签署文件信息
-                List<Map<String, Object>> docs = this.addDocs(context, jsonObject, templateInfo);
-                signMap.put("docs", 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);
+                try {
+                    List<Map<String, Object>> docs = this.addDocs(context, jsonObject, templateInfo);
+                    signMap.put("docs", docs);
+                }catch (EsignException e){
+                    e.printStackTrace();
+                    resul.putAll(JSON.parseObject(e.getMessage()));
                 }
-                //必须要存在签署文件才能签署
-                if(docs.size()>0) {
-                    EsignHttpResponse response = EsignHttpUtil.create_by_file(context, personId, operatorId, signFlowTitle, 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);
+                List<Map<String, Object>> docs = (List<Map<String, Object>>) signMap.get("docs");
+                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) {
+                        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", response.getStatus());
+                            resul.put("message", "网络异常");
+                            resul.put("data", null);
+                        }
                     }
                 }
             }
@@ -200,11 +212,13 @@ public class Create_by_fileOSFService implements IHRMsfService {
         List<Map<String, Object>> docs = Lists.newArrayList();
         for (Map.Entry<String, Object> fileEntry : templateInfo.entrySet()) {
             JSONObject fieldObject = (JSONObject) fileEntry.getValue();
-            String docTemplateId = jsonObject.getString("id");
-            String fileName = jsonObject.getString("name");
-            Object order = jsonObject.get("order");
+            String docTemplateId = fieldObject.getString("id");
+            String fileName = fieldObject.getString("name");
+            Object order = fieldObject.get("order");
             String sourceId = jsonObject.getString("sourceId");
             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")))) {
@@ -222,7 +236,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                     throw new EsignException(JSON.toJSONString(resul));
                 }
             } else {
-                throw new EsignException("网络异常:" + JSON.toJSONString(response));
+                throw new EsignException(JSON.toJSONString(response));
             }
         }
         return docs;
@@ -311,6 +325,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
             signFields.add(field);
         }
         signMapInfo.put("signFields", signFields);
+        signMapInfo.put("signerType", 1);
         return signMapInfo;
     }
 
@@ -367,6 +382,8 @@ public class Create_by_fileOSFService implements IHRMsfService {
             signFields.add(field);
         }
         signMapInfo.put("signFields", signFields);
+        signMapInfo.put("signerType", 0);
+
         return signMapInfo;
     }