Selaa lähdekoodia

羊场栏舍同步调整

baishaojie 5 kuukautta sitten
vanhempi
commit
e0ddbdc1f6
3 muutettua tiedostoa jossa 28 lisäystä ja 28 poistoa
  1. BIN
      __debug_bin.exe
  2. 3 3
      conf/app.ini
  3. 25 25
      http/handle/yq/yq.go

BIN
__debug_bin.exe


+ 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 = 127.0.0.1:3316
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = tmrwatch2
+Name = yq2
 TablePrefix =
 
 ShowXormlog = false

+ 25 - 25
http/handle/yq/yq.go

@@ -37,8 +37,8 @@ func YqCron() {
 		return
 	}
 
-	// token := getToken()
-	// syncBar(token, pastureinfo.Pastureid)
+	token := getToken()
+	syncBar(token, pastureinfo.Pastureid, pastureinfo.Werks)
 	c := cron.New()
 	c.AddFunc("0 0 1 * * *", func() {
 		token := getToken()
@@ -49,7 +49,7 @@ func YqCron() {
 		YcUtirPush(pastureinfo.Pastureid, pastureinfo.Werks, now, token)
 		YcMaterialIssuePush(pastureinfo.Pastureid, pastureinfo.Werks, now, token)
 		YcBarFeedRemainPush(pastureinfo.Pastureid, pastureinfo.Werks, now, token)
-		syncBar(token, pastureinfo.Pastureid)
+		syncBar(token, pastureinfo.Pastureid, pastureinfo.Werks)
 	})
 
 	c.AddFunc("0 0 6 * * *", func() {
@@ -555,7 +555,7 @@ func YcMaterialIssuePush(pastureId, farmId, date, token string) error {
 	return nil
 }
 
-func syncBar(token, pastureid string) {
+func syncBar(token, pastureid, werks string) {
 	req, err := http.NewRequest("GET", "https://vmuyun.com/project-server/openApi/feeding/penList", nil)
 	if err != nil {
 		logs.Error(err)
@@ -582,35 +582,35 @@ func syncBar(token, pastureid string) {
 	for _, item := range dataList {
 		arg := item.(map[string]interface{})
 		fmt.Println(arg)
-		// arg["sheepCount"] = 150
-		_, 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.Println(err)
+		if fmt.Sprintf("%v", arg["farmId"]) == werks {
+			_, 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.Println(err)
 
-		insertSql := `insert into feedp(pastureid,barname,barid,ccount)VALUES(?,?,(select id from bar where bname = ?),?)
+			insertSql := `insert into feedp(pastureid,barname,barid,ccount)VALUES(?,?,(select id from bar where bname = ?),?)
 				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.Println(err)
-		// tx.SQL(` select  from feedp where barname = ? `)
-
-		// barList := make([]*bar,0)
-		b := new(bar)
-		// 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,
+			_, 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.Println(err)
+			// tx.SQL(` select  from feedp where barname = ? `)
+
+			// barList := make([]*bar,0)
+			b := new(bar)
+			// 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
-		fmt.Println(err)
-		fpdBatchEdit(pastureid, b)
-		// {"pastureId":"1653271339","barList":[{"barname":"14","ccount":155,"ratio":"100.00","ftname":"高产2配方",
-		// "times1":"41","times2":"25","times3":"25","times4":0,"times5":0,"times6":0}]}
-
+			fmt.Println(err)
+			fpdBatchEdit(pastureid, b)
+			// {"pastureId":"1653271339","barList":[{"barname":"14","ccount":155,"ratio":"100.00","ftname":"高产2配方",
+			// "times1":"41","times2":"25","times3":"25","times4":0,"times5":0,"times6":0}]}
+		}
 	}
 }