数据分析平台 FT记录晶圆型号赋值问题

FT记录子批次查看新增字段
This commit is contained in:
jh_peng 2024-12-23 16:30:08 +08:00
parent b60aa1f2f0
commit 2589363221
3 changed files with 142 additions and 23 deletions

View File

@ -36,6 +36,7 @@ func InitCronCheckListCron() {
_, err := c.AddFunc("0 0 */1 * *", func() {
fmt.Println(carbon.Now().Format("Y-m-d H:i:s") + "CronCheckListCron start")
test_data.CronCheckCPList()
//test_data.CronCheckFTList()
fmt.Println(carbon.Now().Format("Y-m-d H:i:s") + "CronCheckListCron finish")
})
if err != nil {

View File

@ -1162,6 +1162,101 @@ func CronFTList() {
}
}
func CronCheckFTList() {
var ftListIDs []string
var oldTcSfcFile []*model.TcSfcFile
global.PostGreSQL.Model(&model.FTList{}).Where("wafer_product = ?", "").
Select("pbi").Group("pbi").Find(&ftListIDs)
_ = global.Oracle.Transaction(func(tx *gorm.DB) error {
page := len(ftListIDs)/200 + 1
for i := 0; i < page; i++ {
var pageTcSfcFile []*model.TcSfcFile
var s []string
if i == page-1 {
s = ftListIDs[i*200:]
} else {
s = ftListIDs[i*200 : (i+1)*200]
}
tx.Where("tc_sfc01 IN ? AND tc_sfc08 LIKE ?", s, "%FT%").
Preload("TcSfdFile", func(db *gorm.DB) *gorm.DB {
return db.Preload("SfbFile").Preload("ImaFile").Preload("TcImbFile").Preload("RvbFile", func(db *gorm.DB) *gorm.DB {
return db.Preload("IddFile").Preload("RvaFile")
})
}).Preload("TcSfeFile", func(db *gorm.DB) *gorm.DB {
return db.Preload("ImaFile")
}).
Preload("PmcFile").Find(&pageTcSfcFile)
oldTcSfcFile = append(oldTcSfcFile, pageTcSfcFile...)
}
return nil
})
for _, tcSfc := range oldTcSfcFile {
for _, tcSfd := range tcSfc.TcSfdFile {
if tcSfd.TcSfd13 == "" {
continue
}
status := "未结案"
if tcSfd.SfbFile.Sfb04 == "8" {
status = "结案"
} else if tcSfd.SfbFile.Sfb04 == "0" {
continue
}
var returnQuantity, passQuantity, failQuantity float64
orderDateStockMap := make(map[string][]float64)
for _, rvb := range tcSfd.RvbFile {
if _, ok := orderDateStockMap[rvb.RvaFile.Rva06.Format("2006-01-02")]; !ok {
orderDateStockMap[rvb.RvaFile.Rva06.Format("2006-01-02")] = []float64{0, 0}
}
returnQuantity += rvb.Rvb30
for _, idd := range rvb.IddFile {
if idd.Idd11 == rvb.Rvb02 {
if idd.Idd06 == "BIN99" {
orderDateStockMap[rvb.RvaFile.Rva06.Format("2006-01-02")][1] += idd.Idd13
failQuantity += idd.Idd13
} else {
orderDateStockMap[rvb.RvaFile.Rva06.Format("2006-01-02")][0] += idd.Idd13
passQuantity += idd.Idd13
}
}
}
}
var ftList *model.FTList
global.PostGreSQL.Where("pbi = ? AND outsourcing_pbi = ?",
tcSfc.TcSfc01, tcSfd.TcSfd13).Find(&ftList)
global.PostGreSQL.Transaction(func(tx *gorm.DB) error {
global.PostGreSQL.Model(&ftList).Where("pbi = ? AND outsourcing_pbi = ?",
tcSfc.TcSfc01, tcSfd.TcSfd13).Updates(map[string]interface{}{
"status": status,
"online_quantity": tcSfd.TcSfd05 - returnQuantity,
"return_quantity": returnQuantity,
"pass_quantity": passQuantity,
"fail_quantity": failQuantity,
})
for k, v := range orderDateStockMap {
var ftListStock *model.FTListStock
if errors.Is(global.PostGreSQL.Where("ft_list_id = ? AND return_date = ?", ftList.ID, k).
First(&ftListStock).Error, gorm.ErrRecordNotFound) {
global.PostGreSQL.Create(&model.FTListStock{
FTListID: ftList.ID,
ReturnDate: k,
PassQuantity: v[0],
FailQuantity: v[1],
})
} else {
global.PostGreSQL.Model(&ftListStock).Where("ft_list_id = ? AND return_date = ?", ftList.ID, k).
Updates(map[string]interface{}{
"pass_quantity": v[0],
"fail_quantity": v[1],
})
}
}
return nil
})
}
}
}
func CronTRList() {
var oldTcSfcFile []*model.TcSfcFile
var trListIDs []string

View File

@ -1120,6 +1120,7 @@ func FTList(r *request.FTList) ([]*model.FTShowList, int64) {
PBI: ftShowList.PBI,
OutsourcingPBI: ftShowList.OutsourcingPBI,
Product: ftShowList.Product,
WaferProduct: ftShowList.WaferProduct,
Package: ftShowList.Package,
Factory: ftShowList.Factory,
Lot: ftShowList.Lot,
@ -1385,30 +1386,52 @@ func FTList(r *request.FTList) ([]*model.FTShowList, int64) {
sort.Slice(hardBinFail, func(i, j int) bool {
return hardBinFail[i].Quantity > hardBinFail[j].Quantity
})
var subBatchReportTestQuantity, subBatchReportPassQuantity, subBatchReportPassProbability string
for _, finalReport := range finalReports {
if finalReport.SubBatch == report.SubBatch {
subBatchReportTestQuantityDecimal, _ := decimal.NewFromString(subBatchReportTestQuantity)
subBatchReportPassQuantityDecimal, _ := decimal.NewFromString(subBatchReportPassQuantity)
subBatchFinalReportTestQuantityDecimal, _ := decimal.NewFromString(finalReport.ReportTestQuantity)
subBatchFinalReportPassQuantityDecimal, _ := decimal.NewFromString(finalReport.ReportPassQuantity)
subBatchReportTestQuantity = subBatchReportTestQuantityDecimal.Add(subBatchFinalReportTestQuantityDecimal).String()
subBatchReportPassQuantity = subBatchReportPassQuantityDecimal.Add(subBatchFinalReportPassQuantityDecimal).String()
}
}
subBatchFinalReportTestQuantityDecimal, _ := decimal.NewFromString(reportTestQuantity)
subBatchFinalReportPassQuantityDecimal, _ := decimal.NewFromString(reportPassQuantity)
if !finalReportTestQuantityDecimal.IsZero() {
subBatchReportPassProbability = subBatchFinalReportPassQuantityDecimal.Div(subBatchFinalReportTestQuantityDecimal).Round(4).
Mul(decimal.NewFromInt(100)).String() + "%"
}
ftShowList.SubBatchDetails = append(ftShowList.SubBatchDetails, model.ReportList{
OrderDate: ftShowList.OrderDate,
PBI: ftShowList.PBI,
Product: ftShowList.Product,
Lot: ftShowList.Lot,
SubBatch: report.SubBatch,
WaferID: report.WaferID,
Factory: ftShowList.Factory,
TestMachine: report.TestMachine,
TestProgram: ftShowList.TestProgram,
Seal: report.Seal,
TestQuantity: report.TestQuantity,
FirstPassQuantity: report.FirstPassQuantity,
FirstPassProbability: report.FirstPassProbability,
PassQuantity: report.PassQuantity,
PassProbability: report.PassProbability,
TestTime: report.TestTime,
Step: report.Step,
StackingMaterials: report.StackingMaterials,
SoftBinFailMap: softBinFailMap,
HardBinFailMap: hardBinFailMap,
SoftBinFail: softBinFail,
HardBinFail: hardBinFail,
Site: subBatchReportListSites,
OrderDate: ftShowList.OrderDate,
PBI: ftShowList.PBI,
Product: ftShowList.Product,
Lot: ftShowList.Lot,
SubBatch: report.SubBatch,
WaferID: report.WaferID,
Factory: ftShowList.Factory,
TestMachine: report.TestMachine,
TestProgram: ftShowList.TestProgram,
Seal: report.Seal,
TestQuantity: report.TestQuantity,
FirstPassQuantity: report.FirstPassQuantity,
FirstPassProbability: report.FirstPassProbability,
PassQuantity: report.PassQuantity,
PassProbability: report.PassProbability,
ReportTestQuantity: subBatchReportTestQuantity,
ReportPassQuantity: subBatchReportPassQuantity,
ReportPassProbability: subBatchReportPassProbability,
TestTime: report.TestTime,
Step: report.Step,
StackingMaterials: report.StackingMaterials,
SoftBinFailMap: softBinFailMap,
HardBinFailMap: hardBinFailMap,
SoftBinFail: softBinFail,
HardBinFail: hardBinFail,
Site: subBatchReportListSites,
})
}
sort.Slice(ftShowList.SubBatchDetails, func(i, j int) bool {