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.
168 lines
5.5 KiB
168 lines
5.5 KiB
|
3 years ago
|
package postweb
|
||
|
|
|
||
|
|
import (
|
||
|
|
"key_performance_indicators/models/modelshr"
|
||
|
|
"key_performance_indicators/models/modelskpi"
|
||
|
|
"key_performance_indicators/overall"
|
||
|
|
"key_performance_indicators/overall/publicmethod"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
//岗位指标相关操作
|
||
|
|
|
||
|
|
// 获取指定人要考核的项目列表
|
||
|
|
func (a *ApiMethod) GetPostTarget(c *gin.Context) {
|
||
|
|
var receivedValue getPostManTargetList
|
||
|
|
err := c.ShouldBindJSON(&receivedValue)
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(100, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if receivedValue.Id == "" {
|
||
|
|
publicmethod.Result(101, receivedValue, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if receivedValue.Class == 0 {
|
||
|
|
receivedValue.Class = 1
|
||
|
|
}
|
||
|
|
//获取被考核人基本西悉尼
|
||
|
|
var userCont modelshr.PersonArchives
|
||
|
|
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(107, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
//获取登录人信息
|
||
|
|
context, _ := publicmethod.LoginMyCont(c)
|
||
|
|
|
||
|
|
var qualitSchemeList []modelskpi.QualitativeEvaluationScheme
|
||
|
|
err = overall.CONSTANT_DB_KPI.Raw("SELECT q.* FROM qualitative_evaluation_scheme q Where q.state = 1 AND `attribute` = ? AND q.target_id = some (SELECT target_id FROM target_report tr WHERE tr.type = 2 AND tr.department_id = ? AND tr.post_id = ? AND tr.man_key = ?)", receivedValue.Class, userCont.MainDeparment, userCont.Position, context.Key).Scan(&qualitSchemeList).Error
|
||
|
|
if err != nil || len(qualitSchemeList) < 1 {
|
||
|
|
publicmethod.Result(107, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var outDataAry []outPostManTargetList
|
||
|
|
for _, v := range qualitSchemeList {
|
||
|
|
// jsonStr, _ := json.Marshal(v)
|
||
|
|
// fmt.Printf("v----------->%v\n", string(jsonStr))
|
||
|
|
var outCont outPostManTargetList
|
||
|
|
outCont.Id = strconv.FormatInt(v.Id, 10)
|
||
|
|
outCont.Class = v.Attribute
|
||
|
|
outCont.Title = v.Title
|
||
|
|
if v.Attribute == 1 {
|
||
|
|
if v.Source == 1 { //岗位
|
||
|
|
var postTarDeta modelskpi.PostTargetDetails
|
||
|
|
postTarDeta.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`punishmode`")
|
||
|
|
outCont.AddReduce = postTarDeta.Punishmode
|
||
|
|
} else { //部门
|
||
|
|
var departTarDeta modelskpi.DetailedTarget
|
||
|
|
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`")
|
||
|
|
outCont.AddReduce = departTarDeta.AddReduce
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
outDataAry = append(outDataAry, outCont)
|
||
|
|
}
|
||
|
|
publicmethod.Result(0, outDataAry, c)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 定性指标列表
|
||
|
|
func (a *ApiMethod) GetPostNature(c *gin.Context) {
|
||
|
|
var receivedValue publicmethod.PublicId
|
||
|
|
err := c.ShouldBindJSON(&receivedValue)
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(100, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if receivedValue.Id == "" {
|
||
|
|
publicmethod.Result(101, receivedValue, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
//获取被考核人基本信息
|
||
|
|
var userCont modelshr.PersonArchives
|
||
|
|
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(107, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
//获取登录人信息
|
||
|
|
context, _ := publicmethod.LoginMyCont(c)
|
||
|
|
//获取被考核人本岗位的考核项目
|
||
|
|
var itemList []modelskpi.ShemePeople
|
||
|
|
|
||
|
|
err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `attribute` = 1 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.MainDeparment, userCont.Position, context.Key).Find(&itemList).Error
|
||
|
|
if err != nil || len(itemList) < 1 {
|
||
|
|
publicmethod.Result(107, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var targetId []int64
|
||
|
|
//获取指标内容
|
||
|
|
var outDataAry []outPostManTargetList
|
||
|
|
for _, v := range itemList {
|
||
|
|
if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false {
|
||
|
|
var outCont outPostManTargetList
|
||
|
|
outCont.Id = strconv.FormatInt(v.TargetId, 10)
|
||
|
|
outCont.Title = v.Title
|
||
|
|
outCont.Class = v.Attribute
|
||
|
|
if v.Source == 1 { //岗位
|
||
|
|
var postTarDeta modelskpi.PostTargetDetails
|
||
|
|
postTarDeta.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`punishmode`")
|
||
|
|
outCont.AddReduce = postTarDeta.Punishmode
|
||
|
|
} else { //部门
|
||
|
|
var departTarDeta modelskpi.DetailedTarget
|
||
|
|
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`")
|
||
|
|
outCont.AddReduce = departTarDeta.AddReduce
|
||
|
|
}
|
||
|
|
|
||
|
|
outDataAry = append(outDataAry, outCont)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
publicmethod.Result(0, outDataAry, c)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取定量指标
|
||
|
|
func (a *ApiMethod) GetPostRation(c *gin.Context) {
|
||
|
|
var receivedValue publicmethod.PublicId
|
||
|
|
err := c.ShouldBindJSON(&receivedValue)
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(100, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if receivedValue.Id == "" {
|
||
|
|
publicmethod.Result(101, receivedValue, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
//获取被考核人基本信息
|
||
|
|
var userCont modelshr.PersonArchives
|
||
|
|
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
|
||
|
|
if err != nil {
|
||
|
|
publicmethod.Result(107, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
//获取登录人信息
|
||
|
|
context, _ := publicmethod.LoginMyCont(c)
|
||
|
|
//获取被考核人本岗位的考核项目
|
||
|
|
var itemList []modelskpi.ShemePeople
|
||
|
|
|
||
|
|
err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `attribute` = 2 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.MainDeparment, userCont.Position, context.Key).Find(&itemList).Error
|
||
|
|
if err != nil || len(itemList) < 1 {
|
||
|
|
publicmethod.Result(107, err, c)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
var targetId []int64
|
||
|
|
//获取指标内容
|
||
|
|
var outDataAry []outPostRation
|
||
|
|
for _, v := range itemList {
|
||
|
|
if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false {
|
||
|
|
var outCont outPostRation
|
||
|
|
outCont.Id = strconv.FormatInt(v.TargetId, 10)
|
||
|
|
outCont.Name = v.Title
|
||
|
|
outDataAry = append(outDataAry, outCont)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
publicmethod.Result(0, outDataAry, c)
|
||
|
|
}
|