提交 2b84cf00 authored 作者: 黄夏豪's avatar 黄夏豪

[模型模块] 修改扫描时的一些逻辑

[工作流模块] 修复了回调时填充集合类型时报错
上级 a5d1214f
......@@ -78,11 +78,11 @@ public class ModelController {
@ApiOperation("新增数据模型")
@PostMapping(value = "/addModel")
public ResponseEntity addModel(@RequestBody TableVO tableVO) throws Exception {
List<TableInfo> tableInfos = modelService.listAllEntities(null);
for (TableInfo tableInfo : tableInfos) {
if (tableVO.getModelName().equals(tableInfo.getModelName())) {
return ResultUtil.failed("表已经存在!");
}
SearchTableInfoVo searchTableInfoVo = new SearchTableInfoVo();
searchTableInfoVo.setModelName(tableVO.getModelName());
List<TableInfo> tableInfos = modelService.listAllEntities(searchTableInfoVo);
if (tableInfos.size()>0){
return ResultUtil.failed("表已经存在!");
}
long start = System.currentTimeMillis();
......@@ -141,7 +141,8 @@ public class ModelController {
**/
@ApiOperation("复杂查询")
@GetMapping("/complexQuery")
public ResponseEntity complexQuery(String tableName, List<QueryCondition> queryConditions) {
public ResponseEntity complexQuery(@RequestParam(value = "tableName")String tableName,
@RequestParam(value = "queryConditions" ,required=false) List<QueryCondition> queryConditions) {
List list = modelService.complexQuery(tableName, queryConditions);
if (list != null) {
return ResultUtil.success(list, "查询成功!");
......
......@@ -22,7 +22,7 @@ import java.io.Serializable;
*/
@WorkFlowCoreNoScan
@Entity
//@Table(name = "workflow_table_info")
@Table(name = "workflow_table_info")
@EntityListeners(AuditingEntityListener.class)
@Data
@SQLDelete(sql = "update table_info set deleted = 1 where id = ?")
......@@ -30,9 +30,10 @@ import java.io.Serializable;
public class TableInfo extends BaseEntity {
@ApiModelProperty("名,不能为空")
@ApiModelProperty("数据对象名,不能为空")
@Column(nullable = false)
private String modelName;
@ApiModelProperty("表中文名,不能为空")
@Column(nullable = false)
private String modelTitle;
......
......@@ -17,6 +17,7 @@ import com.tykj.workflowcore.model_layer.utils.SessionUtil;
import com.tykj.workflowcore.model_layer.utils.SqlUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javafx.scene.control.Tab;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.Session;
......@@ -124,7 +125,7 @@ public class ModelImpl implements ModelService {
* @Date 16:15 2021/3/5
**/
@Override
public List<ColumnInfo> showModelFields(SearchColumnInfoVo searchColumnInfoVo) {
public List<ColumnInfo> showModelFields(SearchColumnInfoVo searchColumnInfoVo) {
PredicateBuilder<ColumnInfo> and = Specifications.and();
and.eq(searchColumnInfoVo.getDbId() != null, "dbId", searchColumnInfoVo.getDbId());
and.eq(searchColumnInfoVo.getDbName() != null && StringUtils.isNotEmpty(searchColumnInfoVo.getDbName()), "dbName", searchColumnInfoVo.getDbName());
......@@ -151,12 +152,8 @@ public class ModelImpl implements ModelService {
} else {
tableVO.setModelType(ModelType.BUSINESS);
}
sessionUtil.addXml(xmlMapping);
Session session = sessionUtil.getSession();
List<ColumnVO> dataList = tableVO.getDataList();
TableInfo tableInfo = new TableInfo();
tableInfo.setModelName(tableVO.getModelName());
......@@ -291,19 +288,20 @@ public class ModelImpl implements ModelService {
TableInfo tableInfo = new TableInfo();
TableVO tableVO = new TableVO();
//入表真实名称
String realName = "";
String tableName = "";
String className = "";
if (!aClass.isAnnotationPresent(WorkFlowCoreNoScan.class)) {
if (aClass.isAnnotationPresent(Entity.class)) {
className = getClassName(aClass.toString());
if (aClass.isAnnotationPresent(Table.class)) {
Table table = aClass.getAnnotation(Table.class);
if (!"".equals(table.name()) && table.name() != null) {
realName = table.name();
tableName = table.name();
}else {
tableName = className;
}
} else {
String className = getClassName(aClass.toString());
realName = className;
}
tableVO.setModelName(realName);
tableVO.setModelName(className);
//获得类中文描述
if (aClass.isAnnotationPresent(ApiModel.class)) {
ApiModel annotation = aClass.getAnnotation(ApiModel.class);
......@@ -320,7 +318,6 @@ public class ModelImpl implements ModelService {
}
//获得类所有属性
Field[] declaredFields = aClass.getDeclaredFields();
java.lang.reflect.Type genericType;
List<ColumnVO> list = new ArrayList<>();
ColumnVO primaryColumn = new ColumnVO();
......@@ -385,29 +382,32 @@ public class ModelImpl implements ModelService {
list.addAll(otherColumns);
tableVO.setDataList(list);
//扫描的xml
String xml = createTable(tableVO.getModelName(), primaryColumn, otherColumns);
String xml = createTable(tableVO.getModelName(),tableName, primaryColumn, otherColumns);
tableInfo.setModelName(tableVO.getModelName());
tableInfo.setModelTitle(tableVO.getModelTitle());
tableInfo.setXml(xml);
tableInfo.setModelType(ModelType.BASICS);
//判断是否存在
if (checkRepeat(realName)) {
//查出tableInfo是否存在
TableInfo tableInfoByTableName = getTableInfoByTableName(className);
if (tableInfoByTableName==null) {
tableInfo = tableInfoDao.save(tableInfo);
List<ColumnVO> dataList = tableVO.getDataList();
for (ColumnVO columnVO : dataList) {
ColumnInfo columnInfo = new ColumnInfo();
columnInfo.setFieldName(columnVO.getFieldName());
columnInfo.setFieldType(columnVO.getFieldType());
columnInfo.setFieldLength(columnVO.getFieldLength());
columnInfo.setFieldTitle(columnVO.getFieldTitle());
columnInfo.setPrimaryKey(columnVO.getPrimaryKey());
columnInfo.setDbName(realName);
columnInfo.setDbId(tableInfo.getId());
columnInfoDao.save(columnInfo);
}
} else {
log.warn("{}已存在", realName);
tableInfoByTableName.setXml(xml);
tableInfo = tableInfoDao.save(tableInfoByTableName);
log.warn("{}已存在更新XML", className);
}
//保存ColumnInfo
List<ColumnVO> dataList = tableVO.getDataList();
for (ColumnVO columnVO : dataList) {
ColumnInfo columnInfo = new ColumnInfo();
columnInfo.setFieldName(columnVO.getFieldName());
columnInfo.setFieldType(columnVO.getFieldType());
columnInfo.setFieldLength(columnVO.getFieldLength());
columnInfo.setFieldTitle(columnVO.getFieldTitle());
columnInfo.setPrimaryKey(columnVO.getPrimaryKey());
columnInfo.setDbName(className);
columnInfo.setDbId(tableInfo.getId());
columnInfoDao.save(columnInfo);
}
}
}
......@@ -421,7 +421,7 @@ public class ModelImpl implements ModelService {
* @Description 判重
* @Date 10:50 2021/3/11
**/
public boolean checkRepeat(String tableName) {
public TableInfo getTableInfoByTableName(String tableName) {
Specification spec = (root, criteriaQuery, criteriaBuilder) -> {
Path name = root.get("modelName");
Predicate equal = criteriaBuilder.equal(name, tableName);
......@@ -429,13 +429,10 @@ public class ModelImpl implements ModelService {
};
List<TableInfo> all = tableInfoDao.findAll(spec);
for (TableInfo tableInfo : all) {
String name = tableInfo.getModelName();
if (tableName.equals(name)) {
return false;
}
if (all!=null&&all.size()>0){
return all.get(0);
}
return true;
return null;
}
/**
......@@ -663,7 +660,8 @@ public class ModelImpl implements ModelService {
List<TableInfo> tableInfoList = tableInfoDao.findAllByModelType(ModelType.BASICS);
for (TableInfo tableInfo : tableInfoList) {
/*删除columnInfo*/
// columnInfoDao.deleteAllByDbId(tableInfo.getId());
columnInfoDao.deleteAllByDbId(tableInfo.getId());
}
}
}
......@@ -75,7 +75,7 @@ public class CreateTableUtil {
}
public static String createTable(String entityName,ColumnVO primaryColumn,List<ColumnVO> dataList) {
public static String createTable(String entityName,String tableName,ColumnVO primaryColumn,List<ColumnVO> dataList) {
// 1sql-type="text" string 转为text文本,2长度超过会自动转换
// List<ColumnVO> dataList = tableVO.getDataList();
String xmlMapping = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
......@@ -83,7 +83,7 @@ public class CreateTableUtil {
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n" +
" \"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd\">\n" +
"<hibernate-mapping>\n" +
" <class entity-name=\"" + entityName + "\" table=\"" + entityName + "\">\n";
" <class entity-name=\"" + entityName + "\" table=\"" + tableName + "\">\n";
xmlMapping += " <id name=\""+primaryColumn.getFieldName()+"\" type=\""+primaryColumn.getFieldType()+"\" unsaved-value=\"null\" >\n" +
" </id>";
......
package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.workflow_editer.dao.VariableStorageMapper;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.VariableStorage;
import com.tykj.workflowcore.workflow_editer.entity.vo.*;
......@@ -38,10 +39,10 @@ public class FlowsInfoController {
private WorkFlowService workFlowService;
@Autowired
private NodeInfoService nodeInfoService;
private VariableStorageService variableStorageService;
@Autowired
private VariableStorageService variableStorageService;
VariableStorageMapper variableStorageMapper;
@PostMapping("/searchAllFlowInfo")
......@@ -121,4 +122,11 @@ public class FlowsInfoController {
return ResultUtil.success( variableStorageService.searchVariableById(id),"查询接口调用配置成功");
}
@DeleteMapping("/deleteVariableStorageById")
@ApiOperation("根据ID删除函数调用配置")
public ResponseEntity deleteVariableStorageById(Integer id){
variableStorageMapper.deleteById(id);
return ResultUtil.success( null,"删除成功");
}
}
......@@ -4,7 +4,7 @@ import com.tykj.workflowcore.api.controller.ApiController;
import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.workflow_editer.entity.enums.JavaTypeEnum;
import com.tykj.workflowcore.workflow_editer.entity.JavaTypeEnum;
import com.tykj.workflowcore.workflow_editer.entity.VariableStorage;
import com.tykj.workflowcore.workflow_editer.entity.vo.ParameterVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.SearchVariableStorageVo;
......@@ -170,12 +170,10 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
instance.put(parameterVo.getName(),null);
}else
if (Collection.class.isAssignableFrom(aClass)){
try {
instance.put(parameterVo.getName(),aClass.newInstance());
} catch (InstantiationException e) {
throw new ApiException("目标类型无法被实例化,className:"+parameterVo.getClassName());
} catch (IllegalAccessException e) {
throw new ApiException("无法访问目标类型,className:"+parameterVo.getClassName());
if (List.class.isAssignableFrom(aClass)){
instance.put(parameterVo.getName(),new ArrayList<>());
}else {
instance.put(parameterVo.getName(),new HashSet<>());
}
}else {
instance.put(parameterVo.getName(),new HashMap<>());
......
......@@ -40,4 +40,6 @@ public interface VariableStorageService {
VariableStorage searchVariableById(Integer id);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论