|
@@ -163,17 +163,17 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
} else {
|
|
|
isAdd = 1
|
|
|
}
|
|
|
- fromZoneId := 0
|
|
|
- toZoneId := 0
|
|
|
+ fromZoneIdsStr := ""
|
|
|
+ toZoneIdsStr := ""
|
|
|
|
|
|
if len(req.FromZoneIds) > 0 {
|
|
|
for _, v := range req.FromZoneIds {
|
|
|
- fromZoneId = v
|
|
|
+ fromZoneIdsStr = fmt.Sprintf("%s%d,", fromZoneIdsStr, v)
|
|
|
}
|
|
|
}
|
|
|
if len(req.ToZoneIds) > 0 {
|
|
|
for _, v := range req.ToZoneIds {
|
|
|
- toZoneId = v
|
|
|
+ toZoneIdsStr = fmt.Sprintf("%s%d,", toZoneIdsStr, v)
|
|
|
}
|
|
|
}
|
|
|
// 批量新增指标
|
|
@@ -183,8 +183,8 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
indexObj.Frequency = indexInfo.Frequency
|
|
|
indexObj.ClassifyId = int(classifyId)
|
|
|
indexObj.ProductNames = req.ProductNames
|
|
|
- indexObj.FromZoneId = fromZoneId
|
|
|
- indexObj.ToZoneId = toZoneId
|
|
|
+ indexObj.FromZoneId = fromZoneIdsStr
|
|
|
+ indexObj.ToZoneId = toZoneIdsStr
|
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
|
indexObj.ToZoneName = req.ToZoneNames
|
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
@@ -219,6 +219,8 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
indexObj.Frequency = indexInfo.Frequency
|
|
|
indexObj.ClassifyId = int(classifyId)
|
|
|
indexObj.ProductNames = req.ProductNames
|
|
|
+ indexObj.FromZoneId = fromZoneIdsStr
|
|
|
+ indexObj.ToZoneId = toZoneIdsStr
|
|
|
indexObj.FromZoneName = req.FromZoneNames
|
|
|
indexObj.ToZoneName = req.ToZoneNames
|
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
@@ -233,6 +235,8 @@ func AddKplerIndexByApi(indexList []*models.KplerIndexItem, req *models.KplerSea
|
|
|
updateColsArr = append(updateColsArr, "index_name")
|
|
|
updateColsArr = append(updateColsArr, "classify_id")
|
|
|
updateColsArr = append(updateColsArr, "product_names")
|
|
|
+ updateColsArr = append(updateColsArr, "from_zone_id")
|
|
|
+ updateColsArr = append(updateColsArr, "to_zone_id")
|
|
|
updateColsArr = append(updateColsArr, "from_zone_name")
|
|
|
updateColsArr = append(updateColsArr, "to_zone_name")
|
|
|
updateColsArr = append(updateColsArr, "flow_direction")
|
|
@@ -483,10 +487,40 @@ func handleKplerIndex(req *models.HandleKplerExcelData, terminalCode string, cla
|
|
|
req.ClassifyName = productNames[0]
|
|
|
}
|
|
|
}
|
|
|
- fromZoneNamesStr := req.FromZoneName
|
|
|
+ fromZoneNamesStr := req.FromZoneNames
|
|
|
flowDirection := req.FlowDirection
|
|
|
- toZoneNamesStr := req.ToZoneName
|
|
|
+ toZoneNamesStr := req.ToZoneNames
|
|
|
productNamesStr := req.ProductNames
|
|
|
+
|
|
|
+ // 查询fromZoneIds
|
|
|
+ zoneObj := new(models.BaseFromKplerZone)
|
|
|
+ fromZoneNames := strings.Split(fromZoneNamesStr, ",")
|
|
|
+ fromZoneIdsStr := ""
|
|
|
+ // 查询 zone
|
|
|
+ if len(fromZoneNames) > 0 {
|
|
|
+ fromZoneIds, er := zoneObj.GetIdsByZoneNames(fromZoneNames)
|
|
|
+ if er != nil {
|
|
|
+ err = fmt.Errorf("查询区域失败 Err:%s", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range fromZoneIds {
|
|
|
+ fromZoneIdsStr = fmt.Sprintf("%s%d,", fromZoneIdsStr, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询toZoneIds
|
|
|
+ toZoneNames := strings.Split(toZoneNamesStr, ",")
|
|
|
+ toZoneIdsStr := ""
|
|
|
+ if len(toZoneNames) > 0 {
|
|
|
+ toZoneIds, er := zoneObj.GetIdsByZoneNames(toZoneNames)
|
|
|
+ if er != nil {
|
|
|
+ err = fmt.Errorf("查询区域失败 Err:%s", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range toZoneIds {
|
|
|
+ toZoneIdsStr = fmt.Sprintf("%s%d,", toZoneIdsStr, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
// 拼接指标编码
|
|
|
prefixIndexCode := fmt.Sprintf("k%s%s%s%s", fromZoneNamesStr, flowDirection, toZoneNamesStr, productNamesStr)
|
|
|
// 获取首字母
|
|
@@ -556,10 +590,10 @@ func handleKplerIndex(req *models.HandleKplerExcelData, terminalCode string, cla
|
|
|
indexObj.Frequency = getKplerFrequency(req.Granularity)
|
|
|
indexObj.ClassifyId = int(classifyId)
|
|
|
indexObj.ProductNames = req.ProductNames
|
|
|
- indexObj.FromZoneId = req.FromZoneId
|
|
|
- indexObj.FromZoneName = req.FromZoneName
|
|
|
- indexObj.ToZoneId = req.ToZoneId
|
|
|
- indexObj.ToZoneName = req.ToZoneName
|
|
|
+ indexObj.FromZoneId = fromZoneIdsStr
|
|
|
+ indexObj.ToZoneId = toZoneIdsStr
|
|
|
+ indexObj.FromZoneName = fromZoneNamesStr
|
|
|
+ indexObj.ToZoneName = toZoneNamesStr
|
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
|
indexObj.Granularity = req.Granularity
|
|
|
indexObj.Split = req.Split
|
|
@@ -591,10 +625,8 @@ func handleKplerIndex(req *models.HandleKplerExcelData, terminalCode string, cla
|
|
|
indexObj.Frequency = getKplerFrequency(req.Granularity)
|
|
|
indexObj.ClassifyId = int(classifyId)
|
|
|
indexObj.ProductNames = req.ProductNames
|
|
|
- indexObj.FromZoneId = req.FromZoneId
|
|
|
- indexObj.FromZoneName = req.FromZoneName
|
|
|
- indexObj.ToZoneId = req.ToZoneId
|
|
|
- indexObj.ToZoneName = req.ToZoneName
|
|
|
+ indexObj.FromZoneName = fromZoneNamesStr
|
|
|
+ indexObj.ToZoneName = toZoneNamesStr
|
|
|
indexObj.FlowDirection = req.FlowDirection
|
|
|
indexObj.Granularity = req.Granularity
|
|
|
indexObj.Split = req.Split
|