From 47ff2ac85ac927d87027d3c0b85fd36050885ed3 Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Mon, 24 Apr 2023 10:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E8=AE=A4=E8=AF=81=E9=80=9A?= =?UTF-8?q?=E8=AE=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/empower/authorize/empower.go | 142 ++++++++++ api/empower/authorize/type.go | 25 +- api/shiyan/maptostruct/cang_chu.go | 19 +- api/shiyan/maptostruct/sendwechat.go | 92 +++++++ .../departmentpc/ding_xing.go | 109 +++++++- .../departmentpc/dingliang.go | 116 +++++++- .../departmentseting/departmentpc/type.go | 13 +- .../departmentweb/department.go | 147 ++++++++++ .../departmentseting/departmentweb/type.go | 34 +++ api/version1/flowchart/entry.go | 24 ++ api/version1/flowchart/myworkflow.go | 4 + api/version1/flowchart/sendmsg.go | 252 ++++++++++++++++++ api/workwechat/entry.go | 39 +++ api/workwechat/message.go | 119 +++++++++ apirouter/apishiyan/maptostruct.go | 6 +- apirouter/empower/apirouter.go | 9 +- apirouter/v1/departmentseting/pc.go | 1 + apirouter/v1/departmentseting/web.go | 8 +- config/configDatabase/database.yaml | 33 ++- models/modelskpi/update_wechat_tempmsg.go | 71 +++++ overall/publicmethod/technique.go | 24 +- overall/publicmethod/type.go | 8 + 22 files changed, 1261 insertions(+), 34 deletions(-) create mode 100644 api/version1/flowchart/sendmsg.go create mode 100644 models/modelskpi/update_wechat_tempmsg.go diff --git a/api/empower/authorize/empower.go b/api/empower/authorize/empower.go index b0bca28..cf23e38 100644 --- a/api/empower/authorize/empower.go +++ b/api/empower/authorize/empower.go @@ -1,10 +1,12 @@ package authorize import ( + "encoding/json" "fmt" "key_performance_indicators/models/modelshr" "key_performance_indicators/overall" "strconv" + "strings" "github.com/gin-gonic/gin" @@ -145,3 +147,143 @@ func (e *EmpowerApi) Encryption(c *gin.Context) { outputCont["step"] = dfg publicmethod.Result(0, outputCont, c) } + +// 写入令牌 +func (a *EmpowerApi) WriteToken(c *gin.Context) { + var requestData WriteIderCont + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Openid == "" || requestData.Key == "" || requestData.Token == "" { + publicmethod.Result(101, err, c) + return + } + if requestData.UserInfo.Number == "" || requestData.UserInfo.Password == "" || requestData.UserInfo.Key == "" { + publicmethod.Result(101, err, c) + return + } + var userCont modelshr.ManCont + err = userCont.GetCont(map[string]interface{}{"`number`": requestData.UserInfo.Number, "`key`": requestData.UserInfo.Key, "`password`": requestData.UserInfo.Password}) + if err != nil { + publicmethod.Result(105, err, c) + return + } + if requestData.Openid != userCont.Wechat && requestData.Openid != userCont.WorkWechat { + publicmethod.Result(105, err, c) + return + } + + _, pointId, operation, _ := publicmethod.GetNewAccredit("cangchu", userCont.Role, userCont.Key, userCont.AdminOrg, userCont.Position) + + saveData := publicmethod.MapOut[string]() + saveData["key"] = requestData.Key + saveData["token"] = requestData.Token + saveData["userinfo"] = userCont + writeRedisData := map[string]interface{}{ + "userkey": requestData.Key, + "key": userCont.Key, + "usernumber": userCont.Number, + "userpwd": userCont.Password, + "usertoken": requestData.Token, + "jurisdiction": operation, + "menuOper": pointId, + "wand": 118, + } + var surisdictionStr []string + var surisdictionInt []int64 + jsonErr := json.Unmarshal([]byte(operation), &surisdictionStr) + if jsonErr == nil { + for _, jurVal := range surisdictionStr { + jurValInt, jurValErr := strconv.ParseInt(jurVal, 10, 64) + if jurValErr == nil { + surisdictionInt = append(surisdictionInt, jurValInt) + } + + } + } + var menuOperStr []string + var menuOperInts []int64 + menuOperStr = strings.Split(pointId, ",") + for _, menuOperVal := range menuOperStr { + menuOperInt, menuOperErr := strconv.ParseInt(menuOperVal, 10, 64) + if menuOperErr == nil { + menuOperInts = append(menuOperInts, menuOperInt) + } + + } + // redisFileKey := "ScanCode:Authentication:LoginApi_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + userKeyCode + redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, requestData.Key) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) + redisClient.SetRedisTime(10800) + redisClient.HashMsetAdd(redisFileKey, writeRedisData) + + //缓存写入个人信息 + redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userCont.Number) + myCont := publicmethod.MapOut[string]() + myCont["id"] = userCont.Id + myCont["number"] = userCont.Number //员工工号 + myCont["name"] = userCont.Name //姓名 + myCont["icon"] = userCont.Icon //头像 + myCont["hireclass"] = userCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;) + myCont["emptype"] = userCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职) + myCont["company"] = userCont.Company //入职公司 + myCont["maindeparment"] = userCont.MainDeparment //主部门 + myCont["sunmaindeparment"] = userCont.SunMainDeparment //二级主部门 + myCont["deparment"] = userCont.Deparment //部门 + myCont["adminorg"] = userCont.AdminOrg //所属行政组织 + myCont["teamid"] = userCont.TeamId //班组 + myCont["position"] = userCont.Position //职位 + myCont["jobclass"] = userCont.JobClass //职务分类 + myCont["jobid"] = userCont.JobId //职务 + myCont["jobleve"] = userCont.JobLeve //职务等级 + myCont["wechat"] = userCont.Wechat //微信UserId + myCont["workwechat"] = userCont.WorkWechat //企业微信UserId + myCont["state"] = userCont.State //状态(1:启用;2:禁用;3:删除) + myCont["key"] = userCont.Key //key + myCont["isadmin"] = userCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管 + myCont["password"] = userCont.Password //密码 + myCont["role"] = userCont.Role //角色 + myCont["idcardno"] = userCont.Idcardno //身份证号 + myCont["passportno"] = userCont.Passportno //护照号码 + myCont["globalroaming"] = userCont.Globalroaming //国际区号 + myCont["mobilephone"] = userCont.Mobilephone //手机号码 + myCont["email"] = userCont.Email //电子邮件 + myCont["gender"] = userCont.Gender //性别(1:男性;2:女性;3:中性) + myCont["birthday"] = userCont.Birthday //birthday + myCont["myfolk"] = userCont.Myfolk //民族 + myCont["nativeplace"] = userCont.Nativeplace //籍贯 + myCont["idcardstartdate"] = userCont.Idcardstartdate //身份证有效期开始 + myCont["idcardenddate"] = userCont.Idcardenddate //身份证有效期结束 + myCont["idcardaddress"] = userCont.Idcardaddress //身份证地址 + myCont["idcardIssued"] = userCont.IdcardIssued //身份证签发机关 + myCont["health"] = userCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废) + myCont["maritalstatus"] = userCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异) + myCont["internaltelephone"] = userCont.Internaltelephone //内线电话 + myCont["currentresidence"] = userCont.Currentresidence //现居住地址 + myCont["constellationing"] = userCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座) + myCont["isdoubleworker"] = userCont.Isdoubleworker //是否双职工(1:是;2:否) + myCont["isveterans"] = userCont.Isveterans //是否为退役军人(1:是;2:否) + myCont["veteransnumber"] = userCont.Veteransnumber //退役证编号 + myCont["jobstartdate"] = userCont.Jobstartdate //参加工作日期 + myCont["entrydate"] = userCont.Entrydate //入职日期 + myCont["probationperiod"] = userCont.Probationperiod //试用期 + myCont["planformaldate"] = userCont.Planformaldate //预计转正日期 + myCont["political_outlook"] = userCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员) + + var companyCont modelshr.AdministrativeOrganization + companyCont.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`") + myCont["companyname"] = companyCont.Name + var departmentCont modelshr.AdministrativeOrganization + departmentCont.GetCont(map[string]interface{}{"`id`": userCont.MainDeparment}, "`name`") + myCont["maindeparmentname"] = departmentCont.Name + var postInfo modelshr.Position + postInfo.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`") + myCont["positionname"] = postInfo.Name + redisClient.HashMsetAdd(redisMyContKey, myCont) + + saveData["usercont"] = myCont + // fmt.Printf("redisMyContKey------Login----->%v\n", redisMyContKey) + publicmethod.Result(0, saveData, c) +} diff --git a/api/empower/authorize/type.go b/api/empower/authorize/type.go index 400c74e..3a11e8e 100644 --- a/api/empower/authorize/type.go +++ b/api/empower/authorize/type.go @@ -8,34 +8,49 @@ import ( type EmpowerApi struct{} -//入口 +// 入口 func (e *EmpowerApi) Index(c *gin.Context) { outputCont := publicmethod.MapOut[string]() outputCont["entry"] = "授权入口" publicmethod.Result(0, outputCont, c) } -//授权 +// 授权 type gainAuthorize struct { UserNumber string `json:"username"` Password string `json:"password"` } -//输出Token +// 输出Token type SendToken struct { Token string `json:"token"` Number string `json:"number"` } -//保存Redis Token +// 保存Redis Token type SaveToken struct { Number string `json:"number"` //随机数 UserKey string `json:"userkey"` //用户名 PassWord string `json:"password"` //密码 } -//加密参数 +// 加密参数 type EncryptionData struct { Number string `json:"number"` AppKey string `json:"appkey"` } + +// 写入身份认证 +type WriteIderCont struct { + Openid string `json:"openid"` + Key string `json:"key"` + Token string `json:"token"` + UserInfo UserInfoCont `json:"userinfo"` +} + +// 人员信息 +type UserInfoCont struct { + Number string `json:"number"` + Password string `json:"password"` + Key string `json:"key"` +} diff --git a/api/shiyan/maptostruct/cang_chu.go b/api/shiyan/maptostruct/cang_chu.go index 2faf34f..c199a32 100644 --- a/api/shiyan/maptostruct/cang_chu.go +++ b/api/shiyan/maptostruct/cang_chu.go @@ -6,6 +6,8 @@ import ( "key_performance_indicators/models/modelsstorage" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" + "strconv" + "strings" "github.com/gin-gonic/gin" ) @@ -190,7 +192,7 @@ func GetMenuThreePeiQuan(parentId int64, threeData []MaterialCont) []CaiDanShu { */ func (a *ApiMethod) CheckOldWorkflow(c *gin.Context) { var oldFlowList []modelskpi.EvaluationProcess - err := overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationProcess{}).Find(&oldFlowList).Error + err := overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationProcess{}).Where("ep_old = 1").Find(&oldFlowList).Error if err == nil { for _, v := range oldFlowList { if v.TypeClass == 1 { @@ -203,6 +205,9 @@ func (a *ApiMethod) CheckOldWorkflow(c *gin.Context) { scoreEdit["ep_target"] = scoreFlowCont.TargetId scoreEdit["ep_detailedtarget"] = scoreFlowCont.DetailedId scoreEdit["ep_creater"] = scoreFlowCont.EvaluationUser + scoreEdit["ep_state"] = 4 + scoreEdit["ep_next_step"] = 0 + scoreEdit["ep_next_executor"] = "" var editDingXingEvalPros modelskpi.EvaluationProcess editDingXingEvalPros.EiteCont(map[string]interface{}{"`ep_id`": v.Id}, scoreEdit) } @@ -213,7 +218,18 @@ func (a *ApiMethod) CheckOldWorkflow(c *gin.Context) { if errSore == nil { scoreEditLiang := publicmethod.MapOut[string]() scoreEditLiang["ep_setup_department"] = dingLiangCont.EvaluationDepartment + var fldId []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.FlowLogData{}).Select("fld_target_id").Where("fld_flow_log = ?", v.OrderKey).Find(&fldId) + var idStr []string + for _, v := range fldId { + vInt := strconv.FormatInt(v, 10) + idStr = append(idStr, vInt) + } + scoreEditLiang["ep_target"] = strings.Join(idStr, ",") scoreEditLiang["ep_creater"] = dingLiangCont.EvaluationUser + scoreEditLiang["ep_state"] = 4 + scoreEditLiang["ep_next_step"] = 0 + scoreEditLiang["ep_next_executor"] = "" var editDingLiangEvalPros modelskpi.EvaluationProcess editDingLiangEvalPros.EiteCont(map[string]interface{}{"`ep_id`": v.Id}, scoreEditLiang) } @@ -221,4 +237,5 @@ func (a *ApiMethod) CheckOldWorkflow(c *gin.Context) { } } } + publicmethod.Result(0, err, c) } diff --git a/api/shiyan/maptostruct/sendwechat.go b/api/shiyan/maptostruct/sendwechat.go index 10c91c8..1a4f0c0 100644 --- a/api/shiyan/maptostruct/sendwechat.go +++ b/api/shiyan/maptostruct/sendwechat.go @@ -1,8 +1,10 @@ package maptostruct import ( + "encoding/json" "fmt" "key_performance_indicators/api/workwechat" + "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "github.com/gin-gonic/gin" @@ -107,6 +109,7 @@ func (a *ApiMethod) SendMessage(c *gin.Context) { outPut := make(map[string]interface{}) outPut["callbackID"] = string(callbackID) outPut["err"] = err + outPut["sendMsg"] = sendMsg publicmethod.Result(0, outPut, c) } @@ -208,3 +211,92 @@ func (a *ApiMethod) UpdateTextMsg(c *gin.Context) { outPut["err"] = err publicmethod.Result(0, outPut, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-23 10:22:02 +@ 功能: 发送迷你文本消息 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) SendMessageMini(c *gin.Context) { + var receivedValue publicmethod.PublicName + c.ShouldBindJSON(&receivedValue) + if receivedValue.Name == "" { + receivedValue.Name = "KaiXinGuo" + } + var sendMsg workwechat.SentMiniMessage + //主题信息 + sendMsg.ToUser = receivedValue.Name + + var templateCard workwechat.TemplateCardMsgContMini + + uuid := publicmethod.GetUUid(5) + //头部左标题部分 + templateCard.Source.Desc = "恒信高科头部信息" + //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成 + templateCard.TaskId = fmt.Sprintf("kpi_ratify_%v", uuid) + templateCard.ActionMenu.Desc = "恒信高科" + var rightHand workwechat.ActionListCont + rightHand.Text = "恒信高科" + rightHand.Key = fmt.Sprintf("kpi_head_%v", publicmethod.GetUUid(7)) + templateCard.ActionMenu.ActionList = append(templateCard.ActionMenu.ActionList, rightHand) + //主内容框 + templateCard.MainTitle.Title = "维度" + // templateCard.MainTitle.Desc = "指标" + //引用文献样式 + // templateCard.QuoteArea.Title = "提报时间:2023-04-23 10:29" + setMsg := fmt.Sprintf("%v\n%v\n%v", "扣除5分", "原因:员工违规操作", "提报时间:2023-04-23 10:29") + templateCard.QuoteArea.QuoteText = setMsg + //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + var hcListCont1 workwechat.HorizontalContentListCont + hcListCont1.Type = 0 + hcListCont1.Keyname = "提报部门:" + hcListCont1.Value = "企管部" + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont1) + var hcListCont3 workwechat.HorizontalContentListCont + hcListCont3.Type = 3 + hcListCont3.Keyname = "提报人:" + hcListCont3.Value = "秦东(300450)" + hcListCont3.UserId = "KaiXinGuo" + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont3) + + //审批详情也米娜 + jumpUrl := fmt.Sprintf("%v/#/pages/approval/departworkflowcont?id=%v", overall.CONSTANT_CONFIG.Appsetup.WebUrl, 2190) + //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + var jmpCont1 workwechat.JumpListCont + jmpCont1.Type = 1 + jmpCont1.Title = "前往处理" + jmpCont1.Url = jumpUrl + templateCard.JumpList = append(templateCard.JumpList, jmpCont1) + //整体卡片的点击跳转事件,text_notice必填本字段 + templateCard.CardAction.Url = jumpUrl + + sendMsg.TemplateCard = templateCard + callbackID, err := sendMsg.InitMes().SendMessage() + + var enforcer []string + enforcer = append(enforcer, receivedValue.Name) + + workwechatErr := workwechat.WriteUpdateWechatTempmsg(callbackID, sendMsg, 1, uuid, enforcer) + + var callbackCont publicmethod.WechatCallBack + json.Unmarshal(callbackID, &callbackCont) + outPut := make(map[string]interface{}) + outPut["callbackID"] = string(callbackID) + outPut["err"] = err + outPut["sendMsg"] = sendMsg + outPut["callbackCont"] = callbackCont + outPut["workwechatErr"] = workwechatErr + publicmethod.Result(0, outPut, c) +} diff --git a/api/version1/departmentseting/departmentpc/ding_xing.go b/api/version1/departmentseting/departmentpc/ding_xing.go index 6524607..7d51b41 100644 --- a/api/version1/departmentseting/departmentpc/ding_xing.go +++ b/api/version1/departmentseting/departmentpc/ding_xing.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "key_performance_indicators/api/workflow/workflowengine" + "key_performance_indicators/api/workwechat" "key_performance_indicators/models/modelshonory" "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelskpi" @@ -456,12 +457,118 @@ func (a *ApiMethod) SubmitQualityAssess(c *gin.Context) { scoreFlowErr := gormDb.Create(&addScoreFlow).Error evalProFlowErr := gormDb.Create(&evalProFlowView).Error flowLogContErr := gormDb.Create(&flowLogCont).Error + var callbackMsg []byte // if scoreFlowErr == nil && evalProFlowErr == nil && flowLogContErr == nil { addErr := gormDb.Commit().Error if addErr == nil { if len(receivedValue.UploadFiles) > 0 { EditFileHandel(uuid, "score_flow", receivedValue.UploadFiles) } + //下一个节点内容 + nextNodeStr := string(nextNodeJson) + if nextNodeStr != "" { //判断下个节点是否为空 + if len(haveWorkflow.NextNodeCont.UserList) > 0 { //判断下个节点是够有审批人 + var recipient []string + for _, v := range haveWorkflow.NextNodeCont.UserList { //获取接收人得微信或企业微信Openid用作发送消息的唯一识别码 + if v.Wechat != "" { + if !publicmethod.IsInTrue[string](v.Wechat, recipient) { + recipient = append(recipient, v.Wechat) + } + } else { + var userCont modelshr.PersonArchives + userCont.GetCont(map[string]interface{}{"`key`": v.Id}, "`wechat`", "`work_wechat`") + if userCont.Wechat != "" { + if !publicmethod.IsInTrue[string](userCont.Wechat, recipient) { + recipient = append(recipient, userCont.Wechat) + } + } + if userCont.WorkWechat != "" { + if !publicmethod.IsInTrue[string](userCont.WorkWechat, recipient) { + recipient = append(recipient, userCont.WorkWechat) + } + } + } + } + if len(recipient) > 0 { //判断是否有接收人 + //开始组装消息内容 + var sendMsg workwechat.SentMiniMessage + sendMsg.ToUser = strings.Join(recipient, "|") //收件人配置 + var templateCard workwechat.TemplateCardMsgContMini //模版卡片主体 + //头部左标题部分 + nodeType := publicmethod.GetSetpNodeName(haveWorkflow.NextNodeCont.Type) + templateCard.Source.Desc = fmt.Sprintf("%v-%v", haveWorkflow.NextNodeCont.NodeName, nodeType) + //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成 + templateCard.TaskId = fmt.Sprintf("kpi_ratify_%v", uuid) + //主内容框 + var dimeCont modelskpi.DutyClass + dimeCont.GetCont(map[string]interface{}{"`id`": qualEvalCont.Dimension}, "`title`") + templateCard.MainTitle.Title = dimeCont.Title + var targetCont modelskpi.EvaluationTarget + targetCont.GetCont(map[string]interface{}{"`et_id`": qualEvalCont.Target}, "`et_title`") + templateCard.MainTitle.Desc = targetCont.Title + //引用文献样式 + var bylawsCont modelskpi.DetailedTarget + bylawsCont.GetCont(map[string]interface{}{"`dt_id`": qualEvalCont.DetailedTarget}, "`dt_title`") + templateCard.QuoteArea.Title = bylawsCont.Title + //1:加分;2:减分"` + var quoteText string + if receivedValue.ScoreFlowCont.Type == 1 { + if receivedValue.ScoreFlowCont.Reason != "" { + quoteText = fmt.Sprintf("奖励: %v 分\n原因:%v\n发生时间:%v", publicmethod.DecimalEs(dingFen/100, 2), receivedValue.ScoreFlowCont.Reason, publicmethod.UnixTimeToDay(occurrenceTime, 12)) + } else { + quoteText = fmt.Sprintf("奖励: %v 分\n发生时间:%v", publicmethod.DecimalEs(dingFen/100, 2), publicmethod.UnixTimeToDay(occurrenceTime, 12)) + } + } else { + if receivedValue.ScoreFlowCont.Reason != "" { + quoteText = fmt.Sprintf("扣除: %v 分\n原因:%v\n发生时间:%v", publicmethod.DecimalEs(dingFen/100, 2), receivedValue.ScoreFlowCont.Reason, publicmethod.UnixTimeToDay(occurrenceTime, 12)) + } else { + quoteText = fmt.Sprintf("扣除: %v 分\n发生时间:%v", publicmethod.DecimalEs(dingFen/100, 2), publicmethod.UnixTimeToDay(occurrenceTime, 12)) + } + } + templateCard.QuoteArea.QuoteText = quoteText + //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + var userRecarCont modelshr.PersonArchives + userRecarCont.GetCont(map[string]interface{}{"`key`": myLoginCont.Key}, "`wechat`", "`work_wechat`", "`maindeparment`") + recipientWechat := userRecarCont.Wechat + if userRecarCont.WorkWechat != "" { + recipientWechat = userRecarCont.WorkWechat + } + var orgContInfo modelshr.AdministrativeOrganization + orgContInfo.GetCont(map[string]interface{}{"`id`": userRecarCont.MainDeparment}, "name") + var hcListCont1 workwechat.HorizontalContentListCont + hcListCont1.Type = 0 + hcListCont1.Keyname = "提报部门:" + hcListCont1.Value = orgContInfo.Name + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont1) + var hcListCont3 workwechat.HorizontalContentListCont + hcListCont3.Keyname = "提报人:" + hcListCont3.Value = fmt.Sprintf("%v(%v)", myLoginCont.Name, myLoginCont.Number) + if recipientWechat != "" { + hcListCont3.Type = 3 + hcListCont3.UserId = recipientWechat + } else { + hcListCont3.Type = 0 + } + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont3) + //审批详情访问地址 + jumpUrl := fmt.Sprintf("%v/#/pages/approval/departworkflowcont?id=%v", overall.CONSTANT_CONFIG.Appsetup.WebUrl, evalProFlowView.Id) + //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + var jmpCont1 workwechat.JumpListCont + jmpCont1.Type = 1 + jmpCont1.Title = "前往处理" + jmpCont1.Url = jumpUrl + templateCard.JumpList = append(templateCard.JumpList, jmpCont1) + //整体卡片的点击跳转事件,text_notice必填本字段 + templateCard.CardAction.Url = jumpUrl + sendMsg.TemplateCard = templateCard + callbackMsg, err = sendMsg.InitMes().SendMessage() + } + } + } + outErr := publicmethod.MapOut[string]() + outErr["addErr"] = addErr + outErr["err"] = err + outErr["callbackMsg"] = string(callbackMsg) publicmethod.Result(0, addErr, c) } else { addErr := gormDb.Rollback().Error @@ -470,11 +577,11 @@ func (a *ApiMethod) SubmitQualityAssess(c *gin.Context) { } else { outErr := publicmethod.MapOut[string]() addErr := gormDb.Rollback().Error - outErr["scoreFlowErr"] = scoreFlowErr outErr["evalProFlowErr"] = evalProFlowErr outErr["flowLogContErr"] = flowLogContErr outErr["addErr"] = addErr + outErr["callbackMsg"] = string(callbackMsg) publicmethod.Result(1014, outErr, c) } diff --git a/api/version1/departmentseting/departmentpc/dingliang.go b/api/version1/departmentseting/departmentpc/dingliang.go index 8e9f56b..658cc35 100644 --- a/api/version1/departmentseting/departmentpc/dingliang.go +++ b/api/version1/departmentseting/departmentpc/dingliang.go @@ -6,6 +6,7 @@ import ( "key_performance_indicators/api/version1/postseting/postweb" "key_performance_indicators/api/workflow/currency_recipe" "key_performance_indicators/api/workflow/workflowengine" + "key_performance_indicators/api/workwechat" "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall" @@ -503,6 +504,7 @@ func (a *ApiMethod) SubmitQuantifyTarget(c *gin.Context) { var allZreoConfigInfo FlowLogAllZreo allZreoConfigInfo.Id = v.Id allZreoConfigInfo.TargetId = v.Target + allZreoConfigInfo.TargetWeight = float64(v.TargetWeight) var qualEvalCont modelskpi.QualitativeEvaluation err := qualEvalCont.GetCont(map[string]interface{}{"`qe_id`": v.Id}, "qe_dimension", "qe_target") @@ -615,7 +617,8 @@ func (a *ApiMethod) SubmitQuantifyTarget(c *gin.Context) { flowAllJson, _ := json.Marshal(flowView) evalProFlowView.Content = string(flowAllJson) //流程步进值"` nextNodeJson, _ := json.Marshal(haveWorkflow.NextNodeCont) - evalProFlowView.NextContent = string(nextNodeJson) //下一步内容"` + nextNodeStr := string(nextNodeJson) + evalProFlowView.NextContent = nextNodeStr //下一步内容"` evalProFlowView.Time = operationTime //创建时间"` evalProFlowView.State = 2 //1:起草,2:审批中;3:通过;4:驳回"` evalProFlowView.RoleGroup = 0 //角色组"` @@ -721,10 +724,119 @@ func (a *ApiMethod) SubmitQuantifyTarget(c *gin.Context) { workFlowLogContErr := gormDb.Create(&workFlowLogCont).Error addFlowDataListErr := gormDb.Create(&addFlowDataList).Error flowLogContErr := gormDb.Create(&flowLogCont).Error + var callbackMsg []byte // + var err error if evalProFlowViewErr == nil && workFlowLogContErr == nil && addFlowDataListErr == nil && flowLogContErr == nil { addErr := gormDb.Commit().Error if addErr == nil { - publicmethod.Result(0, addErr, c) + + //下一个节点内容 + if nextNodeStr != "" { //判断下个节点是否为空 + if len(haveWorkflow.NextNodeCont.UserList) > 0 { //判断下个节点是够有审批人 + var recipient []string //接收人 + for _, v := range haveWorkflow.NextNodeCont.UserList { //获取接收人得微信或企业微信Openid用作发送消息的唯一识别码 + if v.Wechat != "" { + if !publicmethod.IsInTrue[string](v.Wechat, recipient) { + recipient = append(recipient, v.Wechat) + } + } else { + var userCont modelshr.PersonArchives + userCont.GetCont(map[string]interface{}{"`key`": v.Id}, "`wechat`", "`work_wechat`") + if userCont.Wechat != "" { + if !publicmethod.IsInTrue[string](userCont.Wechat, recipient) { + recipient = append(recipient, userCont.Wechat) + } + } + if userCont.WorkWechat != "" { + if !publicmethod.IsInTrue[string](userCont.WorkWechat, recipient) { + recipient = append(recipient, userCont.WorkWechat) + } + } + } + } + if len(recipient) > 0 { //判断是否有接收人 + //开始组装消息内容 + var sendMsg workwechat.SentMiniMessage + sendMsg.ToUser = strings.Join(recipient, "|") //收件人配置 + var templateCard workwechat.TemplateCardMsgContMini //模版卡片主体 + //头部左标题部分 + nodeType := publicmethod.GetSetpNodeName(haveWorkflow.NextNodeCont.Type) + templateCard.Source.Desc = fmt.Sprintf("%v-%v", haveWorkflow.NextNodeCont.NodeName, nodeType) + //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成 + templateCard.TaskId = fmt.Sprintf("kpi_ratify_%v", uuid) + //主内容框 + templateCard.MainTitle.Title = fmt.Sprintf("考核周期:%v", publicmethod.UnixTimeToDay(occurrenceTime, 15)) + //引用文献样式 + var yinYongWenXian []string + for _, v := range receivedValue.List { + if v.ScoringMethod == 1 { + yinYongWenXian = append(yinYongWenXian, fmt.Sprintf("指标:%v\n实际值:%v\n达成率:%v\n得分:%v", v.Targetname, v.Actual, v.Reach, v.ReachScore)) + } else { + var lsZeroprize float64 + var lsAllprize float64 + var lsCapping float64 + for _, cv := range allZreoConfig { + if cv.TargetId == v.Target { + lsZeroprize = cv.Zeroprize + lsAllprize = cv.Allprize + lsCapping = cv.Capping + } + } + actualInt, _ := strconv.ParseInt(v.Actual, 10, 64) + scoreVal, _, _, _, _ := publicmethod.CalculateScore(v.TargetWeight, float64(actualInt)*100, lsAllprize, lsZeroprize, lsCapping, 2) + yinYongWenXian = append(yinYongWenXian, fmt.Sprintf("指标:%v\n实际值:%v\n达成率:%v\n得分:%v\n手动分:%v\n原因:%v", v.Targetname, v.Actual, v.Reach, scoreVal, v.ReachScore, v.Reason)) + } + + } + fmt.Printf("sendMsg->%v\ntemplateCard->%v\nyinYongWenXian->%v\n", sendMsg, templateCard, yinYongWenXian) + templateCard.QuoteArea.QuoteText = strings.Join(yinYongWenXian, "\n") + //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + var userRecarCont modelshr.PersonArchives + userRecarCont.GetCont(map[string]interface{}{"`key`": myLoginCont.Key}, "`wechat`", "`work_wechat`", "`maindeparment`") + recipientWechat := userRecarCont.Wechat + if userRecarCont.WorkWechat != "" { + recipientWechat = userRecarCont.WorkWechat + } + var orgContInfo modelshr.AdministrativeOrganization + orgContInfo.GetCont(map[string]interface{}{"`id`": userRecarCont.MainDeparment}, "name") + var hcListCont1 workwechat.HorizontalContentListCont + hcListCont1.Type = 0 + hcListCont1.Keyname = "提报部门:" + hcListCont1.Value = orgContInfo.Name + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont1) + var hcListCont3 workwechat.HorizontalContentListCont + hcListCont3.Keyname = "提报人:" + hcListCont3.Value = fmt.Sprintf("%v(%v)", myLoginCont.Name, myLoginCont.Number) + if recipientWechat != "" { + hcListCont3.Type = 3 + hcListCont3.UserId = recipientWechat + } else { + hcListCont3.Type = 0 + } + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont3) + //审批详情访问地址 + jumpUrl := fmt.Sprintf("%v/#/pages/approval/departworkflowcont?id=%v", overall.CONSTANT_CONFIG.Appsetup.WebUrl, evalProFlowView.Id) + //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + var jmpCont1 workwechat.JumpListCont + jmpCont1.Type = 1 + jmpCont1.Title = "前往处理" + jmpCont1.Url = jumpUrl + templateCard.JumpList = append(templateCard.JumpList, jmpCont1) + //整体卡片的点击跳转事件,text_notice必填本字段 + templateCard.CardAction.Url = jumpUrl + sendMsg.TemplateCard = templateCard + callbackMsg, err = sendMsg.InitMes().SendMessage() + + var callbackCont publicmethod.WechatCallBack + json.Unmarshal(callbackMsg, &callbackCont) + } + } + } + outErr := publicmethod.MapOut[string]() + outErr["addErr"] = addErr + outErr["err"] = err + outErr["callbackMsg"] = string(callbackMsg) + publicmethod.Result(0, outErr, c) } else { addErr := gormDb.Rollback().Error publicmethod.Result(104, addErr, c) diff --git a/api/version1/departmentseting/departmentpc/type.go b/api/version1/departmentseting/departmentpc/type.go index 30de94b..a386226 100644 --- a/api/version1/departmentseting/departmentpc/type.go +++ b/api/version1/departmentseting/departmentpc/type.go @@ -570,15 +570,18 @@ type RationLogList struct { PlanVersionNumber string `json:"planversionnumber"` //版本号 Addtime string `json:"month"` //检查时间 Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年;7:半年 + Reach string `json:"reach"` //达成率 + } // 定量流水全奖值、零奖值、封顶值 type FlowLogAllZreo struct { - Id string `json:"id"` - TargetId string `json:"targetid"` //指标ID` - Zeroprize float64 `json:"zeroprize"` //零奖值"` - Allprize float64 `json:"allprize"` //全奖值"` - Capping float64 `json:"capping"` //封顶值"` + Id string `json:"id"` + TargetId string `json:"targetid"` //指标ID` + Zeroprize float64 `json:"zeroprize"` //零奖值"` + Allprize float64 `json:"allprize"` //全奖值"` + Capping float64 `json:"capping"` //封顶值"` + TargetWeight float64 `json:"targetweight"` //封顶值"` } // 输出方案项目列表 diff --git a/api/version1/departmentseting/departmentweb/department.go b/api/version1/departmentseting/departmentweb/department.go index 1dc18d5..8760826 100644 --- a/api/version1/departmentseting/departmentweb/department.go +++ b/api/version1/departmentseting/departmentweb/department.go @@ -1629,3 +1629,150 @@ func (g *GeteveryYearDttsb) GetOrgMoreTimeScore(orgCont modelshr.AdministrativeO // fmt.Printf("获取:%v------------------>%v------------------>%v------------------>scoreList:%v------------------>maxScore:%v---------------->minSchor:%v\n", orgCont.Name, years, months, scoreList, maxScore, minSchor) SyncSetinges.Done() } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-21 16:30:26 +@ 功能: 相关提报人定性考核细则列表(web使用) +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GetQualityBylawsTasks(c *gin.Context) { + var receivedValue BylawsAboutPeopleDime + c.ShouldBindJSON(&receivedValue) + if receivedValue.OrgId == "" || receivedValue.TargetId == "" { + publicmethod.Result(101, receivedValue, c) + return + } + + //获取登录人信息 + myLoginCont, _ := publicmethod.LoginMyCont(c) + var qualEvaCont modelskpi.QualitativeEvaluationView + gormDb := overall.CONSTANT_DB_KPI.Table(fmt.Sprintf("%s qe", qualEvaCont.TableName())).Select("qe.qe_id,qe.qe_target_sun,qe.qe_detailed_target,qe.qe_content,qe.qe_censor_cont,qe.qe_min_score,qe.qe_max_score,qe.qe_unit,qe.qe_target_sun").Where("qe.`qe_type` = 1 AND qe.`qe_state` = 1 AND qe.`qe_accept_evaluation` = ? AND qe.`qe_target` = ?", receivedValue.OrgId, receivedValue.TargetId) + gormDb = gormDb.Joins("JOIN target_report td ON qe.qe_target = td.target_id AND qe.qe_accept_evaluation = td.`department_id` AND td.target_bylaws = qe.`qe_detailed_target` AND td.`type` = 1 AND td.`post_id` = 0 AND td.state = 1 AND td.type_level = 3 AND td.`man_key` = ?", myLoginCont.Key) + // if receivedValue.OrgId != "" { + // gormDb = gormDb.Where("`qe_accept_evaluation` = ?", receivedValue.OrgId) + // } + var qualEvaList []modelskpi.QualitativeEvaluationView + err := gormDb.Order("qe_accept_evaluation ASC,qe_target ASC").Find(&qualEvaList).Error + if err != nil { + publicmethod.Result(105, err, c) + return + } + var tableId []int64 + var sendContList []OutDimList + for _, v := range qualEvaList { + if !publicmethod.IsInTrue[int64](v.TargetSun, tableId) { + tableId = append(tableId, v.TargetSun) + var sendCont OutDimList + sendCont.Id = strconv.FormatInt(v.TargetSun, 10) + var tableCont modelskpi.QualitativeTarget + tableCont.GetCont(map[string]interface{}{"q_id": v.TargetSun}, "q_title") + sendCont.Name = tableCont.Title + sendCont.OrgId = receivedValue.OrgId + sendCont.TargetId = receivedValue.TargetId + sendContList = append(sendContList, sendCont) + } + } + publicmethod.Result(0, sendContList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-22 08:22:01 +@ 功能: 根据栏目获取获取相关指标 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) BasePostTableHaveTarget(c *gin.Context) { + var receivedValue BaseTableGetTargetWeb + c.ShouldBindJSON(&receivedValue) + if receivedValue.OrgId == "" || receivedValue.TargetId == "" { + publicmethod.Result(101, receivedValue, c) + return + } + if receivedValue.Page == 0 { + receivedValue.Page = 1 + } + if receivedValue.PageSize == 0 { + receivedValue.PageSize = 15 + } + //获取登录人信息 + myLoginCont, _ := publicmethod.LoginMyCont(c) + var qualEvaCont modelskpi.QualitativeEvaluationView + gormDb := overall.CONSTANT_DB_KPI.Table(fmt.Sprintf("%s qe", qualEvaCont.TableName())).Select("qe.qe_id,qe.qe_target_sun,qe.qe_detailed_target,qe.qe_content,qe.qe_censor_cont,qe.qe_min_score,qe.qe_max_score,qe.qe_unit").Where("qe.`qe_type` = 1 AND qe.`qe_state` = 1 AND qe.`qe_accept_evaluation` = ? AND qe.`qe_target` = ? AND qe.`qe_target_sun` = ?", receivedValue.OrgId, receivedValue.TargetId, receivedValue.TableId) + gormDb = gormDb.Joins("JOIN target_report td ON qe.qe_target = td.target_id AND qe.qe_accept_evaluation = td.`department_id` AND td.target_bylaws = qe.`qe_detailed_target` AND td.`type` = 1 AND td.`post_id` = 0 AND td.state = 1 AND td.type_level = 3 AND td.`man_key` = ?", myLoginCont.Key) + + var total int + var qualEvaListCount []modelskpi.QualitativeEvaluationView + totalErr := gormDb.Find(&qualEvaListCount).Error + if totalErr != nil { + total = 0 + } else { + total = len(qualEvaListCount) + } + var qualEvaList []modelskpi.QualitativeEvaluationView + gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize) + err := gormDb.Order("qe_accept_evaluation ASC,qe_target ASC").Find(&qualEvaList).Error + if err != nil { + publicmethod.Result(105, err, c) + return + } + var sendContList []OutPutBylawsCont + for _, v := range qualEvaList { + var sendCont OutPutBylawsCont + sendCont.Id = strconv.FormatInt(v.Id, 10) + var bylawsCont modelskpi.DetailedTarget + bylawsCont.GetCont(map[string]interface{}{"`dt_id`": v.DetailedTarget}, "`dt_title`", "`dt_content`", `dt_add_reduce`) + var columnCont modelskpi.QualitativeTarget + columnCont.GetCont(map[string]interface{}{"`q_id`": v.TargetSun}, "`q_title`") + sendCont.ColumnTitle = columnCont.Title + sendCont.Title = bylawsCont.Title //考核项目 + sendCont.Content = bylawsCont.Content //考核内容 + if v.Content != "" { + sendCont.Content = v.Content + } + if v.CensorCont != "" { + sendCont.Content = v.CensorCont + } + sendCont.MaxScore = publicmethod.DecimalEs(float64(v.MaxScore)/100, 2) + sendCont.MinScore = publicmethod.DecimalEs(float64(v.MinScore)/100, 2) + if sendCont.MinScore > 0 && sendCont.MaxScore > 0 { + sendCont.Standard = fmt.Sprintf("%v-%v", sendCont.MinScore, sendCont.MaxScore) //标准 + sendCont.ScoreType = 2 + } else if sendCont.MinScore > 0 && sendCont.MaxScore <= 0 { + sendCont.Standard = fmt.Sprintf("%v", sendCont.MinScore) + sendCont.ScoreType = 1 + } else if sendCont.MinScore <= 0 && sendCont.MaxScore > 0 { + sendCont.Standard = fmt.Sprintf("%v", sendCont.MaxScore) + sendCont.ScoreType = 1 + } else { + sendCont.Standard = "0" + sendCont.ScoreType = 3 + } + sendCont.Unit = v.Unit //单位 + sendCont.PlusMinusScore = bylawsCont.AddReduce //加减分 + sendContList = append(sendContList, sendCont) + } + publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, int64(total), int64(len(sendContList)), sendContList, c) +} diff --git a/api/version1/departmentseting/departmentweb/type.go b/api/version1/departmentseting/departmentweb/type.go index a0fe6c5..fe8a780 100644 --- a/api/version1/departmentseting/departmentweb/type.go +++ b/api/version1/departmentseting/departmentweb/type.go @@ -223,3 +223,37 @@ type BaseDepartTimeYOY struct { OrgId string `json:"orgid"` //行政组织 DateTime []int `json:"datetime"` //时间 } + +// 相关提报人定性考核细则 +type BylawsAboutPeopleDime struct { + OrgId string `json:"orgid"` //行政组织Id + TargetId string `json:"targetid"` //指标Id +} + +// 输出栏目 +type OutDimList struct { + publicmethod.PublicId + publicmethod.PublicName + BylawsAboutPeopleDime +} + +// 根据栏目获取获取相关指标 +type BaseTableGetTargetWeb struct { + publicmethod.PagesTurn + BylawsAboutPeopleDime + TableId string `json:"tableid"` //栏目Id +} + +// 输出相关考核项目 +type OutPutBylawsCont struct { + publicmethod.PublicId //项目ID + ColumnTitle string `json:"columntitle"` //栏目名称 + Title string `json:"title"` //考核项目 + Content string `json:"content"` //考核内容 + Standard string `json:"standard"` //标准 + Unit string `json:"unit"` //单位 + PlusMinusScore int `json:"plusminusscore"` //加减分 + ScoreType int `json:"scoretype"` //1、定分;2、区间分;3、不定性分值 + MaxScore float64 `json:"maxscore"` //最大分 + MinScore float64 `json:"minscore"` //最小分 +} diff --git a/api/version1/flowchart/entry.go b/api/version1/flowchart/entry.go index 061f413..c80d6bc 100644 --- a/api/version1/flowchart/entry.go +++ b/api/version1/flowchart/entry.go @@ -265,3 +265,27 @@ type DesignatedOperatorCont struct { IsTrue bool `json:"isTrue"` UserList []currency_recipe.UserListFlowAll `json:"userlist"` //节点操作人 } + +// 返回发送消息数据 +type CallBackSendMsgCont struct { + DimeContTitle string + TargetContTitle string + BylawsContTitle string + QuoteText string +} + +// 返回发送消息数据 +type CallBackSendMsgContLiang struct { + OccurrenceTime string + QuoteText string +} + +// 定量流水全奖值、零奖值、封顶值 +type FlowLogAllZreo struct { + Id string `json:"id"` + TargetId string `json:"targetid"` //指标ID` + Zeroprize float64 `json:"zeroprize"` //零奖值"` + Allprize float64 `json:"allprize"` //全奖值"` + Capping float64 `json:"capping"` //封顶值"` + TargetWeight int64 `json:"targetweight"` //封顶值"` +} diff --git a/api/version1/flowchart/myworkflow.go b/api/version1/flowchart/myworkflow.go index 13d8e18..21dea99 100644 --- a/api/version1/flowchart/myworkflow.go +++ b/api/version1/flowchart/myworkflow.go @@ -785,6 +785,8 @@ func (w *WorkFlowRuning) ProcessOperation() { userCarrLog.Enclosure = w.Enclosure //附件 w.List[i].UserList[ui].LogList = append(w.List[i].UserList[ui].LogList, userCarrLog) } + msgkkk, ksgEr := SendTogetherMsg(w.OrderKey, v, 1) + fmt.Printf("ProcessOperation--->%v\n--->%v\n", msgkkk, ksgEr) //是抄送节点 w.ProcessOperation() return @@ -903,6 +905,8 @@ func (w *WorkFlowRuning) NodeYes(total int) { } w.NextNodeCont = v w.NextExecutor = nextZhiXingRen + msgkkk, ksgEr := SendTogetherMsg(w.OrderKey, v, 1) + fmt.Printf("NodeYes--->%v\n--->%v\n", msgkkk, ksgEr) if writeLog { w.RunNode = v w.WriteFlowLog() diff --git a/api/version1/flowchart/sendmsg.go b/api/version1/flowchart/sendmsg.go new file mode 100644 index 0000000..e37e666 --- /dev/null +++ b/api/version1/flowchart/sendmsg.go @@ -0,0 +1,252 @@ +package flowchart + +import ( + "encoding/json" + "fmt" + "key_performance_indicators/api/workflow/currency_recipe" + "key_performance_indicators/api/workwechat" + "key_performance_indicators/models/modelshr" + "key_performance_indicators/models/modelskpi" + "key_performance_indicators/overall" + "key_performance_indicators/overall/publicmethod" + "strconv" + "strings" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-23 14:29:55 +@ 功能: 统一发送信息 +@ 参数 + + #orderId 审批记录编号 + #nodeCont 节点内容 + #operate 操作(1:通过;2:驳回;3:抄送) + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func SendTogetherMsg(orderId int64, nodeCont currency_recipe.NodeCont, operate int) (callbackMsgStr string, err error) { + if orderId == 0 { + return + } + if len(nodeCont.UserList) <= 0 { + return + } + var recipient []string //接收人 + for _, v := range nodeCont.UserList { //获取接收人得微信或企业微信Openid用作发送消息的唯一识别码 + if v.Wechat != "" { + if !publicmethod.IsInTrue[string](v.Wechat, recipient) { + recipient = append(recipient, v.Wechat) + } + } else { + var userCont modelshr.PersonArchives + userCont.GetCont(map[string]interface{}{"`key`": v.Id}, "`wechat`", "`work_wechat`") + if userCont.Wechat != "" { + if !publicmethod.IsInTrue[string](userCont.Wechat, recipient) { + recipient = append(recipient, userCont.Wechat) + } + } + if userCont.WorkWechat != "" { + if !publicmethod.IsInTrue[string](userCont.WorkWechat, recipient) { + recipient = append(recipient, userCont.WorkWechat) + } + } + } + } + if len(recipient) <= 0 { + return + } + var workflowCont modelskpi.EvaluationProcess + err = workflowCont.GetCont(map[string]interface{}{"ep_order_key": orderId}) + if err != nil { + return + } + //开始组装消息内容 + var sendMsg workwechat.SentMiniMessage + sendMsg.ToUser = strings.Join(recipient, "|") //收件人配置 + var templateCard workwechat.TemplateCardMsgContMini //模版卡片主体 + //头部左标题部分 + nodeType := publicmethod.GetSetpNodeName(nodeCont.Type) + templateCard.Source.Desc = fmt.Sprintf("%v-%v", nodeCont.NodeName, nodeType) + //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成 + uuid := publicmethod.GetUUid(7) //上报数据唯一识别码 + templateCard.TaskId = fmt.Sprintf("kpi_ratify_%v", uuid) + if workflowCont.TypeClass == 1 { //定性操作 + msgCont, errs := SendMsgDingXing(orderId) + if errs != nil { + return + } + templateCard.MainTitle.Title = msgCont.DimeContTitle + templateCard.MainTitle.Desc = msgCont.TargetContTitle + templateCard.QuoteArea.Title = msgCont.BylawsContTitle + templateCard.QuoteArea.QuoteText = msgCont.QuoteText + } else { //定量操作 + msgCont, errs := SendMsgDingLiang(workflowCont) + if errs != nil { + return + } + templateCard.MainTitle.Title = msgCont.OccurrenceTime + templateCard.QuoteArea.QuoteText = msgCont.QuoteText + } + //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + var userRecarCont modelshr.PersonArchives + userRecarCont.GetCont(map[string]interface{}{"`key`": workflowCont.Creater}, "`number`", "`name`", "`wechat`", "`work_wechat`", "`maindeparment`") + recipientWechat := userRecarCont.Wechat + if userRecarCont.WorkWechat != "" { + recipientWechat = userRecarCont.WorkWechat + } + var orgContInfo modelshr.AdministrativeOrganization + orgContInfo.GetCont(map[string]interface{}{"`id`": userRecarCont.MainDeparment}, "name") + var hcListCont1 workwechat.HorizontalContentListCont + hcListCont1.Type = 0 + hcListCont1.Keyname = "提报部门:" + hcListCont1.Value = orgContInfo.Name + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont1) + var hcListCont3 workwechat.HorizontalContentListCont + hcListCont3.Keyname = "提报人:" + hcListCont3.Value = fmt.Sprintf("%v(%v)", userRecarCont.Name, userRecarCont.Number) + if recipientWechat != "" { + hcListCont3.Type = 3 + hcListCont3.UserId = recipientWechat + } else { + hcListCont3.Type = 0 + } + templateCard.HorizontalContentList = append(templateCard.HorizontalContentList, hcListCont3) + //审批详情访问地址 + jumpUrl := fmt.Sprintf("%v/#/pages/approval/departworkflowcont?id=%v", overall.CONSTANT_CONFIG.Appsetup.WebUrl, workflowCont.Id) + //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 + var jmpCont1 workwechat.JumpListCont + jmpCont1.Type = 1 + jmpCont1.Title = "前往处理" + jmpCont1.Url = jumpUrl + templateCard.JumpList = append(templateCard.JumpList, jmpCont1) + //整体卡片的点击跳转事件,text_notice必填本字段 + templateCard.CardAction.Url = jumpUrl + sendMsg.TemplateCard = templateCard + callbackMsg, err := sendMsg.InitMes().SendMessage() + callbackMsgStr = string(callbackMsg) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-23 15:09:41 +@ 功能: +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func SendMsgDingLiang(workflowCont modelskpi.EvaluationProcess) (msgCont CallBackSendMsgContLiang, err error) { + msgCont.OccurrenceTime = fmt.Sprintf("考核周期:%v", publicmethod.UnixTimeToDay(workflowCont.HappenTime, 15)) + var flowLogCont modelskpi.FlowLog + err = flowLogCont.GetCont(map[string]interface{}{"fl_key": workflowCont.OrderKey}, "fl_baseline") + if err != nil { + return + } + var allZreoConfig []FlowLogAllZreo + json.Unmarshal([]byte(flowLogCont.Baseline), &allZreoConfig) + var flogDataList []modelskpi.FlowLogData + err = overall.CONSTANT_DB_KPI.Where("fld_flow_log = ?", workflowCont.OrderKey).Find(&flogDataList).Error + if err != nil || len(flogDataList) < 1 { + return + } + var yinYongWenXian []string + for _, v := range flogDataList { + var targetCont modelskpi.EvaluationTarget + targetCont.GetCont(map[string]interface{}{"`et_id`": v.TargetId}, "`et_id`", "`et_title`") + + var lsZeroprize float64 + var lsAllprize float64 + var lsCapping float64 + var targetWeight int64 + for _, cv := range allZreoConfig { + tarStrId := strconv.FormatInt(v.TargetId, 10) + if cv.TargetId == tarStrId { + lsZeroprize = cv.Zeroprize + lsAllprize = cv.Allprize + lsCapping = cv.Capping + targetWeight = cv.TargetWeight + } + } + + scoreVal, _, _, _, _ := publicmethod.CalculateScore(targetWeight, float64(v.Score), lsAllprize, lsZeroprize, lsCapping, 2) + if v.ScoringMethod == 1 { + yinYongWenXian = append(yinYongWenXian, fmt.Sprintf("指标:%v\n实际值:%v\n达成率:%v\n得分:%v", targetCont.Title, publicmethod.DecimalEs(float64(v.Score)/100, 2), v.Content, scoreVal)) + } else { + + yinYongWenXian = append(yinYongWenXian, fmt.Sprintf("指标:%v\n实际值:%v\n达成率:%v\n得分:%v\n手动分:%v\n原因:%v", targetCont.Title, publicmethod.DecimalEs(float64(v.Score)/100, 2), v.Content, scoreVal, publicmethod.DecimalEs(float64(v.ScoringScore)/100, 2), v.Content)) + } + + } + msgCont.QuoteText = strings.Join(yinYongWenXian, "\n") + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-23 15:07:43 +@ 功能: 定性操作 +@ 参数 + + #orderId 流程ID + +@ 返回值 + + #msgCont 返回值 + #err 错误信息 + +@ 方法原型 + + #func SendMsgDingXing(orderId int64) (msgCont CallBackSendMsgCont, err error) +*/ +func SendMsgDingXing(orderId int64) (msgCont CallBackSendMsgCont, err error) { + var scoreFlowCont modelskpi.ScoreFlow + err = scoreFlowCont.GetCont(map[string]interface{}{"sf_key": orderId}) + if err != nil { + //指标 + var targetCont modelskpi.EvaluationTarget + targetCont.GetCont(map[string]interface{}{"`et_id`": scoreFlowCont.TargetId}, "`et_id`", "`et_title`") + msgCont.TargetContTitle = targetCont.Title + var dimeCont modelskpi.DutyClass + dimeCont.GetCont(map[string]interface{}{"`id`": targetCont.Id}, "`title`") + msgCont.DimeContTitle = dimeCont.Title + var bylawsCont modelskpi.DetailedTarget + bylawsCont.GetCont(map[string]interface{}{"`dt_id`": scoreFlowCont.DetailedId}, "`dt_title`") + msgCont.BylawsContTitle = bylawsCont.Title + + //1:加分;2:减分"` + if scoreFlowCont.PlusReduceScore == 1 { + if scoreFlowCont.Reason != "" { + msgCont.QuoteText = fmt.Sprintf("奖励: %v 分\n原因:%v\n发生时间:%v", publicmethod.DecimalEs(float64(scoreFlowCont.Score)/100, 2), scoreFlowCont.Reason, publicmethod.UnixTimeToDay(scoreFlowCont.HappenTime, 12)) + } else { + msgCont.QuoteText = fmt.Sprintf("奖励: %v 分\n发生时间:%v", publicmethod.DecimalEs(float64(scoreFlowCont.Score)/100, 2), publicmethod.UnixTimeToDay(scoreFlowCont.HappenTime, 12)) + } + } else { + if scoreFlowCont.Reason != "" { + msgCont.QuoteText = fmt.Sprintf("扣除: %v 分\n原因:%v\n发生时间:%v", publicmethod.DecimalEs(float64(scoreFlowCont.Score)/100, 2), scoreFlowCont.Reason, publicmethod.UnixTimeToDay(scoreFlowCont.HappenTime, 12)) + } else { + msgCont.QuoteText = fmt.Sprintf("扣除: %v 分\n发生时间:%v", publicmethod.DecimalEs(float64(scoreFlowCont.Score)/100, 2), publicmethod.UnixTimeToDay(scoreFlowCont.HappenTime, 12)) + } + } + } + return +} + +// diff --git a/api/workwechat/entry.go b/api/workwechat/entry.go index 316d5db..8d0fa92 100644 --- a/api/workwechat/entry.go +++ b/api/workwechat/entry.go @@ -9,12 +9,47 @@ type SentMessage struct { TemplateCard TemplateCardMsgCont `json:"template_card"` //模板卡片消息 参数 } +//发送简化消息 +type SentMiniMessage struct { + MessageMain + TemplateCard TemplateCardMsgContMini `json:"template_card"` //模板卡片消息 参数 +} + +//简化消息主题 +type TemplateCardMsgContMini struct { + TemplatePublic + ActionMenu ActionMenuCont `json:"action_menu"` //卡片右上角更多操作按钮 + QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式 + HorizontalContentList []HorizontalContentListCont `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段 + JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 +} + +//发送简化消息 +type SentSmallMessage struct { + MessageMain + TemplateCard TemplateCardMsgContSmall `json:"template_card"` //模板卡片消息 参数 +} + +//简化消息主题 +type TemplateCardMsgContSmall struct { + CardType string `json:"card_type"` //模板卡片类型 text_notice:文本卡片;news_notice:图文卡片;button_interaction:按钮卡片,multiple_interaction:多项选择,vote_interaction:投票 + Source SourceCont `json:"source"` //卡片来源样式信息,不需要来源样式可不填写 + // MainTitle MainTitleCont `json:"main_title"` //一级标题 + TaskId string `json:"task_id"` //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填 + QuoteArea QuoteAreaCont `json:"quote_area"` //引用文献样式 + HorizontalContentList []HorizontalContentListCont `json:"horizontal_content_list"` //二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6 + CardAction CardActionCont `json:"card_action"` //整体卡片的点击跳转事件,text_notice必填本字段 + JumpList []JumpListCont `json:"jump_list"` //跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过3 +} + /* 更新文本信息 */ type UpdateMessage struct { UpdatePublic TemplateCard UpdateTemplateCardMsgCont `json:"template_card"` //模板卡片消息 参数 + } //更新文本信息模板 @@ -149,3 +184,7 @@ type UpdateTemplateCardMsgContVote struct { CheckBox CheckBoxCont `json:"checkbox"` // SubmitButton SubmitButtonCont `json:"submit_button"` //提交按钮样式 } + +//文本参数主体 +type msgTextCont struct { +} diff --git a/api/workwechat/message.go b/api/workwechat/message.go index 41680c6..eb09529 100644 --- a/api/workwechat/message.go +++ b/api/workwechat/message.go @@ -4,7 +4,10 @@ import ( "encoding/json" "fmt" "key_performance_indicators/middleware/wechatapp/wechatstatice" + "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall/publicmethod" + "strings" + "time" ) // 发送文本通知消息 @@ -20,6 +23,74 @@ func (s *SentMessage) SendMessage() (callBackByte []byte, err error) { return } +// 发送迷你信息设定 +func (sendMsg *SentSmallMessage) InitMes() *SentSmallMessage { + sendMsg.MsgType = "template_card" + sendMsg.AgentId = 1000036 + sendMsg.EnableIdTrans = 0 + sendMsg.EnableDuplicateCheck = 0 + sendMsg.DuplicateCheckInterval = 1800 + + // var templateCard TemplateCardMsgContMini + sendMsg.TemplateCard.CardType = "text_notice" + //头部左标题部分 + sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png" + sendMsg.TemplateCard.Source.DescColor = 1 + //引用文献样式 + sendMsg.TemplateCard.QuoteArea.Type = 0 + //整体卡片的点击跳转事件,text_notice必填本字段 + sendMsg.TemplateCard.CardAction.Type = 1 + // sendMsg.TemplateCard = templateCard + return sendMsg +} + +// 发送迷你信息设定 +func (sendMsg *SentMiniMessage) InitMes() *SentMiniMessage { + sendMsg.MsgType = "template_card" + sendMsg.AgentId = 1000036 + sendMsg.EnableIdTrans = 0 + sendMsg.EnableDuplicateCheck = 0 + sendMsg.DuplicateCheckInterval = 1800 + + // var templateCard TemplateCardMsgContMini + sendMsg.TemplateCard.CardType = "text_notice" + //头部左标题部分 + sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png" + sendMsg.TemplateCard.Source.DescColor = 1 + //引用文献样式 + sendMsg.TemplateCard.QuoteArea.Type = 0 + //整体卡片的点击跳转事件,text_notice必填本字段 + sendMsg.TemplateCard.CardAction.Type = 1 + // sendMsg.TemplateCard = templateCard + return sendMsg +} + +// 发送迷你文本通知消息 +func (s *SentMiniMessage) SendMessage() (callBackByte []byte, err error) { + sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl("kpi", "send") + if err != nil { + return + } + fmt.Printf("%v---------sendUrl, token----------->%v\n", sendUrl, token) + + sendDate, _ := json.Marshal(s) + callBackByte = publicmethod.CurlPostJosn(sendUrl, sendDate) + return +} + +// 发送迷你文本通知消息 +func (s *SentSmallMessage) SendMessage() (callBackByte []byte, err error) { + sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl("kpi", "send") + if err != nil { + return + } + fmt.Printf("%v---------sendUrl, token----------->%v\n", sendUrl, token) + + sendDate, _ := json.Marshal(s) + callBackByte = publicmethod.CurlPostJosn(sendUrl, sendDate) + return +} + // 更新文本通知消息 func (s *UpdateMessage) UpdateMessage() (callBackByte []byte, err error) { sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl("kpi", "update") @@ -32,3 +103,51 @@ func (s *UpdateMessage) UpdateMessage() (callBackByte []byte, err error) { callBackByte = publicmethod.CurlPostJosn(sendUrl, sendDate) return } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-24 08:22:22 +@ 功能: 写入企业微信模版信息发送回调 +@ 参数 + + #wechatCallBack 文本发送回调 + #sendMsg 发送文本信息 + #typeClass 类型(1:文本通知型;2:图文展示型;3:按钮交互型;4:投票选择型;5:多项选择型) + #ordeeId 审批记录Id + #enforcer 接收人 + +@ 返回值 + + #err + +@ 方法原型 + + #func WriteUpdateWechatTempmsg(wechatCallBack []byte, sendMsg SentMiniMessage, typeClass int, ordeeId int64, enforcer []string) (err error) +*/ +func WriteUpdateWechatTempmsg(wechatCallBack []byte, sendMsg SentMiniMessage, typeClass int, ordeeId int64, enforcer []string) (err error) { + var weChatCallBack publicmethod.WechatCallBack + err = json.Unmarshal(wechatCallBack, &weChatCallBack) + if err != nil { + return + } + if weChatCallBack.Errcode != 0 { + return + } + sendMsgJson, err := json.Marshal(sendMsg) + if err != nil { + return + } + var insetCont modelskpi.UpdateWechatTempmsg + insetCont.Type = typeClass //类型(1:文本通知型;2:图文展示型;3:按钮交互型;4:投票选择型;5:多项选择型)"` + insetCont.Sendmsgcont = string(sendMsgJson) //发送文件信息"` + insetCont.Msgid = weChatCallBack.MsgId //消息id,用于撤回应用消息"` + insetCont.ResponseCode = weChatCallBack.ResponseCode //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,72小时内有效,且只能使用一次"` + insetCont.Orderkey = ordeeId //流程id"` + insetCont.Enforcer = strings.Join(enforcer, ",") //执行人"` + insetCont.State = 2 //状态(1:已执行更新;2:未执行更新)"` + insetCont.TaskId = sendMsg.TemplateCard.TaskId //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填"` + insetCont.Time = time.Now().Unix() //写入时间"` + err = insetCont.AddCont() + return +} diff --git a/apirouter/apishiyan/maptostruct.go b/apirouter/apishiyan/maptostruct.go index be6cdd0..0a13bc6 100644 --- a/apirouter/apishiyan/maptostruct.go +++ b/apirouter/apishiyan/maptostruct.go @@ -37,8 +37,8 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { //校正老流程 apiRouter.POST("check_old_workflow", methodBinding.CheckOldWorkflow) //校正老流程 //实验企业微信相关 - apiRouter.POST("send_message", methodBinding.SendMessage) //发送文本信息 - apiRouter.POST("update_textmessage", methodBinding.UpdateTextMsg) //更新文本信息 - + apiRouter.POST("send_message", methodBinding.SendMessage) //发送文本信息 + apiRouter.POST("update_textmessage", methodBinding.UpdateTextMsg) //更新文本信息 + apiRouter.POST("send_message_mini", methodBinding.SendMessageMini) //发送文本信息迷你消息 } } diff --git a/apirouter/empower/apirouter.go b/apirouter/empower/apirouter.go index 90cb6c6..cfb5546 100644 --- a/apirouter/empower/apirouter.go +++ b/apirouter/empower/apirouter.go @@ -12,9 +12,10 @@ func (e *EmpowerApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter := router.Group("empower") var methodBinding = empower.AppApiEntry.EmpowerApi { - apiRouter.GET("", methodBinding.Index) //入口 - apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("givemetoken", methodBinding.GainToken) //获取令牌 - apiRouter.POST("encryption", methodBinding.Encryption) //加密验证 + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("givemetoken", methodBinding.GainToken) //获取令牌 + apiRouter.POST("encryption", methodBinding.Encryption) //加密验证 + apiRouter.POST("write_token", methodBinding.WriteToken) //写入令牌 } } diff --git a/apirouter/v1/departmentseting/pc.go b/apirouter/v1/departmentseting/pc.go index bd86b2a..d50b278 100644 --- a/apirouter/v1/departmentseting/pc.go +++ b/apirouter/v1/departmentseting/pc.go @@ -83,5 +83,6 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("get_qualbylaws_tasks", methodBinding.GetQualityBylawsTasks) //相关提报人定性考核细则列表 apiRouter.POST("submit_quality_assess", methodBinding.SubmitQualityAssess) //提交定性考核 apiRouter.POST("submit_quantify_target", methodBinding.SubmitQuantifyTarget) //提交定量考核 + } } diff --git a/apirouter/v1/departmentseting/web.go b/apirouter/v1/departmentseting/web.go index 2f7952e..d69cd1d 100644 --- a/apirouter/v1/departmentseting/web.go +++ b/apirouter/v1/departmentseting/web.go @@ -16,8 +16,12 @@ func (a *ApiRouter) RouterGroupWeb(router *gin.RouterGroup) { apiRouter.POST("", methodBinding.Index) //入口 apiRouter.POST("target_list_for_department", methodBinding.TargetListForDepartment) //指标列表 - apiRouter.POST("bdtts", methodBinding.BasisDepartTargetTimeStatistics) //根据部门、指标、年份统计每月的目标值、实际值、达成率 - apiRouter.POST("bdttsyoy", methodBinding.BasisDepartTargetTimeStatisticsYOY) //历史同比根据部门、定量指标、年份统计每月的实际值 + + apiRouter.POST("get_qualbylaws_tasks", methodBinding.GetQualityBylawsTasks) //相关提报人定性考核细则列表(web使用) + apiRouter.POST("base_post_table_have_target", methodBinding.BasePostTableHaveTarget) //根据栏目获取获取相关指标(web使用) + + apiRouter.POST("bdtts", methodBinding.BasisDepartTargetTimeStatistics) //根据部门、指标、年份统计每月的目标值、实际值、达成率 + apiRouter.POST("bdttsyoy", methodBinding.BasisDepartTargetTimeStatisticsYOY) //历史同比根据部门、定量指标、年份统计每月的实际值 apiRouter.POST("totalscore_org_from_timesearch", methodBinding.TotalScoreOFOrgComesFromTimeSearch) //通过时间获取组织总分 apiRouter.POST("get_hinge_target", methodBinding.GetHingeTarget) //获取关键指标 diff --git a/config/configDatabase/database.yaml b/config/configDatabase/database.yaml index fc5222e..efb81d9 100644 --- a/config/configDatabase/database.yaml +++ b/config/configDatabase/database.yaml @@ -28,14 +28,21 @@ wechat: gorm_log: false #是否开启gorm日志 #HR数据库 hrdatabase: - url_path: '127.0.0.1' #数据库地址 - port: 3306 #数据库端口 + # url_path: '127.0.0.1' #数据库地址 + # port: 3306 #数据库端口 + # name: 'hr_new' #数据库名称 + # username: 'root' #数据库用户民 + # password: 'root' #数据库密码 + + url_path: '120.224.6.6' #数据库地址 + port: 6666 #数据库端口 + name: 'hr_new' #数据库名称 + username: 'hr_new' #数据库用户民 + password: 'AnknKiXiXaxNrw78' #数据库密码 + charset: 'utf8mb4' #数据库编码方式 parseTime: 'True' #是否自动转换时间 loc: 'Local' #时区 - name: 'hr_new' #数据库名称 - username: 'root' #数据库用户民 - password: 'root' #数据库密码 max_idle_conns: 100 #最大空闲数量 max_open_conns: 1500 #最大打开数量 gorm_log: true #是否开启gorm日志 @@ -208,14 +215,22 @@ systemPermission: #仓库系统 storage: - url_path: '127.0.0.1' #数据库地址 + url_path: '172.20.2.87' #数据库地址 port: 3306 #数据库端口 + name: 'depository' #数据库名称 + username: 'depository' #数据库用户民 + password: 'NhE47edekBHxhjYk' #数据库密码 + + # url_path: '127.0.0.1' #数据库地址 + # port: 3306 #数据库端口 + # name: 'depository' #数据库名称 + # username: 'root' #数据库用户民 + # password: 'root' #数据库密码 + + charset: 'utf8mb4' #数据库编码方式 parseTime: 'True' #是否自动转换时间 loc: 'Local' #时区 - name: 'depository' #数据库名称 - username: 'root' #数据库用户民 - password: 'root' #数据库密码 max_idle_conns: 100 #最大空闲数量 max_open_conns: 1500 #最大打开数量 gorm_log: true #是否开启gorm日志 \ No newline at end of file diff --git a/models/modelskpi/update_wechat_tempmsg.go b/models/modelskpi/update_wechat_tempmsg.go new file mode 100644 index 0000000..bd98805 --- /dev/null +++ b/models/modelskpi/update_wechat_tempmsg.go @@ -0,0 +1,71 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 企业微信模版信息发送回调 +type UpdateWechatTempmsg struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` + Type int `json:"type" gorm:"column:type;type:int(1) ;default:1;comment:类型(1:文本通知型;2:图文展示型;3:按钮交互型;4:投票选择型;5:多项选择型)"` + Sendmsgcont string `json:"sendmsgcont" gorm:"column:sendmsgcont;type:longtext ;comment:发送文件信息"` + Msgid string `json:"msgid" gorm:"column:msgid;type:mediumtext;comment:消息id,用于撤回应用消息"` + ResponseCode string `json:"response_code" gorm:"column:response_code;type:mediumtext ;comment:仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,72小时内有效,且只能使用一次"` + Orderkey int64 `json:"orderkey" gorm:"column:orderkey;type:bigint(20) unsigned;not null;default:0;comment:流程id"` + Enforcer string `json:"enforcer" gorm:"column:enforcer;type:mediumtext;comment:执行人"` + State int `json:"sate" gorm:"column:sate;type:int(1) unsigned;default:2;not null;comment:状态(1:已执行更新;2:未执行更新)"` + TaskId string `json:"task_id" gorm:"column:task_id;type:mediumtext;comment:任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` +} + +func (UpdateWechatTempmsg *UpdateWechatTempmsg) TableName() string { + return "update_wechat_tempmsg" +} + +// 添加 +func (cont *UpdateWechatTempmsg) AddCont() (err error) { + err = overall.CONSTANT_DB_KPI.Create(&cont).Error + return +} + +// 编辑内容 +func (cont *UpdateWechatTempmsg) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *UpdateWechatTempmsg) 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 *UpdateWechatTempmsg) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *UpdateWechatTempmsg) ContMap(whereMap interface{}, field ...string) (countAry []UpdateWechatTempmsg, 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).Order("sort ASC").Find(&countAry).Error + return +} + +// 删除内容 +func (cont *UpdateWechatTempmsg) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index b0159ba..b99113e 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -1352,7 +1352,7 @@ func GetPostOfUsEmpowerCont(orgId, postId int64, systemName string) (sysPowerCon @ 方法原型 - #GetNewAccredit(systemName, roleId string, orgId, postId int64) (roleName, pointId, operation string, level int) + #func GetNewAccredit(systemName, roleId string, userKey, orgId, postId int64) (roleName, pointId, operation string, level int) */ func GetNewAccredit(systemName, roleId string, userKey, orgId, postId int64) (roleName, pointId, operation string, level int) { fmt.Printf("jsonStr---1--->%v---->%v---->%v---->%v---->%v\n", systemName, roleId, userKey, orgId, postId) @@ -1474,7 +1474,7 @@ func GetSetpName(setId int) (setpName string) { case 1: setpName = "创建申请" case 2: - setpName = "审核确认" + setpName = "审核" case 3: setpName = "责任划分" case 4: @@ -1492,6 +1492,25 @@ func GetSetpName(setId int) (setpName string) { return } +// 步骤名称/节点类型 0:发起人;1:审批;2:抄送;3:执行节点;4:路由;5:条件; +func GetSetpNodeName(setId int) (setpName string) { + switch setId { + case 1: + setpName = "审核" + case 2: + setpName = "抄送" + case 3: + setpName = "执行" + case 4: + setpName = "路由" + case 5: + setpName = "条件条件" + default: + setpName = "发起申请" + } + return +} + /* * @ 作者: 秦东 @@ -1979,6 +1998,7 @@ func (g *GetOrgAllParent) GetOrgParent(orgId, level int64) { @zeroPrize 零奖值 @CappingVal 封顶值 @achievement 达成率 +func CalculateScore(targetScore int64, resultval, allPrizes, zeroPrizes, CappingVals float64, typeClass int) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) */ func CalculateScore(targetScore int64, resultval, allPrizes, zeroPrizes, CappingVals float64, typeClass int) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) { allPrize = allPrizes / 100 diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go index 4ebd7da..a74ccd9 100644 --- a/overall/publicmethod/type.go +++ b/overall/publicmethod/type.go @@ -283,3 +283,11 @@ type outShenFen struct { Group int64 OrgList []int64 } + +// 企业微信模版卡片返回值 +type WechatCallBack struct { + Errcode int `json:"errcode"` //返回码 + ErrMsg string `json:"errmsg"` //对返回码的文本描述内容 + MsgId string `json:"msgid"` //消息id,用于撤回应用消息 + ResponseCode string `json:"response_code"` //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,72小时内有效,且只能使用一次 +}