Bladeren bron

排序重新编写

shawei_zz 2 jaren geleden
bovenliggende
commit
0923311d04
1 gewijzigde bestanden met toevoegingen van 54 en 16 verwijderingen
  1. 54 16
      routers/api/report.go

+ 54 - 16
routers/api/report.go

@@ -27,6 +27,44 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 		}
 	}
 	queryList, err := tx.SQL(sql, s_params...).Query().List()
+	//############
+	sql2, p2 := restful.GetSqlByNameDBT("getFeednameSort", tx)
+	s_params2 := make([]interface{}, 0)
+	if sql2 != "" {
+		paramslist2 := strings.Split(p2, ",")
+		if len(paramslist2) > 0 && p != "" {
+			for _, value := range paramslist2 {
+				s_params2 = append(s_params2, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+			}
+		}
+	}
+	queryList2, err := tx.SQL(sql2, s_params2...).Query().List()
+	var feednamesort []string
+	if len(queryList2) > 0 {
+		for i := 0; i < len(queryList2); i++ {
+			feednamesort = append(feednamesort, queryList2[i]["fname"].(string))
+		}
+	}
+
+	// #########
+	sql3, p3 := restful.GetSqlByNameDBT("getFeednameSort2", tx)
+	s_params3 := make([]interface{}, 0)
+	if sql3 != "" {
+		paramslist3 := strings.Split(p3, ",")
+		if len(paramslist3) > 0 && p != "" {
+			for _, value := range paramslist3 {
+				s_params3 = append(s_params3, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+			}
+		}
+	}
+	queryList3, err := tx.SQL(sql3, s_params3...).Query().List()
+	var feednamesort3 []string
+	if len(queryList3) > 0 {
+		for z := 0; z < len(queryList3); z++ {
+			feednamesort3 = append(feednamesort3, queryList3[z]["feedname"].(string))
+		}
+	}
+
 	if err != nil {
 		return nil, err
 	}
@@ -76,7 +114,7 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 			}
 		}
 		queryListSum, _ := tx.SQL(sql1, s_params1...).Query().List()
-		queryData, err = getAccuracyV4(queryList, queryListSum, checked)
+		queryData, err = getAccuracyV4(queryList, queryListSum, checked, feednamesort3)
 	case "getPriceAn":
 		queryData, err = getAccuracyV5(queryList)
 	case "getJT1Accu":
@@ -107,14 +145,14 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 			fmt.Println(flleight)
 		}
 		flleightint, _ := strconv.Atoi(flleight)
-		queryData, err = getAccuracyV9(queryList, sqlnamestr, flleightint) //投料简打、累加
+		queryData, err = getAccuracyV9(queryList, sqlnamestr, flleightint, feednamesort) //投料简打、累加
 	default:
 		queryData, err = nil, nil
 	}
 	return
 }
 
-func getAccuracyV9(queryList []map[string]interface{}, sqlnamestr string, flleightint int) (map[string]interface{}, error) {
+func getAccuracyV9(queryList []map[string]interface{}, sqlnamestr string, flleightint int, feednamesort []string) (map[string]interface{}, error) {
 	queryData := make(map[string]interface{})
 
 	chartData := make(map[string]interface{})
@@ -179,9 +217,9 @@ func getAccuracyV9(queryList []map[string]interface{}, sqlnamestr string, flleig
 	stemEnd := []string{}
 	if sqlnamestr == "downloadPlanSFJD" {
 		bb := stem[len(stem)-flleightint : len(stem) : len(stem)]
-		aa := stem[0 : len(stem)-flleightint : len(stem)]
+		//aa := stem[0 : len(stem)-flleightint : len(stem)]
 		stemEnd = append(stemEnd, bb...)
-		stemEnd = append(stemEnd, aa...)
+		stemEnd = append(stemEnd, feednamesort...)
 		//fmt.Println(stemEnd)
 	} else {
 		stemEnd = stem
@@ -662,7 +700,7 @@ func getAccuracyV5(queryList []map[string]interface{}) (map[string]interface{},
 	queryData["data"] = queryList
 	return queryData, nil
 }
-func getAccuracyV4(queryList []map[string]interface{}, queryListSum []map[string]interface{}, checked string) (map[string]interface{}, error) {
+func getAccuracyV4(queryList []map[string]interface{}, queryListSum []map[string]interface{}, checked string, feednamesort3 []string) (map[string]interface{}, error) {
 	queryData := make(map[string]interface{})
 	chartData := make(map[string]interface{})
 	datamap1 := make(map[string]interface{})
@@ -834,15 +872,15 @@ 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)
+	//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++ {
@@ -853,7 +891,7 @@ func getAccuracyV4(queryList []map[string]interface{}, queryListSum []map[string
 		}
 	}
 
-	for _, v := range sortSum {
+	for _, v := range feednamesort3 {
 		for ii := 0; ii < len(data2); ii++ {
 			ss := data2[ii].(map[string]interface{})
 			bb := ss["label"].(string)