浏览代码

库存管理排序

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