|
@@ -1,10 +1,17 @@
|
|
|
package cn.iocoder.yudao.server.service;
|
|
package cn.iocoder.yudao.server.service;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
|
import cn.iocoder.yudao.module.system.oa.E9ApiTokenUtil;
|
|
import cn.iocoder.yudao.module.system.oa.E9ApiTokenUtil;
|
|
|
import cn.iocoder.yudao.module.system.oa.SslSkippingRestTemplate;
|
|
import cn.iocoder.yudao.module.system.oa.SslSkippingRestTemplate;
|
|
|
|
|
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
|
|
|
|
|
+import cn.iocoder.yudao.server.dal.mysql.OaNoticeMapper;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
|
+import lombok.Data;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.impl.client.LaxRedirectStrategy;
|
|
import org.apache.http.impl.client.LaxRedirectStrategy;
|
|
@@ -16,12 +23,11 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
+import org.springframework.web.client.RestClientException;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
|
public class PortalOaFlow {
|
|
public class PortalOaFlow {
|
|
@@ -48,7 +54,7 @@ public class PortalOaFlow {
|
|
|
|
|
|
|
|
private static String spk = "";
|
|
private static String spk = "";
|
|
|
private static String secret = "";
|
|
private static String secret = "";
|
|
|
-
|
|
|
|
|
|
|
+ private OaNoticeMapper oaNoticeMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
public void register() throws Exception{
|
|
public void register() throws Exception{
|
|
@@ -150,5 +156,58 @@ public class PortalOaFlow {
|
|
|
return ImmutableMap.of("todoCount", out, "todoList", jsonObjects,"doneCount", done,"doneList", doneJsonObjects);
|
|
return ImmutableMap.of("todoCount", out, "todoList", jsonObjects,"doneCount", done,"doneList", doneJsonObjects);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public List getOaNotice(String oaId, OaNoticeDO oaNoticeDO, String workcode) throws Exception {
|
|
|
|
|
+ String token = getToken();
|
|
|
|
|
+
|
|
|
|
|
+ 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<>();
|
|
|
|
|
+ params.put("userId", oaId);
|
|
|
|
|
+ if (oaNoticeDO != null) {
|
|
|
|
|
+ params.put("dateTime", oaNoticeDO.getOaCreateTime());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ HttpEntity<Map<String, Object>> requestEntityOut = new HttpEntity<>(params, headersOut);
|
|
|
|
|
|
|
|
|
|
+ RestTemplate noCookieRestTemplate = getNewRestTemplateWithoutCookie();
|
|
|
|
|
+ //消息通知
|
|
|
|
|
+ JSONObject out = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ out = noCookieRestTemplate.postForObject(
|
|
|
|
|
+ "https://yfoa.keruioil.com/api/msgDataInfo/flow/get", requestEntityOut, JSONObject.class
|
|
|
|
|
+ );
|
|
|
|
|
+ } catch (RestClientException e) {
|
|
|
|
|
+ throw new ServiceException(new ErrorCode(1,"获取OA消息通知信息失败"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Objects.isNull(out)) {return new ArrayList();}
|
|
|
|
|
+ //查询的某个日期后面的未读消息中心
|
|
|
|
|
+ String data1 = out.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.setOaCreator(e.getCreator());
|
|
|
|
|
+ oaNoticeDO1.setDeleted(false);
|
|
|
|
|
+ oaNoticeDO1.setWorkCode(workcode);
|
|
|
|
|
+ return oaNoticeDO1;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ oaNoticeMapper.insertBatch(collect);
|
|
|
|
|
+ return oaNoticeDOS;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Data
|
|
|
|
|
+ static class OaNoticeVo{
|
|
|
|
|
+ private String creator;
|
|
|
|
|
+ private String createTime;
|
|
|
|
|
+ private String creatorName;
|
|
|
|
|
+ private String title;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|