|
@@ -88,22 +88,22 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertDragTable(DragTable dragTable) {
|
|
|
- //dragTable.setCreateTime(DateUtils.getNowDate());
|
|
|
- //dragTable.setCreateById(SecurityUtils.getUserId());
|
|
|
+ // dragTable.setCreateTime(DateUtils.getNowDate());
|
|
|
+ // dragTable.setCreateById(SecurityUtils.getUserId());
|
|
|
return dragTableMapper.insertDragTable(dragTable);
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// * 修改动态表格
|
|
|
-// *
|
|
|
-// * @param dragTable 动态表格
|
|
|
-// * @return 结果
|
|
|
-// */
|
|
|
-// @Override
|
|
|
-// public int updateDragTable(DragTable dragTable) {
|
|
|
-// dragTable.setUpdateTime(DateUtils.getNowDate());
|
|
|
-// return dragTableMapper.updateDragTable(dragTable);
|
|
|
-// }
|
|
|
+ // /**
|
|
|
+ // * 修改动态表格
|
|
|
+ // *
|
|
|
+ // * @param dragTable 动态表格
|
|
|
+ // * @return 结果
|
|
|
+ // */
|
|
|
+ // @Override
|
|
|
+ // public int updateDragTable(DragTable dragTable) {
|
|
|
+ // dragTable.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ // return dragTableMapper.updateDragTable(dragTable);
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
|
* 批量删除动态表格
|
|
@@ -129,25 +129,27 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
|
|
|
@Override
|
|
|
public CommonEntity dragTableInfo(String tableKey) {
|
|
|
- //DragTable dragTable = dragTableMapper.selectDragTableBySqlKey(sqlKey);
|
|
|
- //根据tableKey查询动态表格结构数据
|
|
|
+ // DragTable dragTable = dragTableMapper.selectDragTableBySqlKey(sqlKey);
|
|
|
+ // 根据tableKey查询动态表格结构数据
|
|
|
DragTable dragTable = dragTableMapper.selectDragTableByTableKey(tableKey);
|
|
|
- //得到模板数据
|
|
|
+ // 得到模板数据
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
resultMap.put("template", dragTable);
|
|
|
- //resultMap.put("where",dragTableConditionMapper.selectDragTableConditionByTid(dragTable.gettId()));
|
|
|
- //根据表格id查询表格的条件
|
|
|
- List<DragTableCondition> dragTableConditions = dragTableConditionMapper.selectDragTableConditionByTid(dragTable.gettId());
|
|
|
+ // resultMap.put("where",dragTableConditionMapper.selectDragTableConditionByTid(dragTable.gettId()));
|
|
|
+ // 根据表格id查询表格的条件
|
|
|
+ List<DragTableCondition> dragTableConditions =
|
|
|
+ dragTableConditionMapper.selectDragTableConditionByTid(dragTable.gettId());
|
|
|
dragTableConditions.forEach(d -> {
|
|
|
// 0 查询字典 1 查询表数据
|
|
|
if (d.getConditionDatasource() != null && d.getConditionDatasource().equals("0")) {
|
|
|
d.setDropDownList(commonMapper.selectDropDownListByDict(d.getConditionTableName()));
|
|
|
} else if (d.getConditionDatasource() != null && d.getConditionDatasource().equals("1")) {
|
|
|
- d.setDropDownList(commonMapper.selectDropDownList(d.getConditionTableName(), d.getConditionTableFieldKey(), d.getConditionTableFieldName(), new HashMap<>()));
|
|
|
+ d.setDropDownList(commonMapper.selectDropDownList(d.getConditionTableName(),
|
|
|
+ d.getConditionTableFieldKey(), d.getConditionTableFieldName(), new HashMap<>()));
|
|
|
}
|
|
|
});
|
|
|
resultMap.put("where", dragTableConditions);
|
|
|
- //resultMap.put("querySql", tableSqlMapper.selectTableSqlByTSqlKey(sqlKey));
|
|
|
+ // resultMap.put("querySql", tableSqlMapper.selectTableSqlByTSqlKey(sqlKey));
|
|
|
resultMap.put("querySql", tableSqlMapper.selectTableSqlByTSqlKey(dragTable.getSqlKey()));
|
|
|
// 表格样式信息
|
|
|
DragTableStyle dragTableStyle = new DragTableStyle();
|
|
@@ -156,20 +158,19 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
resultMap.put("style", dragTableStyleList);
|
|
|
CommonEntity commonEntity = new CommonEntity();
|
|
|
// 动态表格按钮信息
|
|
|
- //根据tableKey获取根节点信息
|
|
|
+ // 根据tableKey获取根节点信息
|
|
|
List<String> btnKeys = dragTableBtnRelevanceMapper.selectBtnKeyByTableKey(dragTable.getTableKey());
|
|
|
- //获取根节点数据
|
|
|
+ // 获取根节点数据
|
|
|
if (btnKeys.size() > 0) {
|
|
|
List<DragTableBtn> rootNodes = dragTableBtnMapper.selectDragTableBtnListByBtnKey(btnKeys);
|
|
|
- //查询子节点
|
|
|
+ // 查询子节点
|
|
|
List<Long> ids = rootNodes.stream().map(m -> m.getId()).collect(Collectors.toList());
|
|
|
if (ids.isEmpty()) {
|
|
|
resultMap.put("button", rootNodes);
|
|
|
} else {
|
|
|
List<DragTableBtn> childNodes = dragTableBtnMapper.selectChildNodeById(ids);
|
|
|
- List<DragTableBtn> btnList = rootNodes.stream().peek(
|
|
|
- root -> root.setChildren(getChildrenList(root, childNodes))
|
|
|
- ).collect(Collectors.toList());
|
|
|
+ List<DragTableBtn> btnList = rootNodes.stream()
|
|
|
+ .peek(root -> root.setChildren(getChildrenList(root, childNodes))).collect(Collectors.toList());
|
|
|
resultMap.put("button", btnList);
|
|
|
}
|
|
|
}
|
|
@@ -179,9 +180,9 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
|
|
|
private List<DragTableBtn> getChildrenList(DragTableBtn root, List<DragTableBtn> childNodes) {
|
|
|
List<DragTableBtn> list = childNodes.stream().filter(dragTableBtn ->
|
|
|
- //筛选出下一节点元素
|
|
|
- Objects.equals(dragTableBtn.getBtnParentId(), root.getId())).map(dragTableBtn -> {
|
|
|
- //递归set子节点
|
|
|
+ // 筛选出下一节点元素
|
|
|
+ Objects.equals(dragTableBtn.getBtnParentId(), root.getId())).map(dragTableBtn -> {
|
|
|
+ // 递归set子节点
|
|
|
dragTableBtn.setChildren(this.getChildrenList(dragTableBtn, childNodes));
|
|
|
return dragTableBtn;
|
|
|
}).collect(Collectors.toList());
|
|
@@ -200,25 +201,25 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
// SQL 条件的结束
|
|
|
public static final String SQL_END = "LIKE '%#{val}%'";
|
|
|
|
|
|
- //单个表格添加的逻辑
|
|
|
+ // 单个表格添加的逻辑
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void addDragTable(DragTableVo dragTableVo) {
|
|
|
String SQL = "";
|
|
|
- //add drag_table
|
|
|
+ // add drag_table
|
|
|
DragTable dragTable = new DragTable();
|
|
|
BeanUtils.copyProperties(dragTableVo, dragTable);
|
|
|
dragTable.setDtColumnName(JSON.toJSONString(dragTableVo.getDtColumnName()));
|
|
|
dragTable.setPrimaryKey(dragTableVo.getPrimaryKey());
|
|
|
dragTable.setMenuId(dragTableVo.getMenuId());
|
|
|
- dragTable.setDtType("0");//表格类型
|
|
|
- //add table_sql
|
|
|
+ dragTable.setDtType("0");// 表格类型
|
|
|
+ // add table_sql
|
|
|
TableSql tableSql = new TableSql();
|
|
|
tableSql.setTableSql(dragTableVo.getTableSql());
|
|
|
dragTableMapper.insertDragTable(dragTable);
|
|
|
List<String> searchFieldList = new ArrayList<>();
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
|
- if (item.getConditionType().equals("SuperQuery")) { // 当前表格的查询条件是超级查询
|
|
|
+ if (item.getConditionType().equals("SuperQuery")) { // 当前表格的查询条件是超级查询
|
|
|
searchFieldList.add(item.getConditionField());
|
|
|
}
|
|
|
});
|
|
@@ -240,7 +241,7 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
}
|
|
|
break;
|
|
|
case "ORACLE":
|
|
|
-// SQL_START = "";
|
|
|
+ // SQL_START = "";
|
|
|
for (int i = 0; searchFieldList.size() > i; i++) {
|
|
|
SQL += searchFieldList.get(i);
|
|
|
SQL += (searchFieldList.size() - 1 == i ? " " : "||");
|
|
@@ -252,8 +253,8 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
// dragTableVo.getDtTableName() + ".del_flag = '0' AND ";
|
|
|
dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
try {
|
|
|
- where.append(item +
|
|
|
- URLDecoder.decode(dragTableVo.getConditionDefaultValueMap().get(item).toString(), "UTF-8")
|
|
|
+ where.append(
|
|
|
+ item + URLDecoder.decode(dragTableVo.getConditionDefaultValueMap().get(item).toString(), "UTF-8")
|
|
|
+ " AND ");
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
throw new RuntimeException(e);
|
|
@@ -266,51 +267,53 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
tableSql.setOrderByColumn(dragTableVo.getOrderByColumn());
|
|
|
tableSql.setSortOrder(dragTableVo.getSortOrder());
|
|
|
tableSqlMapper.insertTableSql(tableSql);
|
|
|
- // add drag_table_condition
|
|
|
+
|
|
|
+ // add drag_table_condition 添加动态表格高级查询条件以及共通页面条件框类型
|
|
|
if (dragTableVo.getSearchFieldList().size() > 0) {
|
|
|
dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
- dragTableVo.getSearchFieldList().add(
|
|
|
- new DragTableCondition(
|
|
|
- dragTable.gettId(), "默认查询", item, "DefaultQuery", dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
+ dragTableVo.getSearchFieldList().add(new DragTableCondition(dragTable.gettId(), "默认查询", item,
|
|
|
+ "DefaultQuery", dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
});
|
|
|
// 批量更新
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
|
item.settId(dragTable.gettId());
|
|
|
+ // 添加联合查询条件数据
|
|
|
dragTableConditionMapper.insertDragTableConditionOne(item);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //表格组添加表格的逻辑
|
|
|
+ // 表格组添加表格的逻辑
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void addDragTable(DragTableGroupVo dragTableGroupVo) {
|
|
|
for (DragTableVo dragTableVo : dragTableGroupVo.getDragTables()) {
|
|
|
String SQL = "";
|
|
|
- //add drag_table
|
|
|
+ // add drag_table
|
|
|
DragTable dragTable = new DragTable();
|
|
|
BeanUtils.copyProperties(dragTableVo, dragTable);
|
|
|
dragTable.setDtColumnName(JSON.toJSONString(dragTableVo.getDtColumnName()));
|
|
|
dragTable.setPrimaryKey(dragTableVo.getPrimaryKey());
|
|
|
dragTable.setMenuId(dragTableVo.getMenuId());
|
|
|
- dragTable.setDtName(dragTableVo.getDtName());//表格名称
|
|
|
+ dragTable.setDtName(dragTableVo.getDtName());// 表格名称
|
|
|
dragTable.setDtType("1");
|
|
|
- //add table_sql
|
|
|
+ // add table_sql
|
|
|
TableSql tableSql = new TableSql();
|
|
|
tableSql.setTableSql(dragTableVo.getTableSql());
|
|
|
dragTableMapper.insertDragTable(dragTable);
|
|
|
|
|
|
List<String> searchFieldList = new ArrayList<>();
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
|
- if (item.getConditionType().equals("SuperQuery")) { // 当前表格的查询条件是超级查询
|
|
|
+ if (item.getConditionType().equals("SuperQuery")) { // 当前表格的查询条件是超级查询
|
|
|
searchFieldList.add(item.getConditionField());
|
|
|
}
|
|
|
});
|
|
|
- //拼接sql查询条件
|
|
|
+ // 拼接sql查询条件
|
|
|
switch (SecurityUtils.getDatabaseType().toUpperCase()) {
|
|
|
case "MYSQL":
|
|
|
for (int i = 0; searchFieldList.size() > i; i++) {
|
|
|
- SQL += " AND " + searchFieldList.get(i) + "=" + dragTableVo.getConditionDefaultValueMap().get(searchFieldList.get(i));
|
|
|
+ SQL += " AND " + searchFieldList.get(i) + "="
|
|
|
+ + dragTableVo.getConditionDefaultValueMap().get(searchFieldList.get(i));
|
|
|
}
|
|
|
break;
|
|
|
case "DM":
|
|
@@ -322,7 +325,7 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
}
|
|
|
break;
|
|
|
case "ORACLE":
|
|
|
- //SQL_START = "";
|
|
|
+ // SQL_START = "";
|
|
|
for (int i = 0; searchFieldList.size() > i; i++) {
|
|
|
SQL += searchFieldList.get(i);
|
|
|
SQL += (searchFieldList.size() - 1 == i ? " " : "||");
|
|
@@ -337,12 +340,11 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
tableSql.setOrderByColumn(dragTableVo.getOrderByColumn());
|
|
|
tableSql.setSortOrder(dragTableVo.getSortOrder());
|
|
|
tableSqlMapper.insertTableSql(tableSql);
|
|
|
- //add drag_table_condition
|
|
|
+ // add drag_table_condition
|
|
|
if (dragTableVo.getSearchFieldList() != null && searchFieldList.size() > 0) {
|
|
|
dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
- dragTableVo.getSearchFieldList().add(
|
|
|
- new DragTableCondition(
|
|
|
- dragTable.gettId(), "默认查询", item, "DefaultQuery", dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
+ dragTableVo.getSearchFieldList().add(new DragTableCondition(dragTable.gettId(), "默认查询", item,
|
|
|
+ "DefaultQuery", dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
});
|
|
|
// 批量更新
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
@@ -350,9 +352,11 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
dragTableConditionMapper.insertDragTableConditionOne(item);
|
|
|
});
|
|
|
}
|
|
|
- //给表格增加按钮
|
|
|
- if (dragTableVo.getDragTableBtnRelevanceList() != null && dragTableVo.getDragTableBtnRelevanceList().size() > 0) {
|
|
|
- dragTableBtnRelevanceService.batchInsertDragTableBtnRelevance(dragTableVo.getDragTableBtnRelevanceList());
|
|
|
+ // 给表格增加按钮
|
|
|
+ if (dragTableVo.getDragTableBtnRelevanceList() != null
|
|
|
+ && dragTableVo.getDragTableBtnRelevanceList().size() > 0) {
|
|
|
+ dragTableBtnRelevanceService
|
|
|
+ .batchInsertDragTableBtnRelevance(dragTableVo.getDragTableBtnRelevanceList());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -362,18 +366,19 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
DragTableVo vo = dragTableMapper.selectDragTableVoByTId(tId);
|
|
|
// vo.setSearchFieldList(dragTableConditionMapper.selectDragTableSearchField(tId));
|
|
|
vo.setSearchFieldList(dragTableConditionMapper.selectDragTableConditionByTid(tId));
|
|
|
- //查询动态表格数据统计
|
|
|
+ // 查询动态表格数据统计
|
|
|
DragTableStatistic dragTableStatistic = new DragTableStatistic();
|
|
|
dragTableStatistic.setTableKey(vo.getTableKey());
|
|
|
vo.setDragTableStatisticList(dragTableStatisticMapper.selectDragTableStatisticList(dragTableStatistic));
|
|
|
- //查询动态表格样式
|
|
|
+ // 查询动态表格样式
|
|
|
DragTableStyle dragTableStyle = new DragTableStyle();
|
|
|
dragTableStyle.setTableKey(vo.getTableKey());
|
|
|
vo.setDragTableStyleList(dragTableStyleMapper.selectDragTableStyleList(dragTableStyle));
|
|
|
- //查询动态表格和按钮关联表信息
|
|
|
+ // 查询动态表格和按钮关联表信息
|
|
|
DragTableBtnRelevance dragTableBtnRelevance = new DragTableBtnRelevance();
|
|
|
dragTableBtnRelevance.setTableKey(vo.getTableKey());
|
|
|
- vo.setDragTableBtnRelevanceList(dragTableBtnRelevanceMapper.selectDragTableBtnRelevanceList(dragTableBtnRelevance));
|
|
|
+ vo.setDragTableBtnRelevanceList(
|
|
|
+ dragTableBtnRelevanceMapper.selectDragTableBtnRelevanceList(dragTableBtnRelevance));
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
@@ -381,17 +386,17 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
@Override
|
|
|
public void updateDragTable(DragTableVo dragTableVo) {
|
|
|
String SQL = "";
|
|
|
- //update drag_table
|
|
|
+ // update drag_table
|
|
|
DragTable dragTable = new DragTable();
|
|
|
BeanUtils.copyProperties(dragTableVo, dragTable);
|
|
|
dragTable.setDtColumnName(JSON.toJSONString(dragTableVo.getDtColumnName()));
|
|
|
dragTableMapper.updateDragTable(dragTable);
|
|
|
- //update table_sql
|
|
|
+ // update table_sql
|
|
|
TableSql tableSql = new TableSql();
|
|
|
tableSql.setTableSql(dragTableVo.getTableSql());
|
|
|
List<String> searchFieldList = new ArrayList<>();
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
|
- if (item.getConditionType().equals("SuperQuery")) { // 当前表格的查询条件是超级查询
|
|
|
+ if (item.getConditionType().equals("SuperQuery")) { // 当前表格的查询条件是超级查询
|
|
|
searchFieldList.add(item.getConditionField());
|
|
|
}
|
|
|
});
|
|
@@ -413,7 +418,7 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
}
|
|
|
break;
|
|
|
case "ORACLE":
|
|
|
-// SQL_START = "";
|
|
|
+ // SQL_START = "";
|
|
|
for (int i = 0; searchFieldList.size() > i; i++) {
|
|
|
SQL += searchFieldList.get(i);
|
|
|
SQL += (searchFieldList.size() - 1 == i ? " " : "||");
|
|
@@ -424,8 +429,8 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
// dragTableVo.getDtTableName() + ".del_flag = '0' AND ";
|
|
|
dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
try {
|
|
|
- where.append(item +
|
|
|
- URLDecoder.decode(dragTableVo.getConditionDefaultValueMap().get(item).toString(), "UTF-8")
|
|
|
+ where.append(
|
|
|
+ item + URLDecoder.decode(dragTableVo.getConditionDefaultValueMap().get(item).toString(), "UTF-8")
|
|
|
+ " AND ");
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
throw new RuntimeException(e);
|
|
@@ -443,9 +448,8 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
// delete
|
|
|
dragTableConditionMapper.deleteDragTableConditionBytIds(Collections.singletonList(dragTableVo.gettId()));
|
|
|
dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
- dragTableVo.getSearchFieldList().add(
|
|
|
- new DragTableCondition(
|
|
|
- dragTable.gettId(), "默认查询", item, "DefaultQuery", dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
+ dragTableVo.getSearchFieldList().add(new DragTableCondition(dragTable.gettId(), "默认查询", item,
|
|
|
+ "DefaultQuery", dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
});
|
|
|
// 批量更新
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
@@ -460,9 +464,9 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
public void deleteDragTable(List<Long> tIds, List<String> sqlKeys) {
|
|
|
// delete drag_table
|
|
|
dragTableMapper.deleteDragTableByTIds(tIds);
|
|
|
- //delete table_sql
|
|
|
+ // delete table_sql
|
|
|
tableSqlMapper.deleteTableSqlBySqlKeys(sqlKeys);
|
|
|
- //delete drag_table_condition
|
|
|
+ // delete drag_table_condition
|
|
|
dragTableConditionMapper.deleteDragTableConditionBytIds(tIds);
|
|
|
}
|
|
|
|
|
@@ -473,12 +477,12 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
|
|
|
/**
|
|
|
* 查询当前租户下的表格数量
|
|
|
+ *
|
|
|
* @param dragTable
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int selectDragTableListCount(DragTable dragTable) {
|
|
|
- return dragTableMapper.selectDragTableListCount(dragTable);
|
|
|
+ return dragTableMapper.selectDragTableListCount(dragTable);
|
|
|
}
|
|
|
}
|
|
|
-
|