package repository

import (
	"fmt"
	"path"
	"strings"
	"testData/global"
	"testData/model"
)

// QiPai 气派
func QiPai() {
	var fileTexts []*model.FileText
	global.PostGreSQL.
		Where("factory = ?", "qipai").Find(&fileTexts)
	for _, fileText := range fileTexts {
		if strings.ToLower(path.Ext(fileText.Name)) != ".csv" &&
			strings.ToLower(path.Ext(fileText.Name)) != ".xls" && strings.ToLower(path.Ext(fileText.Name)) != ".xlsx" {
			continue
		}
		s := strings.Split(fileText.Name, "_")
		if len(s) == 9 && strings.Contains(fileText.Name, "P(A)_STS8200_4Site_(1P0)") {
			ss := strings.Split(fileText.Name, "P(A)_STS8200_4Site_(1P0)")
			sss := strings.Split(ss[0], "_")
			fmt.Println(sss)
			product := sss[len(sss)-2]
			if strings.Index(product, "(") != -1 {
				product = product[:strings.Index(product, "(")]
			}
			lotArray := strings.Split(sss[1], "-")
			if len(lotArray) > 4 {
				fmt.Println(sss[1])
			}
			//fmt.Println("批号:", sss[2])
			fmt.Println("产品型号:", product)
		}
		//HandleSTS8200Excel(fileText, "")
	}
}
