فهرست منبع

tmr 最新版本提交

bsj 3 سال پیش
والد
کامیت
0c9536e747
50فایلهای تغییر یافته به همراه1232 افزوده شده و 44 حذف شده
  1. BIN
      KPTAdmin32.exe
  2. BIN
      KPTAdmin64.exe
  3. BIN
      KPTAdmin64.zip
  4. BIN
      KPTAdmin641.exe
  5. BIN
      __debug_bin.exe
  6. 5 5
      conf/app.ini
  7. BIN
      dist.zip
  8. 0 0
      dist/index.html
  9. 0 0
      dist/static/css/app.81241f16.css
  10. 0 0
      dist/static/js/app.54c20a1e.js
  11. 0 0
      dist/static/js/chunk-52ecc0ac.235d809e.js
  12. 0 0
      dist/static/js/chunk-5c4dc4a9.b70975ce.js
  13. 0 0
      dist/static/js/chunk-91b31c64.ea39e792.js
  14. 0 0
      dist/static/js/chunk-b702d234.9b5e87a0.js
  15. BIN
      dist0418/favicon.ico
  16. 0 0
      dist0418/index.html
  17. 0 0
      dist0418/static/css/app.a3ef3e74.css
  18. 0 0
      dist0418/static/css/chunk-elementUI.5dea96f6.css
  19. 0 0
      dist0418/static/css/chunk-libs.1664ae71.css
  20. BIN
      dist0418/static/fonts/element-icons.535877f5.woff
  21. BIN
      dist0418/static/fonts/element-icons.732389de.ttf
  22. BIN
      dist0418/static/img/404.a57b6f31.png
  23. BIN
      dist0418/static/img/404_cloud.0f4bc32b.png
  24. 28 0
      dist0418/static/img/iconfont.7d9f8392.svg
  25. BIN
      dist0418/static/img/logo.afed751a.png
  26. BIN
      dist0418/static/img/logo1.0121925c.png
  27. BIN
      dist0418/static/img/logo_u3.3c77f543.png
  28. BIN
      dist0418/static/img/nlogin-bg.e6414ecd.png
  29. BIN
      dist0418/static/img/row-bg3.b3be7548.png
  30. BIN
      dist0418/static/img/topBg.69ecd1e1.png
  31. 0 0
      dist0418/static/js/app.e3ae6a6c.js
  32. 0 0
      dist0418/static/js/chunk-52ecc0ac.98e5f964.js
  33. 0 0
      dist0418/static/js/chunk-5c4dc4a9.eb511b2a.js
  34. 0 0
      dist0418/static/js/chunk-b702d234.0ec8f519.js
  35. 0 0
      dist0418/static/js/chunk-cf83d4b8.b3f7b120.js
  36. 0 0
      dist0418/static/js/chunk-elementUI.a8f15e3f.js
  37. 0 0
      dist0418/static/js/chunk-libs.adee55df.js
  38. BIN
      routers/api/__debug_bin.exe
  39. 3 3
      routers/api/chart.go
  40. 348 18
      routers/api/db.go
  41. 3 2
      routers/api/lpplandtl.go
  42. 791 0
      routers/api/spillage.go
  43. 13 11
      routers/api/udsync.go
  44. 0 3
      routers/restful/sql_utils.go
  45. 12 1
      routers/router.go
  46. 17 1
      update.sql
  47. BIN
      uploads.zip
  48. 5 0
      uploads/dist.sh
  49. BIN
      uploads/file/导入导出模板/基础数据/饲料导入模板.xlsx
  50. 7 0
      uploads/tmrgo.sh

BIN
KPTAdmin32.exe


BIN
KPTAdmin64.exe


BIN
KPTAdmin64.zip


BIN
KPTAdmin641.exe


BIN
__debug_bin.exe


+ 5 - 5
conf/app.ini

@@ -47,27 +47,27 @@ Type = mysql
 User = root
 #Password = root
 #Host = 127.0.0.1:3326
-#Password = root
+Password = root
 #Password = root
 #Password = kptzhu@163.com
 #Host = 192.168.1.50:3326
 #Password = root123456
 #Password = keep
-Password = kepaiteng!QAZ
+#Password = kepaiteng!QAZ
 #Password = kptzhu@163.com
 #Password = root
 #Password = kepaiteng!QAZ
 #Host = 47.92.52.73:3306
 #Host = 127.0.0.1:3306
 #Host = 210.16.186.252:3326
-Host = 222.73.129.15:31306
+#Host = 222.73.129.15:31306
 #Host = 210.16.186.252:3326
-#Host = 127.0.0.1:3316
+Host = 127.0.0.1:3316
 #Name = equipment
 #Name = eqdev
 #Name = eq0422
 #Name = tmrgo
-Name = tmrwatch5
+Name = tmrwatch2
 TablePrefix =
 
 ShowXormlog = false

BIN
dist.zip


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/index.html


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/static/css/app.81241f16.css


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/static/js/app.54c20a1e.js


+ 0 - 0
dist/static/js/chunk-52ecc0ac.98e5f964.js → dist/static/js/chunk-52ecc0ac.235d809e.js


+ 0 - 0
dist/static/js/chunk-5c4dc4a9.eb511b2a.js → dist/static/js/chunk-5c4dc4a9.b70975ce.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/static/js/chunk-91b31c64.ea39e792.js


+ 0 - 0
dist/static/js/chunk-b702d234.0ec8f519.js → dist/static/js/chunk-b702d234.9b5e87a0.js


BIN
dist0418/favicon.ico


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/index.html


+ 0 - 0
dist/static/css/app.a3ef3e74.css → dist0418/static/css/app.a3ef3e74.css


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/static/css/chunk-elementUI.5dea96f6.css


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/static/css/chunk-libs.1664ae71.css


BIN
dist0418/static/fonts/element-icons.535877f5.woff


BIN
dist0418/static/fonts/element-icons.732389de.ttf


BIN
dist0418/static/img/404.a57b6f31.png


BIN
dist0418/static/img/404_cloud.0f4bc32b.png


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 28 - 0
dist0418/static/img/iconfont.7d9f8392.svg


BIN
dist0418/static/img/logo.afed751a.png


BIN
dist0418/static/img/logo1.0121925c.png


BIN
dist0418/static/img/logo_u3.3c77f543.png


BIN
dist0418/static/img/nlogin-bg.e6414ecd.png


BIN
dist0418/static/img/row-bg3.b3be7548.png


BIN
dist0418/static/img/topBg.69ecd1e1.png


+ 0 - 0
dist/static/js/app.e3ae6a6c.js → dist0418/static/js/app.e3ae6a6c.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/static/js/chunk-52ecc0ac.98e5f964.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/static/js/chunk-5c4dc4a9.eb511b2a.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/static/js/chunk-b702d234.0ec8f519.js


+ 0 - 0
dist/static/js/chunk-cf83d4b8.b3f7b120.js → dist0418/static/js/chunk-cf83d4b8.b3f7b120.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/static/js/chunk-elementUI.a8f15e3f.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist0418/static/js/chunk-libs.adee55df.js


BIN
routers/api/__debug_bin.exe


+ 3 - 3
routers/api/chart.go

