You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
5.7 KiB
135 lines
5.7 KiB
|
4 years ago
|
package evaluation
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel"
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
//新定性考核列表
|
||
|
|
func (e *EvaluationInterface) NewQualitative(c *gin.Context) {
|
||
|
|
isTrue, userCont := commonus.ClientIdentity()
|
||
|
|
if isTrue != true {
|
||
|
|
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var requestData NewQualType
|
||
|
|
err := c.ShouldBindJSON(&requestData)
|
||
|
|
if err != nil {
|
||
|
|
// response.Result(102, err, "数据获取失败!", c)
|
||
|
|
// return
|
||
|
|
}
|
||
|
|
var qualEvaList []NewQualOutList
|
||
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("DISTINCT qe_group,qe_accept_evaluation,qe_dimension,qe_target,et_title").Joins("left join evaluationtarget on evaluationtarget.et_id = qualitative_evaluation.qe_target").Where("`qe_type` = 1 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key)
|
||
|
|
if requestData.Group != "" {
|
||
|
|
gormDb = gormDb.Where("`qe_group` = ?", requestData.Group)
|
||
|
|
}
|
||
|
|
if requestData.Department != "" {
|
||
|
|
gormDb = gormDb.Where("`qe_accept_evaluation` = ?", requestData.Department)
|
||
|
|
}
|
||
|
|
if requestData.Title != "" {
|
||
|
|
gormDb = gormDb.Where("evaluationtarget.et_title LIKE ?", "%"+requestData.Title+"%")
|
||
|
|
}
|
||
|
|
errList := gormDb.Order("qe_group ASC,qe_accept_evaluation ASC,qe_dimension ASC,qe_target ASC").Find(&qualEvaList).Error
|
||
|
|
if errList != nil || len(qualEvaList) < 1 {
|
||
|
|
response.Result(102, isTrue, "您没有要参加的考核项目!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var outContList []NewQualOutList
|
||
|
|
for _, v := range qualEvaList {
|
||
|
|
var outCont NewQualOutList
|
||
|
|
outCont.Group = v.Group
|
||
|
|
_, groupCont := commonus.GetGroupCont(v.Group)
|
||
|
|
outCont.GroupName = groupCont.Name
|
||
|
|
outCont.Department = v.Department
|
||
|
|
_, departCont := commonus.GetBranchFactory(v.Department)
|
||
|
|
outCont.DepartmentName = departCont.Name
|
||
|
|
outCont.Dimension = v.Dimension
|
||
|
|
dimensionCont, _ := commonus.GetDutyClassInfo(v.Dimension)
|
||
|
|
outCont.DimensionName = dimensionCont.Title
|
||
|
|
outCont.Target = v.Target
|
||
|
|
outCont.Title = v.Title
|
||
|
|
outContList = append(outContList, outCont)
|
||
|
|
}
|
||
|
|
response.Result(0, outContList, "获取成功!", c)
|
||
|
|
}
|
||
|
|
|
||
|
|
//获取定性考核详细指标
|
||
|
|
func (e *EvaluationInterface) NewGetQualDetailedTarget(c *gin.Context) {
|
||
|
|
isTrue, userCont := commonus.ClientIdentity()
|
||
|
|
if isTrue != true {
|
||
|
|
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var requestData NewQualDetailTar
|
||
|
|
err := c.ShouldBindJSON(&requestData)
|
||
|
|
if err != nil {
|
||
|
|
response.Result(102, err, "数据获取失败!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if requestData.Group == "" || requestData.Department == "" || requestData.Target == "" {
|
||
|
|
response.Result(103, err, "参数错误!请检查您的输入", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var qualEvaList []NewQualDetailOutList
|
||
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id,qe_group,qe_accept_evaluation,qe_dimension,qe_target,et_title,qe_detailed_target,dt_title,qe_target_sun").Joins("left join evaluationtarget on evaluationtarget.et_id = qualitative_evaluation.qe_target").Joins("left join detailed_target on detailed_target.dt_id = qualitative_evaluation.qe_detailed_target").Where("`qe_type` = 1 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key)
|
||
|
|
gormDb = gormDb.Where("`qe_group` = ?", requestData.Group).Where("`qe_accept_evaluation` = ?", requestData.Department).Where("`qe_target` = ?", requestData.Target)
|
||
|
|
errList := gormDb.Order("qe_group ASC,qe_accept_evaluation ASC,qe_dimension ASC,qe_target ASC,qe_detailed_target ASC").Find(&qualEvaList).Error
|
||
|
|
if errList != nil || len(qualEvaList) < 1 {
|
||
|
|
response.Result(102, isTrue, "您没有要参加的考核项目!", c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var outContList []NewQualDetailOutList
|
||
|
|
for _, v := range qualEvaList {
|
||
|
|
detaiTargetCont, _ := commonus.GetDetailedTargetInfo(v.DetailedTargetId)
|
||
|
|
|
||
|
|
var outCont NewQualDetailOutList
|
||
|
|
outCont.Id = v.Id
|
||
|
|
outCont.Group = v.Group
|
||
|
|
_, groupCont := commonus.GetGroupCont(v.Group)
|
||
|
|
outCont.GroupName = groupCont.Name
|
||
|
|
outCont.Department = v.Department
|
||
|
|
_, departCont := commonus.GetBranchFactory(v.Department)
|
||
|
|
outCont.DepartmentName = departCont.Name
|
||
|
|
outCont.Dimension = v.Dimension
|
||
|
|
dimensionCont, _ := commonus.GetDutyClassInfo(v.Dimension)
|
||
|
|
outCont.DimensionName = dimensionCont.Title
|
||
|
|
outCont.Target = v.Target
|
||
|
|
outCont.Title = v.Title
|
||
|
|
|
||
|
|
//子栏目
|
||
|
|
targetCont, _ := commonus.GetQualitativeTargetInfo(v.TargetSun)
|
||
|
|
outCont.Target = v.TargetSun
|
||
|
|
outCont.TargetSunId = strconv.FormatInt(v.TargetSun, 10)
|
||
|
|
outCont.TargetSunName = targetCont.Title
|
||
|
|
|
||
|
|
outCont.DetailedTargetId = v.DetailedTargetId
|
||
|
|
outCont.DetailedTargetTitle = v.DetailedTargetTitle
|
||
|
|
outCont.DetailedTargetCont = detaiTargetCont.Content
|
||
|
|
outCont.AddReduce = detaiTargetCont.AddReduce
|
||
|
|
outCont.Company = detaiTargetCont.Company
|
||
|
|
outCont.State = 1
|
||
|
|
if detaiTargetCont.MinScore > 0 && detaiTargetCont.MaxScore > 0 {
|
||
|
|
outCont.Score = fmt.Sprintf("%v-%v", float64(detaiTargetCont.MinScore)/100, float64(detaiTargetCont.MaxScore)/100)
|
||
|
|
outCont.State = 2
|
||
|
|
} else if detaiTargetCont.MinScore > 0 && detaiTargetCont.MaxScore <= 0 {
|
||
|
|
outCont.Score = fmt.Sprintf("%v", float64(detaiTargetCont.MinScore)/100)
|
||
|
|
outCont.State = 1
|
||
|
|
} else if detaiTargetCont.MinScore <= 0 && detaiTargetCont.MaxScore > 0 {
|
||
|
|
outCont.Score = fmt.Sprintf("%v", float64(detaiTargetCont.MaxScore)/100)
|
||
|
|
outCont.State = 1
|
||
|
|
} else {
|
||
|
|
outCont.Score = "0"
|
||
|
|
outCont.State = 3
|
||
|
|
}
|
||
|
|
|
||
|
|
outContList = append(outContList, outCont)
|
||
|
|
}
|
||
|
|
response.Result(0, outContList, "获取成功!", c)
|
||
|
|
}
|