|
@@ -0,0 +1,159 @@
|
|
|
|
+package main
|
|
|
|
+
|
|
|
|
+import qu "qfw/util"
|
|
|
|
+
|
|
|
|
+// 大模型与抽取数据合并计算
|
|
|
|
+func getCheckDataAI(tmp map[string]interface{}, update_check *map[string]interface{}) {
|
|
|
|
+ if tmp["ai_zhipu"] == nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //记录抽取原值
|
|
|
|
+ ext_ai := map[string]interface{}{}
|
|
|
|
+ ai_zhipu := *qu.ObjToMap(tmp["ai_zhipu"])
|
|
|
|
+ //分类字段···
|
|
|
|
+ s_toptype, s_subtype := qu.ObjToString(ai_zhipu["s_toptype"]), qu.ObjToString(ai_zhipu["s_subtype"])
|
|
|
|
+ s_toptype, s_subtype = CheckClassByOtherFileds(s_toptype, s_subtype, tmp)
|
|
|
|
+ if s_toptype != "" && s_subtype != "" {
|
|
|
|
+ (*update_check)["toptype"] = s_toptype
|
|
|
|
+ (*update_check)["subtype"] = s_subtype
|
|
|
|
+ ext_ai["toptype"] = tmp["toptype"]
|
|
|
|
+ ext_ai["subtype"] = tmp["subtype"]
|
|
|
|
+ } else {
|
|
|
|
+ s_toptype = qu.ObjToString(tmp["toptype"])
|
|
|
|
+ s_subtype = qu.ObjToString(tmp["subtype"])
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //基础字段···
|
|
|
|
+ if s_buyer := qu.ObjToString(ai_zhipu["s_buyer"]); s_buyer != "" {
|
|
|
|
+ (*update_check)["buyer"] = s_buyer
|
|
|
|
+ ext_ai["buyer"] = tmp["buyer"]
|
|
|
|
+ }
|
|
|
|
+ if s_projectname := qu.ObjToString(ai_zhipu["s_projectname"]); s_projectname != "" {
|
|
|
|
+ (*update_check)["projectname"] = s_projectname
|
|
|
|
+ ext_ai["projectname"] = tmp["projectname"]
|
|
|
|
+ }
|
|
|
|
+ if s_projectcode := qu.ObjToString(ai_zhipu["s_projectcode"]); s_projectcode != "" {
|
|
|
|
+ (*update_check)["projectcode"] = s_projectcode
|
|
|
|
+ ext_ai["projectcode"] = tmp["projectcode"]
|
|
|
|
+ }
|
|
|
|
+ if s_budget := qu.Float64All(ai_zhipu["s_budget"]); s_budget > 0.0 && s_budget < 1000000000.0 {
|
|
|
|
+ (*update_check)["budget"] = s_budget
|
|
|
|
+ ext_ai["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_check)["area"] = s_area
|
|
|
|
+ if s_city != "" {
|
|
|
|
+ (*update_check)["city"] = s_city
|
|
|
|
+ if o_district != "" {
|
|
|
|
+ //判断抽取的区县是否合理···
|
|
|
|
+ isT := false
|
|
|
|
+ if ds := S_DistrictDict[o_district]; ds != nil {
|
|
|
|
+ for _, v := range ds {
|
|
|
|
+ if v.C_Name == s_city && v.P_Name == s_area {
|
|
|
|
+ isT = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !isT {
|
|
|
|
+ (*update_check)["district"] = ""
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if o_area != s_area {
|
|
|
|
+ (*update_check)["city"] = ""
|
|
|
|
+ (*update_check)["district"] = ""
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ext_ai["area"] = tmp["area"]
|
|
|
|
+ ext_ai["city"] = tmp["city"]
|
|
|
|
+ ext_ai["district"] = tmp["district"]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //中标字段···
|
|
|
|
+ isRulePkg := false
|
|
|
|
+ if pkg := *qu.ObjToMap(tmp["package"]); len(pkg) > 1 && (s_subtype == "中标" || s_subtype == "成交" || s_subtype == "合同") {
|
|
|
|
+ if !staffInfo(pkg) {
|
|
|
|
+ isRulePkg = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if isRulePkg {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 核算分包信息
|
|
|
|
+func staffInfo(pkg map[string]interface{}) bool {
|
|
|
|
+ //鉴定中标单位
|
|
|
|
+ is_w := 0
|
|
|
|
+ for _, v := range pkg {
|
|
|
|
+ info := *qu.ObjToMap(v)
|
|
|
|
+ if winner := qu.ObjToString(info["winner"]); winner != "" {
|
|
|
|
+ is_w++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //鉴定中标金额
|
|
|
|
+ is_b := 0
|
|
|
|
+ for _, v := range pkg {
|
|
|
|
+ info := *qu.ObjToMap(v)
|
|
|
|
+ if bidamount := qu.Float64All(info["bidamount"]); bidamount > 0.0 {
|
|
|
|
+ is_b++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if is_w != len(pkg) && is_w > 0 {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if is_b != len(pkg) && is_b > 0 {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if is_w == 0 || is_b == 0 {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+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"])
|
|
|
|
+ //1、结果类 中标和成交错误校正
|
|
|
|
+ s_winner := qu.ObjToString(data["s_winner"])
|
|
|
|
+ winnerorder, _ := data["winnerorder"].([]interface{})
|
|
|
|
+ if toptype_ai == "结果" && toptype_rule == "结果" {
|
|
|
|
+ if (subtype_ai == "中标" && subtype_rule == "成交") || (subtype_ai == "成交" && subtype_rule == "中标") {
|
|
|
|
+ if len(winnerorder) > 0 { //有中标候选人->中标
|
|
|
|
+ return toptype_ai, "中标"
|
|
|
|
+ }
|
|
|
|
+ if s_winner != "" || data["bidamount"] != nil {
|
|
|
|
+ return toptype_ai, "成交"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //2、招标、结果错误校正
|
|
|
|
+ if toptype_ai != "结果" && toptype_rule == "结果" {
|
|
|
|
+ //return toptype_rule,subtype_rule//默认规则为准
|
|
|
|
+ if len(winnerorder) > 0 { //有中标候选人->中标
|
|
|
|
+ //return toptype_rule, "中标"//这里subtype是否返回"中标"?
|
|
|
|
+ return toptype_rule, subtype_rule //默认规则是正确的
|
|
|
|
+ } else if s_winner != "" || data["bidamount"] != nil {
|
|
|
|
+ return toptype_rule, subtype_rule
|
|
|
|
+ } else {
|
|
|
|
+ return toptype_ai, subtype_ai
|
|
|
|
+ }
|
|
|
|
+ } else if toptype_ai == "结果" && toptype_rule != "结果" {
|
|
|
|
+ //return toptype_rule,subtype_rule//默认规则为准
|
|
|
|
+ if len(winnerorder) > 0 { //有中标候选人->中标
|
|
|
|
+ return toptype_ai, "中标" //这里subtype返回"中标",避免ai识别错误
|
|
|
|
+ } else if s_winner != "" || data["bidamount"] != nil {
|
|
|
|
+ return toptype_ai, "成交" //这里subtype返回"成交",避免ai识别错误
|
|
|
|
+ } else {
|
|
|
|
+ return toptype_ai, subtype_ai
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return toptype_ai, subtype_ai
|
|
|
|
+}
|