| 
					
				 | 
			
			
				@@ -584,15 +584,18 @@ func syncBar(token, pastureid, werks string) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		arg := item.(map[string]interface{}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		fmt.Println(arg) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if fmt.Sprintf("%v", arg["farmId"]) == werks { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if _, ok := arg["sheepCount"]; !ok { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				arg["sheepCount"] = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			_, err := tx.Exec(` insert into bar(pen,bname,bcode,pastureid)values(?,?,?,?)  ON DUPLICATE KEY UPDATE  pen = ? `, arg["districtName"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]), fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]), pastureid, arg["houseName"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				fmt.Sprintf("%v-%v-%v", arg["districtName"], arg["houseName"], arg["compartmentName"]), fmt.Sprintf("%v-%v-%v", arg["districtName"], arg["houseName"], arg["compartmentName"]), pastureid, arg["districtName"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			fmt.Println(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			insertSql := `insert into feedp(pastureid,barname,barid,ccount)VALUES(?,?,(select id from bar where bname = ?),?) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				ON DUPLICATE KEY UPDATE ccount = ? ,barname = ?  ` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					ON DUPLICATE KEY UPDATE ccount = ? ,barname = ?  ` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			_, err = tx.SQL(insertSql, pastureid, fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]), arg["sheepCount"], arg["sheepCount"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"])).Execute() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				fmt.Sprintf("%v-%v-%v", arg["districtName"], arg["houseName"], arg["compartmentName"]), arg["sheepCount"], arg["sheepCount"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				fmt.Sprintf("%v-%v-%v", arg["districtName"], arg["houseName"], arg["compartmentName"])).Execute() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			fmt.Println(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// tx.SQL(` select  from feedp where barname = ? `) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -601,12 +604,12 @@ func syncBar(token, pastureid, werks string) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// b.BarName = fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// b.Ccount = arg["sheepCount"] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			err = tx.SQL(`	select fp.barname,fp.ccount,ratio,ft.tname ftname,ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 1 ),0) times1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 2 ),0) times2 , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 3 ),0) times3 , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 4 ),0) times4 , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ifnull((select tratio from fpdetail  where barid = fp.barid  and times =5 ),0) times5  , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ifnull((select tratio from fpdetail  where barid = fp.barid  and times =6 ),0) times6   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		 from feedp fp  join feedtemplet ft on ft.id = fp.ftid  where ratio > 0 and fp.barname = ? `, fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"])).GetFirst(b).Error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 2 ),0) times2 , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 3 ),0) times3 , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 4 ),0) times4 , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ifnull((select tratio from fpdetail  where barid = fp.barid  and times =5 ),0) times5  , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ifnull((select tratio from fpdetail  where barid = fp.barid  and times =6 ),0) times6 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 from feedp fp  join feedtemplet ft on ft.id = fp.ftid  where ratio > 0 and fp.barname = ? `, fmt.Sprintf("%v-%v-%v", arg["districtName"], arg["houseName"], arg["compartmentName"])).GetFirst(b).Error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			fmt.Println(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			fpdBatchEdit(pastureid, b) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// {"pastureId":"1653271339","barList":[{"barname":"14","ccount":155,"ratio":"100.00","ftname":"高产2配方", 
			 |