fix(meter): 修复:更换电表时的修改逻辑
This commit is contained in:
parent
3d918eea85
commit
b50eabbca6
|
@ -202,7 +202,12 @@ func replaceMeter(c *fiber.Ctx) error {
|
|||
meterLog.Error("无法更换系统中的表计,无法解析表计更换表单", zap.Error(err))
|
||||
return result.NotAccept(err.Error())
|
||||
}
|
||||
return nil
|
||||
err := service.MeterService.ReplaceMeter(parkId, meterId, &replacementForm.OldReading, replacementForm.NewMeter.Code, replacementForm.NewMeter.Ratio, &replacementForm.NewMeter.Reading)
|
||||
if err != nil {
|
||||
meterLog.Error("更换表计出错", zap.Error(err))
|
||||
return result.Error(500, err.Error())
|
||||
}
|
||||
return result.Success("更换成功")
|
||||
}
|
||||
|
||||
// 列出指定公摊表计下的所有关联表计
|
||||
|
|
|
@ -176,124 +176,6 @@ func CalculateTenementConsumptions(meters MeterMap) (map[string]decimal.Decimal,
|
|||
return consumptions, nil
|
||||
}
|
||||
|
||||
/*
|
||||
/// 计算商户表计的公摊分摊
|
||||
|
||||
func CalculateTenementPoolings(report model.ReportIndex, summary calculate.Summary, meters MeterMap, meterRelations []model.MeterRelation) error {
|
||||
for _, meter := range meters {
|
||||
if meter.Detail.MeterType == model.METER_INSTALLATION_TENEMENT {
|
||||
switch report.PublicPooled {
|
||||
case model.POOLING_MODE_AREA:
|
||||
for _, relation := range meterRelations {
|
||||
if relation.SlaveMeter == meter.Code {
|
||||
key := Key{
|
||||
Code: relation.MasterMeter,
|
||||
}
|
||||
parentMeter, ok := meters[key]
|
||||
if !ok {
|
||||
return errors.New("父级表记未找到")
|
||||
}
|
||||
|
||||
poolingAmount := meter.Detail.Area.Decimal.Div(parentMeter.CoveredArea).
|
||||
Mul(meter.SharedPoolingProportion).
|
||||
Mul(parentMeter.Overall.Amount).Mul(summary.Overall.Price)
|
||||
|
||||
pooling := calculate.Pooling{
|
||||
Code: parentMeter.Code,
|
||||
Detail: model.ConsumptionUnit{
|
||||
Amount: poolingAmount,
|
||||
Fee: poolingAmount.Mul(summary.Overall.Price),
|
||||
Price: summary.Overall.Price,
|
||||
//后续debug此处需要判断,
|
||||
Proportion: poolingAmount.Div(parentMeter.Overall.Amount),
|
||||
},
|
||||
}
|
||||
|
||||
pooling := calculate.Pooling{
|
||||
Code: parentMeter.Code,
|
||||
Detail: model.ConsumptionUnit{
|
||||
Amount: poolingAmount,
|
||||
Fee: poolingAmount.Mul(summary.Overall.Price),
|
||||
Price: summary.Overall.Price,
|
||||
Proportion: poolingAmount.Div(parentMeter.Overall.Amount),
|
||||
},
|
||||
}
|
||||
meter.PooledPublic = &ConsumptionUnit{
|
||||
Amount: poolingAmount,
|
||||
Fee: new(big.Rat).Mul(poolingAmount, summary.Overall.Price),
|
||||
Price: summary.Overall.Price,
|
||||
Proportion: new(big.Rat).Quo(poolingAmount, parentAmount),
|
||||
}
|
||||
|
||||
meter.Poolings = append(meter.Poolings, pooling)
|
||||
}
|
||||
}
|
||||
|
||||
case Consumption:
|
||||
for _, relation := range meterRelations {
|
||||
if relation.SlaveMeter == meter.Code {
|
||||
parentMeter, ok := meters[relation.MasterMeter]
|
||||
if !ok {
|
||||
return errors.New("parent meter not found")
|
||||
}
|
||||
|
||||
if parentMeter.Overall.Amount.Cmp(new(big.Rat)) == 0 {
|
||||
poolingAmount := new(big.Rat)
|
||||
parentAmount := new(big.Rat)
|
||||
|
||||
pooling := &Pooling{
|
||||
Code: parentMeter.Code,
|
||||
Detail: &ConsumptionUnit{
|
||||
Amount: poolingAmount,
|
||||
Fee: new(big.Rat),
|
||||
Price: summary.Overall.Price,
|
||||
Proportion: new(big.Rat),
|
||||
},
|
||||
}
|
||||
|
||||
meter.PooledPublic = &ConsumptionUnit{
|
||||
Amount: poolingAmount,
|
||||
Fee: new(big.Rat),
|
||||
Price: summary.Overall.Price,
|
||||
Proportion: new(big.Rat),
|
||||
}
|
||||
|
||||
meter.Poolings = append(meter.Poolings, pooling)
|
||||
} else {
|
||||
poolingAmount := new(big.Rat).Mul(meter.Overall.Amount, new(big.Rat).Quo(parentMeter.Overall.Amount, parentMeter.Overall.Amount))
|
||||
parentAmount := parentMeter.Overall.Amount
|
||||
|
||||
pooling := &Pooling{
|
||||
Code: parentMeter.Code,
|
||||
Detail: &ConsumptionUnit{
|
||||
Amount: poolingAmount,
|
||||
Fee: new(big.Rat).Mul(poolingAmount, summary.Overall.Price),
|
||||
Price: summary.Overall.Price,
|
||||
Proportion: new(big.Rat).Quo(poolingAmount, parentAmount),
|
||||
},
|
||||
}
|
||||
|
||||
meter.PooledPublic = &ConsumptionUnit{
|
||||
Amount: poolingAmount,
|
||||
Fee: new(big.Rat).Mul(poolingAmount, summary.Overall.Price),
|
||||
Price: summary.Overall.Price,
|
||||
Proportion: new(big.Rat).Quo(poolingAmount, parentAmount),
|
||||
}
|
||||
|
||||
meter.Poolings = append(meter.Poolings, pooling)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
// handle other pooling modes...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
// 计算商户表计的公摊分摊
|
||||
func CalculateTenementPoolings(report model.ReportIndex, summary calculate.Summary, meters MeterMap, meterRelations []model.MeterRelation) error {
|
||||
|
||||
|
|
|
@ -777,3 +777,10 @@ func (ms _MeterService) BatchImportReadings(pid string, file *multipart.FileHead
|
|||
}
|
||||
return make([]excel.ExcelAnalysisError, 0), nil
|
||||
}
|
||||
|
||||
//// 更换系统中的表计
|
||||
//func (ms _MeterService) ReplaceMeter(pid string, oldMeterCode string, oldMeterReading vo.MeterReadingForm,
|
||||
// newMeterCode string, newMeterRatio decimal.Decimal, newMeterDisplayRatio decimal.Decimal,
|
||||
// newMeterReading vo.NewMeterForReplacingForm) {
|
||||
//
|
||||
//}
|
Loading…
Reference in New Issue
Block a user