package repository import ( "gorm.io/gorm" "sort" "strings" "testData/global" "testData/model" "testData/repository/test.data" ) func TestFilesHandlerCron() { var fileTexts []*model.FileText //global.PostGreSQL.Where("processed = ? AND doubt = ? AND factory != ?", false, false, "江苏芯德").Order("procedure").Find(&fileTexts) global.PostGreSQL.Where("processed = ? AND doubt = ? AND factory NOT IN ?", false, false, []string{"亚芯微", "铜陵碁明"}).Order("procedure").Find(&fileTexts) for _, fileText := range fileTexts { if err := test_data.HandleSTS8200Excel(fileText); err != nil { global.PostGreSQL.Model(&fileTexts).Updates(map[string]interface{}{ "doubt": true, }) continue } global.PostGreSQL.Model(&fileTexts).Updates(map[string]interface{}{ "processed": true, }) } fileTexts = []*model.FileText{} global.PostGreSQL.Where("processed = ? AND doubt = ? AND factory = ?", false, false, "亚芯微").Order("procedure").Find(&fileTexts) sort.Slice(fileTexts, func(i, j int) bool { return fileTexts[i].Name < fileTexts[j].Name }) index := 0 for { if index+1 < len(fileTexts) { if strings.Contains(strings.ToUpper(fileTexts[index].Name), "SUMMARY") { index++ continue } test_data.MT737(fileTexts[index+1], fileTexts[index]) global.PostGreSQL.Transaction(func(tx *gorm.DB) error { tx.Model(&fileTexts[index+1]).Updates(map[string]interface{}{ "processed": true, }) tx.Model(&fileTexts[index]).Updates(map[string]interface{}{ "processed": true, }) return nil }) index += 2 continue } break } //for i := 0; i < len(fileTexts)/2; i++ { // test_data.MT737(fileTexts[2*i+1], fileTexts[2*i]) //} fileTexts = []*model.FileText{} global.PostGreSQL.Where("processed = ? AND doubt = ? AND factory = ?", false, false, "铜陵碁明").Order("procedure").Find(&fileTexts) sort.Slice(fileTexts, func(i, j int) bool { return fileTexts[i].Name < fileTexts[j].Name }) for _, fileText := range fileTexts { if err := test_data.HandleDL6850Excel(fileText); err != nil { continue } global.PostGreSQL.Model(&fileTexts).Updates(map[string]interface{}{ "processed": true, }) } }