|
@@ -18,7 +18,6 @@ import (
|
|
|
"sync"
|
|
|
"time"
|
|
|
"tmr-watch/conf/setting"
|
|
|
- "tmr-watch/http/handle/gm"
|
|
|
"tmr-watch/http/handle/jpud"
|
|
|
"tmr-watch/http/handle/restful"
|
|
|
"tmr-watch/models"
|
|
@@ -1118,6 +1117,11 @@ func GetRJSBData(c *gin.Context) {
|
|
|
|
|
|
//STR :=Httppostdata("http://192.168.1.104:8081/authdata/GetDataBySqlIN","POST",string(dataByte),tx)
|
|
|
|
|
|
+ _, err = tx.SQL(`update tmr set xianfeng = (select id from downloadedplan where lpplantype = 5 and mydate = date_format(now() ,'%Y-%m-%d') and havebutton = 1 and iscompleted = 0 )
|
|
|
+ where id = (select tmrid from downloadedplan d where d.pid = (select pid from downloadedplan where lpplantype = 5 and mydate =
|
|
|
+ date_format(now() ,'%Y-%m-%d') and havebutton = 1 and iscompleted= 0 ) and mydate = date_format(now() ,'%Y-%m-%d')
|
|
|
+ and lpplantype in(0,1)) `).Execute()
|
|
|
+
|
|
|
sql, p := restful.GetSqlByNameDBT(sqlnamestr, tx)
|
|
|
sql1, p1 := restful.GetSqlByNameDBT(sqlnamestr1, tx)
|
|
|
if sql != "" {
|
|
@@ -1170,6 +1174,7 @@ func GetRJSBData(c *gin.Context) {
|
|
|
wg.Wait()
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
|
}
|
|
|
+ fmt.Println("先锋获取数据:", time.Now(), queryData)
|
|
|
} else {
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, nil)
|
|
|
}
|
|
@@ -1329,7 +1334,7 @@ func PostRJSBDatas(c *gin.Context) {
|
|
|
dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
fsions := gofasion.NewFasion(string(dataByte)).Array()
|
|
|
logging.Info("PostRJSBDatas err: ", string(dataByte))
|
|
|
- fmt.Println(string(dataByte))
|
|
|
+ fmt.Println("先锋回传数据:", time.Now(), string(dataByte))
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
err := tx.Begin()
|
|
@@ -1372,23 +1377,7 @@ func PostRJSBDatas(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // ALTER TABLE `tmr`
|
|
|
- // ADD COLUMN `concentrate` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0 未回传 1 已回传' AFTER `appoint`
|
|
|
- projuctid := parammaps.Get("projuctid").ValueStr()
|
|
|
- _, err = tx.SQL(`update tmr set concentrate = (select d.id from downloadedplan d
|
|
|
- where d.pid = (select pid from downloadedplan where id = ?) and mydate =(select mydate from downloadedplan where id = ?)
|
|
|
- and lpplantype in(0,1)) where id = (select tmrid from downloadedplan d
|
|
|
- where d.pid = (select pid from downloadedplan where id = ?) and mydate =(select mydate from downloadedplan where id = ?)
|
|
|
- and lpplantype in(0,1)) `, projuctid, projuctid, projuctid, projuctid).Execute()
|
|
|
- if err != nil {
|
|
|
- logging.Error("PostRJSBData-0 err: ", err)
|
|
|
- msg := geterrmsg(err.Error())
|
|
|
- // appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
- appG.Response(http.StatusOK, e.SUCCESS, msg)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- _, err = tx.SQL(sql, s_params...).Execute()
|
|
|
+ _, err := tx.SQL(sql, s_params...).Execute()
|
|
|
if err != nil {
|
|
|
logging.Error("PostRJSBData err: ", err)
|
|
|
msg := geterrmsg(err.Error())
|
|
@@ -1480,6 +1469,28 @@ func PostRJSBDatas(c *gin.Context) {
|
|
|
appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ // ALTER TABLE `tmr`
|
|
|
+ // ADD COLUMN `concentrate` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0 未回传 1 已回传' AFTER `appoint`
|
|
|
+ projuctid := parammaps.Get("projuctid").ValueStr()
|
|
|
+ _, err = tx.SQL(`update tmr set xianfeng = 0, concentrate = (select d.id from downloadedplan d
|
|
|
+ where d.pid = (select pid from downloadedplan where id = ?) and mydate =(select mydate from downloadedplan where id = ?)
|
|
|
+ and lpplantype in(0,1)) where id = (select tmrid from downloadedplan d
|
|
|
+ where d.pid = (select pid from downloadedplan where id = ?) and mydate =(select mydate from downloadedplan where id = ?)
|
|
|
+ and lpplantype in(0,1)) and ( select count(1) from downloadedplan where id = ? and iscompleted = 0 ) = 0 `,
|
|
|
+ projuctid, projuctid, projuctid, projuctid, projuctid).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("PostRJSBData-0 err: ", err)
|
|
|
+ msg := geterrmsg(err.Error())
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ count, _ := tx.SQL(`select count(1) from downloadedplan where id = ? and iscompleted = 0`, projuctid).Count()
|
|
|
+ if count == 0 {
|
|
|
+ fmt.Println(projuctid, "先锋回传计划已完成", count, err)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
@@ -3063,8 +3074,8 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
tempCommon := make(map[string]interface{})
|
|
|
tempval := make([]map[string]interface{}, 0)
|
|
|
fTChange := make(map[string]interface{}, 0)
|
|
|
- fpdOldDataList := make([]map[string]interface{}, 0)
|
|
|
- fpdDataList := make([]map[string]interface{}, 0)
|
|
|
+ // fpdOldDataList := make([]map[string]interface{}, 0)
|
|
|
+ // fpdDataList := make([]map[string]interface{}, 0)
|
|
|
|
|
|
fsion := gofasion.NewFasion(string(dataByte))
|
|
|
// parammaps := fsion.Get("parammaps")
|
|
@@ -3133,14 +3144,14 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
tempCommon = v
|
|
|
}
|
|
|
|
|
|
- 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 = ?)
|
|
|
- UNION
|
|
|
- SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,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,1 AS fttype,cowcount,ccountradio,0 isfill FROM fpdetail
|
|
|
- WHERE fpdetail.pastureid = ? and (ptid = ? or ptsid = ?)) t
|
|
|
- order by t.barname,t.times`, parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"], parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
+ // 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 = ?)
|
|
|
+ // UNION
|
|
|
+ // SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,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,1 AS fttype,cowcount,ccountradio,0 isfill FROM fpdetail
|
|
|
+ // WHERE fpdetail.pastureid = ? and (ptid = ? or ptsid = ?)) t
|
|
|
+ // order by t.barname,t.times`, parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"], parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
|
|
|
if err == nil {
|
|
|
if tempv, exists := c.Get("jwt_username"); exists {
|
|
@@ -3214,38 +3225,52 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
WHERE fp.pastureid = ? AND fp.ptsfid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
|
|
|
}
|
|
|
|
|
|
- fpdDataList, 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((select ftid from feedp where barid =fpdetail.barid)) 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 = ?)
|
|
|
- UNION
|
|
|
- SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,0) weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) 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 (ptid = ? or ptsid = ?)) t
|
|
|
- order by t.barname,t.times`, parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"], parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
-
|
|
|
- lpplanList := make([]*lpplanStruct, 0)
|
|
|
- err = tx.SQL(`select id,times,maxweight from lpplan where pastureid = ? and ftid = ? order by sort desc`, parammaps["pastureid"], parammaps["ftid"]).Find(&lpplanList)
|
|
|
- if err != nil {
|
|
|
- logs.Error(err, 1)
|
|
|
- return
|
|
|
- }
|
|
|
+ values1, _ := tx.SQL(`select b.bname barname, ifnull(ccount,0) ccount,ifnull(ratio,0) ratio,ftname,ptsfname,
|
|
|
+ ifnull((select tratio from fpdetail where barid = fp.barid and times = 1 ),0) as '1' ,
|
|
|
+ ifnull((select tratio from fpdetail where barid = fp.barid and times = 2
|
|
|
+ ),0) as '2' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 3
|
|
|
+ ),0) as '3' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 4
|
|
|
+ ),0) as '4' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 5
|
|
|
+ ),0) as '5' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 6
|
|
|
+ ),0) as '6' from feedp fp join bar b on b.id = fp.barid
|
|
|
+ join feedtemplet ft on ft.id = fp.ftid where ft.id = ?`, parammaps["ftid"]).QueryString()
|
|
|
+ // fmt.Println(ftId)
|
|
|
+ FpdBatchEditGrfd(fmt.Sprintf("%v", parammaps["pastureid"]), values1)
|
|
|
+
|
|
|
+ // fpdDataList, 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((select ftid from feedp where barid =fpdetail.barid)) 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 = ?)
|
|
|
+ // UNION
|
|
|
+ // SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,0) weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) 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 (ptid = ? or ptsid = ?)) t
|
|
|
+ // order by t.barname,t.times`, parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"], parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
+
|
|
|
+ // lpplanList := make([]*lpplanStruct, 0)
|
|
|
+ // err = tx.SQL(`select id,times,if((SELECT inforvalue FROM sysopt WHERE inforname = 'tmrOrVolume' AND pastureid =lpplan.pastureid ) = 0 ,
|
|
|
+ // ifnull((select maxstirfeed from tmr where pastureid =lpplan.pastureid and id = lpplan.tmrid ),100000),(select ifnull(volume,0) from tmr where id = lpplan.tmrid ) *
|
|
|
+ // (select ifnull(volume,0) from feedtemplet where id = lpplan.ftid) ) maxweight from lpplan where pastureid = ? and ftid = ? order by sort desc`, parammaps["pastureid"], parammaps["ftid"]).Find(&lpplanList)
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err, 1)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
|
|
|
- lppidlist := []string{}
|
|
|
- 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)
|
|
|
- if err != nil {
|
|
|
- // tx.Rollback()
|
|
|
- logs.Error(err, 2, parammaps["pastureid"])
|
|
|
- return
|
|
|
- }
|
|
|
+ // lppidlist := []string{}
|
|
|
+ // 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)
|
|
|
+ // if err != nil {
|
|
|
+ // // tx.Rollback()
|
|
|
+ // logs.Error(err, 2, parammaps["pastureid"])
|
|
|
+ // return
|
|
|
+ // }
|
|
|
|
|
|
// for _, lpp := range lpplandtl1AllList {
|
|
|
// _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? )
|
|
@@ -3263,143 +3288,143 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
// return
|
|
|
// }
|
|
|
// }
|
|
|
- var wg sync.WaitGroup
|
|
|
- for _, old := range fpdOldDataList {
|
|
|
- for _, fpd := range fpdDataList {
|
|
|
- wg.Add(1)
|
|
|
- go func(old, fpd map[string]interface{}) {
|
|
|
- updateLppandList := make([]*lpplandtl1, 0)
|
|
|
- defer wg.Done()
|
|
|
- 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) {
|
|
|
-
|
|
|
- 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 weight < oldweight {
|
|
|
- if weight >= 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- w = weight
|
|
|
- status = 0
|
|
|
- } else {
|
|
|
- if oldweight > 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- w = weight
|
|
|
- status = 1
|
|
|
- }
|
|
|
- // fweight = w
|
|
|
- for _, lpp := range lpplanList {
|
|
|
- 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 && lppland.Fpdid == fpdid {
|
|
|
- lpplandtl1List = append(lpplandtl1List, lppland)
|
|
|
- }
|
|
|
- }
|
|
|
- if len(lpplandtl1List) == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- for _, lppland := range lpplandtl1List {
|
|
|
- lweight += lppland.Lweight
|
|
|
- }
|
|
|
-
|
|
|
- if status == 0 {
|
|
|
- if lweight <= 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- } else {
|
|
|
- if lpp.Maxweight <= lweight {
|
|
|
- continue
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for _, lppland := range lpplandtl1List {
|
|
|
-
|
|
|
- if fpdid == lppland.Fpdid {
|
|
|
-
|
|
|
- if status == 1 {
|
|
|
- // if w <= lppland.Lweight {
|
|
|
- if lpp.Maxweight <= lweight {
|
|
|
- continue
|
|
|
- }
|
|
|
- if w+lweight <= lpp.Maxweight {
|
|
|
- lppland.Lweight += w
|
|
|
- lweight += w
|
|
|
- fweight += w
|
|
|
- w = 0
|
|
|
- } else {
|
|
|
- w = w - (lpp.Maxweight - lweight)
|
|
|
- n := (lpp.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
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- updateLppandList = append(updateLppandList, lppland)
|
|
|
- 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=?`, parammaps["type"], fweight, fweight, parammaps["type"], fweight, fweight, parammaps["pastureid"], fpd["id"]).Execute()
|
|
|
- if err != nil {
|
|
|
- // tx.Rollback()
|
|
|
- logs.Error(err, 4, parammaps["type"], fweight, fweight, parammaps["type"], fweight, fweight, parammaps["pastureid"], fpd["id"])
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- for _, lppland := range updateLppandList {
|
|
|
-
|
|
|
- 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
|
|
|
- }
|
|
|
- // defer wg.Done()
|
|
|
- }
|
|
|
- updateLppandList = []*lpplandtl1{}
|
|
|
- if w == 0 {
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }(old, fpd)
|
|
|
- }
|
|
|
+ // var wg sync.WaitGroup
|
|
|
+ // for _, old := range fpdOldDataList {
|
|
|
+ // for _, fpd := range fpdDataList {
|
|
|
+ // wg.Add(1)
|
|
|
+ // go func(old, fpd map[string]interface{}) {
|
|
|
+ // updateLppandList := make([]*lpplandtl1, 0)
|
|
|
+ // defer wg.Done()
|
|
|
+ // 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) {
|
|
|
+
|
|
|
+ // 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 weight < oldweight {
|
|
|
+ // if weight >= 0 {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // w = weight
|
|
|
+ // status = 0
|
|
|
+ // } else {
|
|
|
+ // if oldweight > 0 {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // w = weight
|
|
|
+ // status = 1
|
|
|
+ // }
|
|
|
+ // // fweight = w
|
|
|
+ // for _, lpp := range lpplanList {
|
|
|
+ // 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 && lppland.Fpdid == fpdid {
|
|
|
+ // lpplandtl1List = append(lpplandtl1List, lppland)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if len(lpplandtl1List) == 0 {
|
|
|
+ // continue
|
|
|
+ // }
|
|
|
+ // for _, lppland := range lpplandtl1List {
|
|
|
+ // lweight += lppland.Lweight
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if status == 0 {
|
|
|
+ // if lweight <= 0 {
|
|
|
+ // continue
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // if lpp.Maxweight <= lweight {
|
|
|
+ // continue
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // for _, lppland := range lpplandtl1List {
|
|
|
+
|
|
|
+ // if fpdid == lppland.Fpdid {
|
|
|
+
|
|
|
+ // if status == 1 {
|
|
|
+ // // if w <= lppland.Lweight {
|
|
|
+ // if lpp.Maxweight <= lweight {
|
|
|
+ // continue
|
|
|
+ // }
|
|
|
+ // if w+lweight <= lpp.Maxweight {
|
|
|
+ // lppland.Lweight += w
|
|
|
+ // lweight += w
|
|
|
+ // fweight += w
|
|
|
+ // w = 0
|
|
|
+ // } else {
|
|
|
+ // w = w - (lpp.Maxweight - lweight)
|
|
|
+ // n := (lpp.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
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+ // updateLppandList = append(updateLppandList, lppland)
|
|
|
+ // 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=?`, parammaps["type"], fweight, fweight, parammaps["type"], fweight, fweight, parammaps["pastureid"], fpd["id"]).Execute()
|
|
|
+ // if err != nil {
|
|
|
+ // // tx.Rollback()
|
|
|
+ // logs.Error(err, 4, parammaps["type"], fweight, fweight, parammaps["type"], fweight, fweight, parammaps["pastureid"], fpd["id"])
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ // for _, lppland := range updateLppandList {
|
|
|
+
|
|
|
+ // 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
|
|
|
+ // }
|
|
|
+ // // defer wg.Done()
|
|
|
+ // }
|
|
|
+ // updateLppandList = []*lpplandtl1{}
|
|
|
+ // if w == 0 {
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }(old, fpd)
|
|
|
+ // }
|
|
|
|
|
|
- }
|
|
|
- wg.Wait()
|
|
|
+ // }
|
|
|
+ // wg.Wait()
|
|
|
}
|
|
|
newFpdDataList, err := tx.SQL(` select * from fpdetail where ptid = ? or ptsid = ? `, parammaps["ftid"], parammaps["ftid"]).Query().List()
|
|
|
if err != nil {
|
|
@@ -3616,26 +3641,26 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
ftmap["ptsid"] = list.Get("ptsid").ValueStr()
|
|
|
// fmt.Println(ftmap)
|
|
|
|
|
|
- count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
- and find_in_set(barid,(select barid from feedp where id = ? )) and lweight > 0 `, pastureid, pastureid, ftmap["times"], id).Count()
|
|
|
- if count == 1 {
|
|
|
- _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
- and find_in_set(barid,(select barid from feedp where id = ? )) `, pastureid, pastureid, ftmap["times"], id).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 find_in_set(barid,(select barid from feedp where id = ? ) ) and times = ? `, pastureid, id, ftmap["times"]).Execute()
|
|
|
- if err != nil {
|
|
|
- tx.Rollback()
|
|
|
- logs.Error(err)
|
|
|
- appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ // count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
+ // and find_in_set(barid,(select barid from feedp where id = ? )) and lweight > 0 `, pastureid, pastureid, ftmap["times"], id).Count()
|
|
|
+ // if count == 1 {
|
|
|
+ // _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
+ // and find_in_set(barid,(select barid from feedp where id = ? )) `, pastureid, pastureid, ftmap["times"], id).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 find_in_set(barid,(select barid from feedp where id = ? ) ) and times = ? `, pastureid, id, ftmap["times"]).Execute()
|
|
|
+ // if err != nil {
|
|
|
+ // tx.Rollback()
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
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 ,
|
|
@@ -3657,7 +3682,9 @@ func UpdateFpdetailBar(c *gin.Context) {
|
|
|
var fweight float64
|
|
|
var lweight float64
|
|
|
lpplandtl1List := make([]*lpplandtlInfo, 0)
|
|
|
- err = tx.SQL(`select lppland.*,t.maxstirfeed maxweight from lpplan lpp
|
|
|
+ err = tx.SQL(`select lppland.*,if((SELECT inforvalue FROM sysopt WHERE inforname = 'tmrOrVolume' AND pastureid =lpp.pastureid ) = 0 ,
|
|
|
+ t.maxstirfeed,(select ifnull(volume,0) from tmr where id = lpp.tmrid ) *
|
|
|
+(select ifnull(volume,0) from feedtemplet where id = lpp.ftid) ) maxweight from lpplan lpp
|
|
|
join lpplandtl1 lppland on lpp.id = lppland.lppid
|
|
|
join tmr t on t.id = lpp.tmrid
|
|
|
where lppland.fpdid =?
|
|
@@ -4412,9 +4439,8 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ fmt.Println(outentry["栏舍名称"])
|
|
|
if !errExist {
|
|
|
-
|
|
|
dataexcel := make(map[string]interface{}, 0)
|
|
|
if _, ok := outentry["栏舍名称"]; ok {
|
|
|
dataexcel["barname"] = outentry["栏舍名称"]
|
|
@@ -4433,25 +4459,56 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
if _, ok := outentry["第一班比例(%)"]; ok {
|
|
|
dataexcel["1"] = outentry["第一班比例(%)"]
|
|
|
+ if fmt.Sprintf("%v", dataexcel["1"]) == "" {
|
|
|
+ dataexcel["1"] = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dataexcel["1"] = 0
|
|
|
}
|
|
|
+
|
|
|
if _, ok := outentry["第二班比例(%)"]; ok {
|
|
|
dataexcel["2"] = outentry["第二班比例(%)"]
|
|
|
+ if fmt.Sprintf("%v", dataexcel["2"]) == "" {
|
|
|
+ dataexcel["2"] = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dataexcel["2"] = 0
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第三班比例(%)"]; ok {
|
|
|
dataexcel["3"] = outentry["第三班比例(%)"]
|
|
|
+ if fmt.Sprintf("%v", dataexcel["3"]) == "" {
|
|
|
+ dataexcel["3"] = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dataexcel["3"] = 0
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第四班比例(%)"]; ok {
|
|
|
dataexcel["4"] = outentry["第四班比例(%)"]
|
|
|
+ if fmt.Sprintf("%v", dataexcel["4"]) == "" {
|
|
|
+ dataexcel["4"] = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dataexcel["4"] = 0
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第五班比例(%)"]; ok {
|
|
|
dataexcel["5"] = outentry["第五班比例(%)"]
|
|
|
+ if fmt.Sprintf("%v", dataexcel["5"]) == "" {
|
|
|
+ dataexcel["5"] = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dataexcel["5"] = 0
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第六班比例(%)"]; ok {
|
|
|
dataexcel["6"] = outentry["第六班比例(%)"]
|
|
|
+ if fmt.Sprintf("%v", dataexcel["6"]) == "" {
|
|
|
+ dataexcel["6"] = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dataexcel["6"] = 0
|
|
|
}
|
|
|
|
|
|
dataWeight := new(models.FpdetailEdit)
|
|
@@ -4459,7 +4516,6 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
if _, ok := outentry["第一班重量"]; ok {
|
|
|
// dataWeightMap["weight1"] = outentry["第一班重量"]
|
|
|
dataWeight.Weight1, _ = strconv.ParseFloat(fmt.Sprintf("%v", outentry["第一班重量"]), 64)
|
|
|
-
|
|
|
}
|
|
|
if _, ok := outentry["第二班重量"]; ok {
|
|
|
// dataWeightMap["weight2"] = outentry["第二班重量"]
|
|
@@ -4490,6 +4546,14 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
// dataWeightByte, _ := json.Marshal(dataWeightMap)
|
|
|
// err = json1.Unmarshal(dataWeightByte, &dataWeight)
|
|
|
// fmt.Println(err)
|
|
|
+ if fmt.Sprintf("%v", dataexcel["ccount"]) == "0" {
|
|
|
+ dataWeight.Weight1 = 0
|
|
|
+ dataWeight.Weight2 = 0
|
|
|
+ dataWeight.Weight3 = 0
|
|
|
+ dataWeight.Weight4 = 0
|
|
|
+ dataWeight.Weight5 = 0
|
|
|
+ dataWeight.Weight6 = 0
|
|
|
+ }
|
|
|
weight := dataWeight.Weight1 + dataWeight.Weight2 + dataWeight.Weight3 + dataWeight.Weight4 + dataWeight.Weight5 + dataWeight.Weight6
|
|
|
if weight > 0 {
|
|
|
existbar, err := tx.SQL(` select id from bar where bname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
@@ -5092,26 +5156,26 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
for barname, v := range dataList {
|
|
|
- for _, v1 := range v {
|
|
|
- count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
- and find_in_set(barid,(select barid from feedp where barname = ? )) and lweight > 0 `, pastureid, pastureid, v1.Times, barname).Count()
|
|
|
- if count == 1 {
|
|
|
- _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
- and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, v1.Times, barname).Execute()
|
|
|
- if err != nil {
|
|
|
- logs.Error(err)
|
|
|
- appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
- return
|
|
|
- }
|
|
|
- _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
- WHERE pastureid=? and find_in_set(barid,(select barid from feedp where barname = ? ) ) and times= ? `, pastureid, barname, v1.Times).Execute()
|
|
|
- if err != nil {
|
|
|
- logs.Error(err)
|
|
|
- appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // for _, v1 := range v {
|
|
|
+ // count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
+ // and find_in_set(barid,(select barid from feedp where barname = ? )) and lweight > 0 `, pastureid, pastureid, v1.Times, barname).Count()
|
|
|
+ // if count == 1 {
|
|
|
+ // _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? and times = ? )
|
|
|
+ // and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, v1.Times, barname).Execute()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
+ // WHERE pastureid=? and find_in_set(barid,(select barid from feedp where barname = ? ) ) and times= ? `, pastureid, barname, v1.Times).Execute()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
updateFpdetailByBar(pastureid, barname, v)
|
|
|
}
|
|
|
} else {
|
|
@@ -5319,8 +5383,8 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
dataexcel["4"] = outentry["Fourth Shift Ratio(%)"]
|
|
|
}
|
|
|
|
|
|
- if _, ok := outentry["Fifth shift Ratio(%)"]; ok {
|
|
|
- dataexcel["5"] = outentry["Fifth shift Ratio(%)"]
|
|
|
+ if _, ok := outentry["Fifth Shift Ratio(%)"]; ok {
|
|
|
+ dataexcel["5"] = outentry["Fifth Shift Ratio(%)"]
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["Sixth shift Ratio(%)"]; ok {
|
|
@@ -5771,7 +5835,8 @@ where lppland.pastureid = ? and lppland.fpdid = ? and lpp.times = ? order by l
|
|
|
var fweight float64
|
|
|
var lweight float64
|
|
|
lpplandtl1List := make([]*lpplandtlInfo, 0)
|
|
|
- err = tx.SQL(`select lppland.*,t.maxstirfeed maxweight from lpplan lpp
|
|
|
+ err = tx.SQL(`select lppland.*,if((SELECT inforvalue FROM sysopt WHERE inforname = 'tmrOrVolume' AND pastureid =lpp.pastureid ) = 0 ,
|
|
|
+ t.maxstirfeed,t.volume * (select ifnull(volume,0) from feedtemplet where id = lpp.ftid) ) maxweight from lpplan lpp
|
|
|
join lpplandtl1 lppland on lpp.id = lppland.lppid
|
|
|
join tmr t on t.id = lpp.tmrid
|
|
|
where lppland.fpdid =?
|
|
@@ -8925,20 +8990,20 @@ func FpdBatchEdit(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? )
|
|
|
- and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, dataexcel["barname"]).Execute()
|
|
|
- if err != nil {
|
|
|
- logs.Error(err)
|
|
|
- appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
- return
|
|
|
- }
|
|
|
- _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
- WHERE pastureid=? and find_in_set(barid,(select barid from feedp where barname = ? ) ) `, pastureid, dataexcel["barname"]).Execute()
|
|
|
- if err != nil {
|
|
|
- logs.Error(err)
|
|
|
- appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
- return
|
|
|
- }
|
|
|
+ // _, err = tx.SQL(` update lpplandtl1 set lweight = 0 where pastureid = ? and lppid in(select id from lpplan where pastureid = ? )
|
|
|
+ // and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, dataexcel["barname"]).Execute()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
|
|
|
+ // WHERE pastureid=? and find_in_set(barid,(select barid from feedp where barname = ? ) ) `, pastureid, dataexcel["barname"]).Execute()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusInternalServerError, e.ERROR, err)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
|
|
|
dataexcel["1"] = barFsions.Get("times1").ValueStr()
|
|
|
dataexcel["2"] = barFsions.Get("times2").ValueStr()
|
|
@@ -9249,7 +9314,7 @@ func UdFeedSync(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
// gm.UdFeedSync(pastureid, pastureinfo.Werks)
|
|
|
- // jpud.UdBarSync(pastureid, pastureinfo.Werks)
|
|
|
+ jpud.UdBarSync(pastureid, pastureinfo.Werks)
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
|
|
|
@@ -9270,8 +9335,8 @@ func UdFeedtempletPush(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- gm.UdFeedtempletPush(pastureid, pastureinfo.Werks, date)
|
|
|
-
|
|
|
+ // gm.UdFeedtempletPush(pastureid, pastureinfo.Werks, date)
|
|
|
+ jpud.UdFeedtempletPush(pastureid, pastureinfo.Werks, date)
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
|
|
|
@@ -9292,8 +9357,8 @@ func UdUtirPush(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- gm.UdUtirPush(pastureid, pastureinfo.Werks, date)
|
|
|
-
|
|
|
+ // gm.UdUtirPush(pastureid, pastureinfo.Werks, date)
|
|
|
+ jpud.UdUtirPush(pastureid, pastureinfo.Werks, date)
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
|
|
|
@@ -9314,8 +9379,8 @@ func UdBarFeedRemainPush(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- gm.UdBarFeedRemainPush(pastureid, pastureinfo.Werks, date)
|
|
|
-
|
|
|
+ // gm.UdBarFeedRemainPush(pastureid, pastureinfo.Werks, date)
|
|
|
+ jpud.UdBarFeedRemainPush(pastureid, pastureinfo.Werks, date)
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
|
|
|
@@ -9335,8 +9400,8 @@ func UdMaterialIssuePush(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- gm.UdMaterialIssuePush(pastureid, pastureinfo.Werks, date)
|
|
|
-
|
|
|
+ // gm.UdMaterialIssuePush(pastureid, pastureinfo.Werks, date)
|
|
|
+ jpud.UdMaterialIssuePush(pastureid, pastureinfo.Werks, date)
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
|
|
|
@@ -11360,6 +11425,8 @@ func FtImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
tx := restful.Engine.NewSession()
|
|
|
ftNameList := make(map[string]interface{})
|
|
|
+
|
|
|
+ var ftNames []interface{}
|
|
|
for i, row := range rows {
|
|
|
if i > 0 {
|
|
|
|
|
@@ -11483,7 +11550,6 @@ func FtImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
outentry["input"] = inputdata
|
|
|
- fmt.Println(sql, s_params)
|
|
|
returnmsgmap1, err := tx.SQL(sql, s_params...).Query().List()
|
|
|
|
|
|
if err != nil {
|
|
@@ -11521,18 +11587,7 @@ func FtImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- values1, _ := tx.SQL(`select b.bname barname, ifnull(ccount,0) ccount,ifnull(ratio,0) ratio,ftname,ptsfname,
|
|
|
- ifnull((select tratio from fpdetail where barid = fp.barid and times = 1 ),0) as '1' ,
|
|
|
- ifnull((select tratio from fpdetail where barid = fp.barid and times = 2
|
|
|
- ),0) as '2' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 3
|
|
|
- ),0) as '3' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 4
|
|
|
- ),0) as '4' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 5
|
|
|
- ),0) as '5' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 6
|
|
|
- ),0) as '6' from feedp fp join bar b on b.id = fp.barid
|
|
|
- join feedtemplet ft on ft.id = fp.ftid where ft.tname = ?`, outentry["配方名称"]).QueryString()
|
|
|
- FpdBatchEditGrfd(pastureid, values1)
|
|
|
-
|
|
|
+ ftNames = append(ftNames, outentry["配方名称"])
|
|
|
switch {
|
|
|
case err != nil:
|
|
|
if tx != nil {
|
|
@@ -11552,9 +11607,89 @@ func FtImportExcel(c *gin.Context) {
|
|
|
isdone = true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ go ftSync(ftNames, pastureid)
|
|
|
+
|
|
|
data := make(map[string]interface{})
|
|
|
data["result"] = queryData
|
|
|
data["success"] = ok
|
|
|
data["err_count"] = error
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, data)
|
|
|
}
|
|
|
+
|
|
|
+func ftSync(ftNameList []interface{}, pastureId string) {
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+ for _, ftName := range ftNameList {
|
|
|
+ values1, _ := tx.SQL(`select b.bname barname, ifnull(ccount,0) ccount,ifnull(ratio,0) ratio,ftname,ptsfname,
|
|
|
+ ifnull((select tratio from fpdetail where barid = fp.barid and times = 1 ),0) as '1' ,
|
|
|
+ ifnull((select tratio from fpdetail where barid = fp.barid and times = 2
|
|
|
+ ),0) as '2' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 3
|
|
|
+ ),0) as '3' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 4
|
|
|
+ ),0) as '4' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 5
|
|
|
+ ),0) as '5' ,ifnull((select tratio from fpdetail where barid = fp.barid and times = 6
|
|
|
+ ),0) as '6' from feedp fp join bar b on b.id = fp.barid
|
|
|
+ join feedtemplet ft on ft.id = fp.ftid where ft.tname = ?`, ftName).QueryString()
|
|
|
+ FpdBatchEditGrfd(pastureId, values1)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func CopyFeedtemplet(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsion := gofasion.NewFasion(string(dataByte))
|
|
|
+ pastureid := fsion.Get("pastureid").ValueStr()
|
|
|
+ newName := fsion.Get("newName").ValueStr()
|
|
|
+ id := fsion.Get("id").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ count, err := tx.SQL(` select count(1) from feedtemplet where tname = ? `, newName).Count()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if count > 0 {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "配方名称重复!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ type ftCode struct {
|
|
|
+ Tcode string `xorm:"tcode"`
|
|
|
+ }
|
|
|
+ code := new(ftCode)
|
|
|
+ err = tx.SQL(`select if(left((select max(tcode) from feedtemplet where pastureid = ?),8) =
|
|
|
+ (select DATE_FORMAT(now(),"%Y%m%d")),(select max(tcode)+1 from feedtemplet where pastureid = ?),
|
|
|
+ (select concat(DATE_FORMAT(now(),"%Y%m%d"),"001"))) tcode`, pastureid, pastureid).GetFirst(code).Error
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if code.Tcode == "" {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "配方编码生产失败!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.Exec(`INSERT INTO feedtemplet(pastureid,tname,tcode,tcolor,ccid,ccname,fttype,fttypeid,source,
|
|
|
+ remark,enable,sort,volume,autozone)
|
|
|
+ select pastureid,?,?,tcolor,ccid,ccname,fttype,fttypeid,source,
|
|
|
+ remark,enable,sort,volume,autozone from feedtemplet where id = ? `, newName, code.Tcode, id)
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("配方生成失败 %v", err))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.Exec(`insert into ftdetail(pastureid,ftid,fid,fname,lweight,fweight, islockcount,isfg, sort,feedgroup,preftid, autosecond,
|
|
|
+ autosecondname,splitftpreid, deviation, is_modify, is_show, shutdown,is_surplus, dry)
|
|
|
+select pastureid,(select id from feedtemplet where tcode = ? ),fid,fname,lweight,fweight, islockcount,isfg, sort,feedgroup,preftid, autosecond,
|
|
|
+ autosecondname,splitftpreid, deviation, is_modify, is_show, shutdown,is_surplus, dry
|
|
|
+ from ftdetail where ftid = ? `, code.Tcode, id)
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("配方生成失败 %v", err))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
|
+}
|