|
@@ -2943,7 +2943,7 @@ func GetSummary(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- fmt.Println(s_params, "111")
|
|
|
+
|
|
|
if returntype == "xlsx" {
|
|
|
var xlsxfile *xlsx.File
|
|
|
xlsxfile, _ = restful.QueryByXlsx(sql, s_params)
|
|
@@ -3007,6 +3007,39 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
logging.Info("ExecDataByConfig ", c.Keys, c.Request.RemoteAddr, tempval_["common"], tempval_["data"])
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
+ if v, ok := tempval_["data"].([]interface{}); ok {
|
|
|
+ for _, Tvalue := range v {
|
|
|
+ if v1, ok := Tvalue.(map[string]interface{}); ok {
|
|
|
+ if v1["name"] == "updateFPbyFTChange" {
|
|
|
+ fTChange = v1
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tempval = append(tempval, v1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ parammaps := fTChange["parammaps"].(map[string]interface{})
|
|
|
+
|
|
|
+ // oldFpdDataList, err := tx.SQL(` select * from fpdetail where ptid = ? or ptsid = ? `, parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ // oldLpplandtl1List, err := tx.SQL(` select lppland.* from lpplan lpp join lpplandtl1 lppland on lppland.lppid = lpp.id where lpp.ftid = ? `, parammaps["ftid"]).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ // oldFeedpList, err := tx.SQL(` select * from feedp where ftid = ? or ptsfid = ? `, parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
err = tx.Begin()
|
|
|
if err != nil {
|
|
|
logging.Error("tx.Begin 事务启动失败__error:", err)
|
|
@@ -3021,24 +3054,13 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
tx.Close()
|
|
|
}
|
|
|
}()
|
|
|
+
|
|
|
if err != nil {
|
|
|
} else {
|
|
|
if v, ok := tempval_["common"].(map[string]interface{}); ok {
|
|
|
tempCommon = v
|
|
|
}
|
|
|
|
|
|
- if v, ok := tempval_["data"].([]interface{}); ok {
|
|
|
- for _, Tvalue := range v {
|
|
|
- if v1, ok := Tvalue.(map[string]interface{}); ok {
|
|
|
- if v1["name"] == "updateFPbyFTChange" {
|
|
|
- fTChange = v1
|
|
|
- continue
|
|
|
- }
|
|
|
- tempval = append(tempval, v1)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- parammaps := fTChange["parammaps"].(map[string]interface{})
|
|
|
fpdOldDataList, err = tx.SQL(`select * from (SELECT TRIM(id) id,times,tratio,ifnull(ROUND(ptsrate*weight,2)-ptsuse,0) 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,0 AS fttype,cowcount,ccountradio,1 isfill FROM fpdetail
|
|
|
WHERE fpdetail.pastureid = ? and (ptid = ? or ptsid = ?)
|
|
@@ -3139,6 +3161,10 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
for _, lpp := range lpplanList {
|
|
|
lppidlist = append(lppidlist, strconv.FormatInt(lpp.Id, 10))
|
|
|
}
|
|
|
+ if len(lppidlist) <= 0 {
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
|
+ return
|
|
|
+ }
|
|
|
lpplandtl1AllList := make([]*lpplandtl1, 0)
|
|
|
err = tx.SQL(fmt.Sprintf(`select id,lppid,barid,fpdid,lweight from lpplandtl1 where pastureid = ? and lppid in (%s)
|
|
|
order by sort desc`, strings.Join(lppidlist, ",")), parammaps["pastureid"]).Find(&lpplandtl1AllList)
|
|
@@ -3155,8 +3181,6 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
go func(old, fpd map[string]interface{}) {
|
|
|
updateLppandList := make([]*lpplandtl1, 0)
|
|
|
defer wg.Done()
|
|
|
- // fmt.Println(old, i)
|
|
|
- // fmt.Println(fpd, i)
|
|
|
if fpd["id"].(string) == old["id"].(string) && fpd["fttype"].(int64) == old["fttype"].(int64) &&
|
|
|
fpd["weight"].(string) != old["weight"].(string) && fpd["times"].(int64) == old["times"].(int64) {
|
|
|
|
|
@@ -3166,6 +3190,9 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
var w float64
|
|
|
var status int
|
|
|
|
|
|
+ if fpd["barname"].(string) == "D1" {
|
|
|
+ fmt.Println("1")
|
|
|
+ }
|
|
|
if weight < oldweight {
|
|
|
if weight >= 0 {
|
|
|
return
|
|
@@ -3184,19 +3211,15 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
var fweight float64
|
|
|
var lweight float64
|
|
|
lpplandtl1List := make([]*lpplandtl1, 0)
|
|
|
-
|
|
|
+ fpdid, _ := strconv.ParseInt(fpd["id"].(string), 10, 64)
|
|
|
for _, lppland := range lpplandtl1AllList {
|
|
|
- if lppland.Lppid == lpp.Id {
|
|
|
+ if lppland.Lppid == lpp.Id && lppland.Fpdid == fpdid {
|
|
|
lpplandtl1List = append(lpplandtl1List, lppland)
|
|
|
}
|
|
|
}
|
|
|
- // err = tx.SQL(`select id,lppid,barid,fpdid,lweight from lpplandtl1 where pastureid = ? and lppid = ?
|
|
|
- // order by sort desc`, parammaps["pastureid"], lpp.Id).Find(&lpplandtl1List)
|
|
|
- // if err != nil {
|
|
|
- // tx.Rollback()
|
|
|
- // logs.Error(err, 2, parammaps["pastureid"], lpp.Id)
|
|
|
- // return
|
|
|
- // }
|
|
|
+ if len(lpplandtl1List) == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
for _, lppland := range lpplandtl1List {
|
|
|
lweight += lppland.Lweight
|
|
|
}
|
|
@@ -3213,7 +3236,6 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
|
|
|
for _, lppland := range lpplandtl1List {
|
|
|
|
|
|
- fpdid, _ := strconv.ParseInt(fpd["id"].(string), 10, 64)
|
|
|
if fpdid == lppland.Fpdid {
|
|
|
|
|
|
if status == 1 {
|
|
@@ -3227,11 +3249,6 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
fweight += w
|
|
|
w = 0
|
|
|
} else {
|
|
|
- // if w < lpp.Maxweight-lppland.Lweight {
|
|
|
- // // w = w - (lpp.Maxweight - lweight)
|
|
|
- // lppland.Lweight = lppland.Lweight + w
|
|
|
- // // lweight += (lpp.Maxweight - lweight)
|
|
|
- // }
|
|
|
w = w - (lpp.Maxweight - lweight)
|
|
|
n := (lpp.Maxweight - lweight)
|
|
|
lppland.Lweight = lppland.Lweight + n
|
|
@@ -3256,25 +3273,11 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- // go func(parammaps map[string]interface{}, lppland *lpplandtl1, status int) {
|
|
|
updateLppandList = append(updateLppandList, lppland)
|
|
|
- // tx.Begin()
|
|
|
- // fmt.Println(lppland.Lweight, lppland.Id, parammaps["pastureid"], status)
|
|
|
- // _, err = tx.SQL(`update lpplandtl1 set Lweight = ? where id = ? and pastureid = ?`, lppland.Lweight, lppland.Id, parammaps["pastureid"]).Execute()
|
|
|
- // if err != nil {
|
|
|
- // fmt.Println(lppland.Lweight, lppland.Id, parammaps["pastureid"], status)
|
|
|
- // // tx.Rollback()
|
|
|
- // logs.Error(err, 3)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // // tx.Commit()
|
|
|
- // }(parammaps, lppland, status)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // go func(parammaps map[string]interface{}, fweight float64, status int) {
|
|
|
- // tx.Begin()
|
|
|
_, 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=?`, parammaps["type"], fweight, fweight, parammaps["type"], fweight, fweight, parammaps["pastureid"], fpd["id"]).Execute()
|
|
@@ -3284,9 +3287,6 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // var wg sync.WaitGroup
|
|
|
- // wg.Add(len(updateLppandList))
|
|
|
- // go func(parammaps map[string]interface{}, updateLppandList []*lpplandtl1, status int) {
|
|
|
for _, lppland := range updateLppandList {
|
|
|
|
|
|
fmt.Println(lppland.Lweight, lppland.Id, parammaps["pastureid"], status)
|
|
@@ -3300,22 +3300,11 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
// defer wg.Done()
|
|
|
}
|
|
|
updateLppandList = []*lpplandtl1{}
|
|
|
- // }(parammaps, updateLppandList, status)
|
|
|
- // wg.Wait()
|
|
|
- // tx.Commit()
|
|
|
- // }(parammaps, fweight, status)
|
|
|
-
|
|
|
if w == 0 {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // if weight < oldweight {
|
|
|
- // fmt.Println("下调")
|
|
|
- // } else {
|
|
|
- // fmt.Println("上调")
|
|
|
- // }
|
|
|
- // break
|
|
|
}
|
|
|
}(old, fpd)
|
|
|
}
|
|
@@ -3323,8 +3312,96 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
}
|
|
|
wg.Wait()
|
|
|
}
|
|
|
- // }()
|
|
|
- fmt.Println(time.Now())
|
|
|
+ // newFpdDataList, err := tx.SQL(` select * from fpdetail where ptid = ? or ptsid = ? `, parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // newLpplandtl1List, err := tx.SQL(` select lppland.* from lpplan lpp join lpplandtl1 lppland on lppland.lppid = lpp.id where lpp.ftid = ? `, parammaps["ftid"]).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ // newFeedpList, err := tx.SQL(` select * from feedp where ftid = ? or ptsfid = ? `, parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ // now := time.Now()
|
|
|
+ // for _, oldFpd := range oldFpdDataList {
|
|
|
+ // for _, newFpd := range newFpdDataList {
|
|
|
+ // 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"],
|
|
|
+ // 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
|
|
|
+ // }
|
|
|
+ // // }()
|
|
|
+ // }
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // for _, oldLpplandtl1 := range oldLpplandtl1List {
|
|
|
+ // for _, newLpplandtl1 := range newLpplandtl1List {
|
|
|
+ // if oldLpplandtl1["id"].(int64) == newLpplandtl1["id"].(int64) {
|
|
|
+ // 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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
+ // 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()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // // }()
|
|
|
+ // }
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // for _, oldFeedp := range oldFeedpList {
|
|
|
+ // for _, newFeedp := range newFeedpList {
|
|
|
+ // if oldFeedp["id"].(int64) == newFeedp["id"].(int64) && oldFeedp["feedweight"].(string) != newFeedp["feedweight"].(string) &&
|
|
|
+ // 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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
+ // 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)
|
|
|
}
|
|
|
|
|
@@ -3356,6 +3433,14 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
id := fsion.Get("id").ValueStr()
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
+
|
|
|
+ // oldLpplandtl1List, err := tx.SQL(` select lppland.* from lpplandtl1 lppland where lppland.barid = ? `, id).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
tx.Begin()
|
|
|
|
|
|
for _, list := range fsion.Get("data").Array() {
|
|
@@ -3486,6 +3571,39 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
tx.Commit()
|
|
|
+
|
|
|
+ // now := time.Now()
|
|
|
+ // newLpplandtl1List, err := tx.SQL(` select lppland.* from lpplandtl1 lppland where lppland.barid = ? `, id).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // for _, oldLpplandtl1 := range oldLpplandtl1List {
|
|
|
+ // for _, newLpplandtl1 := range newLpplandtl1List {
|
|
|
+ // if oldLpplandtl1["id"].(int64) == newLpplandtl1["id"].(int64) {
|
|
|
+ // 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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
+ // 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()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // }()
|
|
|
+ // }
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
|
}
|
|
|
|
|
@@ -4592,3 +4710,167 @@ func DeleteFTdetail(c *gin.Context) {
|
|
|
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
|
}
|
|
|
+
|
|
|
+func DeleteSpillageAll(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+ parammaps := fsion.Get("parammaps")
|
|
|
+ pastureid := parammaps.Get("pastureid").ValueStr()
|
|
|
+ times := parammaps.Get("times").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ lpplandtl1List, err := tx.SQL(` select lppland.* from lpplan lpp join lpplandtl1 lppland on lppland.lppid = lpp.id where lpp.times = ? `, times).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ now := time.Now()
|
|
|
+ for _, item := range lpplandtl1List {
|
|
|
+ go func(item map[string]interface{}) {
|
|
|
+ _, err := tx.SQL(` insert into lpplandtl1history(pastureid,lppid,barid,barname,fpdid,fttype,lweight,sort,tmrid,tmrname,
|
|
|
+ background,cowcount,ccountradio,lweighthis,createdate)
|
|
|
+ values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
|
+ item["pastureid"], item["lppid"], item["barid"],
|
|
|
+ item["barname"], item["fpdid"], item["fttype"],
|
|
|
+ item["lweight"], item["sort"], item["tmrid"],
|
|
|
+ item["tmrname"], item["background"], item["cowcount"],
|
|
|
+ item["ccountradio"], item["lweighthis"], now).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(item)
|
|
|
+ }
|
|
|
+
|
|
|
+ tx.Begin()
|
|
|
+ _, err = tx.SQL(` delete from lpplandtl1 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ?) `, pastureid, pastureid, times).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 times = ? `, pastureid, times).Execute()
|
|
|
+ if err != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = tx.Commit()
|
|
|
+ if err != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
|
+}
|
|
|
+
|
|
|
+func GetFeedpHistory(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+ // parammaps := fsion.Get("parammaps")
|
|
|
+ barid := fsion.Get("barid").ValueStr()
|
|
|
+ startDate := fsion.Get("startDate").ValueStr()
|
|
|
+ endDate := fsion.Get("endDate").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ 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 barid = ?
|
|
|
+ and createdate between ? and ? order by createdate desc `, barid, startDate, endDate).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fpdList, err := tx.SQL(` select times,tratio,weight, DATE_FORMAT(createdate,'%Y-%m-%d %H:%i:%s') as createdate from fpdetailhistory where barid = ?
|
|
|
+ and createdate between ? and ? order by createdate desc, times asc`, barid, startDate, endDate).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, feedp := range feedpList {
|
|
|
+ fmt.Println(feedp)
|
|
|
+ for i, fpd := range fpdList {
|
|
|
+ if feedp["createdate"].(string) == fpd["createdate"].(string) {
|
|
|
+ for k, fpd2 := range fpdList {
|
|
|
+ if k > i && fpd["times"].(int64) == fpd2["times"].(int64) {
|
|
|
+ if fpd["weight"].(string) != fpd2["weight"].(string) {
|
|
|
+ fpd["weight"] = fmt.Sprintf("%v/%v", fpd2["weight"], fpd["weight"])
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fpd["barid"] = feedp["barid"]
|
|
|
+ fpd["barname"] = feedp["barname"]
|
|
|
+ fpd["ccount"] = feedp["ccount"]
|
|
|
+ fpd["ratio"] = feedp["ratio"]
|
|
|
+ fpd["ccountratio"] = feedp["ccountratio"]
|
|
|
+ fpd["ftid"] = feedp["ftid"]
|
|
|
+ fpd["ftname"] = feedp["ftname"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, fpdList)
|
|
|
+}
|
|
|
+
|
|
|
+// func GetLpplandtl1History(c *gin.Context) {
|
|
|
+// appG := app.Gin{C: c}
|
|
|
+// dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+// fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+// // parammaps := fsion.Get("parammaps")
|
|
|
+// barid := fsion.Get("barid").ValueStr()
|
|
|
+// startDate := fsion.Get("startDate").ValueStr()
|
|
|
+// endDate := fsion.Get("endDate").ValueStr()
|
|
|
+
|
|
|
+// tx := restful.Engine.NewSession()
|
|
|
+// defer tx.Close()
|
|
|
+
|
|
|
+// // feedpList, err := tx.SQL(` select lpp.times, DATE_FORMAT(lh.createdate,'%Y-%m-%d %H:%i:%s') as createdate
|
|
|
+// // from lpplandtl1history lh join lpplan lpp on lpp.id = lh.lppid where lh.barid = ?
|
|
|
+// // and lh.createdate between ? and ? order by lh.createdate desc lpp.times `, barid, startDate, endDate).Query().List()
|
|
|
+// // if err != nil {
|
|
|
+// // logs.Error(err)
|
|
|
+// // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+// // return
|
|
|
+// // }
|
|
|
+
|
|
|
+// // for _, feedp := range feedpList {
|
|
|
+// // fmt.Println(feedp)
|
|
|
+// // for i, fpd := range fpdList {
|
|
|
+// // if feedp["createdate"].(string) == fpd["createdate"].(string) {
|
|
|
+// // for k, fpd2 := range fpdList {
|
|
|
+// // if k > i && fpd["times"].(int64) == fpd2["times"].(int64) {
|
|
|
+// // if fpd["weight"].(string) != fpd2["weight"].(string) {
|
|
|
+// // fpd["weight"] = fmt.Sprintf("%v/%v", fpd2["weight"], fpd["weight"])
|
|
|
+// // }
|
|
|
+// // break
|
|
|
+// // }
|
|
|
+// // }
|
|
|
+// // fpd["barid"] = feedp["barid"]
|
|
|
+// // fpd["barname"] = feedp["barname"]
|
|
|
+// // fpd["ccount"] = feedp["ccount"]
|
|
|
+// // fpd["ratio"] = feedp["ratio"]
|
|
|
+// // fpd["ccountratio"] = feedp["ccountratio"]
|
|
|
+// // fpd["ftid"] = feedp["ftid"]
|
|
|
+// // fpd["ftname"] = feedp["ftname"]
|
|
|
+// // }
|
|
|
+// // }
|
|
|
+// // }
|
|
|
+
|
|
|
+// appG.Response(http.StatusOK, e.SUCCESS, nil)
|
|
|
+// }
|