|
@@ -253,6 +253,25 @@ func isRepeatArrString(arr1,arr2 []string)bool{
|
|
|
}
|
|
|
return is_r
|
|
|
}
|
|
|
+//中标金额-单位-同时存在-且万元-重构
|
|
|
+func isResetUnitAmountSortKV(table *Table) {
|
|
|
+ isUnitAmount := 0
|
|
|
+ for _, k := range table.SortKV.Keys {
|
|
|
+ v := table.SortKV.Map[k]
|
|
|
+ if new_v, ok := v.(string); ok&&(k=="中标金额"||k=="单位") {
|
|
|
+ if k=="单位" && new_v=="万元" {
|
|
|
+ isUnitAmount++
|
|
|
+ }
|
|
|
+ if k=="中标金额" && MoneyReg.MatchString(new_v) && !strings.Contains(new_v,"万") {
|
|
|
+ isUnitAmount++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if isUnitAmount>1 {
|
|
|
+ table.SortKV.Map["中标金额"] = qutil.ObjToString(table.SortKV.Map["中标金额"])+"万元"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
//对解析后的表格的kv进行过滤
|
|
|
func (table *Table) KVFilter(isSite bool, codeSite string) {
|
|
@@ -265,6 +284,9 @@ func (table *Table) KVFilter(isSite bool, codeSite string) {
|
|
|
table.analyTdKV() //1.遍历每行每列td的sortkv添加到table.SorkVK中;2.td有子表格的处理
|
|
|
as := NewSortMap()
|
|
|
|
|
|
+ //中标金额-单位-同时存在-且万元-重构
|
|
|
+ isResetUnitAmountSortKV(table)
|
|
|
+
|
|
|
//遍历table.sortkv,进行过滤处理,并放入标准化KV中,如果值是数组跳到下一步处理
|
|
|
pre_k := ""
|
|
|
for _, k := range table.SortKV.Keys {
|
|
@@ -387,7 +409,7 @@ func (table *Table) KVFilter(isSite bool, codeSite string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-var winMoneyReg *regexp.Regexp = regexp.MustCompile("(报价|投标价|投标总价)")
|
|
|
+var winMoneyReg *regexp.Regexp = regexp.MustCompile("(报价|投标价|投标总价|总金额)")
|
|
|
var winNoMoneyReg *regexp.Regexp = regexp.MustCompile("(得分|时间|序号)")
|
|
|
//处理table.SortKV.value为数组的情况
|
|
|
func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
@@ -1402,7 +1424,7 @@ func (table *Table) ComputeRowColIsKeyRation(isSite bool, codeSite string) {
|
|
|
ration1, _ := table.StartAndEndRation[ck].GetTDRation(td)
|
|
|
if !checkCompute[ck] {
|
|
|
checkCompute[ck] = true
|
|
|
- if ration1 >= checkval && td.ColPos != 1 {
|
|
|
+ if ration1 >= checkval && td.ColPos != 1 {
|
|
|
for _, tr1 := range table.TRs {
|
|
|
for _, td1 := range tr1.TDs {
|
|
|
if td1.StartCol == td.StartCol {
|
|
@@ -1574,8 +1596,7 @@ func (table *Table) FindKV(isSite bool, codeSite string) {
|
|
|
//sort := 1
|
|
|
nextdirect, nextvdirect := 0, 0
|
|
|
//开始抽取
|
|
|
- //若第一排全为头-临时让第二排-新增 左临 查询,zhengkun
|
|
|
- tb_first_allhead := false
|
|
|
+ than_once_1,than_once_2 := false,false
|
|
|
for tr_index, tr := range table.TRs {
|
|
|
if tr_index==0 {
|
|
|
//fmt.Println("调试")
|
|
@@ -1593,7 +1614,7 @@ func (table *Table) FindKV(isSite bool, codeSite string) {
|
|
|
}
|
|
|
if numbh != 0 && numbh == len(tr.TDs) { //5e0d53ef0cf41612e0640495
|
|
|
if tr_index==0 {
|
|
|
- tb_first_allhead = true
|
|
|
+ than_once_1,than_once_2 = true,true
|
|
|
}
|
|
|
nextdirect, nextvdirect = 2, 1
|
|
|
continue
|
|
@@ -1609,33 +1630,16 @@ func (table *Table) FindKV(isSite bool, codeSite string) {
|
|
|
for _, td := range tr.TDs {
|
|
|
if !td.BH && td.KVDirect < 3 {
|
|
|
if !table.FindTdVal(td, direct, vdirect) { //table.FindTdVal()存储了table.SortKV
|
|
|
- if !table.FindTdVal(td, vdirect, direct) {
|
|
|
- //都识别不到时,对第一、二中标候选人的处理
|
|
|
- //bo, res := GetBidOrder(td, bodirect, sort)
|
|
|
- //if res {
|
|
|
- // sort++
|
|
|
- // bodirect = bo
|
|
|
- //}
|
|
|
- //if len(td.SortKV.Map) > 0 {
|
|
|
- // for _, tdv := range td.SortKV.Keys {
|
|
|
- // if tdv == "" || td.SortKV.Map[tdv] == "" { //value为空或者null不再添加到table.SortKV
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // table.SortKV.AddKey(tdv, td.SortKV.Map[tdv])
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
+ table.FindTdVal(td, vdirect, direct)
|
|
|
}
|
|
|
- if tb_first_allhead && tr_index==1 { //临时-让第二排-向左比对
|
|
|
- if !table.FindTdVal(td, 1, 2) { //table.FindTdVal()存储了table.SortKV
|
|
|
- if !table.FindTdVal(td, vdirect, direct) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- tb_first_allhead = false
|
|
|
+ if than_once_1 && tr_index==1 {
|
|
|
+ table.FindTdVal(td, 1, 2) //table.FindTdVal()存储了table.SortKV
|
|
|
+ than_once_1 = false
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if than_once_2 && tr_index==1 && td.BH && findCandidate.MatchString(td.Val){
|
|
|
+ table.FindTdVal(td, 1, 2) //特殊计算表头异常-情况
|
|
|
}
|
|
|
- //fmt.Println("td:", td.Val, td.BH, td.HeadTd, td.KVDirect)
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
nextdirect, nextvdirect = 0, 0
|
|
@@ -1873,7 +1877,10 @@ func GetBidSort(str string, n int) int {
|
|
|
|
|
|
var cleardwReg *regexp.Regexp = regexp.MustCompile("[((]{1}\\d*[人元件个公斤户]/[人元件个公斤户][))]")
|
|
|
var zbhxrReg *regexp.Regexp = regexp.MustCompile("(中标候选人|投标单位名称)")
|
|
|
-var zbhxrSortReg *regexp.Regexp = regexp.MustCompile("([第|弟][0-9一二三四五]名)")
|
|
|
+var zbhxrSortReg *regexp.Regexp = regexp.MustCompile("([第|弟][1-3一二三]名)")
|
|
|
+var zbhxrSortNameReg *regexp.Regexp = regexp.MustCompile("(中标候选人[第|弟][1-3一二三]名)|[第|弟][1-3一二三]中标候选人")
|
|
|
+var zbhxrSecondReg *regexp.Regexp = regexp.MustCompile("(中标候选人[第|弟][2二]名)|[第|弟][2二]中标候选人")
|
|
|
+
|
|
|
|
|
|
//查找每一个单元格的表头,调用FindNear
|
|
|
func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
@@ -1887,22 +1894,65 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
td.KVDirect = direct
|
|
|
key := repSpace.ReplaceAllString(near.Val, "")
|
|
|
if key == "名称" && near.StartCol == 0 && near.Rowspan > 0 {
|
|
|
- for _, vn := range table.TRs[near.Rowspan-1].TDs {
|
|
|
- if strings.Contains(vn.Val, "代理") {
|
|
|
- key = "代理机构"
|
|
|
- break
|
|
|
- } else if strings.Contains(vn.Val, "招标") {
|
|
|
- key = "采购单位"
|
|
|
- break
|
|
|
- } else if strings.Contains(vn.Val, "中标") {
|
|
|
- key = "中标单位"
|
|
|
- break
|
|
|
+ new_key := ""
|
|
|
+ tr := table.TRs[:td.TR.RowPos]
|
|
|
+ if len(tr)>len(tr)-1 {
|
|
|
+ tds := tr[len(tr)-1].TDs
|
|
|
+ if len(tds)>td.EndCol {
|
|
|
+ td1 := tds[td.EndCol]
|
|
|
+ if zbhxrSecondReg.MatchString(td1.Val) {
|
|
|
+ new_key = td1.Val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if new_key=="" {
|
|
|
+ for _, vn := range table.TRs[near.Rowspan-1].TDs {
|
|
|
+ if strings.Contains(vn.Val, "代理") {
|
|
|
+ key = "代理机构"
|
|
|
+ break
|
|
|
+ } else if strings.Contains(vn.Val, "招标") {
|
|
|
+ key = "采购单位"
|
|
|
+ break
|
|
|
+ } else if strings.Contains(vn.Val, "中标") {
|
|
|
+ key = "中标单位"
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
+ }else {
|
|
|
+ key = new_key
|
|
|
}
|
|
|
} else if zbhxrReg.MatchString(key) && findCandidate2.MatchString(td.Val) {
|
|
|
- //if !hxrRex.MatchString(key) {
|
|
|
- key = "中标单位"
|
|
|
+ new_key := "中标单位"
|
|
|
+ tr_top := table.TRs[:td.TR.RowPos]
|
|
|
+ if len(tr_top)>len(tr_top)-1 { //上临查询
|
|
|
+ tds := tr_top[len(tr_top)-1].TDs
|
|
|
+ if len(tds)>td.EndCol {
|
|
|
+ td1 := tds[td.EndCol]
|
|
|
+ if zbhxrSortNameReg.MatchString(td1.Val) {
|
|
|
+ new_key = td1.Val
|
|
|
+ }else {
|
|
|
+ if zbhxrSortReg.MatchString(td1.Val) {
|
|
|
+ new_key = "中选候选人"+td1.Val
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //if new_key=="中标单位" {
|
|
|
+ // tr_left := table.TRs[:td.TR.RowPos+1] //左临查询
|
|
|
+ // tds := tr_left[len(tr_left)-1].TDs
|
|
|
+ // if td.EndCol-1 >=0 {
|
|
|
+ // td1 := tds[td.EndCol-1]
|
|
|
+ // if zbhxrSortNameReg.MatchString(td1.Val) {
|
|
|
+ // new_key = td1.Val
|
|
|
+ // }else {
|
|
|
+ // if zbhxrSortReg.MatchString(td1.Val) {
|
|
|
+ // new_key = "中选候选人"+td1.Val
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
//}
|
|
|
+
|
|
|
+ key = new_key
|
|
|
} else if key == "单位名称" {//左临上临-拼接
|
|
|
tmpnewnear := table.FindNear(near, 1)
|
|
|
if tmpnewnear == nil {
|
|
@@ -1919,6 +1969,8 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
if near.Val == "" {
|
|
|
key = fmtkey("k", near.TR.RowPos, near.ColPos)
|
|
|
}
|