baishaojie 1 рік тому
батько
коміт
12619ca336
6 змінених файлів з 256 додано та 284 видалено
  1. BIN
      __debug_bin.exe
  2. 4 4
      conf/app.ini
  3. 28 28
      http/handle/api/report.go
  4. 2 2
      http/handle/api/scheduled.go
  5. 2 2
      http/handle/yc/yc.go
  6. 220 248
      http/handle/yq/yq.go

BIN
__debug_bin.exe


+ 4 - 4
conf/app.ini

@@ -21,7 +21,7 @@ TimeFormat = 20060102-150405
 #debug or release
 #RunMode = debuggit 
 RunMode = release
-HttpPort = 8081
+HttpPort = 8082
 ReadTimeout = 60
 WriteTimeout = 60
 NoAuth = 1
@@ -48,8 +48,8 @@ Type = mysql
 User = root
 Password = root
 #Host = 8.130.17.8:3306
-#Host = 192.168.1.93:3326
-Host = 127.0.0.1:3316
+Host = 192.168.1.93:3326
+#Host = 127.0.0.1:3316
 #Name = haiyuan
 #Password = root
 #Password = root
@@ -73,7 +73,7 @@ Host = 127.0.0.1:3316
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = tmrwatch2
+Name = yq2
 TablePrefix =
 
 ShowXormlog = false

+ 28 - 28
http/handle/api/report.go

