|
@@ -4,25 +4,22 @@ import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
-import com.ruoyi.system.entity.DragTable;
|
|
|
-import com.ruoyi.system.entity.DragTableCondition;
|
|
|
-import com.ruoyi.system.entity.DragTableGroup;
|
|
|
-import com.ruoyi.system.entity.TableSql;
|
|
|
+import com.ruoyi.system.entity.*;
|
|
|
import com.ruoyi.system.entity.vo.DragTableGroupVo;
|
|
|
import com.ruoyi.system.entity.vo.DragTableVo;
|
|
|
-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.mapper.*;
|
|
|
+import com.ruoyi.system.service.ICommonService;
|
|
|
import com.ruoyi.system.service.IDragTableBtnRelevanceService;
|
|
|
import com.ruoyi.system.service.IDragTableGroupService;
|
|
|
+import com.ruoyi.system.service.ITableSqlService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.core.parameters.P;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -51,6 +48,19 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
|
|
|
@Autowired
|
|
|
private IDragTableBtnRelevanceService dragTableBtnRelevanceService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CommonMapper commonMapper;
|
|
|
+
|
|
|
+ @Resource // 动态sql
|
|
|
+ private ITableSqlService iTableSqlService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DragTableBtnRelevanceMapper dragTableBtnRelevanceMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DragTableBtnMapper dragTableBtnMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询拖拽格组
|
|
|
*
|
|
@@ -124,7 +134,7 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
public static final String SQL_END = "LIKE '%#{val}%'";
|
|
|
|
|
|
/**
|
|
|
- * 修改拖拽格组
|
|
|
+ * 修改联动表格拖拽格组
|
|
|
*
|
|
|
* @param dragTableGroupVo 拖拽格组
|
|
|
* @return 结果
|
|
@@ -214,6 +224,12 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改表格表单拖拽格组
|
|
|
+ *
|
|
|
+ * @param dragTableGroupVo 拖拽格组
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
@Override
|
|
|
public int editConfigurationGroup(DragTableGroupVo dragTableGroupVo) {
|
|
|
//根据id查询表格组信息
|
|
@@ -237,7 +253,7 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
//add drag_table
|
|
|
DragTable dragTable = new DragTable();
|
|
|
BeanUtils.copyProperties(dragTableVo, dragTable);
|
|
|
- dragTable.setDtColumnName(dragTableVo.getDtColumnName().toString());
|
|
|
+ dragTable.setDtColumnName(JSONObject.toJSONString(dragTableVo.getDtColumnName()));
|
|
|
dragTable.setPrimaryKey(dragTableVo.getPrimaryKey());
|
|
|
dragTable.setMenuId(dragTableVo.getMenuId());
|
|
|
dragTable.setDtType("1");
|
|
@@ -245,7 +261,8 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
TableSql tableSql = new TableSql();
|
|
|
tableSql.setSqlKey(dragTableVo.getSqlKey());
|
|
|
tableSql.setTableSql(dragTableVo.getTableSql());
|
|
|
- dragTableMapper.updateDragTable(dragTable);
|
|
|
+ int i1 = dragTableMapper.updateDragTable(dragTable);
|
|
|
+ System.out.println(i1);
|
|
|
//拼接sql查询条件
|
|
|
switch (SecurityUtils.getDatabaseType().toUpperCase()) {
|
|
|
case "MYSQL":
|
|
@@ -346,31 +363,19 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
return groupTableInfo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询表格组包含的详细信息
|
|
|
+ * @param dragTableGroup
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public DragTableGroupVo selectDragTableGroupListDetail(DragTableGroup dragTableGroup) {
|
|
|
//根据id查询表格组信息
|
|
|
DragTableGroup dragTableGroupOne = dragTableGroupMapper.selectDragTableGroupById(dragTableGroup.getId());
|
|
|
//得到group_table_info
|
|
|
String groupTableInfo = dragTableGroupOne.getGroupTableInfo();
|
|
|
- //把他转换成Map对象
|
|
|
- JSONArray jsonArray = JSON.parseArray(groupTableInfo);
|
|
|
- //排序确保表格的顺序
|
|
|
- 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();
|
|
|
- DragTable dragTable = dragTableMapper.selectDragTableByTableKey(str);
|
|
|
- DragTableVo dragTableVo=new DragTableVo();
|
|
|
- BeanUtils.copyProperties(dragTable, dragTableVo);
|
|
|
- dragTableList.add( dragTableVo);
|
|
|
- });
|
|
|
+ //抽取的方法(处理排序查表格数据)
|
|
|
+ List<DragTableVo> dragTableList = getDragTableVos(groupTableInfo);
|
|
|
//查询这个动态表格的 1.条件 2.sql信息
|
|
|
dragTableList.stream().map(item -> {
|
|
|
//拿到这个表格的所有条件数据
|
|
@@ -401,6 +406,32 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
return dragTableGroupVo;
|
|
|
}
|
|
|
|
|
|
+ private List<DragTableVo> getDragTableVos(String groupTableInfo) {
|
|
|
+ //把他转换成Map对象
|
|
|
+ JSONArray jsonArray = JSON.parseArray(groupTableInfo);
|
|
|
+ //排序确保表格的顺序
|
|
|
+ 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();
|
|
|
+ DragTable dragTable = dragTableMapper.selectDragTableByTableKey(str);
|
|
|
+ DragTableVo dragTableVo=new DragTableVo();
|
|
|
+ BeanUtils.copyProperties(dragTable, dragTableVo);
|
|
|
+ dragTableList.add( dragTableVo);
|
|
|
+ });
|
|
|
+ return dragTableList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询当前组下是否包含有表格信息
|
|
|
+ */
|
|
|
@Override
|
|
|
public Boolean selectDragTableGroupTableListSize(Long[] ids) {
|
|
|
List<DragTableGroup> dragTableGroups = dragTableGroupMapper.selectDragTableGroupByIdIn(ids);
|
|
@@ -422,5 +453,103 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 工艺工序弹窗里边的表格结构信息
|
|
|
+ * @param commonEntity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonEntity getProcessPopupTableInfo(CommonEntity commonEntity) {
|
|
|
+ String groupKey = commonEntity.getQueryMap().get("groupKey").toString();
|
|
|
+ //查询组信息
|
|
|
+ DragTableGroup dragTableGroup = dragTableGroupMapper.selectDragTableGroupOneByGroupKey(groupKey);
|
|
|
+ //把[{"tableKey":"a1","sort":0},{"tableKey":"a2","sort":1}]转换成Map对象
|
|
|
+ JSONArray jsonArray = JSON.parseArray( dragTableGroup.getGroupTableInfo());
|
|
|
+ //排序确保表格的顺序
|
|
|
+ JSONArray sortArray = jsonArray.stream().sorted(
|
|
|
+ Comparator.comparingLong(
|
|
|
+ // 根据对象中的ID进行排序
|
|
|
+ e -> JSONObject.parseObject(e.toString()).getIntValue("sort")
|
|
|
+ )
|
|
|
+ ).collect(Collectors.toCollection(JSONArray::new));
|
|
|
+ //用in查询
|
|
|
+ List<String> tableKeys = new ArrayList<>();
|
|
|
+ sortArray.stream().forEach(item->tableKeys.add(JSONObject.parseObject(item.toString()).get("tableKey").toString()));
|
|
|
+ //查询表格信息
|
|
|
+ List<DragTableVo> dragTableVos = dragTableMapper.selectDragTableTableKeysOrderby(tableKeys);
|
|
|
+ //查询表格按钮信息
|
|
|
+ dragTableVos.forEach(item->{
|
|
|
+ // 动态表格按钮信息
|
|
|
+ //根据tableKey获取根节点信息
|
|
|
+ List<String> btnKeys = dragTableBtnRelevanceMapper.selectBtnKeyByTableKey(item.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()){
|
|
|
+ item.setDragTableBtnList(rootNodes);
|
|
|
+ }else {
|
|
|
+ List<DragTableBtn> childNodes = dragTableBtnMapper.selectChildNodeById(ids);
|
|
|
+ List<DragTableBtn> btnList = rootNodes.stream().peek(
|
|
|
+ root -> root.setChildren(getChildrenList(root, childNodes))
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ item.setDragTableBtnList(btnList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ CommonEntity common=new CommonEntity();
|
|
|
+ dragTableVos.forEach(item->{
|
|
|
+ //结果Map
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put(item.getTableKey(), item);
|
|
|
+ common.setResultMap(resultMap);
|
|
|
+ });
|
|
|
+ return common;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工艺工序弹窗里边的表格数据信息
|
|
|
+ * @param commonEntity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public CommonEntity getProcessPopupTableList(CommonEntity commonEntity) {
|
|
|
+ //拿到表格组名称
|
|
|
+ String groupKey = commonEntity.getQueryMap().get("groupKey").toString();
|
|
|
+ //查询表格组信息
|
|
|
+ String groupTableInfo = dragTableGroupMapper.selectDragTableGroupByGroupKey(groupKey);
|
|
|
+ //查询出来的表信息
|
|
|
+ List<DragTableVo> dragTableVos = getDragTableVos(groupTableInfo);
|
|
|
+ //根据sqlKey查询TableSql数据
|
|
|
+ CommonEntity common=new CommonEntity();
|
|
|
+ dragTableVos.forEach(item->{
|
|
|
+ TableSql tableSql = iTableSqlService.selectTableSqlByTSqlKey(item.getSqlKey());
|
|
|
+ //sql的条件值
|
|
|
+ AtomicReference<String> tableSqlTableCondition= new AtomicReference<>(tableSql.getTableCondition());
|
|
|
+ //循环替换条件占位的值
|
|
|
+ commonEntity.getQueryMap().forEach((k,v)->{
|
|
|
+ tableSqlTableCondition.set(tableSqlTableCondition.get().replace(k, v.toString()));
|
|
|
+ });
|
|
|
+ //sql的执行语句
|
|
|
+ String sqlString = tableSql.getTableSql() + " where " + tableSqlTableCondition;
|
|
|
+ List<CommonEntity> commonEntities = commonMapper.queryTableList(sqlString);
|
|
|
+ common.getResultMap().put(item.getTableKey(),commonEntities);
|
|
|
+ });
|
|
|
+ return common;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //得到按钮表格的循环
|
|
|
+ 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子节点
|
|
|
+ dragTableBtn.setChildren(this.getChildrenList(dragTableBtn, childNodes));
|
|
|
+ return dragTableBtn;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
|
|
|
}
|