|
@@ -18,6 +18,7 @@ func InitBaseIndexData(dataPath string) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("InitBaseIndexData Err:" + err.Error())
|
|
|
+ utils.FileLog.Info("InitJiaYueIndexData Err: " + err.Error())
|
|
|
}
|
|
|
}()
|
|
|
|
|
@@ -51,22 +52,24 @@ func InitBaseIndexData(dataPath string) {
|
|
|
fmt.Println("rows len:", len(rows))
|
|
|
|
|
|
// 获取创建人信息
|
|
|
- admins, e := models.GetSysAdminList(``, make([]interface{}, 0))
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("GetSysAdminList err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
mobileMap := make(map[string]*models.Admin)
|
|
|
- for _, v := range admins {
|
|
|
- if v.Mobile == "" {
|
|
|
- continue
|
|
|
+ if utils.MYSQL_URL_ETA != "" {
|
|
|
+ admins, e := models.GetSysAdminList(``, make([]interface{}, 0))
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("GetSysAdminList err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range admins {
|
|
|
+ if v.Mobile == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mobileMap[v.Mobile] = v
|
|
|
}
|
|
|
- mobileMap[v.Mobile] = v
|
|
|
}
|
|
|
|
|
|
for rk, row := range rows {
|
|
|
if rk > 0 {
|
|
|
- var classifyFirst, classifySecond, classifyThree, indexCode, indexName, frequency, unit, source, mobile string
|
|
|
+ var classifyFirst, classifySecond, classifyThree, classifyFourth, classifyFifth, classifySixth, indexCode, indexName, frequency, unit, source, mobile string
|
|
|
for ck, colCell := range row {
|
|
|
colCell = strings.TrimSpace(colCell)
|
|
|
switch ck {
|
|
@@ -77,95 +80,181 @@ func InitBaseIndexData(dataPath string) {
|
|
|
case 2:
|
|
|
classifyThree = colCell
|
|
|
case 3:
|
|
|
- indexCode = colCell
|
|
|
+ classifyFourth = colCell
|
|
|
case 4:
|
|
|
- indexName = colCell
|
|
|
+ classifyFifth = colCell
|
|
|
case 5:
|
|
|
- frequency = colCell
|
|
|
+ classifySixth = colCell
|
|
|
case 6:
|
|
|
- unit = colCell
|
|
|
+ indexCode = colCell
|
|
|
case 7:
|
|
|
- source = colCell
|
|
|
+ indexName = colCell
|
|
|
case 8:
|
|
|
+ frequency = colCell
|
|
|
+ case 9:
|
|
|
+ unit = colCell
|
|
|
+ case 10:
|
|
|
+ source = colCell
|
|
|
+ case 11:
|
|
|
mobile = colCell
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if classifyFirst != "" &&
|
|
|
- classifySecond != "" &&
|
|
|
- classifyThree != "" &&
|
|
|
indexCode != "" &&
|
|
|
indexName != "" &&
|
|
|
unit != "" &&
|
|
|
frequency != "" &&
|
|
|
source != "" {
|
|
|
|
|
|
+ var firstId, secondId, thirdId, fourthId, fifthId, lastId int
|
|
|
method := "classify/get_or_add"
|
|
|
classifyFirstMap := make(map[string]interface{})
|
|
|
classifyFirstMap["ClassifyName"] = classifyFirst
|
|
|
classifyFirstMap["ParentId"] = 0
|
|
|
classifyFirstMap["Level"] = 0
|
|
|
classifyFirstMap["ClassifyType"] = 0
|
|
|
- result, err := PostEdbLib(classifyFirstMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + err.Error())
|
|
|
+ result, e := PostEdbLib(classifyFirstMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFirst PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
resp := new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- classifySecondMap := make(map[string]interface{})
|
|
|
- classifySecondMap["ClassifyName"] = classifySecond
|
|
|
- classifySecondMap["ParentId"] = resp.Data.ClassifyId
|
|
|
- classifySecondMap["Level"] = 1
|
|
|
- classifySecondMap["ClassifyType"] = 0
|
|
|
- result, err = PostEdbLib(classifySecondMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + err.Error())
|
|
|
+ if e = json.Unmarshal(result, &resp); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFirst json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- classifyThreeMap := make(map[string]interface{})
|
|
|
- classifyThreeMap["ClassifyName"] = classifyThree
|
|
|
- classifyThreeMap["ParentId"] = resp.Data.ClassifyId
|
|
|
- classifyThreeMap["Level"] = 2
|
|
|
- classifyThreeMap["ClassifyType"] = 0
|
|
|
- result, err = PostEdbLib(classifyThreeMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + err.Error())
|
|
|
- return
|
|
|
+ err = fmt.Errorf("ClassifyFirst resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ firstId = resp.Data.ClassifyId
|
|
|
+ lastId = firstId
|
|
|
+
|
|
|
+ // 二级分类
|
|
|
+ if classifySecond != "" {
|
|
|
+ classifySecondMap := make(map[string]interface{})
|
|
|
+ classifySecondMap["ClassifyName"] = classifySecond
|
|
|
+ classifySecondMap["ParentId"] = firstId
|
|
|
+ classifySecondMap["Level"] = 1
|
|
|
+ classifySecondMap["ClassifyType"] = 0
|
|
|
+ res2, e := PostEdbLib(classifySecondMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySecond PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp2 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res2, &resp2); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySecond json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp2.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySecond resp msg: %s; errMsg: %s", resp2.Msg, resp2.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ secondId = resp2.Data.ClassifyId
|
|
|
+ lastId = secondId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 三级分类
|
|
|
+ if classifyThree != "" {
|
|
|
+ classifyThreeMap := make(map[string]interface{})
|
|
|
+ classifyThreeMap["ClassifyName"] = classifyThree
|
|
|
+ classifyThreeMap["ParentId"] = secondId
|
|
|
+ classifyThreeMap["Level"] = 2
|
|
|
+ classifyThreeMap["ClassifyType"] = 0
|
|
|
+ res3, e := PostEdbLib(classifyThreeMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyThird PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp3 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res3, &resp3); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyThird json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp3.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyThird resp msg: %s; errMsg: %s", resp3.Msg, resp3.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ thirdId = resp3.Data.ClassifyId
|
|
|
+ lastId = thirdId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 四级分类
|
|
|
+ if classifyFourth != "" {
|
|
|
+ classifyFourthMap := make(map[string]interface{})
|
|
|
+ classifyFourthMap["ClassifyName"] = classifyFourth
|
|
|
+ classifyFourthMap["ParentId"] = thirdId
|
|
|
+ classifyFourthMap["Level"] = 3
|
|
|
+ classifyFourthMap["ClassifyType"] = 0
|
|
|
+ res4, e := PostEdbLib(classifyFourthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFourth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp4 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res4, &resp4); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFourth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp4.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFourth resp msg: %s; errMsg: %s", resp4.Msg, resp4.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fourthId = resp4.Data.ClassifyId
|
|
|
+ lastId = fourthId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 五级分类
|
|
|
+ if classifyFifth != "" {
|
|
|
+ classifyFifthMap := make(map[string]interface{})
|
|
|
+ classifyFifthMap["ClassifyName"] = classifyFifth
|
|
|
+ classifyFifthMap["ParentId"] = fourthId
|
|
|
+ classifyFifthMap["Level"] = 4
|
|
|
+ classifyFifthMap["ClassifyType"] = 0
|
|
|
+ res5, e := PostEdbLib(classifyFifthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFifth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp5 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res5, &resp5); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFifth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp5.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFifth resp msg: %s; errMsg: %s", resp5.Msg, resp5.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fifthId = resp5.Data.ClassifyId
|
|
|
+ lastId = fifthId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 六级分类
|
|
|
+ if classifySixth != "" {
|
|
|
+ classifySixthMap := make(map[string]interface{})
|
|
|
+ classifySixthMap["ClassifyName"] = classifySixth
|
|
|
+ classifySixthMap["ParentId"] = fifthId
|
|
|
+ classifySixthMap["Level"] = 5
|
|
|
+ classifySixthMap["ClassifyType"] = 0
|
|
|
+ res6, e := PostEdbLib(classifySixthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySixth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp6 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res6, &resp6); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySixth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp6.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySixth resp msg: %s; errMsg: %s", resp6.Msg, resp6.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ lastId = resp6.Data.ClassifyId
|
|
|
}
|
|
|
|
|
|
- if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
method = "edb_info/add"
|
|
|
sourceId, ok := IndexSourceMap[source]
|
|
|
if !ok {
|
|
@@ -179,7 +268,7 @@ func InitBaseIndexData(dataPath string) {
|
|
|
indexMap["EdbName"] = indexName
|
|
|
indexMap["Frequency"] = frequency
|
|
|
indexMap["Unit"] = unit
|
|
|
- indexMap["ClassifyId"] = resp.Data.ClassifyId
|
|
|
+ indexMap["ClassifyId"] = lastId
|
|
|
admin := mobileMap[mobile]
|
|
|
if admin != nil {
|
|
|
indexMap["AdminId"] = admin.AdminId
|
|
@@ -277,22 +366,24 @@ func InitBaseIndexDataFromMysteel(filePath string) {
|
|
|
fmt.Println("rows len:", len(rows))
|
|
|
|
|
|
// 获取创建人信息
|
|
|
- admins, e := models.GetSysAdminList(``, make([]interface{}, 0))
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("GetSysAdminList err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
mobileMap := make(map[string]*models.Admin)
|
|
|
- for _, v := range admins {
|
|
|
- if v.Mobile == "" {
|
|
|
- continue
|
|
|
+ if utils.MYSQL_URL_ETA != "" {
|
|
|
+ admins, e := models.GetSysAdminList(``, make([]interface{}, 0))
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("GetSysAdminList err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range admins {
|
|
|
+ if v.Mobile == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mobileMap[v.Mobile] = v
|
|
|
}
|
|
|
- mobileMap[v.Mobile] = v
|
|
|
}
|
|
|
|
|
|
for rk, row := range rows {
|
|
|
if rk > 0 {
|
|
|
- var classifyFirst, classifySecond, classifyThree, indexCode, indexName, frequency, unit, source, mobile string
|
|
|
+ var classifyFirst, classifySecond, classifyThree, classifyFourth, classifyFifth, classifySixth, indexCode, indexName, frequency, unit, source, mobile string
|
|
|
for ck, colCell := range row {
|
|
|
colCell = strings.TrimSpace(colCell)
|
|
|
switch ck {
|
|
@@ -303,23 +394,27 @@ func InitBaseIndexDataFromMysteel(filePath string) {
|
|
|
case 2:
|
|
|
classifyThree = colCell
|
|
|
case 3:
|
|
|
- indexCode = colCell
|
|
|
+ classifyFourth = colCell
|
|
|
case 4:
|
|
|
- indexName = colCell
|
|
|
+ classifyFifth = colCell
|
|
|
case 5:
|
|
|
- frequency = colCell
|
|
|
+ classifySixth = colCell
|
|
|
case 6:
|
|
|
- unit = colCell
|
|
|
+ indexCode = colCell
|
|
|
case 7:
|
|
|
- source = colCell
|
|
|
+ indexName = colCell
|
|
|
case 8:
|
|
|
+ frequency = colCell
|
|
|
+ case 9:
|
|
|
+ unit = colCell
|
|
|
+ case 10:
|
|
|
+ source = colCell
|
|
|
+ case 11:
|
|
|
mobile = colCell
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if classifyFirst != "" &&
|
|
|
- classifySecond != "" &&
|
|
|
- classifyThree != "" &&
|
|
|
indexCode != "" &&
|
|
|
indexName != "" &&
|
|
|
unit != "" &&
|
|
@@ -330,98 +425,176 @@ func InitBaseIndexDataFromMysteel(filePath string) {
|
|
|
method := "mysteel_chemical/index_detail"
|
|
|
indexSearchMap := make(map[string]interface{})
|
|
|
indexSearchMap["IndexCode"] = indexCode
|
|
|
- indexResult, err := PostEdbLib(indexSearchMap, method)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("判断指标是否存在失败,Err:" + err.Error())
|
|
|
+ indexResult, e := PostEdbLib(indexSearchMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("判断指标是否存在失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
mysteelIndexResp := new(models.MysteelIndexResp)
|
|
|
- err = json.Unmarshal(indexResult, &mysteelIndexResp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("判断指标是否存在失败:" + err.Error())
|
|
|
- fmt.Println("判断指标是否存在失败,Err:" + err.Error())
|
|
|
+ e = json.Unmarshal(indexResult, &mysteelIndexResp)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("判断指标是否存在失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
if mysteelIndexResp.Ret != 200 {
|
|
|
fmt.Println("判断指标是否存在失败,Err:" + mysteelIndexResp.ErrMsg)
|
|
|
//utils.FileLog.Info("判断指标是否存在失败:" + err.Error())
|
|
|
//return
|
|
|
continue
|
|
|
}
|
|
|
-
|
|
|
if mysteelIndexResp.Data.BaseFromMysteelChemicalIndexId <= 0 {
|
|
|
fmt.Println("指标:" + indexCode + ";不存在")
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ var firstId, secondId, thirdId, fourthId, fifthId, lastId int
|
|
|
method = "classify/get_or_add"
|
|
|
classifyFirstMap := make(map[string]interface{})
|
|
|
classifyFirstMap["ClassifyName"] = classifyFirst
|
|
|
classifyFirstMap["ParentId"] = 0
|
|
|
classifyFirstMap["Level"] = 0
|
|
|
classifyFirstMap["ClassifyType"] = 0
|
|
|
- result, err := PostEdbLib(classifyFirstMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + err.Error())
|
|
|
+ result, e := PostEdbLib(classifyFirstMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFirst PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
resp := new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- classifySecondMap := make(map[string]interface{})
|
|
|
- classifySecondMap["ClassifyName"] = classifySecond
|
|
|
- classifySecondMap["ParentId"] = resp.Data.ClassifyId
|
|
|
- classifySecondMap["Level"] = 1
|
|
|
- classifySecondMap["ClassifyType"] = 0
|
|
|
- result, err = PostEdbLib(classifySecondMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + err.Error())
|
|
|
+ if e = json.Unmarshal(result, &resp); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFirst json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- classifyThreeMap := make(map[string]interface{})
|
|
|
- classifyThreeMap["ClassifyName"] = classifyThree
|
|
|
- classifyThreeMap["ParentId"] = resp.Data.ClassifyId
|
|
|
- classifyThreeMap["Level"] = 2
|
|
|
- classifyThreeMap["ClassifyType"] = 0
|
|
|
- result, err = PostEdbLib(classifyThreeMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + err.Error())
|
|
|
- return
|
|
|
+ err = fmt.Errorf("ClassifyFirst resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ firstId = resp.Data.ClassifyId
|
|
|
+ lastId = firstId
|
|
|
+
|
|
|
+ // 二级分类
|
|
|
+ if classifySecond != "" {
|
|
|
+ classifySecondMap := make(map[string]interface{})
|
|
|
+ classifySecondMap["ClassifyName"] = classifySecond
|
|
|
+ classifySecondMap["ParentId"] = firstId
|
|
|
+ classifySecondMap["Level"] = 1
|
|
|
+ classifySecondMap["ClassifyType"] = 0
|
|
|
+ res2, e := PostEdbLib(classifySecondMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySecond PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp2 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res2, &resp2); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySecond json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp2.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySecond resp msg: %s; errMsg: %s", resp2.Msg, resp2.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ secondId = resp2.Data.ClassifyId
|
|
|
+ lastId = secondId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 三级分类
|
|
|
+ if classifyThree != "" {
|
|
|
+ classifyThreeMap := make(map[string]interface{})
|
|
|
+ classifyThreeMap["ClassifyName"] = classifyThree
|
|
|
+ classifyThreeMap["ParentId"] = secondId
|
|
|
+ classifyThreeMap["Level"] = 2
|
|
|
+ classifyThreeMap["ClassifyType"] = 0
|
|
|
+ res3, e := PostEdbLib(classifyThreeMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyThird PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp3 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res3, &resp3); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyThird json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp3.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyThird resp msg: %s; errMsg: %s", resp3.Msg, resp3.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ thirdId = resp3.Data.ClassifyId
|
|
|
+ lastId = thirdId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 四级分类
|
|
|
+ if classifyFourth != "" {
|
|
|
+ classifyFourthMap := make(map[string]interface{})
|
|
|
+ classifyFourthMap["ClassifyName"] = classifyFourth
|
|
|
+ classifyFourthMap["ParentId"] = thirdId
|
|
|
+ classifyFourthMap["Level"] = 3
|
|
|
+ classifyFourthMap["ClassifyType"] = 0
|
|
|
+ res4, e := PostEdbLib(classifyFourthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFourth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp4 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res4, &resp4); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFourth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp4.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFourth resp msg: %s; errMsg: %s", resp4.Msg, resp4.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fourthId = resp4.Data.ClassifyId
|
|
|
+ lastId = fourthId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 五级分类
|
|
|
+ if classifyFifth != "" {
|
|
|
+ classifyFifthMap := make(map[string]interface{})
|
|
|
+ classifyFifthMap["ClassifyName"] = classifyFifth
|
|
|
+ classifyFifthMap["ParentId"] = fourthId
|
|
|
+ classifyFifthMap["Level"] = 4
|
|
|
+ classifyFifthMap["ClassifyType"] = 0
|
|
|
+ res5, e := PostEdbLib(classifyFifthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFifth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp5 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res5, &resp5); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFifth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp5.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFifth resp msg: %s; errMsg: %s", resp5.Msg, resp5.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fifthId = resp5.Data.ClassifyId
|
|
|
+ lastId = fifthId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 六级分类
|
|
|
+ if classifySixth != "" {
|
|
|
+ classifySixthMap := make(map[string]interface{})
|
|
|
+ classifySixthMap["ClassifyName"] = classifySixth
|
|
|
+ classifySixthMap["ParentId"] = fifthId
|
|
|
+ classifySixthMap["Level"] = 5
|
|
|
+ classifySixthMap["ClassifyType"] = 0
|
|
|
+ res6, e := PostEdbLib(classifySixthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySixth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp6 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res6, &resp6); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySixth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp6.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySixth resp msg: %s; errMsg: %s", resp6.Msg, resp6.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ lastId = resp6.Data.ClassifyId
|
|
|
}
|
|
|
|
|
|
- if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
method = "edb_info/add"
|
|
|
indexMap := make(map[string]interface{})
|
|
|
indexMap["Source"] = IndexSourceMap[source]
|
|
@@ -429,7 +602,7 @@ func InitBaseIndexDataFromMysteel(filePath string) {
|
|
|
indexMap["EdbName"] = indexName
|
|
|
indexMap["Frequency"] = frequency
|
|
|
indexMap["Unit"] = unit
|
|
|
- indexMap["ClassifyId"] = resp.Data.ClassifyId
|
|
|
+ indexMap["ClassifyId"] = lastId
|
|
|
admin := mobileMap[mobile]
|
|
|
if admin != nil {
|
|
|
indexMap["AdminId"] = admin.AdminId
|
|
@@ -514,22 +687,24 @@ func InitBaseIndexDataFromDataSourceSmm(filePath string) {
|
|
|
fmt.Println("rows len:", len(rows))
|
|
|
|
|
|
// 获取创建人信息
|
|
|
- admins, e := models.GetSysAdminList(``, make([]interface{}, 0))
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("GetSysAdminList err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
mobileMap := make(map[string]*models.Admin)
|
|
|
- for _, v := range admins {
|
|
|
- if v.Mobile == "" {
|
|
|
- continue
|
|
|
+ if utils.MYSQL_URL_ETA != "" {
|
|
|
+ admins, e := models.GetSysAdminList(``, make([]interface{}, 0))
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("GetSysAdminList err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range admins {
|
|
|
+ if v.Mobile == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ mobileMap[v.Mobile] = v
|
|
|
}
|
|
|
- mobileMap[v.Mobile] = v
|
|
|
}
|
|
|
|
|
|
for rk, row := range rows {
|
|
|
if rk > 0 {
|
|
|
- var classifyFirst, classifySecond, classifyThree, indexCode, indexName, frequency, unit, source, mobile string
|
|
|
+ var classifyFirst, classifySecond, classifyThree, classifyFourth, classifyFifth, classifySixth, indexCode, indexName, frequency, unit, source, mobile string
|
|
|
for ck, colCell := range row {
|
|
|
colCell = strings.TrimSpace(colCell)
|
|
|
switch ck {
|
|
@@ -540,23 +715,27 @@ func InitBaseIndexDataFromDataSourceSmm(filePath string) {
|
|
|
case 2:
|
|
|
classifyThree = colCell
|
|
|
case 3:
|
|
|
- indexCode = colCell
|
|
|
+ classifyFourth = colCell
|
|
|
case 4:
|
|
|
- indexName = colCell
|
|
|
+ classifyFifth = colCell
|
|
|
case 5:
|
|
|
- frequency = colCell
|
|
|
+ classifySixth = colCell
|
|
|
case 6:
|
|
|
- unit = colCell
|
|
|
+ indexCode = colCell
|
|
|
case 7:
|
|
|
- source = colCell
|
|
|
+ indexName = colCell
|
|
|
case 8:
|
|
|
+ frequency = colCell
|
|
|
+ case 9:
|
|
|
+ unit = colCell
|
|
|
+ case 10:
|
|
|
+ source = colCell
|
|
|
+ case 11:
|
|
|
mobile = colCell
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if classifyFirst != "" &&
|
|
|
- classifySecond != "" &&
|
|
|
- classifyThree != "" &&
|
|
|
indexCode != "" &&
|
|
|
indexName != "" &&
|
|
|
unit != "" &&
|
|
@@ -567,98 +746,176 @@ func InitBaseIndexDataFromDataSourceSmm(filePath string) {
|
|
|
method := "smm/index_detail/from_data_source"
|
|
|
indexSearchMap := make(map[string]interface{})
|
|
|
indexSearchMap["IndexCode"] = indexCode
|
|
|
- indexResult, err := PostEdbLib(indexSearchMap, method)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("判断指标是否存在失败,Err:" + err.Error())
|
|
|
+ indexResult, e := PostEdbLib(indexSearchMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("判断指标是否存在失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
smmIndexResp := new(models.BaseFromSmmIndexResp)
|
|
|
- err = json.Unmarshal(indexResult, &smmIndexResp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("判断指标是否存在失败:" + err.Error())
|
|
|
- fmt.Println("判断指标是否存在失败,Err:" + err.Error())
|
|
|
+ e = json.Unmarshal(indexResult, &smmIndexResp)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("判断指标是否存在失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
if smmIndexResp.Ret != 200 {
|
|
|
fmt.Println("判断指标是否存在失败,Err:" + smmIndexResp.ErrMsg)
|
|
|
//utils.FileLog.Info("判断指标是否存在失败:" + err.Error())
|
|
|
//return
|
|
|
continue
|
|
|
}
|
|
|
-
|
|
|
if smmIndexResp.Data.BaseFromSmmIndexId <= 0 {
|
|
|
fmt.Println("指标:" + indexCode + ";不存在")
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ var firstId, secondId, thirdId, fourthId, fifthId, lastId int
|
|
|
method = "classify/get_or_add"
|
|
|
classifyFirstMap := make(map[string]interface{})
|
|
|
classifyFirstMap["ClassifyName"] = classifyFirst
|
|
|
classifyFirstMap["ParentId"] = 0
|
|
|
classifyFirstMap["Level"] = 0
|
|
|
classifyFirstMap["ClassifyType"] = 0
|
|
|
- result, err := PostEdbLib(classifyFirstMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + err.Error())
|
|
|
+ result, e := PostEdbLib(classifyFirstMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFirst PostEdbLib err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
resp := new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类1失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- classifySecondMap := make(map[string]interface{})
|
|
|
- classifySecondMap["ClassifyName"] = classifySecond
|
|
|
- classifySecondMap["ParentId"] = resp.Data.ClassifyId
|
|
|
- classifySecondMap["Level"] = 1
|
|
|
- classifySecondMap["ClassifyType"] = 0
|
|
|
- result, err = PostEdbLib(classifySecondMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + err.Error())
|
|
|
+ if e = json.Unmarshal(result, &resp); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFirst json unmarshal err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类2失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- classifyThreeMap := make(map[string]interface{})
|
|
|
- classifyThreeMap["ClassifyName"] = classifyThree
|
|
|
- classifyThreeMap["ParentId"] = resp.Data.ClassifyId
|
|
|
- classifyThreeMap["Level"] = 2
|
|
|
- classifyThreeMap["ClassifyType"] = 0
|
|
|
- result, err = PostEdbLib(classifyThreeMap, method)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- resp = new(models.ClassifyResp)
|
|
|
- err = json.Unmarshal(result, &resp)
|
|
|
- if err != nil {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + err.Error())
|
|
|
- return
|
|
|
+ err = fmt.Errorf("ClassifyFirst resp msg: %s; errMsg: %s", resp.Msg, resp.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ firstId = resp.Data.ClassifyId
|
|
|
+ lastId = firstId
|
|
|
+
|
|
|
+ // 二级分类
|
|
|
+ if classifySecond != "" {
|
|
|
+ classifySecondMap := make(map[string]interface{})
|
|
|
+ classifySecondMap["ClassifyName"] = classifySecond
|
|
|
+ classifySecondMap["ParentId"] = firstId
|
|
|
+ classifySecondMap["Level"] = 1
|
|
|
+ classifySecondMap["ClassifyType"] = 0
|
|
|
+ res2, e := PostEdbLib(classifySecondMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySecond PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp2 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res2, &resp2); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySecond json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp2.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySecond resp msg: %s; errMsg: %s", resp2.Msg, resp2.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ secondId = resp2.Data.ClassifyId
|
|
|
+ lastId = secondId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 三级分类
|
|
|
+ if classifyThree != "" {
|
|
|
+ classifyThreeMap := make(map[string]interface{})
|
|
|
+ classifyThreeMap["ClassifyName"] = classifyThree
|
|
|
+ classifyThreeMap["ParentId"] = secondId
|
|
|
+ classifyThreeMap["Level"] = 2
|
|
|
+ classifyThreeMap["ClassifyType"] = 0
|
|
|
+ res3, e := PostEdbLib(classifyThreeMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyThird PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp3 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res3, &resp3); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyThird json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp3.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyThird resp msg: %s; errMsg: %s", resp3.Msg, resp3.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ thirdId = resp3.Data.ClassifyId
|
|
|
+ lastId = thirdId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 四级分类
|
|
|
+ if classifyFourth != "" {
|
|
|
+ classifyFourthMap := make(map[string]interface{})
|
|
|
+ classifyFourthMap["ClassifyName"] = classifyFourth
|
|
|
+ classifyFourthMap["ParentId"] = thirdId
|
|
|
+ classifyFourthMap["Level"] = 3
|
|
|
+ classifyFourthMap["ClassifyType"] = 0
|
|
|
+ res4, e := PostEdbLib(classifyFourthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFourth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp4 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res4, &resp4); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFourth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp4.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFourth resp msg: %s; errMsg: %s", resp4.Msg, resp4.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fourthId = resp4.Data.ClassifyId
|
|
|
+ lastId = fourthId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 五级分类
|
|
|
+ if classifyFifth != "" {
|
|
|
+ classifyFifthMap := make(map[string]interface{})
|
|
|
+ classifyFifthMap["ClassifyName"] = classifyFifth
|
|
|
+ classifyFifthMap["ParentId"] = fourthId
|
|
|
+ classifyFifthMap["Level"] = 4
|
|
|
+ classifyFifthMap["ClassifyType"] = 0
|
|
|
+ res5, e := PostEdbLib(classifyFifthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFifth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp5 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res5, &resp5); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifyFifth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp5.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifyFifth resp msg: %s; errMsg: %s", resp5.Msg, resp5.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fifthId = resp5.Data.ClassifyId
|
|
|
+ lastId = fifthId
|
|
|
+ }
|
|
|
+
|
|
|
+ // 六级分类
|
|
|
+ if classifySixth != "" {
|
|
|
+ classifySixthMap := make(map[string]interface{})
|
|
|
+ classifySixthMap["ClassifyName"] = classifySixth
|
|
|
+ classifySixthMap["ParentId"] = fifthId
|
|
|
+ classifySixthMap["Level"] = 5
|
|
|
+ classifySixthMap["ClassifyType"] = 0
|
|
|
+ res6, e := PostEdbLib(classifySixthMap, method)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySixth PostEdbLib err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp6 := new(models.ClassifyResp)
|
|
|
+ if e = json.Unmarshal(res6, &resp6); e != nil {
|
|
|
+ err = fmt.Errorf("ClassifySixth json unmarshal err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if resp6.Ret != 200 {
|
|
|
+ err = fmt.Errorf("ClassifySixth resp msg: %s; errMsg: %s", resp6.Msg, resp6.ErrMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ lastId = resp6.Data.ClassifyId
|
|
|
}
|
|
|
|
|
|
- if resp.Ret != 200 {
|
|
|
- utils.FileLog.Info("初始化分类3失败:" + resp.Msg + ";" + resp.ErrMsg)
|
|
|
- return
|
|
|
- }
|
|
|
method = "edb_info/add"
|
|
|
indexMap := make(map[string]interface{})
|
|
|
indexMap["Source"] = IndexSourceMap[source]
|
|
@@ -666,7 +923,7 @@ func InitBaseIndexDataFromDataSourceSmm(filePath string) {
|
|
|
indexMap["EdbName"] = indexName
|
|
|
indexMap["Frequency"] = frequency
|
|
|
indexMap["Unit"] = unit
|
|
|
- indexMap["ClassifyId"] = resp.Data.ClassifyId
|
|
|
+ indexMap["ClassifyId"] = lastId
|
|
|
admin := mobileMap[mobile]
|
|
|
if admin != nil {
|
|
|
indexMap["AdminId"] = admin.AdminId
|