数据分析平台 报表查询测试数据去除临时测试文件数据
This commit is contained in:
parent
6cd854ae17
commit
c5dc5b8838
@ -1469,17 +1469,17 @@ func ExportFT(isWeek bool) string {
|
|||||||
var ftLists []*model.FTList
|
var ftLists []*model.FTList
|
||||||
var pbis, lots []string
|
var pbis, lots []string
|
||||||
if isWeek {
|
if isWeek {
|
||||||
global.PostGreSQL.Model(&model.Report{}).Where("pbi != ? AND created_at BETWEEN ? AND ?", "",
|
global.PostGreSQL.Model(&model.Report{}).Where("pbi != ? AND pbi LIKE ? AND created_at BETWEEN ? AND ?", "", "%M%",
|
||||||
carbon.Now().SubWeek().Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
carbon.Now().SubWeek().Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
||||||
Group("pbi").Select("pbi").Find(&pbis)
|
Group("pbi").Select("pbi").Find(&pbis)
|
||||||
global.PostGreSQL.Model(&model.Report{}).Where("lot != ? AND created_at BETWEEN ? AND ?", "",
|
global.PostGreSQL.Model(&model.Report{}).Where("lot != ? AND pbi LIKE ? AND created_at BETWEEN ? AND ?", "", "%M%",
|
||||||
carbon.Now().SubWeek().Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
carbon.Now().SubWeek().Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
||||||
Group("lot").Select("lot").Find(&lots)
|
Group("lot").Select("lot").Find(&lots)
|
||||||
} else {
|
} else {
|
||||||
global.PostGreSQL.Model(&model.Report{}).Where("pbi != ? AND created_at BETWEEN ? AND ?", "",
|
global.PostGreSQL.Model(&model.Report{}).Where("pbi != ? AND pbi LIKE ? AND created_at BETWEEN ? AND ?", "", "%M%",
|
||||||
carbon.Now().SubMonths(2).Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
carbon.Now().SubMonths(2).Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
||||||
Group("pbi").Select("pbi").Find(&pbis)
|
Group("pbi").Select("pbi").Find(&pbis)
|
||||||
global.PostGreSQL.Model(&model.Report{}).Where("lot != ? AND created_at BETWEEN ? AND ?", "",
|
global.PostGreSQL.Model(&model.Report{}).Where("lot != ? AND pbi LIKE ? AND created_at BETWEEN ? AND ?", "", "%M%",
|
||||||
carbon.Now().SubMonths(2).Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
carbon.Now().SubMonths(2).Format("Y-m-d"), carbon.Now().Format("Y-m-d")).
|
||||||
Group("lot").Select("lot").Find(&lots)
|
Group("lot").Select("lot").Find(&lots)
|
||||||
}
|
}
|
||||||
@ -1601,7 +1601,7 @@ func ExportFT(isWeek bool) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var fileHandles []*model.FileHandled
|
var fileHandles []*model.FileHandled
|
||||||
global.PostGreSQL.Where("step = ? AND pbi = ? AND product = ? AND lot = ?", "FT", ftList.PBI,
|
global.PostGreSQL.Where("step = ? AND pbi = ?AND product = ? AND lot = ?", "FT", ftList.PBI,
|
||||||
ftList.Product, ftList.Lot).Find(&fileHandles)
|
ftList.Product, ftList.Lot).Find(&fileHandles)
|
||||||
siteDiffState := "正常"
|
siteDiffState := "正常"
|
||||||
stackingMaterials := "否"
|
stackingMaterials := "否"
|
||||||
|
@ -571,17 +571,17 @@ func PassProbability(r *request.PassProbability) (interface{}, string) {
|
|||||||
r.EndDate = carbon.Parse(r.EndDate).AddDay().Format("Y-m-d")
|
r.EndDate = carbon.Parse(r.EndDate).AddDay().Format("Y-m-d")
|
||||||
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 LIKE ? 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(?) AND pbi LIKE ?", "%"+r.Step+"%", r.StartDate, r.EndDate, "%M%").
|
||||||
Order("created_at").Find(&reports)
|
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 LIKE ? 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(?) AND pbi LIKE ?", "%"+r.Step+"%", r.StartDate, r.EndDate, "%M%").
|
||||||
Where("product IN ?", r.Product).Order("created_at").Find(&reports)
|
Where("product IN ?", r.Product).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 LIKE ? 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(?) AND pbi LIKE ?", "%"+r.Step+"%", r.StartDate, r.EndDate, "%M%").
|
||||||
Where("lot IN ?", r.Lot).Order("created_at").Find(&reports)
|
Where("lot IN ?", r.Lot).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 LIKE ? 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(?) AND pbi LIKE ?", "%"+r.Step+"%", r.StartDate, r.EndDate, "%M%").
|
||||||
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).Find(&reports)
|
||||||
}
|
}
|
||||||
|
|
||||||
passProbabilityMap := make(map[string][]float64)
|
passProbabilityMap := make(map[string][]float64)
|
||||||
@ -643,8 +643,15 @@ func PassProbability(r *request.PassProbability) (interface{}, string) {
|
|||||||
if _, ok := passProbabilityMap[s]; !ok {
|
if _, ok := passProbabilityMap[s]; !ok {
|
||||||
passProbabilityMap[s] = []float64{}
|
passProbabilityMap[s] = []float64{}
|
||||||
}
|
}
|
||||||
testQuantityDecimal, _ := decimal.NewFromString(report.TestQuantity)
|
var testQuantityDecimal, passQuantityDecimal decimal.Decimal
|
||||||
passQuantityDecimal, _ := decimal.NewFromString(report.PassQuantity)
|
if r.Y == "初测良率" {
|
||||||
|
testQuantityDecimal, _ = decimal.NewFromString(report.TestQuantity)
|
||||||
|
passQuantityDecimal, _ = decimal.NewFromString(report.FirstPassQuantity)
|
||||||
|
} else if r.Y == "良率" {
|
||||||
|
testQuantityDecimal, _ = decimal.NewFromString(report.TestQuantity)
|
||||||
|
passQuantityDecimal, _ = decimal.NewFromString(report.PassQuantity)
|
||||||
|
}
|
||||||
|
|
||||||
if !testQuantityDecimal.IsZero() {
|
if !testQuantityDecimal.IsZero() {
|
||||||
passProbability, _ := passQuantityDecimal.Div(testQuantityDecimal).Round(4).Mul(decimal.NewFromInt(100)).Float64()
|
passProbability, _ := passQuantityDecimal.Div(testQuantityDecimal).Round(4).Mul(decimal.NewFromInt(100)).Float64()
|
||||||
passProbabilityMap[s] = append(passProbabilityMap[s], passProbability)
|
passProbabilityMap[s] = append(passProbabilityMap[s], passProbability)
|
||||||
@ -739,15 +746,20 @@ func PassProbability(r *request.PassProbability) (interface{}, string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for k, v := range passProbabilityMap {
|
for k := range passProbabilityMap {
|
||||||
|
x = append(x, k)
|
||||||
|
}
|
||||||
|
sort.Slice(x, func(i, j int) bool {
|
||||||
|
return x[i] < x[j]
|
||||||
|
})
|
||||||
|
for _, v := range x {
|
||||||
average := 0.0
|
average := 0.0
|
||||||
for _, passProbability := range v {
|
for _, passProbability := range passProbabilityMap[v] {
|
||||||
average += passProbability
|
average += passProbability
|
||||||
}
|
}
|
||||||
if len(v) != 0 {
|
if len(passProbabilityMap[v]) != 0 {
|
||||||
average /= float64(len(v))
|
average /= float64(len(passProbabilityMap[v]))
|
||||||
}
|
}
|
||||||
x = append(x, k)
|
|
||||||
y = append(y, decimal.NewFromFloat(average).Round(2).String())
|
y = append(y, decimal.NewFromFloat(average).Round(2).String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -765,14 +777,14 @@ func PassProbability(r *request.PassProbability) (interface{}, string) {
|
|||||||
if _, ok := passProbabilityGroup[s]; !ok {
|
if _, ok := passProbabilityGroup[s]; !ok {
|
||||||
groupY = append(groupY, "")
|
groupY = append(groupY, "")
|
||||||
} else {
|
} else {
|
||||||
averagea := 0.0
|
average := 0.0
|
||||||
for _, passProbability := range passProbabilityGroup[s] {
|
for _, passProbability := range passProbabilityGroup[s] {
|
||||||
averagea += passProbability
|
average += passProbability
|
||||||
}
|
}
|
||||||
if len(passProbabilityGroup[s]) != 0 {
|
if len(passProbabilityGroup[s]) != 0 {
|
||||||
averagea /= float64(len(passProbabilityGroup[s]))
|
average /= float64(len(passProbabilityGroup[s]))
|
||||||
}
|
}
|
||||||
groupY = append(groupY, decimal.NewFromFloat(averagea).Round(2).String())
|
groupY = append(groupY, decimal.NewFromFloat(average).Round(2).String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lineSeries := &model.Line{
|
lineSeries := &model.Line{
|
||||||
|
@ -39,6 +39,7 @@ type PassProbability struct {
|
|||||||
StartDate string `json:"start_date"`
|
StartDate string `json:"start_date"`
|
||||||
EndDate string `json:"end_date"`
|
EndDate string `json:"end_date"`
|
||||||
X []string `json:"x"`
|
X []string `json:"x"`
|
||||||
|
Y string `json:"y"`
|
||||||
Product []string `json:"product"`
|
Product []string `json:"product"`
|
||||||
Lot []string `json:"lot"`
|
Lot []string `json:"lot"`
|
||||||
ChartType string `json:"chart_type"`
|
ChartType string `json:"chart_type"`
|
||||||
|
Loading…
Reference in New Issue
Block a user