24 changed files with 3038 additions and 160 deletions
File diff suppressed because it is too large
@ -0,0 +1,638 @@ |
|||
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) 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("`addtime` DESC").Find(&planVersio).Error |
|||
if dataErr != nil { |
|||
response.Result(104, dataErr, "没有查询到数据", c) |
|||
return |
|||
} |
|||
for i, v := range planVersio { |
|||
_, groupCont := commonus.GetGroupCont(v.Group) |
|||
planVersio[i].GroupName = groupCont.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 |
|||
} |
|||
_, 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, err, "数据获取失败!", 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++ |
|||
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 |
|||
|
|||
// 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 { |
|||
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.DepartmentId, 10) |
|||
if commonus.IsItTrueString(departIdStr, departAry) == false { |
|||
departAry = append(departAry, departIdStr) |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
saveData.DepartmentId = strings.Join(departAry, ",") |
|||
|
|||
saveData.QualEvalId = keyStr |
|||
//要新增的条目
|
|||
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 { |
|||
guoDuCont.DetailedTarget = det_v.Id |
|||
guoDuCont.Operator = det_v.Operator |
|||
guoDu = append(guoDu, guoDuCont) |
|||
fmt.Printf("Targer---6---->%v---->%v---->%v\n", ass_v.TargetId, ass_v.SunTargetId, det_v.Id) |
|||
} |
|||
} 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.ReferenceScore = v_s.ReferenceScore //分值
|
|||
saveData.State = judgeState //状态
|
|||
saveData.Addtime = time.Now().Unix() |
|||
saveData.Eitetime = time.Now().Unix() |
|||
saveData.Group = ae_v.Group //集团
|
|||
|
|||
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.DepartmentId, 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 |
|||
//要新增的条目
|
|||
saveDataAry = append(saveDataAry, saveData) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
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) LookDepartDutyVersio(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) |
|||
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 |
|||
_, 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` = ?", requestData.Key).First(&ContInfo).Error |
|||
if getContErr != nil { |
|||
response.Result(103, getContErr, "没有该方案!", c) |
|||
return |
|||
} |
|||
//判断是否可以执行该操作
|
|||
if judgeOnOffVersio(ContInfo, requestData.IsTrue) == true { |
|||
response.Result(103, 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) |
|||
} |
|||
|
|||
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) |
|||
|
|||
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 |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.Group == "" { |
|||
response.Result(102, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.DeaprtId == "" { |
|||
response.Result(103, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.Dimension == "" { |
|||
response.Result(104, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.TargetId == "" { |
|||
response.Result(105, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.QualEvalId == "" { |
|||
response.Result(106, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
eiteData := commonus.MapOut() |
|||
eiteData["qe_eitetime"] = time.Now().Unix() |
|||
eiteData["qe_content"] = requestData.Content |
|||
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 { |
|||
response.Result(0, eiteData, "数据处理成功!", c) |
|||
} else { |
|||
response.Result(102, err, "数据处理失败!", c) |
|||
} |
|||
} |
|||
@ -0,0 +1,134 @@ |
|||
package evaluation |
|||
|
|||
import ( |
|||
"fmt" |
|||
"strconv" |
|||
|
|||
"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(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
var requestData NewQualType |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
// response.Result(102, err, "数据获取失败!", c)
|
|||
// return
|
|||
} |
|||
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 |
|||
_, groupCont := commonus.GetGroupCont(v.Group) |
|||
outCont.GroupName = groupCont.Name |
|||
outCont.Department = v.Department |
|||
_, departCont := commonus.GetBranchFactory(v.Department) |
|||
outCont.DepartmentName = departCont.Name |
|||
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(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
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").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) |
|||
gormDb = gormDb.Where("`qe_group` = ?", requestData.Group).Where("`qe_accept_evaluation` = ?", requestData.Department).Where("`qe_target` = ?", requestData.Target) |
|||
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 |
|||
_, groupCont := commonus.GetGroupCont(v.Group) |
|||
outCont.GroupName = groupCont.Name |
|||
outCont.Department = v.Department |
|||
_, departCont := commonus.GetBranchFactory(v.Department) |
|||
outCont.DepartmentName = departCont.Name |
|||
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) |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package evaluation |
|||
Loading…
Reference in new issue