|
@@ -20,21 +20,21 @@ var (
|
|
|
numclear = regexp.MustCompile("^[\\d一二三四五六七八九十.]+")
|
|
|
num1 = regexp.MustCompile("(\\d)")
|
|
|
//清理表格title中的不需要的内容
|
|
|
- tabletitleclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、.,.。、_/((人民币万元件个公斤))]")
|
|
|
+ tabletitleclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、.,.。_/((人民币万元件个公斤户))]")
|
|
|
tabletitleclear2 = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、,。_??;;~\\-#\\\\()(){}【】\\[\\]<>《》{}〔〕]*")
|
|
|
//清理表格中是key中包含的空格或数字等
|
|
|
- tablekeyclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n、.,.。、_/]+|^[\\d一二三四五六七八九十]+[、.]*|[((【\\[].*?[))】\\]]")
|
|
|
+ tablekeyclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n、.,.。_/]+|^[\\d一二三四五六七八九十]+[、.]*|[((【\\[].*?[))】\\]]")
|
|
|
//清理表格td中的符号
|
|
|
- tabletdclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、,。、_??;;~\\-#\\\\()(){}【】\\[\\]<>《》{}〔〕¥$]*")
|
|
|
+ tabletdclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、,。_??;;~\\-#\\\\()(){}【】\\[\\]<>《》{}〔〕¥$]*")
|
|
|
//判断key是金额,对万元的处理
|
|
|
moneyreg = regexp.MustCompile("(预算|费|价|额|规模|投资)")
|
|
|
//根据表格的内容判断是不是表头,如果含有金额则不是表头
|
|
|
MoneyReg = regexp.MustCompile("^[\\s ::0-9.万元()()人民币¥$]+$")
|
|
|
-
|
|
|
+ GSReg = regexp.MustCompile(".*公司.*")
|
|
|
//判断分包时
|
|
|
moneyNum = regexp.MustCompile("[元整¥万]")
|
|
|
//对隐藏表格的判断
|
|
|
- display = regexp.MustCompile("(?i).*?display\\s?[:]\\s?none.*")
|
|
|
+ display = regexp.MustCompile("(?i).*?display\\s?[:]\\s?none.*")
|
|
|
//---------------
|
|
|
//求是分包的概率
|
|
|
//根据表格的标签对分包进行打分
|
|
@@ -58,7 +58,6 @@ var (
|
|
|
|
|
|
//清理表格标签正则
|
|
|
ClearTagReg = regexp.MustCompile("<[^>]*?>|[\\s\\n\\r]*$")
|
|
|
-
|
|
|
//查找表格标签正则
|
|
|
ttagreg = regexp.MustCompile("(?s)([^\\n::。,;\\s\u3000\u2003\u00a0]{2,30})[::]?[^::。;!\\n]{0,35}[\\s\\n]*$")
|
|
|
|
|
@@ -93,7 +92,8 @@ var (
|
|
|
filter_zbdw_jd = regexp.MustCompile("(投标|成交|中标|合同)(供应商|单位|人|名称).{0,4}$")
|
|
|
//且不包含以下字眼
|
|
|
filter_zbdw_kn = regexp.MustCompile("第[2二3三4四5五]|得分|地址|询价保证金") //且值包含以下字眼
|
|
|
- filter_zbdw_v = regexp.MustCompile("(公司|集团|研究院|设计院|局|厂|部|站|城|店|市|所|处)$|([^购]中心|办公|用品)")
|
|
|
+ //且值包含以下字眼
|
|
|
+ filter_zbdw_v = regexp.MustCompile("(公司|集团|研究院|设计院|局|厂|部|站|城|店|市|所|处)$|([^购]中心|办公|用品)")
|
|
|
//且值包含以下字眼
|
|
|
filter_zbdw_v2 = regexp.MustCompile("(公司|集团|研究院|设计院|局|厂|部|站|城|店|市|所|处)$")
|
|
|
|
|
@@ -135,6 +135,9 @@ func IsHide(g *goquery.Selection) (b bool) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+//59.992664,33.495715,20.001306
|
|
|
+var clearnum *regexp.Regexp = regexp.MustCompile("(([0-9.]{1,6}[,,]+){4,}|(\\d{6}[,,]\\d{2}.){2,})")
|
|
|
+
|
|
|
//对表格的key进行标准化处理,多个k相同时,出现覆盖问题
|
|
|
//待扩展,暂不支持正则标签库
|
|
|
func CommonDataAnaly(k, tabletag, tabledesc string, v interface{}, isSite bool, codeSite string) (kvTags map[string][]*u.Tag, returntag string) {
|
|
@@ -174,12 +177,13 @@ func CommonDataAnaly(k, tabletag, tabledesc string, v interface{}, isSite bool,
|
|
|
}
|
|
|
if winnerOrderAndBidResult.MatchString(tabletag) && t1.Value == "采购单位联系人" { //处理table中项目负责人
|
|
|
kvTags[k] = append(kvTags[k], &u.Tag{Key: k, Value: v1, IsInvalid: true})
|
|
|
- } else if regexp.MustCompile("(中标候选人|名单及其排序|排序)").MatchString(tabletag) && t1.Value == "采购单位" {
|
|
|
+ }else if regexp.MustCompile("(中标候选人|名单及其排序|排序)").MatchString(tabletag) && t1.Value == "采购单位" {
|
|
|
kvTags[t1.Value] = append(kvTags[t1.Value], &u.Tag{Key: k1, Value: v1, Weight: t1.Weight - 150})
|
|
|
} else {
|
|
|
kvTags[t1.Value] = append(kvTags[t1.Value], &u.Tag{Key: k1, Value: v1, Weight: t1.Weight})
|
|
|
}
|
|
|
}
|
|
|
+ res[0].IsInvalid = true
|
|
|
//k1 = res[0].Value
|
|
|
} else {
|
|
|
kvTags[k] = append(kvTags[k], &u.Tag{Key: k, Value: v1, IsInvalid: true})
|
|
@@ -278,20 +282,20 @@ func (table *Table) KVFilter(isSite bool, codeSite string) {
|
|
|
}
|
|
|
}
|
|
|
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, isSite, codeSite)
|
|
|
- if len(winnerOrder) > 0 {
|
|
|
- break L
|
|
|
+ if len(table.WinnerOrder) == 0 {
|
|
|
+ winnerOrder = []map[string]interface{}{}
|
|
|
+ //遍历每个td,查询中标人
|
|
|
+ for _, tr := range table.TRs {
|
|
|
+ for _, td := range tr.TDs {
|
|
|
+ winnerOrder = winnerOrderEntity.Find(td.Val, true, 3, isSite, codeSite)
|
|
|
+ if len(winnerOrder) > 0 {
|
|
|
+ //中标候选人合并
|
|
|
+ winnerOrderEntity.Merge(table.WinnerOrder, winnerOrder)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if len(table.WinnerOrder) > 0 {
|
|
|
- //中标候选人合并
|
|
|
- winnerOrderEntity.Merge(table.WinnerOrder, winnerOrder)
|
|
|
- } else if !table.BPackage { //没有table.WinnerOrder也没有分包 将td中的WinnerOrder赋值给table.WinnerOrder
|
|
|
+ if !table.BPackage { //没有table.WinnerOrder也没有分包 将td中的WinnerOrder赋值给table.WinnerOrder
|
|
|
if len(winnerOrder) > 1 {
|
|
|
table.WinnerOrder = winnerOrder
|
|
|
}
|
|
@@ -304,7 +308,7 @@ func (table *Table) KVFilter(isSite bool, codeSite string) {
|
|
|
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 {
|
|
|
+ if onePkg != nil && (onePkg.WinnerOrder != nil || len(onePkg.WinnerOrder) == 0) {
|
|
|
onePkg.WinnerOrder = table.WinnerOrder
|
|
|
table.BlockPackage.AddKey(onePkgKey, onePkg)
|
|
|
}
|
|
@@ -312,12 +316,20 @@ func (table *Table) KVFilter(isSite bool, codeSite string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+var winMoneyReg *regexp.Regexp = regexp.MustCompile("(报价|投标价|投标总价)")
|
|
|
+
|
|
|
//处理table.SortKV.value为数组的情况
|
|
|
func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
|
winnertag := iswinnertabletag.MatchString(table.Tag) && !nswinnertabletag.MatchString(table.Tag) //table标签
|
|
|
if !winnertag {
|
|
|
winnertag = iswinnertabletag.MatchString(table.TableResult.BlockTag) && !nswinnertabletag.MatchString(table.TableResult.BlockTag) //块标签
|
|
|
}
|
|
|
+ if !winnertag {
|
|
|
+ winnertag = iswinnertabletag.MatchString(table.Desc)
|
|
|
+ }
|
|
|
+ if !winnertag {
|
|
|
+ winnertag = iswinnertabletag.MatchString(table.Html)
|
|
|
+ }
|
|
|
checkKey := map[int]bool{}
|
|
|
//tmpBidmout := []string{}
|
|
|
//log.Println(tmpBidmout)
|
|
@@ -330,7 +342,7 @@ func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
|
table.WinnerOrder = append(table.WinnerOrder, vm...)
|
|
|
} else {
|
|
|
//增加候选人排序逻辑
|
|
|
- if table.WinnerOrder == nil && !checkKey[kn] {
|
|
|
+ if (table.WinnerOrder == nil || len(table.WinnerOrder) == 0) && !checkKey[kn] {
|
|
|
if vs1, ok := v.([]string); ok {
|
|
|
smap := make([]map[string]interface{}, len(vs1))
|
|
|
for n1, _ := range vs1 {
|
|
@@ -350,7 +362,7 @@ func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
|
res, _, _, _, repl := CheckCommon(k, "bidorder")
|
|
|
kv := ""
|
|
|
if !res {
|
|
|
- kt := u.GetTags(filterThText.ReplaceAllString(ClearKey(k, 2), ""), isSite, codeSite)
|
|
|
+ kt := u.GetTags(k, isSite, codeSite)
|
|
|
if kt.Len() > 0 {
|
|
|
if kt[0].Value == "单品报价" && winnertag {
|
|
|
kv = "中标金额"
|
|
@@ -372,6 +384,8 @@ func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
|
if entname != "" {
|
|
|
tmpEntname[vsk] = entname
|
|
|
}
|
|
|
+ } else if winMoneyReg.MatchString(k) && len(tmpPrice[vsk]) == 0 {
|
|
|
+ kv = "中标金额"
|
|
|
} else { //验证val时如果数组中的第一条数据既不满足sort或者entname 判定此数组数据错误
|
|
|
break
|
|
|
}
|
|
@@ -386,6 +400,12 @@ func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
|
for vsk, vsv := range vs {
|
|
|
smap[vsk]["sortstr"] = vsv
|
|
|
smap[vsk]["sort"] = GetBidSort(vsv, vsk+1)
|
|
|
+ if findCandidate2.MatchString(vsv) && kv == "中标单位" && tmpEntname[vsk] == "" { //数据验证val是否是候选人
|
|
|
+ entname, _ := winnerOrderEntity.clear("中标单位", vsv).(string)
|
|
|
+ if entname != "" {
|
|
|
+ tmpEntname[vsk] = entname
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} else if repl == "entname" || kv == "中标单位" {
|
|
|
for vsk, vsv := range vs {
|
|
@@ -393,13 +413,12 @@ func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
|
repl = "sort"
|
|
|
goto SORT
|
|
|
}
|
|
|
- // if entname, _ := smap[vsk]["entname"].(string); entname != "" || len([]rune(vsv)) < 3 {
|
|
|
- // break
|
|
|
- // }
|
|
|
- // entname, _ := winnerOrderEntity.clear("中标单位", vsv).(string)
|
|
|
- // if entname != "" {
|
|
|
- // smap[vsk]["entname"] = entname
|
|
|
- //
|
|
|
+ //if entname, _ := smap[vsk]["entname"].(string); entname != "" || len([]rune(vsv)) < 3 {
|
|
|
+ // break
|
|
|
+ //}
|
|
|
+ //entname, _ := winnerOrderEntity.clear("中标单位", vsv).(string)
|
|
|
+ //if entname != "" {
|
|
|
+ // smap[vsk]["entname"] = entname
|
|
|
if tmpEntname[vsk] != "" || len([]rune(vsv)) < 4 { //排除 单位:["台","个","套"]
|
|
|
break
|
|
|
}
|
|
@@ -455,39 +474,45 @@ func (table *Table) sortKVArr(as *SortMap, isSite bool, codeSite string) {
|
|
|
//} else if len(tmpEntname) > 0 {
|
|
|
//fmt.Println("table winnerorder only has entname", tmpEntname)
|
|
|
//}
|
|
|
- if len(smap_v) > 2 { //只有排序信息 sort和sortstr
|
|
|
+ if len(smap_v) >2{ //只有排序信息 sort和sortstr
|
|
|
newSmap = append(newSmap, smap_v)
|
|
|
}
|
|
|
}
|
|
|
if len(newSmap) > 0 {
|
|
|
table.WinnerOrder = newSmap
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- kvTags, tag := CommonDataAnaly(k, table.Tag, table.Desc, v, isSite, codeSite)
|
|
|
- if tag != "" && table.Tag == "" {
|
|
|
- table.Tag = tag
|
|
|
- }
|
|
|
- for kk, vv := range kvTags {
|
|
|
- if vsss, ok := v.([]string); ok {
|
|
|
- if len(vv) > 0 {
|
|
|
- for _, vvvvvv := range vsss {
|
|
|
- tmp := u.Tag{}
|
|
|
- tmp.Weight = vv[0].Weight
|
|
|
- tmp.Key = vv[0].Key
|
|
|
- tmp.IsInvalid = vv[0].IsInvalid
|
|
|
- if kk == "单品报价" || kk == "中标金额" || kk == "预算" {
|
|
|
- if strings.Contains(k, "万") {
|
|
|
- tmp.Value = vvvvvv + "万"
|
|
|
- } else if strings.Contains(k, "亿") {
|
|
|
- tmp.Value = vvvvvv + "亿"
|
|
|
- } else {
|
|
|
- tmp.Value = vvvvvv
|
|
|
- }
|
|
|
+ } else if vsss, ok := v.([]string); ok {
|
|
|
+ if len(table.WinnerOrder) > 0 && table.WinnerOrder[0]["price"] == nil && len(vsss) == len(table.WinnerOrder) {
|
|
|
+ kv := ""
|
|
|
+ if winMoneyReg.MatchString(k) {
|
|
|
+ kv = "中标金额"
|
|
|
+ } else {
|
|
|
+ kt := u.GetTags(k, isSite, codeSite)
|
|
|
+ if kt.Len() > 0 {
|
|
|
+ if kt[0].Value == "单品报价" && winnertag {
|
|
|
+ kv = "中标金额"
|
|
|
} else {
|
|
|
- tmp.Value = vvvvvv
|
|
|
+ kv = kt[0].Value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if kv == "中标金额" {
|
|
|
+ for i, vx := range vsss {
|
|
|
+
|
|
|
+ p1num := numberReg2.FindString(vx)
|
|
|
+ if strings.Contains(p1num, ",") && strings.Contains(p1num, ".") {
|
|
|
+ p1num = strings.ReplaceAll(p1num, ",", "")
|
|
|
+ }
|
|
|
+ p1 := qutil.Float64All(p1num)
|
|
|
+ if p1 > 0 {
|
|
|
+ //smap[vsk]["price"] = winnerOrderEntity.clear("中标金额", vsv+GetMoneyUnit(k, vsv))
|
|
|
+ price := winnerOrderEntity.clear(kv, vx+GetMoneyUnit(k, vx))
|
|
|
+ if pricestr, _ := price.(string); len(pricestr) < 30 && len(pricestr) > 0 && !clearnum.MatchString(pricestr) {
|
|
|
+ table.WinnerOrder[i]["price"] = pricestr
|
|
|
+ }
|
|
|
}
|
|
|
- table.StandKV[kk] = append(table.StandKV[kk], &tmp)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -599,15 +624,8 @@ func (table *Table) MergerToTableresult() {
|
|
|
if len(v1.WinnerOrder) > 0 && len(bp.WinnerOrder) == 0 {
|
|
|
bp.WinnerOrder = v1.WinnerOrder
|
|
|
}
|
|
|
- //table.TableResult.PackageMap.AddKey(k, v)
|
|
|
}
|
|
|
}
|
|
|
- // str := ""
|
|
|
- // for _, k := range table.TableResult.PackageMap.Keys {
|
|
|
- // v := table.TableResult.PackageMap.Map[k].(*u.BlockPackage)
|
|
|
- // str += fmt.Sprintf("包号:%s,中标人:%s,中标价:%s,预算:%s,文本:%s,排名:%v ---\t", v.Index, v.TableKV["中标单位"]+v.ColonKV["中标单位"], v.TableKV["中标金额"]+v.ColonKV["中标金额"], v.TableKV["预算"]+v.ColonKV["预算"], v.Text, v.WinnerOrder)
|
|
|
- // }
|
|
|
- // u.Debug(table, table.TableResult, str)
|
|
|
}
|
|
|
//遍历标准key到tableresult.sortkv中
|
|
|
for _, v := range table.StandKV {
|
|
@@ -674,6 +692,9 @@ func AnalyTableV2(tabs *goquery.Selection, toptype, blockTag, con string, itype
|
|
|
}
|
|
|
//生成tableresult对象
|
|
|
tabres = NewTableResult(_id, toptype, blockTag, con, itype, ruleBlock)
|
|
|
+ if fblbReg.MatchString(blockTag) {
|
|
|
+ return
|
|
|
+ }
|
|
|
//可以有多个table
|
|
|
//for _, table := range tabs {
|
|
|
//隐藏表格跳过
|
|
@@ -802,7 +823,7 @@ func (table *Table) Analy(contactFormat *u.ContactFormat, isSite bool, codeSite
|
|
|
trs = table.Goquery.ChildrenFiltered("tr")
|
|
|
}
|
|
|
ztb := table.Goquery.Find("table").Size()
|
|
|
- if ztb >= 10 {
|
|
|
+ if ztb >= 9 {
|
|
|
return []*Table{}
|
|
|
}
|
|
|
//遍历节点,初始化table 结构
|
|
@@ -817,6 +838,8 @@ func (table *Table) Analy(contactFormat *u.ContactFormat, isSite bool, codeSite
|
|
|
return ts
|
|
|
}
|
|
|
|
|
|
+var fblbReg *regexp.Regexp = regexp.MustCompile("(废标|流标|负责人资格|负责人业绩|相关业绩|开标记录|附件[:0-9]|越南盾|技术分|填报项目业绩|未通过.*原因)")
|
|
|
+
|
|
|
//遍历节点,初始化table 结构体
|
|
|
func (table *Table) createTabe(trs *goquery.Selection, isSite bool, codeSite string) {
|
|
|
trs.Each(func(n int, sel *goquery.Selection) {
|
|
@@ -843,7 +866,7 @@ func (table *Table) createTabe(trs *goquery.Selection, isSite bool, codeSite str
|
|
|
if tds.Size() == empty {
|
|
|
tdTextIsNull = true
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
})
|
|
|
//向table添加每行不为空的tr
|
|
|
if !tdTextIsNull {
|
|
@@ -1086,7 +1109,11 @@ func (table *Table) ComputeRowColSpan() {
|
|
|
nk := 0 //nk列的起始,k行的起始||如果有合并,起始就不是0
|
|
|
ball := true
|
|
|
rowspans := v.TDs[0].Rowspan //某一行第一个td的rowspan
|
|
|
- for _, v1 := range v.TDs {
|
|
|
+ for k1, v1 := range v.TDs {
|
|
|
+ if k1 == 0 && k == 0 {
|
|
|
+ table.TRs[k].TDs[k1].MustBH = true
|
|
|
+ table.TRs[k].TDs[k1].BH = true
|
|
|
+ }
|
|
|
if v1.Rowspan != rowspans {
|
|
|
ball = false
|
|
|
break
|
|
@@ -1325,7 +1352,7 @@ func (table *Table) ComputeRowColIsKeyRation(isSite bool, codeSite string) {
|
|
|
lentds := len(v.Tdmap[v2])
|
|
|
if v.Rationmap[v2] > checkval {
|
|
|
for _, td := range v.Tdmap[v2] {
|
|
|
- if td.KeyDirect == 0 && !MoneyReg.MatchString(td.Val) {
|
|
|
+ if td.KeyDirect == 0 && !MoneyReg.MatchString(td.Val) && !GSReg.MatchString(td.Val) {
|
|
|
if k1 == "r" {
|
|
|
ck := fmtkey("c", td.StartCol, td.EndCol)
|
|
|
rt := table.StartAndEndRation[ck]
|
|
@@ -1354,7 +1381,7 @@ func (table *Table) ComputeRowColIsKeyRation(isSite bool, codeSite string) {
|
|
|
//clen = len(tdn)
|
|
|
}
|
|
|
if lentds > 1 {
|
|
|
- if ((tdn != nil && v.Rationmap[v2] > fv) || tdn == nil) && td.Valtype != "BO" {
|
|
|
+ if td.Valtype != "NOHEAD" && utf8.RuneCountInString(td.Val) < 15 && ((tdn != nil && v.Rationmap[v2] > fv) || tdn == nil) && td.Valtype != "BO" {
|
|
|
td.KeyDirect = 2
|
|
|
td.KVDirect = 1
|
|
|
td.BH = true
|
|
@@ -1450,10 +1477,10 @@ func (table *Table) FindKV(isSite bool, codeSite string) {
|
|
|
bcon := false
|
|
|
//增加表格切块判断,只判断切块分包
|
|
|
//控制中标人排序方向
|
|
|
- bodirect := 0
|
|
|
+ //bodirect := 0
|
|
|
//控制中标人排序数值
|
|
|
- sort := 1
|
|
|
-
|
|
|
+ //sort := 1
|
|
|
+ nextdirect, nextvdirect := 0, 0
|
|
|
//开始抽取
|
|
|
for _, tr := range table.TRs {
|
|
|
bcon = trSingleColumn(tr, bcon, table) //tr单列,是否丢弃内容
|
|
@@ -1467,7 +1494,12 @@ func (table *Table) FindKV(isSite bool, codeSite string) {
|
|
|
numbh++
|
|
|
}
|
|
|
}
|
|
|
- if numbh > 0 && numbh <= len(tr.TDs)/2 {
|
|
|
+ if numbh != 0 && numbh == len(tr.TDs) { //5e0d53ef0cf41612e0640495
|
|
|
+ nextdirect, nextvdirect = 2, 1
|
|
|
+ continue
|
|
|
+ } else if nextdirect > 0 && nextvdirect > 0 {
|
|
|
+ direct, vdirect = 2, 1
|
|
|
+ } else if numbh > 0 && numbh <= len(tr.TDs)/2 {
|
|
|
direct, vdirect = 1, 2
|
|
|
} else {
|
|
|
direct, vdirect = 2, 1
|
|
@@ -1477,26 +1509,26 @@ func (table *Table) FindKV(isSite bool, codeSite string) {
|
|
|
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])
|
|
|
- }
|
|
|
- }
|
|
|
+ ////都识别不到时,对第一、二中标候选人的处理
|
|
|
+ //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])
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
//fmt.Println("td:", td.Val, td.BH, td.HeadTd, td.KVDirect)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ nextdirect, nextvdirect = 0, 0
|
|
|
}
|
|
|
//qutil.Debug("FindKV", table.SortKV.Map)
|
|
|
} else if len(table.TRs) > 0 { //没有表头的表格处理,默认纵向吧
|
|
@@ -1729,6 +1761,9 @@ func GetBidSort(str string, n int) int {
|
|
|
return val
|
|
|
}
|
|
|
|
|
|
+var cleardwReg *regexp.Regexp = regexp.MustCompile("[((]{1}\\d*[人元件个公斤户]/[人元件个公斤户][))]")
|
|
|
+var zbhxrReg *regexp.Regexp = regexp.MustCompile("(中标候选人|投标单位名称)")
|
|
|
+
|
|
|
//查找每一个单元格的表头,调用FindNear
|
|
|
func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
if td.Val == "" || strings.TrimSpace(td.Val) == "" {
|
|
@@ -1753,7 +1788,7 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- } else if strings.Contains(key, "中标候选人") && strings.Contains(td.Val, "公司") {
|
|
|
+ } else if zbhxrReg.MatchString(key) && findCandidate2.MatchString(td.Val) {
|
|
|
key = "中标单位"
|
|
|
} else if key == "单位名称" {
|
|
|
tmpnewnear := table.FindNear(near, 2)
|
|
@@ -1786,11 +1821,6 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
near = near.TR.TDs[near.ColPos-1]
|
|
|
}
|
|
|
} else {
|
|
|
- //near.Val += "_"
|
|
|
- //for table.SortKV.Map[near.Val] != nil {
|
|
|
- // near.Val += "_"
|
|
|
- //}
|
|
|
- //key = near.Val //之前这个地方没有重置,导致把之前结果覆盖了
|
|
|
bthiskey = true
|
|
|
}
|
|
|
} else {
|
|
@@ -1847,7 +1877,12 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
}
|
|
|
}
|
|
|
if bvalfind && varrpos > -1 && len(vals) > varrpos {
|
|
|
- vals = append(vals, td.Val) // 累加
|
|
|
+ tmapval := strings.TrimSpace(cleardwReg.ReplaceAllString(td.Val, ""))
|
|
|
+ if tmapval == "" {
|
|
|
+ vals = append(vals, td.Val) // 累加
|
|
|
+ } else {
|
|
|
+ vals = append(vals, tmapval) // 累加
|
|
|
+ }
|
|
|
val = vals
|
|
|
//vals[varrpos] = td.Val // += "__" + td.Val
|
|
|
} else {
|
|
@@ -1867,11 +1902,26 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
varrpos = len(vals) - 1
|
|
|
}
|
|
|
} else if vals, ok := val.(string); ok && vals != "" && td.Val != "" {
|
|
|
+ tmapval := strings.TrimSpace(cleardwReg.ReplaceAllString(vals, ""))
|
|
|
+ tmapvaltd := strings.TrimSpace(cleardwReg.ReplaceAllString(td.Val, ""))
|
|
|
if bvalfind {
|
|
|
- val = td.Val //vals + "__" + td.Val
|
|
|
+ if tmapvaltd == "" {
|
|
|
+ val = td.Val //vals + "__" + td.Val
|
|
|
+ } else {
|
|
|
+ val = tmapvaltd
|
|
|
+ }
|
|
|
} else {
|
|
|
- tval := []string{vals}
|
|
|
- tval = append(tval, td.Val)
|
|
|
+ tval := []string{}
|
|
|
+ if tmapval == "" {
|
|
|
+ tval = append(tval, vals)
|
|
|
+ } else {
|
|
|
+ tval = append(tval, tmapval)
|
|
|
+ }
|
|
|
+ if tmapvaltd == "" {
|
|
|
+ tval = append(tval, td.Val)
|
|
|
+ } else {
|
|
|
+ tval = append(tval, tmapvaltd)
|
|
|
+ }
|
|
|
val = tval
|
|
|
varrpos = 1
|
|
|
}
|
|
@@ -1879,7 +1929,12 @@ func (table *Table) FindTdVal(td *TD, direct, vdirect int) (b bool) {
|
|
|
barr = true
|
|
|
} else {
|
|
|
if td.Val != "" {
|
|
|
- val = td.Val
|
|
|
+ tmapval := strings.TrimSpace(cleardwReg.ReplaceAllString(td.Val, ""))
|
|
|
+ if tmapval == "" {
|
|
|
+ val = td.Val
|
|
|
+ } else {
|
|
|
+ val = tmapval
|
|
|
+ }
|
|
|
} else if len(near.SortKV.Map) == 1 && near.SortKV.Map[near.Val] != "" {
|
|
|
val = near.SortKV.Map[near.Val]
|
|
|
}
|
|
@@ -1889,14 +1944,12 @@ 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
|
|
|
- }
|
|
|
if key == "单位名称" && len(near.TR.TDs) > 1 {
|
|
|
- key = near.TR.TDs[0].Val
|
|
|
+ if near.TR.TDs[0].Val != "序号" {
|
|
|
+ key = near.TR.TDs[0].Val
|
|
|
+ }
|
|
|
}
|
|
|
table.SortKV.AddKey(key, val)
|
|
|
- //if table.SortKV.Map[key] != nil {
|
|
|
pos := table.SortKV.Index[key]
|
|
|
if barr {
|
|
|
mval := table.kvscope[pos]
|
|
@@ -1947,16 +2000,20 @@ func (table *Table) FindNear(td *TD, direct int) *TD {
|
|
|
tr := table.TRs[:td.TR.RowPos]
|
|
|
for i := len(tr) - 1; i > -1; i-- {
|
|
|
tds := tr[i].TDs
|
|
|
- for _, td1 := range tds {
|
|
|
+ for it, td1 := range tds {
|
|
|
if td1.StartCol <= td.StartCol && td1.EndCol >= td.EndCol && td1.EndRow+1 == td.StartRow {
|
|
|
//找到左临节点
|
|
|
if td1.BH {
|
|
|
return td1
|
|
|
- } else {
|
|
|
- if td1.HeadTd != nil && td1.HeadTd.KVDirect == direct {
|
|
|
- return td1.HeadTd
|
|
|
- }
|
|
|
+ } else if len(tr[i].TDs) == len(td.TR.TDs) && td1.HeadTd != nil && td1.HeadTd.KVDirect == direct {
|
|
|
+ return td1.HeadTd
|
|
|
+ } else if it > 0 && td1.Val == "" && td1.TR.TopTR == nil && len(td.TR.TDs)-(td.StartCol-1) > 0 && strings.Contains(td.TR.TDs[td.StartCol-1].Val, "中标候选人") {
|
|
|
+ return tds[it-1]
|
|
|
+ } else if td1.HeadTd != nil && td1.HeadTd.KVDirect == direct && td.Colspan == td1.Colspan && td.Rowspan == td.Rowspan {
|
|
|
+ return td1.HeadTd
|
|
|
}
|
|
|
+ } else if td1.StartCol <= td.StartCol && td1.EndCol >= td.EndCol && td1.EndRow+1 == td.StartRow {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2012,7 +2069,6 @@ func (tn *Table) CheckMultiPackageByTable(isSite bool, codeSite string) (b bool,
|
|
|
oldIndex := []string{} //存放包的原始值
|
|
|
brepeat := map[string]bool{}
|
|
|
for k, v := range index {
|
|
|
-
|
|
|
v = u.PackageNumberConvert(v)
|
|
|
if !brepeat[v] {
|
|
|
brepeat[v] = true
|
|
@@ -2046,8 +2102,9 @@ func (tn *Table) CheckMultiPackageByTable(isSite bool, codeSite string) (b bool,
|
|
|
for tnk, tnv := range tn.StandKV {
|
|
|
if nk >= len(tnv) {
|
|
|
continue
|
|
|
+ } else if len(index) == len(tnv) {
|
|
|
+ kv.KvTags[tnk] = append(kv.KvTags[tnk], tnv[nk])
|
|
|
}
|
|
|
- kv.KvTags[tnk] = append(kv.KvTags[tnk], tnv[nk])
|
|
|
}
|
|
|
//kv.KvTags = tn.StandKV
|
|
|
bp := &u.BlockPackage{}
|
|
@@ -2139,119 +2196,24 @@ func (tn *Table) manyPackageProcessByIndex(index []string, standIndex_pos []int,
|
|
|
}
|
|
|
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)
|
|
|
- }
|
|
|
- }
|
|
|
- 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], isSite, codeSite) //组装解析到的分包
|
|
|
- }
|
|
|
- } 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]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if k1 == "单价" {
|
|
|
- continue
|
|
|
- }
|
|
|
- tn.assemblePackage(k1, v, sv2, isSite, codeSite)
|
|
|
- }
|
|
|
- }
|
|
|
- //删除子包的kv
|
|
|
- //u.Debug("----==1==-------", k1)
|
|
|
- k1tags := u.GetTags(k1, isSite, codeSite) //取得匹配
|
|
|
- //if !(len(k1tags) > 0 && k1tags[0].Value == "采购单位") {
|
|
|
- // tn.SortKV.RemoveKey(k1)
|
|
|
- //}
|
|
|
- for _, vcgdw := range k1tags {
|
|
|
- if vcgdw.Value == "采购单位" {
|
|
|
- } else if vcgdw.Value == "预算" && len(val) == len(index) {
|
|
|
- for bi, bv := range index {
|
|
|
- if tn.BlockPackage.Map[bv].(*u.BlockPackage).Budget <= 0 {
|
|
|
- moneys := clear.ObjToMoney([]interface{}{val[bi], ""})
|
|
|
- if len(moneys) > 0 {
|
|
|
- if vf, ok := moneys[0].(float64); ok {
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).Budget = vf
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).IsTrueBudget = moneys[len(moneys)-1].(bool)
|
|
|
- } else if vi, ok := moneys[0].(int); ok {
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).Budget = float64(vi)
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).IsTrueBudget = moneys[len(moneys)-1].(bool)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if vcgdw.Value == "中标金额" && len(val) == len(index) {
|
|
|
- for bi, bv := range index {
|
|
|
- if tn.BlockPackage.Map[bv].(*u.BlockPackage).Bidamount <= 0 {
|
|
|
- moneys := clear.ObjToMoney([]interface{}{val[bi], ""})
|
|
|
- if len(moneys) > 0 {
|
|
|
- if vf, ok := moneys[0].(float64); ok {
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).Bidamount = vf
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).IsTrueBidamount = moneys[len(moneys)-1].(bool)
|
|
|
- } else if vi, ok := moneys[0].(int); ok {
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).Bidamount = float64(vi)
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).IsTrueBidamount = moneys[len(moneys)-1].(bool)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if vcgdw.Value == "中标单位" {
|
|
|
- for _, bv := range index {
|
|
|
- if tn.BlockPackage.Map[bv].(*u.BlockPackage).WinnerOrder == nil || len(tn.BlockPackage.Map[bv].(*u.BlockPackage).WinnerOrder) == 0 {
|
|
|
- continue
|
|
|
- } else {
|
|
|
- tn.BlockPackage.Map[bv].(*u.BlockPackage).Winner = qutil.ObjToString(tn.BlockPackage.Map[bv].(*u.BlockPackage).WinnerOrder[0]["entname"])
|
|
|
- }
|
|
|
+ var v1_arr []string
|
|
|
+ if vtmpv1, ok := v1.(string); ok {
|
|
|
+ v1_arr = PreCon4.FindAllString(qutil.ObjToString(vtmpv1), -1)
|
|
|
+ if len(v1_arr) > 0 {
|
|
|
+ if dw := Precon4dw.FindString(vtmpv1); dw != "" {
|
|
|
+ for i, v := range v1_arr {
|
|
|
+ v1_arr[i] = v + dw
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } else if val, bvs := v1.(string); bvs && len(index) == 1 {
|
|
|
- //删除子包的kv
|
|
|
- kvTags, _ := CommonDataAnaly(k1, "", "", val, isSite, codeSite)
|
|
|
- for kvTag_k, kvTag_v := range kvTags {
|
|
|
- hasValid := false
|
|
|
- for _, kvTag_vv := range kvTag_v {
|
|
|
- if kvTag_vv.IsInvalid {
|
|
|
- continue
|
|
|
- }
|
|
|
- hasValid = true
|
|
|
- }
|
|
|
- if !hasValid {
|
|
|
- continue
|
|
|
- }
|
|
|
- if !(len(kvTags) > 0 && regexp.MustCompile("^(项目|开标|采购单位|招标机构)").MatchString(kvTag_k)) {
|
|
|
- if tn.SortKV.Map[k1] != nil {
|
|
|
- tn.SortKV.RemoveKey(k1)
|
|
|
- tn.assemblePackage(k1, val, index[0], isSite, codeSite)
|
|
|
- }
|
|
|
- //log.Println("remove", k1, val)
|
|
|
- }
|
|
|
+ } else if vtmpv1s, ok := v1.([]string); ok {
|
|
|
+ v1_arr = vtmpv1s
|
|
|
+ }
|
|
|
+ if len(v1_arr) > 0 && len(v1_arr) <= len(index) { //table.SortKV.Map.value数组小于等于分包index
|
|
|
+ for k, v := range v1_arr {
|
|
|
+ tn.assemblePackage(k1, v, index[k], isSite, codeSite) //组装解析到的分包
|
|
|
}
|
|
|
- //u.Debug("----==2==-------", k1)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return isGoonNext
|
|
|
}
|
|
@@ -2271,7 +2233,6 @@ func (tn *Table) isGoonNext(isSite bool, codeSite string) {
|
|
|
} else {
|
|
|
str += fmt.Sprintf("%s:%s\n", nk, v)
|
|
|
}
|
|
|
-
|
|
|
if excludeKey2.MatchString(str) {
|
|
|
continue
|
|
|
}
|
|
@@ -2670,7 +2631,6 @@ func isHasOnePkgAndNoKv(v1 string) (bool, string) {
|
|
|
|
|
|
//替换分包中混淆的词
|
|
|
func replPkgConfusion(v1 string) string {
|
|
|
-
|
|
|
v1 = PreReg.ReplaceAllString(v1, "")
|
|
|
v1 = PreReg1.ReplaceAllString(v1, "")
|
|
|
v1 = PreCon.ReplaceAllString(v1, "")
|
|
@@ -2720,7 +2680,6 @@ func (tn *Table) TdContactFormat(contactFormat *u.ContactFormat, isSite bool, co
|
|
|
for _, this := range thisTdKvs {
|
|
|
if str := ContactInfoVagueReg.FindString(this.Key); str != "" {
|
|
|
td.SortKV.AddKey(tdType+str, this.Value)
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|