浏览代码

圣牧自动补料

baishaojie 5 天之前
父节点
当前提交
6be1b5d701
共有 8 个文件被更改,包括 109 次插入57 次删除
  1. 二进制
      TMRWatchComm
  2. 二进制
      TMRWatchComm.zip
  3. 94 0
      app.ini
  4. 2 2
      conf/app-test.ini
  5. 5 49
      http/handle/api/ops.go
  6. 4 2
      http/handle/api/scheduled.go
  7. 4 4
      http/handle/ymy/ymy.go
  8. 二进制
      tmr-watch.exe

二进制
TMRWatchComm


二进制
TMRWatchComm.zip


+ 94 - 0
app.ini

@@ -0,0 +1,94 @@
+[app]
+PageSize = 10
+JwtSecret = 111111
+
+FileSavePath=uploads/files/
+FileMaxSize = 1000000
+FileAllowType = .jpg, .jpeg, .png, .ico, .svg, .bmp, .gif, .doc, .docx, .ppt, .pptx, .xls, .xlsx, .pdf, .mp3, .txt
+ImageSavePath=uploads/image/
+ExportSavePath=uploads/exportfiles/
+ImageMaxSize = 10
+ThumbnailSavePath=uploads/thumbnail/
+ThumbnailMaxWidth=800
+ThumbnailMaxHeight=800
+
+LogSavePath = logs/
+LogSaveName = log
+LogFileExt = log
+TimeFormat = 20060102-150405
+
+[server]
+#debug or release
+#RunMode = debug
+RunMode = release
+HttpPort = 8081
+ReadTimeout = 120
+WriteTimeout = 120
+NoAuth = 1
+Mdns_servicename = TMRWATCH
+Mdns_serviceport = 5354
+# 0 http 1 https 2 http & https 不填 http
+Https = 2
+HttpsPort = 443
+CrtPath = conf/ssl.crt
+KeyPath = conf/ssl.key
+
+# 服务
+ServerName = tmrgo
+DisplayName = tmrgo
+Description = tmrgo
+
+# 对接
+GRFD = 1
+GRFDURL = http://120.48.30.31:88
+SyncStatus = 9
+
+
+[database]
+Type = mysql
+User = root
+Password = root
+Host = mariadb:3306
+Name = tmrwatch2
+Password = root
+
+
+TablePrefix =
+
+ShowXormlog = false
+ShowGetSqllog = false
+CacheApiSql = false
+
+
+
+[comm]
+PortName =com3
+BaudRate = 9600
+DataBits = 8
+StopBits = 1
+ParityMode = 0    #PARITY_NONE  0	PARITY_ODD  1	PARITY_EVEN  2
+InterCharacterTimeout = 100
+MinimumReadSize = 0
+
+refix =
+
+ShowXormlog = false
+ShowGetSqllog = false
+CacheApiSql = false
+[comm]
+PortName =
+BaudRate = 9600
+DataBits = 8
+StopBits = 1
+ParityMode = 0    #PARITY_NONE  0	PARITY_ODD  1	PARITY_EVEN  2
+InterCharacterTimeout = 100
+MinimumReadSize = 0
+
+
+[yyn]
+#蓝浩
+FarmId = "1830004776"
+ProductKey = "k03txxLKFae"
+DeviceName = "04776_p_breed"
+DeviceSecret = "e1fdb50556b13afe896e738fdcb25bf3"
+HeartBeat = "Tmr183000477604776_p_breed"

+ 2 - 2
conf/app-test.ini

@@ -22,8 +22,8 @@ TimeFormat = 20060102-150405
 #RunMode = debuggit 
 RunMode = release
 HttpPort = 8081
-ReadTimeout = 60
-WriteTimeout = 60
+ReadTimeout = 260
+WriteTimeout = 260
 NoAuth = 1
 Mdns_servicename = TMRWATCH
 Mdns_serviceport = 5354

+ 5 - 49
http/handle/api/ops.go

