|
@@ -1,5 +1,7 @@
|
|
|
package com.zkqy.system.service.impl;
|
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -151,24 +153,24 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
DragTableStyle dragTableStyle = new DragTableStyle();
|
|
|
dragTableStyle.setTableKey(dragTable.getTableKey());
|
|
|
List<DragTableStyle> dragTableStyleList = dragTableStyleMapper.selectDragTableStyleList(dragTableStyle);
|
|
|
- resultMap.put("style",dragTableStyleList);
|
|
|
+ resultMap.put("style", dragTableStyleList);
|
|
|
CommonEntity commonEntity = new CommonEntity();
|
|
|
// 动态表格按钮信息
|
|
|
//根据tableKey获取根节点信息
|
|
|
List<String> btnKeys = dragTableBtnRelevanceMapper.selectBtnKeyByTableKey(dragTable.getTableKey());
|
|
|
//获取根节点数据
|
|
|
- if(btnKeys.size() > 0){
|
|
|
+ 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 {
|
|
|
+ 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());
|
|
|
- resultMap.put("button",btnList);
|
|
|
+ resultMap.put("button", btnList);
|
|
|
}
|
|
|
}
|
|
|
commonEntity.setResultMap(resultMap);
|
|
@@ -239,7 +241,20 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- String where = dragTableVo.getDtTableName() + ".del_flag = '0' AND ";
|
|
|
+
|
|
|
+ StringBuffer where = new StringBuffer();
|
|
|
+ // dragTableVo.getDtTableName() + ".del_flag = '0' AND ";
|
|
|
+
|
|
|
+ dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
+ try {
|
|
|
+ where.append(item +
|
|
|
+ URLDecoder.decode(dragTableVo.getConditionDefaultValueMap().get(item).toString(), "UTF-8")
|
|
|
+ + " AND ");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
tableSql.setTableCondition(where + SQL + SQL_END);
|
|
|
tableSql.setTableAlias(dragTableVo.getDtTableName());
|
|
|
tableSql.setTableExportField(JSON.toJSONString(dragTableVo.getTableExportField()));
|
|
@@ -251,9 +266,13 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
if (dragTableVo.getSearchFieldList().size() > 0) {
|
|
|
List<DragTableCondition> dragTableConditionList = new ArrayList<>();
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
|
- dragTableConditionList.add(new DragTableCondition(dragTable.gettId(),item));
|
|
|
+ dragTableConditionList.add(new DragTableCondition(dragTable.gettId(), item));
|
|
|
+ });
|
|
|
+ dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
+ dragTableConditionList.add(new DragTableCondition(dragTable.gettId(), item, dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
});
|
|
|
- dragTableConditionList.forEach(e->{
|
|
|
+
|
|
|
+ dragTableConditionList.forEach(e -> {
|
|
|
e.setCreateById(SecurityUtils.getUserId());
|
|
|
});
|
|
|
dragTableConditionMapper.insertDragTableConditionByList(dragTableConditionList);
|
|
@@ -265,7 +284,7 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
@Override
|
|
|
public void addDragTable(DragTableGroupVo dragTableGroupVo) {
|
|
|
for (DragTableVo dragTableVo : dragTableGroupVo.getDragTables()) {
|
|
|
- String SQL="";
|
|
|
+ String SQL = "";
|
|
|
//add drag_table
|
|
|
DragTable dragTable = new DragTable();
|
|
|
BeanUtils.copyProperties(dragTableVo, dragTable);
|
|
@@ -282,7 +301,7 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
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));
|
|
|
+ SQL += " AND " + dragTableVo.getSearchFieldList().get(i) + "=" + dragTableVo.getConditionDefaultValueMap().get(dragTableVo.getSearchFieldList().get(i));
|
|
|
}
|
|
|
break;
|
|
|
case "DM":
|
|
@@ -310,15 +329,15 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
tableSql.setSortOrder(dragTableVo.getSortOrder());
|
|
|
tableSqlMapper.insertTableSql(tableSql);
|
|
|
//add drag_table_condition
|
|
|
- if (dragTableVo.getSearchFieldList()!=null&&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);
|
|
|
+ if (dragTableVo.getSearchFieldList() != null && 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);
|
|
|
}
|
|
|
//给表格增加按钮
|
|
|
- if(dragTableVo.getDragTableBtnRelevanceList()!=null&&dragTableVo.getDragTableBtnRelevanceList().size()>0){
|
|
|
+ if (dragTableVo.getDragTableBtnRelevanceList() != null && dragTableVo.getDragTableBtnRelevanceList().size() > 0) {
|
|
|
dragTableBtnRelevanceService.batchInsertDragTableBtnRelevance(dragTableVo.getDragTableBtnRelevanceList());
|
|
|
}
|
|
|
}
|
|
@@ -355,7 +374,7 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
//update table_sql
|
|
|
TableSql tableSql = new TableSql();
|
|
|
tableSql.setTableSql(dragTableVo.getTableSql());
|
|
|
- // 拼接sql查询条件
|
|
|
+ // 拼接sql查询条件(超级查询)
|
|
|
switch (SecurityUtils.getDatabaseType().toUpperCase()) {
|
|
|
case "MYSQL":
|
|
|
SQL += SQL_START;
|
|
@@ -380,7 +399,17 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- String where = dragTableVo.getDtTableName() + ".del_flag = '0' AND ";
|
|
|
+ StringBuffer where = new StringBuffer();
|
|
|
+ // dragTableVo.getDtTableName() + ".del_flag = '0' AND ";
|
|
|
+ dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
+ try {
|
|
|
+ where.append(item +
|
|
|
+ URLDecoder.decode(dragTableVo.getConditionDefaultValueMap().get(item).toString(), "UTF-8")
|
|
|
+ + " AND ");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
tableSql.setTableCondition(where + SQL + SQL_END);
|
|
|
tableSql.setTableAlias(dragTableVo.getDtTableName());
|
|
|
tableSql.setSqlKey(dragTableVo.getSqlKey());
|
|
@@ -395,8 +424,12 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
//insert
|
|
|
List<DragTableCondition> dragTableConditionList = new ArrayList<>();
|
|
|
dragTableVo.getSearchFieldList().forEach(item -> {
|
|
|
- dragTableConditionList.add(new DragTableCondition(dragTable.gettId(),item));
|
|
|
+ dragTableConditionList.add(new DragTableCondition(dragTable.gettId(), item));
|
|
|
});
|
|
|
+ dragTableVo.getConditionDefaultValueMap().keySet().forEach(item -> {
|
|
|
+ dragTableConditionList.add(new DragTableCondition(dragTable.gettId(), item, dragTableVo.getConditionDefaultValueMap().get(item).toString()));
|
|
|
+ });
|
|
|
+
|
|
|
dragTableConditionMapper.insertDragTableConditionByList(dragTableConditionList);
|
|
|
}
|
|
|
}
|
|
@@ -417,3 +450,4 @@ public class DragTableServiceImpl implements IDragTableService {
|
|
|
return dragTableMapper.selectDragTableByTableKey(tableKey);
|
|
|
}
|
|
|
}
|
|
|
+
|