summary_evaluation_controller.go 12.0 KB
package controllers

import (
	"github.com/linmadan/egglib-go/core/application"
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/service"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)

type SummaryEvaluationController struct {
	beego.BaseController
}

func (c *SummaryEvaluationController) GetExecutorCycleList() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryCycleList{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.UserId = int(userReq.UserId)
	paramReq.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetExecutorCycleList(paramReq)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetMenu() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryMenu{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	paramReq.UserId = int(userReq.UserId)
	data, err := srv.GetMenu(paramReq)
	c.Response(data, err)

}

// 获取自评详情
func (c *SummaryEvaluationController) GetEvaluationSelf() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryEvaluation{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetEvaluationSelfByCycle(paramReq)
	c.Response(data, err)

}

// EditEvaluationSelf 编辑综合自评
func (c *SummaryEvaluationController) EditEvaluationSelf() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.EditEvaluationValue{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	paramReq.ExecutorId = int(userReq.UserId)
	data, err := srv.EditEvaluationSelf(paramReq)
	c.Response(data, err)

}

// GetTargetUserCycleList 根据被评估人获取周期列表
func (c *SummaryEvaluationController) GetTargetUserCycleList() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryCycleList{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	data, err := srv.GetTargetUserCycleList(paramReq)
	c.Response(data, err)
}

// CountEvaluationSelfLevel 获取自评小结
func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryEvaluation{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	data, err := srv.CountEvaluationSelfLevel(paramReq)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) Evaluation360List() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluation360List{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	in.UserId = int(userReq.UserId)
	data, err := srv.Evaluation360List(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetEvaluation360() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluation360My{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	in.UserId = int(userReq.UserId)
	data, err := srv.GetEvaluation360(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetEvaluation360Complete() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluation360{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetEvaluation360Complete(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) EditEvaluation360() {
	srv := service.NewSummaryEvaluationService()
	in := &command.EditEvaluationValue{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	in.ExecutorId = int(userReq.UserId)
	data, err := srv.EditEvaluation360(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) EvaluationHRBPList() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluationHRList{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	in.UserId = int(userReq.UserId)
	data, err := srv.EvaluationHRBPList(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetEvaluationHRBP() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluationHRBPMy{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetEvaluationHRBP(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) GetEvaluationHRBPComplete() {
	srv := service.NewSummaryEvaluationService()
	in := &command.QueryEvaluationHRBP{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetEvaluationHRBPComplete(in)
	c.Response(data, err)
}

func (c *SummaryEvaluationController) EditEvaluationHRBP() {
	srv := service.NewSummaryEvaluationService()
	in := &command.EditEvaluationValue{}
	err := c.BindJSON(in)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	in.CompanyId = int(userReq.CompanyId)
	in.ExecutorId = int(userReq.UserId)
	data, err := srv.EditEvaluationHRBP(in)
	c.Response(data, err)
}

// 获取上级评估
func (c *SummaryEvaluationController) GetEvaluationSuper() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryEvaluationSuper{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetEvaluationSuper(param)
	c.Response(data, err)
}

// 编辑上级评估
func (c *SummaryEvaluationController) EditEvaluationSuper() {
	srv := service.NewSummaryEvaluationService()
	param := &command.EditEvaluationValue{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.CompanyId = int(userReq.CompanyId)
	param.ExecutorId = int(userReq.UserId)
	data, err := srv.EditEvaluationSuper(param)
	c.Response(data, err)
}

// 执行人的上级评估列表
func (c *SummaryEvaluationController) ListExecutorEvaluationSuper() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryExecutorEvaluationList{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.CompanyId = int(userReq.CompanyId)
	param.ExecutorId = int(userReq.UserId)
	data, err := srv.ListExecutorEvaluationSuper(param)
	c.Response(data, err)
}

// ConfirmScoreEvaluation 员工确认评估分数
func (c *SummaryEvaluationController) ConfirmScoreEvaluation() {
	srv := service.NewSummaryEvaluationService()
	param := &command.ConfirmScore{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.UserId = int(userReq.UserId)
	err = srv.ConfirmScoreEvaluation(param)
	c.Response(nil, err)
}

// GetTargetEvaluationResult 按照周期和被评估的人 获取考核结果
func (c *SummaryEvaluationController) GetTargetEvaluationResult() {
	srv := service.NewSummaryEvaluationService()
	paramReq := &command.QueryEvaluation{}
	err := c.BindJSON(paramReq)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	paramReq.CompanyId = int(userReq.CompanyId)
	data, err := srv.GetTargetEvaluationResult(paramReq)
	c.Response(data, err)
}

// 按周期获取上级评估列表
func (c *SummaryEvaluationController) ListAllEvaluationFinish() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryEvaluationList{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.CompanyId = int(userReq.CompanyId)
	param.UserId = int(userReq.UserId)
	data, err := srv.ListAllEvaluationFinish(param)
	c.Response(data, err)
}

// 按周期 导出上级评估列表
func (c *SummaryEvaluationController) ExportAllEvaluationFinish() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryEvaluationList{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	userReq := middlewares.GetUser(c.Ctx)
	param.UserId = int(userReq.UserId)
	param.CompanyId = int(userReq.CompanyId)
	data, err := srv.ExportAllEvaluationFinish(param)
	if err != nil {
		c.Response(nil, err)
		return
	}
	c.Ctx.Output.Header("Content-Disposition", "attachment;filename=周期评估")
	c.Ctx.Output.Header("Content-Description", "FileTransfer")
	c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
	c.Ctx.Output.Header("Content-Transfer-Encoding", "binary")
	c.Ctx.Output.Header("Expires", "0")
	data.Write(c.Ctx.ResponseWriter)
}

// 获取现在待执行的综合自评
func (c *SummaryEvaluationController) ListExecutorEvaluationSelf() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryExecutorEvaluationList{}
	userReq := middlewares.GetUser(c.Ctx)
	param.CompanyId = int(userReq.CompanyId)
	param.ExecutorId = int(userReq.UserId)
	data, err := srv.ListExecutorNowEvaluationSelf(param)
	c.Response(data, err)
}

// 获取现在待执行的综合自评
func (c *SummaryEvaluationController) SearchAssessRemark() {
	srv := service.NewSummaryEvaluationService()
	param := &command.QueryAssessRemark{}
	err := c.BindJSON(param)
	if err != nil {
		e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
		c.Response(nil, e)
		return
	}
	data, err := srv.SearchAssessRemark(param)
	c.Response(data, err)
}