zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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;
    }
}