#1 all ratings are maped

This commit is contained in:
Andreas Schröpfer
2021-02-28 11:04:15 +01:00
parent 90af0db862
commit d310fdd2b3
6 changed files with 3312 additions and 65 deletions

View File

@@ -81,15 +81,23 @@ type AreaCol struct {
// The cols must be defined by the letter of the col
// for example "A" for the first col
type Rating struct {
Sheet int `json:"sheet"`
StartRow int `json:"start_row"`
EndRow int `json:"end_row"`
PointsCol string `json:"points_col"`
MaxPointsCol string `json:"max_points_col"`
IDCol string `json:"id_col"`
ShortNameCol string `json:"short_name_col"`
NameCol string `json:"name_col"`
EstimationsCol string `json:"estimations_col"`
WeightCol string `json:"weight_col"`
SelectedByUserCol string `json:"selected_by_user_col"`
Sheet int `json:"sheet"`
StartRow int `json:"start_row"`
EndRow int `json:"end_row"`
Cols []RatingCol `json:"cols"`
PointsCol string `json:"points_col"`
MaxPointsCol string `json:"max_points_col"`
IDCol string `json:"id_col"`
ShortNameCol string `json:"short_name_col"`
NameCol string `json:"name_col"`
EstimationsCol string `json:"estimations_col"`
WeightCol string `json:"weight_col"`
SelectedByUserCol string `json:"selected_by_user_col"`
}
type RatingCol struct {
Col string `json:"col"`
Field string `json:"field"`
Type string `json:"type"`
Default string `json:"default"`
}

View File

@@ -185,14 +185,45 @@
"sheet": 3,
"start_row": 9,
"end_row": 93,
"points_col": "I",
"max_points_col": "J",
"id_col": "",
"short_name_col": "B",
"name_col": "C",
"estimations_col": "H",
"weight_col": "D",
"selected_by_user_col": "N"
"cols": [
{
"col": "I",
"field": "Points",
"type": "int",
"default": ""
},
{
"col": "J",
"field": "MaxPoints",
"type": "float64",
"default": ""
},
{
"col": "C",
"field": "Name",
"type": "int",
"default": ""
},
{
"col": "H",
"field": "Estimations",
"type": "int",
"default": ""
},
{
"col": "D",
"field": "Weight",
"type": "float64",
"default": ""
},
{
"col": "N",
"field": "IsWeightSelectedByUser",
"type": "bool",
"default": ""
}
]
}
}

View File

@@ -94,6 +94,52 @@ func XLSX(r io.Reader, conf *Conf) (*ecalc.Ecalc, error) {
}
}
var topic ecalc.Topic
for r := conf.Rating.StartRow; r <= conf.Rating.EndRow; r++ {
shortName, err := xFile.GetCellValue(
xFile.GetSheetName(conf.Rating.Sheet),
fmt.Sprintf("%s%d", conf.Rating.ShortNameCol, r),
)
if err != nil {
errs = append(errs, err)
}
if len(shortName) < 2 {
continue
} else if len(shortName) == 2 {
if topic.ShortName != "" {
eBalance.CompanyFacts.Rating.Topics = append(eBalance.CompanyFacts.Rating.Topics, topic)
}
topic = ecalc.Topic{
ShortName: shortName,
}
for _, c := range conf.Rating.Cols {
cellValue, err := xFile.GetCellValue(
xFile.GetSheetName(conf.Rating.Sheet),
fmt.Sprintf("%s%d", c.Col, r),
)
if err != nil {
errs = append(errs, err)
}
set.Field(&topic, c.Field, cellValue)
}
} else {
aspect := ecalc.Aspect{
ShortName: shortName,
}
for _, c := range conf.Rating.Cols {
cellValue, err := xFile.GetCellValue(
xFile.GetSheetName(conf.Rating.Sheet),
fmt.Sprintf("%s%d", c.Col, r),
)
if err != nil {
errs = append(errs, err)
}
set.Field(&aspect, c.Field, cellValue)
}
topic.Aspects = append(topic.Aspects, aspect)
}
}
eBalance.CompanyFacts.Rating.Topics = append(eBalance.CompanyFacts.Rating.Topics, topic)
// TODO: error handling of errs
return eBalance, nil
}