fix(#12):修复抄表记录与表记管理处无论选择任何表记类型只会显示全部错误
This commit is contained in:
parent
5f750dd0e0
commit
2aa3729e03
|
@ -54,7 +54,8 @@ func searchMetersWithinPark(c *fiber.Ctx) error {
|
|||
}
|
||||
keyword := c.Query("keyword")
|
||||
page := c.QueryInt("page", 1)
|
||||
meters, total, err := repository.MeterRepository.MetersIn(parkId, uint(page), &keyword)
|
||||
mtype := c.QueryInt("type", 0)
|
||||
meters, total, err := repository.MeterRepository.MetersIn(parkId, uint(page), &keyword, uint(mtype))
|
||||
if err != nil {
|
||||
meterLog.Error("无法查询指定园区下的表计信息,无法获取表计列表", zap.Error(err))
|
||||
return result.Error(http.StatusInternalServerError, err.Error())
|
||||
|
@ -349,6 +350,7 @@ func listUnboundTenementMeters(c *fiber.Ctx) error {
|
|||
func queryMeterReadings(c *fiber.Ctx) error {
|
||||
result := response.NewResult(c)
|
||||
parkId := c.Params("pid")
|
||||
mtype := c.QueryInt("type")
|
||||
if pass, err := checkParkBelongs(parkId, meterLog, c, &result); !pass {
|
||||
return err
|
||||
}
|
||||
|
@ -373,7 +375,7 @@ func queryMeterReadings(c *fiber.Ctx) error {
|
|||
endDate = &parsedDate
|
||||
}
|
||||
}
|
||||
readings, total, err := service.MeterService.SearchMeterReadings(parkId, building, startDate, endDate, uint(page), keyword)
|
||||
readings, total, err := service.MeterService.SearchMeterReadings(parkId, building, startDate, endDate, uint(page), keyword, uint(mtype))
|
||||
if err != nil {
|
||||
meterLog.Error("查询指定园区中的表计读数,无法获取表计读数列表", zap.Error(err))
|
||||
return result.Error(http.StatusInternalServerError, err.Error())
|
||||
|
|
|
@ -249,6 +249,7 @@ func (cr _CalculateRepository) GetLastPeriodReadings(rid string, meterType int16
|
|||
cr.log.Error("获取指定报表中所有涉及到的表计在核算起始日期前的最后一次读数出错", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(">>>>>>>>>>>>", readingsSql)
|
||||
fmt.Println(";;;;;;;;;;;;;;;;;;", readings)
|
||||
return readings, nil
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"electricity_bill_calc/types"
|
||||
"electricity_bill_calc/vo"
|
||||
"fmt"
|
||||
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
_ "github.com/doug-martin/goqu/v9/dialect/postgres"
|
||||
"github.com/georgysavva/scany/v2/pgxscan"
|
||||
|
@ -121,11 +120,10 @@ func (mr _MeterRepository) AllUsedMetersInReport(rid string) ([]*model.MeterDeta
|
|||
}
|
||||
|
||||
// 分页列出指定园区下的表计信息
|
||||
func (mr _MeterRepository) MetersIn(pid string, page uint, keyword *string) ([]*model.MeterDetail, int64, error) {
|
||||
func (mr _MeterRepository) MetersIn(pid string, page uint, keyword *string, mtype uint) ([]*model.MeterDetail, int64, error) {
|
||||
mr.log.Info("分页列出指定园区下的表计信息", zap.String("park id", pid), zap.Uint("page", page), zap.String("keyword", tools.DefaultTo(keyword, "")))
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
|
||||
meterQuery := mr.ds.
|
||||
From(goqu.T("meter_04kv").As("m")).
|
||||
LeftJoin(goqu.T("park_building").As("b"), goqu.On(goqu.I("m.building").Eq(goqu.I("b.id")))).
|
||||
|
@ -135,6 +133,7 @@ func (mr _MeterRepository) MetersIn(pid string, page uint, keyword *string) ([]*
|
|||
Where(
|
||||
goqu.I("m.park_id").Eq(pid),
|
||||
goqu.I("m.detached_at").IsNull(),
|
||||
goqu.I("m.meter_type").Eq(mtype),
|
||||
)
|
||||
countQuery := mr.ds.
|
||||
From(goqu.T("meter_04kv").As("m")).
|
||||
|
@ -142,6 +141,7 @@ func (mr _MeterRepository) MetersIn(pid string, page uint, keyword *string) ([]*
|
|||
Where(
|
||||
goqu.I("m.park_id").Eq(pid),
|
||||
goqu.I("m.detached_at").IsNull(),
|
||||
goqu.I("m.meter_type").Eq(mtype),
|
||||
)
|
||||
|
||||
if keyword != nil && len(*keyword) > 0 {
|
||||
|
@ -174,11 +174,11 @@ func (mr _MeterRepository) MetersIn(pid string, page uint, keyword *string) ([]*
|
|||
mr.log.Error("查询表计信息失败", zap.Error(err))
|
||||
return make([]*model.MeterDetail, 0), 0, err
|
||||
}
|
||||
|
||||
if err := pgxscan.Get(ctx, global.DB, &total, countSql, countArgs...); err != nil {
|
||||
mr.log.Error("查询表计数量失败", zap.Error(err))
|
||||
return make([]*model.MeterDetail, 0), 0, err
|
||||
}
|
||||
|
||||
return meters, total, nil
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,6 @@ func (mr _MeterRepository) ListMetersByIDs(pid string, ids []string) ([]*model.M
|
|||
mr.log.Error("查询表计信息失败", zap.Error(err))
|
||||
return make([]*model.MeterDetail, 0), err
|
||||
}
|
||||
|
||||
return meters, nil
|
||||
}
|
||||
|
||||
|
@ -777,24 +776,28 @@ func (mr _MeterRepository) ListUnboundTenementMeters(uid string, pid *string, ke
|
|||
}
|
||||
|
||||
// 查询指定园区中的符合条件的抄表记录
|
||||
func (mr _MeterRepository) ListMeterReadings(pid string, keyword *string, page uint, start, end *types.Date, buidling *string) ([]*model.MeterReading, int64, error) {
|
||||
func (mr _MeterRepository) ListMeterReadings(pid string, keyword *string, page uint, start, end *types.Date, buidling *string, mtype uint) ([]*model.MeterReading, int64, error) {
|
||||
mr.log.Info("查询指定园区中的符合条件的抄表记录", zap.String("park id", pid), zap.String("keyword", tools.DefaultTo(keyword, "")), zap.Uint("page", page), logger.DateFieldp("start", start), logger.DateFieldp("end", end), zap.String("building", tools.DefaultTo(buidling, "")))
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
|
||||
readingQuery := mr.ds.
|
||||
From(goqu.T("meter_reading").As("r")).
|
||||
LeftJoin(goqu.T("meter_04kv").As("m"), goqu.On(goqu.I("r.meter_id").Eq(goqu.I("m.code")), goqu.I("m.park_id").Eq(goqu.I("r.park_id")))).
|
||||
LeftJoin(goqu.T("meter_04kv").As("m"), goqu.On(goqu.I("r.meter_id").Eq(goqu.I("m.code")),
|
||||
goqu.I("m.park_id").Eq(goqu.I("r.park_id")))).
|
||||
Select("r.*").
|
||||
Where(
|
||||
goqu.I("r.park_id").Eq(pid),
|
||||
goqu.I("m.meter_type").Eq(mtype),
|
||||
)
|
||||
countQuery := mr.ds.
|
||||
From(goqu.T("meter_reading").As("r")).
|
||||
LeftJoin(goqu.T("meter_04kv").As("m"), goqu.On(goqu.I("r.meter_id").Eq(goqu.I("m.code")), goqu.I("m.park_id").Eq(goqu.I("r.park_id")))).
|
||||
LeftJoin(goqu.T("meter_04kv").As("m"), goqu.On(goqu.I("r.meter_id").Eq(goqu.I("m.code")),
|
||||
goqu.I("m.park_id").Eq(goqu.I("r.park_id")))).
|
||||
Select(goqu.COUNT("*")).
|
||||
Where(
|
||||
goqu.I("r.park_id").Eq(pid),
|
||||
goqu.I("m.meter_type").Eq(mtype),
|
||||
)
|
||||
|
||||
if keyword != nil && len(*keyword) > 0 {
|
||||
|
@ -859,7 +862,6 @@ func (mr _MeterRepository) ListMeterReadings(pid string, keyword *string, page u
|
|||
mr.log.Error("查询抄表记录数量失败", zap.Error(err))
|
||||
return make([]*model.MeterReading, 0), 0, err
|
||||
}
|
||||
|
||||
return readings, total, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -64,14 +64,14 @@ func MainCalculateProcess(rid string) error {
|
|||
}
|
||||
|
||||
// 计算所有表计的总电量
|
||||
_ = TotalConsumptionCalculate(tenementReports, summary)
|
||||
parkTotal := TotalConsumptionCalculate(tenementReports, summary)
|
||||
|
||||
// 计算线损以及调整线损
|
||||
//err = LossCalculate(report, parkMetersReports, &parkTotal, &summary)
|
||||
//if err != nil {
|
||||
// fmt.Println("9", err)
|
||||
// return err
|
||||
//}
|
||||
//计算线损以及调整线损
|
||||
err = LossCalculate(report, parkMetersReports, &parkTotal, &summary)
|
||||
if err != nil {
|
||||
fmt.Println("9", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// 计算所有已经启用的商铺面积总和,仅计算所有未迁出的商户的所有表计对应的商铺面积。
|
||||
_, err = EnabledAreaCalculate(&tenementReports, &summary)
|
||||
|
@ -79,14 +79,13 @@ func MainCalculateProcess(rid string) error {
|
|||
fmt.Println("10", err)
|
||||
return err
|
||||
}
|
||||
// 计算基本电费分摊、调整电费分摊、电费摊薄单价。
|
||||
err = CalculatePrices(&summary)
|
||||
if err != nil {
|
||||
fmt.Println("11", err)
|
||||
return err
|
||||
}
|
||||
fmt.Println("计算数据读取完成")
|
||||
// 计算基本电费分摊、调整电费分摊、电费摊薄单价。
|
||||
err = CalculatePrices(&summary)
|
||||
// 收集目前所有已经处理的表计,统一对其进行摊薄计算。
|
||||
meters, err := CollectMeters(tenementReports, poolingMetersReports, parkMetersReports)
|
||||
if err != nil {
|
||||
|
|
|
@ -587,7 +587,7 @@ func (ms _MeterService) UnbindMeter(pid, masterMeter string, slaveMeters []strin
|
|||
}
|
||||
|
||||
// 查询符合条件的表计读数记录
|
||||
func (ms _MeterService) SearchMeterReadings(pid string, building *string, start, end *types.Date, page uint, keyword *string) ([]*model.DetailedMeterReading, int64, error) {
|
||||
func (ms _MeterService) SearchMeterReadings(pid string, building *string, start, end *types.Date, page uint, keyword *string, mtype uint) ([]*model.DetailedMeterReading, int64, error) {
|
||||
ms.log.Info(
|
||||
"查询符合条件的表计读数记录",
|
||||
zap.String("park id", pid),
|
||||
|
@ -597,7 +597,7 @@ func (ms _MeterService) SearchMeterReadings(pid string, building *string, start,
|
|||
zap.Uint("page", page),
|
||||
zap.Stringp("keyword", keyword),
|
||||
)
|
||||
readings, total, err := repository.MeterRepository.ListMeterReadings(pid, keyword, page, start, end, building)
|
||||
readings, total, err := repository.MeterRepository.ListMeterReadings(pid, keyword, page, start, end, building, mtype)
|
||||
if err != nil {
|
||||
ms.log.Error("无法查询符合条件的表计读数记录。", zap.Error(err))
|
||||
return make([]*model.DetailedMeterReading, 0), 0, err
|
||||
|
|
|
@ -12,9 +12,9 @@ Server:
|
|||
ReadTimeout: 60
|
||||
WriteTimeout: 60
|
||||
Redis:
|
||||
Host: 127.0.0.1
|
||||
Host: 192.168.88.129
|
||||
Port: 6379
|
||||
Password:
|
||||
Password: 123456
|
||||
DB: 1
|
||||
Service:
|
||||
MaxSessionLife: 2h
|
||||
|
|
Loading…
Reference in New Issue
Block a user