Browse Source

发送和撤回企业微信

li_v1
herenshan112 8 months ago
parent
commit
0e4f0e07d8
  1. 19
      api/version1/customerform/formTable.go
  2. 2
      api/version1/taskplatform/taskflow/taskFlow.go
  3. 453
      api/version1/taskplatform/taskmanagement/formcontrol.go
  4. 2
      api/version1/taskplatform/taskmanagement/types.go
  5. 62
      api/version1/workWechat/sendMsg.go
  6. 2
      apirouter/v1/taskrouter/taskrouter.go

19
api/version1/customerform/formTable.go

@ -2,6 +2,7 @@ package customerform
import (
datacenter "appPlatform/api/version1/dataCenter"
"appPlatform/middleware/grocerystore"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
@ -1441,6 +1442,11 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok {
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
}
masterKeyVal := publicmethod.TypeToInterface(masterKey)
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", masterKeyVal)
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
formList[i]["retract_true"], _ = redisClient.Get(redisKey)
var taskInfo customerForm.TaskRecord
overall.CONSTANT_DB_CustomerForm.Where("`masters_key` = ?", mastrKeyVal).First(&taskInfo)
formList[i]["runFlowId"] = strconv.FormatInt(taskInfo.RunFlowId, 10)
@ -1582,6 +1588,11 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
}
masterKeyVal := publicmethod.TypeToInterface(masterKey)
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", masterKeyVal)
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
formList[i]["retract_true"], _ = redisClient.Get(redisKey)
}
fmt.Printf("mastrKeyVal----------->%T----------->%v\n", v["table_structure"], v["table_structure"])
for _, sv := range sunMap {
@ -1899,24 +1910,32 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa
switch mvInt {
case 1:
sendInfo[mi] = "启用"
sendInfo["statess"] = 1
case 2:
sendInfo[mi] = "禁用"
sendInfo["statess"] = 2
case 3:
sendInfo[mi] = "删除"
sendInfo["statess"] = 3
default:
sendInfo[mi] = "未知"
sendInfo["statess"] = 4
}
case "flowIsOpen":
mvInt, _ := publicmethod.StringToInt64(mv)
switch mvInt {
case 1:
sendInfo[mi] = "开启"
sendInfo["flowIsOpens"] = 1
case 2:
sendInfo[mi] = "关闭"
sendInfo["flowIsOpens"] = 2
case 3:
sendInfo[mi] = "删除"
sendInfo["flowIsOpens"] = 3
default:
sendInfo[mi] = "未知"
sendInfo["flowIsOpens"] = 4
}
default:
sendInfo[mi] = l.BaseTableAttrField(mi, mv, formJsonCont)

2
api/version1/taskplatform/taskflow/taskFlow.go

@ -1,6 +1,7 @@
package taskflow
import (
"appPlatform/api/version1/workWechat"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/models/reviseform"
@ -1152,5 +1153,6 @@ func (a *ApiMethod) RetractRunFlow(c *gin.Context) {
}
var taskInfo modelAppPlatform.Task
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTaskInfo)
workWechat.RecallWorkWechatMsg("stzl", requestData.Id)
publicmethod.Result(0, err, c)
}

453
api/version1/taskplatform/taskmanagement/formcontrol.go

