|
@@ -17,6 +17,7 @@ import (
|
|
|
"sync"
|
|
|
"time"
|
|
|
"tmr-watch/conf/setting"
|
|
|
+ "tmr-watch/http/handle/gm"
|
|
|
"tmr-watch/http/handle/restful"
|
|
|
"tmr-watch/module"
|
|
|
"tmr-watch/pkg/app"
|
|
@@ -27,6 +28,7 @@ import (
|
|
|
"github.com/Anderson-Lu/gofasion/gofasion"
|
|
|
"github.com/astaxie/beego/logs"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
+ "github.com/qichengzx/coordtransform"
|
|
|
"github.com/tealeg/xlsx"
|
|
|
"github.com/xormplus/xorm"
|
|
|
)
|
|
@@ -704,6 +706,7 @@ func GetReportform(c *gin.Context) {
|
|
|
pagecount := fsion.Get("pagecount").ValueDefaultInt(0)
|
|
|
parammaps := fsion.Get("parammaps")
|
|
|
typea := parammaps.Get("typea").ValueDefaultInt(0) //0 全部 1 理论, 2实际
|
|
|
+ mode := parammaps.Get("mode").ValueDefaultInt(0)
|
|
|
logging.Info("GetReportform ", c.Keys, sqlnamestr, parammaps)
|
|
|
tx := restful.Engine.NewSession()
|
|
|
err := tx.Begin()
|
|
@@ -723,7 +726,7 @@ func GetReportform(c *gin.Context) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- queryData, err := praseReportform(sqlnamestr, parammaps, tx, checked, offset, pagecount, typea)
|
|
|
+ queryData, err := praseReportform(sqlnamestr, parammaps, tx, checked, offset, pagecount, typea, mode)
|
|
|
if err != nil {
|
|
|
appG.Response(http.StatusOK, e.ERROR, err.Error())
|
|
|
} else {
|
|
@@ -1143,15 +1146,15 @@ func GetRJSBData(c *gin.Context) {
|
|
|
arr, _ := tx.SQL(sql1, s_params1...).QueryString() //获取
|
|
|
queryData.(map[string]interface{})["list"].([]map[string]interface{})[index]["arrList"] = arr
|
|
|
}
|
|
|
- // var wg sync.WaitGroup
|
|
|
- // for _, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
|
|
|
- // wg.Add(1)
|
|
|
- // go func(value map[string]interface{}) {
|
|
|
- // defer wg.Done()
|
|
|
- // _, err = tx.SQL(`update downloadedplan set havebutton = 1 where id = ? and pastureid = ? `, value["projuctid"], value["pastureid"]).Execute()
|
|
|
- // }(value)
|
|
|
- // }
|
|
|
- // wg.Wait()
|
|
|
+ var wg sync.WaitGroup
|
|
|
+ for _, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
|
|
|
+ wg.Add(1)
|
|
|
+ go func(value map[string]interface{}) {
|
|
|
+ defer wg.Done()
|
|
|
+ _, err = tx.SQL(`update downloadedplan set artificial = 2 where id = ? and pastureid = ? `, value["projuctid"], value["pastureid"]).Execute()
|
|
|
+ }(value)
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, queryData)
|
|
|
}
|
|
|
} else {
|
|
@@ -1202,7 +1205,8 @@ func PostRJSBData(c *gin.Context) {
|
|
|
if err != nil {
|
|
|
logging.Error("PostRJSBData err: ", err)
|
|
|
msg := geterrmsg(err.Error())
|
|
|
- appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, msg)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1326,6 +1330,11 @@ func PostRJSBDatas(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
parammaps := fsion.Get("parammaps")
|
|
|
+ ID := parammaps.Get("ID").ValueStr()
|
|
|
+ if ID == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
s_params := make([]interface{}, 0)
|
|
|
paramslist := strings.Split(p, ",")
|
|
|
if len(paramslist) > 0 && p != "" {
|
|
@@ -1338,7 +1347,8 @@ func PostRJSBDatas(c *gin.Context) {
|
|
|
if err != nil {
|
|
|
logging.Error("PostRJSBData err: ", err)
|
|
|
msg := geterrmsg(err.Error())
|
|
|
- appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, msg)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, msg)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1511,6 +1521,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"] != "" {
|
|
@@ -3108,19 +3121,20 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
parammaps := fTChange["parammaps"].(map[string]interface{})
|
|
|
if parammaps["type"].(float64) == 1 {
|
|
|
_, err = tx.SQL(`UPDATE feedp fp
|
|
|
- set
|
|
|
- fp.ftweight= IFNULL(IF(
|
|
|
- (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
|
|
|
- ),0),fp.feedweight = IFNULL(IF(
|
|
|
- (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
|
|
|
- ),0) +ifnull(fp.supplyweight,0)
|
|
|
- WHERE fp.pastureid = ? AND fp.ftid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
|
|
|
+ set
|
|
|
+ ccountratio = ccount *(ratio /100 ),
|
|
|
+ fp.ftweight= IFNULL(IF(
|
|
|
+ (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
|
|
|
+ ),0),fp.feedweight = IFNULL(IF(
|
|
|
+ (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*(ccount *(ratio /100 )) +
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ftid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
|
|
|
+ ),0) +ifnull(fp.supplyweight,0)
|
|
|
+ WHERE fp.pastureid = ? AND fp.ftid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
|
|
|
|
|
|
_, err = tx.SQL(`UPDATE fpdetail fpd
|
|
|
INNER JOIN feedp fp
|
|
@@ -3130,19 +3144,19 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
|
|
|
} else {
|
|
|
_, err = tx.SQL(`UPDATE feedp fp
|
|
|
- SET
|
|
|
- fp.supplyweight= IFNULL(IF(
|
|
|
- (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
|
|
|
- ),0),fp.feedweight = IFNULL(IF(
|
|
|
- (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*ccountratio,
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*ccountratio +
|
|
|
- IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*ccount
|
|
|
- ),0) +ifnull(fp.supplyweight,0)
|
|
|
- WHERE fp.pastureid = ? AND fp.ptsfid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
|
|
|
+ SET ccountratio = ccount *(ratio /100 ),
|
|
|
+ fp.supplyweight= IFNULL(IF(
|
|
|
+ (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*(ccount *(ratio /100 )) +
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
|
|
|
+ ),0),fp.feedweight = IFNULL(IF(
|
|
|
+ (SELECT sysopt.inforvalue FROM sysopt WHERE sysopt.pastureid= fp.pastureid AND sysopt.inforname='isLockCount')=0,
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid ),0)*(ccount *(ratio /100 )),
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=0),0)*(ccount *(ratio /100 )) +
|
|
|
+ IFNULL((SELECT SUM(fweight) FROM ftdetail WHERE ftdetail.ftid =fp.ptsfid AND ftdetail.pastureid=fp.pastureid AND ftdetail.islockcount=1),0)*(ccount *(ratio /100 ))
|
|
|
+ ),0) +ifnull(fp.supplyweight,0)
|
|
|
+ WHERE fp.pastureid = ? AND fp.ptsfid =?`, parammaps["pastureid"], parammaps["ftid"]).Execute()
|
|
|
|
|
|
_, err = tx.SQL(`UPDATE fpdetail fpd
|
|
|
INNER JOIN feedp fp
|
|
@@ -3407,9 +3421,6 @@ func UpdateFTdetail(c *gin.Context) {
|
|
|
appG.Response(http.StatusOK, e.ERROR, false)
|
|
|
return
|
|
|
}
|
|
|
- // }()
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, true)
|
|
@@ -3523,14 +3534,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()
|
|
@@ -3540,15 +3547,17 @@ 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
|
|
|
}
|
|
|
|
|
|
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 =?
|
|
|
+ err = tx.SQL(`select lppland.*,t.maxstirfeed maxweight from lpplan lpp
|
|
|
+ join lpplandtl1 lppland on lpp.id = lppland.lppid
|
|
|
+ join tmr t on t.id = lpp.tmrid
|
|
|
+ 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 {
|
|
@@ -3561,7 +3570,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
|
|
|
}
|
|
@@ -3576,11 +3585,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 {
|
|
@@ -3619,13 +3631,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)
|
|
@@ -4121,6 +4146,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
rows = rows[:10000]
|
|
|
}
|
|
|
|
|
|
+ dataList := make(map[string][]*upFpdetail, 0)
|
|
|
for i, row := range rows {
|
|
|
if i > 0 {
|
|
|
|
|
@@ -4278,6 +4304,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if !errExist {
|
|
|
|
|
|
dataexcel := make(map[string]interface{}, 0)
|
|
@@ -4312,7 +4339,7 @@ func FpdImportExcel(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第五班比例(%)"]; ok {
|
|
|
- dataexcel["5"] = outentry["第四班比例(%)"]
|
|
|
+ dataexcel["5"] = outentry["第五班比例(%)"]
|
|
|
}
|
|
|
|
|
|
if _, ok := outentry["第六班比例(%)"]; ok {
|
|
@@ -4329,6 +4356,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)
|
|
@@ -4503,7 +4552,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
|
|
|
}
|
|
|
|
|
@@ -4587,17 +4636,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
|
|
@@ -4699,65 +4751,69 @@ 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
|
|
|
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 =?
|
|
|
+ err = tx.SQL(`select lppland.*,t.maxstirfeed maxweight from lpplan lpp
|
|
|
+ join lpplandtl1 lppland on lpp.id = lppland.lppid
|
|
|
+ join tmr t on t.id = lpp.tmrid
|
|
|
+ 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)
|
|
|
}
|
|
|
-
|
|
|
+ // [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 {
|
|
@@ -4770,7 +4826,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
|
|
@@ -4796,13 +4851,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)
|
|
@@ -4962,7 +5029,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
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4974,7 +5041,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 {
|
|
@@ -4989,7 +5056,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
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5660,7 +5727,7 @@ join lpplan lpp on lpp.id = lppland.lppid where lppland.barname = ? and lppland
|
|
|
for _, history1 := range historyList {
|
|
|
if history1["createdate"].(string) == nextcreatedate && history1["id"].(int64) == history["id"].(int64) &&
|
|
|
history1["times"].(int64) == history["times"].(int64) {
|
|
|
- data[fmt.Sprintf("a%d", times[history["times"]])] = fmt.Sprintf("%v/%v", data[fmt.Sprintf("a%d", times[history["times"]])], history["lweight"])
|
|
|
+ data[fmt.Sprintf("a%d", times[history["times"]])] = fmt.Sprintf("%v/%v", history1["lweight"], history["lweight"])
|
|
|
break
|
|
|
// exist = true
|
|
|
}
|
|
@@ -6657,6 +6724,19 @@ func UpdateDailyData(c *gin.Context) {
|
|
|
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
+
|
|
|
+ count, err := tx.SQL(`select count(1) from downloadedplan where pid in(select pid from downloadedplan where id= ? ) and havebutton = 1 and mydate = ?`, pid, date).Count()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("UpdateDailyData-error-0:", err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("该计划已开始执行,禁止修改!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count > 0 {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, fmt.Sprintf("该计划已开始执行,禁止修改!"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
tx.Begin()
|
|
|
|
|
|
if location == 0 {
|
|
@@ -6949,7 +7029,7 @@ func UpdateDailyData(c *gin.Context) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- err := tx.Commit()
|
|
|
+ err = tx.Commit()
|
|
|
if err != nil {
|
|
|
logs.Error("UpdateDailyData-error-20:", err)
|
|
|
tx.Rollback()
|
|
@@ -7002,7 +7082,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)
|
|
@@ -7171,32 +7251,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" {
|
|
@@ -7790,39 +7870,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" {
|
|
@@ -7917,3 +8002,875 @@ func PostPlanDatas(c *gin.Context) {
|
|
|
}
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
}
|
|
|
+
|
|
|
+func FpdBatchEdit(c *gin.Context) {
|
|
|
+
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ barList := fsions.Get("barList").Array()
|
|
|
+ pastureid := fsions.Get("pastureId").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ oldFpdList, err := tx.SQL(` select ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") fweight,fpd.id,fpd.barname,fpd.weight,fpd.times,fp.ftweight,fp.supplyweight from fpdetail fpd
|
|
|
+ join feedp fp on fp.barid = fpd.barid and fpd.pastureid = fp.pastureid where fpd.pastureid = ?`, pastureid).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, barFsions := range barList {
|
|
|
+
|
|
|
+ dataexcel := make(map[string]interface{}, 0)
|
|
|
+ dataexcel["barname"] = barFsions.Get("barname").ValueStr()
|
|
|
+ dataexcel["ccount"] = barFsions.Get("ccount").ValueStr()
|
|
|
+ dataexcel["ratio"] = barFsions.Get("ratio").ValueStr()
|
|
|
+ dataexcel["ftname"] = barFsions.Get("ftname").ValueStr()
|
|
|
+ dataexcel["ptsfname"] = barFsions.Get("ptsfname").ValueStr()
|
|
|
+ if dataexcel["ftname"] == "" || dataexcel["ccount"] == "0" || dataexcel["ratio"] == "0" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ dataexcel["1"] = barFsions.Get("times1").ValueStr()
|
|
|
+ dataexcel["2"] = barFsions.Get("times2").ValueStr()
|
|
|
+ dataexcel["3"] = barFsions.Get("times3").ValueStr()
|
|
|
+ dataexcel["4"] = barFsions.Get("times4").ValueStr()
|
|
|
+ dataexcel["5"] = barFsions.Get("times5").ValueStr()
|
|
|
+ dataexcel["6"] = barFsions.Get("times6").ValueStr()
|
|
|
+
|
|
|
+ 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)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !ftexist {
|
|
|
+ fmt.Println(dataexcel["barname"], pastureid, dataexcel["ftname"])
|
|
|
+ tx.SQL(` delete from lpplandtl1 where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ tx.SQL(` update fpdetail set ptuse = 0 where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ exist, err := tx.SQL(` select id from feedp where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist {
|
|
|
+ _, err := tx.SQL(` insert into feedp(pastureid,barid,barname,ccount)values(?,(select id from bar where bname = ? and pastureid = ? ),?,?) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"], 0).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var feedpargs []interface{}
|
|
|
+ upFeedpSql := `update feedp set ccount = ? ,ratio = ? ,ccountratio = ?*(?*0.01) `
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"])
|
|
|
+ if _, ok := dataexcel["ftname"]; ok {
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ftname"], pastureid, dataexcel["ftname"])
|
|
|
+ upFeedpSql += ` , ftid = (select id from feedtemplet where tname = ? and pastureid = ? ),ftname = ? `
|
|
|
+
|
|
|
+ upFeedpSql += `,ftweight = (select sum(fweight) fweight from ftdetail
|
|
|
+ where ftid = (select id from feedtemplet where tname = ? and pastureid = ? )) * (?*(?*0.01)) `
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ftname"], pastureid, dataexcel["ccount"], dataexcel["ratio"])
|
|
|
+ } else {
|
|
|
+ upFeedpSql += ` , ftid = -1,ftname = '' ,ftweight = 0 `
|
|
|
+ }
|
|
|
+
|
|
|
+ if _, ok := dataexcel["ptsfname"]; ok {
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ptsfname"], pastureid, dataexcel["ptsfname"])
|
|
|
+ upFeedpSql += ` , ptsfid = (select id from feedtemplet where tname = ? and pastureid = ? ),ptsfname = ? `
|
|
|
+
|
|
|
+ upFeedpSql += `,supplyweight = (select sum(fweight) fweight from ftdetail
|
|
|
+ where ftid = (select id from feedtemplet where tname = ? and pastureid = ? )) * (?*(?*0.01))`
|
|
|
+ feedpargs = append(feedpargs, dataexcel["ptsfname"], pastureid, dataexcel["ccount"], dataexcel["ratio"])
|
|
|
+ } else {
|
|
|
+ upFeedpSql += ` , ptsfid = -1,ptsfname = '',supplyweight = 0 `
|
|
|
+ }
|
|
|
+ upFeedpSql += " where barname = ? and pastureid = ? "
|
|
|
+ feedpargs = append(feedpargs, dataexcel["barname"], pastureid)
|
|
|
+ _, err = tx.SQL(upFeedpSql, feedpargs...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ exist1, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 1 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if !exist1 {
|
|
|
+ _, err := tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,1,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist2, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 2 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist2 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,2,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ exist3, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times =3 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist3 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,3,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist4, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 4 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist4 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,4,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist5, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 5 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist5 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,5,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exist6, err := tx.SQL(` select id from fpdetail where barname = ? and pastureid = ? and times = 6 `, dataexcel["barname"], pastureid).Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !exist6 {
|
|
|
+ _, err = tx.SQL(` insert into fpdetail(pastureid,barid,barname,times,ptuse,ptsuse,ptsrate,ptsid,ptid)values(?,(select id from bar where bname = ? and pastureid = ? ),?,6,0,0,0,-1,-1) `,
|
|
|
+ pastureid, dataexcel["barname"], pastureid, dataexcel["barname"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ upFpdSql := ` update fpdetail set tratio = ? ,weight = (? *0.01) * ((select sum(fweight) fweight from ftdetail
|
|
|
+ where ftid = (select id from feedtemplet where tname = ? and pastureid = ? )) * (?*(?*0.01))) ,cowcount = ? ,
|
|
|
+ ccountradio= ?,ptid= (select id from feedtemplet where tname = ? and pastureid = ? ) where barname = ?
|
|
|
+ and pastureid = ? and times = ?`
|
|
|
+ var fpdargs1 []interface{}
|
|
|
+ fpdargs1 = append(fpdargs1, dataexcel["1"], dataexcel["1"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 1)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs1...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var fpdargs2 []interface{}
|
|
|
+ fpdargs2 = append(fpdargs2, dataexcel["2"], dataexcel["2"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 2)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs2...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var fpdargs3 []interface{}
|
|
|
+ fpdargs3 = append(fpdargs3, dataexcel["3"], dataexcel["3"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 3)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs3...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var fpdargs4 []interface{}
|
|
|
+ fpdargs4 = append(fpdargs4, dataexcel["4"], dataexcel["4"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 4)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs4...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var fpdargs5 []interface{}
|
|
|
+ fpdargs5 = append(fpdargs5, dataexcel["5"], dataexcel["5"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 5)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs5...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var fpdargs6 []interface{}
|
|
|
+ fpdargs6 = append(fpdargs6, dataexcel["6"], dataexcel["6"], dataexcel["ftname"], pastureid,
|
|
|
+ dataexcel["ccount"], dataexcel["ratio"], dataexcel["ccount"], dataexcel["ratio"],
|
|
|
+ dataexcel["ftname"], pastureid, dataexcel["barname"], pastureid, 6)
|
|
|
+ _, err = tx.SQL(upFpdSql, fpdargs6...).Execute()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // _, err = tx.SQL(`call updateLPPbyFPChange(?,( select id from feedp where barname = ? and pastureid = ?))`, pastureid, dataexcel["barname"], pastureid).Execute()
|
|
|
+
|
|
|
+ newList, err := tx.SQL(` select ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") fweight,id,ptid,weight,times from fpdetail where barname = ? and pastureid = ? `, dataexcel["barname"], pastureid).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ appG.Response(http.StatusInternalServerError, e.ERROR, false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // oldFpdList, err := tx.SQL(` select fpd.id,fpd.barname,fpd.weight,fpd.times,fp.ftweight,fp.supplyweight from fpdetail fpd
|
|
|
+ // join feedp fp on fp.barid = fpd.barid and fpd.pastureid = fp.pastureid where fpd.pastureid = ?`, pastureid).Query().List()
|
|
|
+ upFpdetailList := make([]*upFpdetail, 0)
|
|
|
+ for _, newfpd := range newList {
|
|
|
+ for _, oldfpd := range oldFpdList {
|
|
|
+ if oldfpd["id"].(int64) == newfpd["id"].(int64) {
|
|
|
+ var oldweight, newweight float64
|
|
|
+ if oldfpd["weight"] != nil {
|
|
|
+ oldweight, _ = strconv.ParseFloat(oldfpd["weight"].(string), 64)
|
|
|
+ }
|
|
|
+ if newfpd["weight"] != nil {
|
|
|
+ newweight, _ = strconv.ParseFloat(newfpd["weight"].(string), 64)
|
|
|
+ }
|
|
|
+ fweight, _ := strconv.ParseFloat(newfpd["fweight"].(string), 64)
|
|
|
+ upFpdetailList = append(upFpdetailList, &upFpdetail{
|
|
|
+ Old: oldweight,
|
|
|
+ New: newweight,
|
|
|
+ Times: newfpd["times"].(int64),
|
|
|
+ Ptid: newfpd["ptid"].(int64),
|
|
|
+ Fweight: fweight,
|
|
|
+ Id: oldfpd["id"].(int64),
|
|
|
+ })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updateFpdetailByBar(pastureid, dataexcel["barname"].(string), upFpdetailList)
|
|
|
+ }
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func UdBarSync(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ pastureid := fsions.Get("pastureId").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ pastureinfo := new(udPastureInfo)
|
|
|
+ err := tx.SQL(`select werks from pasture where pastureid = ? `, pastureid).GetFirst(pastureinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ gm.UdBarSync(pastureid, pastureinfo.Werks)
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func UdFeedSync(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ pastureid := fsions.Get("pastureId").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ pastureinfo := new(udPastureInfo)
|
|
|
+ err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ gm.UdFeedSync(pastureid, pastureinfo.Werks)
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func UdFeedtempletPush(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ 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()
|
|
|
+
|
|
|
+ pastureinfo := new(udPastureInfo)
|
|
|
+ err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ gm.UdFeedtempletPush(pastureid, pastureinfo.Werks, date)
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func UdUtirPush(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ 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()
|
|
|
+
|
|
|
+ pastureinfo := new(udPastureInfo)
|
|
|
+ err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ gm.UdUtirPush(pastureid, pastureinfo.Werks, date)
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func UdBarFeedRemainPush(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ 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()
|
|
|
+
|
|
|
+ pastureinfo := new(udPastureInfo)
|
|
|
+ err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ gm.UdBarFeedRemainPush(pastureid, pastureinfo.Werks, date)
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func UdMaterialIssuePush(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ 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()
|
|
|
+
|
|
|
+ pastureinfo := new(udPastureInfo)
|
|
|
+ err := tx.SQL(`select werks from pasture where pastureid = ?`, pastureid).GetFirst(pastureinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ gm.UdMaterialIssuePush(pastureid, pastureinfo.Werks, date)
|
|
|
+
|
|
|
+ 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 , 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 , 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 = 0 ,ptid = 0,ptuse= 0 where ptid = ? `, 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").Where(`barid in(?)`, barIdStr).Query().List()
|
|
|
+ // if err != nil {
|
|
|
+ // logs.Error(err)
|
|
|
+ // appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ // newFeedpList, err := tx.Table("feedp").Where(`barid in(?)`, 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 )
|
|
|
+ AND ( SELECT count( 1 ) FROM downloadplandtl2 dd2 WHERE dd2.pid = d.id ) =
|
|
|
+ ( SELECT count( 1 ) FROM downloadplandtl2 dd2 WHERE dd2.pid = d.pid and (select count(1) from downloadplandtl2 where pid = dd2.pid and fname = dd2.fname ) = 1 )
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func EditPlanSort(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ planIdStr := fsions.Get("planId").ValueStr()
|
|
|
+ mydate := fsions.Get("mydate").ValueStr()
|
|
|
+ sort := fsions.Get("sort").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ tx.Begin()
|
|
|
+
|
|
|
+ type downloadedplan struct {
|
|
|
+ Id int64 `xorm:"id"`
|
|
|
+ Sort int `xorm:"sort"`
|
|
|
+ Pid int64 `xorm:"pid"`
|
|
|
+ }
|
|
|
+ planInfo := new(downloadedplan)
|
|
|
+ err := tx.SQL(`select d.id,d.sort,d.pid from downloadedplan d where d.id = ? `, planIdStr).GetFirst(planInfo).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sort1, _ := strconv.Atoi(sort)
|
|
|
+ if sort1 == planInfo.Sort {
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "计划顺序一致修改失败!")
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ count1, err := tx.SQL(` select count(1) from downloadedplan where pid = (select pid from downloadedplan where sort = ? and mydate = ? ) and mydate = ? `, sort, mydate, mydate).Count()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count1 == 0 {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "您所排序的数值不存在!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ count, err := tx.SQL(` select count(1) from downloadedplan where pid = (select pid from downloadedplan where sort = ? and mydate = ? ) and havebutton = 1 and mydate = ? `, sort, mydate, mydate).Count()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count > 0 {
|
|
|
+ tx.Rollback()
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败,该计划已执行!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if planInfo.Sort > sort1 {
|
|
|
+ minSortList, err := tx.SQL(`select min(d.sort) sort from downloadedplan d where d.mydate = ? and d.pid = (select pid from downloadedplan where sort = ? and mydate = ? ) `, mydate, sort, mydate).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var minSort, pidCount int
|
|
|
+ for _, sort := range minSortList {
|
|
|
+ minSort, _ = strconv.Atoi(sort["sort"])
|
|
|
+ }
|
|
|
+
|
|
|
+ planList := make([]*downloadedplan, 0)
|
|
|
+ err = tx.SQL(`select id,d.sort sort,d.pid from downloadedplan d where d.mydate = ? and sort >= ? order by sort`, mydate, minSort).Find(&planList)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ planPid := planInfo.Pid
|
|
|
+ planList1 := make([]*downloadedplan, 0)
|
|
|
+ planList2 := make([]*downloadedplan, 0)
|
|
|
+
|
|
|
+ for _, plan := range planList {
|
|
|
+ if plan.Pid == planPid {
|
|
|
+ pidCount++
|
|
|
+ planList1 = append(planList1, plan)
|
|
|
+ } else {
|
|
|
+ planList2 = append(planList2, plan)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ planList1 = append(planList1, planList2...)
|
|
|
+
|
|
|
+ for i, plan := range planList1 {
|
|
|
+ _, err := tx.Exec(` update downloadedplan set sort = ? where id = ? `, minSort+i, plan.Id)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ maxSortList, err := tx.SQL(`select max(d.sort) sort from downloadedplan d where d.mydate = ? and d.pid = (select pid from downloadedplan where sort = ? and mydate = ? ) `, mydate, sort, mydate).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var maxSort int
|
|
|
+ for _, sort := range maxSortList {
|
|
|
+ maxSort, _ = strconv.Atoi(sort["sort"])
|
|
|
+ }
|
|
|
+
|
|
|
+ planList := make([]*downloadedplan, 0)
|
|
|
+ err = tx.SQL(`select id,d.sort sort,d.pid from downloadedplan d where d.mydate = ? and sort <= ? order by sort`, mydate, maxSort).Find(&planList)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "调整计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ planPid := planInfo.Pid
|
|
|
+ planList1 := make([]*downloadedplan, 0)
|
|
|
+ planList2 := make([]*downloadedplan, 0)
|
|
|
+
|
|
|
+ for _, plan := range planList {
|
|
|
+ if plan.Pid == planPid {
|
|
|
+ // pidCount++
|
|
|
+ planList1 = append(planList1, plan)
|
|
|
+ } else {
|
|
|
+ planList2 = append(planList2, plan)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ planList2 = append(planList2, planList1...)
|
|
|
+
|
|
|
+ for i, plan := range planList2 {
|
|
|
+ _, err := tx.Exec(` update downloadedplan set sort = ? where id = ? `, i+1, plan.Id)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ err = tx.Commit()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划顺序失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+func EditDownloadedplanArtificial(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
+ fsions := gofasion.NewFasion(string(dataByte))
|
|
|
+ planIdStr := fsions.Get("planId").ValueStr()
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+ tx.Begin()
|
|
|
+
|
|
|
+ planIdList := strings.Split(planIdStr, ",")
|
|
|
+
|
|
|
+ for _, planId := range planIdList {
|
|
|
+ _, err := tx.Exec(` update downloadedplan set artificial = 1 ,havebutton = 1,iscompleted = 1 where id = ? and havebutton != 1`, planId)
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划状态失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ err := tx.Commit()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, "修改计划状态失败!"+err.Error())
|
|
|
+ tx.Rollback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "ok")
|
|
|
+}
|
|
|
+
|
|
|
+type PlanRFID struct {
|
|
|
+ RFID string `json:"RFID"`
|
|
|
+ Lweight string `json:"lweight"`
|
|
|
+ Gear string `json:"gear"`
|
|
|
+ Speed string `json:"speed"`
|
|
|
+}
|
|
|
+
|
|
|
+func GetPlanRFID(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ RFIDStr := c.Query("RFID")
|
|
|
+
|
|
|
+ planRFIDList := make([]*PlanRFID, 0)
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1411.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1322.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1904.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "1870.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ planRFIDList = append(planRFIDList, &PlanRFID{
|
|
|
+ RFID: RFIDStr,
|
|
|
+ Lweight: "2041.1",
|
|
|
+ Gear: "1",
|
|
|
+ Speed: "10",
|
|
|
+ })
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, planRFIDList)
|
|
|
+}
|
|
|
+
|
|
|
+type tmrEquipmentMuster struct {
|
|
|
+ A string
|
|
|
+ N string
|
|
|
+}
|
|
|
+
|
|
|
+func GetTmrEquipmentMuster(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+ id := c.Query("id")
|
|
|
+
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+
|
|
|
+ dataList, err := tx.SQL(` select * from tmr_equipment_muster where pid = ? `, id).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error(err)
|
|
|
+ appG.Response(http.StatusOK, e.ERROR, err.Error())
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ tmrEquipmentMusterList := make([]*tmrEquipmentMuster, 0)
|
|
|
+
|
|
|
+ for _, data := range dataList {
|
|
|
+ json.Unmarshal([]byte(data["gptjson"]), &tmrEquipmentMusterList)
|
|
|
+ for _, g := range tmrEquipmentMusterList {
|
|
|
+ a, _ := strconv.ParseFloat(g.A, 64)
|
|
|
+ n, _ := strconv.ParseFloat(g.N, 64)
|
|
|
+ a1, n1 := ddmmtoddd(a, n)
|
|
|
+ g.A = fmt.Sprintf("%f", n1)
|
|
|
+ g.N = fmt.Sprintf("%f", a1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, tmrEquipmentMusterList)
|
|
|
+}
|
|
|
+
|
|
|
+func ddmmtoddd(lng, lat float64) (float64, float64) {
|
|
|
+ lngDegree := fmt.Sprintf("%f", lng/100)
|
|
|
+ lngDegreefloat, _ := strconv.ParseFloat(strings.Split(lngDegree, ".")[1], 64)
|
|
|
+
|
|
|
+ lngDegreeInt := int(lngDegreefloat * 1000000)
|
|
|
+ dd := lngDegreeInt / 100 * 100 / 60
|
|
|
+ fmt.Println(dd)
|
|
|
+ lngStr := strings.Split(lngDegree, ".")[0] + "." + strings.Replace(fmt.Sprintf("%d", lngDegreeInt/100*100/60), ".", "", 0)
|
|
|
+
|
|
|
+ latDegree := fmt.Sprintf("%f", lat/100)
|
|
|
+ // latDegreeInt, _ := strconv.ParseInt(strings.Split(latDegree, ".")[1], 10, 64)
|
|
|
+
|
|
|
+ latDegreefloat, _ := strconv.ParseFloat(strings.Split(latDegree, ".")[1], 64)
|
|
|
+ latDegreeInt := int(latDegreefloat * 1000000)
|
|
|
+ latStr := strings.Split(latDegree, ".")[0] + "." + strings.Replace(fmt.Sprintf("%d", latDegreeInt/100*100/60), ".", "", 0)
|
|
|
+
|
|
|
+ a, _ := strconv.ParseFloat(lngStr, 64)
|
|
|
+ b, _ := strconv.ParseFloat(latStr, 64)
|
|
|
+ return coordtransform.WGS84toGCJ02(b, a)
|
|
|
+}
|