|
@@ -1512,6 +1512,9 @@ func ExecDataByConfig(c *gin.Context) {
|
|
|
logging.Error("ExecDataParam error:", err)
|
|
|
break
|
|
|
}
|
|
|
+ if paramvalue["name"].(string) == "createdownloadedplan" {
|
|
|
+ checkPlan(tx, paramvalue, tempCommon, tempval, 0)
|
|
|
+ }
|
|
|
}
|
|
|
if err == nil {
|
|
|
if tempCommon["returnmap"] != nil && tempCommon["returnmap"] != "" {
|
|
@@ -3409,9 +3412,6 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
return
|
|
|
}
|
|
|
- // }()
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
@@ -3525,14 +3525,10 @@ 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((select ftid from feedp where barid =fpdetail.barid)) 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 =(select barid from feedp where id = ? ) and times = ?
|
|
|
- UNION
|
|
|
+ fpdDataList, err := tx.SQL(`
|
|
|
SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ifnull(ptsid,-1) ) ptsid ,
|
|
|
- (select 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 = (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()
|
|
|
+ (select bname from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,concat(1) AS fttype,cowcount,ccountradio,0 isfill FROM fpdetail
|
|
|
+ WHERE fpdetail.pastureid = ? and barid = (select barid from feedp where id = ? ) and times = ? `, pastureid, id, ftmap["times"]).Query().List()
|
|
|
// fmt.Println(pastureid, id, ftmap["times"], pastureid, id, ftmap["times"])
|
|
|
if err != nil {
|
|
|
tx.Rollback()
|
|
@@ -3542,7 +3538,7 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
for _, fpd := range fpdDataList {
|
|
|
if fpd["times"].(int64) == ftmap["times"].(int64) && (fpd["ptid"].(string) == ftmap["ptid"].(string)) {
|
|
|
fttype := -1
|
|
|
- if ftmap["ptid"].(string) != "-1" {
|
|
|
+ if fpd["fttype"].(string) == "1" {
|
|
|
fttype = 1
|
|
|
}
|
|
|
|
|
@@ -3565,7 +3561,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 ftmap["new"].(float64) < ftmap["old"].(float64) && weight <= 0 {
|
|
|
if weight >= 0 {
|
|
|
continue
|
|
|
}
|
|
@@ -3580,11 +3576,14 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
status = 1
|
|
|
}
|
|
|
|
|
|
- for _, lppland := range lpplandtl1List {
|
|
|
- lweight += lppland.Lweight
|
|
|
- }
|
|
|
+ // for _, lppland := range lpplandtl1List {
|
|
|
+ // lweight += lppland.Lweight
|
|
|
+ // }
|
|
|
|
|
|
for _, lppland := range lpplandtl1List {
|
|
|
+ lpplandInfo := new(lpplandtlInfo)
|
|
|
+ err := tx.SQL(` select ifnull(sum(lweight),0) lweight from lpplandtl1 where lppid = ? `, lppland.Lppid).GetFirst(lpplandInfo).Error
|
|
|
+ lweight = lpplandInfo.Lweight
|
|
|
|
|
|
if status == 1 {
|
|
|
// if w <= lppland.Lweight {
|
|
@@ -3623,13 +3622,26 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- _, 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
|
|
|
+ if 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
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _, err = tx.SQL(`delete from lpplandtl1 where id = ? and pastureid = ?`, lppland.Id, pastureid).Execute()
|
|
|
+ if err != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
- break
|
|
|
+ if w == 0 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ // 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)
|
|
@@ -4125,6 +4137,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
rows = rows[:10000]
|
|
|
}
|
|
|
|
|
|
+ dataList := make(map[string][]*upFpdetail, 0)
|
|
|
for i, row := range rows {
|
|
|
if i > 0 {
|
|
|
|
|
@@ -4282,6 +4295,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if !errExist {
|
|
|
|
|
|
dataexcel := make(map[string]interface{}, 0)
|
|
@@ -4316,7 +4330,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第五班比例(%)"]; ok {
|
|
|
- dataexcel["5"] = outentry["第四班比例(%)"]
|
|
|
+ dataexcel["5"] = outentry["第五班比例(%)"]
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第六班比例(%)"]; ok {
|
|
@@ -4333,6 +4347,28 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ _, err = tx.SQL(` update feedp fp set barname = (select bname from bar where bname = ? and pastureid = ? ) where barid = (select id from bar where bname = ? and pastureid = ? )`, dataexcel["barname"], pastureid, dataexcel["barname"], pastureid).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.SQL(` update fpdetail fp set barname = (select bname from bar where bname = ? and pastureid = ? ) where barid = (select id from bar where bname = ? and pastureid = ? )`, dataexcel["barname"], pastureid, dataexcel["barname"], pastureid).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ existft, err := tx.SQL(` select id from feedtemplet where tname = ? and pastureid = ? `, dataexcel["ftname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, "配方不存在!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !existft {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
ftexist, err := tx.SQL(` select id from feedp where barname = ? and pastureid = ? and ftname = ? `, dataexcel["barname"], pastureid, dataexcel["ftname"]).Exist()
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
@@ -4507,7 +4543,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 1)
|
|
|
_, err = tx.SQL(upFpdSql, fpdargs1...).Execute()
|
|
|
if err != nil {
|
|
|
- appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -4591,17 +4627,20 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- updateFpdetailByBar(pastureid, dataexcel["barname"].(string), upFpdetailList)
|
|
|
-
|
|
|
+ // fmt.Println(dataexcel["barname"])
|
|
|
+ dataList[dataexcel["barname"].(string)] = upFpdetailList
|
|
|
+ // updateFpdetailByBar(pastureid, dataexcel["barname"].(string), upFpdetailList)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
if !isdone {
|
|
|
ok++
|
|
|
isdone = true
|
|
|
}
|
|
|
}
|
|
|
+ for barname, v := range dataList {
|
|
|
+ updateFpdetailByBar(pastureid, barname, v)
|
|
|
+ }
|
|
|
+
|
|
|
data := make(map[string]interface{})
|
|
|
data["result"] = queryData
|
|
|
data["success"] = ok
|
|
@@ -4703,27 +4742,25 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
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 * 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,concat(0) AS fttype,cowcount,ccountradio,1 isfill FROM fpdetail
|
|
|
+ // WHERE fpdetail.pastureid = ? and barname = ? and times = ?
|
|
|
+ // UNION
|
|
|
+ fpdDataList, err := tx.SQL(`
|
|
|
SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM(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()
|
|
|
+ (select bname from bar where pastureid =fpdetail.pastureid and id = fpdetail.barid ) barname,concat(1) AS fttype,cowcount,ccountradio,0 isfill FROM fpdetail
|
|
|
+ WHERE fpdetail.pastureid = ? and barname = ? and times = ? `, pastureid, barname, ftmap["times"]).Query().List()
|
|
|
// fmt.Println(pastureid, id, ftmap["times"], pastureid, id, ftmap["times"])
|
|
|
if err != nil {
|
|
|
tx.Rollback()
|
|
|
logs.Error(err)
|
|
|
}
|
|
|
-
|
|
|
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
|
|
|
- }
|
|
|
+ // fttype := -1
|
|
|
+ // if fpd["fttype"].(string) == "1" {
|
|
|
+ fttype := 1
|
|
|
+ // }
|
|
|
|
|
|
var fweight float64
|
|
|
var lweight float64
|
|
@@ -4738,32 +4775,36 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
tx.Rollback()
|
|
|
logs.Error(err)
|
|
|
}
|
|
|
-
|
|
|
+ // [map[barid:4719430583171155825 barname:泌乳1-5西 ccountradio:131 cowcount:30 fttype:0 id:4828050527277810688 isfill:1 pastureid:1705635208 ptid:83
|
|
|
+ // ptsid:-1 times:1 tratio:48.000 weight:0.00] map[barid:4719430583171155825
|
|
|
+ // barname:泌乳1-5西 ccountradio:131 cowcount:30 fttype:1 id:4828050527277810688 isfill:0 pastureid:1705635208 ptid:83 ptsid:-1 times:1 tratio:48.000 weight:32.0
|
|
|
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 ftmap["new"].(float64) < ftmap["old"].(float64) && weight <= 0 {
|
|
|
if weight >= 0 {
|
|
|
continue
|
|
|
}
|
|
|
w = weight
|
|
|
status = 0
|
|
|
} else {
|
|
|
- if weight-(ftmap["new"].(float64)-ftmap["old"].(float64)) > 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
+ // 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 {
|
|
|
+ // lweight += lppland.Lweight
|
|
|
+ // }
|
|
|
|
|
|
for _, lppland := range lpplandtl1List {
|
|
|
+ lpplandInfo := new(lpplandtlInfo)
|
|
|
+ err := tx.SQL(` select ifnull(sum(lweight),0) lweight from lpplandtl1 where lppid = ? `, lppland.Lppid).GetFirst(lpplandInfo).Error
|
|
|
+ lweight = lpplandInfo.Lweight
|
|
|
|
|
|
if status == 1 {
|
|
|
// if w <= lppland.Lweight {
|
|
@@ -4776,7 +4817,6 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
fweight += w
|
|
|
w = 0
|
|
|
} else {
|
|
|
-
|
|
|
w = w - (lppland.Maxweight - lweight)
|
|
|
n := (lppland.Maxweight - lweight)
|
|
|
lppland.Lweight = lppland.Lweight + n
|
|
@@ -4802,13 +4842,25 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
|
|
|
}
|
|
|
|
|
|
- _, 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
|
|
|
+ if 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
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _, err = tx.SQL(`delete from lpplandtl1 where id = ? and pastureid = ?`, lppland.Id, pastureid).Execute()
|
|
|
+ if err != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if w == 0 {
|
|
|
+ break
|
|
|
}
|
|
|
- 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)
|
|
@@ -4968,7 +5020,7 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
// appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
- return nil
|
|
|
+ return err
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4980,7 +5032,7 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
// appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
- return nil
|
|
|
+ return err
|
|
|
}
|
|
|
}
|
|
|
for _, newFeedp := range newFeedpList {
|
|
@@ -4995,7 +5047,7 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
|
// appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
- return nil
|
|
|
+ return err
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -7008,7 +7060,7 @@ func GetFormulaStatistics(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
downloadedplanList, err := tx.SQL(`select count(1) total,ft.tname,date_format(d.mydate ,'%Y-%m-%d') mydate from downloadedplan d
|
|
|
- join feedtemplet ft on ft.id = d.tempid where d.mydate between ? and ? and d.lpplantype in(0,1) and d.iscompleted = 1 and d.pastureId= ?
|
|
|
+ join feedtempletdate ft on ft.id = d.tempid and ft.date = d.mydate where d.mydate between ? and ? and d.lpplantype in(0,1) and d.iscompleted = 1 and d.pastureId= ?
|
|
|
group by d.tempid,d.mydate `, startTime, endTime, pastureId).Query().List()
|
|
|
if err != nil {
|
|
|
logs.Error("GetFormulaStatistics-error-2:", err)
|
|
@@ -7177,32 +7229,32 @@ func PostPlanData(c *gin.Context) {
|
|
|
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)
|
|
|
+ // sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
|
|
|
+ sql1, p1 := restful.GetSqlByNameDBT("updated1YJXY", tx)
|
|
|
+ sql2, p2 := restful.GetSqlByNameDBT("updated1execYJXY", tx)
|
|
|
+ sql3, p3 := restful.GetSqlByNameDBT("updated2YJXY", 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
|
|
|
- }
|
|
|
+ // 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, ",")
|
|
|
+ paramslist := strings.Split(p1, ",")
|
|
|
if len(paramslist) > 0 && p1 != "" {
|
|
|
for _, value := range paramslist {
|
|
|
// if value == "ID" {
|
|
@@ -7796,39 +7848,44 @@ func PostPlanDatas(c *gin.Context) {
|
|
|
// sql2, p2 := restful.GetSqlByNameDBT("updated1execYJ", tx)
|
|
|
// sql3, p3 := restful.GetSqlByNameDBT("updated2YJ", tx)
|
|
|
|
|
|
- sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
|
|
|
- sql1, p1 := restful.GetSqlByNameDBT("updated1YJ", tx)
|
|
|
- sql2, p2 := restful.GetSqlByNameDBT("updated1execYJ", tx)
|
|
|
- sql3, p3 := restful.GetSqlByNameDBT("updated2YJ", tx)
|
|
|
+ // sql, p := restful.GetSqlByNameDBT("updatedownloadedplanYJ", tx)
|
|
|
+ sql1, p1 := restful.GetSqlByNameDBT("updated1YJXY", tx)
|
|
|
+ sql2, p2 := restful.GetSqlByNameDBT("updated1execYJXY", tx)
|
|
|
+ sql3, p3 := restful.GetSqlByNameDBT("updated2YJXY", tx)
|
|
|
|
|
|
for _, parammaps := range fsions.Get("arrList").Array() {
|
|
|
+ fmt.Println(parammaps.Json())
|
|
|
+ if parammaps.Json() == "null" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
// if !fsion.HasKey("arrList") {
|
|
|
- // appG.Response(http.StatusOK, e.ERROR, "参数解析失败")
|
|
|
- // return
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, "参数解析失败")
|
|
|
+ // return
|
|
|
+ // continue
|
|
|
// }
|
|
|
// parammaps := fsion.Get("arrList")
|
|
|
s_params := make([]interface{}, 0)
|
|
|
- paramslist := strings.Split(p, ",")
|
|
|
- if len(paramslist) > 0 && p != "" {
|
|
|
- for _, value := range paramslist {
|
|
|
- if value == "pastureid" {
|
|
|
- s_params = append(s_params, pastureId)
|
|
|
- } else {
|
|
|
- s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- _, err = tx.SQL(sql, s_params...).Execute()
|
|
|
+ // paramslist := strings.Split(p, ",")
|
|
|
+ // if len(paramslist) > 0 && p != "" {
|
|
|
+ // for _, value := range paramslist {
|
|
|
+ // if value == "pastureid" {
|
|
|
+ // s_params = append(s_params, pastureId)
|
|
|
+ // } else {
|
|
|
+ // 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
|
|
|
- }
|
|
|
+ // 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, ",")
|
|
|
+ paramslist := strings.Split(p1, ",")
|
|
|
if len(paramslist) > 0 && p1 != "" {
|
|
|
for _, value := range paramslist {
|
|
|
// if value == "ID" {
|
|
@@ -8272,6 +8329,7 @@ func UdFeedtempletPush(c *gin.Context) {
|
|
|
dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
fsions := gofasion.NewFasion(string(dataByte))
|
|
|
pastureid := fsions.Get("pastureId").ValueStr()
|
|
|
+ date := fsions.Get("date").ValueStr()
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
@@ -8283,7 +8341,7 @@ func UdFeedtempletPush(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- gm.UdFeedtempletPush(pastureid, pastureinfo.Werks)
|
|
|
+ gm.UdFeedtempletPush(pastureid, pastureinfo.Werks, date)
|
|
|
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
@@ -8352,3 +8410,124 @@ func UdMaterialIssuePush(c *gin.Context) {
|
|
|
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
|
+
|
|
|
+func DelFeedTemplet(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ ftId := fsions.Get("ftId").ValueStr()
|
|
|
+ userId := fsions.Get("userId").ValueStr()
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ _, err := tx.Exec(` update feedtemplet set enable = 1 and isdelete = 1 where id = ? `, ftId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ barIdList, err := tx.SQL(`select barid from feedp where ftid = ? `, ftId).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.Exec(` update feedp set ftid = 0 and ftname = '',feedweight = 0,ftweight = 0, where ftid = ? `, ftId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除栏舍配方失败"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.Exec(` update fpdetail set weight = ? ,ptid = 0,ptuse= 0 where ftid = ? `, ftId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除栏舍配方失败"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ count, _ := tx.SQL(`select count(1) from lpplan where ftid = ? `, ftId).Count()
|
|
|
+ if count > 0 {
|
|
|
+ _, err = tx.Exec(` delete from lpplandtl1 where lppid in(select id from lpplan where ftid = ? ) `, ftId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除子计划失败"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _, err = tx.Exec(` delete from lpplan where ftid = ? `, ftId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除计划失败"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var barIdStr []string
|
|
|
+ for _, bar := range barIdList {
|
|
|
+ barIdStr = append(barIdStr, bar["barid"])
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(barIdStr) > 0 {
|
|
|
+
|
|
|
+ newFpdDataList, err := tx.Table("fpdetail").In(`barid`, barIdStr).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ newFeedpList, err := tx.Table("feedp").In(`barid`, barIdStr).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ now := time.Now()
|
|
|
+ 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,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, userId).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,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, userId).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func checkPlan(tx *xorm.Session, fasion map[string]interface{}, CommonParamMap map[string]interface{}, ParamMap []map[string]interface{}, number int) {
|
|
|
+ data := fasion["parammaps"].(map[string]interface{})
|
|
|
+ plancount, err := tx.Table("downloadedplan").Where(" mydate = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype in(0,1,2) ").Count()
|
|
|
+ fmt.Println(err)
|
|
|
+ plancount1, err := tx.SQL(`select count(1) from (select d.id from downloadedplan d join downloadplandtl1 d1 on d1.pid = d.id
|
|
|
+ join downloadplandtl1_exec d1e on d1e.pid = d.id join downloadplandtl2 d2 on d2.pid = d.id where d.mydate = ? and d.havebutton = 0 and lpplantype in(0,1,2) group by d.id )d `,
|
|
|
+ data["startTime"]).Count()
|
|
|
+ fmt.Println(err)
|
|
|
+ if plancount != plancount1 && number < 10 {
|
|
|
+ number++
|
|
|
+ ExecDataParam(fasion, CommonParamMap, ParamMap, nil, nil, tx)
|
|
|
+ checkPlan(tx, fasion, CommonParamMap, ParamMap, number)
|
|
|
+ }
|
|
|
+}
|