global.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. package ul
  2. import (
  3. "github.com/google/uuid"
  4. qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  5. "strings"
  6. )
  7. var Unset_Check = map[string]interface{}{"winner": 1, "s_winner": 1, "bidamount": 1, "winnerorder": 1}
  8. // 大模型与抽取数据合并计算
  9. func ChooseCheckDataAI(tmp map[string]interface{}, update_info *map[string]interface{}) bool {
  10. if tmp["ai_zhipu"] == nil {
  11. return false
  12. }
  13. //记录抽取原值
  14. ext_ai_record := map[string]interface{}{}
  15. ai_zhipu := *qu.ObjToMap(tmp["ai_zhipu"])
  16. //选取分类
  17. s_toptype, s_subtype := ChooseTheBestClassField(ai_zhipu, tmp, update_info, &ext_ai_record)
  18. //选取字段
  19. ChooseTheBestCoreField(ai_zhipu, s_toptype, s_subtype, tmp, update_info, &ext_ai_record)
  20. //选取分包
  21. ChooseTheBestPackageField(ai_zhipu, s_toptype, s_subtype, tmp, update_info, &ext_ai_record)
  22. //最终金额修正与选取
  23. ChooseTheBestAmountField(tmp, update_info)
  24. //最终单位修正与选取
  25. ChooseTheBestUnitField(ai_zhipu, s_toptype, s_subtype, tmp, update_info, &ext_ai_record)
  26. //其他字段选取
  27. ChooseTheBestOtherField(ai_zhipu, tmp, update_info, &ext_ai_record)
  28. //字段记录
  29. (*update_info)["ext_ai_record"] = ext_ai_record
  30. //跨分类是否删除结果类字段
  31. if s_toptype == "结果" || s_toptype == "其它" || s_subtype == "单一" {
  32. } else {
  33. for k, _ := range Unset_Check {
  34. if tmp[k] != nil {
  35. return true
  36. }
  37. }
  38. }
  39. return false
  40. }
  41. // 选取分类
  42. func ChooseTheBestClassField(ai_zhipu map[string]interface{}, tmp map[string]interface{}, update_info *map[string]interface{}, ext_ai_record *map[string]interface{}) (string, string) {
  43. //分类字段···
  44. s_toptype, s_subtype := qu.ObjToString(ai_zhipu["s_toptype"]), qu.ObjToString(ai_zhipu["s_subtype"])
  45. ns_toptype, ns_subtype := CheckClassByOtherFileds(s_toptype, s_subtype, tmp)
  46. if ns_toptype != s_toptype || ns_subtype != s_subtype {
  47. (*ext_ai_record)["s_toptype"] = ns_toptype
  48. (*ext_ai_record)["s_subtype"] = ns_subtype
  49. }
  50. //赋值···
  51. s_toptype, s_subtype = ns_toptype, ns_subtype
  52. if qu.ObjToString(tmp["toptype"]) == "拟建" || qu.ObjToString(tmp["toptype"]) == "产权" {
  53. s_toptype = qu.ObjToString(tmp["toptype"])
  54. s_subtype = qu.ObjToString(tmp["subtype"])
  55. } else {
  56. if s_toptype != "" && s_subtype != "" {
  57. (*update_info)["toptype"] = s_toptype
  58. (*update_info)["subtype"] = s_subtype
  59. (*ext_ai_record)["toptype"] = tmp["toptype"]
  60. (*ext_ai_record)["subtype"] = tmp["subtype"]
  61. } else {
  62. s_toptype = qu.ObjToString(tmp["toptype"])
  63. s_subtype = qu.ObjToString(tmp["subtype"])
  64. }
  65. }
  66. return s_toptype, s_subtype
  67. }
  68. // 选取字段
  69. 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{}) {
  70. if s_buyer := qu.ObjToString(ai_zhipu["s_buyer"]); s_buyer != "" {
  71. (*update_info)["buyer"] = s_buyer
  72. (*ext_ai_record)["buyer"] = tmp["buyer"]
  73. }
  74. //基础字段···
  75. if s_agency := qu.ObjToString(ai_zhipu["s_agency"]); s_agency != "" {
  76. (*update_info)["agency"] = s_agency
  77. (*ext_ai_record)["agency"] = tmp["agency"]
  78. }
  79. if s_projectname := qu.ObjToString(ai_zhipu["s_projectname"]); s_projectname != "" {
  80. (*update_info)["projectname"] = s_projectname
  81. (*ext_ai_record)["projectname"] = tmp["projectname"]
  82. }
  83. if s_projectcode := qu.ObjToString(ai_zhipu["s_projectcode"]); s_projectcode != "" {
  84. (*update_info)["projectcode"] = s_projectcode
  85. (*ext_ai_record)["projectcode"] = tmp["projectcode"]
  86. }
  87. if s_budget := qu.Float64All(ai_zhipu["s_budget"]); s_budget > 0.0 && s_budget < 1000000000.0 {
  88. (*update_info)["budget"] = s_budget
  89. (*ext_ai_record)["budget"] = tmp["budget"]
  90. }
  91. //规则地域字段···
  92. o_area, o_city, o_district := qu.ObjToString(tmp["area"]), qu.ObjToString(tmp["city"]), qu.ObjToString(tmp["district"])
  93. s_area, s_city := qu.ObjToString(ai_zhipu["s_area"]), qu.ObjToString(ai_zhipu["s_city"])
  94. if s_area != "" && s_area != "全国" {
  95. (*update_info)["area"] = s_area
  96. if s_city != "" {
  97. (*update_info)["city"] = s_city
  98. if o_district != "" {
  99. if s_city != o_city || s_area != o_area {
  100. (*update_info)["district"] = ""
  101. }
  102. }
  103. } else {
  104. if o_area != s_area {
  105. (*update_info)["city"] = ""
  106. (*update_info)["district"] = ""
  107. }
  108. }
  109. (*ext_ai_record)["area"] = tmp["area"]
  110. (*ext_ai_record)["city"] = tmp["city"]
  111. (*ext_ai_record)["district"] = tmp["district"]
  112. }
  113. //先用外围字段替换
  114. if s_toptype == "结果" || s_toptype == "其它" || s_subtype == "单一" {
  115. if s_bidamount := qu.Float64All(ai_zhipu["s_bidamount"]); s_bidamount > 0.0 && s_bidamount < 1000000000.0 {
  116. (*update_info)["bidamount"] = s_bidamount
  117. (*ext_ai_record)["bidamount"] = tmp["bidamount"]
  118. }
  119. if s_winner := qu.ObjToString(ai_zhipu["s_winner"]); s_winner != "" {
  120. (*update_info)["s_winner"] = s_winner
  121. (*ext_ai_record)["s_winner"] = tmp["s_winner"]
  122. (*update_info)["winner"] = s_winner
  123. (*ext_ai_record)["winner"] = tmp["winner"]
  124. //对于winner来说...规则值有包含关系,采用规则值
  125. if winner := qu.ObjToString(tmp["winner"]); winner != "" {
  126. if strings.Contains(s_winner, winner) {
  127. delete((*update_info), "winner")
  128. delete((*ext_ai_record), "winner")
  129. }
  130. }
  131. }
  132. //旧版弃用
  133. //isRulePkg := false
  134. //if pkg := *qu.ObjToMap(tmp["package"]); len(pkg) > 1 && (s_subtype == "中标" || s_subtype == "成交" || s_subtype == "合同") {
  135. // if !staffInfo(pkg) {
  136. // isRulePkg = true
  137. // }
  138. //}
  139. //if isRulePkg { //优先采用大模型分包-值替换
  140. // if ispkg, ok := ai_zhipu["ispkg"].(bool); ispkg && ok {
  141. // if s_pkg := qu.ObjToMap(ai_zhipu["s_pkg"]); s_pkg != nil {
  142. // if p_winner := qu.ObjToString((*s_pkg)["s_winner"]); p_winner != "" {
  143. // (*update_check)["s_winner"] = p_winner
  144. // (*update_check)["winner"] = p_winner
  145. // ext_ai_record["s_winner"] = tmp["s_winner"]
  146. // ext_ai_record["winner"] = tmp["winner"]
  147. // }
  148. // if p_bidamount := qu.Float64All((*s_pkg)["s_bidamount"]); p_bidamount > 0.0 {
  149. // (*update_check)["bidamount"] = p_bidamount
  150. // ext_ai_record["bidamount"] = tmp["bidamount"]
  151. // }
  152. // if s_package := qu.ObjToMap((*s_pkg)["s_pkg"]); s_package != nil {
  153. // (*update_check)["package"] = s_package
  154. // ext_ai_record["package"] = tmp["package"]
  155. // }
  156. // }
  157. // }
  158. //}
  159. } else {
  160. }
  161. }
  162. // 选取分包
  163. 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{}) {
  164. //新分包判定···com_package - 默认大模型分包可信
  165. if s_pkg := qu.ObjToMap(ai_zhipu["s_pkg"]); s_pkg != nil {
  166. com_package := IsMarkInterfaceMap((*s_pkg)["com_package"])
  167. //是否替换外围字段···质谱外围是否已提取
  168. if len(com_package) > 1 { //多包字段覆盖
  169. //校验核对分包结构
  170. new_com_package := staffAiPackageInfo(com_package, s_toptype, s_subtype)
  171. (*update_info)["com_package"] = new_com_package
  172. if p_budget := qu.Float64All((*s_pkg)["s_budget"]); p_budget > 0.0 {
  173. (*update_info)["budget"] = p_budget
  174. (*ext_ai_record)["budget"] = tmp["budget"]
  175. }
  176. if s_toptype == "结果" || s_toptype == "其它" || s_subtype == "单一" {
  177. if p_winner := qu.ObjToString((*s_pkg)["s_winner"]); p_winner != "" {
  178. (*update_info)["s_winner"] = p_winner
  179. (*update_info)["winner"] = p_winner
  180. (*ext_ai_record)["s_winner"] = tmp["s_winner"]
  181. (*ext_ai_record)["winner"] = tmp["winner"]
  182. //对于winner来说...规则值有包含关系,采用规则值应用判重
  183. if winner := qu.ObjToString(tmp["winner"]); winner != "" {
  184. if strings.Contains(p_winner, winner) {
  185. delete((*update_info), "winner")
  186. delete((*ext_ai_record), "winner")
  187. }
  188. }
  189. }
  190. if p_bidamount := qu.Float64All((*s_pkg)["s_bidamount"]); p_bidamount > 0.0 {
  191. (*update_info)["bidamount"] = p_bidamount
  192. (*ext_ai_record)["bidamount"] = tmp["bidamount"]
  193. }
  194. }
  195. } else if len(com_package) == 1 { //单包字段覆盖
  196. if p_budget := qu.Float64All((*s_pkg)["s_budget"]); p_budget > 0.0 && (*update_info)["budget"] == nil {
  197. (*update_info)["budget"] = p_budget
  198. (*ext_ai_record)["budget"] = tmp["budget"]
  199. }
  200. if s_toptype == "结果" || s_toptype == "其它" || s_subtype == "单一" {
  201. if p_winner := qu.ObjToString((*s_pkg)["s_winner"]); p_winner != "" && (*update_info)["s_winner"] == nil {
  202. (*update_info)["s_winner"] = p_winner
  203. (*update_info)["winner"] = p_winner
  204. (*ext_ai_record)["s_winner"] = tmp["s_winner"]
  205. (*ext_ai_record)["winner"] = tmp["winner"]
  206. //对于winner来说...规则值有包含关系,采用规则值应用判重
  207. if winner := qu.ObjToString(tmp["winner"]); winner != "" {
  208. if strings.Contains(p_winner, winner) {
  209. delete((*update_info), "winner")
  210. delete((*ext_ai_record), "winner")
  211. }
  212. }
  213. }
  214. if p_bidamount := qu.Float64All((*s_pkg)["s_bidamount"]); p_bidamount > 0.0 && (*update_info)["bidamount"] == nil {
  215. (*update_info)["bidamount"] = p_bidamount
  216. (*ext_ai_record)["bidamount"] = tmp["bidamount"]
  217. }
  218. }
  219. } else {
  220. }
  221. }
  222. }
  223. // 选取金额
  224. func ChooseTheBestAmountField(tmp map[string]interface{}, update_info *map[string]interface{}) {
  225. if r_budget := qu.Float64All((*update_info)["budget"]); r_budget > 0.0 && r_budget < 1000000000.0 {
  226. if o_budget := qu.Float64All(tmp["budget"]); o_budget > 0.0 {
  227. if r_budget/o_budget == 10000.0 || o_budget/r_budget == 10000.0 {
  228. (*update_info)["budget"] = filterAmount(r_budget, o_budget)
  229. }
  230. }
  231. }
  232. if r_bidamount := qu.Float64All((*update_info)["bidamount"]); r_bidamount > 0.0 && r_bidamount < 1000000000.0 {
  233. if o_bidamount := qu.Float64All(tmp["bidamount"]); o_bidamount > 0.0 {
  234. if r_bidamount/o_bidamount == 10000.0 || o_bidamount/r_bidamount == 10000.0 {
  235. (*update_info)["bidamount"] = filterAmount(r_bidamount, o_bidamount)
  236. }
  237. }
  238. }
  239. }
  240. // 选择核对单位值
  241. func ChooseTheBestUnitField(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{}) {
  242. buyer := qu.ObjToString((*update_info)["buyer"])
  243. s_winner := qu.ObjToString((*update_info)["s_winner"])
  244. agency := qu.ObjToString((*update_info)["agency"])
  245. if buyer == "" {
  246. buyer = qu.ObjToString(tmp["buyer"])
  247. }
  248. if s_winner == "" {
  249. s_winner = qu.ObjToString(tmp["s_winner"])
  250. }
  251. if agency == "" {
  252. agency = qu.ObjToString(tmp["agency"])
  253. }
  254. if buyer == s_winner && buyer != "" {
  255. if strings.Contains(buyer, "公司") {
  256. (*update_info)["buyer"] = ""
  257. (*ext_ai_record)["buyer"] = tmp["buyer"]
  258. } else {
  259. if s_toptype == "结果" || s_toptype == "其它" || s_subtype == "单一" {
  260. (*update_info)["s_winner"] = ""
  261. (*update_info)["winner"] = ""
  262. (*ext_ai_record)["s_winner"] = tmp["s_winner"]
  263. (*ext_ai_record)["winner"] = tmp["winner"]
  264. }
  265. }
  266. }
  267. if agency != "" {
  268. if agency == buyer || agency == s_winner {
  269. (*update_info)["agency"] = ""
  270. (*ext_ai_record)["agency"] = tmp["buyer"]
  271. }
  272. }
  273. }
  274. // 选择其它字段
  275. func ChooseTheBestOtherField(ai_zhipu map[string]interface{}, tmp map[string]interface{}, update_info *map[string]interface{}, ext_ai_record *map[string]interface{}) {
  276. if s_purchasinglist := qu.ObjToMap(ai_zhipu["s_purchasinglist"]); s_purchasinglist != nil {
  277. if purchasinglist := IsMarkInterfaceMap((*s_purchasinglist)["purchasinglist"]); len(purchasinglist) > 0 {
  278. (*update_info)["purchasinglist"] = purchasinglist
  279. }
  280. if purchasinglist_label := qu.ObjToMap((*s_purchasinglist)["purchasinglist_label"]); purchasinglist_label != nil {
  281. (*update_info)["purchasinglist_label"] = purchasinglist_label
  282. }
  283. if jycodes := qu.ObjToString((*s_purchasinglist)["jycodes"]); jycodes != "" {
  284. (*update_info)["jycodes"] = jycodes
  285. }
  286. }
  287. //新增字段
  288. if biddingcode := qu.ObjToString(ai_zhipu["s_biddingcode"]); biddingcode != "" {
  289. (*update_info)["biddingcode"] = biddingcode
  290. }
  291. if packagecode := qu.ObjToString(ai_zhipu["s_packagecode"]); packagecode != "" {
  292. (*update_info)["packagecode"] = packagecode
  293. }
  294. //替换字段
  295. if contractcode := qu.ObjToString(ai_zhipu["s_contractcode"]); contractcode != "" {
  296. (*update_info)["contractcode"] = contractcode
  297. (*ext_ai_record)["contractcode"] = tmp["contractcode"]
  298. }
  299. if bidopenaddress := qu.ObjToString(ai_zhipu["s_bidopenaddress"]); bidopenaddress != "" {
  300. (*update_info)["bidopenaddress"] = bidopenaddress
  301. (*ext_ai_record)["bidopenaddress"] = tmp["bidopenaddress"]
  302. }
  303. //折扣
  304. if biddiscount := qu.Float64All(ai_zhipu["s_biddiscount"]); biddiscount > 0.0 {
  305. (*update_info)["biddiscount"] = biddiscount
  306. (*ext_ai_record)["biddiscount"] = tmp["biddiscount"]
  307. }
  308. //时间戳
  309. if bidopentime := qu.Int64All(ai_zhipu["s_bidopentime"]); bidopentime > 0 {
  310. (*update_info)["bidopentime"] = bidopentime
  311. (*ext_ai_record)["bidopentime"] = tmp["bidopentime"]
  312. }
  313. if bidendtime := qu.Int64All(ai_zhipu["s_bidendtime"]); bidendtime > 0 {
  314. (*update_info)["bidendtime"] = bidendtime
  315. (*ext_ai_record)["bidendtime"] = tmp["bidendtime"]
  316. }
  317. if docstarttime := qu.Int64All(ai_zhipu["s_docstarttime"]); docstarttime > 0 {
  318. (*update_info)["docstarttime"] = docstarttime
  319. (*ext_ai_record)["docstarttime"] = tmp["docstarttime"]
  320. }
  321. if docendtime := qu.Int64All(ai_zhipu["s_docendtime"]); docendtime > 0 {
  322. (*update_info)["docendtime"] = docendtime
  323. (*ext_ai_record)["docendtime"] = tmp["docendtime"]
  324. }
  325. //联系方式
  326. if buyerperson := qu.ObjToString(ai_zhipu["s_buyerperson"]); buyerperson != "" {
  327. (*update_info)["buyerperson"] = buyerperson
  328. (*ext_ai_record)["buyerperson"] = tmp["buyerperson"]
  329. }
  330. if buyertel := qu.ObjToString(ai_zhipu["s_buyertel"]); buyertel != "" {
  331. (*update_info)["buyertel"] = buyertel
  332. (*ext_ai_record)["buyertel"] = tmp["buyertel"]
  333. }
  334. if agencyperson := qu.ObjToString(ai_zhipu["s_agencyperson"]); agencyperson != "" {
  335. (*update_info)["agencyperson"] = agencyperson
  336. (*ext_ai_record)["agencyperson"] = tmp["agencyperson"]
  337. }
  338. if agencytel := qu.ObjToString(ai_zhipu["s_agencytel"]); agencytel != "" {
  339. (*update_info)["agencytel"] = agencytel
  340. (*ext_ai_record)["agencytel"] = tmp["agencytel"]
  341. }
  342. if winnerperson := qu.ObjToString(ai_zhipu["s_winnerperson"]); winnerperson != "" {
  343. (*update_info)["winnerperson"] = winnerperson
  344. (*ext_ai_record)["winnerperson"] = tmp["winnerperson"]
  345. }
  346. if winnertel := qu.ObjToString(ai_zhipu["s_winnertel"]); winnertel != "" {
  347. (*update_info)["winnertel"] = winnertel
  348. (*ext_ai_record)["winnertel"] = tmp["winnertel"]
  349. }
  350. }
  351. // 筛选金额
  352. func filterAmount(f1 float64, f2 float64) float64 {
  353. //选取一个合适的金额 ...
  354. if f1 > f2 {
  355. if f1 > 100000000.0 {
  356. return f2
  357. } else {
  358. return f1
  359. }
  360. } else if f1 < f2 {
  361. if f2 > 100000000.0 {
  362. return f1
  363. } else {
  364. return f2
  365. }
  366. } else {
  367. return f1
  368. }
  369. }
  370. // 核算分包信息
  371. func staffInfo(pkg map[string]interface{}) bool {
  372. //鉴定中标单位
  373. is_w := 0
  374. for _, v := range pkg {
  375. info := *qu.ObjToMap(v)
  376. if winner := qu.ObjToString(info["winner"]); winner != "" {
  377. is_w++
  378. }
  379. }
  380. //鉴定中标金额
  381. is_b := 0
  382. for _, v := range pkg {
  383. info := *qu.ObjToMap(v)
  384. if bidamount := qu.Float64All(info["bidamount"]); bidamount > 0.0 {
  385. is_b++
  386. }
  387. }
  388. if is_w != len(pkg) && is_w > 0 {
  389. return false
  390. }
  391. if is_b != len(pkg) && is_b > 0 {
  392. return false
  393. }
  394. if is_w == 0 || is_b == 0 {
  395. return false
  396. }
  397. return true
  398. }
  399. // 核对ai分包
  400. func staffAiPackageInfo(com_package []map[string]interface{}, s_toptype string, s_subtype string) []map[string]interface{} {
  401. if s_toptype == "结果" || s_toptype == "其它" || s_subtype == "单一" {
  402. return com_package
  403. }
  404. new_com_package := []map[string]interface{}{}
  405. for _, v := range com_package {
  406. delete(v, "winner")
  407. delete(v, "bidamount")
  408. new_com_package = append(new_com_package, v)
  409. }
  410. return new_com_package
  411. }
  412. // 核对分类
  413. func CheckClassByOtherFileds(toptype_ai, subtype_ai string, data map[string]interface{}) (string, string) {
  414. toptype_rule := qu.ObjToString(data["toptype"])
  415. subtype_rule := qu.ObjToString(data["subtype"])
  416. //1、结果类 中标和成交错误校正
  417. s_winner := qu.ObjToString(data["s_winner"])
  418. winnerorder := IsMarkInterfaceMap(data["winnerorder"])
  419. if toptype_ai == "结果" && toptype_rule == "结果" {
  420. if subtype_ai == "成交" && subtype_rule == "成交" && len(winnerorder) > 0 { //规则、大模型都错
  421. return "结果", "中标"
  422. }
  423. if ((subtype_ai == "中标" || subtype_ai == "其它") && subtype_rule == "成交") || ((subtype_ai == "成交" || subtype_ai == "其它") && subtype_rule == "中标") {
  424. if len(winnerorder) > 0 { //有中标候选人->中标
  425. return toptype_ai, "中标"
  426. }
  427. if s_winner != "" || data["bidamount"] != nil {
  428. return toptype_ai, "成交"
  429. }
  430. }
  431. }
  432. //2、招标、结果错误校正
  433. if toptype_ai != "结果" && toptype_rule == "结果" {
  434. //return toptype_rule,subtype_rule//默认规则为准
  435. if len(winnerorder) > 0 || s_winner != "" || data["bidamount"] != nil {
  436. return toptype_rule, subtype_rule
  437. } else {
  438. return toptype_ai, subtype_ai
  439. }
  440. } else if toptype_ai == "结果" && toptype_rule != "结果" && (subtype_ai == "中标" || subtype_ai == "成交") { //结果-变更
  441. //return toptype_rule,subtype_rule//默认规则为准
  442. if len(winnerorder) > 0 { //有中标候选人->中标
  443. return toptype_ai, "中标" //这里subtype返回"中标",避免ai识别错误
  444. } else if s_winner != "" || data["bidamount"] != nil {
  445. return toptype_ai, "成交" //这里subtype返回"成交",避免ai识别错误
  446. } else {
  447. return toptype_ai, subtype_ai
  448. }
  449. }
  450. return toptype_ai, subtype_ai
  451. }
  452. func CreatSingleFieldInfo(tmp map[string]interface{}, update_info map[string]interface{}) []map[string]interface{} {
  453. pkgArr := []map[string]interface{}{}
  454. com_package := map[string]interface{}{}
  455. package_id := uuid.New().String()
  456. package_id = strings.ReplaceAll(package_id, "-", "")
  457. com_package["package_id"] = package_id
  458. com_package["name"] = qu.ObjToString(tmp["projectname"])
  459. com_package["projectcode"] = qu.ObjToString(tmp["projectcode"])
  460. com_package["packagecode"] = qu.ObjToString(tmp["packagecode"])
  461. com_package["contractcode"] = qu.ObjToString(tmp["contractcode"])
  462. if update_info["budget"] != nil {
  463. com_package["budget"] = update_info["budget"]
  464. } else {
  465. if tmp["budget"] != nil {
  466. com_package["budget"] = tmp["budget"]
  467. }
  468. }
  469. toptype := qu.ObjToString(update_info["toptype"])
  470. subtype := qu.ObjToString(update_info["subtype"])
  471. if toptype == "" {
  472. toptype = qu.ObjToString(tmp["toptype"])
  473. }
  474. if subtype == "" {
  475. subtype = qu.ObjToString(tmp["subtype"])
  476. }
  477. //中标类
  478. if toptype == "结果" || toptype == "其它" || subtype == "单一" {
  479. if update_info["bidamount"] != nil {
  480. com_package["bidamount"] = update_info["bidamount"]
  481. } else {
  482. if tmp["bidamount"] != nil {
  483. com_package["bidamount"] = tmp["bidamount"]
  484. }
  485. }
  486. if update_info["winner"] != nil {
  487. com_package["winner"] = update_info["winner"]
  488. } else {
  489. if tmp["winner"] != nil {
  490. com_package["winner"] = tmp["winner"]
  491. }
  492. }
  493. }
  494. pkgArr = append(pkgArr, com_package)
  495. return pkgArr
  496. }