31 changed files with 2610 additions and 188 deletions
@ -0,0 +1,647 @@ |
|||
package evaluation |
|||
|
|||
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 (e *EvaluationInterface) PlusOrMinusPoints(c *gin.Context) { |
|||
isTrue, userCont := commonus.ClientIdentity() |
|||
if isTrue != true { |
|||
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
var requestData addPlusOrMinusPoints |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(102, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.PlanId == "" { |
|||
response.Result(103, requestData, "未知考核项目!请检查你的提交是否正确!", c) |
|||
return |
|||
} |
|||
planIdInt, planIdIntErr := strconv.ParseInt(requestData.PlanId, 10, 64) |
|||
if planIdIntErr != nil { |
|||
response.Result(104, requestData, "未知考核项目!请检查你的提交是否正确!", c) |
|||
return |
|||
} |
|||
//获取考核项目内容
|
|||
var programme assessmentmodel.QualitativeEvaluation |
|||
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", planIdInt).First(&programme).Error |
|||
if judgeProgramme != nil { |
|||
response.Result(105, programme, "未知考核项目!请检查你的提交是否正确!", c) |
|||
return |
|||
} |
|||
if requestData.Type == 0 { |
|||
response.Result(106, requestData, "请问您是要进行加分还是减分?请指定,谢谢!", c) |
|||
return |
|||
} |
|||
if requestData.Score == 0 { |
|||
response.Result(107, requestData, "请您输入要操作的分数,谢谢!", c) |
|||
return |
|||
} |
|||
if requestData.Reason == "" { |
|||
response.Result(108, requestData, "请输入您的原因,谢谢!", c) |
|||
return |
|||
} |
|||
if requestData.Addtime == "" { |
|||
response.Result(108, requestData, "请输入您的检查时间,谢谢!", c) |
|||
return |
|||
} |
|||
if requestData.Rectification == 0 { |
|||
requestData.Rectification = 1 |
|||
} |
|||
operationTime := time.Now().Unix() |
|||
keyNumber := commonus.GetFileNumberEs() |
|||
var addScore assessmentmodel.ScoreFlow |
|||
addScore.EvaluationPlan = planIdInt |
|||
addScore.PlusReduceScore = requestData.Type |
|||
addScore.Score = requestData.Score |
|||
addScore.Key = keyNumber |
|||
addScore.Reason = requestData.Reason |
|||
addScore.Time = operationTime |
|||
addScore.EiteTime = operationTime |
|||
addScore.HappenTime = commonus.DateToTimeStamp(requestData.Addtime) |
|||
departmentId, departmentIdErr := strconv.ParseInt(userCont.DepartmentId, 10, 64) |
|||
if departmentIdErr == nil { |
|||
addScore.EvaluationDepartment = departmentId |
|||
} |
|||
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64) |
|||
if userKeyErr == nil { |
|||
addScore.EvaluationUser = userKey |
|||
} |
|||
userGroup, userGroupErr := strconv.ParseInt(userCont.Group, 10, 64) |
|||
if userGroupErr == nil { |
|||
addScore.EvaluationGroup = userGroup |
|||
} |
|||
addScore.Year = commonus.ComputingTime(operationTime, 1) |
|||
addScore.Quarter = commonus.ComputingTime(operationTime, 2) |
|||
addScore.Month = commonus.ComputingTime(operationTime, 3) |
|||
addScore.Week = commonus.ComputingTime(operationTime, 4) |
|||
enclosure, enclosureErr := json.Marshal(requestData.Enclosure) |
|||
if enclosureErr == nil { |
|||
addScore.Enclosure = string(enclosure) |
|||
} |
|||
addScore.DutyGroup = programme.Group |
|||
addScore.DutyDepartment = programme.AcceptEvaluation |
|||
addScore.Rectification = requestData.Rectification |
|||
addScore.Reply = 1 |
|||
addErr := global.GVA_DB_Performanceappraisal.Create(&addScore).Error |
|||
//步进内容
|
|||
|
|||
if addErr != nil { |
|||
response.Result(109, addErr, "数据写入失败", c) |
|||
return |
|||
} |
|||
|
|||
//给发起人部门负责人发送消息
|
|||
//1、获取发起人部门负责人
|
|||
founderDepartId, _ := strconv.ParseInt(userCont.DepartmentId, 10, 64) |
|||
sendUserIsTrue, sendUserList := commonus.GetSendMsgUserAry(16182159043990656, founderDepartId) //获取对应部门负责人
|
|||
if sendUserIsTrue != true { |
|||
// global.GVA_DB_Performanceappraisal.Where("`sf_id` = ?", addScore.Id).Delete(&assessmentmodel.ScoreFlow{})
|
|||
response.Result(0, sendUserList, "未指定相关部门处理人!请确定部门负责人后,重新发起请求!", c) |
|||
return |
|||
} |
|||
//判断发起人是否为部门负责人
|
|||
myIsTrue := 1 |
|||
for _, v := range sendUserList { |
|||
if v == userCont.WechatId || v == userCont.WorkWechatId { |
|||
myIsTrue = 2 |
|||
} |
|||
} |
|||
taskId := strconv.FormatInt(keyNumber, 10) |
|||
//确定标题
|
|||
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) |
|||
//执行操作内容
|
|||
var subtitle string = "" |
|||
if requestData.Type == 1 { |
|||
subtitle = fmt.Sprintf("加:%v%v\n", requestData.Score, programme.Unit) |
|||
} else { |
|||
subtitle = fmt.Sprintf("扣除:%v%v\n", requestData.Score, programme.Unit) |
|||
} |
|||
|
|||
twoLevelTitle := "考核上报部门:" |
|||
|
|||
twoLevelKeyName := "" |
|||
execDerpatErr, execDerpat := commonus.GetBranchFactory(departmentId) |
|||
if execDerpatErr == true { |
|||
twoLevelKeyName = execDerpat.Name |
|||
} |
|||
var twoLevelKeyValue string = "" |
|||
var twoLevelUserId string = "" |
|||
//获取操作人
|
|||
if userCont.WechatId != "" { |
|||
userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.WechatId) |
|||
if userWechatErr == true { |
|||
twoLevelKeyValue = userWechat.Name |
|||
twoLevelUserId = userCont.WechatId |
|||
} |
|||
} |
|||
if userCont.WorkWechatId != "" { |
|||
userWechatErr, userWechat := commonus.GetUesrContForWechatID(userCont.WorkWechatId) |
|||
if userWechatErr == true { |
|||
twoLevelKeyValue = userWechat.Name |
|||
twoLevelUserId = userCont.WorkWechatId |
|||
} |
|||
} |
|||
|
|||
cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v", keyNumber) |
|||
if myIsTrue != 1 { |
|||
//写入当前流程步骤
|
|||
commonus.StepAddData(keyNumber, 0, 3, 1, userCont.Key) |
|||
//申请人也是部门负责人
|
|||
//给相关部门内勤发送消息。确定相关责任人
|
|||
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", keyNumber) |
|||
jumpUrlTitle := "请前往处理" |
|||
sourceDesc := "责任划分" |
|||
var sendTextMsg sendmessage.TextNoticeTemplateMedium |
|||
sendTextMsg.SendMsgTextShare(sendUserList, taskId, title, desc, subtitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) |
|||
|
|||
} else { |
|||
//写入当前流程步骤
|
|||
commonus.StepAddData(keyNumber, 16182159043990656, 2, 1, userCont.Key) |
|||
//申请人不是是部门负责人 给本部门负责人发送审批
|
|||
//获取发起人部门负责人
|
|||
departmentIdInts, _ := strconv.ParseInt(userCont.DepartmentId, 10, 64) |
|||
_, sendUserList := commonus.GetSendMsgUserAry(16182159043990656, departmentIdInts) //获取对应部门负责人
|
|||
sendUserStr := strings.Join(sendUserList, "|") |
|||
//按钮
|
|||
var buttonMap []sendmessage.ButtonListtype |
|||
var buttonCont sendmessage.ButtonListtype |
|||
buttonCont.Type = 0 |
|||
buttonCont.Text = "批准" |
|||
buttonCont.Style = 1 |
|||
buttonCont.Key = fmt.Sprintf("duty_%v_1_%v", keyNumber, 0) |
|||
buttonMap = append(buttonMap, buttonCont) |
|||
buttonCont.Type = 0 |
|||
buttonCont.Text = "驳回" |
|||
buttonCont.Style = 3 |
|||
buttonCont.Key = fmt.Sprintf("duty_%v_2_%v", keyNumber, 0) |
|||
buttonMap = append(buttonMap, buttonCont) |
|||
var sendTextMsg sendmessage.ButtonNoticeTemplateMedium |
|||
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendButtonShare(sendUserStr, taskId, "部门负责人审批", title, desc, subtitle, reason, twoLevelTitle, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, buttonMap) |
|||
outData := commonus.MapOut() |
|||
outData["callbakcMsg"] = string(callbakcMsg) |
|||
outData["isTrueCall"] = isTrueCall |
|||
outData["callBackCont"] = callBackCont |
|||
response.Result(0, outData, "数据写入成功", c) |
|||
} |
|||
} |
|||
|
|||
//添加责任人
|
|||
func (e *EvaluationInterface) PersonInCharge(c *gin.Context) { |
|||
isTrue, userCont := commonus.ClientIdentity() |
|||
if isTrue != true { |
|||
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
var requestData DivisionResponsibilityTypes |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(102, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.Id == "" { |
|||
response.Result(103, requestData, "未知考核项目!请检查你的提交是否正确!", c) |
|||
return |
|||
} |
|||
orderId, orderIdIntErr := strconv.ParseInt(requestData.Id, 10, 64) |
|||
if orderIdIntErr != nil { |
|||
response.Result(104, requestData, "未知考核项目!请检查你的提交是否正确!", c) |
|||
return |
|||
} |
|||
if len(requestData.UserList) < 1 { |
|||
response.Result(105, requestData, "请选择要考核的人员!", c) |
|||
return |
|||
} else { |
|||
for _, u_v := range requestData.UserList { |
|||
if len(u_v.UserKey) < 1 { |
|||
response.Result(105, requestData, "您有未输入的考核的人员选项!", c) |
|||
return |
|||
} |
|||
// if u_v.Type != 3 {
|
|||
// if len(u_v.UserKey) < 1 {
|
|||
// response.Result(105, requestData, "您有未输入的考核的人员选项!", c)
|
|||
// return
|
|||
// }
|
|||
// }else{}
|
|||
} |
|||
} |
|||
//写入审批流程
|
|||
commonus.StepAddData(orderId, 0, 4, 3, userCont.Key) |
|||
var scoreFlowInfo assessmentmodel.ScoreFlow |
|||
judegFlowErr := global.GVA_DB_Performanceappraisal.Where("`sf_key` = ?", orderId).First(&scoreFlowInfo).Error |
|||
if judegFlowErr != nil { |
|||
response.Result(106, judegFlowErr, "未知考核项目!请检查你的提交是否正确!", c) |
|||
return |
|||
} |
|||
//获取考核项目内容
|
|||
var programme assessmentmodel.QualitativeEvaluation |
|||
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", scoreFlowInfo.EvaluationPlan).First(&programme).Error |
|||
if judgeProgramme != nil { |
|||
response.Result(107, programme, "未知考核项目!请检查你的提交是否正确!", c) |
|||
return |
|||
} |
|||
//确定相关责任人
|
|||
sendUserIsTrue, sendUserList := commonus.GetSendMsgUser(16182159043990656, scoreFlowInfo.DutyDepartment) //获取对应部门负责人
|
|||
if sendUserIsTrue != true { |
|||
response.Result(109, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c) |
|||
return |
|||
} |
|||
|
|||
var reason string //引用文本描述
|
|||
var saveDataAry []assessmentmodel.DivisionResponsibilities |
|||
var userKeyAry []int64 |
|||
var MainResponsiblePerson MainResponsiblePersonType |
|||
var teamIsTrue int = 1 |
|||
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.DepartmentId, 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.Group, 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, 'g', 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 |
|||
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 |
|||
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.DepartmentId, 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.Group, 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 judgeIsSet(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, 'g', 1, 64), 10, 64) |
|||
|
|||
for _, tu_v := range teamUserList { |
|||
if judgeIsSet(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 |
|||
} |
|||
flowSaveData := commonus.MapOut() |
|||
flowSaveData["sf_reply"] = 2 |
|||
flowSaveData["sf_eite_time"] = time.Now().Unix() |
|||
EiteScoreFlow(orderId, flowSaveData) |
|||
|
|||
//提交部门负责人审批
|
|||
taskId := strconv.FormatInt(commonus.GetFileNumberEs(), 10) //卡片唯一识别符
|
|||
//获取执行结果
|
|||
var mainTitleDesc string = "" |
|||
if scoreFlowInfo.PlusReduceScore == 1 { |
|||
mainTitleDesc = "增加:" + strconv.FormatInt(scoreFlowInfo.Score, 10) + programme.Unit |
|||
} else { |
|||
mainTitleDesc = "扣除:" + strconv.FormatInt(scoreFlowInfo.Score, 10) + programme.Unit |
|||
} |
|||
//部门名称
|
|||
var twoLevelKeyName string = "" |
|||
departmentId, _ := strconv.ParseInt(userCont.DepartmentId, 10, 64) |
|||
execDerpatErr, execDerpat := commonus.GetBranchFactory(departmentId) |
|||
if execDerpatErr == true { |
|||
twoLevelKeyName = execDerpat.Name |
|||
} |
|||
var twoLevelUserId string = "" |
|||
if userCont.WechatId != "" { |
|||
twoLevelUserId = userCont.WechatId |
|||
} |
|||
if userCont.WorkWechatId != "" { |
|||
twoLevelUserId = userCont.WorkWechatId |
|||
} |
|||
cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v", orderId) |
|||
// 按钮
|
|||
var buttonMap []sendmessage.ButtonListtype |
|||
var buttonCont sendmessage.ButtonListtype |
|||
buttonCont.Type = 0 |
|||
buttonCont.Text = "批准" |
|||
buttonCont.Style = 1 |
|||
buttonCont.Key = fmt.Sprintf("duty_%v_1_%v", orderId, 0) |
|||
buttonMap = append(buttonMap, buttonCont) |
|||
buttonCont.Type = 0 |
|||
buttonCont.Text = "驳回" |
|||
buttonCont.Style = 3 |
|||
buttonCont.Key = fmt.Sprintf("duty_%v_2_%v", orderId, 0) |
|||
buttonMap = append(buttonMap, buttonCont) |
|||
var sendTextMsg sendmessage.ButtonNoticeTemplateMedium |
|||
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendButtonShare(sendUserList, taskId, "部门负责人审批", scoreFlowInfo.Reason, mainTitleDesc, "责任划分", reason, "责任部门", twoLevelKeyName, userCont.Name, twoLevelUserId, cardJumpUrl, buttonMap) |
|||
outData := commonus.MapOut() |
|||
outData["callbakcMsg"] = string(callbakcMsg) |
|||
outData["isTrueCall"] = isTrueCall |
|||
outData["callBackCont"] = callBackCont |
|||
response.Result(0, outData, "数据写入成功", c) |
|||
|
|||
} |
|||
|
|||
//判断是否已经存在
|
|||
func judgeIsSet(id int64, idAry []int64) (isTrue bool) { |
|||
isTrue = false |
|||
for _, v := range idAry { |
|||
if id == v { |
|||
isTrue = true |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
//填写整改措施
|
|||
func (e *EvaluationInterface) RectificationMeasures(c *gin.Context) { |
|||
isTrue, userCont := commonus.ClientIdentity() |
|||
if isTrue != true { |
|||
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
userKey, userKeyErr := strconv.ParseInt(userCont.Key, 10, 64) |
|||
if userKeyErr != nil { |
|||
response.Result(102, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
departmentId, departmentIdErr := strconv.ParseInt(userCont.DepartmentId, 10, 64) |
|||
if departmentIdErr != nil { |
|||
response.Result(103, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
userGroup, userGroupErr := strconv.ParseInt(userCont.Group, 10, 64) |
|||
if userGroupErr != nil { |
|||
response.Result(104, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
var requestData CorrectiveMeasuresType |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(105, err, "数据获取失败!", c) |
|||
return |
|||
} |
|||
if requestData.OrderId == "" { |
|||
response.Result(106, err, "数据异常!", c) |
|||
return |
|||
} |
|||
orderidval, orderidvalErr := strconv.ParseInt(requestData.OrderId, 10, 64) |
|||
if orderidvalErr != nil { |
|||
response.Result(107, isTrue, "数据异常!!", c) |
|||
return |
|||
} |
|||
if requestData.Content == "" { |
|||
response.Result(108, err, "请输入整改内容!", c) |
|||
return |
|||
} |
|||
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 |
|||
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 |
|||
} |
|||
//写入流程步骤
|
|||
commonus.StepAddData(orderidval, 0, 6, 4, userCont.Key) |
|||
/* |
|||
向本部门负责人发送审批 |
|||
*/ |
|||
//确定相关责任人
|
|||
departmentIdInts, _ := strconv.ParseInt(userCont.DepartmentId, 10, 64) |
|||
sendUserIsTrue, sendUserList := commonus.GetSendMsgUserAry(16182159043990656, departmentIdInts) //获取对应部门负责人
|
|||
sendUserStr := strings.Join(sendUserList, "|") |
|||
taskId := strconv.FormatInt(commonus.GetFileNumberEs(), 10) //卡片唯一识别符
|
|||
if sendUserIsTrue != true { |
|||
response.Result(109, sendUserList, "未指定相关部门处理人!未能向相关人员发送考核项目!请手动发起!", c) |
|||
return |
|||
} |
|||
|
|||
//获取考核项目关联项目
|
|||
targettitle, detailedRulesTitle, detailedRulesInfo, unit, flowContent, _ := commonus.GetDutyAssociatedItems(requestData.OrderId) |
|||
//一级文本处理
|
|||
var title, desc string |
|||
if detailedRulesTitle != "" { |
|||
if targettitle != "" { |
|||
title = targettitle |
|||
desc = detailedRulesTitle |
|||
} else { |
|||
title = detailedRulesTitle |
|||
desc = detailedRulesInfo |
|||
} |
|||
} else if targettitle != "" { |
|||
title = targettitle |
|||
} |
|||
|
|||
//获取执行结果
|
|||
var mainTitleDesc string |
|||
mainTitleDesc = fmt.Sprintf("执行原因:%v\n", flowContent.Reason) |
|||
if flowContent.PlusReduceScore == 1 { |
|||
mainTitleDesc = fmt.Sprintf("%v加:%v%v\n", mainTitleDesc, flowContent.Score, unit) |
|||
} else { |
|||
mainTitleDesc = fmt.Sprintf("%v减:%v%v\n", mainTitleDesc, flowContent.Score, unit) |
|||
} |
|||
var reason string |
|||
reason = fmt.Sprintf("整改措施:\n%v", requestData.Content) |
|||
//部门名称
|
|||
var twoLevelKeyName string = "" |
|||
execDerpatErr, execDerpat := commonus.GetBranchFactory(departmentIdInts) |
|||
if execDerpatErr == true { |
|||
twoLevelKeyName = execDerpat.Name |
|||
} |
|||
var twoLevelUserId string = "" |
|||
if userCont.WechatId != "" { |
|||
twoLevelUserId = userCont.WechatId |
|||
} |
|||
if userCont.WorkWechatId != "" { |
|||
twoLevelUserId = userCont.WorkWechatId |
|||
} |
|||
cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v", requestData.OrderId) |
|||
|
|||
// 按钮
|
|||
var buttonMap []sendmessage.ButtonListtype |
|||
var buttonCont sendmessage.ButtonListtype |
|||
buttonCont.Type = 0 |
|||
buttonCont.Text = "批准" |
|||
buttonCont.Style = 1 |
|||
buttonCont.Key = fmt.Sprintf("duty_%v_1_%v", orderidval, addRecMeas.Id) |
|||
buttonMap = append(buttonMap, buttonCont) |
|||
buttonCont.Type = 0 |
|||
buttonCont.Text = "驳回" |
|||
buttonCont.Style = 3 |
|||
buttonCont.Key = fmt.Sprintf("duty_%v_2_%v", orderidval, addRecMeas.Id) |
|||
buttonMap = append(buttonMap, buttonCont) |
|||
var sendTextMsg sendmessage.ButtonNoticeTemplateMedium |
|||
callbakcMsg, isTrueCall, callBackCont := sendTextMsg.SendButtonShare(sendUserStr, taskId, "部门负责人审批", title, desc, mainTitleDesc, reason, "责任人", twoLevelKeyName, userCont.Name, twoLevelUserId, cardJumpUrl, buttonMap) |
|||
outData := commonus.MapOut() |
|||
outData["callbakcMsg"] = string(callbakcMsg) |
|||
outData["isTrueCall"] = isTrueCall |
|||
outData["callBackCont"] = callBackCont |
|||
response.Result(0, outData, "数据写入成功", c) |
|||
|
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package callback |
|||
|
|||
import ( |
|||
"fmt" |
|||
"strconv" |
|||
|
|||
"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" |
|||
) |
|||
|
|||
//发送流程文本信息
|
|||
/* |
|||
@userList 接收人 |
|||
@taskId 标签ID |
|||
@planId 考核方案项目ID |
|||
@executeReason 执行原因 |
|||
@secondaryCont 参考文本 |
|||
*/ |
|||
func SendUpdateCallBackMsg(userList, orderId, taskId, planId, executeReason, secondaryCont, twoLevelKeyName, twoLevelKeyValue, twoLevelUserId string) (isTrue bool) { |
|||
isTrue = false |
|||
//获取考核项目内容
|
|||
var programme assessmentmodel.QualitativeEvaluation |
|||
judgeProgramme := global.GVA_DB_Performanceappraisal.Where("`qe_id` = ?", planId).First(&programme).Error |
|||
if judgeProgramme != nil { |
|||
return |
|||
} |
|||
executeReason = fmt.Sprintf("%v%v\n", executeReason, programme.Unit) |
|||
//确定标题
|
|||
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个字
|
|||
} |
|||
} |
|||
cardJumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v", orderId) |
|||
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/approvalList?id=%v", orderId) |
|||
jumpUrlTitle := "请前往处理" |
|||
sourceDesc := "信息提示" |
|||
var sendTextMsg sendmessage.TextNoticeTemplateMedium |
|||
sendTextMsg.SendMsgTextShare(userList, taskId, title, desc, secondaryCont, executeReason, "考核上报部门:", twoLevelKeyName, twoLevelKeyValue, twoLevelUserId, cardJumpUrl, jumpUrl, jumpUrlTitle, sourceDesc) |
|||
isTrue = true |
|||
return |
|||
} |
|||
Loading…
Reference in new issue