|
@@ -47,7 +47,7 @@ func init() {
|
|
|
}
|
|
|
|
|
|
//转int
|
|
|
-func ObjToInt(data []interface{}) []interface{} {
|
|
|
+func ObjToInt(data []interface{},spidercode ...string) []interface{} {
|
|
|
tmp, err := strconv.Atoi(fmt.Sprint(data[0]))
|
|
|
if err != nil {
|
|
|
data[0] = 0
|
|
@@ -59,7 +59,7 @@ func ObjToInt(data []interface{}) []interface{} {
|
|
|
}
|
|
|
|
|
|
//转float,精度小数点4位
|
|
|
-func ObjToFloat(data []interface{}) []interface{} {
|
|
|
+func ObjToFloat(data []interface{},spidercode ...string) []interface{} {
|
|
|
con := fmt.Sprint(data[0])
|
|
|
percent := strings.Contains(con, "%")
|
|
|
if percent {
|
|
@@ -81,7 +81,7 @@ func ObjToFloat(data []interface{}) []interface{} {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func ChiToFloat(data []interface{}) []interface{} {
|
|
|
+func ChiToFloat(data []interface{},spidercode ...string) []interface{} {
|
|
|
tmp := ""
|
|
|
str := fmt.Sprint(data[0])
|
|
|
if strings.Contains(str, "百分之") {
|
|
@@ -89,7 +89,7 @@ func ChiToFloat(data []interface{}) []interface{} {
|
|
|
moneyRegChar.ReplaceAllStringFunc(str, func(key string) string {
|
|
|
if v, ok := moneyChar[key].(float64); ok {
|
|
|
tmp += strconv.FormatFloat(v, 'f', 0, 64)
|
|
|
- }else if v, ok := moneyChar[key].(string); ok {
|
|
|
+ } else if v, ok := moneyChar[key].(string); ok {
|
|
|
tmp += v
|
|
|
}
|
|
|
return tmp
|
|
@@ -98,14 +98,14 @@ func ChiToFloat(data []interface{}) []interface{} {
|
|
|
if err != nil {
|
|
|
return data
|
|
|
}
|
|
|
- return []interface{}{tmpF/100, data[1]}
|
|
|
- }else {
|
|
|
+ return []interface{}{tmpF / 100, data[1]}
|
|
|
+ } else {
|
|
|
return data
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//金额转换
|
|
|
-func ObjToMoney(data []interface{}) []interface{} {
|
|
|
+func ObjToMoney(data []interface{},spidercode ...string) []interface{} {
|
|
|
//isfindUnit := true
|
|
|
tmpstr := (data)[0]
|
|
|
totmpstr := util.ObjToString(tmpstr)
|
|
@@ -145,7 +145,7 @@ func ObjToMoney(data []interface{}) []interface{} {
|
|
|
return data
|
|
|
}
|
|
|
data = append(data, true)
|
|
|
- return data
|
|
|
+ return ClearMaxAmount(data,spidercode...)
|
|
|
}
|
|
|
|
|
|
//["中标金额","成交金额","合同金额","中标价","成交价","成交价格","中标(成交)金额","投标报价","中标标价","成交结果"]
|
|
@@ -271,6 +271,7 @@ func capitalMoney(data []interface{}) []interface{} {
|
|
|
str = str[0:index]
|
|
|
suffixUnit = float64(10000)
|
|
|
}
|
|
|
+ yy:=false
|
|
|
moneyRegChar.ReplaceAllStringFunc(str, func(key string) string {
|
|
|
if key == "元" || key == "圆" || key == "点" {
|
|
|
ishaspoint = true
|
|
@@ -299,6 +300,9 @@ func capitalMoney(data []interface{}) []interface{} {
|
|
|
tmp = float64(0)
|
|
|
}
|
|
|
nodes = append(nodes, node*float64(v))
|
|
|
+ if v == 100000000{
|
|
|
+ yy = true
|
|
|
+ }
|
|
|
node = float64(0)
|
|
|
} else {
|
|
|
if v == 10 && tmp == 0 {
|
|
@@ -314,12 +318,20 @@ func capitalMoney(data []interface{}) []interface{} {
|
|
|
}
|
|
|
return ""
|
|
|
})
|
|
|
- nodes = append(nodes, node, tmp)
|
|
|
+ if yy {
|
|
|
+ nodes = append(nodes, node*suffixUnit, tmp)
|
|
|
+ }else {
|
|
|
+ nodes = append(nodes, node, tmp)
|
|
|
+ }
|
|
|
ret := float64(0)
|
|
|
for _, v := range nodes {
|
|
|
ret += v
|
|
|
}
|
|
|
- return []interface{}{(ret + decimals) * suffixUnit, data[1]}
|
|
|
+ if yy {
|
|
|
+ return []interface{}{(ret + decimals), data[1]}
|
|
|
+ }else {
|
|
|
+ return []interface{}{(ret + decimals) * suffixUnit, data[1]}
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//过滤符号
|
|
@@ -341,7 +353,7 @@ func replaceString(con string, ret, rep []string) string {
|
|
|
}
|
|
|
|
|
|
//费率转小数
|
|
|
-func RateToFloat(con []interface{}) []interface{} {
|
|
|
+func RateToFloat(con []interface{},spidercode ...string) []interface{} {
|
|
|
tmp := fmt.Sprint(CutAllSpace(con)[0])
|
|
|
if strings.Contains(tmp, "%") || strings.Contains(tmp, "%") {
|
|
|
tmp = strings.Replace(tmp, "%", "", -1)
|
|
@@ -354,11 +366,27 @@ func RateToFloat(con []interface{}) []interface{} {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//大于一万亿的过滤掉
|
|
|
-func ClearMaxAmount(data []interface{}) []interface{} {
|
|
|
+//大于五千亿的过滤掉
|
|
|
+func ClearMaxAmount(data []interface{},spidercode ...string) []interface{} {
|
|
|
value, _ := data[0].(float64)
|
|
|
- if value >= 1000000000000 {
|
|
|
+ if len(spidercode) > 0{
|
|
|
+ if sp,ok:=moneyClearSpidercode[spidercode[0]];ok{
|
|
|
+ maxmoney := util.Float64All(sp.(map[string]interface{})["maxmoney"])
|
|
|
+ divisor := util.Float64All(sp.(map[string]interface{})["divisor"])
|
|
|
+ if value>=maxmoney{
|
|
|
+ value /= divisor
|
|
|
+ data[0] = value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if value >= 500000000000 {
|
|
|
data[0] = float64(0)
|
|
|
+ data[1] = false
|
|
|
}
|
|
|
return data
|
|
|
}
|
|
|
+var moneyClearSpidercode map[string]interface{}
|
|
|
+
|
|
|
+func init() {
|
|
|
+ util.ReadConfig("res/moneyclear.json",&moneyClearSpidercode)
|
|
|
+}
|