Browse Source

配方模板删除提交

baishaojie 1 year ago
parent
commit
1022427d4e
5 changed files with 69 additions and 62 deletions
  1. BIN
      __debug_bin.exe
  2. 55 55
      http/handle/api/ops.go
  3. 0 2
      http/handle/api/scheduled.go
  4. 12 4
      http/handle/gm/udservice.go
  5. 2 1
      http/routers/app_api.go

BIN
__debug_bin.exe


+ 55 - 55
http/handle/api/ops.go

@@ -8416,32 +8416,32 @@ func DelFeedTemplet(c *gin.Context) {
 	dataByte, _ := ioutil.ReadAll(c.Request.Body)
 	fsions := gofasion.NewFasion(string(dataByte))
 	ftId := fsions.Get("ftId").ValueStr()
-	userId := fsions.Get("userId").ValueStr()
+	// userId := fsions.Get("userId").ValueStr()
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	_, err := tx.Exec(` update feedtemplet set enable = 1 and isdelete = 1  where id = ? `, ftId)
+	_, err := tx.Exec(` update feedtemplet set enable = 1 , isdelete = 1  where id = ? `, ftId)
 	if err != nil {
 		logs.Error(err)
 		appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
 		return
 	}
 
-	barIdList, err := tx.SQL(`select barid from feedp where ftid = ? `, ftId).QueryString()
-	if err != nil {
-		logs.Error(err)
-		appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
-		return
-	}
+	// barIdList, err := tx.SQL(`select barid from feedp where ftid = ? `, ftId).QueryString()
+	// if err != nil {
+	// 	logs.Error(err)
+	// 	appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
+	// 	return
+	// }
 
-	_, err = tx.Exec(` update feedp set ftid = 0 and ftname = '',feedweight = 0,ftweight = 0,  where ftid = ? `, ftId)
+	_, err = tx.Exec(` update feedp set ftid = 0 , ftname = '',feedweight = 0,ftweight = 0  where ftid = ? `, ftId)
 	if err != nil {
 		logs.Error(err)
 		appG.Response(http.StatusOK, e.ERROR, errors.New("删除栏舍配方失败"))
 		return
 	}
 
-	_, err = tx.Exec(` update fpdetail set weight = ? ,ptid =  0,ptuse= 0   where ftid = ? `, ftId)
+	_, err = tx.Exec(` update fpdetail set weight = 0 ,ptid =  0,ptuse= 0   where ptid = ? `, ftId)
 	if err != nil {
 		logs.Error(err)
 		appG.Response(http.StatusOK, e.ERROR, errors.New("删除栏舍配方失败"))
@@ -8464,56 +8464,56 @@ func DelFeedTemplet(c *gin.Context) {
 		return
 	}
 
-	var barIdStr []string
-	for _, bar := range barIdList {
-		barIdStr = append(barIdStr, bar["barid"])
-	}
+	// var barIdStr []string
+	// for _, bar := range barIdList {
+	// 	barIdStr = append(barIdStr, bar["barid"])
+	// }
 
-	if len(barIdStr) > 0 {
+	// if len(barIdStr) > 0 {
 
-		newFpdDataList, err := tx.Table("fpdetail").In(`barid`, barIdStr).Query().List()
-		if err != nil {
-			logs.Error(err)
-			appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
-			return
-		}
+	// 	newFpdDataList, err := tx.Table("fpdetail").Where(`barid in(?)`, barIdStr).Query().List()
+	// 	if err != nil {
+	// 		logs.Error(err)
+	// 		appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
+	// 		return
+	// 	}
 
-		newFeedpList, err := tx.Table("feedp").In(`barid`, barIdStr).Query().List()
-		if err != nil {
-			logs.Error(err)
-			appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
-			return
-		}
+	// 	newFeedpList, err := tx.Table("feedp").Where(`barid in(?)`, barIdStr).Query().List()
+	// 	if err != nil {
+	// 		logs.Error(err)
+	// 		appG.Response(http.StatusOK, e.ERROR, errors.New("删除失败!!!"))
+	// 		return
+	// 	}
 
-		now := time.Now()
-		for _, newFpd := range newFpdDataList {
-			_, err := tx.SQL(` insert into fpdetailhistory(pastureid,barid,barname,times,tratio,weight,ptsrate,cowcount,ccountradio,ptid,ptsid,ptuse,ptsuse,supplement,createdate,userId)
-					 values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, newFpd["pastureid"], newFpd["barid"], newFpd["barname"], newFpd["times"],
-				newFpd["tratio"], newFpd["weight"], newFpd["ptsrate"], newFpd["cowcount"], newFpd["ccountradio"],
-				newFpd["ptid"], newFpd["ptsid"], newFpd["ptuse"], newFpd["ptsuse"], newFpd["supplement"], now, userId).Execute()
-			if err != nil {
-				logs.Error(err)
-				appG.Response(http.StatusOK, e.ERROR, false)
-				return
-			}
-		}
+	// 	now := time.Now()
+	// 	for _, newFpd := range newFpdDataList {
+	// 		_, err := tx.SQL(` insert into fpdetailhistory(pastureid,barid,barname,times,tratio,weight,ptsrate,cowcount,ccountradio,ptid,ptsid,ptuse,ptsuse,supplement,createdate,userId)
+	// 				 values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, newFpd["pastureid"], newFpd["barid"], newFpd["barname"], newFpd["times"],
+	// 			newFpd["tratio"], newFpd["weight"], newFpd["ptsrate"], newFpd["cowcount"], newFpd["ccountradio"],
+	// 			newFpd["ptid"], newFpd["ptsid"], newFpd["ptuse"], newFpd["ptsuse"], newFpd["supplement"], now, userId).Execute()
+	// 		if err != nil {
+	// 			logs.Error(err)
+	// 			appG.Response(http.StatusOK, e.ERROR, false)
+	// 			return
+	// 		}
+	// 	}
 
-		for _, newFeedp := range newFeedpList {
-			_, err := tx.SQL(` insert into feedphistory(pastureid,barname,barid,softccount,ccount,ratio,ccountratio,ftid,
-					ftname,ptsfid,ptsfname,feedweight,ftweight,supplyweight,owner,createdate,userId)
-				values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
-				newFeedp["pastureid"], newFeedp["barname"], newFeedp["barid"],
-				newFeedp["softccount"], newFeedp["ccount"], newFeedp["ratio"],
-				newFeedp["ccountratio"], newFeedp["ftid"], newFeedp["ftname"],
-				newFeedp["ptsfid"], newFeedp["ptsfname"], newFeedp["feedweight"],
-				newFeedp["ftweight"], newFeedp["supplyweight"], newFeedp["owner"], now, userId).Execute()
-			if err != nil {
-				logs.Error(err)
-				appG.Response(http.StatusOK, e.ERROR, false)
-				return
-			}
-		}
-	}
+	// 	for _, newFeedp := range newFeedpList {
+	// 		_, err := tx.SQL(` insert into feedphistory(pastureid,barname,barid,softccount,ccount,ratio,ccountratio,ftid,
+	// 				ftname,ptsfid,ptsfname,feedweight,ftweight,supplyweight,owner,createdate,userId)
+	// 			values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
+	// 			newFeedp["pastureid"], newFeedp["barname"], newFeedp["barid"],
+	// 			newFeedp["softccount"], newFeedp["ccount"], newFeedp["ratio"],
+	// 			newFeedp["ccountratio"], newFeedp["ftid"], newFeedp["ftname"],
+	// 			newFeedp["ptsfid"], newFeedp["ptsfname"], newFeedp["feedweight"],
+	// 			newFeedp["ftweight"], newFeedp["supplyweight"], newFeedp["owner"], now, userId).Execute()
+	// 		if err != nil {
+	// 			logs.Error(err)
+	// 			appG.Response(http.StatusOK, e.ERROR, false)
+	// 			return
+	// 		}
+	// 	}
+	// }
 	appG.Response(http.StatusOK, e.SUCCESS, "ok")
 }
 

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

@@ -130,8 +130,6 @@ func CronScheduled(ctx context.Context) {
 	})
 	dayCron.Start()
 
-	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
-	//
 	// //圣牧自动同步前天有进行中的任务
 	manualUdData(pastureinfo)
 

+ 12 - 4
http/handle/gm/udservice.go

@@ -232,18 +232,26 @@ ifnull(ROUND(d2.lweight * (d1.actualweightminus/ (select sum(actualweightminus)
 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),"") as tmrName ,d.tmrtname equipmentId ,
 d1.fname,
-  ifnull(TRIM(if(( select sum(dd2.actualweightminus) from downloadplandtl2 dd2 where dd2.pid = d2.pid) >0 ,   ROUND( d2.actualweightminus/( select sum(dd2.actualweightminus) from downloadplandtl2 dd2 where dd2.pid = d2.pid) * (d1.actualweightminus ),2), ROUND( d2.lweight/( select sum(dd2.lweight) from downloadplandtl2 dd2 where dd2.pid = d2.pid) * (d1.actualweightminus ),2))),0) feedWeight
+ifnull(TRIM(if(d1.feedcode != '-1', if ( (SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date) > 0 ,
+d2.actualweightminus/(SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  )),
+  
+   d2.lweight/(SELECT SUM(lweight) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
+d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  ))
+  ),'')),0) feedWeight
 
+
+  
 	,ifnull(ftd.sort,"") premixFeedSort ,
 	 ifnull((select feedcode from feed where id = ftd.fid),"") premixFeedId,ifnull(ftd.fname,"")  premixFeedName,
 	 
  
  	ifnull(if(d1.feedcode = '-1', if ( (SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date) > 0 ,
   d2.actualweightminus/(SELECT SUM(actualweightminus) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
-  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetail ftd2 WHERE ftd2.pastureid =d1.pastureid AND ftd2.ftid = d1.fid )),
+  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  )),
 	
 	 d2.lweight/(SELECT SUM(lweight) FROM downloadplandtl2  d2t WHERE d2t.pastureid = d2.pastureid AND d2t.flpid = d2.flpid AND d2t.type = 0 AND d2t.date = d2.date)*
-  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ft.version and ft.id = ftd2.ftid  ))
+  d1.actualweightminus*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdetaildate ftd2 WHERE  ftd2.date = d1.date AND ftd2.version = ftd.version  AND ftd2.ftid = d1.fid  ))
 	),''),'')
   premixFeedWeight
 	
