Forráskód Böngészése

过程分析折线图

shawei_zz 2 éve
szülő
commit
ee16b968d3
1 módosított fájl, 11 hozzáadás és 5 törlés
  1. 11 5
      routers/api/report.go

+ 11 - 5
routers/api/report.go

@@ -53,10 +53,12 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 			quertDataList := queryData["list"]
 			query := quertDataList.(map[string]interface{})
 			querys, _ := GetprocessAnalysisTB(parammaps, tx, quertDataList, queryList)
-			query["data1"] = querys["WTime"]
-			query["data2"] = querys["data2"]
-			query["data3"] = querys["realWandT"]
-			query["data5"] = querys["data5"]
+			if len(querys) != 0 {
+				query["data1"] = querys["WTime"]
+				query["data2"] = querys["data2"]
+				query["data3"] = querys["realWandT"]
+				query["data5"] = querys["data5"]
+			}
 		}
 	case "getHomepro":
 		queryData, err = getAccuracyV3(queryList)
@@ -1041,6 +1043,7 @@ func getAccuracy(queryList []map[string]interface{}) (map[string]interface{}, er
 //统计分析过程分析data值拆分
 func GetprocessAnalysisTB(parammaps *gofasion.Fasion, tx *xorm.Session, quertDataList interface{}, queryList []map[string]interface{}) (query map[string]interface{}, err error) {
 	sql1, p1 := restful.GetSqlByNameDBT("getweightjson", tx)
+	query1 := make(map[string]interface{}, 0)
 	s_params1 := make([]interface{}, 0)
 	if sql1 != "" {
 		paramslist := strings.Split(p1, ",")
@@ -1051,6 +1054,9 @@ func GetprocessAnalysisTB(parammaps *gofasion.Fasion, tx *xorm.Session, quertDat
 		}
 	}
 	queryList2, err := tx.SQL(sql1, s_params1...).Query().List()
+	if len(queryList2) == 0 {
+		return query1, nil
+	}
 	if err != nil {
 		fmt.Println("查询配料出错")
 		return nil, err
@@ -1087,7 +1093,7 @@ func GetprocessAnalysisTB(parammaps *gofasion.Fasion, tx *xorm.Session, quertDat
 		querySlice = append(querySlice, queryList[i]["intime"], queryList[i]["actualweight"], queryList[i]["allname"], queryList[i]["fname"])
 		data5 = append(data5, querySlice)
 	}
-	query1 := make(map[string]interface{}, 0)
+
 	query1["WTime"] = WTime
 	query1["data2"] = data2
 	query1["data5"] = data5