|
@@ -37,8 +37,8 @@ func YqCron() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- // token := getToken()
|
|
|
|
- // syncBar(token, pastureinfo.Pastureid)
|
|
|
|
|
|
+ token := getToken()
|
|
|
|
+ syncBar(token, pastureinfo.Pastureid, pastureinfo.Werks)
|
|
c := cron.New()
|
|
c := cron.New()
|
|
c.AddFunc("0 0 1 * * *", func() {
|
|
c.AddFunc("0 0 1 * * *", func() {
|
|
token := getToken()
|
|
token := getToken()
|
|
@@ -49,7 +49,7 @@ func YqCron() {
|
|
YcUtirPush(pastureinfo.Pastureid, pastureinfo.Werks, now, token)
|
|
YcUtirPush(pastureinfo.Pastureid, pastureinfo.Werks, now, token)
|
|
YcMaterialIssuePush(pastureinfo.Pastureid, pastureinfo.Werks, now, token)
|
|
YcMaterialIssuePush(pastureinfo.Pastureid, pastureinfo.Werks, now, token)
|
|
YcBarFeedRemainPush(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() {
|
|
c.AddFunc("0 0 6 * * *", func() {
|
|
@@ -555,7 +555,7 @@ func YcMaterialIssuePush(pastureId, farmId, date, token string) error {
|
|
return nil
|
|
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)
|
|
req, err := http.NewRequest("GET", "https://vmuyun.com/project-server/openApi/feeding/penList", nil)
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
@@ -582,35 +582,35 @@ func syncBar(token, pastureid string) {
|
|
for _, item := range dataList {
|
|
for _, item := range dataList {
|
|
arg := item.(map[string]interface{})
|
|
arg := item.(map[string]interface{})
|
|
fmt.Println(arg)
|
|
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 = ? `
|
|
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 = 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 = 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 = 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 =5 ),0) times5 ,
|
|
ifnull((select tratio from fpdetail where barid = fp.barid and times =6 ),0) times6
|
|
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
|
|
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}]}
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|