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.

893 lines
36 KiB

package callback
import (
"encoding/json"
"encoding/xml"
"fmt"
"strconv"
"strings"
"time"
// evals "github.com/flipped-aurora/gin-vue-admin/server/api/index/evaluation"
evals "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) {
buttonClickNAme := "已批准"
buttonClickNAmeOther := "其他人已批准"
if clickEnter == "1" {
t.UpdateButton(t.FromUsername, buttonClickNAme)
} else {
buttonClickNAme = "已驳回"
buttonClickNAmeOther = "其他人已驳回"
t.UpdateButton(t.FromUsername, buttonClickNAme)
}
//获取点击人信息
userContInfoIstrue, userContInfo := commonus.GetUesrContForWechatID(t.FromUsername)
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 {
_, butCallBackUser := commonus.GetSendMsgUser(16182159043990656, userContInfo.DepartmentId) //获取对应部门负责人(高科)
userCallAry := strings.Split(butCallBackUser, "|")
t.OtherClickButton(userCallAry, buttonClickNAme)
return
}
fmt.Printf("scoreFlowKey ----------------------------------> %v\n", scoreFlowKey)
//获取审批流程
// evaluation.FlowStep
var flowLog []evals.FlowStep
var evalProc assessmentmodel.EvaluationProcess
judgeErr := global.GVA_DB_Performanceappraisal.Where("`ep_order_key` = ?", scoreFlowKey).First(&evalProc).Error
if judgeErr != nil {
_, butCallBackUser := commonus.GetSendMsgUser(16182159043990656, userContInfo.DepartmentId) //获取对应部门负责人(高科)
userCallAry := strings.Split(butCallBackUser, "|")
t.OtherClickButton(userCallAry, buttonClickNAme)
return
}
fmt.Printf("scoreFlowKey -----------------%v-----------------> %v\n", scoreFlowKey, evalProc.Content)
jsonFlowErr := json.Unmarshal([]byte(evalProc.Content), &flowLog)
if jsonFlowErr != nil || len(flowLog) < 1 {
_, butCallBackUser := commonus.GetSendMsgUser(16182159043990656, userContInfo.DepartmentId) //获取对应部门负责人(高科)
userCallAry := strings.Split(butCallBackUser, "|")
t.OtherClickButton(userCallAry, buttonClickNAme)
return
}
if userContInfoIstrue == true {
if flowLog[len(flowLog)-1].Step == 1 {
_, butCallBackUser := commonus.GetSendMsgUser(16118387069540343, userContInfo.DepartmentId) //获取对应部门内勤(高科)
userCallAry := strings.Split(butCallBackUser, "|")
t.OtherClickButton(userCallAry, buttonClickNAmeOther)
}
if flowLog[len(flowLog)-1].Step == 2 || flowLog[len(flowLog)-1].Step == 4 {
_, butCallBackUser := commonus.GetSendMsgUser(16182159043990656, userContInfo.DepartmentId) //获取对应部门负责人(高科)
userCallAry := strings.Split(butCallBackUser, "|")
t.OtherClickButton(userCallAry, buttonClickNAmeOther)
}
}
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)
fmt.Printf("45@@@@%v\n", flowLog[len(flowLog)-1].Step)
if clickEnter == "1" {
//1:内勤;2:部门负责人:3:整改;4:整改后部门负责;5:归档起草人
switch flowLog[len(flowLog)-1].NextStep {
case 1:
case 2:
//是否需要整改
if scoreFlowInfo.Rectification == 1 {
keyNumber := commonus.GetFileNumberEs()
evals.UpEvaluationProcessApproval(scoreFlowInfo.Key, 0, keyNumber, 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
}
callbakcMsg, isTrueCall, callBackCont, sendTextMsg := SendRectifyMsg(sendUserList, scoreFlowInfo.Reason, scoreFlowInfo.EvaluationPlan, scoreFlowInfo.Key, scoreFlowInfo.DutyDepartment, userKeyInt, scoreFlowInfo.Score, keyNumber, scoreFlowInfo.PlusReduceScore)
fmt.Printf("更新销售发送信息返回:%v-----------%v----------->%v------》%v\n", string(callbakcMsg), isTrueCall, callBackCont, sendTextMsg)
} else {
buttonClickAry := strings.Split(t.EventKey, "_")
if len(buttonClickAry) < 4 {
return
}
keyNumber := commonus.GetFileNumberEs()
evals.UpEvaluationProcessApproval(scoreFlowInfo.Key, 0, keyNumber, 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 := ""
// reason := recMeasCont.Content
//获取当前执行人信息
commonus.GetUesrContForWechatID(t.ToUsername)
// SendRectifyReceipt(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, scoreFlowInfo.DutyDepartment, userKeyInt, keyNumber, scoreFlowInfo.Key, recMeasCont.Id)
SendRectifyReceipt(sendUserList, mainTitle, mainTitleDesc, subtitle, reason, scoreFlowInfo.DutyDepartment, userKeyInt, keyNumber, scoreFlowInfo.Key, 0)
}
case 3:
case 4:
buttonClickAry := strings.Split(t.EventKey, "_")
if len(buttonClickAry) < 4 {
return
}
keyNumber := commonus.GetFileNumberEs()
evals.UpEvaluationProcessApproval(scoreFlowInfo.Key, 0, keyNumber, 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 5:
evals.UpEvaluationProcessApproval(scoreFlowInfo.Key, 0, 0, 1)
flowSaveData := commonus.MapOut()
flowSaveData["sf_reply"] = 3
flowSaveData["sf_eite_time"] = time.Now().Unix()
evals.EiteScoreFlow(scoreFlowInfo.Key, flowSaveData)
fmt.Printf("=========================>\n")
//发送消息
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, scoreFlowInfo.DutyDepartment) //获取对应部门内勤
if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", 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
}
}
var recMeasCont assessmentmodel.RectificationMeasures
judgeRecMeas := global.GVA_DB_Performanceappraisal.Where("`rm_id` = ?", scoreFlowInfo.Key).Find(&recMeasCont).Error
if judgeRecMeas == nil {
// return
}
mainTitleDesc := programme.Content
subtitle := "整改内容:"
scoreReason := recMeasCont.Content
subTitleText := "考核部门"
keyNumber := commonus.GetFileNumberEs()
//发送整改通知
handleUrl := fmt.Sprintf("http://www.hxgk.group?orderid=%v", scoreFlowInfo.Key)
callbakcMsg, isTrueCall, callBackCont, sendTextMsg := sendmessage.SendMsgTxtPublic(sendUserList, mainTitle, mainTitleDesc, programme.Unit, subtitle, handleUrl, scoreReason, subTitleText, scoreFlowInfo.PlusReduceScore, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, scoreFlowInfo.Score, keyNumber, "查看整改详情!")
fmt.Printf("流程结束:%v-----------%v----------->%v------》%v\n", string(callbakcMsg), isTrueCall, callBackCont, sendTextMsg)
default:
}
} else {
fmt.Printf("close==========3===============>%v\n", flowLog[len(flowLog)-1].Step)
//1:内勤;2:部门负责人:3:整改;4:整改后部门负责;5:归档起草人
switch flowLog[len(flowLog)-1].NextStep {
case 1:
case 2:
fmt.Printf("close==========2===============>\n")
evals.UpEvaluationProcessReject(scoreFlowInfo.Key, 16118387069540343, 0, 1)
//发送消息
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, scoreFlowInfo.DutyDepartment) //获取对应部门内勤
if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
// return
}
taskId := commonus.GetFileNumberEs()
targettitle, detailedRulesTitle, detailedRulesInfo, unitStr, flowContent, _ := commonus.GetDutyAssociatedItems(scoreFlowKey)
title := flowContent.Reason
if title == "" {
if detailedRulesInfo != "" {
title = detailedRulesInfo
} else if detailedRulesTitle != "" {
title = detailedRulesInfo
} else {
title = targettitle
}
}
var desc string
if flowContent.PlusReduceScore == 1 {
desc = fmt.Sprintf("增加:%v%v", flowContent.Score, unitStr)
} else {
desc = fmt.Sprintf("扣除:%v%v", flowContent.Score, unitStr)
}
quoteAreaTitle := "责任划分"
var divisionResponsibilities []assessmentmodel.DivisionResponsibilities
dRBerr := global.GVA_DB_Performanceappraisal.Where("df_sf_id = ?", scoreFlowKey).Find(&divisionResponsibilities).Error
var quoteAreaContent string
if dRBerr == nil {
for _, drb_val := range divisionResponsibilities {
var zeren string
switch drb_val.Type {
case 1:
zeren = "主要责任人"
case 2:
zeren = "互保责任人"
case 3:
zeren = "责任班组"
case 4:
zeren = "责任班组长"
case 5:
zeren = "主管"
case 6:
zeren = "三大员"
case 7:
zeren = "厂长、主任"
default:
zeren = "主要责任人"
}
quoteAreaContent = quoteAreaContent + fmt.Sprintf("%v:%v 责任占比:%v\n", zeren, drb_val.UserName, drb_val.Weight)
}
}
roleGroupInfo, roleGroupInfoIstrue := commonus.GetRoleGroup(16182159043990656)
twoLevelTitle := ""
if roleGroupInfoIstrue == true {
twoLevelTitle = roleGroupInfo.Title
}
twoLevelKeyName := roleGroupInfo.Title
twoLevelKeyValue := roleGroupInfo.Title
userWechatErr, userWechat := commonus.GetUesrContForWechatID(t.FromUsername)
if userWechatErr == true {
twoLevelKeyName = userWechat.DepartmentName
twoLevelKeyValue = userWechat.Name
}
twoLevelUserId := t.FromUsername
fmt.Printf("close============3=============>\n")
jumpUrl := fmt.Sprintf("http://www.hxgk.group?orderid=%v", scoreFlowKey)
jumpUrlTitle := "请前往处理被驳回的任务"
sourceDesc := "驳回"
var sendTextMsg sendmessage.TextNoticeTemplateMedium
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendNewsMsgText(sendUserList, strconv.FormatInt(taskId, 10), title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, jumpUrl, jumpUrlTitle, sourceDesc)
fmt.Printf("更新发送信息返回:%v-----------%v----------->%v-----\n", string(callbakcMsg), isTrueCall, callBackCont)
case 3:
case 4:
buttonClickAry := strings.Split(t.EventKey, "_")
if len(buttonClickAry) < 4 {
fmt.Printf("未知整改措施--》:%v\n", t.EventKey)
return
}
var recMeasCont assessmentmodel.RectificationMeasures
judgeRecMeas := global.GVA_DB_Performanceappraisal.Where("`rm_id` = ?", buttonClickAry[3]).First(&recMeasCont).Error
if judgeRecMeas != nil {
fmt.Printf("未知整改措施--->:%v\n", t.EventKey)
return
}
taskId := commonus.GetFileNumberEs()
evals.UpEvaluationProcessReject(scoreFlowInfo.Key, 0, taskId, 3)
//获取接收人是谁 第一责任人
var weChatStr []string
var divisResponInfo []assessmentmodel.DivisionResponsibilities
judegdivisErr := global.GVA_DB_Performanceappraisal.Where("`df_type` = 1 AND `df_sf_id` = ?", scoreFlowKey).Find(&divisResponInfo).Error
if judegdivisErr == nil {
//获取操作人
userFileStr := "wm_number,qywx_key,wx_key"
for _, dri_v := range divisResponInfo {
//操作人条件
userWherAry := commonus.MapOut()
// userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3"
userWherAry["wm_key"] = dri_v.UserKey
userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry)
if userIsTrue == true {
if userConting.WechatId != "" && userConting.WorkWechatId != "" {
weChatStr = append(weChatStr, userConting.WorkWechatId)
} else if userConting.WechatId != "" && userConting.WorkWechatId == "" {
weChatStr = append(weChatStr, userConting.WechatId)
} else if userConting.WechatId == "" && userConting.WorkWechatId != "" {
weChatStr = append(weChatStr, userConting.WorkWechatId)
}
}
}
targettitle, detailedRulesTitle, detailedRulesInfo, unitStr, flowContent, _ := commonus.GetDutyAssociatedItems(scoreFlowKey)
title := flowContent.Reason
if title == "" {
if detailedRulesInfo != "" {
title = detailedRulesInfo
} else if detailedRulesTitle != "" {
title = detailedRulesInfo
} else {
title = targettitle
}
}
var desc string
if flowContent.PlusReduceScore == 1 {
desc = fmt.Sprintf("增加:%v%v", flowContent.Score, unitStr)
} else {
desc = fmt.Sprintf("扣除:%v%v", flowContent.Score, unitStr)
}
sendUserList := strings.Join(weChatStr, "|")
var sendTextMsg sendmessage.TextNoticeTemplateMedium
quoteAreaTitle := "整改方案"
quoteAreaContent := recMeasCont.Content
roleGroupInfo, roleGroupInfoIstrue := commonus.GetRoleGroup(16182159043990656) //部门负责人
twoLevelTitle := ""
if roleGroupInfoIstrue == true {
twoLevelTitle = roleGroupInfo.Title
}
twoLevelKeyName := roleGroupInfo.Title
twoLevelKeyValue := roleGroupInfo.Title
userWechatErr, userWechat := commonus.GetUesrContForWechatID(t.FromUsername)
if userWechatErr == true {
twoLevelKeyName = userWechat.DepartmentName
twoLevelKeyValue = userWechat.Name
}
twoLevelUserId := t.FromUsername
jumpUrl := fmt.Sprintf("http://www.hxgk.group?orderid=%v", scoreFlowKey)
jumpUrlTitle := "请前往处理被驳回的任务"
sourceDesc := "驳回"
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendNewsMsgText(sendUserList, strconv.FormatInt(taskId, 10), title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, jumpUrl, jumpUrlTitle, sourceDesc)
fmt.Printf("更新发送信息返回:%v-----------%v----------->%v-----\n", string(callbakcMsg), isTrueCall, callBackCont)
} else {
fmt.Printf("未找到责任人:%v-----------%v-----\n", judegdivisErr, divisResponInfo)
}
case 5:
taskId := commonus.GetFileNumberEs()
buttonClickAry := strings.Split(t.EventKey, "_")
if len(buttonClickAry) < 4 {
evals.UpEvaluationProcessReject(scoreFlowInfo.Key, 0, taskId, 1)
//发送消息
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, scoreFlowInfo.DutyDepartment) //获取对应部门内勤
if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
// return
}
targettitle, detailedRulesTitle, detailedRulesInfo, unitStr, flowContent, _ := commonus.GetDutyAssociatedItems(scoreFlowKey)
title := flowContent.Reason
if title == "" {
if detailedRulesInfo != "" {
title = detailedRulesInfo
} else if detailedRulesTitle != "" {
title = detailedRulesInfo
} else {
title = targettitle
}
}
var desc string
if flowContent.PlusReduceScore == 1 {
desc = fmt.Sprintf("增加:%v%v", flowContent.Score, unitStr)
} else {
desc = fmt.Sprintf("扣除:%v%v", flowContent.Score, unitStr)
}
quoteAreaTitle := "责任划分"
var divisionResponsibilities []assessmentmodel.DivisionResponsibilities
dRBerr := global.GVA_DB_Performanceappraisal.Where("df_sf_id = ?", scoreFlowKey).Find(&divisionResponsibilities).Error
var quoteAreaContent string
if dRBerr == nil {
for _, drb_val := range divisionResponsibilities {
var zeren string
switch drb_val.Type {
case 1:
zeren = "主要责任人"
case 2:
zeren = "互保责任人"
case 3:
zeren = "责任班组"
case 4:
zeren = "责任班组长"
case 5:
zeren = "主管"
case 6:
zeren = "三大员"
case 7:
zeren = "厂长、主任"
default:
zeren = "主要责任人"
}
quoteAreaContent = quoteAreaContent + fmt.Sprintf("%v:%v 责任占比:%v\n", zeren, drb_val.UserName, drb_val.Weight)
}
}
twoLevelTitle := "考核上报部门"
var twoLevelKeyName, twoLevelKeyValue string
userWechatErr, userWechat := commonus.GetUesrContForWechatID(t.FromUsername)
if userWechatErr == true {
twoLevelKeyName = userWechat.DepartmentName
twoLevelKeyValue = userWechat.Name
}
twoLevelUserId := t.FromUsername
jumpUrl := fmt.Sprintf("http://www.hxgk.group?orderid=%v", scoreFlowKey)
jumpUrlTitle := "请前往处理被驳回的任务"
sourceDesc := "驳回"
var sendTextMsg sendmessage.TextNoticeTemplateMedium
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendNewsMsgText(sendUserList, strconv.FormatInt(taskId, 10), title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, jumpUrl, jumpUrlTitle, sourceDesc)
fmt.Printf("更新发送信息返回:%v-----------%v----------->%v-----\n", string(callbakcMsg), isTrueCall, callBackCont)
} else {
if buttonClickAry[3] == "0" {
evals.UpEvaluationProcessReject(scoreFlowInfo.Key, 0, taskId, 1)
//发送消息
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, scoreFlowInfo.DutyDepartment) //获取对应部门内勤
if sendUserIsTrue != true {
// response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c)
// return
}
targettitle, detailedRulesTitle, detailedRulesInfo, unitStr, flowContent, _ := commonus.GetDutyAssociatedItems(scoreFlowKey)
title := flowContent.Reason
if title == "" {
if detailedRulesInfo != "" {
title = detailedRulesInfo
} else if detailedRulesTitle != "" {
title = detailedRulesInfo
} else {
title = targettitle
}
}
var desc string
if flowContent.PlusReduceScore == 1 {
desc = fmt.Sprintf("增加:%v%v", flowContent.Score, unitStr)
} else {
desc = fmt.Sprintf("扣除:%v%v", flowContent.Score, unitStr)
}
quoteAreaTitle := "责任划分"
var divisionResponsibilities []assessmentmodel.DivisionResponsibilities
dRBerr := global.GVA_DB_Performanceappraisal.Where("df_sf_id = ?", scoreFlowKey).Find(&divisionResponsibilities).Error
var quoteAreaContent string
if dRBerr == nil {
for _, drb_val := range divisionResponsibilities {
var zeren string
switch drb_val.Type {
case 1:
zeren = "主要责任人"
case 2:
zeren = "互保责任人"
case 3:
zeren = "责任班组"
case 4:
zeren = "责任班组长"
case 5:
zeren = "主管"
case 6:
zeren = "三大员"
case 7:
zeren = "厂长、主任"
default:
zeren = "主要责任人"
}
quoteAreaContent = quoteAreaContent + fmt.Sprintf("%v:%v 责任占比:%v\n", zeren, drb_val.UserName, drb_val.Weight)
}
}
twoLevelTitle := "考核上报部门"
var twoLevelKeyName, twoLevelKeyValue string
userWechatErr, userWechat := commonus.GetUesrContForWechatID(t.FromUsername)
if userWechatErr == true {
twoLevelKeyName = userWechat.DepartmentName
twoLevelKeyValue = userWechat.Name
}
twoLevelUserId := t.FromUsername
jumpUrl := fmt.Sprintf("http://www.hxgk.group?orderid=%v", scoreFlowKey)
jumpUrlTitle := "请前往处理被驳回的任务"
sourceDesc := "驳回"
var sendTextMsg sendmessage.TextNoticeTemplateMedium
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendNewsMsgText(sendUserList, strconv.FormatInt(taskId, 10), title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, jumpUrl, jumpUrlTitle, sourceDesc)
fmt.Printf("更新发送信息返回:%v-----------%v----------->%v-----\n", string(callbakcMsg), isTrueCall, callBackCont)
} else {
var recMeasCont assessmentmodel.RectificationMeasures
judgeRecMeas := global.GVA_DB_Performanceappraisal.Where("`rm_id` = ?", buttonClickAry[3]).First(&recMeasCont).Error
if judgeRecMeas != nil {
fmt.Printf("未知整改措施--->:%v\n", t.EventKey)
return
}
evals.UpEvaluationProcessReject(scoreFlowInfo.Key, 0, taskId, 3)
//获取接收人是谁 第一责任人
var weChatStr []string
var divisResponInfo []assessmentmodel.DivisionResponsibilities
judegdivisErr := global.GVA_DB_Performanceappraisal.Where("`df_type` = 1 AND `df_sf_id` = ?", scoreFlowKey).Find(&divisResponInfo).Error
if judegdivisErr == nil {
//获取操作人
userFileStr := "wm_number,qywx_key,wx_key"
for _, dri_v := range divisResponInfo {
//操作人条件
userWherAry := commonus.MapOut()
// userWherAry["wm_key"] = "WoBenShanLiang_3" //"WoBenShanLiang_3"
userWherAry["wm_key"] = dri_v.UserKey
userConting, userIsTrue := commonus.GetUserInfoPublic(userFileStr, userWherAry)
if userIsTrue == true {
if userConting.WechatId != "" && userConting.WorkWechatId != "" {
weChatStr = append(weChatStr, userConting.WorkWechatId)
} else if userConting.WechatId != "" && userConting.WorkWechatId == "" {
weChatStr = append(weChatStr, userConting.WechatId)
} else if userConting.WechatId == "" && userConting.WorkWechatId != "" {
weChatStr = append(weChatStr, userConting.WorkWechatId)
}
}
}
targettitle, detailedRulesTitle, detailedRulesInfo, unitStr, flowContent, _ := commonus.GetDutyAssociatedItems(scoreFlowKey)
title := flowContent.Reason
if title == "" {
if detailedRulesInfo != "" {
title = detailedRulesInfo
} else if detailedRulesTitle != "" {
title = detailedRulesInfo
} else {
title = targettitle
}
}
var desc string
if flowContent.PlusReduceScore == 1 {
desc = fmt.Sprintf("增加:%v%v", flowContent.Score, unitStr)
} else {
desc = fmt.Sprintf("扣除:%v%v", flowContent.Score, unitStr)
}
sendUserList := strings.Join(weChatStr, "|")
var sendTextMsg sendmessage.TextNoticeTemplateMedium
quoteAreaTitle := "整改方案"
quoteAreaContent := recMeasCont.Content
twoLevelTitle := "考核上报部门"
var twoLevelKeyName, twoLevelKeyValue string
userWechatErr, userWechat := commonus.GetUesrContForWechatID(t.FromUsername)
if userWechatErr == true {
twoLevelKeyName = userWechat.DepartmentName
twoLevelKeyValue = userWechat.Name
}
twoLevelUserId := t.FromUsername
jumpUrl := fmt.Sprintf("http://www.hxgk.group?orderid=%v", scoreFlowKey)
jumpUrlTitle := "请前往处理被驳回的任务"
sourceDesc := "驳回"
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendNewsMsgText(sendUserList, strconv.FormatInt(taskId, 10), title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, jumpUrl, jumpUrlTitle, sourceDesc)
fmt.Printf("更新发送信息返回:%v-----------%v----------->%v-----\n", string(callbakcMsg), isTrueCall, callBackCont)
} else {
fmt.Printf("未找到责任人:%v-----------%v-----\n", judegdivisErr, divisResponInfo)
}
}
}
}
}
// 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 {
// userInfoErr, userInfo := commonus.GetUesrContForWechatID(v)
// if userInfoErr == true {
// buttonClickNAmeOtherEs := fmt.Sprintf("%v%v", userInfo.Name, buttonClickNAmeOther)
// t.UpdateButton(v, buttonClickNAmeOtherEs)
// } else {
// t.UpdateButton(v, buttonClickNAmeOther)
// }
// }
// fmt.Printf("click---------------------->%v--->%v\n", sendUserList, scoreFlowInfo.DutyDepartment)
// }
}
//其他按钮处理
func (t *TemplateCardPush) OtherClickButton(userAry []string, buttonClickNAmeOther string) {
userInfoErr, userInfo := commonus.GetUesrContForWechatID(t.FromUsername)
if len(userAry) > 0 {
for _, v := range userAry {
if v != t.FromUsername {
if userInfoErr == true {
buttonClickNAmeOtherEs := fmt.Sprintf("%v%v", userInfo.Name, buttonClickNAmeOther)
t.UpdateButton(v, buttonClickNAmeOtherEs)
} 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, keyNumber 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
}