人员新增任务中增加同步OA绑定

This commit is contained in:
yuxueliang0813 2024-12-20 17:04:56 +08:00
parent 5907e65433
commit e75ce1af72
1 changed files with 18 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import shkd.utils.DobeDWUtils;
import shkd.utils.OAUtils;
import java.io.IOException;
import java.util.ArrayList;
@ -90,7 +91,7 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
QFilter exprtFilter = new QFilter("number", QCP.not_in, exprtNumber);
QFilter dwFilter = new QFilter("source", QCP.equals, "dw");
QFilter enableFilter = new QFilter("enable", QCP.equals, "1");
DynamicObject[] dos = BusinessDataServiceHelper.load("bos_user","id,enable,isforbidden",new QFilter[]{exprtFilter.and(dwFilter).and(enableFilter)});
DynamicObject[] dos = BusinessDataServiceHelper.load(entityName,"id,enable,isforbidden",new QFilter[]{exprtFilter.and(dwFilter).and(enableFilter)});
if(dos.length > 0){
DynamicObject currentUser = null;
for (int i = 0; i < dos.length; i++) {
@ -227,10 +228,26 @@ public class DobeDWpersonTask extends AbstractTask implements Plugin {
}
if(addList.size() > 0){
UserServiceHelper.add(addList);
List<DynamicObject> userinfos = new ArrayList<>();
DynamicObject userinfo = null;
//判断执行结果
for (UserParam result : addList) {
if (!result.isSuccess()) {
log.info(String.format("人员新增异常:%s", result.getMsg()));
}else{
userinfo = BusinessDataServiceHelper.newDynamicObject(entityName);;
userinfo.set("number",result.getDataMap().get("number"));//人员编号
userinfo.set("name",result.getDataMap().get("name"));//人员姓名
userinfos.add(userinfo);
}
}
//处理OA人员绑定
if(userinfos.size() > 0){
String billNo = "person-new-bid";
//获取token
String oaToken = OAUtils.getOaToken(billNo);
if (!DobeDWUtils.isEmpty(oaToken)) {
OAUtils.thirdpartyUser(userinfos, oaToken, billNo);
}
}
}