Browse Source

splinkle: 撒料时间统计

Yi 1 year ago
parent
commit
94c7775d7f
5 changed files with 75 additions and 12 deletions
  1. 61 0
      conf/app-develop.ini
  2. 2 0
      conf/setting/setting.go
  3. 1 1
      models/group_data.go
  4. 8 3
      module/group.go
  5. 3 8
      service/group/group.go

+ 61 - 0
conf/app-develop.ini

@@ -0,0 +1,61 @@
+[app]
+PageSize = 10
+JwtSecret = 111111
+
+FileSavePath=uploads/files/
+FileMaxSize = 1000000
+FileAllowType = .jpg, .jpeg, .png, .ico, .svg, .bmp, .gif, .doc, .docx, .ppt, .pptx, .xls, .xlsx, .pdf, .mp3, .txt
+ImageSavePath=uploads/image/
+ExportSavePath=uploads/exportfiles/
+ImageMaxSize = 10
+ThumbnailSavePath=uploads/thumbnail/
+ThumbnailMaxWidth=800
+ThumbnailMaxHeight=800
+
+LogSavePath = logs/
+LogSaveName = log
+LogFileExt = log
+TimeFormat = 20060102-150405
+
+[server]
+#debug or release
+#RunMode = debug
+RunMode = release
+HttpPort = 8082
+ReadTimeout = 60
+WriteTimeout = 60
+NoAuth = 1
+Mdns_servicename = kptadmin
+Mdns_serviceport = 5354
+# 0 http 1 https 2 http & https 不填 http
+Https = 2
+HttpsPort = 443
+CrtPath = conf/ssl.crt
+KeyPath = conf/ssl.key
+
+# 服务
+ServerName = tmrgo
+DisplayName = tmrgo
+Description = tmrgo
+
+[database]
+Type = mysql
+User = root
+Password = 123456
+Host = 192.168.1.96:3306
+Name = tmrwatch3
+TablePrefix =
+
+ShowXormlog = false
+ShowGetSqllog = false
+CacheApiSql = false
+
+
+[comm]
+PortName =
+BaudRate = 9600
+DataBits = 8
+StopBits = 1
+ParityMode = 0    #PARITY_NONE  0	PARITY_ODD  1	PARITY_EVEN  2
+InterCharacterTimeout = 100
+MinimumReadSize = 0

+ 2 - 0
conf/setting/setting.go

@@ -115,6 +115,8 @@ func Setup() {
 	switch appEnv {
 	case "test":
 		cfg, err = ini.Load(CurrentPath + "conf/app-test.ini")
+	case "develop":
+		cfg, err = ini.Load(CurrentPath + "conf/app-develop.ini")
 	default:
 		cfg, err = ini.Load(CurrentPath + "conf/app.ini")
 	}

+ 1 - 1
models/group_data.go

@@ -38,7 +38,7 @@ type PastureFeedFormulaIsModifyRequest struct {
 }
 
 type AnalysisAccuracyRequest struct {
-	CattleParentCategoryId int32  `json:"cattle_Parent_Category_Id"`
+	CattleParentCategoryId int32  `json:"cattle_parent_category_Id"`
 	FeedFormulaId          int32  `json:"feed_formula_id"`
 	StartDate              string `json:"start_date"`
 	EndDate                string `json:"end_date"`   // 结束时间

+ 8 - 3
module/group.go

@@ -2,6 +2,7 @@ package module
 
 import (
 	"errors"
+	"fmt"
 	"tmr-watch/http/handle/restful"
 	"tmr-watch/models"
 )
@@ -164,9 +165,11 @@ func ProcessAnalysisData(req *models.AnalysisAccuracyRequest) ([]*models.Process
 
 func SprinkleStatistics(req *models.SprinkleStatisticsRequest) ([]*models.SprinkleStatisticsDataList, error) {
 	res := make([]*models.SprinkleStatisticsDataList, 0)
-	newSql := restful.Engine.Table("downloadplandtl2").Alias("a").Select("a.fbarid,a.fname,a.intime,a.processtime,b.times").
-		Join("LEFT", []string{"downloadedplan", "b"}, "a.pastureid = b.pastureid AND b.pid = a.pid").
-		Where("a.pastureid = ?", req.PastureId).And("b.times > 0 ").And("a.fbarid > 0")
+	newSql := restful.Engine.Table("downloadedplan").Alias("b").
+		Select("a.fbarid,a.fname,a.intime,a.processtime,b.times").
+		Join("LEFT", []string{"downloadplandtl2", "a"}, "a.pastureid = b.pastureid AND b.pid = a.flpid").
+		Where("a.pastureid = ?", req.PastureId).And("b.times > 0 ").
+		And("a.fbarid > 0").And("a.intime IS NOT NULL").And("a.processtime IS NOT NULL")
 	if len(req.StartDate) > 0 && len(req.EndDate) > 0 {
 		newSql.And("a.date >= ? and  a.date <= ?", req.StartDate, req.EndDate)
 	}
@@ -178,6 +181,8 @@ func SprinkleStatistics(req *models.SprinkleStatisticsRequest) ([]*models.Sprink
 	if err := newSql.GroupBy("a.fbarid ,b.intime").Find(&res); err != nil {
 		return nil, err
 	}
+	str, err := newSql.LastSQL()
+	fmt.Println("=======str,err===", str, err)
 
 	return res, nil
 }

+ 3 - 8
service/group/group.go

@@ -1,7 +1,6 @@
 package group
 
 import (
-	"encoding/json"
 	"fmt"
 	"sort"
 	"time"
@@ -74,11 +73,6 @@ func AnalysisAccuracyService(req *models.AnalysisAccuracyRequest) (*models.Analy
 	// 撒料正确率
 	sprinkleFodderCorrectDataList, err := module.SprinkleFodderCorrectData(req)
 
-	a, _ := json.Marshal(mixedFodderCorrectDataList)
-	fmt.Println("====mixedFodderCorrectDataList===", string(a))
-	b, _ := json.Marshal(sprinkleFodderCorrectDataList)
-	fmt.Println("====mixedFodderCorrectDataList===", string(b))
-
 	timeList := util.TimeBetween(req.StartDate, req.EndDate)
 	for _, dayTime := range timeList {
 		var mixedInfo, sprinkleInfo, mixedCorrectInfo, sprinkleCorrectInfo bool
@@ -141,8 +135,9 @@ func AnalysisAccuracyService(req *models.AnalysisAccuracyRequest) (*models.Analy
 		}
 
 		for _, mixedFodder := range mixedFodderCorrectDataList {
-			fmt.Println("====mixedFodder.Date========", mixedFodder.Date)
-			if mixedFodder.Date != dayTime {
+			mixDateStr, _ := time.ParseInLocation(time.RFC3339, mixedFodder.Date, time.Local)
+			mixDate := mixDateStr.Format("2006-01-02")
+			if mixDate != dayTime {
 				continue
 			}
 			if mixedFodder.MixedCorrectNumber == 0 || mixedFodder.UseMixedFodderOptionNumber == 0 {