Browse Source

代码更新

baishaojie 4 months ago
parent
commit
de34946284

BIN
KPTAdmin64.exe


BIN
TMRWatchComm


BIN
TMRWatchComm.zip


BIN
__debug_bin.exe


+ 1 - 1
conf/app.ini

@@ -75,7 +75,7 @@ Host = 192.168.1.93:3326
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = grfd
+Name = tmrwatch5
 TablePrefix =
 
 ShowXormlog = false

+ 9 - 5
http/handle/api/grfdApi.go

@@ -476,7 +476,7 @@ func GetFormula(pastureid string) error {
 					logging.Info("create SnowIds err", err)
 				}
 
-				_, err = tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,backup1,backup2,tname,fttypeid,fttype)  values(?,?,(select ccid from feedtemplet where pastureid = ? limit 1),?,?,?,?,1,'饲喂配方') "+
+				_, err = tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,backup1,backup2,tname,fttypeid,fttype)  values(?,?,(select id from cowclass where pastureid = ? limit 1),?,?,?,?,1,'饲喂配方') "+
 					" ON DUPLICATE KEY UPDATE tcode=?,backup2= ?",
 					ids, pastureid, pastureid, ftId, ftId, modifiedAt, ftName, ftId, modifiedAt)
 
@@ -555,15 +555,15 @@ func AddOtherDevice() {
 		}
 	}()
 
