瀏覽代碼

新增项目改为新增物业项

mxs 1 年之前
父節點
當前提交
8d0f9bfddc
共有 3 個文件被更改,包括 60 次插入56 次删除
  1. 4 4
      data_project_wy/history.go
  2. 48 34
      data_project_wy/main.go
  3. 8 18
      data_project_wy/task.go

+ 4 - 4
data_project_wy/history.go

@@ -83,7 +83,7 @@ func HisTransactionDataFromBid() {
 	fmt.Println("结束")
 }
 
-// HisTransactionDataFromBid2 历史bidding(指定截止comeintime,新增项目)
+// HisTransactionDataFromBid2 历史bidding(指定截止comeintime,新增物业项目)
 func HisTransactionDataFromBid2() {
 	sess := MgoB.GetMgoConn()
 	defer MgoB.DestoryMongoConn(sess)
@@ -151,7 +151,7 @@ func HisTransactionDataFromBid2() {
 			//	return
 			//}
 			project_bidstatus := 4 //拟建
-			business_type := "新增项目"
+			business_type := "新增物业项目"
 			result := DealTransactionForBid(tmp, business_type, project_bidstatus)
 			lock.Lock()
 			if len(result) > 0 {
@@ -256,7 +256,7 @@ func HisTransactionDataFromProject() {
 func HisTransactionDataAddInformation() {
 	sess := MgoPro.GetMgoConn()
 	defer MgoPro.DestoryMongoConn(sess)
-	ch := make(chan bool, 5)
+	ch := make(chan bool, 1)
 	wg := &sync.WaitGroup{}
 	lock := &sync.Mutex{}
 	query := map[string]interface{}{
@@ -339,7 +339,7 @@ func HisTransactionDataAddInformation() {
 				tmp["starttime"] = info.Starttime
 				tmp["endtime"] = info.Endtime
 			} else {
-				if project_bidstatus := gconv.Int(tmp["project_bidstatus"]); project_bidstatus == 4 { //拟建新增项目,补充情报信息
+				if project_bidstatus := gconv.Int(tmp["project_bidstatus"]); project_bidstatus == 4 { //拟建新增物业项目,补充情报信息
 					//查询情报信息
 					id := gconv.String(tmp["info_id"])
 					info := FindInfomationData(id) //情报信息查询

+ 48 - 34
data_project_wy/main.go

@@ -2,7 +2,6 @@ package main
 
 import (
 	"fmt"
-	"github.com/gogf/gf/v2/util/gconv"
 	"github.com/robfig/cron"
 	"sync"
 )
@@ -34,20 +33,26 @@ func main() {
 func tmp() {
 	sess := MgoPro.GetMgoConn()
 	defer MgoPro.DestoryMongoConn(sess)
-	ch := make(chan bool, 20)
+	ch := make(chan bool, 1)
 	wg := &sync.WaitGroup{}
-	lock := &sync.Mutex{}
+	//lock := &sync.Mutex{}
 	query := map[string]interface{}{
 		//"project_bidstatus": 4,
 		//"_id": map[string]interface{}{
 		//	"$gte": mongodb.StringTOBsonId("66213b290f6ba3eb160617ad"),
 		//},
+		//"update_time": map[string]interface{}{
+		//	"$lt": 1714959573,
+		//},
+		//"_id": mongodb.StringTOBsonId("6630eae76f6c86a3962f3a07"),
+		"repeat": true,
 	}
-	count := MgoPro.Count("projectset_wy", query)
+	repeat := map[string]bool{}
+	count := MgoPro.Count("projectset_wy_back", query)
 	fmt.Println("count:", count)
-	it := sess.DB(MgoPro.DbName).C("projectset_wy").Find(&query).Iter()
+	it := sess.DB(MgoPro.DbName).C("projectset_wy_back").Find(&query).Iter()
 	n := 0
-	arr := [][]map[string]interface{}{}
+	//arr := []map[string]interface{}{}
 	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
 		ch <- true
 		wg.Add(1)
@@ -56,41 +61,50 @@ func tmp() {
 				<-ch
 				wg.Done()
 			}()
-			project_id := gconv.String(tmp["project_id"])
-			data, _ := MgoB.FindById("bidding", project_id, map[string]interface{}{"buyerclass": 1})
-			buyerclass := gconv.String((*data)["buyerclass"])
-			update := []map[string]interface{}{
-				{"_id": tmp["_id"]},
-			}
-			set := map[string]interface{}{
-				"buyerclass": buyerclass,
-			}
-			//info_id := gconv.String(tmp["info_id"])
-			//data, _ := MgoPro.FindById("projectset", info_id, map[string]interface{}{"bidstatus": 1})
-			//if gconv.String((*data)["bidstatus"]) == "拟建" {
-			//	set["project_bidstatus"] = 4
+			//update := []map[string]interface{}{}
+			//project_id := gconv.String(tmp["project_id"])
+			//lock.Lock()
+			//if !repeat[project_id] {
+			//	Es.DelById(Config.Es.Index, project_id)
+			//	CkhTool.Exec(context.Background(), "ALTER TABLE information.transaction_info_copy DELETE WHERE project_id = ?", project_id)
+			//	repeat[project_id] = true
+			//}
+			//lock.Unlock()
+			//err, result := Es.GetById(Config.Es.Index, project_id)
+			//Es.DelById()
+			//if err != nil || len(result) == 0 {
+			//	fmt.Println(project_id)
+			//	update = append(update, map[string]interface{}{"_id": tmp["_id"]})
+			//	update = append(update, map[string]interface{}{"$set": map[string]interface{}{"es": false}})
 			//} else {
-			//	return
+			//	if gconv.Int(result["project_bidstatus"]) != 0 {
+			//		fmt.Println("11", project_id)
+			//	}
 			//}
-			update = append(update, map[string]interface{}{"$set": set})
-			//
-			lock.Lock()
-			arr = append(arr, update)
-			if len(arr) > 500 {
-				MgoPro.UpdateBulk("projectset_wy", arr...)
-				arr = [][]map[string]interface{}{}
+			if MgoPro.Count("projectset_wy_back", map[string]interface{}{"project_id": tmp["project_id"]}) > 1 {
+				fmt.Println("project_id")
+				//update = append(update, map[string]interface{}{"_id": tmp["_id"]})
+				//update = append(update, map[string]interface{}{"$set": map[string]interface{}{"repeat": true}})
 			}
-			lock.Unlock()
+			//if len(update) > 0 {
+			//	lock.Lock()
+			//	arr = append(arr, update)
+			//	if len(arr) > 500 {
+			//		MgoPro.UpdateBulk("projectset_wy_back", arr...)
+			//		arr = [][]map[string]interface{}{}
+			//	}
+			//	lock.Unlock()
+			//}
 		}(tmp)
-		if n%10000 == 0 {
+		if n%1000 == 0 {
 			fmt.Println("current:", n)
 		}
 		tmp = map[string]interface{}{}
 	}
 	wg.Wait()
-	if len(arr) > 0 {
-		MgoPro.UpdateBulk("projectset_wy", arr...)
-		arr = [][]map[string]interface{}{}
-	}
-	fmt.Println("迁移结束...")
+	//if len(arr) > 0 {
+	//	MgoPro.SaveBulk("projectset_wy_tmp2", arr...)
+	//	arr = []map[string]interface{}{}
+	//}
+	fmt.Println("迁移结束...", len(repeat))
 }

+ 8 - 18
data_project_wy/task.go

@@ -127,7 +127,7 @@ func IncTransactionDataFromBid() {
 				if !strings.Contains(s_topscopeclass, "建筑工程") || strings.Contains(tag_topinformation, "物业") || strings.Contains(tag_topinformation_ai, "物业") {
 					return
 				}
-				business_type = "新增项目"
+				business_type = "新增物业项目"
 				project_bidstatus = 4
 			} else {
 				return
@@ -188,17 +188,10 @@ func DealTransactionForBid(tmp map[string]interface{}, business_type string, pro
 		subclass = gconv.Strings(tag_subinformation_ai)
 	}
 
-	//TODO 情报库信息(待补充)
-	info := Infomation{}
-	//if project_bidstatus == 4 {//补充情报信息
-	//	//bidId = "65fbf3f566cf0db42a2a99d2"
-	//	info = FindInfomationData(id) //情报信息查询
-	//	information_id = info.Id
-	//	starttime = info.Starttime
-	//	endtime = info.Endtime
-	//}
+	//情报信息查询
+	info := FindInfomationData(id)
 
-	//TODO 查询法人信息(待补充)
+	//法人信息
 	winners := []string{}
 	if winner != "" {
 		winners = strings.Split(winner, ",")
@@ -310,7 +303,7 @@ func IncTransactionDataFromPro() {
 			if len(result) > 0 {
 				count++
 				update := []map[string]interface{}{
-					{"project_id": tmp["_id"]},
+					{"project_id": mongodb.BsonIdToSId(tmp["_id"])},
 					{"$set": result},
 				}
 				arr = append(arr, update)
@@ -372,7 +365,7 @@ func DealTransactionForPro(data map[string]interface{}) map[string]interface{} {
 	bidstatus := gconv.String(data["bidstatus"])
 	if bidstatus == "中标" || bidstatus == "成交" || bidstatus == "合同" {
 		project_bidstatus = 1
-		business_type = "存量项目"
+		business_type = "合约到期项目"
 	} else if bidstatus == "废标" || bidstatus == "流标" {
 		project_bidstatus = 0
 	} else if bidstatus == "拟建" {
@@ -381,12 +374,9 @@ func DealTransactionForPro(data map[string]interface{}) map[string]interface{} {
 		business_type = "招标项目"
 	}
 	//查询情报信息
-	//bidId = "65fbf3f566cf0db42a2a99d2"
 	ids := gconv.Strings(data["ids"])
-	info := Infomation{}
-	//info := FindInfomationData(ids...) //情报信息查询
+	info := FindInfomationData(ids...) //情报信息查询
 
-	//TODO 查询法人库信息(待补充)
 	winners := []string{}
 	if winner != "" {
 		winners = strings.Split(winner, ",")
@@ -442,7 +432,7 @@ func IncTransactionDataMgoToCkhAndEs() {
 	fmt.Println("开始执行迁移...")
 	sess := MgoPro.GetMgoConn()
 	defer MgoPro.DestoryMongoConn(sess)
-	ch := make(chan bool, 2)
+	ch := make(chan bool, 1)
 	wg := &sync.WaitGroup{}
 	query := map[string]interface{}{
 		"update_time": map[string]interface{}{