@@ -977,7 +977,7 @@ ROUND(IF(SUM(de.lweight)>SUM(de.actualweightminus),SUM(de.actualweightminus)/SUM
 COUNT(de.id) 添加饲料次数,
 SUM(IF(ABS(de.actualweightminus-de.lweight)<=de.feedallowratio,1,0)) 添加正确数,
 IF(COUNT(de.id)>0,SUM(IF(ABS(de.actualweightminus-de.lweight)<=de.feedallowratio,1,0))/COUNT(de.id),0) 正确率
-FROM downloadedplan d JOIN downloadplandtl1_exec de ON d.id=de.pid AND d.pastureid = de.pastureid 
+FROM downloadedplan d JOIN downloadplandtl1_exec de ON  d.pastureid = de.pastureid  and d.id=de.pid 
 WHERE  d.mydate  BETWEEN ? AND ?  AND d.pastureid=?   AND d.lpplantype  IN (0,1,2,5) AND de.type = 0
 -- 加上就是不含取消操作
 -- AND ((ABS(de.actualweightminus-de.lweight)/de.lweight)<=3 OR (de.lweight <30 AND de.actualweightminus <30 )) 
@@ -1234,7 +1234,7 @@ func GetAccuracyAllCC(c *gin.Context) {
 	var sqlStr = `SELECT d.projname 名称,%s 日期, 
 	SUM(de.lweight) 理论量,SUM(de.actualweightminus) 实际量,
 	ROUND(IF(SUM(de.lweight)>SUM(de.actualweightminus),SUM(de.actualweightminus)/SUM(de.lweight),SUM(de.lweight)/SUM(de.actualweightminus))*100,2) 准确率
-	FROM downloadedplan d right JOIN downloadplandtl1_exec de ON d.id=de.pid AND d.pastureid = de.pastureid
+	FROM downloadedplan d right JOIN downloadplandtl1_exec de ON  d.pastureid = de.pastureid and d.id=de.pid 
 	WHERE d.mydate  BETWEEN ? AND ?  AND  d.pastureid=? AND d.lpplantype  IN (0,1,2,5) AND de.type = 0
 	-- 加上就是不含取消操作
 	-- AND ((ABS(de.actualweightminus-de.lweight)/de.lweight)<=3 OR (de.lweight <30 AND de.actualweightminus <30 )) 
@@ -1407,7 +1407,7 @@ func GetAccuracyAllLS(c *gin.Context) {
 
 	var sqlStr = `SELECT concat(de.fname,'-',d.times,'班') 名称,de.fname,%s 日期, 
 	IFNULL(DATE_FORMAT(de.intime,'%%H.%%i'),'')   准确率  --  撒料时间
-	FROM downloadedplan d right JOIN downloadplandtl2 de ON d.id=de.pid AND d.pastureid = de.pastureid
+	FROM downloadedplan d right JOIN downloadplandtl2 de ON  d.pastureid = de.pastureid and d.id=de.pid 
 	WHERE d.mydate  BETWEEN ? AND ?  AND  d.pastureid=?  AND d.lpplantype  IN (0,1,2,5) AND de.type = 0
 	-- 加上就是不含取消操作
 	-- AND ((ABS(de.actualweightminus-de.lweight)/de.lweight)<=3 OR (de.lweight <30 AND de.actualweightminus <30 )) 

+ 348 - 18
routers/api/db.go

@@ -191,20 +191,19 @@ func GetDataByName(c *gin.Context) {
 							s_params = append(s_params, "")
 						}
 					} else {
-						if sqlnamestr == "getprocessAnalysis" && value == "tmrtname" {
-							tmrArray := parammaps.Get(strings.Trim(value, " ")).Array()
-							tmrNameList := []string{}
-							for _, tmr := range tmrArray {
-								tmrNameList = append(tmrNameList, tmr.ValueStr())
-							}
-							s_params = append(s_params, strings.Join(tmrNameList, ","))
-						} else {
-							s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
-						}
+						// if sqlnamestr == "getprocessAnalysis" && value == "tmrtname" {
+						// 	tmrArray := parammaps.Get(strings.Trim(value, " ")).Array()
+						// 	tmrNameList := []string{}
+						// 	for _, tmr := range tmrArray {
+						// 		tmrNameList = append(tmrNameList, tmr.ValueStr())
+						// 	}
+						// 	s_params = append(s_params, strings.Join(tmrNameList, ","))
+						// } else {
+						s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+						// }
 					}
 				}
 			}
