V0 CP记录片号识别 测试文件定时任务
This commit is contained in:
parent
af12b2447b
commit
983b4bd9c8
@ -44,3 +44,17 @@ func InitEmailCron() {
|
|||||||
}
|
}
|
||||||
c.Start()
|
c.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InitTestFilesHandlerCron() {
|
||||||
|
c := cron.New(cron.WithChain(cron.SkipIfStillRunning(cron.DefaultLogger)))
|
||||||
|
_, err := c.AddFunc("*/30 * * * *", func() {
|
||||||
|
fmt.Println(carbon.Now().Format("Y-m-d H:i:s") + "TestFilesHandlerCron start")
|
||||||
|
repository.TestFilesHandlerCron()
|
||||||
|
fmt.Println(carbon.Now().Format("Y-m-d H:i:s") + "TestFilesHandlerCron finish")
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
global.Log.Errorf("InitTestFilesHandlerCron AddFunc error: %s", err)
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
c.Start()
|
||||||
|
}
|
||||||
|
@ -1651,3 +1651,5 @@
|
|||||||
2024-10-31 15:47:19 INFO | 192.168.0.172 | 200 | 1.5652ms | POST | 未登录 | /testData/chart/pbiSelection
|
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 | 1.891ms | POST | 未登录 | /testData/chart/lotSelection
|
||||||
2024-10-31 15:47:22 INFO | 192.168.0.172 | 200 | 2.351ms | POST | 未登录 | /testData/selection
|
2024-10-31 15:47:22 INFO | 192.168.0.172 | 200 | 2.351ms | POST | 未登录 | /testData/selection
|
||||||
|
2024-11-01 11:14:20 INFO | 192.168.0.172 | 200 | 5.2831464s | POST | 未登录 | /testData/report/ft
|
||||||
|
2024-11-01 14:00:34 INFO | 192.168.0.172 | 200 | 55.4809ms | POST | 未登录 | /testData/report/cp
|
||||||
|
2
main.go
2
main.go
@ -29,7 +29,7 @@ func main() {
|
|||||||
|
|
||||||
initialization.InitCronListCron()
|
initialization.InitCronListCron()
|
||||||
initialization.InitEmailCron()
|
initialization.InitEmailCron()
|
||||||
//repository.TestFilesHandlerCron()
|
//initialization.InitTestFilesHandlerCron()
|
||||||
|
|
||||||
//var fileHandles []*model.FileHandled
|
//var fileHandles []*model.FileHandled
|
||||||
//global.PostGreSQL.Where("lot = ? AND step = ?", "S3S592", "FT").Find(&fileHandles)
|
//global.PostGreSQL.Where("lot = ? AND step = ?", "S3S592", "FT").Find(&fileHandles)
|
||||||
|
@ -355,7 +355,10 @@ func HandleSTS8200Excel(fileText *model.FileText) {
|
|||||||
"title_info": string(titleInfo),
|
"title_info": string(titleInfo),
|
||||||
"size": utils.FormatFileSize(float64(newFile.Size())),
|
"size": utils.FormatFileSize(float64(newFile.Size())),
|
||||||
})
|
})
|
||||||
report := &model.Report{
|
var report *model.Report
|
||||||
|
if errors.Is(global.PostGreSQL.Where("product = ? AND pbi = ? AND factory = ? AND lot = ? AND step = ? AND sub_batch = ? AND wafer_id = ?",
|
||||||
|
fileText.ProductName, fileText.PBI, fileText.Factory, fileText.Lot, fileText.Procedure, fileText.SubBatch, fileText.ChipNum).First(&report).Error, gorm.ErrRecordNotFound) {
|
||||||
|
report = &model.Report{
|
||||||
Product: fileText.ProductName,
|
Product: fileText.ProductName,
|
||||||
PBI: fileText.PBI,
|
PBI: fileText.PBI,
|
||||||
Factory: fileText.Factory,
|
Factory: fileText.Factory,
|
||||||
@ -366,11 +369,8 @@ func HandleSTS8200Excel(fileText *model.FileText) {
|
|||||||
TestProgram: testProgram,
|
TestProgram: testProgram,
|
||||||
WaferID: fileText.ChipNum,
|
WaferID: fileText.ChipNum,
|
||||||
}
|
}
|
||||||
global.PostGreSQL.Transaction(func(tx *gorm.DB) error {
|
global.PostGreSQL.Create(&report)
|
||||||
tx.Create(report)
|
}
|
||||||
tx.Find(&report)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if fileText.Procedure == "CP" {
|
if fileText.Procedure == "CP" {
|
||||||
SaveCP(report)
|
SaveCP(report)
|
||||||
} else {
|
} else {
|
||||||
|
@ -915,7 +915,6 @@ func CronFTList() {
|
|||||||
passQuantity += idd.Idd13
|
passQuantity += idd.Idd13
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var ftList *model.FTList
|
var ftList *model.FTList
|
||||||
|
@ -4,6 +4,8 @@ import (
|
|||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testData/global"
|
"testData/global"
|
||||||
"testData/model"
|
"testData/model"
|
||||||
"testData/request"
|
"testData/request"
|
||||||
@ -423,9 +425,28 @@ func CPList(r *request.CPList) ([]*model.CPShowList, int64) {
|
|||||||
SoftBinFailMap: make(map[string]float64),
|
SoftBinFailMap: make(map[string]float64),
|
||||||
HardBinFailMap: make(map[string]float64),
|
HardBinFailMap: make(map[string]float64),
|
||||||
}
|
}
|
||||||
|
var waferIDs []string
|
||||||
|
waferIDGroups := strings.Split(cpList.WaferID, ",")
|
||||||
|
for _, waferIDGroup := range waferIDGroups {
|
||||||
|
if strings.Contains(waferIDGroup, "-") {
|
||||||
|
waferIDGroup = strings.ReplaceAll(waferIDGroup, "#", "")
|
||||||
|
waferIDLimits := strings.Split(waferIDGroup, "-")
|
||||||
|
startWaferID, _ := strconv.Atoi(waferIDLimits[0])
|
||||||
|
endWaferID, _ := strconv.Atoi(waferIDLimits[1])
|
||||||
|
for i := startWaferID; i <= endWaferID; i++ {
|
||||||
|
if i < 10 {
|
||||||
|
waferIDs = append(waferIDs, "0"+strconv.Itoa(i))
|
||||||
|
} else {
|
||||||
|
waferIDs = append(waferIDs, strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
waferIDs = append(waferIDs, strings.ReplaceAll(waferIDGroup, "#", ""))
|
||||||
|
}
|
||||||
|
}
|
||||||
var reports []*model.Report
|
var reports []*model.Report
|
||||||
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND step LIKE ?", cpList.PBI, cpList.Product, cpList.Lot, "%CP%").
|
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND step LIKE ? AND wafer_id IN ?",
|
||||||
Order("pbi").
|
cpList.PBI, cpList.Product, cpList.Lot, "%CP%", waferIDs).Order("pbi").
|
||||||
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")
|
||||||
}).Preload("Site", func(db *gorm.DB) *gorm.DB {
|
}).Preload("Site", func(db *gorm.DB) *gorm.DB {
|
||||||
@ -696,9 +717,8 @@ func CPList(r *request.CPList) ([]*model.CPShowList, int64) {
|
|||||||
})
|
})
|
||||||
for hardBin, hardBinQuantity := range hardBinFailMap {
|
for hardBin, hardBinQuantity := range hardBinFailMap {
|
||||||
|
|
||||||
var finalReport *model.FinalReport
|
//var finalReport *model.FinalReport
|
||||||
global.PostGreSQL.Where("step = ? AND pbi = ? AND lot = ? AND sub_batch = ?", report.Step, report.PBI, report.Lot,
|
//global.PostGreSQL.Where("step = ? AND pbi = ? AND lot = ?", report.Step, report.PBI, report.Lot).Find(&finalReport)
|
||||||
report.SubBatch).Find(&finalReport)
|
|
||||||
hardBinQuantityDecimal := decimal.NewFromFloat(hardBinQuantity)
|
hardBinQuantityDecimal := decimal.NewFromFloat(hardBinQuantity)
|
||||||
var quantity float64
|
var quantity float64
|
||||||
var reportProportion string
|
var reportProportion string
|
||||||
@ -950,7 +970,7 @@ func FTList(r *request.FTList) ([]*model.FTShowList, int64) {
|
|||||||
}
|
}
|
||||||
var ftLists []*model.FTList
|
var ftLists []*model.FTList
|
||||||
var total int64
|
var total int64
|
||||||
global.PostGreSQL.Where(sql).Order("order_date desc").Find(&ftLists).Count(&total).
|
global.PostGreSQL.Debug().Where(sql).Order("order_date desc").Find(&ftLists).Count(&total).
|
||||||
Offset(r.Page * r.PageSize).Limit(r.PageSize).
|
Offset(r.Page * r.PageSize).Limit(r.PageSize).
|
||||||
Preload("FTListStock").Find(&ftLists)
|
Preload("FTListStock").Find(&ftLists)
|
||||||
var ftShowLists []*model.FTShowList
|
var ftShowLists []*model.FTShowList
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
package repository
|
package repository
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testData/global"
|
"testData/global"
|
||||||
"testData/model"
|
"testData/model"
|
||||||
"testData/repository/test.data"
|
"testData/repository/test.data"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFilesHandlerCron() {
|
func TestFilesHandlerCron() {
|
||||||
start := time.Now()
|
|
||||||
var fileTexts []*model.FileText
|
var fileTexts []*model.FileText
|
||||||
//global.PostGreSQL.Where("processed = ?", false).Group("pbi,lot,procedure").Select("pbi,lot,procedure").Find(&fileTexts)
|
//global.PostGreSQL.Where("processed = ? AND doubt = ? AND factory != ?", false, false, "江苏芯德").Order("procedure").Find(&fileTexts)
|
||||||
global.PostGreSQL.Where("processed = ? AND factory != ?", false, "江苏芯德").Order("procedure").Find(&fileTexts)
|
global.PostGreSQL.Where("processed = ? AND doubt = ?", false, false).Order("procedure").Find(&fileTexts)
|
||||||
for _, fileText := range fileTexts {
|
for _, fileText := range fileTexts {
|
||||||
test_data.HandleSTS8200Excel(fileText)
|
test_data.HandleSTS8200Excel(fileText)
|
||||||
|
global.PostGreSQL.Model(&fileTexts).Updates(map[string]interface{}{
|
||||||
|
"processed": true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
fmt.Println("执行时间:", time.Since(start))
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user