forked from free-lancers/electricity_bill_calc_service
		
	fix(model):补充模型定义时丢失的部分字段。
This commit is contained in:
		| @@ -6,6 +6,17 @@ import ( | ||||
| 	"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 { | ||||
| 	CreatedAndModified `xorm:"extends"` | ||||
| 	Deleted            `xorm:"extends"` | ||||
| @@ -16,8 +27,8 @@ type Park struct { | ||||
| 	Area               decimal.NullDecimal `xorm:"numeric(14,2)" json:"area"` | ||||
| 	TenementQuantity   decimal.NullDecimal `xorm:"numeric(8,0)" json:"tenement"` | ||||
| 	Capacity           decimal.NullDecimal `xorm:"numeric(16,2)" json:"capacity"` | ||||
| 	Category           int8                `xorm:"smallint not null" json:"category"` | ||||
| 	SubmeterType       int8                `xorm:"'meter_04kv_type' smallint not null" json:"meter04kvType"` | ||||
| 	Category           int8                `xorm:"smallint not null default 0" json:"category"` | ||||
| 	SubmeterType       int8                `xorm:"'meter_04kv_type' smallint not null default 0" json:"meter04kvType"` | ||||
| 	Region             *string             `xorm:"varchar(10)" json:"region"` | ||||
| 	Address            *string             `xorm:"varchar(120)" json:"address"` | ||||
| 	Contact            *string             `xorm:"varchar(100)" json:"contact"` | ||||
|   | ||||
| @@ -14,6 +14,8 @@ type Report struct { | ||||
| 	Id                    string     `xorm:"varchar(120) pk not null" json:"id"` | ||||
| 	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"` | ||||
| 	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"` | ||||
| 	Published             bool       `xorm:"bool not null default false" json:"published"` | ||||
| 	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/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