41 lines
1.5 KiB
Go
41 lines
1.5 KiB
Go
package test_data
|
|
|
|
import (
|
|
"gitee.com/golang-module/carbon/v2"
|
|
"testData/global"
|
|
"testData/model"
|
|
"testData/request"
|
|
)
|
|
|
|
func ProductSelection(r *request.ChartSelection) []string {
|
|
now := carbon.Now()
|
|
startDate := now.SubMonths(12).Format("Y-m-d")
|
|
var products []string
|
|
global.PostGreSQL.Model(&model.FileHandled{}).Where("step = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
|
r.Step, startDate, now.Format("Y-m-d")).Group("product").Select("product").Find(&products)
|
|
//if strings.Contains(r.Step, "FT") {
|
|
// global.PostGreSQL.Model(&model.FTList{}).Group("product").Select("product").Find(&products)
|
|
//} else if strings.Contains(r.Step, "CP") {
|
|
// global.PostGreSQL.Model(&model.CPList{}).Group("product").Select("product").Find(&products)
|
|
//}
|
|
return products
|
|
}
|
|
|
|
func LotSelection(r *request.ChartSelection) []string {
|
|
now := carbon.Now()
|
|
startDate := now.SubMonths(12).Format("Y-m-d")
|
|
var lots []string
|
|
global.PostGreSQL.Model(&model.FileHandled{}).Where("step = ? AND product = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
|
r.Step, r.Product, startDate, now.Format("Y-m-d")).Group("lot").Select("lot").Find(&lots)
|
|
return lots
|
|
}
|
|
|
|
func PBISelection(r *request.ChartSelection) []string {
|
|
now := carbon.Now()
|
|
startDate := now.SubMonths(12).Format("Y-m-d")
|
|
var pbis []string
|
|
global.PostGreSQL.Model(&model.FileHandled{}).Where("step = ? AND product = ? AND lot = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
|
r.Step, r.Product, r.Lot, startDate, now.Format("Y-m-d")).Group("pbi").Select("pbi").Find(&pbis)
|
|
return pbis
|
|
}
|