@@ -258,7 +266,7 @@ d1.fname,
 	left JOIN feedtempletdate ft on d.tempid=ft.id and  ft.date =  d1.date           
 		left join ftdetaildate  ftd  on  ftd.date =  d1.date and ftd.ftid = d1.fid
 
-	where d.mydate= date_format(?,'%Y-%m-%d')  and d.lpplanType!=1 and d.havebutton = 1 and d.pastureid = ?  and d1.fname is not null  order by tmrno   `, now, now, pastureId).Query().List()
+	where d.mydate= date_format(?,'%Y-%m-%d')  and d2.type = 0   and d.havebutton = 1  and d.pastureid = ?  and d1.fname is not null  order by tmrno   `, now, now, pastureId).Query().List()
 	if err != nil {
 		logging.Error(err)
 		return err

+ 2 - 1
http/routers/app_api.go

@@ -216,7 +216,6 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 			apiV1.GET("/tmrequipment", api.GetTmrEquipment)
 
 			//光明ud手动上传
-
 			apiV1.POST("/gm/udbar", api.UdBarSync)
 			apiV1.POST("/gm/udfeed", api.UdFeedSync)
 			apiV1.POST("/gm/udfeedtemplet/push", api.UdFeedtempletPush)
@@ -225,6 +224,8 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 			apiV1.POST("/gm/udbarfeedremain/push", api.UdBarFeedRemainPush)
 			apiV1.POST("/gm/udmaterialIssue/push", api.UdMaterialIssuePush)
 
+			apiV1.POST("/feedtemplet/del", api.DelFeedTemplet)
+
 		}
 
 		//不需要登录验证的接口