|
@@ -75,7 +75,7 @@ func GetDownloadedplanMaterial1(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
if downloadedplanInfo.Id == 0 {
|
|
|
- appG.Response(http.StatusOK, e.SUCCESS, "全天结束")
|
|
|
+ appG.Response(http.StatusOK, e.THROUGHOUt_THE_DAY_TO_END, nil)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -106,7 +106,7 @@ func GetSubPlan(c *gin.Context) {
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
|
|
|
- downloadplandtl1List, err := tx.SQL(` select f.id as feedid,d1.fname,d1.feedcode,f.autosecond,f.autozone,d1.lweight,d1.sort,d1.buttontype from downloadplandtl1 d1
|
|
|
+ downloadplandtl1List, err := tx.SQL(` select DATE_FORMAT(d1.begintime, '%Y-%m-%d %H:%i:%S') as begintime, DATE_FORMAT(d1.intime, '%Y-%m-%d %H:%i:%S') as intime ,f.id as feedid,d1.fname,d1.feedcode,f.autosecond,f.autozone,d1.lweight,d1.sort,d1.buttontype,d1.actualweightminus from downloadplandtl1 d1
|
|
|
left join feed f
|
|
|
on f.feedcode = d1.feedcode and f.pastureid = d1.pastureid where d1.pid = ? and d1.pastureid = ? `, pid, pastureid).Query().List()
|
|
|
if err != nil {
|
|
@@ -114,19 +114,13 @@ func GetSubPlan(c *gin.Context) {
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
return
|
|
|
}
|
|
|
- downloadplandtl2List, err := tx.SQL(` select d2.id,d2.pid,d2.fbarid,d2.fname as fbarname,d2.lweight,d.lpplantype from downloadplandtl2 d2 join downloadedplan d on d.id = d2.pid where d2.pid = ? and d2.pastureid = ? `, pid, pastureid).Query().List()
|
|
|
+ downloadplandtl2List, err := tx.SQL(` select DATE_FORMAT(d2.begintime, '%Y-%m-%d %H:%i:%S') as begintime ,DATE_FORMAT(d2.intime, '%Y-%m-%d %H:%i:%S') as intime ,d2.id,d2.pid,d2.fbarid,d2.fname as fbarname,d2.lweight,d.lpplantype,d2.actualweightminus from downloadplandtl2 d2 join downloadedplan d on d.id = d2.pid where d2.pid = ? and d2.pastureid = ? `, pid, pastureid).Query().List()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // dataList := make([]map[string]interface{}, 0)
|
|
|
- // var d2lweight float64
|
|
|
- // for _, item := range downloadplandtl2List {
|
|
|
- // lweight, _ := strconv.ParseFloat(item["lweight"].(string), 64)
|
|
|
- // d2lweight += lweight
|
|
|
- // }
|
|
|
d1List := make([]map[string]interface{}, 0)
|
|
|
d2List := make([]map[string]interface{}, 0)
|
|
|
for _, d2item := range downloadplandtl2List {
|
|
@@ -135,6 +129,10 @@ func GetSubPlan(c *gin.Context) {
|
|
|
data["fbarname"] = d2item["fbarname"]
|
|
|
data["lweight"] = d2item["lweight"]
|
|
|
data["lpplantype"] = d2item["lpplantype"]
|
|
|
+ data["id"] = d2item["id"]
|
|
|
+ data["actualweightminus"] = d2item["actualweightminus"]
|
|
|
+ data["intime"] = d2item["intime"]
|
|
|
+ data["begintime"] = d2item["begintime"]
|
|
|
// flweight, _ := strconv.ParseFloat(d2item["lweight"].(string), 64)
|
|
|
// flweight = flweight / d2lweight
|
|
|
d2List = append(d2List, data)
|
|
@@ -150,8 +148,10 @@ func GetSubPlan(c *gin.Context) {
|
|
|
d1["sort"] = d1item["sort"]
|
|
|
d1["buttontype"] = d1item["buttontype"]
|
|
|
d1["feedid"] = d1item["feedid"]
|
|
|
- // d1["lweight"] = lweight * flweight
|
|
|
d1["lweight"] = d1item["lweight"]
|
|
|
+ d1["intime"] = d1item["intime"]
|
|
|
+ d1["begintime"] = d1item["begintime"]
|
|
|
+ d1["actualweightminus"] = d1item["actualweightminus"]
|
|
|
d1List = append(d1List, d1)
|
|
|
}
|
|
|
|
|
@@ -181,6 +181,10 @@ func CompletePlan(c *gin.Context) {
|
|
|
pastureid := parammaps.Get("pastureid").ValueStr()
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
+ // begintime := ""
|
|
|
+ // if begintimestr != "" {
|
|
|
+ // begintime = strings.ReplaceAll("2022-08-11T13:43:34+08:00", "T", " ")[:len("2006-01-02 15:04:05")]
|
|
|
+ // }
|
|
|
|
|
|
if lpplantype == 0 {
|
|
|
|
|
@@ -232,7 +236,8 @@ func CompletePlan(c *gin.Context) {
|
|
|
actualweight := lweight / sumlweight * actualweightminus
|
|
|
last := lweight / sumlweight * lastactualweight
|
|
|
_, err := tx.SQL(` update downloadplandtl2 set actualweightminus = ifnull(actualweightminus,0)+?, actualweight = ?,
|
|
|
- lastactualweight = ? , intime = now() ,havebuttom = 1,buttontype = ? where id = ? `, actualweight, actualweight, last, buttontype, d2["id"]).Execute()
|
|
|
+ lastactualweight = ? , intime = ?,begintime = ? ,havebuttom = 1,buttontype = ? where id = ? `, actualweight,
|
|
|
+ actualweight, last, intime, begintime, buttontype, d2["id"]).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
@@ -249,7 +254,7 @@ func CompletePlan(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort form downloadplandtl1 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
+ _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort from downloadplandtl1 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
pid, intime, pid, tmrid, pastureid).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -260,8 +265,8 @@ func CompletePlan(c *gin.Context) {
|
|
|
} else if lpplantype == 1 {
|
|
|
|
|
|
_, err := tx.SQL(` update downloadplandtl2 set actualweightminus =ifnull(actualweightminus,0)+?, actualweight = ?,
|
|
|
- lastactualweight = ? , intime = ? ,havebuttom = 1,buttontype = ? where id = ? `,
|
|
|
- actualweightminus, actualweightminus, lastactualweight, intime, buttontype, d2id).Execute()
|
|
|
+ lastactualweight = ? , intime = ? ,begintime = ?,havebuttom = 1,buttontype = ? where id = ? `,
|
|
|
+ actualweightminus, actualweightminus, lastactualweight, intime, begintime, buttontype, d2id).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
@@ -269,8 +274,8 @@ func CompletePlan(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
_, err = tx.SQL(` update downloadplandtl1_exec set actualweightminus =ifnull(actualweightminus,0)+?, actualweight = ?,
|
|
|
- lastactualweight = ? , intime = ? ,havebuttom = 1,buttontype= ? where pid = ? `,
|
|
|
- actualweightminus, actualweightminus, lastactualweight, intime, buttontype, pid).Execute()
|
|
|
+ lastactualweight = ? , intime = ?,begintime= ? ,havebuttom = 1,buttontype= ? where pid = ? `,
|
|
|
+ actualweightminus, actualweightminus, lastactualweight, intime, begintime, buttontype, pid).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
@@ -278,8 +283,8 @@ func CompletePlan(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
_, err = tx.SQL(` update downloadplandtl1 set actualweightminus =ifnull(actualweightminus,0)+?, actualweight = ?,
|
|
|
- lastactualweight = ? , intime = ? ,havebuttom = 1,buttontype = ? where pid = ? `,
|
|
|
- actualweightminus, actualweightminus, lastactualweight, intime, buttontype, pid).Execute()
|
|
|
+ lastactualweight = ? , intime = ?,begintime=? ,havebuttom = 1,buttontype = ? where pid = ? `,
|
|
|
+ actualweightminus, actualweightminus, lastactualweight, intime, begintime, buttontype, pid).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
@@ -302,7 +307,7 @@ func CompletePlan(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort form downloadplandtl2 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
+ _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort from downloadplandtl2 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
pid, intime, pid, tmrid, pastureid).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -312,9 +317,9 @@ func CompletePlan(c *gin.Context) {
|
|
|
|
|
|
} else if lpplantype == 2 {
|
|
|
_, err := tx.SQL(` update downloadplandtl1 set begintime = ? , actualweightminus =ifnull(actualweightminus,0)+ ? ,
|
|
|
- intime = ? ,actualweight = ? ,optdevice = ?,buttontype = ?,havebuttom = 1,lastactualweight = ? where pid = ?
|
|
|
+ intime = ? ,actualweight = ? ,optdevice = ?,buttontype = ?,havebuttom = 1,lastactualweight = ?,begintime = ? where pid = ?
|
|
|
and sort = ? and feedcode = (select feedcode from feed where id = ? )`,
|
|
|
- begintime, actualweightminus, intime, actualweightminus, tmrid, buttontype, lastactualweight, pid, sort, feedid).Execute()
|
|
|
+ begintime, actualweightminus, intime, actualweightminus, tmrid, buttontype, lastactualweight, begintime, pid, sort, feedid).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
@@ -322,16 +327,16 @@ func CompletePlan(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
_, err = tx.SQL(` update downloadplandtl1_exec set begintime = ? ,actualweightminus =ifnull(actualweightminus,0)+ ? ,
|
|
|
- intime = ? ,actualweight = ? ,optdevice = ?,buttontype = ?,havebuttom = 1,lastactualweight = ? where pid = ?
|
|
|
+ intime = ? ,actualweight = ? ,optdevice = ?,buttontype = ?,havebuttom = 1,lastactualweight = ?,begintime = ? where pid = ?
|
|
|
and sort = ? `,
|
|
|
- begintime, actualweightminus, intime, actualweightminus, tmrid, buttontype, lastactualweight, pid, sort).Execute()
|
|
|
+ begintime, actualweightminus, intime, actualweightminus, tmrid, buttontype, lastactualweight, begintime, pid, sort).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort form downloadplandtl1 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
+ _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort from downloadplandtl1 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
pid, intime, pid, tmrid, pastureid).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -341,8 +346,8 @@ func CompletePlan(c *gin.Context) {
|
|
|
|
|
|
} else {
|
|
|
_, err := tx.SQL(` update downloadplandtl2 set actualweightminus =ifnull(actualweightminus,0)+?, actualweight = ?,
|
|
|
- lastactualweight = ? , intime = ? ,havebuttom = 1,buttontype = ? where id = ? `,
|
|
|
- actualweightminus, actualweightminus, lastactualweight, intime, buttontype, d2id).Execute()
|
|
|
+ lastactualweight = ? , intime = ? ,havebuttom = 1,buttontype = ?,begintime where id = ? `,
|
|
|
+ actualweightminus, actualweightminus, lastactualweight, intime, buttontype, begintime, d2id).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
@@ -364,7 +369,7 @@ func CompletePlan(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort form downloadplandtl2 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
+ _, err = tx.SQL(` update tmr set projid = ? ,lastbuttontime =? , nextsort = (select sort from downloadplandtl2 where pid = ? and intime is null order by sort limit 0,1 ) where id = ? and pastureid = ? `,
|
|
|
pid, intime, pid, tmrid, pastureid).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|