|
@@ -2,6 +2,7 @@ package domainService |
|
@@ -2,6 +2,7 @@ package domainService |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "sort"
|
5
|
"strings"
|
6
|
"strings"
|
6
|
|
7
|
|
7
|
"github.com/zeromicro/go-zero/core/collection"
|
8
|
"github.com/zeromicro/go-zero/core/collection"
|
|
@@ -27,6 +28,9 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
|
@@ -27,6 +28,9 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
27
|
// 加载Tables数据
|
28
|
// 加载Tables数据
|
28
|
q := queryComponents[0]
|
29
|
q := queryComponents[0]
|
29
|
cells := q.Layout.LayoutCells()
|
30
|
cells := q.Layout.LayoutCells()
|
|
|
31
|
+ if len(cells)==0{
|
|
|
32
|
+ return res,nil
|
|
|
33
|
+ }
|
30
|
dataTables, err = ptr.LoadDataTables(ctx, cells)
|
34
|
dataTables, err = ptr.LoadDataTables(ctx, cells)
|
31
|
if err != nil {
|
35
|
if err != nil {
|
32
|
return nil, err
|
36
|
return nil, err
|
|
@@ -42,7 +46,7 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
|
@@ -42,7 +46,7 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
42
|
cells[i].Length = length
|
46
|
cells[i].Length = length
|
43
|
cells[i].BlockData = blockData
|
47
|
cells[i].BlockData = blockData
|
44
|
}
|
48
|
}
|
45
|
- // 根据数据修改便宜
|
49
|
+ // 根据数据修改偏移
|
46
|
CellsLocationAdjust(cells)
|
50
|
CellsLocationAdjust(cells)
|
47
|
// 数据布局
|
51
|
// 数据布局
|
48
|
res, err = DataLayout(res, cells)
|
52
|
res, err = DataLayout(res, cells)
|
|
@@ -113,6 +117,61 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { |
|
@@ -113,6 +117,61 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { |
113
|
}
|
117
|
}
|
114
|
}
|
118
|
}
|
115
|
|
119
|
|
|
|
120
|
+func CellsLocationAdjustV1(cells []*domain.LayoutCell) {
|
|
|
121
|
+ yList:=cellsRange(cells,"y")
|
|
|
122
|
+ xList:=cellsRange(cells,"x")
|
|
|
123
|
+ for i := 0; i <len(yList); i++ {
|
|
|
124
|
+ j := yList[i]
|
|
|
125
|
+ move := 0
|
|
|
126
|
+ var c *domain.LayoutCell
|
|
|
127
|
+ for _, cell := range cells {
|
|
|
128
|
+ if cell.Y != j {
|
|
|
129
|
+ continue
|
|
|
130
|
+ }
|
|
|
131
|
+ if cell.Direction != domain.DirectionRight {
|
|
|
132
|
+ continue
|
|
|
133
|
+ }
|
|
|
134
|
+ if max(move, cell.Length) != move {
|
|
|
135
|
+ c = cell
|
|
|
136
|
+ }
|
|
|
137
|
+ move = max(move, cell.Length)
|
|
|
138
|
+ }
|
|
|
139
|
+ ChangeLocation(cells, domain.DirectionRight, j, move, c)
|
|
|
140
|
+ }
|
|
|
141
|
+ for j := 0; j <len(xList); j++ {
|
|
|
142
|
+ i := xList[j]
|
|
|
143
|
+ move := 0
|
|
|
144
|
+ var c *domain.LayoutCell
|
|
|
145
|
+ for _, cell := range cells {
|
|
|
146
|
+ if cell.X != i {
|
|
|
147
|
+ continue
|
|
|
148
|
+ }
|
|
|
149
|
+ if cell.Direction != domain.DirectionDown {
|
|
|
150
|
+ continue
|
|
|
151
|
+ }
|
|
|
152
|
+ if max(move, cell.Length) != move && c==nil {
|
|
|
153
|
+ c = cell
|
|
|
154
|
+ }
|
|
|
155
|
+ move = max(move, cell.Length)
|
|
|
156
|
+ }
|
|
|
157
|
+ ChangeLocation(cells, domain.DirectionDown, i, move, c)
|
|
|
158
|
+ }
|
|
|
159
|
+}
|
|
|
160
|
+
|
|
|
161
|
+func cellsRange(cells []*domain.LayoutCell,direction string)[]int{
|
|
|
162
|
+ list:=collection.NewSet()
|
|
|
163
|
+ for i:=range cells{
|
|
|
164
|
+ if strings.ToLower(direction)=="x"{
|
|
|
165
|
+ list.Add(cells[i].X)
|
|
|
166
|
+ }else{
|
|
|
167
|
+ list.Add(cells[i].Y)
|
|
|
168
|
+ }
|
|
|
169
|
+ }
|
|
|
170
|
+ sortList :=list.KeysInt()
|
|
|
171
|
+ sort.Ints(sortList)
|
|
|
172
|
+ return sortList
|
|
|
173
|
+}
|
|
|
174
|
+
|
116
|
func ChangeLocation(cells []*domain.LayoutCell, direction string, position, move int, c *domain.LayoutCell) {
|
175
|
func ChangeLocation(cells []*domain.LayoutCell, direction string, position, move int, c *domain.LayoutCell) {
|
117
|
// log.Logger.Info("修改定位点")
|
176
|
// log.Logger.Info("修改定位点")
|
118
|
if move == 0 {
|
177
|
if move == 0 {
|