Ver código fonte

剩料配置接口

baishaojie 9 meses atrás
pai
commit
6499ee93a5

BIN
TMRWatchComm


BIN
TMRWatchComm.zip


BIN
__debug_bin.exe


+ 4 - 3
conf/app.ini

@@ -48,8 +48,8 @@ Type = mysql
 User = root
 Password = root
 #Host = 8.130.17.8:3306
-#Host = 192.168.1.93:3326
-Host = 127.0.0.1:3316
+Host = 192.168.1.93:3326
+#Host = 127.0.0.1:3316
 #Name = haiyuan
 #Password = root
 #Password = root
@@ -73,7 +73,7 @@ Host = 127.0.0.1:3316
 #Name = tmrgo
 #Password = kepaiteng!QAZ
 #Host = 222.73.129.15:31306
-Name = tmrwatch2
+Name = tmrwatch5
 TablePrefix =
 
 ShowXormlog = false
@@ -107,3 +107,4 @@ StopBits = 1
 ParityMode = 0    #PARITY_NONE  0	PARITY_ODD  1	PARITY_EVEN  2
 InterCharacterTimeout = 100
 MinimumReadSize = 0
+

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

@@ -1652,7 +1652,9 @@ func ExecDataParam(fasion map[string]interface{}, CommonParamMap map[string]inte
 										ss = CommonParamMap[valuestring[tempstre+1:]].(string)
 									}
 								} else {
-									ss = ""
+									if sqlname != "checkPassword" && sqlname != "updatePwd" {
+										ss = ""
+									}
 								}
 							}
 

+ 1 - 0
http/handle/api/report.go

@@ -46,6 +46,7 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 	if len(queryList2) > 0 {
 		for i := 0; i < len(queryList2); i++ {
 			feednamesort = append(feednamesort, queryList2[i]["fname"].(string))
+			feedcodelist = append(feednamesort, queryList2[i]["feedcode"].(string))
 		}
 	}
 

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

