dddd
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.
 
 
 
 
 

343 lines
13 KiB

package callback
import (
"encoding/json"
"encoding/xml"
"fmt"
"strconv"
"strings"
"github.com/flipped-aurora/gin-vue-admin/server/api/index/evaluation"
"github.com/flipped-aurora/gin-vue-admin/server/api/wechatapp/sendmessage"
"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"
)
//更新数据
func templateEventPush(eventMsg []byte) {
var msgContent TemplateCardPush
err := xml.Unmarshal(eventMsg, &msgContent)
if nil != err {
fmt.Println("***********Unmarshal fail")
}
fmt.Printf("button======>%v\n", msgContent.EventKey)
buttonClick := strings.Split(msgContent.EventKey, "_")
if len(buttonClick) >= 3 {
// for i, v := range buttonClick {
// fmt.Printf("%v====================>%v==================>%v\n", i, v, buttonClick[1])
// }
switch buttonClick[0] {
case "duty": //数据考核审批工作
fmt.Printf("@@@@\n")
msgContent.ButtonTemplateCallBackHandle(buttonClick[1], buttonClick[2])
default:
}
}
jsonStr, _ := json.Marshal(msgContent)
fmt.Printf("jsonStr======>%v\n", string(jsonStr))
// var updateButtonNotClickable commonus.UpdateButtonNotClickable
// updateButtonNotClickable.Userids = append(updateButtonNotClickable.Userids, "KaiXinGuo")
// updateButtonNotClickable.Atall = 0
// updateButtonNotClickable.Agentid = msgContent.Agentid
// updateButtonNotClickable.ResponseCode = msgContent.ResponseCode
// updateButtonNotClickable.Button.ReplaceName = "已提交更新"
// callbakcMsg, isTrueCall, callBackCont := updateButtonNotClickable.UpdateSendButtonMessage()
// fmt.Printf("更新销售发送信息返回:%v-----------%v----------->%v\n", string(callbakcMsg), isTrueCall, callBackCont)
}
//按钮模板回调处理
func (t *TemplateCardPush) ButtonTemplateCallBackHandle(scoreFlowKey, clickEnter string) {
var scoreFlowInfo assessmentmodel.ScoreFlow
judegFlowErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", scoreFlowKey).First(&scoreFlowInfo).Error
fmt.Printf("1@@@@%v\n", scoreFlowInfo)
if judegFlowErr != nil {
return
}
//获取审批流程
var flowLog []evaluation.FlowStep
var evalProc assessmentmodel.EvaluationProcess
judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", scoreFlowKey).First(&evalProc).Error
if judgeErr != nil {
return
}
jsonFlowErr := json.Unmarshal([]byte(evalProc.Content), &flowLog)
if jsonFlowErr != nil || len(flowLog) < 1 {
return
}
fmt.Printf("3@@@@%v\n", scoreFlowInfo)
if len(flowLog) < 1 {
return
}
sendUserList, _ := GetCaoZuoRen(flowLog[len(flowLog)-1].Step, scoreFlowInfo)
// fmt.Printf("1ssss@@@@%v\n", scoreFlowInfo)
buttonClickNAme := "已批准"
buttonClickNAmeOther := "其他人已批准"
fmt.Printf("45@@@@%v\n", flowLog[len(flowLog)-1].Step)
if clickEnter == "1" {
//1:内勤;2:部门负责人:3:整改;4:整改后部门负责;5:归档起草人
switch flowLog[len(flowLog)-1].Step {
case 1:
case 2:
//是否需要整改
if scoreFlowInfo.Rectification != 1 {
evaluation.UpEvaluationProcessApproval(scoreFlowInfo.Key, 0, scoreFlowInfo.Key, 3)
_, sendUserList = commonus.GetSendMsgUser(16182159043990656, scoreFlowInfo.DutyDepartment) //获取对应部门负责人(高科)
userAry := strings.Split(sendUserList, "|")
var userKeyInt int64 = 0
if len(userAry) > 0 {
_, userConts := commonus.GetUesrContForWechatID(userAry[0])
userKeyInt = userConts.Key
}
//获取接收人是谁 第一责任人
var divisResponInfo assessmentmodel.DivisionResponsibilities
judegdivisErr := global.GVA_DB_Performanceappraisal.Where("`df_type` = 1 AND `df_sf_id` = ?", scoreFlowKey).First(&divisResponInfo).Error
if judegdivisErr == nil {
userKeyInt = divisResponInfo.UserKey
}
SendRectifyMsg(sendUserList, scoreFlowInfo.Reason, scoreFlowInfo.EvaluationPlan, scoreFlowInfo.Key, scoreFlowInfo.DutyDepartment, userKeyInt, scoreFlowInfo.Score, scoreFlowInfo.PlusReduceScore)
// callbakcMsg, isTrueCall, callBackCont, sendTextMsg := SendRectifyMsg(sendUserList, scoreFlowInfo.Reason, scoreFlowInfo.EvaluationPlan, scoreFlowInfo.Key, scoreFlowInfo.DutyDepartment, userKeyInt, scoreFlowInfo.Score, scoreFlowInfo.PlusReduceScore)
// fmt.Printf("更新销售:%v-----------%v-----------%v-----------%v\n", scoreFlowInfo.DutyDepartment, userKeyInt, sendUserList, userAry[0])
// fmt.Printf("更新销售发送信息返回:%v-----------%v----------->%v------》%v\n", string(callbakcMsg), isTrueCall, callBackCont, sendTextMsg)
} else {
buttonClickAry := strings.Split(t.EventKey, "_")
if len(buttonClickAry) < 4 {
return
}
evaluation.UpEvaluationProcessApproval(scoreFlowInfo.Key, 0, scoreFlowInfo.Key, 5)
_, sendUserListing := commonus.GetSendMsgUser(16182159043990656, scoreFlowInfo.DutyDepartment) //获取对应部门负责人(高科)
userAry := strings.Split(sendUserListing, "|")
var userKeyInt int64 = 0
if len(userAry) > 0 {
_, userConts := commonus.GetUesrContForWechatID(userAry[0])
userKeyInt = userConts.Key
}
//获取信息接收人
sendUserList := ""
userFileStr := "wm_number,qywx_key,wx_key"
//操作人条件
userWherAry := commonus.MapOut()
// userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3"
userWherAry["wm_key"] = scoreFlowInfo.EvaluationUser
userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry)
if userIsTrue == true {
if userConting.WechatId != "" {
sendUserList = userConting.WechatId
}
if userConting.WorkWechatId != "" {
sendUserList = userConting.WorkWechatId
}
}
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
}
}
var recMeasCont assessmentmodel.RectificationMeasures
judgeRecMeas := global.GVA_DB_Performanceappraisal.Where("`rm_id` = ?", buttonClickAry[3]).First(&recMeasCont).Error
if judgeRecMeas != nil {
return
}
mainTitleDesc := programme.Content
subtitle := "整改内容:"
reason := recMeasCont.Content
//获取当前执行人信息
commonus.GetUesrContForWechatID(t.ToUsername)
keyNumber := commonus.GetFileNumberEs()
SendRectifyReceipt(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, scoreFlowInfo.DutyDepartment, userKeyInt, keyNumber, scoreFlowInfo.Key, recMeasCont.Id)
}
case 3:
case 4:
case 5:
default:
}
} else {
buttonClickNAme = "已驳回"
buttonClickNAmeOther = "其他人已驳回"
scoreFlowKeyId, scoreFlowKeyErr := strconv.ParseInt(scoreFlowKey, 10, 64)
if scoreFlowKeyErr == nil {
evaluation.UpEvaluationProcessReject(scoreFlowKeyId)
}
}
// performSteps := 1
// fmt.Printf("3@@@@%v\n", flowLog[len(flowLog)-1].Step)
// fmt.Printf("2@@@@%v--->%v\n", sendUserList, scoreFlowInfo.DutyDepartment)
userAry := strings.Split(sendUserList, "|")
for _, v := range userAry {
if v == t.FromUsername {
t.UpdateButton(v, buttonClickNAme)
} else {
t.UpdateButton(v, buttonClickNAmeOther)
}
}
}
//更新按钮
func (t *TemplateCardPush) UpdateButton(userOpenId, buttonName string) {
var updateButtonNotClickable commonus.UpdateButtonNotClickable
updateButtonNotClickable.Userids = append(updateButtonNotClickable.Userids, userOpenId)
updateButtonNotClickable.Atall = 0
updateButtonNotClickable.Agentid = t.Agentid
updateButtonNotClickable.ResponseCode = t.ResponseCode
updateButtonNotClickable.Button.ReplaceName = buttonName
// callbakcMsg, isTrueCall, callBackCont := updateButtonNotClickable.UpdateSendButtonMessage()
// fmt.Printf("更新销售发送信息返回:%v-----------%v----------->%v------》%v\n", string(callbakcMsg), isTrueCall, callBackCont, updateButtonNotClickable)
}
//获取操作人
func GetCaoZuoRen(stepVal int, s assessmentmodel.ScoreFlow) (sendUserList string, stepDepart int64) {
//1:内勤;2:部门负责人:3:整改;4:整改后部门负责;5:归档起草人
switch stepVal {
case 1:
stepDepart = 16118387069540343
_, sendUserList = commonus.GetSendMsgUser(16118387069540343, s.DutyDepartment) //获取对应部门负责人(高科)
case 2:
stepDepart = 16182159043990656
//给相关部门内勤发送消息。确定相关责任人
_, sendUserList = commonus.GetSendMsgUser(16182159043990656, s.DutyDepartment) //获取对应部门负责人(高科)
case 3:
case 4:
stepDepart = 16182159043990656
//给相关部门内勤发送消息。确定相关责任人
_, sendUserList = commonus.GetSendMsgUser(16182159043990656, s.DutyDepartment) //获取对应部门负责人(高科)
case 5:
//获取操作人
userFileStr := "wm_number,qywx_key,wx_key"
//操作人条件
userWherAry := commonus.MapOut()
// userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3"
userWherAry["wm_key"] = s.EvaluationUser
userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry)
if userIsTrue == true {
if userConting.WechatId != "" {
sendUserList = userConting.WechatId
}
if userConting.WorkWechatId != "" {
sendUserList = userConting.WorkWechatId
}
}
default:
}
return
}
//发出整改通知
/*
@floeKey 方案KEY
@sendUserList 接收用户
@planIdInt 考核方案项目ID
@reason 原因
@typeSet 1:加分;2:减分
@departmentId 执行考核部门
@userKey 执行考核人
@Score 考核分值
*/
func SendRectifyMsg(sendUserList, reason string, planIdInt, floeKey, departmentId, userKey, Score int64, typeSet int) (callbakcMsg []byte, isTrueCall bool, callBackCont string, sendTextMsg sendmessage.TextNoticeTemplateMedium) {
var mainTitle string = ""
var mainTitleDesc string = ""
var programme assessmentmodel.QualitativeEvaluation
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", planIdInt).First(&programme).Error
if judgeProgramme != nil {
return
}
if programme.Type == 1 {
detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget)
if detailedTargetErr == true {
if detailedTargetCont.Title != "" {
mainTitle = detailedTargetCont.Title
} else {
mainTitle = 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
}
}
scoreReason := ""
subTitleText := "部门"
keyNumber := commonus.GetFileNumberEs()
//发送整改通知
handleUrl := fmt.Sprintf("http://www.hxgk.group?orderid=%v", floeKey)
callbakcMsg, isTrueCall, callBackCont, sendTextMsg = sendmessage.SendMsgTxtPublic(sendUserList, mainTitle, mainTitleDesc, programme.Unit, reason, handleUrl, scoreReason, subTitleText, typeSet, departmentId, userKey, Score, keyNumber, "请上报整改结果!")
return
}
/*
发送文本任务卡
@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, buttonMap)
return
}