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

302 lines
11 KiB

package maptostruct
import (
"encoding/json"
"fmt"
"key_performance_indicators/api/workwechat"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-04-14 08:29:21
@ 功能: 发送文本信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) SendMessage(c *gin.Context) {
var receivedValue publicmethod.PublicName
c.ShouldBindJSON(&receivedValue)
if receivedValue.Name == "" {
receivedValue.Name = "KaiXinGuo"
}
var sendMsg workwechat.SentMessage
sendMsg.ToUser = receivedValue.Name
sendMsg.MsgType = "template_card"
sendMsg.AgentId = 1000036
sendMsg.EnableIdTrans = 0
sendMsg.EnableDuplicateCheck = 0
sendMsg.DuplicateCheckInterval = 1800
var templateCard workwechat.TemplateCardMsgCont
templateCard.CardType = "text_notice"
//头部左标题部分
templateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
templateCard.Source.Desc = "恒信高科头部信息"
templateCard.Source.DescColor = 1
//头部下拉菜单部分
templateCard.ActionMenu.Desc = "头部下拉"
var actionContOne workwechat.ActionListCont
actionContOne.Text = "头部下拉选项一"
actionContOne.Key = "head_click_1"
templateCard.ActionMenu.ActionList = append(templateCard.ActionMenu.ActionList, actionContOne)
var actionContTwo workwechat.ActionListCont
actionContTwo.Text = "头部下拉选项二"
actionContTwo.Key = "head_click_2"
templateCard.ActionMenu.ActionList = append(templateCard.ActionMenu.ActionList, actionContTwo)
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成
templateCard.TaskId = fmt.Sprintf("task_%v", publicmethod.GetUUid(5))
//主内容框
templateCard.MainTitle.Title = "主内容标题"
templateCard.MainTitle.Desc = "主内容"
//引用文献样式
templateCard.QuoteArea.Type = 1
templateCard.QuoteArea.Url = "https://work.weixin.qq.com"
templateCard.QuoteArea.Title = "企业微信的引用样式标题"
templateCard.QuoteArea.QuoteText = "企业微信的引用样式内容"
//关键数据样式
templateCard.EmphasisContent.Title = "100"
templateCard.EmphasisContent.Desc = "核心数据"
//二级普通文本,建议不超过160个字
templateCard.SubTitleText = "二级普通文本,建议不超过160个字"
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
var hcListCont1 workwechat.HorizontalContentListCont
hcListCont1.Type = 0
hcListCont1.Keyname = "姓名:"
hcListCont1.Value = "秦东"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont1)
var hcListCont2 workwechat.HorizontalContentListCont
hcListCont2.Type = 1
hcListCont2.Keyname = "企业微信官网"
hcListCont2.Value = "点击访问"
hcListCont2.Url = "https://work.weixin.qq.com"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont2)
var hcListCont3 workwechat.HorizontalContentListCont
hcListCont3.Type = 3
hcListCont3.Keyname = "姓名"
hcListCont3.Value = "开心果"
hcListCont3.UserId = "KaiXinGuo"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont3)
//跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
var jmpCont1 workwechat.JumpListCont
jmpCont1.Type = 1
jmpCont1.Title = "跳转1"
jmpCont1.Url = "https://work.weixin.qq.com"
templateCard.JumpList = append(templateCard.JumpList, jmpCont1)
var jmpCont2 workwechat.JumpListCont
jmpCont2.Type = 0
jmpCont2.Title = "不跳转2"
templateCard.JumpList = append(templateCard.JumpList, jmpCont2)
//整体卡片的点击跳转事件,text_notice必填本字段
templateCard.CardAction.Type = 1
templateCard.CardAction.Url = "https://www.baidu.com"
sendMsg.TemplateCard = templateCard
callbackID, err := sendMsg.SendMessage()
outPut := make(map[string]interface{})
outPut["callbackID"] = string(callbackID)
outPut["err"] = err
outPut["sendMsg"] = sendMsg
publicmethod.Result(0, outPut, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-14 11:27:42
@ 功能: 更新文本消息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) UpdateTextMsg(c *gin.Context) {
var receivedValue publicmethod.PublicName
err := c.ShouldBindJSON(&receivedValue)
if receivedValue.Name == "" {
publicmethod.Result(1, err, c, "未知参数")
return
}
var sendMsg workwechat.UpdateMessage
sendMsg.UserIds = append(sendMsg.UserIds, "KaiXinGuo")
sendMsg.AgentId = 1000036
sendMsg.ResponseCode = receivedValue.Name
sendMsg.EnableIdTrans = 0
var templateCard workwechat.UpdateTemplateCardMsgCont
templateCard.CardType = "text_notice"
//头部左标题部分
templateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
templateCard.Source.Desc = "恒信高科头部信息-->1"
templateCard.Source.DescColor = 1
//头部下拉菜单部分
templateCard.ActionMenu.Desc = "头部下拉-->1"
var actionContOne workwechat.ActionListCont
actionContOne.Text = "头部下拉选项一-->1"
actionContOne.Key = "head_click_1"
templateCard.ActionMenu.ActionList = append(templateCard.ActionMenu.ActionList, actionContOne)
var actionContTwo workwechat.ActionListCont
actionContTwo.Text = "头部下拉选项二-->1"
actionContTwo.Key = "head_click_2"
templateCard.ActionMenu.ActionList = append(templateCard.ActionMenu.ActionList, actionContTwo)
//主内容框
templateCard.MainTitle.Title = "主内容标题-->1"
templateCard.MainTitle.Desc = "主内容-->1"
//引用文献样式
templateCard.QuoteArea.Type = 1
templateCard.QuoteArea.Url = "https://work.weixin.qq.com"
templateCard.QuoteArea.Title = "企业微信的引用样式标题-->1"
templateCard.QuoteArea.QuoteText = "企业微信的引用样式内容-->1"
//关键数据样式
templateCard.EmphasisContent.Title = "100-->1"
templateCard.EmphasisContent.Desc = "核心数据-->1"
//二级普通文本,建议不超过160个字
templateCard.SubTitleText = "二级普通文本,建议不超过160个字-->1"
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
var hcListCont1 workwechat.HorizontalContentListCont
hcListCont1.Type = 0
hcListCont1.Keyname = "姓名:"
hcListCont1.Value = "秦东-->1"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont1)
var hcListCont2 workwechat.HorizontalContentListCont
hcListCont2.Type = 1
hcListCont2.Keyname = "企业微信官网-->1"
hcListCont2.Value = "点击访问-->1"
hcListCont2.Url = "https://work.weixin.qq.com"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont2)
var hcListCont3 workwechat.HorizontalContentListCont
hcListCont3.Type = 3
hcListCont3.Keyname = "姓名-->1"
hcListCont3.Value = "开心果-->1"
hcListCont3.UserId = "KaiXinGuo"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont3)
//跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
var jmpCont1 workwechat.JumpListCont
jmpCont1.Type = 1
jmpCont1.Title = "跳转1-->1"
jmpCont1.Url = "https://work.weixin.qq.com"
templateCard.JumpList = append(templateCard.JumpList, jmpCont1)
var jmpCont2 workwechat.JumpListCont
jmpCont2.Type = 0
jmpCont2.Title = "不跳转2-->1"
templateCard.JumpList = append(templateCard.JumpList, jmpCont2)
//整体卡片的点击跳转事件,text_notice必填本字段
templateCard.CardAction.Type = 1
templateCard.CardAction.Url = "https://www.baidu.com"
sendMsg.TemplateCard = templateCard
callbackID, err := sendMsg.UpdateMessage()
outPut := make(map[string]interface{})
outPut["callbackID"] = string(callbackID)
outPut["err"] = err
publicmethod.Result(0, outPut, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-23 10:22:02
@ 功能: 发送迷你文本消息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) SendMessageMini(c *gin.Context) {
var receivedValue publicmethod.PublicName
c.ShouldBindJSON(&receivedValue)
if receivedValue.Name == "" {
receivedValue.Name = "KaiXinGuo"
}
var sendMsg workwechat.SentMiniMessage
//主题信息
sendMsg.ToUser = receivedValue.Name
var templateCard workwechat.TemplateCardMsgContMini
uuid := publicmethod.GetUUid(5)
//头部左标题部分
templateCard.Source.Desc = "恒信高科头部信息"
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成
templateCard.TaskId = fmt.Sprintf("kpi_ratify_%v", uuid)
templateCard.ActionMenu.Desc = "恒信高科"
var rightHand workwechat.ActionListCont
rightHand.Text = "恒信高科"
rightHand.Key = fmt.Sprintf("kpi_head_%v", publicmethod.GetUUid(7))
templateCard.ActionMenu.ActionList = append(templateCard.ActionMenu.ActionList, rightHand)
//主内容框
templateCard.MainTitle.Title = "维度"
// templateCard.MainTitle.Desc = "指标"
//引用文献样式
// templateCard.QuoteArea.Title = "提报时间:2023-04-23 10:29"
setMsg := fmt.Sprintf("%v\n%v\n%v", "扣除5分", "原因:员工违规操作", "提报时间:2023-04-23 10:29")
templateCard.QuoteArea.QuoteText = setMsg
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
var hcListCont1 workwechat.HorizontalContentListCont
hcListCont1.Type = 0
hcListCont1.Keyname = "提报部门:"
hcListCont1.Value = "企管部"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont1)
var hcListCont3 workwechat.HorizontalContentListCont
hcListCont3.Type = 3
hcListCont3.Keyname = "提报人:"
hcListCont3.Value = "秦东(300450)"
hcListCont3.UserId = "KaiXinGuo"
templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont3)
//审批详情也米娜
jumpUrl := fmt.Sprintf("%v/#/pages/approval/departworkflowcont?id=%v", overall.CONSTANT_CONFIG.Appsetup.WebUrl, 2190)
//跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3
var jmpCont1 workwechat.JumpListCont
jmpCont1.Type = 1
jmpCont1.Title = "前往处理"
jmpCont1.Url = jumpUrl
templateCard.JumpList = append(templateCard.JumpList, jmpCont1)
//整体卡片的点击跳转事件,text_notice必填本字段
templateCard.CardAction.Url = jumpUrl
sendMsg.TemplateCard = templateCard
callbackID, err := sendMsg.InitMes().SendMessage()
var enforcer []string
enforcer = append(enforcer, receivedValue.Name)
workwechatErr := workwechat.WriteUpdateWechatTempmsg(callbackID, sendMsg, 1, uuid, enforcer)
var callbackCont publicmethod.WechatCallBack
json.Unmarshal(callbackID, &callbackCont)
outPut := make(map[string]interface{})
outPut["callbackID"] = string(callbackID)
outPut["err"] = err
outPut["sendMsg"] = sendMsg
outPut["callbackCont"] = callbackCont
outPut["workwechatErr"] = workwechatErr
publicmethod.Result(0, outPut, c)
}