forked from free-lancers/electricity_bill_calc_service
		
	enhance(meter):调整对于表计类型的解析。
This commit is contained in:
		| @@ -1,5 +1,9 @@ | |||||||
| package model | package model | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"strings" | ||||||
|  | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| 	ELECTRICITY_CATE_TWO_PART int16 = iota | 	ELECTRICITY_CATE_TWO_PART int16 = iota | ||||||
| 	ELECTRICITY_CATE_UNITARY_PV | 	ELECTRICITY_CATE_UNITARY_PV | ||||||
| @@ -15,8 +19,22 @@ const ( | |||||||
| 	METER_INSTALLATION_TENEMENT int16 = iota | 	METER_INSTALLATION_TENEMENT int16 = iota | ||||||
| 	METER_INSTALLATION_PARK | 	METER_INSTALLATION_PARK | ||||||
| 	METER_INSTALLATION_POOLING | 	METER_INSTALLATION_POOLING | ||||||
|  | 	METER_INSTALLATION_UNDEFINED = 99 | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | func ParseMeterInstallationType(s string) int16 { | ||||||
|  | 	switch { | ||||||
|  | 	case strings.Contains(s, "商户"): | ||||||
|  | 		return METER_INSTALLATION_TENEMENT | ||||||
|  | 	case strings.Contains(s, "公共"): | ||||||
|  | 		return METER_INSTALLATION_PARK | ||||||
|  | 	case strings.Contains(s, "楼道"): | ||||||
|  | 		return METER_INSTALLATION_POOLING | ||||||
|  | 	default: | ||||||
|  | 		return METER_INSTALLATION_UNDEFINED | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| 	PRICING_POLICY_CONSUMPTION int16 = iota | 	PRICING_POLICY_CONSUMPTION int16 = iota | ||||||
| 	PRICING_POLICY_ALL | 	PRICING_POLICY_ALL | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ type PooledMeterDetailCompound struct { | |||||||
| type MeterImportRow struct { | type MeterImportRow struct { | ||||||
| 	Code      string              `json:"code" excel:"code"` | 	Code      string              `json:"code" excel:"code"` | ||||||
| 	Address   *string             `json:"address" excel:"address"` | 	Address   *string             `json:"address" excel:"address"` | ||||||
| 	MeterType int16               `json:"meterType" excel:"meterType"` | 	MeterType *string             `json:"meterType" excel:"meterType"` | ||||||
| 	Building  *string             `json:"building" excel:"building"` | 	Building  *string             `json:"building" excel:"building"` | ||||||
| 	OnFloor   *string             `json:"onFloor" excel:"onFloor"` | 	OnFloor   *string             `json:"onFloor" excel:"onFloor"` | ||||||
| 	Area      decimal.NullDecimal `json:"area" excel:"area"` | 	Area      decimal.NullDecimal `json:"area" excel:"area"` | ||||||
|   | |||||||
| @@ -208,7 +208,7 @@ func (ms _MeterService) BatchImportMeters(pid string, file *multipart.FileHeader | |||||||
| 		return vo.MeterCreationForm{ | 		return vo.MeterCreationForm{ | ||||||
| 			Code:      element.Code, | 			Code:      element.Code, | ||||||
| 			Address:   element.Address, | 			Address:   element.Address, | ||||||
| 			MeterType: element.MeterType, | 			MeterType: model.ParseMeterInstallationType(*element.MeterType), | ||||||
| 			Ratio:     element.Ratio, | 			Ratio:     element.Ratio, | ||||||
| 			Seq:       element.Seq, | 			Seq:       element.Seq, | ||||||
| 			Enabled:   true, | 			Enabled:   true, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user