65 lines
2.3 KiB
Go
65 lines
2.3 KiB
Go
package test_data
|
|
|
|
import (
|
|
"errors"
|
|
"gitee.com/golang-module/carbon/v2"
|
|
"sort"
|
|
"testData/global"
|
|
"testData/model"
|
|
"testData/request"
|
|
)
|
|
|
|
func HandleUploadFiles(fileTexts []*model.FileText, step, machine string) error {
|
|
if step == "" {
|
|
return errors.New("未输入工序")
|
|
}
|
|
sort.Slice(fileTexts, func(i, j int) bool {
|
|
return fileTexts[i].Name < fileTexts[j].Name
|
|
})
|
|
if machine == "STS8200" {
|
|
for _, fileText := range fileTexts {
|
|
if err := HandleSTS8200Excel(fileText); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
} else if machine == "TQT601" {
|
|
//for _, fileText := range fileTexts {
|
|
// HandlerTQT601Excel(fileText)
|
|
//}
|
|
} else if machine == "MT737" {
|
|
for i := 0; i < len(fileTexts)/2; i++ {
|
|
MT737(fileTexts[2*i+1], fileTexts[2*i])
|
|
}
|
|
} else if machine == "德律6850" {
|
|
for i := 0; i < len(fileTexts); i++ {
|
|
if err := HandleDL6850Excel(fileTexts[i]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func DeleteUploadFiles(r *request.UploadFile) error {
|
|
if r.SubBatch == "" && r.WaferID == "" {
|
|
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND factory = ? AND machine = ? AND step = ?",
|
|
r.PBI, r.Product, r.Lot, r.Factory, r.Machine, r.Step).Delete(&model.FileHandled{})
|
|
} else if r.SubBatch != "" && r.WaferID == "" {
|
|
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND factory = ? AND step = ? AND sub_batch = ? AND machine = ?",
|
|
r.PBI, r.Product, r.Lot, r.Factory, r.Step, r.SubBatch, r.Machine).Delete(&model.FileHandled{})
|
|
} else if r.SubBatch == "" && r.WaferID != "" {
|
|
global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND factory = ? AND step = ? AND wafer_id = ? AND machine = ?",
|
|
r.PBI, r.Product, r.Lot, r.Factory, r.Step, r.WaferID, r.Machine).Delete(&model.FileHandled{})
|
|
} else {
|
|
//global.PostGreSQL.Where("pbi = ? AND product = ? AND lot = ? AND factory = ? AND step = ? AND sub_batch = ? AND wafer_id = ? AND machine = ?",
|
|
// r.PBI, r.Product, r.Lot, r.Factory, r.Step, r.SubBatch, r.WaferID, r.Machine).Delete(&model.FileHandled{})
|
|
return errors.New("不支持子批次与片号同时填写删除")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func AutoDeleteUploadFiles() error {
|
|
global.PostGreSQL.Where("pbi NOT LIKE ? AND created_at < ?", "%M%", carbon.Now().SubWeek().Format("Y-m-d")).Delete(&model.FileHandled{})
|
|
return nil
|
|
}
|