|
|
@@ -54,6 +54,7 @@ public class PortalOaFlow {
|
|
|
|
|
|
private static String spk = "";
|
|
|
private static String secret = "";
|
|
|
+ @Autowired
|
|
|
private OaNoticeMapper oaNoticeMapper;
|
|
|
|
|
|
|
|
|
@@ -97,12 +98,24 @@ public class PortalOaFlow {
|
|
|
|
|
|
// ==================== 新增:每次使用【全新的、无Cookie】的RestTemplate ====================
|
|
|
private RestTemplate getNewRestTemplateWithoutCookie() {
|
|
|
- return new RestTemplate(new HttpComponentsClientHttpRequestFactory(
|
|
|
+// return new RestTemplate(new HttpComponentsClientHttpRequestFactory(
|
|
|
+// HttpClients.custom()
|
|
|
+// .disableCookieManagement() // 彻底禁用Cookie,不保存、不携带
|
|
|
+// .setRedirectStrategy(new LaxRedirectStrategy())
|
|
|
+// .build()
|
|
|
+// ));
|
|
|
+ RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(
|
|
|
HttpClients.custom()
|
|
|
- .disableCookieManagement() // 彻底禁用Cookie,不保存、不携带
|
|
|
+ .disableCookieManagement() // 彻底禁用Cookie
|
|
|
.setRedirectStrategy(new LaxRedirectStrategy())
|
|
|
.build()
|
|
|
));
|
|
|
+ // 关键:强制响应编码为 UTF-8
|
|
|
+ restTemplate.getMessageConverters().stream()
|
|
|
+ .filter(converter -> converter instanceof org.springframework.http.converter.StringHttpMessageConverter)
|
|
|
+ .forEach(converter -> ((org.springframework.http.converter.StringHttpMessageConverter) converter)
|
|
|
+ .setDefaultCharset(java.nio.charset.StandardCharsets.UTF_8));
|
|
|
+ return restTemplate;
|
|
|
}
|
|
|
|
|
|
public ImmutableMap<String, Object> getOaTodo(String oaId, Integer pageNo ,Integer pageSize) throws Exception {
|
|
|
@@ -167,6 +180,9 @@ public class PortalOaFlow {
|
|
|
headersOut.setContentType(MediaType.APPLICATION_JSON);
|
|
|
headersOut.remove(HttpHeaders.COOKIE); // 保险清空
|
|
|
|
|
|
+ headersOut.setAcceptCharset(Collections.singletonList(java.nio.charset.StandardCharsets.UTF_8));
|
|
|
+ headersOut.add(HttpHeaders.ACCEPT, "application/json;charset=UTF-8");
|
|
|
+
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("userId", oaId);
|
|
|
if (oaNoticeDO != null) {
|
|
|
@@ -177,25 +193,27 @@ public class PortalOaFlow {
|
|
|
|
|
|
RestTemplate noCookieRestTemplate = getNewRestTemplateWithoutCookie();
|
|
|
//消息通知
|
|
|
- JSONObject out = null;
|
|
|
+ String out = null;
|
|
|
try {
|
|
|
- out = noCookieRestTemplate.postForObject(
|
|
|
- "https://yfoa.keruioil.com/api/msgDataInfo/flow/get", requestEntityOut, JSONObject.class
|
|
|
- );
|
|
|
+ out = noCookieRestTemplate.postForObject("https://yfoa.keruioil.com/api/msgDataInfo/flow/get", requestEntityOut, String.class);
|
|
|
} catch (RestClientException e) {
|
|
|
throw new ServiceException(new ErrorCode(1,"获取OA消息通知信息失败"));
|
|
|
}
|
|
|
- if (Objects.isNull(out)) {return new ArrayList();}
|
|
|
+ if (Objects.isNull(out)||StringUtils.isBlank(out)) {return new ArrayList();}
|
|
|
+ JSONObject out1 = JSON.parseObject(out);
|
|
|
//查询的某个日期后面的未读消息中心
|
|
|
- String data1 = out.getString("data");
|
|
|
+ String data1 = out1.getString("data");
|
|
|
List<OaNoticeVo> oaNoticeDOS = JSON.parseArray(data1, OaNoticeVo.class);
|
|
|
if (CollUtil.isEmpty(oaNoticeDOS)) {return new ArrayList();}
|
|
|
List<OaNoticeDO> collect = oaNoticeDOS.stream().map(e -> {
|
|
|
OaNoticeDO oaNoticeDO1 = new OaNoticeDO();
|
|
|
oaNoticeDO1.setOaCreateName(e.getCreatorName());
|
|
|
oaNoticeDO1.setOaCreateTime(e.getCreateTime());
|
|
|
+ oaNoticeDO1.setTitle(e.getTitle());
|
|
|
oaNoticeDO1.setOaCreator(e.getCreator());
|
|
|
oaNoticeDO1.setDeleted(false);
|
|
|
+ //未读
|
|
|
+ oaNoticeDO1.setStatus("0");
|
|
|
oaNoticeDO1.setWorkCode(workcode);
|
|
|
return oaNoticeDO1;
|
|
|
}).collect(Collectors.toList());
|