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.
358 lines
13 KiB
358 lines
13 KiB
package assessment
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/api/v1/archiveapi"
|
|
"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/flipped-aurora/gin-vue-admin/server/model/testpage"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
//部门考核
|
|
func (d *DutyHandle) DepartmentList(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 []deparMentModel
|
|
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)
|
|
|
|
var qualitativeEvaluationAry []assessmentmodel.QualitativeEvaluation
|
|
gormDb := global.GVA_DB_Performanceappraisal
|
|
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_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)
|
|
}
|
|
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)
|
|
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) 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)
|
|
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
|
|
}
|
|
|