Commit 2d45a71c by zhoupeng

提交导入组织架构openapi接口

parent ac1a0146
...@@ -6,6 +6,7 @@ import com.github.pagehelper.PageInfo; ...@@ -6,6 +6,7 @@ import com.github.pagehelper.PageInfo;
import com.rome.order.domain.enums.ResponseMsg; import com.rome.order.domain.enums.ResponseMsg;
import com.rome.order.domain.service.OrganizationRedisService; import com.rome.order.domain.service.OrganizationRedisService;
import com.rome.order.domain.service.SyncEmployeCdpService; import com.rome.order.domain.service.SyncEmployeCdpService;
import com.rome.order.domain.util.BatchHandlerUtil;
import com.rome.order.domain.util.HttpUtil; import com.rome.order.domain.util.HttpUtil;
import com.rome.order.domain.util.ParameterCheckUtils; import com.rome.order.domain.util.ParameterCheckUtils;
import com.rome.order.infrastructure.dataobject.SyncEmployeeCdpDO; import com.rome.order.infrastructure.dataobject.SyncEmployeeCdpDO;
...@@ -126,6 +127,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -126,6 +127,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
try { try {
//转换成Map //转换成Map
Map<String, List<OrgDTO>> orgDTOMap = this.getOrgDTOMap(allOrg); Map<String, List<OrgDTO>> orgDTOMap = this.getOrgDTOMap(allOrg);
List<EmpMainDataResDTO> allEmps=new ArrayList<>();
// 分页获取全量数据 // 分页获取全量数据
int pageNum = 1; int pageNum = 1;
if(pageParamNum!=null){ if(pageParamNum!=null){
...@@ -145,7 +147,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -145,7 +147,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
break; break;
} }
// 处理同步的员工信息 // 处理同步的员工信息
this.dealthEmpCdpList(empResList,orgDTOMap); this.dealthEmpCdpList(empResList,allEmps);
if(empResList.size()<pageSize){ if(empResList.size()<pageSize){
// 处理同步的员工信息 // 处理同步的员工信息
log.info("------synAllEmpCdp全量同步结束-------"); log.info("------synAllEmpCdp全量同步结束-------");
...@@ -153,6 +155,10 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -153,6 +155,10 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
} }
pageNum ++; pageNum ++;
} }
//同步腾讯
if(!CollectionUtils.isEmpty(allEmps)){
this.orgSyncTecent(allEmps, orgDTOMap);
}
log.info("------synAllEmpCdp全量同步结束-------"); log.info("------synAllEmpCdp全量同步结束-------");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
...@@ -179,7 +185,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -179,7 +185,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
* 处理同步的员工信息 * 处理同步的员工信息
* @param empResList * @param empResList
*/ */
private void dealthEmpCdpList(List<EmpMainDataResDTO> empResList, Map<String, List<OrgDTO>> orgDTOMap){ private void dealthEmpCdpList(List<EmpMainDataResDTO> empResList, List<EmpMainDataResDTO> allEmps){
empResList.forEach(s->{ empResList.forEach(s->{
s.setCreator(-1); s.setCreator(-1);
s.setCreatorName("system"); s.setCreatorName("system");
...@@ -195,8 +201,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -195,8 +201,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
//需要用户id 根据进行去重 //需要用户id 根据进行去重
// empResList = empResList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getUserId()))), ArrayList::new)); // empResList = empResList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getUserId()))), ArrayList::new));
syncEmployeeCdpMapper.batchSaveEmpCdp(empResList); syncEmployeeCdpMapper.batchSaveEmpCdp(empResList);
//同步腾讯 allEmps.addAll(empResList);
this.orgSyncTecent( empResList, orgDTOMap);
}else{ }else{
//批量添加 //批量添加
List<EmpMainDataResDTO> batchAdd=new ArrayList<>(); List<EmpMainDataResDTO> batchAdd=new ArrayList<>();
...@@ -209,8 +214,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -209,8 +214,7 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
} }
if(!CollectionUtils.isEmpty(batchAdd)){ if(!CollectionUtils.isEmpty(batchAdd)){
syncEmployeeCdpMapper.batchSaveEmpCdp(batchAdd); syncEmployeeCdpMapper.batchSaveEmpCdp(batchAdd);
//同步腾讯 allEmps.addAll(batchAdd);
this.orgSyncTecent( empResList, orgDTOMap);
} }
} }
} }
...@@ -299,7 +303,13 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService { ...@@ -299,7 +303,13 @@ public class SyncEmployeCdpServiceImpl implements SyncEmployeCdpService {
s.setErrorMsg(errMsg); s.setErrorMsg(errMsg);
} }
} }
syncEmployeeCdpMapper.batchUpdateEmpCdp(empResList); if(!CollectionUtils.isEmpty(empResList)){
List<List<EmpMainDataResDTO>> addLists = BatchHandlerUtil.splitTo(empResList, 200);
log.info("appPlanExecuteList总条数:{},分{}批更新", addLists.size(), addLists.size());
for (List<EmpMainDataResDTO> list : addLists) {
syncEmployeeCdpMapper.batchUpdateEmpCdp(list);
}
}
} }
private String orgSetAdminAccountId(String accountId){ private String orgSetAdminAccountId(String accountId){
......
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