9060 6 days ago
parent
commit
90f8ac4236

+ 19 - 3
src/com/kingdee/eas/custom/esign/app/ESignTemplateControllerBean.java

@@ -95,7 +95,14 @@ public class ESignTemplateControllerBean extends AbstractESignTemplateController
         for (int i = 0; i < entrys.size(); i++) {
             ESignTemplateFileEntryInfo entryInfo = entrys.get(i);
             String entryId = entryInfo.getId().toString();
-            entryInfo.getFields().addCollection(entryFieldCollectionMap.get(entryId));
+            ESignTemplateFileEntryFieldCollection fields = entryInfo.getFields();
+            ESignTemplateFileEntryFieldCollection oldFields = entryFieldCollectionMap.get(entryId);
+            for (int x=0;x<oldFields.size();x++){
+                ESignTemplateFileEntryFieldInfo xInfo =oldFields.get(x);
+                if (!fields.contains(xInfo)){
+                    fields.add(xInfo);
+                }
+            }
         }
         super._update(ctx, pk, model);
     }
@@ -136,15 +143,18 @@ public class ESignTemplateControllerBean extends AbstractESignTemplateController
             throw new EASBizException(EASBizException.CHECKBLANK, new Object[]{"单据id不能为空!"});
         }
         SelectorItemCollection sic = new SelectorItemCollection();
+        sic.add("id");
         sic.add("entrys.*");
         sic.add("entrys.fields.*");
         ESignTemplateInfo info = getESignTemplateInfo(ctx, new ObjectUuidPK(billId), sic);
         ESignTemplateFileEntryCollection entrys = info.getEntrys();
+        IESignTemplateFileEntry field = ESignTemplateFileEntryFactory.getLocalInstance(ctx);
         for (int i = 0; i < entrys.size(); i++) {
             ESignTemplateFileEntryInfo entryInfo = entrys.get(i);
             String eSignTemplateId = entryInfo.getESignTemplateId();
             try {
                 ESignTemplateFileEntryFieldCollection fields = entryInfo.getFields();
+
                 Map<String, ESignTemplateFileEntryFieldInfo> fieldMap = new HashMap<String, ESignTemplateFileEntryFieldInfo>();
                 for (int j = 0; j < fields.size(); j++) {
                     ESignTemplateFileEntryFieldInfo fieldInfo = fields.get(j);
@@ -221,6 +231,10 @@ public class ESignTemplateControllerBean extends AbstractESignTemplateController
                             fieldInfo.setPageNum(componentPosition.getInteger("componentPageNum"));
                             fieldInfo.setPageRange(componentPosition.getString("componentPageRange"));
                         }
+//                         if(null==fieldInfo.getId()) {
+//                             fieldInfo.setParent1(entryInfo);
+//                             field.save(fieldInfo);
+//                         }
                     }
                 }
                 if (!fieldMap.isEmpty()) {
@@ -238,9 +252,11 @@ public class ESignTemplateControllerBean extends AbstractESignTemplateController
 //                throw new RuntimeException(e);
             }
             entryInfo.setSyncTime(new Time(System.currentTimeMillis()));
+            //更新
+            field.update(new ObjectUuidPK(entryInfo.getId()),entryInfo);
         }
-        //更新
-        update(ctx, new ObjectUuidPK(billId), info);
+
+        //update(ctx, new ObjectUuidPK(billId), info);
         //3.同步模板附件
         //syncTemplateAttachments(ctx, billId);
     }

+ 3 - 0
src/com/kingdee/eas/custom/esign/util/SyncSignedFilesUtil.java

