部门同步接口代码更新

This commit is contained in:
zengweihai 2024-05-21 09:29:25 +08:00
parent 1e4be8f2bd
commit 700b095943
1 changed files with 12 additions and 11 deletions

View File

@ -7,18 +7,13 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.exception.KDException;
import kd.bos.org.model.OrgDutyView;
import kd.bos.org.model.OrgParam;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.org.OrgViewType;
import kd.sdk.plugin.Plugin;
@ -27,13 +22,16 @@ import shkd.cosmic.cxkg.task.DTO.QueryDTO;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
/**
* 后台任务插件
* @projectName: shkd-cosmic-root-project
* @package: shkd.cosmic.cxkg.task
* @className: HrmDepartmentTaskImpl
* @author: zengwh
* @description: 获取部门信息的定时任务
* @date: 2024/5/9 10:27
* @version: 1.0
*/
public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
private static Logger logger = LoggerFactory.getLogger(HrmDepartmentTaskImpl.class);
@ -43,7 +41,7 @@ public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
static boolean flag = false; //判断上级部门而设置默认部门的情况是否存在
/**
* 预先取部分数据进行测试构建组织单元
* 抽取oa数据进行测试构建组织单元
* @param requestContext
* @param map
* @throws KDException
@ -80,7 +78,7 @@ public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
}
JSONObject data = this.getOADepartment(query, oaUrl);
if (data != null){
List<OrgParam> orgList = new ArrayList<>();//存放
List<OrgParam> orgList = new ArrayList<>();//存放部门构造参数
BigDecimal totalSize = data.getBigDecimal("totalSize");//获取查询到部门总数
BigDecimal size = new BigDecimal(PAGESIZE);//设置页大小为20
BigDecimal pageNumber = totalSize.divide(size, 0, RoundingMode.UP);//计算需要分页数量
@ -91,6 +89,7 @@ public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
for (int i = 1; i < pageNumber.intValue(); i++){//查询成功取第一轮数据同步
//修改CURPAGE当前页数
CURPAGE = i + 1;
queryDTO.setCurpage(CURPAGE);
JSONObject dataNext = this.getOADepartment(query, oaUrl);//获取查询的数据
this.addOrgList(orgList, dataNext, orgIds);
}
@ -112,6 +111,8 @@ public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
orgIds.put(queryOrg.getString("shkd_oaid"),queryOrg.getLong("id"));//存放已经存在的部门的id以及oaid
}
for (int i = 1; i < pageNumber.intValue(); i++){//查询成功取第一轮数据同步
CURPAGE = i ;
queryDTO.setCurpage(CURPAGE);
JSONObject dataNext = this.getOADepartment(query, oaUrl);//获取查询的数据
this.addOrgList(orgList, dataNext, orgIds);
}