浏览代码

多语言版本合并

baishaojie 10 月之前
父节点
当前提交
4b8c4ba7f4
共有 7 个文件被更改,包括 1151 次插入419 次删除
  1. 二进制
      TMRWatchComm
  2. 二进制
      TMRWatchComm.zip
  3. 4 5
      conf/app.ini
  4. 946 409
      http/handle/api/ops.go
  5. 198 3
      http/handle/api/report.go
  6. 2 2
      http/handle/api/scheduled.go
  7. 1 0
      http/routers/app_api.go

二进制
TMRWatchComm


二进制
TMRWatchComm.zip


+ 4 - 5
conf/app.ini

@@ -92,12 +92,11 @@ Password =
 Name = 
 
 [yyn]
-FarmId = "1830002642"
+FarmId = "1830002645"
 ProductKey = "k03txxLKFae"
-DeviceName = "02642_p_breed"
-DeviceSecret = "c5968fc9ebd6bdaa7c27c441cfb9faf9"
-HeartBeat = "Tmr183000264202642_p_breed"
-
+DeviceName = "02645_p_breed"
+DeviceSecret = "9edae4cb70ae57ed1a07c70bbd201462"
+HeartBeat = "Tmr183000264502645_p_breed"
 
 [comm]
 PortName =

文件差异内容过多而无法显示
+ 946 - 409
http/handle/api/ops.go


+ 198 - 3
http/handle/api/report.go

@@ -167,11 +167,23 @@ func praseReportform(sqlnamestr string, parammaps *gofasion.Fasion, tx *xorm.Ses
 			// fmt.Println(flleight)
 		}
 		flleightint, _ := strconv.Atoi(flleight)
-		if sqlnamestr == "downloadPlanTSLJD" {
-			queryData, err = getAccuracyV9(queryList, sqlnamestr, flleightint, feednamesort3)
+		// getAccuracyV9English
+		languageStatus := GetLanguageStatus()
+
+		if languageStatus == "0" {
+			if sqlnamestr == "downloadPlanTSLJD" {
+				queryData, err = getAccuracyV9(queryList, sqlnamestr, flleightint, feednamesort3)
+			} else {
+				queryData, err = getAccuracyV9(queryList, sqlnamestr, flleightint, feednamesort) //投料简打、累加
+			}
 		} else {
-			queryData, err = getAccuracyV9(queryList, sqlnamestr, flleightint, feednamesort) //投料简打、累加
+			if sqlnamestr == "downloadPlanTSLJD" {
+				queryData, err = getAccuracyV9English(queryList, sqlnamestr, flleightint, feednamesort3)
+			} else {
+				queryData, err = getAccuracyV9English(queryList, sqlnamestr, flleightint, feednamesort) //投料简打、累加
+			}
 		}
+
 	default:
 		queryData, err = nil, nil
 	}
@@ -359,6 +371,189 @@ func getAccuracyV9(queryList []map[string]interface{}, sqlnamestr string, flleig
 	queryData["data"] = queryList
 	return queryData, nil
 }
