biddingindex.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. package main
  2. import (
  3. "encoding/json"
  4. "reflect"
  5. //"fmt"
  6. "log"
  7. mu "mfw/util"
  8. "net"
  9. qutil "qfw/util"
  10. elastic "qfw/util/elastic"
  11. "regexp"
  12. "strings"
  13. "sync"
  14. "time"
  15. "gopkg.in/mgo.v2/bson"
  16. )
  17. //对字段处理 bidamount budget
  18. //招标数据表和抽取表一一对应开始更新
  19. func biddingTask(data []byte, mapInfo map[string]interface{}) {
  20. defer qutil.Catch()
  21. q, _ := mapInfo["query"].(map[string]interface{})
  22. bkey, _ := mapInfo["bkey"].(string)
  23. if q == nil {
  24. q = map[string]interface{}{
  25. "_id": bson.M{
  26. "$gt": qutil.StringTOBsonId(mapInfo["gtid"].(string)),
  27. "$lte": qutil.StringTOBsonId(mapInfo["lteid"].(string)),
  28. },
  29. }
  30. }
  31. //连接信息
  32. c, _ := bidding["collect"].(string)
  33. extractc, _ := bidding["extractcollect"].(string)
  34. db, _ := bidding["db"].(string)
  35. extractdb, _ := bidding["extractdb"].(string)
  36. index, _ := bidding["index"].(string)
  37. itype, _ := bidding["type"].(string)
  38. //extract库
  39. extractsession := extractmgo.GetMgoConn(86400)
  40. defer extractmgo.DestoryMongoConn(extractsession)
  41. extractquery := extractsession.DB(extractdb).C(extractc).Find(q).Sort("_id").Iter()
  42. eMap := map[string]map[string]interface{}{}
  43. for tmp := make(map[string]interface{}); extractquery.Next(tmp); {
  44. tid := qutil.BsonIdToSId(tmp["_id"])
  45. eMap[tid] = tmp
  46. tmp = make(map[string]interface{})
  47. }
  48. //bidding库
  49. session := mgo.GetMgoConn(86400)
  50. count, _ := session.DB(db).C(c).Find(&q).Count()
  51. log.Println("查询语句:", q, "同步总数:", count, "elastic库:", index)
  52. n1, n2 := 0, 0
  53. if count < 200000 {
  54. res := make([]map[string]interface{}, 1)
  55. session.DB(db).C(c).Find(q).Select(bson.M{
  56. "projectinfo.attachment": 0,
  57. "contenthtml": 0,
  58. }).All(&res)
  59. mgo.DestoryMongoConn(session)
  60. if len(res) != count {
  61. log.Println("查询结果不一致", "count:", count, "res:", len(res))
  62. time.Sleep(20 * time.Second)
  63. toadd := &net.UDPAddr{
  64. IP: net.ParseIP("127.0.0.1"),
  65. Port: qutil.IntAll(Sysconfig["udpport"]),
  66. }
  67. udpclient.WriteUdp(data, mu.OP_TYPE_DATA, toadd)
  68. } else {
  69. n1, n2 = doIndex(res, eMap, index, itype, db, c, bkey)
  70. if (n1 + n2) != count {
  71. log.Println("任务错误,结果不一致")
  72. }
  73. }
  74. } else {
  75. log.Println("数据量太大,放弃!", count)
  76. mgo.DestoryMongoConn(session)
  77. }
  78. log.Println(mapInfo, "create bidding index...over", "all:", count, "n1:", n1, "n2:", n2)
  79. //go delEs(mapInfo, index, itype, db, c) //删除索引
  80. }
  81. //删除索引
  82. // func delEs(mapInfo map[string]interface{}, index, itype, db, c string) {
  83. // defer qutil.Catch()
  84. // other_delete := false
  85. // if other_index != "" && other_itype != "" {
  86. // other_delete = true
  87. // }
  88. // ids := qutil.ObjToString(mapInfo["ids"])
  89. // idsarr := strings.Split(ids, ",")
  90. // log.Println("delete ids count:", len(idsarr))
  91. // n1 := 0
  92. // update := [][]map[string]interface{}{} //将bidding表中的extracttype改为-1
  93. // set := map[string]interface{}{
  94. // "$set": map[string]interface{}{"extracttype": -1},
  95. // }
  96. // for _, id := range idsarr {
  97. // if id != "" {
  98. // update = append(update, []map[string]interface{}{ //更新
  99. // map[string]interface{}{
  100. // "_id": qutil.StringTOBsonId(id),
  101. // },
  102. // set,
  103. // })
  104. // if elastic.DelById(index, itype, id) {
  105. // n1++
  106. // }
  107. // if other_delete {
  108. // bidding_other_es.DelById(other_index, other_itype, id)
  109. // }
  110. // }
  111. // }
  112. // //更新
  113. // if len(update) > 0 {
  114. // mgo.UpdateBulkAll(db, c, update...)
  115. // }
  116. // log.Println("result delete bidding index...over", "all:", n1)
  117. // }
  118. func doIndex(infos []map[string]interface{}, eMap map[string]map[string]interface{}, index, itype, db, c, bkey string) (int, int) {
  119. n1, n2 := 0, 0
  120. //线程池
  121. UpdatesLock := sync.Mutex{}
  122. fields := strings.Split(bidding["fields"].(string), ",")
  123. //更新数组
  124. arr := [][]map[string]interface{}{}
  125. arrEs := []map[string]interface{}{}
  126. //对比两张表数据,减少查询次数
  127. var compare bson.M
  128. log.Println("开始迭代..")
  129. for n, tmp := range infos {
  130. n1++
  131. // if sensitive := qutil.ObjToString(tmp["sensitive"]); sensitive != "" { //bidding中有敏感词,不生索引
  132. // tmp = make(map[string]interface{})
  133. // continue
  134. // }
  135. update := map[string]interface{}{} //要更新的mongo数据
  136. //对比方法----------------
  137. tid := qutil.BsonIdToSId(tmp["_id"])
  138. if eMap[tid] != nil {
  139. compare = eMap[tid]
  140. if qutil.IntAll(compare["dataging"]) == 1 { //extract中dataging=1不生索引
  141. tmp = make(map[string]interface{})
  142. compare = nil
  143. continue
  144. }
  145. delete(eMap, tid)
  146. //更新bidding表,生成索引;bidding表modifyinfo中的字段不更新
  147. modifyinfo := make(map[string]bool)
  148. if tmpmodifyinfo, ok := tmp["modifyinfo"].(map[string]interface{}); ok && tmpmodifyinfo != nil {
  149. for k, _ := range tmpmodifyinfo {
  150. modifyinfo[k] = true
  151. }
  152. }
  153. //更新bidding表,生成索引
  154. for _, k := range fields {
  155. v1 := compare[k] //extract
  156. v2 := tmp[k] //bidding
  157. if v2 == nil && v1 != nil && !modifyinfo[k] {
  158. update[k] = v1
  159. } else if v2 != nil && v1 != nil && !modifyinfo[k] {
  160. //update[k+"_b"] = v2
  161. update[k] = v1
  162. } else if v2 != nil && v1 == nil {
  163. //update[k+"_b"] = v2
  164. }
  165. }
  166. if qutil.IntAll(compare["repeat"]) == 1 {
  167. update["extracttype"] = -1
  168. } else {
  169. update["extracttype"] = 1
  170. }
  171. } else {
  172. compare = nil
  173. }
  174. //下面可以多线程跑的--->
  175. //处理分类
  176. if compare != nil { //extract
  177. subscopeclass, _ := compare["subscopeclass"].([]interface{}) //subscopeclass
  178. if subscopeclass != nil {
  179. //str := ","
  180. m1 := map[string]bool{}
  181. newclass := []string{}
  182. for _, sc := range subscopeclass {
  183. sclass, _ := sc.(string)
  184. if !m1[sclass] {
  185. m1[sclass] = true
  186. //str += sclass + ","
  187. newclass = append(newclass, sclass)
  188. }
  189. }
  190. update["s_subscopeclass"] = strings.Join(newclass, ",")
  191. update["subscopeclass"] = newclass
  192. }
  193. topscopeclass, _ := compare["topscopeclass"].([]interface{}) //topscopeclass
  194. if topscopeclass != nil {
  195. m2 := map[string]bool{}
  196. newclass := []string{}
  197. for _, tc := range topscopeclass {
  198. tclass, _ := tc.(string)
  199. tclass = reg_letter.ReplaceAllString(tclass, "") // 去除字母
  200. if !m2[tclass] {
  201. m2[tclass] = true
  202. newclass = append(newclass, tclass)
  203. }
  204. }
  205. update["s_topscopeclass"] = strings.Join(newclass, ",")
  206. }
  207. //处理中标企业
  208. // winner, _ := compare["winner"].(string)
  209. // m1 := map[string]bool{}
  210. // if winner != "" {
  211. // m1[winner] = true
  212. // }
  213. // package1 := compare["package"]
  214. // if package1 != nil {
  215. // packageM, _ := package1.(map[string]interface{})
  216. // for _, p := range packageM {
  217. // pm, _ := p.(map[string]interface{})
  218. // pw, _ := pm["winner"].(string)
  219. // if pw != "" {
  220. // m1[pw] = true
  221. // }
  222. // }
  223. // }
  224. compare = nil
  225. // if len(m1) > 0 {
  226. // //str := ","
  227. // winnerarr := []string{}
  228. // for k, _ := range m1 {
  229. // //str += k + ","
  230. // winnerarr = append(winnerarr, k)
  231. // }
  232. // update["s_winner"] = strings.Join(winnerarr, ",")
  233. // }
  234. }
  235. //------------------对比结束
  236. //处理key descript
  237. if bkey == "" {
  238. DealInfo(&tmp, &update)
  239. }
  240. //同时保存到elastic
  241. for tk, tv := range update {
  242. tmp[tk] = tv
  243. }
  244. //对projectscope字段的索引处理
  245. ps, _ := tmp["projectscope"].(string)
  246. if len(ps) > ESLEN {
  247. tmp["projectscope"] = string(([]rune(ps))[:4000])
  248. }
  249. //对标的物为空处理
  250. if filetext := getFileText(tmp); len(filetext) > 10 { //attach_text
  251. // if site, _ := tmp["site"].(string); site == "中国招标投标公共服务平台" { //site:中国招标投标公共服务平台 detail替换成filetext 并加入标记filedetail=1
  252. // tmp["detail"] = filetext //更新es中detail
  253. // update["detail"] = filetext //更新mongo中detail
  254. // update["filedetail"] = 1 //mongo中打标记
  255. // }
  256. tmp["filetext"] = filetext
  257. }
  258. if purchasing, ok := tmp["purchasing"].(string); ok && purchasing == "" {
  259. delete(tmp, "purchasing")
  260. }
  261. if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok && len(purchasinglist) == 0 {
  262. delete(tmp, "purchasinglist")
  263. }
  264. //数据为空处理
  265. for _, f := range []string{"bidstatus", "city", "district", "channel"} {
  266. if fVal, ok := tmp[f].(string); ok && fVal == "" {
  267. delete(tmp, f)
  268. }
  269. }
  270. UpdatesLock.Lock()
  271. // for k1, _ := range tmp {
  272. // if strings.HasSuffix(k1, "_b") || k1 == "contenthtml" {
  273. // delete(tmp, k1)
  274. // }
  275. // }
  276. go IS.Add("bidding")
  277. if qutil.IntAll(update["extracttype"]) != -1 {
  278. newTmp := map[string]interface{}{} //最终生索引的数据
  279. for field, ftype := range biddingIndexFieldsMap { //
  280. if tmp[field] != nil { //
  281. if field == "projectinfo" {
  282. mp, _ := tmp[field].(map[string]interface{})
  283. if mp != nil {
  284. newmap := map[string]interface{}{}
  285. for k, ktype := range projectinfoFieldsMap {
  286. mpv := mp[k]
  287. if mpv != nil && reflect.TypeOf(mpv).String() == ktype {
  288. newmap[k] = mp[k]
  289. }
  290. }
  291. if len(newmap) > 0 {
  292. newTmp[field] = newmap
  293. }
  294. }
  295. } else if field == "purchasinglist" { //标的物处理
  296. purchasinglist_new := []map[string]interface{}{}
  297. if pcl, _ := tmp[field].([]interface{}); len(pcl) > 0 {
  298. for _, ls := range pcl {
  299. lsm_new := make(map[string]interface{})
  300. lsm := ls.(map[string]interface{})
  301. for pf, pftype := range purchasinglistFieldsMap {
  302. lsmv := lsm[pf]
  303. if lsmv != nil && reflect.TypeOf(lsmv).String() == pftype {
  304. lsm_new[pf] = lsm[pf]
  305. }
  306. }
  307. if lsm_new != nil && len(lsm_new) > 0 {
  308. purchasinglist_new = append(purchasinglist_new, lsm_new)
  309. }
  310. }
  311. }
  312. if len(purchasinglist_new) > 0 {
  313. newTmp[field] = purchasinglist_new
  314. }
  315. } else if field == "winnerorder" { //中标候选
  316. winnerorder_new := []map[string]interface{}{}
  317. if winnerorder, _ := tmp[field].([]interface{}); len(winnerorder) > 0 {
  318. for _, win := range winnerorder {
  319. winMap_new := make(map[string]interface{})
  320. winMap := win.(map[string]interface{})
  321. for wf, wftype := range winnerorderlistFieldsMap {
  322. wfv := winMap[wf]
  323. if wfv != nil && reflect.TypeOf(wfv).String() == wftype {
  324. if wf == "sort" && qutil.Int64All(wfv) > 100 {
  325. continue
  326. }
  327. winMap_new[wf] = winMap[wf]
  328. }
  329. }
  330. if winMap_new != nil && len(winMap_new) > 0 {
  331. winnerorder_new = append(winnerorder_new, winMap_new)
  332. }
  333. }
  334. }
  335. if len(winnerorder_new) > 0 {
  336. newTmp[field] = winnerorder_new
  337. }
  338. } else if field == "detail" { //过滤
  339. detail, _ := tmp[field].(string)
  340. if len([]rune(detail)) > detailLength {
  341. detail = detail[:detailLength]
  342. }
  343. newTmp[field] = FilterDetail(detail)
  344. } else if field == "_id" || field == "topscopeclass" { //不做处理
  345. newTmp[field] = tmp[field]
  346. } else { //其它字段判断数据类型,不正确舍弃
  347. if fieldval := tmp[field]; reflect.TypeOf(fieldval).String() != ftype {
  348. continue
  349. } else {
  350. newTmp[field] = fieldval
  351. }
  352. }
  353. }
  354. }
  355. // for _, v := range biddingIndexFields { //索引字段
  356. // if tmp[v] != nil {
  357. // if "projectinfo" == v {
  358. // mp, _ := tmp[v].(map[string]interface{})
  359. // if mp != nil {
  360. // newmap := map[string]interface{}{}
  361. // for _, v1 := range projectinfoFields {
  362. // if mp[v1] != nil {
  363. // newmap[v1] = fmt.Sprint(mp[v1])
  364. // }
  365. // }
  366. // if len(newmap) > 0 {
  367. // newTmp[v] = newmap
  368. // }
  369. // // attachments := mp["attachments"]
  370. // // con := ""
  371. // // if attachments != nil {
  372. // // am, _ := attachments.(map[string]interface{})
  373. // // if am != nil {
  374. // // for _, v1 := range am {
  375. // // vm, _ := v1.(map[string]interface{})
  376. // // if vm != nil {
  377. // // c, _ := vm["content"].(string)
  378. // // con += c
  379. // // }
  380. // // }
  381. // // }
  382. // // }
  383. // // con = FilterDetailSpace(con)
  384. // // if con != "" {
  385. // // newTmp["attachments"] = con
  386. // // }
  387. // }
  388. // } else if v == "purchasinglist" { //标的物处理
  389. // purchasinglist_new := []map[string]interface{}{}
  390. // if pcl, _ := tmp[v].([]interface{}); len(pcl) > 0 {
  391. // for _, ls := range pcl {
  392. // lsm_new := make(map[string]interface{})
  393. // lsm := ls.(map[string]interface{})
  394. // for _, pf := range purchasinglistFields {
  395. // if lsm[pf] != nil {
  396. // lsm_new[pf] = lsm[pf]
  397. // }
  398. // }
  399. // if lsm_new != nil && len(lsm_new) > 0 {
  400. // purchasinglist_new = append(purchasinglist_new, lsm_new)
  401. // }
  402. // }
  403. // }
  404. // if len(purchasinglist_new) > 0 {
  405. // newTmp[v] = purchasinglist_new
  406. // }
  407. // /*} else if v == "winnerorder" { //中标候选
  408. // winnerorder_new := []map[string]interface{}{}
  409. // if winnerorder, _ := tmp[v].([]interface{}); len(winnerorder) > 0 {
  410. // for _, win := range winnerorder {
  411. // winMap_new := make(map[string]interface{})
  412. // winMap := win.(map[string]interface{})
  413. // for _, wf := range winnerorderlistFields {
  414. // if wfv := winMap[wf]; wfv != nil {
  415. // if wf == "sort" && qutil.Int64All(wfv) > 100 {
  416. // continue
  417. // }
  418. // winMap_new[wf] = winMap[wf]
  419. // }
  420. // }
  421. // if winMap_new != nil && len(winMap_new) > 0 {
  422. // winnerorder_new = append(winnerorder_new, winMap_new)
  423. // }
  424. // }
  425. // }
  426. // if len(winnerorder_new) > 0 {
  427. // newTmp[v] = winnerorder_new
  428. // }
  429. // */
  430. // } else {
  431. // if v == "detail" {
  432. // detail, _ := tmp[v].(string)
  433. // if len([]rune(detail)) > detailLength {
  434. // detail = detail[:detailLength]
  435. // }
  436. // newTmp[v] = FilterDetail(detail)
  437. // } else {
  438. // newTmp[v] = tmp[v]
  439. // }
  440. // }
  441. // }
  442. // }
  443. arrEs = append(arrEs, newTmp)
  444. }
  445. if len(update) > 0 {
  446. delete(update, "winnerorder") //winnerorder不需要更新到bindding表,删除
  447. arr = append(arr, []map[string]interface{}{
  448. map[string]interface{}{
  449. "_id": tmp["_id"],
  450. },
  451. map[string]interface{}{
  452. "$set": update,
  453. },
  454. })
  455. }
  456. if len(arr) >= BulkSize-1 {
  457. mgo.UpdateBulkAll(db, c, arr...)
  458. arr = [][]map[string]interface{}{}
  459. }
  460. if len(arrEs) >= BulkSize-1 {
  461. tmps := arrEs
  462. elastic.BulkSave(index, itype, &tmps, true)
  463. if other_index != "" && other_itype != "" {
  464. bidding_other_es.BulkSave(other_index, other_itype, &tmps, true)
  465. }
  466. if len(multiIndex) == 2 {
  467. elastic.BulkSave(multiIndex[0], multiIndex[1], &tmps, true)
  468. }
  469. arrEs = []map[string]interface{}{}
  470. }
  471. UpdatesLock.Unlock()
  472. if n%100 == 0 {
  473. log.Println("current:", n)
  474. }
  475. tmp = make(map[string]interface{})
  476. }
  477. UpdatesLock.Lock()
  478. if len(arr) > 0 {
  479. mgo.UpdateBulkAll(db, c, arr...)
  480. }
  481. if len(arrEs) > 0 {
  482. tmps := arrEs
  483. elastic.BulkSave(index, itype, &tmps, true)
  484. if other_index != "" && other_itype != "" {
  485. bidding_other_es.BulkSave(other_index, other_itype, &tmps, true)
  486. }
  487. if len(multiIndex) == 2 {
  488. elastic.BulkSave(multiIndex[0], multiIndex[1], &tmps, true)
  489. }
  490. }
  491. UpdatesLock.Unlock()
  492. return n1, n2
  493. }
  494. var client *mu.Client
  495. var reg = regexp.MustCompile("^[0-9a-zA-Z-.]+$")
  496. var reg_space = regexp.MustCompile("(?ism)(<style.*?>.*?</style>)|([.#]?\\w{1,20}\\{.*?\\})|(<.*?>)|(\\\\t)+|\\t|( +)|( +)|(" + string(rune(160)) + "+)")
  497. var reg_row = regexp.MustCompile("(?i)<(tr|div|p)[^>]*?>|(\\n)+")
  498. var reg_dh = regexp.MustCompile("[,]+")
  499. var reg_newdb = regexp.MustCompile("([:,、:,。.;])[,]")
  500. var reg_no = regexp.MustCompile("^[0-9]*$")
  501. var reg_letter = regexp.MustCompile("[a-z]*")
  502. var MSG_SERVER = "123.56.236.148:7070"
  503. var DesLen = 120
  504. func inits() {
  505. ser := qutil.ObjToString(Sysconfig["msg_server"])
  506. if ser != "" {
  507. MSG_SERVER = ser
  508. }
  509. cf := &mu.ClientConfig{
  510. ClientName: "剑鱼抽关键词",
  511. EventHandler: func(p *mu.Packet) {},
  512. MsgServerAddr: MSG_SERVER,
  513. CanHandleEvents: []int{},
  514. OnConnectSuccess: func() {
  515. log.Println("c.")
  516. },
  517. ReadBufferSize: 10,
  518. WriteBufferSize: 10,
  519. }
  520. client, _ = mu.NewClient(cf)
  521. }
  522. //var clientlock = &sync.Mutex{}
  523. var keypool = make(chan bool, 1)
  524. func DealInfo(obj, update *map[string]interface{}) {
  525. defer qutil.Catch()
  526. if (*obj)["keywords"] != nil && (*obj)["description"] != nil {
  527. return
  528. } else {
  529. (*update)["keywords"] = ""
  530. (*update)["description"] = ""
  531. }
  532. title := qutil.ObjToString((*obj)["title"])
  533. var m [][]string
  534. select {
  535. case <-func() <-chan bool {
  536. ch := make(chan bool, 1)
  537. go func(chan bool) {
  538. select {
  539. case keypool <- true:
  540. defer func() {
  541. <-keypool
  542. }()
  543. ret, _ := client.Call("", mu.UUID(8), 4010, mu.SENDTO_TYPE_RAND_RECIVER, title, 1)
  544. json.Unmarshal(ret, &m)
  545. case <-time.After(10 * time.Millisecond):
  546. }
  547. ch <- true
  548. }(ch)
  549. return ch
  550. }():
  551. case <-time.After(40 * time.Millisecond):
  552. }
  553. arr := []string{}
  554. keyword := []string{}
  555. keywordnew := []string{}
  556. for _, tmp := range m {
  557. if reg.MatchString(tmp[0]) {
  558. arr = append(arr, tmp[0])
  559. } else {
  560. if len(arr) > 0 {
  561. str := strings.Join(arr, "")
  562. keyword = append(keyword, str)
  563. arr = []string{}
  564. }
  565. if len(tmp[0]) > 3 && (strings.HasPrefix(tmp[1], "n") || tmp[1] == "v" || tmp[1] == "vn" || strings.HasPrefix(tmp[1], "g")) {
  566. keyword = append(keyword, tmp[0])
  567. }
  568. }
  569. }
  570. for _, v := range keyword {
  571. v = reg_no.ReplaceAllString(v, "")
  572. if len(v) > 0 {
  573. keywordnew = append(keywordnew, v)
  574. }
  575. }
  576. keywords := strings.Join(keywordnew, ",")
  577. (*update)["keywords"] = keywords
  578. content := ""
  579. if (*obj)["detail_bak"] != nil {
  580. content = qutil.ObjToString((*obj)["detail_bak"])
  581. } else {
  582. content = qutil.ObjToString((*obj)["detail"])
  583. }
  584. //内容替换
  585. content = strings.Replace(content, " ", "", -1)
  586. content = reg_space.ReplaceAllString(content, "")
  587. content = reg_row.ReplaceAllString(content, ",")
  588. content = reg_dh.ReplaceAllString(content, ",")
  589. content = reg_newdb.ReplaceAllString(content, "$1")
  590. if strings.HasPrefix(content, ",") {
  591. content = content[1:]
  592. }
  593. //log.Println(content)
  594. tc := []rune(content)
  595. ltc := len(tc)
  596. description := content
  597. if ltc > DesLen {
  598. description = string(tc[:DesLen])
  599. }
  600. (*update)["description"] = description
  601. //保存到数据库
  602. return
  603. }