enhance(calculate):基本完成摊薄总计部分的计算改动。

This commit is contained in:
徐涛 2022-09-20 15:44:25 +08:00
parent 2c182496fa
commit 8ec217534e
4 changed files with 209 additions and 147 deletions

View File

@ -41,27 +41,7 @@ type EndUserOverallPart struct {
ValleyFee decimal.NullDecimal `json:"valleyFee"` ValleyFee decimal.NullDecimal `json:"valleyFee"`
} }
type DilutedConsumptionOverallPart struct { type ConsumptionOverallPart struct {
Overall decimal.Decimal `json:"overall"`
OverallPrice decimal.Decimal `json:"overallPrice"`
ConsumptionFee decimal.Decimal `json:"consumptionFee"`
OverallFee decimal.Decimal `json:"overallFee"`
Critical decimal.NullDecimal `json:"critical"`
CriticalPrice decimal.NullDecimal `json:"criticalPrice"`
CriticalFee decimal.NullDecimal `json:"criticalFee"`
Peak decimal.NullDecimal `json:"peak"`
PeakPrice decimal.NullDecimal `json:"peakPrice"`
PeakFee decimal.NullDecimal `json:"peakFee"`
Flat decimal.NullDecimal `json:"flat"`
FlatPrice decimal.NullDecimal `json:"flatPrice"`
FlatFee decimal.NullDecimal `json:"flatFee"`
Valley decimal.NullDecimal `json:"valley"`
ValleyPrice decimal.NullDecimal `json:"valleyPrice"`
ValleyFee decimal.NullDecimal `json:"valleyFee"`
Proportion decimal.Decimal `json:"proportion"`
}
type PublicConsumptionOverallPart struct {
Overall decimal.Decimal `json:"overall"` Overall decimal.Decimal `json:"overall"`
OverallPrice decimal.Decimal `json:"overallPrice"` OverallPrice decimal.Decimal `json:"overallPrice"`
ConsumptionFee decimal.Decimal `json:"consumptionFee"` ConsumptionFee decimal.Decimal `json:"consumptionFee"`
@ -126,10 +106,10 @@ type Publicity struct {
User UserDetail `json:"enterprise"` User UserDetail `json:"enterprise"`
Park Park `json:"park"` Park Park `json:"park"`
Paid PaidPart `json:"paid"` Paid PaidPart `json:"paid"`
EndUser EndUserOverallPart `json:"endUserSum"` EndUser ConsumptionOverallPart `json:"endUserSum"`
Loss LossPart `json:"loss"` Loss LossPart `json:"loss"`
DilutedConsumptionOverall DilutedConsumptionOverallPart `json:"diluted"` DilutedConsumptionOverall ConsumptionOverallPart `json:"diluted"`
PublicConsumptionOverall PublicConsumptionOverallPart `json:"public"` PublicConsumptionOverall ConsumptionOverallPart `json:"public"`
OtherCollections OtherShouldCollectionPart `json:"others"` OtherCollections OtherShouldCollectionPart `json:"others"`
Maintenance MaintenancePart `json:"maintenance"` Maintenance MaintenancePart `json:"maintenance"`
EndUserDetails []EndUserSummary `json:"endUser"` EndUserDetails []EndUserSummary `json:"endUser"`

View File

@ -57,6 +57,22 @@ type Consumptions struct {
Proportion decimal.NullDecimal `json:"proportion"` Proportion decimal.NullDecimal `json:"proportion"`
} }
func NewConsumptions() Consumptions {
return Consumptions{
Consumption: decimal.NewNullDecimal(decimal.Zero),
ConsumptionFee: decimal.NewNullDecimal(decimal.Zero),
Critical: decimal.NewNullDecimal(decimal.Zero),
Peak: decimal.NewNullDecimal(decimal.Zero),
PeakFee: decimal.NewNullDecimal(decimal.Zero),
Flat: decimal.NewNullDecimal(decimal.Zero),
CriticalFee: decimal.NewNullDecimal(decimal.Zero),
FlatFee: decimal.NewNullDecimal(decimal.Zero),
Valley: decimal.NewNullDecimal(decimal.Zero),
ValleyFee: decimal.NewNullDecimal(decimal.Zero),
Proportion: decimal.NewNullDecimal(decimal.Zero),
}
}
func (s ReportSummary) Validate() (bool, error) { func (s ReportSummary) Validate() (bool, error) {
amountSum := decimal.Sum(s.Critical, s.Peak, s.Valley) amountSum := decimal.Sum(s.Critical, s.Peak, s.Valley)
if amountSum.GreaterThan(s.Overall) { if amountSum.GreaterThan(s.Overall) {

View File

@ -41,16 +41,9 @@ func (_CalculateService) ComprehensivelyCalculateReport(reportId string) (err er
} }
// 计算终端用户信息与概览中的合计 // 计算终端用户信息与概览中的合计
report.Summary.PublicConsumption = decimal.NewNullDecimal(decimal.Zero) report.Summary.Customers = model.NewConsumptions()
report.Summary.PublicConsumptionCritical = decimal.NewNullDecimal(decimal.Zero) report.Summary.Publics = model.NewConsumptions()
report.Summary.PublicConsumptionPeak = decimal.NewNullDecimal(decimal.Zero) report.Summary.Diluteds = model.NewConsumptions()
report.Summary.PublicConsumptionFlat = decimal.NewNullDecimal(decimal.Zero)
report.Summary.PublicConsumptionValley = decimal.NewNullDecimal(decimal.Zero)
report.Summary.CustomerConsumption = decimal.NewNullDecimal(decimal.Zero)
report.Summary.CustomerConsumptionCritical = decimal.NewNullDecimal(decimal.Zero)
report.Summary.CustomerConsumptionPeak = decimal.NewNullDecimal(decimal.Zero)
report.Summary.CustomerConsumptionFlat = decimal.NewNullDecimal(decimal.Zero)
report.Summary.CustomerConsumptionValley = decimal.NewNullDecimal(decimal.Zero)
for _, eu := range report.EndUsers { for _, eu := range report.EndUsers {
eu.OverallFee = decimal.NewNullDecimal( eu.OverallFee = decimal.NewNullDecimal(
eu.Overall.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), eu.Overall.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
@ -67,95 +60,144 @@ func (_CalculateService) ComprehensivelyCalculateReport(reportId string) (err er
eu.ValleyFee = decimal.NewNullDecimal( eu.ValleyFee = decimal.NewNullDecimal(
eu.Valley.Decimal.Mul(report.Summary.ValleyPrice.Decimal).RoundBank(2), eu.Valley.Decimal.Mul(report.Summary.ValleyPrice.Decimal).RoundBank(2),
) )
if eu.IsPublicMeter && eu.WillDilute { if eu.IsPublicMeter {
report.Summary.PublicConsumption.Decimal = report.Summary.PublicConsumption.Decimal.Add(eu.Overall.Decimal) report.Summary.Publics.Consumption.Decimal = report.Summary.Publics.Consumption.Decimal.Add(eu.Overall.Decimal)
report.Summary.PublicConsumptionCritical.Decimal = report.Summary.PublicConsumptionCritical.Decimal.Add(eu.Critical.Decimal) report.Summary.Publics.Critical.Decimal = report.Summary.Publics.Critical.Decimal.Add(eu.Critical.Decimal)
report.Summary.PublicConsumptionPeak.Decimal = report.Summary.PublicConsumptionPeak.Decimal.Add(eu.Peak.Decimal) report.Summary.Publics.Peak.Decimal = report.Summary.Publics.Peak.Decimal.Add(eu.Peak.Decimal)
report.Summary.PublicConsumptionFlat.Decimal = report.Summary.PublicConsumptionFlat.Decimal.Add(eu.Flat.Decimal) report.Summary.Publics.Flat.Decimal = report.Summary.Publics.Flat.Decimal.Add(eu.Flat.Decimal)
report.Summary.PublicConsumptionValley.Decimal = report.Summary.PublicConsumptionValley.Decimal.Add(eu.Valley.Decimal) report.Summary.Publics.Valley.Decimal = report.Summary.Publics.Valley.Decimal.Add(eu.Valley.Decimal)
if eu.WillDilute {
report.Summary.Diluteds.Consumption.Decimal = report.Summary.Diluteds.Consumption.Decimal.Add(eu.Overall.Decimal)
report.Summary.Diluteds.Critical.Decimal = report.Summary.Diluteds.Critical.Decimal.Add(eu.Critical.Decimal)
report.Summary.Diluteds.Peak.Decimal = report.Summary.Diluteds.Peak.Decimal.Add(eu.Peak.Decimal)
report.Summary.Diluteds.Flat.Decimal = report.Summary.Diluteds.Flat.Decimal.Add(eu.Flat.Decimal)
report.Summary.Diluteds.Valley.Decimal = report.Summary.Diluteds.Valley.Decimal.Add(eu.Valley.Decimal)
}
} else { } else {
report.Summary.CustomerConsumption.Decimal = report.Summary.CustomerConsumption.Decimal.Add(eu.Overall.Decimal) report.Summary.Customers.Consumption.Decimal = report.Summary.Customers.Consumption.Decimal.Add(eu.Overall.Decimal)
report.Summary.CustomerConsumptionCritical.Decimal = report.Summary.CustomerConsumptionCritical.Decimal.Add(eu.Critical.Decimal) report.Summary.Customers.Critical.Decimal = report.Summary.Customers.Critical.Decimal.Add(eu.Critical.Decimal)
report.Summary.CustomerConsumptionPeak.Decimal = report.Summary.CustomerConsumptionPeak.Decimal.Add(eu.Peak.Decimal) report.Summary.Customers.Peak.Decimal = report.Summary.Customers.Peak.Decimal.Add(eu.Peak.Decimal)
report.Summary.CustomerConsumptionFlat.Decimal = report.Summary.CustomerConsumptionFlat.Decimal.Add(eu.Flat.Decimal) report.Summary.Customers.Flat.Decimal = report.Summary.Customers.Flat.Decimal.Add(eu.Flat.Decimal)
report.Summary.CustomerConsumptionValley.Decimal = report.Summary.CustomerConsumptionValley.Decimal.Add(eu.Valley.Decimal) report.Summary.Customers.Valley.Decimal = report.Summary.Customers.Valley.Decimal.Add(eu.Valley.Decimal)
} }
} }
// 计算户表总电费和公共总电费以及相应的摊薄 // 计算户表总电费和公共总电费以及相应的摊薄
if report.SubmeterType == model.CUSTOMER_METER_NON_PV { if report.SubmeterType == model.CUSTOMER_METER_NON_PV {
report.Summary.CustomerConsumptionFee = decimal.NewNullDecimal( // 计算终端用户部分
report.Summary.CustomerConsumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Customers.ConsumptionFee = decimal.NewNullDecimal(
report.Summary.Customers.Consumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionCriticalFee = decimal.NewNullDecimal( report.Summary.Customers.CriticalFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionCritical.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Customers.Critical.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionPeakFee = decimal.NewNullDecimal( report.Summary.Customers.PeakFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionPeak.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Customers.Peak.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionFlatFee = decimal.NewNullDecimal( report.Summary.Customers.FlatFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionFlat.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Customers.Flat.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionValleyFee = decimal.NewNullDecimal( report.Summary.Customers.ValleyFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionValley.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Customers.Valley.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionFee = decimal.NewNullDecimal( // 计算公共区域部分
report.Summary.PublicConsumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Publics.ConsumptionFee = decimal.NewNullDecimal(
report.Summary.Publics.Consumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionCriticalFee = decimal.NewNullDecimal( report.Summary.Publics.CriticalFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionCritical.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Publics.Critical.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionPeakFee = decimal.NewNullDecimal( report.Summary.Publics.PeakFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionPeak.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Publics.Peak.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionFlatFee = decimal.NewNullDecimal( report.Summary.Publics.FlatFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionFlat.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Publics.Flat.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionValleyFee = decimal.NewNullDecimal( report.Summary.Publics.ValleyFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionValley.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Publics.Valley.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
)
// 计算摊薄总计部分
report.Summary.Diluteds.ConsumptionFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Consumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.CriticalFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Critical.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.PeakFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Peak.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.FlatFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Flat.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.ValleyFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Valley.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
} }
if report.SubmeterType == model.CUSTOMER_METER_PV { if report.SubmeterType == model.CUSTOMER_METER_PV {
report.Summary.CustomerConsumptionFee = decimal.NewNullDecimal( // 计算终端用户部分
report.Summary.CustomerConsumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Customers.ConsumptionFee = decimal.NewNullDecimal(
report.Summary.Customers.Consumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionCriticalFee = decimal.NewNullDecimal( report.Summary.Customers.CriticalFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionCritical.Decimal.Mul(report.Summary.CriticalPrice.Decimal).RoundBank(2), report.Summary.Customers.Critical.Decimal.Mul(report.Summary.CriticalPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionPeakFee = decimal.NewNullDecimal( report.Summary.Customers.PeakFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionPeak.Decimal.Mul(report.Summary.PeakPrice.Decimal).RoundBank(2), report.Summary.Customers.Peak.Decimal.Mul(report.Summary.PeakPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionFlatFee = decimal.NewNullDecimal( report.Summary.Customers.FlatFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionFlat.Decimal.Mul(report.Summary.FlatPrice.Decimal).RoundBank(2), report.Summary.Customers.Flat.Decimal.Mul(report.Summary.FlatPrice.Decimal).RoundBank(2),
) )
report.Summary.CustomerConsumptionValleyFee = decimal.NewNullDecimal( report.Summary.Customers.ValleyFee = decimal.NewNullDecimal(
report.Summary.CustomerConsumptionValley.Decimal.Mul(report.Summary.ValleyPrice.Decimal).RoundBank(2), report.Summary.Customers.Valley.Decimal.Mul(report.Summary.ValleyPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionFee = decimal.NewNullDecimal( // 计算公共区域部分
report.Summary.PublicConsumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2), report.Summary.Publics.ConsumptionFee = decimal.NewNullDecimal(
report.Summary.Publics.Consumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionCriticalFee = decimal.NewNullDecimal( report.Summary.Publics.CriticalFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionCritical.Decimal.Mul(report.Summary.CriticalPrice.Decimal).RoundBank(2), report.Summary.Publics.Critical.Decimal.Mul(report.Summary.CriticalPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionPeakFee = decimal.NewNullDecimal( report.Summary.Publics.PeakFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionPeak.Decimal.Mul(report.Summary.PeakPrice.Decimal).RoundBank(2), report.Summary.Publics.Peak.Decimal.Mul(report.Summary.PeakPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionFlatFee = decimal.NewNullDecimal( report.Summary.Publics.FlatFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionFlat.Decimal.Mul(report.Summary.FlatPrice.Decimal).RoundBank(2), report.Summary.Publics.Flat.Decimal.Mul(report.Summary.FlatPrice.Decimal).RoundBank(2),
) )
report.Summary.PublicConsumptionValleyFee = decimal.NewNullDecimal( report.Summary.Publics.ValleyFee = decimal.NewNullDecimal(
report.Summary.PublicConsumptionValley.Decimal.Mul(report.Summary.ValleyPrice.Decimal).RoundBank(2), report.Summary.Publics.Valley.Decimal.Mul(report.Summary.ValleyPrice.Decimal).RoundBank(2),
)
// 计算摊薄部分
report.Summary.Diluteds.ConsumptionFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Consumption.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.CriticalFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Critical.Decimal.Mul(report.Summary.CriticalPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.PeakFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Peak.Decimal.Mul(report.Summary.PeakPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.FlatFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Flat.Decimal.Mul(report.Summary.FlatPrice.Decimal).RoundBank(2),
)
report.Summary.Diluteds.ValleyFee = decimal.NewNullDecimal(
report.Summary.Diluteds.Valley.Decimal.Mul(report.Summary.ValleyPrice.Decimal).RoundBank(2),
) )
} }
if report.Summary.Overall.Abs().GreaterThan(decimal.Zero) { if report.Summary.Overall.Abs().GreaterThan(decimal.Zero) {
report.Summary.PublicConsumptionProportion = decimal.NewNullDecimal( report.Summary.Customers.Proportion = decimal.NewNullDecimal(
report.Summary.PublicConsumption.Decimal.Div(report.Summary.Overall).RoundBank(15), report.Summary.Customers.Consumption.Decimal.Div(report.Summary.Overall).RoundBank(15),
)
report.Summary.Publics.Proportion = decimal.NewNullDecimal(
report.Summary.Publics.Consumption.Decimal.Div(report.Summary.Overall).RoundBank(15),
)
report.Summary.Diluteds.Proportion = decimal.NewNullDecimal(
report.Summary.Diluteds.Consumption.Decimal.Div(report.Summary.Overall).RoundBank(15),
) )
} }
// 计算线损 // 计算线损
report.Summary.Loss = decimal.NewNullDecimal( report.Summary.Loss = decimal.NewNullDecimal(
report.Summary.Overall.Sub(report.Summary.PublicConsumption.Decimal).Sub(report.Summary.CustomerConsumption.Decimal), report.Summary.Overall.Sub(report.Summary.Publics.Consumption.Decimal).Sub(report.Summary.Customers.Consumption.Decimal),
) )
report.Summary.LossFee = decimal.NewNullDecimal( report.Summary.LossFee = decimal.NewNullDecimal(
report.Summary.Loss.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(8), report.Summary.Loss.Decimal.Mul(report.Summary.OverallPrice.Decimal).RoundBank(8),
@ -165,25 +207,27 @@ func (_CalculateService) ComprehensivelyCalculateReport(reportId string) (err er
report.Summary.Loss.Decimal.Div(report.Summary.Overall).RoundBank(15), report.Summary.Loss.Decimal.Div(report.Summary.Overall).RoundBank(15),
) )
} }
if report.Summary.CustomerConsumption.Decimal.Abs().GreaterThan(decimal.Zero) { if report.Summary.Customers.Consumption.Decimal.Abs().GreaterThan(decimal.Zero) {
report.Summary.LossDilutedPrice = decimal.NewNullDecimal( report.Summary.LossDilutedPrice = decimal.NewNullDecimal(
report.Summary.LossFee.Decimal.Div(report.Summary.CustomerConsumption.Decimal).RoundBank(8), report.Summary.LossFee.Decimal.Div(report.Summary.Customers.Consumption.Decimal).RoundBank(8),
) )
} }
// 计算基本电费和调整电费等的摊薄 // 计算基本电费和调整电费等的摊薄
if report.Summary.CustomerConsumption.Decimal.Abs().GreaterThan(decimal.Zero) { if report.Summary.Customers.Consumption.Decimal.Abs().GreaterThan(decimal.Zero) {
report.Summary.BasicDilutedPrice = decimal.NewNullDecimal( report.Summary.BasicDilutedPrice = decimal.NewNullDecimal(
report.Summary.BasicFee.Div(report.Summary.CustomerConsumption.Decimal).RoundBank(8), report.Summary.BasicFee.Div(report.Summary.Customers.Consumption.Decimal).RoundBank(8),
) )
report.Summary.AdjustDilutedPrice = decimal.NewNullDecimal( report.Summary.AdjustDilutedPrice = decimal.NewNullDecimal(
report.Summary.AdjustFee.Div(report.Summary.CustomerConsumption.Decimal).RoundBank(8), report.Summary.AdjustFee.Div(report.Summary.Customers.Consumption.Decimal).RoundBank(8),
) )
report.Summary.MaintenanceDilutedPrice = decimal.NewNullDecimal( report.Summary.MaintenanceDilutedPrice = decimal.NewNullDecimal(
maintenanceFeeTotal.Div(report.Summary.CustomerConsumption.Decimal).RoundBank(8), maintenanceFeeTotal.Div(report.Summary.Customers.Consumption.Decimal).RoundBank(8),
) )
// ! 这里需要注意的是在原始设计中PublicConsumptionDilutedPrice就是表示公共摊薄价格
// ! 而不是所有公共设施合计数据所以要使用Diluteds部分数据。
report.Summary.PublicConsumptionDilutedPrice = decimal.NewNullDecimal( report.Summary.PublicConsumptionDilutedPrice = decimal.NewNullDecimal(
report.Summary.PublicConsumptionFee.Decimal.Div(report.Summary.CustomerConsumption.Decimal).RoundBank(8), report.Summary.Diluteds.ConsumptionFee.Decimal.Div(report.Summary.Customers.Consumption.Decimal).RoundBank(8),
) )
} }
@ -192,7 +236,7 @@ func (_CalculateService) ComprehensivelyCalculateReport(reportId string) (err er
report.Summary.FinalDilutedOverall = decimal.NewNullDecimal( report.Summary.FinalDilutedOverall = decimal.NewNullDecimal(
report.Summary.BasicFee. report.Summary.BasicFee.
Add(report.Summary.AdjustFee). Add(report.Summary.AdjustFee).
Add(report.Summary.PublicConsumptionFee.Decimal). Add(report.Summary.Diluteds.ConsumptionFee.Decimal).
Add(maintenanceFeeTotal). Add(maintenanceFeeTotal).
Add(report.Summary.LossFee.Decimal), Add(report.Summary.LossFee.Decimal),
) )
@ -201,15 +245,15 @@ func (_CalculateService) ComprehensivelyCalculateReport(reportId string) (err er
for _, eu := range report.EndUsers { for _, eu := range report.EndUsers {
if eu.IsPublicMeter && eu.WillDilute { if eu.IsPublicMeter && eu.WillDilute {
// 计算需要摊薄的公共表计的摊薄内容 // 计算需要摊薄的公共表计的摊薄内容
if report.Summary.PublicConsumption.Decimal.Abs().GreaterThan(decimal.Zero) { if report.Summary.Diluteds.Consumption.Decimal.Abs().GreaterThan(decimal.Zero) {
eu.OverallProportion = eu.Overall.Decimal.Div(report.Summary.PublicConsumption.Decimal).RoundBank(15) eu.OverallProportion = eu.Overall.Decimal.Div(report.Summary.Diluteds.Consumption.Decimal).RoundBank(15)
} else { } else {
eu.OverallProportion = decimal.Zero eu.OverallProportion = decimal.Zero
} }
} else { } else {
// 计算户表表计的摊薄内容 // 计算户表表计的摊薄内容
if report.Summary.CustomerConsumption.Decimal.Abs().GreaterThan(decimal.Zero) { if report.Summary.Customers.Consumption.Decimal.Abs().GreaterThan(decimal.Zero) {
eu.OverallProportion = eu.Overall.Decimal.Div(report.Summary.CustomerConsumption.Decimal).RoundBank(15) eu.OverallProportion = eu.Overall.Decimal.Div(report.Summary.Customers.Consumption.Decimal).RoundBank(15)
} else { } else {
eu.OverallProportion = decimal.Zero eu.OverallProportion = decimal.Zero
} }

View File

@ -632,22 +632,24 @@ func (_ReportService) AssembleReportPublicity(reportId string) (*model.Publicity
BasicFee: report.Summary.BasicFee, BasicFee: report.Summary.BasicFee,
AdjustFee: report.Summary.AdjustFee, AdjustFee: report.Summary.AdjustFee,
} }
endUserSummary := model.EndUserOverallPart{ endUserSummary := model.ConsumptionOverallPart{
Overall: report.Summary.CustomerConsumption.Decimal, Overall: report.Summary.Customers.Consumption.Decimal,
OverallPrice: report.Summary.OverallPrice.Decimal, OverallPrice: report.Summary.OverallPrice.Decimal,
OverallFee: report.Summary.CustomerConsumptionFee.Decimal, ConsumptionFee: report.Summary.Customers.ConsumptionFee.Decimal,
Critical: report.Summary.CustomerConsumptionCritical, OverallFee: report.Summary.Customers.ConsumptionFee.Decimal,
Critical: report.Summary.Customers.Critical,
CriticalPrice: report.Summary.CriticalPrice, CriticalPrice: report.Summary.CriticalPrice,
CriticalFee: report.Summary.CustomerConsumptionCriticalFee, CriticalFee: report.Summary.Customers.CriticalFee,
Peak: report.Summary.CustomerConsumptionPeak, Peak: report.Summary.Customers.Peak,
PeakPrice: report.Summary.PeakPrice, PeakPrice: report.Summary.PeakPrice,
PeakFee: report.Summary.CustomerConsumptionPeakFee, PeakFee: report.Summary.Customers.PeakFee,
Flat: report.Summary.CustomerConsumptionFlat, Flat: report.Summary.Customers.Flat,
FlatPrice: report.Summary.FlatPrice, FlatPrice: report.Summary.FlatPrice,
FlatFee: report.Summary.CustomerConsumptionFlatFee, FlatFee: report.Summary.Customers.FlatFee,
Valley: report.Summary.CustomerConsumptionValley, Valley: report.Summary.Customers.Valley,
ValleyPrice: report.Summary.ValleyPrice, ValleyPrice: report.Summary.ValleyPrice,
ValleyFee: report.Summary.CustomerConsumptionValleyFee, ValleyFee: report.Summary.Customers.ValleyFee,
Proportion: report.Summary.Customers.Proportion.Decimal,
} }
lossPart := model.LossPart{ lossPart := model.LossPart{
Quantity: report.Summary.Loss.Decimal, Quantity: report.Summary.Loss.Decimal,
@ -655,24 +657,43 @@ func (_ReportService) AssembleReportPublicity(reportId string) (*model.Publicity
ConsumptionFee: report.Summary.LossFee.Decimal, ConsumptionFee: report.Summary.LossFee.Decimal,
Proportion: report.Summary.LossProportion.Decimal, Proportion: report.Summary.LossProportion.Decimal,
} }
publicSummary := model.PublicConsumptionOverallPart{ publicSummary := model.ConsumptionOverallPart{
Overall: report.Summary.PublicConsumption.Decimal, Overall: report.Summary.Publics.Consumption.Decimal,
OverallPrice: report.Summary.OverallPrice.Decimal, OverallPrice: report.Summary.OverallPrice.Decimal,
ConsumptionFee: report.Summary.PublicConsumptionFee.Decimal, ConsumptionFee: report.Summary.Publics.ConsumptionFee.Decimal,
OverallFee: report.Summary.PublicConsumptionFee.Decimal, OverallFee: report.Summary.Publics.ConsumptionFee.Decimal,
Critical: report.Summary.PublicConsumptionCritical, Critical: report.Summary.Publics.Critical,
CriticalPrice: report.Summary.CriticalPrice, CriticalPrice: report.Summary.CriticalPrice,
CriticalFee: report.Summary.PublicConsumptionCriticalFee, CriticalFee: report.Summary.Publics.CriticalFee,
Peak: report.Summary.PublicConsumptionPeak, Peak: report.Summary.Publics.Peak,
PeakPrice: report.Summary.PeakPrice, PeakPrice: report.Summary.PeakPrice,
PeakFee: report.Summary.PublicConsumptionPeakFee, PeakFee: report.Summary.Publics.PeakFee,
Flat: report.Summary.PublicConsumptionFlat, Flat: report.Summary.Publics.Flat,
FlatPrice: report.Summary.FlatPrice, FlatPrice: report.Summary.FlatPrice,
FlatFee: report.Summary.PublicConsumptionFlatFee, FlatFee: report.Summary.Publics.FlatFee,
Valley: report.Summary.PublicConsumptionValley, Valley: report.Summary.Publics.Valley,
ValleyPrice: report.Summary.ValleyPrice, ValleyPrice: report.Summary.ValleyPrice,
ValleyFee: report.Summary.PublicConsumptionValleyFee, ValleyFee: report.Summary.Publics.ValleyFee,
Proportion: report.Summary.PublicConsumptionProportion.Decimal, Proportion: report.Summary.Publics.Proportion.Decimal,
}
dilutedSummary := model.ConsumptionOverallPart{
Overall: report.Summary.Diluteds.Consumption.Decimal,
OverallPrice: report.Summary.OverallPrice.Decimal,
ConsumptionFee: report.Summary.Diluteds.ConsumptionFee.Decimal,
OverallFee: report.Summary.Diluteds.ConsumptionFee.Decimal,
Critical: report.Summary.Diluteds.Critical,
CriticalPrice: report.Summary.CriticalPrice,
CriticalFee: report.Summary.Diluteds.CriticalFee,
Peak: report.Summary.Diluteds.Peak,
PeakPrice: report.Summary.PeakPrice,
PeakFee: report.Summary.Diluteds.PeakFee,
Flat: report.Summary.Diluteds.Flat,
FlatPrice: report.Summary.FlatPrice,
FlatFee: report.Summary.Diluteds.FlatFee,
Valley: report.Summary.Diluteds.Valley,
ValleyPrice: report.Summary.ValleyPrice,
ValleyFee: report.Summary.Diluteds.ValleyFee,
Proportion: report.Summary.Diluteds.Proportion.Decimal,
} }
otherCollection := model.OtherShouldCollectionPart{ otherCollection := model.OtherShouldCollectionPart{
MaintenanceFee: report.Summary.MaintenanceOverall, MaintenanceFee: report.Summary.MaintenanceOverall,
@ -731,6 +752,7 @@ func (_ReportService) AssembleReportPublicity(reportId string) (*model.Publicity
EndUser: endUserSummary, EndUser: endUserSummary,
Loss: lossPart, Loss: lossPart,
PublicConsumptionOverall: publicSummary, PublicConsumptionOverall: publicSummary,
DilutedConsumptionOverall: dilutedSummary,
OtherCollections: otherCollection, OtherCollections: otherCollection,
Maintenance: maintenanceFees, Maintenance: maintenanceFees,
EndUserDetails: endUsers, EndUserDetails: endUsers,