+
+func getAccuracyV9English(queryList []map[string]interface{}, sqlnamestr string, flleightint int, feednamesort []string) (map[string]interface{}, error) {
+	queryData := make(map[string]interface{})
+
+	chartData := make(map[string]interface{})
+	mapc3 := make(map[string]interface{})
+	data2 := []interface{}{}
+	data1 := []interface{}{}
+
+	mapc3["label"] = "Batch"
+	mapc3["prop"] = "projname"
+	data1 = append(data1, mapc3)
+	mapc3 = make(map[string]interface{})
+
+	mapc3["label"] = "TMR"
+	mapc3["prop"] = "tmrtname"
+	data1 = append(data1, mapc3)
+	mapc3 = make(map[string]interface{})
+	//if sqlnamestr == "downloadPlanSFJD":
+
+	//mapc3["label"] = "时间"
+	//mapc3["prop"] = "plantime"
+	//data1 = append(data1, mapc3)
+	//mapc3 = make(map[string]interface{})
+	//
+	//mapc3["label"] = "班组"
+	//mapc3["prop"] = "times"
+	//data1 = append(data1, mapc3)
+	//mapc3 = make(map[string]interface{})
+	//
+	//mapc3["label"] = "驾驶员"
+	//mapc3["prop"] = "driver"
+	//data1 = append(data1, mapc3)
+	//mapc3 = make(map[string]interface{})
+	//
+	//mapc3["label"] = "日系数比例"
+	//mapc3["prop"] = "rate"
+	//data1 = append(data1, mapc3)
+	//mapc3 = make(map[string]interface{})
+	//
+	//mapc3["label"] = "牛头数"
+	//mapc3["prop"] = "feedpcount"
+	//data1 = append(data1, mapc3)
+	//mapc3 = make(map[string]interface{})
+	//
+	//mapc3["label"] = "配方模板"
+	//mapc3["prop"] = "templetname"
+	//data1 = append(data1, mapc3)
+	//mapc3 = make(map[string]interface{})
+
+	//#######################################################################################
+	mtem := make(map[interface{}]interface{})
+	var stem, feedNames []string
+
+	for _, feed := range feednamesort {
+		feed = strings.ReplaceAll(feed, " ", "")
+		mtem[feed] = struct{}{}
+		// fmt.Println(feed)
+		stem = append(stem, feed)
+	}
+
+	for i := 0; i < len(queryList); i++ { // 获取所有饲料种类
+		// if _, ok := mtem[queryList[i]["fname"]]; ok {
+		// 	continue
+		// }
+
+		// stem = append(stem, queryList[i]["fname"].(string))
+		// mtem[queryList[i]["fname"]] = struct{}{}
+		feedNames = append(feedNames, queryList[i]["fname"].(string))
+
+	}
+	sort.Strings(feedNames)
+	for _, feed := range feedNames {
+		if _, ok := mtem[feed]; ok {
+			continue
+		}
+		// fmt.Println(feed)
+		stem = append(stem, feed)
+		mtem[feed] = struct{}{}
+	}
+
+	stemEnd := []string{}
+	if sqlnamestr == "downloadPlanSFJD" {
+		bb := stem[len(stem)-flleightint : len(stem) : len(stem)]
+		//aa := stem[0 : len(stem)-flleightint : len(stem)]
+		stemEnd = append(stemEnd, bb...)
+		stemEnd = append(stemEnd, feednamesort...)
+		//fmt.Println(stemEnd)
+	} else {
+		stemEnd = stem
+	}
+
+	//logging.Info("导出数据 ",stemEnd )
+
+	for _, va := range stemEnd {
+		mapc3["label"] = va
+		mapc3["prop"] = va
+		data1 = append(data1, mapc3)
+		mapc3 = make(map[string]interface{})
+	}
+	if queryList[0]["sumlweight"] != nil {
+		mapc3["label"] = "Sum"
+		mapc3["prop"] = "sumlweight"
+	}
+	data1 = append(data1, mapc3)
+	mapc3 = make(map[string]interface{})
+	var tem interface{}
+	mapc2 := make(map[string]interface{})
+	for i := 0; i < len(queryList); i++ { // 获取所有饲料种类
+
+		if i == 0 {
+			tem = queryList[i]["projname"]
+			mapc2 = queryList[i]
+			if mapc2["sumlweight"] != nil {
+				var sumlweight float64
+				sumlweight, _ = strconv.ParseFloat(mapc2["sumlweight"].(string), 64)
+				mapc2["sumlweight"] = sumlweight
+			}
+
+			for key := range mtem {
+				mapc2[xorm.String(key)] = 0
+			}
+			// var lweight float64
+			if queryList[i]["lweight"] != nil {
+				// var error errors.Error
+				lweight, err := strconv.ParseFloat(queryList[i]["lweight"].(string), 64)
+				if err == nil {
+					mapc2[xorm.String(queryList[i]["fname"])] = lweight
+				} else {
+					mapc2[xorm.String(queryList[i]["fname"])] = queryList[i]["lweight"]
+				}
+			} else {
+				mapc2[xorm.String(queryList[i]["fname"])] = queryList[i]["lweight"]
+			}
+
+		}
+		if tem == queryList[i]["projname"] {
+			// var lweight float64
+			if queryList[i]["lweight"] != nil {
+				lweight, err := strconv.ParseFloat(queryList[i]["lweight"].(string), 64)
+				if err == nil {
+					mapc2[xorm.String(queryList[i]["fname"])] = lweight
+				} else {
+					mapc2[xorm.String(queryList[i]["fname"])] = queryList[i]["lweight"]
+				}
+			} else {
+				mapc2[xorm.String(queryList[i]["fname"])] = queryList[i]["lweight"]
+			}
+		} else {
+			data2 = append(data2, mapc2)
+			tem = queryList[i]["projname"]
+			mapc2 = queryList[i]
+			if mapc2["sumlweight"] != nil {
+				var sumlweight float64
+				sumlweight, _ = strconv.ParseFloat(mapc2["sumlweight"].(string), 64)
+				mapc2["sumlweight"] = sumlweight
+			}
+			for key := range mtem {
+				mapc2[xorm.String(key)] = 0
+			}
+			if queryList[i]["lweight"] != nil {
+				lweight, err := strconv.ParseFloat(queryList[i]["lweight"].(string), 64)
+				if err == nil {
+					mapc2[xorm.String(queryList[i]["fname"])] = lweight
+				} else {
+					mapc2[xorm.String(queryList[i]["fname"])] = queryList[i]["lweight"]
+				}
+			} else {
+				mapc2[xorm.String(queryList[i]["fname"])] = queryList[i]["lweight"]
+			}
+		}
+	}
+
+	data2 = append(data2, mapc2)
+	chartData["data1"] = data1
+	chartData["data2"] = data2
+	queryData["list"] = chartData
+	queryData["code"] = 0
+	queryData["message"] = "ok"
+	queryData["data"] = queryList
+	return queryData, nil
+}
+
 func getAccuracyV8(queryList []map[string]interface{}) (map[string]interface{}, error) {
 	queryData := make(map[string]interface{})
 	chartData := make(map[string]interface{})

+ 2 - 2
http/handle/api/scheduled.go

@@ -131,7 +131,7 @@ func CronScheduled(ctx context.Context) {
 	dayCron.Start()
 	// udFeedSync(pastureinfo)
 	// //圣牧自动同步前天有进行中的任务
-	manualUdData(pastureinfo)
+	// manualUdData(pastureinfo)
 	// gm.GmUdSync(pastureinfo.Pastureid, pastureinfo.Werks)
 	// xdmy := cron.New()
 	// err = xdmy.AddFunc("0 30 4 * * *", func() {
@@ -146,7 +146,7 @@ func CronScheduled(ctx context.Context) {
 	// })
 
 	// xdmy.Start()
-	InitMqttClient()
+	// InitMqttClient()
 	// yq.YqCron()
 }
 

+ 1 - 0
http/routers/app_api.go

@@ -45,6 +45,7 @@ func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 
 		s.GET("/getData", api.GetWxCode)
 		s.GET("/getData/yq", api.GetYqWxCode)
+		s.POST("/language/edit", api.EditLanguage)
 
 		s.POST("/userwxopenid/binding", api.UserWXOpenIDBinding)
 

部分文件因为文件数量过多而无法显示