baishaojie 3 hete
szülő
commit
61366d54de
6 módosított fájl, 60 hozzáadás és 19 törlés
  1. BIN
      TMRWatchComm
  2. BIN
      TMRWatchComm.zip
  3. 3 3
      conf/app-test.ini
  4. 19 13
      http/handle/api/ops.go
  5. 38 3
      http/handle/restful/sql_utils.go
  6. BIN
      tmr-watch.exe

BIN
TMRWatchComm


BIN
TMRWatchComm.zip


+ 3 - 3
conf/app-test.ini

@@ -52,8 +52,8 @@ User = root
 #Password = root
 #Password = kepaiteng!QAZ
 #Host = 8.130.17.8:3306
-Host = 192.168.1.93:3326
-#Host = 127.0.0.1:3316
+#Host = 192.168.1.93:3326
+Host = 127.0.0.1:3316
 #Name = root
 Password = root
 #Password = root
@@ -77,7 +77,7 @@ Password = root
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = yq2
+Name = tmrwatch2
 TablePrefix =
 
 ShowXormlog = false

+ 19 - 13
http/handle/api/ops.go

@@ -230,6 +230,7 @@ func GetDataByName(c *gin.Context) {
 			_ = xlsxfile.Write(c.Writer)
 
 		} else {
+			fmt.Println(time.Now())
 			if sqlnamestr == "getHomepageStr" {
 				parammaps := fsion.Get("parammaps")
 				pastureid := parammaps.Get("pastureid").ValueStr()
@@ -243,31 +244,37 @@ func GetDataByName(c *gin.Context) {
 					nowstr := now.AddDate(0, 0, -i).Format("2006-01-02")
 					go func(nowstr string) {
 						defer wg.Done()
+						fmt.Println(nowstr)
 						sqlstr := `select ifnull( getSLtimeDiffSINGEL ( ?, ? ), 0.0 ) as montime`
 						slTimeList, _ := restful.QueryByMap(sqlstr, 0, 0, []interface{}{pastureid, nowstr})
+						fmt.Println(nowstr)
 						if len(slTimeList.(map[string]interface{})["list"].([]map[string]interface{})) > 0 {
 							m, _ := strconv.ParseFloat(slTimeList.(map[string]interface{})["list"].([]map[string]interface{})[0]["montime"].(string), 64)
 							montimeList = append(montimeList, m)
 						}
 					}(nowstr)
 				}
-
+				fmt.Println(time.Now())
 				queryData, err := getDataBySqlT(sql, offset, pagecount, returntype, s_params, tx)
 				if err != nil {
 					logging.Error("GetDataByName  err: ", err)
 					msg := geterrmsg(err.Error())
 					appG.Response(http.StatusOK, e.ERROR, msg)
 				}
-
+				fmt.Println(time.Now())
 				wg.Wait()
 				for _, m := range montimeList {
 					montime += m
 				}
 				queryData.(map[string]interface{})["list"].([]map[string]interface{})[0]["montime"] = Decimal(montime / 30)
-
+				fmt.Println(time.Now())
 				appG.Response(http.StatusOK, e.SUCCESS, queryData)
 				return
 			}
+			// if sqlnamestr == "getHomepageStr" {
+
+			// }
+
 			queryData, err := getDataBySqlT(sql, offset, pagecount, returntype, s_params, tx)
 			if err != nil {
 				logging.Error("GetDataByName  err: ", err)
@@ -2156,7 +2163,6 @@ func getDataBySqlT(sqlstr string, offset, pagecount int, returntype string, para
 		queryData, err := restful.QueryByListListT(sqlstr, offset, pagecount, params, tx)
 		return queryData, err
 	} else {
-		fmt.Println(params)
 		queryData, err := restful.QueryByMapT(sqlstr, offset, pagecount, params, tx)
 		return queryData, err
 	}
@@ -4455,12 +4461,12 @@ func FpdImportExcel(c *gin.Context) {
 					if _, ok := outentry["栏舍名称"]; ok {
 						dataexcel["barname"] = outentry["栏舍名称"]
 					}
-					if _, ok := outentry["实际牛头数"]; ok {
-						dataexcel["ccount"] = outentry["实际牛头数"]
-					}
-					// if _, ok := outentry["实际羊只数"]; ok {
-					// 	dataexcel["ccount"] = outentry["实际羊只数"]
+					// if _, ok := outentry["实际牛头数"]; ok {
+					// 	dataexcel["ccount"] = outentry["实际牛头数"]
 					// }
+					if _, ok := outentry["实际羊只数"]; ok {
+						dataexcel["ccount"] = outentry["实际羊只数"]
+					}
 					if _, ok := outentry["系数(%)"]; ok {
 						dataexcel["ratio"] = outentry["系数(%)"]
 					}
@@ -9037,7 +9043,7 @@ func FpdBatchEdit(c *gin.Context) {
 			continue
 		}
 
-		/*
+		// /*
 		_, err = tx.SQL(` update  lpplandtl1  set lweight = 0 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ?  )
 		and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, dataexcel["barname"]).Execute()
 		if err != nil {
@@ -9052,7 +9058,7 @@ func FpdBatchEdit(c *gin.Context) {
 			appG.Response(http.StatusInternalServerError, e.ERROR, err)
 			return
 		}
-		*/
+		// */
 
 		dataexcel["1"] = barFsions.Get("times1").ValueStr()
 		dataexcel["2"] = barFsions.Get("times2").ValueStr()
@@ -10670,7 +10676,7 @@ func FpdBatchEditGrfd(pastureid string, barList []map[string]string) {
 		// dataexcel["5"] = barFsions.Get("times5").ValueStr()
 		// dataexcel["6"] = barFsions.Get("times6").ValueStr()
 
-		/*
+		// /*
 	
 				tx.SQL(` update  lpplandtl1  set lweight = 0  where barid = (select  id from bar where bname = ? ) and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
 				if err != nil {
@@ -10683,7 +10689,7 @@ func FpdBatchEditGrfd(pastureid string, barList []map[string]string) {
 					return
 				}
 			
-		*/
+		// */
 
 		exist, err := tx.SQL(` select id from  feedp where barid = (select  id from bar where bname = ? ) and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
 		if err != nil {

+ 38 - 3
http/handle/restful/sql_utils.go

@@ -459,9 +459,22 @@ func QueryByMapT(sqlstr string, offset, count int, params []interface{}, tx *xor
 		return 0, err
 	}
 	recordcount := int64(0)
-
+	firstPos := strings.IndexByte(sqlstr, '?')
 	if count > 1 {
-		tt, err := tx.SQL("SELECT COUNT(*) as count FROM ("+sqlstr+") a", params...).Query().List()
+		
+		var params1 []interface{}
+		if firstPos != -1 {
+			for i, a :=range  params{
+				if i== 2 {
+					params1 = append(params1,0)	
+				} else if  i == 3 {
+					params1 = append(params1,99999)	
+				}else{
+					params1 = append(params1,a)	
+				}
+			}
+
+			tt, err := tx.SQL("select count(1) count from bar where pastureid = ? and enable=1 ", params1[0]).Query().List()
 		if err != nil {
 			fmt.Println("s1", err)
 			return nil, err
@@ -480,10 +493,32 @@ func QueryByMapT(sqlstr string, offset, count int, params []interface{}, tx *xor
 
 		}
 
+		}else{
+			// params1 = append(params1, params...)
+			tt, err := tx.SQL("SELECT COUNT(*) as count FROM ("+sqlstr+") a", params...).Query().List()
+		if err != nil {
+			fmt.Println("s1", err)
+			return nil, err
+		}
+		if tt == nil {
+			recordcount = 0
+		} else {
+			switch tt[0]["count"].(type) {
+			case int64:
+				recordcount = tt[0]["count"].(int64)
+			case string:
+				temp, _ := strconv.Atoi(tt[0]["count"].(string))
+				recordcount = int64(temp)
+
+			}
+		}	
+		}
+		
+
 	}
 	queryData := make([]map[string]interface{}, 1)
 	var err error
-	if count == 0 {
+	if count == 0 ||firstPos > 0 {
 		queryData, err = tx.SQL(sqlstr, params...).Query().List()
 	} else {
 		if count > 0 && offset > 0 {

BIN
tmr-watch.exe