baishaojie il y a 4 mois
Parent
commit
980ce039b4
4 fichiers modifiés avec 16 ajouts et 13 suppressions
  1. BIN
      TMRWatchComm
  2. BIN
      TMRWatchComm.zip
  3. 3 3
      conf/app.ini
  4. 13 10
      http/handle/yq/yq.go

BIN
TMRWatchComm


BIN
TMRWatchComm.zip


+ 3 - 3
conf/app.ini

@@ -48,8 +48,8 @@ Type = mysql
 User = root
 Password = root
 #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 = haiyuan
 #Password = root
 #Password = root
@@ -73,7 +73,7 @@ Host = 192.168.1.93:3326
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = yq2
+Name = tmrwatch2
 TablePrefix =
 
 ShowXormlog = false

+ 13 - 10
http/handle/yq/yq.go

@@ -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配方",