|
|
@@ -15,7 +15,11 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"tmr-watch/conf/setting"
|
|
|
+ "tmr-watch/http/handle/gm"
|
|
|
+ "tmr-watch/http/handle/jpud"
|
|
|
"tmr-watch/http/handle/restful"
|
|
|
+ "tmr-watch/http/handle/sap"
|
|
|
+ "tmr-watch/http/handle/ymy"
|
|
|
"tmr-watch/pkg/app"
|
|
|
"tmr-watch/pkg/e"
|
|
|
"tmr-watch/pkg/logging"
|
|
|
@@ -130,26 +134,84 @@ func CronScheduled(ctx context.Context) {
|
|
|
})
|
|
|
dayCron.Start()
|
|
|
|
|
|
- // jpud.JPUDUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
- // udFeedSync(pastureinfo)
|
|
|
+ // 0 无同步 1 圣牧 2 现代牧业 3 新希望 4 乐源 5 光明ud 6 多语言京鹏ud 7 一牧云
|
|
|
+ if setting.ServerSetting.SyncStatus == 1 {
|
|
|
+ // 圣牧
|
|
|
+ manualUdData(pastureinfo)
|
|
|
+ InitMqttClient()
|
|
|
+ } else if setting.ServerSetting.SyncStatus == 2 {
|
|
|
+ xdmy := cron.New()
|
|
|
+ err = xdmy.AddFunc("0 05 7 * * *", func() {
|
|
|
+ // 现代牧业sap同步
|
|
|
+ sap.SyncMaterialOutbound()
|
|
|
+ sap.SyncSurplusOutbound()
|
|
|
+ sap.SyncLeftoverEntry()
|
|
|
+ // sap.SyncWasteuse()
|
|
|
+ })
|
|
|
+ xdmy.Start()
|
|
|
+ InitMqttClient()
|
|
|
+ } else if setting.ServerSetting.SyncStatus == 3 {
|
|
|
+ duetimecst4, _ := time.ParseInLocation("15:04:05", "00:01:00", time.Local)
|
|
|
+ duetimecst5, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
+ spec2 := fmt.Sprintf("@every %v", duetimecst4.Sub(duetimecst5))
|
|
|
+ xxw := cron.New()
|
|
|
+ xxw.AddFunc(spec2, func() {
|
|
|
+ XxwFeedtemplet(pastureinfo.Pastureid)
|
|
|
+ xxwFeedpSync(pastureinfo.Pastureid)
|
|
|
+ })
|
|
|
+ xxw.Start()
|
|
|
+ } else if setting.ServerSetting.SyncStatus == 4 {
|
|
|
+ duetimecst4, _ := time.ParseInLocation("15:04:05", "00:01:00", time.Local)
|
|
|
+ duetimecst5, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
+ spec2 := fmt.Sprintf("@every %v", duetimecst4.Sub(duetimecst5))
|
|
|
+ ly := cron.New()
|
|
|
+ ly.AddFunc(spec2, func() {
|
|
|
+ XxwFeedtemplet(pastureinfo.Pastureid)
|
|
|
+ xxwFeedpSync(pastureinfo.Pastureid)
|
|
|
+ })
|
|
|
+ ly.Start()
|
|
|
+ } else if setting.ServerSetting.SyncStatus == 5 {
|
|
|
+ gmud := cron.New()
|
|
|
+ err = gmud.AddFunc("0 05 7 * * *", func() {
|
|
|
+ gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
+ })
|
|
|
+ gmud.Start()
|
|
|
+ } else if setting.ServerSetting.SyncStatus == 6 {
|
|
|
+ jp := cron.New()
|
|
|
+ err = jp.AddFunc("0 05 7 * * *", func() {
|
|
|
+ jpud.JPUDUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
+ })
|
|
|
+ jp.Start()
|
|
|
+ } else if setting.ServerSetting.SyncStatus == 7 {
|
|
|
+ c := cron.New()
|
|
|
+ err = c.AddFunc("0 05 7 * * *", func() {
|
|
|
+ ymy.YmyCron(pastureinfo.Werks, pastureinfo.Pastureid)
|
|
|
+ })
|
|
|
+ c.Start()
|
|
|
+ } else if setting.ServerSetting.SyncStatus == 8 {
|
|
|
+ InitMqttClient()
|
|
|
+ }
|
|
|
+ // manualUdData(pastureinfo)
|
|
|
+ // ymy.YmyCron(pastureinfo.Werks, pastureinfo.Pastureid)
|
|
|
// //圣牧自动同步前天有进行中的任务
|
|
|
- manualUdData(pastureinfo)
|
|
|
+ // manualUdData(pastureinfo)
|
|
|
// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
// jpud.UdBarSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
// jpud.UdFeedSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
// xdmy := cron.New()
|
|
|
// err = xdmy.AddFunc("0 05 7 * * *", func() {
|
|
|
// // // // //现代牧业sap同步
|
|
|
- // // sap.SyncMaterialOutbound()
|
|
|
- // // sap.SyncSurplusOutbound()
|
|
|
- // // sap.SyncLeftoverEntry()
|
|
|
+ // sap.SyncMaterialOutbound()
|
|
|
+ // sap.SyncSurplusOutbound()
|
|
|
+ // sap.SyncLeftoverEntry()
|
|
|
+ // sap.SyncWasteuse()
|
|
|
// // // // // 光明ud同步
|
|
|
// // // fmt.Println(time.Now())
|
|
|
// // gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
- // jpud.JPUDUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
+ // // jpud.JPUDUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
|
|
|
// })
|
|
|
// xdmy.Start()
|
|
|
- InitMqttClient()
|
|
|
+ // InitMqttClient()
|
|
|
// yq.YqCron()
|
|
|
//新希望配方同步定时任务
|
|
|
|
|
|
@@ -165,8 +227,6 @@ func CronScheduled(ctx context.Context) {
|
|
|
// })
|
|
|
// xxw.Start()
|
|
|
|
|
|
- // ymy.YmySyncFeed(pastureinfo.Werks, pastureinfo.Pastureid)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
type ScheduledInfo struct {
|
|
|
@@ -1069,76 +1129,76 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
|
|
|
}
|
|
|
|
|
|
func manualUdData(pastureinfo *udPastureInfo) {
|
|
|
- // c := cron.New()
|
|
|
- // c.AddFunc("10 06 * * *", func() {
|
|
|
- tx := restful.Engine.NewSession()
|
|
|
- defer tx.Close()
|
|
|
- now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
|
|
- // now := "2023-02-22"
|
|
|
- dataList, err := tx.SQL(" select id from downloadedplan where mydate = ? ", now).QueryString()
|
|
|
- if err != nil {
|
|
|
- logging.Error("manualUdData-error-1:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- var idList []string
|
|
|
- for _, data := range dataList {
|
|
|
- idList = append(idList, data["id"])
|
|
|
- }
|
|
|
+ c := cron.New()
|
|
|
+ c.AddFunc("10 06 * * *", func() {
|
|
|
+ tx := restful.Engine.NewSession()
|
|
|
+ defer tx.Close()
|
|
|
+ now := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
|
|
+ // now := "2023-02-22"
|
|
|
+ dataList, err := tx.SQL(" select id from downloadedplan where mydate = ? ", now).QueryString()
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("manualUdData-error-1:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var idList []string
|
|
|
+ for _, data := range dataList {
|
|
|
+ idList = append(idList, data["id"])
|
|
|
+ }
|
|
|
|
|
|
- upList := make([]*ScheduledUpInfo, 0)
|
|
|
- up := tx.Table("scheduled_up")
|
|
|
+ upList := make([]*ScheduledUpInfo, 0)
|
|
|
+ up := tx.Table("scheduled_up")
|
|
|
|
|
|
- up.Where("company = ? ", "ud")
|
|
|
- up.Where("datatype in (3,4,1)")
|
|
|
- up.Where("automatic = 1")
|
|
|
- err = up.Find(&upList)
|
|
|
- if err != nil {
|
|
|
- logging.Error("manualUdData-error-2: ", err)
|
|
|
- return
|
|
|
- }
|
|
|
+ up.Where("company = ? ", "ud")
|
|
|
+ up.Where("datatype in (3,4,1)")
|
|
|
+ up.Where("automatic = 1")
|
|
|
+ err = up.Find(&upList)
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("manualUdData-error-2: ", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- for _, item := range upList {
|
|
|
- if item.Datasql != "" {
|
|
|
- // if item.Datatype == 4 {
|
|
|
- targetdataList := strings.Split(item.Targetdata, ",")
|
|
|
- var args []interface{}
|
|
|
- for _, targetdata := range targetdataList {
|
|
|
- if targetdata == "pastureid" {
|
|
|
- args = append(args, pastureinfo.Pastureid)
|
|
|
- } else if targetdata == "idlist" {
|
|
|
- item.Datasql = strings.ReplaceAll(item.Datasql, "idlist", strings.Join(idList, ","))
|
|
|
- } else if targetdata == "date" {
|
|
|
- args = append(args, now)
|
|
|
+ for _, item := range upList {
|
|
|
+ if item.Datasql != "" {
|
|
|
+ // if item.Datatype == 4 {
|
|
|
+ targetdataList := strings.Split(item.Targetdata, ",")
|
|
|
+ var args []interface{}
|
|
|
+ for _, targetdata := range targetdataList {
|
|
|
+ if targetdata == "pastureid" {
|
|
|
+ args = append(args, pastureinfo.Pastureid)
|
|
|
+ } else if targetdata == "idlist" {
|
|
|
+ item.Datasql = strings.ReplaceAll(item.Datasql, "idlist", strings.Join(idList, ","))
|
|
|
+ } else if targetdata == "date" {
|
|
|
+ args = append(args, now)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- data, err := tx.SQL(item.Datasql, args...).Query().List()
|
|
|
- if err != nil {
|
|
|
- logging.Error("manualUdData-error-3: ", err)
|
|
|
- continue
|
|
|
- }
|
|
|
- if len(data) > 0 {
|
|
|
- databyte, err := json.Marshal(data)
|
|
|
+ data, err := tx.SQL(item.Datasql, args...).Query().List()
|
|
|
if err != nil {
|
|
|
- logging.Error("manualUdData-error-4: ", err)
|
|
|
- continue
|
|
|
- }
|
|
|
- exist, err := tx.SQL(`select * from saplog where pastureId = ? and msgtype = ? and date_format(dataDate ,'%Y-%m-%d') = ? `,
|
|
|
- pastureinfo.Pastureid, item.Datatype, now).Exist()
|
|
|
- if exist {
|
|
|
+ logging.Error("manualUdData-error-3: ", err)
|
|
|
continue
|
|
|
}
|
|
|
+ if len(data) > 0 {
|
|
|
+ databyte, err := json.Marshal(data)
|
|
|
+ if err != nil {
|
|
|
+ logging.Error("manualUdData-error-4: ", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ exist, err := tx.SQL(`select * from saplog where pastureId = ? and msgtype = ? and date_format(dataDate ,'%Y-%m-%d') = ? `,
|
|
|
+ pastureinfo.Pastureid, item.Datatype, now).Exist()
|
|
|
+ if exist {
|
|
|
+ continue
|
|
|
+ }
|
|
|
|
|
|
- tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
|
|
|
+ tx.Exec(` insert into saplog(pastureId,request,response,status,msgtext,createTime,msgtype,dataDate,url)
|
|
|
values(?,?,?,?,?,now(),?,?,?)`, pastureinfo.Pastureid, string(databyte), "", "", "", item.Datatype, now, "https://wdc.unidairy.cn/copartner_uploads/")
|
|
|
|
|
|
- var method string
|
|
|
- UDPostPush1(fmt.Sprintf(item.Package, string(databyte), len(data)), method)
|
|
|
+ var method string
|
|
|
+ UDPostPush1(fmt.Sprintf(item.Package, string(databyte), len(data)), method)
|
|
|
+ }
|
|
|
+ // }
|
|
|
}
|
|
|
- // }
|
|
|
}
|
|
|
- }
|
|
|
- // })
|
|
|
- // c.Start()
|
|
|
+ })
|
|
|
+ c.Start()
|
|
|
|
|
|
c1 := cron.New()
|
|
|
c1.AddFunc("01 18 * * *", func() {
|
|
|
@@ -1865,6 +1925,46 @@ func XxwFeedtemplet(pastureId string) {
|
|
|
// pastureId = "1725428057"
|
|
|
if count == 1 {
|
|
|
|
|
|
+ tx.Exec(` delete from ftdetail_sync `)
|
|
|
+ tx.Exec(` INSERT INTO ftdetail_sync (
|
|
|
+ id,
|
|
|
+ pastureid,
|
|
|
+ ftid,
|
|
|
+ fid,
|
|
|
+ fname,
|
|
|
+ lweight,
|
|
|
+ fweight,
|
|
|
+ islockcount,
|
|
|
+ isfg,
|
|
|
+ sort,
|
|
|
+ feedgroup,
|
|
|
+ preftid,
|
|
|
+ autosecond,
|
|
|
+ autosecondname,
|
|
|
+ splitftpreid,
|
|
|
+ deviation,
|
|
|
+ is_show
|
|
|
+) SELECT
|
|
|
+id,
|
|
|
+pastureid,
|
|
|
+ftid,
|
|
|
+fid,
|
|
|
+fname,
|
|
|
+lweight,
|
|
|
+fweight,
|
|
|
+islockcount,
|
|
|
+isfg,
|
|
|
+sort,
|
|
|
+feedgroup,
|
|
|
+preftid,
|
|
|
+ifnull(autosecond,0),
|
|
|
+autosecondname,
|
|
|
+splitftpreid,
|
|
|
+deviation,
|
|
|
+is_show
|
|
|
+FROM
|
|
|
+ ftdetail`)
|
|
|
+
|
|
|
ftList, err := tx.SQL(` SELECT
|
|
|
IFNULL(recipeId, '') AS recipeId,
|
|
|
IFNULL(fodderId, '') AS fodderId,
|
|
|
@@ -1905,79 +2005,79 @@ FROM
|
|
|
ids = time.Now().UnixNano()
|
|
|
logging.Info("create SnowIds err", err)
|
|
|
}
|
|
|
+ /*
|
|
|
+ if item["mergerFodderId"] == "" {
|
|
|
+ _, err = tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,tname,fttypeid,fttype,xxwTempletCode) "+
|
|
|
+ "values(?,?,(select id from cowclass where pastureid = ? limit 1),?,?,1,'饲喂配方',?) "+
|
|
|
+ " ON DUPLICATE KEY UPDATE owner ='丰顿下发' ", ids, pastureId, pastureId, item["recipeId"], item["recipeId"], item["recipeId"])
|
|
|
+ if err != nil {
|
|
|
+ log.Println("XxwFeedtemplet-error-2: ", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
// /*
|
|
|
if item["mergerFodderId"] == "" {
|
|
|
_, err = tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,tname,fttypeid,fttype,xxwTempletCode) "+
|
|
|
"values(?,?,(select id from cowclass where pastureid = ? limit 1),?,?,1,'饲喂配方',?) "+
|
|
|
- " ON DUPLICATE KEY UPDATE owner ='丰顿下发' ", ids, pastureId, pastureId, item["recipeId"], item["recipeId"], item["recipeId"])
|
|
|
+ " ON DUPLICATE KEY UPDATE owner ='丰顿下发' ", ids, pastureId, pastureId, item["recipeId"],
|
|
|
+ item["recipeId"], item["recipeId"])
|
|
|
if err != nil {
|
|
|
log.Println("XxwFeedtemplet-error-2: ", err)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ _, err = tx.Exec(` update feedtemplet f set tcode = (select if(left((select max(tcode) from
|
|
|
+ feedtemplet where pastureid = ?),8) = (select DATE_FORMAT(now(),"%Y%m%d")),
|
|
|
+ (select max(tcode)+1 from feedtemplet where pastureid = ?),
|
|
|
+ (select concat(DATE_FORMAT(now(),"%Y%m%d"),"001"))))
|
|
|
+ where xxwTempletCode = ? and tcode is null `, pastureId, pastureId, item["recipeId"])
|
|
|
+ if err != nil {
|
|
|
+ log.Println("XxwFeedtemplet-error-3: ", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // */
|
|
|
+ } else {
|
|
|
+ _, err = tx.Exec(`insert into feedtemplet(id,pastureid,ccid,tname,fttypeid,fttype,xxwTempletCode)
|
|
|
+ values(?,?,(select id from cowclass where pastureid = ? limit 1),?,2,'预混配方',?)
|
|
|
+ ON DUPLICATE KEY UPDATE owner ='丰顿下发' `, ids, pastureId, pastureId,
|
|
|
+ item["mergerFodderName"]+item["recipeId"], item["mergerFodderId"])
|
|
|
+ if err != nil {
|
|
|
+ log.Println("XxwFeedtemplet-error-3: ", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = tx.Exec(` update feedtemplet f set tcode = (select if(left((select max(tcode) from
|
|
|
+ feedtemplet where pastureid = ?),8) = (select DATE_FORMAT(now(),"%Y%m%d")),
|
|
|
+ (select max(tcode)+1 from feedtemplet where pastureid = ?),
|
|
|
+ (select concat(DATE_FORMAT(now(),"%Y%m%d"),"001"))))
|
|
|
+ where xxwTempletCode = ? and tcode is null `, pastureId, pastureId, item["mergerFodderId"])
|
|
|
+ if err != nil {
|
|
|
+ log.Println("XxwFeedtemplet-error-3: ", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ tx.Exec(` update feedtemplet f set ccname = (select classname from cowclass where id = f.ccid )
|
|
|
+ where xxwTempletCode = ? and tcode is null `, item["mergerFodderId"])
|
|
|
+
|
|
|
+ ids, err := setting.SnowIds.NextId()
|
|
|
+ if err != nil {
|
|
|
+ ids = time.Now().UnixNano()
|
|
|
+ logging.Info("create SnowIds err", err)
|
|
|
+ }
|
|
|
+ _, err = tx.Exec(`insert into ftdetail(id,pastureid,ftid,fid,fname,fweight,sort,autosecond,autosecondname,feedgroup,preftid,version)
|
|
|
+ values(?,?,(select id from feedtemplet where pastureid=? and xxwTempletCode=? limit 1),
|
|
|
+ (select id from feedtemplet where pastureid=? and xxwTempletCode=? limit 1) ,?,?,?,0,'',?,
|
|
|
+ (select id from feedtemplet where pastureid=? and xxwTempletCode =? limit 1),
|
|
|
+ (select version from feedtemplet where pastureid=? and xxwTempletCode=? limit 1)) `,
|
|
|
+ ids, pastureId, pastureId, item["recipeId"], pastureId, item["mergerFodderId"], item["mergerFodderName"]+item["recipeId"], item["autoWeight"],
|
|
|
+ item["orderNum"], item["mergerFodderName"], pastureId, item["mergerFodderId"], pastureId, item["recipeId"])
|
|
|
+ if err != nil {
|
|
|
+ log.Println("XxwFeedtemplet-error-4: ", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- // */
|
|
|
- // /*
|
|
|
- // if item["mergerFodderId"] == "" {
|
|
|
- // _, err = tx.Exec("insert into feedtemplet(id,pastureid,ccid,tcode,tname,fttypeid,fttype,xxwTempletCode) "+
|
|
|
- // "values(?,?,(select id from cowclass where pastureid = ? limit 1),?,?,1,'饲喂配方',?) "+
|
|
|
- // " ON DUPLICATE KEY UPDATE owner ='丰顿下发' ", ids, pastureId, pastureId, item["recipeId"],
|
|
|
- // item["recipeId"], item["recipeId"])
|
|
|
- // if err != nil {
|
|
|
- // log.Println("XxwFeedtemplet-error-2: ", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
-
|
|
|
- // _, err = tx.Exec(` update feedtemplet f set tcode = (select if(left((select max(tcode) from
|
|
|
- // feedtemplet where pastureid = ?),8) = (select DATE_FORMAT(now(),"%Y%m%d")),
|
|
|
- // (select max(tcode)+1 from feedtemplet where pastureid = ?),
|
|
|
- // (select concat(DATE_FORMAT(now(),"%Y%m%d"),"001"))))
|
|
|
- // where xxwTempletCode = ? and tcode is null `, pastureId, pastureId, item["recipeId"])
|
|
|
- // if err != nil {
|
|
|
- // log.Println("XxwFeedtemplet-error-3: ", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // // */
|
|
|
- // } else {
|
|
|
- // _, err = tx.Exec(`insert into feedtemplet(id,pastureid,ccid,tname,fttypeid,fttype,xxwTempletCode)
|
|
|
- // values(?,?,(select id from cowclass where pastureid = ? limit 1),?,2,'预混配方',?)
|
|
|
- // ON DUPLICATE KEY UPDATE owner ='丰顿下发' `, ids, pastureId, pastureId,
|
|
|
- // item["mergerFodderName"]+item["recipeId"], item["mergerFodderId"])
|
|
|
- // if err != nil {
|
|
|
- // log.Println("XxwFeedtemplet-error-3: ", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
-
|
|
|
- // _, err = tx.Exec(` update feedtemplet f set tcode = (select if(left((select max(tcode) from
|
|
|
- // feedtemplet where pastureid = ?),8) = (select DATE_FORMAT(now(),"%Y%m%d")),
|
|
|
- // (select max(tcode)+1 from feedtemplet where pastureid = ?),
|
|
|
- // (select concat(DATE_FORMAT(now(),"%Y%m%d"),"001"))))
|
|
|
- // where xxwTempletCode = ? and tcode is null `, pastureId, pastureId, item["mergerFodderId"])
|
|
|
- // if err != nil {
|
|
|
- // log.Println("XxwFeedtemplet-error-3: ", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
-
|
|
|
- // tx.Exec(` update feedtemplet f set ccname = (select classname from cowclass where id = f.ccid )
|
|
|
- // where xxwTempletCode = ? and tcode is null `, item["mergerFodderId"])
|
|
|
-
|
|
|
- // ids, err := setting.SnowIds.NextId()
|
|
|
- // if err != nil {
|
|
|
- // ids = time.Now().UnixNano()
|
|
|
- // logging.Info("create SnowIds err", err)
|
|
|
- // }
|
|
|
- // _, err = tx.Exec(`insert into ftdetail(id,pastureid,ftid,fid,fname,fweight,sort,autosecond,autosecondname,feedgroup,preftid,version)
|
|
|
- // values(?,?,(select id from feedtemplet where pastureid=? and xxwTempletCode=? limit 1),
|
|
|
- // (select id from feedtemplet where pastureid=? and xxwTempletCode=? limit 1) ,?,?,?,0,'',?,
|
|
|
- // (select id from feedtemplet where pastureid=? and xxwTempletCode =? limit 1),
|
|
|
- // (select version from feedtemplet where pastureid=? and xxwTempletCode=? limit 1)) `,
|
|
|
- // ids, pastureId, pastureId, item["recipeId"], pastureId, item["mergerFodderId"], item["mergerFodderName"]+item["recipeId"], item["autoWeight"],
|
|
|
- // item["orderNum"], item["mergerFodderName"], pastureId, item["mergerFodderId"], pastureId, item["recipeId"])
|
|
|
- // if err != nil {
|
|
|
- // log.Println("XxwFeedtemplet-error-4: ", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
for _, item := range dataList {
|
|
|
@@ -2000,32 +2100,35 @@ FROM
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- /*
|
|
|
- _, err = tx.Exec("insert into ftdetail(id,pastureid,ftid,fid,fname,fweight,sort,autosecond,autosecondname,feedgroup,version) "+
|
|
|
- " values(?,?,(select id from feedtemplet where pastureid=? and xxwTempletCode=? limit 1),"+
|
|
|
- " (select id from feed where pastureid=? and xxwFeedCode=? limit 1) ,?,?,?,0,'',?,(select version from feedtemplet where pastureid=? and xxwTempletCode=? limit 1)) ON DUPLICATE KEY UPDATE pastureid = ? ",
|
|
|
- ids, pastureId, pastureId, item["mergerFodderId"], pastureId, item["fodderId"], item["fodderName"], item["autoWeight"],
|
|
|
- item["orderNum"], item["fodderName"], pastureId, item["mergerFodderId"], pastureId)
|
|
|
- if err != nil {
|
|
|
- log.Println("XxwFeedtemplet-error-6: ", err)
|
|
|
- return
|
|
|
- }
|
|
|
- */
|
|
|
// /*
|
|
|
_, err = tx.Exec("insert into ftdetail(id,pastureid,ftid,fid,fname,fweight,sort,autosecond,autosecondname,feedgroup,version) "+
|
|
|
" values(?,?,(select id from feedtemplet where pastureid=? and xxwTempletCode=? limit 1),"+
|
|
|
- " (select id from feed where pastureid=? and xxwFeedCode=? limit 1) ,?,?,?,0,'',?,(select version from feedtemplet where pastureid=? and xxwTempletCode=? limit 1)) ",
|
|
|
- ids, pastureId, pastureId, item["recipeId"], pastureId, item["fodderId"], item["fodderName"], item["autoWeight"],
|
|
|
- item["orderNum"], item["mergerFodderName"], pastureId, item["recipeId"])
|
|
|
+ " (select id from feed where pastureid=? and xxwFeedCode=? limit 1) ,?,?,?,0,'',?,(select version from feedtemplet where pastureid=? and xxwTempletCode=? limit 1)) ON DUPLICATE KEY UPDATE pastureid = ? ",
|
|
|
+ ids, pastureId, pastureId, item["mergerFodderId"], pastureId, item["fodderId"], item["fodderName"], item["autoWeight"],
|
|
|
+ item["orderNum"], item["fodderName"], pastureId, item["mergerFodderId"], pastureId)
|
|
|
if err != nil {
|
|
|
- log.Println("XxwFeedtemplet-error-7: ", err)
|
|
|
+ log.Println("XxwFeedtemplet-error-6: ", err)
|
|
|
return
|
|
|
}
|
|
|
// */
|
|
|
+ /*
|
|
|
+ _, err = tx.Exec("insert into ftdetail(id,pastureid,ftid,fid,fname,fweight,sort,autosecond,autosecondname,feedgroup,version) "+
|
|
|
+ " values(?,?,(select id from feedtemplet where pastureid=? and xxwTempletCode=? limit 1),"+
|
|
|
+ " (select id from feed where pastureid=? and xxwFeedCode=? limit 1) ,?,?,?,0,'',?,(select version from feedtemplet where pastureid=? and xxwTempletCode=? limit 1)) ",
|
|
|
+ ids, pastureId, pastureId, item["recipeId"], pastureId, item["fodderId"], item["fodderName"], item["autoWeight"],
|
|
|
+ item["orderNum"], item["mergerFodderName"], pastureId, item["recipeId"])
|
|
|
+ if err != nil {
|
|
|
+ log.Println("XxwFeedtemplet-error-7: ", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ tx.Exec(`update ftdetail f set autosecond = (select autosecond from ftdetail_sync where ftid = f.ftid and fid = f.fid ) ,
|
|
|
+ autosecondname = (select autosecondname from ftdetail_sync where ftid = f.ftid and fid = f.fid ) `)
|
|
|
+
|
|
|
feedingList, err := tx.SQL(` SELECT
|
|
|
IFNULL(recipeId, '') AS recipeId
|
|
|
|