|
@@ -4,6 +4,7 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/date"
|
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/uuid"
|
|
|
"app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
"app.yhyue.com/moapp/jybase/log"
|
|
|
"app.yhyue.com/moapp/jybase/mongodb"
|
|
@@ -103,6 +104,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
rows := sheet.Rows
|
|
|
ch := make(chan bool, 20) // 协程处理
|
|
|
var idLock sync.Mutex
|
|
|
+ var areaIdLock sync.Mutex
|
|
|
wg := &sync.WaitGroup{}
|
|
|
for rn, row := range rows {
|
|
|
if rn == 0 {
|
|
@@ -150,7 +152,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
tmp[fMap[index]] = id
|
|
|
}
|
|
|
info1 := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "region", "pcode": "$isNull"}, "", "")
|
|
|
- if info1 != nil && len(*info) > 0 {
|
|
|
+ if info1 != nil && len(*info1) > 0 {
|
|
|
util.EntMysql.Insert("customer_data_yys_permission_elements", bson.M{"name": val, "ent_id": eid,
|
|
|
"element_field": "region", "pcode": common.IntAll((*info1)["code"]), "element_value": id})
|
|
|
}
|
|
@@ -170,12 +172,33 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
tmp[fMap[index]] = id
|
|
|
}
|
|
|
info1 := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "industry", "pcode": "$isNull"}, "", "")
|
|
|
- if info1 != nil && len(*info) > 0 {
|
|
|
+ if info1 != nil && len(*info1) > 0 {
|
|
|
+ util.EntMysql.Insert("customer_data_yys_permission_elements", bson.M{"name": val, "ent_id": eid,
|
|
|
+ "element_field": "industry", "pcode": common.IntAll((*info1)["code"]), "element_value": id})
|
|
|
+ }
|
|
|
+ idLock.Unlock()
|
|
|
+ } else if fMap[index] == "businesstype" {
|
|
|
+ // 行业
|
|
|
+ idLock.Lock()
|
|
|
+ var id int64
|
|
|
+ info := util.EntMysql.FindOne("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
+ "type": 6}, "", "")
|
|
|
+ if info != nil && len(*info) > 0 {
|
|
|
+ id = common.Int64All((*info)["code"])
|
|
|
+ tmp[fMap[index]] = id
|
|
|
+ } else {
|
|
|
+ id = util.EntMysql.Insert("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
+ "type": 6})
|
|
|
+ tmp[fMap[index]] = id
|
|
|
+ }
|
|
|
+ info1 := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "industry", "pcode": "$isNull"}, "", "")
|
|
|
+ if info1 != nil && len(*info1) > 0 {
|
|
|
util.EntMysql.Insert("customer_data_yys_permission_elements", bson.M{"name": val, "ent_id": eid,
|
|
|
"element_field": "industry", "pcode": common.IntAll((*info1)["code"]), "element_value": id})
|
|
|
}
|
|
|
idLock.Unlock()
|
|
|
- } else if fMap[index] == "bidopentime" || fMap[index] == "publishtime" || fMap[index] == "docstarttime" || fMap[index] == "bidstarttime" || fMap[index] == "bidendtime" {
|
|
|
+ } else if fMap[index] == "bidopentime" || fMap[index] == "publishtime" || fMap[index] == "docstarttime" || fMap[index] == "bidstarttime" || fMap[index] == "bidendtime" ||
|
|
|
+ fMap[index] == "expurasingtime" {
|
|
|
if cell.Type() == xlsx.CellTypeNumeric {
|
|
|
dates, err := cell.GetTime(false)
|
|
|
if err != nil {
|
|
@@ -186,7 +209,6 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
} else {
|
|
|
tmp[fMap[index]] = val
|
|
|
}
|
|
|
-
|
|
|
} else if fMap[index] == "winner_tag" {
|
|
|
// 中标单位标签
|
|
|
idLock.Lock()
|
|
@@ -207,6 +229,8 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
"element_field": "winner_tag", "pcode": common.IntAll((*info1)["code"]), "element_value": id})
|
|
|
}
|
|
|
idLock.Unlock()
|
|
|
+ } else if fMap[index] == "multpackage" {
|
|
|
+ tmp[fMap[index]] = common.IntAll(val)
|
|
|
} else {
|
|
|
if fMap[index] != "" {
|
|
|
tmp[fMap[index]] = val
|
|
@@ -214,8 +238,21 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if tmp["infoid"] == nil {
|
|
|
- return
|
|
|
+ if tmp["infoid"] != nil {
|
|
|
+ tmp["bid"] = tmp["infoid"]
|
|
|
+ if common.IntAll(tmp["multpackage"]) == 1 {
|
|
|
+ tmp["infoid"] = common.GetMd5String(fmt.Sprintf("%s-%s", tmp["bid"], common.ObjToString(tmp["packagenumb"])))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if common.IntAll(tmp["multpackage"]) == 0 {
|
|
|
+ str := strings.ReplaceAll(uuid.New(), "-", "")
|
|
|
+ tmp["bid"] = str
|
|
|
+ tmp["infoid"] = common.GetMd5String(str)
|
|
|
+ } else {
|
|
|
+ str := strings.ReplaceAll(uuid.New(), "-", "")
|
|
|
+ tmp["bid"] = str
|
|
|
+ tmp["infoid"] = common.GetMd5String(fmt.Sprintf("%s-%s", str, common.ObjToString(tmp["packagenumb"])))
|
|
|
+ }
|
|
|
}
|
|
|
*importDataNum++
|
|
|
if common.ObjToString(tmp["href"]) == "#" || strings.Contains(common.ObjToString(tmp["href"]), "jianyu360.cn") {
|
|
@@ -225,12 +262,16 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
}
|
|
|
tmp["eid"] = eid
|
|
|
tmp["entid"] = entid
|
|
|
- tmp["jybxhref"] = "https://www.jianyu360.cn/succbi/yyssjdz/app/sjdz.app/detail.spg?E_id=" + common.ObjToString(tmp["infoid"])
|
|
|
+ tmp["jybxhref"] = "https://www.jianyu360.cn/succbi/yyssjdz/app/sjdz.app/detail.spg?E_id=" + common.ObjToString(tmp["bid"])
|
|
|
tmp["pici"] = now.Format(date.Date_Full_Layout)
|
|
|
if tmp["tagname3"] == nil {
|
|
|
tmp["tagname3"] = "DICT"
|
|
|
}
|
|
|
- if info := util.EntMysql.FindOne("customer_data", bson.M{"entid": entid, "infoid": tmp["infoid"]}, "", ""); info != nil && len(*info) > 0 {
|
|
|
+ areaIdLock.Lock()
|
|
|
+ areaFuc(tmp) // 处理地区
|
|
|
+ areaIdLock.Unlock()
|
|
|
+ q := common.GetMd5String(fmt.Sprintf("%s-%s", common.ObjToString(tmp["bid"]), common.ObjToString(tmp["packagenumb"])))
|
|
|
+ if info := util.EntMysql.FindOne("customer_data", bson.M{"entid": entid, "infoid": q}, "", ""); info != nil && len(*info) > 0 {
|
|
|
tmp["status"] = 1
|
|
|
util.EntMysql.Update("customer_data", bson.M{"entid": entid, "infoid": tmp["infoid"]}, tmp)
|
|
|
id := (*info)["id"]
|
|
@@ -246,7 +287,7 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
} else {
|
|
|
id := util.EntMysql.Insert("customer_data", tmp)
|
|
|
tmp["id"] = id
|
|
|
- detail := detailFuc(common.ObjToString(tmp["infoid"]))
|
|
|
+ detail := detailFuc(common.ObjToString(tmp["bid"]))
|
|
|
esSaveFuc(tmp, detail)
|
|
|
}
|
|
|
}(row.Cells, &importDataNum)
|
|
@@ -269,6 +310,45 @@ func FiledFuc(eid int64) (map[string]interface{}, map[string]interface{}) {
|
|
|
return mField, fField
|
|
|
}
|
|
|
|
|
|
+func areaFuc(tmp map[string]interface{}) {
|
|
|
+ area_id := int64(0)
|
|
|
+ if a := common.ObjToString(tmp["area"]); a != "" {
|
|
|
+ info := util.EntMysql.SelectBySql("SELECT id FROM bi_service.d_yys_area_data WHERE ent_id = ? AND name = ?", tmp["eid"], a)
|
|
|
+ if len(*info) > 0 {
|
|
|
+ area_id = common.Int64All((*info)[0]["id"])
|
|
|
+ } else {
|
|
|
+ area_id = util.EntMysql.Insert("d_yys_area_data", bson.M{"ent_id": tmp["eid"], "name": a, "level": 1})
|
|
|
+ util.EntMysql.ExecBySql("UPDATE bi_service.d_yys_area_data SET SZ_PID0 = ? WHERE id = ?", a, area_id)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ city_id := int64(0)
|
|
|
+ if c := common.ObjToString(tmp["city"]); c != "" {
|
|
|
+ info := util.EntMysql.SelectBySql("SELECT id FROM bi_service.d_yys_area_data WHERE ent_id = ? AND name = ?", tmp["eid"], c)
|
|
|
+ if len(*info) > 0 {
|
|
|
+ city_id = common.Int64All((*info)[0]["id"])
|
|
|
+ } else {
|
|
|
+ city_id = util.EntMysql.Insert("d_yys_area_data", bson.M{"ent_id": tmp["eid"], "name": c, "level": 2, "pcode": area_id})
|
|
|
+ util.EntMysql.ExecBySql("UPDATE bi_service.d_yys_area_data SET SZ_PID0 = ?, SZ_PID1 = ? WHERE id = ?", common.ObjToString(tmp["area"]), c, city_id)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ district_id := int64(0)
|
|
|
+ if d := common.ObjToString(tmp["district"]); d != "" {
|
|
|
+ info := util.EntMysql.SelectBySql("SELECT id FROM bi_service.d_yys_area_data WHERE ent_id = ? AND name = ?", tmp["eid"], d)
|
|
|
+ if len(*info) > 0 {
|
|
|
+ district_id = common.Int64All((*info)[0]["id"])
|
|
|
+ } else {
|
|
|
+ district_id = util.EntMysql.Insert("d_yys_area_data", bson.M{"ent_id": tmp["eid"], "name": d, "level": 3, "pcode": city_id})
|
|
|
+ a := common.ObjToString(tmp["area"])
|
|
|
+ c := common.ObjToString(tmp["city"])
|
|
|
+ util.EntMysql.ExecBySql("UPDATE bi_service.d_yys_area_data SET SZ_PID0 = ?, SZ_PID1 = ?, SZ_PID2 = ? WHERE id = ?", a, c, d, district_id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func CodeFieldFuc(entid int64) (map[string]interface{}, map[string]interface{}, map[string]interface{}) {
|
|
|
AreaMap := make(map[string]interface{})
|
|
|
IndustryMap := make(map[string]interface{})
|
|
@@ -352,6 +432,9 @@ func detailFuc(infoid string) string {
|
|
|
//if binfo != nil && len(*binfo) > 0 {
|
|
|
// return common.ObjToString((*binfo)["ES_detail"])
|
|
|
//}
|
|
|
+ if !mongodb.IsObjectIdHex(infoid) {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
info, _ := util.MgoBidding.FindById("bidding", infoid, bson.M{"detail": 1, "contenthtml": 1})
|
|
|
if info != nil && len(*info) == 0 {
|
|
|
info, _ = util.MgoBidding.FindById("bidding_back", infoid, bson.M{"detail": 1, "contenthtml": 1})
|
|
@@ -362,19 +445,19 @@ func detailFuc(infoid string) string {
|
|
|
save["ES_detail"] = (*info)["detail"]
|
|
|
detail = common.ObjToString((*info)["contenthtml"])
|
|
|
save["details"] = detail
|
|
|
+ go func() {
|
|
|
+ if util.EntMysql.Count("customer_data_yys_gl", bson.M{"info_id": infoid}) == 0 {
|
|
|
+ util.EntMysql.Insert("customer_data_yys_gl", save)
|
|
|
+ }
|
|
|
+ }()
|
|
|
}
|
|
|
- go func() {
|
|
|
- if util.EntMysql.Count("customer_data_yys_gl", bson.M{"info_id": infoid}) == 0 {
|
|
|
- util.EntMysql.Insert("customer_data_yys_gl", save)
|
|
|
- }
|
|
|
- }()
|
|
|
return detail
|
|
|
}
|
|
|
|
|
|
func esSaveFuc(tmp map[string]interface{}, detail string) {
|
|
|
saveEs := make(map[string]interface{})
|
|
|
- for _, f := range []string{"id", "tagname", "publishtime", "toptype", "subtype", "area", "city", "district", "title", "buyerclass",
|
|
|
- "detail", "ent_id", "matchkey", "region", "industry", "winner_tag", "buyer", "budget", "s_winner", "bidamount", "pici"} {
|
|
|
+ for _, f := range []string{"id", "tagname", "publishtime", "toptype", "subtype", "area", "city", "district", "title", "buyerclass", "businesstype",
|
|
|
+ "detail", "ent_id", "matchkey", "region", "industry", "winner_tag", "buyer", "budget", "s_winner", "bidamount", "pici", "expurasingtime", "bidopentime"} {
|
|
|
if f == "tagname" {
|
|
|
var a1 []string
|
|
|
for _, i := range []string{"tagname", "tagname2", "tagname3"} {
|
|
@@ -387,7 +470,7 @@ func esSaveFuc(tmp map[string]interface{}, detail string) {
|
|
|
}
|
|
|
} else if f == "ent_id" {
|
|
|
saveEs[f] = tmp["eid"]
|
|
|
- } else if f == "publishtime" || f == "pici" {
|
|
|
+ } else if f == "publishtime" || f == "pici" || f == "expurasingtime" || f == "bidopentime" {
|
|
|
thisTime, err := time.ParseInLocation(date.Date_Full_Layout, common.ObjToString(tmp[f]), time.Local)
|
|
|
if err == nil {
|
|
|
saveEs[f] = thisTime.Unix()
|