|
@@ -31,10 +31,23 @@ func SyncMaterialOutbound() error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
materialOutbound(pastureinfo.Pastureid, time.Now().AddDate(0, 0, -1).Format("2006-01-02"))
|
|
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
|
|
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) {
|
|
func SyncSapBar(c *gin.Context) {
|
|
appG := app.Gin{C: c}
|
|
appG := app.Gin{C: c}
|
|
dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
dataByte, _ := ioutil.ReadAll(c.Request.Body)
|
|
@@ -360,13 +373,15 @@ func surplusOutbound(pastureId, date string) error {
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
+ now, _ := time.ParseInLocation("2006-01-02", date, time.Local)
|
|
|
|
|
|
dataList, err := tx.SQL(`SELECT
|
|
dataList, err := tx.SQL(`SELECT
|
|
tem.sort ZEILE,
|
|
tem.sort ZEILE,
|
|
tem.feedname MAKTX,
|
|
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(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
|
|
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 (
|
|
FROM (
|
|
(SELECT
|
|
(SELECT
|
|
@@ -443,7 +458,7 @@ left join feed f on f.id = ftd.fid
|
|
HAVING d2.type = 0 order by b.sort,d2.fbarid)
|
|
HAVING d2.type = 0 order by b.sort,d2.fbarid)
|
|
|
|
|
|
) tem
|
|
) 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 {
|
|
if err != nil {
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
return err
|
|
return err
|
|
@@ -462,8 +477,6 @@ left join feed f on f.id = ftd.fid
|
|
}`
|
|
}`
|
|
databyte, _ := json.Marshal(dataList)
|
|
databyte, _ := json.Marshal(dataList)
|
|
|
|
|
|
- now, _ := time.ParseInLocation("2006-01-02", date, time.Local)
|
|
|
|
-
|
|
|
|
data = fmt.Sprintf(data, now.Format("20060102"), pastureinfo.Werks, string(databyte))
|
|
data = fmt.Sprintf(data, now.Format("20060102"), pastureinfo.Werks, string(databyte))
|
|
url := "https://app.modernfarming.cn:7443/sap/QAS/Feed/MM032/LeftoverEntry"
|
|
url := "https://app.modernfarming.cn:7443/sap/QAS/Feed/MM032/LeftoverEntry"
|
|
postPush(url, data, 0, tx, pastureId)
|
|
postPush(url, data, 0, tx, pastureId)
|