|
@@ -18,14 +18,14 @@ import (
|
|
|
"github.com/xormplus/xorm"
|
|
"github.com/xormplus/xorm"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-func YmyCron() {
|
|
|
|
|
- // 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
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+func YmyCron(farmId, pastureId string) {
|
|
|
|
|
+ date := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
|
|
|
|
+ // date := "2025-05-11"
|
|
|
|
|
+ YmyUtirPush(pastureId, farmId, date)
|
|
|
|
|
+ YmyMaterialIssuePush(pastureId, farmId, date)
|
|
|
|
|
+ YmySyncBar(farmId, pastureId)
|
|
|
|
|
+ YmySyncFeed(pastureId)
|
|
|
|
|
+ YmyFeedtempletPush(pastureId, farmId, date)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func YmySyncBar(farmId, pastureId string) {
|
|
func YmySyncBar(farmId, pastureId string) {
|
|
@@ -74,12 +74,13 @@ func barPull(url, data string, msgtype int, tx *xorm.Session, pastureId string)
|
|
|
values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, url)
|
|
values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, url)
|
|
|
|
|
|
|
|
for _, v := range respData.Result {
|
|
for _, v := range respData.Result {
|
|
|
|
|
+ fmt.Println(v)
|
|
|
count, _ := tx.Table("bar").Where("pastureId = ? ", pastureId).Count()
|
|
count, _ := tx.Table("bar").Where("pastureId = ? ", pastureId).Count()
|
|
|
tx.Exec(`insert into bar(pastureid,bcode,bname,sort)values(?,?,?,?) ON DUPLICATE KEY UPDATE bname = ? `, pastureId, v.PenId, v.PenName, count+1, v.PenName)
|
|
tx.Exec(`insert into bar(pastureid,bcode,bname,sort)values(?,?,?,?) ON DUPLICATE KEY UPDATE bname = ? `, pastureId, v.PenId, v.PenName, count+1, v.PenName)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func YmySyncFeed(farmId, pastureId string) {
|
|
|
|
|
|
|
+func YmySyncFeed(pastureId string) {
|
|
|
tx := restful.Engine.NewSession()
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
defer tx.Close()
|
|
|
|
|
|
|
@@ -88,12 +89,10 @@ func YmySyncFeed(farmId, pastureId string) {
|
|
|
"page": "0",
|
|
"page": "0",
|
|
|
"size": "1000",
|
|
"size": "1000",
|
|
|
"modifiedAfter":"2025-01-01 00:00:00",
|
|
"modifiedAfter":"2025-01-01 00:00:00",
|
|
|
- "MATERIAL_BASIC_CLASSIFICATION_CODE":"",
|
|
|
|
|
|
|
+ "MATERIAL_BASIC_CLASSIFICATION_CODE":"",
|
|
|
"MATERIAL_CODE": ""
|
|
"MATERIAL_CODE": ""
|
|
|
}}`
|
|
}}`
|
|
|
-
|
|
|
|
|
- // reqJson = fmt.Sprintf(reqJson, time.Now().Format("2006-01-02 15:04:05"))
|
|
|
|
|
- feedPull("http://113.250.182.238:9000/ierp/kapi/v2/iscb/route/script_cusapi_deepexi_material_query", reqJson, 2, tx, pastureId, getApiToken())
|
|
|
|
|
|
|
+ feedPull("http://219.151.177.119:9000/ierp/kapi/v2/iscb/route/script_cusapi_deepexi_material_query", reqJson, 2, tx, pastureId, getApiToken())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type udPastureInfo struct {
|
|
type udPastureInfo struct {
|
|
@@ -137,13 +136,13 @@ AND column_name = 'pastureid' `, setting.DatabaseSetting.Name).GetFirst(pasturei
|
|
|
"client_id": "Cosmic_deepexi_user",
|
|
"client_id": "Cosmic_deepexi_user",
|
|
|
"client_secret": "Cosmic_zkm_deepexi_openapi@user01",
|
|
"client_secret": "Cosmic_zkm_deepexi_openapi@user01",
|
|
|
"username": "dipujiekouyonghu",
|
|
"username": "dipujiekouyonghu",
|
|
|
- "accountId": "2174058657413595136",
|
|
|
|
|
|
|
+ "accountId": "1986218827033083904",
|
|
|
"nonce": "a42c1a91-56ad-4c6d-95d1-40bcb8b5ec89",
|
|
"nonce": "a42c1a91-56ad-4c6d-95d1-40bcb8b5ec89",
|
|
|
"timestamp": "%s",
|
|
"timestamp": "%s",
|
|
|
"language": "zh_CN"
|
|
"language": "zh_CN"
|
|
|
}`
|
|
}`
|
|
|
reqJson = fmt.Sprintf(reqJson, time.Now().Format("2006-01-02 15:04:05"))
|
|
reqJson = fmt.Sprintf(reqJson, time.Now().Format("2006-01-02 15:04:05"))
|
|
|
- req, err := http.NewRequest("POST", "http://113.250.182.238:9000/ierp/kapi/oauth2/getToken", bytes.NewBuffer([]byte(reqJson)))
|
|
|
|
|
|
|
+ req, err := http.NewRequest("POST", "http://219.151.177.119:9000/ierp/kapi/oauth2/getToken", bytes.NewBuffer([]byte(reqJson)))
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
|
}
|
|
}
|
|
@@ -235,44 +234,42 @@ func YmyFeedtempletPush(pastureId, farmId, date string) error {
|
|
|
ft.tcode AS recipeId,
|
|
ft.tcode AS recipeId,
|
|
|
ft.TNAME AS recipeName,
|
|
ft.TNAME AS recipeName,
|
|
|
f.feedcode AS ingId,
|
|
f.feedcode AS ingId,
|
|
|
|
|
+ f.feedcode AS feedCode,
|
|
|
ifnull(f.udname,f.fname) AS ingName,
|
|
ifnull(f.udname,f.fname) AS ingName,
|
|
|
- round( f.dry * ftd.FWEIGHT, 2 ) AS dmQty,
|
|
|
|
|
|
|
+ round( fn.dry * ftd.FWEIGHT, 2 ) AS dmQty,
|
|
|
ftd.FWEIGHT AS afQty,
|
|
ftd.FWEIGHT AS afQty,
|
|
|
ftd.SORT AS mixNo,
|
|
ftd.SORT AS mixNo,
|
|
|
round( f.Uprice * ftd.FWEIGHT, 2 ) AS recipeCost,
|
|
round( f.Uprice * ftd.FWEIGHT, 2 ) AS recipeCost,
|
|
|
- fc.fcname AS ingType,
|
|
|
|
|
- f.AllowRatio AS allowableError ,fc.fcname ingType
|
|
|
|
|
|
|
+ ifnull(fc.fcname,'饲料') AS ingType,
|
|
|
|
|
+ f.AllowRatio AS allowableError
|
|
|
FROM
|
|
FROM
|
|
|
feedtempletdate ft
|
|
feedtempletdate ft
|
|
|
JOIN ftdetaildate ftd ON ft.id = ftd.FTID and ft.date = ftd.date
|
|
JOIN ftdetaildate ftd ON ft.id = ftd.FTID and ft.date = ftd.date
|
|
|
JOIN feed f ON ftd.FID = f.id
|
|
JOIN feed f ON ftd.FID = f.id
|
|
|
- JOIN feedclass fc ON f.fclassid = fc.id
|
|
|
|
|
|
|
+ left join feednur fn on fn.fid = f.id
|
|
|
|
|
+ left JOIN feedclass fc ON f.fclassid = fc.id
|
|
|
WHERE
|
|
WHERE
|
|
|
ft.ENABLE = 1
|
|
ft.ENABLE = 1
|
|
|
- AND ft.isDelete != 1 and ft.date = ? `, now).Query().List()
|
|
|
|
|
|
|
+ AND ft.isDelete != 1 and ft.date = ? `, now).Query().List()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logging.Error(err)
|
|
logging.Error(err)
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
dataByte, _ := json.Marshal(&dataList)
|
|
dataByte, _ := json.Marshal(&dataList)
|
|
|
-
|
|
|
|
|
- reqJson := `{
|
|
|
|
|
- "reqMethod": "getfeedtempletinfo",
|
|
|
|
|
- "platForm": "EYIMU",
|
|
|
|
|
- "regCode": "123543",
|
|
|
|
|
- "command ": "202cb962ac590",
|
|
|
|
|
- "apiId": "getCptData ",
|
|
|
|
|
- "param": {
|
|
|
|
|
|
|
+ reqJson := `
|
|
|
|
|
+ {"param": {
|
|
|
|
|
+ "method": "getfeedtempletinfo",
|
|
|
|
|
+ "resultData": %s,
|
|
|
"farmId": "%s",
|
|
"farmId": "%s",
|
|
|
- "method": "getfeedtempletinfo ",
|
|
|
|
|
- "code": "1",
|
|
|
|
|
- "errMessage": "",
|
|
|
|
|
- "rowCount": %d,
|
|
|
|
|
- "resultData": %s
|
|
|
|
|
- }
|
|
|
|
|
-}`
|
|
|
|
|
- reqJson = fmt.Sprintf(reqJson, farmId, len(dataList), string(dataByte))
|
|
|
|
|
|
|
+ "parlorType": "CPT",
|
|
|
|
|
+ "account":"CPT"
|
|
|
|
|
+ },
|
|
|
|
|
+ "platform": "CPT",
|
|
|
|
|
+ "regCode": "cpt180511",
|
|
|
|
|
+ "secret": "67a74fd5748054ac67b6fc433e9249b0",
|
|
|
|
|
+ "methodKey": "pushCptData"}`
|
|
|
|
|
+ reqJson = fmt.Sprintf(reqJson, string(dataByte), farmId)
|
|
|
fmt.Println(reqJson)
|
|
fmt.Println(reqJson)
|
|
|
postPush(reqJson, 4, tx, pastureId)
|
|
postPush(reqJson, 4, tx, pastureId)
|
|
|
return nil
|
|
return nil
|
|
@@ -289,11 +286,11 @@ func YmyUtirPush(pastureId, farmId, date string) error {
|
|
|
now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
|
now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- dataList, err := tx.SQL(`select date_format(d1.date,'%Y-%m-%d') dropDate,date_format(d1.date,'%Y-%m-%d') loadDate,d.times loadShift,d.datacaptureno tmrNo,ft.tcode recipeId,ft.ccname recipeName,if(d1.feedcode = -1 ,d1.fid,f.feedcode) ingId,ifnull(f.fname,ftd.fname) ingName,
|
|
|
|
|
|
|
+ dataList, err := tx.SQL(`select MD5(CONCAT(d.pid, d.mydate)) loadId , date_format(d1.date,'%Y-%m-%d') dropDate,date_format(d1.date,'%Y-%m-%d') loadDate,d.times loadShift,d.id tmrNo,ft.tcode recipeId,ft.ccname recipeName,if(d1.feedcode = -1 ,d1.feedcode,f.feedcode) ingId,if(d1.feedcode = -1 ,d1.feedcode,f.feedcode) feedCode ,ifnull(f.fname,ftd.fname) ingName,
|
|
|
ifnull(ifnull(fc.fcname,(select fcname from feedclass fc1 join feed f1 on f1.fclassid = fc1.id where f1.id =ftd.fid )),'饲料') ingType,
|
|
ifnull(ifnull(fc.fcname,(select fcname from feedclass fc1 join feed f1 on f1.fclassid = fc1.id where f1.id =ftd.fid )),'饲料') ingType,
|
|
|
ifnull(f.dry * d1.actualweightminus,0) dmPct,d1.sort mixNo,ifnull(d1.feedallowratio,0) allowableError , if(f.fname is not null, ifnull(d1.lweight,''), ifnull(ftd.fweight / (select sum(fweight) from ftdetaildate where date = d1.date and ftid = d1.fid ) * d1.lweight,"") ) expWeight,
|
|
ifnull(f.dry * d1.actualweightminus,0) dmPct,d1.sort mixNo,ifnull(d1.feedallowratio,0) allowableError , if(f.fname is not null, ifnull(d1.lweight,''), ifnull(ftd.fweight / (select sum(fweight) from ftdetaildate where date = d1.date and ftid = d1.fid ) * d1.lweight,"") ) expWeight,
|
|
|
|
|
|
|
|
- if(f.fname is not null, ifnull(d1.actualweightminus,''), ifnull(ftd.fweight / (select sum(fweight) from ftdetaildate where date = d1.date and ftid = d1.fid ) * d1.actualweightminus,"") ) actualWeight,
|
|
|
|
|
|
|
+ if(f.fname is not null, ifnull(d1.actualweightminus,''),ifnull(ftd.fweight / (select sum(fweight) from ftdetaildate where date = d1.date and ftid = d1.fid ) * d1.actualweightminus,"") ) actualWeight,
|
|
|
DATE_FORMAT(IFNULL((SELECT MAX(intime) FROM downloadplandtl1 d2
|
|
DATE_FORMAT(IFNULL((SELECT MAX(intime) FROM downloadplandtl1 d2
|
|
|
WHERE d1.pid=d2.pid AND d1.pastureid = d2.pastureid AND d2.intime<d1.intime)
|
|
WHERE d1.pid=d2.pid AND d1.pastureid = d2.pastureid AND d2.intime<d1.intime)
|
|
|
, (SELECT MAX(intime) FROM downloadedplan d2
|
|
, (SELECT MAX(intime) FROM downloadedplan d2
|
|
@@ -308,7 +305,7 @@ WHERE d1.date=d2.mydate AND d1.pastureid = d2.pastureid AND d2.id=d1.pid)
|
|
|
left join ftdetaildate ftd on ftd.date = d1.date and ftd.ftid = d1.fid
|
|
left join ftdetaildate ftd on ftd.date = d1.date and ftd.ftid = d1.fid
|
|
|
join tmr t on t.id = d.tmrid
|
|
join tmr t on t.id = d.tmrid
|
|
|
left join driver on driver.drivercode = t.eqcode
|
|
left join driver on driver.drivercode = t.eqcode
|
|
|
- where d1.date = ? and d.havebutton = 1 and d1.type = 0 `, now).Query().List()
|
|
|
|
|
|
|
+ where d1.date = ? and d.havebutton = 1 and d1.type = 0 `, now).Query().List()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logging.Error(err)
|
|
logging.Error(err)
|
|
|
return err
|
|
return err
|
|
@@ -316,23 +313,19 @@ WHERE d1.date=d2.mydate AND d1.pastureid = d2.pastureid AND d2.id=d1.pid)
|
|
|
|
|
|
|
|
dataByte, _ := json.Marshal(&dataList)
|
|
dataByte, _ := json.Marshal(&dataList)
|
|
|
|
|
|
|
|
- reqJson := `{
|
|
|
|
|
- "reqMethod": "uploadadddata",
|
|
|
|
|
- "platform": "EYIMU",
|
|
|
|
|
- "regCode": "123543",
|
|
|
|
|
- "command": "202cb962ac590",
|
|
|
|
|
- "apiId": "getCptData",
|
|
|
|
|
- "param": {
|
|
|
|
|
- "farmId": '%s',
|
|
|
|
|
- "method": "uploadadddata",
|
|
|
|
|
- "code": "1",
|
|
|
|
|
- "errMessage": "",
|
|
|
|
|
- "rowCount": %d,
|
|
|
|
|
- "resultData": %s
|
|
|
|
|
- }
|
|
|
|
|
- }`
|
|
|
|
|
-
|
|
|
|
|
- reqJson = fmt.Sprintf(reqJson, farmId, len(dataList), string(dataByte))
|
|
|
|
|
|
|
+ reqJson := `{"param": {
|
|
|
|
|
+ "method": "uploadadddata",
|
|
|
|
|
+ "resultData": %s,
|
|
|
|
|
+ "farmId": "%s",
|
|
|
|
|
+ "parlorType": "CPT",
|
|
|
|
|
+ "account":"CPT"
|
|
|
|
|
+ },
|
|
|
|
|
+ "platform": "CPT",
|
|
|
|
|
+ "regCode": "cpt180511",
|
|
|
|
|
+ "secret": "67a74fd5748054ac67b6fc433e9249b0",
|
|
|
|
|
+ "methodKey": "pushCptData"} `
|
|
|
|
|
+
|
|
|
|
|
+ reqJson = fmt.Sprintf(reqJson, string(dataByte), farmId)
|
|
|
postPush(reqJson, 0, tx, pastureId)
|
|
postPush(reqJson, 0, tx, pastureId)
|
|
|
fmt.Println(reqJson)
|
|
fmt.Println(reqJson)
|
|
|
return nil
|
|
return nil
|
|
@@ -349,75 +342,35 @@ func YmyMaterialIssuePush(pastureId, farmId, date string) error {
|
|
|
now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
|
now = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- dataList, err := tx.SQL(`SELECT d1.sort feedSort, ifnull(f.feedcode,d1.fid) feedId,ifnull(ifnull(f.udname,f.fname),d1.fname) feedName,
|
|
|
|
|
- d.id,IFNULL(ft.tcode,d2.feedtempletid ) recipeId,IFNULL(ft.tcode,d2.feedtempletid ) feedtempletId,ifnull(ft.tname,d.templetName) feedtempletName ,
|
|
|
|
|
- IFNULL(d.templetName,d2.feedtempletName ) recipeName,
|
|
|
|
|
- date_format(d.mydate,'%Y-%m-%d') as dropDate,ifnull((select sort from downloadedplan where pid=d.pid and lpplanType !=d.lpplanType and mydate=d.mydate),d.sort) as tmrNo,
|
|
|
|
|
- d.Times as dropShift,ifnull(b.bcode,b.id) as penId,b.bname as penName,fp.CCOUNT as cowCount, d2.SORT as feedingNo,
|
|
|
|
|
-ifnull(ROUND(d2.lweight * (d1.actualweightminus/ (select sum(actualweightminus) from downloadplandtl1 where pid = d1.pid and type = 0) ),2) ,0)as expWeight,
|
|
|
|
|
- ifnull(d2.ActualWeightMinus,0) as actualWeight, ifnull(date_format(timestamp(d2.InTime,CONCAT('-',d2.processTime)),'%Y-%m-%d %H:%i:%s'),d.mydate) as startTime,
|
|
|
|
|
- ifnull(date_format(d2.InTime,'%Y-%m-%d %H:%i:%s'),d.mydate) as endTime,ifnull((SELECT dr.driver FROM dutyrecord dr
|
|
|
|
|
|
|
+ dataList, err := tx.SQL(`SELECT MD5(CONCAT(d.pid, d.mydate)) loadId ,d2.sort feedingNo,ifnull((SELECT dr.driver FROM dutyrecord dr
|
|
|
WHERE dr.pastureid = d.pastureid AND dr.eqid = d.tmrid AND dr.times= d.times AND dr.operatetime <=d.mydate
|
|
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(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.lweight*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.lweight*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.lweight*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.lweight*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')
|
|
|
|
|
- premixFeedWeight
|
|
|
|
|
-
|
|
|
|
|
|
|
+ORDER BY dr.operatetime DESC LIMIT 1),"") as tmrName,d.tmrtname equipmentId,fp.ccount cowCount,b.bname penName,date_format(d2.date,'%Y-%m-%d') dropDate,d2.lweight expWeight ,d2.actualweightminus actualWeight, ifnull(date_format(timestamp(d2.InTime,CONCAT('-',d2.processTime)),'%Y-%m-%d %H:%i:%s'),d.mydate) as startTime,
|
|
|
|
|
+ ifnull(date_format(d2.InTime,'%Y-%m-%d %H:%i:%s'),d.mydate) as endTime
|
|
|
from downloadedplan d
|
|
from downloadedplan d
|
|
|
LEFT JOIN downloadplandtl2 d2 on d.id=d2.PID
|
|
LEFT JOIN downloadplandtl2 d2 on d.id=d2.PID
|
|
|
- LEFT JOIN (select dd.pid as lppid,dd1.* from downloadedplan dd join downloadplandtl1 dd1 on dd1.pid = dd.id and dd1.type = 0
|
|
|
|
|
- where dd.mydate= date_format(?,'%Y-%m-%d') and dd.lpplanType in (0,1) ) d1 on d1.lppid = d.pid
|
|
|
|
|
-
|
|
|
|
|
- LEFT JOIN feedp fp on d2.FBarID=fp.barid
|
|
|
|
|
- join bar b on fp.barid = b.id and d.pastureid = b.pastureid
|
|
|
|
|
- left join feed f on f.feedcode = d1.feedcode
|
|
|
|
|
- left JOIN feedtempletdate ft on d.tempid=ft.id and ft.date = d1.date and d.tversion = ft.version
|
|
|
|
|
- left join feedtempletdate ft1 on d1.feedcode = '-1' and ft1.date = d1.date and ft1.id = d1.fid
|
|
|
|
|
- left join ftdetaildate ftd on ftd.date = d1.date and ftd.ftid = d1.fid AND d1.feedcode = '-1' and ftd.version = ft1.version
|
|
|
|
|
|
|
+ left join bar b on b.id = d2.fbarid
|
|
|
|
|
+ left join feedpdate fp on d2.date =fp.date and fp.barid = b.id
|
|
|
|
|
|
|
|
- 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()
|
|
|
|
|
|
|
+ where d.mydate= date_format(?,'%Y-%m-%d') and d2.type = 0 and d.havebutton = 1 `, now).Query().List()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logging.Error(err)
|
|
logging.Error(err)
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
dataByte, _ := json.Marshal(&dataList)
|
|
dataByte, _ := json.Marshal(&dataList)
|
|
|
- reqJson := `{
|
|
|
|
|
- "reqMethod": "uploaddiliverdata",
|
|
|
|
|
- "platForm": "EYIMU",
|
|
|
|
|
- "regCode": "123543",
|
|
|
|
|
- "command": "202cb962ac590",
|
|
|
|
|
- "apiId": "uploaddiliverdata",
|
|
|
|
|
- "param": {
|
|
|
|
|
- "farmId": "%s",
|
|
|
|
|
- "method": "getCptData",
|
|
|
|
|
- "code": "1",
|
|
|
|
|
- "errMessage": "",
|
|
|
|
|
- "rowCount": %d,
|
|
|
|
|
- "resultData": %s
|
|
|
|
|
- }
|
|
|
|
|
- }`
|
|
|
|
|
- reqJson = fmt.Sprintf(reqJson, farmId, len(dataList), string(dataByte))
|
|
|
|
|
|
|
+ reqJson := ` {"param": {
|
|
|
|
|
+ "method": "uploaddiliverdata",
|
|
|
|
|
+ "resultData": %s,
|
|
|
|
|
+ "farmId": "%s",
|
|
|
|
|
+ "parlorType": "CPT",
|
|
|
|
|
+ "account":"CPT"
|
|
|
|
|
+ },
|
|
|
|
|
+ "platform": "CPT",
|
|
|
|
|
+ "regCode": "cpt180511",
|
|
|
|
|
+ "secret": "67a74fd5748054ac67b6fc433e9249b0",
|
|
|
|
|
+ "methodKey": "pushCptData"} `
|
|
|
|
|
+
|
|
|
|
|
+ reqJson = fmt.Sprintf(reqJson, string(dataByte), farmId)
|
|
|
// '0饲喂 1剩料 2原料 3栏舍 4配方 5栏舍牛头数 6库存',
|
|
// '0饲喂 1剩料 2原料 3栏舍 4配方 5栏舍牛头数 6库存',
|
|
|
postPush(reqJson, 0, tx, pastureId)
|
|
postPush(reqJson, 0, tx, pastureId)
|
|
|
fmt.Println(reqJson)
|
|
fmt.Println(reqJson)
|
|
@@ -427,13 +380,13 @@ d1.lweight*IF(ftd.id IS NULL,1,ftd.fweight/(SELECT SUM(ftd2.fweight) FROM ftdeta
|
|
|
func postPush(data string, msgtype int, tx *xorm.Session, pastureId string) {
|
|
func postPush(data string, msgtype int, tx *xorm.Session, pastureId string) {
|
|
|
|
|
|
|
|
// forwardingReq := new(ForwardingReq)
|
|
// forwardingReq := new(ForwardingReq)
|
|
|
- // forwardingReq.Url = "https://fnhbdairyfarmlive.fn.com.my:8380/copartner_uploads/"
|
|
|
|
|
|
|
+ url := "http://dairy.yimucloud.com/dairy/external/api"
|
|
|
// forwardingReq.Method = "POST"
|
|
// forwardingReq.Method = "POST"
|
|
|
// forwardingReq.Body = data
|
|
// forwardingReq.Body = data
|
|
|
// jsonStr, _ := json.Marshal(forwardingReq)
|
|
// jsonStr, _ := json.Marshal(forwardingReq)
|
|
|
// fmt.Println(setting.ServerSetting.UDForwardingSvc)
|
|
// fmt.Println(setting.ServerSetting.UDForwardingSvc)
|
|
|
// req, err := http.NewRequest("POST", setting.ServerSetting.UDForwardingSvc+":8080/forwarding", bytes.NewBuffer(jsonStr))
|
|
// req, err := http.NewRequest("POST", setting.ServerSetting.UDForwardingSvc+":8080/forwarding", bytes.NewBuffer(jsonStr))
|
|
|
- req, err := http.NewRequest("POST", "http://dapp-web.yimucloud.com:8080/webapps/api.html", bytes.NewBuffer([]byte(data)))
|
|
|
|
|
|
|
+ req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(data)))
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logs.Error(err)
|
|
logs.Error(err)
|
|
|
// return nil
|
|
// return nil
|
|
@@ -441,7 +394,7 @@ func postPush(data string, msgtype int, tx *xorm.Session, pastureId string) {
|
|
|
|
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
tr := &http.Transport{
|
|
tr := &http.Transport{
|
|
|
- TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
|
|
|
|
|
|
+ // TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
|
|
}
|
|
}
|
|
|
client := &http.Client{Transport: tr}
|
|
client := &http.Client{Transport: tr}
|
|
|
|
|
|
|
@@ -460,14 +413,14 @@ func postPush(data string, msgtype int, tx *xorm.Session, pastureId string) {
|
|
|
json.Unmarshal(body, &bodyData)
|
|
json.Unmarshal(body, &bodyData)
|
|
|
if _, ok := bodyData["data"]; ok {
|
|
if _, ok := bodyData["data"]; ok {
|
|
|
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(),?,now(),?)`, pastureId, data, bodyData["data"], "", "", msgtype, forwardingReq.Url)
|
|
|
|
|
|
|
+ values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, bodyData["data"], "", "", msgtype, url)
|
|
|
} else {
|
|
} else {
|
|
|
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(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, forwardingReq.Url)
|
|
|
|
|
|
|
+ values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, url)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
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(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, forwardingReq.Url)
|
|
|
|
|
|
|
+ values(?,?,?,?,?,now(),?,now(),?)`, pastureId, data, string(body), "", "", msgtype, url)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|