[计算相关]fix 计算线损以及调整线损参数错误。new 计算所有已经启用的商铺面积总和,仅计算所有未迁出的商户的所有表计对应的商铺面积。(完成)
This commit is contained in:
parent
6b3d3dd93c
commit
5710a640e8
@ -42,8 +42,8 @@ func removeDuplicates(meters []calculate.Meter) []calculate.Meter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//计算线损以及调整线损
|
//计算线损以及调整线损
|
||||||
func LossCalculate(report *model.ReportIndex, Public []calculate.Meter,
|
func LossCalculate(report *model.ReportIndex, Public *[]calculate.Meter,
|
||||||
publicTotal decimal.Decimal, summary calculate.Summary) error {
|
publicTotal *decimal.Decimal, summary *calculate.Summary) error {
|
||||||
summary.Loss = summary.Overall.Amount.Sub(summary.TotalConsumption)
|
summary.Loss = summary.Overall.Amount.Sub(summary.TotalConsumption)
|
||||||
|
|
||||||
var summaryAmount decimal.Decimal
|
var summaryAmount decimal.Decimal
|
||||||
@ -56,6 +56,7 @@ func LossCalculate(report *model.ReportIndex, Public []calculate.Meter,
|
|||||||
summary.LossProportion = summary.Loss.Div(summaryAmount)
|
summary.LossProportion = summary.Loss.Div(summaryAmount)
|
||||||
|
|
||||||
var authorizedLossRate decimal.Decimal
|
var authorizedLossRate decimal.Decimal
|
||||||
|
//TODO: 2023.08.04 在此发现reportIndex结构体与数据库中的report表字段不对应缺少两个相应字段,在此添加的,如在其他地方有错误优先查找这里
|
||||||
if summary.LossProportion.InexactFloat64() > report.AuthorizedLossRate {
|
if summary.LossProportion.InexactFloat64() > report.AuthorizedLossRate {
|
||||||
authorizedLossRate = summary.LossProportion
|
authorizedLossRate = summary.LossProportion
|
||||||
} else {
|
} else {
|
||||||
@ -75,7 +76,7 @@ func LossCalculate(report *model.ReportIndex, Public []calculate.Meter,
|
|||||||
return errors.New("园区公共表计的电量总和为非正值,或者园区未设置公共表计,无法计算核定线损")
|
return errors.New("园区公共表计的电量总和为非正值,或者园区未设置公共表计,无法计算核定线损")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, meter := range Public {
|
for _, meter := range *Public {
|
||||||
amountProportion := meter.Overall.Amount.InexactFloat64() / publicTotal.InexactFloat64()
|
amountProportion := meter.Overall.Amount.InexactFloat64() / publicTotal.InexactFloat64()
|
||||||
adjustAmount := differentialLoss.InexactFloat64() * decimal.NewFromFloat(-1.0).InexactFloat64()
|
adjustAmount := differentialLoss.InexactFloat64() * decimal.NewFromFloat(-1.0).InexactFloat64()
|
||||||
meter.AdjustLoss = model.ConsumptionUnit{
|
meter.AdjustLoss = model.ConsumptionUnit{
|
||||||
@ -87,3 +88,26 @@ func LossCalculate(report *model.ReportIndex, Public []calculate.Meter,
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算已经启用的商铺面积和
|
||||||
|
func EnabledAreaCalculate(tenements *[]calculate.PrimaryTenementStatistics, summary *calculate.Summary) error {
|
||||||
|
var areaMeters []calculate.Meter
|
||||||
|
for _, t := range *tenements {
|
||||||
|
areaMeters = append(areaMeters, t.Meters...)
|
||||||
|
}
|
||||||
|
// 去重
|
||||||
|
uniqueAreaMeters := make(map[string]calculate.Meter)
|
||||||
|
for _, meter := range areaMeters {
|
||||||
|
uniqueAreaMeters[meter.Code] = meter
|
||||||
|
}
|
||||||
|
var areaTotal decimal.Decimal
|
||||||
|
for _, meter := range uniqueAreaMeters {
|
||||||
|
areaTotal = areaTotal.Add(meter.Detail.Area.Decimal)
|
||||||
|
}
|
||||||
|
if summary != nil {
|
||||||
|
summary.OverallArea = areaTotal
|
||||||
|
} else {
|
||||||
|
return errors.New("summary is nil")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -65,12 +65,19 @@ func MainCalculateProcess(rid string) {
|
|||||||
//计算所有表计的总电量
|
//计算所有表计的总电量
|
||||||
parkTotal := TotalConsumptionCalculate(tenementReports, summary)
|
parkTotal := TotalConsumptionCalculate(tenementReports, summary)
|
||||||
|
|
||||||
err = LossCalculate(report, parkMetersReports, parkTotal, summary)
|
// 计算线损以及调整线损
|
||||||
|
err = LossCalculate(report, &parkMetersReports, &parkTotal, &summary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("9", err)
|
fmt.Println("9", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = EnabledAreaCalculate(&tenementReports, &summary)
|
||||||
|
if err != nil{
|
||||||
|
fmt.Println("10",err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(meterRelations, poolingMetersReports, parkMetersReports, parkTotal)
|
fmt.Println(meterRelations, poolingMetersReports, parkMetersReports, parkTotal)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user