|
|
@@ -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;
|
|
|
}
|
|
|
|