V0 导入测试文件、测试厂选项
This commit is contained in:
parent
604699048e
commit
055fabba11
28
api/erp/test.data.go
Normal file
28
api/erp/test.data.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package erp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"testData/model/response"
|
||||||
|
"testData/repository/erp"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ITestDataService interface {
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestDataService struct{}
|
||||||
|
|
||||||
|
func InitTestDataService() *TestDataService {
|
||||||
|
return &TestDataService{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags 数据分析平台
|
||||||
|
// @Summary 测试文件导入-测试厂选项
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @accept application/json
|
||||||
|
// @Produce application/json
|
||||||
|
// -// @Param data body request.QuerySelection true "查询参数"
|
||||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"操作成功"}"
|
||||||
|
// @Router /testData/import/testFile/factorySelection [get]
|
||||||
|
func (S *TestDataService) FactorySelection(c *gin.Context) {
|
||||||
|
response.OkWithData(erp.GetFactorySelections(), c)
|
||||||
|
}
|
@ -2,6 +2,7 @@ package test_data
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"mime/multipart"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -36,7 +37,11 @@ func (D *UploadService) UploadAnswerFile(c *gin.Context) {
|
|||||||
response.FailWithMessage(err.Error(), c)
|
response.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
files := form.File["file"]
|
filesMap := form.File
|
||||||
|
var files []*multipart.FileHeader
|
||||||
|
for _, v := range filesMap {
|
||||||
|
files = append(files, v...)
|
||||||
|
}
|
||||||
if len(form.Value["pbi"]) < 1 {
|
if len(form.Value["pbi"]) < 1 {
|
||||||
response.FailWithMessage("缺少PBI名称", c)
|
response.FailWithMessage("缺少PBI名称", c)
|
||||||
return
|
return
|
||||||
@ -57,11 +62,22 @@ func (D *UploadService) UploadAnswerFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
factory := form.Value["factory"][0]
|
factory := form.Value["factory"][0]
|
||||||
|
var subBatch string
|
||||||
if len(form.Value["sub_batch"]) < 1 {
|
if len(form.Value["sub_batch"]) < 1 {
|
||||||
response.FailWithMessage("缺少子批次", c)
|
subBatch = ""
|
||||||
|
} else {
|
||||||
|
subBatch = form.Value["sub_batch"][0]
|
||||||
|
}
|
||||||
|
if len(form.Value["step"]) < 1 {
|
||||||
|
response.FailWithMessage("缺少工序", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
subBatch := form.Value["sub_batch"][0]
|
var waferID string
|
||||||
|
if len(form.Value["wafer_id"]) < 1 {
|
||||||
|
waferID = ""
|
||||||
|
} else {
|
||||||
|
waferID = form.Value["wafer_id"][0]
|
||||||
|
}
|
||||||
if len(form.Value["step"]) < 1 {
|
if len(form.Value["step"]) < 1 {
|
||||||
response.FailWithMessage("缺少工序", c)
|
response.FailWithMessage("缺少工序", c)
|
||||||
return
|
return
|
||||||
@ -79,7 +95,7 @@ func (D *UploadService) UploadAnswerFile(c *gin.Context) {
|
|||||||
fileTexts := make([]*model.FileText, 0)
|
fileTexts := make([]*model.FileText, 0)
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
suffix := file.Filename[strings.LastIndex(file.Filename, "."):]
|
suffix := file.Filename[strings.LastIndex(file.Filename, "."):]
|
||||||
fileName := time.Now().Format("20060102150405") + suffix
|
fileName := file.Filename[:strings.LastIndex(file.Filename, ".")] + time.Now().Format("20060102150405") + suffix
|
||||||
os.MkdirAll("/testData/siyuanUpload", os.ModePerm)
|
os.MkdirAll("/testData/siyuanUpload", os.ModePerm)
|
||||||
filePath := filepath.Join("/testData/siyuanUpload", fileName)
|
filePath := filepath.Join("/testData/siyuanUpload", fileName)
|
||||||
if err = c.SaveUploadedFile(file, filePath); err != nil {
|
if err = c.SaveUploadedFile(file, filePath); err != nil {
|
||||||
@ -94,6 +110,7 @@ func (D *UploadService) UploadAnswerFile(c *gin.Context) {
|
|||||||
PBI: pbi,
|
PBI: pbi,
|
||||||
Lot: lot,
|
Lot: lot,
|
||||||
SubBatch: subBatch,
|
SubBatch: subBatch,
|
||||||
|
WaferID: waferID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ func InitRouter() *gin.Engine {
|
|||||||
router.InitWarningRouter(testData)
|
router.InitWarningRouter(testData)
|
||||||
router.InitFinalReportExcelRouter(testData)
|
router.InitFinalReportExcelRouter(testData)
|
||||||
router.InitImportRouter(testData)
|
router.InitImportRouter(testData)
|
||||||
|
|
||||||
|
router.InitTestDataERPRouter(testData)
|
||||||
}
|
}
|
||||||
testDataUpload := r.Group("testData")
|
testDataUpload := r.Group("testData")
|
||||||
testDataUploadService := testdata.InitUpload()
|
testDataUploadService := testdata.InitUpload()
|
||||||
|
@ -1593,3 +1593,18 @@
|
|||||||
2024-10-11 14:50:17 INFO | 192.168.0.172 | 200 | 3.3515ms | POST | 未登录 | /testData/upload
|
2024-10-11 14:50:17 INFO | 192.168.0.172 | 200 | 3.3515ms | POST | 未登录 | /testData/upload
|
||||||
2024-10-11 14:50:17 INFO | 192.168.0.172 | 200 | 16.5018ms | POST | 未登录 | /testData/upload
|
2024-10-11 14:50:17 INFO | 192.168.0.172 | 200 | 16.5018ms | POST | 未登录 | /testData/upload
|
||||||
2024-10-11 15:00:15 INFO | 192.168.0.172 | 200 | 9m25.648566s | POST | 未登录 | /testData/upload
|
2024-10-11 15:00:15 INFO | 192.168.0.172 | 200 | 9m25.648566s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:41 INFO | 192.168.0.172 | 200 | 1.2534ms | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:41 INFO | 192.168.0.172 | 200 | 0s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:41 INFO | 192.168.0.172 | 200 | 540.4µs | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:41 INFO | 192.168.0.172 | 200 | 3.1513ms | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:58 INFO | 192.168.0.172 | 200 | 24.0818ms | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:58 INFO | 192.168.0.172 | 200 | 33.3799ms | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:58 INFO | 192.168.0.172 | 200 | 39.0893ms | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:05:58 INFO | 192.168.0.172 | 200 | 37.9752ms | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:17:20 INFO | 192.168.0.172 | 200 | 1m53.7931364s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:18:05 INFO | 192.168.0.172 | 200 | 31.1169547s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:22:49 INFO | 192.168.0.172 | 200 | 4m11.2095059s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:23:19 INFO | 192.168.0.172 | 200 | 19.8354639s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:24:07 INFO | 192.168.0.172 | 200 | 34.1357627s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 10:25:24 INFO | 192.168.0.172 | 200 | 9.8706437s | POST | 未登录 | /testData/upload
|
||||||
|
2024-10-12 11:07:57 INFO | 192.168.0.172 | 200 | 3.6585071s | POST | 未登录 | /testData/upload
|
||||||
|
@ -109,6 +109,7 @@ func (RvvFile) TableName() string { return "rvv_file" }
|
|||||||
|
|
||||||
type PmcFile struct {
|
type PmcFile struct {
|
||||||
Pmc01 string `json:"pmc01"` // 厂商编号
|
Pmc01 string `json:"pmc01"` // 厂商编号
|
||||||
|
Pmc02 string `json:"pmc02"` // 厂商类型
|
||||||
Pmc03 string `json:"pmc03"` // 厂商名称
|
Pmc03 string `json:"pmc03"` // 厂商名称
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ type FileText struct {
|
|||||||
ProductName string `json:"product_name"`
|
ProductName string `json:"product_name"`
|
||||||
PBI string `json:"pbi"`
|
PBI string `json:"pbi"`
|
||||||
Lot string `json:"lot" gorm:"comment:批次号"`
|
Lot string `json:"lot" gorm:"comment:批次号"`
|
||||||
SubBatch string `json:"sub_batch" gorm:"子批次"`
|
SubBatch string `json:"sub_batch" gorm:"comment:子批次"`
|
||||||
|
WaferID string `json:"wafer_id" gorm:"comment:片号"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"-"`
|
UpdatedAt time.Time `json:"-"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||||
|
@ -184,6 +184,9 @@ func MT737(summary, dataLog *model.FileText, step string) {
|
|||||||
log.Println("创建文件失败:", err)
|
log.Println("创建文件失败:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if summary.WaferID != "" {
|
||||||
|
waferID = summary.WaferID
|
||||||
|
}
|
||||||
if errors.Is(global.PostGreSQL.Where("name = ?", fileName).First(&fileHandled).Error, gorm.ErrRecordNotFound) {
|
if errors.Is(global.PostGreSQL.Where("name = ?", fileName).First(&fileHandled).Error, gorm.ErrRecordNotFound) {
|
||||||
global.PostGreSQL.Create(&model.FileHandled{
|
global.PostGreSQL.Create(&model.FileHandled{
|
||||||
Name: fileName,
|
Name: fileName,
|
||||||
|
@ -269,6 +269,9 @@ func HandleSTS8200Excel(fileText *model.FileText, step string) {
|
|||||||
log.Println("创建文件失败:", err)
|
log.Println("创建文件失败:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if fileText.WaferID != "" {
|
||||||
|
waferID = fileText.WaferID
|
||||||
|
}
|
||||||
if errors.Is(global.PostGreSQL.Where("name = ?", fileName).First(&fileHandled).Error, gorm.ErrRecordNotFound) {
|
if errors.Is(global.PostGreSQL.Where("name = ?", fileName).First(&fileHandled).Error, gorm.ErrRecordNotFound) {
|
||||||
global.PostGreSQL.Create(&model.FileHandled{
|
global.PostGreSQL.Create(&model.FileHandled{
|
||||||
Name: fileName,
|
Name: fileName,
|
||||||
|
@ -205,6 +205,9 @@ func HandlerTQT601Excel(fileText *model.FileText, step string) {
|
|||||||
}
|
}
|
||||||
details["lot"] = fileText.Name[start+1 : end]
|
details["lot"] = fileText.Name[start+1 : end]
|
||||||
}
|
}
|
||||||
|
if fileText.Lot != "" {
|
||||||
|
details["lot"] = fileText.Lot
|
||||||
|
}
|
||||||
testProgram := details["TestProgram"]
|
testProgram := details["TestProgram"]
|
||||||
fileName := details["product"] + "_" + details["lot"] + "_" + details["Test_Code"] + ".csv"
|
fileName := details["product"] + "_" + details["lot"] + "_" + details["Test_Code"] + ".csv"
|
||||||
utils.MakeDir("/testData/test")
|
utils.MakeDir("/testData/test")
|
||||||
@ -225,8 +228,11 @@ func HandlerTQT601Excel(fileText *model.FileText, step string) {
|
|||||||
Path: filePath,
|
Path: filePath,
|
||||||
Size: "",
|
Size: "",
|
||||||
Factory: fileText.Factory,
|
Factory: fileText.Factory,
|
||||||
|
PBI: fileText.PBI,
|
||||||
Product: details["product"],
|
Product: details["product"],
|
||||||
Step: details["Test_Code"],
|
Step: details["Test_Code"],
|
||||||
|
//Lot: fileText.Lot,
|
||||||
|
SubBatch: fileText.SubBatch,
|
||||||
Lot: details["lot"],
|
Lot: details["lot"],
|
||||||
TestMachineModel: "TQT601",
|
TestMachineModel: "TQT601",
|
||||||
TestMachine: details["TesterNO."],
|
TestMachine: details["TesterNO."],
|
||||||
@ -234,6 +240,7 @@ func HandlerTQT601Excel(fileText *model.FileText, step string) {
|
|||||||
BeginningTime: details["Beginning Time"],
|
BeginningTime: details["Beginning Time"],
|
||||||
EndingTime: details["Ending Time"],
|
EndingTime: details["Ending Time"],
|
||||||
TitleInfo: string(titleInfo),
|
TitleInfo: string(titleInfo),
|
||||||
|
WaferID: fileText.WaferID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
repository/erp/erp.go
Normal file
12
repository/erp/erp.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package erp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testData/global"
|
||||||
|
"testData/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFactorySelections() []string {
|
||||||
|
var factories []string
|
||||||
|
global.Oracle.Model(&model.PmcFile{}).Where("pmc02 IN ?", []string{"AB", "CPFT", "FT"}).Select("pmc03").Find(&factories)
|
||||||
|
return factories
|
||||||
|
}
|
@ -2,6 +2,7 @@ package test_data
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"sort"
|
||||||
"testData/model"
|
"testData/model"
|
||||||
"testData/repository"
|
"testData/repository"
|
||||||
)
|
)
|
||||||
@ -10,6 +11,9 @@ func HandleUploadFiles(fileTexts []*model.FileText, step, machine string) error
|
|||||||
if step == "" {
|
if step == "" {
|
||||||
return errors.New("未输入工序")
|
return errors.New("未输入工序")
|
||||||
}
|
}
|
||||||
|
sort.Slice(fileTexts, func(i, j int) bool {
|
||||||
|
return fileTexts[i].Name < fileTexts[j].Name
|
||||||
|
})
|
||||||
if machine == "STS8200" {
|
if machine == "STS8200" {
|
||||||
for _, fileText := range fileTexts {
|
for _, fileText := range fileTexts {
|
||||||
repository.HandleSTS8200Excel(fileText, step)
|
repository.HandleSTS8200Excel(fileText, step)
|
||||||
@ -20,7 +24,7 @@ func HandleUploadFiles(fileTexts []*model.FileText, step, machine string) error
|
|||||||
}
|
}
|
||||||
} else if machine == "MT737" {
|
} else if machine == "MT737" {
|
||||||
for i := 0; i < len(fileTexts)/2; i++ {
|
for i := 0; i < len(fileTexts)/2; i++ {
|
||||||
repository.MT737(fileTexts[2*i], fileTexts[2*i+1], step)
|
repository.MT737(fileTexts[2*i+1], fileTexts[2*i], step)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
14
router/erp.go
Normal file
14
router/erp.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package router
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
test_data "testData/api/erp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitTestDataERPRouter(R *gin.RouterGroup) {
|
||||||
|
testDataService := test_data.InitTestDataService()
|
||||||
|
testDataGroup := R.Group("")
|
||||||
|
{
|
||||||
|
testDataGroup.GET("import/testFile/factorySelection", testDataService.FactorySelection)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user