|
@@ -20,15 +20,18 @@ import com.dingtalk.api.response.OapiV2UserGetResponse;
|
|
import com.malk.pro.zyjn.service.TongbuService;
|
|
import com.malk.pro.zyjn.service.TongbuService;
|
|
import com.malk.server.aliwork.YDConf;
|
|
import com.malk.server.aliwork.YDConf;
|
|
import com.malk.server.aliwork.YDParam;
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
|
+import com.malk.server.common.McException;
|
|
import com.malk.server.common.McR;
|
|
import com.malk.server.common.McR;
|
|
import com.malk.server.dingtalk.DDR_New;
|
|
import com.malk.server.dingtalk.DDR_New;
|
|
import com.malk.service.aliwork.YDClient;
|
|
import com.malk.service.aliwork.YDClient;
|
|
import com.malk.service.dingtalk.DDClient;
|
|
import com.malk.service.dingtalk.DDClient;
|
|
|
|
+import com.malk.service.dingtalk.DDClient_Schedule;
|
|
import com.malk.utils.UtilHttp;
|
|
import com.malk.utils.UtilHttp;
|
|
import com.malk.utils.UtilMap;
|
|
import com.malk.utils.UtilMap;
|
|
import com.taobao.api.ApiException;
|
|
import com.taobao.api.ApiException;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import okhttp3.*;
|
|
import okhttp3.*;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -99,7 +102,7 @@ public class TongbuServiceImpl implements TongbuService {
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
|
|
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
|
|
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
|
|
req.setUserid(userId);
|
|
req.setUserid(userId);
|
|
- OapiV2UserGetResponse rsp = client.execute(req, getAccessToken());
|
|
|
|
|
|
+ OapiV2UserGetResponse rsp = client.execute(req, ddClient.getAccessToken());
|
|
// System.out.println(rsp.getBody());
|
|
// System.out.println(rsp.getBody());
|
|
String body = rsp.getBody();
|
|
String body = rsp.getBody();
|
|
//通过fastjson工具转换成json对象,逐层解析
|
|
//通过fastjson工具转换成json对象,逐层解析
|
|
@@ -662,7 +665,18 @@ public class TongbuServiceImpl implements TongbuService {
|
|
//根据实例id修改宜搭表单数据
|
|
//根据实例id修改宜搭表单数据
|
|
Map mapData = new HashMap<>();
|
|
Map mapData = new HashMap<>();
|
|
mapData.put("textField_m54zg5b1", richengID);
|
|
mapData.put("textField_m54zg5b1", richengID);
|
|
-
|
|
|
|
|
|
+ // prd 25.06.26 同步预约会议室, 于会议室水牌显示日程
|
|
|
|
+ String roomId = jsonObject.getString("textField_mccrafms");
|
|
|
|
+ if (StringUtils.isNoneBlank(roomId)) {
|
|
|
|
+ try {
|
|
|
|
+ ddClient_schedule.bookMeetingRoom(getAccessToken(), userId, richengID, Arrays.asList(roomId));
|
|
|
|
+ } catch (McException e) {
|
|
|
|
+ mapData.put("textareaField_mccs33fz", e.getMessage());
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ mapData.put("textareaField_mccs33fz", "会议室 roomId 为空, 取消创建");
|
|
|
|
+ }
|
|
String mapAllString = JSON.toJSONString(mapData);
|
|
String mapAllString = JSON.toJSONString(mapData);
|
|
System.out.println("封装修改字段:" + mapAllString);
|
|
System.out.println("封装修改字段:" + mapAllString);
|
|
|
|
|
|
@@ -829,4 +843,95 @@ public class TongbuServiceImpl implements TongbuService {
|
|
|
|
|
|
return McR.success(ddrNew);
|
|
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();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DDClient_Schedule ddClient_schedule;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DDClient dddClient;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void test() {
|
|
|
|
+
|
|
|
|
+ String userId = "253434204020308091";
|
|
|
|
+
|
|
|
|
+ List<Map> dataList = (List<Map>) ddClient_schedule.getMeetingRoomList(dddClient.getAccessToken(), userId).getResult();
|
|
|
|
+ log.info("dataList, {}", dataList);
|
|
|
|
+
|
|
|
|
+ ddClient_schedule.bookMeetingRoom(dddClient.getAccessToken(), userId, "K1ZoWFNuQXo0RlRubzQ0OVJycXEwQT09", Arrays.asList("ab0d05412c9e11a144d5c49e58adef08bfa2770908bf1ec7"));
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|