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.
880 lines
34 KiB
880 lines
34 KiB
package assessment
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"gin_server_admin/api/v1/archiveapi"
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/assessmentmodel"
|
|
"gin_server_admin/model/common/response"
|
|
"gin_server_admin/model/hrsystem"
|
|
"gin_server_admin/model/testpage"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 部门考核
|
|
func (d *DutyHandle) DepartmentList(c *gin.Context) {
|
|
var requestData rationSelect
|
|
c.ShouldBindJSON(&requestData)
|
|
var groupId int64 = 309
|
|
if requestData.Group != "" {
|
|
groupId, _ = strconv.ParseInt(requestData.Group, 10, 64)
|
|
}
|
|
var departList []deparMentModel
|
|
gromDb := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("id", "name", "wechat_organization_id").Where("`state` = 1 AND `superior` = ?", groupId)
|
|
if requestData.DepartmentId != "" {
|
|
gromDb = gromDb.Where("`id` = ?", requestData.DepartmentId)
|
|
}
|
|
departMentErr := gromDb.Find(&departList).Error
|
|
if departMentErr != nil || len(departList) < 1 {
|
|
response.Result(101, departMentErr, "没有数据!", c)
|
|
return
|
|
}
|
|
var departAryList []departmentDuty
|
|
for _, v := range departList {
|
|
var departCont departmentDuty
|
|
departCont.Id = strconv.FormatInt(v.Id, 10)
|
|
departCont.Name = v.Name
|
|
departCont.Child = getDepartDimension(groupId, v.Id)
|
|
departAryList = append(departAryList, departCont)
|
|
}
|
|
response.Result(0, departAryList, "数据获取成功!", c)
|
|
}
|
|
|
|
func (d *DutyHandle) DepartmentListOld(c *gin.Context) {
|
|
var requestData rationSelect
|
|
c.ShouldBindJSON(&requestData)
|
|
var groupId int64 = 3
|
|
if requestData.Group != "" {
|
|
groupId, _ = strconv.ParseInt(requestData.Group, 10, 64)
|
|
}
|
|
var departList []deparMentModelOld
|
|
gromDb := global.GVA_DB_Master.Model(&testpage.BranchFactory{}).Select("bf_id", "bf_name", "bf_wechat_id").Where("`bf_set` = 1 AND `bf_group` = ?", groupId)
|
|
if requestData.DepartmentId != "" {
|
|
gromDb = gromDb.Where("`bf_id` = ?", requestData.DepartmentId)
|
|
}
|
|
departMentErr := gromDb.Find(&departList).Error
|
|
if departMentErr != nil || len(departList) < 1 {
|
|
response.Result(101, departMentErr, "没有数据!", c)
|
|
return
|
|
}
|
|
var departAryList []departmentDuty
|
|
for _, v := range departList {
|
|
var departCont departmentDuty
|
|
departCont.Id = strconv.FormatInt(v.Id, 10)
|
|
departCont.Name = v.Name
|
|
departCont.Child = getDepartDimension(groupId, v.Id)
|
|
departAryList = append(departAryList, departCont)
|
|
}
|
|
response.Result(0, departAryList, "数据获取成功!", c)
|
|
}
|
|
|
|
// 获取部门考核维度
|
|
func getDepartDimension(groupId, departId int64) (dimensionAry []departmentDimension) {
|
|
var fileAry []int64
|
|
dimErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartmentDimension{}).Select("dd_dimension").Where("`dd_group` = ? AND `dd_department` = ?", groupId, departId).Group("dd_dimension").Find(&fileAry).Error
|
|
// fmt.Printf("1--------------->%v\n", dimErr)
|
|
if dimErr == nil {
|
|
for _, v := range fileAry {
|
|
dimInfo, dimInfoErr := commonus.GetDutyClassInfo(v)
|
|
// fmt.Printf("2--------------->%v\n", dimInfo)
|
|
if dimInfoErr == true {
|
|
var dimCont departmentDimension
|
|
dimCont.Id = strconv.FormatInt(v, 10)
|
|
dimCont.Name = dimInfo.Title
|
|
dimCont.Child = targetRationDepartList(groupId, departId, v)
|
|
dimensionAry = append(dimensionAry, dimCont)
|
|
}
|
|
}
|
|
|
|
}
|
|
return
|
|
}
|
|
|
|
// 部门考核项目
|
|
func targetRationDepartList(groupID, departmentID, dimension int64) (contentList []taskDetails) {
|
|
var fileTargetAry []assessmentmodel.QualitativeEvaluation
|
|
listTargetErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_group` = ? AND `qe_accept_evaluation` = ? AND `qe_dimension` = ?", groupID, departmentID, dimension).Find(&fileTargetAry).Error
|
|
if listTargetErr != nil {
|
|
return
|
|
}
|
|
for _, v := range fileTargetAry {
|
|
var content taskDetails
|
|
targetInfo, targetErr := commonus.GetTargetInfo(v.Target)
|
|
if targetErr == true {
|
|
content.Id = strconv.FormatInt(v.Target, 10)
|
|
content.Name = targetInfo.Title
|
|
content.QeId = strconv.FormatInt(v.Id, 10)
|
|
content.Unit = v.Unit
|
|
content.ReferenceScore = v.ReferenceScore
|
|
content.Cycles = v.Cycles
|
|
content.CycleAttres = v.CycleAttres
|
|
content.State = v.State
|
|
|
|
contentList = append(contentList, content)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (d *DutyHandle) DepartmentTaskList(c *gin.Context) {
|
|
var requestData DelQualitative
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
if requestData.VersionNumber == "" {
|
|
response.Result(101, requestData, "未知版本号码", c)
|
|
return
|
|
}
|
|
|
|
var qualitativeEvaluationAry []assessmentmodel.QualitativeEvaluation
|
|
gormDb := global.GVA_DB_Performanceappraisal.Select("qualitative_evaluation.*,dutyclass.sort")
|
|
if requestData.Type != 0 {
|
|
gormDb = gormDb.Where("`qe_type` = ?", requestData.Type)
|
|
}
|
|
if requestData.Group != "" {
|
|
gormDb = gormDb.Where("`qe_group` = ?", requestData.Group)
|
|
}
|
|
// if requestData.DepartmentId != "" {
|
|
gormDb = gormDb.Where("`qe_qual_eval_id` = ?", requestData.VersionNumber)
|
|
// }
|
|
if requestData.DepartmentId != "" {
|
|
gormDb = gormDb.Where("`qe_accept_evaluation` = ?", requestData.DepartmentId)
|
|
}
|
|
|
|
if requestData.Dimension != "" {
|
|
gormDb = gormDb.Where("`qe_dimension` = ?", requestData.Dimension)
|
|
}
|
|
if requestData.Target != "" {
|
|
gormDb = gormDb.Where("`qe_target` = ?", requestData.Target)
|
|
}
|
|
if requestData.TargetSun != "" {
|
|
gormDb = gormDb.Where("`qe_target_sun` = ?", requestData.TargetSun)
|
|
}
|
|
// gormDb = gormDb.Where("`qe_state` = 1")
|
|
listTargetErr := gormDb.Joins("left join dutyclass on id = qe_dimension").Order("qe_group asc,qe_accept_evaluation asc,sort asc,qe_type asc,qe_target asc,qe_target_sun asc").Find(&qualitativeEvaluationAry).Error
|
|
|
|
if listTargetErr != nil || len(qualitativeEvaluationAry) < 1 {
|
|
response.Result(101, qualitativeEvaluationAry, "没有数据!", c)
|
|
return
|
|
}
|
|
response.Result(101, qualitativeEvaluationAry, "没有数据!", c)
|
|
return
|
|
var uotContAry []TargetContOutCont
|
|
for _, v := range qualitativeEvaluationAry {
|
|
var uotCont TargetContOutCont
|
|
uotCont.Id = strconv.FormatInt(v.Id, 10)
|
|
uotCont.Type = v.Type
|
|
uotCont.Group = strconv.FormatInt(v.Group, 10)
|
|
|
|
where := commonus.MapOut()
|
|
where["id"] = v.Group
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
uotCont.GroupNAme = orgCont.Name
|
|
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v.AcceptEvaluation
|
|
orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
|
|
uotCont.DepartmentName = orgContDepart.Name
|
|
|
|
// groupErr, groupCont := commonus.GetGroupCont(v.Group)
|
|
// if groupErr == true {
|
|
// uotCont.GroupNAme = groupCont.Name
|
|
// }
|
|
uotCont.DepartmentId = strconv.FormatInt(v.AcceptEvaluation, 10)
|
|
// deparConErr, deparConCont := commonus.GetBranchFactory(v.AcceptEvaluation)
|
|
// if deparConErr == true {
|
|
// uotCont.DepartmentName = deparConCont.Name
|
|
// }
|
|
uotCont.Dimension = strconv.FormatInt(v.Dimension, 10)
|
|
dutyClassCont, dutyClassErr := commonus.GetDutyClassInfo(v.Dimension)
|
|
if dutyClassErr == true {
|
|
uotCont.DimensionName = dutyClassCont.Title
|
|
}
|
|
uotCont.DimensionWeight = commonus.GetDimesionTargetWeight(1, v.Group, v.AcceptEvaluation, v.Dimension, 0)
|
|
|
|
uotCont.Target = strconv.FormatInt(v.Target, 10)
|
|
targetInfo, targetErr := commonus.GetTargetInfo(v.Target)
|
|
if targetErr == true {
|
|
uotCont.TargetName = targetInfo.Title
|
|
}
|
|
uotCont.TargetWeight = commonus.GetDimesionTargetWeight(2, v.Group, v.AcceptEvaluation, v.Dimension, v.Target)
|
|
uotCont.TargetSun = strconv.FormatInt(v.TargetSun, 10)
|
|
info, infoErr := commonus.GetQualitativeTargetInfo(v.TargetSun)
|
|
if infoErr == true {
|
|
uotCont.TargetSunName = info.Title
|
|
}
|
|
uotCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10)
|
|
dtCont, dtIsTrue := commonus.GetDetailedTargetInfo(v.DetailedTarget)
|
|
if dtIsTrue == true {
|
|
uotCont.DetailedTargetName = dtCont.Title
|
|
uotCont.Content = dtCont.Content
|
|
}
|
|
|
|
uotCont.Unit = v.Unit
|
|
uotCont.ReferenceScore = v.ReferenceScore
|
|
uotCont.Cycles = v.Cycles
|
|
uotCont.CycleAttres = v.CycleAttres
|
|
uotCont.State = v.State
|
|
userAry := strings.Split(v.Operator, ",")
|
|
uotCont.UserList = userAry
|
|
for _, u_v := range userAry {
|
|
usCont, usErr := archiveapi.GetUserInfo([]string{"worker_man.wm_number", "worker_man_data.wmd_name"}, map[string]interface{}{"wm_key": u_v})
|
|
if usErr == true {
|
|
var userCont QualEvalArrt
|
|
userCont.Id = u_v
|
|
userCont.Name = usCont.Name
|
|
uotCont.UserListAry = append(uotCont.UserListAry, userCont)
|
|
}
|
|
}
|
|
|
|
if v.MinScore > 0 && v.MaxScore > 0 {
|
|
uotCont.MinOrMaxScore = fmt.Sprintf("%v-%v", float64(v.MinScore)/100, float64(v.MaxScore)/100)
|
|
} else if v.MinScore > 0 && v.MaxScore <= 0 {
|
|
uotCont.MinOrMaxScore = fmt.Sprintf("%v", float64(v.MinScore)/100)
|
|
} else if v.MinScore <= 0 && v.MaxScore > 0 {
|
|
uotCont.MinOrMaxScore = fmt.Sprintf("%v", float64(v.MaxScore)/100)
|
|
} else {
|
|
uotCont.MinOrMaxScore = "0"
|
|
}
|
|
|
|
uotCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10)
|
|
uotContAry = append(uotContAry, uotCont)
|
|
}
|
|
response.Result(0, uotContAry, "数据获取成功!", c)
|
|
}
|
|
|
|
// 获取方案考核细则内容
|
|
func (d *DutyHandle) DetailsAssessmentScheme(c *gin.Context) {
|
|
var requestData commonus.SetIds
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Id == 0 && requestData.OutId == "" {
|
|
response.Result(102, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if requestData.OutId != "" {
|
|
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64)
|
|
if inIntErr == nil {
|
|
requestData.Id = idInt
|
|
}
|
|
}
|
|
|
|
var systemBFCont assessmentmodel.QualitativeEvaluation
|
|
contErr := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", requestData.Id).First(&systemBFCont).Error
|
|
if contErr != nil {
|
|
response.Result(102, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
var uotCont TargetContOutCont
|
|
uotCont.Id = strconv.FormatInt(systemBFCont.Id, 10)
|
|
uotCont.Type = systemBFCont.Type
|
|
uotCont.Group = strconv.FormatInt(systemBFCont.Group, 10)
|
|
|
|
where := commonus.MapOut()
|
|
where["id"] = systemBFCont.Group
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
uotCont.GroupNAme = orgCont.Name
|
|
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = systemBFCont.AcceptEvaluation
|
|
orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
|
|
uotCont.DepartmentName = orgContDepart.Name
|
|
|
|
// groupErr, groupCont := commonus.GetGroupCont(systemBFCont.Group)
|
|
// if groupErr == true {
|
|
// uotCont.GroupNAme = groupCont.Name
|
|
// }
|
|
uotCont.DepartmentId = strconv.FormatInt(systemBFCont.AcceptEvaluation, 10)
|
|
// deparConErr, deparConCont := commonus.GetBranchFactory(systemBFCont.AcceptEvaluation)
|
|
// if deparConErr == true {
|
|
// uotCont.DepartmentName = deparConCont.Name
|
|
// }
|
|
uotCont.Dimension = strconv.FormatInt(systemBFCont.Dimension, 10)
|
|
dutyClassCont, dutyClassErr := commonus.GetDutyClassInfo(systemBFCont.Dimension)
|
|
if dutyClassErr == true {
|
|
uotCont.DimensionName = dutyClassCont.Title
|
|
}
|
|
uotCont.Target = strconv.FormatInt(systemBFCont.Target, 10)
|
|
targetInfo, targetErr := commonus.GetTargetInfo(systemBFCont.Target)
|
|
if targetErr == true {
|
|
uotCont.TargetName = targetInfo.Title
|
|
}
|
|
uotCont.TargetSun = strconv.FormatInt(systemBFCont.TargetSun, 10)
|
|
info, infoErr := commonus.GetQualitativeTargetInfo(systemBFCont.TargetSun)
|
|
if infoErr == true {
|
|
uotCont.TargetSunName = info.Title
|
|
}
|
|
uotCont.DetailedTarget = strconv.FormatInt(systemBFCont.DetailedTarget, 10)
|
|
dtCont, dtIsTrue := commonus.GetDetailedTargetInfo(systemBFCont.DetailedTarget)
|
|
if dtIsTrue == true {
|
|
uotCont.DetailedTargetName = dtCont.Title
|
|
uotCont.Content = dtCont.Content
|
|
}
|
|
uotCont.Unit = systemBFCont.Unit
|
|
uotCont.ReferenceScore = systemBFCont.ReferenceScore
|
|
uotCont.Cycles = systemBFCont.Cycles
|
|
uotCont.CycleAttres = systemBFCont.CycleAttres
|
|
uotCont.State = systemBFCont.State
|
|
uotCont.UserList = strings.Split(systemBFCont.Operator, ",")
|
|
uotCont.DetailedTarget = strconv.FormatInt(systemBFCont.DetailedTarget, 10)
|
|
response.Result(0, uotCont, "数据获取成功!", c)
|
|
}
|
|
|
|
// 删除考核细则方案内容
|
|
func (d *DutyHandle) DelDepartmentTaskList(c *gin.Context) {
|
|
var requestData commonus.SetIds
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Id == 0 && requestData.OutId == "" {
|
|
response.Result(102, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if requestData.OutId != "" {
|
|
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64)
|
|
if inIntErr == nil {
|
|
requestData.Id = idInt
|
|
}
|
|
}
|
|
var oldCont assessmentmodel.QualitativeEvaluation
|
|
getOldContErr := global.GVA_DB_Performanceappraisal.Where("qe_id = ?", requestData.Id).Find(&oldCont).Error
|
|
if getOldContErr != nil {
|
|
response.Result(102, err, "没有此数据", c)
|
|
return
|
|
}
|
|
roleErr := global.GVA_DB_Performanceappraisal.Where("qe_id = ?", requestData.Id).Delete(&assessmentmodel.QualitativeEvaluation{}).Error
|
|
if roleErr != nil {
|
|
response.Result(102, err, "删除失败!", c)
|
|
return
|
|
} else {
|
|
var judgeNum int64
|
|
delGormDb := global.GVA_DB_Performanceappraisal
|
|
delGormDb = delGormDb.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_group` = ? AND `qe_accept_evaluation` = ? AND `qe_dimension` = ? AND `qe_type` = ?", oldCont.Group, oldCont.AcceptEvaluation, oldCont.Dimension, oldCont.Type)
|
|
if oldCont.Type == 1 {
|
|
delGormDb = delGormDb.Where("`qe_target` = ? AND `qe_target_sun` = ? ", oldCont.Target, oldCont.TargetSun)
|
|
}
|
|
judgeErr := delGormDb.Pluck("COALESCE(COUNT(qe_id), 0) as countid", &judgeNum).Error
|
|
if judgeErr == nil && judgeNum == 0 && oldCont.Type == 1 {
|
|
delDimErr := global.GVA_DB_Performanceappraisal.Where("`ddw_type` = 1 AND `ddw_hierarchy` = 2 AND `ddw_group` = ? AND `ddw_derpatment` = ? AND `ddw_dimension` = ? AND `ddw_target` = ?", oldCont.Group, oldCont.AcceptEvaluation, oldCont.Dimension, oldCont.Target).Delete(&assessmentmodel.DepartmentDimensionWeight{}).Error
|
|
if delDimErr == nil {
|
|
}
|
|
}
|
|
response.Result(0, err, "删除成功!", c)
|
|
}
|
|
}
|
|
|
|
// 修改考核方案单条考核细则
|
|
func (d *DutyHandle) EiteOneQualitativeEvaluation(c *gin.Context) {
|
|
var requestData EiteOneQualEval
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Id == 0 && requestData.OutId == "" {
|
|
response.Result(102, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if requestData.OutId != "" {
|
|
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64)
|
|
if inIntErr == nil {
|
|
requestData.Id = idInt
|
|
}
|
|
}
|
|
saveData := commonus.MapOut()
|
|
saveData["qe_eitetime"] = time.Now().Unix()
|
|
if requestData.Unit != "" {
|
|
saveData["qe_unit"] = requestData.Unit
|
|
}
|
|
if requestData.ReferenceScore != 0 {
|
|
saveData["qe_reference_score"] = requestData.ReferenceScore
|
|
}
|
|
if requestData.Cycles != 0 {
|
|
saveData["qe_cycle"] = requestData.Cycles
|
|
}
|
|
if requestData.CycleAttres != 0 {
|
|
saveData["qe_cycleattr"] = requestData.CycleAttres
|
|
}
|
|
if requestData.State != 0 {
|
|
saveData["qe_state"] = requestData.State
|
|
}
|
|
if requestData.Content != "" {
|
|
saveData["qe_content"] = requestData.Content
|
|
}
|
|
if len(requestData.Operator) > 0 {
|
|
saveData["qe_operator"] = strings.Join(requestData.Operator, ",")
|
|
saveData["qe_department_id"] = strings.Join(GetDepartmentByUserBast(requestData.Operator), ",")
|
|
}
|
|
roleIsTrue, roleErr := eiteOneQuaEvaInfo(requestData.Id, saveData)
|
|
if roleIsTrue != true {
|
|
response.Result(106, roleErr, "编辑失败!", c)
|
|
} else {
|
|
response.Result(0, saveData, "编辑成功!", c)
|
|
}
|
|
}
|
|
|
|
// 编辑职务数据处理
|
|
func eiteOneQuaEvaInfo(saveId int64, saveData map[string]interface{}) (isTrue bool, infoErr error) {
|
|
isTrue = false
|
|
infoErr = global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_id` = ?", saveId).Updates(saveData).Error
|
|
if infoErr != nil {
|
|
return
|
|
}
|
|
isTrue = true
|
|
return
|
|
}
|
|
|
|
// 获取定性考核指标对应的结构树
|
|
func (d *DutyHandle) QualEvalTargetTree(c *gin.Context) {
|
|
var requestData QualEvalTargetTreeDies
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Group == "" {
|
|
response.Result(102, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.DepartmentId == "" {
|
|
response.Result(103, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Dimension == "" {
|
|
response.Result(104, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Target == "" {
|
|
response.Result(105, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
|
|
var qualitativeEvaluationAry []assessmentmodel.QualitativeEvaluation
|
|
gormDb := global.GVA_DB_Performanceappraisal
|
|
|
|
gormDb = gormDb.Where("`qe_group` = ?", requestData.Group)
|
|
gormDb = gormDb.Where("`qe_accept_evaluation` = ?", requestData.DepartmentId)
|
|
gormDb = gormDb.Where("`qe_dimension` = ?", requestData.Dimension)
|
|
gormDb = gormDb.Where("`qe_target` = ?", requestData.Target)
|
|
listTargetErr := gormDb.Order("qe_type asc,qe_group asc,qe_accept_evaluation asc,qe_dimension asc,qe_target asc,qe_target_sun asc").Find(&qualitativeEvaluationAry).Error
|
|
|
|
if listTargetErr != nil || len(qualitativeEvaluationAry) < 1 {
|
|
response.Result(101, listTargetErr, "没有数据!", c)
|
|
return
|
|
}
|
|
var uotContAry []TargetContOutCont
|
|
for _, v := range qualitativeEvaluationAry {
|
|
var uotCont TargetContOutCont
|
|
uotCont.Id = strconv.FormatInt(v.Id, 10)
|
|
uotCont.Type = v.Type
|
|
uotCont.Group = strconv.FormatInt(v.Group, 10)
|
|
|
|
where := commonus.MapOut()
|
|
where["id"] = v.Group
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
uotCont.GroupNAme = orgCont.Name
|
|
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v.AcceptEvaluation
|
|
orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
|
|
uotCont.DepartmentName = orgContDepart.Name
|
|
|
|
// groupErr, groupCont := commonus.GetGroupCont(v.Group)
|
|
// if groupErr == true {
|
|
// uotCont.GroupNAme = groupCont.Name
|
|
// }
|
|
uotCont.DepartmentId = strconv.FormatInt(v.AcceptEvaluation, 10)
|
|
// deparConErr, deparConCont := commonus.GetBranchFactory(v.AcceptEvaluation)
|
|
// if deparConErr == true {
|
|
// uotCont.DepartmentName = deparConCont.Name
|
|
// }
|
|
uotCont.Dimension = strconv.FormatInt(v.Dimension, 10)
|
|
dutyClassCont, dutyClassErr := commonus.GetDutyClassInfo(v.Dimension)
|
|
if dutyClassErr == true {
|
|
uotCont.DimensionName = dutyClassCont.Title
|
|
}
|
|
uotCont.Target = strconv.FormatInt(v.Target, 10)
|
|
targetInfo, targetErr := commonus.GetTargetInfo(v.Target)
|
|
if targetErr == true {
|
|
uotCont.TargetName = targetInfo.Title
|
|
}
|
|
uotCont.TargetSun = strconv.FormatInt(v.TargetSun, 10)
|
|
info, infoErr := commonus.GetQualitativeTargetInfo(v.TargetSun)
|
|
if infoErr == true {
|
|
uotCont.TargetSunName = info.Title
|
|
}
|
|
uotCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10)
|
|
dtCont, dtIsTrue := commonus.GetDetailedTargetInfo(v.DetailedTarget)
|
|
if dtIsTrue == true {
|
|
uotCont.DetailedTargetName = dtCont.Title
|
|
uotCont.Content = dtCont.Content
|
|
}
|
|
uotCont.Unit = v.Unit
|
|
uotCont.ReferenceScore = v.ReferenceScore
|
|
uotCont.Cycles = v.Cycles
|
|
uotCont.CycleAttres = v.CycleAttres
|
|
uotCont.State = v.State
|
|
userAry := strings.Split(v.Operator, ",")
|
|
uotCont.UserList = userAry
|
|
for _, u_v := range userAry {
|
|
usCont, usErr := archiveapi.GetUserInfo([]string{"worker_man.wm_number", "worker_man_data.wmd_name"}, map[string]interface{}{"wm_key": u_v})
|
|
if usErr == true {
|
|
var userCont QualEvalArrt
|
|
userCont.Id = u_v
|
|
userCont.Name = usCont.Name
|
|
uotCont.UserListAry = append(uotCont.UserListAry, userCont)
|
|
}
|
|
}
|
|
|
|
uotCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10)
|
|
uotContAry = append(uotContAry, uotCont)
|
|
}
|
|
response.Result(0, uotContAry, "数据获取成功!", c)
|
|
}
|
|
|
|
// 部门考核(新)
|
|
func (d *DutyHandle) DepartmentListNew(c *gin.Context) {
|
|
var requestData rationSelect
|
|
c.ShouldBindJSON(&requestData)
|
|
//获取维度列表
|
|
var dutyClassAry []assessmentmodel.DutyClass
|
|
gromDb := global.GVA_DB_Performanceappraisal
|
|
gromDb = gromDb.Where("`state` = 1")
|
|
classErr := gromDb.Order("sort ASC").Find(&dutyClassAry).Error
|
|
|
|
if classErr != nil {
|
|
response.Result(0, classErr, "未获取到数据", c)
|
|
return
|
|
}
|
|
|
|
var departAryList []departmentDutyNew
|
|
for _, v := range dutyClassAry {
|
|
childList := GetEvalTarget(v.Id, requestData.Group, requestData.DepartmentId)
|
|
if len(childList) > 0 {
|
|
var departCont departmentDutyNew
|
|
departCont.Id = strconv.FormatInt(v.Id, 10)
|
|
departCont.Name = v.Title
|
|
departCont.Child = GetEvalTarget(v.Id, requestData.Group, requestData.DepartmentId)
|
|
departAryList = append(departAryList, departCont)
|
|
}
|
|
}
|
|
response.Result(0, departAryList, "数据获取成功!", c)
|
|
}
|
|
|
|
// 获取考核指标
|
|
func GetEvalTarget(dimId int64, group, departId string) (dimensionAry []taskDetailsLinkage) {
|
|
var contAry []assessmentmodel.EvaluationTarget
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationTarget{}).Where("et_state = 1 AND `et_dimension` = ?", dimId)
|
|
if departId != "" {
|
|
sqlOrStr := fmt.Sprintf("FIND_IN_SET(%v,`et_relevant_departments`)", departId)
|
|
sqlOrStr = fmt.Sprintf("`et_share` = 1 OR (`et_share` = 2 AND (%v))", sqlOrStr)
|
|
gormDb = gormDb.Where(sqlOrStr)
|
|
}
|
|
listErr := gormDb.Find(&contAry).Error
|
|
if listErr != nil {
|
|
return
|
|
}
|
|
for _, v := range contAry {
|
|
|
|
var dimCont taskDetailsLinkage
|
|
dimCont.Id = strconv.FormatInt(v.Id, 10)
|
|
dimCont.Name = v.Title
|
|
dimCont.Content = ""
|
|
scoreVal := GetDepartDimTargetScore(group, departId, dimId, v.Id)
|
|
dimCont.ReferenceScore = scoreVal
|
|
if scoreVal > 0 {
|
|
dimCont.IsTrue = 2
|
|
} else {
|
|
dimCont.IsTrue = 1
|
|
}
|
|
dimCont.Unit = v.Uniteing
|
|
dimCont.Cycles = v.Cycles
|
|
dimCont.CycleAttres = v.CycleAttres
|
|
|
|
if v.Type == 1 {
|
|
var counetNumber int64
|
|
countErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DetailedTarget{}).Select("dt_id").Where("`dt_parentid` = ?", v.Id).Pluck("COALESCE(COUNT(dt_id), 0) as countid", &counetNumber).Error
|
|
if countErr == nil {
|
|
if counetNumber > 0 {
|
|
dimensionAry = append(dimensionAry, dimCont)
|
|
}
|
|
}
|
|
} else {
|
|
dimensionAry = append(dimensionAry, dimCont)
|
|
}
|
|
|
|
}
|
|
return
|
|
}
|
|
|
|
// 计算该指定部门维度指标下的分值
|
|
func GetDepartDimTargetScore(group, depert string, dimeid, targetid int64) (scoreAll int64) {
|
|
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_group` = ? AND `qe_accept_evaluation` = ? AND `qe_dimension` = ? AND `qe_target` = ? AND qe_state = 1", group, depert, dimeid, targetid).Pluck("COALESCE(SUM(qe_reference_score), 0) as rescore", &scoreAll).Error
|
|
if err != nil {
|
|
scoreAll = 0
|
|
}
|
|
return
|
|
}
|
|
|
|
// 部门添加考核方案NEw
|
|
func (d *DutyHandle) AddDepartmentDutyInfo(c *gin.Context) {
|
|
var requestData AddDutyNewContGroup
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Group == "" {
|
|
response.Result(102, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
groupId, groupErr := strconv.ParseInt(requestData.Group, 10, 64)
|
|
if groupErr != nil {
|
|
groupId = 0
|
|
}
|
|
if requestData.DepartmentId == "" {
|
|
response.Result(103, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
departId, departErr := strconv.ParseInt(requestData.DepartmentId, 10, 64)
|
|
if departErr != nil {
|
|
departId = 0
|
|
}
|
|
if len(requestData.Child) < 0 {
|
|
response.Result(104, err, "没有要添加的数据", c)
|
|
return
|
|
}
|
|
var eiteIdAry []int64
|
|
var saveDataAry []assessmentmodel.QualitativeEvaluation
|
|
fmt.Printf("1-------------%v---------------->%v\n", groupId, requestData.Group)
|
|
for _, v := range requestData.Child { //维度
|
|
for _, v_s := range v.Child { //指标
|
|
if v_s.Status == 1 {
|
|
|
|
//指标ID转换
|
|
targetId, targetErr := strconv.ParseInt(v_s.Id, 10, 64)
|
|
if targetErr == nil {
|
|
//获取指标内容
|
|
evalTarCont, evalTarContErr := commonus.GetTargetInfo(targetId)
|
|
if evalTarContErr == true {
|
|
//判断是定量还是定性
|
|
if evalTarCont.Type == 2 {
|
|
//定量指标操作
|
|
var saveData assessmentmodel.QualitativeEvaluation
|
|
|
|
var qeId []int64
|
|
eiteQualEvalSaveData := commonus.MapOut()
|
|
gormQualEval := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("`qe_dimension` = ? AND `qe_target` = ? AND `qe_type` = ?", v.Id, targetId, evalTarCont.Type)
|
|
//计算执行考核人部门
|
|
if evalTarCont.Report != "" {
|
|
var departAry []string
|
|
userKeyAry := strings.Split(evalTarCont.Report, ",")
|
|
if len(userKeyAry) > 0 {
|
|
for _, u_v := range userKeyAry {
|
|
usCont, usErr := archiveapi.GetUserInfo([]string{"worker_man.wm_bf_id"}, map[string]interface{}{"wm_key": u_v})
|
|
if usErr == true {
|
|
departAry = append(departAry, strconv.FormatInt(usCont.DepartmentId, 10))
|
|
}
|
|
}
|
|
}
|
|
saveData.DepartmentId = strings.Join(departAry, ",")
|
|
gormQualEval = gormQualEval.Where("`qe_department_id` IN ?", departAry)
|
|
eiteQualEvalSaveData["qe_department_id"] = strings.Join(departAry, ",")
|
|
}
|
|
|
|
//维度ID
|
|
dimId, dimErr := strconv.ParseInt(v.Id, 10, 64)
|
|
if dimErr == nil {
|
|
saveData.Dimension = dimId
|
|
}
|
|
saveData.Target = targetId //指标
|
|
saveData.Type = evalTarCont.Type //类型
|
|
saveData.Unit = v_s.Unit //单位
|
|
saveData.ReferenceScore = v_s.ReferenceScore //分值
|
|
// saveData.ReferenceScore = v_s.ReferenceScore //分值
|
|
saveData.State = 1 //状态
|
|
saveData.Addtime = time.Now().Unix()
|
|
saveData.Eitetime = time.Now().Unix()
|
|
saveData.Group = groupId //集团
|
|
saveData.Cycles = v_s.Cycles //单位
|
|
saveData.CycleAttres = v_s.CycleAttres //辅助计数
|
|
saveData.AcceptEvaluation = departId //接受考核部门
|
|
saveData.Content = v_s.Content //描述
|
|
saveData.Operator = evalTarCont.Report //执行考核人
|
|
|
|
judgeContErr := gormQualEval.Find(&qeId).Error
|
|
if judgeContErr == nil && len(qeId) > 0 {
|
|
eiteQualEvalSaveData["qe_dimension"] = dimId
|
|
eiteQualEvalSaveData["qe_target"] = targetId
|
|
eiteQualEvalSaveData["qe_type"] = evalTarCont.Type
|
|
eiteQualEvalSaveData["qe_unit"] = v_s.Unit
|
|
eiteQualEvalSaveData["qe_reference_score"] = v_s.ReferenceScore
|
|
eiteQualEvalSaveData["qe_state"] = 1
|
|
eiteQualEvalSaveData["qe_eitetime"] = time.Now().Unix()
|
|
eiteQualEvalSaveData["qe_group"] = groupId
|
|
eiteQualEvalSaveData["qe_cycle"] = v_s.Cycles
|
|
eiteQualEvalSaveData["qe_cycleattr"] = v_s.CycleAttres
|
|
eiteQualEvalSaveData["qe_accept_evaluation"] = departId
|
|
eiteQualEvalSaveData["qe_operator"] = evalTarCont.Report
|
|
eiteQualEvalSaveData["qe_content"] = v_s.Content
|
|
eiteIdAry = append(eiteIdAry, dimId)
|
|
//修改已经存在的内容
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_id` IN ?", qeId).Updates(eiteQualEvalSaveData)
|
|
} else {
|
|
saveDataAry = append(saveDataAry, saveData)
|
|
}
|
|
|
|
} else {
|
|
//定性考核
|
|
//获取子栏目列表
|
|
var sunTarget []assessmentmodel.QualitativeTarget
|
|
sunErr := global.GVA_DB_Performanceappraisal.Where("q_parent_id = ?", targetId).Find(&sunTarget).Error
|
|
fmt.Printf("judge----------------1----------->%v\n", sunErr)
|
|
if sunErr == nil {
|
|
if len(sunTarget) > 0 {
|
|
fmt.Printf("judge----------------2----------->%v\n", len(sunTarget))
|
|
//获取定性指标子项目下的考核详情
|
|
for _, s_d_v := range sunTarget {
|
|
//指标详情
|
|
var detaTarget []assessmentmodel.DetailedTarget
|
|
detaiErr := global.GVA_DB_Performanceappraisal.Where("dt_parentid = ? AND dt_parentid_sun = ?", targetId, s_d_v.Id).Find(&detaTarget).Error
|
|
fmt.Printf("judge----------------3----------->%v\n", detaiErr)
|
|
if detaiErr == nil {
|
|
if len(detaTarget) > 0 {
|
|
fmt.Printf("judge----------------4----------->%v\n", len(detaTarget))
|
|
//指标详情循环
|
|
for _, s_t_v := range detaTarget {
|
|
var saveDataDetar assessmentmodel.QualitativeEvaluation
|
|
|
|
var qeId []int64
|
|
eiteQualEvalSaveData := commonus.MapOut()
|
|
gormQualEval := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("`qe_dimension` = ? AND `qe_target` = ? AND `qe_type` = ? AND `qe_target_sun` = ? AND `qe_detailed_target` = ?", v.Id, targetId, evalTarCont.Type, s_d_v.Id, s_t_v.Id)
|
|
|
|
//计算执行考核部门
|
|
if evalTarCont.Report != "" {
|
|
var departAry []string
|
|
userKeyAry := strings.Split(evalTarCont.Report, ",")
|
|
if len(userKeyAry) > 0 {
|
|
for _, u_v := range userKeyAry {
|
|
usCont, usErr := archiveapi.GetUserInfo([]string{"worker_man.wm_bf_id"}, map[string]interface{}{"wm_key": u_v})
|
|
if usErr == true {
|
|
departAry = append(departAry, strconv.FormatInt(usCont.DepartmentId, 10))
|
|
}
|
|
}
|
|
}
|
|
saveDataDetar.DepartmentId = strings.Join(departAry, ",")
|
|
gormQualEval = gormQualEval.Where("`qe_department_id` IN ?", departAry)
|
|
eiteQualEvalSaveData["qe_department_id"] = strings.Join(departAry, ",")
|
|
}
|
|
//维度ID
|
|
dimId, dimErr := strconv.ParseInt(v.Id, 10, 64)
|
|
if dimErr == nil {
|
|
saveDataDetar.Dimension = dimId
|
|
}
|
|
saveDataDetar.Target = targetId //指标
|
|
saveDataDetar.TargetSun = s_d_v.Id //子栏目
|
|
saveDataDetar.DetailedTarget = s_t_v.Id //指标详情
|
|
saveDataDetar.Type = evalTarCont.Type //类型
|
|
saveDataDetar.Unit = v_s.Unit //单位
|
|
saveDataDetar.ReferenceScore = v_s.ReferenceScore //得分
|
|
saveDataDetar.State = 1 //状态
|
|
saveDataDetar.Addtime = time.Now().Unix()
|
|
saveDataDetar.Eitetime = time.Now().Unix()
|
|
saveDataDetar.Group = groupId //departId
|
|
saveDataDetar.Cycles = v_s.Cycles
|
|
saveDataDetar.CycleAttres = v_s.CycleAttres
|
|
saveDataDetar.AcceptEvaluation = departId
|
|
saveDataDetar.Operator = evalTarCont.Report
|
|
saveDataDetar.Content = v_s.Content
|
|
|
|
judgeContErr := gormQualEval.Find(&qeId).Error
|
|
if judgeContErr == nil && len(qeId) > 0 {
|
|
fmt.Printf("judge----------------5-------%v---->%v\n", judgeContErr, len(qeId))
|
|
eiteQualEvalSaveData["qe_dimension"] = dimId
|
|
eiteQualEvalSaveData["qe_target"] = targetId
|
|
eiteQualEvalSaveData["qe_target_sun"] = s_d_v.Id
|
|
eiteQualEvalSaveData["qe_detailed_target"] = s_t_v.Id
|
|
eiteQualEvalSaveData["qe_type"] = evalTarCont.Type
|
|
eiteQualEvalSaveData["qe_unit"] = v_s.Unit
|
|
eiteQualEvalSaveData["qe_reference_score"] = v_s.ReferenceScore
|
|
eiteQualEvalSaveData["qe_state"] = 1
|
|
eiteQualEvalSaveData["qe_eitetime"] = time.Now().Unix()
|
|
eiteQualEvalSaveData["qe_group"] = groupId
|
|
eiteQualEvalSaveData["qe_cycle"] = v_s.Cycles
|
|
eiteQualEvalSaveData["qe_cycleattr"] = v_s.CycleAttres
|
|
eiteQualEvalSaveData["qe_accept_evaluation"] = departId
|
|
eiteQualEvalSaveData["qe_operator"] = evalTarCont.Report
|
|
eiteQualEvalSaveData["qe_content"] = v_s.Content
|
|
eiteIdAry = append(eiteIdAry, dimId)
|
|
//修改已经存在的内容
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_id` IN ?", qeId).Updates(eiteQualEvalSaveData)
|
|
} else {
|
|
fmt.Printf("judge----------------5---5----%v---->%v\n", judgeContErr, len(qeId))
|
|
saveDataAry = append(saveDataAry, saveDataDetar)
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
fmt.Printf("judge----------------4-----4------>%v\n", len(detaTarget))
|
|
}
|
|
} else {
|
|
fmt.Printf("judge----------------3-----3------>%v\n", detaiErr)
|
|
}
|
|
}
|
|
} else {
|
|
fmt.Printf("judge----------------2---2-------->%v\n", len(sunTarget))
|
|
}
|
|
} else {
|
|
fmt.Printf("judge----------------1-----1------>%v\n", sunErr)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
fmt.Printf("judge----------------6-----1------>%v\n", v_s)
|
|
var qualEvalId []int64
|
|
judgeQualEvalErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("`qe_group` = ? AND FIND_IN_SET(?,`qe_department_id`) AND `qe_dimension` = ? AND `qe_target` = ?", groupId, departId, v.Id, v_s.Id).Find(&qualEvalId).Error
|
|
if judgeQualEvalErr == nil {
|
|
if len(qualEvalId) > 0 {
|
|
eiteIdAry = append(eiteIdAry, 2)
|
|
fmt.Printf("judge----------------6-----3------>%v\n", judgeQualEvalErr)
|
|
qualEvalSave := commonus.MapOut()
|
|
qualEvalSave["qe_state"] = 2
|
|
qualEvalSave["qe_eitetime"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_id` IN ?", qualEvalId).Updates(qualEvalSave)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(saveDataAry) <= 0 && len(eiteIdAry) <= 0 {
|
|
response.Result(105, saveDataAry, "没有要添加的数据", c)
|
|
return
|
|
}
|
|
|
|
// fmt.Printf("judge----------------7----------->%v\n", v_s)
|
|
if len(saveDataAry) > 0 {
|
|
addErr := global.GVA_DB_Performanceappraisal.Create(&saveDataAry).Error
|
|
if addErr != nil {
|
|
response.Result(106, len(saveDataAry), "数据添加失败", c)
|
|
return
|
|
}
|
|
}
|
|
|
|
if departId != 0 {
|
|
|
|
}
|
|
response.Result(0, saveDataAry, "数据添加成功", c)
|
|
}
|
|
|