| | |
| | | @Value("${data.system.name}") |
| | | private String dataSystemName; |
| | | |
| | | |
| | | @Transactional |
| | | public void deleteCenterLogV2() { |
| | | try { |
| | | |
| | |
| | | |
| | | String[] uuids = uuidSet.toArray(new String[0]); |
| | | |
| | | |
| | | insertSql.append(" select * from product_sys_data_center_log").append(" where (").append(BaseUtil.buildQuestionMarkFilter("uuid", uuids.length, true)).append(")"); |
| | | //已经在表中的数据进行排除 |
| | | insertSql.append(" and uuid not in (select uuid from ").append(tableName).append("_").append(currentMonth).append(" )"); |
| | | getBaseDao().executeUpdate(insertSql.toString(), uuids); |
| | | |
| | | //删除采集、提取日志数据 |
| | |
| | | |
| | | //分页删除type>2的数据 |
| | | querySql.setLength(0); |
| | | querySql.append(" select uuid from product_sys_data_center_log a"); |
| | | querySql.append(" select uuid,id from product_sys_data_center_log a"); |
| | | querySql.append(" where id >= ? and id <= ? and type>2 and (result = 1 or ( deal_flag = 1 AND deal_result = 1 ) ) limit ").append(pageSize * 2); |
| | | while (true) { |
| | | DataTableEntity queryDt = getBaseDao().listTable(querySql.toString(), new Object[]{minId, maxId}); |
| | |
| | | List<String> uuidList = queryDt.getData().stream().map(e -> e.getString("uuid")).collect(Collectors.toList()); |
| | | //排除rangeUuids中的数据 |
| | | uuidList.removeAll(Arrays.asList(retainUuids)); |
| | | if (uuidList.isEmpty()) { |
| | | if (queryDt.getRows() < pageSize * 2) { |
| | | break; |
| | | } else { |
| | | minId = queryDt.getData().stream().min(Comparator.comparingInt(e -> e.getInteger("id"))).get().getInteger("id"); |
| | | } |
| | | } |
| | | //根据查询出的uuid将数据插入到对应的表中,使用insert into select的方式 条件是 uuid in uuidList 的数据 |
| | | StringBuilder insertSql = new StringBuilder(64); |
| | | insertSql.append(" insert into ").append(tableName).append("_").append(currentMonth); |
| | | insertSql.append(" select * from product_sys_data_center_log").append(" where (").append(BaseUtil.buildQuestionMarkFilter("uuid", uuidList.size(), true)).append(")"); |
| | | //已经在表中的数据进行排除 |
| | | insertSql.append(" and uuid not in (select uuid from ").append(tableName).append("_").append(currentMonth).append(" )"); |
| | | getBaseDao().executeUpdate(insertSql.toString(), uuidList.toArray()); |
| | | //删除其他日志数据 |
| | | StringBuilder deleteSql = new StringBuilder(64); |