@@ -154,6 +154,9 @@ public class SyncSignedFilesUtil {
             byte[] content = DownloaderUtil.downloadFileToByteArray(downloadUrl);
             // 检查文件名是否包含脚本攻击
             fileName = checkScriptAttack(fileName);
+            if( fileName.lastIndexOf(46)<=0) {
+                fileName +=".pdf";
+            }
             String mainname = fileName.substring(0, fileName.lastIndexOf(46));
             String extname = fileName.substring(fileName.lastIndexOf(46) + 1, fileName.length());
             extname = extname.toLowerCase();

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

@@ -571,6 +571,10 @@ public class ESignGlobalStatusOverviewListHandler extends ListHandler {
     private void saveAttachment(Context ctx, ESignGlobalStatusOverviewInfo info, JSONObject fileMap, String uipk, String propertyName) throws IOException, ShrWebBizException, BOSException, EASBizException {
         String fileId = fileMap.getString("fileId");
         String fileName = fileMap.getString("fileName");
+        System.out.println("saveAttachment:fileMap"+fileMap);
+        if(StringUtils.isBlank(fileName)) {
+            fileName = info.getFileName()+".pdf";
+        }
         String downloadUrl = fileMap.getString("downloadUrl");
         if(StringUtils.isBlank(downloadUrl)) {
             downloadUrl = fileMap.getString("fileDownloadUrl");
@@ -580,6 +584,9 @@ public class ESignGlobalStatusOverviewListHandler extends ListHandler {
         ISHRAttachmentExt SHRAttchExt = SHRAttachmentExtFactory.getLocalInstance(ctx);
         byte[] content = DownloaderUtil.downloadFileToByteArray(downloadUrl);
         fileName = this.checkScriptAttack(fileName);
+        if( fileName.lastIndexOf(46)<=0) {
+            fileName +=".pdf";
+        }
         String mainname = fileName.substring(0, fileName.lastIndexOf(46));
         String extname = fileName.substring(fileName.lastIndexOf(46) + 1, fileName.length());
         extname = extname.toLowerCase();

+ 8 - 5
websrc/com/kingdee/eas/custom/esign/osf/CallBackToOSFService.java

@@ -159,16 +159,19 @@ public class CallBackToOSFService implements IHRMsfService {
         IESignGlobalStatusOverview globalStatusOverview = ESignGlobalStatusOverviewFactory.getLocalInstance(ctx);
         ESignGlobalStatusOverviewCollection collection = globalStatusOverview.getESignGlobalStatusOverviewCollection(view);
         for( int i=0;i<collection.size();i++){
-            ESignGlobalStatusOverviewInfo info = collection.get(i);
-            info.setEsignStatus(EsignStatusEnum.getEnum(Integer.parseInt(signFlowStatus)));
-            info.setDescription(statusDescription);
-            SyncSignedFilesUtil.syncAttachmentsForEmpPage(ctx,info.getId().toString());
+            try {
+                ESignGlobalStatusOverviewInfo info = collection.get(i);
+                info.setEsignStatus(EsignStatusEnum.getEnum(Integer.parseInt(signFlowStatus)));
+                info.setDescription(statusDescription);
+                SyncSignedFilesUtil.syncAttachmentsForEmpPage(ctx, info.getId().toString());
+            }catch (Exception e){
+                e.printStackTrace();
+            }
         }
         SelectorItemCollection selectorUpdatePartial = new SelectorItemCollection();
         selectorUpdatePartial.add(new SelectorItemInfo("esignStatus"));
         selectorUpdatePartial.add(new SelectorItemInfo("description"));
         globalStatusOverview.updatePartialBatchData(collection,selectorUpdatePartial);
-
         return map;
     }
 

+ 403 - 41
websrc/com/kingdee/eas/custom/esign/osf/Create_by_fileOSFService.java

@@ -10,6 +10,7 @@ import com.kingdee.bos.BOSException;
 import com.kingdee.bos.Context;
 import com.kingdee.bos.bsf.service.app.IHRMsfService;
 import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.esign.bizEnum.ComponentTypeEnum;
 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;
@@ -18,9 +19,7 @@ import com.kingdee.eas.custom.esign.util.EsignHttpUtil;
 import org.apache.commons.lang3.StringUtils;
 
 import java.net.URISyntaxException;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -37,7 +36,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
     private static final int RETRY_INTERVAL_SECONDS = 3;
 
     @Override
-    public Object process(Context context, Map  map) throws EASBizException, BOSException {
+    public Object process(Context context, Map map) throws EASBizException, BOSException {
 
         String mack = (String) map.get("mack");
         String data = (String) map.get("data");
@@ -65,15 +64,21 @@ public class Create_by_fileOSFService implements IHRMsfService {
                 //文件
                 JSONObject templateInfo = jsonObject.getJSONObject("templateInfo");
                 //设置待签署文件信息
+                List<Map<String, Object>> docs = null;
                 try {
-                    List<Map<String, Object>> docs = this.addDocs(context, jsonObject, templateInfo);
-                    signMap.put("docs", docs);
-                }catch (EsignException e){
+                    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);
+                        docNew.remove("signListGroup");
+                        signDocs.add(docNew);
+                    }
+                    signMap.put("docs", signDocs);
+                } catch (EsignException e) {
                     e.printStackTrace();
                     resul.putAll(JSON.parseObject(e.getMessage()));
                 }
-                List<Map<String, Object>> docs = (List<Map<String, Object>>) signMap.get("docs");
-                if(null!=docs) {
+                if (null != docs) {
                     //签署流程配置项
                     Map<String, Object> signFlowConfig = this.addSignFlowConfig(context, signFlowTitle, jsonObject);
                     signMap.put("signFlowConfig", signFlowConfig);
@@ -90,8 +95,11 @@ public class Create_by_fileOSFService implements IHRMsfService {
                     }
                     //必须要存在签署文件才能签署
 
-                    if ( docs.size() > 0) {
-                        EsignHttpResponse response = EsignHttpUtil.create_by_file(context, personId, signFlowTitle,operatorId , sourceId, JSON.toJSONString(signMap));
+                    if (docs.size() > 0) {
+                        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);
@@ -103,8 +111,11 @@ public class Create_by_fileOSFService implements IHRMsfService {
                     }
                 }
             }
-        } catch (EsignException | URISyntaxException  e) {
+        } catch (EsignException | URISyntaxException e) {
             e.printStackTrace();
+            resul.put("code", 400);
+            resul.put("message", e.getMessage());
+            resul.put("data", null);
         }
         return resul;
     }
@@ -112,6 +123,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
     /**
      * 根据”填写模板生成文件“返回的文件id查询文件处理状态
      * 需要阻塞等待这个状态变为2或者5才能调用发起签署接口
+     *
      * @param response
      * @param context
      * @return
@@ -129,15 +141,17 @@ public class Create_by_fileOSFService implements IHRMsfService {
         String fileId = jsonData.getString("fileId");
         JSONObject pollData = pollFileDownloadUrl(context, fileId);
 
-        if (null!=pollData && StringUtils.isNotBlank(pollData.getString("fileDownloadUrl"))) {
+        if (null != pollData && StringUtils.isNotBlank(pollData.getString("fileDownloadUrl"))) {
             jsonData.putAll(pollData);
         }
         result.putAll(body);
+        System.out.println("processFileResponse:" + result);
         return result;
     }
 
     /**
      * 阻塞循环调用获取文件信息接口
+     *
      * @param context
      * @param fileId
      * @return
@@ -146,7 +160,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
         for (int i = MAX_RETRY_COUNT; i > 0; i--) {
             try {
                 JSONObject data = tryGetFileDownloadUrl(context, fileId);
-                if (null!=data && StringUtils.isNotBlank(data.getString("fileDownloadUrl"))) {
+                if (null != data && StringUtils.isNotBlank(data.getString("fileDownloadUrl"))) {
                     return data;
                 }
                 TimeUnit.SECONDS.sleep(RETRY_INTERVAL_SECONDS);
@@ -155,7 +169,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
                 break;
             } catch (Exception e) {
                 // 记录日志,继续重试
-               e.printStackTrace();
+                e.printStackTrace();
             }
         }
         return null;
@@ -168,7 +182,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
      * @param fileId
      * @return
      */
-    private JSONObject tryGetFileDownloadUrl(Context context, String fileId)  {
+    private JSONObject tryGetFileDownloadUrl(Context context, String fileId) {
         try {
             EsignHttpResponse response = EsignHttpUtil.getFileStatus(context, fileId, PREVIEW_OPERATION);
 
@@ -189,13 +203,247 @@ public class Create_by_fileOSFService implements IHRMsfService {
             if (COMPLETED_STATUS.contains(fileStatus)) {
                 return data;
             }
-        }catch (EsignException e){
+        } catch (EsignException e) {
             e.printStackTrace();
         }
         return null;
     }
 
+    /**
+     * 设置待签署文件位置信息
+     *
+     * @param context
+     * @param fileId
+     * @param keyword
+     * @param sourceId
+     * @return
+     * @throws EsignException
+     */
+    public JSONObject addPositions(Context context, String fileId, String keyword, String sourceId) throws EsignException {
+        List<String> keywords = Lists.newArrayList();
+        keywords.add(keyword);
+        JSONObject coordinate = null;
+        System.out.println("respPosition:fileId:" + fileId);
+        System.out.println("respPosition:keywords:" + keywords);
+        EsignHttpResponse respPosition = EsignHttpUtil.keyword_positions(context, fileId, keywords, sourceId);
+        System.out.println("respPosition:" + respPosition.getBody());
+        if (respPosition.getStatus() >= 200 && respPosition.getStatus() < 300) {
+            JSONObject resp = JSON.parseObject(respPosition.getBody());
+            if ("0".equals(String.valueOf(resp.get("code")))) {
+                JSONObject keywordData = (JSONObject) resp.get("data");
+                if (null != keywordData) {
+                    JSONArray keywordPositions = keywordData.getJSONArray("keywordPositions");
+
+                    if (null != keywordPositions && keywordPositions.size() > 0) {
+                        JSONObject keywordPs = keywordPositions.getJSONObject(keywordPositions.size() - 1);
+
+                        if (keywordPs.getBoolean("searchResult")) {
+                            if (null != keywordPs) {
+                                JSONArray positions = keywordPs.getJSONArray("positions");
+
+                                if (null != positions && positions.size() > 0) {
+                                    JSONObject position = positions.getJSONObject(positions.size() - 1);
+
+                                    if (null != position) {
+                                        Object pageNum = position.get("pageNum");
+                                        JSONArray coordinates = position.getJSONArray("coordinates");
+
+                                        if (null != coordinates && coordinates.size() > 0) {
+                                            coordinate = coordinates.getJSONObject(coordinates.size() - 1);
+                                            if (null != coordinate) {
+                                                coordinate.put("positionPage", pageNum);
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            System.out.println("coordinate:" + coordinate);
+        }
+        return coordinate;
+    }
+
+    /**
+     * 获取签署人的签署区
+     *
+     * @param context
+     * @param fields
+     * @param fileId
+     * @param sourceId
+     * @return
+     * @throws EsignException
+     */
+    public Map<String, List<Map<String, Object>>> addsignAreaList(Context context, Map<String, Object> fields, String fileId, String sourceId) throws EsignException {
+        Map<String, List<Map<String, Object>>> signListGroup = Maps.newHashMap();
+        for (Map.Entry<String, Object> field : fields.entrySet()) {
+            String componentId = field.getKey();
+            JSONObject fieldInfo = (JSONObject) field.getValue();
+            Object componentValue = fieldInfo.get("value");
+            Double positionX = fieldInfo.getDouble("positionX");
+            Double positionY = fieldInfo.getDouble("positionY");
+            Object pageNum = fieldInfo.get("pageNum");
+            String name = fieldInfo.getString("name");
+            String dataType = fieldInfo.getString("dataType");
+
+            if (ComponentTypeEnum.SIGN_AREA.getAlias().equals(dataType)) {
+                Map<String, Object> signMap = Maps.newHashMap();
+                String[] keys = name.split("_");
+                String key = "签署方";
+                for (String k : keys) {
+                    if (k.startsWith("签署方")) {
+                        key = k;
+                        break;
+                    }
+                }
+                signMap.put("key", key);
+                signMap.put("fileId", fileId);
+                signMap.put("signFieldType", 0);
+                String keyword = keys[0];
+                if (keyword.indexOf("骑缝") >= 0) {
+                    signMap.put("signFieldStyle", 2);
+                } else {
+                    if (null == positionX || null == positionY) {
+                        signMap.put("signFieldStyle", 1);
+                        JSONObject coordinate = this.addPositions(context, fileId, keyword, sourceId);
+                        System.out.println("doc.coordinate:" + coordinate);
+                        if (null != coordinate) {
+                            double posX = coordinate.getDouble("positionX");
+                            double posY = coordinate.getDouble("positionY");
+                            for (String k : keys) {
+                                if (k.startsWith("X")) {
+                                    String x = k.replace("X", "");
+                                    posX = posX + Integer.parseInt(x);
+                                    signMap.put("posX", posX);
+                                    break;
+                                }
+                            }
+                            for (String k : keys) {
+                                if (k.startsWith("Y")) {
+                                    String y = k.replace("Y", "");
+                                    posY = posY + Integer.parseInt(y);
+                                    signMap.put("posY", posY);
+                                    break;
+                                }
+                            }
+                            signMap.put("positionX", coordinate.getDouble("positionX"));
+                            signMap.put("positionY", coordinate.getDouble("positionY"));
+                            signMap.put("positionPage", coordinate.get("positionPage"));
+                        }
+                    } else {
+                        double posX = positionX;
+                        double posY = positionY;
+                        for (String k : keys) {
+                            if (k.startsWith("X")) {
+                                String x = k.replace("X", "");
+                                posX = posX + Integer.parseInt(x);
+                                signMap.put("posX", posX);
+                                break;
+                            }
+                        }
+                        for (String k : keys) {
+                            if (k.startsWith("Y")) {
+                                String y = k.replace("Y", "");
+                                posY = posY + Integer.parseInt(y);
+                                signMap.put("posY", posY);
+                                break;
+                            }
+                        }
+                        signMap.put("positionX", positionX);
+                        signMap.put("positionY", positionY);
+                        signMap.put("positionPage", pageNum);
+                    }
+                }
+                List<Map<String, Object>> signList = signListGroup.get((String) signMap.get("key"));
+                if (null == signList) {
+                    signList = Lists.newArrayList();
+                    signListGroup.put((String) signMap.get("key"), signList);
+                }
+                signList.add(signMap);
+            } else if (ComponentTypeEnum.REMARK_SIGN_AREA.getAlias().equals(dataType)) {
+
+                Map<String, Object> signMap = Maps.newHashMap();
 
+                String[] keys = name.split("_");
+                String key = "签署方";
+                for (String k : keys) {
+                    if (k.startsWith("签署方")) {
+                        key = k;
+                        break;
+                    }
+                }
+                signMap.put("key", key);
+                signMap.put("fileId", fileId);
+                signMap.put("signFieldType", 1);
+
+                String keyword = keys[0];
+                if (keyword.indexOf("骑缝") >= 0) {
+                    signMap.put("signFieldStyle", 2);
+                } else {
+                    if (null == positionX || null == positionY) {
+                        signMap.put("signFieldStyle", 1);
+                        JSONObject coordinate = this.addPositions(context, fileId, keyword, sourceId);
+                        System.out.println("doc.coordinate:" + coordinate);
+                        if (null != coordinate) {
+                            double posX = coordinate.getDouble("positionX");
+                            double posY = coordinate.getDouble("positionY");
+                            for (String k : keys) {
+                                if (k.startsWith("X")) {
+                                    String x = k.replace("X", "");
+                                    posX = posX + Integer.parseInt(x);
+                                    signMap.put("posX", posX);
+                                    break;
+                                }
+                            }
+                            for (String k : keys) {
+                                if (k.startsWith("Y")) {
+                                    String y = k.replace("Y", "");
+                                    posY = posY + Integer.parseInt(y);
+                                    signMap.put("posY", posY);
+                                    break;
+                                }
+                            }
+                            signMap.put("positionX", coordinate.getDouble("positionX"));
+                            signMap.put("positionY", coordinate.getDouble("positionY"));
+                            signMap.put("positionPage", coordinate.get("positionPage"));
+                        }
+                    } else {
+                        double posX = positionX;
+                        double posY = positionY;
+                        for (String k : keys) {
+                            if (k.startsWith("X")) {
+                                String x = k.replace("X", "");
+                                posX = posX + Integer.parseInt(x);
+                                signMap.put("posX", posX);
+                                break;
+                            }
+                        }
+                        for (String k : keys) {
+                            if (k.startsWith("Y")) {
+                                String y = k.replace("Y", "");
+                                posY = posY + Integer.parseInt(y);
+                                signMap.put("posY", posY);
+                                break;
+                            }
+                        }
+                        signMap.put("positionX", positionX);
+                        signMap.put("positionY", positionY);
+                        signMap.put("positionPage", pageNum);
+                    }
+                }
+                List<Map<String, Object>> signList = signListGroup.get((String) signMap.get("key"));
+                if (null == signList) {
+                    signList = Lists.newArrayList();
+                    signListGroup.put((String) signMap.get("key"), signList);
+                }
+                signList.add(signMap);
+            }
+        }
+        System.out.println("signListGroup:" + signListGroup);
+        return signListGroup;
+    }
 
     /**
      * 设置待签署文件信息
@@ -216,11 +464,12 @@ public class Create_by_fileOSFService implements IHRMsfService {
             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);
+            resul.put("id", docTemplateId);
+            resul.put("name", fileName);
             if (response.getStatus() >= 200 && response.getStatus() < 300) {
-                Map<String,Object> body = this.processFileResponse(response,context);
+                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();
@@ -229,6 +478,14 @@ public class Create_by_fileOSFService implements IHRMsfService {
                     if (null != order) {
                         doc.put("order", Integer.parseInt(String.valueOf(order)));
                     }
+                    doc.put("positionX", null);
+                    doc.put("positionY", null);
+                    doc.put("positionPage", null);
+                    System.out.println("addDocs:" + fieldObject);
+                    JSONObject fields = fieldObject.getJSONObject("fields");
+                    //取得这个文件的签署人的签署区
+                    Map<String, List<Map<String, Object>>> signAreaList = this.addsignAreaList(context, fields, (String) file.get("fileId"), sourceId);
+                    doc.put("signListGroup", signAreaList);
                     docs.add(doc);
                 } else {
                     //文件模板生成失败
@@ -263,6 +520,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
 
     /**
      * 添加签署组织
+     *
      * @param context
      * @param orgSignerInfo
      * @param docs
@@ -283,9 +541,20 @@ public class Create_by_fileOSFService implements IHRMsfService {
                 JSONObject orgPsn = body.getJSONObject("data");
                 String orgId = orgPsn.getString("orgId");
                 orgName = orgPsn.getString("orgName");
-                orgPsnSignMap.put("orgId", orgId);
-                orgPsnSignMap.put("orgName", orgName);
-                orgPsnSignMap.put("orgInfo", orgPsn.getJSONObject("orgInfo"));
+                //自动落章只能传orgId
+                if (true == orgSignerInfo.getBoolean("isRadio")) {
+                    orgPsnSignMap.put("orgId", orgId);
+
+                } else {
+                    orgPsnSignMap.put("orgName", orgName);
+                    Map<String, Object> transactorInfo = Maps.newHashMap();
+                    transactorInfo.put("psnAccount", orgSignerInfo.getString("psnAccount"));
+                    Map<String, Object> psnInfo = Maps.newHashMap();
+                    psnInfo.put("psnName", orgSignerInfo.getString("psnAccount"));
+                    transactorInfo.put("psnInfo", psnInfo);
+                    orgPsnSignMap.put("transactorInfo", transactorInfo);
+                    orgPsnSignMap.put("orgInfo", orgPsn.getJSONObject("orgInfo"));
+                }
             } else {
                 //失败
                 resul.putAll(body);
@@ -312,17 +581,69 @@ public class Create_by_fileOSFService implements IHRMsfService {
         }
         signMapInfo.put("noticeConfig", noticeConfig);
         //签署区信息
+        String signName = orgSignerInfo.getString("signName");
+        if (StringUtils.isBlank(signName)) {
+            signName = "签署方" + signOrder;
+        }
         List<Map<String, Object>> signFields = Lists.newArrayList();
         for (Map<String, Object> doc : docs) {
-            Map<String, Object> field = Maps.newHashMap();
-            field.put("fileId", doc.get("fileId"));
-            field.put("customBizNum", sourceId);
-            field.put("signFieldType", 0);
-            //签章区配置项(指定signFieldType为 0 - 签章区时,该参数为必传项)
-            Map<String, Object> normalSignFieldConfig = Maps.newHashMap();
-            normalSignFieldConfig.put("freeMode", true);
-            field.put("normalSignFieldConfig", normalSignFieldConfig);
-            signFields.add(field);
+            Map<String, List<Map<String, Object>>> signListGroup = (Map<String, List<Map<String, Object>>>) doc.get("signListGroup");
+            List<Map<String, Object>> fieldList = signListGroup.get(signName);
+            for (Map<String, Object> fieldMap : fieldList) {
+                Map<String, Object> field = Maps.newHashMap();
+                field.put("fileId", fieldMap.get("fileId"));
+                field.put("customBizNum", sourceId);
+                if (0 == ((int) fieldMap.get("signFieldType"))) {
+                    field.put("signFieldType", fieldMap.get("signFieldType"));
+                    //签章区配置项(指定signFieldType为 0 - 签章区时,该参数为必传项)
+                    Map<String, Object> normalSignFieldConfig = Maps.newHashMap();
+                    if (true == orgSignerInfo.getBoolean("isRadio")) {
+                        //企业/机构自动落章(autoSign为true),请不要传该参数。
+                        orgPsnSignMap.remove("transactorInfo");
+                        //自动落章
+                        normalSignFieldConfig.put("freeMode", false);
+                        normalSignFieldConfig.put("autoSign", true);
+                        //印章id
+                        normalSignFieldConfig.put("assignedSealId", orgSignerInfo.getString("sealId"));
+                        //印章类型:1印章,2骑缝章
+                        normalSignFieldConfig.put("signFieldStyle", fieldMap.get("signFieldStyle"));
+                        Map<String, Object> signFieldPosition = Maps.newHashMap();
+                        if (1 == ((int) fieldMap.get("signFieldStyle"))) {
+                            //正常章
+                            if (null != fieldMap.get("positionPage") && null != fieldMap.get("positionX") && null != fieldMap.get("positionY")) {
+                                signFieldPosition.put("positionPage", fieldMap.get("positionPage"));
+                                signFieldPosition.put("positionX", fieldMap.get("positionX"));
+                                signFieldPosition.put("positionY", fieldMap.get("positionY"));
+                                if (null != fieldMap.get("posX") ) {
+                                    signFieldPosition.put("positionX", fieldMap.get("posX"));
+                                }
+                                if (null != fieldMap.get("posY")) {
+                                    signFieldPosition.put("positionY", fieldMap.get("posY"));
+                                }
+                            }
+                        } else {
+                            //骑缝章
+                        }
+                        normalSignFieldConfig.put("signFieldPosition", signFieldPosition);
+                        Map<String, Object> signDateConfig = Maps.newHashMap();
+                        signDateConfig.put("showSignDate", 1);
+                        field.put("signDateConfig", signDateConfig);
+                    } else {
+                        //手动签章
+                        normalSignFieldConfig.put("freeMode", true);
+                        normalSignFieldConfig.put("autoSign", false);
+                    }
+                    field.put("normalSignFieldConfig", normalSignFieldConfig);
+                } else {
+                    field.put("signFieldType", fieldMap.get("signFieldType"));
+                    //签章区配置项(指定signFieldType为 0 - 签章区时,该参数为必传项)
+                    Map<String, Object> remarkSignFieldConfig = Maps.newHashMap();
+                    remarkSignFieldConfig.put("freeMode", true);
+                    remarkSignFieldConfig.put("inputType", 2);
+                    field.put("remarkSignFieldConfig", remarkSignFieldConfig);
+                }
+                signFields.add(field);
+            }
         }
         signMapInfo.put("signFields", signFields);
         signMapInfo.put("signerType", 1);
@@ -331,6 +652,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
 
     /**
      * 添加签署人
+     *
      * @param context
      * @param psnSignerInfo
      * @param docs
@@ -370,16 +692,49 @@ public class Create_by_fileOSFService implements IHRMsfService {
         signMapInfo.put("noticeConfig", noticeConfig);
         //签署区信息
         List<Map<String, Object>> signFields = Lists.newArrayList();
+//        for (Map<String, Object> doc : docs) {
+//            Map<String, Object> field = Maps.newHashMap();
+//            field.put("fileId", doc.get("fileId"));
+//            field.put("customBizNum", sourceId);
+//            field.put("signFieldType", 0);
+//            //签章区配置项(指定signFieldType为 0 - 签章区时,该参数为必传项)
+//            Map<String, Object> normalSignFieldConfig = Maps.newHashMap();
+//            normalSignFieldConfig.put("freeMode", true);
+//            normalSignFieldConfig.put("movableSignField", false);
+//
+//            field.put("normalSignFieldConfig", normalSignFieldConfig);
+//            signFields.add(field);
+//        }
+        //签署区信息
+        String signName = psnSignerInfo.getString("signName");
+        if (StringUtils.isBlank(signName)) {
+            signName = "签署方" + signOrder;
+        }
         for (Map<String, Object> doc : docs) {
-            Map<String, Object> field = Maps.newHashMap();
-            field.put("fileId", doc.get("fileId"));
-            field.put("customBizNum", sourceId);
-            field.put("signFieldType", 0);
-            //签章区配置项(指定signFieldType为 0 - 签章区时,该参数为必传项)
-            Map<String, Object> normalSignFieldConfig = Maps.newHashMap();
-            normalSignFieldConfig.put("freeMode", true);
-            field.put("normalSignFieldConfig", normalSignFieldConfig);
-            signFields.add(field);
+            Map<String, List<Map<String, Object>>> signListGroup = (Map<String, List<Map<String, Object>>>) doc.get("signListGroup");
+            List<Map<String, Object>> fieldList = signListGroup.get(signName);
+            for (Map<String, Object> fieldMap : fieldList) {
+                Map<String, Object> field = Maps.newHashMap();
+                field.put("fileId", fieldMap.get("fileId"));
+                field.put("customBizNum", sourceId);
+                if (0 == ((int) fieldMap.get("signFieldType"))) {
+                    field.put("signFieldType", fieldMap.get("signFieldType"));
+                    //签章区配置项(指定signFieldType为 0 - 签章区时,该参数为必传项)
+                    Map<String, Object> normalSignFieldConfig = Maps.newHashMap();
+                    //手动签章
+                    normalSignFieldConfig.put("freeMode", true);
+                    normalSignFieldConfig.put("autoSign", false);
+                    field.put("normalSignFieldConfig", normalSignFieldConfig);
+                } else {
+                    field.put("signFieldType", fieldMap.get("signFieldType"));
+                    //签章区配置项(指定signFieldType为 0 - 签章区时,该参数为必传项)
+                    Map<String, Object> remarkSignFieldConfig = Maps.newHashMap();
+                    remarkSignFieldConfig.put("freeMode", true);
+                    remarkSignFieldConfig.put("inputType", 2);
+                    field.put("remarkSignFieldConfig", remarkSignFieldConfig);
+                }
+                signFields.add(field);
+            }
         }
         signMapInfo.put("signFields", signFields);
         signMapInfo.put("signerType", 0);
@@ -387,6 +742,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
         return signMapInfo;
     }
 
+
     /**
      * 处理签署方信息
      *
@@ -454,6 +810,7 @@ public class Create_by_fileOSFService implements IHRMsfService {
 
     /**
      * 根据传入数据调用 ”填写模板生成文件“ 接口
+     *
      * @param jsonObject
      * @return
      */
@@ -472,9 +829,14 @@ public class Create_by_fileOSFService implements IHRMsfService {
         List<Map<String, Object>> components = Lists.newArrayList();
         JSONObject fields = jsonObject.getJSONObject("fields");
         for (Map.Entry<String, Object> field : fields.entrySet()) {
+
             Map<String, Object> component = Maps.newHashMap();
             component.put("componentId", field.getKey());
             JSONObject fieldInfo = (JSONObject) field.getValue();
+            String dataType = (String) fieldInfo.get("dataType");
+            if (ComponentTypeEnum.SIGN_AREA.getAlias().equals(dataType)) {
+                continue;
+            }
             component.put("componentValue", fieldInfo.get("value"));
             components.add(component);
         }