@@ -373,7 +373,7 @@ func getAccuracyV8(queryList []map[string]interface{}) (map[string]interface{},
 		trans35f, _ := strconv.ParseFloat(queryList[i]["trans35f"].(string), 64)
 		jcrate, _ := strconv.ParseFloat(queryList[i]["jcrate"].(string), 64)
 		uprice, _ := strconv.ParseFloat(queryList[i]["uprice"].(string), 64)
-		kprice, _ := strconv.ParseFloat(queryList[i]["dry"].(string), 64)
+		// kprice, _ := strconv.ParseFloat(queryList[i]["dry"].(string), 64)
 
 		adf, _ := strconv.ParseFloat(queryList[i]["adf"].(string), 64)
 		ca, _ := strconv.ParseFloat(queryList[i]["ca"].(string), 64)
@@ -384,9 +384,9 @@ func getAccuracyV8(queryList []map[string]interface{}) (map[string]interface{},
 		cpd, _ := strconv.ParseFloat(queryList[i]["cpd"].(string), 64)
 		fat, _ := strconv.ParseFloat(queryList[i]["fat"].(string), 64)
 		ndf, _ := strconv.ParseFloat(queryList[i]["ndf"].(string), 64)
-		nm, _ := strconv.ParseFloat(queryList[i]["nm"].(string), 64)
-		nmd, _ := strconv.ParseFloat(queryList[i]["nmd"].(string), 64)
-		nuint, _ := strconv.ParseFloat(queryList[i]["nuint"].(string), 64)
+		// nm, _ := strconv.ParseFloat(queryList[i]["nm"].(string), 64)
+		// nmd, _ := strconv.ParseFloat(queryList[i]["nmd"].(string), 64)
+		// nuint, _ := strconv.ParseFloat(queryList[i]["nuint"].(string), 64)
 		p, _ := strconv.ParseFloat(queryList[i]["p"].(string), 64)
 		pd, _ := strconv.ParseFloat(queryList[i]["pd"].(string), 64)
 		starch, _ := strconv.ParseFloat(queryList[i]["starch"].(string), 64)
@@ -414,13 +414,13 @@ func getAccuracyV8(queryList []map[string]interface{}) (map[string]interface{},
 		list["cyl"] = TransFloat(uprice * Srate)
 		data = append(data, list)
 
-		list = make(map[string]interface{})
-		list["ft"] = kprice
-		list["index"] = "公斤奶成本"
+		// list = make(map[string]interface{})
+		// list["ft"] = kprice
+		// list["index"] = "公斤奶成本"
 
-		list["tmr"] = TransFloat(kprice * Hrate)
-		list["cyl"] = TransFloat(kprice * Srate)
-		data = append(data, list)
+		// list["tmr"] = TransFloat(kprice * Hrate)
+		// list["cyl"] = TransFloat(kprice * Srate)
+		// data = append(data, list)
 
 		list = make(map[string]interface{})
 		list["ft"] = cdry
@@ -430,21 +430,21 @@ func getAccuracyV8(queryList []map[string]interface{}) (map[string]interface{},
 		list["cyl"] = TransFloat(cdry * Srate)
 		data = append(data, list)
 
-		list = make(map[string]interface{})
-		list["ft"] = nm
-		list["index"] = " 产奶净能(MJ)"
+		// list = make(map[string]interface{})
+		// list["ft"] = nm
+		// list["index"] = " 产奶净能(MJ)"
 
-		list["tmr"] = TransFloat(nm * Hrate)
-		list["cyl"] = TransFloat(nm * Srate)
-		data = append(data, list)
+		// list["tmr"] = TransFloat(nm * Hrate)
+		// list["cyl"] = TransFloat(nm * Srate)
+		// data = append(data, list)
 
-		list = make(map[string]interface{})
-		list["ft"] = nuint
-		list["index"] = "奶牛能量单位(NND)"
+		// list = make(map[string]interface{})
+		// list["ft"] = nuint
+		// list["index"] = "奶牛能量单位(NND)"
 
-		list["tmr"] = TransFloat(nuint * Hrate)
-		list["cyl"] = TransFloat(nuint * Srate)
-		data = append(data, list)
+		// list["tmr"] = TransFloat(nuint * Hrate)
+		// list["cyl"] = TransFloat(nuint * Srate)
+		// data = append(data, list)
 
 		list = make(map[string]interface{})
 		list["ft"] = cp
@@ -478,13 +478,13 @@ func getAccuracyV8(queryList []map[string]interface{}) (map[string]interface{},
 		list["cyl"] = TransFloat(p * Srate)
 		data = append(data, list)
 
-		list = make(map[string]interface{})
-		list["ft"] = nmd
-		list["index"] = "产奶净能(Mcal/DM)"
+		// list = make(map[string]interface{})
+		// list["ft"] = nmd
+		// list["index"] = "产奶净能(Mcal/DM)"
 
-		list["tmr"] = TransFloat(nmd * Hrate)
-		list["cyl"] = TransFloat(nmd * Srate)
-		data = append(data, list)
+		// list["tmr"] = TransFloat(nmd * Hrate)
+		// list["cyl"] = TransFloat(nmd * Srate)
+		// data = append(data, list)
 
 		list = make(map[string]interface{})
 		list["ft"] = fat

+ 2 - 2
http/handle/api/scheduled.go

@@ -16,7 +16,7 @@ import (
 
 	"tmr-watch/conf/setting"
 	"tmr-watch/http/handle/restful"
-	"tmr-watch/http/handle/yc"
+	"tmr-watch/http/handle/yq"
 	"tmr-watch/pkg/app"
 	"tmr-watch/pkg/e"
 	"tmr-watch/pkg/logging"
@@ -144,7 +144,7 @@ func CronScheduled(ctx context.Context) {
 	// })
 	// xdmy.Start()
 	// InitMqttClient()
-	yc.YqCron()
+	yq.YqCron()
 }
 
 type ScheduledInfo struct {

+ 2 - 2
http/handle/yc/yc.go

@@ -36,8 +36,8 @@ func YqCron() {
 		return
 	}
 
-	// token := getToken()
-	// syncBar(token, pastureinfo.Pastureid)
+	token := getToken()
+	syncBar(token, pastureinfo.Pastureid)
 
 	c := cron.New()
 	c.AddFunc("0 0 1 * * *", func() {

+ 220 - 248
http/handle/yq/yq.go

@@ -12,11 +12,8 @@ import (
 	"time"
 	"tmr-watch/conf/setting"
 	"tmr-watch/http/handle/restful"
-	"tmr-watch/pkg/app"
-	"tmr-watch/pkg/e"
 	"tmr-watch/pkg/logging"
 
-	"github.com/Anderson-Lu/gofasion/gofasion"
 	"github.com/astaxie/beego/logs"
 	"github.com/robfig/cron"
 	"github.com/xormplus/xorm"
@@ -585,30 +582,32 @@ func syncBar(token, pastureid string) {
 	for _, item := range dataList {
 		arg := item.(map[string]interface{})
 		fmt.Println(arg)
+		// arg["sheepCount"] = 150
 		_, err := tx.Exec(` insert into bar(pen,bname,bcode,pastureid)values(?,?,?,?)  ON DUPLICATE KEY UPDATE  pen = ? `, arg["districtName"],
 			fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]), fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]), pastureid, arg["houseName"])
 		fmt.Println(err)
 
 		insertSql := `insert into feedp(pastureid,barname,barid,ccount)VALUES(?,?,(select id from bar where bname = ?),?)
 				ON DUPLICATE KEY UPDATE ccount = ? ,barname = ?  `
-		tx.SQL(insertSql, pastureid, fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]),
+		_, err = tx.SQL(insertSql, pastureid, fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]),
 			fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"]), arg["sheepCount"], arg["sheepCount"],
 			fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"])).Execute()
-
-		tx.SQL(` select  from feedp where barname = ? `)
+		fmt.Println(err)
+		// tx.SQL(` select  from feedp where barname = ? `)
 
 		// barList := make([]*bar,0)
 		b := new(bar)
 		// b.BarName = fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"])
 		// b.Ccount = arg["sheepCount"]
-		err = tx.SQL(`select fp.barname,fp.ccount,ratio,ft.tname ftname,(select tratio from fpdetail  where barid = fp.barid  and times = 1 ) times1,
-(select tratio from fpdetail  where barid = fp.barid  and times = 2 ) times2 ,
-(select tratio from fpdetail  where barid = fp.barid  and times = 3 ) times3 ,
-(select tratio from fpdetail  where barid = fp.barid  and times = 4 ) times4 ,
-(select tratio from fpdetail  where barid = fp.barid  and times =5 ) times5  ,
-(select tratio from fpdetail  where barid = fp.barid  and times =6 ) times6  
- from feedp fp  join feedtemplet ft on ft.id = fp.ftid  where ratio > 0  and fp.barname = ? `, fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"])).GetFirst(&b).Error
-
+		err = tx.SQL(`	select fp.barname,fp.ccount,ratio,ft.tname ftname,ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 1 ),0) times1,
+		ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 2 ),0) times2 ,
+		ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 3 ),0) times3 ,
+		ifnull((select tratio from fpdetail  where barid = fp.barid  and times = 4 ),0) times4 ,
+		ifnull((select tratio from fpdetail  where barid = fp.barid  and times =5 ),0) times5  ,
+		ifnull((select tratio from fpdetail  where barid = fp.barid  and times =6 ),0) times6  
+		 from feedp fp  join feedtemplet ft on ft.id = fp.ftid  where ratio > 0 and fp.barname = ? `, fmt.Sprintf("%v-%v", arg["houseName"], arg["compartmentName"])).GetFirst(b).Error
+		fmt.Println(err)
+		fpdBatchEdit(pastureid, b)
 		// {"pastureId":"1653271339","barList":[{"barname":"14","ccount":155,"ratio":"100.00","ftname":"高产2配方",
 		// "times1":"41","times2":"25","times3":"25","times4":0,"times5":0,"times6":0}]}
 
@@ -616,19 +615,19 @@ func syncBar(token, pastureid string) {
 }
 
 type bar struct {
-	BarName string `xorm:"barname" json:"barname"`
-	Ccount  string `xorm:"ccount" json:"ccount"`
-	Ratio   string `xorm:"ratio" json:"ratio"`
-	Ftname  string `xorm:"ftname" json:"ftname"`
-	Times1  int64  `xorm:"times1" json:"times1"`
-	Times2  int64  `xorm:"times2" json:"times2"`
-	Times3  int64  `xorm:"times3" json:"times3"`
-	Times4  int64  `xorm:"times4" json:"times4"`
-	Times5  int64  `xorm:"times5" json:"times5"`
-	Times6  int64  `xorm:"times6" json:"times6"`
+	BarName string  `xorm:"barname"`
+	Ccount  string  `xorm:"ccount"`
+	Ratio   string  `xorm:"ratio"`
+	Ftname  string  `xorm:"ftname"`
+	Times1  float64 `xorm:"times1"`
+	Times2  float64 `xorm:"times2"`
+	Times3  float64 `xorm:"times3"`
+	Times4  float64 `xorm:"times4"`
+	Times5  float64 `xorm:"times5"`
+	Times6  float64 `xorm:"times6"`
 }
 
-func fpdBatchEdit(pastureid string ,b *bar) {
+func fpdBatchEdit(pastureid string, b *bar) {
 
 	// appG := app.Gin{C: c}
 	// dataByte, _ := ioutil.ReadAll(c.Request.Body)
@@ -648,285 +647,258 @@ func fpdBatchEdit(pastureid string ,b *bar) {
 
 	// for _, barFsions := range barList {
 
-		dataexcel := make(map[string]interface{}, 0)
-		dataexcel["barname"] =b.BarName
-		dataexcel["ccount"] = b.Ccount
-		dataexcel["ratio"] = b.Ratio
-		dataexcel["ftname"] = b.Ftname
-		// dataexcel["ptsfname"] = barFsions.Get("ptsfname").ValueStr()
-		if dataexcel["ftname"] == "" || dataexcel["ccount"] == "0" || dataexcel["ratio"] == "0" {
-			return
-		}
+	dataexcel := make(map[string]interface{}, 0)
+	dataexcel["barname"] = b.BarName
+	dataexcel["ccount"] = b.Ccount
+	dataexcel["ratio"] = b.Ratio
+	dataexcel["ftname"] = b.Ftname
+	// dataexcel["ptsfname"] = barFsions.Get("ptsfname").ValueStr()
+	if dataexcel["ftname"] == "" || dataexcel["ccount"] == "0" || dataexcel["ratio"] == "0" {
+		return
+	}
 
-		dataexcel["1"] = b.Times1
-		dataexcel["2"] = b.Times2
-		dataexcel["3"] = b.Times3
-		dataexcel["4"] = b.Times4
-		dataexcel["5"] = b.Times5
-		dataexcel["6"] = b.Times6
+	dataexcel["1"] = b.Times1
+	dataexcel["2"] = b.Times2
+	dataexcel["3"] = b.Times3
+	dataexcel["4"] = b.Times4
+	dataexcel["5"] = b.Times5
+	dataexcel["6"] = b.Times6
 
-		ftexist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ? and ftname = ?  `, dataexcel["barname"], pastureid, dataexcel["ftname"]).Exist()
+	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)
+		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)
-	
 			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
-			}
+		tx.SQL(`  update fpdetail set ptuse = 0  where  barname = ? and pastureid = ?   `, dataexcel["barname"], pastureid).Exist()
+		if err != nil {
+			logs.Error(err)
+			return
 		}
+	}
 
-		exist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
+	exist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
+	if err != nil {
+		logs.Error(err)
+		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
 		}
-		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 = ? `
+	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 
+		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 `
-		}
+		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 = ? `
+	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 
+		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
-		}
+		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)
+		return
+	}
 
-		exist1, err := tx.SQL(` select id from  fpdetail where barname = ?  and pastureid = ? and times = 1 `, dataexcel["barname"], pastureid).Exist()
+	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)
+		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
 		}
-
-		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()
+	}
+	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)
+		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
 		}
-		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()
+	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)
+		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
 		}
-		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()
+	}
+	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)
+		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
 		}
-		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()
+	}
+	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)
+		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
 		}
-		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()
+	}
+	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)
+		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
 		}
-		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 
+	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 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 {
+		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 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 {
+		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 {
+		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 {
+		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 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 {
+		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()
+	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 {
+		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
+	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 {
+		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")
+	updateFpdetailByBar(pastureid, dataexcel["barname"].(string), upFpdetailList)
 }
 
 type lpplandtlInfo struct {