diff --git a/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.java b/src/main/java/neatlogic/framework/dao/mapper/DataBaseViewInfoMapper.java
index dc5a3b3f77f98a58b7d40e4bf6f071403ff8c43a..0b620a262dd9a116c83a3939a8aeb077b2e389a9 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 dd61ce6658c3e92d70299e2278be7ee7e625ef79..476fbaba1a25772a06f463ff31665fc3b9b99beb 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 b6aae22abca71e5e87311ac5a67055aa0cbc92d0..ec6f59120b0a76e8246c2b98ff2cc6816ee8bb22 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;
}