|  | @@ -3151,11 +3151,11 @@ func UpdateFTdetail(c *gin.Context) {
 | 
	
		
			
				|  |  |  				WHERE fp.pastureid = ? AND fp.ptsfid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		fpdDataList, err = tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,0) weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
 | 
	
		
			
				|  |  | +		fpdDataList, err = tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,0) weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ptsid ) ptsid ,
 | 
	
		
			
				|  |  |  		(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,0 AS fttype,cowcount,ccountradio,1 isfill  FROM fpdetail
 | 
	
		
			
				|  |  |  		WHERE fpdetail.pastureid = ?    and (ptid = ? or ptsid = ?)
 | 
	
		
			
				|  |  |  		UNION
 | 
	
		
			
				|  |  | -		SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,0) weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
 | 
	
		
			
				|  |  | +		SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,0) weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ptsid ) ptsid ,
 | 
	
		
			
				|  |  |  		(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,1 AS fttype,cowcount,ccountradio,0 isfill  FROM fpdetail
 | 
	
		
			
				|  |  |  		WHERE fpdetail.pastureid = ?  and (ptid = ? or ptsid = ?)) t
 | 
	
		
			
				|  |  |  		order by t.barname,t.times`, parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"], parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"]).Query().List()
 | 
	
	
		
			
				|  | @@ -3523,11 +3523,11 @@ func UpdateFpdetailBar(c *gin.Context) {
 | 
	
		
			
				|  |  |  		ftmap["ptsid"] = list.Get("ptsid").ValueStr()
 | 
	
		
			
				|  |  |  		// fmt.Println(ftmap)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		fpdDataList, err := tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(-1 ) ptsid ,
 | 
	
		
			
				|  |  | +		fpdDataList, err := tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(-1 ) ptsid ,
 | 
	
		
			
				|  |  |  			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,0 AS fttype,cowcount,ccountradio,1 isfill  FROM fpdetail
 | 
	
		
			
				|  |  |  			WHERE fpdetail.pastureid = ?   and barid =(select barid from feedp where id = ? )  and  times = ?
 | 
	
		
			
				|  |  |  			UNION
 | 
	
		
			
				|  |  | -			SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
 | 
	
		
			
				|  |  | +			SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ifnull(ptsid,-1) ) ptsid ,
 | 
	
		
			
				|  |  |  			(select bname  from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,1 AS fttype,cowcount,ccountradio,0 isfill  FROM fpdetail
 | 
	
		
			
				|  |  |  			WHERE fpdetail.pastureid = ?  and barid = (select barid from feedp where id = ? )  and  times = ? ) t
 | 
	
		
			
				|  |  |  			order by t.barname,t.times`, pastureid, id, ftmap["times"], pastureid, id, ftmap["times"]).Query().List()
 | 
	
	
		
			
				|  | @@ -3641,7 +3641,6 @@ func UpdateFpdetailBar(c *gin.Context) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	fmt.Println("33333333333333")
 | 
	
		
			
				|  |  |  	tx.Commit()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	now := time.Now()
 | 
	
	
		
			
				|  | @@ -3652,20 +3651,6 @@ func UpdateFpdetailBar(c *gin.Context) {
 | 
	
		
			
				|  |  |  		return
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	// newFpdDataList, err := tx.SQL(` select *  from fpdetail where barid = ? and pastureid = ? `, id, pastureid).Query().List()
 | 
	
		
			
				|  |  | -	// if err != nil {
 | 
	
		
			
				|  |  | -	// 	logs.Error(err)
 | 
	
		
			
				|  |  | -	// 	appG.Response(http.StatusOK, e.ERROR, false)
 | 
	
		
			
				|  |  | -	// 	return
 | 
	
		
			
				|  |  | -	// }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	// newFeedpList, err := tx.SQL(` select *  from feedp    where barid = ? and pastureid = ?`, id, pastureid).Query().List()
 | 
	
		
			
				|  |  | -	// if err != nil {
 | 
	
		
			
				|  |  | -	// 	logs.Error(err)
 | 
	
		
			
				|  |  | -	// 	appG.Response(http.StatusOK, e.ERROR, false)
 | 
	
		
			
				|  |  | -	// 	return
 | 
	
		
			
				|  |  | -	// }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  	for _, newLpplandtl1 := range newLpplandtl1List {
 | 
	
		
			
				|  |  |  		_, err := tx.SQL(` insert into lpplandtl1history(pastureid,lppid,barid,barname,fpdid,fttype,lweight,sort,tmrid,tmrname,
 | 
	
		
			
				|  |  |  						background,cowcount,ccountradio,lweighthis,createdate,userId)
 |