|
|
@@ -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"));
|