|
|
|
|
package shiyan
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"encoding/xml"
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"strconv"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"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/approvalprocess"
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/testpage"
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/model/wechat"
|
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/utils/redishandel"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ShiyanApi struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *ShiyanApi) AddBaseMenu(c *gin.Context) {
|
|
|
|
|
var answerMap testpage.Answer
|
|
|
|
|
err := global.GVA_DB_Master.First(&answerMap)
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%v\n", answerMap)
|
|
|
|
|
response.Ok(c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get请求获参
|
|
|
|
|
func (a *ShiyanApi) GetRequestOperation(c *gin.Context) {
|
|
|
|
|
id := c.Query("id")
|
|
|
|
|
fmt.Printf("====>%v\n", id)
|
|
|
|
|
response.Ok(c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get请求获参
|
|
|
|
|
type postGroupCanshu struct {
|
|
|
|
|
Id int `json:"id" from:"id"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *ShiyanApi) PostRequestOperation(c *gin.Context) {
|
|
|
|
|
var ids postGroupCanshu
|
|
|
|
|
_ = c.ShouldBindJSON(&ids)
|
|
|
|
|
// name := c.Query("id")
|
|
|
|
|
fmt.Printf("====>%v\n", ids.Id)
|
|
|
|
|
response.Ok(c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//实验递归
|
|
|
|
|
func (s *ShiyanApi) DiGui(c *gin.Context) {
|
|
|
|
|
var group []wechat.GroupForm
|
|
|
|
|
listErr := global.GVA_DB_WatchDate.Find(&group).Error
|
|
|
|
|
if listErr == nil {
|
|
|
|
|
}
|
|
|
|
|
var ids wechat.GroupForm
|
|
|
|
|
_ = c.ShouldBindJSON(&ids)
|
|
|
|
|
var setid int64
|
|
|
|
|
setid = 51
|
|
|
|
|
if ids.Id != 0 {
|
|
|
|
|
setid = ids.Id
|
|
|
|
|
}
|
|
|
|
|
// var parentId []int64
|
|
|
|
|
// var dd Ddigui
|
|
|
|
|
// dd.faherDigui(81, group, parentId)
|
|
|
|
|
// dd.Date = commonus.BubbleSort(dd.Date)
|
|
|
|
|
var dd commonus.ErgodicStruct
|
|
|
|
|
dd.ParentId = 1
|
|
|
|
|
dd.ErgodicParentClassGroup(setid, group)
|
|
|
|
|
dd.Date = append(dd.Date, setid)
|
|
|
|
|
dd.Date = commonus.BubbleSort(dd.Date)
|
|
|
|
|
setidIntString := strconv.FormatInt(setid, 10)
|
|
|
|
|
setidInt, _ := strconv.Atoi(setidIntString)
|
|
|
|
|
depart, isTrue := commonus.GetDepartment(setidInt)
|
|
|
|
|
dateary := commonus.MapOut()
|
|
|
|
|
dateary["data"] = depart
|
|
|
|
|
dateary["istrue"] = isTrue
|
|
|
|
|
dateary["digui"] = dd.Date
|
|
|
|
|
response.Result(0, dateary, "查询失败", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Ddigui struct {
|
|
|
|
|
Date []int64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//递归递归函数
|
|
|
|
|
func (d *Ddigui) faherDigui(id int64, groupStruct []wechat.GroupForm, parentId []int64) []int64 {
|
|
|
|
|
var parentIds []int64
|
|
|
|
|
// parentId = append(parentId, id)
|
|
|
|
|
for _, v := range groupStruct {
|
|
|
|
|
if v.Id == id {
|
|
|
|
|
d.Date = append(d.Date, v.Parentid)
|
|
|
|
|
|
|
|
|
|
d.faherDigui(v.Parentid, groupStruct, parentId)
|
|
|
|
|
// parentId = append(parentId, v.Parentid)
|
|
|
|
|
// fmt.Printf("%v==========>%v*******%v\n", id, v.Parentid, parentId)
|
|
|
|
|
// parentIds = parentId
|
|
|
|
|
// parentIds = faherDigui(v.Parentid, groupStruct, parentIds)
|
|
|
|
|
|
|
|
|
|
// parentId = append(parentId, v.Parentid)
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("%v==========>%v*******%v\n", id, v.Parentid, parentId)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// parentId = parentIds
|
|
|
|
|
// fmt.Printf("%v==========>*******\n", parentIds)
|
|
|
|
|
return parentIds
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//实验结果保存到数组
|
|
|
|
|
func (s *ShiyanApi) GormToMap(c *gin.Context) {
|
|
|
|
|
// returnData := commonus.MapOut()
|
|
|
|
|
// var returnData []map[string]interface{}
|
|
|
|
|
// tableName := "groupform"
|
|
|
|
|
// global.GVA_DB_WatchDate.Table(tableName).Find(&returnData)
|
|
|
|
|
var pGorm commonus.GormTopMap
|
|
|
|
|
pGorm.Db = global.GVA_DB_WatchDate
|
|
|
|
|
pGorm.TableName = "groupform"
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
returnData["ary"] = pGorm.PublicOrmToMap()
|
|
|
|
|
returnData["one"] = pGorm.PublicOrmToMapOne()
|
|
|
|
|
response.Result(0, returnData, "查询成功", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PersonInfo struct {
|
|
|
|
|
DefinitIons interface{} `json:"definitions"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//读取json文件解析
|
|
|
|
|
func (s *ShiyanApi) ReadJsonFiles(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
filePtr, err := os.Open("conf/forkflow.json")
|
|
|
|
|
defer filePtr.Close()
|
|
|
|
|
if err != nil {
|
|
|
|
|
dfg := fmt.Sprintf("Open file failed [Err:%s]", err.Error())
|
|
|
|
|
// fmt.Println("Open file failed [Err:%s]", err.Error())
|
|
|
|
|
response.Result(0, dfg, "查询成功", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
decoder := json.NewDecoder(filePtr)
|
|
|
|
|
|
|
|
|
|
var person []PersonInfo
|
|
|
|
|
|
|
|
|
|
err = decoder.Decode(&person)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println("Decoder failed", err.Error())
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Println("Open file failed [Err:%s]", person)
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
returnData["json"] = person
|
|
|
|
|
response.Result(0, returnData, "查询成功", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//XML转换处理
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*XML结构体
|
|
|
|
|
*/
|
|
|
|
|
type Definitions struct {
|
|
|
|
|
XMLName xml.Name `xml:"definitions" json:"definitions"`
|
|
|
|
|
Text string `xml:",chardata" json:"chardata"`
|
|
|
|
|
Bpmn2 string `xml:"bpmn2,attr" json:"bpmn2"`
|
|
|
|
|
Xsi string `xml:"xsi,attr" json:"xsi"`
|
|
|
|
|
Bpmndi string `xml:"bpmndi,attr" json:"bpmndi"`
|
|
|
|
|
Dc string `xml:"dc,attr" json:"dc"`
|
|
|
|
|
Flowable string `xml:"flowable,attr" json:"flowable"`
|
|
|
|
|
Di string `xml:"di,attr" json:"di"`
|
|
|
|
|
ID string `xml:"id,attr" json:"id"`
|
|
|
|
|
TargetNamespace string `xml:"targetNamespace,attr" json:"targetNamespace"`
|
|
|
|
|
SchemaLocation string `xml:"schemaLocation,attr" json:"schemaLocation"`
|
|
|
|
|
Process ProcessStruct `xml:"process" json:"process"` //工作流过程
|
|
|
|
|
BPMNDiagram BPMNDiagramStruct `xml:"BPMNDiagram" json:"BPMNDiagram"` //BPMN图结构
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//工作流过程
|
|
|
|
|
type ProcessStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
NameStruct
|
|
|
|
|
Documentation Documentationstruct `xml:"documentation" json:"documentation"` //结构描述
|
|
|
|
|
StartEvent StartEventStruct `xml:"startEvent" json:"startEvent"` //开始事件
|
|
|
|
|
UserTask []UserTaskStruct `xml:"userTask" json:"userTask"` //流程主体(用户任务)
|
|
|
|
|
EndEvent EndEventStruct `xml:"endEvent" json:"endEvent"` //结束事件
|
|
|
|
|
SequenceFlow []SequenceFlowStruct `xml:"sequenceFlow" json:"sequenceFlow"` //序列流
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//text结构体
|
|
|
|
|
type TextStruct struct {
|
|
|
|
|
Text string `xml:",chardata" json:",text"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//name结构体
|
|
|
|
|
type NameStruct struct {
|
|
|
|
|
Name string `xml:"name,attr" json:"name"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Text与ID 结构
|
|
|
|
|
type TextAndIdStruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
ID string `xml:"id,attr" json:"id"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Documentationstruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//工作流开始事件
|
|
|
|
|
type StartEventStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
NameStruct
|
|
|
|
|
Outgoing []OutgoingStruct `xml:"outgoing" json:"outgoing"` //流程出口
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//流程出口结构
|
|
|
|
|
type OutgoingStruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//流程主体(用户任务)
|
|
|
|
|
type UserTaskStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
NameStruct
|
|
|
|
|
Assignee string `xml:"assignee,attr" json:"assignee"` //处理人
|
|
|
|
|
CandidateGroups string `xml:"candidateGroups,attr" json:"candidateGroups"` //处理角色
|
|
|
|
|
CandidateUsers string `xml:"candidateUsers,attr" json:"candidateUsers"` //处理人
|
|
|
|
|
Incoming []IncomingStruct `xml:"incoming" json:"incoming"` //来源
|
|
|
|
|
Outgoing []OutgoingStruct `xml:"outgoing" json:"outgoing"` //流程去向(下一个节点)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//本节点来源
|
|
|
|
|
type IncomingStruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//结束事件
|
|
|
|
|
type EndEventStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
NameStruct
|
|
|
|
|
Incoming []IncomingStruct `xml:"incoming" json:"incoming"` //来源
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//序列流
|
|
|
|
|
type SequenceFlowStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
NameStruct
|
|
|
|
|
SourceRef string `xml:"sourceRef,attr" json:"sourceRef"` //源
|
|
|
|
|
TargetRef string `xml:"targetRef,attr" json:"targetRef"` //流向
|
|
|
|
|
ConditionExpression ConditionExpressionStruct `xml:"conditionExpression" json:"conditionExpression"` //条件表达式
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//条件表达式
|
|
|
|
|
type ConditionExpressionStruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
Type string `xml:"type,attr" json:"type"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//BPMN图结构
|
|
|
|
|
type BPMNDiagramStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
BPMNPlane BPMNPlaneStruct `xml:"BPMNPlane" json:"BPMNPlane"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//图平面坐标参数
|
|
|
|
|
type BPMNPlaneStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
BpmnElement string `xml:"bpmnElement,attr" json:"bpmnElement"` //Bpmn元素
|
|
|
|
|
BPMNShape []BPMNShapeStruct `xml:"BPMNShape" json:"BPMNShape"` //Bpmn 坐标参数
|
|
|
|
|
BPMNEdge []BPMNEdgeStruct `xml:"BPMNEdge" json:"BPMNEdge"` //Bpmn界限
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Bpmn 坐标参数
|
|
|
|
|
type BPMNShapeStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
BpmnElement string `xml:"bpmnElement,attr" json:"bpmnElement"`
|
|
|
|
|
Bounds BoundsStruct `xml:"Bounds" json:"Bounds"` //图形元素坐标
|
|
|
|
|
BPMNLabel BPMNLabelStruct `xml:"BPMNLabel" json:"BPMNLabel"` //BPMN标签
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//图形元素坐标
|
|
|
|
|
type BoundsStruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
X string `xml:"x,attr" json:"x"`
|
|
|
|
|
Y string `xml:"y,attr" json:"y"`
|
|
|
|
|
Width string `xml:"width,attr" json:"width"`
|
|
|
|
|
Height string `xml:"height,attr" json:"height"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//BPMN标签
|
|
|
|
|
type BPMNLabelStruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
Bounds BoundsStruct `xml:"Bounds" json:"Bounds"` //图形元素坐标
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Bpmn界限
|
|
|
|
|
type BPMNEdgeStruct struct {
|
|
|
|
|
TextAndIdStruct
|
|
|
|
|
BpmnElement string `xml:"bpmnElement,attr" json:"bpmnElement"`
|
|
|
|
|
Waypoint []WaypointStruct `xml:"waypoint" json:"waypoint"` //线路径坐标
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//线路径坐标
|
|
|
|
|
type WaypointStruct struct {
|
|
|
|
|
TextStruct
|
|
|
|
|
X string `xml:"x,attr" json:"x"`
|
|
|
|
|
Y string `xml:"y,attr" json:"y"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//接收参数
|
|
|
|
|
type XmlCanShu struct {
|
|
|
|
|
ProcessKey string `json:"processKey"`
|
|
|
|
|
ProcessName string `json:"processName"`
|
|
|
|
|
ResourceName string `json:"resourceName"`
|
|
|
|
|
Xml string `json:"xml"`
|
|
|
|
|
Svg string `json:"svg"`
|
|
|
|
|
JsonStr string `json:"jsonstr"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//工作流XML解析
|
|
|
|
|
func (s *ShiyanApi) XmlToJson(c *gin.Context) {
|
|
|
|
|
var xmlToStruct Definitions
|
|
|
|
|
var reportAnswer XmlCanShu
|
|
|
|
|
err := c.ShouldBindJSON(&reportAnswer)
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// response.Result(101, err, "参数错误!", c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
if reportAnswer.Xml == "" {
|
|
|
|
|
response.Result(102, err, "参数错误!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
errs := xml.Unmarshal([]byte(reportAnswer.Xml), &xmlToStruct)
|
|
|
|
|
if nil != errs {
|
|
|
|
|
fmt.Println("Unmarshal fail")
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("struct", xmlToStruct)
|
|
|
|
|
}
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
returnData["reportAnswer"] = reportAnswer
|
|
|
|
|
returnData["xmlToStruct"] = xmlToStruct
|
|
|
|
|
|
|
|
|
|
var approvalProcess approvalprocess.ApprovalProcess
|
|
|
|
|
processMap := commonus.MapOut()
|
|
|
|
|
|
|
|
|
|
processId := commonus.GetFileNumberEs()
|
|
|
|
|
approvalProcess.Id = processId
|
|
|
|
|
processMap["id"] = processId
|
|
|
|
|
|
|
|
|
|
approvalProcess.Name = xmlToStruct.Process.Name
|
|
|
|
|
|
|
|
|
|
processMap["name"] = xmlToStruct.Process.Name
|
|
|
|
|
|
|
|
|
|
result, jsonErr := json.Marshal(xmlToStruct)
|
|
|
|
|
if jsonErr == nil {
|
|
|
|
|
approvalProcess.Flow = string(result)
|
|
|
|
|
processMap["flow"] = string(result)
|
|
|
|
|
} else {
|
|
|
|
|
processMap["flow"] = ""
|
|
|
|
|
}
|
|
|
|
|
approvalProcess.FlowJson = reportAnswer.JsonStr
|
|
|
|
|
processMap["flowjson"] = reportAnswer.JsonStr
|
|
|
|
|
approvalProcess.FlowXml = reportAnswer.Xml
|
|
|
|
|
processMap["flowxml"] = reportAnswer.Xml
|
|
|
|
|
approvalProcess.FlowSvg = reportAnswer.Svg
|
|
|
|
|
processMap["flowsvg"] = reportAnswer.Svg
|
|
|
|
|
|
|
|
|
|
resultPro, jsonErrPro := json.Marshal(xmlToStruct.Process)
|
|
|
|
|
if jsonErrPro == nil {
|
|
|
|
|
approvalProcess.GetFlowJson = string(resultPro)
|
|
|
|
|
processMap["getflowjson"] = string(resultPro)
|
|
|
|
|
} else {
|
|
|
|
|
processMap["getflowjson"] = ""
|
|
|
|
|
}
|
|
|
|
|
approvalProcess.Time = time.Now().Unix()
|
|
|
|
|
approvalProcess.EiteTime = time.Now().Unix()
|
|
|
|
|
approvalProcess.Sate = 1
|
|
|
|
|
processMap["sate"] = 1
|
|
|
|
|
|
|
|
|
|
batchNum := commonus.GetFileNumberEs()
|
|
|
|
|
approvalProcess.Batch = batchNum
|
|
|
|
|
processMap["batchnum"] = batchNum
|
|
|
|
|
approvalProcess.EditionNum = "V1.0"
|
|
|
|
|
processMap["editionnum"] = "V1.0"
|
|
|
|
|
|
|
|
|
|
returnData["approvalProcess"] = approvalProcess
|
|
|
|
|
|
|
|
|
|
// writeRedisData := map[string]interface{}{
|
|
|
|
|
// "name": xmlToStruct.Process.Name,
|
|
|
|
|
// "flow": string(result),
|
|
|
|
|
// "flowjson": reportAnswer.JsonStr,
|
|
|
|
|
// "flowxml": reportAnswer.Xml,
|
|
|
|
|
// "flowsvg": reportAnswer.Svg,
|
|
|
|
|
// "getflowjson": string(resultPro),
|
|
|
|
|
// "sate": 1,
|
|
|
|
|
// "batchnum": batchNum,
|
|
|
|
|
// "editionnum": "V1.0",
|
|
|
|
|
// }
|
|
|
|
|
// addProcess := global.GVA_DB_ApprovalProcess.Create(&approvalProcess)
|
|
|
|
|
// if addProcess.Error != nil {
|
|
|
|
|
// response.Result(104, addProcess.Error, "流程创建失败", c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
|
|
|
redisClient.SetRedisTime(0)
|
|
|
|
|
kks := redisClient.HashMsetAdd("Process:ApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(batchNum, 10), processMap)
|
|
|
|
|
|
|
|
|
|
response.Result(103, kks, "参数错误!", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ExamineApprove struct {
|
|
|
|
|
ProcessId int64 `json:"processId"` //流程批次
|
|
|
|
|
ExamineApproveId int64 `json:"examineApproveId"` //正在执行的流程
|
|
|
|
|
Type int `json:"type"` //状态(1:同意;2:驳回;3:暂存)
|
|
|
|
|
Condition string `json:"condition"` //判断条件
|
|
|
|
|
State int `json:"state"` //状态
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//审批记录Redis过度
|
|
|
|
|
type ApprovalProcessLogRedis struct {
|
|
|
|
|
Id string `json:"id"`
|
|
|
|
|
Process string `json:"process" `
|
|
|
|
|
CurrentNode string `json:"currentNode"`
|
|
|
|
|
Title string `json:"title" `
|
|
|
|
|
Time string `json:"time"`
|
|
|
|
|
EiteTime string `json:"eiteTime"`
|
|
|
|
|
ProcessNum string `json:"processNum"`
|
|
|
|
|
IsEnd string `json:"isEnd"`
|
|
|
|
|
State string `json:"state"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建及审批
|
|
|
|
|
func (s *ShiyanApi) EstablishApprove(c *gin.Context) {
|
|
|
|
|
var examineApprove ExamineApprove
|
|
|
|
|
err := c.ShouldBindJSON(&examineApprove)
|
|
|
|
|
if err != nil {
|
|
|
|
|
response.Result(101, err, "参数错误!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if examineApprove.ProcessId == 0 || examineApprove.ExamineApproveId == 0 {
|
|
|
|
|
response.Result(102, examineApprove, "参数错误!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if examineApprove.Type == 0 {
|
|
|
|
|
examineApprove.Type = 2
|
|
|
|
|
}
|
|
|
|
|
//正在执行的流程
|
|
|
|
|
var runApprovalProcess approvalprocess.ApprovalProcessLog
|
|
|
|
|
//缓存设置
|
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
|
|
|
|
|
|
|
|
approvalProcessRedis, isTrue := redisClient.HashGetAll("Process:RunApprovalProcess_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + strconv.FormatInt(examineApprove.ExamineApproveId, 10))
|
|
|
|
|
if isTrue != true { //判断是否存在缓存
|
|
|
|
|
runProcessMap := commonus.MapOut()
|
|
|
|
|
appProLogErr := global.GVA_DB_ApprovalProcess.Where("`apl_id` = ?", examineApprove.ExamineApproveId).First(&runApprovalProcess).Error
|
|
|
|
|
if appProLogErr != nil {
|
|
|
|
|
var getApprovalProcess approvalprocess.ApprovalProcess
|
|
|
|
|
getProLogErr := global.GVA_DB_ApprovalProcess.Where("`ap_batch` = ? AND `ap_state` = 1", examineApprove.ProcessId).First(&getApprovalProcess).Error
|
|
|
|
|
if getProLogErr != nil {
|
|
|
|
|
response.Result(103, getApprovalProcess, "对不起该流程不存在", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runApprovalProcess.Process = getApprovalProcess.GetFlowJson
|
|
|
|
|
runProcessMap["process"] = getApprovalProcess.GetFlowJson
|
|
|
|
|
//流程json转为struct
|
|
|
|
|
var process ProcessStruct
|
|
|
|
|
jsonErrPro := json.Unmarshal([]byte(getApprovalProcess.GetFlowJson), &process)
|
|
|
|
|
if jsonErrPro == nil {
|
|
|
|
|
runApprovalProcess.CurrentNode = process.StartEvent.ID
|
|
|
|
|
runApprovalProcess.Title = process.StartEvent.Name
|
|
|
|
|
runApprovalProcess.ProcessNum = getApprovalProcess.Batch
|
|
|
|
|
|
|
|
|
|
runProcessMap["currentNode"] = process.StartEvent.ID
|
|
|
|
|
runProcessMap["title"] = process.StartEvent.Name
|
|
|
|
|
runProcessMap["processNum"] = getApprovalProcess.Batch
|
|
|
|
|
} else {
|
|
|
|
|
runApprovalProcess.CurrentNode = ""
|
|
|
|
|
runApprovalProcess.Title = ""
|
|
|
|
|
runApprovalProcess.ProcessNum = 0
|
|
|
|
|
|
|
|
|
|
runProcessMap["currentNode"] = ""
|
|
|
|
|
runProcessMap["title"] = ""
|
|
|
|
|
runProcessMap["processNum"] = 0
|
|
|
|
|
}
|
|
|
|
|
runApprovalProcess.Time = time.Now().Unix()
|
|
|
|
|
runApprovalProcess.EiteTime = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
runApprovalProcess.IsEnd = 1
|
|
|
|
|
runProcessMap["isend"] = 1
|
|
|
|
|
if examineApprove.State == 0 {
|
|
|
|
|
runApprovalProcess.Sate = 1
|
|
|
|
|
runProcessMap["state"] = 1
|
|
|
|
|
} else {
|
|
|
|
|
runApprovalProcess.Sate = examineApprove.State
|
|
|
|
|
runProcessMap["state"] = examineApprove.State
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runProcessMap["time"] = time.Now().Unix()
|
|
|
|
|
runProcessMap["eiteTime"] = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
addProcess := global.GVA_DB_ApprovalProcess.Create(&runApprovalProcess).Error
|
|
|
|
|
if addProcess != nil {
|
|
|
|
|
response.Result(104, getApprovalProcess, "对不起该流程启用失败", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
runProcessMap["id"] = runApprovalProcess.Id
|
|
|
|
|
redisClient.SetRedisTime(0)
|
|
|
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
|
|
|
} else {
|
|
|
|
|
runProcessMap["process"] = runApprovalProcess.Process
|
|
|
|
|
runProcessMap["currentNode"] = runApprovalProcess.CurrentNode
|
|
|
|
|
runProcessMap["title"] = runApprovalProcess.Title
|
|
|
|
|
runProcessMap["processNum"] = runApprovalProcess.ProcessNum
|
|
|
|
|
runProcessMap["time"] = runApprovalProcess.Time
|
|
|
|
|
runProcessMap["eiteTime"] = runApprovalProcess.EiteTime
|
|
|
|
|
runProcessMap["id"] = runApprovalProcess.Id
|
|
|
|
|
runProcessMap["isend"] = runApprovalProcess.IsEnd
|
|
|
|
|
runProcessMap["state"] = runApprovalProcess.Sate
|
|
|
|
|
if runApprovalProcess.IsEnd == 1 {
|
|
|
|
|
redisClient.SetRedisTime(0)
|
|
|
|
|
} else {
|
|
|
|
|
redisClient.SetRedisTime(604800)
|
|
|
|
|
}
|
|
|
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
|
|
|
if runApprovalProcess.IsEnd != 1 {
|
|
|
|
|
response.Result(105, runApprovalProcess, "该流程已经结束!请不要重复执行!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// fmt.Printf("Redis====》%v\n", runApprovalProcess)
|
|
|
|
|
var approvalProcessLogRedis ApprovalProcessLogRedis
|
|
|
|
|
err := mapstructure.Decode(approvalProcessRedis, &approvalProcessLogRedis)
|
|
|
|
|
if err != nil {
|
|
|
|
|
response.Result(104, err, "对不起该流程启用失败", c)
|
|
|
|
|
return
|
|
|
|
|
// return departmentlist, false
|
|
|
|
|
}
|
|
|
|
|
appId, appIdErr := strconv.ParseInt(approvalProcessLogRedis.Id, 10, 64)
|
|
|
|
|
|
|
|
|
|
if appIdErr == nil {
|
|
|
|
|
runApprovalProcess.Id = appId
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("审批ID==Redis==》%v-------------%v\n", approvalProcessLogRedis.Id, appId)
|
|
|
|
|
|
|
|
|
|
processNum, processNumErr := strconv.ParseInt(approvalProcessLogRedis.ProcessNum, 10, 64)
|
|
|
|
|
if processNumErr == nil {
|
|
|
|
|
runApprovalProcess.ProcessNum = processNum
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
timeVal, timeErr := strconv.ParseInt(approvalProcessLogRedis.Time, 10, 64)
|
|
|
|
|
if timeErr == nil {
|
|
|
|
|
runApprovalProcess.Time = timeVal
|
|
|
|
|
}
|
|
|
|
|
eiteTime, eiteTimeErr := strconv.ParseInt(approvalProcessLogRedis.EiteTime, 10, 64)
|
|
|
|
|
if eiteTimeErr == nil {
|
|
|
|
|
runApprovalProcess.EiteTime = eiteTime
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isEnd, isEndErr := strconv.Atoi(approvalProcessLogRedis.IsEnd)
|
|
|
|
|
if isEndErr == nil {
|
|
|
|
|
runApprovalProcess.IsEnd = isEnd
|
|
|
|
|
} else {
|
|
|
|
|
response.Result(107, runApprovalProcess, "对不起该流程启用失败!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
sateSet, sateErr := strconv.Atoi(approvalProcessLogRedis.State)
|
|
|
|
|
if sateErr == nil {
|
|
|
|
|
runApprovalProcess.Sate = sateSet
|
|
|
|
|
} else {
|
|
|
|
|
response.Result(108, sateErr, "对不起该流程启用失败!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runApprovalProcess.Process = approvalProcessLogRedis.Process
|
|
|
|
|
runApprovalProcess.CurrentNode = approvalProcessLogRedis.CurrentNode
|
|
|
|
|
runApprovalProcess.Title = approvalProcessLogRedis.Title
|
|
|
|
|
|
|
|
|
|
if runApprovalProcess.IsEnd != 1 {
|
|
|
|
|
response.Result(106, runApprovalProcess, "该流程已经结束!请不要重复执行!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// fmt.Printf("数据结构===========>%v\n", runApprovalProcess)
|
|
|
|
|
switch examineApprove.Type {
|
|
|
|
|
case 1: //批准
|
|
|
|
|
ApproveOperation(runApprovalProcess, examineApprove)
|
|
|
|
|
case 3: //暂存
|
|
|
|
|
default: //驳回
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//批准操作
|
|
|
|
|
func ApproveOperation(runApprovalProcess approvalprocess.ApprovalProcessLog, examineApprove ExamineApprove) (isTrue bool) {
|
|
|
|
|
// fmt.Printf("审批ID==Redis==》%v-------------%v\n", runApprovalProcess.Id, runApprovalProcess)
|
|
|
|
|
isTrue = false
|
|
|
|
|
// fmt.Printf("结果====》%v\n", runApprovalProcess)
|
|
|
|
|
var process ProcessStruct
|
|
|
|
|
jsonErrPro := json.Unmarshal([]byte(runApprovalProcess.Process), &process)
|
|
|
|
|
if jsonErrPro != nil {
|
|
|
|
|
fmt.Printf("转换失败====》%v\n", process)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if runApprovalProcess.CurrentNode == process.EndEvent.ID {
|
|
|
|
|
fmt.Printf("执行结束节点====》%v\n", process.EndEvent.ID)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if runApprovalProcess.CurrentNode == process.StartEvent.ID {
|
|
|
|
|
fmt.Printf("执行开始节点====》%v\n", process.StartEvent.ID)
|
|
|
|
|
|
|
|
|
|
if len(process.StartEvent.Outgoing) > 1 {
|
|
|
|
|
fmt.Printf("执行开始节点====有条件》%v\n", process.StartEvent.ID)
|
|
|
|
|
|
|
|
|
|
currentId := runApprovalProcess.CurrentNode
|
|
|
|
|
|
|
|
|
|
appId, appTitle, appIsTrue, isEnd := ApprovalCriteria(1, process, examineApprove, runApprovalProcess.CurrentNode)
|
|
|
|
|
|
|
|
|
|
fmt.Printf("执行审批节点==11111==下一个节点》%v----%v-----%v\n", appId, appTitle, appIsTrue)
|
|
|
|
|
if appIsTrue != true {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
isTrue = true
|
|
|
|
|
currentId = appId
|
|
|
|
|
|
|
|
|
|
// for _, outGoing := range process.StartEvent.Outgoing {
|
|
|
|
|
// for _, seqFlow := range process.SequenceFlow {
|
|
|
|
|
// if outGoing.Text == seqFlow.ID {
|
|
|
|
|
// // fmt.Printf("条件(%v)====》对比条件-----%v\n", seqFlow.ConditionExpression.Text, examineApprove.Condition)
|
|
|
|
|
// if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
|
|
|
// isTrue = true
|
|
|
|
|
// currentId = seqFlow.TargetRef
|
|
|
|
|
// fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
runApprovalProcess.CurrentNode = currentId
|
|
|
|
|
runApprovalProcess.Title = appTitle
|
|
|
|
|
runApprovalProcess.EiteTime = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
runProcessMap := commonus.MapOut()
|
|
|
|
|
runProcessMap["process"] = runApprovalProcess.Process
|
|
|
|
|
runProcessMap["currentNode"] = currentId
|
|
|
|
|
|
|
|
|
|
runProcessMap["processNum"] = runApprovalProcess.ProcessNum
|
|
|
|
|
runProcessMap["time"] = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
runProcessMap["title"] = appTitle
|
|
|
|
|
runProcessMap["eiteTime"] = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
if isEnd == true {
|
|
|
|
|
runApprovalProcess.IsEnd = 2
|
|
|
|
|
runProcessMap["isend"] = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//缓存设置
|
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
|
|
|
redisClient.SetRedisTime(604800)
|
|
|
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
|
|
|
|
|
|
|
|
fmt.Printf("审批ID==22222==》%v\n", runApprovalProcess.Id)
|
|
|
|
|
|
|
|
|
|
eiteProcess := global.GVA_DB_ApprovalProcess.Where("`apl_id` = ?", runApprovalProcess.Id).Updates(&runApprovalProcess).Error
|
|
|
|
|
|
|
|
|
|
if eiteProcess == nil {
|
|
|
|
|
fmt.Printf("更新成功====》%v\n", runApprovalProcess)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("更新失败====》%v\n", runApprovalProcess)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
} else if len(process.StartEvent.Outgoing) < 1 {
|
|
|
|
|
fmt.Printf("执行开始节点====未知下个节点》%v\n", process.StartEvent.ID)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("执行开始节点====直接到审批》%v\n", process.StartEvent.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, taskVal := range process.UserTask {
|
|
|
|
|
if runApprovalProcess.CurrentNode == taskVal.ID {
|
|
|
|
|
fmt.Printf("执行审批节点====》%v\n", taskVal.ID)
|
|
|
|
|
appId, appTitle, appIsTrue, isEnd := ApprovalCriteria(3, process, examineApprove, runApprovalProcess.CurrentNode)
|
|
|
|
|
|
|
|
|
|
fmt.Printf("执行审批节点====下一个节点》%v----%v-----%v\n", appId, appTitle, appIsTrue)
|
|
|
|
|
|
|
|
|
|
currentId := runApprovalProcess.CurrentNode
|
|
|
|
|
if appIsTrue != true {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
isTrue = true
|
|
|
|
|
currentId = appId
|
|
|
|
|
runApprovalProcess.CurrentNode = currentId
|
|
|
|
|
runApprovalProcess.Title = appTitle
|
|
|
|
|
runApprovalProcess.EiteTime = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
runProcessMap := commonus.MapOut()
|
|
|
|
|
runProcessMap["process"] = runApprovalProcess.Process
|
|
|
|
|
runProcessMap["currentNode"] = currentId
|
|
|
|
|
|
|
|
|
|
runProcessMap["processNum"] = runApprovalProcess.ProcessNum
|
|
|
|
|
runProcessMap["time"] = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
runProcessMap["title"] = appTitle
|
|
|
|
|
runProcessMap["eiteTime"] = time.Now().Unix()
|
|
|
|
|
|
|
|
|
|
if isEnd == true {
|
|
|
|
|
runApprovalProcess.IsEnd = 2
|
|
|
|
|
runProcessMap["isend"] = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//缓存设置
|
|
|
|
|
redisClient := redishandel.RunRedis()
|
|
|
|
|
redisClient.SetRedisTime(604800)
|
|
|
|
|
redisClient.HashMsetAdd("Process:RunApprovalProcess_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+strconv.FormatInt(runApprovalProcess.Id, 10), runProcessMap)
|
|
|
|
|
|
|
|
|
|
fmt.Printf("审批ID====》%v\n", runApprovalProcess.Id)
|
|
|
|
|
|
|
|
|
|
eiteProcess := global.GVA_DB_ApprovalProcess.Where("`apl_id` = ?", runApprovalProcess.Id).Updates(&runApprovalProcess).Error
|
|
|
|
|
|
|
|
|
|
if eiteProcess == nil {
|
|
|
|
|
fmt.Printf("更新成功uis====》%v\n", runApprovalProcess)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("更新失败uis====》%v\n", runApprovalProcess)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//审批条件解析
|
|
|
|
|
/*
|
|
|
|
|
@execStatus 执行状态 1:开始;2:结束;3:审批
|
|
|
|
|
*/
|
|
|
|
|
func ApprovalCriteria(execStatus int, process ProcessStruct, examineApprove ExamineApprove, currentNode string) (currentId, nextTitle string, isTrue, isEnd bool) {
|
|
|
|
|
isTrue = false
|
|
|
|
|
isEnd = false
|
|
|
|
|
//解析条件判断,获取出下个节点的ID
|
|
|
|
|
switch execStatus {
|
|
|
|
|
case 1:
|
|
|
|
|
fmt.Printf("State ----------> %v\n", execStatus)
|
|
|
|
|
for _, outGoing := range process.StartEvent.Outgoing {
|
|
|
|
|
for _, seqFlow := range process.SequenceFlow {
|
|
|
|
|
if outGoing.Text == seqFlow.ID {
|
|
|
|
|
fmt.Printf("条件(%v)====》对比条件-----%v\n", seqFlow.ConditionExpression.Text, examineApprove.Condition)
|
|
|
|
|
if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
|
|
|
isTrue = true
|
|
|
|
|
currentId = seqFlow.TargetRef
|
|
|
|
|
fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case 2:
|
|
|
|
|
fmt.Printf("State ----------> %v\n", execStatus)
|
|
|
|
|
default:
|
|
|
|
|
fmt.Printf("State ----------> %v\n", execStatus)
|
|
|
|
|
for _, taskVal := range process.UserTask {
|
|
|
|
|
if taskVal.ID == currentNode {
|
|
|
|
|
for _, outGoing := range taskVal.Outgoing {
|
|
|
|
|
for _, seqFlow := range process.SequenceFlow {
|
|
|
|
|
if outGoing.Text == seqFlow.ID {
|
|
|
|
|
fmt.Printf("条件(%v)====》对比条件-----%v\n", seqFlow.ConditionExpression.Text, examineApprove.Condition)
|
|
|
|
|
if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
|
|
|
isTrue = true
|
|
|
|
|
currentId = seqFlow.TargetRef
|
|
|
|
|
fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// for _, seqFlow := range process.SequenceFlow {
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("条件(%v)====》对比条件-----%v\n", taskVal.ID, seqFlow.ID)
|
|
|
|
|
|
|
|
|
|
// if taskVal.ID == seqFlow.ID {
|
|
|
|
|
|
|
|
|
|
// if seqFlow.ConditionExpression.Text == examineApprove.Condition {
|
|
|
|
|
// isTrue = true
|
|
|
|
|
// currentId = seqFlow.TargetRef
|
|
|
|
|
// fmt.Printf("执行节点====》%v\n", seqFlow.TargetRef)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nextNameIsTrue := false
|
|
|
|
|
//获取审批节点名称
|
|
|
|
|
for _, taskVal := range process.UserTask {
|
|
|
|
|
if taskVal.ID == currentId {
|
|
|
|
|
nextTitle = taskVal.Name
|
|
|
|
|
nextNameIsTrue = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if nextNameIsTrue != true {
|
|
|
|
|
if currentId == process.EndEvent.ID {
|
|
|
|
|
nextTitle = process.EndEvent.Name
|
|
|
|
|
nextNameIsTrue = true
|
|
|
|
|
isEnd = true
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if currentId == process.StartEvent.ID {
|
|
|
|
|
nextTitle = process.StartEvent.Name
|
|
|
|
|
nextNameIsTrue = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//实验发送按钮交互模板
|
|
|
|
|
func (s *ShiyanApi) SendButtonMsg(c *gin.Context) {
|
|
|
|
|
// var sendMsg commonus.ButtonTemplateAll
|
|
|
|
|
var sendMsg commonus.ButtonTemplate
|
|
|
|
|
sendMsg.Touser = "KaiXinGuo"
|
|
|
|
|
sendMsg.MsgType = "template_card"
|
|
|
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
|
|
|
sendMsg.AgentId = appId
|
|
|
|
|
sendMsg.EnableIdTrans = 0
|
|
|
|
|
sendMsg.EnableDuplicateCheck = 0
|
|
|
|
|
sendMsg.DuplicateCheckInterval = 1800
|
|
|
|
|
//模板卡片类型,按钮交互型卡片填写"button_interaction" (必填)
|
|
|
|
|
sendMsg.TemplateCard.CardType = "button_interaction"
|
|
|
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
|
|
|
sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
|
|
|
sendMsg.TemplateCard.Source.Desc = "知行学院"
|
|
|
|
|
sendMsg.TemplateCard.Source.DescColor = 2
|
|
|
|
|
//卡片右上角更多操作按钮 (非必填)
|
|
|
|
|
// sendMsg.TemplateCard.ActionMenu =
|
|
|
|
|
// sendMsg.TemplateCard.ActionMenu.Desc = "卡片副交互辅助文本说明"
|
|
|
|
|
// var actionList []commonus.ActionListStruct
|
|
|
|
|
// var actionCont commonus.ActionListStruct
|
|
|
|
|
// actionCont.Text = "接受推送"
|
|
|
|
|
// actionCont.Key = "A"
|
|
|
|
|
// actionList = append(actionList, actionCont)
|
|
|
|
|
// actionCont.Text = "不再推"
|
|
|
|
|
// actionCont.Key = "b"
|
|
|
|
|
// actionList = append(actionList, actionCont)
|
|
|
|
|
// sendMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
|
|
|
//一级标题,建议不超过36个字,(支持id转译)
|
|
|
|
|
sendMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
|
|
|
sendMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
|
|
|
//引用文献样式
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Type = 1
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
|
|
|
|
|
|
//二级普通文本,建议不超过160个字(非必填)
|
|
|
|
|
// sendMsg.TemplateCard.SubTitleText = "二级普通文本,下载企业微信还能抢红包!"
|
|
|
|
|
|
|
|
|
|
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6(非必填)
|
|
|
|
|
var htalConListStrMap []commonus.HorizontalContentListStruct
|
|
|
|
|
var htalConListStrCon commonus.HorizontalContentListStruct
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "申请人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
// htalConListStrCon.Type = 1
|
|
|
|
|
// htalConListStrCon.KeyName = "企业微信官网"
|
|
|
|
|
// htalConListStrCon.Value = "点击访问"
|
|
|
|
|
// htalConListStrCon.Url = "http://admin.hxgk.group"
|
|
|
|
|
// htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
sendMsg.TemplateCard.HorizontalContentList = htalConListStrMap
|
|
|
|
|
//整体卡片的点击跳转事件 (非必填)
|
|
|
|
|
sendMsg.TemplateCard.CardAction.Type = 1
|
|
|
|
|
sendMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
|
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
|
|
|
taskId := commonus.GetFileNumberEs()
|
|
|
|
|
sendMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
|
|
|
//下拉式的选择器 (未知是否必填)
|
|
|
|
|
// questionKey := commonus.GetFileNumberEs()
|
|
|
|
|
// sendMsg.TemplateCard.ButtonSelection.QuestionKey = strconv.FormatInt(questionKey, 10)
|
|
|
|
|
// sendMsg.TemplateCard.ButtonSelection.Title = "下拉标题"
|
|
|
|
|
// //下拉内容设置
|
|
|
|
|
// var optionListMap []commonus.OptionListStructes
|
|
|
|
|
// var optionListCont commonus.OptionListStructes
|
|
|
|
|
// optionListCont.Id = "btn_selection_id1"
|
|
|
|
|
// optionListCont.Text = "100分"
|
|
|
|
|
// optionListMap = append(optionListMap, optionListCont)
|
|
|
|
|
// optionListCont.Id = "btn_selection_id2"
|
|
|
|
|
// optionListCont.Text = "110分"
|
|
|
|
|
// optionListMap = append(optionListMap, optionListCont)
|
|
|
|
|
// sendMsg.TemplateCard.ButtonSelection.OptionList = optionListMap
|
|
|
|
|
// sendMsg.TemplateCard.ButtonSelection.SelectedId = "btn_selection_id1"
|
|
|
|
|
//按钮列表,列表长度不超过6(必填)
|
|
|
|
|
var buttonMap []commonus.ButtonListStruct
|
|
|
|
|
var buttonCont commonus.ButtonListStruct
|
|
|
|
|
buttonCont.Type = 0
|
|
|
|
|
buttonCont.Text = "批准"
|
|
|
|
|
buttonCont.Style = 1
|
|
|
|
|
buttonCont.Key = "button_key_1"
|
|
|
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
|
|
|
buttonCont.Type = 0
|
|
|
|
|
buttonCont.Text = "驳回"
|
|
|
|
|
buttonCont.Style = 3
|
|
|
|
|
buttonCont.Key = "button_key_2"
|
|
|
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
|
|
|
sendMsg.TemplateCard.ButtonList = buttonMap
|
|
|
|
|
response.Result(0, sendMsg, "查询成功", c)
|
|
|
|
|
|
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendMsg.SendButtonMessage()
|
|
|
|
|
fmt.Printf("发送信息返回:%v-----------%v----------->%v\n", string(callbakcMsg), isTrueCall, callBackCont)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ShiyanApi) SendButtonMessageAll(c *gin.Context) {
|
|
|
|
|
var sendMsg commonus.ButtonTemplateAll
|
|
|
|
|
// var sendMsg commonus.ButtonTemplate
|
|
|
|
|
sendMsg.Touser = "KaiXinGuo"
|
|
|
|
|
sendMsg.MsgType = "template_card"
|
|
|
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
|
|
|
sendMsg.AgentId = appId
|
|
|
|
|
sendMsg.EnableIdTrans = 0
|
|
|
|
|
sendMsg.EnableDuplicateCheck = 0
|
|
|
|
|
sendMsg.DuplicateCheckInterval = 1800
|
|
|
|
|
//模板卡片类型,按钮交互型卡片填写"button_interaction" (必填)
|
|
|
|
|
sendMsg.TemplateCard.CardType = "button_interaction"
|
|
|
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
|
|
|
sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
|
|
|
sendMsg.TemplateCard.Source.Desc = "知行学院"
|
|
|
|
|
sendMsg.TemplateCard.Source.DescColor = 2
|
|
|
|
|
//卡片右上角更多操作按钮 (非必填)
|
|
|
|
|
// sendMsg.TemplateCard.ActionMenu =
|
|
|
|
|
sendMsg.TemplateCard.ActionMenu.Desc = "卡片副交互辅助文本说明"
|
|
|
|
|
var actionList []commonus.ActionListStruct
|
|
|
|
|
var actionCont commonus.ActionListStruct
|
|
|
|
|
actionCont.Text = "接受推送"
|
|
|
|
|
actionCont.Key = "A"
|
|
|
|
|
actionList = append(actionList, actionCont)
|
|
|
|
|
actionCont.Text = "不再推"
|
|
|
|
|
actionCont.Key = "b"
|
|
|
|
|
actionList = append(actionList, actionCont)
|
|
|
|
|
sendMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
|
|
|
//一级标题,建议不超过36个字,(支持id转译)
|
|
|
|
|
sendMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
|
|
|
sendMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
|
|
|
//引用文献样式
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Type = 1
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
|
|
|
|
|
|
//二级普通文本,建议不超过160个字(非必填)
|
|
|
|
|
sendMsg.TemplateCard.SubTitleText = "二级普通文本,下载企业微信还能抢红包!"
|
|
|
|
|
|
|
|
|
|
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6(非必填)
|
|
|
|
|
var htalConListStrMap []commonus.HorizontalContentListStruct
|
|
|
|
|
var htalConListStrCon commonus.HorizontalContentListStruct
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "申请人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
htalConListStrCon.Type = 1
|
|
|
|
|
htalConListStrCon.KeyName = "企业微信官网"
|
|
|
|
|
htalConListStrCon.Value = "点击访问"
|
|
|
|
|
htalConListStrCon.Url = "tel:15069130853"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
sendMsg.TemplateCard.HorizontalContentList = htalConListStrMap
|
|
|
|
|
//整体卡片的点击跳转事件 (非必填)
|
|
|
|
|
sendMsg.TemplateCard.CardAction.Type = 1
|
|
|
|
|
sendMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
|
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
|
|
|
taskId := commonus.GetFileNumberEs()
|
|
|
|
|
sendMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
|
|
|
//下拉式的选择器 (未知是否必填)
|
|
|
|
|
questionKey := commonus.GetFileNumberEs()
|
|
|
|
|
sendMsg.TemplateCard.ButtonSelection.QuestionKey = strconv.FormatInt(questionKey, 10)
|
|
|
|
|
sendMsg.TemplateCard.ButtonSelection.Title = "下拉标题"
|
|
|
|
|
// //下拉内容设置
|
|
|
|
|
var optionListMap []commonus.OptionListStructes
|
|
|
|
|
var optionListCont commonus.OptionListStructes
|
|
|
|
|
optionListCont.Id = "btn_selection_id1"
|
|
|
|
|
optionListCont.Text = "100分"
|
|
|
|
|
optionListMap = append(optionListMap, optionListCont)
|
|
|
|
|
optionListCont.Id = "btn_selection_id2"
|
|
|
|
|
optionListCont.Text = "110分"
|
|
|
|
|
optionListMap = append(optionListMap, optionListCont)
|
|
|
|
|
sendMsg.TemplateCard.ButtonSelection.OptionList = optionListMap
|
|
|
|
|
sendMsg.TemplateCard.ButtonSelection.SelectedId = "btn_selection_id1"
|
|
|
|
|
//按钮列表,列表长度不超过6(必填)
|
|
|
|
|
var buttonMap []commonus.ButtonListStruct
|
|
|
|
|
var buttonCont commonus.ButtonListStruct
|
|
|
|
|
buttonCont.Type = 0
|
|
|
|
|
buttonCont.Text = "批准"
|
|
|
|
|
buttonCont.Style = 1
|
|
|
|
|
buttonCont.Key = "button_key_1"
|
|
|
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
|
|
|
buttonCont.Type = 0
|
|
|
|
|
buttonCont.Text = "驳回"
|
|
|
|
|
buttonCont.Style = 3
|
|
|
|
|
buttonCont.Key = "button_key_2"
|
|
|
|
|
buttonMap = append(buttonMap, buttonCont)
|
|
|
|
|
sendMsg.TemplateCard.ButtonList = buttonMap
|
|
|
|
|
response.Result(0, sendMsg, "查询成功", c)
|
|
|
|
|
|
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendMsg.SendButtonMessage()
|
|
|
|
|
fmt.Printf("发送信息返回:%v-----------%v----------->%v\n", string(callbakcMsg), isTrueCall, callBackCont)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//模板卡片消息
|
|
|
|
|
//文本通知型
|
|
|
|
|
func (s *ShiyanApi) SendTextMessageAll(c *gin.Context) {
|
|
|
|
|
var sendTextMsg commonus.TextNotice
|
|
|
|
|
sendTextMsg.Touser = "KaiXinGuo"
|
|
|
|
|
sendTextMsg.MsgType = "template_card"
|
|
|
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
|
|
|
sendTextMsg.AgentId = appId
|
|
|
|
|
sendTextMsg.EnableIdTrans = 0
|
|
|
|
|
sendTextMsg.EnableDuplicateCheck = 0
|
|
|
|
|
sendTextMsg.DuplicateCheckInterval = 1800
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.CardType = "text_notice"
|
|
|
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
|
|
|
sendTextMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
|
|
|
sendTextMsg.TemplateCard.Source.Desc = "知行学院"
|
|
|
|
|
sendTextMsg.TemplateCard.Source.DescColor = 2
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.ActionMenu.Desc = "是否继续关注"
|
|
|
|
|
var actionList []commonus.ActionListStruct
|
|
|
|
|
var actionCont commonus.ActionListStruct
|
|
|
|
|
actionCont.Text = "接受推送"
|
|
|
|
|
actionCont.Key = "A"
|
|
|
|
|
actionList = append(actionList, actionCont)
|
|
|
|
|
actionCont.Text = "不再推"
|
|
|
|
|
actionCont.Key = "b"
|
|
|
|
|
actionList = append(actionList, actionCont)
|
|
|
|
|
sendTextMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
|
|
|
|
|
|
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
|
|
|
taskId := commonus.GetFileNumberEs()
|
|
|
|
|
sendTextMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
|
|
|
sendTextMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
|
|
|
|
|
|
|
|
//引用文献样式
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.Type = 1
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.EmphasisContent.Title = "100"
|
|
|
|
|
sendTextMsg.TemplateCard.EmphasisContent.DescStruct.Desc = "核心数据"
|
|
|
|
|
|
|
|
|
|
//二级普通文本,建议不超过160个字(非必填)
|
|
|
|
|
sendTextMsg.TemplateCard.SubTitleText = "二级普通文本,下载企业微信还能抢红包!"
|
|
|
|
|
|
|
|
|
|
//二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6(非必填)
|
|
|
|
|
var htalConListStrMap []commonus.HorizontalContentListStruct
|
|
|
|
|
var htalConListStrCon commonus.HorizontalContentListStruct
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "申请人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
htalConListStrCon.Type = 1
|
|
|
|
|
htalConListStrCon.KeyName = "企业微信官网"
|
|
|
|
|
htalConListStrCon.Value = "点击访问"
|
|
|
|
|
htalConListStrCon.Url = "tel:15069130853"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
htalConListStrMap = append(htalConListStrMap, htalConListStrCon)
|
|
|
|
|
sendTextMsg.TemplateCard.HorizontalContentList = htalConListStrMap
|
|
|
|
|
|
|
|
|
|
var jumpListStruct commonus.JumpListStruct
|
|
|
|
|
|
|
|
|
|
jumpListStruct.Type = 1
|
|
|
|
|
jumpListStruct.Title = "知行学院官网"
|
|
|
|
|
jumpListStruct.Url = "http://www.hxgk.group"
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct)
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.CardAction.Type = 1
|
|
|
|
|
sendTextMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
|
|
|
|
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendTextTemplateCard()
|
|
|
|
|
outData := commonus.MapOut()
|
|
|
|
|
outData["callbakcMsg"] = string(callbakcMsg)
|
|
|
|
|
outData["isTrueCall"] = isTrueCall
|
|
|
|
|
outData["callBackCont"] = callBackCont
|
|
|
|
|
response.Result(0, outData, "查询成功", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//图文展示型
|
|
|
|
|
func (s *ShiyanApi) SendImageMessageAll(c *gin.Context) {
|
|
|
|
|
var sendTextMsg commonus.ImageTextTemplate
|
|
|
|
|
|
|
|
|
|
sendTextMsg.Touser = "KaiXinGuo"
|
|
|
|
|
sendTextMsg.MsgType = "template_card"
|
|
|
|
|
appId, _ := strconv.ParseInt(global.GVA_CONFIG.WorkWechatSchool.AgentId, 10, 64)
|
|
|
|
|
sendTextMsg.AgentId = appId
|
|
|
|
|
sendTextMsg.EnableIdTrans = 0
|
|
|
|
|
sendTextMsg.EnableDuplicateCheck = 0
|
|
|
|
|
sendTextMsg.DuplicateCheckInterval = 1800
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.CardType = "news_notice"
|
|
|
|
|
//卡片来源样式信息,不需要来源样式可不填写(非必填)
|
|
|
|
|
sendTextMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
|
|
|
sendTextMsg.TemplateCard.Source.Desc = "知行学院"
|
|
|
|
|
sendTextMsg.TemplateCard.Source.DescColor = 2
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.ActionMenu.Desc = "是否继续关注"
|
|
|
|
|
var actionList []commonus.ActionListStruct
|
|
|
|
|
var actionCont commonus.ActionListStruct
|
|
|
|
|
actionCont.Text = "接受推送"
|
|
|
|
|
actionCont.Key = "A"
|
|
|
|
|
actionList = append(actionList, actionCont)
|
|
|
|
|
actionCont.Text = "不再推"
|
|
|
|
|
actionCont.Key = "b"
|
|
|
|
|
actionList = append(actionList, actionCont)
|
|
|
|
|
sendTextMsg.TemplateCard.ActionMenu.ActionList = actionList
|
|
|
|
|
|
|
|
|
|
//任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节 (必填)
|
|
|
|
|
taskId := commonus.GetFileNumberEs()
|
|
|
|
|
sendTextMsg.TemplateCard.TaskId = strconv.FormatInt(taskId, 10)
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.MainTitle.Title = "公务用车审批"
|
|
|
|
|
sendTextMsg.TemplateCard.MainTitle.Desc = "请你认真查询审批内容!" //标题辅助信息,建议不超过44个字,(支持id转译)
|
|
|
|
|
|
|
|
|
|
//引用文献样式
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.Type = 1
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.Url = "http://www.hxgk.group"
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.Title = "用车编号"
|
|
|
|
|
sendTextMsg.TemplateCard.QuoteArea.QuoteText = "用车理由:\n工作需要 \n目的地:宁阳"
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.ImageTextArea.Type = 1
|
|
|
|
|
sendTextMsg.TemplateCard.ImageTextArea.Url = "http://www.baidu.com"
|
|
|
|
|
sendTextMsg.TemplateCard.ImageTextArea.Title = "企业微信的左图右文样式"
|
|
|
|
|
sendTextMsg.TemplateCard.ImageTextArea.Desc = "企业微信真好用呀真好用"
|
|
|
|
|
sendTextMsg.TemplateCard.ImageTextArea.ImageUrl = "https://img.iplaysoft.com/wp-content/uploads/2019/free-images/free_stock_photo_2x.jpg"
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.CardImage.Url = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
|
|
|
sendTextMsg.TemplateCard.CardImage.AspectRatio = 1.3
|
|
|
|
|
|
|
|
|
|
var verCont commonus.VerticalContentListStr
|
|
|
|
|
verCont.Title = "惊喜红包等你来拿"
|
|
|
|
|
verCont.Desc = "下载企业微信还能抢红包!"
|
|
|
|
|
sendTextMsg.TemplateCard.VerticalContentList = append(sendTextMsg.TemplateCard.VerticalContentList, verCont)
|
|
|
|
|
verCont.Title = "====>惊喜红包等你来拿"
|
|
|
|
|
verCont.Desc = "====>下载企业微信还能抢红包!"
|
|
|
|
|
sendTextMsg.TemplateCard.VerticalContentList = append(sendTextMsg.TemplateCard.VerticalContentList, verCont)
|
|
|
|
|
|
|
|
|
|
var htalConListStrCon commonus.HorizontalContentListStruct
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "申请人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
sendTextMsg.TemplateCard.HorizontalContentList = append(sendTextMsg.TemplateCard.HorizontalContentList, htalConListStrCon)
|
|
|
|
|
htalConListStrCon.Type = 1
|
|
|
|
|
htalConListStrCon.KeyName = "企业微信官网"
|
|
|
|
|
htalConListStrCon.Value = "点击访问"
|
|
|
|
|
htalConListStrCon.Url = "tel:15069130853"
|
|
|
|
|
sendTextMsg.TemplateCard.HorizontalContentList = append(sendTextMsg.TemplateCard.HorizontalContentList, htalConListStrCon)
|
|
|
|
|
htalConListStrCon.Type = 3
|
|
|
|
|
htalConListStrCon.KeyName = "乘车人"
|
|
|
|
|
htalConListStrCon.Value = "秦东"
|
|
|
|
|
htalConListStrCon.UserId = "KaiXinGuo"
|
|
|
|
|
sendTextMsg.TemplateCard.HorizontalContentList = append(sendTextMsg.TemplateCard.HorizontalContentList, htalConListStrCon)
|
|
|
|
|
|
|
|
|
|
var jumpListStruct commonus.JumpListStruct
|
|
|
|
|
|
|
|
|
|
jumpListStruct.Type = 1
|
|
|
|
|
jumpListStruct.Title = "知行学院官网"
|
|
|
|
|
jumpListStruct.Url = "http://www.hxgk.group"
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct)
|
|
|
|
|
|
|
|
|
|
jumpListStruct.Type = 1
|
|
|
|
|
jumpListStruct.Title = "知行学院官网====>"
|
|
|
|
|
jumpListStruct.Url = "http://www.hxgk.group"
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.JumpList = append(sendTextMsg.TemplateCard.JumpList, jumpListStruct)
|
|
|
|
|
|
|
|
|
|
sendTextMsg.TemplateCard.CardAction.Type = 1
|
|
|
|
|
sendTextMsg.TemplateCard.CardAction.Url = "http://admin.hxgk.group"
|
|
|
|
|
|
|
|
|
|
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendImageTemplateCard()
|
|
|
|
|
outData := commonus.MapOut()
|
|
|
|
|
outData["callbakcMsg"] = string(callbakcMsg)
|
|
|
|
|
outData["isTrueCall"] = isTrueCall
|
|
|
|
|
outData["callBackCont"] = callBackCont
|
|
|
|
|
outData["sendTextMsg"] = sendTextMsg
|
|
|
|
|
response.Result(0, outData, "查询成功", c)
|
|
|
|
|
}
|