package com.kingdee.eas.custom.esign.osf;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
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.tsign.hz.comm.EsignHttpResponse;
import com.kingdee.eas.custom.esign.tsign.hz.exception.EsignException;
import com.kingdee.eas.custom.esign.util.EsignConfig;
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;
/**
* description: Create_by_fileOSFService
* date: 28/11/2025 上午 9:46
* author: lhbj
* version: 1.0
*/
public class Create_by_fileOSFService implements IHRMsfService {
public static void main(String[] args) {
JSONObject jsonObject = JSON.parseObject("{\"tableName\":\"3-信息安全承诺书.pdf\",\"tableId\":\"4b19400154d1444e969bf69a6ce0c83c\",\"fields\":{\"49e2cabb3fff4e0090d580f7d4d6e0fc\":{\"name\":\"单行文本1\",\"dataType\":\"单行文本\",\"dataFormat\":\"undefined\",\"value\":\"大王大大\"},\"700825a785484185a6e3fd02e358792c\":{\"name\":\"工号\",\"dataType\":\"单行文本\",\"dataFormat\":\"undefined\",\"value\":\"1234534\"},\"a95f4a5d491d473cbba755a9bb84a04a\":{\"name\":\"日期1\",\"dataType\":\"Date\",\"dataFormat\":\"undefined\",\"value\":\"2024-12-03 00:00:00\"},\"35e09954d6aa41538bd27ffc42da59aa\":{\"name\":\"部门\",\"dataType\":\"String\",\"dataFormat\":\"undefined\",\"value\":\"HR产品处\"},\"df8743514be54648a1bc755cd51e315c\":{\"name\":\"多行文本1\",\"dataType\":\"String\",\"dataFormat\":\"undefined\",\"value\":\"4-1-3\"}}}");
for (Map.Entry fileEntry : jsonObject.entrySet()) {
JSONObject fieldObject = (JSONObject) fileEntry.getValue();
}
}
@Override
public Object process(Context context, Map map) throws EASBizException, BOSException {
String mack = (String) map.get("mack");
String data = (String) map.get("data");
Map resul = Maps.newHashMap();
try {
JSONObject jsonObject = JSON.parseObject(data);
if ("preview".equals(mack)) {
EsignHttpResponse response = this.previewFile(context, jsonObject, "预览");
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 {
Map signMap = Maps.newHashMap();
String sourceId = jsonObject.getString("sourceId");
String signFlowTitle = jsonObject.getString("signFlowTitle");
//文件
JSONObject templateInfo = jsonObject.getJSONObject("templateInfo");
//设置待签署文件信息
List