baishaojie 4 dní pred
rodič
commit
969d1a7916

BIN
KPTAdmin64.exe


BIN
TMRWatchComm


BIN
TMRWatchComm.zip


+ 11 - 7
conf/app-test.ini

@@ -21,7 +21,7 @@ TimeFormat = 20060102-150405
 #debug or release
 #RunMode = debuggit 
 RunMode = release
-HttpPort = 8082
+HttpPort = 8081
 ReadTimeout = 60
 WriteTimeout = 60
 NoAuth = 1
@@ -39,7 +39,7 @@ DisplayName = tmrgo
 Description = tmrgo
 UDForwardingSvc = "http://192.168.8.250"
 # 0 无同步 1 圣牧+云养牛mqtt 2 现代牧业+云养牛mqtt 3 新希望 4 乐源 5 光明ud 6 多语言京鹏ud 7 一牧云 8 云养牛mqtt
-SyncStatus = 9
+SyncStatus = 0
 # 对接
 GRFD = 1
 #GRFDURL = http://120.48.30.31:88
@@ -77,7 +77,7 @@ Password = root
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = yq2
+Name = tn
 TablePrefix =
 
 ShowXormlog = false
@@ -95,12 +95,15 @@ Name =
 
 
 
+
 [yyn]
-FarmId = "1830005373"
+FarmId = "1830005393"
 ProductKey = "k03txxLKFae"
-DeviceName = "05373_p_breed"
-DeviceSecret = "c67a1996c9aa40732753de57c67a8c69"
-HeartBeat = "Tmr183000537305373_p_breed"
+DeviceName = "05393_p_breed"
+DeviceSecret = "36186966ebe3e73d14188d61554ee55d"
+HeartBeat = "Tmr183000539305393_p_breed"
+
+
 
 
 [comm]
@@ -112,3 +115,4 @@ ParityMode = 0    #PARITY_NONE  0	PARITY_ODD  1	PARITY_EVEN  2
 InterCharacterTimeout = 100
 MinimumReadSize = 0
 
+

+ 8 - 30
conf/app.ini

@@ -77,7 +77,7 @@ Password = root
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = yq2
+Name = tn
 TablePrefix =
 
 ShowXormlog = false
@@ -94,12 +94,15 @@ Password =
 Name = 
 
 
+
 [yyn]
-FarmId = "1830002077"
+FarmId = "1830005393"
 ProductKey = "k03txxLKFae"
-DeviceName = "02077_p_breed"
-DeviceSecret = "2eda4a25a086d9d188c1d42c1ba74a9d"
-HeartBeat = "Tmr183000207702077_p_breed"
+DeviceName = "05393_p_breed"
+DeviceSecret = "36186966ebe3e73d14188d61554ee55d"
+HeartBeat = "Tmr183000539305393_p_breed"
+
+
 
 
 
@@ -111,28 +114,3 @@ StopBits = 1
 ParityMode = 0    #PARITY_NONE  0	PARITY_ODD  1	PARITY_EVEN  2
 InterCharacterTimeout = 100
 MinimumReadSize = 0
-
-
-
-
-
-  tmrwatchcomm:
-    image: registry.cn-hangzhou.aliyuncs.com/kptyun/tmrwatchcomm_amd64:latest
- #   ports:
- #     - "80:8080"
-    volumes:
-       - /home/tmrwatch/TMRWatch:/opt/TMRWatchComm
-    depends_on:
-      - mariadb
-    network_mode: "host"
-    devices:
-      - "/dev/ttyUSB0:/dev/ttyS0"
-    deploy:
-      restart_policy:
-        condition: unless-stopped
-    logging:
-      driver: json-file
-      options:
-        max-size: 30m
-        max-file: 2
-

+ 5 - 6
http/handle/api/mqtt.go

