123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- package clean
- import (
- "data_ai/ul"
- "github.com/google/uuid"
- "github.com/shopspring/decimal"
- qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
- "strings"
- )
- var DSToptype = map[string]map[string]string{
- "招标公告": { //招标
- "单一来源公告": "单一",
- "询价公告": "询价",
- "竞价公告": "竞价",
- "邀标公告": "邀标",
- "竞争谈判公告": "竞谈",
- "变更公告": "变更",
- "招标公告": "招标",
- },
- "结果公告": { //其它
- "中标公告": "中标",
- "候选公告": "中标",
- "成交公告": "成交",
- "变更公告": "结果变更",
- "结果其它公告": "其它",
- "废标公告": "废标",
- "流标公告": "流标",
- },
- "预告公告": { //预告
- "预告公告": "预告",
- "预审公告": "预审",
- "预审结果公告": "预审结果",
- "论证意见公告": "论证意见",
- "需求公示公告": "需求公示",
- },
- }
- // 清洗新模型····
- func CleanDeepSeekInfo(ai_info map[string]interface{}, tmp map[string]interface{}) map[string]interface{} {
- fns := getfnsinfo(tmp)
- zhipu := *qu.ObjToMap(ai_info["任务1"])
- data := map[string]interface{}{}
- //重点字段
- if s_area, s_city := CleanRegion(qu.ObjToString(zhipu["省份"]), qu.ObjToString(zhipu["城市"])); s_area != "" || s_city != "" {
- data["s_area"] = s_area
- data["s_city"] = s_city
- }
- if s_buyer := CleanBuyer(qu.ObjToString(zhipu["采购单位"])); s_buyer != "" {
- data["s_buyer"] = s_buyer
- }
- if s_pname := CleanPname(qu.ObjToString(zhipu["项目名称"])); s_pname != "" {
- data["s_projectname"] = s_pname
- }
- if s_pcode := CleanPcode(qu.ObjToString(zhipu["项目编号"]), fns); s_pcode != "" {
- data["s_projectcode"] = s_pcode
- }
- if s_biddingcode := CleanOtherCode(qu.ObjToString(zhipu["招标编号"])); s_biddingcode != "" {
- data["s_biddingcode"] = s_biddingcode
- }
- if s_packagecode := CleanOtherCode(qu.ObjToString(zhipu["标段编号"])); s_packagecode != "" {
- data["s_packagecode"] = s_packagecode
- }
- if s_contractcode := CleanOtherCode(qu.ObjToString(zhipu["合同编号"])); s_contractcode != "" {
- data["s_contractcode"] = s_contractcode
- }
- if s_budget, s_budget_unit := CleanMoney([]interface{}{zhipu["预算金额"], ""}); s_budget > 0.0 && s_budget < 1000000000.0 {
- if !s_budget_unit {
- if n_s_budget := ConvertMoney(s_budget, qu.ObjToString(zhipu["预算金额单位"])); n_s_budget > 0.0 && n_s_budget < 1000000000.0 {
- data["s_budget"] = n_s_budget
- } else {
- data["s_budget"] = s_budget
- }
- } else {
- data["s_budget"] = s_budget
- }
- }
- if s_bidamount, s_bidamount_unit := CleanMoney([]interface{}{zhipu["中标金额"], ""}); s_bidamount > 0.0 && s_bidamount < 1000000000.0 {
- if !s_bidamount_unit {
- if n_s_bidamount := ConvertMoney(s_bidamount, qu.ObjToString(zhipu["中标金额单位"])); n_s_bidamount > 0.0 && n_s_bidamount < 1000000000.0 {
- data["s_bidamount"] = n_s_bidamount
- } else {
- data["s_bidamount"] = s_bidamount
- }
- } else {
- data["s_bidamount"] = s_bidamount
- }
- }
- if s_agency := CleanAgency(qu.ObjToString(zhipu["代理机构"])); s_agency != "" {
- data["s_agency"] = s_agency
- }
- if s_winner := CleanWinner(qu.ObjToString(zhipu["中标单位"])); s_winner != "" {
- data["s_winner"] = s_winner
- }
- //其他字段
- if s_bidopenaddress := CleanOtherName(qu.ObjToString(zhipu["开标地点"])); s_bidopenaddress != "" {
- data["s_bidopenaddress"] = s_bidopenaddress
- }
- if s_biddiscount := CleanDiscount(qu.ObjToString(zhipu["中标金额折扣率"])); s_biddiscount > 0.0 {
- data["s_biddiscount"] = s_biddiscount
- }
- //时间相关
- if s_bidopentime := CleanTime(qu.ObjToString(zhipu["开标日期"])); s_bidopentime > 0 {
- data["s_bidopentime"] = s_bidopentime
- }
- if s_bidendtime := CleanTime(qu.ObjToString(zhipu["投标截止时间"])); s_bidendtime > 0 {
- data["s_bidendtime"] = s_bidendtime
- }
- if s_docstarttime := CleanTime(qu.ObjToString(zhipu["招标文件获取开始时间"])); s_docstarttime > 0 {
- data["s_docstarttime"] = s_docstarttime
- }
- if s_docendtime := CleanTime(qu.ObjToString(zhipu["招标文件获取结束时间"])); s_docendtime > 0 {
- data["s_docendtime"] = s_docendtime
- }
- //联系方式方式
- if s_buyerperson := CleanContactPerson(qu.ObjToString(zhipu["采购单位联系人"])); s_buyerperson != "" {
- data["s_buyerperson"] = s_buyerperson
- }
- if s_buyertel := CleanContactTel(qu.ObjToString(zhipu["采购单位联系方式"])); s_buyertel != "" {
- data["s_buyertel"] = s_buyertel
- }
- if s_agencyperson := CleanContactPerson(qu.ObjToString(zhipu["代理机构联系人"])); s_agencyperson != "" {
- data["s_agencyperson"] = s_agencyperson
- }
- if s_agencytel := CleanContactTel(qu.ObjToString(zhipu["代理机构联系方式"])); s_agencytel != "" {
- data["s_agencytel"] = s_agencytel
- }
- if s_winnerperson := CleanContactPerson(qu.ObjToString(zhipu["中标单位联系人"])); s_winnerperson != "" {
- data["s_winnerperson"] = s_winnerperson
- }
- if s_winnertel := CleanContactTel(qu.ObjToString(zhipu["中标单位联系方式"])); s_winnertel != "" {
- data["s_winnertel"] = s_winnertel
- }
- //标的物字段
- if zhipu["s_purchasinglist"] != nil {
- data["s_purchasinglist"] = zhipu["s_purchasinglist"]
- }
- //分类字段
- //o_toptype, _ := qu.ObjToString(tmp["toptype"]), qu.ObjToString(tmp["subtype"])
- //ts_type := *qu.ObjToMap(ai_info["任务2"])
- //toptype_ai, subtype_ai := qu.ObjToString(ts_type["一级分类"]), qu.ObjToString(ts_type["二级分类"])
- //new_toptype, new_subtype := TopSubConvert(o_toptype, toptype_ai, subtype_ai)
- //if new_toptype != "" && new_subtype != "" {
- // data["s_toptype"] = new_toptype
- // data["s_subtype"] = new_subtype
- //}
- //解析分包···
- p_info := *qu.ObjToMap(ai_info["任务2"])
- if pkg := PackageConvert(p_info); len(pkg) > 0 {
- data["s_pkg"] = pkg
- }
- //最终根据分类-删除
- return data
- }
- // 转换分包
- func PackageConvert(res map[string]interface{}) map[string]interface{} {
- //转格式...
- if res == nil {
- return map[string]interface{}{}
- }
- ai_pkg := map[string]interface{}{}
- s_winner, s_bidamount, s_budget, com_package := "", 0.0, 0.0, []map[string]interface{}{}
- win_arr, win_temp := []string{}, map[string]string{}
- pkginfo := ul.IsMarkInterfaceMap(res["分包信息"])
- for _, v := range pkginfo {
- name := qu.ObjToString(v["标段名称"])
- code := qu.ObjToString(v["标段/包号"])
- winner := CleanWinner(qu.ObjToString(v["中标单位"]))
- bidamount, bidamount_unit := CleanMoney([]interface{}{v["中标金额"], ""})
- budget, budget_unit := CleanMoney([]interface{}{v["预算金额"], ""})
- if !bidamount_unit {
- bidamount = ConvertMoney(bidamount, qu.ObjToString(v["中标金额单位"]))
- }
- if !budget_unit {
- budget = ConvertMoney(budget, qu.ObjToString(v["预算金额单位"]))
- }
- if bidamount > 1000000000.0 {
- bidamount = 0.0
- }
- if budget > 1000000000.0 {
- budget = 0.0
- }
- //各种编号编号
- projectcode := CleanPcode(qu.ObjToString(v["项目编号"]), []string{})
- packagecode := CleanOtherCode(qu.ObjToString(v["标段编号"]))
- contractcode := CleanOtherCode(qu.ObjToString(v["合同编号"]))
- //分包信息结构
- package_id := uuid.New().String()
- package_id = strings.ReplaceAll(package_id, "-", "")
- p := map[string]interface{}{
- "package_id": package_id,
- "name": name,
- "code": code,
- "budget": budget,
- "winner": winner,
- "bidamount": bidamount,
- "projectcode": projectcode,
- "packagecode": packagecode,
- "contractcode": contractcode,
- }
- com_package = append(com_package, p)
- //去重计算单位与总金额-精度丢失···
- s_bid1 := decimal.NewFromFloat(s_bidamount)
- s_bid2 := decimal.NewFromFloat(bidamount)
- s_bid_add := s_bid1.Add(s_bid2)
- s_bidamount, _ = s_bid_add.Float64()
- s_bud1 := decimal.NewFromFloat(s_budget)
- s_bud2 := decimal.NewFromFloat(budget)
- s_bud_add := s_bud1.Add(s_bud2)
- s_budget, _ = s_bud_add.Float64()
- if win_temp[winner] == "" && winner != "" {
- win_arr = append(win_arr, winner)
- win_temp[winner] = winner
- }
- }
- s_winner = strings.Join(win_arr, ",")
- ai_pkg["s_winner"] = s_winner
- ai_pkg["s_bidamount"] = s_bidamount
- ai_pkg["s_budget"] = s_budget
- ai_pkg["com_package"] = com_package
- return ai_pkg
- }
- // 分类校验···
- func TopSubConvert(old_toptype string, toptype_ai string, subtype_ai string) (string, string) {
- if old_toptype == "拟建" {
- return "拟建", "拟建"
- } else if old_toptype == "产权" {
- return "产权", "产权"
- } else if old_toptype == "采购意向" {
- return "采购意向", "采购意向"
- } else {
- }
- if toptype_ai == "采购意向公告" {
- return "采购意向", "采购意向"
- } else if toptype_ai == "合同公告" {
- return "其它", "合同"
- } else if toptype_ai == "验收公告" {
- return "其它", "验收"
- } else if toptype_ai == "违规公告" {
- return "其它", "违规"
- } else {
- }
- //映射大模型识别的分类
- new_toptype, new_subtype := "", ""
- Sub := DSToptype[toptype_ai]
- if Sub != nil {
- if toptype_ai == "招标公告" {
- new_toptype = "招标"
- if Sub[subtype_ai] != "" {
- new_subtype = Sub[subtype_ai]
- } else {
- new_subtype = "招标"
- }
- } else if toptype_ai == "结果公告" {
- new_toptype = "结果"
- if Sub[subtype_ai] != "" {
- new_subtype = Sub[subtype_ai]
- } else {
- new_subtype = "其它"
- }
- } else if toptype_ai == "预告公告" {
- new_toptype = "预告"
- if Sub[subtype_ai] != "" {
- new_subtype = Sub[subtype_ai]
- } else {
- new_subtype = "预告"
- }
- } else {
- }
- }
- return new_toptype, new_subtype
- }
- // 获取附件名字信息
- func getfnsinfo(tmp map[string]interface{}) []string {
- arr := []string{}
- if projectinfo := qu.ObjToMap(tmp["projectinfo"]); projectinfo != nil {
- if attachments := qu.ObjToMap((*projectinfo)["attachments"]); attachments != nil {
- for _, v := range *attachments {
- if info := qu.ObjToMap(v); info != nil {
- if filename := qu.ObjToString((*info)["filename"]); filename != "" {
- arr = append(arr, filename)
- }
- }
- }
- }
- }
- return arr
- }
|