V0 图表工序模糊
This commit is contained in:
parent
538facc977
commit
8664dd811a
@ -283,12 +283,12 @@ func PassProbabilityByFactory(r *request.PassProbabilityByFactory) ([]*model.Lin
|
|||||||
if r.Factory != "" {
|
if r.Factory != "" {
|
||||||
sql += "factory = '" + r.Factory + "'"
|
sql += "factory = '" + r.Factory + "'"
|
||||||
}
|
}
|
||||||
global.PostGreSQL.Model(&model.Report{}).Where("step = ? AND order_date BETWEEN ? AND ?", r.Type, startDate, endDate).
|
global.PostGreSQL.Model(&model.Report{}).Where("step LIKE ? AND order_date BETWEEN ? AND ?", "%"+r.Type+"%", startDate, endDate).
|
||||||
Where(sql).Group("factory").Select("Factory").Find(&factorys)
|
Where(sql).Group("factory").Select("Factory").Find(&factorys)
|
||||||
for _, factory := range factorys {
|
for _, factory := range factorys {
|
||||||
var x, lineY, histogramY []string
|
var x, lineY, histogramY []string
|
||||||
var reports []*model.Report
|
var reports []*model.Report
|
||||||
global.PostGreSQL.Where("step = ? AND factory = ? AND order_date BETWEEN ? AND ?", r.Type, factory, startDate, endDate).
|
global.PostGreSQL.Where("step = ? AND factory = ? AND order_date BETWEEN ? AND ?", "%"+r.Type+"%", factory, startDate, endDate).
|
||||||
Find(&reports)
|
Find(&reports)
|
||||||
factoryMap := make(map[string][]string)
|
factoryMap := make(map[string][]string)
|
||||||
for _, report := range reports {
|
for _, report := range reports {
|
||||||
@ -355,8 +355,8 @@ func FTPassProbabilityByProduct(r *request.PassProbabilityByProduct) (*model.Lin
|
|||||||
sql += "factory = '" + r.Factory + "'"
|
sql += "factory = '" + r.Factory + "'"
|
||||||
}
|
}
|
||||||
var reports []*model.Report
|
var reports []*model.Report
|
||||||
global.PostGreSQL.Where("step = ? AND product = ? AND order_date BETWEEN ? AND ?",
|
global.PostGreSQL.Where("step LIKE ? AND product = ? AND order_date BETWEEN ? AND ?",
|
||||||
r.Type, r.Product, startDate, endDate).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
"%"+r.Type+"%", r.Product, startDate, endDate).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("report_site_id = ?", 0)
|
return db.Where("report_site_id = ?", 0)
|
||||||
}).Where(sql).Find(&reports)
|
}).Where(sql).Find(&reports)
|
||||||
productMap := make(map[string][]string)
|
productMap := make(map[string][]string)
|
||||||
@ -462,16 +462,16 @@ func PassProbabilityLine(r *request.TestPassProbabilityLine) {
|
|||||||
func PassProbability(r *request.PassProbability) (interface{}, string) {
|
func PassProbability(r *request.PassProbability) (interface{}, string) {
|
||||||
var reports []*model.Report
|
var reports []*model.Report
|
||||||
if len(r.Product) == 0 && len(r.Lot) == 0 {
|
if len(r.Product) == 0 && len(r.Lot) == 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Order("created_at").Find(&reports)
|
Order("created_at").Find(&reports)
|
||||||
} else if len(r.Product) != 0 && len(r.Lot) == 0 {
|
} else if len(r.Product) != 0 && len(r.Lot) == 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Where("product IN ?", r.Product).Order("created_at").Find(&reports)
|
Where("product IN ?", r.Product).Order("created_at").Find(&reports)
|
||||||
} else if len(r.Product) == 0 && len(r.Lot) != 0 {
|
} else if len(r.Product) == 0 && len(r.Lot) != 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Where("lot IN ?", r.Lot).Order("created_at").Find(&reports)
|
Where("lot IN ?", r.Lot).Order("created_at").Find(&reports)
|
||||||
} else if len(r.Product) != 0 && len(r.Lot) != 0 {
|
} else if len(r.Product) != 0 && len(r.Lot) != 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Where("product IN ? AND lot IN ?", r.Product, r.Lot).Order("created_at").Find(&reports)
|
Where("product IN ? AND lot IN ?", r.Product, r.Lot).Order("created_at").Find(&reports)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,22 +714,22 @@ func PassProbability(r *request.PassProbability) (interface{}, string) {
|
|||||||
func BinProbability(r *request.BinProbability) (interface{}, string) {
|
func BinProbability(r *request.BinProbability) (interface{}, string) {
|
||||||
var reports []*model.Report
|
var reports []*model.Report
|
||||||
if len(r.Product) == 0 && len(r.Lot) == 0 {
|
if len(r.Product) == 0 && len(r.Lot) == 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("report_site_id = ?", 0)
|
return db.Where("report_site_id = ?", 0)
|
||||||
}).Order("created_at").Find(&reports)
|
}).Order("created_at").Find(&reports)
|
||||||
} else if len(r.Product) != 0 && len(r.Lot) == 0 {
|
} else if len(r.Product) != 0 && len(r.Lot) == 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Where("product IN ?", r.Product).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
Where("product IN ?", r.Product).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("report_site_id = ?", 0)
|
return db.Where("report_site_id = ?", 0)
|
||||||
}).Order("created_at").Find(&reports)
|
}).Order("created_at").Find(&reports)
|
||||||
} else if len(r.Product) == 0 && len(r.Lot) != 0 {
|
} else if len(r.Product) == 0 && len(r.Lot) != 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Where("lot IN ?", r.Lot).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
Where("lot IN ?", r.Lot).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("report_site_id = ?", 0)
|
return db.Where("report_site_id = ?", 0)
|
||||||
}).Order("created_at").Find(&reports)
|
}).Order("created_at").Find(&reports)
|
||||||
} else if len(r.Product) != 0 && len(r.Lot) != 0 {
|
} else if len(r.Product) != 0 && len(r.Lot) != 0 {
|
||||||
global.PostGreSQL.Where("step = ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", r.Step, r.StartDate, r.EndDate).
|
global.PostGreSQL.Where("step LIKE ? AND DATE(created_at) BETWEEN DATE(?) AND DATE(?)", "%"+r.Step+"%", r.StartDate, r.EndDate).
|
||||||
Where("product IN ? AND lot IN ?", r.Product, r.Lot).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
Where("product IN ? AND lot IN ?", r.Product, r.Lot).Preload("BinFail", func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("report_site_id = ?", 0)
|
return db.Where("report_site_id = ?", 0)
|
||||||
}).Order("created_at").Find(&reports)
|
}).Order("created_at").Find(&reports)
|
||||||
|
Loading…
Reference in New Issue
Block a user