Pārlūkot izejas kodu

撒料计划查询sql方式修改

bsj 2 gadi atpakaļ
vecāks
revīzija
36bacc0653
1 mainītis faili ar 28 papildinājumiem un 26 dzēšanām
  1. 28 26
      routers/api/spillage.go

+ 28 - 26
routers/api/spillage.go

@@ -814,32 +814,34 @@ func GetSpillage(c *gin.Context) {
 	}
 
 	if refresh == 0 || refresh == 1 {
-		lppList, err := tx.SQL(`SELECT
-	ifnull((select eqcode from tmr where pastureid =lpplan.pastureid and id = lpplan.tmrid ),lpplan.tmrname) tmrname,trim(tmrid) tmrid,sort,sel,
-	CASE times
-	WHEN 1 THEN
-	'第一班'
-WHEN 2 THEN
-'第二班'
-WHEN 3 THEN
-'第三班'
-WHEN 4 THEN
-'第四班'
-END timesstr,issplit,
-times,display,begintime,
-(select tname from feedtemplet where pastureid =lpplan.pastureid and id = lpplan.ftid ) ftname,sumcowcount,
-IFNULL(round((SELECT SUM(lpplandtl1.lweight) FROM lpplandtl1 WHERE lpplandtl1.lppid=lpplan.id),2),0) sumweight ,
-ifnull((select maxstirfeed from tmr where pastureid =lpplan.pastureid and id = lpplan.tmrid ),100000) maxweight,
-TRIM(ftid) ftid,
-TRIM(id) id,
-TRIM(id) lppid,
-TRIM(pastureid) pastureid
-
-FROM
-  lpplan
-WHERE pastureid = ?   and times <= (SELECT sysopt.inforvalue  FROM sysopt 
- WHERE sysopt.pastureid= lpplan.pastureid  AND sysopt.inforname='times')
-ORDER BY  lpplan.sort`, pastureid).Query().List()
+		sqlstr := `SELECT
+		ifnull((select eqcode from tmr where pastureid =lpplan.pastureid and id = lpplan.tmrid ),lpplan.tmrname) tmrname,trim(tmrid) tmrid,sort,sel,
+		CASE times
+		WHEN 1 THEN
+		'第一班'
+	WHEN 2 THEN
+	'第二班'
+	WHEN 3 THEN
+	'第三班'
+	WHEN 4 THEN
+	'第四班'
+	END timesstr,issplit,
+	times,display,begintime,
+	(select tname from feedtemplet where pastureid =lpplan.pastureid and id = lpplan.ftid ) ftname,sumcowcount,
+	IFNULL(round((SELECT SUM(lpplandtl1.lweight) FROM lpplandtl1 WHERE lpplandtl1.lppid=lpplan.id),2),0) sumweight ,
+	ifnull((select maxstirfeed from tmr where pastureid =lpplan.pastureid and id = lpplan.tmrid ),100000) maxweight,
+	TRIM(ftid) ftid,
+	TRIM(id) id,
+	TRIM(id) lppid,
+	TRIM(pastureid) pastureid
+	
+	FROM
+	  lpplan
+	WHERE pastureid = ?   and times <= (SELECT sysopt.inforvalue  FROM sysopt 
+	 WHERE sysopt.pastureid= lpplan.pastureid  AND sysopt.inforname='times')
+	ORDER BY  lpplan.sort`
+		session := tx.SQL(sqlstr, pastureid)
+		lppList, err := session.Query().List()
 		if err != nil {
 			log.Println("GetSpillage-error-3: ", err)
 			appG.Response(http.StatusOK, e.ERROR, nil)