绩效考核
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.
 
 
 

2093 lines
80 KiB

package evaluation
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"gin_server_admin/api/v1/archiveapi"
"gin_server_admin/api/wechatapp/sendmessage"
"gin_server_admin/commonus"
"gin_server_admin/global"
"gin_server_admin/model/assessmentmodel"
"gin_server_admin/model/common/response"
"github.com/gin-gonic/gin"
)
// 个人要执行的考核任务
func (e *EvaluationInterface) Index(c *gin.Context) {
outPut := commonus.MapOut()
response.Result(0, outPut, "用户端个人要执行的考核任务", c)
}
// 获取定性考核任务列表
func (e *EvaluationInterface) QualitativeEvaluation(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
// var qualEvaList []assessmentmodel.QualitativeEvaluation
// var detailsId []int64
// listErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_accept_evaluation").Where("`qe_type` = 1 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key).Group("qe_accept_evaluation").Find(&detailsId).Error
// if listErr != nil || len(detailsId) < 1 {
// response.Result(102, isTrue, "您没有要参加的考核项目!", c)
// return
// }
// response.Result(0, detailsId, "用户端个人要执行的考核任务", c)
var qualEvaList []assessmentmodel.QualitativeEvaluation
listErr := global.GVA_DB_Performanceappraisal.Where("`qe_type` = 1 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key).Order("qe_type ASC,qe_group ASC,qe_accept_evaluation ASC,qe_dimension ASC,qe_target ASC,qe_target_sun ASC,qe_detailed_target ASC").Find(&qualEvaList).Error
if listErr != nil || len(qualEvaList) < 1 {
response.Result(102, isTrue, "您没有要参加的考核项目!", c)
return
}
var uotContAry []TargetContOutCont
for _, v := range qualEvaList {
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 (e *EvaluationInterface) AdditionAndSubtractionScore(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
var requestData addPlusOrMinusPoints
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(102, err, "数据获取失败!", c)
return
}
if requestData.PlanId == "" {
response.Result(103, requestData, "未知考核项目!请检查你的提交是否正确!", c)
return
}
planIdInt, planIdIntErr := strconv.ParseInt(requestData.PlanId, 10, 64)
if planIdIntErr != nil {
response.Result(104, requestData, "未知考核项目!请检查你的提交是否正确!", c)
return
}
//获取考核项目内容
var programme assessmentmodel.QualitativeEvaluation
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", planIdInt).First(&programme).Error
if judgeProgramme != nil {
response.Result(105, programme, "未知考核项目!请检查你的提交是否正确!", c)
return
}
if requestData.Type == 0 {
response.Result(106, requestData, "请问您是要进行加分还是减分?请指定,谢谢!", c)
return
}
if requestData.Score == "" {
response.Result(107, requestData, "请您输入要操作的分数,谢谢!", c)
return
}
if requestData.Reason == "" {
response.Result(108, requestData, "请输入您的原因,谢谢!", c)
return
}
if requestData.Addtime == "" {
response.Result(108, requestData, "请输入您的检查时间,谢谢!", c)
return
}
if requestData.Rectification == 0 {
requestData.Rectification = 1
}
// happenTimeStr := fmt.Sprintf("%v:00", requestData.Addtime)
// happenTime := commonus.DateToTimeStamp(happenTimeStr)
operationTime := time.Now().Unix()
keyNumber := commonus.GetFileNumberEs()
var addScore assessmentmodel.ScoreFlow
addScore.EvaluationPlan = planIdInt
addScore.PlusReduceScore = requestData.Type
// addScore.Score = requestData.Score
addScore.Key = keyNumber
addScore.Reason = requestData.Reason
addScore.Time = operationTime
addScore.EiteTime = operationTime
addScore.HappenTime = commonus.DateToTimeStamp(requestData.Addtime)
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
if departmentIdErr == nil {
addScore.EvaluationDepartment = departmentId
}
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
if userKeyErr == nil {
addScore.EvaluationUser = userKey
}
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
if userGroupErr == nil {
addScore.EvaluationGroup = userGroup
}
addScore.Year = commonus.ComputingTime(operationTime, 1)
addScore.Quarter = commonus.ComputingTime(operationTime, 2)
addScore.Month = commonus.ComputingTime(operationTime, 3)
addScore.Week = commonus.ComputingTime(operationTime, 4)
enclosure, enclosureErr := json.Marshal(requestData.Enclosure)
if enclosureErr == nil {
addScore.Enclosure = string(enclosure)
}
addScore.DutyGroup = programme.Group
addScore.DutyDepartment = programme.AcceptEvaluation
addScore.Rectification = requestData.Rectification
addScore.Reply = 1
addErr := global.GVA_DB_Performanceappraisal.Create(&addScore).Error
//步进内容
if addErr != nil {
response.Result(109, addErr, "数据写入失败", c)
return
}
commonus.StepAddData(keyNumber, 0, 2, 1, 1, 2, 1, userCont.Key)
// /*
// @flowID 流程ID
// @userKey 操作人key
// @roleGroupId 角色组Id
// @stepName 步骤名称
// @stepInt 当前是第几部
// @nextStep 下一步
// */
// var evalProCont assessmentmodel.EvaluationProcess
// judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", keyNumber).First(&evalProCont).Error
// if judgeErr != nil {
// var flowStepAryMaps []FlowStep
// var flowSteping FlowStep
// flowSteping.Step = 1
// flowSteping.Key = strconv.FormatInt(keyNumber, 10)
// flowSteping.State = 1
// flowSteping.RoleGroup = 16118387069540343
// flowSteping.NextStep = 1
// flowSteping.ClickName = userCont.Key
// flowSteping.AddTime = time.Now().Unix()
// flowStepAryMaps = append(flowStepAryMaps, flowSteping)
// //fmt.Printf("%v------------------>%v\n", flowSteping, flowStepAryMaps)
// evalProCont.OrderKey = keyNumber
// evalProCont.Step = 1
// evalProCont.State = 1
// evalProCont.RoleGroup = 16118387069540343
// evalProCont.Time = time.Now().Unix()
// flowStepJson, flowStepErr := json.Marshal(flowStepAryMaps)
// if flowStepErr == nil {
// evalProCont.Content = string(flowStepJson)
// }
// // //fmt.Printf("------------------>%v\n", evalProCont)
// global.GVA_DB_Performanceappraisal.Create(&evalProCont)
// } else {
// var flowStepAry []FlowStep
// var flowStepArys []FlowStep
// json.Unmarshal([]byte(evalProCont.Content), &flowStepAry)
// for _, f_v := range flowStepAry {
// if f_v.Step == evalProCont.Step {
// f_v.State = 2
// }
// flowStepArys = append(flowStepArys, f_v)
// }
// var flowStep FlowStep
// flowStep.Step = evalProCont.Step + 1
// flowStep.Key = strconv.FormatInt(keyNumber, 10)
// flowStep.State = 1
// flowStep.RoleGroup = 16118387069540343
// flowStep.NextStep = 1
// flowStep.ClickName = userCont.Key
// flowStep.AddTime = time.Now().Unix()
// flowStepArys = append(flowStepArys, flowStep)
// saveData := commonus.MapOut()
// saveData["ep_time"] = time.Now().Unix()
// saveData["ep_role_group"] = 16118387069540343
// flowStepJson, flowStepErr := json.Marshal(flowStepArys)
// if flowStepErr == nil {
// saveData["ep_cont"] = string(flowStepJson)
// }
// EiteDutiesInfoes(evalProCont.Id, saveData)
// //fmt.Printf("----------3-------->%v\n", evalProCont)
// }
//给相关部门内勤发送消息。确定相关责任人
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, programme.AcceptEvaluation) //获取对应部门内勤
if sendUserIsTrue != true {
response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
return
}
// response.Result(0, sendUserList, "数据写入成功", c)
// return
var mainTitle string = ""
var mainTitleDesc string = ""
if programme.Type == 1 {
detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget)
if detailedTargetErr == true {
if detailedTargetCont.Title != "" {
mainTitle = detailedTargetCont.Title
} else {
mainTitle = requestData.Reason
}
if programme.Content == "" {
mainTitleDesc = detailedTargetCont.Content
} else {
mainTitleDesc = programme.Content
}
} else {
mainTitle = strconv.FormatInt(programme.DetailedTarget, 10)
mainTitleDesc = programme.Content
}
} else {
targetCont, targetErr := commonus.GetTargetInfo(programme.Target)
if targetErr == true {
mainTitle = targetCont.Title
mainTitleDesc = programme.Content
} else {
mainTitleDesc = programme.Content
}
}
// handleUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", keyNumber)
// callbakcMsg, isTrueCall, callBackCont := sendmessage.SendMsgPublic(sendUserList, mainTitle, mainTitleDesc, programme.Unit, requestData.Reason, handleUrl, requestData.Type, departmentId, userKey, requestData.Score, keyNumber, "请前往处理")
outData := commonus.MapOut()
// outData["callbakcMsg"] = string(callbakcMsg)
// outData["isTrueCall"] = isTrueCall
// outData["callBackCont"] = callBackCont
outData["addScore"] = addScore
outData["mainTitle"] = mainTitle
outData["mainTitleDesc"] = mainTitleDesc
response.Result(0, outData, "数据写入成功", c)
}
// 添加责任人
func (e *EvaluationInterface) AddDivisionResponsibility(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
var requestData DivisionResponsibilityType
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(102, err, "数据获取失败!", c)
return
}
if requestData.Id == "" {
response.Result(103, requestData, "未知考核项目!请检查你的提交是否正确!", c)
return
}
orderId, orderIdIntErr := strconv.ParseInt(requestData.Id, 10, 64)
if orderIdIntErr != nil {
response.Result(104, requestData, "未知考核项目!请检查你的提交是否正确!", c)
return
}
if len(requestData.UserList) < 1 {
response.Result(105, requestData, "请选择要考核的人员!", c)
return
}
var scoreFlowInfo assessmentmodel.ScoreFlow
judegFlowErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", orderId).First(&scoreFlowInfo).Error
if judegFlowErr != nil {
response.Result(106, judegFlowErr, "未知考核项目!请检查你的提交是否正确!", c)
return
}
//获取考核项目内容
var programme assessmentmodel.QualitativeEvaluation
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", scoreFlowInfo.EvaluationPlan).First(&programme).Error
if judgeProgramme != nil {
response.Result(105, programme, "未知考核项目!请检查你的提交是否正确!", c)
return
}
//给相关部门内勤发送消息。确定相关责任人
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, scoreFlowInfo.DutyDepartment) //获取对应部门内勤
if sendUserIsTrue != true {
response.Result(109, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
return
}
var reason string
var saveDataAry []assessmentmodel.DivisionResponsibilities
var saveDataErrAry []assessmentmodel.DivisionResponsibilities
for _, v := range requestData.UserList {
var saveDataCont assessmentmodel.DivisionResponsibilities
saveDataCont.ScoreFlow = orderId
saveDataCont.Type = v.Type
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
if departmentIdErr == nil {
saveDataCont.EvaluationDepartment = departmentId
}
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
if userKeyErr == nil {
saveDataCont.EvaluationUser = userKey
}
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
if userGroupErr == nil {
saveDataCont.EvaluationGroup = userGroup
}
//获取操作人
userFileStr := "wm_number,qywx_key,wx_key"
//操作人条件
userWherAry := commonus.MapOut()
// userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3"
userWherAry["wm_key"] = v.UserKey
userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry)
saveDataCont.UserName = v.UserName
saveDataCont.Weight = v.Weight
saveDataCont.Time = time.Now().Unix()
saveDataCont.EiteTime = time.Now().Unix()
saveDataCont.DistributionUser = commonus.GetFileNumberEs()
var userWechatErr bool
var userWechat commonus.PublicUserCont
if userIsTrue == true {
if userConting.Wechat != "" {
userWechatErr, userWechat = commonus.GetUesrContForWechatID(userConting.Wechat)
}
if userConting.WorkWechat != "" {
userWechatErr, userWechat = commonus.GetUesrContForWechatID(userConting.WorkWechat)
}
}
if userWechatErr == true {
saveDataCont.UserKey = userWechat.Key
saveDataCont.Group = userWechat.Group
saveDataCont.Department = userWechat.DepartmentId
saveDataCont.Tema = userWechat.Tema
var zeren string
switch v.Type {
case 1:
zeren = "主要责任人"
case 2:
zeren = "互保责任人"
case 3:
zeren = "责任班组"
case 4:
zeren = "责任班组长"
case 5:
zeren = "主管"
case 6:
zeren = "三大员"
case 7:
zeren = "厂长、主任"
default:
zeren = "主要责任人"
}
reason = reason + fmt.Sprintf("%v:%v 责任占比:%v\n", zeren, v.UserName, v.Weight)
saveDataAry = append(saveDataAry, saveDataCont)
} else {
saveDataErrAry = append(saveDataErrAry, saveDataCont)
}
}
if len(saveDataAry) < 1 {
response.Result(107, saveDataAry, "请检查您提交的要考核人员名单是否正确!", c)
return
}
global.GVA_DB_Performanceappraisal.Where("`df_sf_id` = ?", orderId).Delete(&assessmentmodel.DivisionResponsibilities{})
writeDataErr := global.GVA_DB_Performanceappraisal.Create(&saveDataAry).Error
if writeDataErr != nil {
response.Result(108, writeDataErr, "数据写入失败", c)
return
}
flowSaveData := commonus.MapOut()
flowSaveData["sf_reply"] = 2
flowSaveData["sf_eite_time"] = time.Now().Unix()
EiteScoreFlow(orderId, flowSaveData)
// return
keyNumber := commonus.GetFileNumberEs()
var evalProCont assessmentmodel.EvaluationProcess
judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", orderId).First(&evalProCont).Error
// //fmt.Printf("VVVVVVVVVVVVVVVVVVVVVVVVV%v\n", judgeErr)
if judgeErr != nil {
var flowStepAry []FlowStep
var flowStep FlowStep
flowStep.Step = 1
flowStep.Key = strconv.FormatInt(keyNumber, 10)
flowStep.State = 1
flowStep.RoleGroup = 16182159043990656
flowStep.NextStep = 2
flowStep.ClickName = userCont.Key
flowStep.AddTime = time.Now().Unix()
flowStepAry = append(flowStepAry, flowStep)
evalProCont.OrderKey = orderId
evalProCont.Step = 1
evalProCont.State = 1
evalProCont.Time = time.Now().Unix()
evalProCont.RoleGroup = 16182159043990656
flowStepJson, flowStepErr := json.Marshal(flowStepAry)
if flowStepErr == nil {
evalProCont.Content = string(flowStepJson)
}
global.GVA_DB_Performanceappraisal.Create(&evalProCont)
// //fmt.Printf("VVVVV--->%v\n", jsh)
} else {
var flowStepAry []FlowStep
var flowStepArys []FlowStep
json.Unmarshal([]byte(evalProCont.Content), &flowStepAry)
for _, f_v := range flowStepAry {
if f_v.Step == evalProCont.Step {
f_v.State = 2
}
flowStepArys = append(flowStepArys, f_v)
}
var flowStep FlowStep
flowStep.Step = evalProCont.Step + 1
flowStep.Key = strconv.FormatInt(keyNumber, 10)
flowStep.State = 1
flowStep.RoleGroup = 16182159043990656
flowStep.NextStep = 2
flowStep.ClickName = userCont.Key
flowStep.AddTime = time.Now().Unix()
flowStepArys = append(flowStepArys, flowStep)
saveData := commonus.MapOut()
saveData["ep_time"] = time.Now().Unix()
saveData["ep_role_group"] = 16182159043990656
saveData["ep_step"] = evalProCont.Step + 1
flowStepJson, flowStepErr := json.Marshal(flowStepArys)
if flowStepErr == nil {
saveData["ep_cont"] = string(flowStepJson)
}
EiteDutiesInfoes(evalProCont.Id, saveData)
}
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
var mainTitle string = "责任划分"
var mainTitleDesc string = ""
mainTitle = scoreFlowInfo.Reason
if scoreFlowInfo.PlusReduceScore == 1 {
mainTitleDesc = "增加:" + strconv.FormatInt(scoreFlowInfo.Score, 10) + programme.Unit
} else {
mainTitleDesc = "扣除:" + strconv.FormatInt(scoreFlowInfo.Score, 10) + programme.Unit
}
// if programme.Type == 1 {
// detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget)
// if detailedTargetErr == true {
// if detailedTargetCont.Title != "" {
// mainTitle = detailedTargetCont.Title
// } else {
// targetCont, targetErr := commonus.GetTargetInfo(programme.Target)
// if targetErr == true {
// mainTitle = targetCont.Title
// } else {
// mainTitle = strconv.FormatInt(programme.Target, 10)
// }
// }
// if programme.Content == "" {
// mainTitleDesc = detailedTargetCont.Content
// } else {
// mainTitleDesc = programme.Content
// }
// } else {
// mainTitle = strconv.FormatInt(programme.DetailedTarget, 10)
// mainTitleDesc = programme.Content
// }
// } else {
// targetCont, targetErr := commonus.GetTargetInfo(programme.Target)
// if targetErr == true {
// mainTitle = targetCont.Title
// mainTitleDesc = programme.Content
// } else {
// mainTitleDesc = programme.Content
// }
// }
subtitle := "责任划分"
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
if departmentIdErr != nil {
departmentId = 1
}
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
if userKeyErr != nil {
userKey = 0
}
var buttonMap []sendmessage.ButtonListtype
var buttonCont sendmessage.ButtonListtype
buttonCont.Type = 0
buttonCont.Text = "批准"
buttonCont.Style = 1
buttonCont.Key = fmt.Sprintf("duty_%v_1", orderId)
buttonMap = append(buttonMap, buttonCont)
buttonCont.Type = 0
buttonCont.Text = "驳回"
buttonCont.Style = 3
buttonCont.Key = fmt.Sprintf("duty_%v_2", orderId)
buttonMap = append(buttonMap, buttonCont)
callbakcMsg, isTrueCall, callBackCont, ss := sendmessage.SendButtonPublic(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, departmentId, userKey, keyNumber, orderId, buttonMap)
outData := commonus.MapOut()
outData["callbakcMsg"] = string(callbakcMsg)
outData["isTrueCall"] = isTrueCall
outData["callBackCont"] = callBackCont
outData["addScore"] = ss
// outData["sendTextMsg"] = sendTextMsg
response.Result(0, outData, "数据写入成功", c)
}
// 添加整改措施
func (e *EvaluationInterface) AddCorrectiveMeasures(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
if userKeyErr != nil {
response.Result(102, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
if departmentIdErr != nil {
response.Result(103, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
if userGroupErr != nil {
response.Result(104, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
var requestData CorrectiveMeasuresType
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(105, err, "数据获取失败!", c)
return
}
if requestData.OrderId == "" {
response.Result(106, err, "数据异常!", c)
return
}
orderidval, orderidvalErr := strconv.ParseInt(requestData.OrderId, 10, 64)
if orderidvalErr != nil {
response.Result(107, isTrue, "数据异常!!", c)
return
}
if requestData.Content == "" {
response.Result(108, err, "请输入整改内容!", c)
return
}
var addRecMeas assessmentmodel.RectificationMeasures
addRecMeas.UserKey = userKey
addRecMeas.Department = departmentId
addRecMeas.Group = userGroup
addRecMeas.OrderKey = orderidval
addRecMeas.State = 1
addRecMeas.Time = time.Now().Unix()
addRecMeas.EiteTime = time.Now().Unix()
addRecMeas.Content = requestData.Content
enclosure, enclosureErr := json.Marshal(requestData.Enclosure)
if enclosureErr == nil {
addRecMeas.Enclosure = string(enclosure)
}
addErr := global.GVA_DB_Performanceappraisal.Create(&addRecMeas).Error
//步进内容
if addErr != nil {
response.Result(109, addErr, "数据写入失败", c)
return
}
keyNumber := commonus.GetFileNumberEs()
UpEvaluationProcessApproval(orderidval, 16182159043990656, keyNumber, 4, userCont.Key)
_, sendUserList := commonus.GetSendMsgUser(16182159043990656, departmentId) //获取对应部门负责人(高科)
var scoreFlowInfo assessmentmodel.ScoreFlow
judegFlowErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", orderidval).First(&scoreFlowInfo).Error
if judegFlowErr != nil {
response.Result(110, err, "审批发送失败!", c)
return
}
var programme assessmentmodel.QualitativeEvaluation
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", scoreFlowInfo.EvaluationPlan).First(&programme).Error
if judgeProgramme != nil {
return
}
var mainTitle string = ""
if programme.DetailedTarget != 0 {
detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget)
if detailedTargetErr == true {
mainTitle = detailedTargetCont.Title
}
} else {
detailedTargetCont, detailedTargetErr := commonus.GetTargetInfo(programme.Target)
if detailedTargetErr == true {
mainTitle = detailedTargetCont.Title
}
}
mainTitleDesc := scoreFlowInfo.Reason
subtitle := "整改内容:"
reason := requestData.Content
callbakcMsg, isTrueCall, callBackCont := SendRectifyReceipt(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, scoreFlowInfo.DutyDepartment, userKey, keyNumber, scoreFlowInfo.Key, addRecMeas.Id)
outData := commonus.MapOut()
outData["callbakcMsg"] = string(callbakcMsg)
outData["isTrueCall"] = isTrueCall
outData["callBackCont"] = callBackCont
outData["addRecMeas"] = addRecMeas
response.Result(0, outData, "数据写入成功", c)
}
/*
发送文本任务卡
@sendUserList 接收信息人员
@Title 一级标题,建议不超过36个字
@Desc 标题辅助信息,建议不超过44个字
@Unit 考核计量单位
@Reason 二级文本标题
@handleUrl 访问Key
@Type 1:加分;2:减分
@departmentId 执行考核部门
@userKey 执行考核人
@Score 考核分值
@keyNumber 任务卡ID
@scoreReason 二级文本描述
@subTitleText 下级 组件标题"考核上报部门:"
@formId 表单ID
*/
func SendRectifyReceipt(sendUserList, mainTitle, mainTitleDesc, subtitle, reason string, departmentId, userKey, keyNumber, orderId, formId int64) (callbakcMsg []byte, isTrueCall bool, callBackCont string) {
if subtitle == "" {
subtitle = "整改内容"
}
var buttonMap []sendmessage.ButtonListtype
var buttonCont sendmessage.ButtonListtype
buttonCont.Type = 0
buttonCont.Text = "批准"
buttonCont.Style = 1
buttonCont.Key = fmt.Sprintf("duty_%v_1_%v", orderId, formId)
buttonMap = append(buttonMap, buttonCont)
buttonCont.Type = 0
buttonCont.Text = "驳回"
buttonCont.Style = 3
buttonCont.Key = fmt.Sprintf("duty_%v_2_%v", orderId, formId)
buttonMap = append(buttonMap, buttonCont)
callbakcMsg, isTrueCall, callBackCont, _ = sendmessage.SendButtonPublic(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, departmentId, userKey, keyNumber, orderId, buttonMap)
return
}
// 获取定量考核任务列表
func (e *EvaluationInterface) QualitativeEvalRation(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
var requestData GetRationFlowLog
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(102, err, "数据获取失败!", c)
return
}
//获取当月的起止时间
// startMonth, endMonth := commonus.GetAppointMonthStarAndEndTimeInt(time.Now().Unix())
//获取当月内所有的审批流程的部门及指标ID
// var qualEvalFlowLogList QualEvalFlowLog
// var evalId []int64
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where("fl_time BETWEEN ? AND ?", startMonth, endMonth).Find(&evalId)
// var qualEvaList []assessmentmodel.QualitativeEvaluation
// var detailsId []int64
// listErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_accept_evaluation").Where("`qe_type` = 1 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key).Group("qe_accept_evaluation").Find(&detailsId).Error
// if listErr != nil || len(detailsId) < 1 {
// response.Result(102, isTrue, "您没有要参加的考核项目!", c)
// return
// }
// response.Result(0, detailsId, "用户端个人要执行的考核任务", c)
// var qualEvaList []assessmentmodel.QualitativeEvaluation
var qualEvaList []assessmentmodel.QualitativeEvaluation
gormDbIng := global.GVA_DB_Performanceappraisal
gormDbIng = gormDbIng.Where("`qe_type` = 2 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", userCont.Key)
//判断是否已经提交上个月的数据
// if len(evalId) > 0 {
// gormDbIng = gormDbIng.Not(map[string]interface{}{"qe_id": evalId})
// }
if requestData.GroupId != "" {
gormDbIng = gormDbIng.Where("qe_group = ?", requestData.GroupId)
}
if requestData.DepartmentID != "" {
gormDbIng = gormDbIng.Where("qe_accept_evaluation = ?", requestData.DepartmentID)
}
if requestData.TargetId != "" {
gormDbIng = gormDbIng.Where("qe_target = ?", requestData.TargetId)
}
if requestData.Title != "" {
gormDbIng = gormDbIng.Where("et_title LIKE ?", "%"+requestData.Title+"%")
}
listErr := gormDbIng.Order("qe_type ASC,qe_group ASC,qe_accept_evaluation ASC,qe_dimension ASC,qe_target ASC,qe_target_sun ASC,qe_detailed_target ASC").Find(&qualEvaList).Error
if listErr != nil || len(qualEvaList) < 1 {
response.Result(102, qualEvaList, "您没有要参加的考核项目!", c)
return
}
var uotContAry []TargetContOutCont
for _, v := range qualEvaList {
// kickOut := 1 //踢出设置
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
uotCont.PlanVersionNumber = v.QualEvalId
// 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.ScoringMethod = int64(targetInfo.ScoringMethod)
}
if v.TargetSun != 0 {
uotCont.TargetSun = strconv.FormatInt(v.TargetSun, 10)
info, infoErr := commonus.GetQualitativeTargetInfo(v.TargetSun)
if infoErr == true {
uotCont.TargetSunName = info.Title
}
}
if v.DetailedTarget != 0 {
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})
usCont, usErr := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": u_v}, "number", "name")
if usErr == true {
var userCont QualEvalArrt
userCont.Id = u_v
userCont.Name = usCont.Name
uotCont.UserListAry = append(uotCont.UserListAry, userCont)
}
}
uotCont.DimensionWeight, uotCont.TargetWeight = getPlanVersionWeghit(v.QualEvalId, strconv.FormatInt(v.Dimension, 10), strconv.FormatInt(v.Target, 10))
//获取目标设定
quanTitWhere := commonus.MapOut()
quanTitWhere["group"] = v.Group
quanTitWhere["departmentid"] = v.AcceptEvaluation
quanTitWhere["dimension"] = v.Dimension
quanTitWhere["target"] = v.Target
if v.DetailedTarget != 0 {
quanTitWhere["targetconfig"] = v.DetailedTarget
}
quanTitWhere["year"] = commonus.TimeStampToDate(time.Now().Unix(), 11)
quanTitWhere["timecopy"] = AllZreoConfig(v.Cycles)
quanTitCont := commonus.GetQuantitativeConfig(quanTitWhere)
// jsonCont, _ := json.Marshal(quanTitCont)
// qualEvaListjsonCont, _ := json.Marshal(v)
// fmt.Printf("quanTitWhere----------->%v\n-------->%v\n-------->%v\n", quanTitWhere, string(jsonCont), string(qualEvaListjsonCont))
uotCont.ZeroPrize = strconv.FormatFloat(float64(quanTitCont.Zeroprize)/100, 'f', -1, 64)
uotCont.AllPrize = strconv.FormatFloat(float64(quanTitCont.Allprize)/100, 'f', -1, 64)
uotCont.CappingVal = quanTitCont.CappingVal / 100
//获取实际值
shiJiZhi := commonus.MapOut()
shiJiZhi["fl_evaluation_user"] = userCont.Key
shiJiZhi["fl_evaluation_department"] = userCont.Deparment
shiJiZhi["fl_evaluation_group"] = userCont.Company
operationTime := time.Now().Unix()
switch v.Cycles {
case 1:
shiJiZhi["fl_year"] = commonus.ComputingTime(operationTime, 1)
shiJiZhi["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
shiJiZhi["fl_month"] = commonus.ComputingTime(operationTime, 3)
shiJiZhi["fl_week"] = commonus.ComputingTime(operationTime, 4)
shiJiZhi["fl_day"] = commonus.ComputingTime(operationTime, 5)
case 2:
shiJiZhi["fl_year"] = commonus.ComputingTime(operationTime, 1)
shiJiZhi["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
shiJiZhi["fl_month"] = commonus.ComputingTime(operationTime, 3)
shiJiZhi["fl_week"] = commonus.ComputingTime(operationTime, 4)
shiJiZhi["fl_day"] = commonus.ComputingTime(operationTime, 5)
case 3:
shiJiZhi["fl_year"] = commonus.ComputingTime(operationTime, 1)
shiJiZhi["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
shiJiZhi["fl_month"] = commonus.ComputingTime(operationTime, 3)
shiJiZhi["fl_week"] = commonus.ComputingTime(operationTime, 4)
case 4:
shiJiZhi["fl_year"] = commonus.ComputingTime(operationTime, 1)
shiJiZhi["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
shiJiZhi["fl_month"] = commonus.ComputingTime(operationTime, 3)
case 5:
shiJiZhi["fl_year"] = commonus.ComputingTime(operationTime, 1)
shiJiZhi["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
case 6:
shiJiZhi["fl_year"] = commonus.ComputingTime(operationTime, 1)
default:
shiJiZhi["fl_year"] = commonus.ComputingTime(operationTime, 1)
shiJiZhi["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
shiJiZhi["fl_month"] = commonus.ComputingTime(operationTime, 3)
shiJiZhi["fl_week"] = commonus.ComputingTime(operationTime, 4)
shiJiZhi["fl_day"] = commonus.ComputingTime(operationTime, 5)
}
actualValue := commonus.GetTimeIntervalDuty(shiJiZhi, v.Id) //实际值
uotCont.Actual = strconv.FormatFloat(actualValue/100, 'f', -1, 64)
chuShuVal := actualValue - quanTitCont.Zeroprize
beiChuShuVal := quanTitCont.Allprize - quanTitCont.Zeroprize
if beiChuShuVal > 0 {
uotCont.ReachScore = chuShuVal / beiChuShuVal
} else {
uotCont.ReachScore = 0
}
// judgeActualValue := commonus.GetTimeIntervalDutyJudge(shiJiZhi, v.Id) //判断当前条件下时候又审批中和审批通过的
// if judgeActualValue > 0 {
// kickOut = 2
// }
//计算达成率
if quanTitCont.Zeroprize == 0 && quanTitCont.Allprize == 0 {
uotCont.Reach = "未设置目标值"
} else {
// divisor := actualValue - float64(quanTitCont.Zeroprize) //除数
dividend := quanTitCont.Allprize - quanTitCont.Zeroprize //被除数
if dividend == 0 {
uotCont.Reach = "未设置目标值"
} else {
uotCont.Reach = fmt.Sprintf("((实际值-零奖值)/(全奖值-零奖值))*指标权重")
// reachValue := ((divisor / 100) / (float64(dividend) / 100)) * 100
// if reachValue < 0 {
// uotCont.Reach = "0%"
// } else {
// reachValueStr := strconv.FormatFloat(reachValue, 'f', -1, 64)
// uotCont.Reach = fmt.Sprintf("%v%", reachValueStr)
// }
}
}
uotCont.Reason = ""
uotCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10)
// if kickOut == 1 {
// uotContAry = append(uotContAry, uotCont)
// }
uotContAry = append(uotContAry, uotCont)
}
response.Result(0, uotContAry, "用户端个人要执行的考核任务", c)
}
// 添加定量考核项目
func (e *EvaluationInterface) AddFlowRationLog(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64)
if userKeyErr != nil {
response.Result(102, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64)
if departmentIdErr != nil {
response.Result(103, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64)
if userGroupErr != nil {
response.Result(104, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
todaying := commonus.ComputingTime(time.Now().Unix(), 5)
if todaying > 10 {
// response.Result(1051, todaying, "不在可提交数据提时间期限内!不可提交数据。请每月10号前提交数据!。", c)
// return
}
var requestData AddRationFlowLog
err := c.ShouldBindJSON(&requestData)
if err != nil {
response.Result(105, err, "数据获取失败!", c)
return
}
if requestData.GroupId == "" {
response.Result(106, err, "数据异常!", c)
return
}
if requestData.DepartmentID == "" {
response.Result(107, err, "数据异常!", c)
return
}
if len(requestData.List) < 1 {
response.Result(108, err, "没有要考核的项目", c)
return
}
//判断是否已经添加的条件
existenceProess := commonus.MapOut()
existenceProess["fl_planversion"] = requestData.PlanVersionNumber
operationTime := time.Now().Unix()
keyNumber := commonus.GetFileNumberEs()
var flowLog assessmentmodel.FlowLog
flowLog.Key = keyNumber
flowLog.Time = time.Now().Unix()
flowLog.EiteTime = time.Now().Unix()
flowLog.PlanVersion = requestData.PlanVersionNumber
if requestData.Addtime != "" {
timeOccurrence := commonus.DateToTimeStamp(requestData.Addtime) //发生时间
flowLog.Year = commonus.ComputingTime(timeOccurrence, 1)
flowLog.Quarter = commonus.ComputingTime(timeOccurrence, 2)
flowLog.Month = commonus.ComputingTime(timeOccurrence, 3)
flowLog.Week = commonus.ComputingTime(timeOccurrence, 4)
flowLog.ToDay = commonus.ComputingTime(timeOccurrence, 5)
existenceProess["fl_year"] = commonus.ComputingTime(timeOccurrence, 1)
existenceProess["fl_quarter"] = commonus.ComputingTime(timeOccurrence, 2)
existenceProess["fl_month"] = commonus.ComputingTime(timeOccurrence, 3)
existenceProess["fl_week"] = commonus.ComputingTime(timeOccurrence, 4)
existenceProess["fl_day"] = commonus.ComputingTime(timeOccurrence, 5)
} else {
lastMonth, _, _ := commonus.GetLastMonth()
lastMonthInt, lastMonthErr := commonus.DateToTimeStampEs(fmt.Sprintf("%v-10 12:00:00", lastMonth))
if lastMonthErr == true {
operationTime = lastMonthInt
}
flowLog.Year = commonus.ComputingTime(operationTime, 1)
flowLog.Quarter = commonus.ComputingTime(operationTime, 2)
flowLog.Month = commonus.ComputingTime(operationTime, 3)
flowLog.Week = commonus.ComputingTime(operationTime, 4)
flowLog.ToDay = commonus.ComputingTime(operationTime, 5)
existenceProess["fl_year"] = commonus.ComputingTime(operationTime, 1)
existenceProess["fl_quarter"] = commonus.ComputingTime(operationTime, 2)
existenceProess["fl_month"] = commonus.ComputingTime(operationTime, 3)
existenceProess["fl_week"] = commonus.ComputingTime(operationTime, 4)
existenceProess["fl_day"] = commonus.ComputingTime(operationTime, 5)
}
flowLog.EvaluationDepartment = departmentId
flowLog.EvaluationUser = userKey
flowLog.EvaluationGroup = userGroup
// existenceProess["fl_evaluation_department"] = departmentId
// existenceProess["fl_evaluation_user"] = userKey
// existenceProess["fl_evaluation_group"] = userGroup
dutyGroup, dutyGroupErr := strconv.ParseInt(requestData.GroupId, 10, 64)
if dutyGroupErr == nil {
flowLog.DutyGroup = dutyGroup
existenceProess["fl_duty_group"] = dutyGroup
}
departIdInt, departIdIntErr := strconv.ParseInt(requestData.DepartmentID, 10, 64)
if departIdIntErr == nil {
flowLog.DutyDepartment = departIdInt
existenceProess["fl_duty_department"] = departIdInt
}
flowLog.Reply = 1
var evaluationIdStr string
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Select("fl_evaluation_id").Where(existenceProess).First(&evaluationIdStr)
var evaluationIdStrAry []string
if evaluationIdStr != "" {
evaluationIdStrAry = strings.Split(evaluationIdStr, ",")
}
var flowDataLogAry []assessmentmodel.FlowLogData
var reason string
var evaluationPlan []string //方案ID
var yiTianJianMingc []string
// jsonMapStr, _ := json.Marshal(requestData.List)
json.Marshal(requestData.List)
//fmt.Printf("OutJsonMap-----1------>%\n", string(jsonMapStr))
for i, v := range requestData.List {
if len(evaluationIdStrAry) > 0 {
if commonus.IsItTrueString(v.Id, evaluationIdStrAry) == false {
var flowDataLog assessmentmodel.FlowLogData
evaluationPlan = append(evaluationPlan, v.Id)
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
if evaluationPlanidErr == nil {
flowDataLog.EvaluationPlan = evaluationPlanid
}
flowDataLog.Key = keyNumber
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
flowDataLog.Content = v.Reason
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
if v.ScoringMethod == 2 {
flowDataLog.ScoringMethod = 2
flowDataLog.ScoringScore = v.ScoringScore
} else {
flowDataLog.ScoringMethod = 1
flowDataLog.ScoringScore = 0
}
// flowDataLog.PlanVersion = v.PlanVersionNumber
flowDataLog.Time = time.Now().Unix()
targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(evaluationPlanid, 10))
tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
if i == 0 {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
}
}
} else {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
}
}
}
flowDataLogAry = append(flowDataLogAry, flowDataLog)
} else {
yiTianJianMingc = append(yiTianJianMingc, v.TargetName)
}
} else {
var flowDataLog assessmentmodel.FlowLogData
evaluationPlan = append(evaluationPlan, v.Id)
evaluationPlanid, evaluationPlanidErr := strconv.ParseInt(v.Id, 10, 64)
if evaluationPlanidErr == nil {
flowDataLog.EvaluationPlan = evaluationPlanid
}
flowDataLog.Key = keyNumber
flowDataLog.Score = commonus.GetDuyCycle(v.Actual, 100)
flowDataLog.Content = v.Reason
flowDataLog.Enclosure = strings.Join(v.Enclosure, ",")
if v.ScoringMethod == 2 {
flowDataLog.ScoringMethod = 2
flowDataLog.ScoringScore = v.ScoringScore
} else {
flowDataLog.ScoringMethod = 1
flowDataLog.ScoringScore = 0
}
flowDataLog.PlanVersion = requestData.PlanVersionNumber
flowDataLog.Time = time.Now().Unix()
targetInfo, targetInfoErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(evaluationPlanid, 10))
tarInfo, _ := commonus.GetTargetInfo(targetInfo.Target)
if i == 0 {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v :%v%v\n备注:%v", tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v :%v%v", tarInfo.Title, v.Actual, v.Unit)
}
}
} else {
if targetInfoErr == true {
if v.Reason != "" {
reason = fmt.Sprintf("%v\n%v :%v%v\n备注:%v", reason, tarInfo.Title, v.Actual, v.Unit, v.Reason)
} else {
reason = fmt.Sprintf("%v\n%v :%v%v", reason, tarInfo.Title, v.Actual, v.Unit)
}
}
}
flowDataLogAry = append(flowDataLogAry, flowDataLog)
}
}
gromDb := global.GVA_DB_Performanceappraisal.Begin()
flowLog.EvaluationPlan = strings.Join(evaluationPlan, ",")
if len(flowDataLogAry) <= 0 {
response.Result(0, yiTianJianMingc, "您的数据已经提交!请不要重复提交!", c)
return
}
addFlowLogErr := gromDb.Create(&flowLog).Error
addFlowLogDataErr := gromDb.Create(&flowDataLogAry).Error
commonus.StepAddData(keyNumber, 16182159043990656, 2, 7, 2, 1, 1, userCont.Key)
// response.Result(0, flowLog, "数据写入成功", c)
// return
//暂停审核方便录入测试数据
//fmt.Printf("%v---------------------->%v\n", addFlowLogErr, addFlowLogDataErr)
if addFlowLogErr == nil && addFlowLogDataErr == nil {
affairDbErr := gromDb.Commit().Error
if affairDbErr == nil {
//发送消息
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, departIdInt) //获取对应部门负责人
if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
// return
}
// UpEvaluationProcessApproval(keyNumber, 16182159043990656, keyNumber, 1, userCont.Key)
commonus.StepAddData(keyNumber, 16182159043990656, 2, 7, 2, 1, 1, userCont.Key)
mainTitle := fmt.Sprintf("%v数据表", commonus.TimeStampToDate(operationTime, 10))
mainTitleDesc := ""
subtitle := "数据详情:"
// reason := requestData.Content
// callbakcMsg, isTrueCall, callBackCont := SendRectifyReceipt(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, departmentId, userKey, keyNumber, keyNumber, 0)
var buttonMap []sendmessage.ButtonListtype
var buttonCont sendmessage.ButtonListtype
buttonCont.Type = 0
buttonCont.Text = "批准"
buttonCont.Style = 1
buttonCont.Key = fmt.Sprintf("ration_%v_1", keyNumber)
buttonMap = append(buttonMap, buttonCont)
buttonCont.Type = 0
buttonCont.Text = "驳回"
buttonCont.Style = 3
buttonCont.Key = fmt.Sprintf("ration_%v_2", keyNumber)
buttonMap = append(buttonMap, buttonCont)
// callbakcMsg, isTrueCall, callBackCont, sendText := sendmessage.SendButtonPublicRation(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, departmentId, userKey, keyNumber, keyNumber, buttonMap)
sendmessage.SendButtonPublicRation(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, departmentId, userKey, keyNumber, keyNumber, buttonMap)
//fmt.Printf("1、更新发送信息返回:%v-----------%v----------->%v-----%v\n", string(callbakcMsg), isTrueCall, callBackCont, sendText)
response.Result(0, yiTianJianMingc, "数据提交成功!", c)
} else {
gromDb.Rollback()
response.Result(118, yiTianJianMingc, "数据提交失败!", c)
}
} else {
affairDbErr := gromDb.Rollback().Error
if affairDbErr == nil {
response.Result(119, yiTianJianMingc, "数据提交失败!", c)
} else {
response.Result(120, yiTianJianMingc, "数据提交失败!", c)
}
}
}
// 查看定性考核审批列表
func (e *EvaluationInterface) LookDutkScoreFlow(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, userCont, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
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 titleVal string = ""
//fmt.Printf("1-------------------->\n")
var addScore assessmentmodel.ScoreFlow
gerErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", requestData.Id).Find(&addScore).Error
//fmt.Printf("2-------------------->%v\n", gerErr)
if gerErr != nil {
response.Result(103, gerErr, "没有此审批单!", c)
return
}
//fmt.Printf("3-------------------->%v\n", gerErr)
// return
//获取方案
qualEvalCont, qualEvalErr := commonus.GetQualitativeEvaluation(strconv.FormatInt(addScore.EvaluationPlan, 10))
//fmt.Printf("4-------------------->%v\n", addScore.EvaluationPlan)
if qualEvalErr != true {
response.Result(103, qualEvalErr, "没有此方案!", c)
return
}
//fmt.Printf("5-------------------->%v\n", qualEvalErr)
var dutyCecorFlowInfo DutyCecorFlow
dutyCecorFlowInfo.OrderId = strconv.FormatInt(requestData.Id, 10)
//fmt.Printf("6-------------------->%v\n", requestData.Id)
if qualEvalCont.Dimension != 0 {
dimInfo, dimInfoErr := commonus.GetDutyClassInfo(qualEvalCont.Dimension)
if dimInfoErr == true {
dutyCecorFlowInfo.Dimension = dimInfo.Title
titleVal = dimInfo.Title
}
}
if qualEvalCont.Target != 0 {
target, targetErr := commonus.GetTargetInfo(qualEvalCont.Target)
if targetErr == true {
dutyCecorFlowInfo.Target = target.Title
titleVal = target.Title
}
}
if qualEvalCont.TargetSun != 0 {
tarsun, tarsunErr := commonus.GetQualitativeTargetInfo(qualEvalCont.TargetSun)
if tarsunErr == true {
dutyCecorFlowInfo.TargetSun = tarsun.Title
// titleVal = tarsun.Title
}
}
//单位划分
var danWeStr string
if qualEvalCont.DetailedTarget != 0 {
detaTar, detaTarErr := commonus.GetDetailedTargetInfo(qualEvalCont.DetailedTarget)
if detaTarErr == true {
var danWeStrAry []string
danWeStrAry = strings.Split(detaTar.Company, "/")
if len(danWeStrAry) > 0 {
danWeStr = danWeStrAry[0]
}
dutyCecorFlowInfo.DetailedTarget = detaTar.Title
dutyCecorFlowInfo.Content = detaTar.Content
// titleVal = detaTar.Title
if detaTar.MaxScore != 0 && detaTar.MinScore != 0 {
dutyCecorFlowInfo.Content = fmt.Sprintf("%v-%v%v", float64(detaTar.MinScore)/100, float64(detaTar.MaxScore)/100, detaTar.Company)
} else if detaTar.MaxScore != 0 && detaTar.MinScore == 0 {
dutyCecorFlowInfo.Content = fmt.Sprintf("%v%v", float64(detaTar.MaxScore)/100, detaTar.Company)
} else if detaTar.MaxScore == 0 && detaTar.MinScore != 0 {
dutyCecorFlowInfo.Content = fmt.Sprintf("%v%v", float64(detaTar.MinScore)/100, detaTar.Company)
} else {
dutyCecorFlowInfo.Content = "未设置标准。"
}
}
}
fmt.Printf("7-------------------->%v\n", danWeStr)
dutyCecorFlowInfo.Reason = addScore.Reason
if addScore.Enclosure != "" {
var fujian []EnclosureFormat
json.Unmarshal([]byte(addScore.Enclosure), &fujian)
dutyCecorFlowInfo.Enclosure = fujian
// fmt.Printf("FileType----------------->%v------------->%v\n", jsonerr, addScore.Enclosure)
// enclosure, enclosureErr := json.Marshal(addScore.Enclosure)
// if enclosureErr == nil {
// dutyCecorFlowInfo.Enclosure = string(enclosure) //附件
// }
}
// dutyCecorFlowInfo.Enclosure =
//分数
sendScore := addScore.Score * int64(addScore.Count)
if addScore.PlusReduceScore == 1 {
dutyCecorFlowInfo.LanMuName = "考核加分"
// dutyCecorFlowInfo.ReasonInfo = fmt.Sprintf("%v%v\n", float64(sendScore)/100, danWeStr)
dutyCecorFlowInfo.ReasonInfo = fmt.Sprintf("%v\n", float64(sendScore)/100)
} else {
dutyCecorFlowInfo.LanMuName = "考核减分"
// dutyCecorFlowInfo.ReasonInfo = fmt.Sprintf("考核减%v%v\n", float64(sendScore)/100, danWeStr)
dutyCecorFlowInfo.ReasonInfo = fmt.Sprintf("%v\n", float64(sendScore)/100)
}
// if addScore.PlusReduceScore == 1 {
// dutyCecorFlowInfo.ReasonInfo = "增加:" + strconv.FormatInt(addScore.Score, 10) + qualEvalCont.Unit
// } else {
// dutyCecorFlowInfo.ReasonInfo = "扣除:" + strconv.FormatInt(addScore.Score, 10) + qualEvalCont.Unit
// }
//fmt.Printf("8-------------------->%v\n", requestData.Id)
if addScore.Rectification == 1 {
var divisionResponsibilities []assessmentmodel.DivisionResponsibilities
dRBerr := global.GVA_DB_Performanceappraisal.Where("df_sf_id = ?", requestData.Id).Find(&divisionResponsibilities).Error
//fmt.Printf("8-------1------------->%v\n", divisionResponsibilities)
if dRBerr == nil {
for _, d_v := range divisionResponsibilities {
//fmt.Printf("8-------2------------->%v\n", d_v.UserKey)
var divBilInfo DivisiosibilityType
switch d_v.Type {
case 1:
divBilInfo.Type = "主要责任人"
case 2:
divBilInfo.Type = "互保责任人"
case 3:
divBilInfo.Type = "责任班组"
case 4:
divBilInfo.Type = "责任班组长"
case 5:
divBilInfo.Type = "主管"
case 6:
divBilInfo.Type = "三大员"
case 7:
divBilInfo.Type = "厂长、主任"
default:
divBilInfo.Type = "主要责任人"
}
userInfoGet, userInfoGetErr := commonus.GetWorkUser(strconv.FormatInt(d_v.UserKey, 10))
if userInfoGetErr == true {
divBilInfo.UserName = userInfoGet.Name
}
//fmt.Printf("8-------1-3------------>%v\n", userInfoGet)
// divBilInfo.Weight = int64(d_v.Weight)
divBilInfo.Weight = d_v.Weight / 100
dutyCecorFlowInfo.DivisionResponsibility = append(dutyCecorFlowInfo.DivisionResponsibility, divBilInfo)
}
}
var recMeasCont []assessmentmodel.RectificationMeasures
judgeRecMeas := global.GVA_DB_Performanceappraisal.Where("`rm_order` = ?", requestData.Id).First(&recMeasCont).Error
if judgeRecMeas == nil {
for _, r_v := range recMeasCont {
var recMeasInfo RectifMeasures
whe := commonus.MapOut()
whe["wm_key"] = r_v.UserKey
uidVal, uidValErr := commonus.GetUserInfoPublic("worker_man.*,worker_man_data.*", whe)
if uidValErr == true {
recMeasInfo.RecName = uidVal.Name
}
recMeasInfo.RecCont = r_v.Content
recMeasInfo.State = r_v.State
recMeasInfo.TimeVal = commonus.TimeStampToDate(r_v.Time, 1)
if r_v.Enclosure != "" && r_v.Enclosure != "null" {
json.Unmarshal([]byte(r_v.Enclosure), &recMeasInfo.Enclosure)
}
dutyCecorFlowInfo.RectifMeasures = append(dutyCecorFlowInfo.RectifMeasures, recMeasInfo)
}
}
}
//fmt.Printf("9-------------------->%v\n", requestData.Id)
var evalProInfo assessmentmodel.EvaluationProcess
gerEvalErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", requestData.Id).Find(&evalProInfo).Error
//fmt.Printf("9-----------1--------->%v\n", gerEvalErr)
if gerEvalErr == nil {
fmt.Printf("evalProInfo.NextExecutor------->%v-------》userCont.Key------->%v\n", evalProInfo.NextExecutor, userCont.Key)
dutyCecorFlowInfo.IsSet = 2
isSetUser := strings.Split(evalProInfo.NextExecutor, ",")
if len(isSetUser) > 0 {
if commonus.IsItTrueString(userCont.Key, isSetUser) == true {
dutyCecorFlowInfo.IsSet = 1
}
}
var flowStepAryMaps []FlowStep
jsonFlowErr := json.Unmarshal([]byte(evalProInfo.Content), &flowStepAryMaps)
//fmt.Printf("9-----------2--------->%v\n", flowStepAryMaps)
if jsonFlowErr == nil {
//fmt.Printf("9-----------3--------->%v\n", flowStepAryMaps)
if len(flowStepAryMaps) > 0 {
for _, fw_v := range flowStepAryMaps {
var flowLog TechnologicalProcessType
flowLog.Step = fw_v.Step
flowLog.State = fw_v.State
workUser, workUserErr := commonus.GetWorkUser(fw_v.ClickName)
//fmt.Printf("9-----------4-----2---->%v\n", fw_v)
if workUserErr == true {
//fmt.Printf("9-----------4-----1---->%v\n", workUserErr)
// bfErr, bf := commonus.GetBranchFactory(workUser.DepartmentId)
bf, bfErr := commonus.GetNewOrgCont(workUser.MainDeparment)
//fmt.Printf("9-----------4-----3---->%v\n", bfErr)
if bfErr == nil {
getGroupRoleInfoErr, getGroupRoleInfo, roleGroupInfo := commonus.GetOfficeWork(fw_v.RoleGroup, int64(bf.WechatOrganizationId))
//fmt.Printf("9-----------4-----5---->%v---->%v---->%v\n", getGroupRoleInfoErr, getGroupRoleInfo, roleGroupInfo)
if getGroupRoleInfoErr == true {
flowLog.GroupName = roleGroupInfo.Title
for _, rg_v := range getGroupRoleInfo {
clickUserInfoErr, clickUserInfo := commonus.GetUesrContForWechatID(rg_v.Id)
//fmt.Printf("9-----------4--------->%v\n", clickUserInfoErr)
var caoZuoRenInfnfo caoZuoRen
if clickUserInfoErr == true {
if strconv.FormatInt(clickUserInfo.Key, 10) == fw_v.ClickName {
caoZuoRenInfnfo.IsTrue = 1
if fw_v.AddTime != 0 {
caoZuoRenInfnfo.TimeVal = commonus.TimeStampToDate(fw_v.AddTime, 1)
}
}
gErrs, groupInfos := commonus.GetGroupCont(clickUserInfo.Group)
if gErrs == true {
caoZuoRenInfnfo.GroupName = groupInfos.Name
}
caoZuoRenInfnfo.DepartmentName = clickUserInfo.DepartmentName
caoZuoRenInfnfo.WorkShopName = clickUserInfo.WorkshopName
caoZuoRenInfnfo.Postname = clickUserInfo.PostName
caoZuoRenInfnfo.TeamName = clickUserInfo.TemaName
caoZuoRenInfnfo.Icon = clickUserInfo.Icon
caoZuoRenInfnfo.Name = clickUserInfo.Name
flowLog.UserList = append(flowLog.UserList, caoZuoRenInfnfo)
}
// var caoZuoRenInfnfo caoZuoRen
// caoZuoRenInfnfo.Name =
// if workUser.WechatId == rg_v.Id || workUser.WorkWechatId == rg_v.Id {
// }
}
}
}
}
dutyCecorFlowInfo.TechnologicalProcess = append(dutyCecorFlowInfo.TechnologicalProcess, flowLog)
}
}
}
//流程全面
var flowAllMapList []commonus.FlowAllMap
// fmt.Printf("evalProInfo.NextContent----------->%v\n", evalProInfo.NextContent)
jsonFlowErrers := json.Unmarshal([]byte(evalProInfo.NextContent), &flowAllMapList)
// fmt.Printf("flowAllMapList----------->%v\n", flowAllMapList)
if jsonFlowErrers == nil {
dutyCecorFlowInfo.FlowMapAll = flowAllMapList
}
// fmt.Printf("flowAllMapList----------->%v\n", dutyCecorFlowInfo.FlowMapAll)
}
var flowLogList []assessmentmodel.AssessmentLogIng
flowLogErr := global.GVA_DB_Performanceappraisal.Where("al_order_id = ?", requestData.Id).Order("al_id ASC").Find(&flowLogList).Error
if flowLogErr == nil {
for flli, fllv := range flowLogList {
var flowListCont FlowContLog
if fllv.DutyList == "" && flli == 0 {
flowListCont.Content = "创建申请"
} else {
flowListCont.Content = fllv.DutyList
}
flowListCont.TimeVal = commonus.TimeStampToDate(fllv.ExecutorTime, 6)
userFlowCont, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": fllv.ExecutorUser})
flowListCont.Name = userFlowCont.Name
flowListCont.Icon = userFlowCont.Icon
gorupCont, _ := commonus.GetNewOrgCont(map[string]interface{}{"`id`": fllv.ExecutorDepart}, "`name`")
flowListCont.DepartmentName = gorupCont.Name
dutyCecorFlowInfo.ApprovalRecord = append(dutyCecorFlowInfo.ApprovalRecord, flowListCont)
}
}
titlekUserInfo, _ := commonus.GetWorkUser(strconv.FormatInt(addScore.EvaluationUser, 10))
// titleStr := fmt.Sprintf("%v提交%v考核数据 %v", titlekUserInfo.Name, titleVal, commonus.TimeStampToDate(addScore.HappenTime,6))
BranchInfo, dErr := commonus.GetNewOrgCont(addScore.DutyDepartment, "name")
if dErr == nil {
dutyCecorFlowInfo.Title = fmt.Sprintf("%v提交%v%v考核数据 %v", titlekUserInfo.Name, BranchInfo.Name, titleVal, commonus.TimeStampToDate(addScore.HappenTime, 6))
} else {
dutyCecorFlowInfo.Title = fmt.Sprintf("%v提交%v考核数据 %v", titlekUserInfo.Name, titleVal, commonus.TimeStampToDate(addScore.HappenTime, 6))
}
response.Result(0, dutyCecorFlowInfo, "获取成功", c)
}
// 查看定量考核列表
func (d *EvaluationInterface) LookRationkScoreFlow(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, userCont, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
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, requestData, "参数错误!请重新提交!", c)
return
}
if requestData.OutId != "" {
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64)
if inIntErr == nil {
requestData.Id = idInt
}
}
var flowDataLog []assessmentmodel.FlowLogData
getErr := global.GVA_DB_Performanceappraisal.Where("`fld_flow_log` = ?", requestData.Id).Order("fld_id ASC").Find(&flowDataLog).Error
if getErr != nil {
response.Result(103, err, "参数错误!请重新提交!", c)
return
}
var flowLogInfo assessmentmodel.FlowLog
getErrs := global.GVA_DB_Performanceappraisal.Where("`fl_key` = ?", requestData.Id).First(&flowLogInfo).Error
var planVersioCont assessmentmodel.PlanVersio
global.GVA_DB_Performanceappraisal.Where("`key` = ?", flowLogInfo.PlanVersion).First(&planVersioCont)
var planVersioInfo []AddDutyNewCont
if planVersioCont.Content != "" {
json.Unmarshal([]byte(planVersioCont.Content), &planVersioInfo)
// jsonErr := json.Unmarshal([]byte(planVersioCont.Content), &planVersioInfo)
// if jsonErr == nil {
// for _, v := range planVersioInfo {
// for _, cv := range v.Child {
// if cv.Id == strconv.FormatInt(planVersioCont.Id, 10) {
// targetScore = cv.ReferenceScore
// }
// }
// }
// }
}
// var flowLogInfo
var outList []RationOutStruct
for _, v := range flowDataLog {
var targetScore int64 = 0
var outContt RationOutStruct
outContt.Id = strconv.FormatInt(v.Id, 10)
outContt.FlowId = strconv.FormatInt(v.Key, 10)
targetCont, targetContErr := commonus.LookRationInfo(v.EvaluationPlan)
if targetContErr == true {
outContt.Title = targetCont.Title
outContt.Unit = targetCont.Unit
outContt.Cycles = targetCont.Cycles
outContt.CycleAttres = targetCont.CycleAttres
var monthQues int64 = 1
switch targetCont.Cycles {
case 5:
monthQues = flowLogInfo.Quarter
case 6:
monthQues = 1
default:
monthQues = flowLogInfo.Month
}
if len(planVersioInfo) > 0 {
for _, pviv := range planVersioInfo {
for _, pvivcv := range pviv.Child {
if pvivcv.Id == strconv.FormatInt(targetCont.Target, 10) {
targetScore = pvivcv.ReferenceScore
}
}
}
}
outContt.Weight = float64(targetScore)
//获取指标
var tarGetId int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_target").Where("`qe_id` = ?", v.EvaluationPlan).First(&tarGetId)
// outContt.Actual, outContt.AllPrize, outContt.ZeroPrize, outContt.CappingVal, outContt.Achievement = GetQuantitativeConfig(targetScore, float64(v.Score), strconv.FormatInt(flowLogInfo.DutyGroup, 10), strconv.FormatInt(flowLogInfo.DutyDepartment, 10), strconv.FormatInt(targetCont.Dimension, 10), strconv.FormatInt(tarGetId, 10), strconv.FormatInt(targetCont.DetailedTarget, 10), flowLogInfo.Year, monthQues)
// targetScore = v.Score
outContt.Actual, outContt.AllPrize, outContt.ZeroPrize, outContt.CappingVal, outContt.Achievement = GetQuantitativeConfig(targetScore, float64(v.Score), strconv.FormatInt(flowLogInfo.DutyGroup, 10), strconv.FormatInt(flowLogInfo.DutyDepartment, 10), strconv.FormatInt(targetCont.Dimension, 10), strconv.FormatInt(tarGetId, 10), strconv.FormatInt(targetCont.DetailedTarget, 10), flowLogInfo.Year, monthQues, 2)
}
outContt.Score = float64(v.Score) / 100
outContt.Content = v.Content
outList = append(outList, outContt)
}
if len(outList) <= 0 {
response.Result(103, err, "没有数据!", c)
return
}
//流程查看
var flowAllMapList []commonus.FlowAllMap
var flowLogList []TechnologicalProcessType
var evalProInfo assessmentmodel.EvaluationProcess
gerEvalErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", requestData.Id).Find(&evalProInfo).Error
//fmt.Printf("9-----------1--------->%v\n", gerEvalErr)
var isShenPi int = 2
if gerEvalErr == nil {
var flowStepAryMaps []FlowStep
jsonFlowErr := json.Unmarshal([]byte(evalProInfo.Content), &flowStepAryMaps)
//fmt.Printf("9-----------2--------->%v\n", jsonFlowErr)
if jsonFlowErr == nil {
// //fmt.Printf("9-----------3--------->%v\n", flowStepAryMaps)
if len(flowStepAryMaps) > 0 {
for _, fw_v := range flowStepAryMaps {
var flowLog TechnologicalProcessType
flowLog.Step = fw_v.Step
flowLog.State = fw_v.State
workUser, workUserErr := commonus.GetWorkUser(fw_v.ClickName)
// //fmt.Printf("9-----------4-----2---->%v\n", fw_v)
if workUserErr == true {
// //fmt.Printf("9-----------4-----1---->%v\n", workUserErr)
// bfErr, bf := commonus.GetBranchFactory(workUser.DepartmentId)
bf, bfErr := commonus.GetNewOrgCont(workUser.MainDeparment)
// //fmt.Printf("9-----------4-----3---->%v\n", bfErr)
if bfErr == nil {
getGroupRoleInfoErr, getGroupRoleInfo, roleGroupInfo := commonus.GetOfficeWork(fw_v.RoleGroup, int64(bf.WechatOrganizationId))
// //fmt.Printf("9-----------4-----5---->%v---->%v---->%v\n", getGroupRoleInfoErr, getGroupRoleInfo, roleGroupInfo)
if getGroupRoleInfoErr == true {
flowLog.GroupName = roleGroupInfo.Title
for _, rg_v := range getGroupRoleInfo {
clickUserInfoErr, clickUserInfo := commonus.GetUesrContForWechatID(rg_v.Id)
// jjsk, _ := json.Marshal(clickUserInfo)
// //fmt.Printf("9-----------4--------->%v-->%v\n", string(jjsk), clickUserInfo.Key)
var caoZuoRenInfnfo caoZuoRen
if clickUserInfoErr == true {
if strconv.FormatInt(clickUserInfo.Key, 10) == fw_v.ClickName {
caoZuoRenInfnfo.IsTrue = 1
if fw_v.AddTime != 0 {
caoZuoRenInfnfo.TimeVal = commonus.TimeStampToDate(fw_v.AddTime, 1)
}
}
gErrs, groupInfos := commonus.GetGroupCont(clickUserInfo.Group)
if gErrs == true {
caoZuoRenInfnfo.GroupName = groupInfos.Name
}
caoZuoRenInfnfo.DepartmentName = clickUserInfo.DepartmentName
caoZuoRenInfnfo.WorkShopName = clickUserInfo.WorkshopName
caoZuoRenInfnfo.Postname = clickUserInfo.PostName
caoZuoRenInfnfo.TeamName = clickUserInfo.TemaName
caoZuoRenInfnfo.Icon = clickUserInfo.Icon
caoZuoRenInfnfo.Name = clickUserInfo.Name
flowLog.UserList = append(flowLog.UserList, caoZuoRenInfnfo)
}
// var caoZuoRenInfnfo caoZuoRen
// caoZuoRenInfnfo.Name =
// if workUser.WechatId == rg_v.Id || workUser.WorkWechatId == rg_v.Id {
// }
}
}
}
}
flowLogList = append(flowLogList, flowLog)
}
}
}
//流程图全面
// flowAllMapList
if evalProInfo.NextContent != "" {
jsonFlowErr := json.Unmarshal([]byte(evalProInfo.NextContent), &flowAllMapList)
if jsonFlowErr == nil {
}
}
// fmt.Printf("evalProInfo.NextExecutor-------------->%v\n", evalProInfo.NextExecutor)
if evalProInfo.NextExecutor != "" {
zhiXingRenAry := strings.Split(evalProInfo.NextExecutor, ",")
if commonus.IsItTrueString(userCont.Key, zhiXingRenAry) == true {
isShenPi = 1
}
}
}
outListMap := commonus.MapOut()
outListMap["List"] = outList
outListMap["flowLog"] = flowLogList
outListMap["flowall"] = flowAllMapList
outListMap["title"] = ""
outListMap["isset"] = isShenPi
outListMap["orderid"] = requestData.Id
if getErrs == nil {
titlekUserInfo, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": flowLogInfo.EvaluationUser}, "`name`")
// titlekUserInfo, _ := commonus.GetWorkUser(strconv.FormatInt(flowLogInfo.EvaluationUser, 10))
titleStr := fmt.Sprintf("%v提交的", titlekUserInfo.Name)
// gErr, groupInfo := commonus.GetGroupCont(flowLogInfo.DutyGroup)
groupInfo, gErr := commonus.GetNewOrgCont(flowLogInfo.DutyGroup)
if gErr == nil {
outListMap["groupname"] = groupInfo.Name
} else {
outListMap["groupname"] = ""
}
// dErr, BranchInfo := commonus.GetBranchFactory(flowLogInfo.DutyDepartment)
BranchInfo, dErr := commonus.GetNewOrgCont(flowLogInfo.DutyDepartment)
if dErr == nil {
outListMap["departmentname"] = BranchInfo.Name
titleStr = fmt.Sprintf("%v%v", titleStr, BranchInfo.Name)
} else {
outListMap["departmentname"] = ""
}
titleStr = fmt.Sprintf("%v%v年%v月定量考核数据", titleStr, flowLogInfo.Year, flowLogInfo.Month)
outListMap["title"] = titleStr
}
var flowLogListes []assessmentmodel.AssessmentLogIng
var approvalRecord []FlowContLog
flowLogErr := global.GVA_DB_Performanceappraisal.Where("al_order_id = ?", requestData.Id).Order("al_id ASC").Find(&flowLogListes).Error
if flowLogErr == nil {
for flli, fllv := range flowLogListes {
var flowListCont FlowContLog
if fllv.DutyList == "" && flli == 0 {
flowListCont.Content = "创建申请"
} else {
flowListCont.Content = fllv.DutyList
}
flowListCont.TimeVal = commonus.TimeStampToDate(fllv.ExecutorTime, 6)
userFlowCont, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": fllv.ExecutorUser})
flowListCont.Name = userFlowCont.Name
flowListCont.Icon = userFlowCont.Icon
gorupCont, _ := commonus.GetNewOrgCont(map[string]interface{}{"`id`": fllv.ExecutorDepart}, "`name`")
flowListCont.DepartmentName = gorupCont.Name
approvalRecord = append(approvalRecord, flowListCont)
}
}
outListMap["flowLogList"] = approvalRecord
response.Result(0, outListMap, "查询成功", c)
}
// 获取权重
func getPlanVersionWeghit(planKey, dimensionId, targetId string) (dimensionIdWeghit, targetIdWeghit int64) {
var planVersionCont assessmentmodel.PlanVersio
err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PlanVersio{}).Select("`content`").Where("`key` = ?", planKey).First(&planVersionCont).Error
if err != nil {
return
}
var planVersioInfo []AddDutyNewCont
jsonErr := json.Unmarshal([]byte(planVersionCont.Content), &planVersioInfo)
if jsonErr != nil {
return
}
for _, v := range planVersioInfo {
if v.Id == dimensionId {
dimensionIdWeghit = int64(v.ZhiFraction)
for _, cv := range v.Child {
if cv.Id == targetId {
targetIdWeghit = cv.ReferenceScore
}
}
}
}
return
}
// 新查看定量考核列表
func (e *EvaluationInterface) NewLookRationkScoreFlow(c *gin.Context) {
isTrue, userCont := commonus.ClientIdentity()
if isTrue != true {
response.Result(1001, userCont, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
return
}
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, requestData, "参数错误!请重新提交!", c)
return
}
if requestData.OutId != "" {
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64)
if inIntErr == nil {
requestData.Id = idInt
}
}
var flowDataLog []assessmentmodel.FlowLogData
getErr := global.GVA_DB_Performanceappraisal.Where("`fld_flow_log` = ?", requestData.Id).Order("fld_id ASC").Find(&flowDataLog).Error
if getErr != nil {
response.Result(103, err, "参数错误!请重新提交!", c)
return
}
//获取数据列
var flowLogInfo assessmentmodel.FlowLog
getErrs := global.GVA_DB_Performanceappraisal.Where("`fl_key` = ?", requestData.Id).First(&flowLogInfo).Error
//获取 审批记录数据参考值
var allZreoCappVal []FlowLogAllZreo
baseLineErr := json.Unmarshal([]byte(flowLogInfo.Baseline), &allZreoCappVal)
//获取版本
var planVersioCont assessmentmodel.PlanVersio
global.GVA_DB_Performanceappraisal.Where("`key` = ?", flowLogInfo.PlanVersion).First(&planVersioCont)
//解析版本项目
var planVersioInfo []AddDutyNewCont
if planVersioCont.Content != "" {
json.Unmarshal([]byte(planVersioCont.Content), &planVersioInfo)
}
//指标列表
var outList []RationOutStruct
//遍历流水
for _, v := range flowDataLog {
var targetScore int64 = 0 //指标分值
var outContt RationOutStruct //指标内容
outContt.Id = strconv.FormatInt(v.Id, 10)
outContt.FlowId = strconv.FormatInt(v.Key, 10)
targetCont, targetContErr := commonus.LookRationInfo(v.EvaluationPlan) //查看定量考核数据
if targetContErr == true {
outContt.Title = targetCont.Title
outContt.Unit = targetCont.Unit
outContt.Cycles = targetCont.Cycles
outContt.CycleAttres = targetCont.CycleAttres
var monthQues int64 = 1
switch targetCont.Cycles {
case 5:
monthQues = flowLogInfo.Quarter
case 6:
monthQues = 1
default:
monthQues = flowLogInfo.Month
}
if len(planVersioInfo) > 0 {
for _, pviv := range planVersioInfo {
for _, pvivcv := range pviv.Child {
if pvivcv.Id == strconv.FormatInt(targetCont.Target, 10) {
targetScore = pvivcv.ReferenceScore
}
}
}
}
outContt.Weight = float64(targetScore)
if baseLineErr != nil { //当数据流不存在 全奖、零奖、封顶值 设定时
var tarGetId int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_target").Where("`qe_id` = ?", v.EvaluationPlan).First(&tarGetId)
outContt.Actual, outContt.AllPrize, outContt.ZeroPrize, outContt.CappingVal, outContt.Achievement = GetQuantitativeConfig(targetScore, float64(v.Score), strconv.FormatInt(flowLogInfo.DutyGroup, 10), strconv.FormatInt(flowLogInfo.DutyDepartment, 10), strconv.FormatInt(targetCont.Dimension, 10), strconv.FormatInt(tarGetId, 10), strconv.FormatInt(targetCont.DetailedTarget, 10), flowLogInfo.Year, monthQues, 2)
} else {
isExistence := false
var allprizeVal float64 = 0
var zeroprizeVal float64 = 0
var cappingVal float64 = 0
if len(allZreoCappVal) > 0 {
for _, azcv := range allZreoCappVal {
if strconv.FormatInt(v.EvaluationPlan, 10) == azcv.Id {
allprizeVal = azcv.Allprize
zeroprizeVal = azcv.Zeroprize
cappingVal = azcv.Capping
isExistence = true
break
}
}
}
if isExistence == true {
outContt.Actual, outContt.AllPrize, outContt.ZeroPrize, outContt.CappingVal, outContt.Achievement = commonus.CalculateScore(targetScore, float64(v.Score), allprizeVal, zeroprizeVal, cappingVal, 2)
} else {
var tarGetId int64
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_target").Where("`qe_id` = ?", v.EvaluationPlan).First(&tarGetId)
outContt.Actual, outContt.AllPrize, outContt.ZeroPrize, outContt.CappingVal, outContt.Achievement = GetQuantitativeConfig(targetScore, float64(v.Score), strconv.FormatInt(flowLogInfo.DutyGroup, 10), strconv.FormatInt(flowLogInfo.DutyDepartment, 10), strconv.FormatInt(targetCont.Dimension, 10), strconv.FormatInt(tarGetId, 10), strconv.FormatInt(targetCont.DetailedTarget, 10), flowLogInfo.Year, monthQues, 2)
}
}
}
outContt.Score = float64(v.Score) / 100 //打分分值
outContt.Content = v.Content
outList = append(outList, outContt)
}
if len(outList) <= 0 {
response.Result(103, err, "没有数据!", c)
return
}
//流程查看
var flowAllMapList []commonus.FlowAllMap
var flowLogList []TechnologicalProcessType
var evalProInfo assessmentmodel.EvaluationProcess
gerEvalErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", requestData.Id).Find(&evalProInfo).Error
//fmt.Printf("9-----------1--------->%v\n", gerEvalErr)
var isShenPi int = 2
if gerEvalErr == nil {
var flowStepAryMaps []FlowStep
jsonFlowErr := json.Unmarshal([]byte(evalProInfo.Content), &flowStepAryMaps)
//fmt.Printf("9-----------2--------->%v\n", jsonFlowErr)
if jsonFlowErr == nil {
// //fmt.Printf("9-----------3--------->%v\n", flowStepAryMaps)
if len(flowStepAryMaps) > 0 {
for _, fw_v := range flowStepAryMaps {
var flowLog TechnologicalProcessType
flowLog.Step = fw_v.Step
flowLog.State = fw_v.State
workUser, workUserErr := commonus.GetWorkUser(fw_v.ClickName)
// //fmt.Printf("9-----------4-----2---->%v\n", fw_v)
if workUserErr == true {
// //fmt.Printf("9-----------4-----1---->%v\n", workUserErr)
// bfErr, bf := commonus.GetBranchFactory(workUser.DepartmentId)
bf, bfErr := commonus.GetNewOrgCont(workUser.MainDeparment)
// //fmt.Printf("9-----------4-----3---->%v\n", bfErr)
if bfErr == nil {
getGroupRoleInfoErr, getGroupRoleInfo, roleGroupInfo := commonus.GetOfficeWork(fw_v.RoleGroup, int64(bf.WechatOrganizationId))
// //fmt.Printf("9-----------4-----5---->%v---->%v---->%v\n", getGroupRoleInfoErr, getGroupRoleInfo, roleGroupInfo)
if getGroupRoleInfoErr == true {
flowLog.GroupName = roleGroupInfo.Title
for _, rg_v := range getGroupRoleInfo {
clickUserInfoErr, clickUserInfo := commonus.GetUesrContForWechatID(rg_v.Id)
// jjsk, _ := json.Marshal(clickUserInfo)
// //fmt.Printf("9-----------4--------->%v-->%v\n", string(jjsk), clickUserInfo.Key)
var caoZuoRenInfnfo caoZuoRen
if clickUserInfoErr == true {
if strconv.FormatInt(clickUserInfo.Key, 10) == fw_v.ClickName {
caoZuoRenInfnfo.IsTrue = 1
if fw_v.AddTime != 0 {
caoZuoRenInfnfo.TimeVal = commonus.TimeStampToDate(fw_v.AddTime, 1)
}
}
gErrs, groupInfos := commonus.GetGroupCont(clickUserInfo.Group)
if gErrs == true {
caoZuoRenInfnfo.GroupName = groupInfos.Name
}
caoZuoRenInfnfo.DepartmentName = clickUserInfo.DepartmentName
caoZuoRenInfnfo.WorkShopName = clickUserInfo.WorkshopName
caoZuoRenInfnfo.Postname = clickUserInfo.PostName
caoZuoRenInfnfo.TeamName = clickUserInfo.TemaName
caoZuoRenInfnfo.Icon = clickUserInfo.Icon
caoZuoRenInfnfo.Name = clickUserInfo.Name
flowLog.UserList = append(flowLog.UserList, caoZuoRenInfnfo)
}
// var caoZuoRenInfnfo caoZuoRen
// caoZuoRenInfnfo.Name =
// if workUser.WechatId == rg_v.Id || workUser.WorkWechatId == rg_v.Id {
// }
}
}
}
}
flowLogList = append(flowLogList, flowLog)
}
}
}
//流程图全面
// flowAllMapList
if evalProInfo.NextContent != "" {
jsonFlowErr := json.Unmarshal([]byte(evalProInfo.NextContent), &flowAllMapList)
if jsonFlowErr == nil {
}
}
// fmt.Printf("evalProInfo.NextExecutor-------------->%v\n", evalProInfo.NextExecutor)
if evalProInfo.NextExecutor != "" {
zhiXingRenAry := strings.Split(evalProInfo.NextExecutor, ",")
if commonus.IsItTrueString(userCont.Key, zhiXingRenAry) == true {
isShenPi = 1
}
}
}
outListMap := commonus.MapOut()
outListMap["List"] = outList
outListMap["flowLog"] = flowLogList
outListMap["flowall"] = flowAllMapList
outListMap["title"] = ""
outListMap["isset"] = isShenPi
outListMap["orderid"] = requestData.Id
if getErrs == nil {
titlekUserInfo, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": flowLogInfo.EvaluationUser}, "`name`")
// titlekUserInfo, _ := commonus.GetWorkUser(strconv.FormatInt(flowLogInfo.EvaluationUser, 10))
titleStr := fmt.Sprintf("%v提交的", titlekUserInfo.Name)
// gErr, groupInfo := commonus.GetGroupCont(flowLogInfo.DutyGroup)
groupInfo, gErr := commonus.GetNewOrgCont(flowLogInfo.DutyGroup)
if gErr == nil {
outListMap["groupname"] = groupInfo.Name
} else {
outListMap["groupname"] = ""
}
// dErr, BranchInfo := commonus.GetBranchFactory(flowLogInfo.DutyDepartment)
BranchInfo, dErr := commonus.GetNewOrgCont(flowLogInfo.DutyDepartment)
if dErr == nil {
outListMap["departmentname"] = BranchInfo.Name
titleStr = fmt.Sprintf("%v%v", titleStr, BranchInfo.Name)
} else {
outListMap["departmentname"] = ""
}
titleStr = fmt.Sprintf("%v%v年%v月定量考核数据", titleStr, flowLogInfo.Year, flowLogInfo.Month)
outListMap["title"] = titleStr
}
var flowLogListes []assessmentmodel.AssessmentLogIng
var approvalRecord []FlowContLog
flowLogErr := global.GVA_DB_Performanceappraisal.Where("al_order_id = ?", requestData.Id).Order("al_id ASC").Find(&flowLogListes).Error
if flowLogErr == nil {
for flli, fllv := range flowLogListes {
var flowListCont FlowContLog
if fllv.DutyList == "" && flli == 0 {
flowListCont.Content = "创建申请"
} else {
flowListCont.Content = fllv.DutyList
}
flowListCont.TimeVal = commonus.TimeStampToDate(fllv.ExecutorTime, 6)
userFlowCont, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": fllv.ExecutorUser})
flowListCont.Name = userFlowCont.Name
flowListCont.Icon = userFlowCont.Icon
gorupCont, _ := commonus.GetNewOrgCont(map[string]interface{}{"`id`": fllv.ExecutorDepart}, "`name`")
flowListCont.DepartmentName = gorupCont.Name
approvalRecord = append(approvalRecord, flowListCont)
}
}
outListMap["flowLogList"] = approvalRecord
response.Result(0, outListMap, "查询成功", c)
}