...
|
...
|
@@ -2,6 +2,7 @@ package domainService |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"sort"
|
|
|
"strings"
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/collection"
|
...
|
...
|
@@ -27,6 +28,9 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
|
|
// 加载Tables数据
|
|
|
q := queryComponents[0]
|
|
|
cells := q.Layout.LayoutCells()
|
|
|
if len(cells)==0{
|
|
|
return res,nil
|
|
|
}
|
|
|
dataTables, err = ptr.LoadDataTables(ctx, cells)
|
|
|
if err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -42,7 +46,7 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
|
|
cells[i].Length = length
|
|
|
cells[i].BlockData = blockData
|
|
|
}
|
|
|
// 根据数据修改便宜
|
|
|
// 根据数据修改偏移
|
|
|
CellsLocationAdjust(cells)
|
|
|
// 数据布局
|
|
|
res, err = DataLayout(res, cells)
|
...
|
...
|
@@ -113,6 +117,61 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
func CellsLocationAdjustV1(cells []*domain.LayoutCell) {
|
|
|
yList:=cellsRange(cells,"y")
|
|
|
xList:=cellsRange(cells,"x")
|
|
|
for i := 0; i <len(yList); i++ {
|
|
|
j := yList[i]
|
|
|
move := 0
|
|
|
var c *domain.LayoutCell
|
|
|
for _, cell := range cells {
|
|
|
if cell.Y != j {
|
|
|
continue
|
|
|
}
|
|
|
if cell.Direction != domain.DirectionRight {
|
|
|
continue
|
|
|
}
|
|
|
if max(move, cell.Length) != move {
|
|
|
c = cell
|
|
|
}
|
|
|
move = max(move, cell.Length)
|
|
|
}
|
|
|
ChangeLocation(cells, domain.DirectionRight, j, move, c)
|
|
|
}
|
|
|
for j := 0; j <len(xList); j++ {
|
|
|
i := xList[j]
|
|
|
move := 0
|
|
|
var c *domain.LayoutCell
|
|
|
for _, cell := range cells {
|
|
|
if cell.X != i {
|
|
|
continue
|
|
|
}
|
|
|
if cell.Direction != domain.DirectionDown {
|
|
|
continue
|
|
|
}
|
|
|
if max(move, cell.Length) != move && c==nil {
|
|
|
c = cell
|
|
|
}
|
|
|
move = max(move, cell.Length)
|
|
|
}
|
|
|
ChangeLocation(cells, domain.DirectionDown, i, move, c)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func cellsRange(cells []*domain.LayoutCell,direction string)[]int{
|
|
|
list:=collection.NewSet()
|
|
|
for i:=range cells{
|
|
|
if strings.ToLower(direction)=="x"{
|
|
|
list.Add(cells[i].X)
|
|
|
}else{
|
|
|
list.Add(cells[i].Y)
|
|
|
}
|
|
|
}
|
|
|
sortList :=list.KeysInt()
|
|
|
sort.Ints(sortList)
|
|
|
return sortList
|
|
|
}
|
|
|
|
|
|
func ChangeLocation(cells []*domain.LayoutCell, direction string, position, move int, c *domain.LayoutCell) {
|
|
|
// log.Logger.Info("修改定位点")
|
|
|
if move == 0 {
|
...
|
...
|
|