|
@@ -18,8 +18,13 @@ import com.dingtalk.api.response.OapiUserListidResponse;
|
|
|
import com.dingtalk.api.response.OapiV2DepartmentListsubidResponse;
|
|
|
import com.dingtalk.api.response.OapiV2UserGetResponse;
|
|
|
import com.malk.pro.zyjn.service.TongbuService;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
import com.malk.server.common.McR;
|
|
|
+import com.malk.server.dingtalk.DDR_New;
|
|
|
import com.malk.service.dingtalk.DDClient;
|
|
|
+import com.malk.utils.UtilHttp;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
import com.taobao.api.ApiException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import okhttp3.*;
|
|
@@ -31,6 +36,9 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.Instant;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static com.malk.utils.UtilMc.distinctByKey;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -720,4 +728,48 @@ public class TongbuServiceImpl implements TongbuService {
|
|
|
|
|
|
return McR.success("删除钉钉日程成功!");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR getUsersDepts(List<String> userIds) {
|
|
|
+ List<Map<String,String>> deptList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String userId : userIds) {
|
|
|
+ Map<String,Object> param = new HashMap();
|
|
|
+ param.put("access_token",getAccessToken());
|
|
|
+
|
|
|
+ //查询用户详情
|
|
|
+ DDR_New deptDDR = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/user/get", null, param, UtilMap.map("userid", userId), DDR_New.class);
|
|
|
+
|
|
|
+ if (Objects.isNull(deptDDR.getResult())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map result = (Map) deptDDR.getResult();
|
|
|
+
|
|
|
+ List<Integer> deptIdList = (List<Integer>) result.get("dept_id_list");
|
|
|
+
|
|
|
+ Integer deptId = deptIdList.get(0);
|
|
|
+
|
|
|
+ //查询部门详情
|
|
|
+ DDR_New deptDDR2 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/department/get", null, param, UtilMap.map("dept_id", deptId), DDR_New.class);
|
|
|
+
|
|
|
+ Map result2 = (Map) deptDDR2.getResult();
|
|
|
+
|
|
|
+ if (Objects.nonNull(result2)){
|
|
|
+ String deptName = result2.get("name").toString();
|
|
|
+
|
|
|
+ Map<String,String> dept = new HashMap<>();
|
|
|
+ dept.put("text",deptName);
|
|
|
+ dept.put("value",deptId+"");
|
|
|
+
|
|
|
+ deptList.add(dept);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //deptList根据dept的value去重
|
|
|
+ List<Map<String, String>> uniqueDeptList = deptList.stream()
|
|
|
+ .filter(distinctByKey(m -> m.get("value")))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return McR.success(uniqueDeptList);
|
|
|
+ }
|
|
|
}
|