@@ -36,8 +36,8 @@ func InitMqttClient() {
 	if setting.YynserverSetting.FarmId != "" {
 		c, pubTopic = MqttClient()
 		deviceHeartbeat(c, pubTopic)
-		// GetFeedDataFromApi()
-		// getBarDataFromApi()
+		GetFeedDataFromApi()
+		getBarDataFromApi()
 		// i := 50
 		// for {
 		// 	i--
@@ -70,13 +70,13 @@ func InitMqttClient() {
 		mqttCron := cron.New()
 		mqttCron.AddFunc("10 07 * * *", func() {
 			now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
+			GetFeedDataFromApi()
 			stirPush(c, pubTopic, now)
 			dustingPush(c, pubTopic, now)
 			equipmentAccuracyPush(c, pubTopic, now)
 			finishedWeightPush(c, pubTopic, now)
 			feedtempletPush(c, pubTopic)
 			CompletedTrainNumberPush(c, pubTopic, now)
-			GetFeedDataFromApi()
 			getBarDataFromApi()
 		})
 		mqttCron.Start()
@@ -623,7 +623,6 @@ func GetFeedDataFromApi() {
 	if err != nil {
 		return
 	}
-
 	if reDataString != "" {
 		var resultMap map[string]interface{}
 		err = json.Unmarshal([]byte(reDataString), &resultMap)
@@ -668,16 +667,16 @@ func GetFeedDataFromApi() {
 				return
 			}
 
-			fmt.Println(feed.CategoryName)
 			ids1, err := setting.SnowIds.NextId()
 			if err != nil {
 				ids1 = time.Now().UnixNano()
 				logging.Info("create SnowIds err", err)
 			}
 
-			tx.Exec(` insert into feed(id,pastureid,fname,feedcode,fclass,fclassid,source)
+			_, err =  tx.Exec(` insert into feed(id,pastureid,fname,feedcode,fclass,fclassid,source)
 			values(?,?,?,?,?,(select id from feedclass where pastureid = ? and fccode = ? ),'云养牛')  ON DUPLICATE KEY UPDATE source = '云养牛'  `,
 				ids1, pastureinfo.Pastureid, feed.MaterialName, feed.MaterialCode, feed.CategoryName, pastureinfo.Pastureid, feed.CategoryCode)
+				fmt.Println(err)
 		}
 	}
 }

+ 405 - 89
http/handle/api/ops.go

@@ -3642,27 +3642,28 @@ func UpdateFpdetailBar(c *gin.Context) {
 		ftmap["ptid"] = list.Get("ptid").ValueStr()
 		ftmap["ptsid"] = list.Get("ptsid").ValueStr()
 		// fmt.Println(ftmap)
-
-		// count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ? and times = ?  )
-		// and find_in_set(barid,(select barid from feedp where id = ?  ))  and lweight > 0 `, pastureid, pastureid, ftmap["times"], id).Count()
-		// if count == 1 {
-		// 	_, err = tx.SQL(` update  lpplandtl1  set lweight = 0 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ?  and times = ? )
-		// 	and find_in_set(barid,(select barid from feedp where id = ? )) `, pastureid, pastureid, ftmap["times"], id).Execute()
-		// 	if err != nil {
-		// 		tx.Rollback()
-		// 		logs.Error(err)
-		// 		appG.Response(http.StatusInternalServerError, e.ERROR, err)
-		// 		return
-		// 	}
-		// 	_, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
-		// 	WHERE pastureid=?  and find_in_set(barid,(select barid from feedp where id = ? )  )   and times = ?    `, pastureid, id, ftmap["times"]).Execute()
-		// 	if err != nil {
-		// 		tx.Rollback()
-		// 		logs.Error(err)
-		// 		appG.Response(http.StatusInternalServerError, e.ERROR, err)
-		// 		return
-		// 	}
-		// }
+// /*
+		count, err := tx.SQL(` select count(1) from lpplandtl1 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ? and times = ?  )
+		and find_in_set(barid,(select barid from feedp where id = ?  ))  and lweight > 0 `, pastureid, pastureid, ftmap["times"], id).Count()
+		if count == 1 {
+			_, err = tx.SQL(` update  lpplandtl1  set lweight = 0 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ?  and times = ? )
+			and find_in_set(barid,(select barid from feedp where id = ? )) `, pastureid, pastureid, ftmap["times"], id).Execute()
+			if err != nil {
+				tx.Rollback()
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, err)
+				return
+			}
+			_, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
+			WHERE pastureid=?  and find_in_set(barid,(select barid from feedp where id = ? )  )   and times = ?    `, pastureid, id, ftmap["times"]).Execute()
+			if err != nil {
+				tx.Rollback()
+				logs.Error(err)
+				appG.Response(http.StatusInternalServerError, e.ERROR, err)
+				return
+			}
+		}
+			// */
 
 		fpdDataList, err := tx.SQL(`
 			SELECT TRIM(id) id,times,tratio,ifnull(ROUND((1-ptsrate)*weight,2)-ptuse,"") weight,TRIM(barid) barid,TRIM(pastureid) pastureid,TRIM((select ftid from feedp where barid =fpdetail.barid)) ptid,TRIM(ifnull(ptsid,-1) ) ptsid ,
@@ -4447,12 +4448,12 @@ func FpdImportExcel(c *gin.Context) {
 					if _, ok := outentry["栏舍名称"]; ok {
 						dataexcel["barname"] = outentry["栏舍名称"]
 					}
-					// if _, ok := outentry["实际牛头数"]; ok {
-					// 	dataexcel["ccount"] = outentry["实际牛头数"]
-					// }
-					if _, ok := outentry["实际羊只数"]; ok {
-						dataexcel["ccount"] = outentry["实际羊只数"]
+					if _, ok := outentry["实际牛头数"]; ok {
+						dataexcel["ccount"] = outentry["实际牛头数"]
 					}
+					// if _, ok := outentry["实际羊只数"]; ok {
+					// 	dataexcel["ccount"] = outentry["实际羊只数"]
+					// }
 					if _, ok := outentry["系数(%)"]; ok {
 						dataexcel["ratio"] = outentry["系数(%)"]
 					}
@@ -5181,6 +5182,21 @@ func FpdImportExcel(c *gin.Context) {
 			// 				}
 			// 			}
 			// 		}
+
+// /*
+			_, err = tx.SQL(` update  lpplandtl1  set lweight = 0 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ?  )
+			and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, barname).Execute()
+			if err != nil {
+				logs.Error(err)
+				return
+			}
+			_, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
+			WHERE pastureid=?  and find_in_set(barid,(select barid from feedp where barname = ? )  )   `, pastureid, barname).Execute()
+			if err != nil {
+				logs.Error(err)
+				return
+			}
+			// */
 			updateFpdetailByBar(pastureid, barname, v)
 		}
 	} else {
@@ -6254,31 +6270,31 @@ func GetTMRListEnableTypeAll(c *gin.Context) {
 	for i := carNum; i > 0; i-- {
 		id++
 		n++
-		data := make(map[string]interface{}, 0)
-		data["eqcode"] = fmt.Sprintf("任意车%d", n)
-		data["tname"] = fmt.Sprintf("任意车%d", n)
-		data["datacaptureno"] = -2
-		data["tclassid"] = -2
-		data["tmrmix"] = fmt.Sprintf("任意车%d", n)
-		data["tclassname"] = fmt.Sprintf("任意车%d", n)
-		data["maxstirfeed"] = 100000
-		data["remark"] = fmt.Sprintf("任意车%d", n)
-		data["enable"] = 1
-		data["id"] = fmt.Sprintf("%d", id)
-		data["pastureid"] = pastureid
-
 		// data := make(map[string]interface{}, 0)
-		// data["eqcode"] = fmt.Sprintf("AnyCar%d", n)
-		// data["tname"] = fmt.Sprintf("AnyCar%d", n)
+		// data["eqcode"] = fmt.Sprintf("任意车%d", n)
+		// data["tname"] = fmt.Sprintf("任意车%d", n)
 		// data["datacaptureno"] = -2
 		// data["tclassid"] = -2
-		// data["tmrmix"] = fmt.Sprintf("AnyCar%d", n)
-		// data["tclassname"] = fmt.Sprintf("AnyCar%d", n)
+		// data["tmrmix"] = fmt.Sprintf("任意车%d", n)
+		// data["tclassname"] = fmt.Sprintf("任意车%d", n)
 		// data["maxstirfeed"] = 100000
-		// data["remark"] = fmt.Sprintf("AnyCar%d", n)
+		// data["remark"] = fmt.Sprintf("任意车%d", n)
 		// data["enable"] = 1
 		// data["id"] = fmt.Sprintf("%d", id)
 		// data["pastureid"] = pastureid
+
+		data := make(map[string]interface{}, 0)
+		data["eqcode"] = fmt.Sprintf("AnyCar%d", n)
+		data["tname"] = fmt.Sprintf("AnyCar%d", n)
+		data["datacaptureno"] = -2
+		data["tclassid"] = -2
+		data["tmrmix"] = fmt.Sprintf("AnyCar%d", n)
+		data["tclassname"] = fmt.Sprintf("AnyCar%d", n)
+		data["maxstirfeed"] = 100000
+		data["remark"] = fmt.Sprintf("AnyCar%d", n)
+		data["enable"] = 1
+		data["id"] = fmt.Sprintf("%d", id)
+		data["pastureid"] = pastureid
 		dataList = append(dataList, data)
 	}
 	// UNION ALL
@@ -9008,20 +9024,20 @@ func FpdBatchEdit(c *gin.Context) {
 			continue
 		}
 
-		// _, err = tx.SQL(` update  lpplandtl1  set lweight = 0 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ?  )
-		// and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, dataexcel["barname"]).Execute()
-		// if err != nil {
-		// 	logs.Error(err)
-		// 	appG.Response(http.StatusInternalServerError, e.ERROR, err)
-		// 	return
-		// }
-		// _, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
-		// WHERE pastureid=?  and find_in_set(barid,(select barid from feedp where barname = ? )  )   `, pastureid, dataexcel["barname"]).Execute()
-		// if err != nil {
-		// 	logs.Error(err)
-		// 	appG.Response(http.StatusInternalServerError, e.ERROR, err)
-		// 	return
-		// }
+		_, err = tx.SQL(` update  lpplandtl1  set lweight = 0 where pastureid = ? and  lppid in(select  id from lpplan where pastureid = ?  )
+		and find_in_set(barid,(select barid from feedp where barname = ? )) `, pastureid, pastureid, dataexcel["barname"]).Execute()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, err)
+			return
+		}
+		_, err = tx.SQL(` UPDATE fpdetail SET ptuse=0,ptsuse=0
+		WHERE pastureid=?  and find_in_set(barid,(select barid from feedp where barname = ? )  )   `, pastureid, dataexcel["barname"]).Execute()
+		if err != nil {
+			logs.Error(err)
+			appG.Response(http.StatusInternalServerError, e.ERROR, err)
+			return
+		}
 
 		dataexcel["1"] = barFsions.Get("times1").ValueStr()
 		dataexcel["2"] = barFsions.Get("times2").ValueStr()
@@ -9628,36 +9644,336 @@ func DelFeedTemplet(c *gin.Context) {
 
 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  and  dd2.fname = d2.fname) = 
-		( SELECT count( 1 ) FROM downloadplandtl2 dd2   WHERE dd2.pid = d.id  and (select count(1) from downloadplandtl2  where pid = dd2.pid  and fname = dd2.fname   ) = 1  and dd2.fname = d2.fname )
-	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)
+	// plancount, err := tx.Table("downloadedplan").Where(" mydate  = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype in(2) ").Count()
+	downloadedplanList := make([]*models.DownloadedPlan, 0)
+	tx.Table("downloadedplan").Where(" mydate  = ? ", data["startTime"]).Where(" havebutton = 0 ").Where(" lpplantype = 2 ").Find(&downloadedplanList)
+
+
+	// 
+	lweight := 20.0
+	for _, downloadedplan := range downloadedplanList {
+		downloadplandtl1List :=make([]*models.DownloadPlanDtl1,0)
+		downloadplandtl1ExecList :=make([]*models.DownloadPlanDtl1Exec,0)
+		downloadplandtl2List :=make([]*models.DownloadPlanDtl2,0)
+		tx.Table("downloadplandtl1").Where(" pid = ? ",downloadedplan.ID).Find(&downloadplandtl1List)
+		tx.Table("downloadplandtl2").Where(" pid = ? ",downloadedplan.ID).Find(&downloadplandtl2List)
+		tx.Table("downloadplandtl1_exec").Where(" pid = ? ",downloadedplan.ID).Find(&downloadplandtl1ExecList)
+
+		lweightCount := math.Floor(downloadedplan.LWeight / lweight)
+		for i := 0; i <= int(lweightCount); i++ {
+			if i ==0 {
+				tx.Exec(` update downloadedplan set lweight = ? where id = ? `, lweight, downloadedplan.ID)
+				for _, downloadplandtl1 := range downloadplandtl1List{
+					tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
+				}
+				for _, downloadplandtl2 := range downloadplandtl2List{
+					tx.Exec(` update downloadplandtl2 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl2.LWeight, downloadplandtl2.ID)
+				}
+				for _, downloadplandtl2 := range downloadplandtl1ExecList{
+					tx.Exec(` update downloadplandtl1_exec set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl2.LWeight, downloadplandtl2.ID)
+				}
+				
+			} else if i < int(lweightCount) {
+				parts := strings.Split(downloadedplan.ProjName, ".")
+				parts[len(parts)-1] = fmt.Sprintf("%d", i+1)
+				data :=&models.DownloadedPlan{
+					PastureID     :downloadedplan.PastureID     ,
+					MyDate        :downloadedplan.MyDate        ,
+					ProjName      :strings.Join(parts, ".")     ,
+					DataCaptureNo :downloadedplan.DataCaptureNo ,
+					TmrID         :downloadedplan.TmrID         ,
+					TmrtName      :downloadedplan.TmrtName      ,
+					HaveButton    :downloadedplan.HaveButton    ,
+					InButtonType  :downloadedplan.InButtonType  ,
+					PlanTime      :downloadedplan.PlanTime      ,
+					InTime        :downloadedplan.InTime        ,
+					CompletedTime :downloadedplan.CompletedTime ,
+					IsCompleted   :downloadedplan.IsCompleted   ,
+					LpPlanType    :downloadedplan.LpPlanType    ,
+					Times         :downloadedplan.Times         ,
+					Sort          :downloadedplan.Sort          ,
+					Remark        :downloadedplan.Remark        ,
+					ItemNum       :downloadedplan.ItemNum       ,
+					OutItems      :downloadedplan.OutItems      ,
+					FeedPName     :downloadedplan.FeedPName     ,
+					FeedPCount    :downloadedplan.FeedPCount    ,
+					Pid           :downloadedplan.Pid           ,
+					TempID        :downloadedplan.TempID        ,
+					TempletName   :downloadedplan.TempletName   ,
+					PtsTempID     :downloadedplan.PtsTempID     ,
+					PtsTempletName:downloadedplan.PtsTempletName,
+					ThoWeight     :downloadedplan.ThoWeight     ,
+					FpWeight      :downloadedplan.FpWeight      ,
+					LWeight       :lweight       ,       
+					IWeight       :downloadedplan.IWeight       ,
+					OWeight       :downloadedplan.OWeight       ,
+					TVersion      :downloadedplan.TVersion      ,
+					PtVersion     :downloadedplan.PtVersion     ,
+					Enable        :downloadedplan.Enable        ,
+					IsUse         :downloadedplan.IsUse         ,
+					OldTmrID      :downloadedplan.OldTmrID      ,
+					DriverID      :downloadedplan.DriverID      ,
+					Artificial    :downloadedplan.Artificial    ,
+				}
+				_, err := tx.Insert(data)
+				fmt.Println(data,err)
+
+				for _, downloadplandtl1 := range downloadplandtl1List{
+					// tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
+					d1 :=&models.DownloadPlanDtl1{
+						PastureID        :downloadplandtl1.PastureID        ,
+						Pid              :data.ID              ,
+						Flpid            :downloadplandtl1.Flpid            ,
+						Fid              :downloadplandtl1.Fid              ,
+						LWeight          :lweight/downloadedplan.LWeight * downloadplandtl1.LWeight          ,
+						Sort             :downloadplandtl1.Sort             ,
+						ButtonType       :downloadplandtl1.ButtonType       ,
+						OptDevice        :downloadplandtl1.OptDevice        ,
+						FeedCode         :downloadplandtl1.FeedCode         ,
+						FName            :downloadplandtl1.FName            ,
+						FeedSort         :downloadplandtl1.FeedSort         ,
+						FeedAllowRatio   :downloadplandtl1.FeedAllowRatio   ,
+						StirDelay        :downloadplandtl1.StirDelay        ,
+						FWeight          :downloadplandtl1.FWeight          ,
+						TmrLoadName      :downloadplandtl1.TmrLoadName      ,
+						DryFeed          :downloadplandtl1.DryFeed          ,
+						PriceFeed        :downloadplandtl1.PriceFeed        ,
+						OutWeight        :downloadplandtl1.OutWeight        ,
+						ErrRatio         :downloadplandtl1.ErrRatio         ,
+						Date             :downloadplandtl1.Date             ,
+						ButtonSucc       :downloadplandtl1.ButtonSucc       ,
+						Type             :downloadplandtl1.Type             ,
+						Deviation        :downloadplandtl1.Deviation        ,
+						XxwFeedCode      :downloadplandtl1.XxwFeedCode      ,
+					}
+					 tx.Insert(d1)
+				}
+				for _, downloadplandtl2 := range downloadplandtl2List{
+					// tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
+					d2 :=&models.DownloadPlanDtl2{
+						PastureID :downloadplandtl2.PastureID      ,         
+						Pid :data.ID           ,               
+						Flpid :downloadplandtl2.Flpid          ,             
+						Fbarid :downloadplandtl2.Fbarid         ,            
+						FName :downloadplandtl2.FName          ,             
+						LWeight :lweight/downloadedplan.LWeight * downloadplandtl2.LWeight          ,           
+						LWeightHis :lweight/downloadedplan.LWeight * downloadplandtl2.LWeight       ,        
+						RemainLeftW :downloadplandtl2.RemainLeftW    ,       
+						AllowRW :downloadplandtl2.AllowRW        ,           
+						Sort :downloadplandtl2.Sort           ,              
+						HaveButton :downloadplandtl2.HaveButton     ,               
+						BeginTag :downloadplandtl2.BeginTag       ,          
+						EndTag :downloadplandtl2.EndTag         ,            
+						ButtonType :downloadplandtl2.ButtonType     ,        
+						OptDevice :downloadplandtl2.OptDevice      ,         
+						CowCount :downloadplandtl2.CowCount       ,          
+						CowClassID :downloadplandtl2.CowClassID     ,        
+						CowClassName :downloadplandtl2.CowClassName   ,      
+						BigCowName :downloadplandtl2.BigCowName     ,        
+						PWeight :downloadplandtl2.PWeight        ,           
+						CCountRatio :downloadplandtl2.CCountRatio    ,       
+						SumRTime :downloadplandtl2.SumRTime       ,          
+						FeedTempletID :downloadplandtl2.FeedTempletID  ,     
+						FeedTempletName :downloadplandtl2.FeedTempletName,   
+						DryWeight :downloadplandtl2.DryWeight      ,         
+						SumWeight :downloadplandtl2.SumWeight      ,         
+						PriceWeight :downloadplandtl2.PriceWeight    ,       
+						// ProcessTime :downloadplandtl2.ProcessTime    ,       
+						Fpid :downloadplandtl2.Fpid           ,              
+						UseInBarType :downloadplandtl2.UseInBarType   ,      
+						Date :downloadplandtl2.Date           ,              
+						AllowRatio :downloadplandtl2.AllowRatio     ,        
+						ErrRatio :downloadplandtl2.ErrRatio       ,          
+						ButtonSucc :downloadplandtl2.ButtonSucc     ,        
+						Type :downloadplandtl2.Type           ,              
+						XxwTempletCode :downloadplandtl2.XxwTempletCode ,    
+						XxwBarCode :downloadplandtl2.XxwBarCode     ,        
+					}
+					_,err :=tx.Insert(d2)
+					fmt.Println(err )
+				}
+
+				for _, downloadplandtl2 := range downloadplandtl1ExecList{
+					d2 :=&models.DownloadPlanDtl1Exec{
+						PastureID:downloadplandtl2.PastureID,        
+						Pid:data.ID,
+						Flpid:downloadplandtl2.Flpid,            
+						LWeight:lweight/downloadedplan.LWeight * downloadplandtl2.LWeight          ,          
+						HaveButton:downloadplandtl2.HaveButton,       
+						ButtonType:downloadplandtl2.ButtonType,       
+						OptDevice:downloadplandtl2.OptDevice,        
+						Sort:downloadplandtl2.Sort,             
+						FName:downloadplandtl2.FName,            
+						FCount:downloadplandtl2.FCount           ,           
+						TmrLoadName:downloadplandtl2.TmrLoadName      ,      
+						FeedAllowRatio:downloadplandtl2.FeedAllowRatio   ,       
+						StirDelay:downloadplandtl2.StirDelay        ,        
+						ButtonSucc:downloadplandtl2.ButtonSucc       ,       
+						ErrRatio:downloadplandtl2.ErrRatio         ,         
+						Date:downloadplandtl2.Date             ,             
+						Type:downloadplandtl2.Type             ,             
+						Deviation:downloadplandtl2.Deviation        ,        
+						XxwFeedCode:downloadplandtl2.XxwFeedCode      ,          
+					}
+					_,err :=tx.Insert(d2)
+					fmt.Println(err )
+				}
+
+			} else {
+				parts := strings.Split(downloadedplan.ProjName, ".")
+				parts[len(parts)-1] = fmt.Sprintf("%d", i+1)
+
+				data := &models.DownloadedPlan{
+					PastureID     :downloadedplan.PastureID     ,
+					MyDate        :downloadedplan.MyDate        ,
+					ProjName      :strings.Join(parts, ".")     ,
+					DataCaptureNo :downloadedplan.DataCaptureNo ,
+					TmrID         :downloadedplan.TmrID         ,
+					TmrtName      :downloadedplan.TmrtName      ,
+					HaveButton    :downloadedplan.HaveButton    ,
+					InButtonType  :downloadedplan.InButtonType  ,
+					PlanTime      :downloadedplan.PlanTime      ,
+					InTime        :downloadedplan.InTime        ,
+					CompletedTime :downloadedplan.CompletedTime ,
+					IsCompleted   :downloadedplan.IsCompleted   ,
+					LpPlanType    :downloadedplan.LpPlanType    ,
+					Times         :downloadedplan.Times         ,
+					Sort          :downloadedplan.Sort          ,
+					Remark        :downloadedplan.Remark        ,
+					ItemNum       :downloadedplan.ItemNum       ,
+					OutItems      :downloadedplan.OutItems      ,
+					FeedPName     :downloadedplan.FeedPName     ,
+					FeedPCount    :downloadedplan.FeedPCount    ,
+					Pid           :downloadedplan.Pid           ,
+					TempID        :downloadedplan.TempID        ,
+					TempletName   :downloadedplan.TempletName   ,
+					PtsTempID     :downloadedplan.PtsTempID     ,
+					PtsTempletName:downloadedplan.PtsTempletName,
+					ThoWeight     :downloadedplan.ThoWeight     ,
+					FpWeight      :downloadedplan.FpWeight      ,
+					LWeight       :downloadedplan.LWeight-float64(i)*lweight,
+					IWeight       :downloadedplan.IWeight       ,
+					OWeight       :downloadedplan.OWeight       ,
+					TVersion      :downloadedplan.TVersion      ,
+					PtVersion     :downloadedplan.PtVersion     ,
+					Enable        :downloadedplan.Enable        ,
+					IsUse         :downloadedplan.IsUse         ,
+					OldTmrID      :downloadedplan.OldTmrID      ,
+					DriverID      :downloadedplan.DriverID      ,
+					Artificial    :downloadedplan.Artificial  	,
+				}
+				_, err := tx.Insert(data)
+				fmt.Println(data,err)
+				for _, downloadplandtl1 := range downloadplandtl1List{
+					// tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
+					d1 :=&models.DownloadPlanDtl1{
+						PastureID        :downloadplandtl1.PastureID        ,
+						Pid              :data.ID              ,
+						Flpid            :downloadplandtl1.Flpid            ,
+						Fid              :downloadplandtl1.Fid              ,
+						LWeight          :(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl1.LWeight          ,
+						Sort             :downloadplandtl1.Sort             ,
+						ButtonType       :downloadplandtl1.ButtonType       ,
+						OptDevice        :downloadplandtl1.OptDevice        ,
+						FeedCode         :downloadplandtl1.FeedCode         ,
+						FName            :downloadplandtl1.FName            ,
+						FeedSort         :downloadplandtl1.FeedSort         ,
+						FeedAllowRatio   :downloadplandtl1.FeedAllowRatio   ,
+						StirDelay        :downloadplandtl1.StirDelay        ,
+						FWeight          :downloadplandtl1.FWeight          ,
+						TmrLoadName      :downloadplandtl1.TmrLoadName      ,
+						DryFeed          :downloadplandtl1.DryFeed          ,
+						PriceFeed        :downloadplandtl1.PriceFeed        ,
+						OutWeight        :downloadplandtl1.OutWeight        ,
+						ErrRatio         :downloadplandtl1.ErrRatio         ,
+						Date             :downloadplandtl1.Date             ,
+						ButtonSucc       :downloadplandtl1.ButtonSucc       ,
+						Type             :downloadplandtl1.Type             ,
+						Deviation        :downloadplandtl1.Deviation        ,
+						XxwFeedCode      :downloadplandtl1.XxwFeedCode      ,
+					}
+					 tx.Insert(d1)
+				}
+				for _, downloadplandtl2 := range downloadplandtl2List{
+					// tx.Exec(` update downloadplandtl1 set lweight = ? where id = ? `, lweight/downloadedplan.LWeight * downloadplandtl1.LWeight, downloadplandtl1.ID)
+					d2 :=&models.DownloadPlanDtl2{
+						PastureID :downloadplandtl2.PastureID      ,         
+						Pid :data.ID           ,               
+						Flpid :downloadplandtl2.Flpid          ,             
+						Fbarid :downloadplandtl2.Fbarid         ,            
+						FName :downloadplandtl2.FName          ,             
+						LWeight :(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl2.LWeight        ,           
+						LWeightHis :(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl2.LWeight     ,        
+						RemainLeftW :downloadplandtl2.RemainLeftW    ,       
+						AllowRW :downloadplandtl2.AllowRW        ,           
+						Sort :downloadplandtl2.Sort           ,              
+						HaveButton :downloadplandtl2.HaveButton     ,               
+						BeginTag :downloadplandtl2.BeginTag       ,          
+						EndTag :downloadplandtl2.EndTag         ,            
+						ButtonType :downloadplandtl2.ButtonType     ,        
+						OptDevice :downloadplandtl2.OptDevice      ,         
+						CowCount :downloadplandtl2.CowCount       ,          
+						CowClassID :downloadplandtl2.CowClassID     ,        
+						CowClassName :downloadplandtl2.CowClassName   ,      
+						BigCowName :downloadplandtl2.BigCowName     ,        
+						PWeight :downloadplandtl2.PWeight        ,           
+						CCountRatio :downloadplandtl2.CCountRatio    ,       
+						SumRTime :downloadplandtl2.SumRTime       ,          
+						FeedTempletID :downloadplandtl2.FeedTempletID  ,     
+						FeedTempletName :downloadplandtl2.FeedTempletName,   
+						DryWeight :downloadplandtl2.DryWeight      ,         
+						SumWeight :downloadplandtl2.SumWeight      ,         
+						PriceWeight :downloadplandtl2.PriceWeight    ,       
+						// ProcessTime :downloadplandtl2.ProcessTime    ,       
+						Fpid :downloadplandtl2.Fpid           ,              
+						UseInBarType :downloadplandtl2.UseInBarType   ,      
+						Date :downloadplandtl2.Date           ,              
+						AllowRatio :downloadplandtl2.AllowRatio     ,        
+						ErrRatio :downloadplandtl2.ErrRatio       ,          
+						ButtonSucc :downloadplandtl2.ButtonSucc     ,        
+						Type :downloadplandtl2.Type           ,              
+						XxwTempletCode :downloadplandtl2.XxwTempletCode ,    
+						XxwBarCode :downloadplandtl2.XxwBarCode     ,        
+					}
+					 _,err :=tx.Insert(d2)
+					 fmt.Println(err )
+				}
+				for _, downloadplandtl2 := range downloadplandtl1ExecList{
+					d2 :=&models.DownloadPlanDtl1Exec{
+						PastureID:downloadplandtl2.PastureID,        
+						Pid:data.ID,              
+						Flpid:downloadplandtl2.Flpid,            
+						LWeight:(downloadedplan.LWeight-float64(i)*lweight )/downloadedplan.LWeight * downloadplandtl2.LWeight          ,          
+						HaveButton:downloadplandtl2.HaveButton,       
+						ButtonType:downloadplandtl2.ButtonType,       
+						OptDevice:downloadplandtl2.OptDevice,        
+						Sort:downloadplandtl2.Sort,             
+						FName:downloadplandtl2.FName,            
+						FCount:downloadplandtl2.FCount           ,           
+						TmrLoadName:downloadplandtl2.TmrLoadName      ,      
+						FeedAllowRatio:downloadplandtl2.FeedAllowRatio   ,       
+						StirDelay:downloadplandtl2.StirDelay        ,        
+						ButtonSucc:downloadplandtl2.ButtonSucc       ,       
+						ErrRatio:downloadplandtl2.ErrRatio         ,         
+						Date:downloadplandtl2.Date             ,             
+						Type:downloadplandtl2.Type             ,             
+						Deviation:downloadplandtl2.Deviation        ,        
+						XxwFeedCode:downloadplandtl2.XxwFeedCode      ,          
+					}
+					fmt.Println(d2)
+					_,err :=tx.Insert(d2)
+					fmt.Println(err )
+				}
+
+			}
+		}
+
+	}
+
+	downloadedplanSortList := make([]*models.DownloadedPlan, 0)
+	tx.SQL(`SELECT * FROM downloadedplan WHERE mydate = ? ORDER BY projname`,data["startTime"] ).Find(&downloadedplanSortList)
+	for i,d  :=range downloadedplanSortList{
+		tx.Exec(` update downloadedplan set sort = ? where id = ? `, i+1, d.ID)
 	}
 }
 
@@ -12197,7 +12513,7 @@ ORDER BY ftdetail.sort,ftdetail.id `, id, id).Find(&fpdetailFnameList)
 		appG.Response(http.StatusOK, e.ERROR, "查询失败")
 		return
 	}
-
+   
 	fpdetailList := make([]*models.Fpdetail, 0)
 	err = tx.SQL(`select id,barid,barname,times,weight from fpdetail	 where barid = ?`, id).Find(&fpdetailList)
 	if err != nil {

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

@@ -165,7 +165,7 @@ func CronScheduled(ctx context.Context) {
 	} else if setting.ServerSetting.SyncStatus == 9 {
 		yq.YqCron()
 	}
-
+	// InitMqttClient()
 	// err = xdmy.AddFunc("0 05 7 * * *", func() {
 	// 	// 	// 	// 	//现代牧业sap同步
 	// sap.SyncMaterialOutbound()

+ 10 - 12
http/handle/yq/yq.go

@@ -339,16 +339,17 @@ func YcFeedPush(pastureId, farmId, token string) error {
 	defer tx.Close()
 
 	dataList, err := tx.SQL(`SELECT
-	dry dmQty,
-	sort,
-	feedcode ingId,
-	fname ingName,
-	fclass ingType,
-	allowratio allowableError 
+	f.dry dmQty,
+	f.sort,
+	f.feedcode ingId,
+	f.fname ingName,
+	fc.fcname ingType,
+	f.allowratio allowableError 
 FROM
-	feed 
+	feed f 
+	join feedclass fc on fc.id = f.fclassid
 WHERE
-	pastureId = ?  `, pastureId).Query().List()
+	f.pastureId = ?  `, pastureId).Query().List()
 	if err != nil {
 		logging.Error(err)
 		return err
@@ -1276,7 +1277,4 @@ where lppland.pastureid = ?  and lppland.fpdid = ? and lpp.times = ?  order by l
 	}
 
 	return nil
-}
-
-
-
+}

+ 241 - 0
models/downloadedplan.go

@@ -0,0 +1,241 @@
+package models
+                                
+import (
+	"time"
+)
+
+
+
+type DownloadedPlan struct {
+    ID            int64     `xorm:"'id' bigint(20) pk autoincr"`
+    PastureID     int64     `xorm:"'pastureid' bigint(20) not null"`
+    MyDate        time.Time `xorm:"'mydate' datetime not null comment('计划日期')"`
+    ProjName      string    `xorm:"'projname' varchar(30) comment('计划编号')"`
+    DataCaptureNo int       `xorm:"'datacaptureno' int(11) comment('设备编号')"`
+    TmrID         int64     `xorm:"'tmrid' bigint(20) comment('tmr主键')"`
+    TmrtName      string    `xorm:"'tmrtname' varchar(20) comment('tmr名称')"`
+    HaveButton    bool      `xorm:"'havebutton' tinyint(1) default 0 comment('是否开始执行')"`
+    InButtonType  int       `xorm:"'inbuttontype' int(11) default 0 comment('按钮类型')"`
+    PlanTime      string    `xorm:"'plantime' varchar(50) comment('计划时分')"`
+    InTime        time.Time `xorm:"'intime' datetime comment('开始执行时间')"`
+    CompletedTime time.Time `xorm:"'completedtime' datetime comment('结束执行时间')"`
+    // ProcessTime   string    `xorm:"'processtime' time comment('过程时间')"`
+    IsCompleted   int       `xorm:"'iscompleted' tinyint(4) default 0 comment('是否已完成')"`
+    LpPlanType    int       `xorm:"'lpplantype' int(11) default 0 comment('计算模式')"`
+    Times         int       `xorm:"'times' int(11) default 0 comment('班次')"`
+    Sort          int       `xorm:"'sort' int(11) default 0 comment('顺序')"`
+    Remark        string    `xorm:"'remark' varchar(50) comment('备注')"`
+    ItemNum       int       `xorm:"'itemnum' int(11) comment('添加饲料种类数')"`
+    OutItems      int       `xorm:"'outitems' int(11) comment('发料牛舍数')"`
+    FeedPName     string    `xorm:"'feedpname' varchar(200) comment('牛舍列表')"`
+    FeedPCount    int       `xorm:"'feedpcount' int(11) default 0 comment('牛头数')"`
+    Pid           int64     `xorm:"'pid' bigint(20) comment('发料计划编号')"`
+    TempID        int64     `xorm:"'tempid' bigint(20) comment('配方id')"`
+    TempletName   string    `xorm:"'templetname' varchar(50) comment('配方模版名称')"`
+    PtsTempID     int64     `xorm:"'ptstempid' bigint(20) comment('补料配方id')"`
+    PtsTempletName string   `xorm:"'ptstempletname' varchar(50) comment('补料配方模版名称')"`
+    ThoWeight     string    `xorm:"'thoweight' char(20) comment('配方理论干物质')"`
+    FpWeight      string    `xorm:"'fpweight' char(20) comment('配方总重')"`
+    LWeight       float64   `xorm:"'lweight' decimal(38,2) comment('应做料总量')"`
+    IWeight       int       `xorm:"'iweight' int(11) comment('实际做料总量')"`
+    OWeight       int       `xorm:"'oweight' int(11) comment('实发料重量')"`
+    TVersion      int       `xorm:"'tversion' int(11) default 0 comment('配方版本')"`
+    PtVersion     int       `xorm:"'ptversion' int(11) default 0 comment('补料配方版本')"`
+    Enable        int       `xorm:"'enable' tinyint(4) default 1 comment('是否启用')"`
+    IsUse         int       `xorm:"'isUse' int(11) default 0 comment('是否使用')"`
+    OldTmrID      int64     `xorm:"'oldtmrid' bigint(20)"`
+    DriverID      int64     `xorm:"'driverId' bigint(20) comment('驾驶员')"`
+    Artificial    bool      `xorm:"'artificial' tinyint(1) not null default 0 comment('手动完成')"`
+}
+
+func (d *DownloadedPlan) TableName() string {
+    return "downloadedplan"
+}
+
+
+type DownloadPlanDtl1 struct {
+    ID               int64     `xorm:"'id' bigint(20) pk autoincr"`
+    PastureID        int64     `xorm:"'pastureid' bigint(20) not null"`
+    Pid              int64     `xorm:"'pid' bigint(20) not null comment('计划id')"`
+    Flpid            int64     `xorm:"'flpid' bigint(20) comment('发料计划的主id')"`
+    Fid              int64     `xorm:"'fid' bigint(20) not null comment('饲料id')"`
+    LWeight          float64   `xorm:"'lweight' decimal(20,2) not null comment('理论重量')"`
+    Sort             int       `xorm:"'sort' int(11) not null default 0 comment('顺序')"`
+    LastActualWeight float64   `xorm:"'lastactualweight' decimal(10,2) comment('上次重量')"`
+    ActualWeight     float64   `xorm:"'actualweight' decimal(10,2) comment('实际重量')"`
+    ActualWeightMinus float64  `xorm:"'actualweightminus' decimal(10,2) comment('实际重量')"`
+    HaveButton       bool      `xorm:"'havebuttom' tinyint(1) default 0 comment('是否操作')"`
+    BeginTime        time.Time `xorm:"'begintime' datetime comment('操作开始时间')"`
+    InTime           time.Time `xorm:"'intime' datetime comment('操作结束时间')"`
+    ButtonType       int       `xorm:"'buttontype' int(11) default 0 comment('操作类型')"`
+    OptDevice        int64     `xorm:"'optdevice' bigint(20) comment('操作车id')"`
+    FeedCode         string    `xorm:"'feedcode' varchar(50) comment('饲料编码')"`
+    FName            string    `xorm:"'fname' varchar(120) comment('饲料名称')"`
+    FeedSort         int       `xorm:"'feedsort' int(11) default 0 comment('饲料顺序')"`
+    FeedAllowRatio   float32   `xorm:"'feedallowratio' float default 0 comment('饲料允许误差率')"`
+    StirDelay        int       `xorm:"'stirdelay' int(11) default 0 comment('搅拌延时(分钟)')"`
+    FWeight          float64   `xorm:"'fweight' decimal(10,3) comment('配方明细量')"`
+    TmrLoadName      string    `xorm:"'tmrloadname' varchar(150) comment('相同饲料顺序在tmr车上的显示名称')"`
+    DryFeed          float64   `xorm:"'dryfeed' decimal(38,2) comment('饲料干物质')"`
+    PriceFeed        float64   `xorm:"'pricefeed' decimal(38,2) comment('饲料单价')"`
+    OutWeight        int       `xorm:"'outweight' int(11) comment('人工确认出库量')"`
+    ErrRatio         float64   `xorm:"'errratio' decimal(38,2)"`
+    Date             time.Time `xorm:"'date' date not null"`
+    ButtonSucc       int       `xorm:"'buttonsucc' tinyint(4)"`
+    Type             int       `xorm:"'type' tinyint(4) default 0 comment('类型')"`
+    Deviation        int       `xorm:"'deviation' int(11) comment('搅拌延时值允许延时偏差')"`
+    XxwFeedCode      string    `xorm:"'xxwFeedCode' varchar(100)"`
+}
+
+func (d *DownloadPlanDtl1) TableName() string {
+    return "downloadplandtl1"
+}
+
+// 如果需要定义索引,可以添加以下方法
+func (d *DownloadPlanDtl1) TableIndex() [][]string {
+    return [][]string{
+        {"pastureid", "flpid", "fid", "date", "pid"},
+        {"fid"},
+        {"date"},
+        {"pid", "pastureid"},
+        {"pastureid", "flpid", "type", "date"},
+        {"pastureid", "intime", "date"},
+    }
+}
+
+// 复合主键配置(XORM对复合主键支持有限,这里提供一种方式)
+func (d *DownloadPlanDtl1) PrimaryKeys() []string {
+    return []string{"id", "pastureid", "date"}
+}
+
+// 或者使用ID作为主键,其他作为唯一索引
+func (d *DownloadPlanDtl1) Id() int64 {
+    return d.ID
+}
+
+type DownloadPlanDtl1Exec struct {
+    ID                int64     `xorm:"'id' bigint(20) pk autoincr"`
+    PastureID         int64     `xorm:"'pastureid' bigint(20) not null"`
+    Pid               int64     `xorm:"'pid' bigint(20) not null comment('计划id')"`
+    Flpid             int64     `xorm:"'flpid' bigint(20)"`
+    LastActualWeight  float64   `xorm:"'lastactualweight' decimal(10,2) comment('上次重量')"`
+    ActualWeight      float64   `xorm:"'actualweight' decimal(10,2) comment('本次重量')"`
+    LWeight           float64   `xorm:"'lweight' decimal(16,2) not null comment('理论重量')"`
+    ActualWeightMinus float64   `xorm:"'actualweightminus' decimal(10,2) comment('实际重量')"`
+    // BeginTime         time.Time `xorm:"'begintime' datetime comment('操作开始时间')"`
+    // InTime            time.Time `xorm:"'intime' datetime comment('操作结束时间')"`
+    HaveButton        bool      `xorm:"'havebuttom' tinyint(1) not null default 0 comment('是否已操作')"`
+    ButtonType        int       `xorm:"'buttontype' int(11) default 0 comment('按钮类型')"`
+    OptDevice         int64     `xorm:"'optdevice' bigint(20) comment('操作车id')"`
+    Sort              int       `xorm:"'sort' int(11) not null default 0 comment('顺序')"`
+    FName             string    `xorm:"'fname' varchar(120) comment('饲料名称')"`
+    FCount            int       `xorm:"'fcount' int(11) comment('饲料数')"`
+    TmrLoadName       string    `xorm:"'tmrloadname' varchar(120) comment('相同饲料顺序在tmr车上的显示名称')"`
+    FeedAllowRatio    float32   `xorm:"'feedallowratio' float default 0 comment('饲料允许误差公斤')"`
+    // ProcessTime       string    `xorm:"'processtime' time comment('过程时间')"`
+    StirDelay         int       `xorm:"'stirdelay' int(11) default 0 comment('搅拌延时(分钟)')"`
+    ButtonSucc        int       `xorm:"'buttonsucc' tinyint(4) default 0"`
+    ErrRatio          float64   `xorm:"'errratio' decimal(38,2)"`
+    Date              time.Time `xorm:"'date' date not null"`
+    Type              int       `xorm:"'type' tinyint(4) default 0 comment('类型')"`
+    Deviation         int       `xorm:"'deviation' int(11) comment('搅拌延时值允许延时偏差')"`
+    XxwFeedCode       string    `xorm:"'xxwFeedCode' varchar(100)"`
+}
+
+func (d *DownloadPlanDtl1Exec) TableName() string {
+    return "downloadplandtl1_exec"
+}
+
+// 定义索引
+func (d *DownloadPlanDtl1Exec) TableIndex() [][]string {
+    return [][]string{
+        {"pastureid", "pid", "sort", "date", "type"},
+        {"pid"},
+        {"pastureid", "pid"},
+        {"date", "pastureid"},
+        {"intime", "pastureid"},
+        {"flpid"},
+    }
+}
+
+// 复合主键配置
+func (d *DownloadPlanDtl1Exec) PrimaryKeys() []string {
+    return []string{"id", "pastureid", "date"}
+}
+
+// 如果需要使用ID作为主键,可以添加这个方法
+func (d *DownloadPlanDtl1Exec) Id() int64 {
+    return d.ID
+}
+type DownloadPlanDtl2 struct {
+    ID                int64     `xorm:"'id' bigint(20) pk autoincr"`
+    PastureID         int64     `xorm:"'pastureid' bigint(20) not null"`
+    Pid               int64     `xorm:"'pid' bigint(20) not null comment('计划id')"`
+    Flpid             int64     `xorm:"'flpid' bigint(20) comment('发料计划的主id')"`
+    Fbarid            int64     `xorm:"'fbarid' bigint(20) not null comment('牛舍id')"`
+    FName             string    `xorm:"'fname' varchar(50) comment('牛舍名称')"`
+    LastActualWeight  float64   `xorm:"'lastactualweight' decimal(10,0) comment('上次重量')"`
+    ActualWeight      float64   `xorm:"'actualweight' decimal(10,2) comment('本次重量')"`
+    LWeight           float64   `xorm:"'lweight' decimal(16,2) comment('理论重量')"`
+    LWeightHis        float64   `xorm:"'lweighthis' decimal(10,2) comment('历史理论重量')"`
+    RemainLeftW       float64   `xorm:"'remainleftw' decimal(10,2) comment('剩料量')"`
+    AllowRW           float64   `xorm:"'allowrw' decimal(10,2) comment('允许分配剩料量')"`
+    ActualWeightMinus float64   `xorm:"'actualweightminus' decimal(10,2) comment('实际重量')"`
+    Sort              int       `xorm:"'sort' int(11) not null default 0 comment('顺序')"`
+    HaveButton        bool      `xorm:"'havebuttom' tinyint(1) default 0 comment('是否操作')"`
+    BeginTime         time.Time `xorm:"'begintime' datetime comment('操作开始时间')"`
+    BeginTag          string    `xorm:"'begintag' varchar(50) comment('开始标签')"`
+    InTime            time.Time `xorm:"'intime' datetime comment('操作完成时间')"`
+    EndTag            string    `xorm:"'endtag' varchar(50) comment('结束标签')"`
+    ButtonType        int       `xorm:"'buttontype' int(11) default 0 comment('操作按键类型')"`
+    OptDevice         int64     `xorm:"'optdevice' bigint(20) comment('操作车id')"`
+    CowCount          int       `xorm:"'cowcount' int(11) default 0 comment('牛头数')"`
+    CowClassID        int64     `xorm:"'cowclassid' bigint(20) comment('牛只类型id')"`
+    CowClassName      string    `xorm:"'cowclassname' varchar(50) comment('类型名称')"`
+    BigCowName        string    `xorm:"'bigcowname' varchar(50)"`
+    PWeight           float64   `xorm:"'pweight' decimal(10,2) comment('通过加料计算出重量')"`
+    CCountRatio       float32   `xorm:"'ccountratio' float default 100 comment('牛头系数')"`
+    SumRTime          float32   `xorm:"'sumrtime' float default 0 comment('该班次比例')"`
+    FeedTempletID     int64     `xorm:"'feedtempletid' bigint(20) comment('配方模版id')"`
+    FeedTempletName   string    `xorm:"'feedtempletname' varchar(20) comment('配方模版名称')"`
+    DryWeight         float64   `xorm:"'dryweight' decimal(10,2) comment('配方干物质')"`
+    SumWeight         float64   `xorm:"'sumweight' decimal(10,2) comment('配方饲料总重量')"`
+    PriceWeight       float64   `xorm:"'priceweight' decimal(10,2) comment('配方单价')"`
+    // ProcessTime       string    `xorm:"'processtime' time comment('过程时间')"`
+    Fpid              int64     `xorm:"'fpid' bigint(20) comment('栏舍配方id')"`
+    UseInBarType      int64     `xorm:"'useinbartype' bigint(20) comment('转投栏舍类型')"`
+    Date              time.Time `xorm:"'date' date not null"`
+    AllowRatio        int       `xorm:"'allowratio' int(11) comment('栏舍允许误差')"`
+    ErrRatio          float64   `xorm:"'errratio' decimal(38,2)"`
+    ButtonSucc        int       `xorm:"'buttonsucc' tinyint(4)"`
+    Type              int       `xorm:"'type' tinyint(4) default 0 comment('类型')"`
+    XxwTempletCode    string    `xorm:"'xxwTempletCode' varchar(100)"`
+    XxwBarCode        string    `xorm:"'xxwBarCode' varchar(100)"`
+}
+
+func (d *DownloadPlanDtl2) TableName() string {
+    return "downloadplandtl2"
+}
+
+// 定义索引
+func (d *DownloadPlanDtl2) TableIndex() [][]string {
+    return [][]string{
+        {"fbarid"},
+        {"flpid"},
+        {"pid"},
+        {"intime"},
+        {"date"},
+        {"pastureid", "pid", "type"},
+        {"pastureid", "flpid", "type", "date"},
+    }
+}
+
+// 复合主键配置
+func (d *DownloadPlanDtl2) PrimaryKeys() []string {
+    return []string{"id", "pastureid", "date"}
+}
+
+// 获取ID的方法
+func (d *DownloadPlanDtl2) Id() int64 {
+    return d.ID
+}

BIN
tmr-watch.exe