|
@@ -98,14 +98,11 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
xls, _ := xlsx.OpenBinary(binary)
|
|
|
mField, _ := FiledFuc()
|
|
|
fMap := make(map[int]string) //字段位置
|
|
|
- AreaM, IndustryM, WtM := CodeFieldFuc(eid)
|
|
|
|
|
|
- var m1Lock sync.Mutex
|
|
|
- var m2Lock sync.Mutex
|
|
|
- var m3Lock sync.Mutex
|
|
|
sheet := xls.Sheets[0]
|
|
|
rows := sheet.Rows
|
|
|
ch := make(chan bool, 20) // 协程处理
|
|
|
+ var idLock sync.Mutex
|
|
|
wg := &sync.WaitGroup{}
|
|
|
for rn, row := range rows {
|
|
|
if rn == 0 {
|
|
@@ -140,38 +137,44 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
}
|
|
|
} else if fMap[index] == "region" {
|
|
|
// 业务地区
|
|
|
- if v := AreaM[val]; v != nil && v != 0 {
|
|
|
- tmp[fMap[index]] = v
|
|
|
+ idLock.Lock()
|
|
|
+ var id int64
|
|
|
+ info := util.EntMysql.FindOne("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
+ "type": 1}, "", "")
|
|
|
+ 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,
|
|
|
+ id = util.EntMysql.Insert("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
"type": 1})
|
|
|
- m1Lock.Lock()
|
|
|
- AreaM[val] = id
|
|
|
- m1Lock.Unlock()
|
|
|
tmp[fMap[index]] = id
|
|
|
- info := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "region", "pcode": "$isNull"}, "", "")
|
|
|
- if info != nil && len(*info) > 0 {
|
|
|
- util.EntMysql.Insert("customer_data_yys_permission_elements", bson.M{"name": val, "ent_id": eid,
|
|
|
- "element_field": "region", "pcode": common.IntAll((*info)["code"]), "element_value": 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 {
|
|
|
+ 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})
|
|
|
+ }
|
|
|
+ idLock.Unlock()
|
|
|
} else if fMap[index] == "industry" {
|
|
|
// 行业
|
|
|
- if v := IndustryM[val]; v != nil && v != 0 {
|
|
|
- tmp[fMap[index]] = v
|
|
|
+ idLock.Lock()
|
|
|
+ var id int64
|
|
|
+ info := util.EntMysql.FindOne("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
+ "type": 2}, "", "")
|
|
|
+ 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,
|
|
|
+ id = util.EntMysql.Insert("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
"type": 2})
|
|
|
- m2Lock.Lock()
|
|
|
- IndustryM[val] = id
|
|
|
- m2Lock.Unlock()
|
|
|
tmp[fMap[index]] = id
|
|
|
- info := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "industry", "pcode": "$isNull"}, "", "")
|
|
|
- if info != nil && len(*info) > 0 {
|
|
|
- util.EntMysql.Insert("customer_data_yys_permission_elements", bson.M{"name": val, "ent_id": eid,
|
|
|
- "element_field": "industry", "pcode": common.IntAll((*info)["code"]), "element_value": 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 {
|
|
|
+ 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" {
|
|
|
if cell.Type() == xlsx.CellTypeNumeric {
|
|
|
dates, err := cell.GetTime(false)
|
|
@@ -186,21 +189,24 @@ func ImportDataByExcel(mf multipart.File, eid int64, entid string) (int, int64,
|
|
|
|
|
|
} else if fMap[index] == "winner_tag" {
|
|
|
// 中标单位标签
|
|
|
- if v := WtM[val]; v != nil && v != 0 {
|
|
|
- tmp[fMap[index]] = v
|
|
|
+ idLock.Lock()
|
|
|
+ var id int64
|
|
|
+ info := util.EntMysql.FindOne("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
+ "type": 3}, "", "")
|
|
|
+ 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,
|
|
|
+ id = util.EntMysql.Insert("d_yys_analyze_dimensions", bson.M{"ent_id": eid, "name": val,
|
|
|
"type": 3})
|
|
|
- m3Lock.Lock()
|
|
|
- WtM[val] = id
|
|
|
- m3Lock.Unlock()
|
|
|
tmp[fMap[index]] = id
|
|
|
- info := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "winner_tag", "pcode": "$isNull"}, "", "")
|
|
|
- if info != nil && len(*info) > 0 {
|
|
|
- util.EntMysql.Insert("customer_data_yys_permission_elements", bson.M{"name": val, "ent_id": eid,
|
|
|
- "element_field": "winner_tag", "pcode": common.IntAll((*info)["code"]), "element_value": id})
|
|
|
- }
|
|
|
}
|
|
|
+ info1 := util.EntMysql.FindOne("customer_data_yys_permission_elements", bson.M{"ent_id": eid, "element_field": "winner_tag", "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": "winner_tag", "pcode": common.IntAll((*info1)["code"]), "element_value": id})
|
|
|
+ }
|
|
|
+ idLock.Unlock()
|
|
|
} else {
|
|
|
if fMap[index] != "" {
|
|
|
tmp[fMap[index]] = val
|