baishaojie 1 rok pred
rodič
commit
cb5469f64f

BIN
TMRWatchComm


BIN
TMRWatchComm.zip


BIN
__debug_bin.exe


+ 21 - 3
http/handle/api/ops.go

@@ -1062,7 +1062,9 @@ func PostDataByName(c *gin.Context) {
 		keyWord = "cow_delete"
 		err = module.GroupCategoryDelete(keyWord, fsion)
 	case "updateFT":
-		// FtdetailSurplus(fsion)
+		FtdetailSurplus(fsion)
+	case "updateFeed":
+		FeedSurplus(fsion)
 	default:
 	}
 	if err != nil {
@@ -9000,10 +9002,16 @@ func FtdetailSurplus(fasion *gofasion.Fasion) {
 					break
 				}
 			}
-			for _, ft := range ftList {
-				if ft.Sort > sort {
+			if sort == 0 {
+				for _, ft := range ftList {
 					ft.Sort = ft.Sort + 1
 				}
+			} else {
+				for _, ft := range ftList {
+					if ft.Sort > sort {
+						ft.Sort = ft.Sort + 1
+					}
+				}
 			}
 			for _, ft := range ftList {
 				tx.Exec(` update ftdetail set sort = ? where id = ? `, ft.Sort, ft.Id)
@@ -9020,3 +9028,13 @@ func FtdetailSurplus(fasion *gofasion.Fasion) {
 		}
 	}
 }
+
+func FeedSurplus(fasion *gofasion.Fasion) {
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	params := fasion.Get("parammaps")
+	feedId := params.Get("id").ValueStr()
+	tx.Exec(` update surplus set surplus = (select fname from feed where id = ? )  where feedId = ? `, feedId, feedId)
+	tx.Exec(` update feed set fname = concat((select id from surplus    where feedId = ? ) ,'_剩料')  where backup3 = (select id from surplus    where feedId = ? )`, feedId, feedId)
+}

+ 9 - 10
http/handle/api/scheduled.go

@@ -15,7 +15,6 @@ import (
 	"time"
 
 	"tmr-watch/conf/setting"
-	"tmr-watch/http/handle/gm"
 	"tmr-watch/http/handle/restful"
 	"tmr-watch/pkg/app"
 	"tmr-watch/pkg/e"
@@ -134,15 +133,15 @@ func CronScheduled(ctx context.Context) {
 	// //圣牧自动同步前天有进行中的任务
 	// manualUdData(pastureinfo)
 	// 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)
-	})
-	xdmy.Start()
+	// xdmy := cron.New()
+	// err = xdmy.AddFunc("0 30 4 * * *", func() {
+	// 	// 	//现代牧业sap同步
+	// 	// sap.SyncMaterialOutbound()
+	// 	// 	// 光明ud同步
+	// 	// 	fmt.Println(time.Now())
+	// 	gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
+	// })
+	// xdmy.Start()
 	// InitMqttClient()
 	// yq.YqCron()
 }

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

@@ -20,6 +20,7 @@ type surplus struct {
 	Id        int64  `xorm:"id" json:"id"`
 	PastureId int64  `xorm:"pastureId" json:"pastureId"`
 	Surplus   string `xorm:"surplus" json:"surplus"`
+	FeedId    string `xorm:"feedId" json:"feedId"`
 }
 
 func AddSurplus(c *gin.Context) {
@@ -35,7 +36,7 @@ func AddSurplus(c *gin.Context) {
 	tx.Begin()
 
 	if s.Id > 0 {
-		_, err := tx.Exec(` update surplus set surplus = ?  where id = ? `, s.Surplus, s.Id)
+		_, err := tx.Exec(` update surplus set surplus = ?,feedId = ?   where id = ? `, s.Surplus, s.FeedId, s.Id)
 		if err != nil {
 			log.Println("AddSurplus-error-5: ", err)
 			tx.Rollback()
@@ -74,7 +75,8 @@ func AddSurplus(c *gin.Context) {
 		ids = time.Now().UnixNano()
 		logging.Info("create SnowIds err", err)
 	}
-	_, err = tx.Exec(`insert into feed(id,pastureid,feedcode,fname,fclass,fclassid,backup3)values(?,?,?,?,?,(select id from feedclass where pastureid = ? and fcname = ? ),?)`,
+	_, err = tx.Exec(`insert into feed(id,pastureid,feedcode,fname,fclass,fclassid,backup3,is_surplus)values(?,?,?,?,?,
+		(select id from feedclass where pastureid = ? and fcname = ? ),?,1)`,
 		ids, s.PastureId, s.Surplus+"_剩料", s.Surplus+"_剩料", "剩料", s.PastureId, "剩料", s1.Id)
 	if err != nil {
 		log.Println("AddSurplus-error-4: ", err)