|
@@ -1490,6 +1490,18 @@ func ExecDataByConfig(c *gin.Context) {
|
|
|
tempCommon["jwt_username"] = tempv.(string)
|
|
|
}
|
|
|
|
|
|
+ for _, paramvalue := range tempval {
|
|
|
+ fmt.Println(paramvalue["name"])
|
|
|
+ if paramvalue["name"].(string) == "updateBigFP" {
|
|
|
+ err = updateLpplandtlInfo(tx, paramvalue["parammaps"].(map[string]interface{}))
|
|
|
+ if err != nil {
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for _, paramvalue := range tempval {
|
|
|
if _, ok := paramvalue["resultname"]; !ok {
|
|
|
paramvalue["resultname"] = paramvalue["name"]
|
|
@@ -2995,7 +3007,7 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
|
|
|
fsion := gofasion.NewFasion(string(dataByte))
|
|
|
// parammaps := fsion.Get("parammaps")
|
|
|
- createdate := fsion.Get("createdate").ValueStr()
|
|
|
+ createdate := time.Now().Format("2006-01-02 15:04:05")
|
|
|
err := json.Unmarshal(dataByte, &tempval_)
|
|
|
if err != nil {
|
|
|
appG.Response(http.StatusOK, e.ERROR, false)
|
|
@@ -3184,13 +3196,13 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
|
|
|
weight, _ := strconv.ParseFloat(fpd["weight"].(string), 64)
|
|
|
oldweight, _ := strconv.ParseFloat(old["weight"].(string), 64)
|
|
|
+ if weight > oldweight {
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
var w float64
|
|
|
var status int
|
|
|
|
|
|
- if fpd["barname"].(string) == "D1" {
|
|
|
- fmt.Println("1")
|
|
|
- }
|
|
|
if weight < oldweight {
|
|
|
if weight >= 0 {
|
|
|
return
|
|
@@ -3336,10 +3348,10 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
// if oldFpd["id"].(int64) == newFpd["id"].(int64) && oldFpd["times"].(int64) == newFpd["times"].(int64) {
|
|
|
// if oldFpd["tratio"].(string) != newFpd["tratio"].(string) || oldFpd["weight"].(string) != newFpd["weight"].(string) {
|
|
|
// go func() {
|
|
|
- _, err := tx.SQL(` insert into fpdetailhistory(pastureid,barid,barname,times,tratio,weight,ptsrate,cowcount,ccountradio,ptid,ptsid,ptuse,ptsuse,supplement,createdate)
|
|
|
- values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, newFpd["pastureid"], newFpd["barid"], newFpd["barname"], newFpd["times"],
|
|
|
+ _, err := tx.SQL(` insert into fpdetailhistory(pastureid,barid,barname,times,tratio,weight,ptsrate,cowcount,ccountradio,ptid,ptsid,ptuse,ptsuse,supplement,createdate,userId)
|
|
|
+ values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, newFpd["pastureid"], newFpd["barid"], newFpd["barname"], newFpd["times"],
|
|
|
newFpd["tratio"], newFpd["weight"], newFpd["ptsrate"], newFpd["cowcount"], newFpd["ccountradio"],
|
|
|
- newFpd["ptid"], newFpd["ptsid"], newFpd["ptuse"], newFpd["ptsuse"], newFpd["supplement"], now).Execute()
|
|
|
+ newFpd["ptid"], newFpd["ptsid"], newFpd["ptuse"], newFpd["ptsuse"], newFpd["supplement"], now, fsion.Get("userId").ValueStr()).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusOK, e.ERROR, false)
|
|
@@ -3358,13 +3370,13 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
// if oldLpplandtl1["lweight"] != newLpplandtl1["lweight"] {
|
|
|
// go func() {
|
|
|
_, err := tx.SQL(` insert into lpplandtl1history(pastureid,lppid,barid,barname,fpdid,fttype,lweight,sort,tmrid,tmrname,
|
|
|
- background,cowcount,ccountradio,lweighthis,createdate)
|
|
|
- values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
+ background,cowcount,ccountradio,lweighthis,createdate,userId)
|
|
|
+ values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
newLpplandtl1["pastureid"], newLpplandtl1["lppid"], newLpplandtl1["barid"],
|
|
|
newLpplandtl1["barname"], newLpplandtl1["fpdid"], newLpplandtl1["fttype"],
|
|
|
newLpplandtl1["lweight"], newLpplandtl1["sort"], newLpplandtl1["tmrid"],
|
|
|
newLpplandtl1["tmrname"], newLpplandtl1["background"], newLpplandtl1["cowcount"],
|
|
|
- newLpplandtl1["ccountradio"], newLpplandtl1["lweighthis"], now).Execute()
|
|
|
+ newLpplandtl1["ccountradio"], newLpplandtl1["lweighthis"], now, fsion.Get("userId").ValueStr()).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusOK, e.ERROR, false)
|
|
@@ -3383,13 +3395,13 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
// oldFeedp["ftweight"].(string) != newFeedp["ftweight"].(string) {
|
|
|
// go func() {
|
|
|
_, err := tx.SQL(` insert into feedphistory(pastureid,barname,barid,softccount,ccount,ratio,ccountratio,ftid,
|
|
|
- ftname,ptsfid,ptsfname,feedweight,ftweight,supplyweight,owner,createdate)
|
|
|
- values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
+ ftname,ptsfid,ptsfname,feedweight,ftweight,supplyweight,owner,createdate,userId)
|
|
|
+ values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
newFeedp["pastureid"], newFeedp["barname"], newFeedp["barid"],
|
|
|
newFeedp["softccount"], newFeedp["ccount"], newFeedp["ratio"],
|
|
|
newFeedp["ccountratio"], newFeedp["ftid"], newFeedp["ftname"],
|
|
|
newFeedp["ptsfid"], newFeedp["ptsfname"], newFeedp["feedweight"],
|
|
|
- newFeedp["ftweight"], newFeedp["supplyweight"], newFeedp["owner"], now).Execute()
|
|
|
+ newFeedp["ftweight"], newFeedp["supplyweight"], newFeedp["owner"], now, fsion.Get("userId").ValueStr()).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusOK, e.ERROR, false)
|
|
@@ -3433,7 +3445,7 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
tx := restful.Engine.NewSession()
|
|
|
tx.Begin()
|
|
|
|
|
|
- fpdList, err := tx.SQL(` select id,ifnull(ROUND((1-ptsrate)*weight,2),"") weight,ptuse from fpdetail where pastureid = ? and barid = ? order by times `,
|
|
|
+ fpdList, err := tx.SQL(` select id,ifnull(ROUND((1-ptsrate)*weight,2),"") weight,ptuse from fpdetail where pastureid = ? and barid = (select barid from feedp where id = ? ) order by times `,
|
|
|
pastureid, id).Query().List()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -3484,13 +3496,15 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
- _, err := tx.SQL(` update lpplandtl1 set lweight = ? where id = ? `, lppland["lweight"].(float64)-weight, lppland["id"]).Execute()
|
|
|
- if err != nil {
|
|
|
- tx.Rollback()
|
|
|
- logs.Error(err)
|
|
|
- appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
- return
|
|
|
- }
|
|
|
+
|
|
|
+ // _, err := tx.SQL(` update lpplandtl1 set lweight = ?-? where id = ? `, lppland["lweight"], weight, lppland["id"]).Execute()
|
|
|
+ // _, err := tx.SQL(` update lpplandtl1 set lweight = ? where id = ? `, lpplandlweight-weight, lppland["id"]).Execute()
|
|
|
+ // if err != nil {
|
|
|
+ // tx.Rollback()
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
weight = 0
|
|
|
break
|
|
|
}
|
|
@@ -3508,13 +3522,13 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
ftmap["ptsid"] = list.Get("ptsid").ValueStr()
|
|
|
// fmt.Println(ftmap)
|
|
|
|
|
|
- fpdDataList, err := tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
|
|
|
+ fpdDataList, err := tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(-1 ) ptsid ,
|
|
|
(select bname from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,0 AS fttype,cowcount,ccountradio,1 isfill FROM fpdetail
|
|
|
- WHERE fpdetail.pastureid = ? and barid = ? and times = ?
|
|
|
+ WHERE fpdetail.pastureid = ? and barid =(select barid from feedp where id = ? ) and times = ?
|
|
|
UNION
|
|
|
SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(ptid) ptid,TRIM(ptsid ) ptsid ,
|
|
|
(select bname from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,1 AS fttype,cowcount,ccountradio,0 isfill FROM fpdetail
|
|
|
- WHERE fpdetail.pastureid = ? and barid = ? and times = ? ) t
|
|
|
+ WHERE fpdetail.pastureid = ? and barid = (select barid from feedp where id = ? ) and times = ? ) t
|
|
|
order by t.barname,t.times`, pastureid, id, ftmap["times"], pastureid, id, ftmap["times"]).Query().List()
|
|
|
// fmt.Println(pastureid, id, ftmap["times"], pastureid, id, ftmap["times"])
|
|
|
if err != nil {
|
|
@@ -3546,7 +3560,7 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
|
|
|
var w float64
|
|
|
var status int
|
|
|
-
|
|
|
+ fmt.Println(ftmap["new"].(float64), ftmap["old"].(float64))
|
|
|
if ftmap["new"].(float64) < ftmap["old"].(float64) {
|
|
|
if weight >= 0 {
|
|
|
continue
|
|
@@ -3554,7 +3568,8 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
w = weight
|
|
|
status = 0
|
|
|
} else {
|
|
|
- if weight-(ftmap["new"].(float64)-ftmap["old"].(float64)) > 0 {
|
|
|
+ // continue
|
|
|
+ if weight <= 0 {
|
|
|
continue
|
|
|
}
|
|
|
w = weight
|
|
@@ -3653,13 +3668,13 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
|
|
|
for _, newLpplandtl1 := range newLpplandtl1List {
|
|
|
_, err := tx.SQL(` insert into lpplandtl1history(pastureid,lppid,barid,barname,fpdid,fttype,lweight,sort,tmrid,tmrname,
|
|
|
- background,cowcount,ccountradio,lweighthis,createdate)
|
|
|
- values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
+ background,cowcount,ccountradio,lweighthis,createdate,userId)
|
|
|
+ values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
newLpplandtl1["pastureid"], newLpplandtl1["lppid"], newLpplandtl1["barid"],
|
|
|
newLpplandtl1["barname"], newLpplandtl1["fpdid"], newLpplandtl1["fttype"],
|
|
|
newLpplandtl1["lweight"], newLpplandtl1["sort"], newLpplandtl1["tmrid"],
|
|
|
newLpplandtl1["tmrname"], newLpplandtl1["background"], newLpplandtl1["cowcount"],
|
|
|
- newLpplandtl1["ccountradio"], newLpplandtl1["lweighthis"], now).Execute()
|
|
|
+ newLpplandtl1["ccountradio"], newLpplandtl1["lweighthis"], now, fsion.Get("userId").ValueStr()).Execute()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
appG.Response(http.StatusOK, e.ERROR, false)
|
|
@@ -3667,33 +3682,6 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // for _, newFpd := range newFpdDataList {
|
|
|
- // _, err := tx.SQL(` insert into fpdetailhistory(pastureid,barid,barname,times,tratio,weight,ptsrate,cowcount,ccountradio,ptid,ptsid,ptuse,ptsuse,supplement,createdate)
|
|
|
- // values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, newFpd["pastureid"], newFpd["barid"], newFpd["barname"], newFpd["times"],
|
|
|
- // newFpd["tratio"], newFpd["weight"], newFpd["ptsrate"], newFpd["cowcount"], newFpd["ccountradio"],
|
|
|
- // newFpd["ptid"], newFpd["ptsid"], newFpd["ptuse"], newFpd["ptsuse"], newFpd["supplement"], now).Execute()
|
|
|
- // if err != nil {
|
|
|
- // logs.Error(err)
|
|
|
- // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // }
|
|
|
- // for _, newFeedp := range newFeedpList {
|
|
|
- // _, err := tx.SQL(` insert into feedphistory(pastureid,barname,barid,softccount,ccount,ratio,ccountratio,ftid,
|
|
|
- // ftname,ptsfid,ptsfname,feedweight,ftweight,supplyweight,owner,createdate)
|
|
|
- // values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
- // newFeedp["pastureid"], newFeedp["barname"], newFeedp["barid"],
|
|
|
- // newFeedp["softccount"], newFeedp["ccount"], newFeedp["ratio"],
|
|
|
- // newFeedp["ccountratio"], newFeedp["ftid"], newFeedp["ftname"],
|
|
|
- // newFeedp["ptsfid"], newFeedp["ptsfname"], newFeedp["feedweight"],
|
|
|
- // newFeedp["ftweight"], newFeedp["supplyweight"], newFeedp["owner"], now).Execute()
|
|
|
- // if err != nil {
|
|
|
- // logs.Error(err)
|
|
|
- // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
|
}
|
|
|
|
|
@@ -3840,7 +3828,7 @@ func AddFtdry(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
var actweight float64
|
|
|
- actweightList, err := tx.SQL(`select ROUND(avg(actweight),2) as actweight from ftdry
|
|
|
+ actweightList, err := tx.SQL(`select ifnull(ROUND(avg(actweight),2),0) as actweight from ftdry
|
|
|
where barid in ( select barid from feedp where ftid in ( select ftid from feedp where barid = ? and pastureid = ?))
|
|
|
and operatetime = (select date_format(operatetime ,'%Y-%m-%d') from ftdry
|
|
|
where barid in ( select barid from feedp where ftid in ( select ftid from feedp where barid = ? and pastureid = ? ))
|
|
@@ -4333,10 +4321,19 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
if _, ok := outentry["第三班比例(%)"]; ok {
|
|
|
dataexcel["3"] = outentry["第三班比例(%)"]
|
|
|
}
|
|
|
+
|
|
|
if _, ok := outentry["第四班比例(%)"]; ok {
|
|
|
dataexcel["4"] = outentry["第四班比例(%)"]
|
|
|
}
|
|
|
|
|
|
+ if _, ok := outentry["第五班比例(%)"]; ok {
|
|
|
+ dataexcel["5"] = outentry["第四班比例(%)"]
|
|
|
+ }
|
|
|
+
|
|
|
+ if _, ok := outentry["第六班比例(%)"]; ok {
|
|
|
+ dataexcel["6"] = outentry["第六班比例(%)"]
|
|
|
+ }
|
|
|
+
|
|
|
existbar, err := tx.SQL(` select id from bar where bname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -4354,6 +4351,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
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)
|
|
@@ -4417,12 +4415,13 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- exist1, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ 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)
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
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()
|
|
@@ -4431,7 +4430,14 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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 {
|
|
@@ -4439,7 +4445,15 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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 {
|
|
@@ -4447,7 +4461,14 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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 {
|
|
@@ -4456,6 +4477,36 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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 = ? ,
|
|
@@ -4470,10 +4521,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
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 fpdargs2 []interface{}
|
|
|
fpdargs2 = append(fpdargs2, dataexcel["2"], dataexcel["2"], dataexcel["ftname"], pastureid,
|
|
|
dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
@@ -4501,6 +4549,26 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
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 {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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 {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ 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()
|
|
@@ -4567,7 +4635,7 @@ func updateFpdetailByBar(pastureid, barname string, dataList []*upFpdetail) erro
|
|
|
defer tx.Close()
|
|
|
tx.Begin()
|
|
|
|
|
|
- fpdList, err := tx.SQL(` select id,ifnull(ROUND((1-ptsrate)*weight,2),"") weight,ptuse,times from fpdetail where pastureid = ? and barname = ? order by times `,
|
|
|
+ fpdList, err := tx.SQL(` select id,ifnull(ROUND((1-ifnull(ptsrate,0))*weight,2),"") weight,ptuse,times from fpdetail where pastureid = ? and barname = ? order by times `,
|
|
|
pastureid, barname).Query().List()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -4575,7 +4643,7 @@ func updateFpdetailByBar(pastureid, barname string, dataList []*upFpdetail) erro
|
|
|
|
|
|
for _, fpd := range fpdList {
|
|
|
|
|
|
- lpplandList, err := tx.SQL(` select lppland.id,lppland.lweight from lpplandtl1 lppland join lpplan lpp on lpp.id = lppland.lppid
|
|
|
+ lpplandList, err := tx.SQL(` select lppland.id,ifnull(lppland.lweight,0) lweight from lpplandtl1 lppland join lpplan lpp on lpp.id = lppland.lppid
|
|
|
where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by lpp.sort desc `,
|
|
|
pastureid, fpd["id"], fpd["times"]).Query().List()
|
|
|
if err != nil {
|
|
@@ -5205,7 +5273,7 @@ func GetFeedpHistory(c *gin.Context) {
|
|
|
defer tx.Close()
|
|
|
|
|
|
feedpList, err := tx.SQL(` select barid,barname,ccount,ratio,ccountratio,ftid,ftname,
|
|
|
- DATE_FORMAT(createdate,'%Y-%m-%d %H:%i:%s') as createdate from feedphistory where barname = ?
|
|
|
+ DATE_FORMAT(createdate,'%Y-%m-%d %H:%i:%s') as createdate,(select empname from user where id = feedphistory.userId)empname from feedphistory where barname = ?
|
|
|
and createdate between ? and ? order by createdate desc `, bar, startDate, endDate).Query().List()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -5213,7 +5281,8 @@ func GetFeedpHistory(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- fpdList, err := tx.SQL(` select times,tratio,weight, DATE_FORMAT(createdate,'%Y-%m-%d %H:%i:%s') as createdate from fpdetailhistory where barname = ?
|
|
|
+ fpdList, err := tx.SQL(` select times,tratio,weight, DATE_FORMAT(createdate,'%Y-%m-%d %H:%i:%s') as createdate,
|
|
|
+ (select empname from user where id = fpdetailhistory.userId)empname from fpdetailhistory where barname = ?
|
|
|
and createdate between ? and ? order by createdate desc, times asc`, bar, startDate, endDate).Query().List()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -5465,7 +5534,8 @@ func UpdateRemind(c *gin.Context) {
|
|
|
noticeMsgtype.PushTime = parammaps.Get("push_time").ValueStr()
|
|
|
noticeMsgtype.IntervalTime = parammaps.Get("interval_time").ValueInt64()
|
|
|
noticeMsgtype.PushLimit = parammaps.Get("push_limit").ValueInt64()
|
|
|
- noticeMsgtype.TemplateId = parammaps.Get("template_id").ValueStr()
|
|
|
+ // noticeMsgtype.TemplateId = parammaps.Get("template_id").ValueStr()
|
|
|
+ noticeMsgtype.TemplateId = "1_zBqvbzD-edg0b-O5OD1kAEMefygikcmBZACSiwX0w"
|
|
|
// noticeMsgtype. = parammaps.Get("roles_id").ValueStr()
|
|
|
noticeMsgtype.DateType = parammaps.Get("date_type").ValueInt64()
|
|
|
noticeMsgtype.CycleType = parammaps.Get("cycle_type").ValueInt64()
|
|
@@ -5736,7 +5806,7 @@ func GetFeedtempletHistory(c *gin.Context) {
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
|
|
|
- ftList, err := tx.SQL(` select *,DATE_FORMAT(createdate,'%Y-%m-%d %H:%i:%s') as createdate1 from feedtemplethistory where createdate between ? and ?
|
|
|
+ ftList, err := tx.SQL(` select *,DATE_FORMAT(createdate,'%Y-%m-%d %H:%i:%s') as createdate1,(select empname from user where id = feedtemplethistory.userId) empname from feedtemplethistory where createdate between ? and ?
|
|
|
and id = ? and pastureid = ? order by createdate desc `,
|
|
|
start, end, ftid, pastureid).Query().List()
|
|
|
if err != nil {
|
|
@@ -5757,6 +5827,7 @@ func GetFeedtempletHistory(c *gin.Context) {
|
|
|
for i, ft := range ftList {
|
|
|
fithisList, err := tx.SQL(` select fit.Eweight,fit.weight,fit.name as fname,
|
|
|
ifnull(fit.feedgroup,( select ft.feedgroup from ftdetail ft where ft.ftid = fit.fitid and fit.name = ft.fname )) as feedgroup,
|
|
|
+ (select empname from user where id = fit.userId) empname,
|
|
|
|
|
|
ifnull(fit.autosecond ,( select ft.autosecond from ftdetail ft where ft.ftid = fit.fitid and fit.name = ft.fname )) as autosecond from fit_history fit
|
|
|
where fit.fitid = ?
|
|
@@ -5843,6 +5914,7 @@ func GetFeedtempletHistory(c *gin.Context) {
|
|
|
data := make(map[string]interface{})
|
|
|
data["feedgroup"] = fit["feedgroup"]
|
|
|
data["fname"] = fit["fname"]
|
|
|
+ data["empname"] = fit["empname"]
|
|
|
if fit["Eweight"] != nil {
|
|
|
if fit["Eweight"].(string) != fit["weight"].(string) {
|
|
|
data["fweight"] = fmt.Sprintf("%v/%v", fit["Eweight"], fit["weight"])
|
|
@@ -6991,3 +7063,714 @@ func GetFormulaStatistics(c *gin.Context) {
|
|
|
resp["data2"] = data2
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, resp)
|
|
|
}
|
|
|
+
|
|
|
+func GetPlanData(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+
|
|
|
+ fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+ sqlnamestr := fsion.Get("name").ValueStr()
|
|
|
+ sqlnamestr1 := fsion.Get("name1").ValueStr()
|
|
|
+ offset := fsion.Get("offset").ValueDefaultInt(0)
|
|
|
+ pagecount := fsion.Get("plancount").ValueDefaultInt(0)
|
|
|
+ returntype := fsion.Get("returntype").ValueDefaultStr("map")
|
|
|
+ month := fsion.Get("month").ValueDefaultStr("map")
|
|
|
+ logging.Info("GetUpkeepPlan ", c.Keys, sqlnamestr, month)
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ err := tx.Begin()
|
|
|
+ defer func() {
|
|
|
+ switch {
|
|
|
+ case err != nil:
|
|
|
+ if tx != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ if tx != nil {
|
|
|
+ err = tx.Commit()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if tx != nil {
|
|
|
+ tx.Close()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ sql, p := restful.GetSqlByNameDBT(sqlnamestr, tx)
|
|
|
+ sql1, p1 := restful.GetSqlByNameDBT(sqlnamestr1, tx)
|
|
|
+ if sql != "" {
|
|
|
+ s_params := make([]interface{}, 0)
|
|
|
+ if fsion.HasKey("parammaps") {
|
|
|
+ parammaps := fsion.Get("parammaps")
|
|
|
+ paramslist := strings.Split(p, ",")
|
|
|
+ if len(paramslist) > 0 && p != "" {
|
|
|
+ for _, value := range paramslist {
|
|
|
+ if strings.ToLower(strings.Trim(value, " ")) == "jwt_username" {
|
|
|
+ if tempv, exists := c.Get("jwt_username"); exists {
|
|
|
+ s_params = append(s_params, tempv.(string))
|
|
|
+ } else {
|
|
|
+ s_params = append(s_params, "")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ queryData, err := getDataBySqlT(sql, offset, pagecount, returntype, s_params, tx)
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, err.Error())
|
|
|
+
|
|
|
+ } else {
|
|
|
+ paramslist1 := strings.Split(p1, ",")
|
|
|
+
|
|
|
+ for index, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
|
|
|
+ s_params1 := make([]interface{}, 0)
|
|
|
+ if len(paramslist1) > 0 && p1 != "" {
|
|
|
+ for _, v := range paramslist1 {
|
|
|
+ s_params1 = append(s_params1, value[strings.ToLower(strings.Trim(v, " "))])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ arr, _ := tx.SQL(sql1, s_params1...).Query().List() //获取
|
|
|
+ for _, item := range arr {
|
|
|
+ trgaddressList := []string{}
|
|
|
+ if _, ok := item["trgaddress"]; ok {
|
|
|
+ trgaddressList1 := strings.Split(item["trgaddress"].(string), ",")
|
|
|
+ for _, str := range trgaddressList1 {
|
|
|
+ if str != "" {
|
|
|
+ trgaddressList = append(trgaddressList, str)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item["trgaddressList"] = trgaddressList
|
|
|
+ }
|
|
|
+ queryData.(map[string]interface{})["list"].([]map[string]interface{})[index]["arrList"] = arr
|
|
|
+ }
|
|
|
+ // var wg sync.WaitGroup
|
|
|
+ // for _, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
|
|
|
+ // wg.Add(1)
|
|
|
+ // go func(value map[string]interface{}) {
|
|
|
+ // defer wg.Done()
|
|
|
+ // _, err = tx.SQL(`update downloadedplan set havebutton = 1 where id = ? and pastureid = ? `, value["projuctid"], value["pastureid"]).Execute()
|
|
|
+ // }(value)
|
|
|
+ // }
|
|
|
+ // wg.Wait()
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, nil)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func PostPlanData(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+ logging.Info("PostRJSBData err: ", string(dataByte))
|
|
|
+
|
|
|
+ s_params := make([]interface{}, 0)
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ err := tx.Begin()
|
|
|
+ defer func() {
|
|
|
+ switch {
|
|
|
+ case err != nil:
|
|
|
+ if tx != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ if tx != nil {
|
|
|
+ err = tx.Commit()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if tx != nil {
|
|
|
+ tx.Close()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
|
|
|
+ sql1, p1 := restful.GetSqlByNameDBT("updated1YJ", tx)
|
|
|
+ sql2, p2 := restful.GetSqlByNameDBT("updated1execYJ", tx)
|
|
|
+ sql3, p3 := restful.GetSqlByNameDBT("updated2YJ", tx)
|
|
|
+ if !fsion.HasKey("parammaps") {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "参数解析失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ parammaps := fsion.Get("parammaps")
|
|
|
+
|
|
|
+ paramslist := strings.Split(p, ",")
|
|
|
+ if len(paramslist) > 0 && p != "" {
|
|
|
+ for _, value := range paramslist {
|
|
|
+ s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _, err = tx.SQL(sql, s_params...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("PostRJSBData err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ s_params = make([]interface{}, 0)
|
|
|
+ paramslist = strings.Split(p1, ",")
|
|
|
+ if len(paramslist) > 0 && p1 != "" {
|
|
|
+ for _, value := range paramslist {
|
|
|
+ // if value == "ID" {
|
|
|
+ // id := parammaps.Get("ID").ValueStr()
|
|
|
+ // pastureid := parammaps.Get("pastureid").ValueStr()
|
|
|
+ // datalist, err := tx.SQL(`select d2.id as id from downloadplandtl1 d1 join downloadplandtl1_exec d2 on d1.id = d2.id where d1.pid = (select pid from downloadplandtl1 where id = ? and pastureid = ? ) and
|
|
|
+ // d1.sort = (select sort from downloadplandtl1 where id = ? and pastureid = ? )`, id, pastureid, id, pastureid).QueryString()
|
|
|
+ // if err != nil {
|
|
|
+ // logging.Error("PostRJSBData err: ", err)
|
|
|
+ // msg := geterrmsg(err.Error())
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ // for _, item := range datalist {
|
|
|
+ // id = item["id"]
|
|
|
+ // }
|
|
|
+ // s_params = append(s_params, id)
|
|
|
+ // } else {
|
|
|
+ // s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ // }
|
|
|
+ s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _, err = tx.SQL(sql1, s_params...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("PostRJSBData1 err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ s_params = make([]interface{}, 0)
|
|
|
+
|
|
|
+ paramslist = strings.Split(p2, ",")
|
|
|
+ if len(paramslist) > 0 && p2 != "" {
|
|
|
+ for _, value := range paramslist {
|
|
|
+
|
|
|
+ if value == "ID" {
|
|
|
+ id := parammaps.Get("ID").ValueStr()
|
|
|
+ pastureid := parammaps.Get("pastureid").ValueStr()
|
|
|
+ datalist, err := tx.SQL(`select d2.id as id from downloadplandtl1 d1 join downloadplandtl1_exec d2 on d1.id = d2.id where d1.pid = (select pid from downloadplandtl1 where id = ? and pastureid = ? ) and
|
|
|
+ d1.sort = (select sort from downloadplandtl1 where id = ? and pastureid = ? )`, id, pastureid, id, pastureid).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("PostRJSBData err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, item := range datalist {
|
|
|
+ id = item["id"]
|
|
|
+ }
|
|
|
+ s_params = append(s_params, id)
|
|
|
+ } else {
|
|
|
+ s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.SQL(sql2, s_params...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("PostRJSBData2 err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ s_params = make([]interface{}, 0)
|
|
|
+
|
|
|
+ paramslist = strings.Split(p3, ",")
|
|
|
+ if len(paramslist) > 0 && p3 != "" {
|
|
|
+ for _, value := range paramslist {
|
|
|
+ s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _, err = tx.SQL(sql3, s_params...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("PostRJSBData3 err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func CheckFeedTrgaddress(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+ fclassid := fsion.Get("fclassid").ValueStr()
|
|
|
+ feedId := fsion.Get("feedId").ValueStr()
|
|
|
+ backup1 := fsion.Get("backup1").ValueStr()
|
|
|
+
|
|
|
+ backup1List := strings.Split(backup1, ",")
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ // if backup1 != "" {
|
|
|
+ feedList, _ := tx.SQL(` select id,fname,ifnull(backup1,'') backup1 from feed where fclassid = ? and (id != ? or ? = '' ) `, fclassid, feedId, feedId).QueryString()
|
|
|
+ for _, feed := range feedList {
|
|
|
+ if feed["backup1"] == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ feedbackupList := strings.Split(feed["backup1"], ",")
|
|
|
+ for _, feedbackup := range feedbackupList {
|
|
|
+
|
|
|
+ for _, backup := range backup1List {
|
|
|
+ if feedbackup == backup {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("数据:%s 在饲料:%s已被使用!", backup, feed["fname"]))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // }
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func ThiGetDataByName(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+ sqlnamestr := fsion.Get("name").ValueStr()
|
|
|
+ offset := fsion.Get("offset").ValueDefaultInt(0)
|
|
|
+ pagecount := fsion.Get("pagecount").ValueDefaultInt(0)
|
|
|
+ returntype := fsion.Get("returntype").ValueDefaultStr("map")
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ err := tx.Begin()
|
|
|
+ defer func() {
|
|
|
+ switch {
|
|
|
+ case err != nil:
|
|
|
+ logging.Error("tx.Begin 事务启动失败__error:", err)
|
|
|
+ if tx != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ if tx != nil {
|
|
|
+ err = tx.Commit()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if tx != nil {
|
|
|
+ tx.Close()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ sql, p := restful.GetSqlByNameDBT(sqlnamestr, tx)
|
|
|
+ if sql != "" {
|
|
|
+ s_params := make([]interface{}, 0)
|
|
|
+ if fsion.HasKey("parammaps") {
|
|
|
+ parammaps := fsion.Get("parammaps")
|
|
|
+ if sqlnamestr != "getNoMesList" && sqlnamestr != "getNoMesCount" {
|
|
|
+ logging.Info("GetDataByName", c.Keys, c.Request.RemoteAddr, sqlnamestr, parammaps.ValueStr())
|
|
|
+ }
|
|
|
+
|
|
|
+ paramslist := strings.Split(p, ",")
|
|
|
+ if len(paramslist) > 0 && p != "" {
|
|
|
+ for _, value := range paramslist {
|
|
|
+ if strings.ToLower(strings.Trim(value, " ")) == "jwt_username" {
|
|
|
+ if tempv, exists := c.Get("jwt_username"); exists {
|
|
|
+ s_params = append(s_params, tempv.(string))
|
|
|
+ } else {
|
|
|
+ s_params = append(s_params, "")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if fsion.HasKey("params") {
|
|
|
+ params := fsion.Get("params").Array()
|
|
|
+ logging.Info("GetDataByName", c.Keys, c.Request.RemoteAddr, sqlnamestr, params)
|
|
|
+ for _, v_params := range params {
|
|
|
+ s_params = append(s_params, v_params.ValueStr())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if returntype == "xlsx" {
|
|
|
+ var xlsxfile *xlsx.File
|
|
|
+ xlsxfile, _ = restful.QueryByXlsx(sql, s_params)
|
|
|
+ //c.File("c:/dd.xlsx")
|
|
|
+ c.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
+ c.Header("Content-Disposition", "attachment; filename="+"Workbook.xlsx")
|
|
|
+ c.Header("Content-Transfer-Encoding", "binary")
|
|
|
+ _ = xlsxfile.Write(c.Writer)
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if sqlnamestr == "getHomepageStr" {
|
|
|
+ parammaps := fsion.Get("parammaps")
|
|
|
+ pastureid := parammaps.Get("pastureid").ValueStr()
|
|
|
+ var montimeList []float64
|
|
|
+ var montime float64
|
|
|
+ var wg sync.WaitGroup
|
|
|
+
|
|
|
+ now := time.Now()
|
|
|
+ for i := 0; i < 30; i++ {
|
|
|
+ wg.Add(1)
|
|
|
+ nowstr := now.AddDate(0, 0, -i).Format("2006-01-02")
|
|
|
+ go func(nowstr string) {
|
|
|
+ defer wg.Done()
|
|
|
+ sqlstr := `select ifnull( getSLtimeDiffSINGEL ( ?, ? ), 0.0 ) as montime`
|
|
|
+ slTimeList, _ := restful.QueryByMap(sqlstr, 0, 0, []interface{}{pastureid, nowstr})
|
|
|
+ m, _ := strconv.ParseFloat(slTimeList.(map[string]interface{})["list"].([]map[string]interface{})[0]["montime"].(string), 64)
|
|
|
+ montimeList = append(montimeList, m)
|
|
|
+ }(nowstr)
|
|
|
+ }
|
|
|
+
|
|
|
+ queryData, err := getDataBySqlT(sql, offset, pagecount, returntype, s_params, tx)
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("GetDataByName err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ }
|
|
|
+
|
|
|
+ wg.Wait()
|
|
|
+ for _, m := range montimeList {
|
|
|
+ montime += m
|
|
|
+ }
|
|
|
+ queryData.(map[string]interface{})["list"].([]map[string]interface{})[0]["montime"] = Decimal(montime / 30)
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ queryData, err := getDataBySqlT(sql, offset, pagecount, returntype, s_params, tx)
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("GetDataByName err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ } else {
|
|
|
+ if sqlnamestr == "getFeedTrgaddressList" {
|
|
|
+ for _, item := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
|
|
|
+ trgaddressList1 := strings.Split(item["trgaddress"].(string), ",")
|
|
|
+ trgaddressList := []string{}
|
|
|
+ for _, str := range trgaddressList1 {
|
|
|
+ if str != "" {
|
|
|
+ trgaddressList = append(trgaddressList, str)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ item["trgaddressList"] = trgaddressList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, nil)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// func ToggleCcount(c *gin.Context) {
|
|
|
+// appG := app.Gin{C: c}
|
|
|
+// dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+// fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+// // 0 实际 1 软件
|
|
|
+// status := fsion.Get("status").ValueDefaultInt64(0)
|
|
|
+// pastureId := fsion.Get("pastureId").ValueStr()
|
|
|
+
|
|
|
+// tx := restful.Engine.NewSession()
|
|
|
+// err := tx.Begin()
|
|
|
+// defer func() {
|
|
|
+// switch {
|
|
|
+// case err != nil:
|
|
|
+// logging.Error("tx.Begin 事务启动失败__error:", err)
|
|
|
+// if tx != nil {
|
|
|
+// tx.Rollback()
|
|
|
+// }
|
|
|
+// default:
|
|
|
+// if tx != nil {
|
|
|
+// err = tx.Commit()
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if tx != nil {
|
|
|
+// tx.Close()
|
|
|
+// }
|
|
|
+// }()
|
|
|
+
|
|
|
+// barList, err := tx.SQL(`select * from bar where pastureId = ? `, pastureId).Query().List()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// for _, bar := range barList {
|
|
|
+// exist, err := tx.SQL(` select id from feedp where barname = ? and pastureid = ? `, bar["bname"], pastureId).Exist()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if !exist {
|
|
|
+// _, err := tx.SQL(` insert into feedp(pastureid,barid,barname,ccount)values(?,(select id from bar where bname = ? and pastureid = ? ),?,?) `,
|
|
|
+// pastureId, bar["bname"], pastureId, bar["bname"], 0).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// if status == 0 {
|
|
|
+// tx.Exec(`update feedp set ccount = actualcount `)
|
|
|
+// }else{
|
|
|
+// tx.Exec(`update feedp set ccount = softccount `)
|
|
|
+// }
|
|
|
+
|
|
|
+// feedpList, err := tx.SQL(`select * from feedp where pastureId = ? `, pastureId).Query().List()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// for _, feedpData :=range feedpList{
|
|
|
+// var feedpargs []interface{}
|
|
|
+// upFeedpSql := `update feedp set ccount = ? ,ratio = ? ,ccountratio = ?*(?*0.01) `
|
|
|
+// feedpargs = append(feedpargs, feedpData["ccount"], feedpData["ratio"], feedpData["ccount"], feedpData["ratio"])
|
|
|
+// if _, ok := feedpData["ftname"]; ok {
|
|
|
+// feedpargs = append(feedpargs, feedpData["ftname"], pastureid, feedpData["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, feedpData["ftname"], pastureid, feedpData["ccount"], feedpData["ratio"])
|
|
|
+// } else {
|
|
|
+// upFeedpSql += ` , ftid = -1,ftname = '' ,ftweight = 0 `
|
|
|
+// }
|
|
|
+
|
|
|
+// if _, ok := feedpData["ptsfname"]; ok {
|
|
|
+// feedpargs = append(feedpargs, feedpData["ptsfname"], pastureid, feedpData["ptsfname"])
|
|
|
+// upFeedpSql += ` , ptsfid = (select id from feedtemplet where tname = ? and pastureid = ? ),ptsfname = ? `
|
|
|
+
|
|
|
+// upFeedpSql += `,supplyweight = (select sum(fweight) fweight from ftdetail
|
|
|
+// where ftid = (select id from feedtemplet where tname = ? and pastureid = ? )) * (?*(?*0.01))`
|
|
|
+// feedpargs = append(feedpargs, feedpData["ptsfname"], pastureid, feedpData["ccount"], feedpData["ratio"])
|
|
|
+// } else {
|
|
|
+// upFeedpSql += ` , ptsfid = -1,ptsfname = '',supplyweight = 0 `
|
|
|
+// }
|
|
|
+// upFeedpSql += " where barname = ? and pastureid = ? "
|
|
|
+// feedpargs = append(feedpargs, feedpData["barname"], pastureid)
|
|
|
+// _, err = tx.SQL(upFeedpSql, feedpargs...).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// exist1, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 1 `, feedpData["barname"], pastureid).Exist()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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, feedpData["barname"], pastureid, feedpData["barname"]).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// exist2, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 2 `, feedpData["barname"], pastureid).Exist()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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, feedpData["barname"], pastureid, feedpData["barname"]).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// exist3, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times =3 `, feedpData["barname"], pastureid).Exist()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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, feedpData["barname"], pastureid, feedpData["barname"]).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// exist4, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 4 `, feedpData["barname"], pastureid).Exist()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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, feedpData["barname"], pastureid, feedpData["barname"]).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// exist5, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 5 `, feedpData["barname"], pastureid).Exist()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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, feedpData["barname"], pastureid, feedpData["barname"]).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// exist6, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 6 `, feedpData["barname"], pastureid).Exist()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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, feedpData["barname"], pastureid, feedpData["barname"]).Execute()
|
|
|
+// if err != nil {
|
|
|
+// logs.Error(err)
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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 {
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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 {
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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 {
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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 {
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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 {
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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 {
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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 {
|
|
|
+// appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+// 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, feedpData["barname"].(string), upFpdetailList)
|
|
|
+// }
|
|
|
+
|
|
|
+// appG.Response(http.StatusOK, e.SUCCESS, nil)
|
|
|
+// }
|
|
|
+
|
|
|
+func updateLpplandtlInfo(tx *xorm.Session, data map[string]interface{}) error {
|
|
|
+ feedpList, err := tx.SQL(`select id,concat(ftid)ftid ,pastureId,barid from feedp where id = ? `, data["id"]).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ for _, item := range feedpList {
|
|
|
+ // if item["ftid"].(string) != data["ftid"].(string) {
|
|
|
+ _, err = tx.SQL(` delete from lpplandtl1 where barid = ? and ? != ?`, item["barid"], item["ftid"], data["ftid"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
+ WHERE pastureid=? and find_in_set(barid,?) and ? != ? `, item["pastureId"], item["barid"], item["ftid"], data["ftid"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|