修复部门和人员删除之后查询钉钉接口失败的问题
This commit is contained in:
parent
79c44e1f2d
commit
b7916bbfb4
|
@ -5,17 +5,20 @@ import cn.hutool.core.map.MapBuilder;
|
|||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
|
||||
import com.dingtalk.api.response.OapiV2UserGetResponse;
|
||||
import com.dingtalk.open.app.api.message.GenericOpenDingTalkEvent;
|
||||
import com.hzya.frame.dingtalk.enums.OrgEventEnum;
|
||||
import com.hzya.frame.dingtalk.service.IDingTalkService;
|
||||
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
|
||||
import com.hzya.frame.uuid.UUIDUtils;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import shade.com.alibaba.fastjson2.JSONArray;
|
||||
import shade.com.alibaba.fastjson2.JSONObject;
|
||||
|
@ -30,6 +33,8 @@ import java.util.stream.Collectors;
|
|||
* @Date 2024/8/27 15:33
|
||||
**/
|
||||
public class GenericEventConsumer {
|
||||
@Autowired
|
||||
private ComparisonServiceImpl comparisonServiceimpl;
|
||||
Logger logger = LoggerFactory.getLogger(getClass());
|
||||
//中台应用
|
||||
public static final String APPCODE = "800004";
|
||||
|
@ -104,10 +109,24 @@ public class GenericEventConsumer {
|
|||
//调用钉钉查询用户详情接口
|
||||
for (int i=0; i<userIds.size();i++){
|
||||
try {
|
||||
if(!eventType.equals("user_leave_org")){
|
||||
//获取用户详情
|
||||
String userRes = getUserById(String.valueOf(userIds.get(i)));
|
||||
//保存钉钉用户到mdm
|
||||
String userMdmRes = createUser(userRes,eventType);
|
||||
}else {
|
||||
String userId = (String) userIds.get(i);
|
||||
com.alibaba.fastjson.JSONObject jsonStr = new com.alibaba.fastjson.JSONObject();
|
||||
com.alibaba.fastjson.JSONObject mdmUser = new com.alibaba.fastjson.JSONObject();
|
||||
jsonStr.put("mdmCode","10015");
|
||||
jsonStr.put("optionName","admin");
|
||||
mdmUser.put("data_id",userId);
|
||||
mdmUser.put("event_type","user_leave_org");
|
||||
jsonStr.put("mdm_dd_user",mdmUser);
|
||||
Object result = comparisonServiceimpl.updateEntity(jsonStr);
|
||||
logger.info("更新结果为:{}", JSON.toJSONString(result));
|
||||
//根据userid更新mdm档案
|
||||
}
|
||||
}catch (Exception ex ){
|
||||
logger.error("钉钉用户保存到主数据报错:{}",ex);
|
||||
}
|
||||
|
@ -118,10 +137,23 @@ public class GenericEventConsumer {
|
|||
try {
|
||||
JSONArray deptIdArr = bizData.getJSONArray("deptId");
|
||||
for (int i=0; i<deptIdArr.size(); i++){
|
||||
if(!eventType.equals("org_dept_remove")){
|
||||
//查询部门详情
|
||||
String deptRes = getDeptById(deptIdArr.getLong(i));
|
||||
//保存部门到mdm
|
||||
String deptMdmRes = createDept(deptRes,apiCode);
|
||||
}else{
|
||||
String deptId = String.valueOf(deptIdArr.getLong(i));
|
||||
com.alibaba.fastjson.JSONObject jsonStr = new com.alibaba.fastjson.JSONObject();
|
||||
com.alibaba.fastjson.JSONObject mdmUser = new com.alibaba.fastjson.JSONObject();
|
||||
jsonStr.put("mdmCode","10016");
|
||||
jsonStr.put("optionName","admin");
|
||||
mdmUser.put("data_id",deptId);
|
||||
jsonStr.put("mdm_dd_dept",mdmUser);
|
||||
Object result = comparisonServiceimpl.deleteEntity(jsonStr);
|
||||
logger.info("更新结果为:{}", JSON.toJSONString(result));
|
||||
}
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("钉钉部门保存到主数据报错:{}",e);
|
||||
|
|
Loading…
Reference in New Issue