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.
864 lines
33 KiB
864 lines
33 KiB
package dutyassess
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"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 (d *DutyAssessApi) GetActivationPlanVersion(c *gin.Context) {
|
|
var requestData DutyPlanVersio
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Group == "" {
|
|
response.Result(101, requestData, "请选择集团!", c)
|
|
return
|
|
}
|
|
if requestData.DeaprtId == "" {
|
|
response.Result(101, requestData, "请选择部门!", c)
|
|
return
|
|
}
|
|
gormDb := global.GVA_DB_Performanceappraisal
|
|
gormDb = gormDb.Where("`group` = ?", requestData.Group)
|
|
gormDb = gormDb.Where("`department` = ?", requestData.DeaprtId)
|
|
gormDb = gormDb.Where("`state` = 1")
|
|
var planVersio []DutyPlanVersioOut
|
|
dataErr := gormDb.Order("`addtime` DESC").Find(&planVersio).Error
|
|
if dataErr != nil {
|
|
response.Result(104, dataErr, "没有查询到数据", c)
|
|
return
|
|
}
|
|
response.Result(0, planVersio, "获取成功", c)
|
|
}
|
|
|
|
// 部门考核方案版本列表
|
|
func (d *DutyAssessApi) DepartDutyPlanVersion(c *gin.Context) {
|
|
var requestData DutyPlanVersio
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
if err != nil {
|
|
// response.Result(101, err, "数据获取失败!", c)
|
|
// return
|
|
}
|
|
gormDb := global.GVA_DB_Performanceappraisal
|
|
if requestData.Group != "" {
|
|
gormDb = gormDb.Where("`group` = ?", requestData.Group)
|
|
}
|
|
if requestData.DeaprtId != "" {
|
|
gormDb = gormDb.Where("`department` = ?", requestData.DeaprtId)
|
|
}
|
|
if requestData.Year != "" {
|
|
gormDb = gormDb.Where("`yeares` = ?", requestData.Year)
|
|
}
|
|
if requestData.Versio != "" {
|
|
gormDb = gormDb.Where("`versio` LIKE ?", "%"+requestData.Versio+"%")
|
|
}
|
|
if requestData.VersioNum != "" {
|
|
gormDb = gormDb.Where("`key` LIKE ?", "%"+requestData.VersioNum+"%")
|
|
}
|
|
if requestData.State != 0 {
|
|
gormDb = gormDb.Where("`state` = ?", requestData.State)
|
|
} else {
|
|
gormDb = gormDb.Where("`state` IN (1,2)")
|
|
}
|
|
// response.Result(104, requestData, "没有查询到数据", c)
|
|
// return
|
|
var planVersio []DutyPlanVersioOut
|
|
// dataErr := gormDb.Order("`group` ASC").Order("`department` ASC").Order("`state` ASC").Order("`addtime` ASC").Find(&planVersio).Error
|
|
dataErr := gormDb.Order("`id` ASC").Order("`department` ASC").Order("`addtime` DESC").Find(&planVersio).Error
|
|
if dataErr != nil {
|
|
response.Result(104, dataErr, "没有查询到数据", c)
|
|
return
|
|
}
|
|
for i, v := range planVersio {
|
|
where := commonus.MapOut()
|
|
where["id"] = v.Group
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
planVersio[i].GroupName = orgCont.Name
|
|
// _, groupCont := commonus.GetGroupCont(v.Group)
|
|
// planVersio[i].GroupName = groupCont.Name
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = v.Department
|
|
orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
|
|
planVersio[i].DeaprtName = orgContDepart.Name
|
|
// _, departMent := commonus.GetBranchFactory(v.Department)
|
|
// planVersio[i].DeaprtName = departMent.Name
|
|
planVersio[i].Time = commonus.TimeStampToDate(v.AddTime, 20)
|
|
}
|
|
response.Result(0, planVersio, "获取成功", c)
|
|
}
|
|
|
|
// 添加部门考核方案(待版本号的版本)
|
|
func (d *DutyAssessApi) AddDepartDutyVersio(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) //集团ID
|
|
if groupErr != nil {
|
|
groupId = 0
|
|
}
|
|
|
|
where := commonus.MapOut()
|
|
where["id"] = groupId
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name", "abbreviation")
|
|
firstNameWord := orgCont.Abbreviation
|
|
if firstNameWord == "" {
|
|
firstNameWord = orgCont.Name
|
|
}
|
|
groupInitials := commonus.ChinaToPinYinFirstWord(firstNameWord) //获取集团首字母
|
|
|
|
// _, groupCont := commonus.GetGroupCont(groupId)
|
|
// groupInitials := commonus.ChinaToPinYinFirstWord(groupCont.Name) //获取集团首字母
|
|
if requestData.DepartmentId == "" {
|
|
response.Result(103, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
departId, departErr := strconv.ParseInt(requestData.DepartmentId, 10, 64) //部门ID
|
|
if departErr != nil {
|
|
departId = 0
|
|
}
|
|
if requestData.Year == "" {
|
|
response.Result(104, requestData, "请选择年份", c)
|
|
return
|
|
}
|
|
yearInt, _ := strconv.ParseInt(requestData.Year, 10, 64) //部门ID
|
|
|
|
if len(requestData.Child) < 0 {
|
|
response.Result(105, err, "没有要添加的数据", c)
|
|
return
|
|
}
|
|
judgeState := 1
|
|
//判断是否有新生成的方案
|
|
var versionState []int
|
|
judgeVersio := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Select("`state`").Where("`group` = ? AND `department` = ?", requestData.Group, requestData.DepartmentId).Find(&versionState).Error //判断是否有启用的方案
|
|
if judgeVersio == nil {
|
|
for _, s_v := range versionState {
|
|
if s_v == 1 {
|
|
judgeState = 2
|
|
}
|
|
}
|
|
}
|
|
var versioNum string
|
|
//判断年度是否存在版本
|
|
var sumVerson float64
|
|
judgeVersioNum := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Select("`id`").Where("`group` = ? AND `yeares` = ?", requestData.Group, requestData.Year).Pluck("COALESCE(COUNT(id), 0) as countid", &sumVerson).Error
|
|
// fmt.Printf("sumVerson---->%v\n", sumVerson)
|
|
if judgeVersioNum == nil {
|
|
if sumVerson == 0 {
|
|
versioNum = "0001"
|
|
} else {
|
|
sumVerson++
|
|
versioNum = fmt.Sprintf("%04v", sumVerson)
|
|
// if sumVerson <= 9999 {
|
|
// versioNumGuoDu := strconv.FormatFloat(sumVerson/10000, 'f', -1, 64)
|
|
// versioNumAry := strings.Split(versioNumGuoDu, ".")
|
|
// if len(versioNumAry) == 2 {
|
|
// versioNum = versioNumAry[1]
|
|
// } else {
|
|
// versioNum = "0001"
|
|
// }
|
|
// } else {
|
|
// versioNumGuoDu := strconv.FormatFloat(sumVerson/10000000, 'f', -1, 64)
|
|
// versioNumAry := strings.Split(versioNumGuoDu, ".")
|
|
// if len(versioNumAry) == 2 {
|
|
// versioNum = versioNumAry[1]
|
|
// } else {
|
|
// versioNum = "0001"
|
|
// }
|
|
// }
|
|
|
|
}
|
|
} else {
|
|
versioNum = "0001"
|
|
}
|
|
todyTime := time.Now().Unix()
|
|
keyStr := fmt.Sprintf("%v%v%v", groupInitials, commonus.TimeStampToDate(todyTime, 14), versioNum)
|
|
//方案版本
|
|
var savePlanVersio assessmentmodel.PlanVersio
|
|
savePlanVersio.Group = groupId
|
|
savePlanVersio.Department = departId
|
|
savePlanVersio.Year = yearInt
|
|
savePlanVersio.Versio = versioNum
|
|
savePlanVersio.Key = keyStr
|
|
savePlanVersio.State = judgeState
|
|
savePlanVersio.AddTime = todyTime
|
|
savePlanVersio.EiteTime = todyTime
|
|
if len(requestData.Child) > 0 {
|
|
var planVersioAry []AddDutyNewCont
|
|
for _, pva := range requestData.Child {
|
|
var planVersioccAry AddDutyNewCont
|
|
planVersioccAry.Id = pva.Id
|
|
planVersioccAry.Name = pva.Name
|
|
planVersioccAry.ZhiFraction = pva.ZhiFraction
|
|
|
|
for _, pva_v := range pva.Child {
|
|
var evalProsCont EvaluPross
|
|
evalProsCont.Id = pva_v.Id //`json:"id"` //维度ID
|
|
evalProsCont.Name = pva_v.Name //`json:"name"`
|
|
evalProsCont.Content = pva_v.Content //`json:"content"` //指标说明
|
|
evalProsCont.Unit = pva_v.Unit //`json:"unit"` //单位"`
|
|
evalProsCont.ReferenceScore = pva_v.ReferenceScore //`json:"referencescore"` //标准分值"`
|
|
var zhiBiaoCont assessmentmodel.EvaluationTarget
|
|
evalTarContErr := zhiBiaoCont.GetCont(map[string]interface{}{"et_id": pva_v.Id}, "et_cycle,et_cycleattr") //获取指标内容
|
|
if evalTarContErr == nil {
|
|
evalProsCont.Cycles = zhiBiaoCont.Cycles // `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
evalProsCont.CycleAttres = zhiBiaoCont.CycleAttres // `json:"cycleattr"` //辅助计数"`
|
|
}
|
|
evalProsCont.State = pva_v.State // `json:"state"`
|
|
evalProsCont.Status = pva_v.Status // `json:"status"`
|
|
planVersioccAry.Child = append(planVersioccAry.Child, evalProsCont)
|
|
}
|
|
|
|
planVersioAry = append(planVersioAry, planVersioccAry)
|
|
}
|
|
|
|
planJsonCont, planJsonErr := json.Marshal(planVersioAry)
|
|
// planJsonCont, planJsonErr := json.Marshal(requestData.Child)
|
|
if planJsonErr == nil {
|
|
savePlanVersio.Content = string(planJsonCont)
|
|
}
|
|
}
|
|
|
|
// response.Result(0, savePlanVersio, "添加成功!", c)
|
|
// return
|
|
var saveDataAry []assessmentmodel.QualitativeEvaluation //新增条目
|
|
for _, v := range requestData.Child { //维度
|
|
commonus.AddWeight(requestData.Group, v.Id, requestData.DepartmentId, "", int64(v.ZhiFraction), 1) //添加维度权重
|
|
for _, tar_v := range v.Child { //指标
|
|
if tar_v.Status == 1 || tar_v.Status == 3 {
|
|
targetId, _ := strconv.ParseInt(tar_v.Id, 10, 64) //指标ID转换
|
|
evalTarCont, evalTarContErr := commonus.GetTargetInfo(targetId) //获取指标内容
|
|
if evalTarContErr == true {
|
|
//判断是定量还是定性
|
|
if evalTarCont.Type == 2 {
|
|
//定量指标操作
|
|
commonus.AddWeight(requestData.Group, v.Id, requestData.DepartmentId, tar_v.Id, tar_v.ReferenceScore, 2)
|
|
var saveData assessmentmodel.QualitativeEvaluation
|
|
|
|
//维度ID
|
|
dimId, dimErr := strconv.ParseInt(v.Id, 10, 64)
|
|
if dimErr == nil {
|
|
saveData.Dimension = dimId
|
|
}
|
|
saveData.Target = targetId //指标
|
|
saveData.Type = evalTarCont.Type //类型
|
|
saveData.Unit = evalTarCont.Uniteing //单位
|
|
saveData.ReferenceScore = tar_v.ReferenceScore //分值
|
|
// saveData.ReferenceScore = v_s.ReferenceScore //分值
|
|
saveData.State = judgeState //状态
|
|
saveData.Addtime = time.Now().Unix()
|
|
saveData.Eitetime = time.Now().Unix()
|
|
saveData.Group = groupId //集团
|
|
saveData.Cycles = evalTarCont.Cycles //单位
|
|
saveData.CycleAttres = evalTarCont.CycleAttres //辅助计数
|
|
saveData.AcceptEvaluation = departId //接受考核部门
|
|
saveData.Content = tar_v.Content //描述
|
|
saveData.Operator = evalTarCont.Report //执行考核人
|
|
|
|
var departAry []string
|
|
userKeyAry := strings.Split(evalTarCont.Report, ",")
|
|
if len(userKeyAry) > 0 {
|
|
for _, u_v := range userKeyAry {
|
|
usCont, usErr := commonus.GetWorkUser(u_v)
|
|
if usErr == true {
|
|
departIdStr := strconv.FormatInt(usCont.MainDeparment, 10)
|
|
if commonus.IsItTrueString(departIdStr, departAry) == false {
|
|
departAry = append(departAry, departIdStr)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
saveData.DepartmentId = strings.Join(departAry, ",")
|
|
|
|
saveData.QualEvalId = keyStr
|
|
saveData.Observer = tar_v.Status
|
|
//要新增的条目
|
|
saveDataAry = append(saveDataAry, saveData)
|
|
} else {
|
|
//定性操作
|
|
commonus.AddWeight(requestData.Group, v.Id, requestData.DepartmentId, tar_v.Id, tar_v.ReferenceScore, 1)
|
|
//获取部门关联考核指标项目
|
|
var assessTarList []assessmentmodel.Assesstarget
|
|
judgeARTErr := global.GVA_DB_Performanceappraisal.Where("`group` = ? AND `dimension` = ? AND `targetid` = ? AND FIND_IN_SET(?,`departmentmap`)", groupId, v.Id, tar_v.Id, departId).Find(&assessTarList).Error
|
|
if judgeARTErr == nil {
|
|
var guoDu []AddPartMentGuodu
|
|
for _, ass_v := range assessTarList {
|
|
judgeTure := commonus.JudegSunTarToDepart(ass_v.SunTargetId, departId)
|
|
if judgeTure == true {
|
|
var guoDuCont AddPartMentGuodu
|
|
guoDuCont.Group = groupId
|
|
guoDuCont.DeaprtId = departId
|
|
guoDuCont.Dimension = ass_v.Dimension
|
|
guoDuCont.TargetId = ass_v.TargetId
|
|
guoDuCont.SunTargetId = ass_v.SunTargetId
|
|
if ass_v.Content != "" {
|
|
//拆解指标详情
|
|
var detailedList []DutyAssEssTarget
|
|
detailedListErr := json.Unmarshal([]byte(ass_v.Content), &detailedList)
|
|
if detailedListErr == nil {
|
|
for _, det_v := range detailedList {
|
|
var deparmentStr string
|
|
deErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DetailedTarget{}).Select("`dt_paretment`").Where("`dt_id` = ? AND (FIND_IN_SET(?,`dt_paretment`) OR `dt_paretment` = '')", det_v.Id, departId).First(&deparmentStr).Error
|
|
if deErr == nil {
|
|
if deparmentStr != "" {
|
|
guoDuCont.DetailedTarget = det_v.Id
|
|
guoDuCont.Operator = det_v.Operator
|
|
guoDu = append(guoDu, guoDuCont)
|
|
}
|
|
}
|
|
fmt.Printf("Targer---7---->%v---->%v---->%v---->%v---->%v\n", det_v.Id, departId, deparmentStr, guoDu, deErr)
|
|
}
|
|
} else {
|
|
// guoDu = append(guoDu, guoDuCont)
|
|
}
|
|
} else {
|
|
// guoDu = append(guoDu, guoDuCont)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
//判断关联项目
|
|
if len(guoDu) > 0 {
|
|
// guoDuJsonm, _ := json.Marshal(guoDu)
|
|
// fmt.Printf("Targer---7---->%v---->%v\n", string(guoDuJsonm), guoDu)
|
|
for _, ae_v := range guoDu {
|
|
//写入新的定性考核细则
|
|
var saveData assessmentmodel.QualitativeEvaluation
|
|
saveData.Dimension = ae_v.Dimension
|
|
saveData.Target = ae_v.TargetId //指标
|
|
saveData.Type = 1 //类型
|
|
|
|
saveData.TargetSun = ae_v.SunTargetId
|
|
|
|
getEvalTarCont, _ := commonus.GetDetailedTargetInfo(ae_v.DetailedTarget) //获取指标内容
|
|
|
|
saveData.DetailedTarget = ae_v.DetailedTarget
|
|
|
|
saveData.Unit = getEvalTarCont.Company //单位
|
|
saveData.ReferenceScore = 0 //分值
|
|
|
|
saveData.MinScore = getEvalTarCont.MinScore
|
|
saveData.MaxScore = getEvalTarCont.MaxScore
|
|
|
|
saveData.CensorType = getEvalTarCont.CensorType
|
|
saveData.CensorCont = getEvalTarCont.CensorCont
|
|
saveData.CensorRate = getEvalTarCont.CensorRate
|
|
// saveData.ReferenceScore = v_s.ReferenceScore //分值
|
|
saveData.State = judgeState //状态
|
|
saveData.Addtime = time.Now().Unix()
|
|
saveData.Eitetime = time.Now().Unix()
|
|
saveData.Group = ae_v.Group //集团
|
|
|
|
if getEvalTarCont.Cycles > 0 {
|
|
saveData.Cycles = getEvalTarCont.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年
|
|
saveData.CycleAttres = getEvalTarCont.CycleAttres //辅助计数
|
|
} else {
|
|
evaDingXinglTarCont, _ := commonus.GetTargetInfo(ae_v.TargetId) //获取指标内容
|
|
saveData.Cycles = evaDingXinglTarCont.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年
|
|
saveData.CycleAttres = evaDingXinglTarCont.CycleAttres //辅助计数
|
|
}
|
|
|
|
saveData.AcceptEvaluation = ae_v.DeaprtId //接受考核部门
|
|
saveData.Content = getEvalTarCont.Content //描述
|
|
saveData.Operator = strings.Join(ae_v.Operator, ",") //执行考核人
|
|
//获取执行人部门
|
|
var departAry []string
|
|
if len(ae_v.Operator) > 0 {
|
|
for _, u_v := range ae_v.Operator {
|
|
usCont, usErr := commonus.GetWorkUser(u_v)
|
|
if usErr == true {
|
|
departIdStr := strconv.FormatInt(usCont.MainDeparment, 10)
|
|
if commonus.IsItTrueString(departIdStr, departAry) == false {
|
|
departAry = append(departAry, departIdStr)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
saveData.DepartmentId = strings.Join(departAry, ",")
|
|
|
|
saveDataJsonm, _ := json.Marshal(saveData)
|
|
fmt.Printf("Targer---9---->%v---->%v\n", string(saveDataJsonm), saveData)
|
|
saveData.QualEvalId = keyStr
|
|
saveData.Observer = tar_v.Status
|
|
//要新增的条目
|
|
saveDataAry = append(saveDataAry, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// saveDataJsonmww, _ := json.Marshal(saveDataAry)
|
|
// fmt.Printf("Targer---19---->%v\n", string(saveDataJsonmww))
|
|
// panic(saveDataAry)
|
|
if len(saveDataAry) > 0 {
|
|
|
|
affairDb := global.GVA_DB_Performanceappraisal.Begin()
|
|
addSysAdminContErr := affairDb.Create(&savePlanVersio).Error
|
|
addSysAdminAttrContErr := affairDb.Create(&saveDataAry).Error
|
|
if addSysAdminContErr == nil && addSysAdminAttrContErr == nil {
|
|
affairDbErr := affairDb.Commit().Error
|
|
if affairDbErr == nil {
|
|
response.Result(0, affairDbErr, "数据写入成功!", c)
|
|
} else {
|
|
response.Result(108, affairDbErr, "数据写入失败!", c)
|
|
}
|
|
} else {
|
|
affairDbErr := affairDb.Rollback().Error
|
|
response.Result(109, affairDbErr, "数据写入失败!", c)
|
|
}
|
|
}
|
|
// response.Result(0, saveDataAry, "添加成功!", c)
|
|
}
|
|
|
|
// 查看考核方案
|
|
func (d *DutyAssessApi) LookDepartDutyVersioOld(c *gin.Context) {
|
|
var requestData LookDutyVersio
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Key == "" {
|
|
response.Result(102, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
var qualitativeEvaluationAry []assessmentmodel.QualitativeEvaluation
|
|
listTargetErr := global.GVA_DB_Performanceappraisal.Select("qualitative_evaluation.*,dutyclass.sort").Where("`qe_qual_eval_id` = ?", requestData.Key).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, 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.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
|
|
if v.Content == "" {
|
|
uotCont.Content = dtCont.Content
|
|
} else {
|
|
uotCont.Content = v.Content
|
|
}
|
|
|
|
} else {
|
|
uotCont.Content = v.Content
|
|
}
|
|
uotCont.QualEvalId = v.QualEvalId
|
|
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)
|
|
// }
|
|
usCont, usErr := commonus.GetWorkUser(u_v)
|
|
// GetWorkUser
|
|
if usErr == true {
|
|
var userCont QualEvalArrt
|
|
userCont.Id = u_v
|
|
userCont.Name = usCont.Name
|
|
userCont.Icon = usCont.Icon
|
|
|
|
where := commonus.MapOut()
|
|
where["id"] = usCont.Company
|
|
orgCont, _ := commonus.GetNewOrgCont(where, "id", "name")
|
|
userCont.GroupName = orgCont.Name
|
|
|
|
whereDepart := commonus.MapOut()
|
|
whereDepart["id"] = usCont.MainDeparment
|
|
orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "id", "name")
|
|
userCont.DepartmentName = orgContDepart.Name
|
|
|
|
// _, groupInfo := commonus.GetGroupCont(usCont.Group)
|
|
// userCont.GroupName = groupInfo.Name
|
|
// _, bfInfo := commonus.GetBranchFactory(usCont.DepartmentId)
|
|
// userCont.DepartmentName = bfInfo.Name
|
|
userCont.Number = usCont.Number
|
|
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 *DutyAssessApi) OnOffDepartDutyVersio(c *gin.Context) {
|
|
var requestData SetOnOffDutyVersio
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Key == "" {
|
|
response.Result(102, err, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.State == 0 {
|
|
requestData.State = 1
|
|
}
|
|
if requestData.IsTrue == 0 {
|
|
requestData.IsTrue = 2
|
|
}
|
|
//判断是否存在
|
|
var ContInfo assessmentmodel.PlanVersio
|
|
getContErr := global.GVA_DB_Performanceappraisal.Where("`key` = ? AND `state` <> 3", requestData.Key).First(&ContInfo).Error
|
|
if getContErr != nil {
|
|
response.Result(103, getContErr, "没有该方案!", c)
|
|
return
|
|
}
|
|
//判断是否可以执行该操作
|
|
if judgeOnOffVersio(ContInfo, requestData.IsTrue) == true {
|
|
response.Result(1003, ContInfo, "要禁用的方案还有未走完的审批流程!请不要进行此操作!", c)
|
|
return
|
|
}
|
|
//获取
|
|
|
|
if requestData.State != 3 {
|
|
eiteOtherData := commonus.MapOut()
|
|
eiteOtherData["state"] = 2
|
|
eiteOtherData["eitetime"] = time.Now().Unix()
|
|
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("`group` = ? AND `department` = ? AND `yeares` = ?", ContInfo.Group, ContInfo.Department, ContInfo.Year).Updates(eiteOtherData)
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("`group` = ? AND `department` = ? AND `state` <> 3 AND `key` <> ?", ContInfo.Group, ContInfo.Department, requestData.Key).Updates(eiteOtherData)
|
|
}
|
|
|
|
eiteData := commonus.MapOut()
|
|
eiteData["state"] = requestData.State
|
|
eiteData["eitetime"] = time.Now().Unix()
|
|
errOne := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("`key` = ?", requestData.Key).Updates(eiteData).Error
|
|
|
|
eiteQuerData := commonus.MapOut()
|
|
eiteQuerData["qe_state"] = requestData.State
|
|
eiteQuerData["qe_eitetime"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_qual_eval_id` = ?", requestData.Key).Updates(eiteQuerData)
|
|
|
|
var planKey []assessmentmodel.PlanVersio
|
|
plankeErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("`group` = ? AND `department` = ? AND `state` <> 3 AND `key` <> ?", ContInfo.Group, ContInfo.Department, requestData.Key).Find(&planKey).Error
|
|
if plankeErr == nil {
|
|
var keyPlanStr []string
|
|
for _, plv := range planKey {
|
|
keyPlanStr = append(keyPlanStr, plv.Key)
|
|
}
|
|
if requestData.State == 1 {
|
|
if len(keyPlanStr) > 0 {
|
|
eiteQuerDataAll := commonus.MapOut()
|
|
eiteQuerDataAll["qe_state"] = 2
|
|
eiteQuerDataAll["qe_eitetime"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_qual_eval_id` IN ?", keyPlanStr).Updates(eiteQuerDataAll)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if errOne != nil {
|
|
response.Result(102, errOne, "修改失败", c)
|
|
return
|
|
}
|
|
response.Result(0, errOne, "修改成功", c)
|
|
}
|
|
|
|
// 判断是否可以执行启用禁用操作
|
|
func judgeOnOffVersio(contInfo assessmentmodel.PlanVersio, onOff int) (isTrue bool) {
|
|
isTrue = false
|
|
if onOff == 1 {
|
|
var isOpen []assessmentmodel.PlanVersio
|
|
isErr := global.GVA_DB_Performanceappraisal.Where("`group` = ? AND `department` = ? AND `yeares` = ?", contInfo.Group, contInfo.Department, contInfo.Year).Find(&isOpen).Error
|
|
if isErr != nil {
|
|
return
|
|
}
|
|
for _, v := range isOpen {
|
|
if v.State == 1 {
|
|
isTrue = selectServio(v.Key)
|
|
}
|
|
}
|
|
} else {
|
|
isTrue = selectServio(contInfo.Key)
|
|
}
|
|
return
|
|
}
|
|
|
|
// 查询
|
|
func selectServio(key string) (isTrue bool) {
|
|
isTrue = false
|
|
fmt.Printf("HGJK--------1---------->%v", key)
|
|
var dutyList []assessmentmodel.QualitativeEvaluation
|
|
dutyErr := global.GVA_DB_Performanceappraisal.Where("`qe_state` = 1 AND `qe_qual_eval_id` = ?", key).Find(&dutyList).Error
|
|
fmt.Printf("HGJK--------2---------->%v", dutyErr)
|
|
if dutyErr != nil {
|
|
return
|
|
}
|
|
var dingXing []int64
|
|
var dingLiang []int64
|
|
for _, v := range dutyList {
|
|
if v.Type == 1 {
|
|
dingXing = append(dingXing, v.Id)
|
|
} else {
|
|
dingLiang = append(dingLiang, v.Id)
|
|
}
|
|
}
|
|
var dataStruct dataLockStatistics
|
|
|
|
syncProcess.Add(1)
|
|
go dataStruct.SelectDutyVersioProcessXing(dingXing)
|
|
syncProcess.Add(1)
|
|
go dataStruct.SelectDutyVersioProcessLing(dingLiang)
|
|
syncProcess.Wait()
|
|
|
|
readDingXingDataMap, readDingLiangDataMap := dataStruct.readMyDayData()
|
|
if len(readDingXingDataMap) > 0 || len(readDingLiangDataMap) > 0 {
|
|
isTrue = true
|
|
}
|
|
return
|
|
}
|
|
|
|
// 并发查询定性考核方案
|
|
func (d *dataLockStatistics) SelectDutyVersioProcessXing(departId []int64) {
|
|
d.mutext.Lock()
|
|
defer d.mutext.Unlock()
|
|
if len(departId) > 0 {
|
|
var stateIsTrue []bingFaOut
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_id,sf_key,sf_evaluation_plan,sf_reply,ep_order_key,ep_state").Where("`sf_evaluation_plan` IN ?", departId).Joins("left join evaluation_process on ep_order_key = sf_key").Find(&stateIsTrue).Error
|
|
if err == nil {
|
|
for _, v := range stateIsTrue {
|
|
if v.State == 1 {
|
|
isIn := commonus.MapOut()
|
|
isIn["id"] = v.Id
|
|
isIn["key"] = v.Key
|
|
isIn["state"] = v.State
|
|
d.dataMap = append(d.dataMap, isIn)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
syncProcess.Done()
|
|
}
|
|
|
|
// 并发查询定量考核方案
|
|
func (d *dataLockStatistics) SelectDutyVersioProcessLing(departId []int64) {
|
|
d.mutext.Lock()
|
|
defer d.mutext.Unlock()
|
|
if len(departId) > 0 {
|
|
var stateIsTrue []bingFaOutDingLiang
|
|
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_id,fl_key,fl_evaluation_id,fl_reply,ep_order_key,ep_state").Where("`sf_evaluation_plan` IN ?", departId).Joins("left join evaluation_process on ep_order_key = fl_key").Find(&stateIsTrue).Error
|
|
if err == nil {
|
|
for _, v := range stateIsTrue {
|
|
if v.State == 1 {
|
|
isIn := commonus.MapOut()
|
|
isIn["id"] = v.Id
|
|
isIn["key"] = v.Key
|
|
isIn["state"] = v.State
|
|
d.dataErrMap = append(d.dataErrMap, isIn)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
syncProcess.Done()
|
|
}
|
|
|
|
// 修改部门考核方案内的说明
|
|
func (d *DutyAssessApi) EiteDepartExplain(c *gin.Context) {
|
|
var requestData EitrDepartExplan
|
|
c.ShouldBindJSON(&requestData)
|
|
// err := c.ShouldBindJSON(&requestData)
|
|
// if err != nil {
|
|
// response.Result(101, err, "数据获取失败!", c)
|
|
// return
|
|
// }
|
|
if requestData.Group == "" {
|
|
response.Result(102, requestData, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.DeaprtId == "" {
|
|
response.Result(103, requestData, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.Dimension == "" {
|
|
response.Result(104, requestData, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.TargetId == "" {
|
|
response.Result(105, requestData, "数据获取失败!", c)
|
|
return
|
|
}
|
|
if requestData.QualEvalId == "" {
|
|
response.Result(106, requestData, "数据获取失败!", c)
|
|
return
|
|
}
|
|
eiteData := commonus.MapOut()
|
|
eiteData["qe_eitetime"] = time.Now().Unix()
|
|
eiteData["qe_content"] = requestData.Content
|
|
if requestData.State > 0 {
|
|
// eiteData["qe_state"] = requestData.State
|
|
eiteData["observer"] = requestData.State
|
|
} else {
|
|
eiteData["qe_state"] = 2
|
|
eiteData["observer"] = 2
|
|
}
|
|
if len(requestData.Operator) > 0 {
|
|
eiteData["qe_operator"] = strings.Join(requestData.Operator, ",")
|
|
}
|
|
saveErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Where("`qe_qual_eval_id` = ? AND `qe_group` = ? AND `qe_accept_evaluation` = ? AND `qe_dimension` = ? AND `qe_target` = ?", requestData.QualEvalId, requestData.Group, requestData.DeaprtId, requestData.Dimension, requestData.TargetId).Updates(eiteData).Error
|
|
if saveErr == nil {
|
|
if requestData.State != 0 {
|
|
eitePlanVersion(requestData.QualEvalId, requestData.TargetId, requestData.State, requestData.Content)
|
|
}
|
|
response.Result(0, eiteData, "数据处理成功!", c)
|
|
} else {
|
|
response.Result(102, saveErr, "数据处理失败!", c)
|
|
}
|
|
}
|
|
|
|
// 编辑版本主体
|
|
func eitePlanVersion(key string, tarId string, state int, contStr string) {
|
|
var planVersioCont assessmentmodel.PlanVersio
|
|
planErr := global.GVA_DB_Performanceappraisal.Where("`key` = ?", key).First(&planVersioCont).Error
|
|
var planContSave []AddDutyNewCont
|
|
// fmt.Printf("Plan--------1----------->%v\n", planErr)
|
|
if planErr == nil {
|
|
if planVersioCont.Content != "" {
|
|
// fmt.Printf("Plan--------2----------->%v\n", planVersioCont)
|
|
var planCont []AddDutyNewCont
|
|
jsonErrPlan := json.Unmarshal([]byte(planVersioCont.Content), &planCont)
|
|
// fmt.Printf("Plan--------3----------->%v\n", jsonErrPlan)
|
|
if jsonErrPlan == nil {
|
|
|
|
for _, v := range planCont {
|
|
var saveCont AddDutyNewCont
|
|
saveCont.Id = v.Id
|
|
saveCont.Name = v.Name
|
|
saveCont.ZhiFraction = v.ZhiFraction
|
|
for _, cv := range v.Child {
|
|
var chidCont EvaluPross
|
|
if cv.Id == tarId {
|
|
chidCont.Id = cv.Id
|
|
chidCont.Name = cv.Name // `json:"name"`
|
|
chidCont.Content = contStr // `json:"content"` //指标说明
|
|
chidCont.Unit = cv.Unit // `json:"unit"` //单位"`
|
|
chidCont.ReferenceScore = cv.ReferenceScore // `json:"referencescore"` //标准分值"`
|
|
chidCont.Cycles = cv.Cycles // `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
chidCont.CycleAttres = cv.CycleAttres // `json:"cycleattr"` //辅助计数"`
|
|
chidCont.State = state // `json:"state"`
|
|
chidCont.Score = cv.Score // `json:"score"` //分数
|
|
chidCont.QualEvalId = cv.QualEvalId // `json:"qeid"`
|
|
chidCont.Status = state // `json:"status"`
|
|
} else {
|
|
chidCont.Id = cv.Id
|
|
chidCont.Name = cv.Name // `json:"name"`
|
|
chidCont.Content = cv.Content // `json:"content"` //指标说明
|
|
chidCont.Unit = cv.Unit // `json:"unit"` //单位"`
|
|
chidCont.ReferenceScore = cv.ReferenceScore // `json:"referencescore"` //标准分值"`
|
|
chidCont.Cycles = cv.Cycles // `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
chidCont.CycleAttres = cv.CycleAttres // `json:"cycleattr"` //辅助计数"`
|
|
chidCont.State = cv.State // `json:"state"`
|
|
chidCont.Score = cv.Score // `json:"score"` //分数
|
|
chidCont.QualEvalId = cv.QualEvalId // `json:"qeid"`
|
|
chidCont.Status = cv.Status // `json:"status"`
|
|
|
|
}
|
|
saveCont.Child = append(saveCont.Child, chidCont)
|
|
}
|
|
planContSave = append(planContSave, saveCont)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
// fmt.Printf("Plan--------4----------->%v\n", len(planContSave))
|
|
if len(planContSave) > 0 {
|
|
planContInfo, planJsonErr := json.Marshal(planContSave)
|
|
if planJsonErr == nil {
|
|
eitaData := commonus.MapOut()
|
|
eitaData["content"] = string(planContInfo)
|
|
eitaData["eitetime"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Where("`key` = ?", key).Updates(eitaData)
|
|
}
|
|
|
|
}
|
|
}
|
|
|