|
@@ -1,19 +1,102 @@
|
|
package main
|
|
package main
|
|
|
|
+
|
|
import (
|
|
import (
|
|
qu "qfw/util"
|
|
qu "qfw/util"
|
|
|
|
+ "strings"
|
|
|
|
+ "unicode/utf8"
|
|
)
|
|
)
|
|
var element_reason map[string]interface{}
|
|
var element_reason map[string]interface{}
|
|
|
|
|
|
func dealWithElementRate(tmp map[string]interface{}) (int,map[string]interface{}) {
|
|
func dealWithElementRate(tmp map[string]interface{}) (int,map[string]interface{}) {
|
|
|
|
|
|
- //score_standard 打分标准
|
|
|
|
|
|
+ //score_standard 打分标准 要素打分 - 需慎重
|
|
element_reason = map[string]interface{}{}
|
|
element_reason = map[string]interface{}{}
|
|
m,n,z :=0,0,0
|
|
m,n,z :=0,0,0
|
|
core_value,other_value,deduct_value :="","",""
|
|
core_value,other_value,deduct_value :="","",""
|
|
|
|
|
|
|
|
+ //第一次-配置验证
|
|
|
|
+ coreArr,otherArr:=filterConfiguration(tmp)
|
|
|
|
+ //细节过滤-验证
|
|
|
|
+ new_coreArr,new_otherArr:=[]string{},[]string{}
|
|
|
|
+ for _,v:=range coreArr{
|
|
|
|
+ if v=="projectname"||v=="buyer"||v=="winner" {
|
|
|
|
+ if isChinese(qu.ObjToString(tmp[v])) {
|
|
|
|
+ new_coreArr = append(new_coreArr,v)
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ new_coreArr = append(new_coreArr,v)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _,v:=range otherArr{
|
|
|
|
+ if v=="agencyperson"||v=="buyerperson"||v=="winnerperson" {
|
|
|
|
+ if isChinese(qu.ObjToString(tmp[v])) {
|
|
|
|
+ new_otherArr = append(new_otherArr,v)
|
|
|
|
+ }
|
|
|
|
+ }else if v=="agencytel"||v=="buyertel"||v=="winnertel" {
|
|
|
|
+ if !isChinese(qu.ObjToString(tmp[v])) {
|
|
|
|
+ if isTelephone(qu.ObjToString(tmp[v])) {
|
|
|
|
+ new_otherArr = append(new_otherArr,v)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else if v=="bidopentime"||v=="signaturedate" {
|
|
|
|
+ if isTimestamp(qu.Int64All(tmp[v])) {
|
|
|
|
+ new_otherArr = append(new_otherArr,v)
|
|
|
|
+ }
|
|
|
|
+ }else if v=="bidopenaddress"||v=="winneraddr"||v=="agencyaddr"||
|
|
|
|
+ v=="buyeraddr" {
|
|
|
|
+ if isPlaceAddr(qu.ObjToString(tmp[v])) {
|
|
|
|
+ new_otherArr = append(new_otherArr,v)
|
|
|
|
+ }
|
|
|
|
+ }else if v=="projectaddr" {
|
|
|
|
+ if isChinese(qu.ObjToString(tmp[v])) {
|
|
|
|
+ new_otherArr = append(new_otherArr,v)
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ new_otherArr = append(new_otherArr,v)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ core_value = strings.Join(new_coreArr, ",")
|
|
|
|
+ m = len(new_coreArr)
|
|
|
|
|
|
- //要素打分 - 需慎重 core_element other_element deduct_element
|
|
|
|
|
|
+ other_value = strings.Join(new_otherArr, ",")
|
|
|
|
+ n = len(new_otherArr)
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //扣分项
|
|
|
|
+ for _,v:=range deduct_element{
|
|
|
|
+ if qu.ObjToString(tmp[v])=="" {
|
|
|
|
+ z--
|
|
|
|
+ if deduct_value == "" {
|
|
|
|
+ deduct_value = v
|
|
|
|
+ }else {
|
|
|
|
+ deduct_value = deduct_value+","+v
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ total,core_s,other_s,deduct_s:=calculateScore(m,n,z)
|
|
|
|
+ return total,map[string]interface{}{
|
|
|
|
+ "coreElement":map[string]interface{}{
|
|
|
|
+ "key":core_value,
|
|
|
|
+ "core_score":core_s,
|
|
|
|
+ },
|
|
|
|
+ "otherElement":map[string]interface{}{
|
|
|
|
+ "key":other_value,
|
|
|
|
+ "other_score":other_s,
|
|
|
|
+ },
|
|
|
|
+ "deductElement":map[string]interface{}{
|
|
|
|
+ "key":deduct_value,
|
|
|
|
+ "deduct_score":deduct_s,
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func filterConfiguration(tmp map[string]interface{})([]string,[]string) {
|
|
|
|
+ coreArr ,otherArr:= []string{},[]string{}
|
|
|
|
+ //核心要素 int - 时间- float-金额区间 string-字符串长度
|
|
for _,v:=range core_element{
|
|
for _,v:=range core_element{
|
|
for k1,v1:=range v{
|
|
for k1,v1:=range v{
|
|
if tmp[k1]==nil {
|
|
if tmp[k1]==nil {
|
|
@@ -21,23 +104,25 @@ func dealWithElementRate(tmp map[string]interface{}) (int,map[string]interface{}
|
|
}
|
|
}
|
|
dict :=*qu.ObjToMap(v1)
|
|
dict :=*qu.ObjToMap(v1)
|
|
element_type := qu.ObjToString(dict["type"])
|
|
element_type := qu.ObjToString(dict["type"])
|
|
|
|
+
|
|
if element_type=="int" {
|
|
if element_type=="int" {
|
|
- temp_num:=qu.IntAll(dict["large"])
|
|
|
|
- if qu.IntAll(tmp[k1])>temp_num {
|
|
|
|
- m++
|
|
|
|
- core_value = core_value+k1+"-"
|
|
|
|
|
|
+ min:=qu.IntAll(dict["min"])
|
|
|
|
+ if qu.IntAll(tmp[k1])>min {
|
|
|
|
+ coreArr = append(coreArr,k1)
|
|
}
|
|
}
|
|
}else if element_type=="float" {
|
|
}else if element_type=="float" {
|
|
- temp_num:=qu.Float64All(dict["large"])
|
|
|
|
- if qu.Float64All(tmp[k1])>temp_num {
|
|
|
|
- m++
|
|
|
|
- core_value = core_value+k1+"-"
|
|
|
|
|
|
+ min:=qu.Float64All(dict["min"])
|
|
|
|
+ max:=qu.Float64All(dict["max"])
|
|
|
|
+ if qu.Float64All(tmp[k1])>min && qu.Float64All(tmp[k1])<max{
|
|
|
|
+ coreArr = append(coreArr,k1)
|
|
}
|
|
}
|
|
}else if element_type=="string" {
|
|
}else if element_type=="string" {
|
|
- temp_length:=qu.IntAll(dict["length"])
|
|
|
|
- if len(qu.ObjToString(tmp[k1]))>temp_length {
|
|
|
|
- m++
|
|
|
|
- core_value = core_value+k1+"-"
|
|
|
|
|
|
+ min:=qu.IntAll(dict["min"])
|
|
|
|
+ max:=qu.IntAll(dict["max"])
|
|
|
|
+
|
|
|
|
+ if utf8.RuneCountInString(qu.ObjToString(tmp[k1]))>min &&
|
|
|
|
+ utf8.RuneCountInString(qu.ObjToString(tmp[k1]))<max{
|
|
|
|
+ coreArr = append(coreArr,k1)
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
|
|
|
|
@@ -45,6 +130,7 @@ func dealWithElementRate(tmp map[string]interface{}) (int,map[string]interface{}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
for _,v:=range other_element{
|
|
for _,v:=range other_element{
|
|
for k1,v1:=range v{
|
|
for k1,v1:=range v{
|
|
if tmp[k1]==nil {
|
|
if tmp[k1]==nil {
|
|
@@ -52,23 +138,25 @@ func dealWithElementRate(tmp map[string]interface{}) (int,map[string]interface{}
|
|
}
|
|
}
|
|
dict :=*qu.ObjToMap(v1)
|
|
dict :=*qu.ObjToMap(v1)
|
|
element_type := qu.ObjToString(dict["type"])
|
|
element_type := qu.ObjToString(dict["type"])
|
|
|
|
+
|
|
if element_type=="int" {
|
|
if element_type=="int" {
|
|
- temp_num:=qu.IntAll(dict["large"])
|
|
|
|
- if qu.IntAll(tmp[k1])>temp_num {
|
|
|
|
- n++
|
|
|
|
- other_value = other_value+k1+"-"
|
|
|
|
|
|
+ min:=qu.IntAll(dict["min"])
|
|
|
|
+ if qu.IntAll(tmp[k1])>min {
|
|
|
|
+ otherArr = append(otherArr,k1)
|
|
}
|
|
}
|
|
}else if element_type=="float" {
|
|
}else if element_type=="float" {
|
|
- temp_num:=qu.Float64All(dict["large"])
|
|
|
|
- if qu.Float64All(tmp[k1])>temp_num {
|
|
|
|
- n++
|
|
|
|
- other_value = other_value+k1+"-"
|
|
|
|
|
|
+ min:=qu.Float64All(dict["min"])
|
|
|
|
+ max:=qu.Float64All(dict["max"])
|
|
|
|
+ if qu.Float64All(tmp[k1])>min && qu.Float64All(tmp[k1])<max{
|
|
|
|
+ otherArr = append(otherArr,k1)
|
|
}
|
|
}
|
|
}else if element_type=="string" {
|
|
}else if element_type=="string" {
|
|
- temp_length:=qu.IntAll(dict["length"])
|
|
|
|
- if len(qu.ObjToString(tmp[k1]))>temp_length {
|
|
|
|
- n++
|
|
|
|
- other_value = other_value+k1+"-"
|
|
|
|
|
|
+ min:=qu.IntAll(dict["min"])
|
|
|
|
+ max:=qu.IntAll(dict["max"])
|
|
|
|
+
|
|
|
|
+ if utf8.RuneCountInString(qu.ObjToString(tmp[k1]))>min &&
|
|
|
|
+ utf8.RuneCountInString(qu.ObjToString(tmp[k1]))<max{
|
|
|
|
+ otherArr = append(otherArr,k1)
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
|
|
|
|
@@ -76,30 +164,11 @@ func dealWithElementRate(tmp map[string]interface{}) (int,map[string]interface{}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ return coreArr,otherArr
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
- for _,v:=range deduct_element{
|
|
|
|
- if qu.ObjToString(tmp[v])=="" {
|
|
|
|
- z--
|
|
|
|
- deduct_value = deduct_value+v+"-"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- total,core_s,other_s,deduct_s:=calculateScore(m,n,z)
|
|
|
|
- return total,map[string]interface{}{
|
|
|
|
- "coreElement":map[string]interface{}{
|
|
|
|
- "key":core_value,
|
|
|
|
- "core_score":core_s,
|
|
|
|
- },
|
|
|
|
- "otherElement":map[string]interface{}{
|
|
|
|
- "key":other_value,
|
|
|
|
- "other_score":other_s,
|
|
|
|
- },
|
|
|
|
- "deductElement":map[string]interface{}{
|
|
|
|
- "key":deduct_value,
|
|
|
|
- "deduct_score":deduct_s,
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
|
|
func calculateScore(core_num int,other_num int,deduct_num int) (int,int,int,int) {
|
|
func calculateScore(core_num int,other_num int,deduct_num int) (int,int,int,int) {
|
|
|
|
|