123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package main
- import (
- "fmt"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
- "log"
- "strconv"
- "strings"
- "sync"
- "testing"
- "time"
- )
- func TestTime(T *testing.T) {
- now := time.Now()
- year := strconv.Itoa(now.Year())
- month := now.Month()
- quarter := strconv.Itoa((int(now.Month())-1)/3 + 1)
- monthStringTwoDigits := fmt.Sprintf("%02d", int(now.Month()))
- fmt.Println(year, month.String(), quarter)
- fmt.Println(monthStringTwoDigits)
- }
- func TestSendAi(T *testing.T) {
- title := "松江南站大型居住社区C18-26-01号地块动迁安置房(智能化工程)"
- detail := "<br><ul ><li>招标项目编号:</li><li >e3100000151006395007</li></ul><ul ><li>相关标段(包)编号:</li><li >e3100000151006395007001</li></ul><ul ><li>公示标题:</li><li >松江南站大型居住社区C18-26-01号地块动迁安置房(智能化工程)</li></ul><ul ><li>公示内容:</li><li >第一中标候选人:上海浩臣机电科技有限公司,投标价格:1228.1990,得分/投票:合格;第二中标候选人:上海格瑞特机电系统工程有限公司,投标价格:1230.1015,得分/投票:合格;</li></ul><ul ><li>公示发布时间:</li><li >2024-01-03</li></ul><ul ><li>公示发布媒介:</li><li >http://zjw.sh.gov.cn</li></ul><ul ><li>公示源URL:</li><li ><br>https://ciac.zjw.sh.gov.cn/XMJYPTInterWeb/Tender/PrinttoPdf?zbgcid=65693</li></ul><ul ><li>公示类型:</li><li >正常</li></ul><ul ><li>公示开始时间:</li><li >2024-01-03</li></ul><ul ><li>公示结束时间:</li><li >2024-01-05</li></ul>"
- data := map[string]interface{}{
- "title": title,
- "detail": detail,
- }
- reqData := map[string]interface{}{
- "texts": []interface{}{data},
- }
- res := SendAi(reqData)
- fmt.Println("len res", len(res))
- fmt.Println("aaaa")
- if len(res) > 0 {
- resa := res["result"]
- fmt.Println(resa)
- if dataa, ok := resa.([]string); ok {
- fmt.Println(222)
- da := dataa[0]
- if len(da) > 0 {
- cs := strings.Split(da, "-")
- fmt.Println("toptype", cs[0])
- fmt.Println("subtype", cs[1])
- }
- }
- }
- fmt.Println("res", res)
- }
- func TestCh(t *testing.T) {
- num := 0
- var wg sync.WaitGroup
- for i := 0; i < 10; i++ {
- wg.Add(1)
- go func(num *int) {
- defer wg.Done()
- addNum(num)
- }(&num)
- }
- wg.Wait()
- fmt.Println(num)
- }
- func addNum(num *int) {
- *num++
- }
- func TestUpdateBidding(t *testing.T) {
- Mgo := &mongodb.MongodbSim{
- //MongodbAddr: "172.17.189.140:27080",
- MongodbAddr: "127.0.0.1:27083",
- Size: 10,
- DbName: "qfw",
- UserName: "SJZY_RWbid_ES",
- Password: "SJZY@B4i4D5e6S",
- Direct: true,
- }
- Mgo.InitPool()
- Mgo2 := &mongodb.MongodbSim{
- //MongodbAddr: "172.17.189.140:27080",
- MongodbAddr: "127.0.0.1:27017",
- Size: 10,
- DbName: "wcc",
- UserName: "",
- Password: "",
- //Direct: true,
- }
- Mgo2.InitPool()
- sess := Mgo2.GetMgoConn()
- defer Mgo2.DestoryMongoConn(sess)
- query := sess.DB("wcc").C("wcc_bidding_20240103_subtype_exists").Find(nil).Select(nil).Iter()
- count := 0
- for tmp := make(map[string]interface{}); query.Next(tmp); count++ {
- if count%10000 == 0 {
- log.Println("current:", count)
- }
- id := mongodb.BsonIdToSId(tmp["_id"])
- bidding, _ := Mgo.FindById("bidding", id, nil)
- update := map[string]interface{}{
- "toptype": (*bidding)["toptype"],
- "subtype": (*bidding)["subtype"],
- "infoformat": (*bidding)["infoformat"],
- }
- Mgo2.UpdateById("wcc_bidding_20240103_subtype_exists", id, map[string]interface{}{"$set": update})
- tmp = make(map[string]interface{})
- }
- }
|