From a3ba5db359871eb7846882ae58a96ffa08816a44 Mon Sep 17 00:00:00 2001 From: 许鹏程 <1821349743@qq.com> Date: 星期一, 29 七月 2024 17:00:03 +0800 Subject: [PATCH] 123 --- product-server-data-center/src/main/java/com/product/data/center/service/CommonService.java | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/product-server-data-center/src/main/java/com/product/data/center/service/CommonService.java b/product-server-data-center/src/main/java/com/product/data/center/service/CommonService.java index f5b4632..90e2ad1 100644 --- a/product-server-data-center/src/main/java/com/product/data/center/service/CommonService.java +++ b/product-server-data-center/src/main/java/com/product/data/center/service/CommonService.java @@ -56,7 +56,7 @@ @Value("${data.system.name}") private String dataSystemName; - + @Transactional public void deleteCenterLogV2() { try { @@ -166,7 +166,10 @@ 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); //鍒犻櫎閲囬泦銆佹彁鍙栨棩蹇楁暟鎹� @@ -181,7 +184,7 @@ //鍒嗛〉鍒犻櫎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}); @@ -192,10 +195,19 @@ 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); -- Gitblit v1.9.2