use of com.dingtalk.api.response.OapiProcessinstanceCreateResponse in project dingtalk-app-server by nju-softeng.
the class OAApi method createAbsentOA.
public String createAbsentOA(AbsentOA absentOA) {
try {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/processinstance/create");
OapiProcessinstanceCreateRequest request = new OapiProcessinstanceCreateRequest();
request.setAgentId(BaseApi.AGENTID);
// 设置process code
request.setProcessCode(absentOAProcessCode);
request.setOriginatorUserId(userService.getUserid(absentOA.getUser().getId()));
request.setDeptId(-1L);
// 设置表单内容
List<OapiProcessinstanceCreateRequest.FormComponentValueVo> form = new ArrayList<>();
OapiProcessinstanceCreateRequest.FormComponentValueVo type = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
form.add(type);
type.setName("请假类型");
type.setValue(absentOA.getType());
OapiProcessinstanceCreateRequest.FormComponentValueVo start = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
form.add(start);
start.setName("开始时间");
start.setValue(absentOA.getDingTalkSchedule().getStart().toString());
OapiProcessinstanceCreateRequest.FormComponentValueVo end = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
form.add(end);
end.setName("结束时间");
end.setValue(absentOA.getDingTalkSchedule().getEnd().toString());
// OapiProcessinstanceCreateRequest.FormComponentValueVo dayNum = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
// form.add(dayNum);
// dayNum.setName("结束时间");
// dayNum.setValue(absentOA.getDayNum().toString());
OapiProcessinstanceCreateRequest.FormComponentValueVo reason = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
form.add(reason);
reason.setName("请假缘由");
reason.setValue(absentOA.getReason());
request.setFormComponentValues(form);
// 设置审批人
List<OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo> processInstanceApproverVoList = new ArrayList<>();
OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo processInstanceApproverVo = new OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo();
processInstanceApproverVoList.add(processInstanceApproverVo);
request.setApprovers(absentOA.getDingTalkSchedule().getOrganizer().getUserid());
OapiProcessinstanceCreateResponse rsp = client.execute(request, getAccessToken());
return rsp.getProcessInstanceId();
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
Aggregations