@@ -5184,7 +5184,7 @@ 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 {
@@ -5197,7 +5197,7 @@ func FpdImportExcel(c *gin.Context) {
 				logs.Error(err)
 				return
 			}
-			// */
+			*/
 			updateFpdetailByBar(pastureid, barname, v)
 		}
 	} else {
@@ -10659,13 +10659,7 @@ func FpdBatchEditGrfd(pastureid string, barList []map[string]string) {
 		// dataexcel["6"] = barFsions.Get("times6").ValueStr()
 
 		// /*
-			// ftexist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ? and ftname = ?  `, dataexcel["barname"], pastureid, dataexcel["ftname"]).Exist()
-			// if err != nil {
-			// 	logs.Error(err)
-			// 	return
-			// }
-			// if !ftexist {
-			// 	fmt.Println(dataexcel["barname"], pastureid, dataexcel["ftname"])
+	
 				tx.SQL(` update  lpplandtl1  set lweight = 0  where barid = (select  id from bar where bname = ? ) and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
 				if err != nil {
 					logs.Error(err)
@@ -10676,49 +10670,11 @@ func FpdBatchEditGrfd(pastureid string, barList []map[string]string) {
 					logs.Error(err)
 					return
 				}
-			// _, 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
-		// 	}
-		// }
+			
 		// */
 
 		exist, err := tx.SQL(` select id from  feedp where barid = (select  id from bar where bname = ? ) and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
 		if err != nil {
-			fmt.Println("1111111111111111111")
 			logs.Error(err)
 			return
 		}
@@ -10726,7 +10682,6 @@ func FpdBatchEditGrfd(pastureid string, barList []map[string]string) {
 			_, err := tx.SQL(` insert into  feedp(pastureid,barid,barname,ccount)values(?,(select id from bar where  bname = ? and pastureid = ? ),?,?) `,
 				pastureid, dataexcel["barname"], pastureid, dataexcel["barname"], 0).Execute()
 			if err != nil {
-					fmt.Println("1111111111111111111")
 				logs.Error(err)
 				return
 			}
@@ -12692,3 +12647,4 @@ func GetLyUdData(c *gin.Context) {
 
 	// appG.Response(http.StatusOK, e.SUCCESS, fpdetailFnameList)
 }
+

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

@@ -105,7 +105,8 @@ func CronScheduled(ctx context.Context) {
 		}
 	})
 	dayCron.Start()
-	// manualUdData(pastureinfo)
+	// ymy.YmyCron(pastureinfo.Werks, pastureinfo.Pastureid)
+	
 	// 0 无同步 1 圣牧 2 现代牧业 3 新希望 4 乐源 5 光明ud 6 多语言京鹏ud 7 一牧云
 	if setting.ServerSetting.SyncStatus == 1 {
 		// 圣牧
@@ -1105,7 +1106,8 @@ func manualUdData(pastureinfo *udPastureInfo) {
 		up := tx.Table("scheduled_up")
 
 		up.Where("company = ? ", "ud")
-		up.Where("datatype in (3,4,1)")
+		// up.Where("datatype in (3,4,1)")
+		up.Where("datatype in (8)")
 		up.Where("automatic = 1")
 		err = up.Find(&upList)
 		if err != nil {

+ 4 - 4
http/handle/ymy/ymy.go

@@ -22,9 +22,9 @@ func YmyCron(farmId, pastureId string) {
 	date := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
 	// date := "2025-05-11"
 	YmyFeedtempletPush(pastureId, farmId, date)
-	YmyUtirPush(pastureId, farmId, date)
-	YmyMaterialIssuePush(pastureId, farmId, date)
-	YmySyncBar(farmId, pastureId)
+	// YmyUtirPush(pastureId, farmId, date)
+	// YmyMaterialIssuePush(pastureId, farmId, date)
+	// YmySyncBar(farmId, pastureId)
 	// YmySyncFeed(pastureId)
 	
 }
@@ -234,7 +234,7 @@ func YmyFeedtempletPush(pastureId, farmId, date string) error {
 	dataList, err := tx.SQL(`SELECT
 	ft.tcode AS recipeId,
 	ft.TNAME AS recipeName,
-	ifnull(f.feedcode,f.id)   AS ingId,
+	f.id   AS ingId,
 		''   AS feedCode,
 	ifnull(f.udname,f.fname) AS ingName,
 	round( fn.dry * ftd.FWEIGHT, 2 ) AS dmQty,

二进制
tmr-watch.exe