同步不调用 mapFunction 生成接口,调整数据添加速度

This commit is contained in:
tiger_zhou 2022-12-07 10:31:21 +08:00
parent cd344bc3f0
commit c18565cf21
3 changed files with 38 additions and 4 deletions

View File

@ -35,6 +35,17 @@ public interface RtsDistributeDAO {
" #{record.dsc,jdbcType=VARCHAR},#{record.isSync,jdbcType=BIT})</script>") " #{record.dsc,jdbcType=VARCHAR},#{record.isSync,jdbcType=BIT})</script>")
void customerSyncInsert(@Param("record") RtsDistribute record); void customerSyncInsert(@Param("record") RtsDistribute record);
@Insert("<script>" +
"insert into rts_distribute (id,map_id, source_subject_id, forever,`status`, create_time, update_time,start_time, end_time, creator_id,dsc,is_sync)" +
" values" +
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\",\"> " +
" (#{item.id,jdbcType=BIGINT},#{item.mapId,jdbcType=BIGINT}, #{item.sourceSubjectId,jdbcType=BIGINT}, #{item.forever,jdbcType=BIT}, " +
" #{item.status,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, " +
" #{item.startTime,jdbcType=TIMESTAMP}, #{item.endTime,jdbcType=TIMESTAMP}, #{item.creatorId,jdbcType=BIGINT}, " +
" #{item.dsc,jdbcType=VARCHAR},#{item.isSync,jdbcType=BIT})" +
"</foreach>" +
"</script>")
void customerSyncBatchInsert(@Param("list") List<RtsDistribute> record);
/** /**
* 状态参考 {@link PermissionDistributeStatusEnum} * 状态参考 {@link PermissionDistributeStatusEnum}
*/ */

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.entity.permission.RtsPermissionDistributeRefExample;
import java.util.List; import java.util.List;
import club.joylink.rtss.vo.permission.distribute.DistributeDataVO; import club.joylink.rtss.vo.permission.distribute.DistributeDataVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
@ -25,6 +26,17 @@ public interface RtsPermissionDistributeRefDAO {
" where 1 = 1 and A.distribute_id = #{disId}" + " where 1 = 1 and A.distribute_id = #{disId}" +
"</script>") "</script>")
List<DistributeDataVO.DistributePermissionVO> selectTimeOut(); List<DistributeDataVO.DistributePermissionVO> selectTimeOut();
@Insert("<script>" +
"insert into rts_permission_distribute_ref (distribute_id, permission_id, amount,remains, is_sync)" +
" values " +
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\",\"> " +
"(#{item.distributeId,jdbcType=BIGINT}, #{item.permissionId,jdbcType=BIGINT}, #{item.amount,jdbcType=INTEGER},\n" +
" #{item.remains,jdbcType=INTEGER}, #{item.isSync,jdbcType=BIT})" +
"</foreach>" +
"</script>")
void batchInsert(@Param("list") List<RtsPermissionDistributeRef> refList);
long countByExample(RtsPermissionDistributeRefExample example); long countByExample(RtsPermissionDistributeRefExample example);
int deleteByExample(RtsPermissionDistributeRefExample example); int deleteByExample(RtsPermissionDistributeRefExample example);

View File

@ -98,12 +98,12 @@ public class OldPermissionDataSyncService {
SYNC_RESULT_LIST.clear(); SYNC_RESULT_LIST.clear();
try{ try{
truncateAllTable(); truncateAllTable();
MapInfoExample example = new MapInfoExample(); /*MapInfoExample example = new MapInfoExample();
example.createCriteria().andStatusEqualTo("1" ); example.createCriteria().andStatusEqualTo("1" );
List<MapInfo> mapInfoList = this.mapInfoDAO.selectByExample(example); List<MapInfo> mapInfoList = this.mapInfoDAO.selectByExample(example);
for (MapInfo mapInfo : mapInfoList) { for (MapInfo mapInfo : mapInfoList) {
this.generate(mapInfo); this.generate(mapInfo);
} }*/
this.abilityService.autoSynchMapSystemData(0L); this.abilityService.autoSynchMapSystemData(0L);
}catch (Exception e){ }catch (Exception e){
log.error("用户权限初始化失败 msg:" + e.getMessage(),e); log.error("用户权限初始化失败 msg:" + e.getMessage(),e);
@ -210,15 +210,26 @@ public class OldPermissionDataSyncService {
} }
private void insertDistribute(List<DistributeDataVO> distributeDataVOList){ private void insertDistribute(List<DistributeDataVO> distributeDataVOList){
List<RtsPermissionDistributeRef> allRefList = Lists.newArrayList();
List<RtsDistribute> disList = Lists.newArrayList();
for (DistributeDataVO dataVO : distributeDataVOList) { for (DistributeDataVO dataVO : distributeDataVOList) {
RtsDistribute rd = PermissionDistributeConvertor.convertDistributeDataVoTo(dataVO,dataVO.getCreatorId()); RtsDistribute rd = PermissionDistributeConvertor.convertDistributeDataVoTo(dataVO,dataVO.getCreatorId());
rd.setIsSync(true); rd.setIsSync(true);
this.rtsDistributeDAO.customerSyncInsert(rd); disList.add(rd);
List<RtsPermissionDistributeRef> refList = PermissionDistributeConvertor.convertDistributeRefListTo(dataVO.getPermissionIds(),null); List<RtsPermissionDistributeRef> refList = PermissionDistributeConvertor.convertDistributeRefListTo(dataVO.getPermissionIds(),null);
for (RtsPermissionDistributeRef ref : refList) { for (RtsPermissionDistributeRef ref : refList) {
ref.setIsSync(true); ref.setIsSync(true);
this.distributeRefDAO.insert(ref); allRefList.add(ref);
} }
}
if(!CollectionUtils.isEmpty(disList)){
rtsDistributeDAO.customerSyncBatchInsert(disList);
}
if(!CollectionUtils.isEmpty(allRefList)){
distributeRefDAO.batchInsert(allRefList);
} }
} }
private void insertUserPermission(List<PermissionSubject> psList){ private void insertUserPermission(List<PermissionSubject> psList){