dddd
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.

223 lines
9.1 KiB

4 years ago
package evaluation
import (
"encoding/json"
4 years ago
"fmt"
"strconv"
"time"
4 years ago
"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(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
4 years ago
return
}
4 years ago
var requestData NewQualType
err := c.ShouldBindJSON(&requestData)
if err != nil {
// response.Result(102, err, "数据获取失败!", c)
// return
}
userContJson, _ := json.Marshal(userCont)
fmt.Printf("userCont----------------->%v\n", string(userContJson))
4 years ago
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
where := commonus.MapOut()
where["id"] = v.Group
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
outCont.GroupName = orgCont.Name
// _, groupCont := commonus.GetGroupCont(v.Group)
// outCont.GroupName = groupCont.Name
4 years ago
outCont.Department = v.Department
whereDepart := commonus.MapOut()
whereDepart["id"] = v.Department
orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
outCont.DepartmentName = orgContDepart.Name
// _, departCont := commonus.GetBranchFactory(v.Department)
// outCont.DepartmentName = departCont.Name
4 years ago
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(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
4 years ago
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,qe_qual_eval_id").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)
4 years ago
gormDb = gormDb.Where("`qe_group` = ?", requestData.Group).Where("`qe_accept_evaluation` = ?", requestData.Department).Where("`qe_target` = ?", requestData.Target)
if requestData.Title != "" {
gormDb = gormDb.Where("`dt_title` LIKE ?", "%"+requestData.Title+"%")
}
4 years ago
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
outCont.PlanVersionNumber = v.PlanVersionNumber
where := commonus.MapOut()
where["id"] = v.Group
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
outCont.GroupName = orgCont.Name
whereDepart := commonus.MapOut()
whereDepart["id"] = v.Department
orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
outCont.DepartmentName = orgContDepart.Name
// _, groupCont := commonus.GetGroupCont(v.Group)
// outCont.GroupName = groupCont.Name
4 years ago
outCont.Department = v.Department
// _, departCont := commonus.GetBranchFactory(v.Department)
// outCont.DepartmentName = departCont.Name
4 years ago
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)
}
//判断全奖与零奖参数
func AllZreoConfig(cycles int) (monthInt int64) {
switch cycles {
case 4:
monthInt = commonus.ComputingTime(time.Now().Unix(), 1)
// monthInt, _ = strconv.ParseInt(monthstr, 10, 64)
case 5:
// var dfds error
monthInt = commonus.ComputingTime(time.Now().Unix(), 2)
// monthInt, dfds = strconv.ParseInt(monthstrsss, 10, 64)
// fmt.Printf("monthstr--------monthInt-------->%v----->%v----->%v\n", monthstrsss, monthInt, dfds)
default:
}
return
}
//获取定量考核任务列表===>筛出已经提交的数据
func (e *EvaluationInterface) QualitativeEvalRationNew(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
var requestData GetRationFlowLog
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(102, err, "数据获取失败!", c)
return
}
//获取当月的起止时间
startMonth, endMonth := commonus.GetAppointMonthStarAndEndTimeInt(time.Now().Unix())
//获取当月内所有的审批流程的部门及指标ID
// var qualEvalFlowLogList QualEvalFlowLog
var evalId []int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where("fl_time BETWEEN ? AND ?", startMonth, endMonth).Find(&evalId)
var qualEvaList []assessmentmodel.QualitativeEvaluation
gormDbIng := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qualitative_evaluation.*")
gormDbIng = gormDbIng.Where("`qe_type` = 2 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key)
gormDbIng = gormDbIng.Not(map[string]interface{}{"qe_id": evalId})
if requestData.GroupId != "" {
gormDbIng = gormDbIng.Where("qe_group = ?", requestData.GroupId)
}
if requestData.DepartmentID != "" {
gormDbIng = gormDbIng.Where("qe_accept_evaluation = ?", requestData.DepartmentID)
}
if requestData.TargetId != "" {
gormDbIng = gormDbIng.Where("qe_target = ?", requestData.TargetId)
}
listErr := gormDbIng.Order("qe_type ASC,qe_group ASC,qe_accept_evaluation ASC,qe_dimension ASC,qe_target ASC,qe_target_sun ASC,qe_detailed_target ASC").Find(&qualEvaList).Error
if listErr != nil || len(qualEvaList) < 1 {
response.Result(102, qualEvaList, "您没有要参加的考核项目!", c)
return
}
}