Commit a9b5f524 authored by 周亚武's avatar 周亚武

钉钉相关接口

parent 8851d215
......@@ -83,8 +83,8 @@ public interface IDingPersonService extends IDingTalkService {
* @param endTime 审批实例结束时间,Unix时间戳,单位毫秒。
* @param nextToken 分页游标。如果是非首次调用,该参数传上次调用时返回的nextToken。
* @param maxResults 分页参数,每页大小,最多传20。
* @param phone 发起人电话
* @param phones 发起人电话列表 最大列表长度为10
*/
Rest<ListProcessInstanceIdsResponse> getProcessInstanceIdByPhone(String processCode, long startTime, long endTime, long nextToken, long maxResults, String phone) throws Exception;
Rest<ListProcessInstanceIdsResponse> getProcessInstanceIdByPhone(String processCode, long startTime, long endTime, long nextToken, long maxResults, String phones) throws Exception;
}
......@@ -42,6 +42,7 @@ import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -195,7 +196,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
* @param endTime 审批实例结束时间,Unix时间戳,单位毫秒。
* @param nextToken 分页游标。如果是非首次调用,该参数传上次调用时返回的nextToken。
* @param maxResults 分页参数,每页大小,最多传20。
* @param phone 发起人电话
* @param phones 发起人电话列表 最大列表长度为10
*
* @return 返回示例 {
* "result" : {
......@@ -205,13 +206,27 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
* "success" : true
* }
*/
public Rest<ListProcessInstanceIdsResponse> getProcessInstanceIdByPhone(String processCode,long startTime,long endTime,long nextToken,long maxResults,String phone) throws Exception{
public Rest<ListProcessInstanceIdsResponse> getProcessInstanceIdByPhone(String processCode,long startTime,long endTime,long nextToken,long maxResults,String phones) throws Exception{
String userIds = "";
if(!phones.isEmpty()){
List<String> phonesList = Arrays.asList(phones);
for(String phone : phonesList){
Rest<String> mobileRest = getPersonByMobile(phone);
if(mobileRest.getCode() == Rest.SUCCESS){
userIds += mobileRest.getData()+",";
}
}
}
//去掉末尾的逗号
if(userIds.endsWith(",")){
userIds = userIds.substring(0,userIds.lastIndexOf(","));
}
Rest<String> mobileRest = getPersonByMobile(phone);
if (mobileRest.getCode() == Rest.SUCCESS) {
String userId = mobileRest.getData();
if (!userIds.equals("")) {
com.aliyun.dingtalkworkflow_1_0.Client client = new com.aliyun.dingtalkworkflow_1_0.Client(setConfig());
com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsHeaders listProcessInstanceIdsHeaders = new com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsHeaders();
listProcessInstanceIdsHeaders.xAcsDingtalkAccessToken = getToken();
......@@ -224,7 +239,7 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
.setEndTime(endTime)
.setNextToken(nextToken)
.setMaxResults(maxResults)
.setUserIds(java.util.Arrays.asList(userId));
.setUserIds(java.util.Arrays.asList(userIds));
try {
ListProcessInstanceIdsResponse rsp = client.listProcessInstanceIdsWithOptions(listProcessInstanceIdsRequest, listProcessInstanceIdsHeaders, new RuntimeOptions());
return Rest.ok("成功", rsp);
......@@ -237,11 +252,9 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
}
return Rest.fail("获取审批实例列表失败:"+com.aliyun.teautil.Common.empty(err.message));
}
}else {
log.error("根据手机号: "+phone+" 未查询到钉钉userid; erro->"+mobileRest.getMsg());
return Rest.fail("根据手机号: "+phone+" 未查询到钉钉userid; erro->"+mobileRest.getMsg());
}
return Rest.fail("根据手机号: "+phones+" 未查询到钉钉userid");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment