|
|
@@ -38,199 +38,78 @@ func CronScheduled(ctx context.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- duetimecst, _ := time.ParseInLocation("15:04:05", "00:00:30", time.Local)
|
|
|
- duetimecst1, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
- spec := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1))
|
|
|
-
|
|
|
- c := cron.New()
|
|
|
- c.AddFunc(spec, func() {
|
|
|
- tx1 := restful.Engine.NewSession()
|
|
|
- defer tx1.Close()
|
|
|
- exist, err := tx1.Table("notice").Where("status = 1").And("content = ? ", "downloadedplan_log").Exist()
|
|
|
- if err != nil {
|
|
|
- logs.Error("CronScheduled-error-1:", err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- fmt.Println(exist)
|
|
|
- if exist {
|
|
|
- _, err := tx.SQL(`update notice set status = 0 where content = ? `, "downloadedplan_log").Execute()
|
|
|
- if err != nil {
|
|
|
- logs.Error("CronScheduled-error-2:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- Scheduled(ctx, tx1, pastureinfo)
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- c.Start()
|
|
|
-
|
|
|
- // duetimecst2, _ := time.ParseInLocation("15:04:05", "00:01:01", time.Local)
|
|
|
- // duetimecst3, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
- // spec1 := fmt.Sprintf("@every %v", duetimecst2.Sub(duetimecst3))
|
|
|
-
|
|
|
- // downloadplandtl1 := cron.New()
|
|
|
- // downloadplandtl1.AddFunc(spec1, func() {
|
|
|
- // tx2 := restful.Engine.NewSession()
|
|
|
- // defer tx2.Close()
|
|
|
-
|
|
|
- // exist, err := tx2.Table("notice").Where("status = 1").And("content = ? ", "downloadplandtl1").Exist()
|
|
|
+ // duetimecst, _ := time.ParseInLocation("15:04:05", "00:05:00", time.Local)
|
|
|
+ // duetimecst1, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
+ // spec := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1))
|
|
|
+
|
|
|
+ // c := cron.New()
|
|
|
+ // c.AddFunc(spec, func() {
|
|
|
+ // tx1 := restful.Engine.NewSession()
|
|
|
+ // defer tx1.Close()
|
|
|
+ // exist, err := tx1.Table("notice").Where("status = 1").And("content = ? ", "downloadedplan_log").Exist()
|
|
|
// if err != nil {
|
|
|
- // logs.Error("CronScheduled-error-4:", err)
|
|
|
+ // logs.Error("CronScheduled-error-1:", err)
|
|
|
// return
|
|
|
// }
|
|
|
+
|
|
|
// fmt.Println(exist)
|
|
|
// if exist {
|
|
|
- // _, err := tx2.SQL(`update notice set status = 0 where content = ? `, "downloadplandtl1").Execute()
|
|
|
+ // _, err := tx.SQL(`update notice set status = 0 where content = ? `, "downloadedplan_log").Execute()
|
|
|
// if err != nil {
|
|
|
- // logs.Error("CronScheduled-error-5:", err)
|
|
|
+ // logs.Error("CronScheduled-error-2:", err)
|
|
|
// return
|
|
|
// }
|
|
|
+ // Scheduled(ctx, tx1, pastureinfo)
|
|
|
+ // }
|
|
|
|
|
|
- // dataList, err := tx2.SQL("select * from downloadplandtl1_log where date = date_format(now(),'%Y-%m-%d') ").Query().List()
|
|
|
- // if err != nil {
|
|
|
- // logs.Error("CronScheduled-error-6:", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // plandtl1SlIdMap := make(map[string][]int64, 0)
|
|
|
- // // plandtl1HlIdMap := make(map[string][]string, 0)
|
|
|
- // for _, data := range dataList {
|
|
|
- // if data["type"].(int64) == 0 && data["plandtl1"] != nil {
|
|
|
- // plandtl1SlIdMap["planid"] = append(plandtl1SlIdMap["planid"], data["plandtl1"].(int64))
|
|
|
- // }
|
|
|
+ // })
|
|
|
+ // c.Start()
|
|
|
|
|
|
- // }
|
|
|
+ duetimecst2, _ := time.ParseInLocation("15:04:05", "00:00:30", time.Local)
|
|
|
+ duetimecst3, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
+ spec1 := fmt.Sprintf("@every %v", duetimecst2.Sub(duetimecst3))
|
|
|
|
|
|
- // for _, data := range dataList {
|
|
|
- // if data["type"].(int64) == 0 {
|
|
|
- // plandtl1List, err := tx2.SQL(`select d1.fname,d.tmrtname,d1.intime,d1.id,d1.feedallowratio,abs(d1.actualweightminus -d1.lweight ) errorvalue ,d1.actualweightminus,d1.lweight,
|
|
|
- // if(d1.actualweightminus <= d1.lweight,ROUND(d1.actualweightminus/d1.lweight* 100,2),ROUND(d1.lweight/d1.actualweightminus* 100,2) ) as accuracy from
|
|
|
- // downloadplandtl1 d1
|
|
|
- // join downloadedplan d on d.id = d1.pid
|
|
|
- // where d1.pid = ? and d1.sort = ? and d1.pastureid = ? and d1.intime is not null and d1.type = 0 `,
|
|
|
- // data["planid"], data["sort"], data["pastureid"]).Query().List()
|
|
|
-
|
|
|
- // if err != nil {
|
|
|
- // logs.Error("CronScheduled-error-7:", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // idexist := false
|
|
|
- // for _, plandtl1 := range plandtl1List {
|
|
|
- // //防止同顺序饲料多次推送
|
|
|
- // for _, plandtl1Id := range plandtl1SlIdMap["planid"] {
|
|
|
- // if plandtl1Id == plandtl1["id"].(int64) {
|
|
|
- // idexist = true
|
|
|
- // break
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
- // if idexist {
|
|
|
- // continue
|
|
|
- // }
|
|
|
-
|
|
|
- // errorvalue, _ := strconv.ParseFloat(plandtl1["errorvalue"].(string), 64)
|
|
|
- // if plandtl1["feedallowratio"].(float64) < errorvalue {
|
|
|
- // // if plandtl1["feedallowratio"].(float64) < plandtl1["errorvalue"].(float64) {
|
|
|
- // fmt.Println(plandtl1, "推送")
|
|
|
- // target := []string{"13916925233"}
|
|
|
- // var sendList []interface{}
|
|
|
- // sendStr := fmt.Sprintf("tmr名称:%v\n饲料名称:%v\n计划重量(kg):%v\n实际重量(kg):%v\n误差值(kg):%v\n准确率:%v",
|
|
|
- // plandtl1["tmrtname"], plandtl1["fname"], plandtl1["lweight"], plandtl1["actualweightminus"], plandtl1["errorvalue"], plandtl1["accuracy"])
|
|
|
- // // content = append(content, "混料", plandtl1["begintime"], "kpt", sendStr, "搅拌预警")
|
|
|
-
|
|
|
- // sendMap1 := make(map[string]interface{}, 0)
|
|
|
- // sendMap1["value"] = "搅拌"
|
|
|
- // sendMap1["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap1)
|
|
|
- // sendMap2 := make(map[string]interface{}, 0)
|
|
|
- // sendMap2["value"] = plandtl1["intime"]
|
|
|
- // sendMap2["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap2)
|
|
|
- // sendMap3 := make(map[string]interface{}, 0)
|
|
|
- // sendMap3["value"] = "kpt"
|
|
|
- // sendMap3["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap3)
|
|
|
- // sendMap4 := make(map[string]interface{}, 0)
|
|
|
- // sendMap4["value"] = sendStr
|
|
|
- // sendMap4["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap4)
|
|
|
-
|
|
|
- // sendMap5 := make(map[string]interface{}, 0)
|
|
|
- // sendMap5["value"] = "搅拌预警"
|
|
|
- // sendMap5["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap5)
|
|
|
- // wxPush(target, sendList)
|
|
|
- // }
|
|
|
-
|
|
|
- // plandtl1SlIdMap["planid"] = append(plandtl1SlIdMap["planid"], plandtl1["id"].(int64))
|
|
|
- // _, err := tx2.SQL(" update downloadplandtl1_log set plandtl1 = ? where id = ? and type = 0 ", plandtl1["id"], data["id"]).Execute()
|
|
|
- // if err != nil {
|
|
|
- // logs.Error("CronScheduled-error-8:", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // plandtl1List, err := tx2.SQL(`select d2.fname,d.tmrtname,d2.id,ifnull(d2.allowratio,0) allowratio ,abs(d2.actualweightminus -d2.lweight ) errorvalue ,d2.intime,d2.actualweightminus,d2.lweight,
|
|
|
- // if(d2.actualweightminus <= d2.lweight,ROUND(d2.actualweightminus/d2.lweight* 100,2),ROUND(d2.lweight/d2.actualweightminus* 100,2) ) as accuracy
|
|
|
- // from downloadplandtl2 d2
|
|
|
- // join downloadedplan d on d.id = d2.pid
|
|
|
- // where d2.pid = ? and d2.sort = ? and d2.pastureid = ? and d2.intime is not null and d2.type = 0 `,
|
|
|
- // data["planid"], data["sort"], data["pastureid"]).Query().List()
|
|
|
- // // Where(" pid = ? ", data["planid"]).And("sort = ? ", data["sort"]).And(" pastureid = ? ", data["pastureid"]).And(" intime is not null").And("type = 0 ").Query().List()
|
|
|
- // if err != nil {
|
|
|
- // logs.Error("CronScheduled-error-7:", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // for _, plandtl1 := range plandtl1List {
|
|
|
- // errorvalue, _ := strconv.ParseFloat(plandtl1["errorvalue"].(string), 64)
|
|
|
- // if float64(plandtl1["allowratio"].(int64)) < errorvalue && float64(plandtl1["allowratio"].(int64)) != 0 {
|
|
|
- // fmt.Println(plandtl1, "推送")
|
|
|
- // target := []string{"13916925233"}
|
|
|
- // // var content []interface{}
|
|
|
-
|
|
|
- // var sendList []interface{}
|
|
|
- // sendStr := fmt.Sprintf("tmr名称:%v\n栏舍名称:%v\n计划重量(kg):%v\n实际重量(kg):%v\n误差值(kg):%v\n准确率:%v",
|
|
|
- // plandtl1["tmrtname"], plandtl1["fname"], plandtl1["lweight"], plandtl1["actualweightminus"], plandtl1["errorvalue"], plandtl1["accuracy"])
|
|
|
- // sendMap1 := make(map[string]interface{}, 0)
|
|
|
- // sendMap1["value"] = "撒料"
|
|
|
- // sendMap1["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap1)
|
|
|
- // sendMap2 := make(map[string]interface{}, 0)
|
|
|
- // sendMap2["value"] = plandtl1["intime"]
|
|
|
- // sendMap2["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap2)
|
|
|
- // sendMap3 := make(map[string]interface{}, 0)
|
|
|
- // sendMap3["value"] = "kpt"
|
|
|
- // sendMap3["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap3)
|
|
|
- // sendMap4 := make(map[string]interface{}, 0)
|
|
|
- // sendMap4["value"] = sendStr
|
|
|
- // sendMap4["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap4)
|
|
|
-
|
|
|
- // sendMap5 := make(map[string]interface{}, 0)
|
|
|
- // sendMap5["value"] = "撒料预警"
|
|
|
- // sendMap5["color"] = "#173177"
|
|
|
- // sendList = append(sendList, sendMap5)
|
|
|
-
|
|
|
- // wxPush(target, sendList)
|
|
|
- // }
|
|
|
-
|
|
|
- // plandtl1SlIdMap["planid"] = append(plandtl1SlIdMap["planid"], plandtl1["id"].(int64))
|
|
|
- // _, err := tx2.SQL(" update downloadplandtl1_log set plandtl1 = ? where id = ? and type = 1 ", plandtl1["id"], data["id"]).Execute()
|
|
|
- // if err != nil {
|
|
|
- // logs.Error("CronScheduled-error-8:", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
+ downloadplandtl1 := cron.New()
|
|
|
+ downloadplandtl1.AddFunc(spec1, func() {
|
|
|
+ dataList, err := tx.SQL(` select user,function,id from remind where pastureid = ? `, pastureinfo.Pastureid).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-3:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, data := range dataList {
|
|
|
+ if data["function"].(string) == "processAnalysisEarlyWarning" {
|
|
|
+ // user := strings.Split(data["user"].(string), ",")
|
|
|
+ if len(data["user"].(string)) > 0 {
|
|
|
+ var userids string
|
|
|
+ for _, str := range strings.Split(data["user"].(string), ",") {
|
|
|
+ if len(userids) <= 0 {
|
|
|
+ userids = fmt.Sprintf("'%s'", str)
|
|
|
+ } else {
|
|
|
+ userids += fmt.Sprintf(",'%s'", str)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sql := fmt.Sprintf(` select openid from user_wx where pastureid = ? and userid in(%s)`, userids)
|
|
|
+ fmt.Println(sql)
|
|
|
+ openidList, err := tx.SQL(sql, pastureinfo.Pastureid).Query().List()
|
|
|
+ // openidList, err := tx.Table("user_wx").Where(" pastureid = ? ", pastureinfo.Pastureid).And("userid in (?)", data["user"].(string)).Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-4:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- // downloadplandtl1.Start()
|
|
|
+ var openIdList []string
|
|
|
+ for _, open := range openidList {
|
|
|
+ if open["openid"] != nil {
|
|
|
+ openIdList = append(openIdList, open["openid"].(string))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ processAnalysisEarlyWarning(openIdList, pastureinfo.Pastureid, data["id"].(int64))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ downloadplandtl1.Start()
|
|
|
}
|
|
|
|
|
|
type ScheduledInfo struct {
|
|
|
@@ -852,17 +731,18 @@ func (h *ScheduledDown) SyncFeedp(pastureid string, feedpList []interface{}) err
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func wxPush(target []string, content []interface{}) {
|
|
|
+func wxPush(target []string, content []interface{}, pastureId string, serviceId int64) {
|
|
|
url := "http://tmrwatch.cn/notice/message"
|
|
|
|
|
|
dataStr := `{
|
|
|
- "sys_name": "tmrwatch",
|
|
|
- "remind_type": "1",
|
|
|
+ "pasture_id":%s,
|
|
|
+ "service_id":%d,
|
|
|
+ "sys_name": "tmrWatch",
|
|
|
"template_id": "BtkN1rWKOJtKP0C64lGxIrPzLRFsYFas-4gupX2-pFo",
|
|
|
"target": %s,
|
|
|
"miniprogram": {
|
|
|
- "appid": "xiaochengxuappid12345",
|
|
|
- "pagepath": "index?foo=bar"
|
|
|
+ "appid": "wx9ab2b5b25701da0a",
|
|
|
+ "pagepath": "pages/index/index?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IjAwMDI4IiwicGFzc3dvcmQiOiJlMTBhZGMzOTQ5YmE1OWFiYmU1NmUwNTdmMjBmODgzZSIsImV4cCI6MTY1NDIzMDMxMywiaXNzIjoiaHR0cHM6Ly9naXRodWIuY29tL2twdHl1bi9nby1hZG1pbi8ifQ.jKLR74kTy9tXqFH5OwlwK7zTGKvMVbrOecsaJpxbxq8"
|
|
|
},
|
|
|
"keys": [
|
|
|
"first",
|
|
|
@@ -876,7 +756,8 @@ func wxPush(target []string, content []interface{}) {
|
|
|
|
|
|
targetStr, _ := json.Marshal(target)
|
|
|
contentStr, _ := json.Marshal(content)
|
|
|
- dataStr = fmt.Sprintf(dataStr, string(targetStr), string(contentStr))
|
|
|
+ dataStr = fmt.Sprintf(dataStr, pastureId, serviceId, string(targetStr), string(contentStr))
|
|
|
+
|
|
|
var jsonStr = []byte(dataStr)
|
|
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
|
|
|
|
|
|
@@ -889,7 +770,8 @@ func wxPush(target []string, content []interface{}) {
|
|
|
|
|
|
defer resp.Body.Close()
|
|
|
body, _ := ioutil.ReadAll(resp.Body)
|
|
|
- fmt.Println("response Body:", string(body))
|
|
|
+ fmt.Println(dataStr)
|
|
|
+ fmt.Println("response Body:", string(body), "fasong")
|
|
|
}
|
|
|
|
|
|
func UDPostPush1(data, method string) {
|
|
|
@@ -909,7 +791,6 @@ func UDPostPush1(data, method string) {
|
|
|
|
|
|
defer resp.Body.Close()
|
|
|
body, _ := ioutil.ReadAll(resp.Body)
|
|
|
- fmt.Println("response Body:", string(body))
|
|
|
fsion := gofasion.NewFasion(string(body))
|
|
|
tx := restful.Engine.NewSession()
|
|
|
defer tx.Close()
|
|
|
@@ -925,5 +806,164 @@ func UDPostPush1(data, method string) {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+ fmt.Println("response Body:", string(body))
|
|
|
+}
|
|
|
+
|
|
|
+func processAnalysisEarlyWarning(target []string, pastureId string, serviceId int64) {
|
|
|
+ tx2 := restful.Engine.NewSession()
|
|
|
+ defer tx2.Close()
|
|
|
+
|
|
|
+ exist, err := tx2.Table("notice").Where("status = 1").And("content = ? ", "downloadplandtl1").Exist()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-4:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if exist {
|
|
|
+ _, err := tx2.SQL(`update notice set status = 0 where content = ? `, "downloadplandtl1").Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-5:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ dataList, err := tx2.SQL("select * from downloadplandtl1_log where date = date_format(now(),'%Y-%m-%d') ").Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-6:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ plandtl1SlIdMap := make(map[string][]int64, 0)
|
|
|
+ // plandtl1HlIdMap := make(map[string][]string, 0)
|
|
|
+ for _, data := range dataList {
|
|
|
+ if data["type"].(int64) == 0 && data["plandtl1"] != nil {
|
|
|
+ plandtl1SlIdMap["planid"] = append(plandtl1SlIdMap["planid"], data["plandtl1"].(int64))
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ for _, data := range dataList {
|
|
|
+ if data["type"].(int64) == 0 {
|
|
|
+ plandtl1List, err := tx2.SQL(`select d1.fname,d.tmrtname,d1.intime,d1.id,d1.feedallowratio,abs(d1.actualweightminus -d1.lweight ) errorvalue ,d1.actualweightminus,d1.lweight,
|
|
|
+ if(d1.actualweightminus <= d1.lweight,ROUND(d1.actualweightminus/d1.lweight* 100,2),ROUND(d1.lweight/d1.actualweightminus* 100,2) ) as accuracy from
|
|
|
+ downloadplandtl1 d1
|
|
|
+ join downloadedplan d on d.id = d1.pid
|
|
|
+ where d1.pid = ? and d1.sort = ? and d1.pastureid = ? and d1.intime is not null and d1.type = 0 `,
|
|
|
+ data["planid"], data["sort"], data["pastureid"]).Query().List()
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-7:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ idexist := false
|
|
|
+ for _, plandtl1 := range plandtl1List {
|
|
|
+ //防止同顺序饲料多次推送
|
|
|
+ for _, plandtl1Id := range plandtl1SlIdMap["planid"] {
|
|
|
+ if plandtl1Id == plandtl1["id"].(int64) {
|
|
|
+ idexist = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if idexist {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ errorvalue, _ := strconv.ParseFloat(plandtl1["errorvalue"].(string), 64)
|
|
|
+ if plandtl1["feedallowratio"].(float64) < errorvalue {
|
|
|
+ // if plandtl1["feedallowratio"].(float64) < plandtl1["errorvalue"].(float64) {
|
|
|
+ fmt.Println(plandtl1, "推送")
|
|
|
+ // target := []string{"13916925233"}
|
|
|
+ var sendList []interface{}
|
|
|
+ sendStr := fmt.Sprintf("tmr名称:%v\n饲料名称:%v\n计划重量(kg):%v\n实际重量(kg):%v\n误差值(kg):%v\n准确率:%v",
|
|
|
+ plandtl1["tmrtname"], plandtl1["fname"], plandtl1["lweight"], plandtl1["actualweightminus"], plandtl1["errorvalue"], plandtl1["accuracy"])
|
|
|
+ // content = append(content, "混料", plandtl1["begintime"], "kpt", sendStr, "搅拌预警")
|
|
|
+
|
|
|
+ sendMap1 := make(map[string]interface{}, 0)
|
|
|
+ sendMap1["value"] = "搅拌"
|
|
|
+ sendMap1["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap1)
|
|
|
+ sendMap2 := make(map[string]interface{}, 0)
|
|
|
+ sendMap2["value"] = plandtl1["intime"]
|
|
|
+ sendMap2["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap2)
|
|
|
+ sendMap3 := make(map[string]interface{}, 0)
|
|
|
+ sendMap3["value"] = "kpt"
|
|
|
+ sendMap3["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap3)
|
|
|
+ sendMap4 := make(map[string]interface{}, 0)
|
|
|
+ sendMap4["value"] = sendStr
|
|
|
+ sendMap4["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap4)
|
|
|
+
|
|
|
+ sendMap5 := make(map[string]interface{}, 0)
|
|
|
+ sendMap5["value"] = "搅拌预警"
|
|
|
+ sendMap5["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap5)
|
|
|
+ wxPush(target, sendList, pastureId, serviceId)
|
|
|
+ }
|
|
|
+
|
|
|
+ plandtl1SlIdMap["planid"] = append(plandtl1SlIdMap["planid"], plandtl1["id"].(int64))
|
|
|
+ _, err := tx2.SQL(" update downloadplandtl1_log set plandtl1 = ? where id = ? and type = 0 ", plandtl1["id"], data["id"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-8:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ plandtl1List, err := tx2.SQL(`select d2.fname,d.tmrtname,d2.id,ifnull(d2.allowratio,0) allowratio ,abs(d2.actualweightminus -d2.lweight ) errorvalue ,d2.intime,d2.actualweightminus,d2.lweight,
|
|
|
+ if(d2.actualweightminus <= d2.lweight,ROUND(d2.actualweightminus/d2.lweight* 100,2),ROUND(d2.lweight/d2.actualweightminus* 100,2) ) as accuracy
|
|
|
+ from downloadplandtl2 d2
|
|
|
+ join downloadedplan d on d.id = d2.pid
|
|
|
+ where d2.pid = ? and d2.sort = ? and d2.pastureid = ? and d2.intime is not null and d2.type = 0 `,
|
|
|
+ data["planid"], data["sort"], data["pastureid"]).Query().List()
|
|
|
+ // Where(" pid = ? ", data["planid"]).And("sort = ? ", data["sort"]).And(" pastureid = ? ", data["pastureid"]).And(" intime is not null").And("type = 0 ").Query().List()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-7:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, plandtl1 := range plandtl1List {
|
|
|
+ errorvalue, _ := strconv.ParseFloat(plandtl1["errorvalue"].(string), 64)
|
|
|
+ if float64(plandtl1["allowratio"].(int64)) < errorvalue && float64(plandtl1["allowratio"].(int64)) != 0 {
|
|
|
+ fmt.Println(plandtl1, "推送")
|
|
|
+ // target := []string{"13916925233"}
|
|
|
+ // var content []interface{}
|
|
|
+
|
|
|
+ var sendList []interface{}
|
|
|
+ sendStr := fmt.Sprintf("tmr名称:%v\n栏舍名称:%v\n计划重量(kg):%v\n实际重量(kg):%v\n误差值(kg):%v\n准确率:%v",
|
|
|
+ plandtl1["tmrtname"], plandtl1["fname"], plandtl1["lweight"], plandtl1["actualweightminus"], plandtl1["errorvalue"], plandtl1["accuracy"])
|
|
|
+ sendMap1 := make(map[string]interface{}, 0)
|
|
|
+ sendMap1["value"] = "撒料"
|
|
|
+ sendMap1["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap1)
|
|
|
+ sendMap2 := make(map[string]interface{}, 0)
|
|
|
+ sendMap2["value"] = plandtl1["intime"]
|
|
|
+ sendMap2["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap2)
|
|
|
+ sendMap3 := make(map[string]interface{}, 0)
|
|
|
+ sendMap3["value"] = "kpt"
|
|
|
+ sendMap3["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap3)
|
|
|
+ sendMap4 := make(map[string]interface{}, 0)
|
|
|
+ sendMap4["value"] = sendStr
|
|
|
+ sendMap4["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap4)
|
|
|
+
|
|
|
+ sendMap5 := make(map[string]interface{}, 0)
|
|
|
+ sendMap5["value"] = "撒料预警"
|
|
|
+ sendMap5["color"] = "#173177"
|
|
|
+ sendList = append(sendList, sendMap5)
|
|
|
+
|
|
|
+ wxPush(target, sendList, pastureId, serviceId)
|
|
|
+ }
|
|
|
+
|
|
|
+ plandtl1SlIdMap["planid"] = append(plandtl1SlIdMap["planid"], plandtl1["id"].(int64))
|
|
|
+ _, err := tx2.SQL(" update downloadplandtl1_log set plandtl1 = ? where id = ? and type = 1 ", plandtl1["id"], data["id"]).Execute()
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("CronScheduled-error-8:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|