forked from free-lancers/electricity_bill_calc_service
		
	feat(report):增加推进报表抄表步骤和发布报表功能。
This commit is contained in:
		| @@ -32,6 +32,8 @@ func InitializeReportController(router *gin.Engine) { | ||||
| 	router.PUT("/report/:rid/maintenance/:mid", security.EnterpriseAuthorize, modifyWillDilutedFee) | ||||
| 	router.DELETE("/report/:rid/maintenance/:mid", security.EnterpriseAuthorize, deleteTemporaryWillDilutedFee) | ||||
| 	router.PUT("/report/:rid/step/diluted/fees", security.EnterpriseAuthorize, progressReportWillDilutedFee) | ||||
| 	router.PUT("/report/:rid/step/meter/register", security.EnterpriseAuthorize, progressEndUserRegister) | ||||
| 	router.POST("/report/:rid/publish", security.EnterpriseAuthorize, publishReport) | ||||
| } | ||||
|  | ||||
| func ensureReportBelongs(c *gin.Context, result *response.Result, requestReportId string) bool { | ||||
| @@ -358,3 +360,41 @@ func progressReportWillDilutedFee(c *gin.Context) { | ||||
| 	} | ||||
| 	result.Success("待摊薄费用编辑步骤已经完成。") | ||||
| } | ||||
|  | ||||
| func progressEndUserRegister(c *gin.Context) { | ||||
| 	result := response.NewResult(c) | ||||
| 	requestReportId := c.Param("rid") | ||||
| 	if !ensureReportBelongs(c, result, requestReportId) { | ||||
| 		return | ||||
| 	} | ||||
| 	report, err := service.ReportService.RetreiveReportIndex(requestReportId) | ||||
| 	if err != nil { | ||||
| 		result.NotFound(err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	err = service.ReportService.ProgressReportRegisterEndUser(*report) | ||||
| 	if err != nil { | ||||
| 		result.Error(http.StatusInternalServerError, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	result.Success("终端用户抄表编辑步骤已经完成。") | ||||
| } | ||||
|  | ||||
| func publishReport(c *gin.Context) { | ||||
| 	result := response.NewResult(c) | ||||
| 	requestReportId := c.Param("rid") | ||||
| 	if !ensureReportBelongs(c, result, requestReportId) { | ||||
| 		return | ||||
| 	} | ||||
| 	report, err := service.ReportService.RetreiveReportIndex(requestReportId) | ||||
| 	if err != nil { | ||||
| 		result.NotFound(err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	err = service.ReportService.PublishReport(*report) | ||||
| 	if err != nil { | ||||
| 		result.Error(http.StatusInternalServerError, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	result.Success("指定的公示报表已经发布。") | ||||
| } | ||||
|   | ||||
| @@ -343,6 +343,18 @@ func (_ReportService) ProgressReportWillDilutedFee(report model.Report) (err err | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (_ReportService) ProgressReportRegisterEndUser(report model.Report) (err error) { | ||||
| 	report.StepState.Submeter = true | ||||
| 	_, err = global.DBConn.ID(report.Id).Cols("step_state").Update(report) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (_ReportService) ProgressReportCalculate(report model.Report) (err error) { | ||||
| 	report.StepState.Calculate = true | ||||
| 	_, err = global.DBConn.ID(report.Id).Cols("step_state").Update(report) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (_ReportService) RetreiveParkEndUserMeterType(reportId string) (int, error) { | ||||
| 	var types = make([]int, 0) | ||||
| 	err := global.DBConn. | ||||
| @@ -359,3 +371,11 @@ func (_ReportService) RetreiveParkEndUserMeterType(reportId string) (int, error) | ||||
| 	} | ||||
| 	return types[0], nil | ||||
| } | ||||
|  | ||||
| func (_ReportService) PublishReport(report model.Report) (err error) { | ||||
| 	report.Published = true | ||||
| 	report.PublishedAt = lo.ToPtr(time.Now()) | ||||
| 	report.StepState.Publish = true | ||||
| 	_, err = global.DBConn.ID(report.Id).Cols("step_state", "published", "published_at").Update(report) | ||||
| 	return | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user