package cn.autoform.web.client.util; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; import java.util.Objects; import java.util.Random; import java.util.TreeMap; import org.springframework.stereotype.Service; import cn.autoform.db.exten.Process; import cn.autoform.util.thread.Keys; import cn.autoform.util.thread.ThreadData; import cn.autoform.util.tool.JSONTool; import net.sf.json.JSONObject; @Service public class WorkflowTwe { //请求参数 public static Map getParam(Map data){ Map param = new TreeMap<>(data); param.put("id", "1289899" + new SimpleDateFormat("yyyyMMdd").format(new Date()) + String.format("%09d", new Random().nextInt(999999999))); param.put("sign", countSign(param)); return param; } public Process getProcess(JSONObject jsonObjects){ @SuppressWarnings("unchecked") Map JsonObject = JSONTool.toObj(JSONTool.toJson(jsonObjects),Map.class); Map param = new TreeMap<>(); Map loginParam = new TreeMap<>(); Map data = new TreeMap<>(); param.put("data", JSONTool.toJson(jsonObjects)); loginParam.put("loginSecurity",getLogInSecurity()); data.putAll(param); data.putAll(loginParam); System.err.println(); Process pro = new Process(); pro.setFormID(JsonObject.get("formID")); System.out.println("进入粗"); pro.setTenantID(Objects.toString(JsonObject.get("tenantID"),null)); pro.setFlowmap(getParam(data)); return pro; } public String getLogInSecurity(){ String token = ThreadData.get(Keys.TOKEN); String openId = ThreadData.get(Keys.OPEN_ID); String accessId = "8080067"; String appKey = "49074c3e9bc94105a5eed868ded3eb9d"; return "{\"token\":\"" + token + "\",\"appKey\":\"" + appKey + "\",\"accessId\":\"" + accessId + "\",\"openId\":\"" + openId + "\"}"; } //取出Sign public static String countSign(Map param) { StringBuilder sb = new StringBuilder(); for (Map.Entry map : param.entrySet()) { /* 拼接条件 */ sb.append(map.getKey()) .append('=') .append(map.getValue()) .append('&'); } sb.append("key=").append("eb5e293a974642eaa28312a14a71b2b1"); System.out.println(sb); return MD5.GetMD5Code(sb.toString().replaceAll(" ","")); } }