V0
This commit is contained in:
parent
d95a730b7b
commit
4839476d26
@ -612,43 +612,46 @@ func SaveCP(report *model.Report) { //pbi, product, lot, waferID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SaveFT(report *model.Report) { //pbi, product, lot, subBatch string,
|
func SaveFT(report *model.Report) { //pbi, product, lot, subBatch string,
|
||||||
var ftFile *model.FileHandled
|
var ftFiles []*model.FileHandled
|
||||||
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND sub_batch = ? AND step = ?",
|
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND sub_batch = ? AND step = ?",
|
||||||
report.PBI, report.Product, report.Lot, report.SubBatch, "FT").Find(&ftFile)
|
report.PBI, report.Product, report.Lot, report.SubBatch, "FT").Find(&ftFiles)
|
||||||
if _, err := os.Stat(ftFile.Path); err != nil {
|
|
||||||
log.Println("该文件不存在")
|
|
||||||
}
|
|
||||||
|
|
||||||
ft, err := os.Open(ftFile.Path)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(ftFile.Path, ":", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer ft.Close()
|
|
||||||
scanner := bufio.NewScanner(ft)
|
|
||||||
datas := make([][]string, 0)
|
datas := make([][]string, 0)
|
||||||
fieldMap := make(map[string]int)
|
fieldMap := make(map[string]int)
|
||||||
for scanner.Scan() {
|
sbinHbinMap := make(map[string]string)
|
||||||
line := scanner.Text()
|
for _, ftFile := range ftFiles {
|
||||||
s := strings.Split(line, ",")
|
fileDatas := make([][]string, 0)
|
||||||
datas = append(datas, s[:len(s)-1])
|
if _, err := os.Stat(ftFile.Path); err != nil {
|
||||||
if len(datas) == 1 {
|
log.Println("该文件不存在")
|
||||||
for index, cell := range s {
|
}
|
||||||
if index == len(s)-1 {
|
|
||||||
continue
|
ft, err := os.Open(ftFile.Path)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(ftFile.Path, ":", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
scanner := bufio.NewScanner(ft)
|
||||||
|
for scanner.Scan() {
|
||||||
|
line := scanner.Text()
|
||||||
|
s := strings.Split(line, ",")
|
||||||
|
fileDatas = append(fileDatas, s[:len(s)-1])
|
||||||
|
if len(fileDatas) == 1 {
|
||||||
|
for index, cell := range s {
|
||||||
|
if index == len(s)-1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fieldMap[cell] = index
|
||||||
}
|
}
|
||||||
fieldMap[cell] = index
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if len(datas) >= 1 {
|
||||||
if len(datas) >= 1 {
|
datas = append(datas, fileDatas[1:]...)
|
||||||
datas = datas[1:]
|
}
|
||||||
|
ft.Close()
|
||||||
|
//sbinHbinMap := make(map[string]map[string]string)
|
||||||
|
sbinHbinByte := []byte(ftFile.SbinHbin)
|
||||||
|
_ = json.Unmarshal(sbinHbinByte, &sbinHbinMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sbinHbinMap := make(map[string]map[string]string)
|
|
||||||
sbinHbinMap := make(map[string]string)
|
|
||||||
sbinHbinByte := []byte(ftFile.SbinHbin)
|
|
||||||
_ = json.Unmarshal(sbinHbinByte, &sbinHbinMap)
|
|
||||||
binCounter := make(map[string]int)
|
binCounter := make(map[string]int)
|
||||||
siteCounters := make(map[string]map[string]int)
|
siteCounters := make(map[string]map[string]int)
|
||||||
for _, data := range datas {
|
for _, data := range datas {
|
||||||
@ -659,35 +662,41 @@ func SaveFT(report *model.Report) { //pbi, product, lot, subBatch string,
|
|||||||
siteCounters[data[fieldMap["SITE_NUM"]]][data[fieldMap["SOFT_BIN"]]]++
|
siteCounters[data[fieldMap["SITE_NUM"]]][data[fieldMap["SOFT_BIN"]]]++
|
||||||
}
|
}
|
||||||
|
|
||||||
var rtFile *model.FileHandled
|
var rtFiles []*model.FileHandled
|
||||||
var passCounter int
|
var passCounter int
|
||||||
if !errors.Is(global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND sub_batch = ? AND step = ?",
|
if !errors.Is(global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND sub_batch = ? AND step = ?",
|
||||||
report.PBI, report.Product, report.Lot, report.SubBatch, "RT").
|
report.PBI, report.Product, report.Lot, report.SubBatch, "RT").
|
||||||
Find(&rtFile).Error, gorm.ErrRecordNotFound) {
|
Find(&rtFiles).Error, gorm.ErrRecordNotFound) {
|
||||||
rt, err := os.Open(rtFile.Path)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
defer rt.Close()
|
|
||||||
rtScanner := bufio.NewScanner(rt)
|
|
||||||
rtDatas := make([][]string, 0)
|
rtDatas := make([][]string, 0)
|
||||||
rtFieldMap := make(map[string]int)
|
rtFieldMap := make(map[string]int)
|
||||||
for rtScanner.Scan() {
|
|
||||||
line := rtScanner.Text()
|
for _, rtFile := range rtFiles {
|
||||||
s := strings.Split(line, ",")
|
fileDatas := make([][]string, 0)
|
||||||
rtDatas = append(rtDatas, s[:len(s)-1])
|
rt, err := os.Open(rtFile.Path)
|
||||||
if len(rtDatas) == 1 {
|
if err != nil {
|
||||||
for index, cell := range s {
|
log.Println(err)
|
||||||
if index == len(s)-1 {
|
}
|
||||||
continue
|
rtScanner := bufio.NewScanner(rt)
|
||||||
|
for rtScanner.Scan() {
|
||||||
|
line := rtScanner.Text()
|
||||||
|
s := strings.Split(line, ",")
|
||||||
|
fileDatas = append(fileDatas, s[:len(s)-1])
|
||||||
|
if len(fileDatas) == 1 {
|
||||||
|
for index, cell := range s {
|
||||||
|
if index == len(s)-1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
rtFieldMap[cell] = index
|
||||||
}
|
}
|
||||||
rtFieldMap[cell] = index
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rt.Close()
|
||||||
|
if len(rtDatas) >= 1 {
|
||||||
|
rtDatas = append(rtDatas, fileDatas[1:]...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(rtDatas) >= 1 {
|
|
||||||
rtDatas = rtDatas[1:]
|
|
||||||
}
|
|
||||||
for _, rtData := range rtDatas {
|
for _, rtData := range rtDatas {
|
||||||
if rtData[rtFieldMap["SOFT_BIN"]] == "1" {
|
if rtData[rtFieldMap["SOFT_BIN"]] == "1" {
|
||||||
passCounter++
|
passCounter++
|
||||||
@ -715,13 +724,18 @@ func SaveFT(report *model.Report) { //pbi, product, lot, subBatch string,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
var siteReports []*model.ReportSites
|
var siteReports []*model.ReportSites
|
||||||
for site := range siteCounters {
|
global.PostGreSQL.Transaction(func(tx *gorm.DB) error {
|
||||||
siteReports = append(siteReports, &model.ReportSites{
|
for site := range siteCounters {
|
||||||
ReportID: report.ID,
|
siteReports = append(siteReports, &model.ReportSites{
|
||||||
Site: site,
|
ReportID: report.ID,
|
||||||
})
|
Site: site,
|
||||||
}
|
})
|
||||||
global.PostGreSQL.Create(&siteReports)
|
|
||||||
|
tx.Where("report_id = ?", report.ID).Delete(&model.ReportSites{})
|
||||||
|
tx.Create(&siteReports)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
siteReports = []*model.ReportSites{}
|
siteReports = []*model.ReportSites{}
|
||||||
global.PostGreSQL.Where("report_id = ?", report.ID).Find(&siteReports)
|
global.PostGreSQL.Where("report_id = ?", report.ID).Find(&siteReports)
|
||||||
for _, siteReport := range siteReports {
|
for _, siteReport := range siteReports {
|
||||||
|
Loading…
Reference in New Issue
Block a user