dzx 1 gadu atpakaļ
vecāks
revīzija
46ab55a40c

+ 9 - 5
src/main/java/com/xjrsoft/module/form/service/impl/FormExecuteServiceImpl.java

@@ -1320,12 +1320,16 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
 
                     if (childTableConfig.isPresent()) {
                         //删除子表单数据
-                        Entity childDeleteWhere = Entity.create(tableMap.getKey()).set(childTableConfig.get().getRelationField(), keyValue);
-                        result = SqlRunnerAdapter.db().dynamicDelete(tableName, childDeleteWhere);
-                        if (!result) {
-                            throw new MyException("删除数据失败");
-                        }
+                        String keyValuesStr = "(" + keyValue + ")";
 
+                        long count = SqlRunnerAdapter.db().selectCount("select * from " + childTableConfig.get().getTableName() + " where " + childTableConfig.get().getRelationField() + " in " + keyValuesStr);
+                        if(count > 0){
+                            Entity childDeleteWhere = Entity.create(tableMap.getKey()).set(childTableConfig.get().getRelationField(), keyValue);
+                            result = SqlRunnerAdapter.db().dynamicDelete(tableName, childDeleteWhere);
+                            if (!result) {
+                                throw new MyException("删除数据失败");
+                            }
+                        }
                         //再重新新增
                         List<Entity> childList = tableMap.getValue();
                         result = SqlRunnerAdapter.db().dynamicInsertBatch(tableName, childList);