| | |
| | | |
| | | import cn.huge.module.client.api.impl.CustClientImpl; |
| | | import cn.huge.module.sync.dao.mapper.SyncMapper; |
| | | import cn.huge.module.sync.domain.source.SourceCtAccount; |
| | | import cn.huge.module.sync.domain.source.SourceCtUnit; |
| | | import cn.huge.module.sync.domain.target.TargetCtAccount; |
| | | import cn.huge.module.sync.domain.target.TargetCtUnit; |
| | | import org.apache.commons.beanutils.BeanUtils; |
| | | import org.apache.commons.beanutils.ConvertUtils; |
| | |
| | | @Autowired |
| | | private CustClientImpl custClient; |
| | | |
| | | private static final String MYSQL_TABLE = "dyh_ct_unit"; |
| | | private static final String MYSQL_TABLE = "dyh_ct_account"; |
| | | |
| | | public void syncData() { |
| | | try { |
| | | List<SourceCtUnit> sourceCtUnitList = new ArrayList<>(); |
| | | List<TargetCtUnit> targetCtUnitList = new ArrayList<>(); |
| | | List<SourceCtAccount> sourceTableList = new ArrayList<>(); |
| | | |
| | | // 查询MySQL表结构 |
| | | Sort sort = Sort.by(Sort.Direction.ASC, "create_time"); |
| | | int page = 1; |
| | | int size = 1000; |
| | | PageRequest pageRequest = PageRequest.of(page-1, size, sort); |
| | | sourceCtUnitList = syncMapper.pageInfo(MYSQL_TABLE, pageRequest); |
| | | |
| | | //查询mysql总量 |
| | | int total = syncMapper.countData(MYSQL_TABLE); |
| | |
| | | maxPage += 1; |
| | | } |
| | | |
| | | for (int i = 1; i >= maxPage; i++) { |
| | | for(SourceCtUnit sourceCtUnit: sourceCtUnitList){ |
| | | TargetCtUnit targetCtUnit = new TargetCtUnit(); |
| | | for (int i = 1; i <= maxPage; i++) { |
| | | // 查询MySQL表结构 |
| | | Sort sort = Sort.by(Sort.Direction.ASC, "create_time"); |
| | | PageRequest pageRequest = PageRequest.of(page-1, size, sort); |
| | | sourceTableList = syncMapper.pageInfo(MYSQL_TABLE, pageRequest); |
| | | page++; |
| | | |
| | | List<TargetCtAccount> targetTableList = new ArrayList<>(); |
| | | for(SourceCtAccount sourceTable: sourceTableList){ |
| | | TargetCtAccount tagetTable = new TargetCtAccount(); |
| | | ConvertUtils.register(new DateConverter(null), java.util.Date.class); |
| | | BeanUtils.copyProperties(targetCtUnit, sourceCtUnit); |
| | | BeanUtils.copyProperties(tagetTable, sourceTable); |
| | | // for(Field field: sourceCtUnit.getClass().getDeclaredFields()){ |
| | | // convertType(field.get(sourceCtUnit), field.getName(), targetCtUnit); |
| | | // } |
| | | targetCtUnitList.add(targetCtUnit); |
| | | //字段名不一致,手动set |
| | | tagetTable.setCipher(sourceTable.getCipher()); |
| | | tagetTable.setAccType(1); |
| | | targetTableList.add(tagetTable); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(targetCtUnitList)){ |
| | | custClient.clientGetUser(targetCtUnitList); |
| | | if(CollectionUtils.isNotEmpty(targetTableList)){ |
| | | custClient.saveTableList1(targetTableList); |
| | | } |
| | | } |
| | | } catch (Exception e) { |