|
@@ -222,13 +222,49 @@ func GetDataByName(c *gin.Context) {
|
|
_ = xlsxfile.Write(c.Writer)
|
|
_ = xlsxfile.Write(c.Writer)
|
|
|
|
|
|
} else {
|
|
} 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)
|
|
queryData, err := getDataBySqlT(sql, offset, pagecount, returntype, s_params, tx)
|
|
if err != nil {
|
|
if err != nil {
|
|
logging.Error("GetDataByName err: ", err)
|
|
logging.Error("GetDataByName err: ", err)
|
|
msg := geterrmsg(err.Error())
|
|
msg := geterrmsg(err.Error())
|
|
appG.Response(http.StatusOK, e.ERROR, msg)
|
|
appG.Response(http.StatusOK, e.ERROR, msg)
|
|
} else {
|
|
} else {
|
|
|
|
+
|
|
appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2906,6 +2942,8 @@ func GetSummary(c *gin.Context) {
|
|
sqlnamestr = "getAccuracyMC"
|
|
sqlnamestr = "getAccuracyMC"
|
|
} else if status == "6" {
|
|
} else if status == "6" {
|
|
sqlnamestr = "getAccuracyFeedHL"
|
|
sqlnamestr = "getAccuracyFeedHL"
|
|
|
|
+ } else if status == "7" {
|
|
|
|
+ sqlnamestr = "getAccuracyRT"
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if status == "0" {
|
|
if status == "0" {
|
|
@@ -2920,6 +2958,8 @@ func GetSummary(c *gin.Context) {
|
|
sqlnamestr = "getAccuracySCC"
|
|
sqlnamestr = "getAccuracySCC"
|
|
} else if status == "5" {
|
|
} else if status == "5" {
|
|
sqlnamestr = "getAccuracySLCL"
|
|
sqlnamestr = "getAccuracySLCL"
|
|
|
|
+ } else if status == "7" {
|
|
|
|
+ sqlnamestr = "getAccuracySCCRT"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if isDate == "1" {
|
|
if isDate == "1" {
|
|
@@ -3485,7 +3525,7 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
lpplandlweight, _ := strconv.ParseFloat(lppland["lweight"].(string), 64)
|
|
lpplandlweight, _ := strconv.ParseFloat(lppland["lweight"].(string), 64)
|
|
if weight >= lpplandlweight {
|
|
if weight >= lpplandlweight {
|
|
weight = weight - lpplandlweight
|
|
weight = weight - lpplandlweight
|
|
- _, err := tx.SQL(` delete from lppland where id = ? `, lppland["id"]).Execute()
|
|
|
|
|
|
+ _, err := tx.SQL(` delete from lpplandtl1 where id = ? `, lppland["id"]).Execute()
|
|
if err != nil {
|
|
if err != nil {
|
|
tx.Rollback()
|
|
tx.Rollback()
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
@@ -3493,7 +3533,7 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- _, err := tx.SQL(` update lppland set lweight = ? where id = ? `, lppland["lweight"].(float64)-weight, lppland["id"]).Execute()
|
|
|
|
|
|
+ _, err := tx.SQL(` update lpplandtl1 set lweight = ? where id = ? `, lppland["lweight"].(float64)-weight, lppland["id"]).Execute()
|
|
if err != nil {
|
|
if err != nil {
|
|
tx.Rollback()
|
|
tx.Rollback()
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
@@ -4151,9 +4191,6 @@ func FpdImportExcel(c *gin.Context) {
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- for _, item := range oldFpdList {
|
|
|
|
- fmt.Println(item)
|
|
|
|
- }
|
|
|
|
rows, _ := xlsx1.GetRows(sheetname)
|
|
rows, _ := xlsx1.GetRows(sheetname)
|
|
// 限制10000条,多余的截取掉
|
|
// 限制10000条,多余的截取掉
|
|
if len(rows) > 10000 {
|
|
if len(rows) > 10000 {
|
|
@@ -4578,113 +4615,312 @@ func updateFpdetailByBar(pastureid, barname string, dataList []*upFpdetail) erro
|
|
tx := restful.Engine.NewSession()
|
|
tx := restful.Engine.NewSession()
|
|
defer tx.Close()
|
|
defer tx.Close()
|
|
tx.Begin()
|
|
tx.Begin()
|
|
- 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)
|
|
|
|
|
|
+ fpdList, err := tx.SQL(` select id,ifnull(ROUND((1-ptsrate)*weight,2),"") weight,ptuse,times from fpdetail where pastureid = ? and barname = ? order by times `,
|
|
|
|
+ pastureid, barname).Query().List()
|
|
|
|
+ if err != nil {
|
|
|
|
+ logs.Error(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, fpd := range fpdList {
|
|
|
|
+
|
|
|
|
+ lpplandList, err := tx.SQL(` select lppland.id,lppland.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 {
|
|
if err != nil {
|
|
tx.Rollback()
|
|
tx.Rollback()
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
return 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
|
|
|
|
|
|
+ var lweight float64
|
|
|
|
+ for _, lppland := range lpplandList {
|
|
|
|
+ lweight1, _ := strconv.ParseFloat(lppland["lweight"].(string), 64)
|
|
|
|
+ lweight += lweight1
|
|
}
|
|
}
|
|
- 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
|
|
|
|
|
|
+ fpdweight, _ := strconv.ParseFloat(fpd["weight"].(string), 64)
|
|
|
|
+ ptuse, _ := strconv.ParseFloat(fpd["ptuse"].(string), 64)
|
|
|
|
|
|
|
|
+ if fpdweight >= ptuse && lweight == ptuse {
|
|
|
|
+ continue
|
|
|
|
+ } else {
|
|
|
|
+ if lweight <= fpdweight {
|
|
|
|
+ _, err := tx.SQL(` update fpdetail set ptuse = ? where id = ? `, lweight, fpd["id"]).Execute()
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ logs.Error(err)
|
|
|
|
+ return err
|
|
}
|
|
}
|
|
} else {
|
|
} 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
|
|
|
|
|
|
+ weight := lweight - fpdweight
|
|
|
|
+ _, err = tx.SQL(`UPDATE fpdetail SET ptuse=?
|
|
|
|
+ WHERE pastureid=? AND id=?`, fpdweight, pastureid, fpd["id"]).Execute()
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ logs.Error(err)
|
|
|
|
+ return err
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ for _, lppland := range lpplandList {
|
|
|
|
+ lpplandlweight, _ := strconv.ParseFloat(lppland["lweight"].(string), 64)
|
|
|
|
+ if weight >= lpplandlweight {
|
|
|
|
+ weight = weight - lpplandlweight
|
|
|
|
+ _, err := tx.SQL(` delete from lpplandtl1 where id = ? `, lppland["id"]).Execute()
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ logs.Error(err)
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ lpplandlweight, _ := strconv.ParseFloat(lppland["lweight"].(string), 64)
|
|
|
|
+ _, err := tx.SQL(` update lpplandtl1 set lweight = ? where id = ? `, lpplandlweight-weight, lppland["id"]).Execute()
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ logs.Error(err)
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ weight = 0
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- _, 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()
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, list := range dataList {
|
|
|
|
+ ftmap := make(map[string]interface{})
|
|
|
|
+ ftmap["old"] = list.Old
|
|
|
|
+ ftmap["new"] = list.New
|
|
|
|
+ ftmap["times"] = list.Times
|
|
|
|
+ ftmap["ptid"] = strconv.FormatInt(list.Ptid, 10)
|
|
|
|
+ ftmap["ptsid"] = ""
|
|
|
|
+ // 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 ,
|
|
|
|
+ (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 barname = ? 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 barname = ? and times = ? ) t
|
|
|
|
+ order by t.barname,t.times`, pastureid, barname, ftmap["times"], pastureid, barname, ftmap["times"]).Query().List()
|
|
|
|
+ // fmt.Println(pastureid, id, ftmap["times"], pastureid, id, ftmap["times"])
|
|
if err != nil {
|
|
if err != nil {
|
|
tx.Rollback()
|
|
tx.Rollback()
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
- return err
|
|
|
|
}
|
|
}
|
|
- // if w == 0 {
|
|
|
|
- // break
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
|
|
|
|
|
|
+ for _, fpd := range fpdDataList {
|
|
|
|
+ if fpd["times"].(int64) == ftmap["times"].(int64) && (fpd["ptid"].(string) == ftmap["ptid"].(string) || fpd["ptsid"].(string) == ftmap["ptsid"].(string)) {
|
|
|
|
+ fttype := -1
|
|
|
|
+ if ftmap["ptid"].(string) != "-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 `,
|
|
|
|
+ fpd["id"], fttype, pastureid, ftmap["times"]).Find(&lpplandtl1List)
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ logs.Error(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ weight, _ := strconv.ParseFloat(fpd["weight"].(string), 64)
|
|
|
|
+ // ptuse, _ := strconv.ParseFloat(fpd["ptuse"].(string), 64)
|
|
|
|
+
|
|
|
|
+ var w float64
|
|
|
|
+ var status int
|
|
|
|
+
|
|
|
|
+ if ftmap["new"].(float64) < ftmap["old"].(float64) {
|
|
|
|
+ if weight >= 0 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ w = weight
|
|
|
|
+ status = 0
|
|
|
|
+ } else {
|
|
|
|
+ if weight-(ftmap["new"].(float64)-ftmap["old"].(float64)) > 0 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ w = weight
|
|
|
|
+ status = 1
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, lppland := range lpplandtl1List {
|
|
|
|
+ lweight += lppland.Lweight
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, lppland := range lpplandtl1List {
|
|
|
|
+
|
|
|
|
+ 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, fpd["id"]).Execute()
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ logs.Error(err)
|
|
|
|
+ }
|
|
|
|
+ if w == 0 {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- err := tx.Commit()
|
|
|
|
|
|
+ // 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 {
|
|
if err != nil {
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
tx.Rollback()
|
|
tx.Rollback()
|
|
@@ -6297,3 +6533,9 @@ func UpdateMaterialTMRDate(c *gin.Context) {
|
|
|
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func Decimal(value float64) float64 {
|
|
|
|
+ value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
|
|
|
|
+ return value
|
|
|
|
+}
|
|
|
|
+
|