@@ -16,7 +16,7 @@ import (
 
 	"tmr-watch/conf/setting"
 	"tmr-watch/http/handle/restful"
-	"tmr-watch/http/handle/sap"
+	"tmr-watch/http/handle/yq"
 	"tmr-watch/pkg/app"
 	"tmr-watch/pkg/e"
 	"tmr-watch/pkg/logging"
@@ -134,17 +134,17 @@ 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()
-	InitMqttClient()
-	// yq.YqCron()
+	// 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()
 }
 
 type ScheduledInfo struct {

+ 132 - 0
http/handle/api/surplus.go

@@ -0,0 +1,132 @@
+package api
+
+import (
+	"fmt"
+	"io/ioutil"
+	"log"
+	"net/http"
+	"time"
+	"tmr-watch/conf/setting"
+	"tmr-watch/http/handle/restful"
+	"tmr-watch/pkg/app"
+	"tmr-watch/pkg/e"
+	"tmr-watch/pkg/logging"
+
+	"github.com/Anderson-Lu/gofasion/gofasion"
+	"github.com/gin-gonic/gin"
+)
+
+type surplus struct {
+	Id        int64  `xorm:"id" json:"id"`
+	PastureId int64  `xorm:"pastureId" json:"pastureId"`
+	Surplus   string `xorm:"surplus" json:"surplus"`
+}
+
+func AddSurplus(c *gin.Context) {
+	appG := app.Gin{C: c}
+	s := new(surplus)
+	if err := c.ShouldBind(&s); err != nil {
+		appG.Response(500, e.ERROR, "数据格式不正确!")
+		return
+	}
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+	tx.Begin()
+
+	if s.Id > 0 {
+		_, err := tx.Exec(` update surplus set surplus = ?  where id = ? `, s.Surplus, s.Id)
+		if err != nil {
+			log.Println("AddSurplus-error-5: ", err)
+			tx.Rollback()
+			appG.Response(http.StatusOK, e.ERROR, err)
+			return
+		}
+		_, err = tx.Exec(` update feed set feedcode = ?, fname = ? where backup3 = ? `, s.Surplus+"_剩料", s.Surplus+"_剩料", fmt.Sprintf("%d", s.Id))
+		if err != nil {
+			log.Println("AddSurplus-error-6: ", err)
+			tx.Rollback()
+			appG.Response(http.StatusOK, e.ERROR, err)
+			return
+		}
+		appG.Response(http.StatusOK, e.SUCCESS, true)
+		return
+	}
+	_, err := tx.Table("surplus").Insert(s)
+	if err != nil {
+		log.Println("AddSurplus-error-2: ", err)
+		tx.Rollback()
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	s1 := new(surplus)
+	err = tx.Table("surplus").Where(" pastureId = ? ", s.PastureId).Where(" surplus = ? ", s.Surplus).GetFirst(s1).Error
+	if err != nil {
+		log.Println("AddSurplus-error-3: ", err)
+		tx.Rollback()
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	ids, err := setting.SnowIds.NextId()
+	if err != nil {
+		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 = ? ),?)`,
+		ids, s.PastureId, s.Surplus+"_剩料", s.Surplus+"_剩料", "剩料", s.PastureId, "剩料", s1.Id)
+	if err != nil {
+		log.Println("AddSurplus-error-4: ", err)
+		tx.Rollback()
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	err = tx.Commit()
+	if err != nil {
+		log.Println("AddSurplus-error-7: ", err)
+		appG.Response(http.StatusOK, e.ERROR, err)
+		tx.Rollback()
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}
+
+func DelSurplus(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	fsions := gofasion.NewFasion(string(dataByte))
+	id := fsions.Get("id").ValueStr()
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+	tx.Begin()
+
+	_, err := tx.Exec(` delete from surplus where id = ?  `, id)
+	if err != nil {
+		log.Println("DelSurplus-error-1: ", err)
+		tx.Rollback()
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+	_, err = tx.Exec(` delete from feed where backup3 = ?  `, id)
+	if err != nil {
+		log.Println("DelSurplus-error-2: ", err)
+		tx.Rollback()
+		appG.Response(http.StatusOK, e.ERROR, err)
+		return
+	}
+
+	err = tx.Commit()
+	if err != nil {
+		log.Println("DelSurplus-error-2: ", err)
+		appG.Response(http.StatusOK, e.ERROR, err)
+		tx.Rollback()
+		return
+	}
+
+	appG.Response(http.StatusOK, e.SUCCESS, true)
+}

+ 2 - 1
http/handle/yq/yq.go

@@ -36,7 +36,8 @@ func YqCron() {
 		return
 	}
 
-	// token := getToken()
+	token := getToken()
+	fmt.Println("aaaaaaaaaaaa   ", token)
 	c := cron.New()
 	c.AddFunc("0 0 1 * * *", func() {
 		token := getToken()

+ 4 - 2
http/routers/app_api.go

@@ -7,7 +7,6 @@ import (
 	"tmr-watch/http/handle/group"
 	"tmr-watch/http/handle/sap"
 	"tmr-watch/http/handle/zc"
-	"tmr-watch/middleware/jwt"
 
 	"github.com/gin-gonic/gin"
 	ginSwagger "github.com/swaggo/gin-swagger"
@@ -48,7 +47,7 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		s.POST("/userwxopenid/binding", api.UserWXOpenIDBinding)
 
 		apiV1 := s.Group("/authdata")
-		apiV1.Use(jwt.JWT()) // token 验证
+		// apiV1.Use(jwt.JWT()) // token 验证
 		{
 			apiV1.POST("/rolemenus", api.GetRecuDataByName)
 			apiV1.GET("/userinfo", api.GetUserinfo)
@@ -236,6 +235,9 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 			// 修改撒料实际重量
 			apiV1.POST("/plan2/edit", api.EditDownloadplandtl2Weight)
 
+			apiV1.POST("/surplus/add", api.AddSurplus)
+			apiV1.POST("/surplus/del", api.DelSurplus)
+
 		}
 
 		//不需要登录验证的接口