Browse Source

消息提醒更新

baishaojie 2 years ago
parent
commit
7e654c4ee9
10 changed files with 459 additions and 168 deletions
  1. BIN
      KPTAdmin64.exe
  2. BIN
      KPTAdmin64.zip
  3. 3 3
      conf/app.ini
  4. 13 2
      routers/api/db.go
  5. 6 5
      routers/api/material.go
  6. 1 2
      routers/api/sap/sap.go
  7. 409 156
      routers/api/scheduled.go
  8. 5 0
      routers/router.go
  9. BIN
      tmrgo.zip
  10. 22 0
      update.220802.sql

BIN
tmrgo → KPTAdmin64.exe


BIN
KPTAdmin64.zip


+ 3 - 3
conf/app.ini

@@ -46,9 +46,9 @@ GRFDURL = http://120.48.30.31:88
 Type = mysql
 User = root
 #Password = root
-Host = 192.168.1.93:3326
-#Host = 127.0.0.1:3316
-Name = tmrwatch
+#Host = 192.168.1.93:3326
+Host = 127.0.0.1:3316
+Name = tmrwatch2
 Password = root
 #Password = root
 #Password = kptzhu@163.com

+ 13 - 2
routers/api/db.go

@@ -4290,6 +4290,16 @@ func FpdImportExcel(c *gin.Context) {
 					dataexcel["4"] = outentry["第四班比例(%)"]
 				}
 
