|
@@ -99,7 +99,7 @@ public class TongbuServiceImpl implements TongbuService {
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
|
|
|
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
|
|
|
req.setUserid(userId);
|
|
|
- OapiV2UserGetResponse rsp = client.execute(req, getAccessToken());
|
|
|
+ OapiV2UserGetResponse rsp = client.execute(req, ddClient.getAccessToken());
|
|
|
// System.out.println(rsp.getBody());
|
|
|
String body = rsp.getBody();
|
|
|
//通过fastjson工具转换成json对象,逐层解析
|
|
@@ -829,4 +829,76 @@ public class TongbuServiceImpl implements TongbuService {
|
|
|
|
|
|
return McR.success(ddrNew);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public McR updateRicheng(Map map) {
|
|
|
+ String formInstId = UtilMap.getString(map, "formInstId");
|
|
|
+ String dept = UtilMap.getString(map, "dept");
|
|
|
+
|
|
|
+ Map formData = ydClient.queryData(YDParam.builder()
|
|
|
+ .formInstId(formInstId)
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+
|
|
|
+ //获取各部门参会人
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+
|
|
|
+ switch (dept){
|
|
|
+ case "信息技术科": userIds = UtilMap.getList(formData,"employeeField_m99dcmr0_id");break;
|
|
|
+ case "研发管理科": userIds = UtilMap.getList(formData,"employeeField_m99dcmr1_id");break;
|
|
|
+ case "竞赛管理科": userIds = UtilMap.getList(formData,"employeeField_m99dcmr4_id");break;
|
|
|
+ case "综合办公室": userIds = UtilMap.getList(formData,"employeeField_m99dcmr5_id");break;
|
|
|
+ case "考务管理科": userIds = UtilMap.getList(formData,"employeeField_m99dcmr6_id");break;
|
|
|
+ case "财务科": userIds = UtilMap.getList(formData,"employeeField_m99dcmr2_id");break;
|
|
|
+ case "质量督导科": userIds = UtilMap.getList(formData,"employeeField_m99dcmr7_id");break;
|
|
|
+ case "题库管理科": userIds = UtilMap.getList(formData,"employeeField_m99dcmr8_id");break;
|
|
|
+ case "系统实施": userIds = UtilMap.getList(formData,"employeeField_mc4mc2vw_id");break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取日程参与者
|
|
|
+ String scheduleId = UtilMap.getString(formData, "textField_m54zg5b1");//日程id
|
|
|
+ String userId = UtilMap.getString(formData, "textField_m54zg5b0");//发起人
|
|
|
+ String unionId = getUnionId(userId);//发起人unionId
|
|
|
+ String jsonString = UtilHttp.doGet("https://api.dingtalk.com/v1.0/calendar/users/" + unionId + "/calendars/primary/events/" + scheduleId + "/attendees", ddClient.initTokenHeader(), new HashMap<>());
|
|
|
+
|
|
|
+ Map result = (Map) JSONObject.parse(jsonString);
|
|
|
+
|
|
|
+ //原参会人列表
|
|
|
+ List<Map> attendees = UtilMap.getList(result, "attendees");
|
|
|
+
|
|
|
+ List<Map> attendeesToAdd = new ArrayList<>();
|
|
|
+
|
|
|
+ //添加当前部门参会人
|
|
|
+ for (String userId2 : userIds) {
|
|
|
+ Map attendee = new HashMap();
|
|
|
+
|
|
|
+ String unionId2 = getUnionId(userId2);
|
|
|
+
|
|
|
+ //参会人是否存在
|
|
|
+ boolean isExists = attendees.stream().anyMatch(item -> unionId2.equals(UtilMap.getString(item,"id")));
|
|
|
+
|
|
|
+ if (!isExists){
|
|
|
+ attendee.put("id",unionId2);//参会人unionId
|
|
|
+ attendee.put("isOptional",true);//是否为可选参与人
|
|
|
+
|
|
|
+ attendeesToAdd.add(attendee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加日程参会人
|
|
|
+ if (!attendeesToAdd.isEmpty()){
|
|
|
+ Map body = new HashMap();
|
|
|
+
|
|
|
+ body.put("attendeesToAdd",attendeesToAdd);//需要添加的参与人列表
|
|
|
+ body.put("pushNotification",true);//是否弹窗提醒
|
|
|
+ body.put("chatNotification",true);//是否单聊提醒
|
|
|
+
|
|
|
+ String jsonString2 = UtilHttp.doPost("https://api.dingtalk.com/v1.0/calendar/users/" + unionId + "/calendars/primary/events/" + scheduleId + "/attendees", ddClient.initTokenHeader(), null, body);
|
|
|
+
|
|
|
+ log.info("添加日程参会人结束:{}",jsonString2);
|
|
|
+ }else {
|
|
|
+ log.info("无需添加日程参会人");
|
|
|
+ }
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
}
|