From c261e37772b068b80ee0369294883aac09b647f1 Mon Sep 17 00:00:00 2001 From: jh_peng Date: Thu, 31 Oct 2024 18:39:17 +0800 Subject: [PATCH] =?UTF-8?q?V0=20=E8=87=AA=E5=8A=A8=E6=8A=93=E5=8F=96?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/test.data/import.go | 12 +- api/test.data/upload.go | 3 +- initialization/postgre.go | 2 +- log/message.log | 11 ++ main.go | 1 + model/excel.go | 14 +- repository/changdian.go | 14 +- repository/chengte.go | 19 +- repository/saimeike.go | 40 ++-- repository/{ => test.data}/MT737.go | 37 ++-- repository/{ => test.data}/STS8200.go | 183 +++++++++++------- repository/{ => test.data}/TQT601.go | 4 +- repository/test.data/chart.selection.go | 10 +- .../test.data/report.chart.selection.go | 7 +- repository/test.data/report.go | 16 +- repository/test.data/upload.go | 11 +- repository/test.file.handler.go | 20 ++ repository/xinde.go | 2 +- 18 files changed, 251 insertions(+), 155 deletions(-) rename repository/{ => test.data}/MT737.go (92%) rename repository/{ => test.data}/STS8200.go (62%) rename repository/{ => test.data}/TQT601.go (99%) create mode 100644 repository/test.file.handler.go diff --git a/api/test.data/import.go b/api/test.data/import.go index 0eaf64a..d3b4e06 100644 --- a/api/test.data/import.go +++ b/api/test.data/import.go @@ -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{ - Name: file.Filename, - Path: filePath, - Size: utils.FormatFileSize(float64(file.Size)), + test_data.HandleSTS8200Excel(&model.FileText{ + Name: file.Filename, + Path: filePath, + //Size: utils.FormatFileSize(float64(file.Size)), Factory: factory, ProductName: productName, Lot: lot, - SubBatch: subBatch}, step) + SubBatch: subBatch, + Procedure: step}) response.Ok(c) } diff --git a/api/test.data/upload.go b/api/test.data/upload.go index dd9c7cc..f5a1baf 100644 --- a/api/test.data/upload.go +++ b/api/test.data/upload.go @@ -106,7 +106,8 @@ func (D *UploadService) UploadAnswerFile(c *gin.Context) { PBI: pbi, Lot: lot, SubBatch: subBatch, - WaferID: waferID, + ChipNum: waferID, + Procedure: step, }) } diff --git a/initialization/postgre.go b/initialization/postgre.go index a830601..1dbc212 100644 --- a/initialization/postgre.go +++ b/initialization/postgre.go @@ -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{}) } } diff --git a/log/message.log b/log/message.log index c852634..9796d36 100644 --- a/log/message.log +++ b/log/message.log @@ -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 diff --git a/main.go b/main.go index 24f810a..ce76f98 100644 --- a/main.go +++ b/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) diff --git a/model/excel.go b/model/excel.go index ad647d0..d55dded 100644 --- a/model/excel.go +++ b/model/excel.go @@ -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:"-"` diff --git a/repository/changdian.go b/repository/changdian.go index 4e6217a..8c908a0 100644 --- a/repository/changdian.go +++ b/repository/changdian.go @@ -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() } } diff --git a/repository/chengte.go b/repository/chengte.go index 85bd251..b289dbe 100644 --- a/repository/chengte.go +++ b/repository/chengte.go @@ -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) + //} } diff --git a/repository/saimeike.go b/repository/saimeike.go index 9cf04b4..f455e62 100644 --- a/repository/saimeike.go +++ b/repository/saimeike.go @@ -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) } } diff --git a/repository/MT737.go b/repository/test.data/MT737.go similarity index 92% rename from repository/MT737.go rename to repository/test.data/MT737.go index b771027..17c5464 100644 --- a/repository/MT737.go +++ b/repository/test.data/MT737.go @@ -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" { - length := len(summary.Name) - waferID = summary.Name[length-10 : length-8] - fileName = summary.ProductName + "_" + summary.Lot + "_" + waferID + "_" + details["Test_Code"] + ".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" + 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 + "_" + 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 + "_" + 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", diff --git a/repository/STS8200.go b/repository/test.data/STS8200.go similarity index 62% rename from repository/STS8200.go rename to repository/test.data/STS8200.go index b6998f2..0ca10f6 100644 --- a/repository/STS8200.go +++ b/repository/test.data/STS8200.go @@ -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" - } 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" + var fileName string + if fileText.Procedure == "CP" { + fileName = fileText.ProductName + "_" + fileText.Lot + "_" + fileText.ChipNum + "_" + fileText.Procedure + ".csv" + } else { + 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) + } } diff --git a/repository/TQT601.go b/repository/test.data/TQT601.go similarity index 99% rename from repository/TQT601.go rename to repository/test.data/TQT601.go index 84b406c..a046042 100644 --- a/repository/TQT601.go +++ b/repository/test.data/TQT601.go @@ -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, }) } } diff --git a/repository/test.data/chart.selection.go b/repository/test.data/chart.selection.go index 088b81b..35ca70d 100644 --- a/repository/test.data/chart.selection.go +++ b/repository/test.data/chart.selection.go @@ -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 } diff --git a/repository/test.data/report.chart.selection.go b/repository/test.data/report.chart.selection.go index 692a07d..6ac1fb0 100644 --- a/repository/test.data/report.chart.selection.go +++ b/repository/test.data/report.chart.selection.go @@ -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 } diff --git a/repository/test.data/report.go b/repository/test.data/report.go index 4fa4c4a..7b8d83b 100644 --- a/repository/test.data/report.go +++ b/repository/test.data/report.go @@ -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) diff --git a/repository/test.data/upload.go b/repository/test.data/upload.go index a6c6334..a8b1907 100644 --- a/repository/test.data/upload.go +++ b/repository/test.data/upload.go @@ -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 diff --git a/repository/test.file.handler.go b/repository/test.file.handler.go new file mode 100644 index 0000000..5832647 --- /dev/null +++ b/repository/test.file.handler.go @@ -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)) +} diff --git a/repository/xinde.go b/repository/xinde.go index dd67d3b..3a003c7 100644 --- a/repository/xinde.go +++ b/repository/xinde.go @@ -24,6 +24,6 @@ func XinDe() { if fileText.ProductName == "" || fileText.Lot == "" { continue } - HandleSTS8200Excel(fileText, "") + //HandleSTS8200Excel(fileText, "") } }