|
@@ -385,7 +385,6 @@ func httpGet(farmId, method string) []interface{} {
|
|
|
var data map[string][]interface{}
|
|
|
json.Unmarshal(robots, &data)
|
|
|
return data["msg"]
|
|
|
-
|
|
|
}
|
|
|
|
|
|
func UDFeedtempletinfo(token, pastureid string) {
|
|
@@ -443,31 +442,33 @@ func UDUploadadddata(token, pastureid string) {
|
|
|
IFNULL(d.templetName ,((SELECT feedtempletName FROM downloadplandtl2 d2 WHERE d2.pid=d.id LIMIT 1))) recipeName,
|
|
|
ifnull(f.feedcode,"") as ingId,de.Fname as ingName,ifnull(fc.FCNAME,"") ingType,
|
|
|
ifnull(f.dry,"") dmPct,de.SORT mixNo,de.feedallowratio allowableError, de.LWEIGHT expWeight,
|
|
|
- de.ActualWeightMinus actualWeight,ifnull(date_format(timestamp(de.InTime,CONCAT('-',de.processTime)),'%Y-%m-%d %H:%i:%s'),"") startTime,
|
|
|
+ de.ActualWeightMinus actualWeight,ifnull(date_format(timestamp(de.InTime,CONCAT('-',(select processTime from downloadplandtl1_exec where pid = de.pid and sort = de.sort and pastureid = de.pastureid))),'%Y-%m-%d %H:%i:%s'),"") startTime,
|
|
|
date_format(de.InTime,'%Y-%m-%d %H:%i:%s') endTime,ifnull((SELECT dr.driver FROM dutyrecord dr
|
|
|
WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times AND dr.operatetime <=d.mydate
|
|
|
ORDER BY dr.operatetime DESC LIMIT 1),"") tmrName ,d.tmrtname equipmentId
|
|
|
- from downloadedplan d LEFT JOIN downloadplandtl1_exec de on d.id=de.PID
|
|
|
- left join downloadplandtl1 de1 on de1.pid = d.id
|
|
|
- LEFT JOIN feed f on de1.Fid=f.id and f.pastureid = de1.pastureid LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME
|
|
|
+ from downloadedplan d
|
|
|
+ left join downloadplandtl1 de on de.pid = d.id and de.type = 0
|
|
|
+ LEFT JOIN feed f on de.Fid=f.id and f.pastureid = de.pastureid LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME
|
|
|
LEFT JOIN feedclass fc on f.FCLASS=fc.id
|
|
|
- where d.mydate=date_format(NOW(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType=0 and d.pastureid = ?
|
|
|
+ where d.mydate=date_format(now(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType=0 and d.pastureid = ?
|
|
|
+
|
|
|
union all
|
|
|
+
|
|
|
select date_format(d.mydate,'%Y-%m-%d') loadDate,d.SORT tmrNo,d.Times loadShift,
|
|
|
IFNULL(ft.id,((SELECT feedtempletid FROM downloadplandtl2 d2 WHERE d2.flpid=d.id LIMIT 1))) recipeId,
|
|
|
IFNULL(d.templetName ,((SELECT feedtempletName FROM downloadplandtl2 d2 WHERE d2.flpid=d.id LIMIT 1))) recipeName,
|
|
|
ifnull(f.feedcode,"") as ingId,de.Fname as ingName,ifnull(fc.FCNAME,"") ingType,
|
|
|
ifnull(f.dry,"") dmPct,de.SORT mixNo,de.feedallowratio allowableError, de.LWEIGHT expWeight,
|
|
|
- de.ActualWeightMinus actualWeight,ifnull(date_format(timestamp(de.InTime,CONCAT('-',de.processTime)),'%Y-%m-%d %H:%i:%s'),"") startTime,
|
|
|
+ de.ActualWeightMinus actualWeight,ifnull(date_format(timestamp(de.InTime,CONCAT('-',(select processTime from downloadplandtl1_exec where pid = de.pid and sort = de.sort and pastureid = de.pastureid))),'%Y-%m-%d %H:%i:%s'),"") startTime,
|
|
|
date_format(de.InTime,'%Y-%m-%d %H:%i:%s') endTime,ifnull((SELECT dr.driver FROM dutyrecord dr
|
|
|
WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times AND dr.operatetime <=d.mydate
|
|
|
ORDER BY dr.operatetime DESC LIMIT 1),"") tmrName ,d.tmrtname equipmentId
|
|
|
- from downloadedplan d LEFT JOIN downloadplandtl1_exec de on d.id=de.PID
|
|
|
- left join downloadplandtl1 de1 on de1.pid = d.id
|
|
|
- LEFT JOIN feed f on de1.Fid=f.id and f.pastureid = de1.pastureid LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME
|
|
|
+ from downloadedplan d
|
|
|
+ left join downloadplandtl1 de on de.pid = d.id and de.type = 0
|
|
|
+ LEFT JOIN feed f on de.Fid=f.id and f.pastureid = de.pastureid LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME
|
|
|
LEFT JOIN feedclass fc on f.FCLASS=fc.id
|
|
|
- where d.mydate=date_format(NOW(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType=1 and d.pastureid = ?
|
|
|
-ORDER BY mixNo `
|
|
|
+ where d.mydate=date_format(now(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType=1 and d.pastureid = ?
|
|
|
+ORDER BY tmrno`
|
|
|
|
|
|
data, err := tx.SQL(sqlstr, pastureid, pastureid).Query().List()
|
|
|
if err != nil {
|
|
@@ -493,20 +494,22 @@ func UDUploaddiliverdata(token, pastureid string) {
|
|
|
defer tx.Close()
|
|
|
|
|
|
sqlstr := `SELECT
|
|
|
- IFNULL(ft.id,d2.feedtempletid ) recipeId,
|
|
|
+ d.id,IFNULL(ft.id,d2.feedtempletid ) recipeId,
|
|
|
IFNULL(d.templetName,d2.feedtempletName ) recipeName,
|
|
|
date_format(d.mydate,'%Y-%m-%d') as dropDate,ifnull((select sort from downloadedplan where pid=d.pid and lpplanType !=d.lpplanType and mydate=d.mydate),d.sort) as tmrNo,
|
|
|
d.Times as dropShift,b.bcode as penId,d2.Fname as penName,fp.CCOUNT as cowCount, d2.SORT as feedingNo, d2.LWEIGHT as expWeight,
|
|
|
d2.ActualWeightMinus as actualWeight, ifnull(date_format(timestamp(d2.InTime,CONCAT('-',d2.processTime)),'%Y-%m-%d %H:%i:%s'),"") as startTime,
|
|
|
date_format(d2.InTime,'%Y-%m-%d %H:%i:%s') as endTime,ifnull((SELECT dr.driver FROM dutyrecord dr
|
|
|
WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times AND dr.operatetime <=d.mydate
|
|
|
-ORDER BY dr.operatetime DESC LIMIT 1),"") as tmrName ,d.tmrtname equipmentId
|
|
|
- from downloadedplan d
|
|
|
+ORDER BY dr.operatetime DESC LIMIT 1),"") as tmrName ,d.tmrtname equipmentId , dd.fname,ROUND((d2.actualweightminus / ( select sum(actualweightminus) from downloadplandtl2 where pid = d.id ) * (dd.actualweightminus/ (select sum(actualweightminus) from downloadplandtl1 where pid = dd.pid and type = 0) * ( select sum(actualweightminus) from downloadplandtl2 where pid = d.id ))),2) as feedWeight
|
|
|
+ from downloadedplan d
|
|
|
LEFT JOIN downloadplandtl2 d2 on d.id=d2.PID
|
|
|
+ LEFT JOIN (select dd.pid as lppid,dd1.* from downloadedplan dd join downloadplandtl1 dd1 on dd1.pid = dd.id and dd1.type = 0 where dd.mydate= date_format(NOW(),'%Y-%m-%d') and dd.IsCompleted=1 and dd.lpplanType =1 ) dd on dd.lppid = d.pid
|
|
|
+
|
|
|
LEFT JOIN feedp fp on d2.FBarID=fp.id
|
|
|
left join bar b on fp.barid = b.id and d.pastureid = b.pastureid
|
|
|
left JOIN feedtemplet ft on d.templetName=ft.TNAME
|
|
|
- where d.mydate= date_format(NOW(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType!=1 and d.pastureid = ? `
|
|
|
+ where d.mydate= date_format(NOW(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType!=1 and d.pastureid = ? order by tmrno `
|
|
|
|
|
|
data, err := tx.SQL(sqlstr, pastureid).Query().List()
|
|
|
if err != nil {
|