|
@@ -14,6 +14,7 @@ import com.ruoyi.system.mapper.DragTableConditionMapper;
|
|
|
import com.ruoyi.system.mapper.DragTableGroupMapper;
|
|
|
import com.ruoyi.system.mapper.DragTableMapper;
|
|
|
import com.ruoyi.system.mapper.TableSqlMapper;
|
|
|
+import com.ruoyi.system.service.IDragTableBtnRelevanceService;
|
|
|
import com.ruoyi.system.service.IDragTableGroupService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -48,6 +49,8 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
@Autowired
|
|
|
private TableSqlMapper tableSqlMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDragTableBtnRelevanceService dragTableBtnRelevanceService;
|
|
|
/**
|
|
|
* 查询拖拽格组
|
|
|
*
|
|
@@ -148,6 +151,84 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
//删除表格数据
|
|
|
//dragTableMapper.deleteDragTableByTableKeys(tableKeys);
|
|
|
|
|
|
+ //优化逻辑 1、表格组信息 2、表格信息、条件信息、sql信息
|
|
|
+ List<DragTableVo> dragTables = dragTableGroupVo.getDragTables();
|
|
|
+ if (dragTables.size()>0) {
|
|
|
+ dragTables.stream().forEach(dragTableVo->{
|
|
|
+ String SQL="";
|
|
|
+ //update drag_table
|
|
|
+ DragTable dragTable = new DragTable();
|
|
|
+ BeanUtils.copyProperties(dragTableVo, dragTable);
|
|
|
+ dragTable.setDtColumnName(dragTableVo.getDtColumnName().toString());
|
|
|
+ dragTable.setPrimaryKey(dragTableVo.getPrimaryKey());
|
|
|
+ dragTable.setMenuId(dragTableVo.getMenuId());
|
|
|
+ dragTable.setDtType("1");
|
|
|
+ dragTableMapper.updateDragTable(dragTable);
|
|
|
+ //update table_sql
|
|
|
+ TableSql tableSql = new TableSql();
|
|
|
+ //拼接sql查询条件
|
|
|
+ switch (SecurityUtils.getDatabaseType().toUpperCase()) {
|
|
|
+ case "MYSQL":
|
|
|
+ for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
|
|
|
+ SQL += " AND "+dragTableVo.getSearchFieldList().get(i)+"="+dragTableVo.getConditionDefaultValueMap().get(dragTableVo.getSearchFieldList().get(i));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "DM":
|
|
|
+ case "SQLSERVER":
|
|
|
+ SQL += SQL_START;
|
|
|
+ for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
|
|
|
+ SQL += SQL_DM_SERVER_MIDDLE.replace("#{VAL}", dragTableVo.getSearchFieldList().get(i));
|
|
|
+ SQL += dragTableVo.getSearchFieldList().size() - 1 == i ? ",'')" : ",\n";
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "ORACLE":
|
|
|
+ //SQL_START = "";
|
|
|
+ for (int i = 0; dragTableVo.getSearchFieldList().size() > i; i++) {
|
|
|
+ SQL += dragTableVo.getSearchFieldList().get(i);
|
|
|
+ SQL += (dragTableVo.getSearchFieldList().size() - 1 == i ? " " : "||");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ String where = dragTableVo.getDtTableName() + ".del_flag = '0'";
|
|
|
+ tableSql.setTableCondition(where + SQL);
|
|
|
+ tableSql.setTableAlias(dragTableVo.getDtTableName());
|
|
|
+ tableSql.setOrderByColumn(dragTableVo.getOrderByColumn());
|
|
|
+ tableSql.setSortOrder(dragTableVo.getSortOrder());
|
|
|
+ tableSql.setSqlKey(dragTableVo.getSqlKey());
|
|
|
+ int i = tableSqlMapper.updateTableSqlBySqlKey(tableSql);
|
|
|
+ System.out.println(i);
|
|
|
+ //add drag_table_condition
|
|
|
+ if (dragTableVo.getSearchFieldList().size() > 0) {
|
|
|
+ List<DragTableCondition> dragTableConditionList = new ArrayList<>();
|
|
|
+ dragTableVo.getSearchFieldList().forEach(item -> {
|
|
|
+ dragTableConditionList.add(new DragTableCondition(dragTable.gettId(), item,dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
+ });
|
|
|
+ dragTableConditionMapper.insertDragTableConditionByList(dragTableConditionList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //修改表格组列表信息
|
|
|
+ DragTableGroup dragTableGroup = new DragTableGroup();
|
|
|
+ BeanUtils.copyProperties(dragTableGroupVo, dragTableGroup);
|
|
|
+ int i = dragTableGroupMapper.updateDragTableGroup(dragTableGroup);
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int editConfigurationGroup(DragTableGroupVo dragTableGroupVo) {
|
|
|
+ //根据id查询表格组信息
|
|
|
+ DragTableGroup dragTableGroupOne = dragTableGroupMapper.selectDragTableGroupById(dragTableGroupVo.getId());
|
|
|
+ //得到group_table_info
|
|
|
+ String groupTableInfo = dragTableGroupOne.getGroupTableInfo();
|
|
|
+ //把他转换成Map对象
|
|
|
+ JSONArray jsonArray = JSON.parseArray(groupTableInfo);
|
|
|
+ //收集tableKey
|
|
|
+ List<String> tableKeys = jsonArray.stream().map(item -> JSONObject.parseObject(item.toString()).get("tableKey").toString()
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ //删除条件数据
|
|
|
+ List<Long> dragTableIds = dragTableMapper.selectDragTableTableKeys(tableKeys)
|
|
|
+ .stream().map(item -> item.gettId()).collect(Collectors.toList());
|
|
|
+ dragTableConditionMapper.deleteDragTableConditionBytIds(dragTableIds);
|
|
|
//优化逻辑 1、表格组信息 2、表格信息、条件信息、sql信息
|
|
|
List<DragTableVo> dragTables = dragTableGroupVo.getDragTables();
|
|
|
if (dragTables.size()>0) {
|
|
@@ -156,13 +237,13 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
//add drag_table
|
|
|
DragTable dragTable = new DragTable();
|
|
|
BeanUtils.copyProperties(dragTableVo, dragTable);
|
|
|
- dragTable.setDtColumnName(JSON.toJSONString(dragTableVo.getDtColumnName()));
|
|
|
+ dragTable.setDtColumnName(dragTableVo.getDtColumnName().toString());
|
|
|
dragTable.setPrimaryKey(dragTableVo.getPrimaryKey());
|
|
|
dragTable.setMenuId(dragTableVo.getMenuId());
|
|
|
dragTable.setDtType("1");
|
|
|
//add table_sql
|
|
|
TableSql tableSql = new TableSql();
|
|
|
- tableSql.settId(dragTable.gettId());
|
|
|
+ tableSql.setSqlKey(dragTableVo.getSqlKey());
|
|
|
tableSql.setTableSql(dragTableVo.getTableSql());
|
|
|
dragTableMapper.updateDragTable(dragTable);
|
|
|
//拼接sql查询条件
|
|
@@ -191,7 +272,6 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
String where = dragTableVo.getDtTableName() + ".del_flag = '0'";
|
|
|
tableSql.setTableCondition(where + SQL);
|
|
|
tableSql.setTableAlias(dragTableVo.getDtTableName());
|
|
|
- tableSql.setTableExportField(JSON.toJSONString(dragTableVo.getTableExportField()));
|
|
|
tableSql.setSqlKey(dragTableVo.getSqlKey());
|
|
|
tableSql.setOrderByColumn(dragTableVo.getOrderByColumn());
|
|
|
tableSql.setSortOrder(dragTableVo.getSortOrder());
|
|
@@ -204,14 +284,14 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
});
|
|
|
dragTableConditionMapper.insertDragTableConditionByList(dragTableConditionList);
|
|
|
}
|
|
|
+ //修改按钮信息
|
|
|
+ dragTableBtnRelevanceService.updateDragTableBtnRelevance(dragTableVo);
|
|
|
});
|
|
|
}
|
|
|
//修改表格组列表信息
|
|
|
DragTableGroup dragTableGroup = new DragTableGroup();
|
|
|
BeanUtils.copyProperties(dragTableGroupVo, dragTableGroup);
|
|
|
int i = dragTableGroupMapper.updateDragTableGroup(dragTableGroup);
|
|
|
- //从新插入数据
|
|
|
- //dragTableService.addDragTable(dragTableGroupVo);
|
|
|
return i;
|
|
|
}
|
|
|
|
|
@@ -274,15 +354,25 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
String groupTableInfo = dragTableGroupOne.getGroupTableInfo();
|
|
|
//把他转换成Map对象
|
|
|
JSONArray jsonArray = JSON.parseArray(groupTableInfo);
|
|
|
- List<String> stringList=new ArrayList<>();
|
|
|
- //收集下tableKey
|
|
|
- jsonArray.forEach(e->{
|
|
|
+ //排序确保表格的顺序
|
|
|
+ JSONArray sortArray = jsonArray.stream().sorted(
|
|
|
+ Comparator.comparingLong(
|
|
|
+ // 根据对象中的ID进行排序
|
|
|
+ e -> JSONObject.parseObject(e.toString()).getIntValue("sort")
|
|
|
+ )
|
|
|
+ ).collect(Collectors.toCollection(JSONArray::new));
|
|
|
+ //把查询出来的动态表格数据放到一个集合里边
|
|
|
+ List<DragTableVo> dragTableList=new ArrayList<>();
|
|
|
+ sortArray.forEach(e->{
|
|
|
JSONObject jsonObject = JSON.parseObject(e.toString());
|
|
|
String str = jsonObject.get("tableKey").toString();
|
|
|
- stringList.add(str);
|
|
|
+ DragTable dragTable = dragTableMapper.selectDragTableByTableKey(str);
|
|
|
+ DragTableVo dragTableVo=new DragTableVo();
|
|
|
+ BeanUtils.copyProperties(dragTable, dragTableVo);
|
|
|
+ dragTableList.add( dragTableVo);
|
|
|
});
|
|
|
- //根据tableKey批量查询表格数据
|
|
|
- List<DragTableVo> dragTables = dragTableMapper.selectDragTableTableKeys(stringList).stream().map(item -> {
|
|
|
+ //查询这个动态表格的 1.条件 2.sql信息
|
|
|
+ dragTableList.stream().map(item -> {
|
|
|
//拿到这个表格的所有条件数据
|
|
|
List<DragTableCondition> dragTableConditions = dragTableConditionMapper.selectDragTableConditionByTid(item.gettId());
|
|
|
//条件
|
|
@@ -297,11 +387,16 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
item.setConditionDefaultValueMap(conditionDefaultValueMap);
|
|
|
}
|
|
|
});
|
|
|
+ //排序字段
|
|
|
+ TableSql tableSql = tableSqlMapper.selectTableSqlByTSqlKey(item.getSqlKey());
|
|
|
+ if(tableSql!=null){
|
|
|
+ item.setOrderByColumn(tableSql.getOrderByColumn());
|
|
|
+ }
|
|
|
return item;
|
|
|
}).collect(Collectors.toList());
|
|
|
DragTableGroupVo dragTableGroupVo=new DragTableGroupVo();
|
|
|
BeanUtils.copyProperties(dragTableGroupOne, dragTableGroupVo);
|
|
|
- dragTableGroupVo.setDragTables(dragTables);
|
|
|
+ dragTableGroupVo.setDragTables(dragTableList);
|
|
|
//查询表格的关联数据
|
|
|
return dragTableGroupVo;
|
|
|
}
|