forked from free-lancers/electricity_bill_calc_service
fix(#12):修复抄表记录与表记管理处无论选择任何表记类型只会显示全部错误
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user