|
|
@@ -5506,112 +5506,7 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- // for _, data := range dataList {
|
|
|
- // fttype := -1
|
|
|
- // if data.Ptid != -1 {
|
|
|
- // fttype = 1
|
|
|
- // }
|
|
|
-
|
|
|
- // var fweight float64
|
|
|
- // var lweight float64
|
|
|
- // lpplandtl1List := make([]*lpplandtlInfo, 0)
|
|
|
- // err := tx.SQL(`select lppland.*,lpp.maxweight from lpplan lpp
|
|
|
- // join lpplandtl1 lppland on lpp.id = lppland.lppid where lppland.fpdid =?
|
|
|
- // and lppland.fttype = ? and lpp.pastureid = ? and lpp.times = ? order by lpp.sort desc `,
|
|
|
- // data.Id, fttype, pastureid, data.Times).Find(&lpplandtl1List)
|
|
|
- // if err != nil {
|
|
|
- // tx.Rollback()
|
|
|
- // logs.Error(err)
|
|
|
- // return err
|
|
|
- // }
|
|
|
-
|
|
|
- // weight := data.Fweight
|
|
|
- // // weight, _ := strconv.ParseFloat(fpd["weight"].(string), 64)
|
|
|
-
|
|
|
- // var w float64
|
|
|
- // var status int
|
|
|
- // if data.New < data.Old {
|
|
|
- // if weight >= 0 {
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // w = weight
|
|
|
- // status = 0
|
|
|
- // } else {
|
|
|
- // // if weight-(data.New-data.Old) > 0 {
|
|
|
- // // continue
|
|
|
- // // }
|
|
|
- // w = data.New - data.Old
|
|
|
- // status = 1
|
|
|
- // }
|
|
|
- // for _, lppland := range lpplandtl1List {
|
|
|
- // var lppdata lpplandtlInfo
|
|
|
- // tx.SQL(`select sum(lweight) as lweight from lpplandtl1 lpp where lppid = ? and lpp.pastureid = ? `,
|
|
|
- // lppland.Lppid, pastureid).GetFirst(&lppdata)
|
|
|
- // if err != nil {
|
|
|
- // tx.Rollback()
|
|
|
- // logs.Error(err)
|
|
|
- // return err
|
|
|
- // }
|
|
|
- // lweight = lppdata.Lweight
|
|
|
- // if status == 1 {
|
|
|
- // // if w <= lppland.Lweight {
|
|
|
- // if lppland.Maxweight <= lweight {
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // if w+lweight <= lppland.Maxweight {
|
|
|
- // lppland.Lweight += w
|
|
|
- // lweight += w
|
|
|
- // fweight += w
|
|
|
- // w = 0
|
|
|
- // } else {
|
|
|
-
|
|
|
- // w = w - (lppland.Maxweight - lweight)
|
|
|
- // n := (lppland.Maxweight - lweight)
|
|
|
- // lppland.Lweight = lppland.Lweight + n
|
|
|
- // lweight += n
|
|
|
- // fweight += n
|
|
|
-
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // if lppland.Lweight == 0 {
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // if w+lppland.Lweight >= 0 {
|
|
|
- // lppland.Lweight = lppland.Lweight + w
|
|
|
- // lweight = lweight + w
|
|
|
- // fweight = fweight + w
|
|
|
- // w = 0
|
|
|
- // } else {
|
|
|
- // w = w + lppland.Lweight
|
|
|
- // lweight = lweight - lppland.Lweight
|
|
|
- // fweight = fweight - lppland.Lweight
|
|
|
- // lppland.Lweight = 0
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // _, err = tx.SQL(`update lpplandtl1 set Lweight = ? where id = ? and pastureid = ?`, lppland.Lweight, lppland.Id, pastureid).Execute()
|
|
|
- // if err != nil {
|
|
|
- // tx.Rollback()
|
|
|
- // logs.Error(err)
|
|
|
- // return err
|
|
|
- // }
|
|
|
- // break
|
|
|
- // }
|
|
|
- // _, err = tx.SQL(`UPDATE fpdetail SET ptuse=IF(?=1,IF(ptuse+? <0,0,ptuse+?),ptuse),
|
|
|
- // ptsuse=IF(?=0,IF(ptsuse+?<0,0,ptsuse+?),ptsuse)
|
|
|
- // WHERE pastureid=? AND id=?`, fttype, fweight, fweight, fttype, fweight, fweight, pastureid, data.Id).Execute()
|
|
|
- // if err != nil {
|
|
|
- // tx.Rollback()
|
|
|
- // logs.Error(err)
|
|
|
- // return err
|
|
|
- // }
|
|
|
- // // if w == 0 {
|
|
|
- // // break
|
|
|
- // // }
|
|
|
- // // }
|
|
|
|
|
|
- // }
|
|
|
err = tx.Commit()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
@@ -9519,12 +9414,15 @@ func EditDownloadedplanExecWeight(c *gin.Context) {
|
|
|
pid := fsions.Get("pid").ValueStr()
|
|
|
sort := fsions.Get("sort").ValueStr()
|
|
|
weight := fsions.Get("weight").ValueStr()
|
|
|
+ userId := fsions.Get("userId").ValueStr()
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
tx.Begin()
|
|
|
|
|
|
- _, err := tx.Exec(` update downloadplandtl1_exec set actualweight = ? where pid = ? and sort = ? `, weight, pid, sort)
|
|
|
+ _, err := tx.Exec(` insert into downloadplandtl1_update(pid,sort,lastweight,weight,userId,createdate)
|
|
|
+ values(?,?,(select actualweightminus from downloadplandtl1_exec where pid = ? and sort = ? ),?,?,now()) `,
|
|
|
+ pid, sort, pid, sort, weight, userId)
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusOK, e.ERROR, "修改计划重量失败!"+err.Error())
|
|
|
@@ -9532,7 +9430,15 @@ func EditDownloadedplanExecWeight(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- _, err = tx.Exec(` update downloadplandtl1 set actualweight = lweight / (select sum(lweight) from downloadplandtl1 where pid = ? and sort = ? ) * ? where pid = ? and sort = ? `, pid, sort, weight, pid, sort)
|
|
|
+ _, err = tx.Exec(` update downloadplandtl1_exec set actualweightminus = ? where pid = ? and sort = ? `, weight, pid, sort)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划重量失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.Exec(` update downloadplandtl1 set actualweightminus = lweight / (select sum(lweight) from downloadplandtl1 where pid = ? and sort = ? ) * ? where pid = ? and sort = ? `, pid, sort, weight, pid, sort)
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusOK, e.ERROR, "修改计划重量失败!"+err.Error())
|
|
|
@@ -9558,12 +9464,23 @@ func EditDownloadplandtl2Weight(c *gin.Context) {
|
|
|
pid := fsions.Get("pid").ValueStr()
|
|
|
sort := fsions.Get("sort").ValueStr()
|
|
|
weight := fsions.Get("weight").ValueStr()
|
|
|
+ userId := fsions.Get("userId").ValueStr()
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
tx.Begin()
|
|
|
|
|
|
- _, err := tx.Exec(` update downloadplandtl2 set actualweight = ? where pid = ? and sort = ? `, weight, pid, sort)
|
|
|
+ _, err := tx.Exec(` insert into downloadplandtl2_update(pid,sort,lastweight,weight,userId,createdate)
|
|
|
+ values(?,?,(select actualweightminus from downloadplandtl2 where pid = ? and sort = ? ),?,?,now()) `,
|
|
|
+ pid, sort, pid, sort, weight, userId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划重量失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.Exec(` update downloadplandtl2 set actualweightminus = ? where pid = ? and sort = ? `, weight, pid, sort)
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusOK, e.ERROR, "修改计划重量失败!"+err.Error())
|
|
|
@@ -9809,3 +9726,287 @@ func EditLanguage(c *gin.Context) {
|
|
|
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
|
}
|
|
|
+
|
|
|
+func FpdBatchEditGrfd(pastureid string, barList []map[string]string) {
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ oldFpdList, err := tx.SQL(` select ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") fweight,fpd.id,fpd.barname,fpd.weight,fpd.times,fp.ftweight,fp.supplyweight from fpdetail fpd
|
|
|
+ join feedp fp on fp.barid = fpd.barid and fpd.pastureid = fp.pastureid where fpd.pastureid = ?`, pastureid).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ // appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, dataexcel := range barList {
|
|
|
+
|
|
|
+ // dataexcel := make(map[string]interface{}, 0)
|
|
|
+ // dataexcel["barname"] = barFsions.Get("barname").ValueStr()
|
|
|
+ // dataexcel["ccount"] = barFsions.Get("ccount").ValueStr()
|
|
|
+ // dataexcel["ratio"] = barFsions.Get("ratio").ValueStr()
|
|
|
+ // dataexcel["ftname"] = barFsions.Get("ftname").ValueStr()
|
|
|
+ // dataexcel["ptsfname"] = barFsions.Get("ptsfname").ValueStr()
|
|
|
+ _, 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)
|
|
|
+ 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)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if dataexcel["ftname"] == "" || dataexcel["ccount"] == "0" || dataexcel["ratio"] == "0" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // dataexcel["1"] = barFsions.Get("times1").ValueStr()
|
|
|
+ // dataexcel["2"] = barFsions.Get("times2").ValueStr()
|
|
|
+ // dataexcel["3"] = barFsions.Get("times3").ValueStr()
|
|
|
+ // dataexcel["4"] = barFsions.Get("times4").ValueStr()
|
|
|
+ // dataexcel["5"] = barFsions.Get("times5").ValueStr()
|
|
|
+ // dataexcel["6"] = barFsions.Get("times6").ValueStr()
|
|
|
+
|
|
|
+ ftexist, err := tx.SQL(` select id from feedp where barname = ? and pastureid = ? and ftname = ? `, dataexcel["barname"], pastureid, dataexcel["ftname"]).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !ftexist {
|
|
|
+ fmt.Println(dataexcel["barname"], pastureid, dataexcel["ftname"])
|
|
|
+ tx.SQL(` delete from lpplandtl1 where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ tx.SQL(` update fpdetail set ptuse = 0 where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ exist, err := tx.SQL(` select id from feedp where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist {
|
|
|
+ _, err := tx.SQL(` insert into feedp(pastureid,barid,barname,ccount)values(?,(select id from bar where bname = ? and pastureid = ? ),?,?) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"], 0).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var feedpargs []interface{}
|
|
|
+ upFeedpSql := `update feedp set ccount = ? ,ratio = ? ,ccountratio = ?*(?*0.01) `
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"])
|
|
|
+ if _, ok := dataexcel["ftname"]; ok {
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ftname"], pastureid, dataexcel["ftname"])
|
|
|
+ upFeedpSql += ` , ftid = (select id from feedtemplet where tname = ? and pastureid = ? ),ftname = ? `
|
|
|
+
|
|
|
+ upFeedpSql += `,ftweight = (select sum(fweight) fweight from ftdetail
|
|
|
+ where ftid = (select id from feedtemplet where tname = ? and pastureid = ? )) * (?*(?*0.01)) `
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ftname"], pastureid, dataexcel["ccount"], dataexcel["ratio"])
|
|
|
+ } else {
|
|
|
+ upFeedpSql += ` , ftid = -1,ftname = '' ,ftweight = 0 `
|
|
|
+ }
|
|
|
+
|
|
|
+ if _, ok := dataexcel["ptsfname"]; ok {
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ptsfname"], pastureid, dataexcel["ptsfname"])
|
|
|
+ upFeedpSql += ` , ptsfid = (select id from feedtemplet where tname = ? and pastureid = ? ),ptsfname = ? `
|
|
|
+
|
|
|
+ upFeedpSql += `,supplyweight = ifnull((select sum(fweight) fweight from ftdetail
|
|
|
+ where ftid = (select id from feedtemplet where tname = ? and pastureid = ? )) * (?*(?*0.01)),0)`
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ptsfname"], pastureid, dataexcel["ccount"], dataexcel["ratio"])
|
|
|
+ } else {
|
|
|
+ upFeedpSql += ` , ptsfid = -1,ptsfname = '',supplyweight = 0 `
|
|
|
+ }
|
|
|
+ upFeedpSql += " where barname = ? and pastureid = ? "
|
|
|
+ feedpargs = append(feedpargs, dataexcel["barname"], pastureid)
|
|
|
+ _, err = tx.SQL(upFeedpSql, feedpargs...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ exist1, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 1 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if !exist1 {
|
|
|
+ _, err := tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,1,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist2, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 2 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist2 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,2,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ exist3, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times =3 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist3 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,3,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist4, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 4 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist4 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,4,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist5, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 5 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist5 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,5,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist6, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 6 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist6 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,6,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ upFpdSql := ` update fpdetail set tratio = ? ,weight = (? *0.01) * ((select sum(fweight) fweight from ftdetail
|
|
|
+ where ftid = (select id from feedtemplet where tname = ? and pastureid = ? )) * (?*(?*0.01))) ,cowcount = ? ,
|
|
|
+ ccountradio= ?,ptid= (select id from feedtemplet where tname = ? and pastureid = ? ) where barname = ?
|
|
|
+ and pastureid = ? and times = ?`
|
|
|
+ var fpdargs1 []interface{}
|
|
|
+ fpdargs1 = append(fpdargs1, dataexcel["1"], dataexcel["1"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 1)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs1...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var fpdargs2 []interface{}
|
|
|
+ fpdargs2 = append(fpdargs2, dataexcel["2"], dataexcel["2"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 2)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs2...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var fpdargs3 []interface{}
|
|
|
+ fpdargs3 = append(fpdargs3, dataexcel["3"], dataexcel["3"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 3)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs3...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var fpdargs4 []interface{}
|
|
|
+ fpdargs4 = append(fpdargs4, dataexcel["4"], dataexcel["4"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 4)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs4...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var fpdargs5 []interface{}
|
|
|
+ fpdargs5 = append(fpdargs5, dataexcel["5"], dataexcel["5"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 5)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs5...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var fpdargs6 []interface{}
|
|
|
+ fpdargs6 = append(fpdargs6, dataexcel["6"], dataexcel["6"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 6)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs6...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // _, err = tx.SQL(`call updateLPPbyFPChange(?,( select id from feedp where barname = ? and pastureid = ?))`, pastureid, dataexcel["barname"], pastureid).Execute()
|
|
|
+
|
|
|
+ newList, err := tx.SQL(` select ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") fweight,id,ptid,weight,times from fpdetail where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // oldFpdList, err := tx.SQL(` select fpd.id,fpd.barname,fpd.weight,fpd.times,fp.ftweight,fp.supplyweight from fpdetail fpd
|
|
|
+ // join feedp fp on fp.barid = fpd.barid and fpd.pastureid = fp.pastureid where fpd.pastureid = ?`, pastureid).Query().List()
|
|
|
+ upFpdetailList := make([]*upFpdetail, 0)
|
|
|
+ for _, newfpd := range newList {
|
|
|
+ for _, oldfpd := range oldFpdList {
|
|
|
+ if oldfpd["id"].(int64) == newfpd["id"].(int64) {
|
|
|
+ var oldweight, newweight float64
|
|
|
+ if oldfpd["weight"] != nil {
|
|
|
+ oldweight, _ = strconv.ParseFloat(oldfpd["weight"].(string), 64)
|
|
|
+ }
|
|
|
+ if newfpd["weight"] != nil {
|
|
|
+ newweight, _ = strconv.ParseFloat(newfpd["weight"].(string), 64)
|
|
|
+ }
|
|
|
+ fweight, _ := strconv.ParseFloat(newfpd["fweight"].(string), 64)
|
|
|
+ upFpdetailList = append(upFpdetailList, &upFpdetail{
|
|
|
+ Old: oldweight,
|
|
|
+ New: newweight,
|
|
|
+ Times: newfpd["times"].(int64),
|
|
|
+ Ptid: newfpd["ptid"].(int64),
|
|
|
+ Fweight: fweight,
|
|
|
+ Id: oldfpd["id"].(int64),
|
|
|
+ })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateFpdetailByBar(pastureid, dataexcel["barname"], upFpdetailList)
|
|
|
+ }
|
|
|
+}
|