fix(model):补充模型定义时丢失的部分字段。
This commit is contained in:
parent
9bc2001b2e
commit
ad19169ac5
@ -6,6 +6,17 @@ import (
|
|||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CATEGORY_TWO_PART int8 = iota
|
||||||
|
CATEGORY_SINGLE_PV
|
||||||
|
CATEGORY_SINGLE_NON_PV
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CUSTOMER_METER_NON_PV int8 = iota
|
||||||
|
CUSTOMER_METER_PV
|
||||||
|
)
|
||||||
|
|
||||||
type Park struct {
|
type Park struct {
|
||||||
CreatedAndModified `xorm:"extends"`
|
CreatedAndModified `xorm:"extends"`
|
||||||
Deleted `xorm:"extends"`
|
Deleted `xorm:"extends"`
|
||||||
@ -16,8 +27,8 @@ type Park struct {
|
|||||||
Area decimal.NullDecimal `xorm:"numeric(14,2)" json:"area"`
|
Area decimal.NullDecimal `xorm:"numeric(14,2)" json:"area"`
|
||||||
TenementQuantity decimal.NullDecimal `xorm:"numeric(8,0)" json:"tenement"`
|
TenementQuantity decimal.NullDecimal `xorm:"numeric(8,0)" json:"tenement"`
|
||||||
Capacity decimal.NullDecimal `xorm:"numeric(16,2)" json:"capacity"`
|
Capacity decimal.NullDecimal `xorm:"numeric(16,2)" json:"capacity"`
|
||||||
Category int8 `xorm:"smallint not null" json:"category"`
|
Category int8 `xorm:"smallint not null default 0" json:"category"`
|
||||||
SubmeterType int8 `xorm:"'meter_04kv_type' smallint not null" json:"meter04kvType"`
|
SubmeterType int8 `xorm:"'meter_04kv_type' smallint not null default 0" json:"meter04kvType"`
|
||||||
Region *string `xorm:"varchar(10)" json:"region"`
|
Region *string `xorm:"varchar(10)" json:"region"`
|
||||||
Address *string `xorm:"varchar(120)" json:"address"`
|
Address *string `xorm:"varchar(120)" json:"address"`
|
||||||
Contact *string `xorm:"varchar(100)" json:"contact"`
|
Contact *string `xorm:"varchar(100)" json:"contact"`
|
||||||
|
@ -14,6 +14,8 @@ type Report struct {
|
|||||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||||
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
|
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
|
||||||
Period time.Time `xorm:"date not null" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
Period time.Time `xorm:"date not null" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||||
|
Category int8 `xorm:"smallint not null default 0" json:"category"`
|
||||||
|
SubmeterType int8 `xorm:"'meter_04kv_type' smallint not null default 0" json:"meter04kvType"`
|
||||||
StepState Steps `xorm:"text not null json" json:"stepState"`
|
StepState Steps `xorm:"text not null json" json:"stepState"`
|
||||||
Published bool `xorm:"bool not null default false" json:"published"`
|
Published bool `xorm:"bool not null default false" json:"published"`
|
||||||
PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"electricity_bill_calc/global"
|
"electricity_bill_calc/global"
|
||||||
"electricity_bill_calc/model"
|
"electricity_bill_calc/model"
|
||||||
"electricity_bill_calc/tools"
|
"electricity_bill_calc/tools"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fufuok/utils"
|
"github.com/fufuok/utils"
|
||||||
@ -154,6 +155,11 @@ func (_ReportService) InitializeNewReport(parkId string, period time.Time) (stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
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()
|
tx := global.DBConn.NewSession()
|
||||||
if err = tx.Begin(); err != nil {
|
if err = tx.Begin(); err != nil {
|
||||||
@ -162,12 +168,14 @@ func (_ReportService) InitializeNewReport(parkId string, period time.Time) (stri
|
|||||||
defer tx.Close()
|
defer tx.Close()
|
||||||
// 插入已经生成的报表索引信息和园区概况信息
|
// 插入已经生成的报表索引信息和园区概况信息
|
||||||
newReport := model.Report{
|
newReport := model.Report{
|
||||||
Id: uuid.New().String(),
|
Id: uuid.New().String(),
|
||||||
ParkId: parkId,
|
ParkId: parkId,
|
||||||
Period: period,
|
Period: period,
|
||||||
StepState: model.NewSteps(),
|
Category: parkInfo.Category,
|
||||||
Published: false,
|
SubmeterType: parkInfo.SubmeterType,
|
||||||
Withdraw: model.REPORT_NOT_WITHDRAW,
|
StepState: model.NewSteps(),
|
||||||
|
Published: false,
|
||||||
|
Withdraw: model.REPORT_NOT_WITHDRAW,
|
||||||
}
|
}
|
||||||
newReportSummary := model.ReportSummary{
|
newReportSummary := model.ReportSummary{
|
||||||
ReportId: newReport.Id,
|
ReportId: newReport.Id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user