Dasflugen 5 лет назад
Родитель
Сommit
e24e1f5832
2 измененных файлов с 32 добавлено и 30 удалено
  1. 5 3
      main.go
  2. 27 27
      schedule/xlsx.go

+ 5 - 3
main.go

@@ -103,10 +103,12 @@ func main() {
 	http.HandleFunc("/wekan", wekanRedirect)
 	http.HandleFunc("/test/", testPage) // testing token
 	// HTTP pages handling end
-	port := os.Args[1]
-	api.PrintConsole("Server is listening")
+	api.PrintConsole("Server is starting...")
 
-	http.ListenAndServe(":" + port, nil)
+	err := http.ListenAndServe(":" + os.Args[1], nil)
+	if err!=nil{
+		api.PrintConsole("Error while starting server")
+	}
 }
 
 func wekanRedirect(w http.ResponseWriter, r *http.Request){

+ 27 - 27
schedule/xlsx.go

@@ -17,35 +17,35 @@ func ImportXLSX(filename string) []*PlanXLSX {
     }
     for _, sheet := range xlFile.Sheets {
         var plan = new(PlanXLSX)
-        plan.ProgramCode   = sheet.Rows[5].Cells[1].String()
-        plan.NameCode      = strings.Split(sheet.Rows[5].Cells[6].String(), " ")[0]
-        plan.PeriodOfStudy = sheet.Rows[7].Cells[6].String()
-        splited := strings.Split(sheet.Rows[9].Cells[1].String(), " ")
+        plan.ProgramCode   = sheet.Row[5].Col[1].String()
+        plan.NameCode      = strings.Split(sheet.Row[5].Col[6].String(), " ")[0]
+        plan.PeriodOfStudy = sheet.Row[7].Col[6].String()
+        splited := strings.Split(sheet.Row[9].Col[1].String(), " ")
         plan.GroupNumber   = strings.Split(splited[len(splited)-1], "-")[0]
 
-        for i, row := range sheet.Rows {
+        for i, row := range sheet.Row {
             if i < 20 {
                 continue
             }
-            if len(row.Cells) < 20 {
+            if len(row.Col) < 20 {
                 continue
             }
-            if row.Cells[2].String() == "" || row.Cells[2].String() == "ИТОГО" {
+            if row.Col[2].String() == "" || row.Col[2].String() == "ИТОГО" {
                 continue
             }
 
-            if strings.HasPrefix(row.Cells[1].String(), "Консультации") || strings.HasPrefix(row.Cells[1].String(), "Государственная") {
+            if strings.HasPrefix(row.Col[1].String(), "Консультации") || strings.HasPrefix(row.Col[1].String(), "Государственная") {
                 continue
             }
 
-            splited := strings.Split(row.Cells[1].String(), ".")
+            splited := strings.Split(row.Col[1].String(), ".")
             if len(splited) != 2 {
                 continue
             }
 
             typerow := TypeRow(IsSubTR)
             switch {
-            case strings.Contains(row.Cells[2].String(), "цикл"):
+            case strings.Contains(row.Col[2].String(), "цикл"):
                 typerow = IsCycleTR
             case splited[1] == "00":
                 typerow = IsStartTR
@@ -53,23 +53,23 @@ func ImportXLSX(filename string) []*PlanXLSX {
                 typerow = IsPmTR
             }
 
-            max, _       := row.Cells[4].Int()
-            selfstudy, _ := row.Cells[5].Int()
-            allstudy, _  := row.Cells[6].Int()
-            lectures, _  := row.Cells[7].Int()
-            labs, _      := row.Cells[8].Int()
-            projects, _  := row.Cells[9].Int()
-            c1s1, _      := row.Cells[12].Int()
-            c1s2, _      := row.Cells[13].Int()
-            c2s1, _      := row.Cells[14].Int()
-            c2s2, _      := row.Cells[15].Int()
-            c3s1, _      := row.Cells[16].Int()
-            c3s2, _      := row.Cells[17].Int()
-            c4s1, _      := row.Cells[18].Int()
-            c4s2, _      := row.Cells[19].Int()
+            max, _       := row.Col[4].Int()
+            selfstudy, _ := row.Col[5].Int()
+            allstudy, _  := row.Col[6].Int()
+            lectures, _  := row.Col[7].Int()
+            labs, _      := row.Col[8].Int()
+            projects, _  := row.Col[9].Int()
+            c1s1, _      := row.Col[12].Int()
+            c1s2, _      := row.Col[13].Int()
+            c2s1, _      := row.Col[14].Int()
+            c2s2, _      := row.Col[15].Int()
+            c3s1, _      := row.Col[16].Int()
+            c3s2, _      := row.Col[17].Int()
+            c4s1, _      := row.Col[18].Int()
+            c4s2, _      := row.Col[19].Int()
 
             certform := ""
-            splited = strings.Split(row.Cells[3].String(), ",")
+            splited = strings.Split(row.Col[3].String(), ",")
             for _, v := range splited {
                 if v != "-" {
                     certform = v
@@ -78,8 +78,8 @@ func ImportXLSX(filename string) []*PlanXLSX {
             }
 
             plan.Lines = append(plan.Lines, LineXLSX{
-                ID:        row.Cells[1].String(),
-                Name:      row.Cells[2].String(),
+                ID:        row.Col[1].String(),
+                Name:      row.Col[2].String(),
                 CertForm:  certform,
                 StudyLoad: StudyLoadXLSX{
                     Max:       max,