|
@@ -1,20 +1,25 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.ruoyi.common.utils.DateUtils;
|
|
|
-import com.ruoyi.system.entity.DragTable;
|
|
|
+import com.ruoyi.system.entity.DragTableCondition;
|
|
|
import com.ruoyi.system.entity.DragTableGroup;
|
|
|
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.service.IDragTableGroupService;
|
|
|
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 java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author hmc
|
|
@@ -34,6 +39,12 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
@Autowired
|
|
|
private DragTableServiceImpl dragTableService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DragTableConditionMapper dragTableConditionMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TableSqlMapper tableSqlMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询拖拽格组
|
|
|
*
|
|
@@ -72,23 +83,43 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
DragTableGroup dragTableGroup=new DragTableGroup();
|
|
|
BeanUtils.copyProperties(dragTableGroupVo,dragTableGroup);
|
|
|
//添加动态表格列表
|
|
|
- List<DragTableVo> dragTables = dragTableGroupVo.getDragTables();
|
|
|
- dragTables.forEach(item->{
|
|
|
- dragTableService.addDragTable(item);
|
|
|
- });
|
|
|
+ dragTableService.addDragTable(dragTableGroupVo);
|
|
|
return dragTableGroupMapper.insertDragTableGroup(dragTableGroup);
|
|
|
}
|
|
|
/**
|
|
|
* 修改拖拽格组
|
|
|
*
|
|
|
- * @param dragTableGroup 拖拽格组
|
|
|
+ * @param dragTableGroupVo 拖拽格组
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateDragTableGroup(DragTableGroup dragTableGroup)
|
|
|
+ public int updateDragTableGroup(DragTableGroupVo dragTableGroupVo)
|
|
|
{
|
|
|
- dragTableGroup.setUpdateTime(DateUtils.getNowDate());
|
|
|
- return dragTableGroupMapper.updateDragTableGroup(dragTableGroup);
|
|
|
+ //根据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());
|
|
|
+ //删除表格数据
|
|
|
+ dragTableMapper.deleteDragTableByTableKeys(tableKeys);
|
|
|
+ //删除条件数据
|
|
|
+ List<Long> dragTableIds = dragTableMapper.selectDragTableTableKeys(tableKeys)
|
|
|
+ .stream().map(item -> item.gettId()).collect(Collectors.toList());
|
|
|
+ dragTableConditionMapper.deleteDragTableConditionBytIds(dragTableIds);
|
|
|
+ //删除sql数据
|
|
|
+ Long[] dragTableIds1 = dragTableIds.toArray(new Long[0]);
|
|
|
+ tableSqlMapper.deleteTableSqlByTIds(dragTableIds1);
|
|
|
+ //修改表格组列表信息
|
|
|
+ DragTableGroup dragTableGroup=new DragTableGroup();
|
|
|
+ BeanUtils.copyProperties(dragTableGroupVo,dragTableGroup );
|
|
|
+ dragTableGroupMapper.updateDragTableGroup(dragTableGroup);
|
|
|
+ //从新插入数据
|
|
|
+ int insertRow = this.insertDragTableGroup(dragTableGroupVo);
|
|
|
+ return insertRow;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -103,17 +134,6 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
return dragTableGroupMapper.deleteDragTableGroupByIds(ids);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 删除拖拽格组信息
|
|
|
- *
|
|
|
- * @param id 拖拽格组主键
|
|
|
- * @return 结果
|
|
|
- */
|
|
|
- @Override
|
|
|
- public int deleteDragTableGroupById(Long id)
|
|
|
- {
|
|
|
- return dragTableGroupMapper.deleteDragTableGroupById(id);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 根据表格组key查询表格组信息
|
|
@@ -123,16 +143,67 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
|
|
|
@Override
|
|
|
public String selectDragTableGroup(String groupKey) {
|
|
|
String groupTableInfo = dragTableGroupMapper.selectDragTableGroupByGroupKey(groupKey);
|
|
|
- //HashMap hashMap = JSONObject.parseObject(groupTableInfo, HashMap.class);
|
|
|
- ////向 hashMap 中添加键值对
|
|
|
- //ArrayList<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(hashMap.entrySet());
|
|
|
- //Collections.sort(list, Comparator.comparing(Map.Entry::getValue));
|
|
|
- //// 遍历排序后的 ArrayList
|
|
|
- //HashMap<String,String> sortHashMap=new HashMap();
|
|
|
- //for (Map.Entry<String, Integer> entry : list) {
|
|
|
- // System.out.println(entry.getKey() + ":" + entry.getValue());
|
|
|
- // sortHashMap.put(entry.getKey(),entry.getValue().toString());
|
|
|
- //}
|
|
|
return groupTableInfo;
|
|
|
}
|
|
|
+
|
|
|
+ @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);
|
|
|
+ List<String> stringList=new ArrayList<>();
|
|
|
+ //收集下tableKey
|
|
|
+ jsonArray.forEach(e->{
|
|
|
+ JSONObject jsonObject = JSON.parseObject(e.toString());
|
|
|
+ String str = jsonObject.get("tableKey").toString();
|
|
|
+ stringList.add(str);
|
|
|
+ });
|
|
|
+ //根据tableKey批量查询表格数据
|
|
|
+ List<DragTableVo> dragTables = dragTableMapper.selectDragTableTableKeys(stringList).stream().map(item -> {
|
|
|
+ //拿到这个表格的所有条件数据
|
|
|
+ List<DragTableCondition> dragTableConditions = dragTableConditionMapper.selectDragTableConditionByTid(item.gettId());
|
|
|
+ //条件
|
|
|
+ item.setSearchFieldList(dragTableConditions.stream().map(it->it.getConditionField()).collect(Collectors.toList()));
|
|
|
+ //绑定的默认值map
|
|
|
+ HashMap<String, Object> conditionDefaultValueMap = new HashMap<>();
|
|
|
+ //关联条件
|
|
|
+ dragTableConditions.forEach(condition -> {
|
|
|
+ if (condition.getConditionDefaultValue() != null && condition.getConditionDefaultValue() != "") {
|
|
|
+ //条件字段:条件值
|
|
|
+ conditionDefaultValueMap.put(condition.getConditionField(), condition.getConditionDefaultValue());
|
|
|
+ item.setConditionDefaultValueMap(conditionDefaultValueMap);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ DragTableGroupVo dragTableGroupVo=new DragTableGroupVo();
|
|
|
+ BeanUtils.copyProperties(dragTableGroupOne, dragTableGroupVo);
|
|
|
+ dragTableGroupVo.setDragTables(dragTables);
|
|
|
+ //查询表格的关联数据
|
|
|
+ return dragTableGroupVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean selectDragTableGroupTableListSize(Long[] ids) {
|
|
|
+ List<DragTableGroup> dragTableGroups = dragTableGroupMapper.selectDragTableGroupByIdIn(ids);
|
|
|
+ List<String> tableKeys=new ArrayList<>();
|
|
|
+ //收集这个组下的所有tableKey
|
|
|
+ dragTableGroups.stream().forEach(item->{
|
|
|
+ JSONArray jsonArray = JSON.parseArray(item.getGroupTableInfo());
|
|
|
+ jsonArray.stream().forEach(
|
|
|
+ it ->{
|
|
|
+ tableKeys.add( JSONObject.parseObject(it.toString()).get("tableKey").toString());
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
+ //判断tableKey在表格表中出现了吗
|
|
|
+ List<DragTableVo> dragTableVos = dragTableMapper.selectDragTableTableKeys(tableKeys);
|
|
|
+ if(dragTableVos.size()>0){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|