|
@@ -7,36 +7,98 @@ import (
|
|
|
|
|
|
var Unset_Check = map[string]interface{}{"winner": 1, "s_winner": 1, "bidamount": 1, "winnerorder": 1}
|
|
|
|
|
|
+// 大模型与抽取数据合并计算
|
|
|
+func ChooseCheckDataAI(tmp map[string]interface{}, update_info *map[string]interface{}) bool {
|
|
|
+ if tmp["ai_zhipu"] == nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //记录抽取原值
|
|
|
+ ext_ai_record := map[string]interface{}{}
|
|
|
+ ai_zhipu := *qu.ObjToMap(tmp["ai_zhipu"])
|
|
|
+ //选取分类
|
|
|
+ s_toptype, s_subtype := ChooseTheBestClassField(ai_zhipu, tmp, update_info, &ext_ai_record)
|
|
|
+ //选取字段
|
|
|
+ ChooseTheBestCoreField(ai_zhipu, s_toptype, s_subtype, tmp, update_info, &ext_ai_record)
|
|
|
+ //选取分包
|
|
|
+ ChooseTheBestPackageField(ai_zhipu, s_toptype, s_subtype, tmp, update_info, &ext_ai_record)
|
|
|
+ //最终金额修正与选取
|
|
|
+ ChooseTheBestAmountField(tmp, update_info)
|
|
|
+
|
|
|
+ //字段记录
|
|
|
+ (*update_info)["ext_ai_record"] = ext_ai_record
|
|
|
+
|
|
|
+ //跨分类是否删除结果类字段
|
|
|
+ if s_subtype == "单一" || s_subtype == "中标" || s_subtype == "成交" || s_subtype == "合同" {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ for k, _ := range Unset_Check {
|
|
|
+ if tmp[k] != nil {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+// 选取分类
|
|
|
+func ChooseTheBestClassField(ai_zhipu map[string]interface{}, tmp map[string]interface{}, update_info *map[string]interface{}, ext_ai_record *map[string]interface{}) (string, string) {
|
|
|
+ //分类字段···
|
|
|
+ s_toptype, s_subtype := qu.ObjToString(ai_zhipu["s_toptype"]), qu.ObjToString(ai_zhipu["s_subtype"])
|
|
|
+ ns_toptype, ns_subtype := CheckClassByOtherFileds(s_toptype, s_subtype, tmp)
|
|
|
+ if ns_toptype != s_toptype || ns_subtype != s_subtype {
|
|
|
+ (*ext_ai_record)["s_toptype"] = ns_toptype
|
|
|
+ (*ext_ai_record)["s_subtype"] = ns_subtype
|
|
|
+ }
|
|
|
+ //赋值···
|
|
|
+ s_toptype, s_subtype = ns_toptype, ns_subtype
|
|
|
+ if qu.ObjToString(tmp["toptype"]) == "拟建" || qu.ObjToString(tmp["toptype"]) == "产权" {
|
|
|
+ s_toptype = qu.ObjToString(tmp["toptype"])
|
|
|
+ s_subtype = qu.ObjToString(tmp["subtype"])
|
|
|
+ } else {
|
|
|
+ if s_toptype != "" && s_subtype != "" {
|
|
|
+ (*update_info)["toptype"] = s_toptype
|
|
|
+ (*update_info)["subtype"] = s_subtype
|
|
|
+ (*ext_ai_record)["toptype"] = tmp["toptype"]
|
|
|
+ (*ext_ai_record)["subtype"] = tmp["subtype"]
|
|
|
+ } else {
|
|
|
+ s_toptype = qu.ObjToString(tmp["toptype"])
|
|
|
+ s_subtype = qu.ObjToString(tmp["subtype"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return s_toptype, s_subtype
|
|
|
+}
|
|
|
+
|
|
|
// 选取字段
|
|
|
-func ChooseTheBestCoreField(ai_zhipu map[string]interface{}, s_toptype string, s_subtype string, tmp map[string]interface{}, update_info map[string]interface{}, ext_ai_record map[string]interface{}) {
|
|
|
+func ChooseTheBestCoreField(ai_zhipu map[string]interface{}, s_toptype string, s_subtype string, tmp map[string]interface{}, update_info *map[string]interface{}, ext_ai_record *map[string]interface{}) {
|
|
|
//基础字段···
|
|
|
if s_buyer := qu.ObjToString(ai_zhipu["s_buyer"]); s_buyer != "" {
|
|
|
- update_info["buyer"] = s_buyer
|
|
|
- ext_ai_record["buyer"] = tmp["buyer"]
|
|
|
+ (*update_info)["buyer"] = s_buyer
|
|
|
+ (*ext_ai_record)["buyer"] = tmp["buyer"]
|
|
|
if agency := qu.ObjToString(tmp["agency"]); agency != "" && agency == s_buyer {
|
|
|
- delete(update_info, "buyer")
|
|
|
- delete(ext_ai_record, "buyer")
|
|
|
+ delete((*update_info), "buyer")
|
|
|
+ delete((*ext_ai_record), "buyer")
|
|
|
}
|
|
|
}
|
|
|
if s_projectname := qu.ObjToString(ai_zhipu["s_projectname"]); s_projectname != "" {
|
|
|
- update_info["projectname"] = s_projectname
|
|
|
- ext_ai_record["projectname"] = tmp["projectname"]
|
|
|
+ (*update_info)["projectname"] = s_projectname
|
|
|
+ (*ext_ai_record)["projectname"] = tmp["projectname"]
|
|
|
}
|
|
|
if s_projectcode := qu.ObjToString(ai_zhipu["s_projectcode"]); s_projectcode != "" {
|
|
|
- update_info["projectcode"] = s_projectcode
|
|
|
- ext_ai_record["projectcode"] = tmp["projectcode"]
|
|
|
+ (*update_info)["projectcode"] = s_projectcode
|
|
|
+ (*ext_ai_record)["projectcode"] = tmp["projectcode"]
|
|
|
}
|
|
|
if s_budget := qu.Float64All(ai_zhipu["s_budget"]); s_budget > 0.0 && s_budget < 1000000000.0 {
|
|
|
- update_info["budget"] = s_budget
|
|
|
- ext_ai_record["budget"] = tmp["budget"]
|
|
|
+ (*update_info)["budget"] = s_budget
|
|
|
+ (*ext_ai_record)["budget"] = tmp["budget"]
|
|
|
}
|
|
|
//地域字段···
|
|
|
o_area, o_district := qu.ObjToString(tmp["area"]), qu.ObjToString(tmp["district"])
|
|
|
s_area, s_city := qu.ObjToString(ai_zhipu["s_area"]), qu.ObjToString(ai_zhipu["s_city"])
|
|
|
if s_area != "" && s_area != "全国" {
|
|
|
- update_info["area"] = s_area
|
|
|
+ (*update_info)["area"] = s_area
|
|
|
if s_city != "" {
|
|
|
- update_info["city"] = s_city
|
|
|
+ (*update_info)["city"] = s_city
|
|
|
if o_district != "" {
|
|
|
//判断抽取的区县是否合理···
|
|
|
isT := false
|
|
@@ -49,35 +111,35 @@ func ChooseTheBestCoreField(ai_zhipu map[string]interface{}, s_toptype string, s
|
|
|
}
|
|
|
}
|
|
|
if !isT {
|
|
|
- update_info["district"] = ""
|
|
|
+ (*update_info)["district"] = ""
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
if o_area != s_area {
|
|
|
- update_info["city"] = ""
|
|
|
- update_info["district"] = ""
|
|
|
+ (*update_info)["city"] = ""
|
|
|
+ (*update_info)["district"] = ""
|
|
|
}
|
|
|
}
|
|
|
- ext_ai_record["area"] = tmp["area"]
|
|
|
- ext_ai_record["city"] = tmp["city"]
|
|
|
- ext_ai_record["district"] = tmp["district"]
|
|
|
+ (*ext_ai_record)["area"] = tmp["area"]
|
|
|
+ (*ext_ai_record)["city"] = tmp["city"]
|
|
|
+ (*ext_ai_record)["district"] = tmp["district"]
|
|
|
}
|
|
|
//先用外围字段替换
|
|
|
if s_subtype == "中标" || s_subtype == "成交" || s_subtype == "合同" || s_subtype == "单一" {
|
|
|
if s_bidamount := qu.Float64All(ai_zhipu["s_bidamount"]); s_bidamount > 0.0 && s_bidamount < 1000000000.0 {
|
|
|
- update_info["bidamount"] = s_bidamount
|
|
|
- ext_ai_record["bidamount"] = tmp["bidamount"]
|
|
|
+ (*update_info)["bidamount"] = s_bidamount
|
|
|
+ (*ext_ai_record)["bidamount"] = tmp["bidamount"]
|
|
|
}
|
|
|
if s_winner := qu.ObjToString(ai_zhipu["s_winner"]); s_winner != "" {
|
|
|
- update_info["s_winner"] = s_winner
|
|
|
- ext_ai_record["s_winner"] = tmp["s_winner"]
|
|
|
- update_info["winner"] = s_winner
|
|
|
- ext_ai_record["winner"] = tmp["winner"]
|
|
|
+ (*update_info)["s_winner"] = s_winner
|
|
|
+ (*ext_ai_record)["s_winner"] = tmp["s_winner"]
|
|
|
+ (*update_info)["winner"] = s_winner
|
|
|
+ (*ext_ai_record)["winner"] = tmp["winner"]
|
|
|
//对于winner来说...规则值有包含关系,采用规则值
|
|
|
if winner := qu.ObjToString(tmp["winner"]); winner != "" {
|
|
|
if strings.Contains(s_winner, winner) {
|
|
|
- delete(update_info, "winner")
|
|
|
- delete(ext_ai_record, "winner")
|
|
|
+ delete((*update_info), "winner")
|
|
|
+ delete((*ext_ai_record), "winner")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -113,91 +175,64 @@ func ChooseTheBestCoreField(ai_zhipu map[string]interface{}, s_toptype string, s
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 选取分类
|
|
|
-func ChooseTheBestClassField(ai_zhipu map[string]interface{}, tmp map[string]interface{}, update_info map[string]interface{}, ext_ai_record map[string]interface{}) (string, string) {
|
|
|
- //分类字段···
|
|
|
- s_toptype, s_subtype := qu.ObjToString(ai_zhipu["s_toptype"]), qu.ObjToString(ai_zhipu["s_subtype"])
|
|
|
- ns_toptype, ns_subtype := CheckClassByOtherFileds(s_toptype, s_subtype, tmp)
|
|
|
- if ns_toptype != s_toptype || ns_subtype != s_subtype {
|
|
|
- ext_ai_record["s_toptype"] = ns_toptype
|
|
|
- ext_ai_record["s_subtype"] = ns_subtype
|
|
|
- }
|
|
|
- //赋值···
|
|
|
- s_toptype, s_subtype = ns_toptype, ns_subtype
|
|
|
- if qu.ObjToString(tmp["toptype"]) == "拟建" || qu.ObjToString(tmp["toptype"]) == "产权" {
|
|
|
- s_toptype = qu.ObjToString(tmp["toptype"])
|
|
|
- s_subtype = qu.ObjToString(tmp["subtype"])
|
|
|
- } else {
|
|
|
- if s_toptype != "" && s_subtype != "" {
|
|
|
- update_info["toptype"] = s_toptype
|
|
|
- update_info["subtype"] = s_subtype
|
|
|
- ext_ai_record["toptype"] = tmp["toptype"]
|
|
|
- ext_ai_record["subtype"] = tmp["subtype"]
|
|
|
- } else {
|
|
|
- s_toptype = qu.ObjToString(tmp["toptype"])
|
|
|
- s_subtype = qu.ObjToString(tmp["subtype"])
|
|
|
- }
|
|
|
- }
|
|
|
- return s_toptype, s_subtype
|
|
|
-}
|
|
|
-
|
|
|
// 选取分包
|
|
|
-func ChooseTheBestPackageField(ai_zhipu map[string]interface{}, s_toptype string, s_subtype string, tmp map[string]interface{}, update_info map[string]interface{}, ext_ai_record map[string]interface{}) {
|
|
|
+func ChooseTheBestPackageField(ai_zhipu map[string]interface{}, s_toptype string, s_subtype string, tmp map[string]interface{}, update_info *map[string]interface{}, ext_ai_record *map[string]interface{}) {
|
|
|
//新分包判定···com_package - 默认大模型分包可信
|
|
|
if s_pkg := qu.ObjToMap(ai_zhipu["s_pkg"]); s_pkg != nil {
|
|
|
com_package := IsMarkInterfaceMap((*s_pkg)["com_package"])
|
|
|
//是否替换外围字段···质谱外围是否已提取
|
|
|
if len(com_package) > 1 { //多包字段覆盖
|
|
|
+ //校验核对分包结构
|
|
|
new_com_package := staffAiPackageInfo(com_package, s_toptype, s_subtype)
|
|
|
- update_info["com_package"] = new_com_package
|
|
|
+ (*update_info)["com_package"] = new_com_package
|
|
|
|
|
|
if p_budget := qu.Float64All((*s_pkg)["s_budget"]); p_budget > 0.0 {
|
|
|
- update_info["budget"] = p_budget
|
|
|
- ext_ai_record["budget"] = tmp["budget"]
|
|
|
+ (*update_info)["budget"] = p_budget
|
|
|
+ (*ext_ai_record)["budget"] = tmp["budget"]
|
|
|
}
|
|
|
if s_subtype == "单一" || s_subtype == "中标" || s_subtype == "成交" || s_subtype == "合同" {
|
|
|
if p_winner := qu.ObjToString((*s_pkg)["s_winner"]); p_winner != "" {
|
|
|
- update_info["s_winner"] = p_winner
|
|
|
- update_info["winner"] = p_winner
|
|
|
- ext_ai_record["s_winner"] = tmp["s_winner"]
|
|
|
- ext_ai_record["winner"] = tmp["winner"]
|
|
|
+ (*update_info)["s_winner"] = p_winner
|
|
|
+ (*update_info)["winner"] = p_winner
|
|
|
+ (*ext_ai_record)["s_winner"] = tmp["s_winner"]
|
|
|
+ (*ext_ai_record)["winner"] = tmp["winner"]
|
|
|
|
|
|
//对于winner来说...规则值有包含关系,采用规则值应用判重
|
|
|
if winner := qu.ObjToString(tmp["winner"]); winner != "" {
|
|
|
if strings.Contains(p_winner, winner) {
|
|
|
- delete(update_info, "winner")
|
|
|
- delete(ext_ai_record, "winner")
|
|
|
+ delete((*update_info), "winner")
|
|
|
+ delete((*ext_ai_record), "winner")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if p_bidamount := qu.Float64All((*s_pkg)["s_bidamount"]); p_bidamount > 0.0 {
|
|
|
- update_info["bidamount"] = p_bidamount
|
|
|
- ext_ai_record["bidamount"] = tmp["bidamount"]
|
|
|
+ (*update_info)["bidamount"] = p_bidamount
|
|
|
+ (*ext_ai_record)["bidamount"] = tmp["bidamount"]
|
|
|
}
|
|
|
}
|
|
|
} else if len(com_package) == 1 { //单包字段覆盖
|
|
|
- if p_budget := qu.Float64All((*s_pkg)["s_budget"]); p_budget > 0.0 && update_info["budget"] == nil {
|
|
|
- update_info["budget"] = p_budget
|
|
|
- ext_ai_record["budget"] = tmp["budget"]
|
|
|
+ if p_budget := qu.Float64All((*s_pkg)["s_budget"]); p_budget > 0.0 && (*update_info)["budget"] == nil {
|
|
|
+ (*update_info)["budget"] = p_budget
|
|
|
+ (*ext_ai_record)["budget"] = tmp["budget"]
|
|
|
}
|
|
|
if s_subtype == "单一" || s_subtype == "中标" || s_subtype == "成交" || s_subtype == "合同" {
|
|
|
- if p_winner := qu.ObjToString((*s_pkg)["s_winner"]); p_winner != "" && update_info["s_winner"] == nil {
|
|
|
- update_info["s_winner"] = p_winner
|
|
|
- update_info["winner"] = p_winner
|
|
|
- ext_ai_record["s_winner"] = tmp["s_winner"]
|
|
|
- ext_ai_record["winner"] = tmp["winner"]
|
|
|
+ if p_winner := qu.ObjToString((*s_pkg)["s_winner"]); p_winner != "" && (*update_info)["s_winner"] == nil {
|
|
|
+ (*update_info)["s_winner"] = p_winner
|
|
|
+ (*update_info)["winner"] = p_winner
|
|
|
+ (*ext_ai_record)["s_winner"] = tmp["s_winner"]
|
|
|
+ (*ext_ai_record)["winner"] = tmp["winner"]
|
|
|
|
|
|
//对于winner来说...规则值有包含关系,采用规则值应用判重
|
|
|
if winner := qu.ObjToString(tmp["winner"]); winner != "" {
|
|
|
if strings.Contains(p_winner, winner) {
|
|
|
- delete(update_info, "winner")
|
|
|
- delete(ext_ai_record, "winner")
|
|
|
+ delete((*update_info), "winner")
|
|
|
+ delete((*ext_ai_record), "winner")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if p_bidamount := qu.Float64All((*s_pkg)["s_bidamount"]); p_bidamount > 0.0 && update_info["bidamount"] == nil {
|
|
|
- update_info["bidamount"] = p_bidamount
|
|
|
- ext_ai_record["bidamount"] = tmp["bidamount"]
|
|
|
+ if p_bidamount := qu.Float64All((*s_pkg)["s_bidamount"]); p_bidamount > 0.0 && (*update_info)["bidamount"] == nil {
|
|
|
+ (*update_info)["bidamount"] = p_bidamount
|
|
|
+ (*ext_ai_record)["bidamount"] = tmp["bidamount"]
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -207,55 +242,21 @@ func ChooseTheBestPackageField(ai_zhipu map[string]interface{}, s_toptype string
|
|
|
}
|
|
|
|
|
|
// 选取金额
|
|
|
-func ChooseTheBestAmountField(tmp map[string]interface{}, update_info map[string]interface{}) {
|
|
|
- if r_budget := qu.Float64All(update_info["budget"]); r_budget > 0.0 && r_budget < 1000000000.0 {
|
|
|
+func ChooseTheBestAmountField(tmp map[string]interface{}, update_info *map[string]interface{}) {
|
|
|
+ if r_budget := qu.Float64All((*update_info)["budget"]); r_budget > 0.0 && r_budget < 1000000000.0 {
|
|
|
if o_budget := qu.Float64All(tmp["budget"]); o_budget > 0.0 {
|
|
|
if r_budget/o_budget == 10000.0 || o_budget/r_budget == 10000.0 {
|
|
|
- update_info["budget"] = filterAmount(r_budget, o_budget)
|
|
|
+ (*update_info)["budget"] = filterAmount(r_budget, o_budget)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if r_bidamount := qu.Float64All(update_info["bidamount"]); r_bidamount > 0.0 && r_bidamount < 1000000000.0 {
|
|
|
+ if r_bidamount := qu.Float64All((*update_info)["bidamount"]); r_bidamount > 0.0 && r_bidamount < 1000000000.0 {
|
|
|
if o_bidamount := qu.Float64All(tmp["bidamount"]); o_bidamount > 0.0 {
|
|
|
if r_bidamount/o_bidamount == 10000.0 || o_bidamount/r_bidamount == 10000.0 {
|
|
|
- update_info["bidamount"] = filterAmount(r_bidamount, o_bidamount)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// 大模型与抽取数据合并计算
|
|
|
-func ChooseCheckDataAI(tmp map[string]interface{}, update_info map[string]interface{}) bool {
|
|
|
- if tmp["ai_zhipu"] == nil {
|
|
|
- return false
|
|
|
- }
|
|
|
- //记录抽取原值
|
|
|
- ext_ai_record := map[string]interface{}{}
|
|
|
- ai_zhipu := *qu.ObjToMap(tmp["ai_zhipu"])
|
|
|
- //选取分类
|
|
|
- s_toptype, s_subtype := ChooseTheBestClassField(ai_zhipu, tmp, update_info, ext_ai_record)
|
|
|
- //选取字段
|
|
|
- ChooseTheBestCoreField(ai_zhipu, s_toptype, s_subtype, tmp, update_info, ext_ai_record)
|
|
|
- //选取分包
|
|
|
- ChooseTheBestPackageField(ai_zhipu, s_toptype, s_subtype, tmp, update_info, ext_ai_record)
|
|
|
- //最终金额修正与选取
|
|
|
- ChooseTheBestAmountField(tmp, update_info)
|
|
|
-
|
|
|
- //字段记录
|
|
|
- update_info["ext_ai_record"] = ext_ai_record
|
|
|
-
|
|
|
- //跨分类是否删除结果类字段
|
|
|
- if s_subtype == "单一" || s_subtype == "中标" || s_subtype == "成交" || s_subtype == "合同" {
|
|
|
-
|
|
|
- } else {
|
|
|
- for k, _ := range Unset_Check {
|
|
|
- if tmp[k] != nil {
|
|
|
- return true
|
|
|
+ (*update_info)["bidamount"] = filterAmount(r_bidamount, o_bidamount)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return false
|
|
|
}
|
|
|
|
|
|
// 筛选金额
|
|
@@ -322,6 +323,7 @@ func staffAiPackageInfo(com_package []map[string]interface{}, s_toptype string,
|
|
|
return new_com_package
|
|
|
}
|
|
|
|
|
|
+// 核对分类
|
|
|
func CheckClassByOtherFileds(toptype_ai, subtype_ai string, data map[string]interface{}) (string, string) {
|
|
|
toptype_rule := qu.ObjToString(data["toptype"])
|
|
|
subtype_rule := qu.ObjToString(data["subtype"])
|