+				existbar, err := tx.SQL(` select id from  bar where bname = ?  and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
+				if err != nil {
+					logs.Error(err)
+					appG.Response(http.StatusInternalServerError, e.ERROR, false)
+					return
+				}
+				if !existbar {
+					continue
+				}
+
 				exist, err := tx.SQL(` select id from  feedp where barname = ?  and pastureid = ?  `, dataexcel["barname"], pastureid).Exist()
 				if err != nil {
 					logs.Error(err)
@@ -5098,7 +5108,7 @@ func GetRemind(c *gin.Context) {
 	}
 
 	// pastureid = "3"
-	resp, err := http.Get(fmt.Sprintf("http://tmrwatch.cn/notice/msgtype?sys_name=tmrwatch&pasture_id=%s", pastureid))
+	resp, err := http.Get(fmt.Sprintf("http://tmrwatch.cn/notice/msgtype?sys_name=tmrwatch_test&pasture_id=%s", pastureid))
 	if err != nil {
 		logs.Error(err)
 		appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -5213,6 +5223,7 @@ func UpdateRemind(c *gin.Context) {
 
 	// var jsonStr = []byte(noticeMsgtype
 	noticeMsgtypebyte, err := json.Marshal(noticeMsgtype)
+	fmt.Println(string(noticeMsgtypebyte), "aaaaaaaaaa")
 	req, err := http.NewRequest("POST", "http://tmrwatch.cn/notice/msgtype", bytes.NewBuffer(noticeMsgtypebyte))
 
 	req.Header.Set("Content-Type", "application/json")
@@ -5235,7 +5246,7 @@ func UpdateRemind(c *gin.Context) {
 	defer getresp.Body.Close()
 	buf := bytes.NewBuffer(make([]byte, 0, 512))
 	buf.ReadFrom(getresp.Body)
-	fmt.Println(string(buf.Bytes()))
+	// fmt.Println(string(buf.Bytes()))
 
 	respMap := make(map[string]interface{}, 0)
 	err = json.Unmarshal(buf.Bytes(), &respMap)

+ 6 - 5
routers/api/material.go

@@ -44,6 +44,7 @@ func GetDownloadedplanMaterial1(c *gin.Context) {
 	date := fsion.Get("date").ValueStr()
 	pastureid := fsion.Get("pastureid").ValueStr()
 	datacaptureno := fsion.Get("datacaptureno").ValueStr()
+	id := fsion.Get("id").ValueStr()
 
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
@@ -65,9 +66,9 @@ func GetDownloadedplanMaterial1(c *gin.Context) {
 	and if(d.lpplantype = 2,if((select count(1) from downloadplandtl1 d1 
 	where d1.pid = (select id from downloadedplan dd where dd.mydate = d.mydate 
 		and dd.pastureId = d.pastureid and dd.lpplanType IN (0,1) and dd.pid = d.pid and dd.times = d.times ) 
-		and d1.type = 0 and d1.havebuttom = 0 ) >0 ,1,0 ),0) = 0
+		and d1.type = 0 and d1.havebuttom = 0 ) >0 ,1,0 ),0) = 0  and (?= '' or d.id = ? )
 	 order by d.sort  `,
-		date, pastureid, datacaptureno, tclassid, tclassid).GetFirst(downloadedplanInfo).Error
+		date, pastureid, datacaptureno, tclassid, tclassid, id, id).GetFirst(downloadedplanInfo).Error
 	if err != nil {
 		logs.Error(err)
 		appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -114,7 +115,7 @@ func GetSubPlan(c *gin.Context) {
 		appG.Response(http.StatusInternalServerError, e.ERROR, err)
 		return
 	}
-	downloadplandtl2List, err := tx.SQL(` select  DATE_FORMAT(d2.begintime, '%Y-%m-%d %H:%i:%S') as begintime ,DATE_FORMAT(d2.intime, '%Y-%m-%d %H:%i:%S')  as intime  ,d2.id,d2.pid,d2.fbarid,d2.fname as fbarname,d2.lweight,d.lpplantype,d2.actualweightminus from  downloadplandtl2 d2 join downloadedplan d on d.id = d2.pid where d2.pid = ? and d2.pastureid = ? `, pid, pastureid).Query().List()
+	downloadplandtl2List, err := tx.SQL(` select  d2.sort,DATE_FORMAT(d2.begintime, '%Y-%m-%d %H:%i:%S') as begintime ,DATE_FORMAT(d2.intime, '%Y-%m-%d %H:%i:%S')  as intime  ,d2.id,d2.pid,d2.fbarid,d2.fname as fbarname,d2.lweight,d.lpplantype,d2.actualweightminus from  downloadplandtl2 d2 join downloadedplan d on d.id = d2.pid where d2.pid = ? and d2.pastureid = ? `, pid, pastureid).Query().List()
 	if err != nil {
 		logs.Error(err)
 		appG.Response(http.StatusInternalServerError, e.ERROR, err)
@@ -134,7 +135,7 @@ func GetSubPlan(c *gin.Context) {
 		data["intime"] = d2item["intime"]
 		data["begintime"] = d2item["begintime"]
 		// flweight, _ := strconv.ParseFloat(d2item["lweight"].(string), 64)
-		// flweight = flweight / d2lweight
+		data["sort"] = d2item["sort"]
 		d2List = append(d2List, data)
 	}
 
@@ -346,7 +347,7 @@ func CompletePlan(c *gin.Context) {
 
 	} else {
 		_, err := tx.SQL(` update downloadplandtl2 set actualweightminus =ifnull(actualweightminus,0)+?, actualweight = ?,
-		lastactualweight = ? , intime = ? ,havebuttom = 1,buttontype = ?,begintime where id = ? `,
+		lastactualweight = ? , intime = ? ,havebuttom = 1,buttontype = ?,begintime = ? where id = ? `,
 			actualweightminus, actualweightminus, lastactualweight, intime, buttontype, begintime, d2id).Execute()
 		if err != nil {
 			logs.Error(err)

+ 1 - 2
routers/api/sap/sap.go

@@ -122,7 +122,7 @@ func postPush(url, data string) interface{} {
 		return nil
 	}
 
-	req.SetBasicAuth("zinf_user", "init@1234")
+	req.SetBasicAuth("zinf_TMR", "zinf_TMR@1234")
 	req.Header.Set("Content-Type", "application/json")
 	client := &http.Client{}
 	resp, err := client.Do(req)
@@ -140,7 +140,6 @@ func postPush(url, data string) interface{} {
 		logs.Error(err)
 		return nil
 	}
-	fmt.Println(string(body))
 	if _, ok := respData["DATA"]; ok {
 		return respData["DATA"]
 	} else {

+ 409 - 156
routers/api/scheduled.go

@@ -63,7 +63,10 @@ func CronScheduled(ctx context.Context) {
 
 	})
 	c.Start()
+	//自动同步前天有进行中的任务
+	manualUdData(pastureinfo)
 
+	//消息提醒
 	duetimecst2, _ := time.ParseInLocation("15:04:05", "00:01:00", time.Local)
 	duetimecst3, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
 	spec1 := fmt.Sprintf("@every %v", duetimecst2.Sub(duetimecst3))
@@ -76,128 +79,54 @@ func CronScheduled(ctx context.Context) {
 			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)
-					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
-					}
+			var openIdList []string
+			if _, ok := data["user"]; ok {
+				openIdList = strings.Split(data["user"].(string), ",")
+			}
 
-					var openIdList []string
-					for _, open := range openidList {
-						if open["openid"] != nil {
-							openIdList = append(openIdList, open["openid"].(string))
-						}
-					}
-					if len(openIdList) > 0 {
-						processAnalysisEarlyWarning(openIdList, pastureinfo.Pastureid, data["id"].(int64))
-					}
+			if data["function"].(string) == "processAnalysisEarlyWarning" {
+				if len(openIdList) > 0 {
+					processAnalysisEarlyWarning(openIdList, pastureinfo.Pastureid, data["id"].(int64))
 				}
 			} else if data["function"].(string) == "abnormalMixingDelay" {
-				if data["user"] != nil {
-					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)
-					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
-					}
-
-					var openIdList []string
-					for _, open := range openidList {
-						if open["openid"] != nil {
-							openIdList = append(openIdList, open["openid"].(string))
-						}
-					}
-					if len(openIdList) > 0 {
-						abnormalMixingDelay(openIdList, pastureinfo.Pastureid, data["id"].(int64))
-					}
+				if len(openIdList) > 0 {
+					abnormalMixingDelay(openIdList, pastureinfo.Pastureid, data["id"].(int64))
 				}
 			} else if data["function"].(string) == "endOfShift" {
-				if data["user"] != nil {
-					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)
-					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
-					}
-
-					var openIdList []string
-					for _, open := range openidList {
-						if open["openid"] != nil {
-							openIdList = append(openIdList, open["openid"].(string))
-						}
-					}
-					if len(openIdList) > 0 {
-						endOfShift(openIdList, pastureinfo.Pastureid, data["id"].(int64))
-					}
+				if len(openIdList) > 0 {
+					endOfShift(openIdList, pastureinfo.Pastureid, data["id"].(int64))
 				}
 			} else if data["function"].(string) == "plansToComplete" {
-				if data["user"] != nil {
-					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)
-					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
-					}
-
-					var openIdList []string
-					for _, open := range openidList {
-						if open["openid"] != nil {
-							openIdList = append(openIdList, open["openid"].(string))
-						}
-					}
-					if len(openIdList) > 0 {
-						plansToComplete(openIdList, pastureinfo.Pastureid, data["id"].(int64))
-					}
+				if len(openIdList) > 0 {
+					plansToComplete(openIdList, pastureinfo.Pastureid, data["id"].(int64))
 				}
 			}
 
 		}
 	})
-
 	downloadplandtl1.Start()
 
-	//自动同步前天有进行中的任务
-	manualUdData(pastureinfo)
+	dayCron := cron.New()
+	dayCron.AddFunc("30 23 * * *", func() {
+		dataList, err := tx.SQL(` select user,function,id from remind where pastureid = ?  and  function = ? `, pastureinfo.Pastureid, "inventoryWarning").Query().List()
+		if err != nil {
+			logs.Error("CronScheduled-error-5:", err)
+			return
+		}
+		for _, data := range dataList {
+			var openIdList []string
+			if _, ok := data["user"]; ok {
+				openIdList = strings.Split(data["user"].(string), ",")
+			}
+
+			if data["function"].(string) == "inventoryWarning" {
+				if len(openIdList) > 0 {
+					inventoryWarning(openIdList, pastureinfo.Pastureid, data["id"].(int64))
+				}
+			}
+		}
+	})
+	dayCron.Start()
 }
 
 type ScheduledInfo struct {
@@ -828,7 +757,7 @@ func wxPush(target []string, content []interface{}, pastureId string, serviceId
 	dataStr := `{
 		"pasture_id":%s,
 		"service_id":%d,
-		"sys_name": "tmrWatch_test",
+		"sys_name": "tmrWatch",
 		"target": %s,
 		"miniprogram": {
 			"appid": "wx9ab2b5b25701da0a",
@@ -846,7 +775,7 @@ func wxPush(target []string, content []interface{}, pastureId string, serviceId
 	targetStr, _ := json.Marshal(target)
 	contentStr, _ := json.Marshal(content)
 	dataStr = fmt.Sprintf(dataStr, pastureId, serviceId, string(targetStr), string(contentStr))
-
+	fmt.Println(dataStr)
 	var jsonStr = []byte(dataStr)
 	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
 
@@ -859,18 +788,14 @@ func wxPush(target []string, content []interface{}, pastureId string, serviceId
 
 	defer resp.Body.Close()
 
-	body, _ := ioutil.ReadAll(resp.Body)
-	fmt.Println(dataStr)
-	logs.Info("response Body:", string(body), "fasong")
+	// body, _ := ioutil.ReadAll(resp.Body)
+	// logs.Info("response Body:", string(body), "fasong")
 
 }
 
 func UDPostPush1(data, method string) {
-
 	url := "https://wdc.unidairy.cn/copartner_uploads/"
 	// 超时时间:5秒
-	fmt.Println(url, data)
-
 	var jsonStr = []byte(data)
 	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
 
@@ -883,7 +808,6 @@ func UDPostPush1(data, method string) {
 
 	defer resp.Body.Close()
 	body, _ := ioutil.ReadAll(resp.Body)
-
 	fmt.Println("response Body:", string(body))
 }
 
@@ -893,19 +817,19 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 
 	exist, err := tx2.Table("notice").Where("status = 1").And("content = ? ", "downloadplandtl1").Exist()
 	if err != nil {
-		logs.Error("CronScheduled-error-4:", err)
+		logs.Error("processAnalysisEarlyWarning-error-1:", 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)
+			logs.Error("processAnalysisEarlyWarning-error-2:", 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)
+			logs.Error("processAnalysisEarlyWarning-error-3:", err)
 			return
 		}
 		plandtl1SlIdMap := make(map[string][]int64, 0)
@@ -920,7 +844,7 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 
 		pastureList, err := tx2.SQL("select pasture_name from pasture  where pastureid = ? ", pastureId).Query().List()
 		if err != nil {
-			logs.Error("CronScheduled-error-6:", err)
+			logs.Error("processAnalysisEarlyWarning-error-4:", err)
 			return
 		}
 		var pastureName string
@@ -939,7 +863,7 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 					data["planid"], data["sort"], data["pastureid"]).Query().List()
 
 				if err != nil {
-					logs.Error("CronScheduled-error-7:", err)
+					logs.Error("processAnalysisEarlyWarning-error-5:", err)
 					return
 				}
 				for _, plandtl1 := range plandtl1List {
@@ -958,13 +882,9 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 
 					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("操作编号:%v\n牧场:%s\nTMR名称:%v\n描述:%v\n饲料名称:%v\n计划重量(kg):%v\n实际重量(kg):%v\n误差值(kg):%v\n准确率(%%):%v",
 							plandtl1["projname"], pastureName, plandtl1["tmrtname"], plandtl1["remark"], 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"] = "混料准确率异常"
@@ -980,10 +900,6 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 						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)
 
 						sendMap5 := make(map[string]interface{}, 0)
 						sendMap5["value"] = "无备注"
@@ -995,7 +911,7 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 					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)
+						logs.Error("processAnalysisEarlyWarning-error-6:", err)
 						return
 					}
 
@@ -1009,7 +925,7 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 					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)
+					logs.Error("processAnalysisEarlyWarning-error-7:", err)
 					return
 				}
 				for _, plandtl1 := range plandtl1List {
@@ -1030,8 +946,6 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 					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("操作编号:%v\n牧场:%s\nTMR名称:%v\n描述:%v\n栏舍名称:%v\n计划重量(kg):%v\n实际重量(kg):%v\n误差值(kg):%v\n准确率(%%):%v",
@@ -1061,7 +975,7 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 					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)
+						logs.Error("processAnalysisEarlyWarning-error-8:", err)
 						return
 					}
 
@@ -1072,7 +986,6 @@ func processAnalysisEarlyWarning(target []string, pastureId string, serviceId in
 }
 
 func manualUdData(pastureinfo *udPastureInfo) {
-
 	c := cron.New()
 	c.AddFunc("10 02 * * *", func() {
 		// fmt.Println(time.Now())
@@ -1089,7 +1002,7 @@ func manualUdData(pastureinfo *udPastureInfo) {
 		if exist {
 			dataList, err := tx.SQL(" select id  from downloadedplan where mydate = ? ", now).QueryString()
 			if err != nil {
-				logs.Error("manualUdData-error-1:", err)
+				logs.Error("manualUdData-error-2:", err)
 				return
 			}
 			var idList []string
@@ -1106,8 +1019,8 @@ func manualUdData(pastureinfo *udPastureInfo) {
 func abnormalMixingDelay(target []string, pastureId string, serviceId int64) {
 	tx2 := restful.Engine.NewSession()
 	defer tx2.Close()
-	// time.Now().Format("2006-01-02")
-	dataList, err := tx2.SQL(` select  id,planid,sort from downloadplandtl1_log   where abnormalMixingDelay = 0 and type = 0 and  pastureid = ?  and date = ? `, pastureId, "2022-06-24").Query().List()
+	now := time.Now().Format("2006-01-02")
+	dataList, err := tx2.SQL(` select  id,planid,sort from downloadplandtl1_log   where abnormalMixingDelay = 0 and type = 0 and  pastureid = ?  and date = ? `, pastureId, now).Query().List()
 	if err != nil {
 		logs.Error("abnormalMixingDelay-error-1:", err)
 		return
@@ -1121,12 +1034,11 @@ func abnormalMixingDelay(target []string, pastureId string, serviceId int64) {
 		d.datacaptureno,(select pasture_name from  pasture   where pastureid = ?) as pasturename,de.actualweightminus  from downloadplandtl1_exec  de 
 		join downloadedplan  d  on de.pid = d.id   where de.pid = ? and de.sort = ? `, pastureId, data["planid"], data["sort"]).Query().List()
 		if err != nil {
-			logs.Error("abnormalMixingDelay-error-1:", err)
+			logs.Error("abnormalMixingDelay-error-2:", err)
 			return
 		}
 
 		for _, plan := range planList {
-			// if plan["stirdelay"].(int64) > 0 {
 			showTime, _ := time.ParseInLocation("2006-01-02 15:04:05", fmt.Sprintf("%s %s", time.Now().Format("2006-01-02"), plan["processtime"]), local)
 			nowTime, _ := time.ParseInLocation("2006-01-02 15:04:05", fmt.Sprintf("%s 00:00:00", time.Now().Format("2006-01-02")), local)
 
@@ -1156,10 +1068,9 @@ func abnormalMixingDelay(target []string, pastureId string, serviceId int64) {
 
 				wxPush(target, sendList, pastureId, serviceId)
 			}
-			// }
 			_, err := tx2.SQL(` update downloadplandtl1_log set abnormalMixingDelay = 1 where id = ? `, data["id"]).Execute()
 			if err != nil {
-				logs.Error("abnormalMixingDelay-error-2:", err)
+				logs.Error("abnormalMixingDelay-error-3:", err)
 				return
 			}
 		}
@@ -1169,15 +1080,15 @@ func abnormalMixingDelay(target []string, pastureId string, serviceId int64) {
 func endOfShift(target []string, pastureId string, serviceId int64) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
-	// time.Now().Format("2006-01-02")
-	logList, err := tx.SQL(` select times from downloadedplan_log  where date = ? and classes = 0 group by times `, "2022-06-24").Query().List()
+	now := time.Now().Format("2006-01-02")
+	logList, err := tx.SQL(` select times from downloadedplan_log  where date = ? and classes = 0 group by times `, now).Query().List()
 	if err != nil {
 		logs.Error("endOfShift-error-1:", err)
 		return
 	}
 
 	for _, item := range logList {
-		exist, err := tx.SQL(` select id from downloadedplan  where mydate = ? and times = ? and iscompleted = 0  and enable = 1 `, "2022-06-24", item["times"]).Exist()
+		exist, err := tx.SQL(` select id from downloadedplan  where mydate = ? and times = ? and iscompleted = 0  and enable = 1 `, now, item["times"]).Exist()
 		if err != nil {
 			logs.Error("endOfShift-error-2:", err)
 			return
@@ -1192,7 +1103,7 @@ func endOfShift(target []string, pastureId string, serviceId int64) {
 			round( sum(UNIX_TIMESTAMP(concat("2022-01-01 ", de.processtime)) - UNIX_TIMESTAMP("2022-01-01 00:00:00") ),0)  processtime ,abs(sum(de.actualweightminus)-sum(de.lweight)) as wcz
 			from downloadedplan d  
 			join downloadplandtl1_exec  de on de.pid = d.id   
-			where d.times = ? and d.mydate = ?  and lpplantype in(0,1)  group by d.times`, item["times"], "2022-06-24").Query().List()
+			where d.times = ? and d.mydate = ?  and lpplantype in(0,1)  group by d.times`, item["times"], now).Query().List()
 			if err != nil {
 				logs.Error("endOfShift-error-3:", err)
 				return
@@ -1205,7 +1116,7 @@ func endOfShift(target []string, pastureId string, serviceId int64) {
 			round( sum(UNIX_TIMESTAMP(concat("2022-01-01 ", de.processtime)) - UNIX_TIMESTAMP("2022-01-01 00:00:00") ),0) processtime ,abs(sum(de.actualweightminus)-sum(de.lweight)) as wcz
 			from downloadedplan d  
 			join downloadplandtl2  de on de.pid = d.id   
-			where d.times = ? and d.mydate = ?  and lpplantype in(0,2)  group by d.times `, item["times"], "2022-06-24").Query().List()
+			where d.times = ? and d.mydate = ?  and lpplantype in(0,2)  group by d.times `, item["times"], now).Query().List()
 			if err != nil {
 				logs.Error("endOfShift-error-4:", err)
 				return
@@ -1259,7 +1170,7 @@ func endOfShift(target []string, pastureId string, serviceId int64) {
 
 			wxPush(target, sendList, pastureId, serviceId)
 
-			_, err = tx.SQL(` update downloadedplan_log set classes = 1 where date = ? and times = ? `, "2022-06-24", item["times"]).Execute()
+			_, err = tx.SQL(` update downloadedplan_log set classes = 1 where date = ? and times = ? `, now, item["times"]).Execute()
 			if err != nil {
 				logs.Error("endOfShift-error-5:", err)
 				return
@@ -1273,13 +1184,14 @@ func plansToComplete(target []string, pastureId string, serviceId int64) {
 	tx := restful.Engine.NewSession()
 	defer tx.Close()
 
-	exist, err := tx.SQL(` select id from downloadedplan_log  where date = ? and dailyplan = 0 `, "2022-06-24").Exist()
+	now := time.Now()
+	exist, err := tx.SQL(` select id from downloadedplan_log  where date = ? and dailyplan = 0 `, now).Exist()
 	if err != nil {
 		logs.Error("plansToComplete-error-1:", err)
 		return
 	}
 	if exist {
-		downloadedplanExist, err := tx.SQL(` select id from downloadedplan  where mydate = ?  and iscompleted = 0  and enable = 1 `, "2022-06-24").Exist()
+		downloadedplanExist, err := tx.SQL(` select id from downloadedplan  where mydate = ?  and iscompleted = 0  and enable = 1 `, now).Exist()
 		if err != nil {
 			logs.Error("plansToComplete-error-2:", err)
 			return
@@ -1294,7 +1206,7 @@ func plansToComplete(target []string, pastureId string, serviceId int64) {
 			round( sum(UNIX_TIMESTAMP(concat("2022-01-01 ", de.processtime)) - UNIX_TIMESTAMP("2022-01-01 00:00:00") ),0)  processtime ,abs(sum(de.actualweightminus)-sum(de.lweight)) as wcz
 			from downloadedplan d
 			join downloadplandtl1_exec  de on de.pid = d.id
-			where  d.mydate = ?  and lpplantype in(0,1)  group by d.mydate`, "2022-06-24", "2022-06-24").Query().List()
+			where  d.mydate = ?  and lpplantype in(0,1)  group by d.mydate`, now, now).Query().List()
 			if err != nil {
 				logs.Error("plansToComplete-error-3:", err)
 				return
@@ -1307,7 +1219,7 @@ func plansToComplete(target []string, pastureId string, serviceId int64) {
 			round( sum(UNIX_TIMESTAMP(concat("2022-01-01 ", de.processtime)) - UNIX_TIMESTAMP("2022-01-01 00:00:00") ),0) processtime ,abs(sum(de.actualweightminus)-sum(de.lweight)) as wcz
 			from downloadedplan d
 			join downloadplandtl2  de on de.pid = d.id
-			where d.mydate = ?  and lpplantype in(0,2)  group by d.mydate `, "2022-06-24").Query().List()
+			where d.mydate = ?  and lpplantype in(0,2)  group by d.mydate `, now).Query().List()
 			if err != nil {
 				logs.Error("plansToComplete-error-4:", err)
 				return
@@ -1322,7 +1234,6 @@ func plansToComplete(target []string, pastureId string, serviceId int64) {
 				data["hlaccurate"] = hl["accurate"]
 				data["hlcorrect"] = hl["correct"]
 				data["hlcorrectcount"] = hl["correctcount"]
-				// data["hlprocesstime"] = util.TimeTransformation(hl["processtime"].(int64))
 				data["hlwcz"] = hl["wcz"]
 			}
 			for _, sl := range slList {
@@ -1331,7 +1242,6 @@ func plansToComplete(target []string, pastureId string, serviceId int64) {
 				data["slaccurate"] = sl["accurate"]
 				data["slcorrect"] = sl["correct"]
 				data["slcorrectcount"] = sl["correctcount"]
-				// data["slprocesstime"] = util.TimeTransformation(sl["processtime"].(int64))
 				data["slwcz"] = sl["wcz"]
 			}
 			sendStr := fmt.Sprintf("班次数:%v\n车次数:\n实际混料(kg):%v\n混料误差值(kg):%v\n混料准确率:%v\n混料正确数:%v\n混料正确率:%v\n混料完成时间:%v\n实际撒料(kg):%v\n撒料误差值(kg):%v\n撒料准确率:%v\n撒料正确数:%v\n撒料正确率:%v",
@@ -1362,7 +1272,7 @@ func plansToComplete(target []string, pastureId string, serviceId int64) {
 
 			wxPush(target, sendList, pastureId, serviceId)
 
-			_, err = tx.SQL(` update downloadedplan_log set dailyplan = 1 where date = ? `, "2022-06-24").Execute()
+			_, err = tx.SQL(` update downloadedplan_log set dailyplan = 1 where date = ? `, now).Execute()
 			if err != nil {
 				logs.Error("plansToComplete-error-5:", err)
 				return
@@ -1370,3 +1280,346 @@ func plansToComplete(target []string, pastureId string, serviceId int64) {
 		}
 	}
 }
+
+func AddFormulaIssued(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	tempval_ := make(map[string]interface{})
+	tempCommon := make(map[string]interface{})
+	tempval := make([]map[string]interface{}, 0)
+	err := json.Unmarshal(dataByte, &tempval_)
+	logging.Info("AddFormulaIssued ", c.Keys, c.Request.RemoteAddr, tempval_["common"], tempval_["data"])
+	if err != nil {
+	} else {
+		if v, ok := tempval_["data"].([]interface{}); ok {
+			for _, Tvalue := range v {
+				if v1, ok := Tvalue.(map[string]interface{}); ok {
+					tempval = append(tempval, v1)
+				}
+			}
+		}
+		tx := restful.Engine.NewSession()
+
+		err := tx.Begin()
+		if err != nil {
+			logging.Error("tx.Begin 事务启动失败__error:", err)
+		}
+		defer func() {
+			switch {
+			case err != nil:
+				if tx != nil {
+					tx.Rollback()
+				}
+			default:
+				if tx != nil {
+					err = tx.Commit()
+				}
+			}
+			if tx != nil {
+				tx.Close()
+			}
+		}()
+
+		if err == nil {
+			if tempv, exists := c.Get("jwt_username"); exists {
+				tempCommon["jwt_username"] = tempv.(string)
+			}
+
+			for _, paramvalue := range tempval {
+				if _, ok := paramvalue["resultname"]; !ok {
+					paramvalue["resultname"] = paramvalue["name"]
+				}
+				_, err = ExecDataParam(paramvalue, tempCommon, tempval, nil, nil, tx)
+				if err != nil {
+					logging.Error("AddFormulaIssued error-1:", err)
+					break
+				}
+			}
+			if err == nil {
+				var temid, jtpastureid, tcode, tname, ccname, fttype string
+				for _, tem := range tempval {
+					if tem["name"].(string) == "insertSpotList" {
+						for _, item := range tem["resultmaps"].(map[string]interface{})["list"].([]interface{}) {
+							itemmap := item.(map[string]interface{})
+							jtpastureid = itemmap["pastureid"].(string)
+							temid = itemmap["id"].(string)
+						}
+					}
+				}
+				feedtempletList, err := tx.SQL(` select tname,tcode,id,ccname,fttype from feedtemplet where id = ? and pastureid = ?  `, temid, jtpastureid).Query().List()
+				if err != nil {
+					logs.Error("AddFormulaIssued-error-2:", err)
+					return
+				}
+
+				for _, feedtemplet := range feedtempletList {
+					tcode = feedtemplet["tcode"].(string)
+					tname = feedtemplet["tname"].(string)
+					ccname = feedtemplet["ccname"].(string)
+					fttype = feedtemplet["fttype"].(string)
+				}
+				for _, tem := range tempval {
+					if tem["name"].(string) == "insertSpotList2" {
+						for _, item := range tem["resultmaps"].(map[string]interface{})["list"].([]interface{}) {
+							itemmap := item.(map[string]interface{})
+							dataList, err := tx.SQL(` select user,function,id,service_id from remind where pastureid = ? and function = ? `, itemmap["id"], "formulaIssued").Query().List()
+							if err != nil {
+								logs.Error("AddFormulaIssued-error-3:", err)
+								return
+							}
+
+							for _, data := range dataList {
+								var openIdList []string
+								if _, ok := data["user"]; ok {
+									openIdList = strings.Split(data["user"].(string), ",")
+								}
+
+								var sendList []interface{}
+								sendStr := fmt.Sprintf("配方名称:%v\n配方编码:%s\n牲畜类别:%v\n配方类型:%v",
+									tname, tcode, ccname, fttype)
+
+								sendMap1 := make(map[string]interface{}, 0)
+								sendMap1["value"] = "混料准确率异常"
+								sendMap1["color"] = "#173177"
+								sendList = append(sendList, sendMap1)
+
+								sendMap4 := make(map[string]interface{}, 0)
+								sendMap4["value"] = sendStr
+								sendMap4["color"] = "#173177"
+								sendList = append(sendList, sendMap4)
+
+								sendMap2 := make(map[string]interface{}, 0)
+								sendMap2["value"] = time.Now().Format("2006-01-02 15:04:05")
+								sendMap2["color"] = "#173177"
+								sendList = append(sendList, sendMap2)
+
+								sendMap5 := make(map[string]interface{}, 0)
+								sendMap5["value"] = "无备注"
+								sendMap5["color"] = "#173177"
+								sendList = append(sendList, sendMap5)
+								wxPush(openIdList, sendList, itemmap["id"].(string), data["service_id"].(int64))
+							}
+						}
+						break
+					}
+				}
+				if tempCommon["returnmap"] != nil && tempCommon["returnmap"] != "" {
+					appG.Response(http.StatusOK, e.SUCCESS, tempval)
+				} else {
+					appG.Response(http.StatusOK, e.SUCCESS, "成功执行!")
+				}
+			} else {
+				msg := geterrmsg(err.Error())
+				appG.Response(http.StatusOK, e.ERROR, msg)
+			}
+		}
+	}
+	if err != nil {
+		msg := geterrmsg(err.Error())
+		appG.Response(http.StatusOK, e.ERROR, msg)
+		appG.Response(http.StatusOK, 200, nil)
+	}
+}
+
+func AddBigInventory(c *gin.Context) {
+	appG := app.Gin{C: c}
+	dataByte, _ := ioutil.ReadAll(c.Request.Body)
+	tempval_ := make(map[string]interface{})
+	tempCommon := make(map[string]interface{})
+	tempval := make([]map[string]interface{}, 0)
+	err := json.Unmarshal(dataByte, &tempval_)
+	logging.Info("AddBigInventory ", c.Keys, c.Request.RemoteAddr, tempval_["common"], tempval_["data"])
+
+	if err != nil {
+	} else {
+		if v, ok := tempval_["common"].(map[string]interface{}); ok {
+			tempCommon = v
+		}
+
+		if v, ok := tempval_["data"].([]interface{}); ok {
+			for _, Tvalue := range v {
+				if v1, ok := Tvalue.(map[string]interface{}); ok {
+					tempval = append(tempval, v1)
+				}
+			}
+		}
+		tx := restful.Engine.NewSession()
+
+		err := tx.Begin()
+		if err != nil {
+			logging.Error("tx.Begin 事务启动失败__error:", err)
+		}
+		defer func() {
+			switch {
+			case err != nil:
+				if tx != nil {
+					tx.Rollback()
+				}
+			default:
+				if tx != nil {
+					err = tx.Commit()
+				}
+			}
+			if tx != nil {
+				tx.Close()
+			}
+		}()
+
+		if err == nil {
+			if tempv, exists := c.Get("jwt_username"); exists {
+				tempCommon["jwt_username"] = tempv.(string)
+			}
+
+			for _, paramvalue := range tempval {
+				if _, ok := paramvalue["resultname"]; !ok {
+					paramvalue["resultname"] = paramvalue["name"]
+				}
+				_, err = ExecDataParam(paramvalue, tempCommon, tempval, nil, nil, tx)
+				if err != nil {
+					logging.Error("AddBigInventory error-1:", err)
+					break
+				}
+			}
+			if err == nil {
+
+				var pastureid, date string
+				for _, tem := range tempval {
+					if tem["name"].(string) == "insertBigInventory" {
+						parammaps := tem["parammaps"].(map[string]interface{})
+						pastureid = parammaps["pastureid"].(string)
+						date = parammaps["inventorydate"].(string)
+					}
+				}
+
+				feedinventoryList, err := tx.SQL(`SELECT
+				remark,DATE_FORMAT(inventorydate, '%Y-%m-%d') inventorydate,createuser,
+				TRIM(f.id) id,
+				TRIM(f.pastureid) pastureid,
+				ifnull(round((select sum(theoryweight-factweight) from feedinventorydetail fd where fd.pastureid and fd.invid = f.id and fd.theoryweight>fd.factweight) ,2),0) lessWeight,
+				ifnull(round((select sum(factweight-theoryweight) from feedinventorydetail fd where fd.pastureid and fd.invid = f.id and fd.theoryweight<fd.factweight),2),0)  moreWeight ,
+				ifnull(round((select sum(factweight-theoryweight) from feedinventorydetail fd where fd.pastureid and fd.invid = f.id and fd.theoryweight<>fd.factweight) ,2),0)  differWeight
+				FROM
+				  feedinventory f
+				WHERE f.pastureid = ?  and f.inventorydate=? `, pastureid, date).Query().List()
+				if err != nil {
+					logs.Error("AddBigInventory-error-2:", err)
+					return
+				}
+
+				dataList, err := tx.SQL(` select user,function,id,service_id from remind where pastureid = ? and function = ? `, pastureid, "formulaIssued").Query().List()
+				if err != nil {
+					logs.Error("AddBigInventory-error-3:", err)
+					return
+				}
+
+				for _, data := range dataList {
+					var openIdList []string
+					if _, ok := data["user"]; ok {
+						openIdList = strings.Split(data["user"].(string), ",")
+					}
+					var createuser, lessWeight, moreWeight, differWeight interface{}
+					for _, f := range feedinventoryList {
+						createuser = f["createuser"]
+						lessWeight = f["lessWeight"]
+						moreWeight = f["moreWeight"]
+						differWeight = f["differWeight"]
+					}
+					var sendList []interface{}
+					sendStr := fmt.Sprintf("盘点人:%v\n盘盈库存(kg):%v\n盘亏库存(kg):%v\n盈亏净值(kg):%v",
+						createuser, moreWeight, lessWeight, differWeight)
+					sendMap1 := make(map[string]interface{}, 0)
+					sendMap1["value"] = "库存盘点"
+					sendMap1["color"] = "#173177"
+					sendList = append(sendList, sendMap1)
+
+					sendMap4 := make(map[string]interface{}, 0)
+					sendMap4["value"] = sendStr
+					sendMap4["color"] = "#173177"
+					sendList = append(sendList, sendMap4)
+
+					sendMap2 := make(map[string]interface{}, 0)
+					sendMap2["value"] = time.Now().Format("2006-01-02 15:04:05")
+					sendMap2["color"] = "#173177"
+					sendList = append(sendList, sendMap2)
+
+					sendMap5 := make(map[string]interface{}, 0)
+					sendMap5["value"] = "无备注"
+					sendMap5["color"] = "#173177"
+					sendList = append(sendList, sendMap5)
+
+					wxPush(openIdList, sendList, pastureid, data["service_id"].(int64))
+				}
+				if tempCommon["returnmap"] != nil && tempCommon["returnmap"] != "" {
+					appG.Response(http.StatusOK, e.SUCCESS, tempval)
+				} else {
+					appG.Response(http.StatusOK, e.SUCCESS, "成功执行!")
+				}
+			} else {
+				msg := geterrmsg(err.Error())
+				appG.Response(http.StatusOK, e.ERROR, msg)
+			}
+		}
+	}
+	if err != nil {
+		msg := geterrmsg(err.Error())
+		appG.Response(http.StatusOK, e.ERROR, msg)
+	}
+}
+
+func inventoryWarning(target []string, pastureId string, serviceId int64) {
+
+	tx := restful.Engine.NewSession()
+	defer tx.Close()
+
+	feedstorageList, err := tx.SQL(`
+	SELECT
+	(select fname  from feed where pastureid =fs.pastureid and id = fs.feedid ) feedname,
+	fs.stockweight,round(fs.lweight,2) avgweight, if (fs.stockweight<=0,0, FLOOR(fs.stockweight/fs.lweight)) ldays,
+	TRIM(fs.feedid) feedid,
+	TRIM(fs.pastureid) pastureid,
+	DATE_FORMAT((select max(date) from fswarnhis where pastureid = fs.pastureid and feedid = fs.feedid ), '%Y-%m-%d') lastdate
+	FROM (SELECT  fs.pushstatus,
+	fs.id,
+	 fs.feedname,fs.stockweight,
+	fs.feedid feedid,
+	fs.pastureid pastureid,DATE_FORMAT(NOW(), '%Y-%m-%d') lastdate,
+	(SELECT SUM(d.lweight)/7 lweight FROM downloadplandtl1 d WHERE d.pastureid = fs.pastureid
+	AND date >= DATE_FORMAT(DATE_ADD(NOW(),INTERVAL -7 DAY), '%Y-%m-%d')
+	AND date <DATE_FORMAT(NOW(), '%Y-%m-%d') AND d.fid = fs.feedid) lweight
+	FROM feedstorage  fs) fs
+	WHERE  fs.pastureid=? AND fs.stockweight< fs.lweight*(SELECT inforvalue FROM sysopt WHERE sysopt.pastureid = fs.pastureid
+	 AND inforname = 'repertoryWarn')
+	ORDER BY ldays ,stockweight `).Query().List()
+	if err != nil {
+		logs.Error("inventoryWarning-error-1:", err)
+		return
+	}
+
+	for _, f := range feedstorageList {
+		var sendList []interface{}
+		sendStr := fmt.Sprintf("饲料名称:%v\n库存量(kg):%s\n近7天平均计划量:%v\n剩余使用天数:%v",
+			f["feedname"], f["stockweight"], f["lweight"], f["ldays"])
+
+		sendMap1 := make(map[string]interface{}, 0)
+		sendMap1["value"] = "库存预警"
+		sendMap1["color"] = "#173177"
+		sendList = append(sendList, sendMap1)
+
+		sendMap4 := make(map[string]interface{}, 0)
+		sendMap4["value"] = sendStr
+		sendMap4["color"] = "#173177"
+		sendList = append(sendList, sendMap4)
+
+		sendMap2 := make(map[string]interface{}, 0)
+		sendMap2["value"] = time.Now().Format("2006-01-02 15:04:05")
+		sendMap2["color"] = "#173177"
+		sendList = append(sendList, sendMap2)
+
+		sendMap5 := make(map[string]interface{}, 0)
+		sendMap5["value"] = "无备注"
+		sendMap5["color"] = "#173177"
+		sendList = append(sendList, sendMap5)
+		wxPush(target, sendList, pastureId, serviceId)
+	}
+
+}

+ 5 - 0
routers/router.go

@@ -212,6 +212,11 @@ func InitRouter() *gin.Engine {
 		apiV1.POST("/materialtmr/edit", api.UpdateMaterialTMR)
 		apiV1.POST("/materialtmr/date/edit", api.UpdateMaterialTMRDate)
 
+		//集团端配方下发
+		apiV1.POST("/formulaissued", api.AddFormulaIssued)
+		//盘点单添加
+		apiV1.POST("/biginventory", api.AddBigInventory)
+
 	}
 
 	//不需要登录验证的接口

BIN
tmrgo.zip


+ 22 - 0
update.220802.sql

@@ -36,4 +36,26 @@ ALTER TABLE `downloadplandtl1_exec`
 ADD COLUMN `deviation` int NULL COMMENT '搅拌延时值允许延时偏差' AFTER `type`
 
 
+-- 2022-08-16
+CREATE TABLE `remainplanrecord` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT,
+  `pastureid` bigint(20) DEFAULT NULL,
+  `eqname` varchar(50) DEFAULT NULL COMMENT '设备名称',
+  `eqcode` varchar(50) DEFAULT NULL COMMENT '设备编码',
+  `tclassid` int(11) DEFAULT NULL COMMENT '设备类型',
+  `tclassname` varchar(50) DEFAULT NULL,
+  `barid` bigint(20) DEFAULT NULL COMMENT '栏舍',
+  `barname` varchar(50) DEFAULT NULL,
+  `createtime` datetime DEFAULT NULL COMMENT '收集时间',
+  `weight` decimal(38,2) DEFAULT NULL COMMENT '重量',
+  `beginweight` decimal(38,2) DEFAULT NULL COMMENT '开始重量',
+  `endweight` decimal(38,2) DEFAULT NULL COMMENT '结束重量',
+  `driver` varchar(30) DEFAULT NULL COMMENT '司机',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3;
+
+
+
+ALTER TABLE `tmrwatch2`.`downloadplandtl1_log` 
+ADD COLUMN `InventoryWarning` tinyint(1) NULL AFTER `abnormalMixingDelay`