import com.alibaba.fastjson.TypeReference;
|
import com.changhong.epc.rely.api.tool.HttpUtil;
|
import com.iemsoft.framework.cloud.core.password.MD5;
|
import com.iemsoft.framework.cloud.core.tools.JSONTool;
|
import lombok.Data;
|
import org.springframework.ui.ModelMap;
|
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.Map;
|
import java.util.Random;
|
import java.util.TreeMap;
|
|
public class UbpTest {
|
|
public static final String id = "1185510";
|
|
public static final String sign = "4cf38be3bf9a4902b957a7352736719b";
|
|
public static void main(String[] args) throws Exception{
|
|
Map<String, Object> param = new TreeMap<>();
|
Map<String, Object> loginParam = new TreeMap<>();
|
|
LoginSecurity ls =new LoginSecurity();
|
|
ls.setOpenId("893ccd52f0ec4eae");
|
// {"companyId":355,"openId":"f4a3d8fa90f64b78","serviceId":24,"tenantId":100000339}
|
ls.setTenantId(100000308);
|
ls.setCompanyId(294);
|
ls.setServiceId(86);
|
|
// ls.setAppKey("41d6665398db40b8855f893f27b5af4c");
|
// ls.setAccessId("6743651");
|
|
// loginParam.put("loginSecurity", JSONTool.toJson(ls));
|
loginParam.put("loginSecurity", "{\"serviceId\":\"86\",\"tenantId\":\"100000308\",\"openId\":\"893ccd52f0ec4eae\",\"companyId\":\"294\"}");
|
|
// Map<String, Object> data = new ModelMap();
|
// data.put("processDefName", "6754e0b453d848a3aa8297ecfae5f746");
|
// data.put("processDefId", "522");
|
// data.put("processInstName", UUID.randomUUID().toString().replace("-", ""));
|
|
// data.put("dataType", 40);
|
// data.put("openId", "893ccd52f0ec4eae");
|
// data.put("pageNum", 1);
|
// data.put("pageSize", 5);
|
// data.put("tenantId", "14");
|
// data.put("companyId", "3");
|
// data.put("serviceId", "10");
|
|
// param.put("data", JSONTool.toJson(
|
// new ModelMap("serviceId", ls.getServiceId())
|
// .addAttribute("tenantId", ls.getTenantId())
|
// .addAttribute("companyId", ls.getCompanyId())
|
// )
|
// );
|
param.put("data", "{\"formID\":\"682eb6309acdc42f\",\"tenantID\":\"100000308\",\"processChName\":\"test\"}");
|
|
try {
|
String value = HttpUtil.post(
|
// "http://chworkflow.chfcloud.com/ubp/ubp-api-control/process/rest/check"
|
// "http://chworkflow.chfcloud.com/ubp/ubp-api-control/process/rest/initialization"
|
"http://chworkflow.chfcloud.com/ubp/ubp-api-control/process/def/create"
|
// "http://chworkflow.chfcloud.com/ubp/ubp-api-seache/process/inst/seache"
|
// "http://ubpyq.chfcloud.com:8087/ubp/ubp-api-seache/process/inst/seache/handle"
|
, null, get(param,loginParam)
|
, null, new TypeReference<String>(){}.getType());
|
System.err.println(value);
|
} catch (Exception e) {
|
}
|
}
|
|
public static Map<String, Object> get(Map<String, Object> data ,Map<String, Object> loginSercity){
|
data.putAll(data);
|
data.putAll(loginSercity);
|
return getParam(data);
|
}
|
|
public static Map<String, Object> getParam(Map<String, Object> data){
|
Map<String, Object> param = new TreeMap<>(data);
|
param.put("id", id + new SimpleDateFormat("yyyyMMdd").format(new Date()) + String.format("%09d", new Random().nextInt(999999999)));
|
param.put("sign", countSign(param));
|
return param;
|
}
|
|
public static String countSign(Map<String, Object> param) {
|
StringBuilder sb = new StringBuilder();
|
for (Map.Entry<String, Object> map : param.entrySet()) {
|
/* 拼接条件 */
|
sb.append(map.getKey())
|
.append('=')
|
.append(map.getValue())
|
.append('&');
|
}
|
//fccbc9f3815341bf8fdbfec79351a928
|
//1dce3f25908b4aa3ba85bbe68eeb42bb
|
//5392b72e7a764142ac7b99400f4097e0
|
sb.append("key=").append(sign);
|
System.out.println(sb);
|
return MD5.toMD5(sb.toString());
|
}
|
|
@Data
|
public static class LoginSecurity{
|
|
private String appKey;
|
|
private String token;
|
|
private Integer tenantId;
|
|
private Integer companyId;
|
|
private String openId;
|
|
private Integer appId;
|
|
private Integer parentAppId;
|
|
private Integer serviceId;
|
|
private String accessId;
|
|
private ServiceApp serviceApp;
|
|
}
|
|
@Data
|
public static class ServiceApp{
|
|
/**
|
* 组织机构获取途径
|
*/
|
private String isLocalOrganization;
|
/**
|
* 组织机构获取路径
|
*/
|
private String organizationUrl;
|
/**
|
* 业务系统加密key
|
*/
|
private String securityKey;
|
/**
|
* 业务系统id
|
*/
|
private String accessId;
|
}
|
}
|