|
|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
@ -45,7 +46,6 @@ import com.epmet.service.IcUserChangeRecordService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -175,7 +175,6 @@ public class IcUserChangeRecordServiceImpl extends BaseServiceImpl<IcUserChangeR |
|
|
|
* @Author sun |
|
|
|
* @Description 按客户初始化客户下居民的变更记录、变更明细数据 |
|
|
|
**/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void initIcUserChange(String customerId) throws ParseException { |
|
|
|
log.info("开始初始客户下居民的变更记录和变更明细数据,客户Id->"+customerId); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
@ -205,8 +204,7 @@ public class IcUserChangeRecordServiceImpl extends BaseServiceImpl<IcUserChangeR |
|
|
|
//3.遍历封装数据
|
|
|
|
for (Map<String,String> map : icUserList){ |
|
|
|
//存放一个人的类别为是的变更明细数据
|
|
|
|
List<IcUserChangeDetailedEntity> subList = new ArrayList<>(); |
|
|
|
String changeId = UUID.randomUUID().toString().replaceAll("-", ""); |
|
|
|
String changeId = IdWorker.getIdStr(); |
|
|
|
for (IcResiCategoryStatsConfigDTO dto : categoryListResult.getData()){ |
|
|
|
if(map.containsKey(dto.getColumnName())&&"1".equals(map.get(dto.getColumnName()))){ |
|
|
|
detailed = new IcUserChangeDetailedEntity(); |
|
|
@ -228,12 +226,10 @@ public class IcUserChangeRecordServiceImpl extends BaseServiceImpl<IcUserChangeR |
|
|
|
detailed.setCreatedTime(sdf.parse(map.get("CREATED_TIME"))); |
|
|
|
detailed.setUpdatedBy("APP_USER"); |
|
|
|
detailed.setUpdatedTime(new Date()); |
|
|
|
subList.add(detailed); |
|
|
|
detailedList.add(detailed); |
|
|
|
} |
|
|
|
} |
|
|
|
if (subList.size() > NumConstant.ZERO) { |
|
|
|
detailedList.addAll(subList); |
|
|
|
} |
|
|
|
|
|
|
|
if (!hash.containsKey(map.get("CREATED_BY"))) { |
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, map.get("CREATED_BY")); |
|
|
|
//被删除或被移除的工作人员,名字为空
|
|
|
@ -257,20 +253,34 @@ public class IcUserChangeRecordServiceImpl extends BaseServiceImpl<IcUserChangeR |
|
|
|
change.setUpdatedTime(new Date()); |
|
|
|
changeList.add(change); |
|
|
|
} |
|
|
|
//每500个居民处理一批
|
|
|
|
if (changeList.size()>= NumConstant.FIVE_HUNDRED){ |
|
|
|
delAndInsertChangeRecord(customerId, changeList, detailedList); |
|
|
|
} |
|
|
|
} while (icUserList.size() == NumConstant.ONE_THOUSAND); |
|
|
|
//4.批量新增数据,先删后增【只删除新增节点的历史数据】
|
|
|
|
//4-1.删除待处理的人员数据【这类人是指在变更记录表中不存在新增节点数据的人】
|
|
|
|
//最后再处理一批
|
|
|
|
delAndInsertChangeRecord(customerId, changeList, detailedList); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delAndInsertChangeRecord(String customerId, List<IcUserChangeRecordEntity> changeList, List<IcUserChangeDetailedEntity> detailedList) { |
|
|
|
if (CollectionUtils.isEmpty(changeList)) { |
|
|
|
log.info("customerId:{}初始变更记录数据 已完成!", customerId); |
|
|
|
return; |
|
|
|
} |
|
|
|
List<String> icUserIdList = changeList.stream().map(IcUserChangeRecordEntity::getIcUserId).collect(Collectors.toList()); |
|
|
|
List<List<String>> partition = ListUtils.partition(icUserIdList, NumConstant.FIVE_HUNDRED); |
|
|
|
partition.forEach(part -> { |
|
|
|
baseDao.delByCustomerId(customerId, "add", part); |
|
|
|
icUserChangeDetailedService.delByCustomerId(customerId, "add", part); |
|
|
|
}); |
|
|
|
baseDao.delByCustomerId(customerId, "add", icUserIdList); |
|
|
|
icUserChangeDetailedService.delByCustomerId(customerId, "add", icUserIdList); |
|
|
|
|
|
|
|
log.info("初始变更记录数据,总条数->" + changeList.size()); |
|
|
|
icUserChangeRecordService.insertBatch(changeList); |
|
|
|
log.info("初始变更记录明细数据,总条数->" + detailedList.size()); |
|
|
|
icUserChangeDetailedService.insertBatch(detailedList); |
|
|
|
changeList.clear(); |
|
|
|
detailedList.clear(); |
|
|
|
icUserIdList.clear(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|