package qual import ( "encoding/json" "fmt" "strconv" "strings" "time" "gin_server_admin/api/wechatapp/sendmessage" "gin_server_admin/commonus" "gin_server_admin/global" "gin_server_admin/model/assessmentmodel" "gin_server_admin/model/common/response" "gin_server_admin/model/hrsystem" "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 { // } userConting, userIsTrue := commonus.GetNewHrPeopleInfo(map[string]interface{}{"key": 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.Company demtId, _ := strconv.ParseInt(userConting.Deparment, 10, 64) saveDataCont.Department = demtId saveDataCont.Tema = 0 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.Company MainResponsiblePerson.Department = demtId MainResponsiblePerson.WorkshopId = userConting.AdminOrg MainResponsiblePerson.Tema = 0 // usKeyInt, _ := strconv.ParseInt(ua_v, 10, 64) 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.Company saveDataContTeam.Department = tu_v.MainDeparment saveDataContTeam.Tema = tu_v.TeamId 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()}) WritePersonLiable(orderId, userKeyMainAry) // response.Result(107, userKeyMainAry, "请检查您提交的要考核人员名单是否正确!", c) // return //修改定性审批流状态 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, time.Now().Unix()) //更新审批流 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) } // 写入责任节点 func WritePersonLiable(flowKey int64, userKey []int64) { var userAry []hrsystem.PersonArchives userAryErr := global.GVA_DB_HrDataBase.Model(&hrsystem.PersonArchives{}).Where("`key` IN ?", userKey).Find(&userAry).Error var userFlow []commonus.UserListFlowAll // fmt.Printf("userAry---->%v\n", userAry) if userAryErr == nil { for _, uv := range userAry { var usFlowInfo commonus.UserListFlowAll usFlowInfo.Id = strconv.FormatInt(uv.Key, 10) // `json:"id"` //操作人ID usFlowInfo.Name = uv.Name // `json:"name"` //操作人姓名 usFlowInfo.Icon = uv.Icon // `json:"icon"` //操作人头像 usFlowInfo.Wechat = uv.Wechat if uv.WorkWechat != "" { usFlowInfo.Wechat = uv.WorkWechat // `json:"wechat"` //微信Openid } whereGroup := commonus.MapOut() whereGroup["id"] = uv.Company orgContGroup, _ := commonus.GetNewOrgCont(whereGroup, "name") usFlowInfo.Group = uv.Company // `json:"group"` //集团公司 usFlowInfo.GroupName = orgContGroup.Name // `json:"groupname"` //分厂名称 // departId, _ := strconv.ParseInt(uv.Deparment, 10, 64) usFlowInfo.DepartmentId = uv.MainDeparment // `json:"departmentid"` //分厂Id whereDepart := commonus.MapOut() whereDepart["id"] = uv.MainDeparment orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "name") usFlowInfo.DepartmentName = orgContDepart.Name // `json:"departmentname"` //分厂名称 usFlowInfo.WorkshopId = uv.AdminOrg // `json:"workshopid"` //工段Id wherePost := commonus.MapOut() wherePost["id"] = uv.AdminOrg orgContPost, _ := commonus.GetNewOrgCont(wherePost, "name") usFlowInfo.WorkshopName = orgContPost.Name // `json:"workshopname"` //工段名称 usFlowInfo.PostId = uv.Position // `json:"postid"` //职务Id var zhiWuInfo hrsystem.Position zhiWuInfo.GetCont(map[string]interface{}{"`id`": uv.Position}, "`name`") usFlowInfo.PostName = zhiWuInfo.Name // `json:"postname"` //职务名称 usFlowInfo.Tema = uv.TeamId // `json:"tema"` //班组Id var teamConts hrsystem.TeamGroup teamConts.GetCont(map[string]interface{}{"`id`": uv.TeamId}, "`name`") usFlowInfo.TemaName = teamConts.Name // `json:"temaname"` //班组名称 userFlow = append(userFlow, usFlowInfo) } } //获取流程内容 var flowCont string err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Select("`ep_next_cont`").Where("`ep_order_key` = ?", flowKey).First(&flowCont).Error // fmt.Printf("flowCont--------------->%v\n", flowCont) if err == nil { var twoFlowInfo []commonus.FlowAllMap jsonErr := json.Unmarshal([]byte(flowCont), &twoFlowInfo) // fmt.Printf("jsonErr--------------->%v\n", jsonErr) if jsonErr == nil { for i, v := range twoFlowInfo { if v.Step == 5 { twoFlowInfo[i].UserList = userFlow } } } // fmt.Printf("userFlow--------------->%v\n", userFlow) // fmt.Printf("twoFlowInfo--------------->%v\n", twoFlowInfo) saveData := commonus.MapOut() jsonShenPiCont, jsonShenPiErr := json.Marshal(twoFlowInfo) if jsonShenPiErr == nil { saveData["ep_next_cont"] = string(jsonShenPiCont) global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", flowKey).Updates(&saveData) } } } func WritePersonLiableold(flowKey int64, userKey []int64) { var userAry []hrsystem.Personnel userAryErr := global.GVA_DB_HrDataBase.Model(&hrsystem.Personnel{}).Where("`key` IN ?", userKey).Find(&userAry).Error var userFlow []commonus.UserListFlowAll // fmt.Printf("userAry---->%v\n", userAry) if userAryErr == nil { for _, uv := range userAry { var usFlowInfo commonus.UserListFlowAll usFlowInfo.Id = strconv.FormatInt(uv.Key, 10) // `json:"id"` //操作人ID usFlowInfo.Name = uv.Name // `json:"name"` //操作人姓名 usFlowInfo.Icon = uv.Icon // `json:"icon"` //操作人头像 usFlowInfo.Wechat = uv.Wechat if uv.WorkWechat != "" { usFlowInfo.Wechat = uv.WorkWechat // `json:"wechat"` //微信Openid } whereGroup := commonus.MapOut() whereGroup["id"] = uv.Company orgContGroup, _ := commonus.GetNewOrgCont(whereGroup, "name") usFlowInfo.Group = uv.Company // `json:"group"` //集团公司 usFlowInfo.GroupName = orgContGroup.Name // `json:"groupname"` //分厂名称 departId, _ := strconv.ParseInt(uv.Deparment, 10, 64) usFlowInfo.DepartmentId = departId // `json:"departmentid"` //分厂Id whereDepart := commonus.MapOut() whereDepart["id"] = uv.Deparment orgContDepart, _ := commonus.GetNewOrgCont(whereDepart, "name") usFlowInfo.DepartmentName = orgContDepart.Name // `json:"departmentname"` //分厂名称 usFlowInfo.WorkshopId = uv.AdminOrg // `json:"workshopid"` //工段Id wherePost := commonus.MapOut() wherePost["id"] = uv.AdminOrg orgContPost, _ := commonus.GetNewOrgCont(wherePost, "name") usFlowInfo.WorkshopName = orgContPost.Name // `json:"workshopname"` //工段名称 usFlowInfo.PostId = uv.Position // `json:"postid"` //职务Id var zhiWuInfo hrsystem.Position zhiWuInfo.GetCont(map[string]interface{}{"`id`": uv.Position}, "`name`") usFlowInfo.PostName = zhiWuInfo.Name // `json:"postname"` //职务名称 usFlowInfo.Tema = 1 // `json:"tema"` //班组Id usFlowInfo.TemaName = "" // `json:"temaname"` //班组名称 userFlow = append(userFlow, usFlowInfo) } } //获取流程内容 var flowCont string err := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Select("`ep_next_cont`").Where("`ep_order_key` = ?", flowKey).First(&flowCont).Error // fmt.Printf("flowCont--------------->%v\n", flowCont) if err == nil { var twoFlowInfo []commonus.FlowAllMap jsonErr := json.Unmarshal([]byte(flowCont), &twoFlowInfo) // fmt.Printf("jsonErr--------------->%v\n", jsonErr) if jsonErr == nil { for i, v := range twoFlowInfo { if v.Step == 5 { twoFlowInfo[i].UserList = userFlow } } } // fmt.Printf("userFlow--------------->%v\n", userFlow) // fmt.Printf("twoFlowInfo--------------->%v\n", twoFlowInfo) saveData := commonus.MapOut() jsonShenPiCont, jsonShenPiErr := json.Marshal(twoFlowInfo) if jsonShenPiErr == nil { saveData["ep_next_cont"] = string(jsonShenPiCont) global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.EvaluationProcess{}).Where("`ep_order_key` = ?", flowKey).Updates(&saveData) } } }