作者 linmadan

添加新的布局算法

1 module gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion 1 module gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion
2 2
3 -go 1.16 3 +go 1.19
4 4
5 require ( 5 require (
6 - github.com/ajg/form v1.5.1 // indirect  
7 - github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible // indirect 6 + github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible
8 github.com/beego/beego/v2 v2.0.1 7 github.com/beego/beego/v2 v2.0.1
9 github.com/bwmarrin/snowflake v0.3.0 8 github.com/bwmarrin/snowflake v0.3.0
10 github.com/dgrijalva/jwt-go v3.2.0+incompatible 9 github.com/dgrijalva/jwt-go v3.2.0+incompatible
11 github.com/extrame/xls v0.0.1 10 github.com/extrame/xls v0.0.1
12 - github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect  
13 - github.com/fatih/structs v1.1.0 // indirect  
14 github.com/gavv/httpexpect v2.0.0+incompatible 11 github.com/gavv/httpexpect v2.0.0+incompatible
15 github.com/go-gota/gota v0.12.0 12 github.com/go-gota/gota v0.12.0
16 github.com/go-pg/pg/v10 v10.10.6 13 github.com/go-pg/pg/v10 v10.10.6
17 github.com/go-redis/redis v6.15.9+incompatible 14 github.com/go-redis/redis v6.15.9+incompatible
18 - github.com/google/go-querystring v1.1.0 // indirect  
19 github.com/google/gofuzz v1.2.0 15 github.com/google/gofuzz v1.2.0
20 github.com/google/uuid v1.3.0 16 github.com/google/uuid v1.3.0
21 github.com/gookit/event v1.0.6 17 github.com/gookit/event v1.0.6
22 - github.com/imkira/go-interpol v1.1.0 // indirect  
23 github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 18 github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7
24 - github.com/moul/http2curl v1.0.0 // indirect  
25 github.com/onsi/ginkgo v1.16.5 19 github.com/onsi/ginkgo v1.16.5
26 github.com/onsi/gomega v1.18.1 20 github.com/onsi/gomega v1.18.1
27 github.com/patrickmn/go-cache v2.1.0+incompatible 21 github.com/patrickmn/go-cache v2.1.0+incompatible
28 - github.com/sergi/go-diff v1.2.0 // indirect  
29 github.com/shopspring/decimal v1.3.1 22 github.com/shopspring/decimal v1.3.1
30 - github.com/silenceper/wechat/v2 v2.1.4 // indirect  
31 - github.com/smartystreets/goconvey v1.7.2 // indirect  
32 github.com/stretchr/testify v1.7.1 23 github.com/stretchr/testify v1.7.1
  24 + github.com/xuri/excelize/v2 v2.6.0
  25 + github.com/zeromicro/go-zero v1.3.4
  26 + golang.org/x/text v0.3.7
  27 + gorm.io/driver/mysql v1.3.6
  28 + gorm.io/driver/postgres v1.3.9
  29 + gorm.io/gorm v1.23.8
  30 +)
  31 +
  32 +require (
  33 + github.com/Shopify/sarama v1.30.0 // indirect
  34 + github.com/ajg/form v1.5.1 // indirect
  35 + github.com/andybalholm/brotli v1.0.4 // indirect
  36 + github.com/beorn7/perks v1.0.1 // indirect
  37 + github.com/cespare/xxhash/v2 v2.1.2 // indirect
  38 + github.com/davecgh/go-spew v1.1.1 // indirect
  39 + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
  40 + github.com/eapache/go-resiliency v1.2.0 // indirect
  41 + github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
  42 + github.com/eapache/queue v1.1.0 // indirect
  43 + github.com/extrame/goyymmdd v0.0.0-20210114090516-7cc815f00d1a // indirect
  44 + github.com/extrame/ole2 v0.0.0-20160812065207-d69429661ad7 // indirect
  45 + github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
  46 + github.com/fatih/color v1.13.0 // indirect
  47 + github.com/fatih/structs v1.1.0 // indirect
  48 + github.com/fsnotify/fsnotify v1.4.9 // indirect
  49 + github.com/go-logr/logr v1.2.3 // indirect
  50 + github.com/go-logr/stdr v1.2.2 // indirect
  51 + github.com/go-pg/zerochecker v0.2.0 // indirect
  52 + github.com/go-redis/redis/v8 v8.11.5 // indirect
  53 + github.com/go-sql-driver/mysql v1.6.0 // indirect
  54 + github.com/golang/protobuf v1.5.2 // indirect
  55 + github.com/golang/snappy v0.0.4 // indirect
  56 + github.com/google/go-querystring v1.1.0 // indirect
  57 + github.com/gorilla/websocket v1.4.2 // indirect
  58 + github.com/hashicorp/go-uuid v1.0.2 // indirect
  59 + github.com/hashicorp/golang-lru v0.5.4 // indirect
  60 + github.com/imkira/go-interpol v1.1.0 // indirect
  61 + github.com/jackc/chunkreader/v2 v2.0.1 // indirect
  62 + github.com/jackc/pgconn v1.12.1 // indirect
  63 + github.com/jackc/pgio v1.0.0 // indirect
  64 + github.com/jackc/pgpassfile v1.0.0 // indirect
  65 + github.com/jackc/pgproto3/v2 v2.3.0 // indirect
  66 + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
  67 + github.com/jackc/pgtype v1.11.0 // indirect
  68 + github.com/jackc/pgx/v4 v4.16.1 // indirect
  69 + github.com/jcmturner/aescts/v2 v2.0.0 // indirect
  70 + github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
  71 + github.com/jcmturner/gofork v1.0.0 // indirect
  72 + github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
  73 + github.com/jcmturner/rpc/v2 v2.0.3 // indirect
  74 + github.com/jinzhu/inflection v1.0.0 // indirect
  75 + github.com/jinzhu/now v1.1.5 // indirect
  76 + github.com/klauspost/compress v1.15.0 // indirect
  77 + github.com/mattn/go-colorable v0.1.9 // indirect
  78 + github.com/mattn/go-isatty v0.0.14 // indirect
  79 + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
  80 + github.com/mitchellh/mapstructure v1.3.3 // indirect
  81 + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
  82 + github.com/moul/http2curl v1.0.0 // indirect
  83 + github.com/mozillazg/go-pinyin v0.19.0 // indirect
  84 + github.com/nxadm/tail v1.4.8 // indirect
  85 + github.com/openzipkin/zipkin-go v0.4.0 // indirect
  86 + github.com/pelletier/go-toml/v2 v2.0.1 // indirect
  87 + github.com/pierrec/lz4 v2.6.1+incompatible // indirect
  88 + github.com/pkg/errors v0.9.1 // indirect
  89 + github.com/pmezard/go-difflib v1.0.0 // indirect
  90 + github.com/prometheus/client_golang v1.12.2 // indirect
  91 + github.com/prometheus/client_model v0.2.0 // indirect
  92 + github.com/prometheus/common v0.32.1 // indirect
  93 + github.com/prometheus/procfs v0.7.3 // indirect
  94 + github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
  95 + github.com/richardlehane/mscfb v1.0.4 // indirect
  96 + github.com/richardlehane/msoleps v1.0.1 // indirect
  97 + github.com/sergi/go-diff v1.2.0 // indirect
  98 + github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
  99 + github.com/sirupsen/logrus v1.9.0 // indirect
  100 + github.com/smartystreets/goconvey v1.7.2 // indirect
  101 + github.com/spaolacci/murmur3 v1.1.0 // indirect
  102 + github.com/tealeg/xlsx v1.0.5 // indirect
  103 + github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
  104 + github.com/valyala/bytebufferpool v1.0.0 // indirect
33 github.com/valyala/fasthttp v1.38.0 // indirect 105 github.com/valyala/fasthttp v1.38.0 // indirect
  106 + github.com/vmihailenco/bufpool v0.1.11 // indirect
  107 + github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
  108 + github.com/vmihailenco/tagparser v0.1.2 // indirect
  109 + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
  110 + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
  111 + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
34 github.com/xeipuuv/gojsonschema v1.2.0 // indirect 112 github.com/xeipuuv/gojsonschema v1.2.0 // indirect
35 github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect 113 github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
36 - github.com/xuri/excelize/v2 v2.6.0 114 + github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
37 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect 115 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
38 github.com/yudai/gojsondiff v1.0.0 // indirect 116 github.com/yudai/gojsondiff v1.0.0 // indirect
39 github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect 117 github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
40 github.com/yudai/pp v2.0.1+incompatible // indirect 118 github.com/yudai/pp v2.0.1+incompatible // indirect
41 - github.com/zeromicro/go-zero v1.3.4  
42 - golang.org/x/text v0.3.7  
43 - gorm.io/driver/mysql v1.3.6  
44 - gorm.io/driver/postgres v1.3.9  
45 - gorm.io/gorm v1.23.8 119 + go.opentelemetry.io/otel v1.7.0 // indirect
  120 + go.opentelemetry.io/otel/exporters/jaeger v1.7.0 // indirect
  121 + go.opentelemetry.io/otel/exporters/zipkin v1.7.0 // indirect
  122 + go.opentelemetry.io/otel/sdk v1.7.0 // indirect
  123 + go.opentelemetry.io/otel/trace v1.7.0 // indirect
  124 + go.uber.org/automaxprocs v1.5.1 // indirect
  125 + golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
  126 + golang.org/x/mod v0.4.2 // indirect
  127 + golang.org/x/net v0.0.0-20220421235706-1d1ef9303861 // indirect
  128 + golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
  129 + golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
  130 + golang.org/x/tools v0.1.5 // indirect
  131 + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
  132 + gonum.org/v1/gonum v0.9.1 // indirect
  133 + google.golang.org/grpc v1.46.2 // indirect
  134 + google.golang.org/protobuf v1.28.0 // indirect
  135 + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
  136 + gopkg.in/yaml.v2 v2.4.0 // indirect
  137 + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
  138 + mellium.im/sasl v0.2.1 // indirect
46 ) 139 )
47 140
48 replace ( 141 replace (
@@ -59,6 +59,38 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain @@ -59,6 +59,38 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain
59 } 59 }
60 60
61 func CellsLocationAdjust(cells []*domain.LayoutCell) { 61 func CellsLocationAdjust(cells []*domain.LayoutCell) {
  62 + if len(cells) > 0 {
  63 + addedRows := 0
  64 + addedColumns := 0
  65 + preRowMaxDownLength := 0
  66 + preRawCellX := 0
  67 + for _, cell := range cells {
  68 + if preRawCellX != cell.X {
  69 + addedColumns = 0
  70 + addedRows = addedRows + preRowMaxDownLength - 1
  71 + preRowMaxDownLength = 0
  72 + preRawCellX = cell.X
  73 + }
  74 + switch cell.Direction {
  75 + case domain.DirectionRight:
  76 + cell.X = addedRows + cell.X
  77 + cell.Y = addedColumns + cell.Y
  78 + addedColumns = addedColumns + cell.Length - 1
  79 + case domain.DirectionDown:
  80 + cell.X = addedRows + cell.X
  81 + cell.Y = addedColumns + cell.Y
  82 + if cell.Length > preRowMaxDownLength {
  83 + preRowMaxDownLength = cell.Length
  84 + }
  85 + case domain.DirectionNone:
  86 + cell.X = addedRows + cell.X
  87 + cell.Y = addedColumns + cell.Y
  88 + }
  89 + }
  90 + }
  91 +}
  92 +
  93 +func CellsLocationAdjustOld(cells []*domain.LayoutCell) {
62 xMin := 0 94 xMin := 0
63 xMax := 0 95 xMax := 0
64 yMin := 0 96 yMin := 0
  1 +package domainService
  2 +
  3 +import (
  4 + "github.com/stretchr/testify/assert"
  5 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
  6 + "testing"
  7 +)
  8 +
  9 +func TestNewDataLayout(t *testing.T) {
  10 + inputs := []struct {
  11 + cells []*domain.LayoutCell
  12 + flag Location
  13 + title string
  14 + debug bool
  15 + }{
  16 + {
  17 + title: "配置组多组混合",
  18 + cells: []*domain.LayoutCell{
  19 + // 分组一
  20 + {
  21 + X: 0,
  22 + Y: 0,
  23 + Length: 2,
  24 + ImageData: "2",
  25 + Direction: domain.DirectionRight,
  26 + },
  27 + {
  28 + X: 0,
  29 + Y: 1,
  30 + Length: 3,
  31 + ImageData: "3",
  32 + Direction: domain.DirectionRight,
  33 + },
  34 + {
  35 + X: 0,
  36 + Y: 2,
  37 + Length: 1,
  38 + ImageData: "",
  39 + Direction: domain.DirectionRight,
  40 + },
  41 + {
  42 + X: 0,
  43 + Y: 4,
  44 + Length: 5,
  45 + ImageData: "5",
  46 + Direction: domain.DirectionDown,
  47 + },
  48 + {
  49 + X: 1,
  50 + Y: 1,
  51 + Length: 2,
  52 + ImageData: "a",
  53 + Direction: domain.DirectionDown,
  54 + },
  55 + {
  56 + X: 1,
  57 + Y: 2,
  58 + Length: 2,
  59 + ImageData: "f",
  60 + Direction: domain.DirectionDown,
  61 + },
  62 + {
  63 + X: 1,
  64 + Y: 3,
  65 + Length: 2,
  66 + ImageData: "b",
  67 + Direction: domain.DirectionDown,
  68 + },
  69 + {
  70 + X: 2,
  71 + Y: 0,
  72 + Length: 2,
  73 + ImageData: "e",
  74 + Direction: domain.DirectionDown,
  75 + },
  76 + {
  77 + X: 2,
  78 + Y: 1,
  79 + Length: 1,
  80 + ImageData: "c",
  81 + Direction: domain.DirectionNone,
  82 + },
  83 + {
  84 + X: 2,
  85 + Y: 2,
  86 + Length: 1,
  87 + ImageData: "d",
  88 + Direction: domain.DirectionNone,
  89 + },
  90 + {
  91 + X: 5,
  92 + Y: 0,
  93 + Length: 6,
  94 + ImageData: "g",
  95 + Direction: domain.DirectionDown,
  96 + },
  97 + },
  98 + flag: Location{X: 2, Y: 2},
  99 + },
  100 + }
  101 + padding := func(cells []*domain.LayoutCell) {
  102 + for _, cell := range cells {
  103 + for i := 0; i < cell.Length; i++ {
  104 + cell.BlockData = append(cell.BlockData, cell.ImageData)
  105 + }
  106 + }
  107 + }
  108 + debugItem := false
  109 + for _, input := range inputs {
  110 + if debugItem && !input.debug {
  111 + continue
  112 + }
  113 + padding(input.cells)
  114 + // 根据数据修改位移
  115 + CellsLocationAdjust(input.cells)
  116 + // 数据布局
  117 + res := &domain.DataTable{}
  118 + res, err := DataLayout(res, input.cells)
  119 + if err != nil {
  120 + assert.NoError(t, err)
  121 + }
  122 + printRes(res)
  123 + }
  124 +}
@@ -75,456 +75,398 @@ func TestDataLayout(t *testing.T) { @@ -75,456 +75,398 @@ func TestDataLayout(t *testing.T) {
75 ImageData: "d", 75 ImageData: "d",
76 Direction: domain.DirectionNone, 76 Direction: domain.DirectionNone,
77 }, 77 },
78 -  
79 - //分组二 右平移10  
80 - {  
81 - X: 0,  
82 - Y: 10,  
83 - Length: 2,  
84 - ImageData: "2",  
85 - Direction: domain.DirectionRight,  
86 - },  
87 - {  
88 - X: 0,  
89 - Y: 11,  
90 - Length: 3,  
91 - ImageData: "3",  
92 - Direction: domain.DirectionRight,  
93 - },  
94 - {  
95 - X: 1,  
96 - Y: 10,  
97 - Length: 2,  
98 - ImageData: "a",  
99 - Direction: domain.DirectionDown,  
100 - },  
101 - {  
102 - X: 1,  
103 - Y: 11,  
104 - Length: 2,  
105 - ImageData: "f",  
106 - Direction: domain.DirectionDown,  
107 - },  
108 - {  
109 - X: 1,  
110 - Y: 12,  
111 - Length: 2,  
112 - ImageData: "b",  
113 - Direction: domain.DirectionDown,  
114 - },  
115 - {  
116 - X: 1,  
117 - Y: 13,  
118 - Length: 2,  
119 - ImageData: "e",  
120 - Direction: domain.DirectionDown,  
121 - },  
122 - {  
123 - X: 2,  
124 - Y: 10,  
125 - Length: 1,  
126 - ImageData: "c",  
127 - Direction: domain.DirectionNone,  
128 - },  
129 - {  
130 - X: 2,  
131 - Y: 11,  
132 - Length: 1,  
133 - ImageData: "d",  
134 - Direction: domain.DirectionNone,  
135 - },  
136 }, 78 },
137 flag: Location{X: 2, Y: 2}, 79 flag: Location{X: 2, Y: 2},
138 }, 80 },
139 - {  
140 - title: "正常多字段横排",  
141 - cells: []*domain.LayoutCell{  
142 - // 分组一  
143 - {  
144 - X: 0,  
145 - Y: 0,  
146 - Length: 5,  
147 - ImageData: "a",  
148 - Direction: domain.DirectionRight,  
149 - },  
150 - {  
151 - X: 1,  
152 - Y: 0,  
153 - Length: 5,  
154 - ImageData: "b",  
155 - Direction: domain.DirectionRight,  
156 - },  
157 - {  
158 - X: 2,  
159 - Y: 0,  
160 - Length: 5,  
161 - ImageData: "c",  
162 - Direction: domain.DirectionRight,  
163 - },  
164 - {  
165 - X: 3,  
166 - Y: 0,  
167 - Length: 5,  
168 - ImageData: "d",  
169 - Direction: domain.DirectionRight,  
170 - },  
171 -  
172 - // 分组二 平移10  
173 - {  
174 - X: 0,  
175 - Y: 10,  
176 - Length: 5,  
177 - ImageData: "a",  
178 - Direction: domain.DirectionRight,  
179 - },  
180 - {  
181 - X: 1,  
182 - Y: 10,  
183 - Length: 5,  
184 - ImageData: "b",  
185 - Direction: domain.DirectionRight,  
186 - },  
187 - {  
188 - X: 2,  
189 - Y: 10,  
190 - Length: 5,  
191 - ImageData: "c",  
192 - Direction: domain.DirectionRight,  
193 - },  
194 - {  
195 - X: 3,  
196 - Y: 10,  
197 - Length: 5,  
198 - ImageData: "d",  
199 - Direction: domain.DirectionRight,  
200 - },  
201 - },  
202 - flag: Location{X: 3, Y: 4},  
203 - },  
204 -  
205 - {  
206 - title: "正常多字段横排+计算项目",  
207 - cells: []*domain.LayoutCell{  
208 - // 分组一  
209 - {  
210 - X: 0,  
211 - Y: 0,  
212 - Length: 5,  
213 - ImageData: "a",  
214 - Direction: domain.DirectionRight,  
215 - },  
216 - {  
217 - X: 1,  
218 - Y: 0,  
219 - Length: 5,  
220 - ImageData: "b",  
221 - Direction: domain.DirectionRight,  
222 - },  
223 - {  
224 - X: 2,  
225 - Y: 0,  
226 - Length: 1,  
227 - ImageData: "c",  
228 - Direction: domain.DirectionNone,  
229 - },  
230 - {  
231 - X: 3,  
232 - Y: 0,  
233 - Length: 1,  
234 - ImageData: "d",  
235 - Direction: domain.DirectionNone,  
236 - },  
237 -  
238 - // 分组二 平移10  
239 - {  
240 - X: 0,  
241 - Y: 10,  
242 - Length: 1,  
243 - ImageData: "a",  
244 - Direction: domain.DirectionRight,  
245 - },  
246 - {  
247 - X: 1,  
248 - Y: 10,  
249 - Length: 5,  
250 - ImageData: "b",  
251 - Direction: domain.DirectionRight,  
252 - },  
253 - {  
254 - X: 2,  
255 - Y: 10,  
256 - Length: 1,  
257 - ImageData: "c",  
258 - Direction: domain.DirectionNone,  
259 - },  
260 - {  
261 - X: 2,  
262 - Y: 11,  
263 - Length: 1,  
264 - ImageData: "e",  
265 - Direction: domain.DirectionNone,  
266 - },  
267 - {  
268 - X: 3,  
269 - Y: 10,  
270 - Length: 1,  
271 - ImageData: "d",  
272 - Direction: domain.DirectionNone,  
273 - },  
274 - },  
275 - flag: Location{X: 2, Y: 1},  
276 - },  
277 -  
278 - {  
279 - title: "正常多字段横排+竖排",  
280 - cells: []*domain.LayoutCell{  
281 - // 分组一  
282 - {  
283 - X: 0,  
284 - Y: 0,  
285 - Length: 5,  
286 - ImageData: "a",  
287 - Direction: domain.DirectionRight,  
288 - },  
289 - {  
290 - X: 0,  
291 - Y: 1,  
292 - Length: 5,  
293 - ImageData: "b",  
294 - Direction: domain.DirectionDown,  
295 - },  
296 - {  
297 - X: 1,  
298 - Y: 0,  
299 - Length: 5,  
300 - ImageData: "c",  
301 - Direction: domain.DirectionRight,  
302 - },  
303 - {  
304 - X: 2,  
305 - Y: 0,  
306 - Length: 5,  
307 - ImageData: "d",  
308 - Direction: domain.DirectionRight,  
309 - },  
310 - },  
311 - flag: Location{X: 2, Y: 1},  
312 - },  
313 -  
314 - {  
315 - title: "正常多字段横排(长度不一样)+竖排",  
316 - cells: []*domain.LayoutCell{  
317 - // 分组一  
318 - {  
319 - X: 0,  
320 - Y: 0,  
321 - Length: 5,  
322 - ImageData: "a",  
323 - Direction: domain.DirectionRight,  
324 - },  
325 - {  
326 - X: 0,  
327 - Y: 1,  
328 - Length: 5,  
329 - ImageData: "b",  
330 - Direction: domain.DirectionDown,  
331 - },  
332 - {  
333 - X: 1,  
334 - Y: 0,  
335 - Length: 6,  
336 - ImageData: "c",  
337 - Direction: domain.DirectionRight,  
338 - },  
339 - {  
340 - X: 2,  
341 - Y: 0,  
342 - Length: 7,  
343 - ImageData: "d",  
344 - Direction: domain.DirectionRight,  
345 - },  
346 - },  
347 - flag: Location{X: 2, Y: 1},  
348 - },  
349 -  
350 - {  
351 - title: "测试用例1",  
352 - cells: []*domain.LayoutCell{  
353 - // 分组一  
354 - {  
355 - X: 0,  
356 - Y: 0,  
357 - Length: 1,  
358 - ImageData: "a",  
359 - Direction: domain.DirectionNone,  
360 - },  
361 - {  
362 - X: 0,  
363 - Y: 1,  
364 - Length: 1,  
365 - ImageData: "b",  
366 - Direction: domain.DirectionNone,  
367 - },  
368 - {  
369 - X: 2,  
370 - Y: 2,  
371 - Length: 5,  
372 - ImageData: "c",  
373 - Direction: domain.DirectionRight,  
374 - },  
375 - },  
376 - flag: Location{X: 0, Y: 0},  
377 - },  
378 - {  
379 - title: "测试用例3",  
380 - cells: []*domain.LayoutCell{  
381 - // 分组一  
382 - {  
383 - X: 0,  
384 - Y: 0,  
385 - Length: 5,  
386 - ImageData: "a",  
387 - Direction: domain.DirectionRight,  
388 - },  
389 - {  
390 - X: 1,  
391 - Y: 0,  
392 - Length: 5,  
393 - ImageData: "b",  
394 - Direction: domain.DirectionDown,  
395 - },  
396 - {  
397 - X: 1,  
398 - Y: 1,  
399 - Length: 5,  
400 - ImageData: "c",  
401 - Direction: domain.DirectionRight,  
402 - },  
403 - {  
404 - X: 2,  
405 - Y: 1,  
406 - Length: 5,  
407 - ImageData: "d",  
408 - Direction: domain.DirectionRight,  
409 - },  
410 - },  
411 - flag: Location{X: 2, Y: 1},  
412 - },  
413 - {  
414 - title: "测试用例4",  
415 - cells: []*domain.LayoutCell{  
416 - // 分组一  
417 - {  
418 - X: 0,  
419 - Y: 0,  
420 - Length: 5,  
421 - ImageData: "a",  
422 - Direction: domain.DirectionDown,  
423 - },  
424 - {  
425 - X: 0,  
426 - Y: 1,  
427 - Length: 5,  
428 - ImageData: "b",  
429 - Direction: domain.DirectionDown,  
430 - },  
431 - // ,  
432 - // {  
433 - // X: 1,  
434 - // Y: 1,  
435 - // Length: 5,  
436 - // ImageData: "c",  
437 - // Direction: domain.DirectionRight,  
438 - // },  
439 - // {  
440 - // X: 2,  
441 - // Y: 1,  
442 - // Length: 5,  
443 - // ImageData: "d",  
444 - // Direction: domain.DirectionRight,  
445 - // },  
446 - },  
447 - flag: Location{X: 0, Y: 0},  
448 - },  
449 - {  
450 - title: "测试用例5",  
451 - cells: []*domain.LayoutCell{  
452 - // 分组一  
453 - {  
454 - X: 0,  
455 - Y: 0,  
456 - Length: 5,  
457 - ImageData: "a",  
458 - Direction: domain.DirectionDown,  
459 - },  
460 - {  
461 - X: 0,  
462 - Y: 1,  
463 - Length: 6,  
464 - ImageData: "b",  
465 - Direction: domain.DirectionDown,  
466 - },  
467 - {  
468 - X: 1,  
469 - Y: 0,  
470 - Length: 1,  
471 - ImageData: "t",  
472 - Direction: domain.DirectionNone,  
473 - },  
474 - {  
475 - X: 1,  
476 - Y: 1,  
477 - Length: 1,  
478 - ImageData: "x",  
479 - Direction: domain.DirectionNone,  
480 - },  
481 - // ,  
482 - // {  
483 - // X: 1,  
484 - // Y: 1,  
485 - // Length: 5,  
486 - // ImageData: "c",  
487 - // Direction: domain.DirectionRight,  
488 - // },  
489 - // {  
490 - // X: 2,  
491 - // Y: 1,  
492 - // Length: 5,  
493 - // ImageData: "d",  
494 - // Direction: domain.DirectionRight,  
495 - // },  
496 - },  
497 - flag: Location{X: 0, Y: 0},  
498 - debug:true,  
499 - },  
500 - {  
501 - title: "测试用例6",  
502 - cells: []*domain.LayoutCell{  
503 - // 分组一  
504 - {  
505 - X: 0,  
506 - Y: 0,  
507 - Length: 1,  
508 - ImageData: "a",  
509 - Direction: domain.DirectionNone,  
510 - },  
511 - {  
512 - X: 1,  
513 - Y: 1,  
514 - Length: 5,  
515 - ImageData: "c",  
516 - Direction: domain.DirectionRight,  
517 - },  
518 - {  
519 - X: 2,  
520 - Y: 1,  
521 - Length: 5,  
522 - ImageData: "d",  
523 - Direction: domain.DirectionRight,  
524 - },  
525 - },  
526 - flag: Location{X: 0, Y: 0},  
527 - }, 81 + //{
  82 + // title: "正常多字段横排",
  83 + // cells: []*domain.LayoutCell{
  84 + // // 分组一
  85 + // {
  86 + // X: 0,
  87 + // Y: 0,
  88 + // Length: 5,
  89 + // ImageData: "a",
  90 + // Direction: domain.DirectionRight,
  91 + // },
  92 + // {
  93 + // X: 1,
  94 + // Y: 0,
  95 + // Length: 5,
  96 + // ImageData: "b",
  97 + // Direction: domain.DirectionRight,
  98 + // },
  99 + // {
  100 + // X: 2,
  101 + // Y: 0,
  102 + // Length: 5,
  103 + // ImageData: "c",
  104 + // Direction: domain.DirectionRight,
  105 + // },
  106 + // {
  107 + // X: 3,
  108 + // Y: 0,
  109 + // Length: 5,
  110 + // ImageData: "d",
  111 + // Direction: domain.DirectionRight,
  112 + // },
  113 + //
  114 + // // 分组二 平移10
  115 + // {
  116 + // X: 0,
  117 + // Y: 10,
  118 + // Length: 5,
  119 + // ImageData: "a",
  120 + // Direction: domain.DirectionRight,
  121 + // },
  122 + // {
  123 + // X: 1,
  124 + // Y: 10,
  125 + // Length: 5,
  126 + // ImageData: "b",
  127 + // Direction: domain.DirectionRight,
  128 + // },
  129 + // {
  130 + // X: 2,
  131 + // Y: 10,
  132 + // Length: 5,
  133 + // ImageData: "c",
  134 + // Direction: domain.DirectionRight,
  135 + // },
  136 + // {
  137 + // X: 3,
  138 + // Y: 10,
  139 + // Length: 5,
  140 + // ImageData: "d",
  141 + // Direction: domain.DirectionRight,
  142 + // },
  143 + // },
  144 + // flag: Location{X: 3, Y: 4},
  145 + //},
  146 + //
  147 + //{
  148 + // title: "正常多字段横排+计算项目",
  149 + // cells: []*domain.LayoutCell{
  150 + // // 分组一
  151 + // {
  152 + // X: 0,
  153 + // Y: 0,
  154 + // Length: 5,
  155 + // ImageData: "a",
  156 + // Direction: domain.DirectionRight,
  157 + // },
  158 + // {
  159 + // X: 1,
  160 + // Y: 0,
  161 + // Length: 5,
  162 + // ImageData: "b",
  163 + // Direction: domain.DirectionRight,
  164 + // },
  165 + // {
  166 + // X: 2,
  167 + // Y: 0,
  168 + // Length: 1,
  169 + // ImageData: "c",
  170 + // Direction: domain.DirectionNone,
  171 + // },
  172 + // {
  173 + // X: 3,
  174 + // Y: 0,
  175 + // Length: 1,
  176 + // ImageData: "d",
  177 + // Direction: domain.DirectionNone,
  178 + // },
  179 + //
  180 + // // 分组二 平移10
  181 + // {
  182 + // X: 0,
  183 + // Y: 10,
  184 + // Length: 1,
  185 + // ImageData: "a",
  186 + // Direction: domain.DirectionRight,
  187 + // },
  188 + // {
  189 + // X: 1,
  190 + // Y: 10,
  191 + // Length: 5,
  192 + // ImageData: "b",
  193 + // Direction: domain.DirectionRight,
  194 + // },
  195 + // {
  196 + // X: 2,
  197 + // Y: 10,
  198 + // Length: 1,
  199 + // ImageData: "c",
  200 + // Direction: domain.DirectionNone,
  201 + // },
  202 + // {
  203 + // X: 2,
  204 + // Y: 11,
  205 + // Length: 1,
  206 + // ImageData: "e",
  207 + // Direction: domain.DirectionNone,
  208 + // },
  209 + // {
  210 + // X: 3,
  211 + // Y: 10,
  212 + // Length: 1,
  213 + // ImageData: "d",
  214 + // Direction: domain.DirectionNone,
  215 + // },
  216 + // },
  217 + // flag: Location{X: 2, Y: 1},
  218 + //},
  219 + //
  220 + //{
  221 + // title: "正常多字段横排+竖排",
  222 + // cells: []*domain.LayoutCell{
  223 + // // 分组一
  224 + // {
  225 + // X: 0,
  226 + // Y: 0,
  227 + // Length: 5,
  228 + // ImageData: "a",
  229 + // Direction: domain.DirectionRight,
  230 + // },
  231 + // {
  232 + // X: 0,
  233 + // Y: 1,
  234 + // Length: 5,
  235 + // ImageData: "b",
  236 + // Direction: domain.DirectionDown,
  237 + // },
  238 + // {
  239 + // X: 1,
  240 + // Y: 0,
  241 + // Length: 5,
  242 + // ImageData: "c",
  243 + // Direction: domain.DirectionRight,
  244 + // },
  245 + // {
  246 + // X: 2,
  247 + // Y: 0,
  248 + // Length: 5,
  249 + // ImageData: "d",
  250 + // Direction: domain.DirectionRight,
  251 + // },
  252 + // },
  253 + // flag: Location{X: 2, Y: 1},
  254 + //},
  255 + //
  256 + //{
  257 + // title: "正常多字段横排(长度不一样)+竖排",
  258 + // cells: []*domain.LayoutCell{
  259 + // // 分组一
  260 + // {
  261 + // X: 0,
  262 + // Y: 0,
  263 + // Length: 5,
  264 + // ImageData: "a",
  265 + // Direction: domain.DirectionRight,
  266 + // },
  267 + // {
  268 + // X: 0,
  269 + // Y: 1,
  270 + // Length: 5,
  271 + // ImageData: "b",
  272 + // Direction: domain.DirectionDown,
  273 + // },
  274 + // {
  275 + // X: 1,
  276 + // Y: 0,
  277 + // Length: 6,
  278 + // ImageData: "c",
  279 + // Direction: domain.DirectionRight,
  280 + // },
  281 + // {
  282 + // X: 2,
  283 + // Y: 0,
  284 + // Length: 7,
  285 + // ImageData: "d",
  286 + // Direction: domain.DirectionRight,
  287 + // },
  288 + // },
  289 + // flag: Location{X: 2, Y: 1},
  290 + //},
  291 + //
  292 + //{
  293 + // title: "测试用例1",
  294 + // cells: []*domain.LayoutCell{
  295 + // // 分组一
  296 + // {
  297 + // X: 0,
  298 + // Y: 0,
  299 + // Length: 1,
  300 + // ImageData: "a",
  301 + // Direction: domain.DirectionNone,
  302 + // },
  303 + // {
  304 + // X: 0,
  305 + // Y: 1,
  306 + // Length: 1,
  307 + // ImageData: "b",
  308 + // Direction: domain.DirectionNone,
  309 + // },
  310 + // {
  311 + // X: 2,
  312 + // Y: 2,
  313 + // Length: 5,
  314 + // ImageData: "c",
  315 + // Direction: domain.DirectionRight,
  316 + // },
  317 + // },
  318 + // flag: Location{X: 0, Y: 0},
  319 + //},
  320 + //{
  321 + // title: "测试用例3",
  322 + // cells: []*domain.LayoutCell{
  323 + // // 分组一
  324 + // {
  325 + // X: 0,
  326 + // Y: 0,
  327 + // Length: 5,
  328 + // ImageData: "a",
  329 + // Direction: domain.DirectionRight,
  330 + // },
  331 + // {
  332 + // X: 1,
  333 + // Y: 0,
  334 + // Length: 5,
  335 + // ImageData: "b",
  336 + // Direction: domain.DirectionDown,
  337 + // },
  338 + // {
  339 + // X: 1,
  340 + // Y: 1,
  341 + // Length: 5,
  342 + // ImageData: "c",
  343 + // Direction: domain.DirectionRight,
  344 + // },
  345 + // {
  346 + // X: 2,
  347 + // Y: 1,
  348 + // Length: 5,
  349 + // ImageData: "d",
  350 + // Direction: domain.DirectionRight,
  351 + // },
  352 + // },
  353 + // flag: Location{X: 2, Y: 1},
  354 + //},
  355 + //{
  356 + // title: "测试用例4",
  357 + // cells: []*domain.LayoutCell{
  358 + // // 分组一
  359 + // {
  360 + // X: 0,
  361 + // Y: 0,
  362 + // Length: 5,
  363 + // ImageData: "a",
  364 + // Direction: domain.DirectionDown,
  365 + // },
  366 + // {
  367 + // X: 0,
  368 + // Y: 1,
  369 + // Length: 5,
  370 + // ImageData: "b",
  371 + // Direction: domain.DirectionDown,
  372 + // },
  373 + // // ,
  374 + // // {
  375 + // // X: 1,
  376 + // // Y: 1,
  377 + // // Length: 5,
  378 + // // ImageData: "c",
  379 + // // Direction: domain.DirectionRight,
  380 + // // },
  381 + // // {
  382 + // // X: 2,
  383 + // // Y: 1,
  384 + // // Length: 5,
  385 + // // ImageData: "d",
  386 + // // Direction: domain.DirectionRight,
  387 + // // },
  388 + // },
  389 + // flag: Location{X: 0, Y: 0},
  390 + //},
  391 + //{
  392 + // title: "测试用例5",
  393 + // cells: []*domain.LayoutCell{
  394 + // // 分组一
  395 + // {
  396 + // X: 0,
  397 + // Y: 0,
  398 + // Length: 5,
  399 + // ImageData: "a",
  400 + // Direction: domain.DirectionDown,
  401 + // },
  402 + // {
  403 + // X: 0,
  404 + // Y: 1,
  405 + // Length: 6,
  406 + // ImageData: "b",
  407 + // Direction: domain.DirectionDown,
  408 + // },
  409 + // {
  410 + // X: 1,
  411 + // Y: 0,
  412 + // Length: 1,
  413 + // ImageData: "t",
  414 + // Direction: domain.DirectionNone,
  415 + // },
  416 + // {
  417 + // X: 1,
  418 + // Y: 1,
  419 + // Length: 1,
  420 + // ImageData: "x",
  421 + // Direction: domain.DirectionNone,
  422 + // },
  423 + // // ,
  424 + // // {
  425 + // // X: 1,
  426 + // // Y: 1,
  427 + // // Length: 5,
  428 + // // ImageData: "c",
  429 + // // Direction: domain.DirectionRight,
  430 + // // },
  431 + // // {
  432 + // // X: 2,
  433 + // // Y: 1,
  434 + // // Length: 5,
  435 + // // ImageData: "d",
  436 + // // Direction: domain.DirectionRight,
  437 + // // },
  438 + // },
  439 + // flag: Location{X: 0, Y: 0},
  440 + // debug:true,
  441 + //},
  442 + //{
  443 + // title: "测试用例6",
  444 + // cells: []*domain.LayoutCell{
  445 + // // 分组一
  446 + // {
  447 + // X: 0,
  448 + // Y: 0,
  449 + // Length: 1,
  450 + // ImageData: "a",
  451 + // Direction: domain.DirectionNone,
  452 + // },
  453 + // {
  454 + // X: 1,
  455 + // Y: 1,
  456 + // Length: 5,
  457 + // ImageData: "c",
  458 + // Direction: domain.DirectionRight,
  459 + // },
  460 + // {
  461 + // X: 2,
  462 + // Y: 1,
  463 + // Length: 5,
  464 + // ImageData: "d",
  465 + // Direction: domain.DirectionRight,
  466 + // },
  467 + // },
  468 + // flag: Location{X: 0, Y: 0},
  469 + //},
528 } 470 }
529 padding := func(cells []*domain.LayoutCell) { 471 padding := func(cells []*domain.LayoutCell) {
530 for _, cell := range cells { 472 for _, cell := range cells {
@@ -533,9 +475,9 @@ func TestDataLayout(t *testing.T) { @@ -533,9 +475,9 @@ func TestDataLayout(t *testing.T) {
533 } 475 }
534 } 476 }
535 } 477 }
536 - debugItem:= false 478 + debugItem := false
537 for _, input := range inputs { 479 for _, input := range inputs {
538 - if debugItem && !input.debug{ 480 + if debugItem && !input.debug {
539 continue 481 continue
540 } 482 }
541 padding(input.cells) 483 padding(input.cells)