|
|
@@ -6,11 +6,14 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.impl.client.LaxRedirectStrategy;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
@@ -86,6 +89,16 @@ public class PortalOaFlow {
|
|
|
@Autowired
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
+ // ==================== 新增:每次使用【全新的、无Cookie】的RestTemplate ====================
|
|
|
+ private RestTemplate getNewRestTemplateWithoutCookie() {
|
|
|
+ return new RestTemplate(new HttpComponentsClientHttpRequestFactory(
|
|
|
+ HttpClients.custom()
|
|
|
+ .disableCookieManagement() // 彻底禁用Cookie,不保存、不携带
|
|
|
+ .setRedirectStrategy(new LaxRedirectStrategy())
|
|
|
+ .build()
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
public ImmutableMap<String, Object> getOaTodo(String oaId) throws Exception {
|
|
|
String token = getToken();
|
|
|
|
|
|
@@ -95,24 +108,38 @@ public class PortalOaFlow {
|
|
|
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);
|
|
|
params.put("pageSize", 20);
|
|
|
params.put("pageNo", 1);
|
|
|
- System.out.println(JSON.toJSONString(params));
|
|
|
+
|
|
|
HttpEntity<Map<String, Object>> requestEntityOut = new HttpEntity<>(params, headersOut);
|
|
|
- //待办数量
|
|
|
- String out = restTemplate.postForObject("https://yfoa.keruioil.com/api/workflow/paService/getDoingWorkflowRequestCount", requestEntityOut, String.class);
|
|
|
- //待办明细
|
|
|
+
|
|
|
+ // ==================== 关键:每次都用全新无Cookie的RestTemplate ====================
|
|
|
+ RestTemplate noCookieRestTemplate = getNewRestTemplateWithoutCookie();
|
|
|
+
|
|
|
+ // 待办数量
|
|
|
+ String out = noCookieRestTemplate.postForObject(
|
|
|
+ "https://yfoa.keruioil.com/api/workflow/paService/getDoingWorkflowRequestCount",
|
|
|
+ requestEntityOut, String.class
|
|
|
+ );
|
|
|
+
|
|
|
+ // 待办明细
|
|
|
map.put("root", ImmutableMap.of("craterid", oaId));
|
|
|
params.put("conditions", map);
|
|
|
HttpEntity<Map<String, Object>> requestEntityOut1 = new HttpEntity<>(params, headersOut);
|
|
|
- String todoList = restTemplate.postForObject("https://yfoa.keruioil.com/api/workflow/paService/getDoingWorkflowRequestList", requestEntityOut1, String.class);
|
|
|
+
|
|
|
+ String todoList = noCookieRestTemplate.postForObject(
|
|
|
+ "https://yfoa.keruioil.com/api/workflow/paService/getDoingWorkflowRequestList",
|
|
|
+ requestEntityOut1, String.class
|
|
|
+ );
|
|
|
+
|
|
|
List<JSONObject> jsonObjects = JSON.parseArray(todoList, JSONObject.class);
|
|
|
- ImmutableMap<String, Object> todo = ImmutableMap.of("todoCount", out,"todoList", jsonObjects);
|
|
|
- return todo;
|
|
|
+ return ImmutableMap.of("todoCount", out, "todoList", jsonObjects);
|
|
|
}
|
|
|
|
|
|
}
|