|
|
@@ -48,6 +48,10 @@ public class PortalOaFlow {
|
|
|
private String registerUrl;
|
|
|
@Value("${oa.gettoken}")
|
|
|
private String tokenUrl;
|
|
|
+ @Value("${oa.spk}")
|
|
|
+ private String spk;
|
|
|
+ @Value("${oa.secrit}")
|
|
|
+ private String secrit;
|
|
|
|
|
|
private static final Map<String,String> SYSTEM_CACHE = new HashMap <>();
|
|
|
|
|
|
@@ -90,7 +94,7 @@ public class PortalOaFlow {
|
|
|
//调用ECOLOGY系统接口进行注册
|
|
|
String data = HttpRequest.post(address + "/api/ec/dev/auth/regist")
|
|
|
.header("appid", "TW")
|
|
|
- .header("cpk",publicKey)
|
|
|
+ .header("cpk","MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApmtQUp9M82/z22P7am5owQCknjQnjF4U4ckEh7XVtJVQZrZx7d1lCPfoYrwOKEM4DEV7khW6++4Zv5caJ/9nqPn4QFwCqJWVmCEm9vC1BA6i2yfa4bmTxdR1/oeU/Af9pDFlvv5GC9XyilO7CIKu19Ce50v7aN6h1Tjix+h5Ba8e12XAEpEZk9pFroEYfR4lrecvi1pQOwRw8YzDRC4lhGNOo5Cen1rGjk7dwzzgs4uEv9ZyPZoVJnty5P9JE/ctboEf3x4jbqIliuCRgOyXYsLlp+N282CKcWZ35URkGw2orKyG1U6L1hNoj7kkpvAo8Zagf97SdZ0nYdRBIHv6PQIDAQAB")
|
|
|
.timeout(2000)
|
|
|
.disableCookie()
|
|
|
.execute().body();
|
|
|
@@ -104,21 +108,23 @@ public class PortalOaFlow {
|
|
|
return datas;
|
|
|
}
|
|
|
|
|
|
- public static Map<String,Object> testGetoken(String address){
|
|
|
+ public Map<String,Object> testGetoken(String address){
|
|
|
// 从系统缓存或者数据库中获取ECOLOGY系统公钥和Secret信息
|
|
|
- String secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
|
|
- String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
+// String secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
|
|
+// String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
// 如果为空,说明还未进行注册,调用注册接口进行注册认证与数据更新
|
|
|
- if (Objects.isNull(secret)||Objects.isNull(spk)){
|
|
|
+// if (Objects.isNull(secret)||Objects.isNull(spk)){
|
|
|
testRegist(address);
|
|
|
- // 重新获取最新ECOLOGY系统公钥和Secret信息
|
|
|
- secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
|
|
- spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
- }
|
|
|
+// // 重新获取最新ECOLOGY系统公钥和Secret信息
|
|
|
+// secret = SYSTEM_CACHE.get("SERVER_SECRET");
|
|
|
+// spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
+// }
|
|
|
+ String secrett = SYSTEM_CACHE.get("SERVER_SECRET");
|
|
|
+ String spkk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
// 公钥加密,所以RSA对象私钥为null
|
|
|
- RSA rsa = new RSA(null,spk);
|
|
|
+ RSA rsa = new RSA(null,spkk);
|
|
|
//对秘钥进行加密传输,防止篡改数据
|
|
|
- String encryptSecret = rsa.encryptBase64(secret, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
|
|
+ String encryptSecret = rsa.encryptBase64(secrett, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
|
|
//调用ECOLOGY系统接口进行注册
|
|
|
String data = HttpRequest.post(address+ "/api/ec/dev/auth/applytoken")
|
|
|
.header("appid","TW")
|
|
|
@@ -134,29 +140,44 @@ public class PortalOaFlow {
|
|
|
return datas;
|
|
|
}
|
|
|
|
|
|
- public static String testRestful(String address,String api,String jsonParams, String userid){
|
|
|
+ public String testRestful(String address,String api,String jsonParams, String userid){
|
|
|
//ECOLOGY返回的token
|
|
|
String token= SYSTEM_CACHE.get("SERVER_TOKEN");
|
|
|
// if (StrUtil.isEmpty(token)){
|
|
|
token = (String) testGetoken(address).get("token");
|
|
|
// }
|
|
|
- String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
+// String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
//封装请求头参数
|
|
|
- RSA rsa = new RSA(null,spk);
|
|
|
+ String secrett = SYSTEM_CACHE.get("SERVER_SECRET");
|
|
|
+ String spkk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
+ RSA rsa = new RSA(null,spkk);
|
|
|
//对用户信息进行加密传输,暂仅支持传输OA用户ID
|
|
|
String encryptUserid = rsa.encryptBase64(userid,CharsetUtil.CHARSET_UTF_8,KeyType.PublicKey);
|
|
|
//调用ECOLOGY系统接口,注意此处的disableCookie,可翻阅hutool的文档查看
|
|
|
+
|
|
|
+ System.out.println("======================"+token);
|
|
|
+ System.out.println("======================"+encryptUserid);
|
|
|
String data = HttpRequest
|
|
|
.post(address + api).disableCookie()
|
|
|
.header("appid","TW")
|
|
|
.header("token",token)
|
|
|
.header("userid",encryptUserid)
|
|
|
- .body(jsonParams)
|
|
|
+ .body(jsonParams).contentType("application/json")
|
|
|
.execute().body();
|
|
|
System.out.println("testRestful():"+data);
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ public String testRestfulNoHeader(String address,String api,String jsonParams, String userid){
|
|
|
+ //ECOLOGY返回的token
|
|
|
+
|
|
|
+ String data = HttpRequest
|
|
|
+ .post(address + api).disableCookie()
|
|
|
+ .body(jsonParams)
|
|
|
+ .execute().body();
|
|
|
+ System.out.println("testRestful():"+data);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
|
|
|
// public void register() throws Exception{
|
|
|
// HttpHeaders headers = new HttpHeaders();
|
|
|
@@ -201,61 +222,30 @@ public class PortalOaFlow {
|
|
|
// }
|
|
|
|
|
|
public ImmutableMap<String, Object> getOaTodo(String oaId, Integer pageNo ,Integer pageSize) throws Exception {
|
|
|
-// String token = getToken();
|
|
|
-// String spk = SYSTEM_CACHE.get("SERVER_PUBLIC_KEY");
|
|
|
+ return ImmutableMap.of("todoCount", 0 , "todoList", new ArrayList<>(),"doneCount", 0,"doneList", new ArrayList<>());
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// map.put("root", ImmutableMap.of("createrid", oaId));
|
|
|
+// params.put("conditions", map);
|
|
|
//
|
|
|
-// HttpHeaders headersOut = new HttpHeaders();
|
|
|
-// headersOut.add("token", token);
|
|
|
-// headersOut.add("appid", appid);
|
|
|
-// String person = E9ApiTokenUtil.encryptString(spk, oaId);
|
|
|
-// headersOut.add("userid", person);
|
|
|
-// headersOut.setContentType(MediaType.APPLICATION_JSON);
|
|
|
-// headersOut.remove(HttpHeaders.COOKIE); // 保险清空
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("root", ImmutableMap.of("createrid", oaId));
|
|
|
- params.put("conditions", map);
|
|
|
-
|
|
|
-// HttpEntity<Map<String, Object>> requestEntityOut = new HttpEntity<>(params, headersOut);
|
|
|
-
|
|
|
- // ==================== 关键:每次都用全新无Cookie的RestTemplate ====================
|
|
|
-// RestTemplate noCookieRestTemplate = getNewRestTemplateWithoutCookie();
|
|
|
+// String out = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getDoingWorkflowRequestCount", JSON.toJSONString(params), oaId);
|
|
|
+// String done = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getHandledWorkflowRequestCount", JSON.toJSONString(params), oaId);
|
|
|
+// map.put("root", ImmutableMap.of("craterid", oaId,"isdebug", "true"));
|
|
|
+// params.put("conditions", map);
|
|
|
+// System.out.println("-----------"+JSON.toJSONString(params));
|
|
|
//
|
|
|
-// // 待办数量
|
|
|
-// String out = noCookieRestTemplate.postForObject(
|
|
|
-// "https://yfoa.keruioil.com/api/workflow/paService/getDoingWorkflowRequestCount",
|
|
|
-// requestEntityOut, String.class
|
|
|
-// );
|
|
|
- String out = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getDoingWorkflowRequestCount", JSON.toJSONString(params), oaId);
|
|
|
- //已办数量
|
|
|
-// String done = noCookieRestTemplate.postForObject("https://yfoa.keruioil.com/api/workflow/paService/getHandledWorkflowRequestCount", requestEntityOut, String.class);
|
|
|
- String done = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getHandledWorkflowRequestCount", JSON.toJSONString(params), oaId);
|
|
|
- map.put("root", ImmutableMap.of("craterid", oaId,"isdebug", "true"));
|
|
|
- params.put("conditions", map);
|
|
|
-// params.put("pageSize", pageSize);
|
|
|
-// params.put("pageNo", pageNo);
|
|
|
- System.out.println("-----------"+JSON.toJSONString(params));
|
|
|
-// HttpEntity<Map<String, Object>> requestEntityOut1 = new HttpEntity<>(params, headersOut);
|
|
|
- // 待办明细
|
|
|
-// String todoList = noCookieRestTemplate.postForObject(
|
|
|
-// "https://yfoa.keruioil.com/api/workflow/paService/getDoingWorkflowRequestList?pageNo="+pageNo+"&pageSize="+pageSize,
|
|
|
-// requestEntityOut1, String.class
|
|
|
-// );
|
|
|
-
|
|
|
- String todoList = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getDoingWorkflowRequestList?pageNo="+pageNo+"&pageSize="+pageSize, JSON.toJSONString(params), oaId);
|
|
|
- List<JSONObject> jsonObjects = new ArrayList<>();
|
|
|
- if (todoList != null && !todoList.contains("token不存在或者超时")) {
|
|
|
- jsonObjects = JSON.parseArray(todoList, JSONObject.class);
|
|
|
- }
|
|
|
- //已办明细
|
|
|
-// String doneList = noCookieRestTemplate.postForObject("https://yfoa.keruioil.com/api/workflow/paService/getHandledWorkflowRequestList?pageNo="+pageNo+"&pageSize="+pageSize, requestEntityOut1, String.class);
|
|
|
- String doneList = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getHandledWorkflowRequestList?pageNo="+pageNo+"&pageSize="+pageSize, JSON.toJSONString(params), oaId);
|
|
|
- List<JSONObject> doneJsonObjects = new ArrayList<>();
|
|
|
- if (todoList != null && !todoList.contains("token不存在或者超时")) {
|
|
|
- doneJsonObjects = JSON.parseArray(doneList, JSONObject.class);
|
|
|
- }
|
|
|
- return ImmutableMap.of("todoCount", NumberUtil.isNumber(out)?out:0 , "todoList", jsonObjects,"doneCount", NumberUtil.isNumber(done)?done : 0,"doneList", doneJsonObjects);
|
|
|
+// String todoList = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getDoingWorkflowRequestList?pageNo="+pageNo+"&pageSize="+pageSize, JSON.toJSONString(params), oaId);
|
|
|
+// List<JSONObject> jsonObjects = new ArrayList<>();
|
|
|
+// if (todoList != null && !todoList.contains("token不存在或者超时")) {
|
|
|
+// jsonObjects = JSON.parseArray(todoList, JSONObject.class);
|
|
|
+// }
|
|
|
+// //已办明细
|
|
|
+// String doneList = testRestful("https://yfoa.keruioil.com", "/api/workflow/paService/getHandledWorkflowRequestList?pageNo="+pageNo+"&pageSize="+pageSize, JSON.toJSONString(params), oaId);
|
|
|
+// List<JSONObject> doneJsonObjects = new ArrayList<>();
|
|
|
+// if (todoList != null && !todoList.contains("token不存在或者超时")) {
|
|
|
+// doneJsonObjects = JSON.parseArray(doneList, JSONObject.class);
|
|
|
+// }
|
|
|
+// return ImmutableMap.of("todoCount", NumberUtil.isNumber(out)?out:0 , "todoList", jsonObjects,"doneCount", NumberUtil.isNumber(done)?done : 0,"doneList", doneJsonObjects);
|
|
|
}
|
|
|
|
|
|
public List getOaNotice(String oaId, OaNoticeDO oaNoticeDO, String workcode) throws Exception {
|
|
|
@@ -293,8 +283,9 @@ public class PortalOaFlow {
|
|
|
//消息通知
|
|
|
String out = null;
|
|
|
try {
|
|
|
+ System.out.println("---------------"+JSON.toJSONString(params));
|
|
|
// out = noCookieRestTemplate.postForObject("https://yfoa.keruioil.com/api/msgDataInfo/flow/get", requestEntityOut, String.class);
|
|
|
- out = testRestful("https://yfoa.keruioil.com", "/api/msgDataInfo/flow/get", JSON.toJSONString(params), oaId);
|
|
|
+ out = testRestfulNoHeader("https://yfoa.keruioil.com", "/api/msgDataInfo/flow/get", JSON.toJSONString(params), oaId);
|
|
|
|
|
|
} catch (RestClientException e) {
|
|
|
throw new ServiceException(new ErrorCode(1,"获取OA消息通知信息失败"));
|