|
@@ -3642,27 +3642,28 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
ftmap["ptid"] = list.Get("ptid").ValueStr()
|
|
ftmap["ptid"] = list.Get("ptid").ValueStr()
|
|
|
ftmap["ptsid"] = list.Get("ptsid").ValueStr()
|
|
ftmap["ptsid"] = list.Get("ptsid").ValueStr()
|
|
|
// fmt.Println(ftmap)
|
|
// fmt.Println(ftmap)
|
|
|
-
|
|
|
|
|
- // count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
|
|
- // and find_in_set(barid,(select barid from feedp where id = ? )) and lweight > 0 `, pastureid, pastureid, ftmap["times"], id).Count()
|
|
|
|
|
- // if count == 1 {
|
|
|
|
|
- // _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
|
|
- // and find_in_set(barid,(select barid from feedp where id = ? )) `, pastureid, pastureid, ftmap["times"], id).Execute()
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // tx.Rollback()
|
|
|
|
|
- // logs.Error(err)
|
|
|
|
|
- // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
|
|
- // WHERE pastureid=? and find_in_set(barid,(select barid from feedp where id = ? ) ) and times = ? `, pastureid, id, ftmap["times"]).Execute()
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // tx.Rollback()
|
|
|
|
|
- // logs.Error(err)
|
|
|
|
|
- // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+// /*
|
|
|
|
|
+ count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
|
|
+ and find_in_set(barid,(select barid from feedp where id = ? )) and lweight > 0 `, pastureid, pastureid, ftmap["times"], id).Count()
|
|
|
|
|
+ if count == 1 {
|
|
|
|
|
+ _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
|
|
+ and find_in_set(barid,(select barid from feedp where id = ? )) `, pastureid, pastureid, ftmap["times"], id).Execute()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ tx.Rollback()
|
|
|
|
|
+ logs.Error(err)
|
|
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
|
|
+ WHERE pastureid=? and find_in_set(barid,(select barid from feedp where id = ? ) ) and times = ? `, pastureid, id, ftmap["times"]).Execute()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ tx.Rollback()
|
|
|
|
|
+ logs.Error(err)
|
|
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // */
|
|
|
|
|
|
|
|
fpdDataList, err := tx.SQL(`
|
|
fpdDataList, err := tx.SQL(`
|
|
|
SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ifnull(ptsid,-1) ) ptsid ,
|
|
SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ifnull(ptsid,-1) ) ptsid ,
|
|
@@ -4447,12 +4448,12 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
if _, ok := outentry["栏舍名称"]; ok {
|
|
if _, ok := outentry["栏舍名称"]; ok {
|
|
|
dataexcel["barname"] = outentry["栏舍名称"]
|
|
dataexcel["barname"] = outentry["栏舍名称"]
|
|
|
}
|
|
}
|
|
|
- // if _, ok := outentry["实际牛头数"]; ok {
|
|
|
|
|
- // dataexcel["ccount"] = outentry["实际牛头数"]
|
|
|
|
|
- // }
|
|
|
|
|
- if _, ok := outentry["实际羊只数"]; ok {
|
|
|
|
|
- dataexcel["ccount"] = outentry["实际羊只数"]
|
|
|
|
|
|
|
+ if _, ok := outentry["实际牛头数"]; ok {
|
|
|
|
|
+ dataexcel["ccount"] = outentry["实际牛头数"]
|
|
|
}
|
|
}
|
|
|
|
|
+ // if _, ok := outentry["实际羊只数"]; ok {
|
|
|
|
|
+ // dataexcel["ccount"] = outentry["实际羊只数"]
|
|
|
|
|
+ // }
|
|
|
if _, ok := outentry["系数(%)"]; ok {
|
|
if _, ok := outentry["系数(%)"]; ok {
|
|
|
dataexcel["ratio"] = outentry["系数(%)"]
|
|
dataexcel["ratio"] = outentry["系数(%)"]
|
|
|
}
|
|
}
|
|
@@ -5181,6 +5182,21 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
|
|
+
|
|
|
|
|
+// /*
|
|
|
|
|
+ _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? )
|
|
|
|
|
+ and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, barname).Execute()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ logs.Error(err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
|
|
+ WHERE pastureid=? and find_in_set(barid,(select barid from feedp where barname = ? ) ) `, pastureid, barname).Execute()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ logs.Error(err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ // */
|
|
|
updateFpdetailByBar(pastureid, barname, v)
|
|
updateFpdetailByBar(pastureid, barname, v)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -6254,31 +6270,31 @@ func GetTMRListEnableTypeAll(c *gin.Context) {
|
|
|
for i := carNum; i > 0; i-- {
|
|
for i := carNum; i > 0; i-- {
|
|
|
id++
|
|
id++
|
|
|
n++
|
|
n++
|
|
|
- data := make(map[string]interface{}, 0)
|
|
|
|
|
- data["eqcode"] = fmt.Sprintf("任意车%d", n)
|
|
|
|
|
- data["tname"] = fmt.Sprintf("任意车%d", n)
|
|
|
|
|
- data["datacaptureno"] = -2
|
|
|
|
|
- data["tclassid"] = -2
|
|
|
|
|
- data["tmrmix"] = fmt.Sprintf("任意车%d", n)
|
|
|
|
|
- data["tclassname"] = fmt.Sprintf("任意车%d", n)
|
|
|
|
|
- data["maxstirfeed"] = 100000
|
|
|
|
|
- data["remark"] = fmt.Sprintf("任意车%d", n)
|
|
|
|
|
- data["enable"] = 1
|
|
|
|
|
- data["id"] = fmt.Sprintf("%d", id)
|
|
|
|
|
- data["pastureid"] = pastureid
|
|
|
|
|
-
|
|
|
|
|
// data := make(map[string]interface{}, 0)
|
|
// data := make(map[string]interface{}, 0)
|
|
|
- // data["eqcode"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
- // data["tname"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
|
|
+ // data["eqcode"] = fmt.Sprintf("任意车%d", n)
|
|
|
|
|
+ // data["tname"] = fmt.Sprintf("任意车%d", n)
|
|
|
// data["datacaptureno"] = -2
|
|
// data["datacaptureno"] = -2
|
|
|
// data["tclassid"] = -2
|
|
// data["tclassid"] = -2
|
|
|
- // data["tmrmix"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
- // data["tclassname"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
|
|
+ // data["tmrmix"] = fmt.Sprintf("任意车%d", n)
|
|
|
|
|
+ // data["tclassname"] = fmt.Sprintf("任意车%d", n)
|
|
|
// data["maxstirfeed"] = 100000
|
|
// data["maxstirfeed"] = 100000
|
|
|
- // data["remark"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
|
|
+ // data["remark"] = fmt.Sprintf("任意车%d", n)
|
|
|
// data["enable"] = 1
|
|
// data["enable"] = 1
|
|
|
// data["id"] = fmt.Sprintf("%d", id)
|
|
// data["id"] = fmt.Sprintf("%d", id)
|
|
|
// data["pastureid"] = pastureid
|
|
// data["pastureid"] = pastureid
|
|
|
|
|
+
|
|
|
|
|
+ data := make(map[string]interface{}, 0)
|
|
|
|
|
+ data["eqcode"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
+ data["tname"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
+ data["datacaptureno"] = -2
|
|
|
|
|
+ data["tclassid"] = -2
|
|
|
|
|
+ data["tmrmix"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
+ data["tclassname"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
+ data["maxstirfeed"] = 100000
|
|
|
|
|
+ data["remark"] = fmt.Sprintf("AnyCar%d", n)
|
|
|
|
|
+ data["enable"] = 1
|
|
|
|
|
+ data["id"] = fmt.Sprintf("%d", id)
|
|
|
|
|
+ data["pastureid"] = pastureid
|
|
|
dataList = append(dataList, data)
|
|
dataList = append(dataList, data)
|
|
|
}
|
|
}
|
|
|
// UNION ALL
|
|
// UNION ALL
|
|
@@ -9008,20 +9024,20 @@ func FpdBatchEdit(c *gin.Context) {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? )
|
|
|
|
|
- // and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, dataexcel["barname"]).Execute()
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // logs.Error(err)
|
|
|
|
|
- // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- // _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
|
|
- // WHERE pastureid=? and find_in_set(barid,(select barid from feedp where barname = ? ) ) `, pastureid, dataexcel["barname"]).Execute()
|
|
|
|
|
- // if err != nil {
|
|
|
|
|
- // logs.Error(err)
|
|
|
|
|
- // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? )
|
|
|
|
|
+ and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, dataexcel["barname"]).Execute()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ logs.Error(err)
|
|
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
|
|
+ WHERE pastureid=? and find_in_set(barid,(select barid from feedp where barname = ? ) ) `, pastureid, dataexcel["barname"]).Execute()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ logs.Error(err)
|
|
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
dataexcel["1"] = barFsions.Get("times1").ValueStr()
|
|
dataexcel["1"] = barFsions.Get("times1").ValueStr()
|
|
|
dataexcel["2"] = barFsions.Get("times2").ValueStr()
|
|
dataexcel["2"] = barFsions.Get("times2").ValueStr()
|
|
@@ -9628,36 +9644,336 @@ func DelFeedTemplet(c *gin.Context) {
|
|
|
|
|
|
|
|
func checkPlan(tx *xorm.Session, fasion map[string]interface{}, CommonParamMap map[string]interface{}, ParamMap []map[string]interface{}, number int) {
|
|
func checkPlan(tx *xorm.Session, fasion map[string]interface{}, CommonParamMap map[string]interface{}, ParamMap []map[string]interface{}, number int) {
|
|
|
data := fasion["parammaps"].(map[string]interface{})
|
|
data := fasion["parammaps"].(map[string]interface{})
|
|
|
- plancount, err := tx.Table("downloadedplan").Where(" mydate = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype in(0,1,2) ").Count()
|
|
|
|
|
- fmt.Println(err)
|
|
|
|
|
- plancount1, err := tx.SQL(`SELECT
|
|
|
|
|
- count( 1 )
|
|
|
|
|
-FROM
|
|
|
|
|
- (
|
|
|
|
|
- SELECT
|
|
|
|
|
- d.id
|
|
|
|
|
- FROM
|
|
|
|
|
- downloadedplan d
|
|
|
|
|
- JOIN downloadplandtl1 d1 ON d1.pid = d.id
|
|
|
|
|
- JOIN downloadplandtl1_exec d1e ON d1e.pid = d.id
|
|
|
|
|
- JOIN downloadplandtl2 d2 ON d2.pid = d.id
|
|
|
|
|
- WHERE
|
|
|
|
|
- d.mydate = ?
|
|
|
|
|
- AND d.havebutton = 0
|
|
|
|
|
- AND lpplantype IN ( 0, 1, 2 )
|
|
|
|
|
- AND ( SELECT count( 1 ) FROM downloadplandtl2 dd2 WHERE dd2.pid = d.id and dd2.fname = d2.fname) =
|
|
|
|
|
- ( SELECT count( 1 ) FROM downloadplandtl2 dd2 WHERE dd2.pid = d.id and (select count(1) from downloadplandtl2 where pid = dd2.pid and fname = dd2.fname ) = 1 and dd2.fname = d2.fname )
|
|
|
|
|
- GROUP BY
|
|
|
|
|
- d.id
|
|
|
|
|
- ) d
|
|
|
|
|
-
|
|
|
|
|
- `,
|
|
|
|
|
- data["startTime"]).Count()
|
|
|
|
|
- fmt.Println(err)
|
|
|
|
|
- if plancount != plancount1 && number < 10 {
|
|
|
|
|
- number++
|
|
|
|
|
- ExecDataParam(fasion, CommonParamMap, ParamMap, nil, nil, tx)
|
|
|
|
|
- checkPlan(tx, fasion, CommonParamMap, ParamMap, number)
|
|
|
|
|
|
|
+ // plancount, err := tx.Table("downloadedplan").Where(" mydate = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype in(2) ").Count()
|
|
|
|
|
+ downloadedplanList := make([]*models.DownloadedPlan, 0)
|
|
|
|
|
+ tx.Table("downloadedplan").Where(" mydate = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype = 2 ").Find(&downloadedplanList)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //
|
|
|
|
|
+ lweight := 20.0
|
|
|
|
|
+ for _, downloadedplan := range downloadedplanList {
|
|
|
|
|
+ downloadplandtl1List :=make([]*models.DownloadPlanDtl1,0)
|
|
|
|
|
+ downloadplandtl1ExecList :=make([]*models.DownloadPlanDtl1Exec,0)
|
|
|
|
|
+ downloadplandtl2List :=make([]*models.DownloadPlanDtl2,0)
|
|
|
|
|
+ tx.Table("downloadplandtl1").Where(" pid = ? ",downloadedplan.ID).Find(&downloadplandtl1List)
|
|
|
|
|
+ tx.Table("downloadplandtl2").Where(" pid = ? ",downloadedplan.ID).Find(&downloadplandtl2List)
|
|
|
|
|
+ tx.Table("downloadplandtl1_exec").Where(" pid = ? ",downloadedplan.ID).Find(&downloadplandtl1ExecList)
|
|
|
|
|
+
|
|
|
|
|
+ lweightCount := math.Floor(downloadedplan.LWeight / lweight)
|
|
|
|
|
+ for i := 0; i <= int(lweightCount); i++ {
|
|
|
|
|
+ if i ==0 {
|
|
|
|
|
+ tx.Exec(` update downloadedplan set lweight = ? where id = ? `, lweight, downloadedplan.ID)
|
|
|
|
|
+ for _, downloadplandtl1 := range downloadplandtl1List{
|
|
|
|
|
+ tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, downloadplandtl2 := range downloadplandtl2List{
|
|
|
|
|
+ tx.Exec(` update downloadplandtl2 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl2.LWeight, downloadplandtl2.ID)
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, downloadplandtl2 := range downloadplandtl1ExecList{
|
|
|
|
|
+ tx.Exec(` update downloadplandtl1_exec set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl2.LWeight, downloadplandtl2.ID)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else if i < int(lweightCount) {
|
|
|
|
|
+ parts := strings.Split(downloadedplan.ProjName, ".")
|
|
|
|
|
+ parts[len(parts)-1] = fmt.Sprintf("%d", i+1)
|
|
|
|
|
+ data :=&models.DownloadedPlan{
|
|
|
|
|
+ PastureID :downloadedplan.PastureID ,
|
|
|
|
|
+ MyDate :downloadedplan.MyDate ,
|
|
|
|
|
+ ProjName :strings.Join(parts, ".") ,
|
|
|
|
|
+ DataCaptureNo :downloadedplan.DataCaptureNo ,
|
|
|
|
|
+ TmrID :downloadedplan.TmrID ,
|
|
|
|
|
+ TmrtName :downloadedplan.TmrtName ,
|
|
|
|
|
+ HaveButton :downloadedplan.HaveButton ,
|
|
|
|
|
+ InButtonType :downloadedplan.InButtonType ,
|
|
|
|
|
+ PlanTime :downloadedplan.PlanTime ,
|
|
|
|
|
+ InTime :downloadedplan.InTime ,
|
|
|
|
|
+ CompletedTime :downloadedplan.CompletedTime ,
|
|
|
|
|
+ IsCompleted :downloadedplan.IsCompleted ,
|
|
|
|
|
+ LpPlanType :downloadedplan.LpPlanType ,
|
|
|
|
|
+ Times :downloadedplan.Times ,
|
|
|
|
|
+ Sort :downloadedplan.Sort ,
|
|
|
|
|
+ Remark :downloadedplan.Remark ,
|
|
|
|
|
+ ItemNum :downloadedplan.ItemNum ,
|
|
|
|
|
+ OutItems :downloadedplan.OutItems ,
|
|
|
|
|
+ FeedPName :downloadedplan.FeedPName ,
|
|
|
|
|
+ FeedPCount :downloadedplan.FeedPCount ,
|
|
|
|
|
+ Pid :downloadedplan.Pid ,
|
|
|
|
|
+ TempID :downloadedplan.TempID ,
|
|
|
|
|
+ TempletName :downloadedplan.TempletName ,
|
|
|
|
|
+ PtsTempID :downloadedplan.PtsTempID ,
|
|
|
|
|
+ PtsTempletName:downloadedplan.PtsTempletName,
|
|
|
|
|
+ ThoWeight :downloadedplan.ThoWeight ,
|
|
|
|
|
+ FpWeight :downloadedplan.FpWeight ,
|
|
|
|
|
+ LWeight :lweight ,
|
|
|
|
|
+ IWeight :downloadedplan.IWeight ,
|
|
|
|
|
+ OWeight :downloadedplan.OWeight ,
|
|
|
|
|
+ TVersion :downloadedplan.TVersion ,
|
|
|
|
|
+ PtVersion :downloadedplan.PtVersion ,
|
|
|
|
|
+ Enable :downloadedplan.Enable ,
|
|
|
|
|
+ IsUse :downloadedplan.IsUse ,
|
|
|
|
|
+ OldTmrID :downloadedplan.OldTmrID ,
|
|
|
|
|
+ DriverID :downloadedplan.DriverID ,
|
|
|
|
|
+ Artificial :downloadedplan.Artificial ,
|
|
|
|
|
+ }
|
|
|
|
|
+ _, err := tx.Insert(data)
|
|
|
|
|
+ fmt.Println(data,err)
|
|
|
|
|
+
|
|
|
|
|
+ for _, downloadplandtl1 := range downloadplandtl1List{
|
|
|
|
|
+ // tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
|
|
|
|
|
+ d1 :=&models.DownloadPlanDtl1{
|
|
|
|
|
+ PastureID :downloadplandtl1.PastureID ,
|
|
|
|
|
+ Pid :data.ID ,
|
|
|
|
|
+ Flpid :downloadplandtl1.Flpid ,
|
|
|
|
|
+ Fid :downloadplandtl1.Fid ,
|
|
|
|
|
+ LWeight :lweight/downloadedplan.LWeight * downloadplandtl1.LWeight ,
|
|
|
|
|
+ Sort :downloadplandtl1.Sort ,
|
|
|
|
|
+ ButtonType :downloadplandtl1.ButtonType ,
|
|
|
|
|
+ OptDevice :downloadplandtl1.OptDevice ,
|
|
|
|
|
+ FeedCode :downloadplandtl1.FeedCode ,
|
|
|
|
|
+ FName :downloadplandtl1.FName ,
|
|
|
|
|
+ FeedSort :downloadplandtl1.FeedSort ,
|
|
|
|
|
+ FeedAllowRatio :downloadplandtl1.FeedAllowRatio ,
|
|
|
|
|
+ StirDelay :downloadplandtl1.StirDelay ,
|
|
|
|
|
+ FWeight :downloadplandtl1.FWeight ,
|
|
|
|
|
+ TmrLoadName :downloadplandtl1.TmrLoadName ,
|
|
|
|
|
+ DryFeed :downloadplandtl1.DryFeed ,
|
|
|
|
|
+ PriceFeed :downloadplandtl1.PriceFeed ,
|
|
|
|
|
+ OutWeight :downloadplandtl1.OutWeight ,
|
|
|
|
|
+ ErrRatio :downloadplandtl1.ErrRatio ,
|
|
|
|
|
+ Date :downloadplandtl1.Date ,
|
|
|
|
|
+ ButtonSucc :downloadplandtl1.ButtonSucc ,
|
|
|
|
|
+ Type :downloadplandtl1.Type ,
|
|
|
|
|
+ Deviation :downloadplandtl1.Deviation ,
|
|
|
|
|
+ XxwFeedCode :downloadplandtl1.XxwFeedCode ,
|
|
|
|
|
+ }
|
|
|
|
|
+ tx.Insert(d1)
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, downloadplandtl2 := range downloadplandtl2List{
|
|
|
|
|
+ // tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
|
|
|
|
|
+ d2 :=&models.DownloadPlanDtl2{
|
|
|
|
|
+ PastureID :downloadplandtl2.PastureID ,
|
|
|
|
|
+ Pid :data.ID ,
|
|
|
|
|
+ Flpid :downloadplandtl2.Flpid ,
|
|
|
|
|
+ Fbarid :downloadplandtl2.Fbarid ,
|
|
|
|
|
+ FName :downloadplandtl2.FName ,
|
|
|
|
|
+ LWeight :lweight/downloadedplan.LWeight * downloadplandtl2.LWeight ,
|
|
|
|
|
+ LWeightHis :lweight/downloadedplan.LWeight * downloadplandtl2.LWeight ,
|
|
|
|
|
+ RemainLeftW :downloadplandtl2.RemainLeftW ,
|
|
|
|
|
+ AllowRW :downloadplandtl2.AllowRW ,
|
|
|
|
|
+ Sort :downloadplandtl2.Sort ,
|
|
|
|
|
+ HaveButton :downloadplandtl2.HaveButton ,
|
|
|
|
|
+ BeginTag :downloadplandtl2.BeginTag ,
|
|
|
|
|
+ EndTag :downloadplandtl2.EndTag ,
|
|
|
|
|
+ ButtonType :downloadplandtl2.ButtonType ,
|
|
|
|
|
+ OptDevice :downloadplandtl2.OptDevice ,
|
|
|
|
|
+ CowCount :downloadplandtl2.CowCount ,
|
|
|
|
|
+ CowClassID :downloadplandtl2.CowClassID ,
|
|
|
|
|
+ CowClassName :downloadplandtl2.CowClassName ,
|
|
|
|
|
+ BigCowName :downloadplandtl2.BigCowName ,
|
|
|
|
|
+ PWeight :downloadplandtl2.PWeight ,
|
|
|
|
|
+ CCountRatio :downloadplandtl2.CCountRatio ,
|
|
|
|
|
+ SumRTime :downloadplandtl2.SumRTime ,
|
|
|
|
|
+ FeedTempletID :downloadplandtl2.FeedTempletID ,
|
|
|
|
|
+ FeedTempletName :downloadplandtl2.FeedTempletName,
|
|
|
|
|
+ DryWeight :downloadplandtl2.DryWeight ,
|
|
|
|
|
+ SumWeight :downloadplandtl2.SumWeight ,
|
|
|
|
|
+ PriceWeight :downloadplandtl2.PriceWeight ,
|
|
|
|
|
+ // ProcessTime :downloadplandtl2.ProcessTime ,
|
|
|
|
|
+ Fpid :downloadplandtl2.Fpid ,
|
|
|
|
|
+ UseInBarType :downloadplandtl2.UseInBarType ,
|
|
|
|
|
+ Date :downloadplandtl2.Date ,
|
|
|
|
|
+ AllowRatio :downloadplandtl2.AllowRatio ,
|
|
|
|
|
+ ErrRatio :downloadplandtl2.ErrRatio ,
|
|
|
|
|
+ ButtonSucc :downloadplandtl2.ButtonSucc ,
|
|
|
|
|
+ Type :downloadplandtl2.Type ,
|
|
|
|
|
+ XxwTempletCode :downloadplandtl2.XxwTempletCode ,
|
|
|
|
|
+ XxwBarCode :downloadplandtl2.XxwBarCode ,
|
|
|
|
|
+ }
|
|
|
|
|
+ _,err :=tx.Insert(d2)
|
|
|
|
|
+ fmt.Println(err )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for _, downloadplandtl2 := range downloadplandtl1ExecList{
|
|
|
|
|
+ d2 :=&models.DownloadPlanDtl1Exec{
|
|
|
|
|
+ PastureID:downloadplandtl2.PastureID,
|
|
|
|
|
+ Pid:data.ID,
|
|
|
|
|
+ Flpid:downloadplandtl2.Flpid,
|
|
|
|
|
+ LWeight:lweight/downloadedplan.LWeight * downloadplandtl2.LWeight ,
|
|
|
|
|
+ HaveButton:downloadplandtl2.HaveButton,
|
|
|
|
|
+ ButtonType:downloadplandtl2.ButtonType,
|
|
|
|
|
+ OptDevice:downloadplandtl2.OptDevice,
|
|
|
|
|
+ Sort:downloadplandtl2.Sort,
|
|
|
|
|
+ FName:downloadplandtl2.FName,
|
|
|
|
|
+ FCount:downloadplandtl2.FCount ,
|
|
|
|
|
+ TmrLoadName:downloadplandtl2.TmrLoadName ,
|
|
|
|
|
+ FeedAllowRatio:downloadplandtl2.FeedAllowRatio ,
|
|
|
|
|
+ StirDelay:downloadplandtl2.StirDelay ,
|
|
|
|
|
+ ButtonSucc:downloadplandtl2.ButtonSucc ,
|
|
|
|
|
+ ErrRatio:downloadplandtl2.ErrRatio ,
|
|
|
|
|
+ Date:downloadplandtl2.Date ,
|
|
|
|
|
+ Type:downloadplandtl2.Type ,
|
|
|
|
|
+ Deviation:downloadplandtl2.Deviation ,
|
|
|
|
|
+ XxwFeedCode:downloadplandtl2.XxwFeedCode ,
|
|
|
|
|
+ }
|
|
|
|
|
+ _,err :=tx.Insert(d2)
|
|
|
|
|
+ fmt.Println(err )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ parts := strings.Split(downloadedplan.ProjName, ".")
|
|
|
|
|
+ parts[len(parts)-1] = fmt.Sprintf("%d", i+1)
|
|
|
|
|
+
|
|
|
|
|
+ data := &models.DownloadedPlan{
|
|
|
|
|
+ PastureID :downloadedplan.PastureID ,
|
|
|
|
|
+ MyDate :downloadedplan.MyDate ,
|
|
|
|
|
+ ProjName :strings.Join(parts, ".") ,
|
|
|
|
|
+ DataCaptureNo :downloadedplan.DataCaptureNo ,
|
|
|
|
|
+ TmrID :downloadedplan.TmrID ,
|
|
|
|
|
+ TmrtName :downloadedplan.TmrtName ,
|
|
|
|
|
+ HaveButton :downloadedplan.HaveButton ,
|
|
|
|
|
+ InButtonType :downloadedplan.InButtonType ,
|
|
|
|
|
+ PlanTime :downloadedplan.PlanTime ,
|
|
|
|
|
+ InTime :downloadedplan.InTime ,
|
|
|
|
|
+ CompletedTime :downloadedplan.CompletedTime ,
|
|
|
|
|
+ IsCompleted :downloadedplan.IsCompleted ,
|
|
|
|
|
+ LpPlanType :downloadedplan.LpPlanType ,
|
|
|
|
|
+ Times :downloadedplan.Times ,
|
|
|
|
|
+ Sort :downloadedplan.Sort ,
|
|
|
|
|
+ Remark :downloadedplan.Remark ,
|
|
|
|
|
+ ItemNum :downloadedplan.ItemNum ,
|
|
|
|
|
+ OutItems :downloadedplan.OutItems ,
|
|
|
|
|
+ FeedPName :downloadedplan.FeedPName ,
|
|
|
|
|
+ FeedPCount :downloadedplan.FeedPCount ,
|
|
|
|
|
+ Pid :downloadedplan.Pid ,
|
|
|
|
|
+ TempID :downloadedplan.TempID ,
|
|
|
|
|
+ TempletName :downloadedplan.TempletName ,
|
|
|
|
|
+ PtsTempID :downloadedplan.PtsTempID ,
|
|
|
|
|
+ PtsTempletName:downloadedplan.PtsTempletName,
|
|
|
|
|
+ ThoWeight :downloadedplan.ThoWeight ,
|
|
|
|
|
+ FpWeight :downloadedplan.FpWeight ,
|
|
|
|
|
+ LWeight :downloadedplan.LWeight-float64(i)*lweight,
|
|
|
|
|
+ IWeight :downloadedplan.IWeight ,
|
|
|
|
|
+ OWeight :downloadedplan.OWeight ,
|
|
|
|
|
+ TVersion :downloadedplan.TVersion ,
|
|
|
|
|
+ PtVersion :downloadedplan.PtVersion ,
|
|
|
|
|
+ Enable :downloadedplan.Enable ,
|
|
|
|
|
+ IsUse :downloadedplan.IsUse ,
|
|
|
|
|
+ OldTmrID :downloadedplan.OldTmrID ,
|
|
|
|
|
+ DriverID :downloadedplan.DriverID ,
|
|
|
|
|
+ Artificial :downloadedplan.Artificial ,
|
|
|
|
|
+ }
|
|
|
|
|
+ _, err := tx.Insert(data)
|
|
|
|
|
+ fmt.Println(data,err)
|
|
|
|
|
+ for _, downloadplandtl1 := range downloadplandtl1List{
|
|
|
|
|
+ // tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
|
|
|
|
|
+ d1 :=&models.DownloadPlanDtl1{
|
|
|
|
|
+ PastureID :downloadplandtl1.PastureID ,
|
|
|
|
|
+ Pid :data.ID ,
|
|
|
|
|
+ Flpid :downloadplandtl1.Flpid ,
|
|
|
|
|
+ Fid :downloadplandtl1.Fid ,
|
|
|
|
|
+ LWeight :(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl1.LWeight ,
|
|
|
|
|
+ Sort :downloadplandtl1.Sort ,
|
|
|
|
|
+ ButtonType :downloadplandtl1.ButtonType ,
|
|
|
|
|
+ OptDevice :downloadplandtl1.OptDevice ,
|
|
|
|
|
+ FeedCode :downloadplandtl1.FeedCode ,
|
|
|
|
|
+ FName :downloadplandtl1.FName ,
|
|
|
|
|
+ FeedSort :downloadplandtl1.FeedSort ,
|
|
|
|
|
+ FeedAllowRatio :downloadplandtl1.FeedAllowRatio ,
|
|
|
|
|
+ StirDelay :downloadplandtl1.StirDelay ,
|
|
|
|
|
+ FWeight :downloadplandtl1.FWeight ,
|
|
|
|
|
+ TmrLoadName :downloadplandtl1.TmrLoadName ,
|
|
|
|
|
+ DryFeed :downloadplandtl1.DryFeed ,
|
|
|
|
|
+ PriceFeed :downloadplandtl1.PriceFeed ,
|
|
|
|
|
+ OutWeight :downloadplandtl1.OutWeight ,
|
|
|
|
|
+ ErrRatio :downloadplandtl1.ErrRatio ,
|
|
|
|
|
+ Date :downloadplandtl1.Date ,
|
|
|
|
|
+ ButtonSucc :downloadplandtl1.ButtonSucc ,
|
|
|
|
|
+ Type :downloadplandtl1.Type ,
|
|
|
|
|
+ Deviation :downloadplandtl1.Deviation ,
|
|
|
|
|
+ XxwFeedCode :downloadplandtl1.XxwFeedCode ,
|
|
|
|
|
+ }
|
|
|
|
|
+ tx.Insert(d1)
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, downloadplandtl2 := range downloadplandtl2List{
|
|
|
|
|
+ // tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
|
|
|
|
|
+ d2 :=&models.DownloadPlanDtl2{
|
|
|
|
|
+ PastureID :downloadplandtl2.PastureID ,
|
|
|
|
|
+ Pid :data.ID ,
|
|
|
|
|
+ Flpid :downloadplandtl2.Flpid ,
|
|
|
|
|
+ Fbarid :downloadplandtl2.Fbarid ,
|
|
|
|
|
+ FName :downloadplandtl2.FName ,
|
|
|
|
|
+ LWeight :(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl2.LWeight ,
|
|
|
|
|
+ LWeightHis :(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl2.LWeight ,
|
|
|
|
|
+ RemainLeftW :downloadplandtl2.RemainLeftW ,
|
|
|
|
|
+ AllowRW :downloadplandtl2.AllowRW ,
|
|
|
|
|
+ Sort :downloadplandtl2.Sort ,
|
|
|
|
|
+ HaveButton :downloadplandtl2.HaveButton ,
|
|
|
|
|
+ BeginTag :downloadplandtl2.BeginTag ,
|
|
|
|
|
+ EndTag :downloadplandtl2.EndTag ,
|
|
|
|
|
+ ButtonType :downloadplandtl2.ButtonType ,
|
|
|
|
|
+ OptDevice :downloadplandtl2.OptDevice ,
|
|
|
|
|
+ CowCount :downloadplandtl2.CowCount ,
|
|
|
|
|
+ CowClassID :downloadplandtl2.CowClassID ,
|
|
|
|
|
+ CowClassName :downloadplandtl2.CowClassName ,
|
|
|
|
|
+ BigCowName :downloadplandtl2.BigCowName ,
|
|
|
|
|
+ PWeight :downloadplandtl2.PWeight ,
|
|
|
|
|
+ CCountRatio :downloadplandtl2.CCountRatio ,
|
|
|
|
|
+ SumRTime :downloadplandtl2.SumRTime ,
|
|
|
|
|
+ FeedTempletID :downloadplandtl2.FeedTempletID ,
|
|
|
|
|
+ FeedTempletName :downloadplandtl2.FeedTempletName,
|
|
|
|
|
+ DryWeight :downloadplandtl2.DryWeight ,
|
|
|
|
|
+ SumWeight :downloadplandtl2.SumWeight ,
|
|
|
|
|
+ PriceWeight :downloadplandtl2.PriceWeight ,
|
|
|
|
|
+ // ProcessTime :downloadplandtl2.ProcessTime ,
|
|
|
|
|
+ Fpid :downloadplandtl2.Fpid ,
|
|
|
|
|
+ UseInBarType :downloadplandtl2.UseInBarType ,
|
|
|
|
|
+ Date :downloadplandtl2.Date ,
|
|
|
|
|
+ AllowRatio :downloadplandtl2.AllowRatio ,
|
|
|
|
|
+ ErrRatio :downloadplandtl2.ErrRatio ,
|
|
|
|
|
+ ButtonSucc :downloadplandtl2.ButtonSucc ,
|
|
|
|
|
+ Type :downloadplandtl2.Type ,
|
|
|
|
|
+ XxwTempletCode :downloadplandtl2.XxwTempletCode ,
|
|
|
|
|
+ XxwBarCode :downloadplandtl2.XxwBarCode ,
|
|
|
|
|
+ }
|
|
|
|
|
+ _,err :=tx.Insert(d2)
|
|
|
|
|
+ fmt.Println(err )
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, downloadplandtl2 := range downloadplandtl1ExecList{
|
|
|
|
|
+ d2 :=&models.DownloadPlanDtl1Exec{
|
|
|
|
|
+ PastureID:downloadplandtl2.PastureID,
|
|
|
|
|
+ Pid:data.ID,
|
|
|
|
|
+ Flpid:downloadplandtl2.Flpid,
|
|
|
|
|
+ LWeight:(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl2.LWeight ,
|
|
|
|
|
+ HaveButton:downloadplandtl2.HaveButton,
|
|
|
|
|
+ ButtonType:downloadplandtl2.ButtonType,
|
|
|
|
|
+ OptDevice:downloadplandtl2.OptDevice,
|
|
|
|
|
+ Sort:downloadplandtl2.Sort,
|
|
|
|
|
+ FName:downloadplandtl2.FName,
|
|
|
|
|
+ FCount:downloadplandtl2.FCount ,
|
|
|
|
|
+ TmrLoadName:downloadplandtl2.TmrLoadName ,
|
|
|
|
|
+ FeedAllowRatio:downloadplandtl2.FeedAllowRatio ,
|
|
|
|
|
+ StirDelay:downloadplandtl2.StirDelay ,
|
|
|
|
|
+ ButtonSucc:downloadplandtl2.ButtonSucc ,
|
|
|
|
|
+ ErrRatio:downloadplandtl2.ErrRatio ,
|
|
|
|
|
+ Date:downloadplandtl2.Date ,
|
|
|
|
|
+ Type:downloadplandtl2.Type ,
|
|
|
|
|
+ Deviation:downloadplandtl2.Deviation ,
|
|
|
|
|
+ XxwFeedCode:downloadplandtl2.XxwFeedCode ,
|
|
|
|
|
+ }
|
|
|
|
|
+ fmt.Println(d2)
|
|
|
|
|
+ _,err :=tx.Insert(d2)
|
|
|
|
|
+ fmt.Println(err )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ downloadedplanSortList := make([]*models.DownloadedPlan, 0)
|
|
|
|
|
+ tx.SQL(`SELECT * FROM downloadedplan WHERE mydate = ? ORDER BY projname`,data["startTime"] ).Find(&downloadedplanSortList)
|
|
|
|
|
+ for i,d :=range downloadedplanSortList{
|
|
|
|
|
+ tx.Exec(` update downloadedplan set sort = ? where id = ? `, i+1, d.ID)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -12197,7 +12513,7 @@ ORDER BY ftdetail.sort,ftdetail.id `, id, id).Find(&fpdetailFnameList)
|
|
|
appG.Response(http.StatusOK, e.ERROR, "查询失败")
|
|
appG.Response(http.StatusOK, e.ERROR, "查询失败")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
fpdetailList := make([]*models.Fpdetail, 0)
|
|
fpdetailList := make([]*models.Fpdetail, 0)
|
|
|
err = tx.SQL(`select id,barid,barname,times,weight from fpdetail where barid = ?`, id).Find(&fpdetailList)
|
|
err = tx.SQL(`select id,barid,barname,times,weight from fpdetail where barid = ?`, id).Find(&fpdetailList)
|
|
|
if err != nil {
|
|
if err != nil {
|