V0 AB信息抓取调整

This commit is contained in:
jh_peng 2024-11-20 11:43:51 +08:00
parent ceb9a8f3ea
commit a57228be1c

View File

@ -223,7 +223,7 @@ func CronWaferList() {
func CronABList() {
var oldTcSfcFile []*model.TcSfcFile
var abListIDs []string
global.PostGreSQL.Model(&model.ABList{}).Where("status = ?", "未结案").
global.PostGreSQL.Model(&model.ABList{}).Where("status = ?", "未结案").Find(&abListIDs).
Select("pbi").Group("pbi").Find(&abListIDs)
_ = global.Oracle.Transaction(func(tx *gorm.DB) error {
page := len(abListIDs)/200 + 1
@ -304,9 +304,9 @@ func CronABList() {
Round(4).Mul(decimal.NewFromFloat(100)).String()
global.PostGreSQL.Transaction(func(tx *gorm.DB) error {
var abList *model.ABList
global.PostGreSQL.Where("pbi = ? AND outsourcing_pbi = ?",
tx.Where("pbi = ? AND outsourcing_pbi = ?",
tcSfc.TcSfc01, tcSfd.TcSfd13).Find(&abList)
global.PostGreSQL.Model(&abList).Where("pbi = ? AND outsourcing_pbi = ?",
tx.Model(&abList).Where("pbi = ? AND outsourcing_pbi = ?",
tcSfc.TcSfc01, tcSfd.TcSfd13).Updates(map[string]interface{}{
"status": status,
"quantity": quantity,
@ -318,24 +318,33 @@ func CronABList() {
"online_quantity": tcSfd.TcSfd05 - returnQuantity,
"pass_probability": passProbability + "%",
})
tx.Where("ab_list_id = ?", abList.ID).Delete(&model.ABListStock{})
for k, v := range orderDateStockMap {
var abListStock *model.ABListStock
if errors.Is(global.PostGreSQL.Where("ab_list_id = ? AND return_date = ?", abList.ID, k).
First(&abListStock).Error, gorm.ErrRecordNotFound) {
global.PostGreSQL.Create(&model.ABListStock{
ABListID: abList.ID,
ReturnDate: k,
PassQuantity: v[0],
FailQuantity: v[1],
})
} else {
global.PostGreSQL.Model(&abListStock).Where("ab_list_id = ? AND return_date = ?", abList.ID, k).
Updates(map[string]interface{}{
"pass_quantity": v[0],
"fail_quantity": v[1],
})
}
tx.Create(&model.ABListStock{
ABListID: abList.ID,
ReturnDate: k,
PassQuantity: v[0],
FailQuantity: v[1],
})
}
//for k, v := range orderDateStockMap {
// var abListStock *model.ABListStock
// if errors.Is(global.PostGreSQL.Where("ab_list_id = ? AND return_date = ?", abList.ID, k).
// First(&abListStock).Error, gorm.ErrRecordNotFound) {
// global.PostGreSQL.Create(&model.ABListStock{
// ABListID: abList.ID,
// ReturnDate: k,
// PassQuantity: v[0],
// FailQuantity: v[1],
// })
// } else {
// global.PostGreSQL.Model(&abListStock).Where("ab_list_id = ? AND return_date = ?", abList.ID, k).
// Updates(map[string]interface{}{
// "pass_quantity": v[0],
// "fail_quantity": v[1],
// })
// }
//}
return nil
})
}
@ -427,7 +436,7 @@ func CronABList() {
quantity, _ = decimal.NewFromFloat(quantity).Round(6).Float64()
var passProbability string
if strings.Contains(tcSfc.TcSfc01, "M596") {
if strings.Contains(tcSfc.TcSfc01, "M596") && passQuantity == 0 {
var reports []*model.Report
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ?", tcSfc.TcSfc01, tcSfd.ImaFile.Ima02,
tcSfd.TcSfd06).Find(&reports)