shawei_zz пре 2 година
родитељ
комит
1b0b276171
1 измењених фајлова са 37 додато и 6 уклоњено
  1. 37 6
      routers/api/report.go

+ 37 - 6
routers/api/report.go

@@ -668,7 +668,6 @@ func getAccuracyV4(queryList []map[string]interface{}, queryListSum []map[string
 	temsmap := make(map[interface{}]interface{})
 	mapc2 := make(map[interface{}]interface{})
 	mapc3 := make(map[interface{}]interface{})
-
 	data3 := []interface{}{}
 	datamap2child := make(map[string]interface{})
 	data2 := []interface{}{}
@@ -682,11 +681,13 @@ func getAccuracyV4(queryList []map[string]interface{}, queryListSum []map[string
 	var tem interface{}
 	var temstr interface{}
 	var typestr interface{}
+	//var sort interface{}
 
 	for i := 0; i < len(queryList); i++ { // 获取所有饲料种类
 		if i == 0 {
 			temstr = queryList[i]["fname"]
 			typestr = queryList[i]["typestr"]
+			//sort = queryList[i]["sort"]
 		}
 
 		if temstr == queryList[i]["fname"] {
@@ -738,7 +739,6 @@ func getAccuracyV4(queryList []map[string]interface{}, queryListSum []map[string
 	}
 
 	for i := 0; i < len(queryList); i++ {
-
 		a = mapc2[queryList[i]["feedname"]].(int) * 4
 		if i == 0 {
 			datamap2["label"] = "饲料名称"
@@ -832,14 +832,45 @@ func getAccuracyV4(queryList []map[string]interface{}, queryListSum []map[string
 			data3 = []interface{}{}
 		}
 	}
+	var sortSum []string
+	for z := 0; z < len(data2); z++ {
+		ss := data2[z].(map[string]interface{})
+		bb := ss["label"].(string)
+		if bb != "合计" {
+			sortSum = append(sortSum, bb)
+		}
+	}
+	sort.Strings(sortSum)
+	//fmt.Println(sortSum)
+	theEndSort := []interface{}{}
+	for ii := 0; ii < len(data2); ii++ {
+		ss := data2[ii].(map[string]interface{})
+		bb := ss["label"].(string)
+		if "饲料名称" == bb {
+			theEndSort = append(theEndSort, data2[ii])
+		}
+	}
 
+	for _, v := range sortSum {
+		for ii := 0; ii < len(data2); ii++ {
+			ss := data2[ii].(map[string]interface{})
+			bb := ss["label"].(string)
+			if v == bb {
+				theEndSort = append(theEndSort, data2[ii])
+			}
+		}
+	}
+	for ii := 0; ii < len(data2); ii++ {
+		ss := data2[ii].(map[string]interface{})
+		bb := ss["label"].(string)
+		if "合计" == bb {
+			theEndSort = append(theEndSort, data2[ii])
+		}
+	}
 	data1 = append(data1, datamap1)
-
 	chartData["data1"] = data1
-	chartData["data2"] = data2
-
+	chartData["data2"] = theEndSort
 	queryData["list"] = chartData
-
 	queryData["code"] = 0
 	queryData["message"] = "ok"
 	queryData["data"] = queryList