V0 自动抓取测试文件处理
This commit is contained in:
parent
42187b33d0
commit
c261e37772
@ -7,7 +7,6 @@ import (
|
||||
"path/filepath"
|
||||
"testData/model"
|
||||
"testData/model/response"
|
||||
"testData/repository"
|
||||
test_data "testData/repository/test.data"
|
||||
"testData/request"
|
||||
"testData/utils"
|
||||
@ -75,14 +74,15 @@ func (D *ImportService) ImportTestFile(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
repository.HandleSTS8200Excel(&model.FileText{
|
||||
test_data.HandleSTS8200Excel(&model.FileText{
|
||||
Name: file.Filename,
|
||||
Path: filePath,
|
||||
Size: utils.FormatFileSize(float64(file.Size)),
|
||||
//Size: utils.FormatFileSize(float64(file.Size)),
|
||||
Factory: factory,
|
||||
ProductName: productName,
|
||||
Lot: lot,
|
||||
SubBatch: subBatch}, step)
|
||||
SubBatch: subBatch,
|
||||
Procedure: step})
|
||||
response.Ok(c)
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,8 @@ func (D *UploadService) UploadAnswerFile(c *gin.Context) {
|
||||
PBI: pbi,
|
||||
Lot: lot,
|
||||
SubBatch: subBatch,
|
||||
WaferID: waferID,
|
||||
ChipNum: waferID,
|
||||
Procedure: step,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,6 @@ func InitPostgres() {
|
||||
postgresDB.SetConnMaxLifetime(time.Hour)
|
||||
_ = db.AutoMigrate(&model.FileHandled{})
|
||||
global.PostGreSQL = db
|
||||
_ = global.PostGreSQL.AutoMigrate(&model.FileHandled{})
|
||||
_ = global.PostGreSQL.AutoMigrate(&model.FileHandled{}, &model.Report{})
|
||||
}
|
||||
}
|
||||
|
@ -1640,3 +1640,14 @@
|
||||
2024-10-30 11:33:22 INFO | 192.168.0.172 | 200 | 2m21.7066369s | POST | 未登录 | /testData/report/ft
|
||||
2024-10-30 11:33:29 INFO | 192.168.0.172 | 200 | 3.7144008s | POST | 未登录 | /testData/report/ft
|
||||
2024-10-30 11:34:02 INFO | 192.168.0.172 | 200 | 47.8578ms | POST | 未登录 | /testData/report/cp
|
||||
2024-10-31 15:36:47 INFO | 192.168.0.172 | 200 | 2.121ms | POST | 未登录 | /testData/report/probabilitySelection/product
|
||||
2024-10-31 15:36:58 INFO | 192.168.0.172 | 200 | 1.1216ms | POST | 未登录 | /testData/report/probabilitySelection/product
|
||||
2024-10-31 15:38:17 INFO | 192.168.0.172 | 200 | 1.3155ms | POST | 未登录 | /testData/report/probabilitySelection/product
|
||||
2024-10-31 15:38:46 INFO | 192.168.0.172 | 200 | 2.5735ms | POST | 未登录 | /testData/report/probabilitySelection/product
|
||||
2024-10-31 15:46:41 INFO | 192.168.0.172 | 200 | 7m49.8073103s | POST | 未登录 | /testData/report/probabilitySelection/product
|
||||
2024-10-31 15:46:41 INFO | 192.168.0.172 | 200 | 3.0877ms | POST | 未登录 | /testData/report/fTPassProbabilityByFactory
|
||||
2024-10-31 15:46:57 INFO | 192.168.0.172 | 200 | 3.3459679s | POST | 未登录 | /testData/chart/productSelection
|
||||
2024-10-31 15:47:17 INFO | 192.168.0.172 | 200 | 2.5755ms | POST | 未登录 | /testData/chart/lotSelection
|
||||
2024-10-31 15:47:19 INFO | 192.168.0.172 | 200 | 1.5652ms | POST | 未登录 | /testData/chart/pbiSelection
|
||||
2024-10-31 15:47:22 INFO | 192.168.0.172 | 200 | 1.891ms | POST | 未登录 | /testData/chart/lotSelection
|
||||
2024-10-31 15:47:22 INFO | 192.168.0.172 | 200 | 2.351ms | POST | 未登录 | /testData/selection
|
||||
|
1
main.go
1
main.go
@ -29,6 +29,7 @@ func main() {
|
||||
|
||||
initialization.InitCronListCron()
|
||||
initialization.InitEmailCron()
|
||||
//repository.TestFilesHandlerCron()
|
||||
|
||||
//var fileHandles []*model.FileHandled
|
||||
//global.PostGreSQL.Where("lot = ? AND step = ?", "S3S592", "FT").Find(&fileHandles)
|
||||
|
@ -9,17 +9,19 @@ type FileText struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `json:"name" gorm:"comment:文件名;index"`
|
||||
Path string `json:"path" gorm:"comment:文件路径;index"`
|
||||
Size string `json:"size" gorm:"comment:文件大小"`
|
||||
ModTime int64 `json:"modtime" gorm:"comment:文件修改时间"`
|
||||
IsCsv bool `json:"isCsv" gorm:"comment:是否为csv文件"`
|
||||
ModTime time.Time `json:"modtime" gorm:"comment:文件修改时间"`
|
||||
Sha1 string `json:"sha1" gorm:"comment:文件sha1值"`
|
||||
Factory string `json:"factory" gorm:"comment:厂商"`
|
||||
Processed bool `json:"processed" gorm:"comment:是否已处理"`
|
||||
ProductName string `json:"product_name"`
|
||||
PathLot string `json:"path_lot" gorm:"comment:文件路径中的批号"`
|
||||
Lot string `json:"lot" gorm:"comment:真实批号"`
|
||||
SubBatch string `json:"sub_batch" gorm:"comment:子批次号"`
|
||||
PBI string `json:"pbi"`
|
||||
Lot string `json:"lot" gorm:"comment:批次号"`
|
||||
SubBatch string `json:"sub_batch" gorm:"comment:子批次"`
|
||||
WaferID string `json:"wafer_id" gorm:"comment:片号"`
|
||||
Procedure string `json:"procedure"`
|
||||
IsRead bool `json:"is_read" gorm:"comment:是否已从文件中读产品名、批号等信息"`
|
||||
ChipNum string `json:"chipnum" gorm:"comment:晶圆片号"`
|
||||
Doubt bool `json:"doubt" gorm:"comment:文件名中取的值存在疑义,需要人工判断"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"-"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
@ -28,13 +28,13 @@ func ChangDian() {
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var step string
|
||||
if strings.Contains(fileText.Name, "RT") {
|
||||
step = "RT"
|
||||
} else {
|
||||
step = "FT"
|
||||
}
|
||||
HandleSTS8200Excel(fileText, step)
|
||||
//var step string
|
||||
//if strings.Contains(fileText.Name, "RT") {
|
||||
// step = "RT"
|
||||
//} else {
|
||||
// step = "FT"
|
||||
//}
|
||||
//HandleSTS8200Excel(fileText, step)
|
||||
file.Close()
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testData/global"
|
||||
"testData/model"
|
||||
)
|
||||
@ -13,13 +12,13 @@ func ChengTe() {
|
||||
Where("factory = ?", "chengte").
|
||||
Where("name LIKE ? AND name NOT LIKE ? AND name NOT LIKE ? AND name NOT LIKE ? AND name NOT LIKE ?",
|
||||
"%FT%", "%FT_LV%", "%FT_EQC%", "%FT_QC%", "%FT_NT%").Find(&fileTexts)
|
||||
for _, fileText := range fileTexts {
|
||||
var step string
|
||||
if strings.Contains(fileText.Name, "RT") {
|
||||
step = "RT"
|
||||
} else {
|
||||
step = "FT"
|
||||
}
|
||||
HandlerTQT601Excel(fileText, step)
|
||||
}
|
||||
//for _, fileText := range fileTexts {
|
||||
//var step string
|
||||
//if strings.Contains(fileText.Name, "RT") {
|
||||
// step = "RT"
|
||||
//} else {
|
||||
// step = "FT"
|
||||
//}
|
||||
//test_data.HandlerTQT601Excel(fileText, step)
|
||||
//}
|
||||
}
|
||||
|
@ -21,25 +21,25 @@ func SaiMeiKe() {
|
||||
strings.ToLower(path.Ext(fileText.Name)) != ".xls" && strings.ToLower(path.Ext(fileText.Name)) != ".xlsx" {
|
||||
continue
|
||||
}
|
||||
var step string
|
||||
if len(fileText.Name) > 8 {
|
||||
if fileText.Name[len(fileText.Name)-7:] == "cp1.csv" {
|
||||
step = "CP1"
|
||||
} else if fileText.Name[len(fileText.Name)-7:] == "cp2.csv" {
|
||||
step = "CP2"
|
||||
}
|
||||
}
|
||||
messages := strings.Split(fileText.Name, "_")
|
||||
if len(messages) >= 3 {
|
||||
if strings.Contains(messages[2], "r") {
|
||||
step = "RT"
|
||||
} else if strings.Contains(messages[2], "t") {
|
||||
step = "FT"
|
||||
}
|
||||
}
|
||||
if step == "" {
|
||||
continue
|
||||
}
|
||||
HandleSTS8200Excel(fileText, step)
|
||||
//var step string
|
||||
//if len(fileText.Name) > 8 {
|
||||
// if fileText.Name[len(fileText.Name)-7:] == "cp1.csv" {
|
||||
// step = "CP1"
|
||||
// } else if fileText.Name[len(fileText.Name)-7:] == "cp2.csv" {
|
||||
// step = "CP2"
|
||||
// }
|
||||
//}
|
||||
//messages := strings.Split(fileText.Name, "_")
|
||||
//if len(messages) >= 3 {
|
||||
// if strings.Contains(messages[2], "r") {
|
||||
// step = "RT"
|
||||
// } else if strings.Contains(messages[2], "t") {
|
||||
// step = "FT"
|
||||
// }
|
||||
//}
|
||||
//if step == "" {
|
||||
// continue
|
||||
//}
|
||||
//HandleSTS8200Excel(fileText, step)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package repository
|
||||
package test_data
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -22,7 +22,7 @@ import (
|
||||
"testData/utils"
|
||||
)
|
||||
|
||||
func MT737(summary, dataLog *model.FileText, step string) {
|
||||
func MT737(summary, dataLog *model.FileText) {
|
||||
summaryRows := make([][]string, 0)
|
||||
if strings.ToLower(path.Ext(summary.Name)) == ".csv" {
|
||||
csvBytes, err := ioutil.ReadFile(summary.Path)
|
||||
@ -154,25 +154,26 @@ func MT737(summary, dataLog *model.FileText, step string) {
|
||||
}
|
||||
}
|
||||
|
||||
if details["Test_Code"] == "" {
|
||||
details["Test_Code"] = step
|
||||
}
|
||||
//if details["Test_Code"] == "" {
|
||||
// details["Test_Code"] = step
|
||||
//}
|
||||
|
||||
sbinHbin, _ := json.Marshal(&sBinMap)
|
||||
fileName := summary.ProductName + "_" + summary.Lot + "_" + details["Test_Code"] + ".csv"
|
||||
var waferID string
|
||||
if summary.Factory == "yaxinwei" {
|
||||
if step == "CP1" || step == "CP2" {
|
||||
waferID = summary.ChipNum
|
||||
//if summary.Factory == "yaxinwei" {
|
||||
if summary.Procedure == "CP1" || summary.Procedure == "CP2" {
|
||||
length := len(summary.Name)
|
||||
waferID = summary.Name[length-10 : length-8]
|
||||
fileName = summary.ProductName + "_" + summary.Lot + "_" + waferID + "_" + details["Test_Code"] + ".csv"
|
||||
fileName = summary.ProductName + "_" + summary.Lot + "_" + waferID + "_" + summary.Procedure + ".csv"
|
||||
} else {
|
||||
if strings.Index(summary.SubBatch, "-") != strings.LastIndex(summary.SubBatch, "-") {
|
||||
summary.SubBatch = summary.SubBatch[:strings.LastIndex(summary.SubBatch, "-")]
|
||||
}
|
||||
fileName = summary.ProductName + "_" + summary.Lot + "_" + summary.SubBatch + "_" + details["Test_Code"] + ".csv"
|
||||
}
|
||||
fileName = summary.ProductName + "_" + summary.Lot + "_" + summary.SubBatch + "_" + summary.Procedure + ".csv"
|
||||
}
|
||||
//}
|
||||
dirPath := filepath.Join("/testData/test/" + summary.Factory)
|
||||
utils.MakeDir(dirPath)
|
||||
filePath := filepath.Join(dirPath, fileName)
|
||||
@ -184,8 +185,8 @@ func MT737(summary, dataLog *model.FileText, step string) {
|
||||
log.Println("创建文件失败:", err)
|
||||
return
|
||||
}
|
||||
if summary.WaferID != "" {
|
||||
waferID = summary.WaferID
|
||||
if summary.ChipNum != "" {
|
||||
waferID = summary.ChipNum
|
||||
}
|
||||
if errors.Is(global.PostGreSQL.Where("name = ?", fileName).First(&fileHandled).Error, gorm.ErrRecordNotFound) {
|
||||
global.PostGreSQL.Create(&model.FileHandled{
|
||||
@ -195,7 +196,7 @@ func MT737(summary, dataLog *model.FileText, step string) {
|
||||
Product: summary.ProductName,
|
||||
PBI: summary.PBI,
|
||||
Factory: summary.Factory,
|
||||
Step: details["Test_Code"],
|
||||
Step: summary.Procedure,
|
||||
Lot: summary.Lot,
|
||||
SubBatch: summary.SubBatch,
|
||||
TestMachineModel: "MT737",
|
@ -1,4 +1,4 @@
|
||||
package repository
|
||||
package test_data
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"testData/utils"
|
||||
)
|
||||
|
||||
func HandleSTS8200Excel(fileText *model.FileText, step string) {
|
||||
func HandleSTS8200Excel(fileText *model.FileText) {
|
||||
rows := make([][]string, 0)
|
||||
if strings.ToLower(path.Ext(fileText.Name)) == ".csv" {
|
||||
csvBytes, err := ioutil.ReadFile(fileText.Path)
|
||||
@ -194,68 +194,74 @@ func HandleSTS8200Excel(fileText *model.FileText, step string) {
|
||||
return
|
||||
}
|
||||
|
||||
if details["Test_Code"] == "" {
|
||||
details["Test_Code"] = step
|
||||
} else {
|
||||
details["Test_Code"] = details["Test_Code"][:2]
|
||||
}
|
||||
strReader := transform.NewReader(bytes.NewReader([]byte(details["Device_Name"])), simplifiedchinese.GBK.NewDecoder())
|
||||
product, _ := ioutil.ReadAll(strReader)
|
||||
if string(product) == "" {
|
||||
product = []byte(fileText.ProductName)
|
||||
}
|
||||
//if details["Test_Code"] == "" {
|
||||
// details["Test_Code"] = step
|
||||
//} else {
|
||||
// details["Test_Code"] = details["Test_Code"][:2]
|
||||
//}
|
||||
//strReader := transform.NewReader(bytes.NewReader([]byte(details["Device_Name"])), simplifiedchinese.GBK.NewDecoder())
|
||||
//product, _ := ioutil.ReadAll(strReader)
|
||||
//if string(product) == "" {
|
||||
// product = []byte(fileText.ProductName)
|
||||
//}
|
||||
testProgram := details["Program"][strings.LastIndex(details["Program"], "\\")+1:]
|
||||
sbinHbin, _ := json.Marshal(&sBinMap)
|
||||
titleInfo, _ := json.Marshal(&titleInfoMap)
|
||||
paramsSbin, _ := json.Marshal(¶msMap)
|
||||
fileName := string(product) + "_" + fileText.Lot + "_" + details["Test_Code"] + ".csv"
|
||||
var waferID string
|
||||
if fileText.Factory == "saimeike" {
|
||||
if step == "CP1" || step == "CP2" {
|
||||
length := len(fileText.Name)
|
||||
waferID = fileText.Name[length-10 : length-8]
|
||||
fileName = string(product) + "_" + fileText.Lot + "_" + waferID + "_" + details["Test_Code"] + ".csv"
|
||||
var fileName string
|
||||
if fileText.Procedure == "CP" {
|
||||
fileName = fileText.ProductName + "_" + fileText.Lot + "_" + fileText.ChipNum + "_" + fileText.Procedure + ".csv"
|
||||
} else {
|
||||
if strings.Index(fileText.SubBatch, "-") != strings.LastIndex(fileText.SubBatch, "-") {
|
||||
fileText.SubBatch = fileText.SubBatch[:strings.LastIndex(fileText.SubBatch, "-")]
|
||||
}
|
||||
fileName = string(product) + "_" + fileText.Lot + "_" + fileText.SubBatch + "_" + details["Test_Code"] + ".csv"
|
||||
}
|
||||
} else if fileText.Factory == "xinde" {
|
||||
s := strings.Split(fileText.Name, "_")
|
||||
if len(s) < 5 {
|
||||
log.Println("文件名格式有误,文件路径为:", fileText.Path)
|
||||
return
|
||||
}
|
||||
waferIDStr := s[len(s)-3]
|
||||
if len(waferIDStr) < 5 {
|
||||
log.Println("文件名格式有误,文件路径为:", fileText.Path)
|
||||
return
|
||||
}
|
||||
splitIndex := strings.Index(waferIDStr, "-")
|
||||
if splitIndex == -1 {
|
||||
log.Println("文件名格式有误,文件路径为:", fileText.Path)
|
||||
return
|
||||
}
|
||||
waferID = waferIDStr[splitIndex+1 : splitIndex+3]
|
||||
if _, ok := details["WAFER_ID"]; ok {
|
||||
details["Test_Code"] = "CP"
|
||||
if len(waferIDStr[:splitIndex]) < 8 {
|
||||
fileText.Lot = strings.ToUpper(waferIDStr[:splitIndex])
|
||||
}
|
||||
fileText.SubBatch = ""
|
||||
fileName = string(product) + "_" + fileText.Lot + "_" + waferID + "_" + details["Test_Code"] + ".csv"
|
||||
}
|
||||
} else if fileText.Factory == "qipai" {
|
||||
//details["Test_Code"]
|
||||
} else if fileText.Factory == "changdian" {
|
||||
if details["Device_Name"] == "" {
|
||||
log.Println("文件缺少产品型号信息,文件路径为:", fileText.Path)
|
||||
return
|
||||
}
|
||||
product = []byte(details["Device_Name"])
|
||||
fileName = details["Device_Name"] + "_" + fileText.Lot + "_" + fileText.SubBatch + "_" + details["Test_Code"] + ".csv"
|
||||
fileName = fileText.ProductName + "_" + fileText.Lot + "_" + fileText.SubBatch + "_" + fileText.Procedure + ".csv"
|
||||
}
|
||||
//fileName := string(product) + "_" + fileText.Lot + "_" + details["Test_Code"] + ".csv"
|
||||
//var waferID string
|
||||
//if fileText.Factory == "saimeike" {
|
||||
// if step == "CP1" || step == "CP2" {
|
||||
// length := len(fileText.Name)
|
||||
// waferID = fileText.Name[length-10 : length-8]
|
||||
// fileName = string(product) + "_" + fileText.Lot + "_" + waferID + "_" + details["Test_Code"] + ".csv"
|
||||
// } else {
|
||||
// if strings.Index(fileText.SubBatch, "-") != strings.LastIndex(fileText.SubBatch, "-") {
|
||||
// fileText.SubBatch = fileText.SubBatch[:strings.LastIndex(fileText.SubBatch, "-")]
|
||||
// }
|
||||
// fileName = string(product) + "_" + fileText.Lot + "_" + fileText.SubBatch + "_" + details["Test_Code"] + ".csv"
|
||||
// }
|
||||
//} else if fileText.Factory == "xinde" {
|
||||
// s := strings.Split(fileText.Name, "_")
|
||||
// if len(s) < 5 {
|
||||
// log.Println("文件名格式有误,文件路径为:", fileText.Path)
|
||||
// return
|
||||
// }
|
||||
// waferIDStr := s[len(s)-3]
|
||||
// if len(waferIDStr) < 5 {
|
||||
// log.Println("文件名格式有误,文件路径为:", fileText.Path)
|
||||
// return
|
||||
// }
|
||||
// splitIndex := strings.Index(waferIDStr, "-")
|
||||
// if splitIndex == -1 {
|
||||
// log.Println("文件名格式有误,文件路径为:", fileText.Path)
|
||||
// return
|
||||
// }
|
||||
// waferID = waferIDStr[splitIndex+1 : splitIndex+3]
|
||||
// if _, ok := details["WAFER_ID"]; ok {
|
||||
// details["Test_Code"] = "CP"
|
||||
// if len(waferIDStr[:splitIndex]) < 8 {
|
||||
// fileText.Lot = strings.ToUpper(waferIDStr[:splitIndex])
|
||||
// }
|
||||
// fileText.SubBatch = ""
|
||||
// fileName = string(product) + "_" + fileText.Lot + "_" + waferID + "_" + details["Test_Code"] + ".csv"
|
||||
// }
|
||||
//} else if fileText.Factory == "qipai" {
|
||||
// //details["Test_Code"]
|
||||
//} else if fileText.Factory == "changdian" {
|
||||
// if details["Device_Name"] == "" {
|
||||
// log.Println("文件缺少产品型号信息,文件路径为:", fileText.Path)
|
||||
// return
|
||||
// }
|
||||
// product = []byte(details["Device_Name"])
|
||||
// fileName = details["Device_Name"] + "_" + fileText.Lot + "_" + fileText.SubBatch + "_" + details["Test_Code"] + ".csv"
|
||||
//}
|
||||
//strings.ReplaceAll(fileText.Lot, ".", "-")
|
||||
dirPath := filepath.Join("/testData/test/" + fileText.Factory)
|
||||
utils.MakeDir(dirPath)
|
||||
@ -269,18 +275,38 @@ func HandleSTS8200Excel(fileText *model.FileText, step string) {
|
||||
log.Println("创建文件失败:", err)
|
||||
return
|
||||
}
|
||||
if fileText.WaferID != "" {
|
||||
waferID = fileText.WaferID
|
||||
}
|
||||
//if fileText.ChipNum != "" {
|
||||
// waferID = fileText.ChipNum
|
||||
//}
|
||||
if errors.Is(global.PostGreSQL.Where("name = ?", fileName).First(&fileHandled).Error, gorm.ErrRecordNotFound) {
|
||||
//global.PostGreSQL.Create(&model.FileHandled{
|
||||
// Name: fileName,
|
||||
// Path: filePath,
|
||||
// Size: "",
|
||||
// Product: string(product),
|
||||
// PBI: fileText.PBI,
|
||||
// Factory: fileText.Factory,
|
||||
// Step: details["Test_Code"],
|
||||
// Lot: fileText.Lot,
|
||||
// SubBatch: fileText.SubBatch,
|
||||
// TestMachineModel: "STS8200",
|
||||
// TestMachine: details["Tester ID"],
|
||||
// TestProgram: testProgram,
|
||||
// BeginningTime: details["Beginning Time"],
|
||||
// EndingTime: details["Ending Time"],
|
||||
// SbinHbin: string(sbinHbin),
|
||||
// ParamsSbin: string(paramsSbin),
|
||||
// TitleInfo: string(titleInfo),
|
||||
// WaferID: waferID,
|
||||
//})
|
||||
global.PostGreSQL.Create(&model.FileHandled{
|
||||
Name: fileName,
|
||||
Path: filePath,
|
||||
Size: "",
|
||||
Product: string(product),
|
||||
Product: fileText.ProductName,
|
||||
PBI: fileText.PBI,
|
||||
Factory: fileText.Factory,
|
||||
Step: details["Test_Code"],
|
||||
Step: fileText.Procedure,
|
||||
Lot: fileText.Lot,
|
||||
SubBatch: fileText.SubBatch,
|
||||
TestMachineModel: "STS8200",
|
||||
@ -291,7 +317,7 @@ func HandleSTS8200Excel(fileText *model.FileText, step string) {
|
||||
SbinHbin: string(sbinHbin),
|
||||
ParamsSbin: string(paramsSbin),
|
||||
TitleInfo: string(titleInfo),
|
||||
WaferID: waferID,
|
||||
WaferID: fileText.ChipNum,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -315,8 +341,10 @@ func HandleSTS8200Excel(fileText *model.FileText, step string) {
|
||||
return
|
||||
}
|
||||
global.PostGreSQL.Model(&fileHandled).Where("name = ?", fileName).Updates(map[string]interface{}{
|
||||
"product": string(product),
|
||||
"step": details["Test_Code"],
|
||||
"product": fileText.ProductName,
|
||||
"step": fileText.Procedure,
|
||||
//"product": string(product),
|
||||
//"step": details["Test_Code"],
|
||||
"test_machine_model": "STS8200",
|
||||
"test_machine": details["Tester ID"],
|
||||
"test_program": testProgram,
|
||||
@ -327,4 +355,25 @@ func HandleSTS8200Excel(fileText *model.FileText, step string) {
|
||||
"title_info": string(titleInfo),
|
||||
"size": utils.FormatFileSize(float64(newFile.Size())),
|
||||
})
|
||||
report := &model.Report{
|
||||
Product: fileText.ProductName,
|
||||
PBI: fileText.PBI,
|
||||
Factory: fileText.Factory,
|
||||
Step: fileText.Procedure,
|
||||
Lot: fileText.Lot,
|
||||
SubBatch: fileText.SubBatch,
|
||||
TestMachine: details["Tester ID"],
|
||||
TestProgram: testProgram,
|
||||
WaferID: fileText.ChipNum,
|
||||
}
|
||||
global.PostGreSQL.Transaction(func(tx *gorm.DB) error {
|
||||
tx.Create(report)
|
||||
tx.Find(&report)
|
||||
return nil
|
||||
})
|
||||
if fileText.Procedure == "CP" {
|
||||
SaveCP(report)
|
||||
} else {
|
||||
SaveFT(report)
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package repository
|
||||
package test_data
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
@ -240,7 +240,7 @@ func HandlerTQT601Excel(fileText *model.FileText, step string) {
|
||||
BeginningTime: details["Beginning Time"],
|
||||
EndingTime: details["Ending Time"],
|
||||
TitleInfo: string(titleInfo),
|
||||
WaferID: fileText.WaferID,
|
||||
WaferID: fileText.ChipNum,
|
||||
})
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ func ProductSelection(r *request.ChartSelection) []string {
|
||||
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)
|
||||
r.Step, startDate, now.AddDay().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") {
|
||||
@ -26,7 +26,7 @@ func LotSelection(r *request.ChartSelection) []string {
|
||||
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)
|
||||
r.Step, r.Product, startDate, now.AddDay().Format("Y-m-d")).Group("lot").Select("lot").Find(&lots)
|
||||
return lots
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ func PBISelection(r *request.ChartSelection) []string {
|
||||
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)
|
||||
r.Step, r.Product, r.Lot, startDate, now.AddDay().Format("Y-m-d")).Group("pbi").Select("pbi").Find(&pbis)
|
||||
return pbis
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ func SubBatchSelection(r *request.ChartSelection) []string {
|
||||
startDate := now.SubMonths(12).Format("Y-m-d")
|
||||
var subBatch []string
|
||||
global.PostGreSQL.Model(&model.FileHandled{}).Where("step = ? AND product = ? AND lot = ? AND pbi = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
||||
r.Step, r.Product, r.Lot, r.PBI, startDate, now.Format("Y-m-d")).Group("sub_batch").Select("sub_batch").Find(&subBatch)
|
||||
r.Step, r.Product, r.Lot, r.PBI, startDate, now.AddDay().Format("Y-m-d")).Group("sub_batch").Select("sub_batch").Find(&subBatch)
|
||||
return subBatch
|
||||
}
|
||||
|
||||
@ -53,6 +53,6 @@ func WaferIDSelection(r *request.ChartSelection) []string {
|
||||
startDate := now.SubMonths(12).Format("Y-m-d")
|
||||
var waferIDs []string
|
||||
global.PostGreSQL.Model(&model.FileHandled{}).Where("step = ? AND product = ? AND lot = ? AND pbi = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
||||
r.Step, r.Product, r.Lot, r.PBI, startDate, now.Format("Y-m-d")).Group("wafer_id").Select("wafer_id").Find(&waferIDs)
|
||||
r.Step, r.Product, r.Lot, r.PBI, startDate, now.AddDay().Format("Y-m-d")).Group("wafer_id").Select("wafer_id").Find(&waferIDs)
|
||||
return waferIDs
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package test_data
|
||||
|
||||
import (
|
||||
"gitee.com/golang-module/carbon/v2"
|
||||
"testData/global"
|
||||
"testData/model"
|
||||
"testData/request"
|
||||
@ -8,14 +9,14 @@ import (
|
||||
|
||||
func GetProductSelection(r *request.ProbabilitySelection) []string {
|
||||
var products []string
|
||||
global.PostGreSQL.Model(&model.Report{}).Where("step = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
||||
r.Step, r.StartDate, r.EndDate).Group("product").Select("product").Find(&products)
|
||||
global.PostGreSQL.Debug().Model(&model.Report{}).Where("step = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
||||
r.Step, r.StartDate, carbon.Parse(r.EndDate).AddDay().Format("Y-m-d")).Group("product").Select("product").Find(&products)
|
||||
return products
|
||||
}
|
||||
|
||||
func GetLotSelection(r *request.ProbabilitySelection) []string {
|
||||
var lots []string
|
||||
global.PostGreSQL.Model(&model.Report{}).Where("step = ? AND created_at BETWEEN Date(?) AND Date(?)",
|
||||
r.Step, r.StartDate, r.EndDate).Group("lot").Select("lot").Find(&lots)
|
||||
r.Step, r.StartDate, carbon.Parse(r.EndDate).AddDay().Format("Y-m-d")).Group("lot").Select("lot").Find(&lots)
|
||||
return lots
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gitee.com/golang-module/carbon/v2"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/xuri/excelize/v2"
|
||||
@ -613,12 +614,19 @@ func SaveCP(report *model.Report) { //pbi, product, lot, waferID string,
|
||||
|
||||
func SaveFT(report *model.Report) { //pbi, product, lot, subBatch string,
|
||||
var ftFile *model.FileHandled
|
||||
//global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND sub_batch = ? AND step = ?",
|
||||
// report.PBI, report.Product, report.Lot, report.SubBatch, "FT").Find(&ftFile)
|
||||
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND sub_batch = ? AND step = ?",
|
||||
report.PBI, report.Product, report.Lot, report.SubBatch, "FT").Find(&ftFile)
|
||||
if _, err := os.Stat(ftFile.Path); err != nil {
|
||||
log.Println(fmt.Sprintf("pbi = %s AND product = %s AND lot = %s AND sub_batch = %s",
|
||||
report.PBI, report.Product, report.Lot, report.SubBatch))
|
||||
log.Println("该文件不存在")
|
||||
}
|
||||
|
||||
ft, err := os.Open(ftFile.Path)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Println(ftFile.Path, ":", err)
|
||||
return
|
||||
}
|
||||
defer ft.Close()
|
||||
@ -739,10 +747,14 @@ func SaveFT(report *model.Report) { //pbi, product, lot, subBatch string,
|
||||
}
|
||||
sumDecimal := decimal.NewFromInt(int64(sum))
|
||||
passDecimal := decimal.NewFromInt(int64(pass))
|
||||
var passProbability string
|
||||
if !sumDecimal.IsZero() {
|
||||
passProbability = passDecimal.Div(sumDecimal).Mul(decimal.NewFromInt(100)).Round(2).String() + "%"
|
||||
}
|
||||
global.PostGreSQL.Model(&siteReport).Updates(map[string]interface{}{
|
||||
"test_quantity": sumDecimal.String(),
|
||||
"pass_quantity": passDecimal.String(),
|
||||
"pass_probability": passDecimal.Div(sumDecimal).Mul(decimal.NewFromInt(100)).Round(2).String() + "%",
|
||||
"pass_probability": passProbability,
|
||||
})
|
||||
}
|
||||
global.PostGreSQL.Create(&binFail)
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"sort"
|
||||
"testData/model"
|
||||
"testData/repository"
|
||||
)
|
||||
|
||||
func HandleUploadFiles(fileTexts []*model.FileText, step, machine string) error {
|
||||
@ -16,15 +15,15 @@ func HandleUploadFiles(fileTexts []*model.FileText, step, machine string) error
|
||||
})
|
||||
if machine == "STS8200" {
|
||||
for _, fileText := range fileTexts {
|
||||
repository.HandleSTS8200Excel(fileText, step)
|
||||
HandleSTS8200Excel(fileText)
|
||||
}
|
||||
} else if machine == "TQT601" {
|
||||
for _, fileText := range fileTexts {
|
||||
repository.HandlerTQT601Excel(fileText, step)
|
||||
}
|
||||
//for _, fileText := range fileTexts {
|
||||
// HandlerTQT601Excel(fileText)
|
||||
//}
|
||||
} else if machine == "MT737" {
|
||||
for i := 0; i < len(fileTexts)/2; i++ {
|
||||
repository.MT737(fileTexts[2*i+1], fileTexts[2*i], step)
|
||||
MT737(fileTexts[2*i+1], fileTexts[2*i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
20
repository/test.file.handler.go
Normal file
20
repository/test.file.handler.go
Normal file
@ -0,0 +1,20 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testData/global"
|
||||
"testData/model"
|
||||
"testData/repository/test.data"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestFilesHandlerCron() {
|
||||
start := time.Now()
|
||||
var fileTexts []*model.FileText
|
||||
//global.PostGreSQL.Where("processed = ?", false).Group("pbi,lot,procedure").Select("pbi,lot,procedure").Find(&fileTexts)
|
||||
global.PostGreSQL.Where("processed = ? AND factory != ?", false, "江苏芯德").Order("procedure").Find(&fileTexts)
|
||||
for _, fileText := range fileTexts {
|
||||
test_data.HandleSTS8200Excel(fileText)
|
||||
}
|
||||
fmt.Println("执行时间:", time.Since(start))
|
||||
}
|
@ -24,6 +24,6 @@ func XinDe() {
|
||||
if fileText.ProductName == "" || fileText.Lot == "" {
|
||||
continue
|
||||
}
|
||||
HandleSTS8200Excel(fileText, "")
|
||||
//HandleSTS8200Excel(fileText, "")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user