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 := "
- 招标项目编号:
- e3100000151006395007
- 相关标段(包)编号:
- e3100000151006395007001
- 公示标题:
- 松江南站大型居住社区C18-26-01号地块动迁安置房(智能化工程)
- 公示内容:
- 第一中标候选人:上海浩臣机电科技有限公司,投标价格:1228.1990,得分/投票:合格;第二中标候选人:上海格瑞特机电系统工程有限公司,投标价格:1230.1015,得分/投票:合格;
- 公示发布媒介:
- http://zjw.sh.gov.cn
- 公示源URL:
https://ciac.zjw.sh.gov.cn/XMJYPTInterWeb/Tender/PrinttoPdf?zbgcid=65693
"
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{})
}
}