|
@@ -7,6 +7,32 @@ import (
|
|
|
"github.com/tealeg/xlsx"
|
|
|
)
|
|
|
|
|
|
+func (gen *Generator) Template() [][]*Schedule {
|
|
|
+ var (
|
|
|
+ weekLessons = make([][]*Schedule, 7)
|
|
|
+ generator = new(Generator)
|
|
|
+ file *xlsx.File
|
|
|
+ name string
|
|
|
+ )
|
|
|
+ unpackJSON(packJSON(gen), generator)
|
|
|
+ if gen.Debug {
|
|
|
+ file, name = CreateXLSX(OUTDATA + "template.xlsx")
|
|
|
+ }
|
|
|
+ day := generator.Day
|
|
|
+ for i := day; i < day+7; i++ {
|
|
|
+ weekLessons[i % 7] = generator.Generate(nil)
|
|
|
+ if gen.Debug {
|
|
|
+ generator.WriteXLSX(
|
|
|
+ file,
|
|
|
+ name,
|
|
|
+ weekLessons[i % 7],
|
|
|
+ int(i % 7),
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return weekLessons
|
|
|
+}
|
|
|
+
|
|
|
func ImportXLSX(filename string) []*PlanXLSX {
|
|
|
var (
|
|
|
listOfPlans []*PlanXLSX
|
|
@@ -17,19 +43,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.GroupNumber = strings.Split(splited[len(splited)-1], "-")[0]
|
|
|
|
|
|
+ maxCells := 18
|
|
|
+ consultExist := false
|
|
|
+ if strings.HasPrefix(sheet.Rows[13].Cells[9].String(), "Консультации") {
|
|
|
+ maxCells = 19
|
|
|
+ consultExist = true
|
|
|
+ }
|
|
|
+
|
|
|
+ plusTable := 0
|
|
|
+ if sheet.Rows[11].Cells[10].String() == "" || sheet.Rows[11].Cells[11].String() == "" {
|
|
|
+ plusTable = 2
|
|
|
+ }
|
|
|
+
|
|
|
for i, row := range sheet.Rows {
|
|
|
if i < 20 {
|
|
|
continue
|
|
|
}
|
|
|
- if len(row.Cells) < 20 {
|
|
|
+
|
|
|
+ if len(row.Cells) < maxCells {
|
|
|
+ // fmt.Println(len(row.Cells))
|
|
|
continue
|
|
|
}
|
|
|
+
|
|
|
if row.Cells[2].String() == "" || row.Cells[2].String() == "ИТОГО" {
|
|
|
continue
|
|
|
}
|
|
@@ -53,20 +95,44 @@ 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()
|
|
|
+ var (
|
|
|
+ max, selfstudy, allstudy, lectures, labs, consult, projects int
|
|
|
+ c1s1, c1s2, c2s1, c2s2, c3s1, c3s2, c4s1, c4s2 int
|
|
|
+ )
|
|
|
+
|
|
|
+ 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()
|
|
|
+
|
|
|
+ if consultExist {
|
|
|
+ consult, _ = row.Cells[9].Int()
|
|
|
+ projects, _ = row.Cells[10].Int()
|
|
|
+ c1s1, _ = row.Cells[11+plusTable].Int()
|
|
|
+ c1s2, _ = row.Cells[12+plusTable].Int()
|
|
|
+ c2s1, _ = row.Cells[13+plusTable].Int()
|
|
|
+ c2s2, _ = row.Cells[14+plusTable].Int()
|
|
|
+ c3s1, _ = row.Cells[15+plusTable].Int()
|
|
|
+ c3s2, _ = row.Cells[16+plusTable].Int()
|
|
|
+ if plusTable == 0 {
|
|
|
+ c4s1, _ = row.Cells[17+plusTable].Int()
|
|
|
+ c4s2, _ = row.Cells[18+plusTable].Int()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ consult = -1
|
|
|
+ projects, _ = row.Cells[9].Int()
|
|
|
+ c1s1, _ = row.Cells[10+plusTable].Int()
|
|
|
+ c1s2, _ = row.Cells[11+plusTable].Int()
|
|
|
+ c2s1, _ = row.Cells[12+plusTable].Int()
|
|
|
+ c2s2, _ = row.Cells[13+plusTable].Int()
|
|
|
+ c3s1, _ = row.Cells[14+plusTable].Int()
|
|
|
+ c3s2, _ = row.Cells[15+plusTable].Int()
|
|
|
+ if plusTable == 0 {
|
|
|
+ c4s1, _ = row.Cells[16+plusTable].Int()
|
|
|
+ c4s2, _ = row.Cells[17+plusTable].Int()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
certform := ""
|
|
|
splited = strings.Split(row.Cells[3].String(), ",")
|
|
@@ -87,6 +153,7 @@ func ImportXLSX(filename string) []*PlanXLSX {
|
|
|
AllStudy: allstudy,
|
|
|
Lectures: lectures,
|
|
|
Labs: labs,
|
|
|
+ Consultation: consult,
|
|
|
Projects: projects,
|
|
|
},
|
|
|
Course: [4][2]int{
|