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.
173 lines
6.7 KiB
173 lines
6.7 KiB
package quan
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"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 (a *ApiGroup) Sanction(c *gin.Context) {
|
|
isTrue, userCont := commonus.ClientIdentity()
|
|
if isTrue != true {
|
|
response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c)
|
|
return
|
|
}
|
|
founderDepartId, _ := strconv.ParseInt(userCont.Deparment, 10, 64)
|
|
founderUserKey, _ := strconv.ParseInt(userCont.Key, 10, 64)
|
|
|
|
var requestData ApprovalParameters
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(101, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
if requestData.OrderId == "" {
|
|
response.Result(102, err, "参数错误!请重新提交!", c)
|
|
return
|
|
}
|
|
|
|
var evalProcessInfo assessmentmodel.EvaluationProcess
|
|
evalErr := global.GVA_DB_Performanceappraisal.Where("ep_order_key = ?", requestData.OrderId).First(&evalProcessInfo).Error
|
|
if evalErr != nil {
|
|
response.Result(103, err, "审批流不存在!请检查您的数据!", c)
|
|
return
|
|
}
|
|
if evalProcessInfo.State == 3 || evalProcessInfo.NextStep <= 0 {
|
|
response.Result(104, err, "该流程已结束!不可进行操作!", c)
|
|
return
|
|
}
|
|
if evalProcessInfo.NextContent == "" {
|
|
response.Result(105, err, "对不起!您没有权限对此流程进行操作!", c)
|
|
return
|
|
}
|
|
nextReplyUserMap := strings.Split(evalProcessInfo.NextExecutor, ",")
|
|
// fmt.Printf("userCont.Key:%v\n", userCont.Key)
|
|
if commonus.IsItTrueString(userCont.Key, nextReplyUserMap) == false {
|
|
response.Result(106, nextReplyUserMap, "对不起!您没有权限对此流程进行操作!", c)
|
|
return
|
|
}
|
|
|
|
orderIdInt, _ := strconv.ParseInt(requestData.OrderId, 10, 64) //流程Key
|
|
|
|
var flowlogMap assessmentmodel.FlowLog
|
|
flmErr := global.GVA_DB_Performanceappraisal.Where("fl_key = ?", orderIdInt).First(&flowlogMap).Error
|
|
if flmErr != nil {
|
|
response.Result(103, err, "审批流不存在!请检查您的数据!", c)
|
|
return
|
|
}
|
|
|
|
if requestData.YesOrNo != 1 {
|
|
//驳回
|
|
opinionCont := "驳回"
|
|
if requestData.Content != "" {
|
|
opinionCont = requestData.Content
|
|
}
|
|
commonus.StepAddData(orderIdInt, 16182159043990656, 0, 2, 2, 2, 2, userCont.Key) //审批步骤处理
|
|
commonus.WriteReplyLog(orderIdInt, flowlogMap.DutyDepartment, founderDepartId, founderUserKey, 3, commonus.GetSetpName(2), opinionCont) //写入审批流
|
|
//修改定性审批流状态
|
|
eiteScoreFlow := commonus.MapOut()
|
|
eiteScoreFlow["fl_eite_time"] = time.Now().Unix()
|
|
eiteScoreFlow["fl_reply"] = 4
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Where("`fl_key` = ?", requestData.OrderId).Updates(&eiteScoreFlow)
|
|
|
|
evalProcSaveData := commonus.MapOut()
|
|
evalProcSaveData["ep_state"] = 4
|
|
evalProcSaveData["ep_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData)
|
|
|
|
//2.3、获取发起人信息
|
|
var sendUser string = ""
|
|
// faQiRen, _ := commonus.GetWorkUser(strconv.FormatInt(scoreFlowInfo.EvaluationUser, 10))
|
|
faQiRen, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": flowlogMap.EvaluationUser}, "`wechat`", "`work_wechat`")
|
|
if faQiRen.Wechat != "" {
|
|
sendUser = faQiRen.Wechat
|
|
}
|
|
if faQiRen.WorkWechat != "" {
|
|
sendUser = faQiRen.WorkWechat
|
|
}
|
|
|
|
registerNumber := commonus.GetFileNumberEs()
|
|
|
|
title := fmt.Sprintf("%v-%v数据表", flowlogMap.Year, flowlogMap.Month)
|
|
desc := ""
|
|
mainTitleDesc := "数据详情:"
|
|
reason := ""
|
|
evalPlanIdAry := strings.Split(flowlogMap.EvaluationPlan, ",")
|
|
if len(evalPlanIdAry) > 0 {
|
|
var qeInfo []assessmentmodel.QualitativeEvaluation
|
|
judgeErr := global.GVA_DB_Performanceappraisal.Where("`qe_id` IN ?", evalPlanIdAry).First(&qeInfo).Error
|
|
if judgeErr == nil {
|
|
for _, qev := range qeInfo {
|
|
tarInfo, _ := commonus.GetTargetInfo(qev.Target)
|
|
reason = fmt.Sprintf("%\n%v :%v%v", reason, tarInfo.Title, flowlogMap.Score, qev.Unit)
|
|
}
|
|
}
|
|
}
|
|
|
|
//审批卡片跳转链接
|
|
cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10))
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10))
|
|
|
|
jumpUrlTitle := "请前往处理"
|
|
sourceDesc := "驳回"
|
|
twoLevelTitle := "审批信息:"
|
|
|
|
twoLevelKeyName := ""
|
|
departmentId, _ := strconv.ParseInt(userCont.Deparment, 10, 64)
|
|
execDerpat, execDerpatErr := commonus.GetNewOrgCont(departmentId)
|
|
if execDerpatErr == nil {
|
|
twoLevelKeyName = execDerpat.Name
|
|
}
|
|
var twoLevelKeyValue string = ""
|
|
var twoLevelUserId string = ""
|
|
//获取操作人
|
|
if userCont.Wechat != "" {
|
|
userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat)
|
|
if userWechatErr == true {
|
|
twoLevelKeyValue = userWechat.Name
|
|
twoLevelUserId = userCont.Wechat
|
|
}
|
|
}
|
|
|
|
var sendTextMsg sendmessage.TextNoticeTemplateMedium
|
|
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUser, strconv.FormatInt(registerNumber, 10), title, desc, mainTitleDesc, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc)
|
|
|
|
outMap := commonus.MapOut()
|
|
outMap["callbakcMsg"] = string(callbakcMsg)
|
|
outMap["isTrueCall"] = isTrueCall
|
|
outMap["callBackCont"] = callBackCont
|
|
outMap["setval"] = 1
|
|
outMap["sendUser"] = sendUser
|
|
|
|
response.Result(0, outMap, "数据提交成功!", c)
|
|
|
|
} else {
|
|
//同意
|
|
opinionCont := "同意"
|
|
if requestData.Content != "" {
|
|
opinionCont = requestData.Content
|
|
}
|
|
commonus.StepAddData(orderIdInt, 16182159043990656, 0, 2, 2, 2, 2, userCont.Key) //审批步骤处理
|
|
commonus.WriteReplyLog(orderIdInt, flowlogMap.DutyDepartment, founderDepartId, founderUserKey, 2, commonus.GetSetpName(2), opinionCont) //写入审批流
|
|
//修改定性审批流状态
|
|
eiteScoreFlow := commonus.MapOut()
|
|
eiteScoreFlow["fl_eite_time"] = time.Now().Unix()
|
|
eiteScoreFlow["fl_reply"] = 3
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowLog{}).Where("`fl_key` = ?", requestData.OrderId).Updates(&eiteScoreFlow)
|
|
response.Result(0, opinionCont, "数据提交成功!", c)
|
|
evalProcSaveData := commonus.MapOut()
|
|
evalProcSaveData["ep_state"] = 3
|
|
evalProcSaveData["ep_time"] = time.Now().Unix()
|
|
global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData)
|
|
}
|
|
|
|
}
|
|
|