-
 		} else if fsion.HasKey("params") {
 			params := fsion.Get("params").Array()
 			logging.Info("GetDataByName", c.Keys, c.Request.RemoteAddr, sqlnamestr, params)
@@ -1145,6 +1144,7 @@ func GetRJSBData(c *gin.Context) {
 
 		} else {
 			paramslist1 := strings.Split(p1, ",")
+
 			for index, value := range queryData.(map[string]interface{})["list"].([]map[string]interface{}) {
 				s_params1 := make([]interface{}, 0)
 				if len(paramslist1) > 0 && p1 != "" {
@@ -1155,6 +1155,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()
 			appG.Response(http.StatusOK, e.SUCCESS, queryData)
 		}
 	} else {
@@ -1213,6 +1222,25 @@ func PostRJSBData(c *gin.Context) {
 	paramslist = strings.Split(p1, ",")
 	if len(paramslist) > 0 && p1 != "" {
 		for _, value := range paramslist {
+			// if value == "ID" {
+			// 	id := parammaps.Get("ID").ValueStr()
+			// 	pastureid := parammaps.Get("pastureid").ValueStr()
+			// 	datalist, err := tx.SQL(`select d2.id as id from downloadplandtl1 d1 join downloadplandtl1_exec  d2 on d1.id = d2.id  where d1.pid =  (select pid  from downloadplandtl1 where id =  ? and pastureid = ? )  and
+			// 	d1.sort = (select sort  from downloadplandtl1 where id =  ? and pastureid = ? )`, id, pastureid, id, pastureid).QueryString()
+			// 	if err != nil {
+			// 		logging.Error("PostRJSBData  err: ", err)
+			// 		msg := geterrmsg(err.Error())
+			// 		appG.Response(http.StatusOK, e.ERROR, msg)
+			// 		return
+			// 	}
+
+			// 	for _, item := range datalist {
+			// 		id = item["id"]
+			// 	}
+			// 	s_params = append(s_params, id)
+			// } else {
+			// 	s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+			// }
 			s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
 		}
 	}
@@ -1228,9 +1256,30 @@ func PostRJSBData(c *gin.Context) {
 	paramslist = strings.Split(p2, ",")
 	if len(paramslist) > 0 && p2 != "" {
 		for _, value := range paramslist {
-			s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+
+			if value == "ID" {
+				id := parammaps.Get("ID").ValueStr()
+				pastureid := parammaps.Get("pastureid").ValueStr()
+				datalist, err := tx.SQL(`select d2.id as id from downloadplandtl1 d1 join downloadplandtl1_exec  d2 on d1.id = d2.id  where d1.pid =  (select pid  from downloadplandtl1 where id =  ? and pastureid = ? )  and 
+				d1.sort = (select sort  from downloadplandtl1 where id =  ? and pastureid = ? )`, id, pastureid, id, pastureid).QueryString()
+				if err != nil {
+					logging.Error("PostRJSBData  err: ", err)
+					msg := geterrmsg(err.Error())
+					appG.Response(http.StatusOK, e.ERROR, msg)
+					return
+				}
+
+				for _, item := range datalist {
+					id = item["id"]
+				}
+				s_params = append(s_params, id)
+			} else {
+				s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+			}
+
 		}
 	}
+
 	_, err = tx.SQL(sql2, s_params...).Execute()
 	if err != nil {
 		logging.Error("PostRJSBData2  err: ", err)
@@ -1309,6 +1358,25 @@ func PostRJSBDatas(c *gin.Context) {
 		paramslist = strings.Split(p1, ",")
 		if len(paramslist) > 0 && p1 != "" {
 			for _, value := range paramslist {
+				// if value == "ID" {
+				// 	id := parammaps.Get("ID").ValueStr()
+				// 	pastureid := parammaps.Get("pastureid").ValueStr()
+				// 	datalist, err := tx.SQL(`select d2.id as id from downloadplandtl1 d1 join downloadplandtl1_exec  d2 on d1.id = d2.id  where d1.pid =  (select pid  from downloadplandtl1 where id =  ? and pastureid = ? )  and
+				// 	d1.sort = (select sort  from downloadplandtl1 where id =  ? and pastureid = ? )`, id, pastureid, id, pastureid).QueryString()
+				// 	if err != nil {
+				// 		logging.Error("PostRJSBData  err: ", err)
+				// 		msg := geterrmsg(err.Error())
+				// 		appG.Response(http.StatusOK, e.ERROR, msg)
+				// 		return
+				// 	}
+
+				// 	for _, item := range datalist {
+				// 		id = item["id"]
+				// 	}
+				// 	s_params = append(s_params, id)
+				// } else {
+				// 	s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+				// }
 				s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
 			}
 		}
@@ -1324,7 +1392,26 @@ func PostRJSBDatas(c *gin.Context) {
 		paramslist = strings.Split(p2, ",")
 		if len(paramslist) > 0 && p2 != "" {
 			for _, value := range paramslist {
-				s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+				if value == "ID" {
+					id := parammaps.Get("ID").ValueStr()
+					pastureid := parammaps.Get("pastureid").ValueStr()
+					datalist, err := tx.SQL(`select d2.id as id from downloadplandtl1 d1 join downloadplandtl1_exec  d2 on d1.id = d2.id  where d1.pid =  (select pid  from downloadplandtl1 where id =  ? and pastureid = ? )  and 
+					d1.sort = (select sort  from downloadplandtl1 where id =  ? and pastureid = ? )`, id, pastureid, id, pastureid).QueryString()
+					if err != nil {
+						logging.Error("PostRJSBData  err: ", err)
+						msg := geterrmsg(err.Error())
+						appG.Response(http.StatusOK, e.ERROR, msg)
+						return
+					}
+
+					for _, item := range datalist {
+						id = item["id"]
+					}
+					s_params = append(s_params, id)
+				} else {
+					s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+				}
+				// s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
 			}
 		}
 		_, err = tx.SQL(sql2, s_params...).Execute()
@@ -1419,9 +1506,6 @@ func ExecDataByConfig(c *gin.Context) {
 				if _, ok := paramvalue["resultname"]; !ok {
 					paramvalue["resultname"] = paramvalue["name"]
 				}
-				fmt.Println(paramvalue, 1)
-				fmt.Println(tempCommon, 2)
-				fmt.Println(tempval, 3)
 				_, err = ExecDataParam(paramvalue, tempCommon, tempval, nil, nil, tx)
 				if err != nil {
 					logging.Error("ExecDataParam error:", err)
@@ -2127,6 +2211,7 @@ func ImportExcel(c *gin.Context) {
 			}
 			inputdata = ""
 			a := ""
+			fmt.Println(outentry, entry)
 			//校验日期格式
 			for _, v := range dateParamslist {
 				if v == "" {
@@ -2197,7 +2282,7 @@ func ImportExcel(c *gin.Context) {
 			err := tx.Begin()
 
 			for _, sqlnamestr := range sqlslist {
-				sql, paramslists := restful.GetSqlByNameDB(sqlnamestr)
+				sql, paramslists := restful.GetSqlByNameDB(strings.Replace(sqlnamestr, " ", "", -1))
 				paramslist := strings.Split(paramslists, ",")
 				if len(paramslist) > 0 {
 					s_params := make([]interface{}, 0)
@@ -2231,6 +2316,7 @@ func ImportExcel(c *gin.Context) {
 					}
 
 					outentry["input"] = inputdata
+					fmt.Println(sql, s_params)
 					returnmsgmap1, err := tx.SQL(sql, s_params...).Query().List()
 
 					if err != nil {
@@ -3045,7 +3131,7 @@ func UpdateFTdetail(c *gin.Context) {
 		order by t.barname,t.times`, parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"], parammaps["pastureid"], parammaps["ftid"], parammaps["ftid"]).Query().List()
 
 		lpplanList := make([]*lpplanStruct, 0)
-		err = tx.SQL(`select id,times,maxweight  from lpplan where pastureid = ? and ftid = ? and sel = 1 order by  sort desc`, parammaps["pastureid"], parammaps["ftid"]).Find(&lpplanList)
+		err = tx.SQL(`select id,times,maxweight  from lpplan where pastureid = ? and ftid = ? order by  sort desc`, parammaps["pastureid"], parammaps["ftid"]).Find(&lpplanList)
 		if err != nil {
 			logs.Error(err, 1)
 			return
@@ -3404,3 +3490,247 @@ func UpdateFpdetailBar(c *gin.Context) {
 	tx.Commit()
 	appG.Response(http.StatusOK, e.SUCCESS, true)
 }
+
+func GetProcessAnalysis(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	sqlnamestr := fsion.Get("name").ValueStr()
+	offset := fsion.Get("offset").ValueDefaultInt(0)
+	pagecount := fsion.Get("pagecount").ValueDefaultInt(0)
+	returntype := fsion.Get("returntype").ValueDefaultStr("map")
+
+	parammaps := fsion.Get("parammaps")
+
+	tx := restful.Engine.NewSession()
+	err := tx.Begin()
+	defer func() {
+		switch {
+		case err != nil:
+			logging.Error("tx.Begin 事务启动失败__error:", err)
+			if tx != nil {
+				tx.Rollback()
+			}
+		default:
+			if tx != nil {
+				err = tx.Commit()
+			}
+		}
+		if tx != nil {
+			tx.Close()
+		}
+	}()
+
+	sql, p := restful.GetSqlByNameDBT(sqlnamestr, tx)
+
+	s_params := make([]interface{}, 0)
+	paramslist := strings.Split(p, ",")
+	if len(paramslist) > 0 && p != "" {
+		for _, value := range paramslist {
+			if strings.ToLower(strings.Trim(value, " ")) == "jwt_username" {
+				if tempv, exists := c.Get("jwt_username"); exists {
+					s_params = append(s_params, tempv.(string))
+				} else {
+					s_params = append(s_params, "")
+				}
+			} else {
+				s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+			}
+		}
+	}
+	tmrtnameStr := ""
+	for _, tmr := range parammaps.Get("tmrtname").Array() {
+		if len(tmrtnameStr) == 0 {
+			tmrtnameStr = fmt.Sprintf("'%s'", tmr.ValueStr())
+		} else {
+			tmrtnameStr += fmt.Sprintf(",'%s'", tmr.ValueStr())
+		}
+	}
+	if len(tmrtnameStr) > 0 {
+		sql += fmt.Sprintf(" AND (d.`tmrtname` in (%s) ) ", tmrtnameStr)
+	}
+	sql += " ORDER BY d.intime"
+
+	queryData, err := getDataBySqlT(sql, offset, pagecount, returntype, s_params, tx)
+	if err != nil {
+		logging.Error("GetDataByName  err: ", err)
+		msg := geterrmsg(err.Error())
+		appG.Response(http.StatusOK, e.ERROR, msg)
+	} else {
+		appG.Response(http.StatusOK, e.SUCCESS, queryData)
+	}
+}
+
+func UpdateFeedtempletStatus(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	parammaps := fsion.Get("parammaps")
+
+	tx := restful.Engine.NewSession()
+	tx.Begin()
+
+	_, err := tx.SQL(fmt.Sprintf(" update feedtemplet  set enable = ? where id in (%s) ", parammaps.Get("id").ValueStr()), parammaps.Get("enable").ValueInt64()).Execute()
+	if err != nil {
+		tx.Rollback()
+		logs.Error(err)
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+	tx.Commit()
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+func AddFtdry(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	sqlnamestr := fsion.Get("name").ValueStr()
+
+	s_params := make([]interface{}, 0)
+	tx := restful.Engine.NewSession()
+	err := tx.Begin()
+	defer func() {
+		switch {
+		case err != nil:
+
+			if tx != nil {
+				tx.Rollback()
+			}
+		default:
+			if tx != nil {
+				err = tx.Commit()
+			}
+		}
+		if tx != nil {
+			tx.Close()
+		}
+	}()
+	sql, p := restful.GetSqlByNameDBT(sqlnamestr, tx)
+	if sql != "" {
+		parammaps := fsion.Get("parammaps")
+
+		logging.Info("AddFtdry ", c.Keys, c.Request.RemoteAddr, sqlnamestr, parammaps.ValueStr())
+		paramslist := strings.Split(p, ",")
+		if len(paramslist) > 0 && p != "" {
+			for _, value := range paramslist {
+				if strings.ToLower(strings.Trim(value, " ")) == "jwt_username" {
+					if tempv, exists := c.Get("jwt_username"); exists {
+						s_params = append(s_params, tempv.(string))
+					} else {
+						s_params = append(s_params, "")
+					}
+				} else if strings.ToLower(strings.Trim(value, " ")) == "snowid" {
+					ids, err := setting.SnowIds.NextId()
+					if err != nil {
+						ids = time.Now().UnixNano()
+						logging.Info("create SnowIds err", err)
+					}
+					s_params = append(s_params, ids)
+				} else {
+					s_params = append(s_params, parammaps.Get(strings.Trim(value, " ")).ValueStr())
+				}
+			}
+		}
+
+		var actweight float64
+		actweightList, err := tx.SQL(`select ROUND(avg(actweight),2) as actweight  from ftdry  
+	where barid in ( select barid from feedp where ftid in ( select ftid from feedp where barid = ? and pastureid = ?))  
+	and operatetime  = (select date_format(operatetime ,'%Y-%m-%d') from ftdry 
+	where barid  in ( select barid from feedp where ftid in ( select ftid from feedp where barid = ? and pastureid = ? )) 
+	and date_format(operatetime ,'%Y-%m-%d') <date_format(? ,'%Y-%m-%d')  and pastureid = ?
+	group by operatetime  order by operatetime desc  limit 1) and pastureid = ?`,
+			parammaps.Get("barid").ValueStr(), parammaps.Get("pastureid").ValueStr(), parammaps.Get("barid").ValueStr(), parammaps.Get("pastureid").ValueStr(), parammaps.Get("operatetime").ValueStr(), parammaps.Get("pastureid").ValueStr(), parammaps.Get("pastureid").ValueStr()).Query().List()
+		if err != nil {
+			logging.Error("AddFtdry  err: ", err)
+			msg := geterrmsg(err.Error())
+			appG.Response(http.StatusOK, e.ERROR, msg)
+		}
+		if len(actweightList) > 0 {
+			for _, item := range actweightList {
+				fl, err := strconv.ParseFloat(item["actweight"].(string), 64)
+				if err != nil {
+					logging.Error("AddFtdry  err: ", err)
+					msg := geterrmsg(err.Error())
+					appG.Response(http.StatusOK, e.ERROR, msg)
+				}
+				actweight = fl
+			}
+		} else {
+			dryList, err := tx.SQL(`select ifnull(dry,0.0) as dry from feednur  where fid in (select fid from  ftdetail  
+				where ftid = (select ftid from feedp where barid = ? and pastureid = ?)) and pastureid = ?`,
+				parammaps.Get("barid").ValueStr(), parammaps.Get("pastureid").ValueStr(), parammaps.Get("pastureid").ValueStr()).Query().List()
+			if err != nil {
+				logging.Error("AddFtdry  err: ", err)
+				msg := geterrmsg(err.Error())
+				appG.Response(http.StatusOK, e.ERROR, msg)
+			}
+			for _, item := range dryList {
+				dry, err := strconv.ParseFloat(item["dry"].(string), 64)
+				if err != nil {
+					logging.Error("AddFtdry  err: ", err)
+					msg := geterrmsg(err.Error())
+					appG.Response(http.StatusOK, e.ERROR, msg)
+				}
+				actweight += parammaps.Get("freshweight").ValueFloat64() * dry
+			}
+		}
+		if sqlnamestr == "insertFtdry" {
+			s_params = append(s_params, actweight)
+		} else if sqlnamestr == "updateFtdry" {
+			sql = fmt.Sprintf(sql, actweight)
+		}
+
+		queryData, err := execDataBySqlT(sql, s_params, tx)
+		if err != nil {
+			logging.Error("AddFtdry  err: ", err)
+			msg := geterrmsg(err.Error())
+			appG.Response(http.StatusOK, e.ERROR, msg)
+		} else {
+			appG.Response(http.StatusOK, e.SUCCESS, queryData)
+		}
+	} else {
+		appG.Response(http.StatusOK, e.SUCCESS, nil)
+	}
+}
+
+func CheckDates(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	dataList := fsion.Get("data").Array()
+
+	tx := restful.Engine.NewSession()
+	reqList := make([]map[string]interface{}, 0)
+
+	for _, fsion2 := range dataList {
+		s_params := make([]interface{}, 0)
+
+		sqlnamestr := fsion2.Get("sqlname").ValueStr()
+		sql, p := restful.GetSqlByNameDBT(sqlnamestr, tx)
+
+		parammaps := fsion2.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())
+			}
+		}
+
+		queryData, err := tx.SQL(sql, s_params...).QueryString()
+		if err != nil {
+			logging.Error("CheckDates  err: ", err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, err)
+			return
+		}
+
+		reqData := make(map[string]interface{}, 0)
+		for _, item := range queryData {
+			reqData["msg"] = item
+		}
+		reqData["sqlname"] = sqlnamestr
+		reqList = append(reqList, reqData)
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, reqList)
+}

+ 3 - 2
routers/api/lpplandtl.go

@@ -70,6 +70,7 @@ func GetLpplandtlDay(c *gin.Context) {
 	parammaps := fsion.Get("parammaps")
 	lpplanid := parammaps.Get("id").ValueStr()
 	pastureid := parammaps.Get("pastureid").ValueStr()
+	date := parammaps.Get("date").ValueStr()
 	// times := parammaps.Get("times").ValueInt64()
 
 	sqlStr := `SELECT
@@ -94,7 +95,7 @@ func GetLpplandtlDay(c *gin.Context) {
 		  lpplandtl1date as lpplandtl1
 		inner join  fpdetail
 		on  lpplandtl1.fpdid= fpdetail.id and lpplandtl1.pastureid = fpdetail.pastureid
-		WHERE lpplandtl1.pastureid = ?   and lpplandtl1.lweight>0 and lpplandtl1.lppid = ?
+		WHERE lpplandtl1.pastureid = ?   and lpplandtl1.lweight>0 and lpplandtl1.lppid = ? and lpplandtl1.date = ?
 		`
 	// sqlStr += " and times = ? "
 	sqlStr += " ORDER BY  lpplandtl1.sort"
@@ -102,7 +103,7 @@ func GetLpplandtlDay(c *gin.Context) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	data, err := tx.SQL(sqlStr, pastureid, lpplanid).QueryString()
+	data, err := tx.SQL(sqlStr, pastureid, lpplanid, date).QueryString()
 	if err != nil {
 		log.Println("GetLpplandtl-error-1: ", err)
 		appG.Response(http.StatusOK, e.ERROR, err)

+ 791 - 0
routers/api/spillage.go

@@ -1413,3 +1413,794 @@ GROUP BY fpd.ptsid`
 
 	appG.Response(http.StatusOK, e.SUCCESS, data)
 }
+
+func AddLpplandtl(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	parammaps := fsion.Get("parammaps")
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	exist := false
+	var err error
+
+	lpplandList := make([]*lpplandtl1, 0)
+	err = tx.Table("lpplandtl1").Select("id,pastureid,sort,barid,tmrid").Where("lppid = ? ", parammaps.Get("lppid").ValueStr()).And("pastureid = ?", parammaps.Get("pastureid").ValueStr()).
+		OrderBy("sort").Find(&lpplandList)
+	if err != nil {
+		log.Println("AddLpplandtl-error-1: ", err)
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	if parammaps.Get("id").ValueStr() != "" || parammaps.Get("id").ValueStr() != "0" {
+		for _, lppand := range lpplandList {
+			if lppand.Id == parammaps.Get("id").ValueInt64() {
+				if lppand.Tmrid == parammaps.Get("tmrid").ValueInt64() {
+					appG.Response(http.StatusOK, e.SUCCESS, true)
+					return
+				}
+				exist = true
+				break
+			}
+		}
+	}
+
+	tmrid := parammaps.Get("tmrid").ValueInt64()
+	var sort int64 = -1
+	if !exist {
+		for _, lppand := range lpplandList {
+			if lppand.Barid == parammaps.Get("barid").ValueInt64() {
+				_, err := tx.SQL(" update lpplandtl1 set lweight =lweight +  ?  where id = ?  and pastureid = ? ", parammaps.Get("lweight").ValueStr(), lppand.Id, parammaps.Get("pastureid").ValueStr()).Execute()
+				if err != nil {
+					log.Println("AddLpplandtl-error-2: ", err)
+					appG.Response(http.StatusOK, e.ERROR, err)
+					return
+				}
+				appG.Response(http.StatusOK, e.SUCCESS, true)
+				return
+			}
+		}
+		for i, lppand := range lpplandList {
+			lppand.Sort = int64(i) + 1
+		}
+		updateLpplandList := make([]*lpplandtl1, 0)
+		for i, lppand := range lpplandList {
+			n := i + 1
+			if lppand.Tmrid == tmrid {
+				sort = int64(n)
+				lppand.Sort = int64(n) + 1
+				updateLpplandList = append(updateLpplandList, lppand)
+			} else if sort > 0 {
+				lppand.Sort = int64(n) + 1
+				updateLpplandList = append(updateLpplandList, lppand)
+			}
+		}
+
+		tx.Begin()
+		for _, lppand := range updateLpplandList {
+			_, err := tx.SQL(" update lpplandtl1 set sort = ? where id = ?  and pastureid = ? ", lppand.Sort, lppand.Id, lppand.Pastureid).Execute()
+			if err != nil {
+				tx.Rollback()
+				log.Println("AddLpplandtl-error-2: ", err)
+				appG.Response(http.StatusOK, e.ERROR, err)
+				return
+			}
+		}
+
+		if sort < 0 && len(lpplandList) > 0 {
+			sort = int64(len(lpplandList) + 1)
+		} else if len(lpplandList) == 0 {
+			sort = 1
+		}
+
+		_, err = tx.SQL(`INSERT INTO lpplandtl1(pastureid,lppid,barid,barname,fpdid,lweight,sort,tmrid,tmrname,fttype,background,cowcount,ccountradio) 
+	VALUES (?,?,?,?,?,?,?,?,?,
+	?,?,IF(?='',0,?),IF(?='',0,?))`,
+			parammaps.Get("pastureid").ValueStr(),
+			parammaps.Get("lppid").ValueStr(),
+			parammaps.Get("barid").ValueStr(),
+			parammaps.Get("barname").ValueStr(),
+			parammaps.Get("fpdid").ValueStr(),
+			parammaps.Get("lweight").ValueStr(),
+			sort,
+			parammaps.Get("tmrid").ValueStr(),
+			parammaps.Get("tmrname").ValueStr(),
+			parammaps.Get("fttype").ValueStr(),
+			parammaps.Get("background").ValueStr(),
+			parammaps.Get("cowcount").ValueStr(),
+			parammaps.Get("cowcount").ValueStr(),
+			parammaps.Get("ccountradio").ValueStr(),
+			parammaps.Get("ccountradio").ValueStr()).Execute()
+		if err != nil {
+			tx.Rollback()
+			log.Println("AddLpplandtl-error-3: ", err)
+			appG.Response(http.StatusOK, e.ERROR, err)
+			return
+		}
+
+		err = tx.Commit()
+		if err != nil {
+			tx.Rollback()
+			log.Println("AddLpplandtl-error-6: ", err)
+			appG.Response(http.StatusOK, e.ERROR, err)
+			return
+		}
+	} else {
+		lpplandid := parammaps.Get("id").ValueInt64()
+		updateLpplandList := make([]*lpplandtl1, 0)
+		var oldsort int64
+		for i, lppand := range lpplandList {
+			lppand.Sort = int64(i) + 1
+		}
+		for _, lppand := range lpplandList {
+			if lppand.Id == lpplandid {
+				oldsort = lppand.Sort
+				break
+			}
+		}
+
+		for _, lppand := range lpplandList {
+
+			if lppand.Tmrid == tmrid && lppand.Id != lpplandid && sort < 0 {
+				sort = lppand.Sort
+				break
+			}
+		}
+
+		if sort == -1 {
+			sort = 1
+		}
+
+		if oldsort < sort {
+			for _, lppand := range lpplandList {
+				if lppand.Id != lpplandid && lppand.Sort > oldsort && lppand.Sort < sort {
+					lppand.Sort--
+					updateLpplandList = append(updateLpplandList, lppand)
+				} else if lppand.Sort > sort && lppand.Id != lpplandid {
+					lppand.Sort++
+					updateLpplandList = append(updateLpplandList, lppand)
+				}
+			}
+			sort--
+		} else {
+			for _, lppand := range lpplandList {
+				if lppand.Sort < oldsort && lppand.Sort >= sort && lppand.Id != lpplandid {
+					lppand.Sort++
+					updateLpplandList = append(updateLpplandList, lppand)
+				}
+			}
+		}
+
+		var tmrlpplandList []*lpplandtl1
+		for _, lppand := range lpplandList {
+			exist := false
+			for _, lppand1 := range updateLpplandList {
+				if lppand.Id == lppand1.Id {
+					exist = true
+					break
+				}
+			}
+			if !exist {
+				tmrlpplandList = append(tmrlpplandList, lppand)
+			}
+		}
+
+		updateLpplandList = append(updateLpplandList, tmrlpplandList...)
+		if len(updateLpplandList) > 0 {
+			tx.Begin()
+			for _, lppand := range updateLpplandList {
+				_, err := tx.SQL(" update lpplandtl1 set sort = ? where id = ?  and pastureid = ? ", lppand.Sort, lppand.Id, lppand.Pastureid).Execute()
+				if err != nil {
+					tx.Rollback()
+					log.Println("AddLpplandtl-error-2: ", err)
+					appG.Response(http.StatusOK, e.ERROR, err)
+					return
+				}
+			}
+
+			_, err := tx.SQL(" update lpplandtl1 set tmrid = ? , tmrname = ?,sort = ?   where id = ?  and pastureid = ? ", parammaps.Get("tmrid").ValueStr(), parammaps.Get("tmrname").ValueStr(), sort, lpplandid, parammaps.Get("pastureid").ValueStr()).Execute()
+			if err != nil {
+				tx.Rollback()
+				log.Println("AddLpplandtl-error-2: ", err)
+				appG.Response(http.StatusOK, e.ERROR, err)
+				return
+			}
+
+			tx.Commit()
+		}
+
+	}
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+func UpdateLpplandtlSort(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	parammaps := fsion.Get("parammaps")
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	var err error
+
+	lpplandList := make([]*lpplandtl1, 0)
+	err = tx.Table("lpplandtl1").Select("id,pastureid,sort,tmrid").Where("lppid = ? ", parammaps.Get("lppid").ValueStr()).And("pastureid = ?", parammaps.Get("pastureid").ValueStr()).
+		OrderBy("sort").Find(&lpplandList)
+	if err != nil {
+		log.Println("UpdateLpplandtlSort-error-1: ", err)
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+	var oldsort int64
+	tmrid := parammaps.Get("tmrid").ValueInt64()
+	sort := parammaps.Get("sort").ValueInt64()
+
+	for i, lppland := range lpplandList {
+		lppland.Sort = int64(i) + 1
+	}
+
+	for _, lppland := range lpplandList {
+		if tmrid == lppland.Tmrid {
+			oldsort = lppland.Sort
+			break
+		}
+	}
+
+	for _, lppland := range lpplandList {
+		if lppland.Sort == sort {
+			for _, lppland1 := range lpplandList {
+				if lppland.Tmrid == lppland1.Tmrid {
+					sort = lppland1.Sort
+					if oldsort > sort {
+						break
+					}
+				}
+			}
+			break
+		}
+	}
+
+	if oldsort == sort {
+		appG.Response(http.StatusOK, e.SUCCESS, true)
+		return
+	}
+
+	tmrLpplandList := make([]*lpplandtl1, 0)
+	for _, lppland := range lpplandList {
+		if lppland.Tmrid == tmrid {
+			tmrLpplandList = append(tmrLpplandList, lppland)
+		}
+	}
+
+	for i, tmrLppland := range tmrLpplandList {
+		tmrLppland.Sort = sort + int64(i)
+	}
+
+	if oldsort > sort {
+		for _, lppland := range lpplandList {
+			if lppland.Sort == sort {
+				// uptmrid = lppland.Tmrid
+				sort = lppland.Sort
+				break
+			}
+		}
+	} else {
+		var uptmrid int64
+		for _, lppland := range lpplandList {
+			if lppland.Sort == sort {
+				uptmrid = lppland.Tmrid
+				sort = lppland.Sort
+			} else if uptmrid != 0 && uptmrid == lppland.Tmrid {
+				sort = lppland.Sort
+			}
+		}
+	}
+
+	upcount := int64(len(tmrLpplandList))
+	if oldsort > sort {
+		for _, lppland := range lpplandList {
+
+			if lppland.Sort >= sort && lppland.Tmrid != tmrid {
+				lppland.Sort += upcount
+				tmrLpplandList = append(tmrLpplandList, lppland)
+			}
+		}
+	} else {
+		for _, lppland := range lpplandList {
+			if lppland.Sort <= sort && lppland.Sort >= oldsort && lppland.Tmrid != tmrid {
+				lppland.Sort -= upcount
+				tmrLpplandList = append(tmrLpplandList, lppland)
+			}
+		}
+	}
+
+	updateLpplandList := make([]*lpplandtl1, 0)
+	for _, lppland := range lpplandList {
+		exist := false
+		for _, tmrLppland := range tmrLpplandList {
+			if lppland.Id == tmrLppland.Id {
+				exist = true
+				break
+			}
+		}
+
+		if !exist {
+			updateLpplandList = append(updateLpplandList, lppland)
+		}
+	}
+
+	tmrLpplandList = append(tmrLpplandList, updateLpplandList...)
+
+	tx.Begin()
+	// _, err = tx.Table("lpplandtl1").Update(&tmrLpplandList)
+
+	var wg sync.WaitGroup
+	for _, lppland := range tmrLpplandList {
+		wg.Add(1)
+		go func(lppland *lpplandtl1) {
+			defer wg.Done()
+			_, err = tx.SQL(`update  lpplandtl1 set sort = ?  where id = ? and pastureid = ? `, lppland.Sort, lppland.Id, lppland.Pastureid).Execute()
+			if err != nil {
+				log.Println("UpdateLpplandtlSort-error-2: ", err)
+				tx.Rollback()
+				appG.Response(http.StatusOK, e.ERROR, err)
+				return
+			}
+
+		}(lppland)
+	}
+	wg.Wait()
+
+	err = tx.Commit()
+	if err != nil {
+		log.Println("UpdateLpplandtlSort-error-3: ", err)
+		tx.Rollback()
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+func AddLpplandtlDate(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	parammaps := fsion.Get("parammaps")
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	exist := false
+	var err error
+
+	lpplandList := make([]*lpplandtl1, 0)
+	err = tx.Table("lpplandtl1date").Select("id,pastureid,sort,barid,tmrid").Where("lppid = ? ", parammaps.Get("lppid").ValueStr()).And("pastureid = ?", parammaps.Get("pastureid").ValueStr()).
+		And("date = ? ", parammaps.Get("date").ValueStr()).OrderBy("sort").Find(&lpplandList)
+	if err != nil {
+		log.Println("AddLpplandtl-error-1: ", err)
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	if parammaps.Get("id").ValueStr() != "" || parammaps.Get("id").ValueStr() != "0" {
+		for _, lppand := range lpplandList {
+			fmt.Println(parammaps.Get("id").ValueInt64())
+			if lppand.Id == parammaps.Get("id").ValueInt64() {
+				if lppand.Tmrid == parammaps.Get("tmrid").ValueInt64() {
+					appG.Response(http.StatusOK, e.SUCCESS, true)
+					return
+				}
+				exist = true
+				break
+			}
+		}
+	}
+
+	tmrid := parammaps.Get("tmrid").ValueInt64()
+	var sort int64 = -1
+	if !exist {
+		for _, lppand := range lpplandList {
+			if lppand.Barid == parammaps.Get("barid").ValueInt64() {
+				_, err := tx.SQL(" update lpplandtl1date set lweight =lweight + ?  where id = ?  and pastureid = ? ", parammaps.Get("lweight").ValueStr(), lppand.Id, parammaps.Get("pastureid").ValueStr()).Execute()
+				if err != nil {
+					log.Println("AddLpplandtl-error-2: ", err)
+					appG.Response(http.StatusOK, e.ERROR, err)
+					return
+				}
+				appG.Response(http.StatusOK, e.SUCCESS, true)
+				return
+			}
+		}
+		for i, lppand := range lpplandList {
+			lppand.Sort = int64(i) + 1
+		}
+		updateLpplandList := make([]*lpplandtl1, 0)
+		for i, lppand := range lpplandList {
+			n := i + 1
+			if lppand.Tmrid == tmrid {
+				sort = int64(n)
+				lppand.Sort = int64(n) + 1
+				updateLpplandList = append(updateLpplandList, lppand)
+			} else if sort > 0 {
+				lppand.Sort = int64(n) + 1
+				updateLpplandList = append(updateLpplandList, lppand)
+			}
+		}
+		tx.Begin()
+		for _, lppand := range updateLpplandList {
+			_, err := tx.SQL(" update lpplandtl1date set sort = ? where id = ?  and pastureid = ? and date = ? ", lppand.Sort, lppand.Id, lppand.Pastureid, parammaps.Get("date").ValueStr()).Execute()
+			if err != nil {
+				tx.Rollback()
+				log.Println("AddLpplandtl-error-2: ", err)
+				appG.Response(http.StatusOK, e.ERROR, err)
+				return
+			}
+		}
+
+		if sort < 0 && len(lpplandList) > 0 {
+			sort = int64(len(lpplandList) + 1)
+		} else if len(lpplandList) == 0 {
+			sort = 1
+		}
+
+		_, err = tx.SQL(`INSERT INTO lpplandtl1date(pastureid,lppid,barid,barname,fpdid,lweight,sort,tmrid,tmrname,fttype,background,cowcount,ccountradio,date) 
+	VALUES (?,?,?,?,?,?,?,?,?,
+	?,?,IF(?='',0,?),IF(?='',0,?),?)`,
+			parammaps.Get("pastureid").ValueStr(),
+			parammaps.Get("lppid").ValueStr(),
+			parammaps.Get("barid").ValueStr(),
+			parammaps.Get("barname").ValueStr(),
+			parammaps.Get("fpdid").ValueStr(),
+			parammaps.Get("lweight").ValueStr(),
+			sort,
+			parammaps.Get("tmrid").ValueStr(),
+			parammaps.Get("tmrname").ValueStr(),
+			parammaps.Get("fttype").ValueStr(),
+			parammaps.Get("background").ValueStr(),
+			parammaps.Get("cowcount").ValueStr(),
+			parammaps.Get("cowcount").ValueStr(),
+			parammaps.Get("ccountradio").ValueStr(),
+			parammaps.Get("ccountradio").ValueStr(),
+			parammaps.Get("date").ValueStr()).Execute()
+		if err != nil {
+			tx.Rollback()
+			log.Println("AddLpplandtl-error-3: ", err)
+			appG.Response(http.StatusOK, e.ERROR, err)
+			return
+		}
+
+		err = tx.Commit()
+		if err != nil {
+			tx.Rollback()
+			log.Println("AddLpplandtl-error-6: ", err)
+			appG.Response(http.StatusOK, e.ERROR, err)
+			return
+		}
+	} else {
+		lpplandid := parammaps.Get("id").ValueInt64()
+		updateLpplandList := make([]*lpplandtl1, 0)
+		var oldsort int64
+		for i, lppand := range lpplandList {
+			lppand.Sort = int64(i) + 1
+		}
+
+		for _, lppand := range lpplandList {
+			if lppand.Id == lpplandid {
+				oldsort = lppand.Sort
+				break
+			}
+		}
+
+		for _, lppand := range lpplandList {
+
+			if lppand.Tmrid == tmrid && lppand.Id != lpplandid && sort < 0 {
+				sort = lppand.Sort
+				break
+			}
+		}
+
+		if sort == -1 {
+			sort = 1
+		}
+
+		if oldsort < sort {
+			for _, lppand := range lpplandList {
+				if lppand.Id != lpplandid && lppand.Sort > oldsort && lppand.Sort < sort {
+					lppand.Sort--
+					updateLpplandList = append(updateLpplandList, lppand)
+				} else if lppand.Sort > sort && lppand.Id != lpplandid {
+					lppand.Sort++
+					updateLpplandList = append(updateLpplandList, lppand)
+				}
+			}
+			sort--
+		} else {
+			for _, lppand := range lpplandList {
+				if lppand.Sort < oldsort && lppand.Sort >= sort && lppand.Id != lpplandid {
+					lppand.Sort++
+					updateLpplandList = append(updateLpplandList, lppand)
+				}
+			}
+		}
+
+		var tmrlpplandList []*lpplandtl1
+		for _, lppand := range lpplandList {
+			exist := false
+			for _, lppand1 := range updateLpplandList {
+				if lppand.Id == lppand1.Id {
+					exist = true
+					break
+				}
+			}
+			if !exist {
+				tmrlpplandList = append(tmrlpplandList, lppand)
+			}
+		}
+
+		updateLpplandList = append(updateLpplandList, tmrlpplandList...)
+		if len(updateLpplandList) > 0 {
+			tx.Begin()
+			for _, lppand := range updateLpplandList {
+				_, err := tx.SQL(" update lpplandtl1date set sort = ? where id = ?  and pastureid = ?  ", lppand.Sort, lppand.Id, lppand.Pastureid).Execute()
+				if err != nil {
+					tx.Rollback()
+					log.Println("AddLpplandtl-error-2: ", err)
+					appG.Response(http.StatusOK, e.ERROR, err)
+					return
+				}
+			}
+
+			_, err := tx.SQL(" update lpplandtl1date set tmrid = ? , tmrname = ?,sort = ?  where id = ?  and pastureid = ?  ", parammaps.Get("tmrid").ValueStr(), parammaps.Get("tmrname").ValueStr(), sort, lpplandid, parammaps.Get("pastureid").ValueStr()).Execute()
+			if err != nil {
+				tx.Rollback()
+				log.Println("AddLpplandtl-error-2: ", err)
+				appG.Response(http.StatusOK, e.ERROR, err)
+				return
+			}
+
+			tx.Commit()
+		}
+
+	}
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+func UpdateLpplandtlDateSort(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	parammaps := fsion.Get("parammaps")
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	var err error
+
+	lpplandList := make([]*lpplandtl1, 0)
+	err = tx.Table("lpplandtl1date").Select("id,pastureid,sort,tmrid").Where("lppid = ? ", parammaps.Get("lppid").ValueStr()).And("pastureid = ?", parammaps.Get("pastureid").ValueStr()).
+		And("date = ? ", parammaps.Get("date").ValueStr()).OrderBy("sort").Find(&lpplandList)
+	if err != nil {
+		log.Println("UpdateLpplandtlSort-error-1: ", err)
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+	var oldsort int64
+	tmrid := parammaps.Get("tmrid").ValueInt64()
+	sort := parammaps.Get("sort").ValueInt64()
+
+	for i, lppland := range lpplandList {
+		lppland.Sort = int64(i) + 1
+	}
+
+	for _, lppland := range lpplandList {
+		if tmrid == lppland.Tmrid {
+			oldsort = lppland.Sort
+			break
+		}
+	}
+
+	for _, lppland := range lpplandList {
+		if lppland.Sort == sort {
+			for _, lppland1 := range lpplandList {
+				if lppland.Tmrid == lppland1.Tmrid {
+					sort = lppland1.Sort
+					if oldsort > sort {
+						break
+					}
+				}
+			}
+			break
+		}
+	}
+
+	if oldsort == sort {
+		appG.Response(http.StatusOK, e.SUCCESS, true)
+		return
+	}
+
+	tmrLpplandList := make([]*lpplandtl1, 0)
+	for _, lppland := range lpplandList {
+		if lppland.Tmrid == tmrid {
+			tmrLpplandList = append(tmrLpplandList, lppland)
+		}
+	}
+
+	for i, tmrLppland := range tmrLpplandList {
+		tmrLppland.Sort = sort + int64(i)
+	}
+
+	if oldsort > sort {
+		for _, lppland := range lpplandList {
+			if lppland.Sort == sort {
+				// uptmrid = lppland.Tmrid
+				sort = lppland.Sort
+				break
+			}
+		}
+	} else {
+		var uptmrid int64
+		for _, lppland := range lpplandList {
+			if lppland.Sort == sort {
+				uptmrid = lppland.Tmrid
+				sort = lppland.Sort
+			} else if uptmrid != 0 && uptmrid == lppland.Tmrid {
+				sort = lppland.Sort
+			}
+		}
+	}
+
+	upcount := int64(len(tmrLpplandList))
+	if oldsort > sort {
+		for _, lppland := range lpplandList {
+
+			if lppland.Sort >= sort && lppland.Tmrid != tmrid {
+				lppland.Sort += upcount
+				tmrLpplandList = append(tmrLpplandList, lppland)
+			}
+		}
+	} else {
+		for _, lppland := range lpplandList {
+			if lppland.Sort <= sort && lppland.Sort >= oldsort && lppland.Tmrid != tmrid {
+				lppland.Sort -= upcount
+				tmrLpplandList = append(tmrLpplandList, lppland)
+			}
+		}
+	}
+
+	updateLpplandList := make([]*lpplandtl1, 0)
+	for _, lppland := range lpplandList {
+		exist := false
+		for _, tmrLppland := range tmrLpplandList {
+			if lppland.Id == tmrLppland.Id {
+				exist = true
+				break
+			}
+		}
+
+		if !exist {
+			updateLpplandList = append(updateLpplandList, lppland)
+		}
+	}
+
+	tmrLpplandList = append(tmrLpplandList, updateLpplandList...)
+
+	tx.Begin()
+	// _, err = tx.Table("lpplandtl1").Update(&tmrLpplandList)
+
+	var wg sync.WaitGroup
+	for _, lppland := range tmrLpplandList {
+		wg.Add(1)
+		go func(lppland *lpplandtl1) {
+			defer wg.Done()
+			_, err = tx.SQL(`update  lpplandtl1date set sort = ?  where id = ? and pastureid = ? `, lppland.Sort, lppland.Id, lppland.Pastureid).Execute()
+			if err != nil {
+				log.Println("UpdateLpplandtlSort-error-2: ", err)
+				tx.Rollback()
+				appG.Response(http.StatusOK, e.ERROR, err)
+				return
+			}
+
+		}(lppland)
+	}
+	wg.Wait()
+
+	err = tx.Commit()
+	if err != nil {
+		log.Println("UpdateLpplandtlSort-error-3: ", err)
+		tx.Rollback()
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+func GetFeedpUndistributed(c *gin.Context) {
+	appG := app.Gin{C: c}
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsion := gofasion.NewFasion(string(dataByte))
+	timesMax := fsion.Get("times").ValueInt()
+	pastureid := fsion.Get("pastureid").ValueStr()
+
+	data := make(map[string]interface{})
+	for times := 1; times <= timesMax; times++ {
+		sqlStr := `SELECT trim(feedp.pastureid) pastureid,barname,trim(barid) barid,trim(ftid) arrid,1 as type,? as times,ft.tname ftname,ft.tcolor  background,0 isfill FROM feedp 
+	inner join  feedtemplet ft
+on ft.id = feedp.ftid and  ft.pastureid=?
+WHERE feedp.pastureid = ? 
+GROUP BY feedp.ftid
+UNION
+SELECT trim(feedp.pastureid) pastureid,barname,barid,trim(ptsfid) arrid,0 as type,? as times,ft.tname ptsfname ,ft.tcolor  background,1 isfill  FROM feedp
+inner join  feedtemplet ft
+on ft.id = feedp.ptsfid and  ft.pastureid=?
+WHERE feedp.pastureid = ?   and  (SELECT inforvalue FROM sysopt WHERE sysopt.pastureid=feedp.pastureid AND sysopt.inforname= 'isEnableSupplyFeed') = 1
+GROUP BY feedp.ptsfid`
+
+		ftList, err := tx.SQL(sqlStr, times, pastureid, pastureid, times, pastureid, pastureid).Query().List()
+		if err != nil {
+			log.Println("GetFeedpUndistributed-error-1: ", err)
+			appG.Response(http.StatusOK, e.ERROR, nil)
+			return
+		}
+
+		ftDetailList, err := tx.SQL(`SELECT TRIM(id) id,times,tratio,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 times=? AND  ptsuse< ROUND(ptsrate*weight,2) 
+UNION
+SELECT TRIM(id) id,times,tratio,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 times=? AND ptuse<ROUND((1-ptsrate)*weight,2)
+ORDER BY  barid`, pastureid, times, pastureid, times).Query().List()
+		if err != nil {
+			log.Println("GetFeedpUndistributed-error-2: ", err)
+			appG.Response(http.StatusOK, e.ERROR, nil)
+			return
+		}
+
+		for _, ft := range ftList {
+			arrList := make([]map[string]interface{}, 0)
+			arrid := ft["arrid"].(string)
+			for _, detail := range ftDetailList {
+				if _, ok := detail["ptid"]; ok {
+					if arrid == detail["ptid"].(string) && ft["isfill"].(int64) == detail["isfill"].(int64) {
+						detail["background"] = ft["background"]
+						arrList = append(arrList, detail)
+					}
+				} else if _, ok := detail["ptsid"]; ok {
+					if arrid == detail["ptsid"].(string) && ft["isfill"].(int64) == detail["isfill"].(int64) {
+						detail["background"] = ft["background"]
+						arrList = append(arrList, detail)
+					}
+				}
+			}
+			if len(arrList) > 0 {
+				ft["arrList"] = arrList
+			}
+		}
+		var key string
+		if times == 1 {
+			key = "one"
+		} else if times == 2 {
+			key = "two"
+		} else if times == 3 {
+			key = "three"
+		} else if times == 4 {
+			key = "four"
+		} else if times == 5 {
+			key = "five"
+		} else {
+			key = "six"
+		}
+
+		data[key] = ftList
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, data)
+}

+ 13 - 11
routers/api/udsync.go

@@ -17,7 +17,7 @@ import (
 	"github.com/robfig/cron"
 )
 
-func zasUDSync() {
+func UDSync() {
 
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
@@ -396,7 +396,7 @@ func UDFeedtempletinfo(token, pastureid string) {
 	sqlstr := `SELECT
 	ft.ID AS recipeId,
 	ft.TNAME AS recipeName,
-	f.id AS ingId,
+	f.feedcode AS ingId,
 	f.FNAME AS ingName,
 	round( f.dry * ftd.FWEIGHT, 2 ) AS dmQty,
 	ftd.FWEIGHT AS afQty,
@@ -407,7 +407,7 @@ func UDFeedtempletinfo(token, pastureid string) {
 FROM
 	feedtemplet ft
 	LEFT JOIN ftdetail ftd ON ft.id = ftd.FTID
-	LEFT JOIN feed f ON ftd.FID = f.id
+	LEFT JOIN feed f ON ftd.FID = f.id and  ft.pastureid = f.pastureid
 	LEFT JOIN feedclass fc ON f.FCLASS = fc.id  where ft.pastureid = ? `
 
 	data, err := tx.SQL(sqlstr, pastureid).Query().List()
@@ -441,30 +441,30 @@ func UDUploadadddata(token, pastureid string) {
 	sqlstr := `select  date_format(d.mydate,'%Y-%m-%d') loadDate,d.SORT tmrNo,d.Times loadShift,
 	IFNULL(ft.id,((SELECT feedtempletid FROM downloadplandtl2 d2 WHERE d2.pid=d.id LIMIT 1))) recipeId, 
 	IFNULL(d.templetName ,((SELECT feedtempletName FROM downloadplandtl2 d2 WHERE d2.pid=d.id LIMIT 1))) recipeName, 
-	ifnull(de1.Fid,"") as ingId,de.Fname as ingName,ifnull(fc.FCNAME,"")  ingType,
+	ifnull(f.feedcode,"") as ingId,de.Fname as ingName,ifnull(fc.FCNAME,"")  ingType,
 	ifnull(f.dry,"") dmPct,de.SORT mixNo,de.feedallowratio allowableError, de.LWEIGHT expWeight,
 	de.ActualWeightMinus actualWeight,ifnull(date_format(timestamp(de.InTime,CONCAT('-',de.processTime)),'%Y-%m-%d %H:%i:%s'),"") startTime,
 	date_format(de.InTime,'%Y-%m-%d %H:%i:%s') endTime,ifnull((SELECT dr.driver FROM dutyrecord dr 
 WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times  AND dr.operatetime <=d.mydate 
 ORDER BY dr.operatetime DESC LIMIT 1),"") tmrName ,d.tmrtname equipmentId 
 	from downloadedplan d LEFT JOIN downloadplandtl1_exec de on d.id=de.PID 
-	left join downloadplandtl1 de1 on de1.id = d.id
-	LEFT JOIN feed f on de1.Fid=f.id LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME 
+	left join downloadplandtl1 de1 on de1.pid = d.id
+	LEFT JOIN feed f on de1.Fid=f.id and f.pastureid = de1.pastureid LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME 
 	LEFT JOIN feedclass fc on f.FCLASS=fc.id 
 	where d.mydate=date_format(NOW(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType=0  and d.pastureid = ?	
 union all
 select  date_format(d.mydate,'%Y-%m-%d') loadDate,d.SORT tmrNo,d.Times loadShift,
 	IFNULL(ft.id,((SELECT feedtempletid FROM downloadplandtl2 d2 WHERE d2.flpid=d.id LIMIT 1))) recipeId, 
 	IFNULL(d.templetName ,((SELECT feedtempletName FROM downloadplandtl2 d2 WHERE d2.flpid=d.id LIMIT 1))) recipeName, 
-	ifnull(de1.Fid,"") as ingId,de.Fname as ingName,ifnull(fc.FCNAME,"")  ingType,
+	ifnull(f.feedcode,"") as ingId,de.Fname as ingName,ifnull(fc.FCNAME,"")  ingType,
 	ifnull(f.dry,"") dmPct,de.SORT mixNo,de.feedallowratio allowableError, de.LWEIGHT expWeight,
 	de.ActualWeightMinus actualWeight,ifnull(date_format(timestamp(de.InTime,CONCAT('-',de.processTime)),'%Y-%m-%d %H:%i:%s'),"") startTime,
 	date_format(de.InTime,'%Y-%m-%d %H:%i:%s') endTime,ifnull((SELECT dr.driver FROM dutyrecord dr 
 WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times  AND dr.operatetime <=d.mydate 
 ORDER BY dr.operatetime DESC LIMIT 1),"") tmrName ,d.tmrtname equipmentId 
 	from downloadedplan d LEFT JOIN downloadplandtl1_exec de on d.id=de.PID 
-			 left join downloadplandtl1 de1 on de1.id = d.id
-	LEFT JOIN feed f on de1.Fid=f.id LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME 
+			 left join downloadplandtl1 de1 on de1.pid = d.id
+	LEFT JOIN feed f on de1.Fid=f.id and f.pastureid = de1.pastureid LEFT JOIN feedtemplet ft on d.templetName=ft.TNAME 
 	LEFT JOIN feedclass fc on f.FCLASS=fc.id 
 	where d.mydate=date_format(NOW(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType=1 and d.pastureid = ?
 ORDER BY mixNo `
@@ -496,7 +496,7 @@ func UDUploaddiliverdata(token, pastureid string) {
 	IFNULL(ft.id,d2.feedtempletid ) recipeId, 
 	IFNULL(d.templetName,d2.feedtempletName ) recipeName, 
 	date_format(d.mydate,'%Y-%m-%d') as dropDate,d.SORT as tmrNo,
-	d.Times as dropShift,d2.FBarID as penId,d2.Fname as penName,fp.CCOUNT as cowCount, d2.SORT as feedingNo, d2.LWEIGHT as expWeight,
+	d.Times as dropShift,b.bcode as penId,d2.Fname as penName,fp.CCOUNT as cowCount, d2.SORT as feedingNo, d2.LWEIGHT as expWeight,
 	d2.ActualWeightMinus as actualWeight, ifnull(date_format(timestamp(d2.InTime,CONCAT('-',d2.processTime)),'%Y-%m-%d %H:%i:%s'),"") as startTime,
 	date_format(d2.InTime,'%Y-%m-%d %H:%i:%s') as endTime,ifnull((SELECT dr.driver FROM dutyrecord dr 
 WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times  AND dr.operatetime <=d.mydate 
@@ -504,6 +504,7 @@ ORDER BY dr.operatetime DESC LIMIT 1),"") as tmrName ,d.tmrtname equipmentId
 	from  downloadedplan d 
 	LEFT JOIN downloadplandtl2 d2 on d.id=d2.PID 
 	LEFT JOIN feedp fp on d2.FBarID=fp.id 
+	left join bar b on fp.barid = b.id and d.pastureid = b.pastureid
 	left JOIN feedtemplet ft on d.templetName=ft.TNAME 
 	where d.mydate= date_format(NOW(),'%Y-%m-%d') and d.IsCompleted=1 and d.lpplanType!=1 and d.pastureid = ? `
 
@@ -542,12 +543,13 @@ func UDUploadoverplusdata(token, pastureid string) {
 	'' startTime,
 	'' endTime,
 	ifnull(br.RemainDate,"") AS overplusDate,
-	br.barid AS penId,  
+	b.bcode AS penId,  
 	fp.barname AS penName,
 	ifnull(br.Remain,"") AS actualWeight 
 FROM
 	barfeedremain br
 	LEFT JOIN feedp fp ON br.barid = fp.id 
+	left join bar b on fp.barid = b.id
 WHERE
 	RemainDate =  date_format(NOW(),'%Y-%m-%d') and br.pastureid = ? `
 

+ 0 - 3
routers/restful/sql_utils.go

@@ -467,9 +467,6 @@ func QueryByMapT(sqlstr string, offset, count int, params []interface{}, tx *xor
 		queryData, err = tx.SQL(sqlstr, params...).Limit(count, offset).Query().List()
 	}
 	//fmt.Println("count, offset==================",count, offset)
-	for _, item := range queryData {
-		fmt.Println(item)
-	}
 	if err != nil {
 		return nil, err
 	}

+ 12 - 1
routers/router.go

@@ -152,9 +152,20 @@ func InitRouter() *gin.Engine {
 
 		apiV1.POST("/summary", api.GetSummary)
 
-		//
 		apiV1.POST("/ftdetail/edit", api.UpdateFTdetail)
 		apiV1.POST("/fpdetail/edit", api.UpdateFpdetailBar)
+		apiV1.POST("/lpplandtl/add", api.AddLpplandtl)
+		apiV1.POST("/lpplandtl/edit/sort", api.UpdateLpplandtlSort)
+		apiV1.POST("/lpplandtl/date/add", api.AddLpplandtlDate)
+		apiV1.POST("/lpplandtl/edit/date/sort", api.UpdateLpplandtlDateSort)
+		apiV1.POST("/processAnalysist", api.GetProcessAnalysis)
+
+		apiV1.POST("/feedp/undistribute", api.GetFeedpUndistributed)
+
+		apiV1.POST("/feedtemplet/enable", api.UpdateFeedtempletStatus)
+
+		apiV1.POST("/ftdry/add", api.AddFtdry)
+		apiV1.POST("/checkDates", api.CheckDates)
 
 	}
 

+ 17 - 1
update.sql

@@ -24,6 +24,13 @@ alter table fpdetail
 -- ORDER BY fn.sort DESC
 
 
+ update
+  (SELECT @rownum:=0)r ,bar fn
+  set fn.sort =  @rownum := @rownum+1 
+ WHERE fn.pastureid = 1648637190 
+ ORDER BY fn.id DESC
+
+
 -- 宾州筛bug
 -- `barid`, `times`, `operatetime` 唯一索引
 -- 宾州筛历史记录表
@@ -85,4 +92,13 @@ CREATE TABLE `dungandbodyhistory` (
 ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
 
 -- 增加牲畜类别其他
-INSERT INTO `tmrwatch2`.`dictlist`(`pid`, `label`, `value`, `orderby`) VALUES (17, '其他', '6', 6)
+INSERT INTO `tmrwatch2`.`dictlist`(`pid`, `label`, `value`, `orderby`) VALUES (17, '其他', '6', 6)
+
+
+
+
+
+downloadplandtl2   `pastureid`, `pid`   索引
+
+
+feedpdate  调整索引顺序 `pastureid`, `date`, `barid`

BIN
uploads.zip


+ 5 - 0
uploads/dist.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+rm -rf dist
+unzip dist.zip
+

BIN
uploads/file/导入导出模板/基础数据/饲料导入模板.xlsx


+ 7 - 0
uploads/tmrgo.sh

@@ -0,0 +1,7 @@
+!/bin/sh
+
+unzip tmrgo.zip
+chmod +X tmrgo
+rm -f TMRWatchComm
+rm -f tmrgo.zip
+mv tmrgo TMRWatchComm

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است