baishaojie пре 8 месеци
родитељ
комит
b40b92e402

+ 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 = tmrwatch5
+Name = tmrwatchenglish
 TablePrefix =
 
 ShowXormlog = false

+ 6 - 1
http/handle/api/scheduled.go

@@ -16,6 +16,7 @@ import (
 
 	"tmr-watch/conf/setting"
 	"tmr-watch/http/handle/restful"
+	"tmr-watch/http/handle/sap"
 	"tmr-watch/pkg/app"
 	"tmr-watch/pkg/e"
 	"tmr-watch/pkg/logging"
@@ -141,7 +142,11 @@ func CronScheduled(ctx context.Context) {
 	// 	// 	fmt.Println(time.Now())
 	// 	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
 	// })
-	// xdmy.Start()
+	// err = xdmy.AddFunc("0 10 17 * * *", func() {
+	// 	sap.SyncSurplusOutbound()
+	// })
+
+	xdmy.Start()
 	// InitMqttClient()
 	// yq.YqCron()
 }

+ 1 - 1
http/handle/api/user.go

@@ -59,7 +59,7 @@ func Auth(c *gin.Context) {
 	if !isExist {
 		isExist, err = authService.MD5Check()
 		if !isExist {
-			appG.Response(http.StatusOK, e.ERROR_AUTH, "密码错误!")
+			appG.Response(http.StatusOK, e.ERROR_AUTH, "Password error!")
 			return
 		}
 	}

+ 18 - 5
http/handle/sap/sap.go

@@ -31,10 +31,23 @@ func SyncMaterialOutbound() error {
 		return err
 	}
 	materialOutbound(pastureinfo.Pastureid, time.Now().AddDate(0, 0, -1).Format("2006-01-02"))
-	surplusOutbound(pastureinfo.Pastureid, time.Now().AddDate(0, 0, -1).Format("2006-01-02"))
 	return nil
 }
 
+func SyncSurplusOutbound() error {
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	pastureinfo := new(udPastureInfo)
+	err := tx.SQL(`select column_default  as pastureid   from    information_schema.COLUMNS
+	WHERE table_name = 'recweight' AND table_schema = ? AND column_name = 'pastureid'`, setting.DatabaseSetting.Name).GetFirst(pastureinfo).Error
+	if err != nil {
+		logs.Error(err)
+		return err
+	}
+	surplusOutbound(pastureinfo.Pastureid, time.Now().Format("2006-01-02"))
+}
+
 func SyncSapBar(c *gin.Context) {
 	appG := app.Gin{C: c}
 	dataByte, _ := ioutil.ReadAll(c.Request.Body)
@@ -360,13 +373,15 @@ func surplusOutbound(pastureId, date string) error {
 		logs.Error(err)
 		return err
 	}
+	now, _ := time.ParseInLocation("2006-01-02", date, time.Local)
 
 	dataList, err := tx.SQL(`SELECT 
 	tem.sort ZEILE,
 	tem.feedname MAKTX,
 	ifnull(ROUND(if(tem.lweight<0,0,tem.lweight),(select  inforvalue from sysopt  where inforname="decimalPlaces" and pastureid =? )),0)lweight,
 	ifnull(ROUND(tem.actualweightminus,(select  inforvalue from sysopt  where inforname="decimalPlaces" and pastureid = ?)),0) MENGE
-	,tem.bname CHSTX,tem.sapcode CHSNO,tem.cattle FCWTS,(select  inforvalue from sysopt  where inforname="excess" and pastureid = ?) MATNR,tem.sapGoods LGORT
+	,tem.bname CHSTX,tem.sapcode CHSNO,tem.cattle FCWTS,(select  inforvalue from sysopt  where inforname="excess" and pastureid = ?) MATNR,tem.sapGoods LGORT,
+	? WERKS , ? BUDAT
 
 	 FROM (
 	(SELECT 
@@ -443,7 +458,7 @@ left join feed f on f.id = ftd.fid
 	HAVING d2.type = 0  order by b.sort,d2.fbarid)
 	
 	) tem
-	ORDER BY tem.d2sort,tem.feedname     `, pastureId, pastureId, pastureId, pastureId, date, pastureId, date).Query().List()
+	ORDER BY tem.d2sort,tem.feedname     `, pastureId, pastureId, pastureId, pastureinfo.Werks, now.Format("20060102"), pastureId, date, pastureId, date).Query().List()
 	if err != nil {
 		logs.Error(err)
 		return err
@@ -462,8 +477,6 @@ left join feed f on f.id = ftd.fid
 	  }`
 	databyte, _ := json.Marshal(dataList)
 
-	now, _ := time.ParseInLocation("2006-01-02", date, time.Local)
-
 	data = fmt.Sprintf(data, now.Format("20060102"), pastureinfo.Werks, string(databyte))
 	url := "https://app.modernfarming.cn:7443/sap/QAS/Feed/MM032/LeftoverEntry"
 	postPush(url, data, 0, tx, pastureId)

BIN
uploads/file/导入导出模板.zip