From f36a17b752d064851f2d5f931aecbd28ea9ef128 Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Tue, 11 Feb 2025 16:42:13 +0800
Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E9=87=8D=E5=BB=BA?=
=?UTF-8?q?=E8=A7=86=E5=9B=BE=E5=A4=B1=E8=B4=A5=E4=BA=86=E5=8D=B4=E6=8F=90?=
=?UTF-8?q?=E7=A4=BA=E6=88=90=E5=8A=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
关联 #[1352076393676800]重建视图失败了却提示成功 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1352076393676800
---
.../dao/mapper/DataBaseViewInfoMapper.java | 2 ++
.../dao/mapper/DataBaseViewInfoMapper.xml | 4 ++++
.../core/RebuildDataBaseViewManager.java | 22 ++++++++++++++++++-
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.java b/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.java
index dc5a3b3f7..0b620a262 100644
--- a/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.java
+++ b/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.java
@@ -22,4 +22,6 @@ public interface DataBaseViewInfoMapper {
DataBaseViewInfoVo getDataBaseViewInfoByViewName(String viewName);
int insertDataBaseViewInfo(DataBaseViewInfoVo dataBaseViewInfoVo);
+
+ int deleteDataBaseViewInfo();
}
diff --git a/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.xml b/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.xml
index dd61ce665..476fbaba1 100644
--- a/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.xml
+++ b/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.xml
@@ -35,4 +35,8 @@ along with this program. If not, see .-->
`lcu` = #{lcu},
`lcd` = NOW(3)
+
+
+ DELETE FROM `database_view_info`
+
diff --git a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java
index b6aae22ab..ec6f59120 100644
--- a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java
+++ b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java
@@ -19,9 +19,12 @@ import neatlogic.framework.applicationlistener.core.ModuleInitializedListenerBas
import neatlogic.framework.asynchronization.threadlocal.TenantContext;
import neatlogic.framework.bootstrap.NeatLogicWebApplicationContext;
import neatlogic.framework.common.RootComponent;
+import neatlogic.framework.dao.mapper.SchemaMapper;
import neatlogic.framework.dto.module.ModuleGroupVo;
+import neatlogic.framework.transaction.core.EscapeTransactionJob;
import org.apache.commons.collections4.CollectionUtils;
+import javax.annotation.Resource;
import java.util.*;
@RootComponent
@@ -29,6 +32,12 @@ public class RebuildDataBaseViewManager extends ModuleInitializedListenerBase {
private final static Map> moduleGroup2HandlerListMap = new HashMap<>();
+ private static SchemaMapper schemaMapper;
+
+ @Resource
+ public void setSchemaMapper(SchemaMapper _schemaMapper) {
+ schemaMapper = _schemaMapper;
+ }
@Override
protected void onInitialized(NeatLogicWebApplicationContext context) {
Map myMap = context.getBeansOfType(IRebuildDataBaseView.class);
@@ -50,7 +59,18 @@ public class RebuildDataBaseViewManager extends ModuleInitializedListenerBase {
}
list.sort(Comparator.comparing(IRebuildDataBaseView::getSort));
for (IRebuildDataBaseView rebuildDataBaseView : list) {
- resultList.addAll(rebuildDataBaseView.execute());
+ List viewStatusInfoList = rebuildDataBaseView.execute();
+ EscapeTransactionJob.State s = new EscapeTransactionJob(() -> {
+ for (ViewStatusInfo viewStatusInfo : viewStatusInfoList) {
+ if (Objects.equals(viewStatusInfo.getStatus(), ViewStatusInfo.Status.FAILURE.toString())) {
+ String tableType = schemaMapper.checkTableOrViewIsExists(TenantContext.get().getDataDbName(), viewStatusInfo.getName());
+ if (Objects.equals(tableType, "VIEW")) {
+ schemaMapper.deleteView(TenantContext.get().getDataDbName() + "." + viewStatusInfo.getName());
+ }
+ }
+ }
+ }).execute();
+ resultList.addAll(viewStatusInfoList);
}
return resultList;
}
--
Gitee