diff --git a/README.md b/README.md index 01a52f8..26cf3ae 100644 --- a/README.md +++ b/README.md @@ -183,26 +183,27 @@ Time:2022-08-29
CREATE TABLE `post_workflow_orders` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `order_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '审批单ID', - `step` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '当前执行到第几步', - `next_step` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '下一步执行哪个步骤', + `step` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '当前执行到第几步', + `next_step` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '下一步执行哪个步骤', + `count_step` int(5) unsigned NOT NULL DEFAULT '1' COMMENT '总共几步', `work_flow` longtext COMMENT '工作流(审批json字符串)', `company_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '公司', `department_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '部门', `org_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '行政组织', `post_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '岗位', - `class` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '属性1、定性;2、定量', + `class` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '属性1、定性;2、定量', `dimension` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '维度', `target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标', `son_target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标子栏目', `detailed` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标细则', `executor` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人', `executor_department` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人部门', - `state` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '流程状态 1:草稿;2:驳回;3:审批中;4:归档;5:废弃;6:删除', + `state` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '流程状态 1:草稿;2:驳回;3:审批中;4:归档;5:废弃;6:删除', `start_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流程开始时间', `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间', `enclosure_format` longtext COMMENT '附件', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='岗位审批工作流'; + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='岗位审批工作流'; ``` diff --git a/api/shiyan/maptostruct/maptostr.go b/api/shiyan/maptostruct/maptostr.go index 707516d..3caa7fd 100644 --- a/api/shiyan/maptostruct/maptostr.go +++ b/api/shiyan/maptostruct/maptostr.go @@ -1,13 +1,18 @@ package maptostruct import ( + "encoding/xml" "fmt" + "key_performance_indicators/middleware/wechatapp/wechatcallback" + "key_performance_indicators/models/modelshr" + "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" + "time" "github.com/gin-gonic/gin" ) -//map 装 struct 实验 +// map 装 struct 实验 func (a *ApiMethod) MapToStructShiyan(c *gin.Context) { mapShiyan := map[string]string{ "name": "秦东", @@ -26,3 +31,99 @@ func (a *ApiMethod) MapToStructShiyan(c *gin.Context) { fmt.Printf("shiyanType---->%v\n", shiyanVal) publicmethod.Result(0, shiyanVal, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-10-06 11:08:11 +@ 功能: 模拟回调 +@ 参数 + + # + +@ 返回值 + + # +*/ +func (a *ApiMethod) SimulationCallBack(c *gin.Context) { + var receivedValue callBackCont + c.ShouldBindJSON(&receivedValue) + + var jieMiCont wechatcallback.DecryptMsgCont + jieMiCont.MsgSignature = receivedValue.MsgSignature + jieMiCont.Timestamp = receivedValue.Timestamp + jieMiCont.Nonce = receivedValue.Nonce + jieMiCont.ToUsername = receivedValue.ToUsername + jieMiCont.Agentid = receivedValue.Agentid + jieMiCont.Encrypt = receivedValue.Encrypt + decryptMsgCont, jsonErr := jieMiCont.DecryptMsgInfo() + fmt.Printf("Xml----->%v----->%v\n\n", string(decryptMsgCont), jsonErr) + + var msgCont wechatcallback.MsgContentXml + errXml := xml.Unmarshal(decryptMsgCont, &msgCont) + if errXml != nil { + fmt.Printf("回调事件失败!%v\n", errXml) + return + } + fmt.Printf("XmlCont----->%v\n\nwxcptJson----->%v\n\n", string(decryptMsgCont), msgCont) + + switch msgCont.MsgType { + /*消息格式类型 + */ + case "text": //文本 + case "image": //图片 + case "voice": //语音 + case "video": //视频 + case "location": //位置 + wechatcallback.GeographicalPosition(decryptMsgCont) + case "link": //链接 + /*事件格式类型*/ + case "event": + /* + 事件附属格式 + */ + wechatcallback.EventProcessing(decryptMsgCont, jieMiCont, c) + // return + default: + } + + // outData := publicmethod.MapOut[string]() + // outData["Xml"] = string(decryptMsgCont) + // outData["jieMiCont"] = jieMiCont + // outData["jsonErr"] = jsonErr + // outData["msgCont"] = msgCont + // publicmethod.Result(0, outData, c) +} + +// 设置HR系统对接账号和密码 +func (a *ApiMethod) SetUpHrSystem(c *gin.Context) { + var receivedValue hrUsernameAndPassword + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + var hrCont modelshr.EmpowerUser + err = hrCont.GetCont(map[string]interface{}{"`userkey`": receivedValue.Username}, "`id`") + if err == nil { + publicmethod.Result(1, err, c, "该授权已经存在!请不要重复!") + return + } + //密码加密 + var passWordMd5 publicmethod.Md5Encryption + passWordMd5.Md5EncryptionInit(receivedValue.Password) + passWordMd5Str := passWordMd5.Md5EncryptionAlgorithm() + hrCont.UserKey = receivedValue.Username + hrCont.Password = passWordMd5Str + hrCont.Name = receivedValue.Name + hrCont.State = 1 + hrCont.Time = time.Now().Unix() + hrCont.EiteTime = time.Now().Unix() + hrCont.VerificationCode = receivedValue.VerificationCode + err = overall.CONSTANT_DB_HR.Create(&hrCont).Error + if err != nil { + publicmethod.Result(104, err, c) + return + } + publicmethod.Result(0, err, c) +} diff --git a/api/shiyan/maptostruct/type.go b/api/shiyan/maptostruct/type.go index 7125f34..a48f379 100644 --- a/api/shiyan/maptostruct/type.go +++ b/api/shiyan/maptostruct/type.go @@ -8,14 +8,14 @@ import ( type ApiMethod struct{} -//实验入口 +// 实验入口 func (a *ApiMethod) Index(c *gin.Context) { outputCont := publicmethod.MapOut[string]() outputCont["index"] = "实验入口" publicmethod.Result(0, outputCont, c) } -//实验数据 +// 实验数据 type shiyanType struct { Name string `json:"name"` Age int `json:"age"` @@ -24,3 +24,24 @@ type shiyanType struct { Time2 float32 `json:"time2"` Time3 float64 `json:"time3"` } + +// 模拟回调 +type callBackCont struct { + MsgSignature string `json:"msg_signature"` + Timestamp string `json:"timestamp"` + Nonce string `json:"nonce"` + Echostr string `json:"echostr"` + DataType string `json:"datatype"` + SystemApp string `json:"systemapp"` + ToUsername string `json:"ToUserName"` + Agentid uint32 `json:"AgentID"` + Encrypt string `json:"encrypt"` +} + +// Hr username AND password +type hrUsernameAndPassword struct { + Username string `json:"username"` + Password string `json:"password"` + VerificationCode string `json:"verification_code"` + publicmethod.PublicName +} diff --git a/api/version1/flowchart/flow.go b/api/version1/flowchart/flow.go index f68365c..3f497fb 100644 --- a/api/version1/flowchart/flow.go +++ b/api/version1/flowchart/flow.go @@ -253,7 +253,7 @@ func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowPara begin.NodeName = publicmethod.GetSetpName(1) //节点名称 begin.State = 2 //状态 1、不点亮;2、点亮 begin.Class = 1 //节点类型 1、普通节点;2、运行中指定节点 - begin.RunType = 1 //运行状态(1:开始;2:操作点;3:结束) + begin.RunType = 1 //运行状态(1:开始;2:操作点;3:结束;4:抄送) beginUserList := append(begin.UserList, GetApproveUser(founderWechat, founderWechat)) for _, bv := range beginUserList { if isAdd == 1 { @@ -268,7 +268,11 @@ func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowPara isTureCopyMan = append(isTureCopyMan, bv.Id) } } - + var oenStep publicmethod.NodeRelationshipStruct + oenStep.FromNode = 0 + oenStep.ToNode = 2 + oenStep.RejectNode = 0 + begin.NodeRelationship = oenStep flowMap = append(flowMap, begin) //第二步:本部门负责人审批 @@ -299,6 +303,12 @@ func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowPara } } + var twoFlowStep publicmethod.NodeRelationshipStruct + twoFlowStep.FromNode = endStep - 1 + twoFlowStep.ToNode = endStep + 1 + twoFlowStep.RejectNode = 1 + stepTwo.NodeRelationship = twoFlowStep + flowMap = append(flowMap, stepTwo) if qualEvalScheme.Attribute == 1 { @@ -328,6 +338,11 @@ func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowPara } } } + var threeStep publicmethod.NodeRelationshipStruct + threeStep.FromNode = endStep - 1 + threeStep.ToNode = endStep + 1 + threeStep.RejectNode = 1 + stepThree.NodeRelationship = threeStep flowMap = append(flowMap, stepThree) //发起人验收 endStep = endStep + 1 @@ -338,6 +353,11 @@ func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowPara stepFour.Class = 1 stepFour.RunType = 3 stepFour.UserList = append(stepFour.UserList, GetApproveUser(founderWechat, founderWechat)) + var fourStep publicmethod.NodeRelationshipStruct + fourStep.FromNode = endStep - 1 + fourStep.ToNode = endStep + 1 + fourStep.RejectNode = endStep - 1 + stepFour.NodeRelationship = fourStep flowMap = append(flowMap, stepFour) // endStep = 5 } else { @@ -363,8 +383,16 @@ func SetUpWorkFlow(founderWechat string, founderDepartment int64, reviewFlowPara stepCopy.Step = endStep stepCopy.NodeName = publicmethod.GetSetpName(6) stepCopy.State = 1 - stepCopy.Class = 1 + stepCopy.Class = 3 stepCopy.UserList = sendCopyMan + stepCopy.RunType = 4 + + var endFlowStep publicmethod.NodeRelationshipStruct + endFlowStep.FromNode = endStep - 1 + endFlowStep.ToNode = 0 + endFlowStep.RejectNode = 0 + stepCopy.NodeRelationship = endFlowStep + flowMap = append(flowMap, stepCopy) return } diff --git a/api/version1/postseting/postweb/postration.go b/api/version1/postseting/postweb/postration.go index 9050932..f75ff7b 100644 --- a/api/version1/postseting/postweb/postration.go +++ b/api/version1/postseting/postweb/postration.go @@ -10,6 +10,7 @@ import ( "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "strconv" + "strings" "time" "github.com/gin-gonic/gin" @@ -201,7 +202,7 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { overall.CONSTANT_DB_KPI.Model(&modelskpi.PostTarget{}).Select("unit").Where(map[string]interface{}{"`id`": postShemeCont.TargetId}).First(&targetUnit) //获取被考核人基本信息 var userCont modelshr.PersonArchives - err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.PersonLiable}, "`company`", "`maindeparment`", "`admin_org`", "`position`,`wechat`,`work_wechat`") + err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.PersonLiable}, "`company`", "`maindeparment`", "`admin_org`", "`position`", "`wechat`", "`work_wechat`", "`key`") if err != nil { publicmethod.Result(107, err, c) return @@ -244,6 +245,13 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { flowCont.OrderId = uuId //审批单ID"` flowCont.Step = 1 //当前执行到第几步"` flowCont.NextStep = 2 //下一步执行哪个步骤"` + sumStep := len(flowMap) + if sumStep-1 > 0 { + sumStep = sumStep - 1 + } else { + sumStep = 1 + } + flowCont.CountStep = sumStep flowMapJson, _ := json.Marshal(flowMap) flowCont.WorkFlow = string(flowMapJson) //工作流(审批json字符串)"` flowCont.CompanyId = userCont.Company //公司"` @@ -337,12 +345,12 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { var buttonList1 wechatsendmsg.ButtonListCont buttonList1.Text = "批准" buttonList1.Style = 1 - buttonList1.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 1, 1) + buttonList1.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 1, 2) buttonList = append(buttonList, buttonList1) var buttonList2 wechatsendmsg.ButtonListCont buttonList2.Text = "驳回" buttonList2.Style = 3 - buttonList2.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 2, 1) + buttonList2.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 2, 2) buttonList = append(buttonList, buttonList2) //二级标题+文本列表 var twoTitleTextList []wechatsendmsg.HorizontalContentListInfo @@ -372,8 +380,8 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { 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.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 @@ -416,6 +424,8 @@ func (a *ApiMethod) SubmitRationPostCont(c *gin.Context) { openAppChangeLog.ResponseCode = callData.ResponseCode //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"` openAppChangeLog.Stepper = 1 openAppChangeLog.ChangeIsTrue = 1 //是否可变更(1:可变更;2:不可变更)"` + openAppChangeLog.Eiteyime = addTime + openAppChangeLog.YesOrNo = 1 overall.CONSTANT_DB_KPI.Create(&openAppChangeLog) } } diff --git a/api/version1/postseting/postweb/posttarget.go b/api/version1/postseting/postweb/posttarget.go index 3de8d8e..e9bc607 100644 --- a/api/version1/postseting/postweb/posttarget.go +++ b/api/version1/postseting/postweb/posttarget.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "key_performance_indicators/api/version1/flowchart" + "key_performance_indicators/middleware/wechatapp/wechatcallback" "key_performance_indicators/middleware/wechatapp/wechatsendmsg" "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelskpi" @@ -512,7 +513,7 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { } //获取被考核人基本信息 var userCont modelshr.PersonArchives - err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.UserKey}, "`company`", "`maindeparment`", "`admin_org`", "`position`,`wechat`,`work_wechat`") + err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.UserKey}, "`company`", "`maindeparment`", "`admin_org`", "`position`", "`wechat`", "`work_wechat`", "`key`") if err != nil { publicmethod.Result(107, err, c) return @@ -523,30 +524,30 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { if receivedValue.Punishmode == 0 { receivedValue.Punishmode = 1 } - var scoreVal int64 = 0 - var moneyVal int64 = 0 + var scoreVal float64 = 0 + var moneyVal float64 = 0 isTrue := false var msg string switch receivedValue.Punishmode { case 1: - scoreVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.ScoreState, receivedValue.Score, postShemeCont.MaxScore, postShemeCont.MinScore) + scoreVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.ScoreState, receivedValue.Score, float64(postShemeCont.MaxScore), float64(postShemeCont.MinScore)) if isTrue != true { publicmethod.Result(1, isTrue, c, msg) return } case 2: - moneyVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.MoneyState, receivedValue.Money, postShemeCont.Maxmoney, postShemeCont.Minmoney) + moneyVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.MoneyState, receivedValue.Money, float64(postShemeCont.Maxmoney), float64(postShemeCont.Minmoney)) if isTrue != true { publicmethod.Result(1, isTrue, c, msg) return } case 3: - scoreVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.ScoreState, receivedValue.Score, postShemeCont.MaxScore, postShemeCont.MinScore) + scoreVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.ScoreState, receivedValue.Score, float64(postShemeCont.MaxScore), float64(postShemeCont.MinScore)) if isTrue != true { publicmethod.Result(1, isTrue, c, msg) return } - moneyVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.MoneyState, receivedValue.Money, postShemeCont.Maxmoney, postShemeCont.Minmoney) + moneyVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.MoneyState, receivedValue.Money, float64(postShemeCont.Maxmoney), float64(postShemeCont.Minmoney)) if isTrue != true { publicmethod.Result(1, isTrue, c, msg) return @@ -617,6 +618,13 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { flowCont.OrderId = uuId //审批单ID"` flowCont.Step = 1 //当前执行到第几步"` flowCont.NextStep = 2 //下一步执行哪个步骤"` + sumStep := len(flowMap) + if sumStep-1 > 0 { + sumStep = sumStep - 1 + } else { + sumStep = 1 + } + flowCont.CountStep = sumStep flowMapJson, _ := json.Marshal(flowMap) flowCont.WorkFlow = string(flowMapJson) //工作流(审批json字符串)"` flowCont.CompanyId = userCont.Company //公司"` @@ -667,7 +675,8 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { postNatureFlowCont.HappenTime = currentTime //发生时间"` postNatureFlowCont.HappenCount = receivedValue.Count //发生次数"` postNatureFlowCont.Time = time.Now().Unix() //时间"` - + // publicmethod.Result(1, postNatureFlowCont, c, msg) + // return //开启事务提交 gormDbAffair := overall.CONSTANT_DB_KPI.Begin() @@ -774,12 +783,12 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { var buttonList1 wechatsendmsg.ButtonListCont buttonList1.Text = "批准" buttonList1.Style = 1 - buttonList1.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 1, 1) + buttonList1.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 1, 2) buttonList = append(buttonList, buttonList1) var buttonList2 wechatsendmsg.ButtonListCont buttonList2.Text = "驳回" buttonList2.Style = 3 - buttonList2.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 2, 1) + buttonList2.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 2, 2) buttonList = append(buttonList, buttonList2) //二级标题+文本列表 @@ -810,8 +819,8 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { 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.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 @@ -866,6 +875,8 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { openAppChangeLog.ResponseCode = callData.ResponseCode //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"` openAppChangeLog.Stepper = 1 openAppChangeLog.ChangeIsTrue = 1 //是否可变更(1:可变更;2:不可变更)"` + openAppChangeLog.Eiteyime = addTime + openAppChangeLog.YesOrNo = 1 overall.CONSTANT_DB_KPI.Create(&openAppChangeLog) } @@ -888,14 +899,15 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) { @MaxScore 最大值 @minScore 最小值 */ -func judgeScoreOrMoneyIsTrue(scoreState int, score string, maxScore, minScore int64) (scoreInt64 int64, isTrue bool, msg string) { +func judgeScoreOrMoneyIsTrue(scoreState int, score string, maxScore, minScore float64) (scoreInt64 float64, isTrue bool, msg string) { isTrue = false + // fmt.Printf("\n\nscoreState:%v\n\nscore:%v\n\nmaxScore:%v\n\nminScore:%v\n\n", scoreState, score, maxScore, minScore) switch scoreState { case 2, 3: if score == "" { return } - scoreInt64, _ = strconv.ParseInt(score, 10, 64) + scoreInt64, _ = strconv.ParseFloat(score, 64) scoreInt64 = scoreInt64 * 100 if scoreInt64 > maxScore { msg = fmt.Sprintf("您提交的数值超过允许提交的最大值(最大值:%v)!", float64(maxScore)/100) @@ -907,12 +919,661 @@ func judgeScoreOrMoneyIsTrue(scoreState int, score string, maxScore, minScore in } isTrue = true case 1: - scoreInt64, _ = strconv.ParseInt(score, 10, 64) + scoreInt64, _ = strconv.ParseFloat(score, 64) scoreInt64 = scoreInt64 * 100 isTrue = true default: msg = "请您输入要操作的数据,谢谢!" return } + // fmt.Printf("\nscoreInt64:%v\n\nisTrue:%v\n\nmsg:%v\n\n", scoreInt64, isTrue, msg) return } + +// 整改措施 +func (a *ApiMethod) PostRectificationMeasures(c *gin.Context) { + var receivedValue publicmethod.CorrectiveMeasuresType + c.ShouldBindJSON(&receivedValue) + if receivedValue.OrderId == "" || receivedValue.Register == "" || receivedValue.Content == "" { + publicmethod.Result(101, receivedValue, c) + return + } + //判断此号码是否可以使用 + var setUpRegister modelskpi.Register + err := setUpRegister.GetCont(map[string]interface{}{"`number`": receivedValue.Register}, "`state`", "`id`") + if err != nil { + publicmethod.Result(1, err, c, "你们不是此考核项整改的责任人!您无权进行此项操作!") + return + } + if setUpRegister.State != 1 { + publicmethod.Result(1, err, c, "此考核项已经提交过整改方案!") + return + } + syncSeting.Add(1) + go UpdateRegister(setUpRegister.Id, 2) + //获取登录人信息 + context, _ := publicmethod.LoginMyCont(c) + //获取审批流 + var pwoCont modelskpi.PostWorkflowOrders + err = pwoCont.GetCont(map[string]interface{}{"`order_id`": receivedValue.OrderId}) + if err != nil { + publicmethod.Result(1, err, c, "不存在的审批整改项目!") + return + } + if pwoCont.State != 3 { + publicmethod.Result(1, err, c, "此考核项目已经审批结束!请不要重复提交整改措施!") + return + } + if pwoCont.Class == 1 { //定性 + var pnfCont modelskpi.PostNatureFlow + err = pnfCont.GetCont(map[string]interface{}{"`order_id`": receivedValue.OrderId}) + if err != nil { + publicmethod.Result(1, err, c, "不存在的审批整改项目!") + return + } + if pnfCont.PersonLiable != context.Key { + publicmethod.Result(1, err, c, "你们不是此考核项整改的责任人!您无权进行此项操作!") + return + } + + } else { //定量 + var pnfCont modelskpi.PostMeteringFlow + err = pnfCont.GetCont(map[string]interface{}{"`order_id`": receivedValue.OrderId}) + if err != nil { + publicmethod.Result(1, err, c, "不存在的审批整改项目!") + return + } + if pnfCont.PersonLiable != context.Key { + publicmethod.Result(1, err, c, "你们不是此考核项整改的责任人!您无权进行此项操作!") + return + } + } + //提交整改内容 + var addRecMeas modelskpi.RectificationMeasures + addRecMeas.UserKey = context.Key + addRecMeas.Department = context.MainDeparment + addRecMeas.Group = context.Company + addRecMeas.OrderKey = pwoCont.OrderId + addRecMeas.State = 1 + addRecMeas.Time = time.Now().Unix() + addRecMeas.EiteTime = time.Now().Unix() + addRecMeas.Content = receivedValue.Content + if len(receivedValue.Enclosure) > 0 { + enclosure, enclosureErr := json.Marshal(receivedValue.Enclosure) + if enclosureErr == nil { + addRecMeas.Enclosure = string(enclosure) //附件 + } + } + err = overall.CONSTANT_DB_KPI.Create(&addRecMeas).Error + if err != nil { + publicmethod.Result(104, err, c) + return + } + //发送下一步审批信息 + stepIng := pwoCont.NextStep + if stepIng == 0 { + if pwoCont.CountStep-1 > 0 { + stepIng = pwoCont.CountStep - 1 + } else { + stepIng = 1 + } + } + flowMap, flowOneCont, _ := wechatcallback.GetOneNodeCont(pwoCont.WorkFlow, stepIng) //获取流程图 + + nextStep := 0 //下一步执行哪个步骤 + flowState := 3 //判断流程状态 + switch flowOneCont.RunType { + case 1: + flowState = 3 + case 2: + flowState = 3 + case 3: + flowState = 4 + case 4: + flowState = 4 + default: + flowState = 1 + } + //判断下一个当前节点是否为最后一个节点 + if flowState == 4 { + nextStep = 0 + } else { + nextStep = flowOneCont.Step + 1 + } + //更新审批流状态 + syncSeting.Add(1) + go UpdateStateFlow(pwoCont.Id, nextStep, flowState) + //更新审批工作流json内容 + wechatName := context.Wechat + if context.WorkWechat != "" { + wechatName = context.WorkWechat + } + syncSeting.Add(1) + go EidtPostFlowLog(pwoCont.Id, flowMap, flowOneCont, wechatName, 2, stepIng) + + //获取下一个执行点位 + var nextClickStep int + overall.CONSTANT_DB_KPI.Model(&modelskpi.OpenApprovalChangeLog{}).Select("stepper").Where("`orderid` = ?", pwoCont.OrderId).Order("stepper DESC").First(&nextClickStep) + //执行下一步审批 + nextClickStep = nextClickStep + 1 + syncSeting.Add(1) + go ApproveFlow("kpi", flowMap, flowOneCont, nextClickStep, pwoCont) + + var operatorIsTreu modelskpi.OpenApprovalChangeLog + operatorIsTreu.Type = 2 + operatorIsTreu.Title = flowOneCont.NodeName + operatorIsTreu.Operator = context.Key + operatorIsTreu.OrderId = pwoCont.OrderId + operatorIsTreu.OperatorTime = time.Now().Unix() + operatorIsTreu.Step = flowOneCont.Step + operatorIsTreu.OperatorType = 2 + operatorIsTreu.Msgid = "" + operatorIsTreu.ResponseCode = "" + operatorIsTreu.Stepper = nextClickStep + operatorIsTreu.ChangeIsTrue = 2 + operatorIsTreu.YesOrNo = 1 + operatorIsTreu.Eiteyime = time.Now().Unix() + overall.CONSTANT_DB_KPI.Create(&operatorIsTreu) + + syncSeting.Wait() + sendMap := publicmethod.MapOut[string]() + sendMap["flowMap"] = flowMap + sendMap["flowOneCont"] = flowOneCont + publicmethod.Result(0, sendMap, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-10-09 16:48:09 +@ 功能: 更新挂号单 +@ 参数 + + # + +@ 返回值 + + # +*/ +func UpdateRegister(id int64, state int) { + defer syncSeting.Done() + var setUpRegister modelskpi.Register + setUpRegister.EiteCont(map[string]interface{}{"`id`": id}, map[string]interface{}{"`state`": state, "`time`": time.Now().Unix()}) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-10-08 11:20:38 +@ 功能: 同意 +@ 参数 + + #systemApp 系统 + #pwoCont 岗位审批工作流 + #flowMap 流程结构体 + #flowOneCont 当前节点构体 + #step 记录值 + #liangOrXing 属性1、定性;2、定量 + +ApproveFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOneCont publicmethod.FlowChartList, step int, pwoContOld modelskpi.PostWorkflowOrders) +@ 返回值 + + # +*/ +func ApproveFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOneCont publicmethod.FlowChartList, step int, pwoContOld modelskpi.PostWorkflowOrders) { + defer syncSeting.Done() + nextStep := 0 + flowState := 3 //判断流程状态 + switch flowOneCont.RunType { + case 1: + flowState = 3 + case 2: + flowState = 3 + 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 + pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`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>发生时间: %v ", 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>提报人: %v(%v)", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number) + + markDowmStr = fmt.Sprintf("%v\n>\n>[填写整改措施](http://new.hxgk.group/#/rectification?id=%v&num=%v)", markDowmStr, pwoContOld.OrderId, registerNum) + //发送同通信息 + wechatcallback.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) + } + + wechatcallback.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) + } + + wechatcallback.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>被考核人: %v(%v)", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number) + markDowmStr = fmt.Sprintf("%v\n>发生时间: %v ", 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>被考核人: %v(%v)", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number) + + markDowmStr = fmt.Sprintf("%v\n>\n>[查看审批详情](http://new.hxgk.group/#/quantitativeList?id=%v)", markDowmStr, pwoContOld.OrderId) + } + //发送抄送信息 + wechatcallback.SendNoticeMsg(sendToUserList, markDowmStr, systemApp) + } + } + + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-10-09 16:15:56 +@ 功能: 更新审批流 +@ 参数 + + #pwoId 岗位审批工作流ID + #flowMap 流程结构体 + #operatorWechat 操作人 + #clickEnter 操作 + #step 执行的哪一步 + +@ 返回值 + + # +*/ +func EidtPostFlowLog(pwoId int64, flowMap []publicmethod.FlowChartList, oneFlowCont publicmethod.FlowChartList, operatorWechat string, clickEnter, step int) { + defer syncSeting.Done() + var newFlowMap []publicmethod.FlowChartList + for _, v := range flowMap { + var newFlowMapCont publicmethod.FlowChartList + + newFlowMapCont.Step = v.Step //步伐 + newFlowMapCont.NodeName = v.NodeName //节点名称 + newFlowMapCont.Class = v.Class //节点类型 1、普通节点;2、运行中指定节点 + newFlowMapCont.RunType = v.RunType //运行状态(1:开始;2:操作点;3:结束) + newFlowMapCont.NodeRelationship = v.NodeRelationship + if v.Step == oneFlowCont.Step { //获取到当前执行的节点 + + 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()}) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-10-09 16:09:35 +@ 功能: 更新审批状态 +@ 参数 + + #pwoId 审批流ID + #nextStep 下一步 + #flowState 流程状态 + +@ 返回值 + + # +*/ +func UpdateStateFlow(pwoId int64, nextStep, flowState int) { + defer syncSeting.Done() + var pwoCont modelskpi.PostWorkflowOrders + pwoCont.EiteCont(map[string]interface{}{"`id`": pwoId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态 +} diff --git a/api/version1/postseting/postweb/type.go b/api/version1/postseting/postweb/type.go index e973f2a..bd78858 100644 --- a/api/version1/postseting/postweb/type.go +++ b/api/version1/postseting/postweb/type.go @@ -3,12 +3,15 @@ package postweb import ( "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall/publicmethod" + "sync" "github.com/gin-gonic/gin" ) type ApiMethod struct{} +var syncSeting = sync.WaitGroup{} + // 岗位考核WEB端入口 func (a *ApiMethod) Index(c *gin.Context) { outputCont := publicmethod.MapOut[string]() diff --git a/apirouter/apishiyan/maptostruct.go b/apirouter/apishiyan/maptostruct.go index 9ce27ba..b8e12bd 100644 --- a/apirouter/apishiyan/maptostruct.go +++ b/apirouter/apishiyan/maptostruct.go @@ -13,8 +13,11 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { var methodBinding = shiyan.AppApiEntry.MapToStructApi { - apiRouter.GET("", methodBinding.Index) //入口 - apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("maptostructshiyan", methodBinding.MapToStructShiyan) //map转struct + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("maptostructshiyan", methodBinding.MapToStructShiyan) //map转struct + apiRouter.POST("simulationcallback", methodBinding.SimulationCallBack) //模拟回调 + + apiRouter.POST("setuphrsystem", methodBinding.SetUpHrSystem) //设置HR系统对接账号和密码 } } diff --git a/apirouter/v1/postseting/web.go b/apirouter/v1/postseting/web.go index d92db78..86a4703 100644 --- a/apirouter/v1/postseting/web.go +++ b/apirouter/v1/postseting/web.go @@ -15,15 +15,16 @@ func (a *ApiRouter) RouterGroupWeb(router *gin.RouterGroup) { apiRouter.GET("", methodBinding.Index) //入口 apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("getposttarget", methodBinding.GetPostTarget) //获取指定人要考核的项目列表 - apiRouter.POST("getpostnature", methodBinding.GetPostNature) //定性指标列表 - apiRouter.POST("get_post_nature_son_target", methodBinding.GetPostNatureSonTarget) //定性子栏目列表 - apiRouter.POST("getpostration", methodBinding.GetPostRation) //获取定量指标列表 - apiRouter.POST("get_post_deimenso_info", methodBinding.GetPostDeimensoInfo) //获取岗位定性考核指标细则列表 - apiRouter.POST("get_nature_post_dimerons", methodBinding.GetNaturePostDimerons) //获取被考核人定性指标细则详细内容 - apiRouter.POST("send_us_nature_evaluation", methodBinding.SendUsNatureEvaluation) //提交个人岗位定性考核数据 - apiRouter.POST("get_ration_target_cont", methodBinding.GetRationTargetCont) //获取定量考核详细内容 - apiRouter.POST("submit_ration_post_cont", methodBinding.SubmitRationPostCont) //提交定量考核数据 + apiRouter.POST("getposttarget", methodBinding.GetPostTarget) //获取指定人要考核的项目列表 + apiRouter.POST("getpostnature", methodBinding.GetPostNature) //定性指标列表 + apiRouter.POST("get_post_nature_son_target", methodBinding.GetPostNatureSonTarget) //定性子栏目列表 + apiRouter.POST("getpostration", methodBinding.GetPostRation) //获取定量指标列表 + apiRouter.POST("get_post_deimenso_info", methodBinding.GetPostDeimensoInfo) //获取岗位定性考核指标细则列表 + apiRouter.POST("get_nature_post_dimerons", methodBinding.GetNaturePostDimerons) //获取被考核人定性指标细则详细内容 + apiRouter.POST("send_us_nature_evaluation", methodBinding.SendUsNatureEvaluation) //提交个人岗位定性考核数据 + apiRouter.POST("get_ration_target_cont", methodBinding.GetRationTargetCont) //获取定量考核详细内容 + apiRouter.POST("submit_ration_post_cont", methodBinding.SubmitRationPostCont) //提交定量考核数据 + apiRouter.POST("post_rectification_measures", methodBinding.PostRectificationMeasures) //提交整改措施 } } diff --git a/middleware/grocerystore/redis.go b/middleware/grocerystore/redis.go index 1df5c4d..956ff43 100644 --- a/middleware/grocerystore/redis.go +++ b/middleware/grocerystore/redis.go @@ -9,7 +9,7 @@ import ( "github.com/go-redis/redis/v8" ) -//redis 基础设定 +// redis 基础设定 type RedisStoreType struct { Expiration time.Duration PreKey string @@ -17,7 +17,7 @@ type RedisStoreType struct { RedisDb *redis.Client } -//启动redis +// 启动redis func RunRedis(redisClient *redis.Client) *RedisStoreType { var redisStoreType RedisStoreType redisStoreType.Expiration = time.Second * 300 @@ -27,17 +27,17 @@ func RunRedis(redisClient *redis.Client) *RedisStoreType { return &redisStoreType } -//设置键前缀 +// 设置键前缀 func (r *RedisStoreType) SetRedisPrefix(prefix string) { r.PreKey = prefix } -//设置过期时间 +// 设置过期时间 func (r *RedisStoreType) SetRedisTime(timeDate int64) { r.Expiration = time.Second * time.Duration(timeDate) } -//设置字符串 +// 设置字符串 func (r *RedisStoreType) Set(key string, value string) bool { err := r.RedisDb.Set(r.Context, r.PreKey+key, value, r.Expiration).Err() if err != nil { @@ -46,7 +46,7 @@ func (r *RedisStoreType) Set(key string, value string) bool { return true } -//获取字符串 +// 获取字符串 func (r *RedisStoreType) Get(key string) (bool, string) { err := r.RedisDb.Get(r.Context, r.PreKey+key) if err.Err() != nil { @@ -55,7 +55,7 @@ func (r *RedisStoreType) Get(key string) (bool, string) { return true, err.Val() } -//删除键 +// 删除键 func (r *RedisStoreType) DelKey(key string) bool { err := r.RedisDb.Del(r.Context, r.PreKey+key).Err() if err != nil { @@ -122,6 +122,22 @@ func (r *RedisStoreType) HashMsetAdd(hashName string, hashVal map[string]interfa return true } +func (r *RedisStoreType) HashMsetAddinterface(hashName string, hashVal interface{}) bool { + // rdb := RedisInit() + err := r.RedisDb.HMSet(r.Context, r.PreKey+hashName, hashVal).Err() + // fmt.Printf("错误sss=========》%v=====2====》%v\n", err, hashVal) + // err := rdb.HMSet(ctx, "userfg", hashVal).Err() + if err != nil { + return false + } + if r.Expiration == 0 { + r.RedisDb.Persist(r.Context, r.PreKey+hashName) + } else { + r.RedisDb.PExpire(r.Context, r.PreKey+hashName, r.Expiration) + } + + return true +} func (r *RedisStoreType) HashMsetAddAry(hashName string, hashVal []map[string]interface{}) bool { // rdb := RedisInit() err := r.RedisDb.HMSet(r.Context, r.PreKey+hashName, hashVal).Err() @@ -159,7 +175,8 @@ func (r *RedisStoreType) HashGetAll(hashName string) (map[string]string, bool) { //Redis 列表(List) -/** +/* +* Linsert 命令用于在列表的元素前或者后插入元素。当指定元素不存在于列表中时,不执行任何操作。 当列表不存在时,被视为空列表,不执行任何操作。 如果 key 不是列表类型,返回一个错误。 @@ -180,7 +197,8 @@ func (r *RedisStoreType) Linsert(key string, op int, pivot, value interface{}) ( return linsert, true } -/** +/* +* Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 @key 列表 @index 索引 @@ -190,7 +208,8 @@ func (r *RedisStoreType) Lindex(key string, index int64) (val string, err error) return } -/** +/* +* Llen 命令用于返回列表的长度。 如果列表 key 不存在,则 key 被解释为一个空列表,返回 0 。 如果 key 不是列表类型,返回一个错误。 @key 列表 */ @@ -199,7 +218,8 @@ func (r *RedisStoreType) Llen(key string) (val int64, err error) { return } -/** +/* +* Lpop 命令用于移除并返回列表的第一个元素。 @key 列表 */ @@ -208,7 +228,8 @@ func (r *RedisStoreType) Lpop(key string) (val string, err error) { return } -/** +/* +* Lpush 命令将一个或多个值插入到列表头部。 如果 key 不存在,一个空列表会被创建并执行 LPUSH 操作。 当 key 存在但不是列表类型时,返回一个错误。 @key 列表 @value 要插入的字符串 @@ -218,7 +239,8 @@ func (r *RedisStoreType) Lpush(key string, value ...interface{}) (val int64, err return } -/** +/* +* Lpushx 将一个值插入到已存在的列表头部,列表不存在时操作无效。 @key 列表 @value 要插入的字符串 @@ -228,7 +250,8 @@ func (r *RedisStoreType) Lpushx(key, value string) (val int64, err error) { return } -/** +/* +* Lrange 返回列表中指定区间内的元素,区间以偏移量 START 和 END 指定。 其中 0 表示列表的第一个元素, 1 表示列表的第二个元素,以此类推。 你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 @key 列表 @start 起始值 @@ -239,12 +262,15 @@ func (r *RedisStoreType) Lrange(key string, start, stop int64) (val []string, er return } -/** +/* +* Lrem 根据参数 COUNT 的值,移除列表中与参数 VALUE 相等的元素。 COUNT 的值可以是以下几种: + count > 0 : 从表头开始向表尾搜索,移除与 VALUE 相等的元素,数量为 COUNT 。 count < 0 : 从表尾开始向表头搜索,移除与 VALUE 相等的元素,数量为 COUNT 的绝对值。 count = 0 : 移除表中所有与 VALUE 相等的值。 + @start = COUNT @key 列表 */ @@ -253,7 +279,8 @@ func (r *RedisStoreType) Lrem(key string, start int64, value ...interface{}) (va return } -/** +/* +* Redis Lset 通过索引来设置元素的值。 当索引参数超出范围,或对一个空列表进行 LSET 时,返回一个错误。 @@ -265,7 +292,8 @@ func (r *RedisStoreType) Lset(key string, indexes int64, value ...interface{}) ( return } -/** +/* +* Ltrim 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。 下标 0 表示列表的第一个元素,以 1 表示列表的第二个元素,以此类推。 你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 @@ -278,7 +306,8 @@ func (r *RedisStoreType) Ltrim(key string, start, stop int64) (val string, err e return } -/** +/* +* Rpop 命令用于移除列表的最后一个元素,返回值为移除的元素。 @key 列表 */ @@ -287,7 +316,8 @@ func (r *RedisStoreType) Rpop(key string) (val string, err error) { return } -/** +/* +* Rpoplpush 命令用于移除列表的最后一个元素,并将该元素添加到另一个列表并返回。 @sourceKey 源列表 @newKey 目标列表 @@ -297,7 +327,8 @@ func (r *RedisStoreType) Rpoplpush(sourceKey, newKey string) (val string, err er return } -/** +/* +* Rpush 命令用于将一个或多个值插入到列表的尾部(最右边)。 如果列表不存在,一个空列表会被创建并执行 RPUSH 操作。 当列表存在但不是列表类型时,返回一个错误。 @key 列表 @@ -308,7 +339,8 @@ func (r *RedisStoreType) Rpush(key string, value ...interface{}) (val int64, err return } -/** +/* +* Rpushx 命令用于将一个值插入到已存在的列表尾部(最右边)。如果列表不存在,操作无效。 @key 列表 @value 要插入的字符串 @@ -318,7 +350,8 @@ func (r *RedisStoreType) Rpushx(key string, value ...interface{}) (val int64, er return } -/** +/* +* Blpop 命令移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 @key 列表 */ @@ -327,7 +360,8 @@ func (r *RedisStoreType) Blpop(key string) (val []string, err error) { return } -/** +/* +* Brpop 命令移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 @key 列表 */ @@ -336,7 +370,8 @@ func (r *RedisStoreType) Brpop(key string) (val []string, err error) { return } -/** +/* +* Brpoplpush 命令从列表中取出最后一个元素,并插入到另外一个列表的头部; 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 @source 源列表 @destination 目标列表 diff --git a/middleware/wechatapp/wechatcallback/event_processing.go b/middleware/wechatapp/wechatcallback/event_processing.go index e735b72..a46f8e9 100644 --- a/middleware/wechatapp/wechatcallback/event_processing.go +++ b/middleware/wechatapp/wechatcallback/event_processing.go @@ -5,16 +5,34 @@ import ( "encoding/xml" "fmt" "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" ) -// 事件处理 -func EventProcessing(msg []byte, c *gin.Context) { +/* +* +@ 作者: 秦东 +@ 时间: 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) @@ -41,19 +59,22 @@ func EventProcessing(msg []byte, c *gin.Context) { case "share_agent_change": //企业互联共享应用事件回调 case "share_chain_change": //上下游共享应用事件回调 case "template_card_event": //模板卡片事件推送 - TemplateEvent(msg) + TemplateEvent(msg, jieMiCont, c) case "template_card_menu_event": //通用模板卡片右上角菜单事件推送 default: } } // 模板事件处理 -func TemplateEvent(msg []byte) { +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 { @@ -65,7 +86,28 @@ func TemplateEvent(msg []byte) { case "school": default: //默认系统 if eventKeyAry[1] == "post" { + + buttonClickNAme := "已批准" + if eventKeyAry[3] != "1" { + buttonClickNAme = "已驳回" + } + xmlReply := fmt.Sprintf("%v", 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 { //部门考核 } @@ -84,15 +126,19 @@ func TemplateEvent(msg []byte) { @ 参数 #orderId 流程Key - #clickEnter 1:同意;2:驳回 + #clickEnter 0:未操作;1:同意;2:驳回;3:撤回 #systemApp 系统 #step 步进位 + #departmentOrPost 类型(1:部门;2:岗位) + #jieMiCont 解密数据 @ 返回值 # */ -func (b *ButtonEventQuestion) PostTemolateCallBack(orderId, clickEnter, systemApp, step string) { +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}) @@ -144,7 +190,992 @@ func (b *ButtonEventQuestion) PostTemolateCallBack(orderId, clickEnter, systemAp 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 := 2 + 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>发生时间: %v ", 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>提报人: %v(%v)", 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>被考核人: %v(%v)", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number) + } + + nextStep := rejectNode.Step + 1 + var pwoCont modelskpi.PostWorkflowOrders + pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`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 := 3 //判断流程状态 + switch flowOneCont.RunType { + case 1: + flowState = 3 + case 2: + flowState = 3 + 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 + pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`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>发生时间: %v ", 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>提报人: %v(%v)", 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>被考核人: %v(%v)", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number) + markDowmStr = fmt.Sprintf("%v\n>发生时间: %v ", 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>被考核人: %v(%v)", 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("%v", 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()}) } diff --git a/middleware/wechatapp/wechatcallback/response.go b/middleware/wechatapp/wechatcallback/response.go index 4d9716a..ee349ed 100644 --- a/middleware/wechatapp/wechatcallback/response.go +++ b/middleware/wechatapp/wechatcallback/response.go @@ -4,7 +4,11 @@ import ( "encoding/xml" "fmt" "key_performance_indicators/middleware/wechatapp/wechatstatice" + "key_performance_indicators/models/wechatcallback" + "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" + "strconv" + "time" "github.com/gin-gonic/gin" ) @@ -61,6 +65,7 @@ func (a *ApiRouter) CallbackMessageApi(c *gin.Context) { msgStr = basicValueCallback.VerificationUrl() c.String(200, msgStr) } else { + //回调事件 fmt.Printf("回调事件\n") var callBackXmlMsg XmlMsgCont @@ -104,7 +109,7 @@ func (a *ApiRouter) CallbackMessageApi(c *gin.Context) { /* 事件附属格式 */ - EventProcessing(decryptMsgCont, c) + EventProcessing(decryptMsgCont, jieMiCont, c) // return default: } @@ -172,6 +177,37 @@ func (d *DecryptMsgCont) DecryptMsgInfo() (msg []byte, err error) { if cryptErr != nil { err = fmt.Errorf("解密失败1") } - // fmt.Printf("msg:-----------%v\n cryptErr:-----------%v----->all\n\n", string(msg), cryptErr) + + var callbackLog wechatcallback.CallbackLog + callbackLog.MsgSignature = d.MsgSignature + TimestampInt, _ := strconv.ParseInt(d.Timestamp, 10, 64) + callbackLog.TimeStamp = TimestampInt + callbackLog.Nonce = d.Nonce + callbackLog.Echostr = d.Encrypt + callbackLog.Xmlstr = string(msg) + // callbackLog.Reqdata = string(reqData) + callbackLog.AddTime = time.Now().Unix() + overall.CONSTANT_DB_WECHAT_LOG.Create(&callbackLog) + // var decryptMsgCont DecryptMsgCont + // decryptMsgCont.ToUsername = d.ToUsername + // decryptMsgCont.Agentid = d.Agentid + // decryptMsgCont.Encrypt = d.Encrypt + // decryptMsgCont.MsgSignature = d.MsgSignature + // decryptMsgCont.Timestamp = d.Timestamp + // decryptMsgCont.Nonce = d.Nonce + // decryptMsgCont.SystemApp = d.SystemApp + + // msgStr := publicmethod.MapOut[string]() + // jsonDecry, _ := json.Marshal(decryptMsgCont) + // msgStr["DecryptMsgCont"] = string(jsonDecry) // + // msgStr["MsgCont"] = string(msg) + // // jsonStr, _ := json.Marshal(msgStr) + + // //API Token数据 + // redisFileKeyStr := fmt.Sprintf("WorkWechat:CallBack:Xml_%v_%v_%v", d.ToUsername, d.Nonce, d.Agentid) + // redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) + // redisClient.SetRedisTime(86400) + // redisClient.HashMsetAdd(redisFileKeyStr, msgStr) + // fmt.Printf("msg:-----------%v\n cryptErr:-----------%v----->all\n\n", string(jsonDecry), redisFileKeyStr) return } diff --git a/middleware/wechatapp/wechatcallback/type.go b/middleware/wechatapp/wechatcallback/type.go index bcf0f21..1968820 100644 --- a/middleware/wechatapp/wechatcallback/type.go +++ b/middleware/wechatapp/wechatcallback/type.go @@ -1,8 +1,27 @@ package wechatcallback +import "sync" + //企业微信回调 type ApiRouter struct{} +// 协程设置 +var syncSeting = sync.WaitGroup{} +var syncSetingCallback = sync.WaitGroup{} + +// 岗位指标协程操作 +type updateButtonSync struct { + content string `json:"content"` + mutext sync.RWMutex +} + +// 读取岗位指标协程数据 +func (d *updateButtonSync) readDataLock() string { + d.mutext.RLock() + defer d.mutext.RUnlock() + return d.content +} + //企业微信回调基础参数 type CallBackData struct { MsgSignature string `json:"msg_signature"` @@ -28,27 +47,27 @@ type MsgContent struct { //XML 格式回调 type XmlMsgCont struct { - ToUsername string `xml:"ToUserName"` - Agentid uint32 `xml:"AgentID"` - Encrypt string `json:"encrypt"` + ToUsername string `xml:"ToUserName" json:"ToUserName"` + Agentid uint32 `xml:"AgentID" json:"AgentID"` + Encrypt string `xml:"Encrypt" json:"encrypt"` } //通用更新切片 type XmlMsgUpdateCont struct { - ToUsername string `xml:"ToUserName"` - FromUsername string `xml:"FromUserName"` - CreateTime uint32 `xml:"CreateTime"` - MsgType string `xml:"MsgType"` - Agentid uint32 `xml:"AgentID"` - Event string `xml:"Event"` - EventKey string `xml:"EventKey"` + ToUsername string `xml:"ToUserName" json:"ToUserName"` + FromUsername string `xml:"FromUserName" json:"FromUserName"` + CreateTime uint32 `xml:"CreateTime" json:"CreateTime"` + MsgType string `xml:"MsgType" json:"MsgType"` + Agentid uint32 `xml:"AgentID" json:"AgentID"` + Event string `xml:"Event" json:"Event"` + EventKey string `xml:"EventKey" json:"EventKey"` } //XML数据解密 type MsgContentXml struct { XmlMsgUpdateCont - Content string `xml:"Content"` - Msgid string `xml:"MsgId"` + Content string `xml:"Content" json:"Content"` + Msgid string `xml:"MsgId" json:"MsgId"` } //返回消息体解密 @@ -68,21 +87,21 @@ type jsonMsgCont struct { //上报地理位置 type GeographicalPositionType struct { CurrencyMessage - Latitude string `xml:"Latitude"` - Longitude string `xml:"Longitude"` - Precision string `xml:"Precision"` - AppType string `xml:"AppType"` + Latitude string `xml:"Latitude" json:"Latitude"` + Longitude string `xml:"Longitude" json:"Longitude"` + Precision string `xml:"Precision" json:"Precision"` + AppType string `xml:"AppType" json:"AppType"` } //通用更新切片 type CurrencyMessage struct { - ToUsername string `xml:"ToUserName"` - FromUsername string `xml:"FromUserName"` - CreateTime uint32 `xml:"CreateTime"` - MsgType string `xml:"MsgType"` - Agentid uint32 `xml:"AgentID"` - Event string `xml:"Event"` - EventKey string `xml:"EventKey"` + ToUsername string `xml:"ToUserName" json:"ToUserName"` + FromUsername string `xml:"FromUserName" json:"FromUserName"` + CreateTime uint32 `xml:"CreateTime" json:"CreateTime"` + MsgType string `xml:"MsgType" json:"MsgType"` + Agentid uint32 `xml:"AgentID" json:"AgentID"` + Event string `xml:"Event" json:"Event"` + EventKey string `xml:"EventKey" json:"EventKey"` // TaskId string `xml:"TaskId"` } @@ -99,32 +118,50 @@ type GeographicalPositionRedis struct { //模板卡片事件推送 通用 type ButtonEvent struct { - ToUsername string `json:"ToUserName"` - FromUsername string `json:"FromUserName"` - CreateTime uint32 `json:"CreateTime"` - MsgType string `json:"MsgType"` - Event string `xml:"Event"` - EventKey string `xml:"EventKey"` - TaskId string `xml:"TaskId"` - CardType string `xml:"CardType"` - ResponseCode string `xml:"ResponseCode"` - Agentid uint32 `xml:"AgentID"` + ToUsername string `xml:"ToUserName" json:"ToUserName"` + FromUsername string `xml:"FromUserName" json:"FromUserName"` + CreateTime uint32 `xml:"CreateTime" json:"CreateTime"` + MsgType string `xml:"MsgType" json:"MsgType"` + Event string `xml:"Event" json:"Event"` + EventKey string `xml:"EventKey" json:"EventKey"` + TaskId string `xml:"TaskId" json:"TaskId"` + CardType string `xml:"CardType" json:"CardType"` + ResponseCode string `xml:"ResponseCode" json:"ResponseCode"` + Agentid uint32 `xml:"AgentID" json:"AgentID"` } //模板卡片事件推送 问题列表 type ButtonEventQuestion struct { ButtonEvent - SelectedItems []SelectedItemsList `xml:"SelectedItems"` //问题列表 + SelectedItems []SelectedItemsList `xml:"SelectedItems" json:"SelectedItems"` //问题列表 } //问题列表 type SelectedItemsList struct { - SelectedItem []SelectedItemList `xml:"SelectedItem"` + SelectedItem []SelectedItemList `xml:"SelectedItem" json:"SelectedItem"` } type SelectedItemList struct { - QuestionKey string `xml:"QuestionKey"` - OptionIds []OptionIdsStr `xml:"OptionIds"` + QuestionKey string `xml:"QuestionKey" json:"QuestionKey"` + OptionIds []OptionIdsStr `xml:"OptionIds" json:"OptionIds"` } type OptionIdsStr struct { - OptionId string `xml:"OptionId"` + OptionId string `xml:"OptionId" json:"OptionId"` +} + +//回调写入redis +type callBackRedis struct { + DecryptMsgCont string `decrypt_msg_cont` + MsgCont string `msg_cont` +} + +//更新按钮文案 +type UpdateButtonText struct { + ToUserName string `xml:"ToUserName" json:"ToUserName"` + FromUserName string `xml:"FromUserName" json:"FromUserName"` + CreateTime string `xml:"CreateTime" json:"CreateTime"` + MsgType string `xml:"MsgType" json:"MsgType"` + Button UpdateButtonTextCont `xml:"Button" json:"Button"` +} +type UpdateButtonTextCont struct { + ReplaceName string `xml:"ReplaceName" json:"ReplaceName"` } diff --git a/middleware/wechatapp/wechatsendmsg/send_applets_type.go b/middleware/wechatapp/wechatsendmsg/send_applets_type.go index a773f19..c1cb693 100644 --- a/middleware/wechatapp/wechatsendmsg/send_applets_type.go +++ b/middleware/wechatapp/wechatsendmsg/send_applets_type.go @@ -2,7 +2,7 @@ package wechatsendmsg import "key_performance_indicators/middleware/wechatapp/wechatstatice" -//发送markdown消息 +//发送小程序消息 type SendMiniprogramNotice struct { wechatstatice.PublicSendMsgSmaillSub MsgBody MiniprogramNoticeCont `json:"miniprogram_notice"` diff --git a/middleware/wechatapp/wechatsendmsg/send_ordinary_msg.go b/middleware/wechatapp/wechatsendmsg/send_ordinary_msg.go index 3a61520..0a4c5b2 100644 --- a/middleware/wechatapp/wechatsendmsg/send_ordinary_msg.go +++ b/middleware/wechatapp/wechatsendmsg/send_ordinary_msg.go @@ -299,3 +299,29 @@ func (s *SendMultipleInteraction) SendMsg(systemApp string) (callBackCont wechat err = json.Unmarshal(callBackByte, &callBackCont) return } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-10-06 15:21:06 +@ 功能: 更新按钮为不可点击状态 +@ 参数 + + # + +@ 返回值 + + # +*/ +func (u *UpdateButtonNotClickable) UpdateButtonNotClick(systemApp string) (callBackCont wechatstatice.UpdateButtonCallBackMsg, err error) { + sendUrl, _, err := wechatstatice.GetSendMsgTokenUrl(systemApp, "update") + if err != nil { + callBackCont.Errcode = 666666 + callBackCont.Errmsg = "更新失败!" + return + } + sendDate, _ := json.Marshal(u) + callBackByte := publicmethod.CurlPostJosn(sendUrl, sendDate) + err = json.Unmarshal(callBackByte, &callBackCont) + return +} diff --git a/middleware/wechatapp/wechatsendmsg/type.go b/middleware/wechatapp/wechatsendmsg/type.go index 9570c81..012c95e 100644 --- a/middleware/wechatapp/wechatsendmsg/type.go +++ b/middleware/wechatapp/wechatsendmsg/type.go @@ -114,3 +114,25 @@ type SendMarkDown struct { wechatstatice.PublicSendMsg MsgBody TextMsgCont `json:"markdown"` } + +/* +更新模版卡片消息 +*/ +//更新模板卡片通用 +type UpdateTemplateCardCurrency struct { + Userids []string `json:"userids"` //企业的成员ID列表(最多支持1000个) + Partyids []int `json:"partyids"` //企业的部门ID列表(最多支持100个) + Tagids []int `json:"tagids"` //企业的标签ID列表(最多支持100个) + Atall int `json:"atall"` //更新整个任务接收人员 + Agentid uint32 `json:"agentid"` //应用的agentid + ResponseCode string `json:"response_code"` +} + +//更新按钮为不可点击状态 +type UpdateButtonNotClickable struct { + UpdateTemplateCardCurrency + Button ButtonNotClick `json:"button"` +} +type ButtonNotClick struct { + ReplaceName string `json:"replace_name"` +} diff --git a/middleware/wechatapp/wechatstatice/type.go b/middleware/wechatapp/wechatstatice/type.go index 1616d94..b14913d 100644 --- a/middleware/wechatapp/wechatstatice/type.go +++ b/middleware/wechatapp/wechatstatice/type.go @@ -49,3 +49,9 @@ type RevokeMsgSendCallBack struct { Errcode int `json:"errcode"` //返回码 Errmsg string `json:"errmsg"` //对返回码的文本描述内容 } + +//更新模板卡片信息回调 +type UpdateButtonCallBackMsg struct { + RevokeMsgSendCallBack + Invaliduser []string `json:"invaliduser"` //不合法的userid,不区分大小写,统一转为小写 +} diff --git a/models/modelskpi/open_approval_change_log.go b/models/modelskpi/open_approval_change_log.go index 35be927..973e06d 100644 --- a/models/modelskpi/open_approval_change_log.go +++ b/models/modelskpi/open_approval_change_log.go @@ -19,6 +19,8 @@ type OpenApprovalChangeLog struct { ResponseCode string `json:"responsecode" gorm:"column:response_code;type:varchar(255);comment:仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"` Stepper int `json:"stepper" gorm:"column:stepper;type:int(5) unsigned;default:1;not null;comment:步进器"` ChangeIsTrue int `json:"changeistrue" gorm:"column:change_is_true;type:int(1) unsigned;default:1;not null;comment:是否可变更(1:可变更;2:不可变更)"` + Eiteyime int64 `json:"eiteyime" gorm:"column:eiteyime;type:bigint(20) unsigned;default:0;not null;comment:变动时间"` + YesOrNo int `json:"yesorno" gorm:"column:yesorno;type:int(1) unsigned;default:0;not null;comment:0:未操作;1:同意;2:驳回;3:撤回"` } func (OpenApprovalChangeLog *OpenApprovalChangeLog) TableName() string { diff --git a/models/modelskpi/post_nature_flow.go b/models/modelskpi/post_nature_flow.go index 39c19aa..acfc002 100644 --- a/models/modelskpi/post_nature_flow.go +++ b/models/modelskpi/post_nature_flow.go @@ -7,34 +7,34 @@ import ( // 定性考核流水 type PostNatureFlow struct { - Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;autoIncrement;comment:ID"` - OrderId int64 `json:"orderid" gorm:"column:order_id;type:bigint(20) unsigned;default:0;not null;comment:审批单ID"` - AddOrDecrease int `json:"addordecrease" gorm:"column:add_or_decrease;type:tinyint(1) unsigned;default:1;not null;comment:增加或减少(1:增加;2:减少)"` - Score int64 `json:"score" gorm:"column:score;type:bigint(20) unsigned;default:0;not null;comment:分值(*100保存)"` - Money int64 `json:"money" gorm:"column:money;type:bigint(20) unsigned;default:0;not null;comment:钱(扣款或奖励)*100保存"` - Reason string `json:"reason" gorm:"column:reason;type:text;comment:这样操作的原因"` - ShemeId int64 `json:"shemeid" gorm:"column:sheme_id;type:bigint(20) unsigned;default:0;not null;comment:方案ID"` - ShemeVersion string `json:"shemeversion" gorm:"column:sheme_version;type:varchar(255) ;not null;comment:方案版本编号"` - Dimension int64 `json:"dimension" gorm:"column:dimension;type:bigint(20) unsigned;default:0;not null;comment:维度"` - Target int64 `json:"target" gorm:"column:target;type:bigint(20) unsigned;default:0;not null;comment:指标"` - SonTarget int64 `json:"sontarget" gorm:"column:son_target;type:bigint(20) unsigned;default:0;not null;comment:指标子栏目"` - Detailed int64 `json:"detailed" gorm:"column:detailed;type:bigint(20) unsigned;default:0;not null;comment:指标细则"` - Year int64 `json:"year" gorm:"column:year;type:int(7) unsigned;default:0;not null;comment:年"` - Quarter int64 `json:"quarter" gorm:"column:quarter;type:int(3) unsigned;default:0;not null;comment:季度"` - Month int64 `json:"month" gorm:"column:month;type:int(3) unsigned;default:0;not null;comment:月"` - Week int64 `json:"week" gorm:"column:week;type:int(3) unsigned;default:0;not null;comment:周"` - PersonLiable int64 `json:"personliable" gorm:"column:person_liable;type:bigint(20) unsigned;default:0;not null;comment:责任人"` - CompanyId int64 `json:"companyid" gorm:"column:company_id;type:bigint(20) unsigned;default:0;not null;comment:公司"` - DepartmentId int64 `json:"departmentid" gorm:"column:department_id;type:bigint(20) unsigned;default:0;not null;comment:部门"` - OrgId int64 `json:"orgid" gorm:"column:org_id;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` - PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位"` - Executor int64 `json:"executor" gorm:"column:executor;type:bigint(20) unsigned;default:0;not null;comment:执行人"` - ExecutorDepartment int64 `json:"executordepartment" gorm:"column:executor_department;type:bigint(20) unsigned;default:0;not null;comment:执行人部门"` - Rectification int `json:"rectification" gorm:"column:rectification;type:tinyint(1) unsigned;default:2;not null;comment:是否需要整改 1、需要整改;2:无需整改"` - CorrectionTime int64 `json:"correctiontime" gorm:"column:correction_time;type:bigint(20) unsigned;default:0;not null;comment:整改期限"` - HappenTime int64 `json:"happentime" gorm:"column:happen_time;type:bigint(20) unsigned;default:0;not null;comment:发生时间"` - HappenCount int `json:"happencount" gorm:"column:happen_count;type:int(7) unsigned;default:0;not null;comment:发生次数"` - Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:时间"` + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;autoIncrement;comment:ID"` + OrderId int64 `json:"orderid" gorm:"column:order_id;type:bigint(20) unsigned;default:0;not null;comment:审批单ID"` + AddOrDecrease int `json:"addordecrease" gorm:"column:add_or_decrease;type:tinyint(1) unsigned;default:1;not null;comment:增加或减少(1:增加;2:减少)"` + Score float64 `json:"score" gorm:"column:score;type:bigint(20) unsigned;default:0;not null;comment:分值(*100保存)"` + Money float64 `json:"money" gorm:"column:money;type:bigint(20) unsigned;default:0;not null;comment:钱(扣款或奖励)*100保存"` + Reason string `json:"reason" gorm:"column:reason;type:text;comment:这样操作的原因"` + ShemeId int64 `json:"shemeid" gorm:"column:sheme_id;type:bigint(20) unsigned;default:0;not null;comment:方案ID"` + ShemeVersion string `json:"shemeversion" gorm:"column:sheme_version;type:varchar(255) ;not null;comment:方案版本编号"` + Dimension int64 `json:"dimension" gorm:"column:dimension;type:bigint(20) unsigned;default:0;not null;comment:维度"` + Target int64 `json:"target" gorm:"column:target;type:bigint(20) unsigned;default:0;not null;comment:指标"` + SonTarget int64 `json:"sontarget" gorm:"column:son_target;type:bigint(20) unsigned;default:0;not null;comment:指标子栏目"` + Detailed int64 `json:"detailed" gorm:"column:detailed;type:bigint(20) unsigned;default:0;not null;comment:指标细则"` + Year int64 `json:"year" gorm:"column:year;type:int(7) unsigned;default:0;not null;comment:年"` + Quarter int64 `json:"quarter" gorm:"column:quarter;type:int(3) unsigned;default:0;not null;comment:季度"` + Month int64 `json:"month" gorm:"column:month;type:int(3) unsigned;default:0;not null;comment:月"` + Week int64 `json:"week" gorm:"column:week;type:int(3) unsigned;default:0;not null;comment:周"` + PersonLiable int64 `json:"personliable" gorm:"column:person_liable;type:bigint(20) unsigned;default:0;not null;comment:责任人"` + CompanyId int64 `json:"companyid" gorm:"column:company_id;type:bigint(20) unsigned;default:0;not null;comment:公司"` + DepartmentId int64 `json:"departmentid" gorm:"column:department_id;type:bigint(20) unsigned;default:0;not null;comment:部门"` + OrgId int64 `json:"orgid" gorm:"column:org_id;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` + PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位"` + Executor int64 `json:"executor" gorm:"column:executor;type:bigint(20) unsigned;default:0;not null;comment:执行人"` + ExecutorDepartment int64 `json:"executordepartment" gorm:"column:executor_department;type:bigint(20) unsigned;default:0;not null;comment:执行人部门"` + Rectification int `json:"rectification" gorm:"column:rectification;type:tinyint(1) unsigned;default:2;not null;comment:是否需要整改 1、需要整改;2:无需整改"` + CorrectionTime int64 `json:"correctiontime" gorm:"column:correction_time;type:bigint(20) unsigned;default:0;not null;comment:整改期限"` + HappenTime int64 `json:"happentime" gorm:"column:happen_time;type:bigint(20) unsigned;default:0;not null;comment:发生时间"` + HappenCount int `json:"happencount" gorm:"column:happen_count;type:int(7) unsigned;default:0;not null;comment:发生次数"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:时间"` } func (PostNatureFlow *PostNatureFlow) TableName() string { diff --git a/models/modelskpi/post_workflow_orders.go b/models/modelskpi/post_workflow_orders.go index c2ff542..ea107d2 100644 --- a/models/modelskpi/post_workflow_orders.go +++ b/models/modelskpi/post_workflow_orders.go @@ -11,6 +11,7 @@ type PostWorkflowOrders struct { OrderId int64 `json:"orderid" gorm:"column:order_id;type:bigint(20) unsigned;default:0;not null;comment:审批单ID"` Step int `json:"step" gorm:"column:step;type:int(5) unsigned;default:0;not null;comment:当前执行到第几步"` NextStep int `json:"nextstep" gorm:"column:next_step;type:int(5) unsigned;default:0;not null;comment:下一步执行哪个步骤"` + CountStep int `json:"countstep" gorm:"column:count_step;type:int(5) unsigned;default:0;not null;comment:总共几步"` WorkFlow string `json:"workflow" gorm:"column:work_flow;type:longtext;comment:工作流(审批json字符串)"` CompanyId int64 `json:"companyid" gorm:"column:company_id;type:bigint(20) unsigned;default:0;not null;comment:公司"` DepartmentId int64 `json:"departmentid" gorm:"column:department_id;type:bigint(20) unsigned;default:0;not null;comment:部门"` diff --git a/models/modelskpi/rectification_measures.go b/models/modelskpi/rectification_measures.go new file mode 100644 index 0000000..99b2a5b --- /dev/null +++ b/models/modelskpi/rectification_measures.go @@ -0,0 +1,65 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 整改措施 +type RectificationMeasures struct { + Id int64 `json:"id" gorm:"primaryKey;column:rm_id;type:bigint(20) unsigned;not null"` + UserKey int64 `json:"userkey" gorm:"column:rm_user_key;type:bigint(20) unsigned;default:0;not null;comment:整改人"` + Department int64 `json:"department" gorm:"column:rm_department;type:bigint(20) unsigned;default:0;not null;comment:整改部门"` + Group int64 `json:"group" gorm:"column:rm_group;type:bigint(20) unsigned;default:0;not null;comment:集团"` + OrderKey int64 `json:"order" gorm:"column:rm_order;type:bigint(20) unsigned;default:0;not null;comment:订单ID"` + State int `json:"state" gorm:"column:rm_state;type:int(1) unsigned;default:1;not null;comment:1:草果;2:审批中;3:不合格;4:合格"` + Time int64 `json:"time" gorm:"column:rm_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EiteTime int64 `json:"eitetime" gorm:"column:rm_eite_time;type:bigint(20) unsigned;default:0;not null;comment:修改时间"` + Content string `json:"content" gorm:"column:rm_content;type:longtext;comment:整改内容"` + Enclosure string `json:"enclosure" gorm:"column:rm_files;type:longtext;comment:附件"` +} + +func (RectificationMeasures *RectificationMeasures) TableName() string { + return "rectification_measures" +} + +// 编辑内容 +func (cont *RectificationMeasures) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *RectificationMeasures) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *RectificationMeasures) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *RectificationMeasures) ContMap(whereMap interface{}, field ...string) (countAry []RectificationMeasures, err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *RectificationMeasures) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/register.go b/models/modelskpi/register.go new file mode 100644 index 0000000..3e828d1 --- /dev/null +++ b/models/modelskpi/register.go @@ -0,0 +1,65 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 订单挂号 +type Register struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null"` + Number int64 `json:"userkey" gorm:"column:number;type:bigint(20) unsigned;default:0;not null;comment:号码"` + State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:1:正常;2:已经使用"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (Register *Register) TableName() string { + return "register" +} + +// 编辑内容 +func (cont *Register) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Register) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *Register) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Register) ContMap(whereMap interface{}, field ...string) (countAry []Register, err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *Register) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} + +// 添加 +func (cont *Register) AddCont() (err error) { + err = overall.CONSTANT_DB_KPI.Create(&cont).Error + return +} diff --git a/models/wechatcallback/callbacklog.go b/models/wechatcallback/callbacklog.go index 899cf5a..947bcc2 100644 --- a/models/wechatcallback/callbacklog.go +++ b/models/wechatcallback/callbacklog.go @@ -6,7 +6,7 @@ type CallbackLog struct { MsgSignature string `json:"msgSignature" gorm:"column:msg_signature;type:varchar(255);not null;comment:组织名称"` TimeStamp int64 `json:"timestamp" gorm:"column:timestamp;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` Nonce string `json:"nonce" gorm:"column:nonce;type:varchar(255);not null;comment:组织名称"` - Echostr string `json:"echostr" gorm:"column:echostr;type:varchar(255);not null;comment:组织名称"` + Echostr string `json:"echostr" gorm:"column:echostr;type:text;not null;comment:组织名称"` Xmlstr string `json:"xmlstr" gorm:"column:xmlstr;type:text;comment:组织名称"` Jsonstr string `json:"jsonstr" gorm:"column:jsonstr;type:text;comment:组织名称"` AddTime int64 `json:"addtime" gorm:"column:addtime;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go index a615949..1c68dff 100644 --- a/overall/publicmethod/type.go +++ b/overall/publicmethod/type.go @@ -150,12 +150,20 @@ type AuthenticationPower struct { // 流程结构体 type FlowChartList struct { - Step int `json:"step"` //步伐 - NodeName string `json:"nodename"` //节点名称 - State int `json:"state"` //状态 1、不点亮;2、点亮 - Class int `json:"class"` //节点类型 1、普通节点;2、运行中指定节点 - RunType int `json:"runtype"` //运行状态(1:开始;2:操作点;3:结束) - UserList []UserListFlowAll `json:"userlist"` //节点操作人 + Step int `json:"step"` //步伐 + NodeName string `json:"nodename"` //节点名称 + State int `json:"state"` //状态 1、不点亮;2、点亮 + Class int `json:"class"` //节点类型 1、普通节点;2、运行中指定节点;3:抄送节点 + RunType int `json:"runtype"` //运行状态(1:开始;2:操作点;3:结束;4:抄送) + NodeRelationship NodeRelationshipStruct `json:"noderelationship"` //节点关系 + UserList []UserListFlowAll `json:"userlist"` //节点操作人 +} + +// 节点关系 +type NodeRelationshipStruct struct { + FromNode int `json:"fromnode"` // 来源 + ToNode int `json:"tonode"` //去向 + RejectNode int `json:"rejectnode"` //退回 } // 节点操作人 @@ -197,3 +205,13 @@ type roleGroupBodyAry struct { Bfid string `json:"bf_id"` Icons string `json:"icons"` } + +// 改正措施数据提交 +type CorrectiveMeasuresType struct { + OrderId string `json:"orderid"` + Content string `json:"content"` //整改内容 + Register string `json:"register"` //挂号 + // Enclosure []string `json:"enclosure"` //附件 + // Enclosure []EnclosureFormat `json:"enclosure"` //附件 + Enclosure []EnclosureFormat `json:"enclosure"` //附件 +}