173 lines
7.7 KiB
Go
173 lines
7.7 KiB
Go
package test_data
|
|
|
|
import (
|
|
"github.com/spf13/viper"
|
|
"github.com/xuri/excelize/v2"
|
|
"gorm.io/gorm"
|
|
"path/filepath"
|
|
"strconv"
|
|
"strings"
|
|
"testData/global"
|
|
"testData/model"
|
|
"testData/utils"
|
|
"time"
|
|
)
|
|
|
|
func ExportWaferList() string {
|
|
f := excelize.NewFile()
|
|
sheetName := f.GetSheetName(0)
|
|
_ = f.SetSheetRow(sheetName, "A1", &[]interface{}{"状态", "下单日期", "订单号", "晶圆型号", "晶圆厂", "晶圆尺寸", "投片数量",
|
|
"在线数量", "回货数量", "回货日期", "回货批次"})
|
|
var waferLists []*model.WaferList
|
|
global.PostGreSQL.Preload("WaferStock", func(db *gorm.DB) *gorm.DB {
|
|
return db.Order("return_date")
|
|
}).Find(&waferLists)
|
|
for index, waferList := range waferLists {
|
|
var returnDate, returnLot string
|
|
if len(waferList.WaferStock) > 0 {
|
|
returnDate = waferList.WaferStock[0].ReturnDate
|
|
returnLot = waferList.WaferStock[0].Lot
|
|
}
|
|
_ = f.SetSheetRow(sheetName, "A"+strconv.Itoa(index+2), &[]interface{}{waferList.Status, waferList.OrderDate, waferList.PBI,
|
|
waferList.Product, waferList.Factory, waferList.WaferSize, waferList.Quantity,
|
|
waferList.OnlineQuantity, waferList.ReturnQuantity, returnDate, returnLot})
|
|
}
|
|
_ = f.SetColWidth(sheetName, "B", "K", 20)
|
|
filePath := time.Now().Format("Wafer记录2006-01-02_150405.xlsx")
|
|
filePath = filepath.Join(utils.MakeSavePath("记录"), filePath)
|
|
_ = f.SaveAs(filePath)
|
|
f.Close()
|
|
return strings.ReplaceAll(viper.GetString("domain"), "\\", "/") + filePath
|
|
}
|
|
|
|
func ExportABList() string {
|
|
f := excelize.NewFile()
|
|
sheetName := f.GetSheetName(0)
|
|
_ = f.SetSheetRow(sheetName, "A1", &[]interface{}{"状态", "下单日期", "订单号", "成品型号", "晶圆型号", "封装", "封装厂", "批号", "片号",
|
|
"订单数量", "在线数量", "良率", "出库数", "入库数", "回货日期", "封装良品", "封装不良品"})
|
|
var abLists []*model.ABList
|
|
global.PostGreSQL.Order("pbi").Preload("ABListStock", func(db *gorm.DB) *gorm.DB {
|
|
return db.Order("return_date")
|
|
}).Find(&abLists)
|
|
for index, abList := range abLists {
|
|
var returnDate string
|
|
if len(abList.ABListStock) > 0 {
|
|
returnDate = abList.ABListStock[0].ReturnDate
|
|
}
|
|
_ = f.SetSheetRow(sheetName, "A"+strconv.Itoa(index+2), &[]interface{}{abList.Status, abList.OrderDate, abList.PBI,
|
|
abList.Product, abList.WaferProduct, abList.Package, abList.Factory, abList.Lot, abList.WaferID, abList.Quantity,
|
|
abList.OnlineQuantity, abList.PassProbability, abList.StockOutQuantity, abList.StockInQuantity,
|
|
returnDate, abList.PassQuantity, abList.FailQuantity})
|
|
}
|
|
_ = f.SetColWidth(sheetName, "B", "Q", 20)
|
|
filePath := time.Now().Format("AB记录2006-01-02_150405.xlsx")
|
|
filePath = filepath.Join(utils.MakeSavePath("记录"), filePath)
|
|
_ = f.SaveAs(filePath)
|
|
f.Close()
|
|
return strings.ReplaceAll(viper.GetString("domain"), "\\", "/") + filePath
|
|
}
|
|
|
|
func ExportBPList() string {
|
|
f := excelize.NewFile()
|
|
sheetName := f.GetSheetName(0)
|
|
_ = f.SetSheetRow(sheetName, "A1", &[]interface{}{"状态", "下单日期", "订单号", "晶圆型号", "封装", "CP测试厂", "批号", "片号",
|
|
"订单数量", "在线数量", "回货日期", "到货数量", "DIE数量"})
|
|
var bpLists []*model.BPList
|
|
global.PostGreSQL.Order("pbi").Preload("BPListStock", func(db *gorm.DB) *gorm.DB {
|
|
return db.Order("return_date")
|
|
}).Find(&bpLists)
|
|
for index, bpList := range bpLists {
|
|
var returnDate string
|
|
if len(bpList.BPListStock) > 0 {
|
|
returnDate = bpList.BPListStock[0].ReturnDate
|
|
}
|
|
_ = f.SetSheetRow(sheetName, "A"+strconv.Itoa(index+2), &[]interface{}{bpList.Status, bpList.OrderDate, bpList.PBI,
|
|
bpList.Product, bpList.Package, bpList.Factory, bpList.Lot, bpList.WaferID, bpList.Quantity,
|
|
bpList.OnlineQuantity, returnDate, bpList.ReturnQuantity, bpList.DieQuantity})
|
|
}
|
|
_ = f.SetColWidth(sheetName, "B", "M", 20)
|
|
filePath := time.Now().Format("BP记录2006-01-02_150405.xlsx")
|
|
filePath = filepath.Join(utils.MakeSavePath("记录"), filePath)
|
|
_ = f.SaveAs(filePath)
|
|
f.Close()
|
|
return strings.ReplaceAll(viper.GetString("domain"), "\\", "/") + filePath
|
|
}
|
|
|
|
func ExportCPList() string {
|
|
f := excelize.NewFile()
|
|
sheetName := f.GetSheetName(0)
|
|
_ = f.SetSheetRow(sheetName, "A1", &[]interface{}{"状态", "下单日期", "订单号", "晶圆型号", "封装", "CP测试厂", "批号", "片号",
|
|
"订单数量", "在线数量", "测试程序", "回货日期", "到货数量", "DIE数量"})
|
|
var cpLists []*model.CPList
|
|
global.PostGreSQL.Order("pbi").Preload("CPListStock", func(db *gorm.DB) *gorm.DB {
|
|
return db.Order("return_date")
|
|
}).Find(&cpLists)
|
|
for index, cpList := range cpLists {
|
|
var returnDate string
|
|
if len(cpList.CPListStock) > 0 {
|
|
returnDate = cpList.CPListStock[0].ReturnDate
|
|
}
|
|
_ = f.SetSheetRow(sheetName, "A"+strconv.Itoa(index+2), &[]interface{}{cpList.Status, cpList.OrderDate, cpList.PBI,
|
|
cpList.Product, cpList.Package, cpList.Factory, cpList.Lot, cpList.WaferID, cpList.Quantity,
|
|
cpList.OnlineQuantity, cpList.TestProgram, returnDate, cpList.ReturnQuantity, cpList.DieQuantity})
|
|
}
|
|
_ = f.SetColWidth(sheetName, "B", "M", 20)
|
|
filePath := time.Now().Format("CP记录2006-01-02_150405.xlsx")
|
|
filePath = filepath.Join(utils.MakeSavePath("记录"), filePath)
|
|
_ = f.SaveAs(filePath)
|
|
f.Close()
|
|
return strings.ReplaceAll(viper.GetString("domain"), "\\", "/") + filePath
|
|
}
|
|
|
|
func ExportFTList() string {
|
|
f := excelize.NewFile()
|
|
sheetName := f.GetSheetName(0)
|
|
_ = f.SetSheetRow(sheetName, "A1", &[]interface{}{"状态", "下单日期", "订单号", "成品型号", "晶圆型号", "封装", "FT测试厂", "批号", "丝印",
|
|
"订单数量", "在线数量", "FT测试程序", "回货日期", "回货数量", "FT良品", "FT不良品"})
|
|
var ftLists []*model.FTList
|
|
global.PostGreSQL.Order("pbi").Preload("CPListStock", func(db *gorm.DB) *gorm.DB {
|
|
return db.Order("return_date")
|
|
}).Find(&ftLists)
|
|
for index, ftList := range ftLists {
|
|
var returnDate string
|
|
if len(ftList.FTListStock) > 0 {
|
|
returnDate = ftList.FTListStock[0].ReturnDate
|
|
}
|
|
_ = f.SetSheetRow(sheetName, "A"+strconv.Itoa(index+2), &[]interface{}{ftList.Status, ftList.OrderDate, ftList.PBI,
|
|
ftList.Product, ftList.WaferProduct, ftList.Package, ftList.Factory, ftList.Lot, ftList.Seal, ftList.Quantity,
|
|
ftList.OnlineQuantity, ftList.TestProgram, returnDate, ftList.ReturnQuantity, ftList.PassQuantity, ftList.FailQuantity})
|
|
}
|
|
_ = f.SetColWidth(sheetName, "B", "P", 20)
|
|
filePath := time.Now().Format("CP记录2006-01-02_150405.xlsx")
|
|
filePath = filepath.Join(utils.MakeSavePath("记录"), filePath)
|
|
_ = f.SaveAs(filePath)
|
|
f.Close()
|
|
return strings.ReplaceAll(viper.GetString("domain"), "\\", "/") + filePath
|
|
}
|
|
|
|
func ExportTRList() string {
|
|
f := excelize.NewFile()
|
|
sheetName := f.GetSheetName(0)
|
|
_ = f.SetSheetRow(sheetName, "A1", &[]interface{}{"状态", "下单日期", "订单号", "成品型号", "晶圆型号", "封装", "封装厂", "批号",
|
|
"订单数量", "在线数量", "回货日期", "封装良品", "封装不良品"})
|
|
var trLists []*model.TRList
|
|
global.PostGreSQL.Order("pbi").Preload("TRListStock", func(db *gorm.DB) *gorm.DB {
|
|
return db.Order("return_date")
|
|
}).Find(&trLists)
|
|
for index, abList := range trLists {
|
|
var returnDate string
|
|
if len(abList.TRListStock) > 0 {
|
|
returnDate = abList.TRListStock[0].ReturnDate
|
|
}
|
|
_ = f.SetSheetRow(sheetName, "A"+strconv.Itoa(index+2), &[]interface{}{abList.Status, abList.OrderDate, abList.PBI,
|
|
abList.Product, abList.WaferProduct, abList.Package, abList.Factory, abList.Lot, abList.Quantity,
|
|
abList.OnlineQuantity, returnDate, abList.PassQuantity, abList.FailQuantity})
|
|
}
|
|
_ = f.SetColWidth(sheetName, "B", "M", 20)
|
|
filePath := time.Now().Format("TR记录2006-01-02_150405.xlsx")
|
|
filePath = filepath.Join(utils.MakeSavePath("记录"), filePath)
|
|
_ = f.SaveAs(filePath)
|
|
f.Close()
|
|
return strings.ReplaceAll(viper.GetString("domain"), "\\", "/") + filePath
|
|
}
|