|
@@ -2,6 +2,7 @@ package pretreated
|
|
|
|
|
|
import (
|
|
import (
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "github.com/shopspring/decimal"
|
|
"jy/clear"
|
|
"jy/clear"
|
|
u "jy/util"
|
|
u "jy/util"
|
|
qutil "qfw/util"
|
|
qutil "qfw/util"
|
|
@@ -31,7 +32,10 @@ var (
|
|
//清理表格td中的符号
|
|
//清理表格td中的符号
|
|
tabletdclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、,。_??;;~\\-#\\\\()(){}【】\\[\\]<>《》{}〔〕¥$]*")
|
|
tabletdclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、,。_??;;~\\-#\\\\()(){}【】\\[\\]<>《》{}〔〕¥$]*")
|
|
//判断key是金额,对万元的处理
|
|
//判断key是金额,对万元的处理
|
|
- moneyreg = regexp.MustCompile("(预算|费|价|额|规模|投资)")
|
|
|
|
|
|
+ moneyReg = regexp.MustCompile("(预算|费|价|额|规模|投资)")
|
|
|
|
+ //特殊文本-为表头
|
|
|
|
+ specHeadReg = regexp.MustCompile("(成交供应商|中选人)")
|
|
|
|
+
|
|
//key不需要清理-例如折扣 费率
|
|
//key不需要清理-例如折扣 费率
|
|
no_clear_key_reg = regexp.MustCompile(`[((](费率|年|月|日|天|日历天|历天)[))]`)
|
|
no_clear_key_reg = regexp.MustCompile(`[((](费率|年|月|日|天|日历天|历天)[))]`)
|
|
//根据表格的内容判断是不是表头,如果含有金额则不是表头
|
|
//根据表格的内容判断是不是表头,如果含有金额则不是表头
|
|
@@ -167,7 +171,7 @@ func CommonDataAnaly(k, tabletag, tabledesc string, v interface{}, isSite bool,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//对值单位的处理 (预算|费|价|额|规模|投资)
|
|
//对值单位的处理 (预算|费|价|额|规模|投资)
|
|
- if moneyreg.MatchString(k) {
|
|
|
|
|
|
+ if moneyReg.MatchString(k) {
|
|
v1 += GetMoneyUnit(k, v1)
|
|
v1 += GetMoneyUnit(k, v1)
|
|
}
|
|
}
|
|
//先清理key
|
|
//先清理key
|
|
@@ -258,7 +262,7 @@ func isRepeatArrString(arr1, arr2 []string) bool {
|
|
return is_r
|
|
return is_r
|
|
}
|
|
}
|
|
|
|
|
|
-//中标金额-单位-同时存在-且万元-重构
|
|
|
|
|
|
+//对sortkv重构
|
|
func isResetUnitAmountSortKV(table *Table) {
|
|
func isResetUnitAmountSortKV(table *Table) {
|
|
isUnitAmount := 0
|
|
isUnitAmount := 0
|
|
for _, k := range table.SortKV.Keys {
|
|
for _, k := range table.SortKV.Keys {
|
|
@@ -276,6 +280,68 @@ func isResetUnitAmountSortKV(table *Table) {
|
|
table.SortKV.Map["中标金额"] = qutil.ObjToString(table.SortKV.Map["中标金额"]) + "万元"
|
|
table.SortKV.Map["中标金额"] = qutil.ObjToString(table.SortKV.Map["中标金额"]) + "万元"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+func isResetUnitPriceSortKV(table *Table) {
|
|
|
|
+ keyArr := []string{"序号", "数量", "单价"}
|
|
|
|
+ isMatch := true
|
|
|
|
+ for _, v := range keyArr {
|
|
|
|
+ if _, ok := table.SortKV.Map[v].(string); !ok {
|
|
|
|
+ isMatch = false
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isMatch && table.SortKV.Map["总价(元)"] == nil {
|
|
|
|
+ if qutil.ObjToString(table.SortKV.Map["序号"]) == "1" &&
|
|
|
|
+ qutil.ObjToString(table.SortKV.Map["数量"]) == "1" {
|
|
|
|
+ table.SortKV.Map["总价(元)"] = table.SortKV.Map["单价"]
|
|
|
|
+ table.SortKV.Keys = append(table.SortKV.Keys, "总价(元)")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+func isResetAmountAggregateSortKV(table *Table) {
|
|
|
|
+ keyGroup := [][]string{}
|
|
|
|
+ keyGroup = append(keyGroup, []string{"序号", "标项名称", "总价(元)"})
|
|
|
|
+ keyGroup = append(keyGroup, []string{"序号", "服务内容", "验收金额(元)"})
|
|
|
|
+ for _, v := range keyGroup {
|
|
|
|
+ temp := map[string]bool{}
|
|
|
|
+ for _, v1 := range v {
|
|
|
|
+ for _, v2 := range table.SortKV.Keys {
|
|
|
|
+ if v1 == v2 {
|
|
|
|
+ temp[v1] = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(temp) == 3 {
|
|
|
|
+ arr1 := u.ConvertInterface(table.SortKV.Map[v[0]])
|
|
|
|
+ arr2 := u.ConvertInterface(table.SortKV.Map[v[1]])
|
|
|
|
+ arr3 := u.ConvertInterface(table.SortKV.Map[v[2]])
|
|
|
|
+ if len(arr1) == len(arr2) && len(arr1) == len(arr3) && len(arr3) > 1 {
|
|
|
|
+ amount := float64(0)
|
|
|
|
+ for _, nv := range arr3 {
|
|
|
|
+ amount = precisionFloat(amount, qutil.Float64All(nv))
|
|
|
|
+ }
|
|
|
|
+ if amount > float64(0) {
|
|
|
|
+ table.SortKV.Map[v[2]] = fmt.Sprintf("%f", amount)
|
|
|
|
+ }
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+func isReseterialNumberSortKV(table *Table) {
|
|
|
|
+ arr := u.ConvertInterface(table.SortKV.Map["序号"])
|
|
|
|
+ if len(arr) > 5 {
|
|
|
|
+ table.SortKV.Map["序号"] = arr[:3]
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//精度丢失-相加
|
|
|
|
+func precisionFloat(tmp1, tmp2 float64) float64 {
|
|
|
|
+ n1 := decimal.NewFromFloat(tmp1)
|
|
|
|
+ n2 := decimal.NewFromFloat(tmp2)
|
|
|
|
+ decimalValue := n2.Add(n1)
|
|
|
|
+ res, _ := decimalValue.Float64()
|
|
|
|
+ return res
|
|
|
|
+}
|
|
|
|
|
|
//重置as~keys
|
|
//重置as~keys
|
|
func resetAsKeysBidamount(as *SortMap) {
|
|
func resetAsKeysBidamount(as *SortMap) {
|
|
@@ -321,6 +387,12 @@ func (table *Table) KVFilter(isSite bool, codeSite string) {
|
|
|
|
|
|
//中标金额-单位-同时存在-且万元-重构
|
|
//中标金额-单位-同时存在-且万元-重构
|
|
isResetUnitAmountSortKV(table)
|
|
isResetUnitAmountSortKV(table)
|
|
|
|
+ //特殊类~总价需要累加
|
|
|
|
+ isResetAmountAggregateSortKV(table)
|
|
|
|
+ //特殊类~单价核算到金额上
|
|
|
|
+ isResetUnitPriceSortKV(table)
|
|
|
|
+ //针对序号组过长
|
|
|
|
+ isReseterialNumberSortKV(table)
|
|
|
|
|
|
//遍历table.sortkv,进行过滤处理,并放入标准化KV中,如果值是数组跳到下一步处理
|
|
//遍历table.sortkv,进行过滤处理,并放入标准化KV中,如果值是数组跳到下一步处理
|
|
pre_k := ""
|
|
pre_k := ""
|
|
@@ -1421,6 +1493,9 @@ func (table *Table) ComputeRowColIsKeyRation(isSite bool, codeSite string) {
|
|
for _, td := range tr.TDs {
|
|
for _, td := range tr.TDs {
|
|
if !MoneyReg.MatchString(td.Val) {
|
|
if !MoneyReg.MatchString(td.Val) {
|
|
//td.BH = true
|
|
//td.BH = true
|
|
|
|
+ if specHeadReg.MatchString(td.Val) {
|
|
|
|
+ td.BH = true
|
|
|
|
+ }
|
|
td.KeyDirect = 1
|
|
td.KeyDirect = 1
|
|
td.KVDirect = 2
|
|
td.KVDirect = 2
|
|
}
|
|
}
|