package postpc import ( "fmt" "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "strconv" "strings" "time" "github.com/gin-gonic/gin" ) /* * @ 作者: 秦东 @ 时间: 2023-01-12 15:21:20 @ 功能: 搜索行政组织岗位列表 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) SearchOrgPostList(c *gin.Context) { var receivedValue SearchOrgPost err := c.ShouldBindJSON(&receivedValue) if err != nil { publicmethod.Result(100, err, c) return } if receivedValue.Name == "" { publicmethod.Result(1, err, c, "请输入要查询得岗位名称!") return } var companyId int64 = 0 if receivedValue.OrgId != "" { orgIdInt, _ := strconv.ParseInt(receivedValue.OrgId, 10, 64) _, companyId, _, _, _ = publicmethod.GetOrgStructure(orgIdInt) } var postList []modelshr.Position err = overall.CONSTANT_DB_HR.Where("`state` = 1 AND `name` LIKE ?", "%"+receivedValue.Name+"%").Find(&postList).Error if err != nil { publicmethod.Result(1, err, c, "没有相关岗位!") return } var sendList []SendSearPost for _, v := range postList { _, companyIdPost, minDer, sunDer, workId := publicmethod.GetOrgStructure(v.AdministrativeOrganization) var orgAry []int64 // if companyIdPost != 0 && publicmethod.IsInTrue[int64](companyIdPost, orgAry) == false { // orgAry = append(orgAry, companyIdPost) // } if minDer != 0 && publicmethod.IsInTrue[int64](minDer, orgAry) == false { orgAry = append(orgAry, minDer) } if sunDer != 0 && publicmethod.IsInTrue[int64](sunDer, orgAry) == false { orgAry = append(orgAry, sunDer) } if workId != 0 && publicmethod.IsInTrue[int64](workId, orgAry) == false { orgAry = append(orgAry, workId) } if v.AdministrativeOrganization != 0 && publicmethod.IsInTrue[int64](v.AdministrativeOrganization, orgAry) == false { orgAry = append(orgAry, v.AdministrativeOrganization) } if companyId != 0 { if companyIdPost == companyId { var sendCont SendSearPost sendCont.OrgId = orgAry sendCont.PostId = v.Id sendCont.PostList = GetWithOrgList(v.AdministrativeOrganization) sendList = append(sendList, sendCont) } } else { var sendCont SendSearPost sendCont.OrgId = orgAry sendCont.PostId = v.Id sendCont.PostList = GetWithOrgList(v.AdministrativeOrganization) sendList = append(sendList, sendCont) } } // fmt.Printf("总数--->%v\n", len(sendList)) publicmethod.Result(0, sendList, c) } /* * @ 作者: 秦东 @ 时间: 2023-01-12 15:21:30 @ 功能: 获取同行政组织岗位 @ 参数 #orgId 行政组织ID @ 返回值 #postList 岗位列表 @ 方法原型 #func GetWithOrgList(orgId int64) (postList []PostListCont) */ func GetWithOrgList(orgId int64) (postList []PostListCont) { var postListCont []modelshr.Position err := overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`").Where("`state` = 1 AND `administrative_organization` = ?", orgId).Find(&postListCont).Error if err != nil { return } for _, v := range postListCont { var postCont PostListCont postCont.Id = v.Id postCont.Name = v.Name postList = append(postList, postCont) } return } /* * @ 作者: 秦东 @ 时间: 2023-01-13 10:44:16 @ 功能: 获取行政组织级联数组 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) GetOrgAry(c *gin.Context) { var receivedValue publicmethod.PublicId err := c.ShouldBindJSON(&receivedValue) if err != nil { publicmethod.Result(100, err, c) return } if receivedValue.Id == "" { publicmethod.Result(1, err, c, "参数错误!") return } idInt, _ := strconv.ParseInt(receivedValue.Id, 10, 64) _, _, minDer, sunDer, workId := publicmethod.GetOrgStructure(idInt) var orgAry []int64 if minDer != 0 && publicmethod.IsInTrue[int64](minDer, orgAry) == false { orgAry = append(orgAry, minDer) } if sunDer != 0 && publicmethod.IsInTrue[int64](sunDer, orgAry) == false { orgAry = append(orgAry, sunDer) } if workId != 0 && publicmethod.IsInTrue[int64](workId, orgAry) == false { orgAry = append(orgAry, workId) } if idInt != 0 && publicmethod.IsInTrue[int64](idInt, orgAry) == false { orgAry = append(orgAry, idInt) } publicmethod.Result(0, orgAry, c) } /* * @ 作者: 秦东 @ 时间: 2023-02-12 09:03:40 @ 功能: 获取行政组织级联数组和岗位 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) GetOrgAndPostAry(c *gin.Context) { var receivedValue publicmethod.PublicId err := c.ShouldBindJSON(&receivedValue) if err != nil { publicmethod.Result(100, err, c) return } if receivedValue.Id == "" { publicmethod.Result(1, err, c, "参数错误!") return } idInt, _ := strconv.ParseInt(receivedValue.Id, 10, 64) _, _, minDer, sunDer, workId := publicmethod.GetOrgStructure(idInt) var orgAry []int64 if minDer != 0 && minDer != 309 && publicmethod.IsInTrue[int64](minDer, orgAry) == false { orgAry = append(orgAry, minDer) } if sunDer != 0 && sunDer != 309 && publicmethod.IsInTrue[int64](sunDer, orgAry) == false { orgAry = append(orgAry, sunDer) } if workId != 0 && workId != 309 && publicmethod.IsInTrue[int64](workId, orgAry) == false { orgAry = append(orgAry, workId) } if idInt != 0 && idInt != 309 && publicmethod.IsInTrue[int64](idInt, orgAry) == false { orgAry = append(orgAry, idInt) } //获取相关岗位 var postContList []modelshr.Position overall.CONSTANT_DB_HR.Where("`state` = 1 AND administrative_organization = ?", idInt).Find(&postContList) sendData := publicmethod.MapOut[string]() sendData["orglist"] = orgAry sendData["postlist"] = postContList publicmethod.Result(0, sendData, c) } /* * @ 作者: 秦东 @ 时间: 2023-01-13 11:00:48 @ 功能: 添加岗位指标 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) NewAddPostTarget(c *gin.Context) { var receivedValue addPostTarget c.ShouldBindJSON(&receivedValue) if receivedValue.Title == "" { publicmethod.Result(1, receivedValue, c, "请输入指标名称!") return } if receivedValue.Type == 0 { receivedValue.Type = 2 } if receivedValue.ScoringMethod == 0 { receivedValue.ScoringMethod = 1 } // if receivedValue.RelevantDepartments == "" { // publicmethod.Result(1, receivedValue, c, "请选择该指标归属部门!") // return // } if len(receivedValue.OtherPostTarget) < 1 { publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!") return } if receivedValue.Dimension == "" { publicmethod.Result(1, receivedValue, c, "请选择指标归属维度!") return } if receivedValue.Unit == "" { publicmethod.Result(1, receivedValue, c, "请输入该指标计算单位!") return } if receivedValue.Cycle == 0 { receivedValue.Cycle = 1 } if receivedValue.CycleAttr == 0 { receivedValue.CycleAttr = 1 } orgPostManList := HandlingRelations(receivedValue.OtherPostTarget) if len(orgPostManList) < 1 { publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!") return } for _, v := range orgPostManList { var saveData modelskpi.PostTarget saveData.Title = receivedValue.Title //标题"` saveData.Type = receivedValue.Type //1:定性考核;2:定量考核"` saveData.State = 1 //状态(1:启用;2:禁用;3:删除)"` saveData.Time = time.Now().Unix() //创建时间"` saveData.Share = 2 //1:共用;2:私用"` dimensionId, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64) saveData.Dimension = dimensionId //维度"` saveData.Key = publicmethod.GetUUid(1) //UUID"` saveData.Unit = receivedValue.Unit //单位"` saveData.Cycle = receivedValue.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"` saveData.Cycleattr = receivedValue.CycleAttr //辅助计数"` saveData.ScoringMethod = receivedValue.ScoringMethod //计分方式(1:自动;2:手动)"` saveData.VisibleRange = strings.Join(receivedValue.VisibleRange, ",") //可见范围"` saveData.VisibleGroup = strings.Join(receivedValue.VisibleGroup, ",") //可见范围(集团)"` saveData.ReleDepart = v.OrgId //相关部门"` var postList []string var manList []string for _, vp := range v.PostPeople { postId := strconv.FormatInt(vp.PostId, 10) if publicmethod.IsInTrue[string](postId, postList) == false { postList = append(postList, postId) } for _, vm := range vp.PeopleList { if publicmethod.IsInTrue[string](vm, manList) == false { manList = append(manList, vm) } } } saveData.DepartmentsPost = strings.Join(postList, ",") //相关岗位"` saveData.Report = strings.Join(manList, ",") //上报人"` overall.CONSTANT_DB_KPI.Create(&saveData) for _, vps := range v.PostPeople { syncSetinges.Add(1) go DepartAboutPostTargetReport(dimensionId, saveData.Id, 0, 0, v.OrgId, vps.PostId, vps.PeopleList, 2, receivedValue.Type) } //关联部门岗位 if len(postList) > 0 { syncSetinges.Add(1) go EditTargetTableDimenAboutPostOfDepart(dimensionId, saveData.Id, 0, 0, v.OrgId, postList, 2, receivedValue.Type) } } syncSetinges.Wait() publicmethod.Result(0, orgPostManList, c) } /* * @ 作者: 秦东 @ 时间: 2023-01-13 13:40:21 @ 功能: 判断岗位指标是否存在 @ 参数 #targetTitle 指标名称 #Attribute 1:定性考核;2:定量考核 #dimId 维度Key #departId 部门ID #postId 岗位ID @ 返回值 #targetCont 岗位指标 #err 状态 @ 方法原型 #JudgePostTargetIsTrue(targetTitle string, Attribute int, dimId, departId, postId int64) (targetCont modelskpi.PostTarget, err error) */ func JudgePostTargetIsTrue(targetTitle string, Attribute int, dimId, departId, postId int64) (targetCont modelskpi.PostTarget, err error) { err = overall.CONSTANT_DB_KPI.Model(targetCont).Select("`id`").Where("`rele_depart` = ? AND `dimension` = ? AND `type` = ? AND `title` = ? AND FIND_IN_SET(?,`departments_post`)", departId, dimId, Attribute, targetTitle, postId).First(&targetCont).Error return } /* * @ 作者: 秦东 @ 时间: 2023-01-13 11:10:25 @ 功能: 处理行政组织与岗位和相关提报人关系 @ 参数 # @ 返回值 # @ 方法原型 # */ func HandlingRelations(orgPostPeo []OtherPostTargetCont) (orgHandPost []OrgPostPeople) { fmt.Printf("orgPostPeo---->%v\n", orgPostPeo) if len(orgPostPeo) < 1 { return } for _, ov := range orgPostPeo { //循环提交得行政组织与岗位和提报人 isInAry := false for hi, hv := range orgHandPost { //循环已经处理得数据 if ov.OrgId == hv.OrgId { //判断此行政组织是否已经存在 isInAry = true for hvpi, hvp := range hv.PostPeople { //循环已经处理后的岗位及提报人 if hvp.PostId == ov.PostId { //判断岗位数据是否已经处理过类是得岗位 var manList []string for _, hvpm := range hvp.PeopleList { //已经添加了的岗位提报人 manList = append(manList, hvpm) } for _, ovm := range ov.Operator { if publicmethod.IsInTrue[string](ovm, manList) == false { manList = append(manList, ovm) } } //新提报人 orgHandPost[hi].PostPeople[hvpi].PeopleList = manList } else { //此行政组织为处理过相关岗位则新增 var postAndMan PostPeopleList postAndMan.PostId = ov.PostId postAndMan.PeopleList = ov.Operator orgHandPost[hi].PostPeople = append(orgHandPost[hi].PostPeople, postAndMan) } } } } //次行政组织不存在,执行新增操作 if isInAry == false { var orgHandPostCont OrgPostPeople orgHandPostCont.OrgId = ov.OrgId var postAndMan PostPeopleList postAndMan.PostId = ov.PostId postAndMan.PeopleList = ov.Operator orgHandPostCont.PostPeople = append(orgHandPostCont.PostPeople, postAndMan) orgHandPost = append(orgHandPost, orgHandPostCont) } } return } /* * @ 作者: 秦东 @ 时间: 2023-02-12 13:17:05 @ 功能: @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) NewAddPostTargetCont(c *gin.Context) { var receivedValue NewAddPostTargetInfo c.ShouldBindJSON(&receivedValue) if receivedValue.Title == "" { publicmethod.Result(1, receivedValue, c, "请输入指标名称!") return } if receivedValue.Type == 0 { receivedValue.Type = 2 } if receivedValue.ScoringMethod == 0 { receivedValue.ScoringMethod = 1 } var postIdList []string var reportList []string if len(receivedValue.OtherPostTarget) < 1 { publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!") return } else { for _, v := range receivedValue.OtherPostTarget { if v.OrgId == 0 || v.PostId == 0 || len(v.Operator) < 1 { publicmethod.Result(1, receivedValue, c, "关联岗位与提报人员信息不全!请补充") return } postIdStr := strconv.FormatInt(v.PostId, 10) if publicmethod.IsInTrue[string](postIdStr, postIdList) == false { postIdList = append(postIdList, postIdStr) } if len(v.Operator) > 0 { for _, ov := range v.Operator { if publicmethod.IsInTrue[string](ov, reportList) == false { reportList = append(reportList, ov) } } } } } if receivedValue.Dimension == "" { publicmethod.Result(1, receivedValue, c, "请选择指标归属维度!") return } if receivedValue.Unit == "" { publicmethod.Result(1, receivedValue, c, "请输入该指标计算单位!") return } if receivedValue.Cycle == 0 { receivedValue.Cycle = 1 } if receivedValue.CycleAttr == 0 { receivedValue.CycleAttr = 1 } var saveData modelskpi.PostTarget saveData.Title = receivedValue.Title //标题"` saveData.Type = receivedValue.Type //1:定性考核;2:定量考核"` saveData.State = 1 //状态(1:启用;2:禁用;3:删除)"` saveData.Time = time.Now().Unix() //创建时间"` saveData.Share = 2 //1:共用;2:私用"` dimensionId, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64) saveData.Dimension = dimensionId //维度"` saveData.Key = publicmethod.GetUUid(1) //UUID"` saveData.Unit = receivedValue.Unit //单位"` saveData.Cycle = receivedValue.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"` saveData.Cycleattr = receivedValue.CycleAttr //辅助计数"` saveData.ScoringMethod = receivedValue.ScoringMethod //计分方式(1:自动;2:手动)"` saveData.VisibleRange = strings.Join(receivedValue.VisibleRange, ",") //可见范围"` saveData.VisibleGroup = strings.Join(receivedValue.VisibleGroup, ",") //可见范围(集团)"` saveData.DepartmentsPost = strings.Join(postIdList, ",") saveData.Report = strings.Join(reportList, ",") err := overall.CONSTANT_DB_KPI.Create(&saveData).Error if err != nil { publicmethod.Result(104, receivedValue, c) return } for _, v := range receivedValue.OtherPostTarget { syncSeting.Add(1) go DepartTargetAboutPost(dimensionId, saveData.Id, 0, 0, v.OrgId, v.PostId, 1, receivedValue.Type, 2) var peopleListId []int64 for _, pv := range v.Operator { peoId, _ := strconv.ParseInt(pv, 10, 64) if publicmethod.IsInTrue[int64](peoId, peopleListId) == false { peopleListId = append(peopleListId, peoId) } syncSeting.Add(1) go BeparTargetAboutPostMan(dimensionId, saveData.Id, 0, 0, v.OrgId, v.PostId, peoId, 2, receivedValue.Type, 1) } if len(peopleListId) > 0 { syncSeting.Add(1) go ClearTargetDepartAboutPostMan(dimensionId, saveData.Id, 0, 0, v.OrgId, v.PostId, peopleListId, 2, receivedValue.Type, 1) } } syncSeting.Wait() publicmethod.Result(0, err, c) } /* * @ 作者: 秦东 @ 时间: 2023-02-09 13:35:06 @ 功能: 部门指标关联岗位 @ 参数 #dimensionId 维度 #targetId 指标 #targetSunId 栏目 #targetBylaws 细则 #departmentId 部门 #postId 岗位 #typeInt 类型(1:指标;2:子目标;3:细则) #class 属性1:定性考核;2:定量考核 #level 级别(1:部门级;2:岗位级) @ 返回值 # @ 方法原型 #func DepartTargetAboutPost(dimensionId, targetId, targetSunId, targetBylaws, departmentId, postId int64, typeInt, class, level int) */ func DepartTargetAboutPost(dimensionId, targetId, targetSunId, targetBylaws, departmentId, postId int64, typeInt, class, level int) { defer syncSeting.Done() if typeInt == 0 { typeInt = 1 } if class == 0 { class = 1 } if level == 0 { level = 1 } var targetDeparCont modelskpi.TargetDepartment err := targetDeparCont.GetCont(map[string]interface{}{"`level`": level, "`type`": typeInt, "`target_id`": targetId, "`target_sun_id`": targetSunId, "`target_bylaws`": targetBylaws, "`department_id`": departmentId, "`post_id`": postId}) if err != nil { //不存在新增 var tarDepartCont modelskpi.TargetDepartment tarDepartCont.Dimension = dimensionId tarDepartCont.TargetId = targetId //指标ID"` tarDepartCont.TargetSunId = targetSunId //子目标"` tarDepartCont.TargetBylaws = targetBylaws //指标细则"` tarDepartCont.Type = typeInt //类型(1:指标;2:子目标;3:细则)"` tarDepartCont.DepartmentId = departmentId //部门ID"` tarDepartCont.PostId = postId //岗位ID"` tarDepartCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` tarDepartCont.Time = time.Now().Unix() //写入时间"` tarDepartCont.Class = class //1:定性考核;2:定量考核"` tarDepartCont.Level = level //级别(1:部门级;2:岗位级)"` overall.CONSTANT_DB_KPI.Create(&tarDepartCont) } else { //存在修改状态 if targetDeparCont.State != 1 { otherSaveData := publicmethod.MapOut[string]() otherSaveData["`state`"] = 2 otherSaveData["`time`"] = time.Now().Unix() var editTarDepartCont modelskpi.TargetDepartment editTarDepartCont.EiteCont(map[string]interface{}{"`id`": targetDeparCont.Id}, otherSaveData) } } } /* * @ 作者: 秦东 @ 时间: 2023-02-09 14:09:41 @ 功能: 处理部门指标关联岗位提报人关系 @ 参数 # @ 返回值 #dimensionId 维度 #targetId 指标 #targetSunId 栏目 #targetBylaws 细则 #departmentId 部门 #postId 岗位 #typeInt 类型(1:公司级;2:部门级) #manKey 用户Key #class 属性1:定性考核;2:定量考核 #typeLevel 级别(1:指标;2:子目标;3:细则) @ 方法原型 #func BeparTargetAboutPostMan(dimensionId, targetId, targetSunId, targetBylaws, departmentId, postId, manKey int64, typeInt, class, typeLevel int) */ func BeparTargetAboutPostMan(dimensionId, targetId, targetSunId, targetBylaws, departmentId, postId, manKey int64, typeInt, class, typeLevel int) { defer syncSeting.Done() if typeInt == 0 { typeInt = 1 } if class == 0 { class = 1 } if typeLevel == 0 { typeLevel = 1 } var manCont modelshr.PersonArchives manCont.GetCont(map[string]interface{}{"`key`": manKey}, "`maindeparment`") var targetReporCont modelskpi.TargetReport err := targetReporCont.GetCont(map[string]interface{}{"`type_level`": typeLevel, "`type`": typeInt, "`target_id`": targetId, "`target_sun_id`": targetSunId, "`target_bylaws`": targetBylaws, "`department_id`": departmentId, "`post_id`": postId, "man_key": manKey}) if err != nil { //不存在,新增 var tarReportContAdd modelskpi.TargetReport tarReportContAdd.Dimension = dimensionId //维度 tarReportContAdd.TargetId = targetId //指标ID"` tarReportContAdd.TargetSunId = targetSunId //子目标"` tarReportContAdd.TargetBylaws = targetBylaws //指标细则"` tarReportContAdd.DepartmentId = departmentId //部门ID"` tarReportContAdd.PostId = postId //岗位ID"` tarReportContAdd.Type = typeInt //类型(1:公司级;2:部门级)"` tarReportContAdd.State = 1 //状态(1:启用;2:禁用;3:删除)"` tarReportContAdd.ReportPerson = manKey //上报人"` tarReportContAdd.ManDepartment = manCont.MainDeparment //提报人所在部门"` tarReportContAdd.Time = time.Now().Unix() //写入时间"` tarReportContAdd.Class = class //1:定性考核;2:定量考核"` tarReportContAdd.Level = typeLevel //1:指标;2:子目标;3:细则 overall.CONSTANT_DB_KPI.Create(&tarReportContAdd) } else { //存在编辑 if targetReporCont.State != 1 { otherSaveData := publicmethod.MapOut[string]() otherSaveData["`state`"] = 2 if manCont.MainDeparment != targetReporCont.ManDepartment { otherSaveData["`man_department`"] = manCont.MainDeparment } otherSaveData["`time`"] = time.Now().Unix() var editTarReportCont modelskpi.TargetReport editTarReportCont.EiteCont(map[string]interface{}{"`id`": targetReporCont.Id}, otherSaveData) } } } /* * @ 作者: 秦东 @ 时间: 2023-02-09 13:55:26 @ 功能: 清理部门指标不在关联的岗位提报人 @ 参数 #dimensionId 维度 #targetId 指标 #targetSunId 栏目 #targetBylaws 细则 #departmentId 部门 #postId 岗位 #manKey 岗位 #typeInt 级别(1:部门级;2:岗位级) #class 属性1:定性考核;2:定量考核 #level 类型(1:指标;2:子目标;3:细则) @ 返回值 # @ 方法原型 #ClearTargetDepartAboutPostMan(dimensionId, targetId, targetSunId, targetBylaws, departmentId, postId int64, manKey []int64, typeInt, class, level int) */ func ClearTargetDepartAboutPostMan(dimensionId, targetId, targetSunId, targetBylaws, departmentId, postId int64, manKey []int64, typeInt, class, level int) { defer syncSeting.Done() if typeInt == 0 { typeInt = 1 } if class == 0 { class = 1 } if level == 0 { level = 1 } //将不属于该指标细则的部门至禁用 otherSaveData := publicmethod.MapOut[string]() otherSaveData["`state`"] = 2 otherSaveData["`time`"] = time.Now().Unix() overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where("`target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ? AND `department_id` = ? AND `post_id` = ? AND `type` = ? AND `type_level` = ?", targetId, targetSunId, targetBylaws, departmentId, postId, typeInt, level).Not(map[string]interface{}{"man_key": manKey}).Updates(&otherSaveData) } /* * @ 作者: 秦东 @ 时间: 2023-02-12 16:08:11 @ 功能: 编辑岗位指标(新版) @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) NewEditPostTarget(c *gin.Context) { var receivedValue NewEditPostTargetCont c.ShouldBindJSON(&receivedValue) if receivedValue.Id == "" { publicmethod.Result(1, receivedValue, c, "参数错误!请重新提交!") return } if receivedValue.Title == "" { publicmethod.Result(1, receivedValue, c, "请输入指标名称!") return } if receivedValue.Type == 0 { receivedValue.Type = 2 } if receivedValue.ScoringMethod == 0 { receivedValue.ScoringMethod = 1 } var postIdList []string var reportList []string if len(receivedValue.OtherPostTarget) < 1 { publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!") return } else { for _, v := range receivedValue.OtherPostTarget { if v.OrgId == 0 || v.PostId == 0 || len(v.Operator) < 1 { publicmethod.Result(1, receivedValue, c, "关联岗位与提报人员信息不全!请补充") return } postIdStr := strconv.FormatInt(v.PostId, 10) if publicmethod.IsInTrue[string](postIdStr, postIdList) == false { postIdList = append(postIdList, postIdStr) } if len(v.Operator) > 0 { for _, ov := range v.Operator { if publicmethod.IsInTrue[string](ov, reportList) == false { reportList = append(reportList, ov) } } } } } if receivedValue.Dimension == "" { publicmethod.Result(1, receivedValue, c, "请选择指标归属维度!") return } if receivedValue.Unit == "" { publicmethod.Result(1, receivedValue, c, "请输入该指标计算单位!") return } if receivedValue.Cycle == 0 { receivedValue.Cycle = 1 } if receivedValue.CycleAttr == 0 { receivedValue.CycleAttr = 1 } wheAry := publicmethod.MapOut[string]() wheAry["id"] = receivedValue.Id var postTargetInfo modelskpi.PostTarget err := postTargetInfo.GetCont(wheAry) if err != nil { publicmethod.Result(107, receivedValue, c) return } editCont := publicmethod.MapOut[string]() if receivedValue.Title != "" && postTargetInfo.Title != receivedValue.Title { editCont["`title`"] = receivedValue.Title } if receivedValue.Type != postTargetInfo.Type { editCont["`type`"] = receivedValue.Type } postStr := strings.Join(postIdList, ",") if postStr != postTargetInfo.DepartmentsPost { editCont["`departments_post`"] = postStr } reportStr := strings.Join(reportList, ",") if reportStr != postTargetInfo.Report { editCont["`report`"] = reportStr } if receivedValue.Dimension != "" { dimensionInt, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64) if dimensionInt != postTargetInfo.Dimension { editCont["`dimension`"] = dimensionInt } } if receivedValue.Unit != "" && postTargetInfo.Unit != receivedValue.Unit { editCont["`unit`"] = receivedValue.Unit } if receivedValue.Cycle != postTargetInfo.Cycle { editCont["`cycle`"] = receivedValue.Cycle } if receivedValue.CycleAttr != postTargetInfo.Cycleattr { editCont["`cycleattr`"] = receivedValue.CycleAttr } if len(editCont) > 0 { editCont["`time`"] = time.Now().Unix() editCont["`state`"] = 1 var editCont modelskpi.PostTarget err = editCont.EiteCont(wheAry, editCont) } for _, v := range receivedValue.OtherPostTarget { syncSeting.Add(1) go DepartTargetAboutPost(postTargetInfo.Dimension, postTargetInfo.Id, 0, 0, v.OrgId, v.PostId, 1, postTargetInfo.Type, 2) var peopleListId []int64 for _, pv := range v.Operator { peoId, _ := strconv.ParseInt(pv, 10, 64) if publicmethod.IsInTrue[int64](peoId, peopleListId) == false { peopleListId = append(peopleListId, peoId) } syncSeting.Add(1) go BeparTargetAboutPostMan(postTargetInfo.Dimension, postTargetInfo.Id, 0, 0, v.OrgId, v.PostId, peoId, 2, postTargetInfo.Type, 1) } if len(peopleListId) > 0 { syncSeting.Add(1) go ClearTargetDepartAboutPostMan(postTargetInfo.Dimension, postTargetInfo.Id, 0, 0, v.OrgId, v.PostId, peopleListId, 2, postTargetInfo.Type, 1) } } syncSeting.Wait() publicmethod.Result(0, err, c) }