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.
1212 lines
48 KiB
1212 lines
48 KiB
package wechatcallback
|
|
|
|
import (
|
|
"encoding/json"
|
|
"encoding/xml"
|
|
"fmt"
|
|
"key_performance_indicators/api/version1/flowchart"
|
|
"key_performance_indicators/middleware/wechatapp/wechatsendmsg"
|
|
"key_performance_indicators/middleware/wechatapp/wechatstatice"
|
|
"key_performance_indicators/models/modelshr"
|
|
"key_performance_indicators/models/modelskpi"
|
|
"key_performance_indicators/overall"
|
|
"key_performance_indicators/overall/publicmethod"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 13:29:56
|
|
@ 功能: 事件处理
|
|
@ 参数
|
|
|
|
#msg 解密后的数据
|
|
#jieMiCont 接收数据结构体
|
|
#c gin全局结构体
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func EventProcessing(msg []byte, jieMiCont DecryptMsgCont, c *gin.Context) {
|
|
//通用类型判断是回调的什么事件
|
|
var commonType CurrencyMessage
|
|
xml.Unmarshal(msg, &commonType)
|
|
switch commonType.Event {
|
|
case "subscribe": //关注
|
|
case "unsubscribe": //取消关注
|
|
case "enter_agent": //本事件在成员进入企业微信的应用时触发
|
|
case "LOCATION": //上报地理位置
|
|
GeographicalPosition(msg)
|
|
case "batch_job_result": //异步任务完成事件推送
|
|
case "change_contact": //通讯录变更事件
|
|
// WorkWechatMailList(msgContent.ChangeType, decryptMsg)
|
|
case "click": //点击菜单拉取消息的事件推送
|
|
case "view": //点击菜单跳转链接的事件推送
|
|
case "scancode_push": //扫码推事件的事件推送
|
|
case "scancode_waitmsg": //扫码推事件且弹出“消息接收中”提示框的事件推送
|
|
case "pic_sysphoto": //弹出系统拍照发图的事件推送
|
|
case "pic_photo_or_album": //弹出拍照或者相册发图的事件推送
|
|
case "pic_weixin": //弹出微信相册发图器的事件推送
|
|
case "location_select": //弹出地理位置选择器的事件推送
|
|
case "open_approval_change": //审批状态通知事件 自建应用
|
|
// OpenApprovalChange(decryptMsg)
|
|
case "sys_approval_change": //系统审批应用
|
|
case "share_agent_change": //企业互联共享应用事件回调
|
|
case "share_chain_change": //上下游共享应用事件回调
|
|
case "template_card_event": //模板卡片事件推送
|
|
TemplateEvent(msg, jieMiCont, c)
|
|
case "template_card_menu_event": //通用模板卡片右上角菜单事件推送
|
|
default:
|
|
}
|
|
}
|
|
|
|
// 模板事件处理
|
|
func TemplateEvent(msg []byte, jieMiCont DecryptMsgCont, c *gin.Context) {
|
|
var msgCont ButtonEventQuestion
|
|
err := xml.Unmarshal(msg, &msgCont)
|
|
if err != nil {
|
|
return
|
|
}
|
|
// jieMiContJson, jieMiContErr := json.Marshal(jieMiCont)
|
|
// fmt.Printf("eventKeyAry:%v====================>%v==================>%v\n", string(msg), string(jieMiContJson), jieMiContErr)
|
|
|
|
eventKeyAry := strings.Split(msgCont.EventKey, "_")
|
|
buttionLen := len(eventKeyAry)
|
|
if buttionLen >= 5 {
|
|
// for i, v := range eventKeyAry {
|
|
|
|
// fmt.Printf("eventKeyAry:%v====================>%v==================>%v\n", i, v, eventKeyAry[i])
|
|
// }
|
|
switch eventKeyAry[0] {
|
|
case "school":
|
|
default: //默认系统
|
|
if eventKeyAry[1] == "post" {
|
|
|
|
buttonClickNAme := "已批准"
|
|
if eventKeyAry[3] != "1" {
|
|
buttonClickNAme = "已驳回"
|
|
}
|
|
xmlReply := fmt.Sprintf("<xml><ToUserName><![CDATA[%v]]></ToUserName><FromUserName><![CDATA[%v]]></FromUserName><CreateTime>%v</CreateTime><MsgType><![CDATA[update_button]]></MsgType><Button><ReplaceName><![CDATA[%v]]></ReplaceName></Button></xml>", msgCont.ToUsername, msgCont.FromUsername, msgCont.CreateTime, buttonClickNAme)
|
|
wxcptXml := wechatstatice.WechatDecryptXml("kpi")
|
|
msg, cryptErr := wxcptXml.EncryptMsg(xmlReply, jieMiCont.Timestamp, jieMiCont.Nonce)
|
|
if cryptErr != nil {
|
|
fmt.Printf("\n\n更新失败------%v------>%v\n\n", buttonClickNAme, cryptErr)
|
|
} else {
|
|
fmt.Printf("\n\n更新成功------%v------>%v\n\n", buttonClickNAme, cryptErr)
|
|
}
|
|
content := string(msg)
|
|
c.String(200, content)
|
|
|
|
//岗位考核
|
|
syncSetingCallback.Add(1)
|
|
go msgCont.PostTemolateCallBack(eventKeyAry[2], eventKeyAry[3], "kpi", eventKeyAry[4], 2, jieMiCont, c)
|
|
fmt.Printf("ButtonEventQuestion--msgCont->%v\n\n", msgCont)
|
|
syncSetingCallback.Wait()
|
|
// go UpdataButtonTextXml("kpi", eventKeyAry[3], msgCont, jieMiCont, c) //更新点击人按钮
|
|
} else {
|
|
//部门考核
|
|
}
|
|
}
|
|
} else {
|
|
jsonStr, _ := json.Marshal(msgCont)
|
|
fmt.Printf("TemplateEvent======>%v\n", string(jsonStr))
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-05 15:46:05
|
|
@ 功能: 岗位按钮模板回调处理
|
|
@ 参数
|
|
|
|
#orderId 流程Key
|
|
#clickEnter 0:未操作;1:同意;2:驳回;3:撤回
|
|
#systemApp 系统
|
|
#step 步进位
|
|
#departmentOrPost 类型(1:部门;2:岗位)
|
|
#jieMiCont 解密数据
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (b *ButtonEventQuestion) PostTemolateCallBack(orderId, clickEnter, systemApp, step string, departmentOrPost int, jieMiCont DecryptMsgCont, c *gin.Context) {
|
|
defer syncSetingCallback.Done()
|
|
clickEnterInt, _ := strconv.Atoi(clickEnter)
|
|
//1、判断当前流程状态
|
|
var flowCont modelskpi.PostWorkflowOrders
|
|
err := flowCont.GetCont(map[string]interface{}{"`order_id`": orderId})
|
|
if err != nil {
|
|
var sendMsgText wechatsendmsg.SendTextCard
|
|
sendMsgText.Touser = b.FromUsername
|
|
sendMsgText.Msgtype = "textcard"
|
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
|
|
sendMsgText.Agentid = agentIdInt
|
|
sendMsgText.EnableDuplicateCheck = 0
|
|
sendMsgText.DuplicateCheckInterval = 1800
|
|
sendMsgText.EnableIdTrans = 0
|
|
sendMsgText.MsgBody.Title = "流程关闭"
|
|
sendMsgText.MsgBody.Description = "此审批流程已经关闭!请联系发起人!"
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId)
|
|
sendMsgText.MsgBody.URL = jumpUrl
|
|
sendMsgText.MsgBody.BtnTxt = ""
|
|
sendMsgText.SendMsg(systemApp)
|
|
return
|
|
} else {
|
|
var sendMsgText wechatsendmsg.SendTextCard
|
|
sendMsgText.Touser = b.FromUsername
|
|
sendMsgText.Msgtype = "textcard"
|
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
|
|
sendMsgText.Agentid = agentIdInt
|
|
sendMsgText.EnableDuplicateCheck = 0
|
|
sendMsgText.DuplicateCheckInterval = 1800
|
|
sendMsgText.EnableIdTrans = 0
|
|
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId)
|
|
sendMsgText.MsgBody.URL = jumpUrl
|
|
sendMsgText.MsgBody.BtnTxt = "查看详情"
|
|
switch flowCont.State {
|
|
case 4:
|
|
sendMsgText.MsgBody.Title = "流程归档"
|
|
sendMsgText.MsgBody.Description = "此审批流程已经归档!不可继续操作!"
|
|
sendMsgText.SendMsg(systemApp)
|
|
return
|
|
case 5:
|
|
sendMsgText.MsgBody.Title = "流程废弃"
|
|
sendMsgText.MsgBody.Description = "此审批流程已经废弃!不可继续操作!"
|
|
sendMsgText.SendMsg(systemApp)
|
|
return
|
|
case 6:
|
|
sendMsgText.MsgBody.Title = "流程不存在"
|
|
sendMsgText.MsgBody.Description = "此审批流程不存在!请联系发起人!"
|
|
sendMsgText.SendMsg(systemApp)
|
|
return
|
|
default:
|
|
}
|
|
}
|
|
fmt.Printf("ButtonEventQuestion--->%v\n\n", b.FromUsername)
|
|
//获取人员信息
|
|
var carryOutPeople modelshr.PersonArchives
|
|
overall.CONSTANT_DB_HR.Where("`wechat` = ? Or `work_wechat` = ?", b.FromUsername, b.FromUsername).First(&carryOutPeople)
|
|
//判断当前步进位是否已经被操作
|
|
runIsTrue := 1
|
|
var operatorIsTreu modelskpi.OpenApprovalChangeLog
|
|
err = operatorIsTreu.GetCont(map[string]interface{}{"`orderid`": orderId, `stepper`: step})
|
|
// var flowOneCont publicmethod.FlowChartList
|
|
stepIng := flowCont.NextStep
|
|
if stepIng == 0 {
|
|
if flowCont.CountStep-1 > 0 {
|
|
stepIng = flowCont.CountStep - 1
|
|
} else {
|
|
stepIng = 1
|
|
}
|
|
}
|
|
flowMap, flowOneCont, _ := GetOneNodeCont(flowCont.WorkFlow, stepIng)
|
|
if err != nil { //无记录,可继续操作
|
|
UpdateLogNotChange(flowCont.OrderId)
|
|
runIsTrue = 1
|
|
operatorIsTreu.Type = departmentOrPost
|
|
operatorIsTreu.Title = flowOneCont.NodeName
|
|
operatorIsTreu.Operator = carryOutPeople.Key
|
|
orderIdInt, _ := strconv.ParseInt(orderId, 10, 64)
|
|
operatorIsTreu.OrderId = orderIdInt
|
|
operatorIsTreu.OperatorTime = time.Now().Unix()
|
|
operatorIsTreu.Step = flowOneCont.Step
|
|
operatorIsTreu.OperatorType = 2
|
|
operatorIsTreu.Msgid = ""
|
|
operatorIsTreu.ResponseCode = b.ResponseCode
|
|
stepInt, _ := strconv.Atoi(step)
|
|
operatorIsTreu.Stepper = stepInt
|
|
operatorIsTreu.ChangeIsTrue = 2
|
|
operatorIsTreu.YesOrNo = clickEnterInt
|
|
operatorIsTreu.Eiteyime = time.Now().Unix()
|
|
overall.CONSTANT_DB_KPI.Create(&operatorIsTreu)
|
|
} else { //有记录判断该节点是否可继续操作
|
|
if operatorIsTreu.ChangeIsTrue != 1 { //同级人员已经操作过不可继续操作
|
|
runIsTrue = 2
|
|
//获取操作人信息
|
|
var carryPeopleOld modelshr.PersonArchives
|
|
overall.CONSTANT_DB_HR.Where("`key` = ?", operatorIsTreu.Operator).First(&carryPeopleOld)
|
|
var sendMsgText wechatsendmsg.SendTextCard
|
|
sendMsgText.Touser = b.FromUsername
|
|
sendMsgText.Msgtype = "textcard"
|
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
|
|
sendMsgText.Agentid = agentIdInt
|
|
sendMsgText.EnableDuplicateCheck = 0
|
|
sendMsgText.DuplicateCheckInterval = 1800
|
|
sendMsgText.EnableIdTrans = 0
|
|
sendMsgText.MsgBody.Title = "已审批"
|
|
sendMsgText.MsgBody.Description = fmt.Sprintf("此审批流程已被%v审批!请不要重复操作!", carryPeopleOld.Name)
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId)
|
|
sendMsgText.MsgBody.URL = jumpUrl
|
|
sendMsgText.MsgBody.BtnTxt = ""
|
|
sendMsgText.SendMsg(systemApp)
|
|
} else { //有记录,没有人锁止操作,可继续操作
|
|
runIsTrue = 1
|
|
fmt.Println("可以操作")
|
|
operatorIsTreu.EiteCont(map[string]interface{}{"`id`": operatorIsTreu.Id}, map[string]interface{}{"`change_is_true`": 2, "`yesorno`": clickEnterInt, "eiteyime": time.Now().Unix()})
|
|
}
|
|
}
|
|
var updateButSync updateButtonSync
|
|
if runIsTrue == 1 {
|
|
stepIngInt, _ := strconv.Atoi(step)
|
|
// syncSeting.Add(1)
|
|
// go updateButSync.UpdataButtonTextXml(systemApp, clickEnter, b, jieMiCont, c) //更新点击人按钮
|
|
syncSeting.Add(1)
|
|
go updateButSync.UpdataOtherButtonTextXml(systemApp, clickEnter, carryOutPeople, flowOneCont, b) //更新同级别其他人按钮
|
|
syncSeting.Add(1)
|
|
go updateButSync.EidtFlowLog(flowCont.Id, flowMap, b.FromUsername, clickEnterInt, stepIng) //更新审批工作流json内容
|
|
switch clickEnterInt { //执行什么操作
|
|
case 1: //同意
|
|
syncSeting.Add(1)
|
|
go updateButSync.ApproveFlow(systemApp, flowMap, flowOneCont, stepIngInt, flowCont)
|
|
case 2: //驳回
|
|
syncSeting.Add(1)
|
|
go updateButSync.RejectFlow(systemApp, flowMap, flowOneCont, stepIngInt, flowCont)
|
|
case 3: //撤回
|
|
default:
|
|
}
|
|
|
|
}
|
|
syncSeting.Wait()
|
|
updateButtonMsg := updateButSync.readDataLock()
|
|
fmt.Printf("%v\n", updateButtonMsg)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-11 08:10:43
|
|
@ 功能:
|
|
@ 参数
|
|
|
|
#systemApp 系统
|
|
#pwoCont 岗位审批工作流
|
|
#flowMap 流程结构体
|
|
#flowOneCont 当前节点构体
|
|
#step 记录值
|
|
#liangOrXing 属性1、定性;2、定量
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (U *updateButtonSync) RejectFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOneCont publicmethod.FlowChartList, step int, pwoContOld modelskpi.PostWorkflowOrders) {
|
|
defer syncSeting.Done()
|
|
//获取要驳回到的节点
|
|
if flowOneCont.NodeRelationship.RejectNode < 1 {
|
|
return
|
|
}
|
|
var clickUrlPath string
|
|
markDowmStr := "驳回"
|
|
flowState := 3
|
|
rejectNode := GetRejectNode(flowMap, flowOneCont)
|
|
|
|
var sendToUserList []string //获取发送人
|
|
for _, fvu := range rejectNode.UserList {
|
|
if publicmethod.IsInTrue[string](fvu.Wechat, sendToUserList) == false {
|
|
sendToUserList = append(sendToUserList, fvu.Wechat)
|
|
}
|
|
}
|
|
|
|
switch rejectNode.Class {
|
|
case 2: //发送整改信息
|
|
//挂号
|
|
registerNum := publicmethod.GetUUid(2)
|
|
var setUpRegister modelskpi.Register
|
|
setUpRegister.Number = registerNum
|
|
setUpRegister.State = 1
|
|
setUpRegister.Time = time.Now().Unix()
|
|
setUpRegister.AddCont()
|
|
markDowmStr = fmt.Sprintf("您的整改措施被%v", markDowmStr)
|
|
clickUrlPath = fmt.Sprintf("%v\n>\n>[重新填写整改措施](http://new.hxgk.group/#/rectification?id=%v&num=%v)", markDowmStr, pwoContOld.OrderId, registerNum)
|
|
default: //发送驳回信息
|
|
clickUrlPath = fmt.Sprintf("%v\n>\n>[查看审批详情](http://new.hxgk.group/#/quantitativeList?id=%v)", markDowmStr, pwoContOld.OrderId)
|
|
}
|
|
var postTarDeta modelskpi.PostTarget
|
|
postTarDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Target}, "`title`")
|
|
markDowmStr = fmt.Sprintf("%v\n>**事项详情** ", markDowmStr)
|
|
markDowmStr = fmt.Sprintf("%v\n>指标: %v", markDowmStr, postTarDeta.Title)
|
|
if pwoContOld.Class == 1 { //定性操作
|
|
var postTarDetailsDeta modelskpi.PostTargetDetails
|
|
postTarDetailsDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Detailed}, "`title`", "`punishmode`", "`company`")
|
|
|
|
var postNatuerFlowCont modelskpi.PostNatureFlow
|
|
postNatuerFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
|
|
markDowmStr = fmt.Sprintf("%v\n>指标详情: %v", markDowmStr, postTarDetailsDeta.Title)
|
|
markDowmStr = fmt.Sprintf("%v\n><font color=\"info\">发生时间: %v</font> ", markDowmStr, publicmethod.UnixTimeToDay(postNatuerFlowCont.HappenTime, 1))
|
|
switch postTarDetailsDeta.Punishmode {
|
|
case 1:
|
|
if postNatuerFlowCont.Score != 0 {
|
|
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
}
|
|
}
|
|
case 2:
|
|
if postNatuerFlowCont.Money != 0 {
|
|
moneyFloat := float64(postNatuerFlowCont.Money) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
}
|
|
}
|
|
default:
|
|
if postNatuerFlowCont.Score != 0 {
|
|
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>增奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
}
|
|
}
|
|
if postNatuerFlowCont.Money != 0 {
|
|
moneyFloat := float64(postNatuerFlowCont.Money) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
}
|
|
}
|
|
}
|
|
//获取提报人信息
|
|
var zeRenRenCont modelshr.PersonArchives
|
|
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.Executor}, "`name`", "`number`")
|
|
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">提报人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
|
|
markDowmStr = fmt.Sprintf("%v\n> \n>%v", markDowmStr, clickUrlPath)
|
|
} else {
|
|
//定量操作
|
|
var postMeterFlowCont modelskpi.PostMeteringFlow
|
|
postMeterFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
|
|
markDowmStr = fmt.Sprintf("%v\n>%v年", markDowmStr, postMeterFlowCont.Year)
|
|
switch postTarDeta.Cycle {
|
|
case 5:
|
|
markDowmStr = fmt.Sprintf("%v\n>%v季度上报数值%v%v", markDowmStr, postMeterFlowCont.Quarter, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
|
|
case 6:
|
|
markDowmStr = fmt.Sprintf("%v\n>上报数值%v%v", markDowmStr, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
|
|
default:
|
|
markDowmStr = fmt.Sprintf("%v\n>%v月上报数值%v%v", markDowmStr, postMeterFlowCont.Month, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
|
|
}
|
|
//获取责任信息
|
|
var zeRenRenCont modelshr.PersonArchives
|
|
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postMeterFlowCont.PersonLiable}, "`name`", "`number`")
|
|
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">被考核人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
|
|
}
|
|
|
|
nextStep := rejectNode.Step + 1
|
|
var pwoCont modelskpi.PostWorkflowOrders
|
|
nextUserKey, _ := flowchart.GetNodeOperator(flowMap, nextStep)
|
|
nextUserKeyStr := strings.Join(nextUserKey, ",")
|
|
if nextStep == 0 {
|
|
nextUserKeyStr = ""
|
|
}
|
|
|
|
// pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "'next_executor'": nextUserKeyStr, "`time`": time.Now().Unix()}) //改变审批流状态
|
|
|
|
flowParticipants := strings.Split(pwoContOld.Participants, ",")
|
|
for _, vuk := range nextUserKey {
|
|
if publicmethod.IsInTrue[string](vuk, flowParticipants) == false {
|
|
flowParticipants = append(flowParticipants, vuk)
|
|
}
|
|
}
|
|
flowParticipantStr := strings.Join(flowParticipants, ",")
|
|
|
|
pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "'next_executor'": nextUserKeyStr, "`participants`": flowParticipantStr, "`time`": time.Now().Unix()}) //改变审批流状态
|
|
//发送同通信息
|
|
SendNoticeMsg(sendToUserList, markDowmStr, systemApp)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-11 08:56:06
|
|
@ 功能: 获取要驳回到的节点
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func GetRejectNode(flowMap []publicmethod.FlowChartList, flowOneCont publicmethod.FlowChartList) (rejectFlowCont publicmethod.FlowChartList) {
|
|
if flowOneCont.NodeRelationship.RejectNode > 0 {
|
|
for _, v := range flowMap {
|
|
if v.Step == flowOneCont.NodeRelationship.RejectNode {
|
|
rejectFlowCont = v
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-08 11:20:38
|
|
@ 功能: 同意
|
|
@ 参数
|
|
|
|
#systemApp 系统
|
|
#pwoCont 岗位审批工作流
|
|
#flowMap 流程结构体
|
|
#flowOneCont 当前节点构体
|
|
#step 记录值
|
|
#liangOrXing 属性1、定性;2、定量
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (U *updateButtonSync) ApproveFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOneCont publicmethod.FlowChartList, step int, pwoContOld modelskpi.PostWorkflowOrders) {
|
|
defer syncSeting.Done()
|
|
nextStep := 0
|
|
flowState := 2 //判断流程状态
|
|
switch flowOneCont.RunType {
|
|
case 1:
|
|
flowState = 2
|
|
case 2:
|
|
flowState = 2
|
|
case 3:
|
|
flowState = 4
|
|
case 4:
|
|
flowState = 4
|
|
default:
|
|
flowState = 1
|
|
}
|
|
//判断下一个当前节点是否为最后一个节点
|
|
if flowState == 4 {
|
|
nextStep = 0
|
|
} else {
|
|
nextStep = flowOneCont.Step + 1
|
|
}
|
|
//更新审批流状态
|
|
var pwoCont modelskpi.PostWorkflowOrders
|
|
nextUserKey, _ := flowchart.GetNodeOperator(flowMap, nextStep)
|
|
nextUserKeyStr := strings.Join(nextUserKey, ",")
|
|
if nextStep == 0 {
|
|
nextUserKeyStr = ""
|
|
}
|
|
|
|
flowParticipants := strings.Split(pwoContOld.Participants, ",")
|
|
for _, vuk := range nextUserKey {
|
|
if publicmethod.IsInTrue[string](vuk, flowParticipants) == false {
|
|
flowParticipants = append(flowParticipants, vuk)
|
|
}
|
|
}
|
|
flowParticipantStr := strings.Join(flowParticipants, ",")
|
|
|
|
pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "'next_executor'": nextUserKeyStr, "`participants`": flowParticipantStr, "`time`": time.Now().Unix()}) //改变审批流状态
|
|
|
|
//获取下一部操作
|
|
for _, fv := range flowMap {
|
|
if fv.Step == flowOneCont.Step+1 {
|
|
var sendToUserList []string //获取发送人
|
|
for _, fvu := range fv.UserList {
|
|
if publicmethod.IsInTrue[string](fvu.Wechat, sendToUserList) == false {
|
|
sendToUserList = append(sendToUserList, fvu.Wechat)
|
|
}
|
|
}
|
|
if len(sendToUserList) > 0 { //存在接收人执行以下操作
|
|
var postTarDeta modelskpi.PostTarget
|
|
postTarDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Target}, "`title`")
|
|
if fv.Class < 3 {
|
|
sendNextStep := step + 1
|
|
//发送按钮信息
|
|
if pwoContOld.Class == 1 { //定性操作
|
|
var postTarDetailsDeta modelskpi.PostTargetDetails
|
|
postTarDetailsDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Detailed}, "`title`", "`punishmode`", "`company`")
|
|
unitTitle := postTarDetailsDeta.Company
|
|
if unitTitle == "" {
|
|
unitTitle = postTarDeta.Unit
|
|
}
|
|
var postNatuerFlowCont modelskpi.PostNatureFlow
|
|
postNatuerFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
|
|
if fv.Class == 2 { //需要填写信息,发送相关信息
|
|
//挂号
|
|
registerNum := publicmethod.GetUUid(2)
|
|
var setUpRegister modelskpi.Register
|
|
setUpRegister.Number = registerNum
|
|
setUpRegister.State = 1
|
|
setUpRegister.Time = time.Now().Unix()
|
|
setUpRegister.AddCont()
|
|
//抄送信息
|
|
markDowmStr := "整改通知"
|
|
markDowmStr = fmt.Sprintf("%v\n>**事项详情** ", markDowmStr)
|
|
markDowmStr = fmt.Sprintf("%v\n>指标: %v", markDowmStr, postTarDeta.Title)
|
|
markDowmStr = fmt.Sprintf("%v\n>指标详情: %v", markDowmStr, postTarDetailsDeta.Title)
|
|
markDowmStr = fmt.Sprintf("%v\n><font color=\"info\">发生时间: %v</font> ", markDowmStr, publicmethod.UnixTimeToDay(postNatuerFlowCont.HappenTime, 1))
|
|
switch postTarDetailsDeta.Punishmode {
|
|
case 1:
|
|
if postNatuerFlowCont.Score != 0 {
|
|
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
}
|
|
}
|
|
case 2:
|
|
if postNatuerFlowCont.Money != 0 {
|
|
moneyFloat := float64(postNatuerFlowCont.Money) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
}
|
|
}
|
|
default:
|
|
if postNatuerFlowCont.Score != 0 {
|
|
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>增奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
}
|
|
}
|
|
if postNatuerFlowCont.Money != 0 {
|
|
moneyFloat := float64(postNatuerFlowCont.Money) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
}
|
|
}
|
|
}
|
|
//获取提报人信息
|
|
var zeRenRenCont modelshr.PersonArchives
|
|
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.Executor}, "`name`", "`number`")
|
|
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">提报人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
|
|
|
|
markDowmStr = fmt.Sprintf("%v\n>\n>[填写整改措施](http://new.hxgk.group/#/rectification?id=%v&num=%v)", markDowmStr, pwoContOld.OrderId, registerNum)
|
|
//发送同通信息
|
|
SendNoticeMsg(sendToUserList, markDowmStr, systemApp)
|
|
} else { //无需填写信息。继续发送
|
|
//考核标准
|
|
var sunTextCont string
|
|
var quoteTextCont string
|
|
switch postTarDetailsDeta.Punishmode {
|
|
case 2:
|
|
var moneyTitle string
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
moneyTitle = "现金奖励标准"
|
|
quoteTextCont = fmt.Sprintf("奖励现金:%v元", postNatuerFlowCont.Money)
|
|
} else {
|
|
moneyTitle = "现金罚款标准"
|
|
quoteTextCont = fmt.Sprintf("罚款现金:%v元", postNatuerFlowCont.Money)
|
|
}
|
|
var scoreStr string
|
|
if postTarDetailsDeta.Minmoney != 0 {
|
|
scoreStr = fmt.Sprintf("%v元-%v元", publicmethod.DecimalEs(float64(postTarDetailsDeta.Minmoney)/100, 2), publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
|
|
} else {
|
|
scoreStr = fmt.Sprintf("%v元", publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
|
|
}
|
|
sunTextCont = fmt.Sprintf("%v:%v", moneyTitle, scoreStr)
|
|
if postNatuerFlowCont.Reason != "" {
|
|
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, postNatuerFlowCont.Reason)
|
|
}
|
|
case 3:
|
|
var moneyTitle string
|
|
var scoreTitle string
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
moneyTitle = "现金奖励标准"
|
|
scoreTitle = "考核扣分标准"
|
|
quoteTextCont = fmt.Sprintf("考核加:%v%v\n奖励现金:%v元", postNatuerFlowCont.Score, unitTitle, postNatuerFlowCont.Money)
|
|
} else {
|
|
moneyTitle = "现金罚款标准"
|
|
scoreTitle = "考核加分标准"
|
|
quoteTextCont = fmt.Sprintf("考核扣:%v%v\n罚款现金:%v元", postNatuerFlowCont.Score, unitTitle, postNatuerFlowCont.Money)
|
|
}
|
|
var scoreStr string
|
|
|
|
if postTarDetailsDeta.MinScore != 0 {
|
|
scoreStr = fmt.Sprintf("%v%v-%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MinScore)/100, 2), unitTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
|
|
} else {
|
|
scoreStr = fmt.Sprintf("%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
|
|
}
|
|
sunTextCont = fmt.Sprintf("%v:%v", scoreTitle, scoreStr)
|
|
|
|
if postTarDetailsDeta.Minmoney != 0 {
|
|
sunTextCont = fmt.Sprintf("%v\n%v:%v元-%v元", sunTextCont, moneyTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.Minmoney)/100, 2), publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
|
|
} else {
|
|
sunTextCont = fmt.Sprintf("%v\n%v:%v元", sunTextCont, moneyTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
|
|
}
|
|
|
|
if postNatuerFlowCont.Reason != "" {
|
|
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, postNatuerFlowCont.Reason)
|
|
}
|
|
default:
|
|
|
|
var scoreTitle string
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
scoreTitle = "考核加分标准"
|
|
quoteTextCont = fmt.Sprintf("考核加:%v%v", postNatuerFlowCont.Score, unitTitle)
|
|
} else {
|
|
scoreTitle = "考核扣分标准"
|
|
quoteTextCont = fmt.Sprintf("考核扣:%v%v", postNatuerFlowCont.Score, unitTitle)
|
|
}
|
|
var scoreStr string
|
|
if postTarDetailsDeta.MinScore != 0 {
|
|
scoreStr = fmt.Sprintf("%v%v-%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MinScore)/100, 2), unitTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
|
|
} else {
|
|
scoreStr = fmt.Sprintf("%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
|
|
}
|
|
sunTextCont = fmt.Sprintf("%v:%v", scoreTitle, scoreStr)
|
|
|
|
if postNatuerFlowCont.Reason != "" {
|
|
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, postNatuerFlowCont.Reason)
|
|
}
|
|
}
|
|
|
|
var quoteAreaInfo wechatsendmsg.QuoteAreaCont
|
|
quoteAreaInfo.Type = 0
|
|
quoteAreaInfo.Title = "考核明细"
|
|
quoteAreaInfo.QuoteText = quoteTextCont
|
|
|
|
//二级标题+文本列表
|
|
var twoTitleTextList []wechatsendmsg.HorizontalContentListInfo
|
|
var shenQingRen modelshr.PersonArchives
|
|
shenQingRen.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.Executor}, "`wechat`", "`work_wechat`")
|
|
if shenQingRen.Wechat != "" || shenQingRen.WorkWechat != "" {
|
|
wechatOpenId := shenQingRen.Wechat
|
|
if shenQingRen.WorkWechat != "" {
|
|
wechatOpenId = shenQingRen.WorkWechat
|
|
}
|
|
//发送人
|
|
var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
|
|
horizontalContentLis3.KeyName = "申请人:"
|
|
horizontalContentLis3.Value = "点击查看"
|
|
horizontalContentLis3.Type = 3
|
|
horizontalContentLis3.Userid = wechatOpenId
|
|
twoTitleTextList = append(twoTitleTextList, horizontalContentLis3)
|
|
}
|
|
var beiKaoHeRen modelshr.PersonArchives
|
|
beiKaoHeRen.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.Executor}, "`wechat`", "`work_wechat`")
|
|
//被考核人
|
|
if beiKaoHeRen.Wechat != "" || beiKaoHeRen.WorkWechat != "" {
|
|
weChatStrs := beiKaoHeRen.Wechat
|
|
if beiKaoHeRen.WorkWechat != "" {
|
|
weChatStrs = beiKaoHeRen.WorkWechat
|
|
}
|
|
var twoTitleTextCont wechatsendmsg.HorizontalContentListInfo
|
|
twoTitleTextCont.KeyName = "被考核人:"
|
|
twoTitleTextCont.Value = "点击查看"
|
|
twoTitleTextCont.Type = 3
|
|
twoTitleTextCont.Userid = weChatStrs
|
|
twoTitleTextList = append(twoTitleTextList, twoTitleTextCont)
|
|
}
|
|
|
|
SendButtonCard(systemApp, postTarDeta.Title, postTarDetailsDeta.Title, sunTextCont, fv.NodeName, pwoContOld.OrderId, sendNextStep, sendToUserList, quoteAreaInfo, twoTitleTextList)
|
|
}
|
|
} else { //定量操作
|
|
//定量操作
|
|
var postMeterFlowCont modelskpi.PostMeteringFlow
|
|
postMeterFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
|
|
//获取考核项目信息
|
|
var postShemeCont modelskpi.QualitativeEvaluationScheme
|
|
postShemeCont.GetCont(map[string]interface{}{"`id`": postMeterFlowCont.ShemeId})
|
|
|
|
//引用文献
|
|
var quoteAreaInfo wechatsendmsg.QuoteAreaCont
|
|
quoteAreaInfo.Type = 0
|
|
quoteAreaInfo.Title = "数据详细"
|
|
quoteAreaInfo.QuoteText = fmt.Sprintf("数值:%v%v\n备注:%v", publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit, postMeterFlowCont.Reason)
|
|
|
|
//二级标题+文本列表
|
|
var twoTitleTextList []wechatsendmsg.HorizontalContentListInfo
|
|
var shenQingRen modelshr.PersonArchives
|
|
shenQingRen.GetCont(map[string]interface{}{"`key`": postMeterFlowCont.Executor}, "`wechat`", "`work_wechat`")
|
|
if shenQingRen.Wechat != "" || shenQingRen.WorkWechat != "" {
|
|
wechatOpenId := shenQingRen.Wechat
|
|
if shenQingRen.WorkWechat != "" {
|
|
wechatOpenId = shenQingRen.WorkWechat
|
|
}
|
|
//发送人
|
|
var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
|
|
horizontalContentLis3.KeyName = "申请人:"
|
|
horizontalContentLis3.Value = "点击查看"
|
|
horizontalContentLis3.Type = 3
|
|
horizontalContentLis3.Userid = wechatOpenId
|
|
twoTitleTextList = append(twoTitleTextList, horizontalContentLis3)
|
|
}
|
|
var beiKaoHeRen modelshr.PersonArchives
|
|
beiKaoHeRen.GetCont(map[string]interface{}{"`key`": postMeterFlowCont.Executor}, "`wechat`", "`work_wechat`")
|
|
//被考核人
|
|
if beiKaoHeRen.Wechat != "" || beiKaoHeRen.WorkWechat != "" {
|
|
weChatStrs := beiKaoHeRen.Wechat
|
|
if beiKaoHeRen.WorkWechat != "" {
|
|
weChatStrs = beiKaoHeRen.WorkWechat
|
|
}
|
|
var twoTitleTextCont wechatsendmsg.HorizontalContentListInfo
|
|
twoTitleTextCont.KeyName = "被考核人:"
|
|
twoTitleTextCont.Value = "点击查看"
|
|
twoTitleTextCont.Type = 3
|
|
twoTitleTextCont.Userid = weChatStrs
|
|
twoTitleTextList = append(twoTitleTextList, twoTitleTextCont)
|
|
}
|
|
|
|
SendButtonCard(systemApp, postShemeCont.Title, postShemeCont.Content, "", fv.NodeName, pwoContOld.OrderId, sendNextStep, sendToUserList, quoteAreaInfo, twoTitleTextList)
|
|
}
|
|
} else {
|
|
//抄送信息
|
|
markDowmStr := "审批通过-抄送"
|
|
markDowmStr = fmt.Sprintf("%v\n>**事项详情** ", markDowmStr)
|
|
|
|
markDowmStr = fmt.Sprintf("%v\n>指标: %v", markDowmStr, postTarDeta.Title)
|
|
if pwoContOld.Class == 1 {
|
|
//定性操作
|
|
var postTarDetailsDeta modelskpi.PostTargetDetails
|
|
postTarDetailsDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Detailed}, "`title`", "`punishmode`", "`company`")
|
|
markDowmStr = fmt.Sprintf("%v\n>指标详情: %v", markDowmStr, postTarDetailsDeta.Title)
|
|
var postNatuerFlowCont modelskpi.PostNatureFlow
|
|
postNatuerFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
|
|
|
|
switch postTarDetailsDeta.Punishmode {
|
|
case 1:
|
|
if postNatuerFlowCont.Score != 0 {
|
|
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
}
|
|
}
|
|
case 2:
|
|
if postNatuerFlowCont.Money != 0 {
|
|
moneyFloat := float64(postNatuerFlowCont.Money) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
}
|
|
}
|
|
default:
|
|
if postNatuerFlowCont.Score != 0 {
|
|
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>增奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
|
|
}
|
|
}
|
|
if postNatuerFlowCont.Money != 0 {
|
|
moneyFloat := float64(postNatuerFlowCont.Money) / 100
|
|
if postNatuerFlowCont.AddOrDecrease == 1 {
|
|
//增加
|
|
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
} else {
|
|
//减少
|
|
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
|
|
}
|
|
}
|
|
}
|
|
//获取责任信息
|
|
var zeRenRenCont modelshr.PersonArchives
|
|
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.PersonLiable}, "`name`", "`number`")
|
|
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">被考核人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
|
|
markDowmStr = fmt.Sprintf("%v\n><font color=\"info\">发生时间: %v</font> ", markDowmStr, publicmethod.UnixTimeToDay(postNatuerFlowCont.HappenTime, 1))
|
|
markDowmStr = fmt.Sprintf("%v\n>\n>[查看审批详情](http://new.hxgk.group/#/quantitativeList?id=%v)", markDowmStr, pwoContOld.OrderId)
|
|
} else {
|
|
//定量操作
|
|
var postMeterFlowCont modelskpi.PostMeteringFlow
|
|
postMeterFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
|
|
markDowmStr = fmt.Sprintf("%v\n>%v年", markDowmStr, postMeterFlowCont.Year)
|
|
switch postTarDeta.Cycle {
|
|
case 5:
|
|
markDowmStr = fmt.Sprintf("%v\n>%v季度上报数值%v%v", markDowmStr, postMeterFlowCont.Quarter, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
|
|
case 6:
|
|
markDowmStr = fmt.Sprintf("%v\n>上报数值%v%v", markDowmStr, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
|
|
default:
|
|
markDowmStr = fmt.Sprintf("%v\n>%v月上报数值%v%v", markDowmStr, postMeterFlowCont.Month, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
|
|
}
|
|
//获取责任信息
|
|
var zeRenRenCont modelshr.PersonArchives
|
|
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postMeterFlowCont.PersonLiable}, "`name`", "`number`")
|
|
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">被考核人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
|
|
|
|
markDowmStr = fmt.Sprintf("%v\n>\n>[查看审批详情](http://new.hxgk.group/#/quantitativeList?id=%v)", markDowmStr, pwoContOld.OrderId)
|
|
}
|
|
//发送抄送信息
|
|
SendNoticeMsg(sendToUserList, markDowmStr, systemApp)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-09 09:19:54
|
|
@ 功能: 发送按钮卡片
|
|
@ 参数
|
|
|
|
#systemApp 系统
|
|
#mainTitle 主标题
|
|
#descInfo 主标题描述
|
|
#sunTextCont 二级文本
|
|
#sendTitle 头部信息
|
|
#uuId 订单ID
|
|
#step 步进值
|
|
#sendUserList 接收人
|
|
#quoteAreaInfo 引用文献
|
|
#twoTitleTextList 二级标题+文本列表
|
|
|
|
func SendButtonCard(systemApp, mainTitle, descInfo, sunTextCont, sendTitle string, uuId int64, step int, sendUserList []string, quoteAreaInfo wechatsendmsg.QuoteAreaCont, twoTitleTextList []wechatsendmsg.HorizontalContentListInfo)
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func SendButtonCard(systemApp, mainTitle, descInfo, sunTextCont, sendTitle string, uuId int64, step int, sendUserList []string, quoteAreaInfo wechatsendmsg.QuoteAreaCont, twoTitleTextList []wechatsendmsg.HorizontalContentListInfo) {
|
|
|
|
//头部信息
|
|
var sourceText wechatsendmsg.SourceText
|
|
sourceText.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
sourceText.Desc = fmt.Sprintf("恒信高科-%v", sendTitle)
|
|
sourceText.DescColor = 1
|
|
//按钮
|
|
var buttonList []wechatsendmsg.ButtonListCont
|
|
var buttonList1 wechatsendmsg.ButtonListCont
|
|
buttonList1.Text = "批准"
|
|
buttonList1.Style = 1
|
|
buttonList1.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 1, step)
|
|
buttonList = append(buttonList, buttonList1)
|
|
var buttonList2 wechatsendmsg.ButtonListCont
|
|
buttonList2.Text = "驳回"
|
|
buttonList2.Style = 3
|
|
buttonList2.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 2, step)
|
|
buttonList = append(buttonList, buttonList2)
|
|
//卡片跳转地址
|
|
var cardActionContStr wechatsendmsg.CardActionCont
|
|
cardActionContStr.Type = 1
|
|
cardActionContStr.Url = fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v", uuId)
|
|
|
|
var sendButtionMsg wechatsendmsg.SendButtonInteractionSimplify
|
|
// sendButtionMsg.Touser = strings.Join(sendUserList, "|")
|
|
sendButtionMsg.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为
|
|
sendButtionMsg.Msgtype = "template_card"
|
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
|
|
sendButtionMsg.Agentid = agentIdInt
|
|
sendButtionMsg.EnableDuplicateCheck = 0
|
|
sendButtionMsg.DuplicateCheckInterval = 1800
|
|
sendButtionMsg.EnableIdTrans = 0
|
|
sendButtionMsg.TemplateCard.CardType = "button_interaction"
|
|
sendButtionMsg.TemplateCard.Source = sourceText
|
|
sendButtionMsg.TemplateCard.TaskId = fmt.Sprintf("KPI_%v_%v", uuId, step)
|
|
sendButtionMsg.TemplateCard.MainTitle.Title = mainTitle
|
|
|
|
sendButtionMsg.TemplateCard.MainTitle.Desc = descInfo
|
|
sendButtionMsg.TemplateCard.QuoteArea = quoteAreaInfo
|
|
|
|
sendButtionMsg.TemplateCard.SubTitleText = sunTextCont
|
|
sendButtionMsg.TemplateCard.ButtonList = buttonList
|
|
sendButtionMsg.TemplateCard.HorizontalContentList = twoTitleTextList
|
|
sendButtionMsg.TemplateCard.CardAction = cardActionContStr
|
|
// callData, err := sendButtionMsg.SendMsg(systemApp)
|
|
sendButtionMsg.SendMsg(systemApp)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-09 08:38:02
|
|
@ 功能: 发送通知信息
|
|
@ 参数
|
|
|
|
#sendToUserList 信息接收人
|
|
#markDowmStr 消息主体
|
|
#systemApp 系统
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func SendNoticeMsg(sendToUserList []string, markDowmStr, systemApp string) {
|
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64) //应用AgentId
|
|
var sendCopyMsg wechatsendmsg.SendMarkDown
|
|
sendCopyMsg.Touser = strings.Join(sendToUserList, "|")
|
|
sendCopyMsg.Msgtype = "markdown"
|
|
sendCopyMsg.Agentid = agentIdInt
|
|
sendCopyMsg.EnableDuplicateCheck = 0
|
|
sendCopyMsg.DuplicateCheckInterval = 1800
|
|
sendCopyMsg.MsgBody.Content = markDowmStr
|
|
sendCopyMsg.SendMsg(systemApp)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 11:42:06
|
|
@ 功能: 更改操作流程节点信息
|
|
@ 参数
|
|
|
|
#pwoId 岗位审批工作流ID
|
|
#flowMap 流程结构体
|
|
#operatorWechat 操作人
|
|
#clickEnter 操作
|
|
#step 执行的哪一步
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (u *updateButtonSync) EidtFlowLog(pwoId int64, flowMap []publicmethod.FlowChartList, operatorWechat string, clickEnter, step int) {
|
|
defer syncSeting.Done()
|
|
// flowState := 3 //判断流程状态
|
|
var newFlowMap []publicmethod.FlowChartList
|
|
for _, v := range flowMap {
|
|
var newFlowMapCont publicmethod.FlowChartList
|
|
|
|
newFlowMapCont.Step = v.Step //步伐
|
|
newFlowMapCont.NodeName = v.NodeName //节点名称
|
|
// newFlowMapCont.State = 2 `json:"state"` //状态 1、不点亮;2、点亮
|
|
newFlowMapCont.Class = v.Class //节点类型 1、普通节点;2、运行中指定节点
|
|
newFlowMapCont.RunType = v.RunType //运行状态(1:开始;2:操作点;3:结束)
|
|
newFlowMapCont.NodeRelationship = v.NodeRelationship
|
|
if v.Step == step { //获取到当前执行的节点
|
|
// switch v.RunType { //当前节点运行状态
|
|
// case 1:
|
|
// flowState = 1
|
|
// case 2:
|
|
// flowState = 3
|
|
// case 3:
|
|
// flowState = 4
|
|
// default:
|
|
// flowState = 3
|
|
// }
|
|
newFlowMapCont.State = 2 //状态 1、不点亮;2、点亮
|
|
for _, uv := range v.UserList { //遍历审批人列表
|
|
if uv.Wechat == operatorWechat { //当前操作人
|
|
var logCont publicmethod.LogList
|
|
switch clickEnter {
|
|
case 1:
|
|
logCont.State = 2
|
|
case 2:
|
|
logCont.State = 3
|
|
default:
|
|
logCont.State = 1
|
|
}
|
|
|
|
logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1)
|
|
uv.LogList = append(uv.LogList, logCont)
|
|
}
|
|
newFlowMapCont.UserList = append(newFlowMapCont.UserList, uv)
|
|
}
|
|
} else {
|
|
newFlowMapCont.State = v.Class //状态 1、不点亮;2、点亮
|
|
newFlowMapCont.UserList = v.UserList
|
|
}
|
|
|
|
newFlowMap = append(newFlowMap, newFlowMapCont)
|
|
}
|
|
jsonStr, _ := json.Marshal(newFlowMap)
|
|
var pwoCont modelskpi.PostWorkflowOrders
|
|
pwoCont.EiteCont(map[string]interface{}{"`id`": pwoId}, map[string]interface{}{"`work_flow`": string(jsonStr), "`time`": time.Now().Unix()})
|
|
// fmt.Printf("\n\nflowState---->%v\n\njsonStr---->%v\n\n", flowState, string(jsonStr))
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 09:00:15
|
|
@ 功能: 获取单一节点信息与流程图结构体
|
|
@ 参数
|
|
|
|
#workFlowStr 流程字符串
|
|
#step 当前步进值
|
|
|
|
@ 返回值
|
|
|
|
#flowCont 节点内容
|
|
#err 系统信息
|
|
*/
|
|
func GetOneNodeCont(workFlowStr string, step int) (flowMap []publicmethod.FlowChartList, flowCont publicmethod.FlowChartList, err error) {
|
|
//解析流程图
|
|
err = json.Unmarshal([]byte(workFlowStr), &flowMap)
|
|
if err != nil {
|
|
return
|
|
}
|
|
for _, v := range flowMap {
|
|
if v.Step == step {
|
|
flowCont = v
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 13:10:56
|
|
@ 功能: 更新按钮文案
|
|
@ 参数
|
|
|
|
#systemApp 系统
|
|
#clickEnter 1:同意;2:驳回
|
|
#jieMiCont 解密数据
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (u *updateButtonSync) UpdataButtonText(systemApp, clickEnter string, b *ButtonEventQuestion, jieMiCont DecryptMsgCont) {
|
|
defer syncSeting.Done()
|
|
buttonClickNAme := "已批准"
|
|
if clickEnter != "3" {
|
|
buttonClickNAme = "已驳回"
|
|
}
|
|
reqData := fmt.Sprintf(`{"ToUserName":"%v","FromUserName":"%v","CreateTime":"%v","MsgType":"update_button","Button": { "ReplaceName": "%v" }}`, b.ToUsername, b.FromUsername, jieMiCont.Timestamp, buttonClickNAme)
|
|
// reqData := []byte(decryptStr)
|
|
wxcptJson := wechatstatice.WechatDecryptJson(systemApp)
|
|
msg, cryptErr := wxcptJson.EncryptMsg(reqData, jieMiCont.Timestamp, jieMiCont.Nonce)
|
|
if cryptErr != nil {
|
|
// cryptErr = fmt.Errorf("解密失败1")
|
|
fmt.Printf("\n\n更新失败------------>%v\n\n", cryptErr)
|
|
}
|
|
content := string(msg)
|
|
// b.UpdateButtonMsg = sEncryptMsg
|
|
u.content = content
|
|
fmt.Printf("\n\n更新成功------------》%v\n\n", content)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 14:12:58
|
|
@ 功能: 更新按钮文案Xml
|
|
@ 参数
|
|
|
|
#systemApp 系统
|
|
#clickEnter 1:同意;2:驳回
|
|
#jieMiCont 解密数据
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (u *updateButtonSync) UpdataButtonTextXml(systemApp, clickEnter string, b *ButtonEventQuestion, jieMiCont DecryptMsgCont, c *gin.Context) {
|
|
defer syncSeting.Done()
|
|
buttonClickNAme := "已批准"
|
|
if clickEnter != "1" {
|
|
buttonClickNAme = "已驳回"
|
|
}
|
|
// reqData := fmt.Sprintf(`{"ToUserName":"%v","FromUserName":"%v","CreateTime":"%v","MsgType":"update_button","Button": { "ReplaceName": "%v" }}`, b.ToUsername, b.FromUsername, jieMiCont.Timestamp, buttonClickNAme)
|
|
xmlReply := fmt.Sprintf("<xml><ToUserName><![CDATA[%v]]></ToUserName><FromUserName><![CDATA[%v]]></FromUserName><CreateTime>%v</CreateTime><MsgType><![CDATA[update_button]]></MsgType><Button><ReplaceName><![CDATA[%v]]></ReplaceName></Button></xml>", b.ToUsername, b.FromUsername, b.CreateTime, buttonClickNAme)
|
|
// reqData := []byte(decryptStr)
|
|
wxcptXml := wechatstatice.WechatDecryptXml(systemApp)
|
|
msg, cryptErr := wxcptXml.EncryptMsg(xmlReply, jieMiCont.Timestamp, jieMiCont.Nonce)
|
|
if cryptErr != nil {
|
|
// cryptErr = fmt.Errorf("解密失败1")
|
|
fmt.Printf("\n\n更新失败------%v------>%v\n\n", buttonClickNAme, cryptErr)
|
|
}
|
|
content := string(msg)
|
|
// b.UpdateButtonMsg = sEncryptMsg
|
|
u.content = content
|
|
fmt.Printf("\n\n更新成功------%v------》%v\n\n", buttonClickNAme, content)
|
|
c.String(200, content)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 15:13:59
|
|
@ 功能: 更新同一审批节点其他人审批文案
|
|
@ 参数
|
|
|
|
#systemApp 系统
|
|
#clickEnter 1:同意;2:驳回
|
|
#carryOutPeople 当前操作人信息
|
|
#flowOneCont 当前审批节点信息
|
|
#b 点击按钮事件解密信息
|
|
|
|
UpdataOtherButtonTextXml(systemApp, clickEnter string, carryOutPeople modelshr.PersonArchives, flowOneCont publicmethod.FlowChartList, b *ButtonEventQuestion)
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (u *updateButtonSync) UpdataOtherButtonTextXml(systemApp, clickEnter string, carryOutPeople modelshr.PersonArchives, flowOneCont publicmethod.FlowChartList, b *ButtonEventQuestion) {
|
|
defer syncSeting.Done()
|
|
var buttonClickNAme string
|
|
switch clickEnter {
|
|
case "1":
|
|
buttonClickNAme = fmt.Sprintf("%v已批准", carryOutPeople.Name)
|
|
case "3":
|
|
buttonClickNAme = fmt.Sprintf("%v已撤回", carryOutPeople.Name)
|
|
default:
|
|
buttonClickNAme = fmt.Sprintf("%v已驳回", carryOutPeople.Name)
|
|
}
|
|
// wechatOpenID := carryOutPeople.Wechat
|
|
var userOpenId []string
|
|
if len(flowOneCont.UserList) > 0 {
|
|
for _, v := range flowOneCont.UserList {
|
|
if v.Wechat != carryOutPeople.Wechat && v.Wechat != carryOutPeople.WorkWechat && publicmethod.IsInTrue[string](v.Wechat, userOpenId) == false {
|
|
userOpenId = append(userOpenId, v.Wechat)
|
|
}
|
|
}
|
|
}
|
|
// userOpenId = append(userOpenId, "KaiXinGuo")
|
|
if len(userOpenId) > 0 {
|
|
var sendMsgText wechatsendmsg.UpdateButtonNotClickable
|
|
sendMsgText.Userids = userOpenId
|
|
sendMsgText.Atall = 0
|
|
sendMsgText.Agentid = b.Agentid
|
|
sendMsgText.ResponseCode = b.ResponseCode
|
|
sendMsgText.Button.ReplaceName = buttonClickNAme
|
|
callBackCont, err := sendMsgText.UpdateButtonNotClick(systemApp)
|
|
// sendMsgText.UpdateButtonNotClick(systemApp)
|
|
fmt.Printf("10、更新发送信息返回:%v-----------%v----------->%v------》%v\n", callBackCont, err, sendMsgText, buttonClickNAme)
|
|
} else {
|
|
fmt.Printf("\n\n同级没有其他审批人:%v\n\n%v\n\n", carryOutPeople, flowOneCont)
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 16:08:30
|
|
@ 功能: 更新此记录项的所有审批记录为不可操作状态
|
|
@ 参数
|
|
|
|
#orderId 流程Key
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func UpdateLogNotChange(orderId int64) {
|
|
var updateOpenAppChangeLog modelskpi.OpenApprovalChangeLog
|
|
updateOpenAppChangeLog.EiteCont(map[string]interface{}{"`orderid`": orderId}, map[string]interface{}{"`change_is_true`": 2, "eiteyime": time.Now().Unix()})
|
|
}
|
|
|