|
@@ -75,150 +75,6 @@ func (tn *Table) AnalyTables(contactFormat *u.ContactFormat, isSite bool, codeSi
|
|
|
return ts
|
|
|
}
|
|
|
|
|
|
-//初始化组装纵向数据
|
|
|
-func initLongitudinalData(table *Table) [][]string {
|
|
|
- res := make([][]string, len(table.TRs[0].TDs)) //创建table第一行的列数长度
|
|
|
- for n, _ := range res {
|
|
|
- res[n] = []string{}
|
|
|
- }
|
|
|
- for _, tr := range table.TRs {
|
|
|
- for n, td := range table.TRs[0].TDs { //第一行的所有td
|
|
|
- td1 := table.GetTdByRCNo(tr.TDs[0].StartRow, td.StartCol) //根据行号列号获取td对象
|
|
|
- if td1 != nil {
|
|
|
- res[n] = append(res[n], td1.Val)
|
|
|
- } else {
|
|
|
- res[n] = append(res[n], "")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return res
|
|
|
-}
|
|
|
-
|
|
|
-//tr单列,是否丢弃内容
|
|
|
-func trSingleColumn(tr *TR, bcon bool, table *Table) bool {
|
|
|
- if len(tr.TDs) == 1 {
|
|
|
- bcon = false
|
|
|
- td := tr.TDs[0]
|
|
|
- if td.StartCol == 0 && td.EndCol+1 == table.ColNum && len([]rune(td.Val)) > 4 && len([]rune(td.Val)) < 50 {
|
|
|
- res, _, _, _, _ := CheckCommon(td.Val, "abandontable")
|
|
|
- if res { //以下内容丢弃
|
|
|
- bcon = true
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return bcon
|
|
|
-}
|
|
|
-
|
|
|
-//获取中标人顺序
|
|
|
-//direct 0默认 1横向 2纵向
|
|
|
-func GetBidOrder(td *TD, direct, n int) (d int, res bool) {
|
|
|
- if td.Valtype != "BO" {
|
|
|
- return
|
|
|
- }
|
|
|
- if td.Rowspan > 1 {
|
|
|
- for i := 0; i < td.Rowspan; i++ {
|
|
|
- nextcol := 1
|
|
|
- L1:
|
|
|
- for {
|
|
|
- vtd := td.TR.Table.GetTdByRCNo(td.StartRow+i, td.EndCol+nextcol)
|
|
|
- if vtd == nil {
|
|
|
- break L1
|
|
|
- }
|
|
|
- nextcol += vtd.Colspan
|
|
|
- if filter_zbdw_v2.MatchString(vtd.Val) {
|
|
|
- arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
- if arrbo == nil {
|
|
|
- arrbo = []map[string]interface{}{}
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
- }
|
|
|
- a1 := arrbo.([]map[string]interface{})
|
|
|
- a1 = append(a1, map[string]interface{}{
|
|
|
- "entname": vtd.Val,
|
|
|
- "sortstr": td.Val,
|
|
|
- "sort": GetBidSort(td.Val, n),
|
|
|
- })
|
|
|
- res = true
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if td.Colspan > 1 {
|
|
|
- for i := 1; i < td.Colspan; i++ {
|
|
|
- nextcol := 0
|
|
|
- L2:
|
|
|
- for {
|
|
|
- vtd := td.TR.Table.GetTdByRCNo(td.StartRow+i, td.StartCol+nextcol)
|
|
|
- if vtd == nil || vtd.Colspan >= td.Colspan {
|
|
|
- break L2
|
|
|
- }
|
|
|
- nextcol += vtd.Colspan
|
|
|
- if filter_zbdw_v2.MatchString(vtd.Val) {
|
|
|
- arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
- if arrbo == nil {
|
|
|
- arrbo = []map[string]interface{}{}
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
- }
|
|
|
- a1 := arrbo.([]map[string]interface{})
|
|
|
- a1 = append(a1, map[string]interface{}{
|
|
|
- "entname": vtd.Val,
|
|
|
- "sortstr": td.Val,
|
|
|
- "sort": GetBidSort(td.Val, n),
|
|
|
- })
|
|
|
- res = true
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- rtd := td.TR.Table.GetTdByRCNo(td.StartRow, td.EndCol+1)
|
|
|
- btd := td.TR.Table.GetTdByRCNo(td.EndRow+1, td.StartCol)
|
|
|
- //if ((rtd != nil && !rtd.BH && rtd.Valtype == "BO") || direct == 1) && btd != nil && filter_zbdw_v.MatchString(btd.Val) {
|
|
|
- if ((rtd != nil && !rtd.BH) || direct == 1) && btd != nil && filter_zbdw_v2.MatchString(btd.Val) {
|
|
|
- d = 1
|
|
|
- arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
- if arrbo == nil {
|
|
|
- arrbo = []map[string]interface{}{}
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
- }
|
|
|
- a1 := arrbo.([]map[string]interface{})
|
|
|
- a1 = append(a1, map[string]interface{}{
|
|
|
- "entname": btd.Val,
|
|
|
- "sortstr": td.Val,
|
|
|
- "sort": GetBidSort(td.Val, n),
|
|
|
- })
|
|
|
- res = true
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
- //} else if ((btd != nil && !btd.BH && btd.Valtype == "BO") || direct == 2) && rtd != nil && filter_zbdw_v.MatchString(rtd.Val) {
|
|
|
- } else if ((btd != nil && !btd.BH) || direct == 2) && rtd != nil && filter_zbdw_v2.MatchString(rtd.Val) {
|
|
|
- d = 2
|
|
|
- arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
- if arrbo == nil {
|
|
|
- arrbo = []map[string]interface{}{}
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
- }
|
|
|
- a1 := arrbo.([]map[string]interface{})
|
|
|
- a1 = append(a1, map[string]interface{}{
|
|
|
- "entname": rtd.Val,
|
|
|
- "sortstr": td.Val,
|
|
|
- "sort": GetBidSort(td.Val, n),
|
|
|
- })
|
|
|
- res = true
|
|
|
- td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-func GetBidSort(str string, n int) int {
|
|
|
- val := n
|
|
|
- if strings.Index(str, "首选") > -1 {
|
|
|
- val = 1
|
|
|
- } else {
|
|
|
- val = winnerOrderEntity.toNumber(str, n)
|
|
|
- }
|
|
|
- return val
|
|
|
-}
|
|
|
-
|
|
|
//查找每一个单元格的表头,调用FindNear
|
|
|
func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
if td.Val == "" || strings.TrimSpace(td.Val) == "" {
|
|
@@ -1138,3 +994,147 @@ func (tn *Table) assemblePackage(k1, v1, key string, isSite bool, codeSite strin
|
|
|
}
|
|
|
tn.BlockPackage.AddKey(key, bp)
|
|
|
}
|
|
|
+
|
|
|
+//初始化组装纵向数据
|
|
|
+func initLongitudinalData(table *Table) [][]string {
|
|
|
+ res := make([][]string, len(table.TRs[0].TDs)) //创建table第一行的列数长度
|
|
|
+ for n, _ := range res {
|
|
|
+ res[n] = []string{}
|
|
|
+ }
|
|
|
+ for _, tr := range table.TRs {
|
|
|
+ for n, td := range table.TRs[0].TDs { //第一行的所有td
|
|
|
+ td1 := table.GetTdByRCNo(tr.TDs[0].StartRow, td.StartCol) //根据行号列号获取td对象
|
|
|
+ if td1 != nil {
|
|
|
+ res[n] = append(res[n], td1.Val)
|
|
|
+ } else {
|
|
|
+ res[n] = append(res[n], "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|
|
|
+
|
|
|
+//tr单列,是否丢弃内容
|
|
|
+func trSingleColumn(tr *TR, bcon bool, table *Table) bool {
|
|
|
+ if len(tr.TDs) == 1 {
|
|
|
+ bcon = false
|
|
|
+ td := tr.TDs[0]
|
|
|
+ if td.StartCol == 0 && td.EndCol+1 == table.ColNum && len([]rune(td.Val)) > 4 && len([]rune(td.Val)) < 50 {
|
|
|
+ res, _, _, _, _ := CheckCommon(td.Val, "abandontable")
|
|
|
+ if res { //以下内容丢弃
|
|
|
+ bcon = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bcon
|
|
|
+}
|
|
|
+
|
|
|
+//获取中标人顺序
|
|
|
+//direct 0默认 1横向 2纵向
|
|
|
+func GetBidOrder(td *TD, direct, n int) (d int, res bool) {
|
|
|
+ if td.Valtype != "BO" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if td.Rowspan > 1 {
|
|
|
+ for i := 0; i < td.Rowspan; i++ {
|
|
|
+ nextcol := 1
|
|
|
+ L1:
|
|
|
+ for {
|
|
|
+ vtd := td.TR.Table.GetTdByRCNo(td.StartRow+i, td.EndCol+nextcol)
|
|
|
+ if vtd == nil {
|
|
|
+ break L1
|
|
|
+ }
|
|
|
+ nextcol += vtd.Colspan
|
|
|
+ if filter_zbdw_v2.MatchString(vtd.Val) {
|
|
|
+ arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
+ if arrbo == nil {
|
|
|
+ arrbo = []map[string]interface{}{}
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
+ }
|
|
|
+ a1 := arrbo.([]map[string]interface{})
|
|
|
+ a1 = append(a1, map[string]interface{}{
|
|
|
+ "entname": vtd.Val,
|
|
|
+ "sortstr": td.Val,
|
|
|
+ "sort": GetBidSort(td.Val, n),
|
|
|
+ })
|
|
|
+ res = true
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if td.Colspan > 1 {
|
|
|
+ for i := 1; i < td.Colspan; i++ {
|
|
|
+ nextcol := 0
|
|
|
+ L2:
|
|
|
+ for {
|
|
|
+ vtd := td.TR.Table.GetTdByRCNo(td.StartRow+i, td.StartCol+nextcol)
|
|
|
+ if vtd == nil || vtd.Colspan >= td.Colspan {
|
|
|
+ break L2
|
|
|
+ }
|
|
|
+ nextcol += vtd.Colspan
|
|
|
+ if filter_zbdw_v2.MatchString(vtd.Val) {
|
|
|
+ arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
+ if arrbo == nil {
|
|
|
+ arrbo = []map[string]interface{}{}
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
+ }
|
|
|
+ a1 := arrbo.([]map[string]interface{})
|
|
|
+ a1 = append(a1, map[string]interface{}{
|
|
|
+ "entname": vtd.Val,
|
|
|
+ "sortstr": td.Val,
|
|
|
+ "sort": GetBidSort(td.Val, n),
|
|
|
+ })
|
|
|
+ res = true
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ rtd := td.TR.Table.GetTdByRCNo(td.StartRow, td.EndCol+1)
|
|
|
+ btd := td.TR.Table.GetTdByRCNo(td.EndRow+1, td.StartCol)
|
|
|
+ //if ((rtd != nil && !rtd.BH && rtd.Valtype == "BO") || direct == 1) && btd != nil && filter_zbdw_v.MatchString(btd.Val) {
|
|
|
+ if ((rtd != nil && !rtd.BH) || direct == 1) && btd != nil && filter_zbdw_v2.MatchString(btd.Val) {
|
|
|
+ d = 1
|
|
|
+ arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
+ if arrbo == nil {
|
|
|
+ arrbo = []map[string]interface{}{}
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
+ }
|
|
|
+ a1 := arrbo.([]map[string]interface{})
|
|
|
+ a1 = append(a1, map[string]interface{}{
|
|
|
+ "entname": btd.Val,
|
|
|
+ "sortstr": td.Val,
|
|
|
+ "sort": GetBidSort(td.Val, n),
|
|
|
+ })
|
|
|
+ res = true
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
+ //} else if ((btd != nil && !btd.BH && btd.Valtype == "BO") || direct == 2) && rtd != nil && filter_zbdw_v.MatchString(rtd.Val) {
|
|
|
+ } else if ((btd != nil && !btd.BH) || direct == 2) && rtd != nil && filter_zbdw_v2.MatchString(rtd.Val) {
|
|
|
+ d = 2
|
|
|
+ arrbo := td.TR.Table.SortKV.Map[NullTxtBid]
|
|
|
+ if arrbo == nil {
|
|
|
+ arrbo = []map[string]interface{}{}
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, arrbo)
|
|
|
+ }
|
|
|
+ a1 := arrbo.([]map[string]interface{})
|
|
|
+ a1 = append(a1, map[string]interface{}{
|
|
|
+ "entname": rtd.Val,
|
|
|
+ "sortstr": td.Val,
|
|
|
+ "sort": GetBidSort(td.Val, n),
|
|
|
+ })
|
|
|
+ res = true
|
|
|
+ td.TR.Table.SortKV.AddKey(NullTxtBid, a1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetBidSort(str string, n int) int {
|
|
|
+ val := n
|
|
|
+ if strings.Index(str, "首选") > -1 {
|
|
|
+ val = 1
|
|
|
+ } else {
|
|
|
+ val = winnerOrderEntity.toNumber(str, n)
|
|
|
+ }
|
|
|
+ return val
|
|
|
+}
|