biddingtask.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. package main
  2. import (
  3. "createindex/oss"
  4. "reflect"
  5. "regexp"
  6. "strconv"
  7. "strings"
  8. "time"
  9. "unicode/utf8"
  10. util "utils"
  11. "utils/mongodb"
  12. "utils/redis"
  13. )
  14. var date1 = regexp.MustCompile("20[0-2][0-9][年|\\-/.][0-9]{1,2}[月|\\-/.][0-9]{1,2}[日]?")
  15. // @Description 合并extract 字段到bidding表
  16. // @Author J 2022/6/7 2:25 PM
  17. func MergeExtract(tmp, compare, update map[string]interface{}, extractMap map[string]map[string]interface{}, tasktype string) (map[string]interface{}, map[string]interface{}) {
  18. tid := mongodb.BsonIdToSId(tmp["_id"])
  19. if extractMap[tid] != nil {
  20. compare = extractMap[tid]
  21. if tasktype == "bidding" {
  22. // 增量id段 正常数据
  23. if num := util.IntAll(compare["dataging"]); num == 1 { //extract中dataging=1跳过
  24. tmp = make(map[string]interface{})
  25. compare = nil
  26. return compare, update
  27. }
  28. delete(extractMap, tid)
  29. }
  30. if tasktype == "bidding_history" {
  31. //增量id段 历史数据
  32. if compare["history_updatetime"] == nil { //extract中history_updatetime不存在跳过
  33. tmp = make(map[string]interface{})
  34. compare = nil
  35. return compare, update
  36. }
  37. delete(extractMap, tid)
  38. }
  39. //更新bidding表,生成索引;bidding表modifyinfo中的字段不更新
  40. modifyinfo := make(map[string]bool)
  41. if tmpmodifyinfo, ok := tmp["modifyinfo"].(map[string]interface{}); ok && tmpmodifyinfo != nil {
  42. for k, _ := range tmpmodifyinfo {
  43. modifyinfo[k] = true
  44. }
  45. }
  46. //更新bidding表,生成索引
  47. for _, k := range biddingMgoFields {
  48. v1 := compare[k] //extract
  49. v2 := tmp[k] //bidding
  50. if v2 == nil && v1 != nil && !modifyinfo[k] {
  51. update[k] = v1
  52. } else if v2 != nil && v1 != nil && !modifyinfo[k] {
  53. //update[k+"_b"] = v2
  54. update[k] = v1
  55. } else if v2 != nil && v1 == nil {
  56. //update[k+"_b"] = v2
  57. if k == "area" || k == "city" || k == "district" {
  58. update[k] = ""
  59. }
  60. }
  61. }
  62. if util.IntAll(compare["repeat"]) == 1 {
  63. update["extracttype"] = -1
  64. } else {
  65. update["extracttype"] = 1
  66. }
  67. } else {
  68. compare = nil
  69. if util.IntAll(tmp["dataging"]) == 1 { //修改未抽取的bidding数据的dataging
  70. update["dataging"] = 0
  71. }
  72. }
  73. return compare, update
  74. }
  75. // @Description subscopeclass、topscopeclass、package
  76. // @Author J 2022/6/7 5:54 PM
  77. func FieldMethod(compare, update map[string]interface{}) {
  78. subscopeclass, _ := compare["subscopeclass"].([]interface{}) //subscopeclass
  79. if subscopeclass != nil {
  80. m1 := map[string]bool{}
  81. newclass := []string{}
  82. for _, sc := range subscopeclass {
  83. sclass, _ := sc.(string)
  84. if !m1[sclass] {
  85. m1[sclass] = true
  86. newclass = append(newclass, sclass)
  87. }
  88. }
  89. update["s_subscopeclass"] = strings.Join(newclass, ",")
  90. update["subscopeclass"] = newclass
  91. }
  92. topscopeclass, _ := compare["topscopeclass"].([]interface{}) //topscopeclass
  93. if topscopeclass != nil {
  94. m2 := map[string]bool{}
  95. newclass := []string{}
  96. for _, tc := range topscopeclass {
  97. tclass, _ := tc.(string)
  98. tclass = reg_letter.ReplaceAllString(tclass, "") // 去除字母
  99. if !m2[tclass] {
  100. m2[tclass] = true
  101. newclass = append(newclass, tclass)
  102. }
  103. }
  104. update["s_topscopeclass"] = strings.Join(newclass, ",")
  105. }
  106. if package1 := compare["package"]; package1 != nil {
  107. packageM, _ := package1.(map[string]interface{})
  108. for _, p := range packageM {
  109. pm, _ := p.(map[string]interface{})
  110. if util.ObjToString(pm["winner"]) != "" || util.Float64All(pm["budget"]) > 0 ||
  111. util.Float64All(pm["bidamount"]) > 0 {
  112. update["multipackage"] = 1
  113. break
  114. }
  115. }
  116. } else {
  117. update["multipackage"] = 0
  118. }
  119. }
  120. // @Description ES保存字段
  121. // @Author J 2022/6/7 11:34 AM
  122. func GetEsField(tmp, update map[string]interface{}, stype string) map[string]interface{} {
  123. newTmp := make(map[string]interface{})
  124. for field, ftype := range biddingEsFields {
  125. if tmp[field] != nil { //
  126. if field == "projectinfo" {
  127. mp, _ := tmp[field].(map[string]interface{})
  128. if mp != nil {
  129. newmap := map[string]interface{}{}
  130. for k, ktype := range projectinfoFields {
  131. mpv := mp[k]
  132. if mpv != nil && reflect.TypeOf(mpv).String() == ktype {
  133. newmap[k] = mp[k]
  134. }
  135. }
  136. if len(newmap) > 0 {
  137. newTmp[field] = newmap
  138. }
  139. }
  140. } else if field == "purchasinglist" { //标的物处理
  141. purchasinglist_new := []map[string]interface{}{}
  142. if pcl, _ := tmp[field].([]interface{}); len(pcl) > 0 {
  143. for _, ls := range pcl {
  144. lsm_new := make(map[string]interface{})
  145. lsm := ls.(map[string]interface{})
  146. for pf, pftype := range purchasinglistFields {
  147. lsmv := lsm[pf]
  148. if lsmv != nil && reflect.TypeOf(lsmv).String() == pftype {
  149. lsm_new[pf] = lsm[pf]
  150. }
  151. }
  152. if lsm_new != nil && len(lsm_new) > 0 {
  153. purchasinglist_new = append(purchasinglist_new, lsm_new)
  154. }
  155. }
  156. }
  157. if len(purchasinglist_new) > 0 {
  158. newTmp[field] = purchasinglist_new
  159. }
  160. } else if field == "procurementlist" {
  161. if tmp["procurementlist"] != nil {
  162. var arr []interface{}
  163. plist := tmp["procurementlist"].([]interface{})
  164. for _, p := range plist {
  165. p1 := p.(map[string]interface{})
  166. p2 := make(map[string]interface{})
  167. for k, v := range procurementlisFields {
  168. if k == "projectname" && util.ObjToString(p1[k]) == "" {
  169. p2[k] = util.ObjToString(tmp["projectname"])
  170. } else if k == "buyer" && util.ObjToString(p1[k]) == "" && util.ObjToString(tmp["buyer"]) != "" {
  171. p2[k] = util.ObjToString(tmp["buyer"])
  172. } else if k == "expurasingtime" && util.ObjToString(p1[k]) != "" {
  173. res := getMethod(util.ObjToString(p1[k]))
  174. if res != 0 {
  175. p2[k] = res
  176. }
  177. } else if p1[k] != nil && reflect.TypeOf(p1[k]).String() == v {
  178. p2[k] = p1[k]
  179. }
  180. }
  181. arr = append(arr, p2)
  182. }
  183. if len(arr) > 0 {
  184. newTmp[field] = arr
  185. }
  186. }
  187. } else if field == "projectscope" {
  188. ps, _ := tmp["projectscope"].(string)
  189. if len(ps) > pscopeLength {
  190. newTmp["projectscope"] = string(([]rune(ps))[:pscopeLength])
  191. } else {
  192. newTmp["projectscope"] = ps
  193. }
  194. } else if field == "winnerorder" { //中标候选
  195. winnerorder_new := []map[string]interface{}{}
  196. if winnerorder, _ := tmp[field].([]interface{}); len(winnerorder) > 0 {
  197. for _, win := range winnerorder {
  198. winMap_new := make(map[string]interface{})
  199. winMap := win.(map[string]interface{})
  200. for wf, wftype := range winnerorderlistFields {
  201. wfv := winMap[wf]
  202. if wfv != nil && reflect.TypeOf(wfv).String() == wftype {
  203. if wf == "sort" && util.Int64All(wfv) > 100 {
  204. continue
  205. }
  206. winMap_new[wf] = winMap[wf]
  207. }
  208. }
  209. if winMap_new != nil && len(winMap_new) > 0 {
  210. winnerorder_new = append(winnerorder_new, winMap_new)
  211. }
  212. }
  213. }
  214. if len(winnerorder_new) > 0 {
  215. newTmp[field] = winnerorder_new
  216. }
  217. } else if field == "qualifies" {
  218. //项目资质
  219. qs := []string{}
  220. if q, _ := tmp[field].([]interface{}); len(q) > 0 {
  221. for _, v := range q {
  222. v1 := v.(map[string]interface{})
  223. qs = append(qs, util.ObjToString(v1["key"]))
  224. }
  225. }
  226. if len(qs) > 0 {
  227. newTmp[field] = strings.Join(qs, ",")
  228. }
  229. } else if field == "review_experts" {
  230. // 评审专家
  231. if arr, ok := tmp["review_experts"].([]interface{}); ok && len(arr) > 0 {
  232. arr1 := util.ObjArrToStringArr(arr)
  233. newTmp[field] = strings.Join(arr1, ",")
  234. }
  235. } else if field == "bidopentime" {
  236. if tmp[field] != nil && tmp["bidendtime"] == nil {
  237. newTmp["bidendtime"] = tmp[field]
  238. newTmp[field] = tmp[field]
  239. } else if tmp[field] == nil && tmp["bidendtime"] != nil {
  240. newTmp["bidendtime"] = tmp[field]
  241. newTmp[field] = tmp["bidendtime"]
  242. } else {
  243. if tmp["bidopentime"] != nil {
  244. newTmp[field] = tmp["bidopentime"]
  245. }
  246. }
  247. } else if field == "detail" { //过滤
  248. detail, _ := tmp[field].(string)
  249. if len([]rune(detail)) > detailLength {
  250. detail = detail[:detailLength]
  251. }
  252. detail = filterSpace.ReplaceAllString(detail, "")
  253. if stype == "bidding" || stype == "bidding_history" {
  254. text, b := FilterDetail(detail)
  255. newTmp[field] = util.ObjToString(tmp["title"]) + " " + text
  256. update["cleartag"] = b
  257. } else {
  258. if tmp["cleartag"] != nil && tmp["cleartag"].(bool) {
  259. text, _ := FilterDetail(detail)
  260. newTmp[field] = util.ObjToString(tmp["title"]) + " " + text
  261. } else {
  262. newTmp[field] = util.ObjToString(tmp["title"]) + " " + detail
  263. }
  264. }
  265. } else if field == "_id" || field == "topscopeclass" || field == "entidlist" { //不做处理
  266. newTmp[field] = tmp[field]
  267. } else if field == "publishtime" || field == "comeintime" {
  268. //字段类型不正确,特别处理
  269. if tmp[field] != nil && util.Int64All(tmp[field]) > 0 {
  270. newTmp[field] = util.Int64All(tmp[field])
  271. }
  272. } else { //其它字段判断数据类型,不正确舍弃
  273. if fieldval := tmp[field]; reflect.TypeOf(fieldval).String() != ftype {
  274. continue
  275. } else {
  276. if fieldval != "" {
  277. newTmp[field] = fieldval
  278. }
  279. }
  280. }
  281. }
  282. }
  283. filetext := getFileText(tmp)
  284. if len([]rune(filetext)) > 10 {
  285. newTmp["filetext"] = filetext
  286. }
  287. //else {
  288. // // 附件未识别到内容,有附件且附件能够下载 filetext=""
  289. // if pinfo, o1 := tmp["projectinfo"].(map[string]interface{}); o1 {
  290. // if atts, o2 := pinfo["attachments"].(map[string]interface{}); o2 {
  291. // tag := false
  292. // for _, at := range atts {
  293. // at1 := at.(map[string]interface{})
  294. // if at1["fid"] != nil {
  295. // tag = true
  296. // break
  297. // }
  298. // }
  299. // if tag {
  300. // newTmp["filetext"] = ""
  301. // }
  302. // }
  303. // }
  304. //}
  305. YuceEndtime(newTmp) // 预测结果时间
  306. if stype == "bidding" || stype == "bidding_history" {
  307. newTmp["createtime"] = time.Now().Unix() // es库数据创建时间,只有增量数据有
  308. }
  309. return newTmp
  310. }
  311. // @Description 附件内容
  312. // @Author J 2022/6/7 1:54 PM
  313. func getFileText(tmp map[string]interface{}) (filetext string) {
  314. if attchMap, ok := tmp["attach_text"].(map[string]interface{}); attchMap != nil && ok {
  315. for _, tmpData1 := range attchMap {
  316. if tmpData2, ok := tmpData1.(map[string]interface{}); tmpData2 != nil && ok {
  317. for _, result := range tmpData2 {
  318. if resultMap, ok := result.(map[string]interface{}); resultMap != nil && ok {
  319. if attach_url := util.ObjToString(resultMap["attach_url"]); attach_url != "" {
  320. bs := oss.OssGetObject(attach_url) //oss读数据
  321. if utf8.RuneCountInString(filetext+bs) < fileLength {
  322. filetext += bs + "\n"
  323. } else {
  324. if utf8.RuneCountInString(bs) > fileLength {
  325. filetext = bs[0:fileLength]
  326. } else {
  327. filetext = bs
  328. }
  329. break
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. }
  337. return
  338. }
  339. // 预测结果时间
  340. func YuceEndtime(tmp map[string]interface{}) {
  341. flag := true
  342. scope := []string{"服务采购_法律咨询", "服务采购_会计", "服务采购_物业", "服务采购_审计", "服务采购_安保", "服务采购_仓储物流",
  343. "服务采购_广告宣传印刷"}
  344. subscopeclass := util.ObjToString(tmp["s_subscopeclass"])
  345. for _, v := range scope {
  346. if strings.Contains(subscopeclass, v) {
  347. flag = false
  348. break
  349. }
  350. }
  351. if flag {
  352. return
  353. }
  354. subtype := util.ObjToString(tmp["subtype"])
  355. if subtype == "成交" || subtype == "合同" {
  356. // yucestarttime、yuceendtime
  357. yucestarttime, yuceendtime := int64(0), int64(0)
  358. // 项目周期中
  359. if util.ObjToString(tmp["projectperiod"]) != "" {
  360. dateStr := date1.FindStringSubmatch(util.ObjToString(tmp["projectperiod"]))
  361. if len(dateStr) == 2 {
  362. sdate := FormatDateStr(dateStr[0])
  363. edate := FormatDateStr(dateStr[1])
  364. if sdate < edate && sdate != 0 && edate != 0 {
  365. yucestarttime = sdate
  366. yuceendtime = edate
  367. }
  368. }
  369. }
  370. if yucestarttime > 0 && yuceendtime > yucestarttime {
  371. tmp["yuceendtime"] = yuceendtime
  372. return
  373. }
  374. // 预测开始时间 合同签订日期
  375. if yucestarttime == 0 {
  376. if util.IntAll(tmp["signaturedate"]) <= 0 {
  377. if util.IntAll(tmp["publishtime"]) <= 0 {
  378. return
  379. } else {
  380. yucestarttime = util.Int64All(tmp["publishtime"])
  381. }
  382. } else {
  383. yucestarttime = util.Int64All(tmp["signaturedate"])
  384. }
  385. }
  386. // 预测结束时间
  387. if yucestarttime > 0 && yuceendtime == 0 {
  388. if util.IntAll(tmp["project_duration"]) > 0 && util.ObjToString(tmp["project_timeunit"]) != "" {
  389. yuceendtime = YcEndTime(yucestarttime, util.IntAll(tmp["project_duration"]), util.ObjToString(tmp["project_timeunit"]))
  390. tmp["yuceendtime"] = yuceendtime
  391. }
  392. }
  393. }
  394. }
  395. func YcEndTime(starttime int64, num int, unit string) int64 {
  396. yuceendtime := int64(0)
  397. if unit == "日历天" || unit == "天" || unit == "日" {
  398. yuceendtime = starttime + int64(num*86400)
  399. } else if unit == "周" {
  400. yuceendtime = time.Unix(starttime, 0).AddDate(0, 0, num*7).Unix()
  401. } else if unit == "月" {
  402. yuceendtime = time.Unix(starttime, 0).AddDate(0, num, 0).Unix()
  403. } else if unit == "年" {
  404. yuceendtime = time.Unix(starttime, 0).AddDate(num, 0, 0).Unix()
  405. } else if unit == "工作日" {
  406. n := num / 7 * 2
  407. yuceendtime = time.Unix(starttime, 0).AddDate(0, 0, num+n).Unix()
  408. }
  409. return yuceendtime
  410. }
  411. func FormatDateStr(ds string) int64 {
  412. ds = strings.Replace(ds, "年", "-", -1)
  413. ds = strings.Replace(ds, "月", "-", -1)
  414. ds = strings.Replace(ds, "日", "", -1)
  415. ds = strings.Replace(ds, "/", "-", -1)
  416. ds = strings.Replace(ds, ".", "-", -1)
  417. location, err := time.ParseInLocation(util.Date_Short_Layout, ds, time.Local)
  418. if err != nil {
  419. util.Debug(err)
  420. return 0
  421. } else {
  422. return location.Unix()
  423. }
  424. }
  425. // @Description entidlist
  426. // @Author J 2022/6/7 2:36 PM
  427. func FieldFun(tmp map[string]interface{}) (cid []string) {
  428. sWinnerarr := strings.Split(util.ObjToString(tmp["s_winner"]), ",")
  429. for _, w := range sWinnerarr {
  430. if w != "" {
  431. id := redis.GetStr("qyxy_id", w)
  432. if id == "" {
  433. ents, _ := standardMgo.Find("qyxy_std", map[string]interface{}{"company_name": w}, map[string]interface{}{"updatetime": -1}, nil, false, -1, -1)
  434. if len(*ents) > 0 {
  435. id = util.ObjToString((*ents)[0]["_id"])
  436. redis.PutCKV("qyxy_id", w, id)
  437. } else {
  438. ent, _ := qyxyMgo.FindOne("company_history_name", map[string]interface{}{"history_name": w})
  439. if len(*ent) > 0 {
  440. id = util.ObjToString((*ent)["company_id"])
  441. redis.PutCKV("qyxy_id", w, id)
  442. }
  443. }
  444. }
  445. if id == "" {
  446. id = "-"
  447. }
  448. cid = append(cid, id)
  449. }
  450. }
  451. return cid
  452. }
  453. var filterSpace = regexp.MustCompile("<[^>]*?>|[\\s\u3000\u2003\u00a0]")
  454. func FilterDetail(text string) (string, bool) {
  455. b := false // 清理标记
  456. for _, s := range FilterKeyword {
  457. reg := regexp.MustCompile(s)
  458. if reg.MatchString(text) {
  459. text = reg.ReplaceAllString(text, "")
  460. if !b {
  461. b = true
  462. }
  463. }
  464. }
  465. return text, b
  466. }
  467. // 正则判断是否包含
  468. func checkContains(s, sub string) bool {
  469. reg := regexp.MustCompile(`(?i)(^|([\s\t\n]+))(` + sub + `)($|([\s\t\n]+))`)
  470. return reg.MatchString(s)
  471. }
  472. var TimeV1 = regexp.MustCompile("(\\d{4})[年.]?$")
  473. var TimeV2 = regexp.MustCompile("(\\d{4}[年.\\-/]?)(\\d{1,2}[月.\\-/]?$)")
  474. var TimeClear = regexp.MustCompile("[年|月|/|.|-]")
  475. // @Description 采购意向 预计采购时间处理
  476. // @Author J 2022/6/7 8:04 PM
  477. func getMethod(str string) int64 {
  478. if TimeV1.MatchString(str) {
  479. arr := TimeV1.FindStringSubmatch(str)
  480. st := arr[1] + "0000"
  481. parseInt, err := strconv.ParseInt(st, 10, 64)
  482. if err == nil {
  483. return parseInt
  484. }
  485. } else if TimeV2.MatchString(str) {
  486. arr := TimeV2.FindStringSubmatch(str)
  487. str1 := arr[2]
  488. if len(str1) == 1 {
  489. str1 = "0" + str1
  490. }
  491. str2 := TimeClear.ReplaceAllString(arr[1], "") + TimeClear.ReplaceAllString(str1, "") + "00"
  492. parseInt, err := strconv.ParseInt(str2, 10, 64)
  493. if err == nil {
  494. return parseInt
  495. }
  496. }
  497. return 0
  498. }
  499. // @Description 字段空值处理
  500. // @Author J 2022/6/7 8:04 PM
  501. func clearMap(tmp map[string]interface{}) {
  502. for k := range tmp {
  503. if tmp[k] == nil {
  504. continue
  505. }
  506. if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok && len(purchasinglist) == 0 {
  507. delete(tmp, "purchasinglist")
  508. } else if reflect.TypeOf(tmp[k]).String() == "string" && util.ObjToString(tmp[k]) == "" {
  509. delete(tmp, k)
  510. }
  511. }
  512. }
  513. // @Description 附件有效字段(isValidFile)
  514. // @Author J 2022/7/8 14:41
  515. func validFile(tmp map[string]interface{}) int {
  516. isContinue := false
  517. if pinfo, o := tmp["projectinfo"].(map[string]interface{}); o {
  518. if atts, o1 := pinfo["attachments"].(map[string]interface{}); o1 {
  519. for _, att := range atts {
  520. if att == nil {
  521. util.Debug(tmp["_id"])
  522. continue
  523. }
  524. if reflect.TypeOf(att).String() == "string" {
  525. util.Debug(tmp["_id"])
  526. continue
  527. }
  528. att1 := att.(map[string]interface{})
  529. if fid := util.ObjToString(att1["fid"]); fid != "" {
  530. isContinue = true
  531. break
  532. }
  533. }
  534. if isContinue {
  535. if attachTxt, o := tmp["attach_text"].(map[string]interface{}); o {
  536. if len(attachTxt) > 0 {
  537. for _, at := range attachTxt {
  538. at1 := at.(map[string]interface{})
  539. if len(at1) > 0 {
  540. for k, _ := range at1 {
  541. if reflect.TypeOf(at1[k]).String() == "string" {
  542. util.Debug(tmp["_id"])
  543. continue
  544. }
  545. at2 := at1[k].(map[string]interface{})
  546. s := strings.ToLower(util.ObjToString(at2["file_name"]))
  547. if !strings.Contains(s, "jpg") || !strings.Contains(s, "jpeg") != strings.Contains(s, "png") ||
  548. strings.Contains(s, "pdf") {
  549. if strings.Contains(s, "swf") || strings.Contains(s, "html") {
  550. return -1
  551. } else if AnalysisFile(oss.OssGetObject(util.ObjToString(at2["attach_url"]))) {
  552. return 1
  553. }
  554. }
  555. }
  556. break
  557. } else {
  558. break
  559. }
  560. }
  561. }
  562. }
  563. flag := false
  564. for _, att := range atts {
  565. if att == nil {
  566. continue
  567. }
  568. if reflect.TypeOf(att).String() == "string" {
  569. continue
  570. }
  571. att1 := att.(map[string]interface{})
  572. if fid := util.ObjToString(att1["fid"]); fid != "" {
  573. ftype := strings.ToLower(util.ObjToString(tmp["ftype"]))
  574. if ftype != "swf" && ftype != "html" && oss.OssObjExists("jy-datafile", fid) {
  575. return 1
  576. } else {
  577. flag = true
  578. }
  579. }
  580. }
  581. if flag {
  582. return -1
  583. }
  584. }
  585. }
  586. }
  587. return 0
  588. }