rk
2025-09-28 80f9adf3f7682edf1d997f48c65a9bac2e4c1605
server/visits/dmvisit_service/src/main/java/com/doumee/core/dingTalk/DingTalk.java
@@ -105,6 +105,19 @@
    }
    public OapiV2UserGetuserinfoResponse.UserGetByCodeResponse  getDDUserByCode(String code) throws ApiException {
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo");
        OapiV2UserGetuserinfoRequest req = new OapiV2UserGetuserinfoRequest();
        req.setCode(code);
        OapiV2UserGetuserinfoResponse rsp = client.execute(req, getToken());
        if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){
           return  rsp.getResult();
        }else{
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage());
        }
    }
    /**
     * 全量同步 部门信息
     * 接口文档地址 https://open.dingtalk.com/document/orgapp/obtain-the-department-list-v2
@@ -364,6 +377,41 @@
        }
    }
    public void workInfoOANotice(Long agentId,String userIds,OapiMessageCorpconversationAsyncsendV2Request.Msg msg)throws ApiException {
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
        request.setAgentId(agentId);
        request.setUseridList(userIds);
        request.setToAllUser(false);
//        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
//        msg.setMsgtype("oa");
//        OapiMessageCorpconversationAsyncsendV2Request.OA oa = new OapiMessageCorpconversationAsyncsendV2Request.OA();
//        oa.setMessageUrl("");
//        OapiMessageCorpconversationAsyncsendV2Request.Head head = new OapiMessageCorpconversationAsyncsendV2Request.Head();
//        head.setText("");
//        head.setBgcolor("#279BAA");
//
//        oa.setHead(head);
//
//        OapiMessageCorpconversationAsyncsendV2Request.Body body = new OapiMessageCorpconversationAsyncsendV2Request.Body();
//        body.setTitle("");
//        List<OapiMessageCorpconversationAsyncsendV2Request.Form> form = new ArrayList<>();
//
//        body.setForm(form);
//        oa.setBody(body);
//        msg.setOa(oa);
        request.setMsg(msg);
        OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, getToken());
        if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){
        }else{
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage());
        }
    }
}