Procházet zdrojové kódy

调整~备份
1、支持空联系人~有效联系电话
2、增量支持业主单位信息
3、全量业主单位修复

zhengkun před 2 roky
rodič
revize
9ee29b1747

+ 19 - 19
fieldproject_medical/data_preparation/src/class/initdata.go

@@ -61,7 +61,7 @@ var (
 )
 
 func InitClass() {
-	initMgo()
+	//initMgo()
 	initMysql()
 	//initLocalData() //医院相关使用
 	//initVCode()
@@ -136,17 +136,17 @@ func initMysql() {
 	}
 
 	//临时
-	username = "zhengkun"
-	password = "Zk#20220824"
-	address = "127.0.0.1:15001"
-
-	MysqlMedicalTool = &Mysql{
-		Address:  address,
-		UserName: username,
-		PassWord: password,
-		DBName:   "medical_field_data",
-	}
-	MysqlMedicalTool.Init()
+	//username = "zhengkun"
+	//password = "Zk#20220824"
+	//address = "127.0.0.1:15001"
+
+	//MysqlMedicalTool = &Mysql{
+	//	Address:  address,
+	//	UserName: username,
+	//	PassWord: password,
+	//	DBName:   "medical_field_data",
+	//}
+	//MysqlMedicalTool.Init()
 
 	MysqlMedicalDevTool = &Mysql{
 		Address:  address,
@@ -156,13 +156,13 @@ func initMysql() {
 	}
 	MysqlMedicalDevTool.Init()
 
-	MysqlGlobalTool = &Mysql{
-		Address:  address,
-		UserName: username,
-		PassWord: password,
-		DBName:   "global_common_data",
-	}
-	MysqlGlobalTool.Init()
+	//MysqlGlobalTool = &Mysql{
+	//	Address:  address,
+	//	UserName: username,
+	//	PassWord: password,
+	//	DBName:   "global_common_data",
+	//}
+	//MysqlGlobalTool.Init()
 }
 
 //加载代码表~

+ 3 - 2
fieldproject_medical/data_preparation/src/main.go

@@ -10,7 +10,7 @@ import (
 )
 
 func init() {
-	class.IsLocal = true
+	//class.IsLocal = true
 	class.InitClass()
 }
 func main() {
@@ -23,7 +23,8 @@ func main() {
 	//other.TestNewRegionCode()
 	//other.TestSaveRegionCode()
 
-	relation_add.RelationIncreaseInfo()
+	//增量定时~更新新增关系数据
+	relation_add.RelationTimedTask()
 
 	time.Sleep(99999 * time.Hour)
 }

+ 6 - 10
fieldproject_medical/data_preparation/src/relation_add/relation_add.go

@@ -40,17 +40,17 @@ func initResetVar() {
 }
 
 //增量统计更新关系表
-func RelationIncreaseInfo() {
+func RelationIncreaseInfo(query map[string]interface{}) {
 	initResetVar()
 	initEquipmentDepartCode()
 	//取项目相关信息
-	project_ids := findUpdateProjectIds()
+	project_ids := findUpdateProjectIds(query)
 	project_infos := findUpdateProjectInfos(project_ids)
 	findUpdateWinnerIds(project_ids)
 	p_win_infos := findUpdateWinnerInfos()
 	log.Debug("关联中标标识~", len(up_winner_ids), "~信息~", len(up_winner_infos))
 	up_bw_index, up_bw_infos := findBuyerAndWinnerUniqueness(project_ids, project_infos, p_win_infos)
-	log.Debug("唯一性构建完毕~", len(up_bw_index))
+	log.Debug("关系唯一性~", len(up_bw_index), "~等级~", len(up_med_level), "~临时项目~", len(p_win_infos))
 	findUpdateAllProjectInfos()
 	log.Debug("关联项目标识~", len(up_project_ids), "~信息~", len(up_project_infos))
 
@@ -64,15 +64,11 @@ func RelationIncreaseInfo() {
 }
 
 //找项目标识
-func findUpdateProjectIds() []string {
+func findUpdateProjectIds(query map[string]interface{}) []string {
 	up_ids := []string{}
-	query := map[string]interface{}{
-		"updatetime": map[string]string{
-			"gte": "2022-11-08 15:02:28",
-		},
-	}
+	log.Debug("查询语句~", query)
 	datas := *class.MysqlMedicalDevTool.Find("dwd_f_yl_purchasing_baseinfo", query,
-		"projectid,jgtime", "id", 0, 100)
+		"projectid,jgtime", "id", -1, -1)
 	unique_id := map[string]string{}
 	for _, v := range datas {
 		jgtime := qu.ObjToString(v["jgtime"])

+ 36 - 0
fieldproject_medical/data_preparation/src/relation_add/relation_task.go

@@ -0,0 +1,36 @@
+package relation_add
+
+import (
+	"class"
+	"github.com/cron"
+	log "github.com/donnie4w/go-logger/logger"
+	"time"
+)
+
+//定时任务~
+func RelationTimedTask() {
+	c := cron.New()
+	c.AddFunc("0 0 1 ? * *", func() {
+		getQueryTimeSql()
+	})
+	c.Start()
+
+	getQueryTimeSql()
+}
+
+//获取查询语句
+func getQueryTimeSql() {
+	now := time.Now()
+	sql_time := time.Date(now.Year(), now.Month(), now.Day()-1, 0, 0, 0, 0, time.Local).Format(class.TimeLayout)
+	log.Debug("获取前一天凌晨的sql语句~~~", sql_time)
+
+	sql_time = "2022-11-08 15:02:28"
+	log.Debug("临时先确定一个时间点~", sql_time)
+
+	query := map[string]interface{}{
+		"updatetime": map[string]string{
+			"gte": sql_time,
+		},
+	}
+	RelationIncreaseInfo(query)
+}

+ 4 - 4
fieldproject_medical/data_preparation/src/relation_add/relation_update.go

@@ -47,10 +47,10 @@ func updateBuyerWinnerInfoRelation(bw_index []string, bw_infos map[string]map[st
 		//更新操作
 		if is_update && update_id != "" {
 			info["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(cl.TimeLayout)
-			//cl.MysqlMedicalDevTool.Update("", map[string]interface{}{"id": update_id}, info)
+			cl.MysqlMedicalDevTool.Update("dws_f_yl_buyer_winner_relation", map[string]interface{}{"id": update_id}, info)
 		} else {
 			info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(cl.TimeLayout)
-			//cl.InsertMedicalMysqlDevData("",win_info,info)
+			cl.InsertMedicalMysqlDevData("dws_f_yl_buyer_winner_relation", info, info)
 		}
 
 	}
@@ -132,10 +132,10 @@ func updateWinnerInfoRelation() {
 				}
 				if is_update && update_id != "" {
 					win_info["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(cl.TimeLayout)
-					//cl.MysqlMedicalDevTool.Update("", map[string]interface{}{"id": update_id}, win_info)
+					cl.MysqlMedicalDevTool.Update("dws_f_yl_winner_statistics", map[string]interface{}{"id": update_id}, win_info)
 				} else {
 					win_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(cl.TimeLayout)
-					//cl.InsertMedicalMysqlDevData("",win_info,win_info)
+					cl.InsertMedicalMysqlDevData("dws_f_yl_winner_statistics", win_info, win_info)
 				}
 			}
 		}

+ 2 - 1
fieldproject_medical/data_service/src/main.go

@@ -2,11 +2,12 @@ package main
 
 import (
 	log "github.com/donnie4w/go-logger/logger"
+	"udp"
 	ul "util"
 )
 
 func init() {
-	//udp.InitUdpMsg()
+	udp.InitUdpMsg()
 	ul.InitClass()
 	log.Debug("~~~~准备完毕~~~~")
 

+ 21 - 4
fieldproject_medical/data_subject/src/main.go

@@ -6,17 +6,18 @@ import (
 	"log"
 	qu "qfw/util"
 	"subject"
-	"subject_udp"
+	"subject_repair"
 	su "subject_util"
 )
 
 func init() {
-	su.IsLocal = true
+	//su.IsLocal = true
 	su.InitClass()
-	subject_udp.InitUdpMsg()
+	//subject_udp.InitUdpMsg()
 }
 
 func main() {
+	//全量数据准备
 	//subject.RunSubjectFullDataInfo("5a4af64340d2d9bbe8b0859d")
 	//subject_heal.HealSubjectInfoData()
 	//subject_sql.ExportSqlInfoData()
@@ -25,12 +26,28 @@ func main() {
 	//增量~更新数据
 	//subject.RunSubjectAddDataInfo("632892000000000000000000", "63346f800000000000000000")
 
-	//exportdata()
+	//修复全量业主单位数据
+	subject_repair.RunRepairFullOwnerContactInfo("63e06e5b779467cff153ad3b")
 
 	lock := make(chan bool)
 	<-lock
 }
 
+//以下调试方法~~~
+func test() {
+	aaa := qu.IntAll(subject.Str2DEC("0100"))
+	log.Println(aaa)
+
+	bbb := subject.ConvertToBin(9)
+	log.Println(bbb)
+
+	ccc := subject.SupplementIdentityType(bbb)
+	log.Println(ccc)
+
+	eee := subject.CalculateIdentityType("0010", "1000")
+	log.Println(eee)
+
+}
 func exportdata() {
 	dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", "root", "=PDT49#80Z!RVv52_z", "192.168.3.217", 4000, "global_common_data")
 	if !su.IsLocal {

+ 1 - 0
fieldproject_medical/data_subject/src/subject/info.go

@@ -11,5 +11,6 @@ type Contact struct {
 	Buyer       bool
 	Agency      bool
 	Winner      bool
+	Owner       bool
 	Publishtime int64
 }

+ 10 - 7
fieldproject_medical/data_subject/src/subject/method.go

@@ -35,10 +35,10 @@ func ConvertToBin(num int) string {
 func SupplementIdentityType(identity string) string {
 	new_str := identity
 	l := utf8.RuneCountInString(identity)
-	if l >= 3 {
-		return new_str[:3]
+	if l >= 4 {
+		return new_str[:4]
 	}
-	for i := 0; i < 3-l; i++ {
+	for i := 0; i < 4-l; i++ {
 		new_str = "0" + new_str
 	}
 	return new_str
@@ -49,16 +49,19 @@ func CalculateIdentityType(identity string, new_identity string) string {
 	a := identity[:1]
 	b := identity[1:2]
 	c := identity[2:3]
-	if new_identity == "001" {
+	d := identity[3:4]
+	if new_identity == "0001" {
+		d = "1"
+	} else if new_identity == "0010" {
 		c = "1"
-	} else if new_identity == "010" {
+	} else if new_identity == "0100" {
 		b = "1"
-	} else if new_identity == "100" {
+	} else if new_identity == "1000" {
 		a = "1"
 	} else {
 
 	}
-	return a + b + c
+	return a + b + c + d
 }
 
 //计算身份类型

+ 21 - 8
fieldproject_medical/data_subject/src/subject/subject_add.go

@@ -48,7 +48,8 @@ func RunSubjectAddDataInfo(gtid string, lteid string) {
 			}
 			if qu.ObjToString(tmp["buyer"]) == "" &&
 				qu.ObjToString(tmp["agency"]) == "" &&
-				qu.ObjToString(tmp["winner"]) == "" {
+				qu.ObjToString(tmp["winner"]) == "" &&
+				qu.ObjToString(tmp["owner"]) == "" {
 				return
 			}
 			dealWithAddSubjectInfo(tmp)
@@ -63,6 +64,7 @@ func dealWithAddSubjectInfo(tmp map[string]interface{}) {
 	buyer := qu.ObjToString(tmp["buyer"])
 	agency := qu.ObjToString(tmp["agency"])
 	winner := qu.ObjToString(tmp["winner"])
+	owner := qu.ObjToString(tmp["owner"])
 	s_winner := qu.ObjToString(tmp["s_winner"])
 	b_per := qu.ObjToString(tmp["buyerperson"])
 	b_tel := qu.ObjToString(tmp["buyertel"])
@@ -79,6 +81,12 @@ func dealWithAddSubjectInfo(tmp map[string]interface{}) {
 	if utf8.RuneCountInString(w_tel) > 60 {
 		w_tel = ""
 	}
+	o_per := qu.ObjToString(tmp["project_person"])
+	o_tel := qu.ObjToString(tmp["project_phone"])
+	if utf8.RuneCountInString(o_tel) > 60 {
+		o_tel = ""
+	}
+
 	buyerclass := qu.ObjToString(tmp["buyerclass"])
 	publishtime := qu.Int64All(tmp["publishtime"])
 	tmpid := su.BsonTOStringId(tmp["_id"])
@@ -86,23 +94,28 @@ func dealWithAddSubjectInfo(tmp map[string]interface{}) {
 
 	updateLock.Lock()
 	if buyer != "" && utf8.RuneCountInString(buyer) < 30 {
-		dealWithUpdateContact(buyer, buyerclass, &Contact{b_per, b_tel, true, false, false, publishtime}, "001", tmpid)
+		dealWithUpdateContact(buyer, buyerclass, &Contact{b_per, b_tel, true, false, false, false, publishtime}, "0001", tmpid)
 	}
 
 	//中标单位
 	for k, v := range winner_arr {
 		b := winner_bool[k]
-		c := Contact{"", "", false, false, true, publishtime}
+		c := Contact{"", "", false, false, true, false, publishtime}
 		if b {
 			c.Per = w_per
 			c.Tel = w_tel
 		}
-		dealWithUpdateContact(v, "", &c, "010", tmpid)
+		dealWithUpdateContact(v, "", &c, "0010", tmpid)
 	}
 
 	if agency != "" && utf8.RuneCountInString(agency) < 30 {
-		dealWithUpdateContact(agency, "", &Contact{a_per, a_tel, false, true, false, publishtime}, "100", tmpid)
+		dealWithUpdateContact(agency, "", &Contact{a_per, a_tel, false, true, false, false, publishtime}, "0100", tmpid)
 	}
+
+	if owner != "" && utf8.RuneCountInString(owner) < 30 {
+		dealWithUpdateContact(owner, "", &Contact{o_per, o_tel, false, false, false, true, publishtime}, "1000", tmpid)
+	}
+
 	updateLock.Unlock()
 }
 
@@ -136,8 +149,8 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
 		base_info["name_id"] = name_id
 		base_info["identity_type"] = qu.IntAll(Str2DEC(identity))
 		base_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-		//创建通讯录信息
-		if contact.Per != "" && contact.Tel != "" {
+		//创建通讯录信息 调整仅有联系电话即可
+		if contact.Tel != "" {
 			date := ""
 			if contact.Publishtime > 0 {
 				date = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
@@ -237,7 +250,7 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
 			}
 		}
 	}
-	if contact.Per != "" && contact.Tel != "" {
+	if contact.Tel != "" {
 		contact_datas := su.MysqlGlobalTool.Find(su.G_Units_Contact, map[string]interface{}{"name_id": name_id}, "", "", -1, -1)
 		isExists := false
 		for _, v := range *contact_datas {

+ 24 - 8
fieldproject_medical/data_subject/src/subject/subject_full.go

@@ -18,6 +18,7 @@ var BidFields = map[string]interface{}{
 	"buyer": 1, "agency": 1, "winner": 1, "s_winner": 1,
 	"agencytel": 1, "winnertel": 1, "buyertel": 1,
 	"agencyperson": 1, "winnerperson": 1, "buyerperson": 1,
+	"owner": 1, "project_person": 1, "project_phone": 1,
 }
 
 //全量数据准备
@@ -51,7 +52,8 @@ func RunSubjectFullDataInfo(lteid string) {
 			}
 			if qu.ObjToString(tmp["buyer"]) == "" &&
 				qu.ObjToString(tmp["agency"]) == "" &&
-				qu.ObjToString(tmp["winner"]) == "" {
+				qu.ObjToString(tmp["winner"]) == "" &&
+				qu.ObjToString(tmp["owner"]) == "" {
 				return
 			}
 			createBaseInfo(tmp) //处理数据
@@ -108,6 +110,7 @@ func createBaseInfo(tmp map[string]interface{}) {
 	buyer := qu.ObjToString(tmp["buyer"])
 	agency := qu.ObjToString(tmp["agency"])
 	winner := qu.ObjToString(tmp["winner"])
+	owner := qu.ObjToString(tmp["owner"])
 	b_per := qu.ObjToString(tmp["buyerperson"])
 	b_tel := qu.ObjToString(tmp["buyertel"])
 	if utf8.RuneCountInString(b_tel) > 60 {
@@ -123,20 +126,30 @@ func createBaseInfo(tmp map[string]interface{}) {
 	if utf8.RuneCountInString(w_tel) > 60 {
 		w_tel = ""
 	}
+
+	o_per := qu.ObjToString(tmp["project_person"])
+	o_tel := qu.ObjToString(tmp["project_phone"])
+	if utf8.RuneCountInString(o_tel) > 60 {
+		o_tel = ""
+	}
+
 	buyerclass := qu.ObjToString(tmp["buyerclass"])
 	publishtime := qu.Int64All(tmp["publishtime"])
 
 	dataLock.Lock()
 	if buyer != "" {
-		dealWithContact(buyer, buyerclass, &Contact{b_per, b_tel, true, false, false, publishtime}, "001")
+		dealWithContact(buyer, buyerclass, &Contact{b_per, b_tel, true, false, false, false, publishtime}, "0001")
 	}
-	if winner != "" {
-		//拆s_winner 需要拆
-		dealWithContact(winner, "", &Contact{w_per, w_tel, false, false, true, publishtime}, "010")
+	if winner != "" { //拆s_winner 需要拆
+		dealWithContact(winner, "", &Contact{w_per, w_tel, false, false, true, false, publishtime}, "0010")
 	}
 	if agency != "" {
-		dealWithContact(agency, "", &Contact{a_per, a_tel, false, true, false, publishtime}, "100")
+		dealWithContact(agency, "", &Contact{a_per, a_tel, false, true, false, false, publishtime}, "0100")
 	}
+	if owner != "" {
+		dealWithContact(owner, "", &Contact{o_per, o_tel, false, false, false, true, publishtime}, "1000")
+	}
+
 	dataLock.Unlock()
 }
 
@@ -149,7 +162,7 @@ func dealWithContact(name string, buyerclass string, contact *Contact, identity
 		if buyerclass != "" {
 			info.Buyerclass = buyerclass
 		}
-		if contact.Per != "" && contact.Tel != "" {
+		if contact.Tel != "" {
 			key := contact.Per + "~" + contact.Tel
 			old_contact := info.Contact[key]
 			if old_contact != nil {
@@ -162,6 +175,9 @@ func dealWithContact(name string, buyerclass string, contact *Contact, identity
 				if old_contact.Winner {
 					contact.Winner = true
 				}
+				if old_contact.Owner {
+					contact.Owner = true
+				}
 				if old_contact.Publishtime > contact.Publishtime {
 					contact.Publishtime = old_contact.Publishtime
 				}
@@ -170,7 +186,7 @@ func dealWithContact(name string, buyerclass string, contact *Contact, identity
 		}
 	} else {
 		data := map[string]*Contact{}
-		if contact.Per != "" && contact.Tel != "" {
+		if contact.Tel != "" {
 			key := contact.Per + "~" + contact.Tel
 			data[key] = contact
 		}

+ 111 - 152
fieldproject_medical/data_subject/src/subject_repair/repair.go

@@ -2,15 +2,11 @@ package subject_repair
 
 import (
 	log "github.com/donnie4w/go-logger/logger"
-	"github.com/uuid"
 	qu "qfw/util"
-	"strings"
 	"subject"
 	su "subject_util"
 	"sync"
-	"time"
 	"unicode/utf8"
-	ul "util"
 )
 
 var (
@@ -18,15 +14,22 @@ var (
 	numLock  sync.Mutex
 )
 
-var RepairFields = map[string]interface{}{
+var RepairContactFields = map[string]interface{}{
+	"extracttype": 1, "buyerclass": 1, "publishtime": 1,
+	"buyer": 1, "agency": 1, "winner": 1, "s_winner": 1,
+	"agencytel": 1, "winnertel": 1, "buyertel": 1,
+	"agencyperson": 1, "winnerperson": 1, "buyerperson": 1,
+}
+
+//主体owner~相关
+var RepairOwnerFields = map[string]interface{}{
 	"extracttype": 1, "publishtime": 1,
-	"winner": 1, "s_winner": 1,
-	"winnertel": 1, "winnerperson": 1,
+	"owner": 1, "project_person": 1, "project_phone": 1,
 }
 
-//全量数据准备
-func RunRepairFullDataInfo(lteid string) {
-	log.Debug("开始修复全量主体~~~")
+//修复全量业主单位信息
+func RunRepairFullOwnerContactInfo(lteid string) {
+	log.Debug("开始修复~业主单位~联系人数据~")
 	sess := su.SourceMgo.GetMgoConn()
 	defer su.SourceMgo.DestoryMongoConn(sess)
 	q := map[string]interface{}{
@@ -35,13 +38,13 @@ func RunRepairFullDataInfo(lteid string) {
 		},
 	}
 	log.Debug("查询语句 ~ ", q)
-	it := sess.DB(su.SourceMgo.DbName).C(su.S_Coll_Name).Find(&q).Sort("_id").Select(RepairFields).Iter()
-	pool := make(chan bool, 16)
+	it := sess.DB(su.SourceMgo.DbName).C(su.S_Coll_Name).Find(&q).Sort("_id").Select(RepairOwnerFields).Iter()
+	pool := make(chan bool, 6)
 	wg := &sync.WaitGroup{}
 	total, isok := 0, 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
-		if total%10000 == 0 {
-			log.Debug("cur index ", total)
+		if total%100000 == 0 {
+			log.Debug("cur index ", total, "~", isok)
 		}
 		pool <- true
 		wg.Add(1)
@@ -53,10 +56,66 @@ func RunRepairFullDataInfo(lteid string) {
 			if qu.IntAll(tmp["extracttype"]) != 1 {
 				return
 			}
-			if qu.ObjToString(tmp["winner"]) == "" && qu.ObjToString(tmp["s_winner"]) == "" {
+			if qu.ObjToString(tmp["owner"]) == "" {
+				return
+			}
+			createOwnerContactBaseInfo(tmp) //处理数据
+		}(tmp)
+		tmp = make(map[string]interface{})
+	}
+	wg.Wait()
+	log.Debug("is over ~ ", total, "~", isok)
+}
+
+func createOwnerContactBaseInfo(tmp map[string]interface{}) {
+	owner := qu.ObjToString(tmp["owner"])
+	o_per := qu.ObjToString(tmp["project_person"])
+	o_tel := qu.ObjToString(tmp["project_phone"])
+	if utf8.RuneCountInString(o_tel) > 60 {
+		o_tel = ""
+	}
+	publishtime := qu.Int64All(tmp["publishtime"])
+	tmpid := su.BsonTOStringId(tmp["_id"])
+	dataLock.Lock()
+	if owner != "" && utf8.RuneCountInString(owner) < 30 {
+		contact := &subject.Contact{o_per, o_tel, false, false, false, true, publishtime}
+		dealWithRepairContactModel(owner, "", contact, "1000", tmpid)
+	}
+	dataLock.Unlock()
+}
+
+/*
+
+//全量数据修复通讯录~支持空联系人
+func RunRepairFullEmptyPersonContactInfo(lteid string) {
+	log.Debug("开始修复全量空联系人数据~~~")
+	sess := su.SourceMgo.GetMgoConn()
+	defer su.SourceMgo.DestoryMongoConn(sess)
+	q := map[string]interface{}{
+		"_id": map[string]interface{}{
+			"$lte": su.StringTOBsonId(lteid),
+		},
+	}
+	log.Debug("查询语句 ~ ", q)
+	it := sess.DB(su.SourceMgo.DbName).C(su.S_Coll_Name).Find(&q).Sort("_id").Select(RepairContactFields).Iter()
+	pool := make(chan bool, 4)
+	wg := &sync.WaitGroup{}
+	total, isok := 0, 0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("cur index ", total, "~", isok)
+		}
+		pool <- true
+		wg.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-pool
+				wg.Done()
+			}()
+			if qu.IntAll(tmp["extracttype"]) != 1 {
 				return
 			}
-			b := createRepairBaseInfo(tmp) //处理数据
+			b := createRepairContactBaseInfo(tmp) //处理数据
 			if b {
 				numLock.Lock()
 				isok++
@@ -69,162 +128,62 @@ func RunRepairFullDataInfo(lteid string) {
 	log.Debug("is over ~ ", total, "~", isok)
 
 }
-
-func createRepairBaseInfo(tmp map[string]interface{}) bool {
+func createRepairContactBaseInfo(tmp map[string]interface{}) bool {
+	empty := false
+	buyer := qu.ObjToString(tmp["buyer"])
+	agency := qu.ObjToString(tmp["agency"])
 	winner := qu.ObjToString(tmp["winner"])
 	s_winner := qu.ObjToString(tmp["s_winner"])
+	b_per := qu.ObjToString(tmp["buyerperson"])
+	b_tel := qu.ObjToString(tmp["buyertel"])
+	if utf8.RuneCountInString(b_tel) > 60 {
+		b_tel = ""
+	}
+	a_per := qu.ObjToString(tmp["agencyperson"])
+	a_tel := qu.ObjToString(tmp["agencytel"])
+	if utf8.RuneCountInString(a_tel) > 60 {
+		a_tel = ""
+	}
 	w_per := qu.ObjToString(tmp["winnerperson"])
 	w_tel := qu.ObjToString(tmp["winnertel"])
-
 	if utf8.RuneCountInString(w_tel) > 60 {
 		w_tel = ""
 	}
+	buyerclass := qu.ObjToString(tmp["buyerclass"])
 	publishtime := qu.Int64All(tmp["publishtime"])
 	tmpid := su.BsonTOStringId(tmp["_id"])
 	winner_arr, winner_bool := subject.SegmentationEntName(winner, s_winner)
-	if len(winner_arr) <= 1 {
-		return false
+
+	dataLock.Lock()
+	if buyer != "" && utf8.RuneCountInString(buyer) < 30 {
+		if b_per == "" && b_tel != "" {
+			empty = true
+			dealWithRepairContactModel(buyer, buyerclass, &subject.Contact{b_per, b_tel, true, false, false, false, publishtime}, "001", tmpid)
+		}
 	}
-	dataLock.Lock() //处理
+	//中标单位
 	for k, v := range winner_arr {
 		b := winner_bool[k]
-		c := subject.Contact{"", "", false, false, true, publishtime}
+		c := subject.Contact{"", "", false, false, true, false, publishtime}
 		if b {
 			c.Per = w_per
 			c.Tel = w_tel
 		}
-		dealWithRepairSubjectContact(v, "", &c, "010", tmpid)
+		if c.Per == "" && c.Tel != "" {
+			empty = true
+			dealWithRepairContactModel(v, "", &c, "010", tmpid)
+		}
 	}
 
+	if agency != "" && utf8.RuneCountInString(agency) < 30 {
+		if a_per == "" && a_tel != "" {
+			empty = true
+			dealWithRepairContactModel(agency, "", &subject.Contact{a_per, a_tel, false, true, false, false, publishtime}, "100", tmpid)
+		}
+	}
 	dataLock.Unlock()
 
-	return true
+	return empty
 }
 
-func dealWithRepairSubjectContact(name string, buyerclass string, contact *subject.Contact, identity string, tmpid string) {
-	info := su.MysqlGlobalTool.FindOne(su.G_Units_Baseinfo, map[string]interface{}{"name": name}, "", "-id")
-	if info == nil { //新增主体信息~企业补充~年报补充
-		base_info := map[string]interface{}{}
-		base_info["name"] = name
-		qyxy_info := subject.CreateQyxyInfo(name)
-		//通讯录数据结构
-		contact_arr := []map[string]interface{}{}
-		area, city, district := "", "", ""
-		name_id := uuid.New().String()
-		name_id = strings.ReplaceAll(name_id, "-", "")
-		base_info["name_id"] = name_id
-		base_info["identity_type"] = 2
-		base_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-		//创建通讯录信息
-		if contact.Per != "" && contact.Tel != "" {
-			date := ""
-			if contact.Publishtime > 0 {
-				date = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
-			}
-			contact_arr = append(contact_arr, map[string]interface{}{
-				"person":   contact.Per,
-				"tel":      contact.Tel,
-				"date":     date,
-				"email":    "",
-				"type":     1,
-				"identity": base_info["identity_type"],
-			})
-		}
-		if len(qyxy_info) > 0 { //含企业信息
-			info_id := qu.ObjToString(qyxy_info["_id"])
-			base_info["company_id"] = info_id
-			address := qu.ObjToString(qyxy_info["company_address"])
-			if utf8.RuneCountInString(address) > 300 {
-				address = ""
-			}
-			base_info["address"] = address
-			area = qu.ObjToString(qyxy_info["company_area"])
-			city = qu.ObjToString(qyxy_info["company_city"])
-			district = qu.ObjToString(qyxy_info["company_district"])
-			legal_person := qu.ObjToString(qyxy_info["legal_person"])
-			if legal_person != "" { //年报信息
-				subject.CreateAnnualInfo(info_id, legal_person, &contact_arr)
-			}
-		}
-		base_info["area_code"], base_info["city_code"], base_info["district_code"] = subject.CalculateRegionCode(area, city, district)
-		//新增主体信息表
-		b := su.InsertMysqlData(su.G_Units_Baseinfo, base_info, tmpid)
-		if b > 0 { //存通讯录
-			for _, v := range contact_arr {
-				info_book := map[string]interface{}{}
-				info_book["name_id"] = name_id
-				info_book["contact_name"] = qu.ObjToString(v["person"])
-				info_book["contact_tel"] = qu.ObjToString(v["tel"])
-				info_book["contact_email"] = qu.ObjToString(v["email"])
-				date := qu.ObjToString(v["date"])
-				if date != "" {
-					info_book["publishtime"] = date
-				}
-				info_book["source_type"] = qu.IntAll(v["type"])
-				info_book["identity_type"] = qu.IntAll(v["identity"])
-				info_book["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-				su.InsertMysqlData(su.G_Units_Contact, info_book, tmpid)
-			}
-		}
-		return
-	}
-	//更新~主体基本信息表
-	name_id := qu.ObjToString((*info)["name_id"])
-	update_info := map[string]interface{}{}
-	info_identity := subject.ConvertToBin(subject.Str2DEC(qu.ObjToString((*info)["identity_type"])))
-	info_identity = subject.SupplementIdentityType(info_identity)
-	if info_identity != identity {
-		new_identity := subject.CalculateIdentityType(info_identity, identity)
-		if new_identity != info_identity {
-			update_info["identity_type"] = qu.IntAll(subject.Str2DEC(new_identity))
-			update_info["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-			su.MysqlGlobalTool.Update(su.G_Units_Baseinfo, map[string]interface{}{"name_id": name_id}, update_info)
-		}
-	}
-	if contact.Per != "" && contact.Tel != "" {
-		contact_datas := su.MysqlGlobalTool.Find(su.G_Units_Contact, map[string]interface{}{"name_id": name_id}, "", "", -1, -1)
-		isExists := false
-		for _, v := range *contact_datas {
-			update_id := qu.IntAll(v["id"])
-			person := qu.ObjToString(v["contact_name"])
-			tel := qu.ObjToString(v["contact_tel"])
-			pt_str := qu.ObjToString(v["publishtime"])
-			pt := int64(0)
-			if pt_str != "" {
-				t, _ := time.ParseInLocation(su.TimeLayout, pt_str, time.Local)
-				pt = t.Unix()
-			}
-			if person+"~"+tel == contact.Per+"~"+contact.Tel {
-				isExists = true
-				old_contact_identity := subject.ConvertToBin(subject.Str2DEC(qu.ObjToString(v["identity_type"])))
-				old_contact_identity = subject.SupplementIdentityType(old_contact_identity)
-				if old_contact_identity != identity || qu.IntAll(v["source_type"]) == 2 || (contact.Publishtime > pt && contact.Publishtime > 0) {
-					identity = subject.CalculateIdentityType(old_contact_identity, identity)
-					update_contact := map[string]interface{}{}
-					update_contact["source_type"] = 1
-					update_contact["identity_type"] = qu.IntAll(subject.Str2DEC(identity))
-					update_contact["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-					if contact.Publishtime > pt {
-						update_contact["publishtime"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
-					}
-					//更新通讯录
-					su.MysqlGlobalTool.Update(su.G_Units_Contact, map[string]interface{}{"id": update_id}, update_contact)
-				}
-				break
-			}
-		}
-		if !isExists {
-			add_contact := map[string]interface{}{}
-			add_contact["name_id"] = name_id
-			add_contact["contact_name"] = contact.Per
-			add_contact["contact_tel"] = contact.Tel
-			add_contact["contact_email"] = ""
-			add_contact["source_type"] = 1
-			add_contact["publishtime"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
-			add_contact["identity_type"] = 2
-			add_contact["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
-			//新增~通讯录表
-			su.InsertMysqlData(su.G_Units_Contact, add_contact, tmpid)
-		}
-	}
-}
+*/

+ 221 - 0
fieldproject_medical/data_subject/src/subject_repair/repair_bf.go

@@ -0,0 +1,221 @@
+package subject_repair
+
+import (
+	log "github.com/donnie4w/go-logger/logger"
+	"github.com/uuid"
+	qu "qfw/util"
+	"strings"
+	"subject"
+	su "subject_util"
+	"sync"
+	"time"
+	"unicode/utf8"
+	ul "util"
+)
+
+var RepairFields = map[string]interface{}{
+	"extracttype": 1, "publishtime": 1,
+	"winner": 1, "s_winner": 1,
+	"winnertel": 1, "winnerperson": 1,
+}
+
+//全量数据修复s_winner主体以及通讯录
+func RunRepairFullWinnerDataInfo(lteid string) {
+	log.Debug("开始修复全量主体~~~")
+	sess := su.SourceMgo.GetMgoConn()
+	defer su.SourceMgo.DestoryMongoConn(sess)
+	q := map[string]interface{}{
+		"_id": map[string]interface{}{
+			"$lte": su.StringTOBsonId(lteid),
+		},
+	}
+	log.Debug("查询语句 ~ ", q)
+	it := sess.DB(su.SourceMgo.DbName).C(su.S_Coll_Name).Find(&q).Sort("_id").Select(RepairFields).Iter()
+	pool := make(chan bool, 8)
+	wg := &sync.WaitGroup{}
+	total, isok := 0, 0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		if total%10000 == 0 {
+			log.Debug("cur index ", total, "~", isok)
+		}
+		pool <- true
+		wg.Add(1)
+		go func(tmp map[string]interface{}) {
+			defer func() {
+				<-pool
+				wg.Done()
+			}()
+			if qu.IntAll(tmp["extracttype"]) != 1 {
+				return
+			}
+			if qu.ObjToString(tmp["winner"]) == "" && qu.ObjToString(tmp["s_winner"]) == "" {
+				return
+			}
+			b := createRepairWinnerBaseInfo(tmp) //处理数据
+			if b {
+				numLock.Lock()
+				isok++
+				numLock.Unlock()
+			}
+		}(tmp)
+		tmp = make(map[string]interface{})
+	}
+	wg.Wait()
+	log.Debug("is over ~ ", total, "~", isok)
+
+}
+func createRepairWinnerBaseInfo(tmp map[string]interface{}) bool {
+	winner := qu.ObjToString(tmp["winner"])
+	s_winner := qu.ObjToString(tmp["s_winner"])
+	w_per := qu.ObjToString(tmp["winnerperson"])
+	w_tel := qu.ObjToString(tmp["winnertel"])
+
+	if utf8.RuneCountInString(w_tel) > 60 {
+		w_tel = ""
+	}
+	publishtime := qu.Int64All(tmp["publishtime"])
+	tmpid := su.BsonTOStringId(tmp["_id"])
+	winner_arr, winner_bool := subject.SegmentationEntName(winner, s_winner)
+	if len(winner_arr) <= 1 {
+		return false
+	}
+	dataLock.Lock() //处理
+	for k, v := range winner_arr {
+		b := winner_bool[k]
+		c := subject.Contact{"", "", false, false, true, false, publishtime}
+		if b {
+			c.Per = w_per
+			c.Tel = w_tel
+		}
+		dealWithRepairWinnerContact(v, "", &c, "010", tmpid)
+	}
+	dataLock.Unlock()
+	return true
+}
+func dealWithRepairWinnerContact(name string, buyerclass string, contact *subject.Contact, identity string, tmpid string) {
+	info := su.MysqlGlobalTool.FindOne(su.G_Units_Baseinfo, map[string]interface{}{"name": name}, "", "-id")
+	if info == nil { //新增主体信息~企业补充~年报补充
+		base_info := map[string]interface{}{}
+		base_info["name"] = name
+		qyxy_info := subject.CreateQyxyInfo(name)
+		//通讯录数据结构
+		contact_arr := []map[string]interface{}{}
+		area, city, district := "", "", ""
+		name_id := uuid.New().String()
+		name_id = strings.ReplaceAll(name_id, "-", "")
+		base_info["name_id"] = name_id
+		base_info["identity_type"] = 2
+		base_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+		//创建通讯录信息
+		if contact.Tel != "" {
+			date := ""
+			if contact.Publishtime > 0 {
+				date = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
+			}
+			contact_arr = append(contact_arr, map[string]interface{}{
+				"person":   contact.Per,
+				"tel":      contact.Tel,
+				"date":     date,
+				"email":    "",
+				"type":     1,
+				"identity": base_info["identity_type"],
+			})
+		}
+		if len(qyxy_info) > 0 { //含企业信息
+			info_id := qu.ObjToString(qyxy_info["_id"])
+			base_info["company_id"] = info_id
+			address := qu.ObjToString(qyxy_info["company_address"])
+			if utf8.RuneCountInString(address) > 300 {
+				address = ""
+			}
+			base_info["address"] = address
+			area = qu.ObjToString(qyxy_info["company_area"])
+			city = qu.ObjToString(qyxy_info["company_city"])
+			district = qu.ObjToString(qyxy_info["company_district"])
+			legal_person := qu.ObjToString(qyxy_info["legal_person"])
+			if legal_person != "" { //年报信息
+				subject.CreateAnnualInfo(info_id, legal_person, &contact_arr)
+			}
+		}
+		base_info["area_code"], base_info["city_code"], base_info["district_code"] = subject.CalculateRegionCode(area, city, district)
+		//新增主体信息表
+		b := su.InsertMysqlData(su.G_Units_Baseinfo, base_info, tmpid)
+		if b > 0 { //存通讯录
+			for _, v := range contact_arr {
+				info_book := map[string]interface{}{}
+				info_book["name_id"] = name_id
+				info_book["contact_name"] = qu.ObjToString(v["person"])
+				info_book["contact_tel"] = qu.ObjToString(v["tel"])
+				info_book["contact_email"] = qu.ObjToString(v["email"])
+				date := qu.ObjToString(v["date"])
+				if date != "" {
+					info_book["publishtime"] = date
+				}
+				info_book["source_type"] = qu.IntAll(v["type"])
+				info_book["identity_type"] = qu.IntAll(v["identity"])
+				info_book["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+				su.InsertMysqlData(su.G_Units_Contact, info_book, tmpid)
+			}
+		}
+		return
+	}
+	//更新~主体基本信息表
+	name_id := qu.ObjToString((*info)["name_id"])
+	update_info := map[string]interface{}{}
+	info_identity := subject.ConvertToBin(subject.Str2DEC(qu.ObjToString((*info)["identity_type"])))
+	info_identity = subject.SupplementIdentityType(info_identity)
+	if info_identity != identity {
+		new_identity := subject.CalculateIdentityType(info_identity, identity)
+		if new_identity != info_identity {
+			update_info["identity_type"] = qu.IntAll(subject.Str2DEC(new_identity))
+			update_info["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+			su.MysqlGlobalTool.Update(su.G_Units_Baseinfo, map[string]interface{}{"name_id": name_id}, update_info)
+		}
+	}
+	if contact.Tel != "" {
+		contact_datas := su.MysqlGlobalTool.Find(su.G_Units_Contact, map[string]interface{}{"name_id": name_id}, "", "", -1, -1)
+		isExists := false
+		for _, v := range *contact_datas {
+			update_id := qu.IntAll(v["id"])
+			person := qu.ObjToString(v["contact_name"])
+			tel := qu.ObjToString(v["contact_tel"])
+			pt_str := qu.ObjToString(v["publishtime"])
+			pt := int64(0)
+			if pt_str != "" {
+				t, _ := time.ParseInLocation(su.TimeLayout, pt_str, time.Local)
+				pt = t.Unix()
+			}
+			if person+"~"+tel == contact.Per+"~"+contact.Tel {
+				isExists = true
+				old_contact_identity := subject.ConvertToBin(subject.Str2DEC(qu.ObjToString(v["identity_type"])))
+				old_contact_identity = subject.SupplementIdentityType(old_contact_identity)
+				if old_contact_identity != identity || qu.IntAll(v["source_type"]) == 2 || (contact.Publishtime > pt && contact.Publishtime > 0) {
+					identity = subject.CalculateIdentityType(old_contact_identity, identity)
+					update_contact := map[string]interface{}{}
+					update_contact["source_type"] = 1
+					update_contact["identity_type"] = qu.IntAll(subject.Str2DEC(identity))
+					update_contact["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+					if contact.Publishtime > pt {
+						update_contact["publishtime"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
+					}
+					//更新通讯录
+					su.MysqlGlobalTool.Update(su.G_Units_Contact, map[string]interface{}{"id": update_id}, update_contact)
+				}
+				break
+			}
+		}
+		if !isExists {
+			add_contact := map[string]interface{}{}
+			add_contact["name_id"] = name_id
+			add_contact["contact_name"] = contact.Per
+			add_contact["contact_tel"] = contact.Tel
+			add_contact["contact_email"] = ""
+			add_contact["source_type"] = 1
+			add_contact["publishtime"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
+			add_contact["identity_type"] = 2
+			add_contact["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+			//新增~通讯录表
+			su.InsertMysqlData(su.G_Units_Contact, add_contact, tmpid)
+		}
+	}
+}

+ 194 - 0
fieldproject_medical/data_subject/src/subject_repair/repair_way.go

@@ -0,0 +1,194 @@
+package subject_repair
+
+import (
+	"github.com/uuid"
+	qu "qfw/util"
+	"strings"
+	"subject"
+	su "subject_util"
+	"time"
+	"unicode/utf8"
+	ul "util"
+)
+
+//处理数据~保存联系人~主体等方法
+func dealWithRepairContactModel(name string, buyerclass string, contact *subject.Contact, identity string, tmpid string) {
+	info := su.MysqlGlobalTool.FindOne(su.G_Units_Baseinfo, map[string]interface{}{"name": name}, "", "-id")
+	isNewEnt := false
+	isNewEntInfo := map[string]interface{}{}
+	if info == nil {
+	} else { //判断企业库最新的company_id是否与当前保持一致
+		qyxy_info := subject.CreateQyxyInfo(name)
+		if len(qyxy_info) > 0 {
+			new_company_id := qu.ObjToString(qyxy_info["_id"])
+			old_company_id := qu.ObjToString((*info)["company_id"])
+			if old_company_id != "" && new_company_id != "" && old_company_id != new_company_id {
+				isNewEnt = true
+				isNewEntInfo["name"] = name
+				isNewEntInfo["name_id"] = qu.ObjToString((*info)["name_id"])
+				isNewEntInfo["company_id"] = old_company_id
+			}
+		}
+	}
+	if info == nil || isNewEnt { //新增主体信息~企业补充~年报补充
+		base_info := map[string]interface{}{}
+		base_info["name"] = name
+		qyxy_info := subject.CreateQyxyInfo(name)
+		//通讯录数据结构
+		contact_arr := []map[string]interface{}{}
+		area, city, district := "", "", ""
+		name_id := uuid.New().String()
+		name_id = strings.ReplaceAll(name_id, "-", "")
+		base_info["name_id"] = name_id
+		base_info["identity_type"] = qu.IntAll(subject.Str2DEC(identity))
+		base_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+		//创建通讯录信息 调整仅有联系电话即可
+		if contact.Tel != "" {
+			date := ""
+			if contact.Publishtime > 0 {
+				date = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
+			}
+			contact_arr = append(contact_arr, map[string]interface{}{
+				"person":   contact.Per,
+				"tel":      contact.Tel,
+				"date":     date,
+				"email":    "",
+				"type":     1,
+				"identity": base_info["identity_type"],
+			})
+		}
+		if len(qyxy_info) > 0 { //含企业信息
+			info_id := qu.ObjToString(qyxy_info["_id"])
+			base_info["company_id"] = info_id
+			address := qu.ObjToString(qyxy_info["company_address"])
+			if utf8.RuneCountInString(address) > 300 {
+				address = ""
+			}
+			base_info["address"] = address
+			area = qu.ObjToString(qyxy_info["company_area"])
+			city = qu.ObjToString(qyxy_info["company_city"])
+			district = qu.ObjToString(qyxy_info["company_district"])
+			legal_person := qu.ObjToString(qyxy_info["legal_person"])
+			if legal_person != "" { //年报信息
+				subject.CreateAnnualInfo(info_id, legal_person, &contact_arr)
+			}
+		}
+		base_info["area_code"], base_info["city_code"], base_info["district_code"] = subject.CalculateRegionCode(area, city, district)
+		//新增主体信息表
+		b := su.InsertMysqlData(su.G_Units_Baseinfo, base_info, tmpid)
+		if b > 0 { //存通讯录
+			for _, v := range contact_arr {
+				info_book := map[string]interface{}{}
+				info_book["name_id"] = name_id
+				info_book["contact_name"] = qu.ObjToString(v["person"])
+				info_book["contact_tel"] = qu.ObjToString(v["tel"])
+				info_book["contact_email"] = qu.ObjToString(v["email"])
+				date := qu.ObjToString(v["date"])
+				if date != "" {
+					info_book["publishtime"] = date
+				}
+				info_book["source_type"] = qu.IntAll(v["type"])
+				info_book["identity_type"] = qu.IntAll(v["identity"])
+				info_book["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+				su.InsertMysqlData(su.G_Units_Contact, info_book, tmpid)
+			}
+			//存主体标签记录~暂时只进采购单位的主体
+			if qu.IntAll(identity)%10 == 1 {
+				info_tag := map[string]interface{}{}
+				info_tag["name_id"] = name_id
+				info_tag["labelcode"] = "1"
+				labelvalues := "00"
+				if su.BuyerClassData[buyerclass] != "" {
+					labelvalues = su.BuyerClassData[buyerclass]
+				}
+				info_tag["labelvalues"] = labelvalues //代码表
+				info_tag["identity_type"] = 1
+				info_tag["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+				su.InsertMysqlData(su.G_Units_Tags, info_tag, tmpid)
+			}
+			if isNewEnt {
+				isNewEntInfo["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+				su.InsertMysqlData(su.G_Units_Warning, isNewEntInfo, tmpid)
+			}
+		}
+		return
+	}
+	//更新~主体基本信息表
+	name_id := qu.ObjToString((*info)["name_id"])
+	update_info := map[string]interface{}{}
+	info_identity := subject.ConvertToBin(subject.Str2DEC(qu.ObjToString((*info)["identity_type"])))
+	info_identity = subject.SupplementIdentityType(info_identity)
+	if info_identity != identity {
+		new_identity := subject.CalculateIdentityType(info_identity, identity)
+		if new_identity != info_identity {
+			update_info["identity_type"] = qu.IntAll(subject.Str2DEC(new_identity))
+			update_info["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+			su.MysqlGlobalTool.Update(su.G_Units_Baseinfo, map[string]interface{}{"name_id": name_id}, update_info)
+		}
+	}
+	//更新~主体标签记录表
+	if buyerclass != "" && contact.Buyer {
+		info_tag := su.MysqlGlobalTool.FindOne(su.G_Units_Tags, map[string]interface{}{"name_id": name_id}, "", "")
+		if info_tag != nil {
+			update_tag := map[string]interface{}{}
+			cur_code := "00"
+			if su.BuyerClassData[buyerclass] != "" {
+				cur_code = su.BuyerClassData[buyerclass]
+			}
+			old_code := qu.ObjToString((*info_tag)["labelvalues"])
+			if cur_code != old_code {
+				update_tag["labelvalues"] = cur_code
+				update_tag["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+				su.MysqlGlobalTool.Update(su.G_Units_Tags, map[string]interface{}{"name_id": name_id}, update_tag)
+			}
+		}
+	}
+	if contact.Tel != "" {
+		contact_datas := su.MysqlGlobalTool.Find(su.G_Units_Contact, map[string]interface{}{"name_id": name_id}, "", "", -1, -1)
+		isExists := false
+		for _, v := range *contact_datas {
+			update_id := qu.IntAll(v["id"])
+			person := qu.ObjToString(v["contact_name"])
+			tel := qu.ObjToString(v["contact_tel"])
+			pt_str := qu.ObjToString(v["publishtime"])
+			pt := int64(0)
+			if pt_str != "" {
+				t, _ := time.ParseInLocation(su.TimeLayout, pt_str, time.Local)
+				pt = t.Unix()
+			}
+			if person+"~"+tel == contact.Per+"~"+contact.Tel {
+				isExists = true
+				old_contact_identity := subject.ConvertToBin(subject.Str2DEC(qu.ObjToString(v["identity_type"])))
+				old_contact_identity = subject.SupplementIdentityType(old_contact_identity)
+				if old_contact_identity != identity || qu.IntAll(v["source_type"]) == 2 || (contact.Publishtime > pt && contact.Publishtime > 0) {
+					new_identity := subject.CalculateIdentityType(old_contact_identity, identity)
+					update_contact := map[string]interface{}{}
+					update_contact["source_type"] = 1
+					update_contact["identity_type"] = qu.IntAll(subject.Str2DEC(new_identity))
+					update_contact["updatetime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+					if contact.Publishtime > pt {
+						update_contact["publishtime"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
+					}
+					//更新通讯录
+					su.MysqlGlobalTool.Update(su.G_Units_Contact, map[string]interface{}{"id": update_id}, update_contact)
+				}
+				break
+			}
+		}
+		if !isExists {
+			add_contact := map[string]interface{}{}
+			add_contact["name_id"] = name_id
+			add_contact["contact_name"] = contact.Per
+			add_contact["contact_tel"] = contact.Tel
+			add_contact["contact_email"] = ""
+			add_contact["source_type"] = 1
+			if contact.Publishtime > 0 {
+				add_contact["publishtime"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
+			}
+			add_contact["identity_type"] = qu.IntAll(subject.Str2DEC(identity))
+			add_contact["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
+			//新增~通讯录表
+			su.InsertMysqlData(su.G_Units_Contact, add_contact, tmpid)
+		}
+	}
+}