Quellcode durchsuchen

WBS动态库,元素库,编辑元素错误提示

qianxb vor 1 Jahr
Ursprung
Commit
bad4682c2d

+ 13 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsFormElementServiceImpl.java

@@ -31,6 +31,9 @@ import org.springblade.manager.vo.WbsFormElementVO;
 import org.springblade.manager.vo.WbsFormElementVO2;
 import org.springblade.manager.vo.WbsNodeTableVO;
 import org.springblade.system.cache.ParamCache;
+import org.springframework.dao.DataAccessException;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.lang.Nullable;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -53,6 +56,8 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
 
     private final IExcelTabService excelTabService;
 
+    private final JdbcTemplate jdbcTemplate;
+
     //元素字符串、数值、时间类型默认长度
     public static final Integer DEFAULT_ELEMENT_LENGTH_VARCHAR = 250;
     public static final Integer DEFAULT_ELEMENT_LENGTH_NUMBER = 50;
@@ -135,6 +140,13 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
     public WbsFormElement saveAndSyn(WbsFormElement wbsFormElement, String tableName) {
         try {
 
+            String isExitSql = "select * from information_schema.TABLES where TABLE_NAME='" + tableName + "'";
+            List<Map<String, Object>> tabList = jdbcTemplate.queryForList(isExitSql);
+            if (tabList.size() <= 0) {
+                throw new ServiceException("未获取到对应的实体表名称initTableName");
+            }
+
+
             //获取实体表主库信息
             TableInfo tableInfo = tableInfoMapper.selectById(wbsFormElement.getFId());
             if (tableInfo == null) {
@@ -239,7 +251,7 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
 
         } catch (Exception e) {
             baseMapper.deleteElement(wbsFormElement);
-            throw new ServiceException("同步元素字段异常,操作失败");
+            throw new ServiceException("同步元素字段异常,操作失败"+e.getMessage());
         }
         return wbsFormElement;
     }