|
@@ -476,7 +476,7 @@ func GetFormula(pastureid string) error {
|
|
|
logging.Info("create SnowIds err", err)
|
|
|
}
|
|
|
|
|
|
- _, err = tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,backup1,backup2,tname,fttypeid,fttype) values(?,?,(select ccid from feedtemplet where pastureid = ? limit 1),?,?,?,?,1,'饲喂配方') "+
|
|
|
+ _, err = tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,backup1,backup2,tname,fttypeid,fttype) values(?,?,(select id from cowclass where pastureid = ? limit 1),?,?,?,?,1,'饲喂配方') "+
|
|
|
" ON DUPLICATE KEY UPDATE tcode=?,backup2= ?",
|
|
|
ids, pastureid, pastureid, ftId, ftId, modifiedAt, ftName, ftId, modifiedAt)
|
|
|
|
|
@@ -555,15 +555,15 @@ func AddOtherDevice() {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- queryIdList, err1 := tx.SQL(`SELECT d.pid +UNIX_TIMESTAMP(d.mydate) id,d.pid did,d.projname projName ,DATE_FORMAT(d.mydate,'%Y-%m-%d') mydate
|
|
|
+ queryIdList, err1 := tx.SQL(`SELECT d.pid +UNIX_TIMESTAMP(d.mydate) id,d.pid did,d.projname projName ,DATE_FORMAT(d.mydate,'%Y-%m-%d') mydate
|
|
|
FROM downloadedplan d
|
|
|
WHERE (d.mydate=DATE_FORMAT(NOW(),'%Y-%m-%d'))
|
|
|
AND d.isuse=0
|
|
|
AND d.pastureid =(SELECT column_default FROM information_schema.COLUMNS WHERE table_name = 'recweight' AND table_schema = 'tmrwatch2' AND column_name = 'pastureid')
|
|
|
AND (SELECT COUNT(*) FROM downloadplandtl1 d1 WHERE d.id=d1.PID AND d.pastureid=d1.pastureid AND d1.type = 0)>0
|
|
|
AND (SELECT COUNT(*) FROM downloadedplan WHERE pastureid = d.pastureid AND lpplantype in(0,1,5) and mydate = d.mydate AND pid = d.pid AND iscompleted = 0) = 0
|
|
|
- and d.lpplantype in(0,1,5) and d.iscompleted = 1
|
|
|
- GROUP BY d.pid +UNIX_TIMESTAMP(d.mydate)`).Query().List()
|
|
|
+ and d.lpplantype in(0,1) and d.iscompleted = 1
|
|
|
+ GROUP BY d.pid +UNIX_TIMESTAMP(d.mydate) `).Query().List()
|
|
|
|
|
|
queryDataList, err2 := tx.SQL(`SELECT d.pid +UNIX_TIMESTAMP(d.mydate) id,d.projname projName,ROUND(d.lweight,2) lWeight,DATE_FORMAT(d.mydate,'%Y-%m-%d') AS loadDate,d.SORT AS tmrNo,d.Times AS times,ft.backup1 AS ftId,d.templetName AS ftName,f.backup1 AS fId,
|
|
|
de.Fname AS fName,fc.FCNAME AS feedclassName,de.SORT AS sort,de.feedallowratio AS allowableError,
|
|
@@ -577,7 +577,7 @@ func AddOtherDevice() {
|
|
|
AND (SELECT COUNT(*) FROM downloadplandtl1 d1 WHERE d.id=d1.PID AND d.pastureid=d1.pastureid AND d1.type = 0)>0
|
|
|
AND (SELECT COUNT(*) FROM downloadedplan WHERE pastureid = d.pastureid and lpplantype in(0,1,5) and mydate = d.mydate AND pid = d.pid AND iscompleted = 0) = 0
|
|
|
and d.lpplantype in(0,1,5) and d.iscompleted = 1
|
|
|
- group by d.pid,de.Fname,d.mydate`).Query().List()
|
|
|
+ group by d.pid,de.Fname,d.mydate `).Query().List()
|
|
|
|
|
|
if err1 == nil && err2 == nil {
|
|
|
for i := 0; i < len(queryIdList); i++ {
|
|
@@ -771,6 +771,10 @@ func CronGRFD() {
|
|
|
}()
|
|
|
log.Println("Starting CronWXwork...")
|
|
|
c := cron.New()
|
|
|
+ //上传饲料
|
|
|
+ AddOtherDevice()
|
|
|
+ //上传栏舍
|
|
|
+ AddOtherDeviceFeeding()
|
|
|
err := c.AddFunc("0/30 * * * *", PostTmrData) //* * * * *, 从分钟开始 每30分钟执行一次
|
|
|
if err != nil {
|
|
|
println("cron4 err", err.Error())
|