|
@@ -11,7 +11,7 @@ func MixedFodderData(req *models.AnalysisAccuracyRequest) ([]*models.MixedFodder
|
|
|
newSql := restful.Engine.NewSession().Table("downloadedplan").Alias("dp").
|
|
|
Select("dp.oweight,dp.lweight,dp.iweight,dp.mydate").
|
|
|
Join("LEFT", []string{"feedtemplet", "ft"}, "dp.tempid = ft.id").
|
|
|
- Where("1 = 1")
|
|
|
+ Where("dp.pastureid = ?", req.PastureId)
|
|
|
|
|
|
if len(req.StartDate) > 0 && len(req.EndDate) > 0 {
|
|
|
newSql.And("dp.mydate >= ? and dp.mydate <= ?", req.StartDate, req.EndDate)
|
|
@@ -21,10 +21,6 @@ func MixedFodderData(req *models.AnalysisAccuracyRequest) ([]*models.MixedFodder
|
|
|
newSql.And("ft.ccid = ?", req.CattleParentCategoryId)
|
|
|
}
|
|
|
|
|
|
- if req.PastureId > 0 {
|
|
|
- newSql.And("dp.pastureid = ?", req.PastureId)
|
|
|
- }
|
|
|
-
|
|
|
if req.FeedFormulaId > 0 {
|
|
|
newSql.And("dp.tempid = ?", req.FeedFormulaId)
|
|
|
}
|
|
@@ -48,7 +44,7 @@ func MixedFodderCorrectData(req *models.AnalysisAccuracyRequest) ([]*models.Mixe
|
|
|
newSql := restful.Engine.NewSession().Table("downloadplandtl1").Alias("de").
|
|
|
Select(`SUM(de.havebuttom) AS "use_mixed_fodder_option_number",de.date,IFNULL(SUM(IF(ABS(de.actualweightminus-de.lweight)<=de.feedallowratio AND de.actualweightminus<>0,1,0)),0) AS "mixed_correct_number"`).
|
|
|
Join("LEFT", []string{"feedtemplet", "ft"}, "ft.id = de.fid").
|
|
|
- Where("1 = 1")
|
|
|
+ Where("de.pastureid = ?", req.PastureId)
|
|
|
|
|
|
if len(req.StartDate) > 0 && len(req.EndDate) > 0 {
|
|
|
newSql.And("de.date >= ? and de.date <= ?", req.StartDate, req.EndDate)
|
|
@@ -58,10 +54,6 @@ func MixedFodderCorrectData(req *models.AnalysisAccuracyRequest) ([]*models.Mixe
|
|
|
newSql.And("ft.ccid = ?", req.CattleParentCategoryId)
|
|
|
}
|
|
|
|
|
|
- if req.PastureId > 0 {
|
|
|
- newSql.And("de.pastureid = ?", req.PastureId)
|
|
|
- }
|
|
|
-
|
|
|
if req.FeedFormulaId > 0 {
|
|
|
newSql.And("de.tempid = ?", req.FeedFormulaId)
|
|
|
}
|
|
@@ -76,7 +68,7 @@ func SprinkleFodderCorrectData(req *models.AnalysisAccuracyRequest) ([]*models.S
|
|
|
newSql := restful.Engine.NewSession().Table("downloadplandtl2").Alias("de").
|
|
|
Select(`SUM(de.havebuttom) AS "use_sprinkle_option_number",de.date,IFNULL(SUM(IF(ABS(de.actualweightminus-de.lweight)<=de.allowratio AND de.actualweightminus<>0,1,0)),0) AS "sprinkle_correct_number"`).
|
|
|
Join("LEFT", []string{"feedtemplet", "ft"}, "ft.id = de.feedtempletid").
|
|
|
- Where("1 = 1")
|
|
|
+ Where("de.pastureid = ?", req.PastureId)
|
|
|
|
|
|
if len(req.StartDate) > 0 && len(req.EndDate) > 0 {
|
|
|
newSql.And("de.date >= ? and de.date <= ?", req.StartDate, req.EndDate)
|
|
@@ -86,10 +78,6 @@ func SprinkleFodderCorrectData(req *models.AnalysisAccuracyRequest) ([]*models.S
|
|
|
newSql.And("ft.ccid = ?", req.CattleParentCategoryId)
|
|
|
}
|
|
|
|
|
|
- if req.PastureId > 0 {
|
|
|
- newSql.And("de.pastureid = ?", req.PastureId)
|
|
|
- }
|
|
|
-
|
|
|
if req.FeedFormulaId > 0 {
|
|
|
newSql.And("de.tempid = ?", req.FeedFormulaId)
|
|
|
}
|
|
@@ -102,9 +90,9 @@ func SprinkleFodderCorrectData(req *models.AnalysisAccuracyRequest) ([]*models.S
|
|
|
func ProcessAnalysisData(req *models.AnalysisAccuracyRequest) ([]*models.ProcessData, error) {
|
|
|
res := make([]*models.ProcessData, 0)
|
|
|
newSql := restful.Engine.Table("downloadplandtl1_exec").Alias("e").
|
|
|
- Select("e.id,e.begintime as exec_begin_time,e.intime as exec_end_time,e.processtime as exec_process_time,l2.begintime as l2_begin_time,l2.intime as l2_end_time,l2.processtime as l2_process_time").
|
|
|
+ Select("e.id,e.begintime as exec_begin_time,e.intime as exec_end_time,e.processtime as exec_process_time,e.stirdelay as exec_stir_delay ,l2.begintime as l2_begin_time,l2.intime as l2_end_time,l2.processtime as l2_process_time").
|
|
|
Join("LEFT", []string{"downloadplandtl2", "l2"}, "e.pastureid = l2.pastureid and e.pid = l2.pid").
|
|
|
- Where("1 = 1")
|
|
|
+ Where("e.pastureid = ?", req.PastureId)
|
|
|
|
|
|
if len(req.StartDate) > 0 && len(req.EndDate) > 0 {
|
|
|
newSql.And("e.date >= ? and e.date <= ?", req.StartDate, req.EndDate)
|
|
@@ -114,10 +102,6 @@ func ProcessAnalysisData(req *models.AnalysisAccuracyRequest) ([]*models.Process
|
|
|
newSql.And("l2.cowclassid = ?", req.CattleParentCategoryId)
|
|
|
}
|
|
|
|
|
|
- if req.PastureId > 0 {
|
|
|
- newSql.And("e.pastureid = ?", req.PastureId)
|
|
|
- }
|
|
|
-
|
|
|
if req.FeedFormulaId > 0 {
|
|
|
newSql.And("l2.feedtempletid = ?", req.FeedFormulaId)
|
|
|
}
|
|
@@ -127,3 +111,23 @@ func ProcessAnalysisData(req *models.AnalysisAccuracyRequest) ([]*models.Process
|
|
|
|
|
|
return res, nil
|
|
|
}
|
|
|
+
|
|
|
+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")
|
|
|
+ if len(req.StartDate) > 0 && len(req.EndDate) > 0 {
|
|
|
+ newSql.And("a.date >= ? and a.date <= ?", req.StartDate, req.EndDate)
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.FeedFormulaId > 0 {
|
|
|
+ newSql.And("a.feedtempletid = ?", req.FeedFormulaId)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := newSql.GroupBy("a.fbarid ,b.intime").Find(&res); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return res, nil
|
|
|
+}
|