|
@@ -16,9 +16,10 @@ var (
|
|
updateLock sync.Mutex
|
|
updateLock sync.Mutex
|
|
)
|
|
)
|
|
|
|
|
|
-//正产增量主体数据服务
|
|
|
|
|
|
+// 正产增量主体数据服务
|
|
func RunSubjectAddDataInfo(gtid string, lteid string) {
|
|
func RunSubjectAddDataInfo(gtid string, lteid string) {
|
|
log.Debug("增量~~~")
|
|
log.Debug("增量~~~")
|
|
|
|
+ SeoUnique = map[string]string{}
|
|
sess := su.SourceMgo.GetMgoConn()
|
|
sess := su.SourceMgo.GetMgoConn()
|
|
defer su.SourceMgo.DestoryMongoConn(sess)
|
|
defer su.SourceMgo.DestoryMongoConn(sess)
|
|
q := map[string]interface{}{
|
|
q := map[string]interface{}{
|
|
@@ -96,7 +97,6 @@ func dealWithAddSubjectInfo(tmp map[string]interface{}) {
|
|
if buyer != "" && utf8.RuneCountInString(buyer) < 30 {
|
|
if buyer != "" && utf8.RuneCountInString(buyer) < 30 {
|
|
dealWithUpdateContact(buyer, buyerclass, &Contact{b_per, b_tel, true, false, false, false, publishtime}, "0001", tmpid)
|
|
dealWithUpdateContact(buyer, buyerclass, &Contact{b_per, b_tel, true, false, false, false, publishtime}, "0001", tmpid)
|
|
}
|
|
}
|
|
-
|
|
|
|
//中标单位
|
|
//中标单位
|
|
for k, v := range winner_arr {
|
|
for k, v := range winner_arr {
|
|
b := winner_bool[k]
|
|
b := winner_bool[k]
|
|
@@ -123,6 +123,10 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
|
|
info := su.MysqlGlobalTool.FindOne(su.G_Units_Baseinfo, map[string]interface{}{"name": name}, "", "-id")
|
|
info := su.MysqlGlobalTool.FindOne(su.G_Units_Baseinfo, map[string]interface{}{"name": name}, "", "-id")
|
|
isNewEnt := false
|
|
isNewEnt := false
|
|
isNewEntInfo := map[string]interface{}{}
|
|
isNewEntInfo := map[string]interface{}{}
|
|
|
|
+ isLast := false //是否需要更新lastime
|
|
|
|
+ if identity == "0010" || identity == "0001" {
|
|
|
|
+ isLast = true
|
|
|
|
+ }
|
|
if info == nil {
|
|
if info == nil {
|
|
} else { //判断企业库最新的company_id是否与当前保持一致
|
|
} else { //判断企业库最新的company_id是否与当前保持一致
|
|
qyxy_info := CreateQyxyInfo(name)
|
|
qyxy_info := CreateQyxyInfo(name)
|
|
@@ -149,6 +153,9 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
|
|
base_info["name_id"] = name_id
|
|
base_info["name_id"] = name_id
|
|
base_info["identity_type"] = qu.IntAll(Str2DEC(identity))
|
|
base_info["identity_type"] = qu.IntAll(Str2DEC(identity))
|
|
base_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
|
|
base_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
|
|
|
|
+ if isLast && contact.Publishtime > 0 {
|
|
|
|
+ base_info["latest_time"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
|
|
|
|
+ }
|
|
//创建通讯录信息 调整仅有联系电话即可
|
|
//创建通讯录信息 调整仅有联系电话即可
|
|
if contact.Tel != "" {
|
|
if contact.Tel != "" {
|
|
date := ""
|
|
date := ""
|
|
@@ -181,6 +188,7 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
|
|
}
|
|
}
|
|
}
|
|
}
|
|
base_info["area_code"], base_info["city_code"], base_info["district_code"] = CalculateRegionCode(area, city, district)
|
|
base_info["area_code"], base_info["city_code"], base_info["district_code"] = CalculateRegionCode(area, city, district)
|
|
|
|
+ base_info["seo_id"] = GetRandomSeoId(true)
|
|
//新增主体信息表
|
|
//新增主体信息表
|
|
b := su.InsertMysqlData(su.G_Units_Baseinfo, base_info, tmpid)
|
|
b := su.InsertMysqlData(su.G_Units_Baseinfo, base_info, tmpid)
|
|
if b > 0 { //存通讯录
|
|
if b > 0 { //存通讯录
|
|
@@ -225,14 +233,25 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
|
|
update_info := map[string]interface{}{}
|
|
update_info := map[string]interface{}{}
|
|
info_identity := ConvertToBin(Str2DEC(qu.ObjToString((*info)["identity_type"])))
|
|
info_identity := ConvertToBin(Str2DEC(qu.ObjToString((*info)["identity_type"])))
|
|
info_identity = SupplementIdentityType(info_identity)
|
|
info_identity = SupplementIdentityType(info_identity)
|
|
|
|
+ p_l_time := int64(0)
|
|
|
|
+ p_l_time_str := qu.ObjToString((*info)["latest_time"])
|
|
|
|
+ if p_l_time_str != "" {
|
|
|
|
+ t, _ := time.ParseInLocation(su.TimeLayout, p_l_time_str, time.Local)
|
|
|
|
+ p_l_time = t.Unix()
|
|
|
|
+ }
|
|
if info_identity != identity {
|
|
if info_identity != identity {
|
|
new_identity := CalculateIdentityType(info_identity, identity)
|
|
new_identity := CalculateIdentityType(info_identity, identity)
|
|
if new_identity != info_identity {
|
|
if new_identity != info_identity {
|
|
update_info["identity_type"] = qu.IntAll(Str2DEC(new_identity))
|
|
update_info["identity_type"] = qu.IntAll(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 isLast && contact.Publishtime > p_l_time {
|
|
|
|
+ update_info["latest_time"] = time.Unix(contact.Publishtime, 0).Format(ul.TimeLayout)
|
|
|
|
+ }
|
|
|
|
+ if len(update_info) > 0 {
|
|
|
|
+ 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 {
|
|
if buyerclass != "" && contact.Buyer {
|
|
info_tag := su.MysqlGlobalTool.FindOne(su.G_Units_Tags, map[string]interface{}{"name_id": name_id}, "", "")
|
|
info_tag := su.MysqlGlobalTool.FindOne(su.G_Units_Tags, map[string]interface{}{"name_id": name_id}, "", "")
|
|
@@ -253,35 +272,38 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
|
|
if contact.Tel != "" {
|
|
if contact.Tel != "" {
|
|
contact_datas := su.MysqlGlobalTool.Find(su.G_Units_Contact, map[string]interface{}{"name_id": name_id}, "", "", -1, -1)
|
|
contact_datas := su.MysqlGlobalTool.Find(su.G_Units_Contact, map[string]interface{}{"name_id": name_id}, "", "", -1, -1)
|
|
isExists := false
|
|
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 := ConvertToBin(Str2DEC(qu.ObjToString(v["identity_type"])))
|
|
|
|
- old_contact_identity = SupplementIdentityType(old_contact_identity)
|
|
|
|
- if old_contact_identity != identity || qu.IntAll(v["source_type"]) == 2 || (contact.Publishtime > pt && contact.Publishtime > 0) {
|
|
|
|
- new_identity := CalculateIdentityType(old_contact_identity, identity)
|
|
|
|
- update_contact := map[string]interface{}{}
|
|
|
|
- update_contact["source_type"] = 1
|
|
|
|
- update_contact["identity_type"] = qu.IntAll(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)
|
|
|
|
|
|
+ if contact_datas != nil {
|
|
|
|
+ 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 := ConvertToBin(Str2DEC(qu.ObjToString(v["identity_type"])))
|
|
|
|
+ old_contact_identity = SupplementIdentityType(old_contact_identity)
|
|
|
|
+ if old_contact_identity != identity || qu.IntAll(v["source_type"]) == 2 || (contact.Publishtime > pt && contact.Publishtime > 0) {
|
|
|
|
+ new_identity := CalculateIdentityType(old_contact_identity, identity)
|
|
|
|
+ update_contact := map[string]interface{}{}
|
|
|
|
+ update_contact["source_type"] = 1
|
|
|
|
+ update_contact["identity_type"] = qu.IntAll(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)
|
|
}
|
|
}
|
|
- //更新通讯录
|
|
|
|
- su.MysqlGlobalTool.Update(su.G_Units_Contact, map[string]interface{}{"id": update_id}, update_contact)
|
|
|
|
|
|
+ break
|
|
}
|
|
}
|
|
- break
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
if !isExists {
|
|
if !isExists {
|
|
add_contact := map[string]interface{}{}
|
|
add_contact := map[string]interface{}{}
|
|
add_contact["name_id"] = name_id
|
|
add_contact["name_id"] = name_id
|
|
@@ -301,7 +323,7 @@ func dealWithUpdateContact(name string, buyerclass string, contact *Contact, ide
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-//创建年报字段~与现有的通讯录
|
|
|
|
|
|
+// 创建年报字段~与现有的通讯录
|
|
func CreateAnnualInfo(company_id string, legal_person string, contact_arr *[]map[string]interface{}) {
|
|
func CreateAnnualInfo(company_id string, legal_person string, contact_arr *[]map[string]interface{}) {
|
|
keys := map[string]string{}
|
|
keys := map[string]string{}
|
|
for _, v := range *contact_arr {
|
|
for _, v := range *contact_arr {
|
|
@@ -335,7 +357,7 @@ func CreateAnnualInfo(company_id string, legal_person string, contact_arr *[]map
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//创建企业信息
|
|
|
|
|
|
+// 创建企业信息
|
|
func CreateQyxyInfo(name string) map[string]interface{} {
|
|
func CreateQyxyInfo(name string) map[string]interface{} {
|
|
//查询企业库
|
|
//查询企业库
|
|
qyxy_info := map[string]interface{}{}
|
|
qyxy_info := map[string]interface{}{}
|