feat(report):已完成用户抄表记录的上传处理。

This commit is contained in:
徐涛
2022-08-23 10:27:41 +08:00
parent ba7af386c4
commit 1d60706108
6 changed files with 298 additions and 0 deletions

View File

@@ -55,6 +55,14 @@ func (e AnalysisError) MarshalJSON() ([]byte, error) {
return json.Marshal(e.Err.Error())
}
func (e AnalysisError) Error() string {
return e.Err.Error()
}
func (e ExcelAnalysisError) Error() string {
return e.Err.Error()
}
func (r *ColumnRecognizer) Recognize(cellValue string) bool {
matches := make([]bool, 0)
for _, p := range r.Pattern {

31
excel/end_user.go Normal file
View File

@@ -0,0 +1,31 @@
package excel
import (
"electricity_bill_calc/model"
"io"
)
var (
endUserNonPVRecognizers = []*ColumnRecognizer{
{Pattern: []string{"电表编号"}, Tag: "meterId", MatchIndex: -1},
{Pattern: []string{"本期", "(总)"}, Tag: "currentPeriodOverall", MatchIndex: -1},
{Pattern: []string{"退补", "(总)"}, Tag: "adjustOverall", MatchIndex: -1},
}
endUserPVRecognizers = append(
endUserNonPVRecognizers,
&ColumnRecognizer{Pattern: []string{"本期", "(尖峰)"}, Tag: "currentPeriodCritical", MatchIndex: -1},
&ColumnRecognizer{Pattern: []string{"本期", "(峰)"}, Tag: "currentPeriodPeak", MatchIndex: -1},
&ColumnRecognizer{Pattern: []string{"本期", "(谷)"}, Tag: "currentPeriodValley", MatchIndex: -1},
&ColumnRecognizer{Pattern: []string{"退补", "(尖峰)"}, Tag: "adjustCritical", MatchIndex: -1},
&ColumnRecognizer{Pattern: []string{"退补", "(峰)"}, Tag: "adjustPeak", MatchIndex: -1},
&ColumnRecognizer{Pattern: []string{"退补", "(谷)"}, Tag: "adjustValley", MatchIndex: -1},
)
)
func NewEndUserNonPVExcelAnalyzer(file io.Reader) (*ExcelAnalyzer[model.EndUserImport], error) {
return NewExcelAnalyzer[model.EndUserImport](file, endUserNonPVRecognizers)
}
func NewEndUserPVExcelAnalyzer(file io.Reader) (*ExcelAnalyzer[model.EndUserImport], error) {
return NewExcelAnalyzer[model.EndUserImport](file, endUserPVRecognizers)
}