forked from free-lancers/electricity_bill_calc_service
fix(model):补充模型定义时丢失的部分字段。
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"electricity_bill_calc/global"
|
||||
"electricity_bill_calc/model"
|
||||
"electricity_bill_calc/tools"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/fufuok/utils"
|
||||
@@ -154,6 +155,11 @@ func (_ReportService) InitializeNewReport(parkId string, period time.Time) (stri
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var parkInfo = new(model.Park)
|
||||
has, err := global.DBConn.ID(parkId).NoAutoCondition().Get(parkInfo)
|
||||
if err != nil || !has {
|
||||
return "", exceptions.NewNotFoundError(fmt.Sprintf("指定园区未找到, %v", err))
|
||||
}
|
||||
// 生成新一期的报表
|
||||
tx := global.DBConn.NewSession()
|
||||
if err = tx.Begin(); err != nil {
|
||||
@@ -162,12 +168,14 @@ func (_ReportService) InitializeNewReport(parkId string, period time.Time) (stri
|
||||
defer tx.Close()
|
||||
// 插入已经生成的报表索引信息和园区概况信息
|
||||
newReport := model.Report{
|
||||
Id: uuid.New().String(),
|
||||
ParkId: parkId,
|
||||
Period: period,
|
||||
StepState: model.NewSteps(),
|
||||
Published: false,
|
||||
Withdraw: model.REPORT_NOT_WITHDRAW,
|
||||
Id: uuid.New().String(),
|
||||
ParkId: parkId,
|
||||
Period: period,
|
||||
Category: parkInfo.Category,
|
||||
SubmeterType: parkInfo.SubmeterType,
|
||||
StepState: model.NewSteps(),
|
||||
Published: false,
|
||||
Withdraw: model.REPORT_NOT_WITHDRAW,
|
||||
}
|
||||
newReportSummary := model.ReportSummary{
|
||||
ReportId: newReport.Id,
|
||||
|
Reference in New Issue
Block a user