From 50a5d5becdfaa4c7d93b7fd01db507d6ef257333 Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Mon, 16 May 2022 16:20:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=80=A7=E8=80=83=E6=A0=B8=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E6=B5=81=E4=BF=AE=E6=94=B9=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gin_server_admin/README.md | 14 +- .../api/index/evaluation/assessment.go | 49 ++ .../api/index/evaluation/evaluation.go | 6 + .../api/index/evaluation/flowsend.go | 2 - .../api/index/evaluation/flowsendnew.go | 145 +++- .../api/index/evaluation/lookquantita.go | 2 +- gin_server_admin/api/index/evaluation/type.go | 21 +- gin_server_admin/api/reply/enter.go | 16 + gin_server_admin/api/reply/qual/controller.go | 674 ++++++++++++++++++ .../api/reply/qual/divisionrectification.go | 536 ++++++++++++++ gin_server_admin/api/reply/qual/enter.go | 57 ++ gin_server_admin/api/reply/quan/enter.go | 17 + .../wechatapp/sendmessage/sendmsgHandle.go | 2 +- gin_server_admin/commonus/publichaneld.go | 78 +- .../initialize/internal/logger.go | 2 +- gin_server_admin/initialize/router.go | 5 + .../model/assessmentmodel/dutyclass.go | 18 + gin_server_admin/router/enter.go | 2 + gin_server_admin/router/replyrouter/enter.go | 34 + 19 files changed, 1655 insertions(+), 25 deletions(-) create mode 100644 gin_server_admin/api/reply/enter.go create mode 100644 gin_server_admin/api/reply/qual/controller.go create mode 100644 gin_server_admin/api/reply/qual/divisionrectification.go create mode 100644 gin_server_admin/api/reply/qual/enter.go create mode 100644 gin_server_admin/api/reply/quan/enter.go create mode 100644 gin_server_admin/router/replyrouter/enter.go diff --git a/gin_server_admin/README.md b/gin_server_admin/README.md index c43a91b..2f486ed 100644 --- a/gin_server_admin/README.md +++ b/gin_server_admin/README.md @@ -81,4 +81,16 @@ target_weight 2、定量指标添加自动与手东干预 ### 2022.05.01纪要 -1、编写数据表统计信息 \ No newline at end of file +1、编写数据表统计信息 + + + +### 2022.05.15纪要 + +approvalList 流程详情页面 + + +responsible 责任划分页面 + + +rectification 整改措施 \ No newline at end of file diff --git a/gin_server_admin/api/index/evaluation/assessment.go b/gin_server_admin/api/index/evaluation/assessment.go index aae6f99..190916f 100644 --- a/gin_server_admin/api/index/evaluation/assessment.go +++ b/gin_server_admin/api/index/evaluation/assessment.go @@ -45,6 +45,9 @@ func (e *EvaluationInterface) NewQualitative(c *gin.Context) { response.Result(102, isTrue, "您没有要参加的考核项目!", c) return } + todayVal := time.Now().Unix() + yearVal := commonus.ComputingTime(todayVal, 1) + monthVal := commonus.ComputingTime(todayVal, 3) var outContList []NewQualOutList for _, v := range qualEvaList { var outCont NewQualOutList @@ -62,6 +65,10 @@ func (e *EvaluationInterface) NewQualitative(c *gin.Context) { outCont.DepartmentName = orgContDepart.Name // _, departCont := commonus.GetBranchFactory(v.Department) // outCont.DepartmentName = departCont.Name + qualId := GetDepartmentStatiscs(v.Dimension, v.Target, v.Group, v.Department, 1, userCont.Key) + if len(qualId) > 0 { + outCont.ExtraPoints, outCont.ScoreReduction = StatisticsMonthQual(qualId, v.Group, v.Department, yearVal, monthVal) + } outCont.Dimension = v.Dimension dimensionCont, _ := commonus.GetDutyClassInfo(v.Dimension) @@ -220,3 +227,45 @@ func (e *EvaluationInterface) QualitativeEvalRationNew(c *gin.Context) { return } } + +//统计当月定性考核加减分情况 +/* +@qualId 考核项目ID +@dutyGroup 被考核集团 +@dutyDepartment 被考核部门 +@years 年 +@months 月 +*/ +func StatisticsMonthQual(qualId []int64, dutyGroup, dutyDepartment, years, months int64) (addSumScore, scoreReduction float64) { + where := commonus.MapOut() + // where["sf_evaluation_plan"] = qualId + where["sf_year"] = years + where["sf_month"] = months + where["sf_duty_group"] = dutyGroup + where["sf_duty_department"] = dutyDepartment + //加分 + // var addSumScore float64 = 0 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score").Where("sf_evaluation_plan IN ?", qualId).Where(where).Where("sf_plus_reduce_score = 1").Where("sf_reply >= 2 AND sf_reply <> 4").Pluck("COALESCE(SUM(sf_score), 0) as addrescore", &addSumScore) + //加分 + // var scoreReduction float64 = 0 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Select("sf_score").Where("sf_evaluation_plan IN ?", qualId).Where(where).Where("sf_plus_reduce_score = 2").Where("sf_reply >= 2 AND sf_reply <> 4").Pluck("COALESCE(SUM(sf_score), 0) as redurescore", &scoreReduction) + + addSumScore = commonus.Decimal(addSumScore / 100) + scoreReduction = commonus.Decimal(scoreReduction / 100) + return +} + +//获取部门指标下的考核项目 +/* +@dimension 维度 +@targetId 指标 +@dutyGroup 集团 +@dutyDepartment 部门 +@class 1:定性;2:定量 +@userKey 员工编码 +*/ +func GetDepartmentStatiscs(dimension, targetId, dutyGroup, dutyDepartment int64, class int, userKey string) (qeid []int64) { + // var qeid []int64 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("`qe_type` = ? AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`) AND qe_dimension = ? AND qe_target = ? AND qe_group = ? AND qe_accept_evaluation = ?", class, userKey, dimension, targetId, dutyGroup, dutyDepartment).Find(&qeid) + return +} diff --git a/gin_server_admin/api/index/evaluation/evaluation.go b/gin_server_admin/api/index/evaluation/evaluation.go index 28ef3e9..0bfef74 100644 --- a/gin_server_admin/api/index/evaluation/evaluation.go +++ b/gin_server_admin/api/index/evaluation/evaluation.go @@ -1502,10 +1502,15 @@ func (e *EvaluationInterface) LookDutkScoreFlow(c *gin.Context) { } //流程全面 var flowAllMapList []commonus.FlowAllMap + // fmt.Printf("evalProInfo.NextContent----------->%v\n", evalProInfo.NextContent) jsonFlowErrers := json.Unmarshal([]byte(evalProInfo.NextContent), &flowAllMapList) + + // fmt.Printf("flowAllMapList----------->%v\n", flowAllMapList) if jsonFlowErrers == nil { dutyCecorFlowInfo.FlowMapAll = flowAllMapList } + + // fmt.Printf("flowAllMapList----------->%v\n", dutyCecorFlowInfo.FlowMapAll) } titlekUserInfo, _ := commonus.GetWorkUser(strconv.FormatInt(addScore.EvaluationUser, 10)) @@ -1704,6 +1709,7 @@ func (d *EvaluationInterface) LookRationkScoreFlow(c *gin.Context) { outListMap["flowall"] = flowAllMapList outListMap["title"] = "" outListMap["isset"] = isShenPi + outListMap["orderid"] = requestData.Id if getErrs == nil { titlekUserInfo, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": flowLogInfo.EvaluationUser}, "`name`") // titlekUserInfo, _ := commonus.GetWorkUser(strconv.FormatInt(flowLogInfo.EvaluationUser, 10)) diff --git a/gin_server_admin/api/index/evaluation/flowsend.go b/gin_server_admin/api/index/evaluation/flowsend.go index 6e7837a..95012b7 100644 --- a/gin_server_admin/api/index/evaluation/flowsend.go +++ b/gin_server_admin/api/index/evaluation/flowsend.go @@ -205,9 +205,7 @@ func (e *EvaluationInterface) PlusOrMinusPoints(c *gin.Context) { //分数 sendScore := scoreStringToInt64 * int64(countFrequency) - sendScVal := float64(sendScore) / 100 - scoreFloat64ToStringsss := strconv.FormatFloat(sendScVal, 'f', -1, 64) // fmt.Printf("ScoreSetp---2----s->%v----f->%v----fs->%v----si->%v\n", sendScore, float64(sendScore)/100, sendScVal, scoreFloat64ToStringsss) diff --git a/gin_server_admin/api/index/evaluation/flowsendnew.go b/gin_server_admin/api/index/evaluation/flowsendnew.go index 12fc744..583b4d9 100644 --- a/gin_server_admin/api/index/evaluation/flowsendnew.go +++ b/gin_server_admin/api/index/evaluation/flowsendnew.go @@ -4,8 +4,10 @@ import ( "encoding/json" "fmt" "strconv" + "strings" "time" + "github.com/flipped-aurora/gin-vue-admin/server/api/wechatapp/sendmessage" "github.com/flipped-aurora/gin-vue-admin/server/commonus" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" @@ -159,19 +161,158 @@ func (e *EvaluationInterface) PlusOrMinusPointsNew(c *gin.Context) { } myIsTrue := 1 + //流程审批相关 + //生成唯一编号 + registerNumber := commonus.GetFileNumberEs() + //将步骤写入 + var registerCont assessmentmodel.Register + registerCont.Number = registerNumber + registerCont.State = 1 + registerCont.Time = time.Now().Unix() + registerCont.AddCont() + //审批卡片跳转链接 + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10)) + // jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10)) + + // jumpUrlTitle := "请前往处理" + // sourceDesc := commonus.GetSetpName(2) + + //获取通知人信息 + //1、获取发起人部门负责人 + var officWorkUserList string + founderDepartId, _ := strconv.ParseInt(userCont.Deparment, 10, 64) + sendUserIsTrue, sendUserList := commonus.GetSendMsgUserAry(16182159043990656, founderDepartId) //获取对应部门负责人 + if sendUserIsTrue != true { + response.Result(0, sendUserList, "未指定相关部门处理人!请确定部门负责人后,重新发起请求!", c) + return + } + + for _, v := range sendUserList { + if v == userCont.Wechat { + myIsTrue = 2 + } + } + + fmt.Printf("userCont.Wechat====>%v------------>myIsTrue:%v------------>sendUserList:%v\n", userCont.Wechat, myIsTrue, sendUserList) + + officWorkUserList = strings.Join(sendUserList, "|") + + //确定标题 + var title string = "" + //一级标题副本内容 + var desc string = "" + detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget) //获取指标细则 + if detailedTargetErr == true { + tarInf, tarErr := commonus.GetTargetInfo(detailedTargetCont.ParentId) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + desc = detailedTargetCont.Title //一级标题辅助信息,建议不超过44个字 + } else { + title = detailedTargetCont.Title //一级标题,建议不超过36个字 + } + } else { + tarInf, tarErr := commonus.GetTargetInfo(programme.Target) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + } else { + title = strconv.FormatInt(programme.DetailedTarget, 10) //一级标题,建议不超过36个字 + } + } + //执行原因 + reason := fmt.Sprintf("原因:%v\n", requestData.Reason) + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(departmentId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + twoLevelTitle := "考核上报部门:" + //分数 + sendScore := scoreStringToInt64 * int64(countFrequency) + sendScVal := float64(sendScore) / 100 + scoreFloat64ToStringsss := strconv.FormatFloat(sendScVal, 'f', -1, 64) + outMap := commonus.MapOut() + var quoteAreaTitle string //引用文献标题 if requestData.Type != 1 { //减分 + quoteAreaTitle = fmt.Sprintf("考核减分:%v\n", scoreFloat64ToStringsss) if myIsTrue != 1 { //申请人也是部门负责人 - commonus.StepAddDataEs(keyNumber, 0, 3, 1, 1, 1, 1, userCont.Key, requestData.Enclosure) + commonus.StepAddDataEs(keyNumber, 0, 2, 1, 1, 1, 1, userCont.Key, requestData.Enclosure) + + userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64) + commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(1), "") + + commonus.StepAddData(keyNumber, 16182159043990656, 3, 2, 1, 2, 2, userCont.Key) + + commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(2), "同意") + + sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, programme.AcceptEvaluation) //获取对应部门内勤 + if sendUserIsTrue != true { + response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c) + return + } + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10)) + jumpUrlTitle := "请前往处理" + sourceDesc := "责任划分" + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 1 } else { //申请人不是是部门负责人 给本部门负责人发送审批 commonus.StepAddDataEs(keyNumber, 16182159043990656, 2, 1, 1, 1, 1, userCont.Key, requestData.Enclosure) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10)) + jumpUrlTitle := "请前往处理" + sourceDesc := "审核" + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(officWorkUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 2 + + userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64) + commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(1), "") + /*func WriteReplyLog(orderId, acceptDepartment, launchDepartment, launchUser, state int64, title, content string) + @orderId 审批单key + @title 节点名称 + @acceptDepartment 接受考核部门 + @launchDepartment 发起考核部门 + @launchUser 考核发起人 + @state 申请单当前审批状态:1-审批中;2-已通过;3-已驳回;4-已取消 + @content 意见 + */ } } else { //加分 + quoteAreaTitle = fmt.Sprintf("考核加分:%v\n", scoreFloat64ToStringsss) commonus.StepAddDataEs(keyNumber, 16182159043990656, 2, 7, 1, 1, 1, userCont.Key, requestData.Enclosure) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", keyNumber, strconv.FormatInt(registerNumber, 10)) + jumpUrlTitle := "请前往处理" + sourceDesc := "审核" + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(officWorkUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 3 + + userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64) + commonus.WriteReplyLog(keyNumber, programme.AcceptEvaluation, founderDepartId, userKeyInt, 1, commonus.GetSetpName(1), "") } - response.Result(0, requestData, "数据写入成功", c) + response.Result(0, outMap, "数据写入成功", c) } diff --git a/gin_server_admin/api/index/evaluation/lookquantita.go b/gin_server_admin/api/index/evaluation/lookquantita.go index 9fd4ad1..4eb6748 100644 --- a/gin_server_admin/api/index/evaluation/lookquantita.go +++ b/gin_server_admin/api/index/evaluation/lookquantita.go @@ -161,7 +161,7 @@ func (e *EvaluationInterface) SeeFlowLog(c *gin.Context) { if requestData.IsSet == 1 { gormDb = gormDb.Where("FIND_IN_SET(?,`ep_participants`) OR NOT FIND_IN_SET(?,`ep_next_executor`)", userCont.Key, userCont.Key) } else { - gormDb = gormDb.Where("FIND_IN_SET(?,`ep_participants`) OR FIND_IN_SET(?,`ep_next_executor`)", userCont.Key, userCont.Key) + gormDb = gormDb.Where("FIND_IN_SET(?,`ep_next_executor`)", userCont.Key) } if requestData.State != 0 { diff --git a/gin_server_admin/api/index/evaluation/type.go b/gin_server_admin/api/index/evaluation/type.go index d1fb751..71c8e4a 100644 --- a/gin_server_admin/api/index/evaluation/type.go +++ b/gin_server_admin/api/index/evaluation/type.go @@ -303,16 +303,17 @@ type NewQualType struct { //新型定性考核列表输出 type NewQualOutList struct { - Group int64 `json:"group" gorm:"column:qe_group;type:bigint(20) unsigned;default:0;not null;comment:归属集团"` - GroupName string `json:"groupname"` //集团 - Department int64 `json:"department" gorm:"column:qe_accept_evaluation;type:bigint(20) unsigned;default:0;not null;comment:接受考核部门"` - DepartmentName string `json:"departmentname"` //部门 - Dimension int64 `json:"dimension" gorm:"column:qe_dimension;type:bigint(20) unsigned;default:0;not null;comment:考核维度"` - DimensionName string `json:"dimensionname"` //维度 - Target int64 `json:"target" gorm:"column:qe_target;type:bigint(20) unsigned;default:0;not null;comment:考核指标"` - Title string `json:"title" gorm:"column:et_title;type:varchar(255);comment:指标名称"` - ExtraPoints int64 `json:"extrapoints"` //加分总价 - ScoreReduction int64 `json:"scorereduction"` //减分总计 + Id int64 `json:"id" gorm:"primaryKey;column:qe_id;type:bigint(20) unsigned;not null;comment:Id;index"` + Group int64 `json:"group" gorm:"column:qe_group;type:bigint(20) unsigned;default:0;not null;comment:归属集团"` + GroupName string `json:"groupname"` //集团 + Department int64 `json:"department" gorm:"column:qe_accept_evaluation;type:bigint(20) unsigned;default:0;not null;comment:接受考核部门"` + DepartmentName string `json:"departmentname"` //部门 + Dimension int64 `json:"dimension" gorm:"column:qe_dimension;type:bigint(20) unsigned;default:0;not null;comment:考核维度"` + DimensionName string `json:"dimensionname"` //维度 + Target int64 `json:"target" gorm:"column:qe_target;type:bigint(20) unsigned;default:0;not null;comment:考核指标"` + Title string `json:"title" gorm:"column:et_title;type:varchar(255);comment:指标名称"` + ExtraPoints float64 `json:"extrapoints"` //加分总价 + ScoreReduction float64 `json:"scorereduction"` //减分总计 } //新定性考核指标细则列表 diff --git a/gin_server_admin/api/reply/enter.go b/gin_server_admin/api/reply/enter.go new file mode 100644 index 0000000..7e9c81f --- /dev/null +++ b/gin_server_admin/api/reply/enter.go @@ -0,0 +1,16 @@ +package reply + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/api/reply/qual" + "github.com/flipped-aurora/gin-vue-admin/server/api/reply/quan" +) + +//自建审批 + +//企业微信应用 +type ApiGroup struct { + QuanAipGroup quan.ApiGroup + QualApiGroup qual.ApiGroup +} + +var ApiGroupApp = new(ApiGroup) diff --git a/gin_server_admin/api/reply/qual/controller.go b/gin_server_admin/api/reply/qual/controller.go new file mode 100644 index 0000000..6c4d3f0 --- /dev/null +++ b/gin_server_admin/api/reply/qual/controller.go @@ -0,0 +1,674 @@ +package qual + +import ( + "fmt" + "strconv" + "strings" + "time" + + "github.com/flipped-aurora/gin-vue-admin/server/api/wechatapp/sendmessage" + "github.com/flipped-aurora/gin-vue-admin/server/commonus" + "github.com/flipped-aurora/gin-vue-admin/server/global" + "github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" + "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" + "github.com/gin-gonic/gin" +) + +//定性审批解析 +func (a *ApiGroup) Operation(c *gin.Context) { + isTrue, userCont := commonus.ClientIdentity() + if isTrue != true { + response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) + return + } + founderDepartId, _ := strconv.ParseInt(userCont.Deparment, 10, 64) + + var requestData ApprovalParameters + err := c.ShouldBindJSON(&requestData) + if err != nil { + response.Result(101, err, "参数错误!请重新提交!", c) + return + } + if requestData.OrderId == "" { + response.Result(102, err, "参数错误!请重新提交!", c) + return + } + + var evalProcessInfo assessmentmodel.EvaluationProcess + evalErr := global.GVA_DB_Performanceappraisal.Where("ep_order_key = ?", requestData.OrderId).First(&evalProcessInfo).Error + if evalErr != nil { + response.Result(103, err, "审批流不存在!请检查您的数据!", c) + return + } + if evalProcessInfo.State == 3 || evalProcessInfo.NextStep <= 0 { + response.Result(104, err, "该流程已结束!不可进行操作!", c) + return + } + if evalProcessInfo.NextContent == "" { + response.Result(105, err, "对不起!您没有权限对此流程进行操作!", c) + return + } + nextReplyUserMap := strings.Split(evalProcessInfo.NextExecutor, ",") + // fmt.Printf("userCont.Key:%v\n", userCont.Key) + if commonus.IsItTrueString(userCont.Key, nextReplyUserMap) == false { + response.Result(106, nextReplyUserMap, "对不起!您没有权限对此流程进行操作!", c) + return + } + + //2、获取审批单信息 + var scoreFlowInfo assessmentmodel.ScoreFlow + judegFlowErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", requestData.OrderId).First(&scoreFlowInfo).Error + if judegFlowErr != nil { + response.Result(107, err, "对不起!此审批流程已经关闭!请联系发起人!", c) + return + } + //获取考核项目内容 + var programme assessmentmodel.QualitativeEvaluation + judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", scoreFlowInfo.EvaluationPlan).First(&programme).Error + if judgeProgramme != nil { + response.Result(105, programme, "未知考核项目!请检查你的提交是否正确!", c) + return + } + + //确定标题 + var title string = "" + //一级标题副本内容 + var desc string = "" + detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget) //获取指标细则 + if detailedTargetErr == true { + tarInf, tarErr := commonus.GetTargetInfo(detailedTargetCont.ParentId) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + desc = detailedTargetCont.Title //一级标题辅助信息,建议不超过44个字 + } else { + title = detailedTargetCont.Title //一级标题,建议不超过36个字 + } + } else { + tarInf, tarErr := commonus.GetTargetInfo(programme.Target) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + } else { + title = strconv.FormatInt(programme.DetailedTarget, 10) //一级标题,建议不超过36个字 + } + } + var quoteAreaTitle string //引用文献标题 + + orderIdInt, _ := strconv.ParseInt(requestData.OrderId, 10, 64) //流程Key + // userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64) //使用人KEY + + sendScVal := float64(scoreFlowInfo.Score) / 100 + scoreFloat64ToStringsss := strconv.FormatFloat(sendScVal, 'f', -1, 64) + + outMap := commonus.MapOut() + if requestData.YesOrNo != 1 { + //驳回 + opinionCont := "不同意" + if requestData.Content != "" { + opinionCont = requestData.Content + } + // //执行原因 + var reason string + switch evalProcessInfo.NextStep { + case 0: + response.Result(104, err, "该流程已结束!不可进行操作!", c) + return + case 1: + //申请 + case 2: + //申请人部门负责人 + commonus.StepAddData(orderIdInt, 16182159043990656, 1, 2, 1, 3, 2, userCont.Key) //审批步骤处理 + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 3, commonus.GetSetpName(2), opinionCont) //写入审批流 + + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 3 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", requestData.OrderId).Updates(&eiteScoreFlow) + evalProcSaveData := commonus.MapOut() + evalProcSaveData["ep_state"] = 3 + evalProcSaveData["ep_time"] = time.Now().Unix() + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData) + + reason = fmt.Sprintf("原因:%v\n", opinionCont) + + //获取发起人信息 + var sendUser string = "" + var sendUserAry []string + faQiRen, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": scoreFlowInfo.EvaluationUser}, "`wechat`", "`work_wechat`") + if faQiRen.Wechat != "" { + sendUser = faQiRen.Wechat + } + if faQiRen.WorkWechat != "" { + sendUser = faQiRen.WorkWechat + } + if sendUser != "" { + sendUserAry = append(sendUserAry, sendUser) + } + sendUserList := strings.Join(sendUserAry, "|") + + registerNumber := commonus.GetFileNumberEs() + + if scoreFlowInfo.PlusReduceScore != 1 { + quoteAreaTitle = fmt.Sprintf("考核减分:%v\n", scoreFloat64ToStringsss) + } else { + quoteAreaTitle = fmt.Sprintf("考核加分:%v\n", scoreFloat64ToStringsss) + } + + twoLevelTitle := "审批信息:" + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(founderDepartId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrlTitle := "查看详情" + sourceDesc := "驳回" + + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 2 + + case 3: + //接受考核部门内勤(责任划分) + case 4: + //接受考核部门负责人(责任划分确认) + + //申请人部门负责人 + commonus.StepAddData(orderIdInt, 16182159043990656, 3, 3, 1, 3, 4, userCont.Key) + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 3, commonus.GetSetpName(3), opinionCont) //写入审批流 + + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 3 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", requestData.OrderId).Updates(&eiteScoreFlow) + evalProcSaveData := commonus.MapOut() + evalProcSaveData["ep_state"] = 3 + evalProcSaveData["ep_time"] = time.Now().Unix() + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData) + + //判断是加分还是减分 + if scoreFlowInfo.PlusReduceScore != 1 { + quoteAreaTitle = fmt.Sprintf("考核减分:%v\n", scoreFloat64ToStringsss) + } else { + quoteAreaTitle = fmt.Sprintf("考核加分:%v\n", scoreFloat64ToStringsss) + } + //获取责任划分 + teamBility, teamErr := commonus.GetDivisionOfResponsibility(requestData.OrderId, 2) + if teamErr == nil { + for _, team_v := range teamBility { + if team_v["type"] != 3 { + reason = fmt.Sprintf("%v%v:%v 占比:%v%\n", reason, team_v["typename"], team_v["username"], team_v["weight"]) + } else { + reason = fmt.Sprintf("%v%v:%v 占比:%v%\n", reason, team_v["typename"], team_v["temaname"], team_v["weight"]) + } + } + } + + reason = fmt.Sprintf("驳回原因:%v\n", opinionCont) + + sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, scoreFlowInfo.DutyDepartment) //获取对应部门内勤 + if sendUserIsTrue != true { + response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!", c) + return + } + + //生成唯一编号 + registerNumber := commonus.GetFileNumberEs() + var registerCont assessmentmodel.Register + registerCont.Number = registerNumber + registerCont.State = 1 + registerCont.Time = time.Now().Unix() + registerCont.AddCont() + + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v", orderIdInt) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrlTitle := "请前往处理" + sourceDesc := "驳回" + + twoLevelTitle := "审批信息:" + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(founderDepartId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 2 + + case 5: + //主要责任人整改(提交) + case 6: + //接受考核部门负责人(整改确认) + commonus.StepAddData(orderIdInt, 16182159043990656, 5, 5, 1, 3, 6, userCont.Key) + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 3, commonus.GetSetpName(5), opinionCont) //写入审批流 + + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 3 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", requestData.OrderId).Updates(&eiteScoreFlow) + evalProcSaveData := commonus.MapOut() + evalProcSaveData["ep_state"] = 3 + evalProcSaveData["ep_time"] = time.Now().Unix() + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData) + //获取主要责任人 + var personLiable []string + teamBility, teamErr := commonus.GetDivisionOfResponsibility(requestData.OrderId, 1) + if teamErr == nil { + for _, tm_v := range teamBility { + if tm_v["type"] == 1 { + personLiable = append(personLiable, tm_v["wechatid"].(string)) + } + } + } + if len(personLiable) < 1 { + response.Result(0, personLiable, "未指定相关部门处理人!未能向相关人员发送考核项目!", c) + return + } + sendUserList := strings.Join(personLiable, "|") + + //判断是加分还是减分 + if scoreFlowInfo.PlusReduceScore != 1 { + quoteAreaTitle = fmt.Sprintf("考核减分:%v\n", scoreFloat64ToStringsss) + } else { + quoteAreaTitle = fmt.Sprintf("考核加分:%v\n", scoreFloat64ToStringsss) + } + + reason = fmt.Sprintf("驳回原因:%v\n", opinionCont) + + //生成唯一编号 + registerNumber := commonus.GetFileNumberEs() + var registerCont assessmentmodel.Register + registerCont.Number = registerNumber + registerCont.State = 1 + registerCont.Time = time.Now().Unix() + registerCont.AddCont() + + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v", orderIdInt) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/rectification?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrlTitle := "请前往处理" + sourceDesc := "驳回" + + twoLevelTitle := "审批信息:" + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(founderDepartId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 2 + case 7: + //发起人验收 + default: + response.Result(404, err, "未知操作!", c) + return + } + } else { + opinionCont := "同意" + if requestData.Content != "" { + opinionCont = requestData.Content + } + //执行原因 + reason := fmt.Sprintf("原因:%v\n", opinionCont) + + //同意 + switch evalProcessInfo.NextStep { + case 0: + response.Result(104, err, "该流程已结束!不可进行操作!", c) + return + case 1: + //申请 + case 2: + //申请人部门负责人 + + //判断是加分还是减分 + if scoreFlowInfo.PlusReduceScore == 1 { + //加分 + commonus.StepAddData(orderIdInt, 16182159043990656, 0, 2, 1, 2, 2, userCont.Key) //审批步骤处理 + + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 2, commonus.GetSetpName(2), opinionCont) //写入审批流 + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 3 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", requestData.OrderId).Updates(&eiteScoreFlow) + } else { + //减分 + quoteAreaTitle = fmt.Sprintf("考核减分:%v\n", scoreFloat64ToStringsss) + commonus.StepAddData(orderIdInt, 16182159043990656, 3, 2, 1, 2, 2, userCont.Key) //审批步骤处理 + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 1, commonus.GetSetpName(2), opinionCont) //写入审批流 + + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 2 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", requestData.OrderId).Updates(&eiteScoreFlow) + + sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16118387069540343, scoreFlowInfo.DutyDepartment) //获取对应部门内勤 + if sendUserIsTrue != true { + response.Result(0, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!", c) + return + } + + //将步骤写入 判断该步骤是否已经操作 + registerNumber := commonus.GetFileNumberEs() + var registerCont assessmentmodel.Register + registerCont.Number = registerNumber + registerCont.State = 1 + registerCont.Time = time.Now().Unix() + registerCont.AddCont() + //审批卡片跳转链接 + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrlTitle := "请前往划分责任人" + sourceDesc := "责任划分" + + twoLevelTitle := "审批信息:" + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(founderDepartId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 2 + // fmt.Printf("sendClick----->%v\n", outMap) + } + case 3: + //接受考核部门内勤(责任划分) + case 4: + //接受考核部门负责人(责任划分确认) + //是否需要整改 + if scoreFlowInfo.Rectification == 1 { + //需要整改 + commonus.StepAddData(orderIdInt, 16182159043990656, 5, 7, 1, 2, 4, userCont.Key) + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 2, commonus.GetSetpName(7), opinionCont) //写入审批流 + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 2 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", orderIdInt).Updates(&eiteScoreFlow) + evalProcSaveData := commonus.MapOut() + evalProcSaveData["ep_state"] = 2 + evalProcSaveData["ep_time"] = time.Now().Unix() + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData) + //步骤内容写入 + + //获取主要责任人 + var personLiable []string + teamBility, teamErr := commonus.GetDivisionOfResponsibility(requestData.OrderId, 1) + if teamErr == nil { + for _, tm_v := range teamBility { + if tm_v["type"] == 1 { + personLiable = append(personLiable, tm_v["wechatid"].(string)) + } + } + } + if len(personLiable) < 1 { + fmt.Printf("发送整改通知!没有主要负责人%v\n", teamBility) + } + sendUserList := strings.Join(personLiable, "|") + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(founderDepartId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + //将步骤写入 判断该步骤是否已经操作 + registerNumber := commonus.GetFileNumberEs() + var registerCont assessmentmodel.Register + registerCont.Number = registerNumber + registerCont.State = 1 + registerCont.Time = time.Now().Unix() + registerCont.AddCont() + //审批卡片跳转链接 + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/rectification?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + + jumpUrlTitle := "查看详情" + sourceDesc := "整改通知" + twoLevelTitle := "审批信息:" + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 41 + + } else { + //不要整改 + commonus.StepAddData(orderIdInt, 16182159043990656, 0, 2, 1, 2, 4, userCont.Key) + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 2, commonus.GetSetpName(2), opinionCont) //写入审批流 + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 3 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", orderIdInt).Updates(&eiteScoreFlow) + evalProcSaveData := commonus.MapOut() + evalProcSaveData["ep_state"] = 3 + evalProcSaveData["ep_time"] = time.Now().Unix() + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData) + + //获取发起人信息 + var sendUser string = "" + // faQiRen, _ := commonus.GetWorkUser(strconv.FormatInt(scoreFlowInfo.EvaluationUser, 10)) + faQiRen, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": scoreFlowInfo.EvaluationUser}, "`wechat`", "`work_wechat`") + if faQiRen.Wechat != "" { + sendUser = faQiRen.Wechat + } + if faQiRen.WorkWechat != "" { + sendUser = faQiRen.WorkWechat + } + //将步骤写入 判断该步骤是否已经操作 + registerNumber := commonus.GetFileNumberEs() + var registerCont assessmentmodel.Register + registerCont.Number = registerNumber + registerCont.State = 1 + registerCont.Time = time.Now().Unix() + registerCont.AddCont() + //审批卡片跳转链接 + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(founderDepartId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + //抄送发起人 + if sendUser != "" { + jumpUrlTitle := "查看详情" + sourceDesc := "抄送" + twoLevelTitle := "审批信息:" + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUser, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 41 + } + + } + case 5: + //主要责任人整改(提交) + case 6: + //接受考核部门负责人(整改确认) + commonus.StepAddData(orderIdInt, 16182159043990656, 0, 7, 1, 2, 6, userCont.Key) + commonus.WriteReplyLog(orderIdInt, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 2, commonus.GetSetpName(7), opinionCont) //写入审批流 + + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 3 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", orderIdInt).Updates(&eiteScoreFlow) + evalProcSaveData := commonus.MapOut() + evalProcSaveData["ep_state"] = 3 + evalProcSaveData["ep_time"] = time.Now().Unix() + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderIdInt).Updates(&evalProcSaveData) + + //2、获取要抄送人员名单 + var sendUserAry []string + //2.1 获取发起人部门负责人 + launchUserIsTrue, launchUserList := commonus.GetSendMsgUserAry(16182159043990656, scoreFlowInfo.EvaluationDepartment) //获取发起人部门负责人 + if launchUserIsTrue == true { + for _, lau_v := range launchUserList { + sendUserAry = append(sendUserAry, lau_v) + } + } + //2.2、获取职责部门负责人 + dutyUserIsTrue, dutyUserList := commonus.GetSendMsgUserAry(16182159043990656, scoreFlowInfo.DutyDepartment) //获取职责部门负责人 + if dutyUserIsTrue == true { + for _, duty_v := range dutyUserList { + sendUserAry = append(sendUserAry, duty_v) + } + } + //2.3、获取发起人信息 + var sendUser string = "" + // faQiRen, _ := commonus.GetWorkUser(strconv.FormatInt(scoreFlowInfo.EvaluationUser, 10)) + faQiRen, _ := commonus.GetNewHrPeopleInfo(map[string]interface{}{"`key`": scoreFlowInfo.EvaluationUser}, "`wechat`", "`work_wechat`") + if faQiRen.Wechat != "" { + sendUser = faQiRen.Wechat + } + if faQiRen.WorkWechat != "" { + sendUser = faQiRen.WorkWechat + } + if sendUser != "" { + sendUserAry = append(sendUserAry, sendUser) + } + sendMsgToUserList := strings.Join(sendUserAry, "|") + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(founderDepartId) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + //将步骤写入 判断该步骤是否已经操作 + registerNumber := commonus.GetFileNumberEs() + var registerCont assessmentmodel.Register + registerCont.Number = registerNumber + registerCont.State = 1 + registerCont.Time = time.Now().Unix() + registerCont.AddCont() + //审批卡片跳转链接 + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v&num=%v", orderIdInt, strconv.FormatInt(registerNumber, 10)) + + jumpUrlTitle := "查看详情" + sourceDesc := "抄送" + twoLevelTitle := "审批信息:" + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendMsgToUserList, strconv.FormatInt(registerNumber, 10), title, desc, quoteAreaTitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 41 + + case 7: + //发起人验收 + default: + response.Result(404, err, "未知操作!", c) + return + } + } + response.Result(0, outMap, "审批流不存在!请检查您的数据!", c) + +} diff --git a/gin_server_admin/api/reply/qual/divisionrectification.go b/gin_server_admin/api/reply/qual/divisionrectification.go new file mode 100644 index 0000000..b970fe2 --- /dev/null +++ b/gin_server_admin/api/reply/qual/divisionrectification.go @@ -0,0 +1,536 @@ +package qual + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" + "time" + + "github.com/flipped-aurora/gin-vue-admin/server/api/wechatapp/sendmessage" + "github.com/flipped-aurora/gin-vue-admin/server/commonus" + "github.com/flipped-aurora/gin-vue-admin/server/global" + "github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" + "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" + "github.com/gin-gonic/gin" +) + +func (a *ApiGroup) DivisionResponsibility(c *gin.Context) { + isTrue, userCont := commonus.ClientIdentity() + if isTrue != true { + response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) + return + } + var requestData DivisionPeople + err := c.ShouldBindJSON(&requestData) + if err != nil { + response.Result(101, err, "参数错误!请重新提交!", c) + return + } + if requestData.OrderId == "" { + response.Result(102, err, "参数错误!请重新提交!", c) + return + } + if requestData.Number == "" { + response.Result(102, err, "参数错误!请重新提交!", c) + return + } + var registerCont assessmentmodel.Register + regErr := registerCont.GetCont(map[string]interface{}{"number": requestData.Number}, "`id`", "`state`") + if regErr != nil { + response.Result(102, regErr, "对不起!您没有权限进行此操作!", c) + return + } + if registerCont.State != 1 { + response.Result(102, regErr, "对不起!您已经执行了此操作!请不要重复执行!谢谢!", c) + return + } + + if len(requestData.UserList) < 1 { + response.Result(105, requestData, "请选择要考核的人员!", c) + return + } + for _, u_v := range requestData.UserList { + if len(u_v.UserKey) < 1 { + response.Result(105, requestData, "您有未输入的考核的人员选项!", c) + return + } + } + orderId, _ := strconv.ParseInt(requestData.OrderId, 10, 64) //将字符串转化成int64 + var evalProcessInfo assessmentmodel.EvaluationProcess + evalErr := global.GVA_DB_Performanceappraisal.Where("ep_order_key = ?", requestData.OrderId).First(&evalProcessInfo).Error + if evalErr != nil { + response.Result(103, err, "审批流不存在!请检查您的数据!", c) + return + } + if evalProcessInfo.State == 3 || evalProcessInfo.NextStep <= 0 { + response.Result(104, err, "该流程已结束!不可进行操作!", c) + return + } + if evalProcessInfo.NextContent == "" { + response.Result(105, err, "对不起!您没有权限对此流程进行操作!", c) + return + } + nextReplyUserMap := strings.Split(evalProcessInfo.NextExecutor, ",") + // fmt.Printf("userCont.Key:%v\n", userCont.Key) + if commonus.IsItTrueString(userCont.Key, nextReplyUserMap) == false { + response.Result(106, nextReplyUserMap, "对不起!您没有权限对此流程进行操作!", c) + return + } + //2、获取审批单信息 + var scoreFlowInfo assessmentmodel.ScoreFlow + judegFlowErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", requestData.OrderId).First(&scoreFlowInfo).Error + if judegFlowErr != nil { + response.Result(107, err, "对不起!此审批流程已经关闭!请联系发起人!", c) + return + } + //获取考核项目内容 + var programme assessmentmodel.QualitativeEvaluation + judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", scoreFlowInfo.EvaluationPlan).First(&programme).Error + if judgeProgramme != nil { + response.Result(105, programme, "未知考核项目!请检查你的提交是否正确!", c) + return + } + // founderDepartId, _ := strconv.ParseInt(userCont.Deparment, 10, 64) + // userKeyInt, _ := strconv.ParseInt(userCont.Key, 10, 64) //使用人KEY + opinionCont := "责任划分" + + commonus.StepAddData(orderId, 16118387069540343, 4, 3, 1, 2, 3, userCont.Key) //更新审批流 + commonus.WriteReplyLog(orderId, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 1, commonus.GetSetpName(3), opinionCont) //写入审批流 + + //确定相关责任人 + sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, scoreFlowInfo.DutyDepartment) //获取对应部门负责人 + if sendUserIsTrue != true { + response.Result(109, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c) + return + } + + var saveDataAry []assessmentmodel.DivisionResponsibilities + var userKeyAry []int64 + var userKeyMainAry []int64 + var MainResponsiblePerson MainResponsiblePersonType + var teamIsTrue int = 1 + var reason string //引用文本描述 + for _, v := range requestData.UserList { + var saveDataCont assessmentmodel.DivisionResponsibilities + saveDataCont.ScoreFlow = orderId //流程Key + saveDataCont.Type = v.Type //责任类型(1、主要责任人;2、互保责任人;3、责任班组;4、责任班组长;5、主管;6、三大员;7、厂长、主任) + departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64) + if departmentIdErr == nil { + saveDataCont.EvaluationDepartment = departmentId //测评人部门 + } + userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64) + if userKeyErr == nil { + saveDataCont.EvaluationUser = userKey //测评人 + } + userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64) + if userGroupErr == nil { + saveDataCont.EvaluationGroup = userGroup //测评人集团 + } + if v.Type != 3 { + userKeyLen := len(v.UserKey) + if userKeyLen < 1 { + userKeyLen = 1 + } + //分配权限 + weightFloat := float64(v.Weight) / float64(userKeyLen) + weightInt := commonus.Round(weightFloat, 2) * 100 + weightInt64, _ := strconv.ParseInt(strconv.FormatFloat(weightInt, 'f', -1, 64), 10, 64) + //不是班组选项 + for _, ua_v := range v.UserKey { + userConting, userIsTrue := commonus.GetWorkUser(ua_v) + if userIsTrue == true { + } + saveDataCont.UserName = userConting.Name + saveDataCont.Weight = weightInt64 + saveDataCont.Time = time.Now().Unix() + saveDataCont.EiteTime = time.Now().Unix() + saveDataCont.DistributionUser = commonus.GetFileNumberEs() + + saveDataCont.UserKey = userConting.Key + saveDataCont.Group = userConting.Group + saveDataCont.Department = userConting.DepartmentId + saveDataCont.Tema = userConting.Tema + if v.Type != 3 { + userKeyAry = append(userKeyAry, userConting.Key) + } + var zeren string + switch v.Type { + case 1: + zeren = "主要责任人" + MainResponsiblePerson.UserKey = userConting.Key + MainResponsiblePerson.Group = userConting.Group + MainResponsiblePerson.Department = userConting.DepartmentId + MainResponsiblePerson.WorkshopId = userConting.WorkshopId + MainResponsiblePerson.Tema = userConting.Tema + userKeyMainAry = append(userKeyMainAry, userConting.Key) + case 2: + zeren = "互保责任人" + case 3: + zeren = "责任班组" + case 4: + zeren = "责任班组长" + case 5: + zeren = "主管" + case 6: + zeren = "三大员" + case 7: + zeren = "主任" + case 8: + zeren = "厂长" + default: + zeren = "主要责任人" + } + reason = fmt.Sprintf("%v%v:%v 责任占比:%v\n", reason, zeren, userConting.Name, weightInt64/100) + + saveDataAry = append(saveDataAry, saveDataCont) + } + } else { + teamIsTrue = 2 + } + } + + //遍历班组情况 + if teamIsTrue == 2 { + for _, t_v := range requestData.UserList { + if t_v.Type == 3 { + + var saveDataContTeam assessmentmodel.DivisionResponsibilities + saveDataContTeam.ScoreFlow = orderId //流程Key + saveDataContTeam.Type = t_v.Type //责任类型(1、主要责任人;2、互保责任人;3、责任班组;4、责任班组长;5、主管;6、三大员;7、厂长、主任) + departmentId, departmentIdErr := strconv.ParseInt(userCont.Deparment, 10, 64) + if departmentIdErr == nil { + saveDataContTeam.EvaluationDepartment = departmentId //测评人部门 + } + userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64) + if userKeyErr == nil { + saveDataContTeam.EvaluationUser = userKey //测评人 + } + userGroup, userGroupErr := strconv.ParseInt(userCont.Company, 10, 64) + if userGroupErr == nil { + saveDataContTeam.EvaluationGroup = userGroup //测评人集团 + } + for _, tt_v := range t_v.UserKey { + teamIdInt64, _ := strconv.ParseInt(tt_v, 10, 64) + teamContErr, teamCont := commonus.GetTeaming(teamIdInt64) + if teamContErr == true { + reason = fmt.Sprintf("%v%v:%v 责任占比:%v\n", reason, "责任班组", teamCont.Name, t_v.Weight) + } + teamGroup := strconv.FormatInt(MainResponsiblePerson.Group, 10) + teamDepartment := strconv.FormatInt(MainResponsiblePerson.Department, 10) + teamWorkshopId := strconv.FormatInt(MainResponsiblePerson.WorkshopId, 10) + teamUserList, teamUserErr := commonus.GetTeamUserList(teamGroup, teamDepartment, teamWorkshopId, tt_v) + if teamUserErr == true { + var jiShuQi int64 = 0 + for _, tu_v := range teamUserList { + + if commonus.IsItTrue(tu_v.Key, userKeyAry) == false { + jiShuQi++ + } + } + if jiShuQi < 1 { + jiShuQi = 1 + } + //分配权限 + weightFloat := float64(t_v.Weight) / float64(jiShuQi) + weightInt := commonus.Round(weightFloat, 2) * 100 + weightInt64, _ := strconv.ParseInt(strconv.FormatFloat(weightInt, 'f', -1, 64), 10, 64) + + for _, tu_v := range teamUserList { + if commonus.IsItTrue(tu_v.Key, userKeyAry) == false { + saveDataContTeam.UserName = tu_v.Name + saveDataContTeam.Weight = weightInt64 + saveDataContTeam.Time = time.Now().Unix() + saveDataContTeam.EiteTime = time.Now().Unix() + saveDataContTeam.DistributionUser = commonus.GetFileNumberEs() + + saveDataContTeam.UserKey = tu_v.Key + saveDataContTeam.Group = tu_v.Group + saveDataContTeam.Department = tu_v.DepartmentId + saveDataContTeam.Tema = tu_v.Tema + + saveDataAry = append(saveDataAry, saveDataContTeam) + } + } + } + } + } + } + } + if len(saveDataAry) < 1 { + response.Result(107, saveDataAry, "请检查您提交的要考核人员名单是否正确!", c) + return + } + //同一订单下,删除原有的责任人,再从新分配责任人。 + global.GVA_DB_Performanceappraisal.Where("df_sf_id = ?", orderId).Delete(&assessmentmodel.DivisionResponsibilities{}) + writeDataErr := global.GVA_DB_Performanceappraisal.Create(&saveDataAry).Error + if writeDataErr != nil { + response.Result(108, writeDataErr, "数据写入失败", c) + return + } + registerCont.EiteCont(map[string]interface{}{"id": registerCont.Id}, map[string]interface{}{"state": 2, "`time`": time.Now().Unix()}) + + //修改定性审批流状态 + eiteScoreFlow := commonus.MapOut() + eiteScoreFlow["sf_eite_time"] = time.Now().Unix() + eiteScoreFlow["sf_reply"] = 2 + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_key` = ?", orderId).Updates(&eiteScoreFlow) + evalProcSaveData := commonus.MapOut() + evalProcSaveData["ep_state"] = 2 + evalProcSaveData["ep_time"] = time.Now().Unix() + global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", orderId).Updates(&evalProcSaveData) + + //获取执行结果 + var mainTitleDesc string = "" + + //分数 + sendScore := scoreFlowInfo.Score * int64(scoreFlowInfo.Count) + if scoreFlowInfo.PlusReduceScore == 1 { + mainTitleDesc = fmt.Sprintf("考核加分:%v\n", commonus.Decimal(float64(sendScore)/100)) + } else { + mainTitleDesc = fmt.Sprintf("考核减分:%v\n", commonus.Decimal(float64(sendScore)/100)) + } + + //确定标题 + var title string = "" + //一级标题副本内容 + var desc string = "" + detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget) //获取指标细则 + if detailedTargetErr == true { + tarInf, tarErr := commonus.GetTargetInfo(detailedTargetCont.ParentId) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + desc = detailedTargetCont.Title //一级标题辅助信息,建议不超过44个字 + } else { + title = detailedTargetCont.Title //一级标题,建议不超过36个字 + } + } else { + tarInf, tarErr := commonus.GetTargetInfo(programme.Target) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + } else { + title = strconv.FormatInt(programme.DetailedTarget, 10) //一级标题,建议不超过36个字 + } + } + + //将步骤写入 判断该步骤是否已经操作 + registerNumber := commonus.GetFileNumberEs() + var registerContIng assessmentmodel.Register + registerContIng.Number = registerNumber + registerContIng.State = 1 + registerContIng.Time = time.Now().Unix() + registerContIng.AddCont() + //审批卡片跳转链接 + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderId, strconv.FormatInt(registerNumber, 10)) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", orderId, strconv.FormatInt(registerNumber, 10)) + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(scoreFlowInfo.DutyDepartment) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + jumpUrlTitle := "查看详情" + sourceDesc := "审批" + twoLevelTitle := "责任划分人:" + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, mainTitleDesc, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap := commonus.MapOut() + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 41 + response.Result(0, outMap, "数据写入成功", c) +} + +//填写整改措施 +func (a *ApiGroup) AmendMeasures(c *gin.Context) { + isTrue, userCont := commonus.ClientIdentity() + if isTrue != true { + response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) + return + } + var requestData AmendType + err := c.ShouldBindJSON(&requestData) + if err != nil { + response.Result(101, err, "参数错误!请重新提交!", c) + return + } + if requestData.OrderId == "" { + response.Result(102, err, "参数错误!请重新提交!", c) + return + } + if requestData.Number == "" { + response.Result(102, err, "参数错误!请重新提交!", c) + return + } + if requestData.Content == "" { + response.Result(102, err, "请输入整改措施!", c) + return + } + var registerCont assessmentmodel.Register + regErr := registerCont.GetCont(map[string]interface{}{"number": requestData.Number}, "`id`", "`state`") + if regErr != nil { + response.Result(102, regErr, "对不起!您没有权限进行此操作!", c) + return + } + if registerCont.State != 1 { + response.Result(102, regErr, "对不起!您已经执行了此操作!请不要重复执行!谢谢!", c) + return + } + + var evalProcessInfo assessmentmodel.EvaluationProcess + evalErr := global.GVA_DB_Performanceappraisal.Where("ep_order_key = ?", requestData.OrderId).First(&evalProcessInfo).Error + if evalErr != nil { + response.Result(103, err, "审批流不存在!请检查您的数据!", c) + return + } + if evalProcessInfo.State == 3 || evalProcessInfo.NextStep <= 0 { + response.Result(104, err, "该流程已结束!不可进行操作!", c) + return + } + if evalProcessInfo.NextContent == "" { + response.Result(105, err, "对不起!您没有权限对此流程进行操作!", c) + return + } + nextReplyUserMap := strings.Split(evalProcessInfo.NextExecutor, ",") + if commonus.IsItTrueString(userCont.Key, nextReplyUserMap) == false { + response.Result(106, nextReplyUserMap, "对不起!您没有权限对此流程进行操作!", c) + return + } + userKey, _ := strconv.ParseInt(userCont.Key, 10, 64) + departmentId, _ := strconv.ParseInt(userCont.Deparment, 10, 64) + userGroup, _ := strconv.ParseInt(userCont.Company, 10, 64) + orderidval, _ := strconv.ParseInt(requestData.OrderId, 10, 64) + + var addRecMeas assessmentmodel.RectificationMeasures + addRecMeas.UserKey = userKey + addRecMeas.Department = departmentId + addRecMeas.Group = userGroup + addRecMeas.OrderKey = orderidval + addRecMeas.State = 1 + addRecMeas.Time = time.Now().Unix() + addRecMeas.EiteTime = time.Now().Unix() + addRecMeas.Content = requestData.Content + if len(requestData.Enclosure) > 0 { + enclosure, enclosureErr := json.Marshal(requestData.Enclosure) + if enclosureErr == nil { + addRecMeas.Enclosure = string(enclosure) //附件 + } + } + addErr := global.GVA_DB_Performanceappraisal.Create(&addRecMeas).Error + if addErr != nil { + response.Result(109, addErr, "数据写入失败", c) + return + } + + //2、获取审批单信息 + var scoreFlowInfo assessmentmodel.ScoreFlow + judegFlowErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", requestData.OrderId).First(&scoreFlowInfo).Error + if judegFlowErr != nil { + response.Result(107, err, "对不起!此审批流程已经关闭!请联系发起人!", c) + return + } + //获取考核项目内容 + var programme assessmentmodel.QualitativeEvaluation + judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", scoreFlowInfo.EvaluationPlan).First(&programme).Error + if judgeProgramme != nil { + response.Result(105, programme, "未知考核项目!请检查你的提交是否正确!", c) + return + } + opinionCont := fmt.Sprintf("整改措施:%v", requestData.Content) + //写入流程步骤 + commonus.StepAddDataEs(orderidval, 0, 6, 4, 1, 2, 5, userCont.Key, requestData.Enclosure) //更新审批流 + commonus.WriteReplyLog(orderidval, scoreFlowInfo.DutyDepartment, scoreFlowInfo.EvaluationDepartment, scoreFlowInfo.EvaluationUser, 1, commonus.GetSetpName(3), opinionCont) //写入审批流 + + sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, scoreFlowInfo.DutyDepartment) //获取对应部门负责人 + if sendUserIsTrue != true { + response.Result(109, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c) + return + } + + //确定标题 + var title string = "" + //一级标题副本内容 + var desc string = "" + detailedTargetCont, detailedTargetErr := commonus.GetDetailedTargetInfo(programme.DetailedTarget) //获取指标细则 + if detailedTargetErr == true { + tarInf, tarErr := commonus.GetTargetInfo(detailedTargetCont.ParentId) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + desc = detailedTargetCont.Title //一级标题辅助信息,建议不超过44个字 + } else { + title = detailedTargetCont.Title //一级标题,建议不超过36个字 + } + } else { + tarInf, tarErr := commonus.GetTargetInfo(programme.Target) //获取指标信息 + if tarErr == true { + title = tarInf.Title //一级标题,建议不超过36个字 + } else { + title = strconv.FormatInt(programme.DetailedTarget, 10) //一级标题,建议不超过36个字 + } + } + + //获取执行结果 + var mainTitleDesc string = "" + + //分数 + sendScore := scoreFlowInfo.Score * int64(scoreFlowInfo.Count) + if scoreFlowInfo.PlusReduceScore == 1 { + mainTitleDesc = fmt.Sprintf("考核加分:%v\n", commonus.Decimal(float64(sendScore)/100)) + } else { + mainTitleDesc = fmt.Sprintf("考核减分:%v\n", commonus.Decimal(float64(sendScore)/100)) + } + + var reason string + reason = fmt.Sprintf("整改措施:\n%v", requestData.Content) + //将步骤写入 判断该步骤是否已经操作 + registerNumber := commonus.GetFileNumberEs() + var registerContIng assessmentmodel.Register + registerContIng.Number = registerNumber + registerContIng.State = 1 + registerContIng.Time = time.Now().Unix() + registerContIng.AddCont() + //审批卡片跳转链接 + cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", requestData.OrderId, strconv.FormatInt(registerNumber, 10)) + jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v&num=%v", requestData.OrderId, strconv.FormatInt(registerNumber, 10)) + + jumpUrlTitle := "查看详情" + sourceDesc := "审批" + twoLevelTitle := "整改人:" + + twoLevelKeyName := "" + execDerpat, execDerpatErr := commonus.GetNewOrgCont(scoreFlowInfo.DutyDepartment) + if execDerpatErr == nil { + twoLevelKeyName = execDerpat.Name + } + var twoLevelKeyValue string = "" + var twoLevelUserId string = "" + //获取操作人 + if userCont.Wechat != "" { + userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.Wechat) + if userWechatErr == true { + twoLevelKeyValue = userWechat.Name + twoLevelUserId = userCont.Wechat + } + } + + var sendTextMsg sendmessage.TextNoticeTemplateMedium + callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendMsgTextShare(sendUserList, strconv.FormatInt(registerNumber, 10), title, desc, mainTitleDesc, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) + outMap := commonus.MapOut() + outMap["callbakcMsg"] = string(callbakcMsg) + outMap["isTrueCall"] = isTrueCall + outMap["callBackCont"] = callBackCont + outMap["setval"] = 41 + response.Result(0, outMap, "数据写入成功", c) +} diff --git a/gin_server_admin/api/reply/qual/enter.go b/gin_server_admin/api/reply/qual/enter.go new file mode 100644 index 0000000..b1d652f --- /dev/null +++ b/gin_server_admin/api/reply/qual/enter.go @@ -0,0 +1,57 @@ +package qual + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/commonus" + "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" + "github.com/gin-gonic/gin" +) + +//企业微信回调 +type ApiGroup struct { +} + +//入口 +func (a *ApiGroup) Index(c *gin.Context) { + outPut := commonus.MapOut() + response.Result(0, outPut, "定性审批端获取成功", c) +} + +//审批参数 +type ApprovalParameters struct { + OrderId string `json:"orderid"` //流程单KEY + YesOrNo int `json:"yesorno"` //1:同意;2:驳回 + Content string `json:"content"` //审批意见 +} + +type orderIdOrNumber struct { + OrderId string `json:"id"` //流程单KEY + Number string `json:"number"` //1:同意;2:驳回 +} + +type DivisionPeople struct { + orderIdOrNumber + UserList []DivisionResponsibilityUsers `json:"userlist"` //责任人 +} + +type DivisionResponsibilityUsers struct { + Type int `json:"type"` //责任类型(1、主要责任人;2、互保责任人;3、责任班组;4、责任班组长;5、主管;6、三大员;7、厂长;8、主任) + UserKey []string `json:"userkey"` //责任人key + // UserName string `json:"username"` //责任人姓名 + Weight int64 `json:"weight"` //权重 + +} + +type MainResponsiblePersonType struct { + UserKey int64 `json:"userkey"` + Department int64 `json:"department"` + Group int64 `json:"group"` + WorkshopId int64 `json:"workshopid"` + Tema int64 `json:"tema"` + Weight int64 `json:"weight"` +} + +type AmendType struct { + orderIdOrNumber + Content string `json:"content"` //整改内容 + Enclosure []commonus.EnclosureFormat `json:"enclosure"` //附件 +} diff --git a/gin_server_admin/api/reply/quan/enter.go b/gin_server_admin/api/reply/quan/enter.go new file mode 100644 index 0000000..ce685d1 --- /dev/null +++ b/gin_server_admin/api/reply/quan/enter.go @@ -0,0 +1,17 @@ +package quan + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/commonus" + "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" + "github.com/gin-gonic/gin" +) + +//企业微信回调 +type ApiGroup struct { +} + +//入口 +func (a *ApiGroup) Index(c *gin.Context) { + outPut := commonus.MapOut() + response.Result(0, outPut, "定量审批端获取成功", c) +} diff --git a/gin_server_admin/api/wechatapp/sendmessage/sendmsgHandle.go b/gin_server_admin/api/wechatapp/sendmessage/sendmsgHandle.go index 3cc5f4c..4a7daf8 100644 --- a/gin_server_admin/api/wechatapp/sendmessage/sendmsgHandle.go +++ b/gin_server_admin/api/wechatapp/sendmessage/sendmsgHandle.go @@ -417,7 +417,7 @@ func (t *TextNoticeTemplateMedium) SendNewsMsgText(sendUserList, taskId, title, } //发送文本信息通用 -/* +/*SendMsgTextShare(sendUserList, taskId, title, desc, quoteAreaTitle, quoteAreaContent, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc string) (callbakcMsg []byte, isTrueCall bool, callBackCont string) @sendUserList 信息接收人 @taskId 任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填 @Title 一级标题,建议不超过36个字, diff --git a/gin_server_admin/commonus/publichaneld.go b/gin_server_admin/commonus/publichaneld.go index c4ada7a..895b067 100644 --- a/gin_server_admin/commonus/publichaneld.go +++ b/gin_server_admin/commonus/publichaneld.go @@ -1641,7 +1641,7 @@ func GetWorkWechatDuiZhao(openid string) (userInfoStruct wechat.WechatUsers, isT } //步骤内容写入 -/* +/*StepAddData(flowID, roleGroupId , nextStep, stepName, typeclass, state, stepInt , userKey ) @flowID 流程ID @userKey 操作人key @roleGroupId 角色组Id @@ -1764,9 +1764,25 @@ func StepAddData(flowID, roleGroupId int64, nextStep, stepName, typeclass, state } else { saveData["ep_next_executor"] = "" } + if evalProCont.Participants == "" { + saveData["ep_participants"] = userKey + } else { + evalProContUserAry := strings.Split(evalProCont.Participants, ",") + if len(evalProContUserAry) > 0 { + if IsItTrueString(userKey, evalProContUserAry) == false { + evalProContUserAry = append(evalProContUserAry, userKey) + } + saveData["ep_participants"] = strings.Join(evalProContUserAry, ",") + } else { + saveData["ep_participants"] = userKey + } + } + if nextStep == 0 { + saveData["ep_state"] = 3 + } else { + saveData["ep_state"] = state + } - saveData["ep_participants"] = fmt.Sprintf("%v,%v", evalProCont.Participants, userKey) - saveData["ep_state"] = state saveData["ep_next_cont"] = InsetFlowLog(state, stepInt, userKey, evalProCont.NextContent) // fmt.Printf("Flow---Map:--->%v\n", saveData) @@ -1776,7 +1792,11 @@ func StepAddData(flowID, roleGroupId int64, nextStep, stepName, typeclass, state caozuoMap["nextStep"] = nextStep caozuoMap["stepName"] = stepName caozuoMap["typeclass"] = typeclass - caozuoMap["state"] = state + if nextStep == 0 { + caozuoMap["state"] = 3 + } else { + caozuoMap["state"] = state + } caozuoMap["stepInt"] = stepInt caozuoMap["userKey"] = userKey caozuoMap["NextContent"] = evalProCont.NextContent @@ -1844,6 +1864,7 @@ func StepAddDataEs(flowID, roleGroupId int64, nextStep, stepName, typeclass, sta } global.GVA_DB_Performanceappraisal.Create(&evalProCont) + } else { var flowStepAry []FlowStep var flowStepArys []FlowStep @@ -1900,8 +1921,26 @@ func StepAddDataEs(flowID, roleGroupId int64, nextStep, stepName, typeclass, sta saveData["ep_next_executor"] = "" } - saveData["ep_participants"] = fmt.Sprintf("%v,%v", evalProCont.Participants, userKey) - saveData["ep_state"] = state + if evalProCont.Participants == "" { + saveData["ep_participants"] = userKey + } else { + evalProContUserAry := strings.Split(evalProCont.Participants, ",") + if len(evalProContUserAry) > 0 { + if IsItTrueString(userKey, evalProContUserAry) == false { + evalProContUserAry = append(evalProContUserAry, userKey) + } + saveData["ep_participants"] = strings.Join(evalProContUserAry, ",") + } else { + saveData["ep_participants"] = userKey + } + } + if nextStep == 0 { + saveData["ep_state"] = 3 + } else { + saveData["ep_state"] = state + } + // saveData["ep_participants"] = fmt.Sprintf("%v,%v", evalProCont.Participants, userKey) + // saveData["ep_state"] = state saveData["ep_next_cont"] = InsetFlowLogEs(state, stepInt, userKey, evalProCont.NextContent, encFile) // fmt.Printf("Flow---Map:--->%v\n", saveData) @@ -1977,7 +2016,7 @@ func InsetFlowLog(state, stepInt int, userKey, flowMapStr string) (flowAllMap st userClick.TemaName = u_v.TemaName userClick.Wechat = u_v.Wechat - // fmt.Printf("Flow_log:--UsekKey-->%v-->%v\n", u_v.Id, userKey) + fmt.Printf("Flow_log:--UsekKey-->%v-->%v\n", u_v.Id, userKey) if u_v.Id == userKey { var logListMap LogList logListMap.State = state @@ -2057,6 +2096,7 @@ func InsetFlowLogEs(state, stepInt int, userKey, flowMapStr string, encFile []En logListMap.TimeVal = GetToDayAll() logListMap.Enclosure = encFile userClick.LogList = append(userClick.LogList, logListMap) + } userClickAry = append(userClickAry, userClick) @@ -3809,3 +3849,27 @@ func IsLeapYear(year int64) bool { //y == 2000,2004 return false } + +/*WriteReplyLog(orderId, acceptDepartment, launchDepartment, launchUser, state, title, content) +@orderId 审批单key +@title 节点名称 +@acceptDepartment 接受考核部门 +@launchDepartment 发起考核部门 +@launchUser 考核发起人 +@state 申请单当前审批状态:1-审批中;2-已通过;3-已驳回;4-已取消 +@content 意见 +*/ +func WriteReplyLog(orderId, acceptDepartment, launchDepartment, launchUser, state int64, title, content string) { + var assessLogTwo assessmentmodel.AssessmentLogIng + assessLogTwo.OrderId = orderId + assessLogTwo.Title = title + assessLogTwo.Assdepart = acceptDepartment + assessLogTwo.ExecutorDepart = launchDepartment + assessLogTwo.ExecutorUser = launchUser + assessLogTwo.ExecutorTime = time.Now().Unix() + assessLogTwo.States = state + assessLogTwo.AddTime = time.Now().Unix() + assessLogTwo.EiteTime = time.Now().Unix() + assessLogTwo.DutyList = content + global.GVA_DB_Performanceappraisal.Create(&assessLogTwo) +} diff --git a/gin_server_admin/initialize/internal/logger.go b/gin_server_admin/initialize/internal/logger.go index 25b7b8c..6e7c081 100644 --- a/gin_server_admin/initialize/internal/logger.go +++ b/gin_server_admin/initialize/internal/logger.go @@ -22,7 +22,7 @@ type config struct { var ( Discard = New(log.New(ioutil.Discard, "", log.LstdFlags), config{}) Default = New(log.New(os.Stdout, "\r\n", log.LstdFlags), config{ - SlowThreshold: 200 * time.Millisecond, + SlowThreshold: 20000 * time.Millisecond, LogLevel: logger.Warn, Colorful: true, }) diff --git a/gin_server_admin/initialize/router.go b/gin_server_admin/initialize/router.go index a372456..2807ab6 100644 --- a/gin_server_admin/initialize/router.go +++ b/gin_server_admin/initialize/router.go @@ -84,6 +84,9 @@ func Routers() *gin.Engine { groupMangMentRouter := router.RouterGroupApp.AdminRouter.GroupMangMentRouter // GroupMangMentRouter + //自建审批应答 + myReplyRoute := router.RouterGroupApp.ReplyRouterGroup + PublicGroup := Router.Group("") { PublicGroup.GET("/", func(c *gin.Context) { @@ -175,6 +178,8 @@ func Routers() *gin.Engine { statisAppRove.InitRouter(MyCustomPrivateGroup) //统计相关 planVersioStatis.InitRouter(MyCustomPrivateGroup) //根据激活版本统计 + + myReplyRoute.InitShiyanRouter(MyCustomPrivateGroup) //自定义审批 } //自定义后台登录 MyCustomSystemGroup := Router.Group("") diff --git a/gin_server_admin/model/assessmentmodel/dutyclass.go b/gin_server_admin/model/assessmentmodel/dutyclass.go index 46c92ce..bad867f 100644 --- a/gin_server_admin/model/assessmentmodel/dutyclass.go +++ b/gin_server_admin/model/assessmentmodel/dutyclass.go @@ -156,6 +156,24 @@ func (AssessmentLog *AssessmentLog) TableName() string { return "assessment_log" } +type AssessmentLogIng struct { + Id int64 `json:"id" gorm:"primaryKey;column:al_id;type:bigint(20) unsigned;not null;comment:Id"` + Title string `json:"title" gorm:"column:al_title;type:varchar(255);comment:考核标题"` + Assdepart int64 `json:"assdepart" gorm:"column:al_assdepart;type:bigint(20) unsigned;default:0;not null;comment:被考核部门"` + ExecutorUser int64 `json:"executorUser" gorm:"column:al_executor_user;type:bigint(20) unsigned;default:0;not null;comment:执行人"` + ExecutorDepart int64 `json:"executorDepart" gorm:"column:al_executor_depart;type:bigint(20) unsigned;default:0;not null;comment:执行人部门"` + ExecutorTime int64 `json:"executorTime" gorm:"column:al_executor_time;type:bigint(20) unsigned;default:0;not null;comment:执行时间"` + OrderId int64 `json:"orderId" gorm:"column:al_order_id;type:bigint(20) unsigned;default:0;not null;comment:审批流ID"` + States int64 `json:"states" gorm:"column:al_states;type:int(1) unsigned;default:0;not null;comment:申请单当前审批状态:1-审批中;2-已通过;3-已驳回;4-已取消"` + AddTime int64 `json:"addTime" gorm:"column:al_time;type:bigint(20) unsigned;default:0;not null;comment:添加时间"` + EiteTime int64 `json:"eiteTime" gorm:"column:al_eite_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + DutyList string `json:"dutyList" gorm:"column:al_duty_list;type:longtext;comment:评价内容"` +} + +func (AssessmentLog *AssessmentLogIng) TableName() string { + return "assessment_loging" +} + //考核方案 type EvaluationScheme struct { Id int64 `json:"id" gorm:"primaryKey;column:es_id;type:bigint(20) unsigned;not null;comment:Id"` diff --git a/gin_server_admin/router/enter.go b/gin_server_admin/router/enter.go index 4ae0135..b4917fe 100644 --- a/gin_server_admin/router/enter.go +++ b/gin_server_admin/router/enter.go @@ -10,6 +10,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/router/index/examapprove" "github.com/flipped-aurora/gin-vue-admin/server/router/index/statisticsroute" "github.com/flipped-aurora/gin-vue-admin/server/router/publichandel" + "github.com/flipped-aurora/gin-vue-admin/server/router/replyrouter" "github.com/flipped-aurora/gin-vue-admin/server/router/shiyan" "github.com/flipped-aurora/gin-vue-admin/server/router/staffrouter" "github.com/flipped-aurora/gin-vue-admin/server/router/statisticsrouter" @@ -40,6 +41,7 @@ type RouterGroup struct { WebApiRoute webrouter.WebRouter StatisticsRouter statisticsrouter.RouterGroup StatisticsVersion statisticsroute.StatisticsRoute + ReplyRouterGroup replyrouter.RouterGroup //自建审批 } var RouterGroupApp = new(RouterGroup) diff --git a/gin_server_admin/router/replyrouter/enter.go b/gin_server_admin/router/replyrouter/enter.go new file mode 100644 index 0000000..1b4a9af --- /dev/null +++ b/gin_server_admin/router/replyrouter/enter.go @@ -0,0 +1,34 @@ +package replyrouter + +import ( + "github.com/flipped-aurora/gin-vue-admin/server/api/reply" + "github.com/gin-gonic/gin" +) + +type RouterGroup struct { +} + +func (r *RouterGroup) InitShiyanRouter(Router *gin.RouterGroup) { + quanRouter := Router.Group("quan") //定量 + var quanApi = reply.ApiGroupApp.QuanAipGroup + { + quanRouter.POST("", quanApi.Index) //入口 + quanRouter.POST("/", quanApi.Index) //入口 + quanRouter.GET("", quanApi.Index) //入口 + quanRouter.GET("/", quanApi.Index) //入口 + + } + qualRouter := Router.Group("qual") //定性 + var qualApi = reply.ApiGroupApp.QualApiGroup + { + qualRouter.POST("", qualApi.Index) //入口 + qualRouter.POST("/", qualApi.Index) //入口 + qualRouter.GET("", qualApi.Index) //入口 + qualRouter.GET("/", qualApi.Index) //入口 + + qualRouter.POST("operation", qualApi.Operation) //定性审批 + qualRouter.POST("divisionresponsibility", qualApi.DivisionResponsibility) //责任划分 + qualRouter.POST("amendmeasures", qualApi.AmendMeasures) //整改措施 + + } +}