enhance(god):清除报表中不同部分的时候同时重置报表的进度状态。

This commit is contained in:
徐涛 2022-09-07 14:04:52 +08:00
parent 466d21e8b4
commit 62a9fec43f
3 changed files with 48 additions and 6 deletions

View File

@ -436,7 +436,12 @@ func searchReports(c *gin.Context) {
result.NotAccept("查询参数[page]格式不正确。")
return
}
records, totalItems, err := service.ReportService.SearchReport(requestUser, requestPark, requestKeyword, requestPeriod, requestPage)
requestAllReports, err := strconv.ParseBool(c.DefaultQuery("all", "false"))
if err != nil {
result.NotAccept("查询参数[all]格式不正确。")
return
}
records, totalItems, err := service.ReportService.SearchReport(requestUser, requestPark, requestKeyword, requestPeriod, requestPage, !requestAllReports)
if err != nil {
result.NotFound(err.Error())
return

View File

@ -67,16 +67,27 @@ func (_GodModeService) resetReportSummary(tx *xorm.Session, reportId string) (bo
var summary = &model.ReportSummary{
ReportId: reportId,
}
rows, err := tx.ID(reportId).AllCols().NoAutoCondition().Update(summary)
_, err := tx.ID(reportId).AllCols().NoAutoCondition().Update(summary)
if err != nil {
tx.Rollback()
return false, err
}
var report = new(model.Report)
_, err = tx.ID(reportId).NoAutoCondition().Unscoped().Get(report)
if err != nil {
tx.Rollback()
return false, err
}
report.StepState.Summary = false
rows, err := tx.ID(reportId).Cols("step_state").NoAutoCondition().Update(report)
if err != nil {
tx.Rollback()
}
return rows >= 0, err
}
func (_GodModeService) flushReportMaintenances(tx *xorm.Session, reportId string) (bool, error) {
rows, err := tx.
_, err := tx.
Where(builder.Eq{"report_id": reportId}).
NoAutoCondition().
Delete(new(model.WillDilutedFee))
@ -84,6 +95,17 @@ func (_GodModeService) flushReportMaintenances(tx *xorm.Session, reportId string
tx.Rollback()
return false, err
}
var report = new(model.Report)
_, err = tx.ID(reportId).NoAutoCondition().Unscoped().Get(report)
if err != nil {
tx.Rollback()
return false, err
}
report.StepState.WillDiluted = false
rows, err := tx.ID(reportId).Cols("step_state").NoAutoCondition().Update(report)
if err != nil {
tx.Rollback()
}
return rows >= 0, err
}
@ -169,7 +191,18 @@ func (_GodModeService) resetEndUserRecords(tx *xorm.Session, reportId string) (b
return false, err
}
}
return true, nil
var report = new(model.Report)
_, err = tx.ID(reportId).NoAutoCondition().Unscoped().Get(report)
if err != nil {
tx.Rollback()
return false, err
}
report.StepState.Submeter = false
rows, err := tx.ID(reportId).Cols("step_state").NoAutoCondition().Update(report)
if err != nil {
tx.Rollback()
}
return rows >= 0, nil
}
type ReportPeriod struct {

View File

@ -430,10 +430,14 @@ func (_ReportService) PublishReport(report model.Report) (err error) {
return
}
func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword string, requestPeriod *time.Time, requestPage int) ([]model.JoinedReportForWithdraw, int64, error) {
func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword string, requestPeriod *time.Time, requestPage int, onlyPublished bool) ([]model.JoinedReportForWithdraw, int64, error) {
var conditions = make([]string, 0)
conditions = append(conditions, strconv.Itoa(requestPage))
cond := builder.NewCond().And(builder.Eq{"r.published": true})
cond := builder.NewCond()
if onlyPublished {
cond = cond.And(builder.Eq{"r.published": true})
}
conditions = append(conditions, strconv.FormatBool(onlyPublished))
if len(requestUser) > 0 {
cond = cond.And(builder.Eq{"u.id": requestUser})
conditions = append(conditions, requestUser)