|
@@ -207,21 +207,20 @@ func (table *Table) KVFilter() {
|
|
|
if !winnertag {
|
|
|
winnertag = iswinnertabletag.MatchString(table.Tag) && !nswinnertabletag.MatchString(table.TableResult.BlockTag) //块标签
|
|
|
}
|
|
|
- table.analyTdKV() //1.td元素有内嵌kv,遍历放入table的Kv中2.td有子表格的处理,中标候选人排序
|
|
|
+ table.analyTdKV() //1.遍历每行每列td的sortkv添加到table.SorkVK中;2.td有子表格的处理
|
|
|
as := NewSortMap()
|
|
|
- //表格描述处理,对成交结果的处理
|
|
|
+
|
|
|
+ //遍历table.sortkv,进行过滤处理,并放入标准化KV中,如果值是数组跳到下一步处理
|
|
|
for _, k := range table.SortKV.Keys {
|
|
|
+ //表格描述处理,对成交结果的处理
|
|
|
if regexp.MustCompile("(成交|中标|候选|排名|名次|供应商排序)").MatchString(k) {
|
|
|
table.Desc += "成交结果,"
|
|
|
}
|
|
|
- }
|
|
|
- //遍历table.sortkv,进行过滤处理,并放入标准化KV中,如果值是数组跳到下一步处理
|
|
|
- for _, k := range table.SortKV.Keys {
|
|
|
if regexp.MustCompile("^单价").MatchString(k) {
|
|
|
continue
|
|
|
}
|
|
|
v := table.SortKV.Map[k]
|
|
|
- if _, ok := v.(string); ok {
|
|
|
+ if _, ok := v.(string); ok { //table.SortKV.Value为字符串,匹配抽取关键词table.SortKV.Key,匹配到添加k,v到table.StandKV,table.StandKVWeight
|
|
|
k = regSpliteSegment.ReplaceAllString(regReplAllSpace.ReplaceAllString(k, ""), "")
|
|
|
k1, w1, v1, tag, b := CommonDataAnaly(k, table.Tag, table.Desc, v) //对key标准化处理,没有找到会走中标
|
|
|
//qutil.Debug(k, v, k1, w1, v1, tag, b)
|
|
@@ -235,7 +234,7 @@ func (table *Table) KVFilter() {
|
|
|
if tag != "" && table.Tag == "" {
|
|
|
table.Tag = tag
|
|
|
}
|
|
|
- for pos, k2 := range k1 {
|
|
|
+ for pos, k2 := range k1 { //根据关键词,过滤table.SortKV到table.StandKV和table.StandKVWeight
|
|
|
if table.StandKV[k2] == "" || w1[pos] > table.StandKVWeight[k2] {
|
|
|
table.StandKV[k2] = v1 //本节点
|
|
|
table.StandKVWeight[k2] = w1[pos]
|
|
@@ -254,9 +253,84 @@ func (table *Table) KVFilter() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //处理值是数组的kv放入标准化kv中
|
|
|
+ //处理值是数组的kv放入标准化kv中//处理table.SortKV.value为数组的情况
|
|
|
+ table.sortKVArr(as, winnertag)
|
|
|
+ //
|
|
|
+ if filterTableWror.MatchString(table.Tag) {
|
|
|
+ table.WinnerOrder = nil
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if len(table.WinnerOrder) > 0 || !table.BPackage {
|
|
|
+ winnerOrder := []map[string]interface{}{}
|
|
|
+ maxSort := 0
|
|
|
+ //调整顺序
|
|
|
+ for i := 0; i < 2; i++ {
|
|
|
+ for _, v := range table.WinnerOrder {
|
|
|
+ sortstr, _ := v["sortstr"].(string)
|
|
|
+ if (i == 0 && sortstr == "") || (i == 1 && sortstr != "") {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ sort, _ := v["sort"].(int)
|
|
|
+ if i == 0 {
|
|
|
+ if maxSort == 0 || sort > maxSort {
|
|
|
+ maxSort = sort
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ maxSort++
|
|
|
+ v["sort"] = maxSort
|
|
|
+ }
|
|
|
+ winnerOrder = append(winnerOrder, v)
|
|
|
+ }
|
|
|
+ if len(winnerOrder) == len(table.WinnerOrder) {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ table.WinnerOrder = winnerOrder
|
|
|
+ winnerOrder = []map[string]interface{}{}
|
|
|
+ L: //遍历每个td,查询中标人
|
|
|
+ for _, tr := range table.TRs {
|
|
|
+ for _, td := range tr.TDs {
|
|
|
+ winnerOrder = winnerOrderEntity.Find(td.Val, true, 3)
|
|
|
+ if len(winnerOrder) > 0 {
|
|
|
+ break L
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(table.WinnerOrder) > 0 {
|
|
|
+ //中标候选人合并
|
|
|
+ winnerOrderEntity.Merge(table.WinnerOrder, winnerOrder)
|
|
|
+ if table.StandKV["中标单位"] == "" {
|
|
|
+ ent := table.WinnerOrder[0]["entname"]
|
|
|
+ if ent != nil {
|
|
|
+ table.StandKV["中标单位"], _ = ent.(string)
|
|
|
+ table.StandKVWeight["中标单位"] = -25
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if !table.BPackage { //没有table.WinnerOrder也没有分包 将td中的WinnerOrder赋值给table.WinnerOrder
|
|
|
+ if len(winnerOrder) > 1 {
|
|
|
+ table.WinnerOrder = winnerOrder
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //对中标候选人进行排序
|
|
|
+ winnerOrderEntity.Order(table.WinnerOrder)
|
|
|
+ //该表格有一个分包,并且有中标候选人排序的情况下,把中标候选人放到包里面
|
|
|
+ if table.BlockPackage != nil && table.BlockPackage.Keys != nil && len(table.BlockPackage.Keys) == 1 {
|
|
|
+ if table.BlockPackage.Map != nil {
|
|
|
+ onePkgKey := table.BlockPackage.Keys[0]
|
|
|
+ onePkg, _ := table.BlockPackage.Map[onePkgKey].(*u.BlockPackage)
|
|
|
+ if onePkg != nil && onePkg.WinnerOrder != nil && len(onePkg.WinnerOrder) == 0 {
|
|
|
+ onePkg.WinnerOrder = table.WinnerOrder
|
|
|
+ table.BlockPackage.Map[onePkgKey] = onePkg
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//处理table.SortKV.value为数组的情况
|
|
|
+func (table *Table) sortKVArr(as *SortMap, winnertag bool) {
|
|
|
checkKey := map[int]bool{}
|
|
|
- for kn, k := range as.Keys {
|
|
|
+ for kn, k := range as.Keys { //遍历table.SortKV.value为数组的key
|
|
|
v := as.Map[k]
|
|
|
if vm, ok := v.([]map[string]interface{}); ok && k == NullTxtBid {
|
|
|
if table.WinnerOrder == nil {
|
|
@@ -408,79 +482,9 @@ func (table *Table) KVFilter() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //
|
|
|
- if filterTableWror.MatchString(table.Tag) {
|
|
|
- table.WinnerOrder = nil
|
|
|
- }
|
|
|
- //
|
|
|
- if len(table.WinnerOrder) > 0 || !table.BPackage {
|
|
|
- winnerOrder := []map[string]interface{}{}
|
|
|
- maxSort := 0
|
|
|
- //调整顺序
|
|
|
- for i := 0; i < 2; i++ {
|
|
|
- for _, v := range table.WinnerOrder {
|
|
|
- sortstr, _ := v["sortstr"].(string)
|
|
|
- if (i == 0 && sortstr == "") || (i == 1 && sortstr != "") {
|
|
|
- continue
|
|
|
- }
|
|
|
- sort, _ := v["sort"].(int)
|
|
|
- if i == 0 {
|
|
|
- if maxSort == 0 || sort > maxSort {
|
|
|
- maxSort = sort
|
|
|
- }
|
|
|
- } else {
|
|
|
- maxSort++
|
|
|
- v["sort"] = maxSort
|
|
|
- }
|
|
|
- winnerOrder = append(winnerOrder, v)
|
|
|
- }
|
|
|
- if len(winnerOrder) == len(table.WinnerOrder) {
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- table.WinnerOrder = winnerOrder
|
|
|
- winnerOrder = []map[string]interface{}{}
|
|
|
- L:
|
|
|
- for _, tr := range table.TRs {
|
|
|
- for _, td := range tr.TDs {
|
|
|
- winnerOrder = winnerOrderEntity.Find(td.Val, true, 3)
|
|
|
- if len(winnerOrder) > 0 {
|
|
|
- break L
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if len(table.WinnerOrder) > 0 {
|
|
|
- //中标候选人合并
|
|
|
- winnerOrderEntity.Merge(table.WinnerOrder, winnerOrder)
|
|
|
- if table.StandKV["中标单位"] == "" {
|
|
|
- ent := table.WinnerOrder[0]["entname"]
|
|
|
- if ent != nil {
|
|
|
- table.StandKV["中标单位"], _ = ent.(string)
|
|
|
- table.StandKVWeight["中标单位"] = -25
|
|
|
- }
|
|
|
- }
|
|
|
- } else if !table.BPackage { //没有table.WinnerOrder也没有分包 将td中的WinnerOrder赋值给table.WinnerOrder
|
|
|
- if len(winnerOrder) > 1 {
|
|
|
- table.WinnerOrder = winnerOrder
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //对中标候选人进行排序
|
|
|
- winnerOrderEntity.Order(table.WinnerOrder)
|
|
|
- //该表格有一个分包,并且有中标候选人排序的情况下,把中标候选人放到包里面
|
|
|
- if table.BlockPackage != nil && table.BlockPackage.Keys != nil && len(table.BlockPackage.Keys) == 1 {
|
|
|
- if table.BlockPackage.Map != nil {
|
|
|
- onePkgKey := table.BlockPackage.Keys[0]
|
|
|
- onePkg, _ := table.BlockPackage.Map[onePkgKey].(*u.BlockPackage)
|
|
|
- if onePkg != nil && onePkg.WinnerOrder != nil && len(onePkg.WinnerOrder) == 0 {
|
|
|
- onePkg.WinnerOrder = table.WinnerOrder
|
|
|
- table.BlockPackage.Map[onePkgKey] = onePkg
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
-//1.td元素有内嵌kv,遍历放入table的Kv中2.td有子表格的处理,中标候选人排序
|
|
|
+//1.遍历每行每列td的sortkv添加到table.SorkVK中;2.td有子表格的处理
|
|
|
func (table *Table) analyTdKV() {
|
|
|
//遍历每一行
|
|
|
for _, tr := range table.TRs {
|
|
@@ -502,7 +506,7 @@ func (table *Table) analyTdKV() {
|
|
|
if td.HeadTd != nil && len([]rune(k3)) < 4 {
|
|
|
k3 = td.HeadTd.Val + k3
|
|
|
}
|
|
|
- if table.SortKV.Map[k3] == nil {
|
|
|
+ if table.SortKV.Map[k3] == nil && _val != nil && _val != "" {
|
|
|
//u.Debug(k3, _val)
|
|
|
//if !thisFlag || (thisFlag && table.SortKV.Map[k3] == nil) {
|
|
|
table.SortKV.AddKey(k3, _val)
|
|
@@ -768,8 +772,8 @@ func (table *Table) createTabe(trs *goquery.Selection) {
|
|
|
}
|
|
|
|
|
|
//对table进行整体解析处理
|
|
|
-func (table *Table) AnalyTables(contactFormat *u.ContactFormat) []*Table {
|
|
|
- ts := table.tableSubDemolitionTable() //分包,拆表
|
|
|
+func (tn *Table) AnalyTables(contactFormat *u.ContactFormat) []*Table {
|
|
|
+ ts := tn.tableSubDemolitionTable() //分包,拆表
|
|
|
for n, table := range ts {
|
|
|
//处理每个table
|
|
|
if len(table.TRs) > 0 {
|
|
@@ -1436,6 +1440,9 @@ func (table *Table) FindKV() {
|
|
|
}
|
|
|
if len(td.SortKV.Map) > 0 {
|
|
|
for tdk, tdv := range td.SortKV.Map {
|
|
|
+ if tdv == nil || tdv == "" {//value为空或者null不再添加到table.SortKV
|
|
|
+ continue
|
|
|
+ }
|
|
|
table.SortKV.AddKey(tdk, tdv)
|
|
|
}
|
|
|
}
|
|
@@ -1759,11 +1766,22 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
if bvalfind {
|
|
|
vals[varrpos] = td.Val // += "__" + td.Val
|
|
|
} else {
|
|
|
- vals = append(vals, td.Val)
|
|
|
- val = vals
|
|
|
+ //添加时候去除空值和nil
|
|
|
+ newVals := []string{}
|
|
|
+ for _, isval := range vals {
|
|
|
+ if isval == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ newVals = append(newVals, isval)
|
|
|
+ }
|
|
|
+ //vals = append(vals, td.Val)
|
|
|
+ if td.Val != "" {
|
|
|
+ newVals = append(newVals, td.Val)
|
|
|
+ }
|
|
|
+ val = newVals
|
|
|
varrpos = len(vals) - 1
|
|
|
}
|
|
|
- } else if vals, ok := val.(string); ok {
|
|
|
+ } else if vals, ok := val.(string); ok && vals != "" && td.Val != "" {
|
|
|
if bvalfind {
|
|
|
val = td.Val //vals + "__" + td.Val
|
|
|
} else {
|
|
@@ -1786,6 +1804,9 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
tkey := fmtkey("k", near.TR.RowPos, near.ColPos)
|
|
|
table.SortKV.ReplaceKey(key, val, tkey)
|
|
|
} else {
|
|
|
+ if val == nil || val == "" ||key=="采购项目预算金额"{
|
|
|
+ return
|
|
|
+ }
|
|
|
table.SortKV.AddKey(key, val)
|
|
|
//if table.SortKV.Map[key] != nil {
|
|
|
pos := table.SortKV.Index[key]
|
|
@@ -1871,10 +1892,10 @@ func (tn *Table) GetTdByRCNo(row, col int) *TD {
|
|
|
|
|
|
//判断表格是否是分包
|
|
|
func (tn *Table) CheckMultiPackageByTable() (b bool, index []string) {
|
|
|
- pac := 0
|
|
|
- val := 0
|
|
|
- index = []string{} //初始化返回值index
|
|
|
- index_pos := []int{}
|
|
|
+ pac := 0 //包的数量
|
|
|
+ val := 0 //分值
|
|
|
+ index = []string{} //存储分包,使用tbale.SortKV的key和value使用正则等处理对值进行判断
|
|
|
+ index_pos := []int{} //下标
|
|
|
//是数组且能找到标段之类的提示
|
|
|
//arr_count := 0 //计数table.SortKV的value是数组的数量,后面没用
|
|
|
key_index := -1
|
|
@@ -1896,13 +1917,13 @@ func (tn *Table) CheckMultiPackageByTable() (b bool, index []string) {
|
|
|
val += 4
|
|
|
}
|
|
|
//根据table.SortKV的key判断是否分包,如果没有再根据value判断
|
|
|
- val, index, index_pos = foundPacBySortKV(tn, val, index, index_pos, pac, &keyExistsCount, &commonKeyVals, key_index, hasPkgTd)
|
|
|
+ val, index, index_pos = foundPacBySortKV(tn, val, index, index_pos, &keyExistsCount, &commonKeyVals, key_index, hasPkgTd)
|
|
|
}
|
|
|
// u.Debug(index)
|
|
|
//过滤重复及标准化!
|
|
|
standIndex := []string{}
|
|
|
standIndex_pos := []int{}
|
|
|
- oldIndex := []string{}
|
|
|
+ oldIndex := []string{} //存放包的原始值
|
|
|
brepeat := map[string]bool{}
|
|
|
for k, v := range index {
|
|
|
v = u.PackageNumberConvert(v)
|
|
@@ -1910,7 +1931,7 @@ func (tn *Table) CheckMultiPackageByTable() (b bool, index []string) {
|
|
|
brepeat[v] = true
|
|
|
standIndex = append(standIndex, v)
|
|
|
standIndex_pos = append(standIndex_pos, index_pos[k])
|
|
|
- oldIndex = append(oldIndex, v)
|
|
|
+ oldIndex = append(oldIndex, index[k])
|
|
|
}
|
|
|
}
|
|
|
index = standIndex
|
|
@@ -1930,163 +1951,175 @@ func (tn *Table) CheckMultiPackageByTable() (b bool, index []string) {
|
|
|
//多包解析
|
|
|
if b {
|
|
|
tn.BPackage = true
|
|
|
+ //根据数组index分包长度添加table.BlockPackage子包数组
|
|
|
for nk, v := range index {
|
|
|
if tn.BlockPackage.Map[v] == nil {
|
|
|
bp := &u.BlockPackage{}
|
|
|
- bp.Index = v
|
|
|
- bp.Origin = oldIndex[nk]
|
|
|
- bp.TableKV = u.NewJobKv()
|
|
|
+ bp.Index = v //序号 (转换后编号,只有数字或字母)
|
|
|
+ bp.Origin = oldIndex[nk] //包的原始值
|
|
|
+ bp.TableKV = u.NewJobKv() //table kv (分出的对应的KV值)
|
|
|
tn.BlockPackage.AddKey(v, bp) //table子包数组
|
|
|
}
|
|
|
}
|
|
|
- if len(index) == 1 { //是一个的情况
|
|
|
- if len(tn.SortKV.Keys) < 10 && tn.ColNum < 10 && tn.RowNum < 4 {
|
|
|
- beq := true
|
|
|
- for _, v2 := range tn.SortKV.Map {
|
|
|
- if _, ok := v2.(string); !ok {
|
|
|
- beq = false
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- if beq { //统一处理为数组
|
|
|
- td := tn.GetTdByRCNo(tn.RowNum-1, 0)
|
|
|
- if !td.BH && FindVal2_1.MatchString(td.Val) {
|
|
|
- for k2, v2 := range tn.SortKV.Map {
|
|
|
- tn.SortKV.Map[k2] = []string{v2.(string)}
|
|
|
- }
|
|
|
- } else {
|
|
|
- //没有处理成数组的情况下,继续调用正文查找分包的方法
|
|
|
- isGoonNext = true
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ isGoonNext = tn.manyPackageProcessByIndex(index, standIndex_pos) //多包处理,处理不同情况下的分包
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isGoonNext = true
|
|
|
+ }
|
|
|
+ if isGoonNext { //没有处理成数组的情况下,继续调用正文查找分包的方法
|
|
|
+ tn.isGoonNext()
|
|
|
+ }
|
|
|
+ //查找分包中的中标人排序
|
|
|
+ if tn.BlockPackage != nil && tn.BlockPackage.Map != nil && len(tn.BlockPackage.Map) > 0 {
|
|
|
+ for _, v := range tn.BlockPackage.Map {
|
|
|
+ vv := v.(*u.BlockPackage)
|
|
|
+ if vv.WinnerOrder == nil || len(vv.WinnerOrder) == 0 {
|
|
|
+ vv.WinnerOrder = winnerOrderEntity.Find(vv.Text, true, 2)
|
|
|
}
|
|
|
- for _, k1 := range tn.SortKV.Keys {
|
|
|
- v1 := tn.SortKV.Map[k1]
|
|
|
- if _, bvs := v1.(string); bvs && len(index) > 1 && !strings.HasSuffix(k1, "_") {
|
|
|
- v1_array := []string{v1.(string)}
|
|
|
- underline := ""
|
|
|
- for {
|
|
|
- underline += "_"
|
|
|
- if tn.SortKV.Map[k1+underline] == nil {
|
|
|
- break
|
|
|
- } else if v3, v2_ok := tn.SortKV.Map[k1+underline].(string); v2_ok && v3 != "" {
|
|
|
- v1_array = append(v1_array, v3)
|
|
|
- }
|
|
|
- }
|
|
|
- v1 = v1_array
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+//多包处理,处理不同情况下的分包
|
|
|
+func (tn *Table) manyPackageProcessByIndex(index []string, standIndex_pos []int, ) (isGoonNext bool) {
|
|
|
+ if len(index) == 1 { //是一个的情况
|
|
|
+ if len(tn.SortKV.Keys) < 10 && tn.ColNum < 10 && tn.RowNum < 4 { //table带排序的KV值小于10并且小于10列和小于4行
|
|
|
+ beq := true
|
|
|
+ for _, v2 := range tn.SortKV.Map {
|
|
|
+ if _, ok := v2.(string); !ok {
|
|
|
+ beq = false
|
|
|
+ break
|
|
|
}
|
|
|
- if val, bvs := v1.([]string); bvs {
|
|
|
- if len(val) <= len(index) {
|
|
|
- for k, v := range val {
|
|
|
- tn.assemblePackage(k1, v, index[k])
|
|
|
- }
|
|
|
- } else {
|
|
|
- for sk1, sv2 := range index {
|
|
|
- v := val[sk1]
|
|
|
- //处理http://www.hljcg.gov.cn/xwzs!queryOneXwxxqx.action?xwbh=8145b599-a11e-45cb-a76a-12157a715570
|
|
|
- if v == "" && strings.Index(k1, "供应商") > -1 {
|
|
|
- if sk1 != len(index)-1 {
|
|
|
- //u.Debug(val[sk1+1], val[sk1+2])
|
|
|
- if standIndex_pos[sk1+1]-standIndex_pos[sk1] > 1 {
|
|
|
- v = val[standIndex_pos[sk1]+1]
|
|
|
- }
|
|
|
- } else {
|
|
|
- if standIndex_pos[sk1] < len(val)-1 {
|
|
|
- v = val[standIndex_pos[sk1]+1]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- tn.assemblePackage(k1, v, sv2)
|
|
|
- }
|
|
|
- }
|
|
|
- //删除子包的kv
|
|
|
- //u.Debug("----==1==-------", k1)
|
|
|
- k1tags := u.GetTags(k1)
|
|
|
- //if !(len(k1tags) > 0 && k1tags[0].Value == "采购单位") {
|
|
|
- // tn.SortKV.RemoveKey(k1)
|
|
|
- //}
|
|
|
- for _, vcgdw := range k1tags {
|
|
|
- if vcgdw.Value == "采购单位" {
|
|
|
- tn.SortKV.RemoveKey(k1)
|
|
|
- }
|
|
|
- }
|
|
|
- } else if val, bvs := v1.(string); bvs && len(index) == 1 {
|
|
|
- //删除子包的kv
|
|
|
- k1tags, _, _, _, _ := CommonDataAnaly(k1, "", "", val)
|
|
|
- if len(k1tags) > 0 && regexp.MustCompile("^(项目|开标|采购单位|招标机构)").MatchString(k1tags[0]) { //(k1tags[0].Value == "采购单位" || k1tags[0].Value == "项目编号")) {
|
|
|
- //log.Println("remove", k1, val)
|
|
|
- tn.assemblePackage(k1, val, index[0])
|
|
|
- tn.SortKV.RemoveKey(k1)
|
|
|
+ }
|
|
|
+ if beq { //统一处理为数组
|
|
|
+ td := tn.GetTdByRCNo(tn.RowNum-1, 0)
|
|
|
+ if !td.BH && FindVal2_1.MatchString(td.Val) {
|
|
|
+ for k2, v2 := range tn.SortKV.Map {
|
|
|
+ tn.SortKV.Map[k2] = []string{v2.(string)}
|
|
|
}
|
|
|
- //u.Debug("----==2==-------", k1)
|
|
|
+ } else {
|
|
|
+ //没有处理成数组的情况下,继续调用正文查找分包的方法
|
|
|
+ isGoonNext = true
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- isGoonNext = true
|
|
|
}
|
|
|
- if isGoonNext {
|
|
|
- blockPackage := map[string]*u.BlockPackage{}
|
|
|
- for _, k := range tn.SortKV.Keys {
|
|
|
- if excludeKey.MatchString(k) {
|
|
|
- continue
|
|
|
+ for _, k1 := range tn.SortKV.Keys {
|
|
|
+ v1 := tn.SortKV.Map[k1]
|
|
|
+ if _, bvs := v1.(string); bvs && len(index) > 1 && !strings.HasSuffix(k1, "_") { //table.SortKV.Map.value为字符串并且index有分包而且table.SortKV.Map.key没有_
|
|
|
+ v1_array := []string{v1.(string)}
|
|
|
+ underline := ""
|
|
|
+ for {
|
|
|
+ underline += "_"
|
|
|
+ if tn.SortKV.Map[k1+underline] == nil {
|
|
|
+ break
|
|
|
+ } else if v3, v2_ok := tn.SortKV.Map[k1+underline].(string); v2_ok && v3 != "" {
|
|
|
+ v1_array = append(v1_array, v3)
|
|
|
+ }
|
|
|
}
|
|
|
- str := ""
|
|
|
- v := tn.SortKV.Map[k]
|
|
|
- nk := regReplAllSpace.ReplaceAllString(k, "")
|
|
|
- if vs, ok := v.([]string); ok {
|
|
|
- str += fmt.Sprintf("%s:%s\n", nk, strings.Join(vs, " "))
|
|
|
+ v1 = v1_array
|
|
|
+ }
|
|
|
+ if val, bvs := v1.([]string); bvs {
|
|
|
+ if len(val) <= len(index) { //table.SortKV.Map.value数组小于等于分包index
|
|
|
+ for k, v := range val {
|
|
|
+ tn.assemblePackage(k1, v, index[k]) //组装解析到的分包
|
|
|
+ }
|
|
|
} else {
|
|
|
- str += fmt.Sprintf("%s:%s\n", nk, v)
|
|
|
- }
|
|
|
- b, _ := divisionPackageChild(&blockPackage, str, tn.Tag, false, false)
|
|
|
- if b && len(blockPackage) > 0 {
|
|
|
- tn.BPackage = true
|
|
|
- for mk, mv := range blockPackage {
|
|
|
- if tn.BlockPackage.Map[mk] == nil {
|
|
|
- tn.BlockPackage.AddKey(mk, mv)
|
|
|
- } else {
|
|
|
- bp := tn.BlockPackage.Map[mk].(*u.BlockPackage)
|
|
|
- if bp.TableKV == nil {
|
|
|
- bp.TableKV = u.NewJobKv()
|
|
|
- }
|
|
|
- for k2, v2 := range mv.ColonKV.Kv {
|
|
|
- if bp.TableKV.Kv[k2] == "" {
|
|
|
- bp.TableKV.Kv[k2] = v2
|
|
|
- bp.TableKV.KvTag[k2] = mv.ColonKV.KvTag[k2]
|
|
|
- bp.Text += fmt.Sprintf("%v:%v\n", k2, v2)
|
|
|
+ for sk1, sv2 := range index {
|
|
|
+ v := val[sk1]
|
|
|
+ //处理http://www.hljcg.gov.cn/xwzs!queryOneXwxxqx.action?xwbh=8145b599-a11e-45cb-a76a-12157a715570
|
|
|
+ if v == "" && strings.Index(k1, "供应商") > -1 {
|
|
|
+ if sk1 != len(index)-1 {
|
|
|
+ //u.Debug(val[sk1+1], val[sk1+2])
|
|
|
+ if standIndex_pos[sk1+1]-standIndex_pos[sk1] > 1 {
|
|
|
+ v = val[standIndex_pos[sk1]+1]
|
|
|
}
|
|
|
- }
|
|
|
- for k2, v2 := range mv.SpaceKV.Kv {
|
|
|
- if bp.TableKV.Kv[k2] == "" {
|
|
|
- bp.TableKV.Kv[k2] = v2
|
|
|
- bp.TableKV.KvTag[k2] = mv.SpaceKV.KvTag[k2]
|
|
|
- bp.Text += fmt.Sprintf("%v:%v\n", k2, v2)
|
|
|
+ } else {
|
|
|
+ if standIndex_pos[sk1] < len(val)-1 {
|
|
|
+ v = val[standIndex_pos[sk1]+1]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ tn.assemblePackage(k1, v, sv2)
|
|
|
}
|
|
|
- tn.BPackage = true
|
|
|
- tn.SortKV.RemoveKey(k)
|
|
|
}
|
|
|
+ //删除子包的kv
|
|
|
+ //u.Debug("----==1==-------", k1)
|
|
|
+ k1tags := u.GetTags(k1) //取得匹配
|
|
|
+ //if !(len(k1tags) > 0 && k1tags[0].Value == "采购单位") {
|
|
|
+ // tn.SortKV.RemoveKey(k1)
|
|
|
+ //}
|
|
|
+ for _, vcgdw := range k1tags {
|
|
|
+ if vcgdw.Value == "采购单位" {
|
|
|
+ tn.SortKV.RemoveKey(k1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if val, bvs := v1.(string); bvs && len(index) == 1 {
|
|
|
+ //删除子包的kv
|
|
|
+ k1tags, _, _, _, _ := CommonDataAnaly(k1, "", "", val)
|
|
|
+ if len(k1tags) > 0 && regexp.MustCompile("^(项目|开标|采购单位|招标机构)").MatchString(k1tags[0]) { //(k1tags[0].Value == "采购单位" || k1tags[0].Value == "项目编号")) {
|
|
|
+ //log.Println("remove", k1, val)
|
|
|
+ tn.SortKV.RemoveKey(k1)
|
|
|
+ tn.assemblePackage(k1, val, index[0])
|
|
|
+ }
|
|
|
+ //u.Debug("----==2==-------", k1)
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- //查找分包中的中标人排序
|
|
|
- if tn.BlockPackage != nil && tn.BlockPackage.Map != nil && len(tn.BlockPackage.Map) > 0 {
|
|
|
- for _, v := range tn.BlockPackage.Map {
|
|
|
- vv := v.(*u.BlockPackage)
|
|
|
- if vv.WinnerOrder == nil || len(vv.WinnerOrder) == 0 {
|
|
|
- vv.WinnerOrder = winnerOrderEntity.Find(vv.Text, true, 2)
|
|
|
+ return isGoonNext
|
|
|
+}
|
|
|
+
|
|
|
+//没有处理成数组的情况下,继续调用正文查找分包的方法
|
|
|
+func (tn *Table) isGoonNext() {
|
|
|
+ blockPackage := map[string]*u.BlockPackage{}
|
|
|
+ for _, k := range tn.SortKV.Keys {
|
|
|
+ if excludeKey.MatchString(k) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ str := "" //拼装为冒号kv
|
|
|
+ v := tn.SortKV.Map[k]
|
|
|
+ nk := regReplAllSpace.ReplaceAllString(k, "")
|
|
|
+ if vs, ok := v.([]string); ok {
|
|
|
+ str += fmt.Sprintf("%s:%s\n", nk, strings.Join(vs, " "))
|
|
|
+ } else {
|
|
|
+ str += fmt.Sprintf("%s:%s\n", nk, v)
|
|
|
+ }
|
|
|
+ b, _ := divisionPackageChild(&blockPackage, str, tn.Tag, false, false) //分块之后分包
|
|
|
+ if b && len(blockPackage) > 0 {
|
|
|
+ tn.BPackage = true
|
|
|
+ for mk, mv := range blockPackage {
|
|
|
+ if tn.BlockPackage.Map[mk] == nil {
|
|
|
+ tn.BlockPackage.AddKey(mk, mv)
|
|
|
+ } else {
|
|
|
+ bp := tn.BlockPackage.Map[mk].(*u.BlockPackage)
|
|
|
+ if bp.TableKV == nil {
|
|
|
+ bp.TableKV = u.NewJobKv()
|
|
|
+ }
|
|
|
+ for k2, v2 := range mv.ColonKV.Kv {
|
|
|
+ if bp.TableKV.Kv[k2] == "" {
|
|
|
+ bp.TableKV.Kv[k2] = v2
|
|
|
+ bp.TableKV.KvTag[k2] = mv.ColonKV.KvTag[k2]
|
|
|
+ bp.Text += fmt.Sprintf("%v:%v\n", k2, v2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for k2, v2 := range mv.SpaceKV.Kv {
|
|
|
+ if bp.TableKV.Kv[k2] == "" {
|
|
|
+ bp.TableKV.Kv[k2] = v2
|
|
|
+ bp.TableKV.KvTag[k2] = mv.SpaceKV.KvTag[k2]
|
|
|
+ bp.Text += fmt.Sprintf("%v:%v\n", k2, v2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ tn.BPackage = true
|
|
|
+ tn.SortKV.RemoveKey(k)
|
|
|
}
|
|
|
}
|
|
|
- return
|
|
|
}
|
|
|
|
|
|
//根据table.SortKV的key判断是否分包,如果没有再根据value判断
|
|
|
-func foundPacBySortKV(tn *Table, val int, index []string, index_pos []int, pac int, keyExistsCount *map[string]int, commonKeyVals *map[string][]string, key_index int, hasPkgTd map[string]bool) (rval int, rindex []string, rindex_pos []int) {
|
|
|
+func foundPacBySortKV(tn *Table, val int, index []string, index_pos []int, keyExistsCount *map[string]int, commonKeyVals *map[string][]string, key_index int, hasPkgTd map[string]bool) (rval int, rindex []string, rindex_pos []int) {
|
|
|
keyIsPkg := false
|
|
|
for in, k := range tn.SortKV.Keys {
|
|
|
if excludeKey.MatchString(BracketsTextReg.ReplaceAllString(k, "")) { //判断分包前排除
|
|
@@ -2103,7 +2136,7 @@ func foundPacBySortKV(tn *Table, val int, index []string, index_pos []int, pac i
|
|
|
index = append(index, pkgFlag)
|
|
|
index_pos = append(index_pos, len(index))
|
|
|
val += 1
|
|
|
- pac++
|
|
|
+ //pac++
|
|
|
} else {
|
|
|
k = strings.TrimRight(k, "_")
|
|
|
}
|
|
@@ -2129,7 +2162,7 @@ func foundPacBySortKV(tn *Table, val int, index []string, index_pos []int, pac i
|
|
|
index = append(index, v1)
|
|
|
index_pos = append(index_pos, in2)
|
|
|
val += 1
|
|
|
- pac++
|
|
|
+ //pac++
|
|
|
}
|
|
|
}
|
|
|
} else if v1, ok := v.(string); ok && !hasPkgTd[k] {
|
|
@@ -2141,7 +2174,7 @@ func foundPacBySortKV(tn *Table, val int, index []string, index_pos []int, pac i
|
|
|
index = append(index, v1)
|
|
|
index_pos = append(index_pos, 0)
|
|
|
val += 1
|
|
|
- pac++
|
|
|
+ //pac++
|
|
|
underline := ""
|
|
|
for {
|
|
|
underline += "_"
|
|
@@ -2221,7 +2254,7 @@ func initCheckMultiPackageByTable(tn *Table, key_index int, index []string, inde
|
|
|
index_pos = append(index_pos, 0)
|
|
|
val += 1
|
|
|
pac++
|
|
|
- } else if getTd := tn.GetTdByRCNo(0, tn.SortKV.Index[k]); getTd != nil && getTd.KVDirect == 2 {
|
|
|
+ } else if getTd := tn.GetTdByRCNo(0, tn.SortKV.Index[k]); getTd != nil && getTd.KVDirect == 2 { //纵向
|
|
|
/*处理这种情况:
|
|
|
<tr><td>包一:xxxxxxxxx</td></tr>
|
|
|
*/
|
|
@@ -2239,19 +2272,24 @@ func initCheckMultiPackageByTable(tn *Table, key_index int, index []string, inde
|
|
|
return key_index, index, index_pos, val, pac, hasPkgTd
|
|
|
}
|
|
|
|
|
|
-//组装解析到的分包
|
|
|
+//组装解析到的分包,//key如果匹配到抽取关键词就添加到table.SortKV
|
|
|
func (tn *Table) assemblePackage(k1, v1, key string) {
|
|
|
bp := tn.BlockPackage.Map[key].(*u.BlockPackage)
|
|
|
if bp.TableKV == nil {
|
|
|
bp.TableKV = u.NewJobKv()
|
|
|
}
|
|
|
if v1 != "" {
|
|
|
- k2, w1, v2, _, bf := CommonDataAnaly(k1, "中标情况", "", v1)
|
|
|
+ k2, w1, v2, _, bf := CommonDataAnaly(k1, "中标情况", "", v1) //匹配抽取关键词
|
|
|
if bf {
|
|
|
for pos, k3 := range k2 {
|
|
|
if bp.TableKV.Kv != nil && bp.TableKV.KvTag[k3] != nil && (bp.TableKV.Kv[k3] == "" || w1[pos] > bp.TableKV.KvTag[k3].Weight) {
|
|
|
bp.TableKV.Kv[k3] = v2
|
|
|
bp.TableKV.KvTag[k3] = &u.Tag{Value: v2, Weight: w1[pos]}
|
|
|
+ } else {
|
|
|
+ bp.TableKV.Kv[k1] = qutil.ObjToString(v1)
|
|
|
+ if tn.SortKV.Map[k3] == nil {
|
|
|
+ tn.SortKV.AddKey(k3, v2) //添加匹配到抽取关键词的key,value
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -3109,7 +3147,7 @@ func initLineMapLineMapArr(table *Table) (lineMapArr map[string]*SortMap, lineMa
|
|
|
for _, key := range table.SortKV.Keys { //遍历table.SortKV.Keys而不是直接遍历table.SortKV.Map是为了得到table头的顺序
|
|
|
val := table.SortKV.Map[key]
|
|
|
key = regReplAllSpace.ReplaceAllString(key, "")
|
|
|
- key = strings.Replace(key, "", "", -1) //处理一个特殊的采购量 经上层处理空格后未处理掉
|
|
|
+ key = strings.Replace(key, "", "", -1) //处理一个特殊的采购量 经上层处理空格后未处理掉
|
|
|
if realTypeVal, ok := val.([]string); ok { //val为数组 {"数量":["1","2","3"]}
|
|
|
/*
|
|
|
{
|