@ -4,6 +4,7 @@ import (
"appPlatform/api/version1/customerform"
datacenter "appPlatform/api/version1/dataCenter"
"appPlatform/api/version1/workWechat"
"appPlatform/middleware/grocerystore"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
@ -975,8 +976,16 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) {
json.Unmarshal([]byte(formCont.ListJson), &sendMsgInterface)
var sendMsgInfo SendMsgInfo
sendMsgInfo.SendMsg(sendMsgInterface.SendMsg, userCont, taskCont.Title, cureeTime, masterField, masterUnitList)
sendMsgInfo = sendMsgInterface.SendMsg
msgid, _ := sendMsgInfo.SendMsg(userCont, taskCont.Title, uuid, cureeTime, masterField, masterUnitList)
fmt.Printf("发送返回信息------------->%v\n\n\n", msgid)
if msgid != "" {
//设定redis Key名称
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", uuid)
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
redisClient.SetRedisTime(86400)
redisClient.Set(redisKey, msgid)
}
// sendConfig := sendMsgInterface.SendMsg
// if sendConfig.Open {
// msgTitle := taskCont.Title
@ -1008,27 +1017,29 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) {
@ 返回值
#
#msgid 消息id用于撤回应用消息
#err 信息
@ 方法原型
#
*/
func (s *SendMsgInfo) SendMsg(sendConfig SendMsgInfo, userCont modelshr.ManCont, msgTitle string, cureeTime int64, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct) bool {
if sendConfig.Open { //开启发送信息
func (s *SendMsgInfo) SendMsg(userCont modelshr.ManCont, msgTitle string, uuid, cureeTime int64, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct) (msgid string, err error) {
if s.Open { //开启发送信息
var sendMsg workWechat.SendMessage
sendUserCount := 0
var sendUserAll []string
isSend := true
//Step 1: 获取消息的发送范围
switch sendConfig.SendRange {
switch s.SendRange {
case 1: //全集团
sendMsg.Touser = "@all"
case 2: //本公司
var myCompany modelshr.AdministrativeOrganization
myCompany.GetCont(map[string]interface{}{"id": userCont.Company}, "`schoole`")
if myCompany.Schoole != 0 {
sendMsg.Toparty = strconv.FormatInt(myCompany.Schoole, 10)
myCompany.GetCont(map[string]interface{}{"id": userCont.Company}, "`wechat_organization_id`")
if myCompany.WechatOrganizationId != 0 {
sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10)
} else {
if userCont.Company != 0 {
//获取该组织得所以下级
@ -1056,9 +1067,9 @@ func (s *SendMsgInfo) SendMsg(sendConfig SendMsgInfo, userCont modelshr.ManCont,
case 3: //本部门
if userCont.MainDeparment != 0 {
var myCompany modelshr.AdministrativeOrganization
myCompany.GetCont(map[string]interface{}{"id": userCont.MainDeparment}, "`schoole`")
if myCompany.Schoole != 0 {
sendMsg.Toparty = strconv.FormatInt(myCompany.Schoole, 10)
myCompany.GetCont(map[string]interface{}{"id": userCont.MainDeparment}, "`wechat_organization_id`")
if myCompany.WechatOrganizationId != 0 {
sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10)
} else {
//获取该组织得所以下级
sendUserAll = GainOrgManWechat(userCont.MainDeparment)
@ -1085,9 +1096,9 @@ func (s *SendMsgInfo) SendMsg(sendConfig SendMsgInfo, userCont modelshr.ManCont,
case 4: //本行政组织
if userCont.AdminOrg != 0 {
var myCompany modelshr.AdministrativeOrganization
myCompany.GetCont(map[string]interface{}{"id": userCont.AdminOrg}, "`schoole`")
if myCompany.Schoole != 0 {
sendMsg.Toparty = strconv.FormatInt(myCompany.Schoole, 10)
myCompany.GetCont(map[string]interface{}{"id": userCont.AdminOrg}, "`wechat_organization_id`")
if myCompany.WechatOrganizationId != 0 {
sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10)
} else {
//获取该组织得所以下级
sendUserAll = GainOrgManWechat(userCont.AdminOrg)
@ -1122,13 +1133,382 @@ func (s *SendMsgInfo) SendMsg(sendConfig SendMsgInfo, userCont modelshr.ManCont,
}
}
case 6: //自定义
sendUserAll = s.CustomizeSendMsg()
sendUserCount = len(sendUserAll)
if sendUserCount <= 1000 && sendUserCount > 0 {
sendMsg.Touser = strings.Join(sendUserAll, "|")
} else {
if sendUserCount == 0 {
isSend = false
}
}
default:
isSend = false
}
if isSend {
switch s.Types {
case "textcard":
sendMsg.Msgtype = "textcard"
sendMsg.Textcard.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, subUnit)
sendMsg.Textcard.Description = fmt.Sprintf("<div class='gray'>%v</div> <div class='normal'>%v</div><div class='highlight'>请尽快阅读此信息</div>", publicmethod.UnixTimeToDay(time.Now().Unix(), 11), s.SendMsgInfo(s.Content, msgTitle, fieldVal, subUnit))
sendMsg.Textcard.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid)
sendMsg.Textcard.Btntxt = "前往查看"
case "news":
sendMsg.Msgtype = "news"
//图文内容
var imgMsgInfo workWechat.ArticlesList
imgMsgInfo.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, subUnit)
imgMsgInfo.Description = s.SendMsgInfo(s.Content, msgTitle, fieldVal, subUnit)
imgMsgInfo.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid)
imgMsgInfo.PicUrl = s.GainOneField(s.Icon, msgTitle, fieldVal, subUnit)
sendMsg.NewsMsg.Articles = append(sendMsg.NewsMsg.Articles, imgMsgInfo)
// sendMsg.NewsMsg.Articles = s.SendMsgInfo(s.Title, msgTitle, fieldVal, subUnit)
default:
sendMsg.Msgtype = "text"
sendMsg.TextMsg.Content = s.SendMsgInfo(s.Content, msgTitle, fieldVal, subUnit)
}
sendInitInfouser, _ := json.Marshal(sendUserAll)
fmt.Printf("\n\n这是查看接收人信息-----》%v\n\n", string(sendInitInfouser))
sendInitInfo, _ := json.Marshal(sendMsg)
fmt.Printf("\n\n这是查看输入信息-----》%v\n\n", string(sendInitInfo))
//判断当前人数是否曹组
if sendUserCount >= 1000 {
var msgidAry []string
var msgToUser []string
for i, v := range sendUserAll {
if (i+1)%1000 == 0 {
if len(msgToUser) > 0 {
sendMsg.Touser = strings.Join(msgToUser, "|")
msgidSte, errStr := sendMsg.SendMsg("stzl", 1)
msgToUser = []string{}
msgidAry = append(msgidAry, msgidSte)
if errStr != nil {
err = errStr
}
}
} else {
msgToUser = append(msgToUser, v)
}
}
if len(msgToUser) > 0 {
sendMsg.Touser = strings.Join(msgToUser, "|")
msgidSte, errStr := sendMsg.SendMsg("stzl", 1)
msgToUser = []string{}
msgidAry = append(msgidAry, msgidSte)
if errStr != nil {
err = errStr
}
}
if len(msgidAry) > 0 {
msgid = strings.Join(msgidAry, ",")
}
} else {
msgid, err = sendMsg.SendMsg("stzl", 1)
}
}
} else {
err = nil
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-03-31 13:54:38
@ 功能: 获取单一字段的数据
*/
func (s *SendMsgInfo) GainOneField(fields string, msgTitle string, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct) string {
var sendData interface{}
if val, isOk := fieldVal[fields]; isOk {
sendData = val
}
unitCont := GainFieldType(fields, subUnit)
switch unitCont.Type {
case "input", "password", "lowcodeImage": //单行文本
msgTitle = publicmethod.TypeToInterface(sendData)
case "textarea", "tinymce": //多行文本,富文本
msgTitle = publicmethod.TypeToInterface(sendData)
case "radio", "select": //单选框组、下拉选择框
val := publicmethod.TypeToInterface(sendData)
if len(unitCont.Options) > 0 {
for _, uv := range unitCont.Options {
if uv.Value == val {
msgTitle = uv.Label
}
}
}
case "checkbox", "cascader", "treeSelect", "upload": //checkbox,级联选择器,树形控件,图片/文件: ,
if valMap, isOk := sendData.([]int); isOk {
if len(valMap) > 0 && len(unitCont.Options) > 0 {
var titalMap []string
for _, v := range valMap {
for _, uv := range unitCont.Options {
if uv.Value == strconv.Itoa(v) {
titalMap = append(titalMap, uv.Label)
}
}
}
msgTitle = fmt.Sprintf("\"%v\"", strings.Join(titalMap, "、"))
}
}
case "expand-user": //选择用户
val := publicmethod.TypeToInterface(sendData)
var userNumber []string
ruleSet := regexp.MustCompile(`\(([^)]+)\)`)
valMap := ruleSet.FindAllStringSubmatch(val, -1)
if len(valMap) > 0 {
for _, v := range valMap {
vLen := len(v)
if vLen > 0 {
if !publicmethod.IsInTrue(v[vLen-1], userNumber) {
userNumber = append(userNumber, fmt.Sprintf("%v(%v)", v[0], v[vLen-1]))
}
}
}
}
msgTitle = fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、"))
case "datePicker": //日期选择器
if strVal, ok := sendData.([]interface{}); ok {
strValLen := len(strVal)
if strValLen > 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
msgTitle = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14))
} else if strValLen == 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
msgTitle = publicmethod.TypeToClass(startTimg/1000, 14)
}
} else {
startTimg, _ := publicmethod.StringToInt64(sendData)
msgTitle = publicmethod.TypeToClass(startTimg, 14)
}
case "timePicker", "inputNumber": //时间选择器,计数器
if strVal, ok := sendData.([]interface{}); ok {
strValLen := len(strVal)
if strValLen > 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
msgTitle = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14))
} else if strValLen == 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
msgTitle = publicmethod.TypeToClass(startTimg/1000, 14)
}
} else {
startTimg, _ := publicmethod.StringToInt64(sendData)
msgTitle = publicmethod.TypeToClass(startTimg, 14)
}
case "colorPicker": //取色器
msgTitle = publicmethod.TypeToInterface(sendData)
case "switch": //开关
startTimg, _ := publicmethod.StringToInt64(sendData)
if startTimg == 1 {
msgTitle = "是"
} else {
msgTitle = "否"
}
case "rate", "slider": //评分,滑块
msgTitle = publicmethod.TypeToInterface(sendData)
case "txt", "button", "title", "table", "grid", "tabs", "card", "flex", "divider", "div": //文本,按钮,标题,表格,格栅,标签,卡片布局,弹性布局,分割线,容器
msgTitle = publicmethod.TypeToInterface(sendData)
case "component": //自定义组件 (格式待定)
msgTitle = publicmethod.TypeToInterface(sendData)
default:
msgTitle = publicmethod.TypeToInterface(sendData)
}
return msgTitle
}
/*
*
@ 作者: 秦东
@ 时间: 2025-03-28 15:48:28
@ 功能: 获取发送标题
*/
func (s *SendMsgInfo) SendMsgInfo(fields []string, msgTitle string, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct) string {
fmt.Printf("\n\n应获取的字段--->%v\n\n", fields)
if len(fields) > 0 {
biaotiYUneirong := ""
for _, v := range fields {
var sendData interface{}
if val, isOk := fieldVal[v]; isOk {
sendData = val
}
unitCont := GainFieldType(v, subUnit)
fmt.Printf("\n\n应获取的字段--1->%v--->%v\n\n", unitCont.Type, sendData)
switch unitCont.Type {
case "input", "password", "lowcodeImage": //单行文本
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
case "textarea", "tinymce": //多行文本,富文本
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
case "radio", "select": //单选框组、下拉选择框
val := publicmethod.TypeToInterface(sendData)
if len(unitCont.Options) > 0 {
for _, uv := range unitCont.Options {
if uv.Value == val {
biaotiYUneirong = uv.Label
}
}
}
case "checkbox", "cascader", "treeSelect", "upload": //checkbox,级联选择器,树形控件,图片/文件: ,
if valMap, isOk := sendData.([]int); isOk {
if len(valMap) > 0 && len(unitCont.Options) > 0 {
var titalMap []string
for _, v := range valMap {
for _, uv := range unitCont.Options {
if uv.Value == strconv.Itoa(v) {
titalMap = append(titalMap, uv.Label)
}
}
}
biaotiYUneirong = fmt.Sprintf("\"%v\"", strings.Join(titalMap, "、"))
}
}
case "expand-user": //选择用户
val := publicmethod.TypeToInterface(sendData)
var userNumber []string
ruleSet := regexp.MustCompile(`\(([^)]+)\)`)
valMap := ruleSet.FindAllStringSubmatch(val, -1)
if len(valMap) > 0 {
for _, v := range valMap {
vLen := len(v)
if vLen > 0 {
if !publicmethod.IsInTrue(v[vLen-1], userNumber) {
userNumber = append(userNumber, fmt.Sprintf("%v(%v)", v[0], v[vLen-1]))
}
}
}
}
biaotiYUneirong = fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、"))
case "datePicker": //日期选择器
if strVal, ok := sendData.([]interface{}); ok {
strValLen := len(strVal)
if strValLen > 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14))
} else if strValLen == 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
biaotiYUneirong = publicmethod.TypeToClass(startTimg/1000, 14)
}
} else {
startTimg, _ := publicmethod.StringToInt64(sendData)
biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
}
case "timePicker", "inputNumber": //时间选择器,计数器
if strVal, ok := sendData.([]interface{}); ok {
strValLen := len(strVal)
if strValLen > 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14))
} else if strValLen == 1 {
startTimg, _ := publicmethod.StringToInt64(strVal[0])
biaotiYUneirong = publicmethod.TypeToClass(startTimg/1000, 14)
}
} else {
startTimg, _ := publicmethod.StringToInt64(sendData)
biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
}
case "colorPicker": //取色器
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
case "switch": //开关
startTimg, _ := publicmethod.StringToInt64(sendData)
if startTimg == 1 {
biaotiYUneirong = "是"
} else {
biaotiYUneirong = "否"
}
case "rate", "slider": //评分,滑块
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
case "txt", "button", "title", "table", "grid", "tabs", "card", "flex", "divider", "div": //文本,按钮,标题,表格,格栅,标签,卡片布局,弹性布局,分割线,容器
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
case "component": //自定义组件 (格式待定)
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
default:
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
}
}
fmt.Printf("\n\n应获取的字段-3-->%v\n\n", biaotiYUneirong)
return biaotiYUneirong
}
return false
return msgTitle
}
/*
*
@ 作者: 秦东
@ 时间: 2025-03-28 15:52:29
@ 功能: 获取字段类型
*/
func GainFieldType(fields string, subUnit map[string]customerform.MasterStruct) (unitInfo customerform.MasterStruct) {
if fields != "" {
if val, isOk := subUnit[fields]; isOk {
unitInfo = val
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-03-28 15:10:14
@ 功能: 处理自定义人员
*/
func (s *SendMsgInfo) CustomizeSendMsg() (wechatMap []string) {
if len(s.SendRangeList) > 0 {
var Recipient []string
var orgAry []string
var userAry []string
for _, v := range s.SendRangeList {
if v.Types == "masterOrg" {
if !publicmethod.IsInTrue[string](v.Id, orgAry) {
orgAry = append(orgAry, v.Id)
}
} else {
if !publicmethod.IsInTrue[string](v.Id, userAry) {
userAry = append(userAry, v.Id)
}
}
}
if len(orgAry) > 0 {
for _, ov := range orgAry {
val, _ := publicmethod.StringToInt64(ov)
if val != 0 {
//获取该组织得所以下级
Recipient = append(Recipient, GainOrgManWechat(val)...)
}
}
}
if len(userAry) > 0 {
var orgManList []modelshr.PersonArchives
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `id` IN ?", userAry).Find(&orgManList)
if len(orgManList) > 0 {
for _, v := range orgManList {
if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, Recipient) {
Recipient = append(Recipient, v.Wechat)
}
if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, Recipient) {
Recipient = append(Recipient, v.WorkWechat)
}
}
}
}
//人员去重
if len(Recipient) > 0 {
for _, v := range Recipient {
if !publicmethod.IsInTrue[string](v, wechatMap) {
wechatMap = append(wechatMap, v)
}
}
}
}
return
}
/*
@ -1415,3 +1795,42 @@ func WriteSunDatabaseSoucer(sqlDb *gorm.DB, uuid, creater, createrTime int64, ma
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-04-01 13:11:07
@ 功能: 撤回发送的信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) RecalSendMsg(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil || requestData.Id == "" {
publicmethod.Result(10001, err, c)
return
}
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", requestData.Id)
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
isTrue, msgId := redisClient.Get(redisKey)
if !isTrue {
publicmethod.Result(1, err, c, "数据撤回失败!")
return
}
if workWechat.RecallWorkWechatMsg("stzl", msgId) {
redisClient.DelKey(redisKey)
publicmethod.Result(0, err, c)
} else {
publicmethod.Result(1, err, c, "数据撤回失败!")
}
}

2
api/version1/taskplatform/taskmanagement/types.go

@ -184,7 +184,7 @@ type FormListInfo struct {
// 发送企业微信消息
type SendMsgInfo struct {
Open bool `json:"open"` //是否开启发送
Types string `json:"type"` //发送消息类型
Types string `json:"type"` //发送消息类型 textcard:文本卡片;news:图文消息;text:文本消息
Title []string `json:"title"` //发送信息标题(对应表单字段)
Content []string `json:"content"` //发送信息描述(对应表单字段)
Icon string `json:"icon"` //发送信息封面(对应表单字段)

62
api/version1/workWechat/sendMsg.go

@ -40,8 +40,8 @@ func (a *ApiMethod) SendMsg(c *gin.Context) {
// sendText.TemplateCard.CardType = requestData.Name
// sendText.TemplateCard.TextTemplate.CardAction.Type = 1
// sendText.TemplateCard.TextTemplate.CardAction.Url = "https://www.baidu.com"
err := requestData.SendMsg("stzl", 1)
fmt.Printf("sendText: %v\n\n\n", err)
msgid, err := requestData.SendMsg("stzl", 1)
fmt.Printf("sendText: %v\n\n\n%v\n\n\n", msgid, err)
if err != nil {
publicmethod.Result(1, requestData, c, "消息发送失败!")
} else {
@ -50,7 +50,7 @@ func (a *ApiMethod) SendMsg(c *gin.Context) {
}
func (m *SendMapMsg) SendMsg(systemApp string, calss int) (err error) {
func (m *SendMapMsg) SendMsg(systemApp string, calss int) (msgid string, err error) {
sendUrl, _, err := GetSendMsgTokenUrl(systemApp, 1)
if err != nil {
return
@ -60,6 +60,7 @@ func (m *SendMapMsg) SendMsg(systemApp string, calss int) (err error) {
var callBackMap interface{}
err = json.Unmarshal(callBackByte, &callBackMap)
fmt.Printf("jsonCont==>%v\n\n\n\n", string(sendMsgData))
fmt.Printf("\n\n\n\n企业微信返回数据==>%v\n\n\n\n", string(callBackByte))
resendIsRun := false
if val, isOk := callBackMap.(map[string]interface{}); isOk {
if mapVal, isOk := val["errcode"]; isOk {
@ -77,12 +78,15 @@ func (m *SendMapMsg) SendMsg(systemApp string, calss int) (err error) {
} else {
resendIsRun = true
}
if msgidVal, isOk := val["msgid"]; isOk {
msgid = publicmethod.TypeToInterface(msgidVal)
}
} else {
resendIsRun = true
}
if resendIsRun {
m.Number++
err = m.ResendSendMsg(systemApp, calss)
msgid, err = m.ResendSendMsg(systemApp, calss)
// fmt.Scanln()
// m.SendMsg(systemApp, calss)
return
@ -98,13 +102,13 @@ func (m *SendMapMsg) SendMsg(systemApp string, calss int) (err error) {
@ 时间: 2024-12-11 09:56:18
@ 功能: 为得到正确信息是重复发送请求最多发送三次
*/
func (m *SendMapMsg) ResendSendMsg(systemApp string, calss int) (err error) {
func (m *SendMapMsg) ResendSendMsg(systemApp string, calss int) (msgid string, err error) {
fmt.Printf("执行第几次--->%v\n", m.Number)
if m.Number <= 3 {
go func() {
time.Sleep(time.Duration(5) * time.Second)
// fmt.Println("这条信息将在几秒后显示。")
err = m.SendMsg(systemApp, calss)
msgid, err = m.SendMsg(systemApp, calss)
}()
} else {
fmt.Printf("超过最大补发次数!消息作废!--->%v\n", m.Number)
@ -199,7 +203,7 @@ func (s *SendMessage) MsgInit() {
#
*/
func (s *SendMessage) SendMsg(systemApp string, class int) (err error) {
func (s *SendMessage) SendMsg(systemApp string, class int) (msgid string, err error) {
s.MsgInit()
topMapAry, err := s.MsgCommon.MsgCommon()
if err != nil {
@ -274,5 +278,47 @@ func (s *SendMessage) SendMsg(systemApp string, class int) (err error) {
}
// mapAry.Send["template_card"] = templateCard
return mapAry.SendMsg(systemApp, class)
msgid, err = mapAry.SendMsg(systemApp, class)
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-04-01 10:50:40
@ 功能: 撤回已发送的信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func RecallWorkWechatMsg(systemApp, msgId string) bool {
sendUrl, _, err := GetSendMsgTokenUrl(systemApp, 3)
if err != nil {
return false
}
sendInfo := publicmethod.MapOut[string]()
sendInfo["msgid"] = msgId
sendMsgData, _ := json.Marshal(sendInfo)
callBackByte := publicmethod.CurlPostJosn(sendUrl, sendMsgData)
var callBackMap interface{}
err = json.Unmarshal(callBackByte, &callBackMap)
fmt.Printf("jsonCont==>%v\n\n\n\n", string(sendMsgData))
fmt.Printf("\n\n\n\n企业微信返回数据==>%v\n\n\n\n", string(callBackByte))
if val, isOk := callBackMap.(map[string]interface{}); isOk {
if mapVal, isOk := val["errcode"]; isOk {
val, _ := publicmethod.StringToInt64(mapVal)
if val == 0 {
return true
}
}
}
return false
}

2
apirouter/v1/taskrouter/taskrouter.go

@ -50,6 +50,8 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("runTaskFlow", taskManagementRouter.RunTaskFlow) //执行工作流
apiRouter.POST("gainWebTaskFlowInfo", taskManagementRouter.GainWebTaskFlowInfo) // 获取web表单数据
apiRouter.POST("recalSendMsg", taskManagementRouter.RecalSendMsg) // 撤回发送的信息
}
taskFlowApi := router.Group("task_flow")

Loading…
Cancel
Save