|
|
@ -1,16 +1,22 @@ |
|
|
|
package com.epmet.controller.yantai; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoDTOCache; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.api.yt.OrgData; |
|
|
|
import com.epmet.commons.tools.utils.api.yt.UserData; |
|
|
|
import com.epmet.commons.tools.utils.api.yt.YantaiApi; |
|
|
|
import com.epmet.dao.yantai.DataSyncOrgDataDao; |
|
|
|
import com.epmet.dao.yantai.DataSyncUserDataDao; |
|
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
|
import com.epmet.dto.form.yantai.YtUserPageFormDTO; |
|
|
|
import com.epmet.dto.result.yantai.DataSyncOrgDataDTO; |
|
|
|
import com.epmet.dto.result.yantai.YtUserPageResDTO; |
|
|
|
import com.epmet.entity.yantai.DataSyncOrgDataEntity; |
|
|
|
import com.epmet.entity.yantai.DataSyncUserDataEntity; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.service.DataSyncOrgDataService; |
|
|
|
import com.epmet.service.DataSyncUserDataService; |
|
|
@ -56,9 +62,46 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Boolean yanTaiSyncUser(String organizationId) { |
|
|
|
|
|
|
|
// List<UserData> data = YantaiApi.getUserByOuGuid(organizationId);
|
|
|
|
//todo 更新或插入数据
|
|
|
|
String customerId = "45687aa479955f9d06204d415238f7cc"; |
|
|
|
// 缓存初始化staffs
|
|
|
|
epmetUserOpenFeignClient.allCustomerStaffInCache(customerId); |
|
|
|
Integer no = NumConstant.ONE; |
|
|
|
Integer size; |
|
|
|
do { |
|
|
|
// 分批获取org
|
|
|
|
PageInfo<com.epmet.dto.DataSyncOrgDataDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_HUNDRED).doSelectPageInfo(() -> dataSyncOrgDataDao.getAllList(customerId)); |
|
|
|
size = pageInfo.getList().size(); |
|
|
|
if (CollectionUtils.isNotEmpty(pageInfo.getList())){ |
|
|
|
List<DataSyncUserDataEntity> needInsert = new ArrayList<>(); |
|
|
|
pageInfo.getList().forEach(org -> { |
|
|
|
// 根据org查用户
|
|
|
|
List<UserData> data = YantaiApi.getUserByOuGuid(org.getOrganizationId()); |
|
|
|
if (CollectionUtils.isNotEmpty(data)){ |
|
|
|
for (UserData u : data) { |
|
|
|
CustomerStaffInfoDTOCache staffInfo = CustomerStaffRedis.getStaffInfoByMobile(customerId, u.getMobileTelephoneNumber()); |
|
|
|
DataSyncUserDataEntity entity = ConvertUtils.sourceToTarget(u, DataSyncUserDataEntity.class); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setRemark(""); |
|
|
|
if (null == staffInfo){ |
|
|
|
entity.setStatus(NumConstant.ZERO_STR); |
|
|
|
entity.setOrganizationId(""); |
|
|
|
entity.setStaffId(""); |
|
|
|
}else { |
|
|
|
CustomerStaffInfoCacheResult staffInfo1 = CustomerStaffRedis.getStaffInfo(customerId, staffInfo.getUserId()); |
|
|
|
entity.setStatus(NumConstant.ONE_STR); |
|
|
|
entity.setOrganizationId(null == staffInfo1 ? "" : staffInfo1.getAgencyId()); |
|
|
|
entity.setStaffId(staffInfo.getUserId()); |
|
|
|
} |
|
|
|
needInsert.add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
dataSyncUserDataService.insertBatch(needInsert,NumConstant.FIVE_HUNDRED); |
|
|
|
} |
|
|
|
no++; |
|
|
|
}while (size == NumConstant.ONE_HUNDRED); |
|
|
|
// 删除staffs缓存
|
|
|
|
CustomerStaffRedis.delAllCustomerStaff(customerId); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|