-	queryIdList, err1 := tx.SQL(`SELECT d.pid +UNIX_TIMESTAMP(d.mydate) id,d.pid did,d.projname projName ,DATE_FORMAT(d.mydate,'%Y-%m-%d') mydate 
+	queryIdList, err1 := tx.SQL(`SELECT d.pid +UNIX_TIMESTAMP(d.mydate)  id,d.pid did,d.projname projName ,DATE_FORMAT(d.mydate,'%Y-%m-%d') mydate 
 	FROM downloadedplan d 
 	WHERE   (d.mydate=DATE_FORMAT(NOW(),'%Y-%m-%d')) 
 	AND d.isuse=0 
 	AND d.pastureid =(SELECT column_default  FROM information_schema.COLUMNS WHERE table_name = 'recweight' AND table_schema = 'tmrwatch2' AND column_name = 'pastureid')
 	AND (SELECT COUNT(*) FROM downloadplandtl1 d1 WHERE  d.id=d1.PID AND d.pastureid=d1.pastureid  AND  d1.type = 0)>0
 	AND (SELECT COUNT(*) FROM downloadedplan WHERE pastureid = d.pastureid AND    lpplantype in(0,1,5)  and mydate = d.mydate AND pid = d.pid AND iscompleted = 0) = 0
-	and d.lpplantype in(0,1,5)  and d.iscompleted = 1
-	GROUP BY d.pid +UNIX_TIMESTAMP(d.mydate)`).Query().List()
+	and d.lpplantype in(0,1)  and d.iscompleted = 1
+	GROUP BY d.pid +UNIX_TIMESTAMP(d.mydate) `).Query().List()
 
 	queryDataList, err2 := tx.SQL(`SELECT  d.pid +UNIX_TIMESTAMP(d.mydate) id,d.projname projName,ROUND(d.lweight,2) lWeight,DATE_FORMAT(d.mydate,'%Y-%m-%d') AS loadDate,d.SORT AS tmrNo,d.Times AS times,ft.backup1 AS ftId,d.templetName  AS ftName,f.backup1 AS fId,
 		 de.Fname AS fName,fc.FCNAME AS feedclassName,de.SORT AS sort,de.feedallowratio AS allowableError, 
@@ -577,7 +577,7 @@ func AddOtherDevice() {
 		 AND (SELECT COUNT(*) FROM downloadplandtl1 d1 WHERE  d.id=d1.PID AND d.pastureid=d1.pastureid  AND  d1.type = 0)>0
 		 AND (SELECT COUNT(*) FROM downloadedplan WHERE pastureid = d.pastureid  and  lpplantype in(0,1,5)  and mydate = d.mydate AND pid = d.pid AND iscompleted = 0) = 0
 		 and d.lpplantype in(0,1,5)   and d.iscompleted = 1
-		  group by d.pid,de.Fname,d.mydate`).Query().List()
+		  group by d.pid,de.Fname,d.mydate `).Query().List()
 
 	if err1 == nil && err2 == nil {
 		for i := 0; i < len(queryIdList); i++ {
@@ -771,6 +771,10 @@ func CronGRFD() {
 	}()
 	log.Println("Starting CronWXwork...")
 	c := cron.New()
+	//上传饲料
+	AddOtherDevice()
+	//上传栏舍
+	AddOtherDeviceFeeding()
 	err := c.AddFunc("0/30 * * * *", PostTmrData) //* * * * *, 从分钟开始 每30分钟执行一次
 	if err != nil {
 		println("cron4 err", err.Error())

+ 10 - 2
http/handle/api/lpplandtl.go

@@ -348,7 +348,11 @@ func RestoreLpplandtlDay(c *gin.Context) {
 
 	tx.Begin()
 
+	// var wg sync.WaitGroup
 	for _, item := range req.New {
+		// wg.Add(1)
+		// go func(item *lpplandtl) {
+		// defer wg.Done()
 		if len(item.Lweight) > 0 {
 			item.Lweight = fmt.Sprintf("-%s", item.Lweight)
 		}
@@ -369,9 +373,13 @@ func RestoreLpplandtlDay(c *gin.Context) {
 			tx.Rollback()
 			return
 		}
+		// }(item)
 	}
 
 	for _, item := range req.Old {
+		// wg.Add(1)
+		// go func(item *lpplandtl) {
+		// 	defer wg.Done()
 		_, err := tx.SQL(` UPDATE fpdetaildate SET ptuse=IF(?=1,IF(ptuse+? <0,0,ptuse+?),ptuse),ptsuse=IF(?=0,IF(ptsuse+?<0,0,ptsuse+?),ptsuse)
 			WHERE pastureid=? AND id=? `, item.Fttype, item.Lweight, item.Lweight, item.Fttype, item.Lweight, item.Lweight, item.Pastureid, item.Fpdid).Execute()
 		if err != nil {
@@ -379,8 +387,6 @@ func RestoreLpplandtlDay(c *gin.Context) {
 			tx.Rollback()
 			return
 		}
-
-		// tx.Table("lpplandtl1").Insert(item)
 		_, err = tx.SQL(`insert into lpplandtl1date(pastureid,lppid,barid,barname,fpdid,fttype,lweight,sort,tmrid,tmrname,ccountradio,background,date)
 		value(?,?,?,?,?,?,?,?,?,?,?,?,?) 	  
 		ON DUPLICATE KEY UPDATE lweight = ? `, item.Pastureid,
@@ -401,8 +407,10 @@ func RestoreLpplandtlDay(c *gin.Context) {
 			tx.Rollback()
 			return
 		}
+		// }(item)
 	}
 
+	// wg.Wait()
 	err := tx.Commit()
 	if err != nil {
 		log.Println("RestoreLpplandtl-error-6: ", err)

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

@@ -135,11 +135,11 @@ func CronScheduled(ctx context.Context) {
 	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
 	// xdmy := cron.New()
 	// err = xdmy.AddFunc("0 30 4 * * *", func() {
-	// 	// 	//现代牧业sap同步
-	// sap.SyncMaterialOutbound()
-	// 	// 	// 光明ud同步
-	// 	// 	fmt.Println(time.Now())
-	// 	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
+	// 	// 	// 	//现代牧业sap同步
+	// 	// sap.SyncMaterialOutbound()
+	// 	// 	// 	// 光明ud同步
+	// 	// 	// 	fmt.Println(time.Now())
+	// 	gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
 	// })
 	// err = xdmy.AddFunc("0 10 17 * * *", func() {
 	// 	sap.SyncSurplusOutbound()

+ 1 - 1
http/handle/gm/udservice.go

@@ -265,7 +265,7 @@ d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) F
 		where dd.mydate= date_format(?,'%Y-%m-%d')  and dd.lpplanType in (0,1) ) d1 on d1.lppid = d.pid
 
 	LEFT JOIN feedp fp on d2.FBarID=fp.barid
-	left join bar b on fp.barid = b.id and d.pastureid = b.pastureid
+	join bar b on fp.barid = b.id and d.pastureid = b.pastureid
 	left join feed f   on f.feedcode  = d1.feedcode
 	left JOIN feedtempletdate ft on d.tempid=ft.id and  ft.date =  d1.date   and d.tversion = ft.version           
 	left join feedtempletdate  ft1 on   d1.feedcode = '-1'  and ft1.date = d1.date and ft1.id = d1.fid