From 10c8da546018d2fc7574f0393f0cf7fe42a3186f Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Fri, 21 Apr 2023 16:28:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B9=E6=A1=88BUG=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../departmentweb/department.go | 31 ++++- api/version1/flowchart/entry.go | 4 + api/version1/flowchart/myworkflow.go | 35 ++++- api/version1/postseting/postpc/scheme.go | 129 ++++++++++++++++-- api/version1/postseting/postpc/type.go | 32 ++++- apirouter/v1/postseting/pc.go | 2 + 6 files changed, 201 insertions(+), 32 deletions(-) diff --git a/api/version1/departmentseting/departmentweb/department.go b/api/version1/departmentseting/departmentweb/department.go index 46e62ef..1dc18d5 100644 --- a/api/version1/departmentseting/departmentweb/department.go +++ b/api/version1/departmentseting/departmentweb/department.go @@ -357,7 +357,7 @@ func (g *GetDttsb) PerformCalculation(orgId, targetId, years string, month int) # */ func DepartTargetCompletionRate(actualValue, zeroPrize, allPrize, cappingPrize float64) (percentageComplete float64) { - + // fmt.Printf("计算达成率------->%v------->%v------->%v------->%v\n", actualValue, zeroPrize, allPrize, cappingPrize) if allPrize == 0 && zeroPrize == 0 { //全奖值与零奖值都为0 那么达成率 100 percentageComplete = 10000 } else { @@ -367,18 +367,28 @@ func DepartTargetCompletionRate(actualValue, zeroPrize, allPrize, cappingPrize f } else { //实际结算值大于零奖值 chushu := actualValue - zeroPrize beiChuShu := allPrize - zeroPrize + // fmt.Printf("计算达成率-----2-->%v------->%v\n", chushu, beiChuShu) if beiChuShu != 0 { - percentageComplete = publicmethod.DecimalEs(chushu/beiChuShu, 4) - + // percentageComplete = publicmethod.DecimalEs(chushu/beiChuShu, 4) + percentageComplete = chushu / beiChuShu + // fmt.Printf("计算达成率-----3-->%v------->%v------->%v\n", chushu, beiChuShu, percentageComplete) if percentageComplete > 0 { percentageComplete = percentageComplete * 10000 + // fmt.Printf("计算达成率-----4-->%v------->%v------->%v\n", chushu, beiChuShu, percentageComplete) if percentageComplete > cappingPrize { - percentageComplete = cappingPrize + if cappingPrize != 0 { + percentageComplete = cappingPrize + } else { + percentageComplete = 10000 + } + } + // fmt.Printf("计算达成率-----6-->%v------->%v------->%v------->%v\n", chushu, beiChuShu, percentageComplete, cappingPrize) } } else { //被除数为0时 那么达成率0 percentageComplete = 0 } + // fmt.Printf("计算达成率-----5-->%v------->%v------->%v\n", chushu, beiChuShu, percentageComplete) } } else { //如果全奖值小于零奖值 执行一下操作 if actualValue >= zeroPrize { //实际结算值大于零奖值 那么达成率0 @@ -400,6 +410,7 @@ func DepartTargetCompletionRate(actualValue, zeroPrize, allPrize, cappingPrize f } } } + fmt.Printf("计算达成率-----1-->%v------->%v------->%v------->%v------->%v\n", actualValue, zeroPrize, allPrize, cappingPrize, percentageComplete) percentageComplete = publicmethod.DecimalEs(percentageComplete/100, 2) return } @@ -706,9 +717,12 @@ func (a *ApiMethod) TotalScoreOFOrgComesFromTimeSearch(c *gin.Context) { //开启协程,分别获取行政组织时间总分 var syncOrgTimeScore SyncOrgTimeAllScore for _, v := range allOrgListCont { + // if v.Id == 354 { sendData.XAxisVal = append(sendData.XAxisVal, v.Name) SyncSeting.Add(1) go syncOrgTimeScore.OrgCalculateScore(v, currentYears, currentMonths) + // } + } SyncSeting.Wait() scoreList, maxScore, minSchor := syncOrgTimeScore.readPlanTaskData() @@ -826,6 +840,7 @@ func (s *SyncOrgTimeAllScore) OrgCalculateScore(orgCont modelshr.AdministrativeO //判断是不是观察指标 if sv.Status == 3 { getPoints = getPoints + float64(sv.ReferenceScore) + // fmt.Printf("sv-1-->%v--->%v--->%v\n", sv.Id, sv.Name, sv.ReferenceScore) } else { if sv.Status == 1 && sv.Status != 3 { //判断指标是否启用并且不是观察指标 //获取指标内容 @@ -839,14 +854,16 @@ func (s *SyncOrgTimeAllScore) OrgCalculateScore(orgCont modelshr.AdministrativeO //定性考核 dingXingScore := OrgSchemeDingXing(orgCont.Id, sv.ReferenceScore, targetInfo.Id, sv.Cycles, sv.Status, years, months) getPoints = getPoints + dingXingScore + // fmt.Printf("sv-2-->%v--->%v--->%v\n", sv.Id, sv.Name, dingXingScore) } else { //定量考核 dingLiangScore := OrgSchemeDingLiang(orgCont.Id, sv.ReferenceScore, targetInfo.Id, sv.Cycles, sv.Status, years, months) getPoints = getPoints + dingLiangScore + // fmt.Printf("sv-3-->%v--->%v--->%v\n", sv.Id, sv.Name, dingLiangScore) } } } - + // fmt.Printf("sv--->%v--->%v--->%v\n", sv.Id, sv.Name, getPoints) } } } @@ -857,7 +874,7 @@ func (s *SyncOrgTimeAllScore) OrgCalculateScore(orgCont modelshr.AdministrativeO currentMonthInt, _ := strconv.Atoi(currentMonth) if currentYearsInt == yearsInt && monthsInt > currentMonthInt { getPoints = 0 - fmt.Printf("currentYears:%v---->years:%v---->months:%v---->currentMonth:%v---->getPoints:%v\n", currentYearsInt, yearsInt, monthsInt, currentMonthInt, getPoints) + // fmt.Printf("currentYears:%v---->years:%v---->months:%v---->currentMonth:%v---->getPoints:%v\n", currentYearsInt, yearsInt, monthsInt, currentMonthInt, getPoints) } if s.AxisMax < getPoints { @@ -933,7 +950,7 @@ func OrgSchemeDingLiang(orgId, targetWeight, targetId int64, cycles, attribute i dachenglv := DepartTargetCompletionRate(float64(v.Score), zeroPrize, allPrize, cappingPrize) score = float64(targetWeight) * (dachenglv / 100) resultValue = resultValue + score - // fmt.Printf("自动得分------->%v------->%v------->%v------->%v\n", orgId, resultValue, dachenglv, score) + fmt.Printf("自动得分------->%v------->%v------->%v------->%v------->%v------->%v------->%v------->%v\n", orgId, resultValue, dachenglv, score, zeroPrize, allPrize, cappingPrize, v.Score) } else { resultValue = resultValue + publicmethod.DecimalEs(v.ScoringScore/100, 2) } diff --git a/api/version1/flowchart/entry.go b/api/version1/flowchart/entry.go index 9e7976e..061f413 100644 --- a/api/version1/flowchart/entry.go +++ b/api/version1/flowchart/entry.go @@ -31,6 +31,9 @@ type HaveApprovalRecord struct { State int `json:"state"` // 0:全部;1:审批中;2:驳回;3:归档;4:删除 NameorNumber string `json:"nameornumber"` //申请人姓名或工号 Title string `json:"title"` //标题 + OrgId string `json:"orgid"` //行政组织 + Years int `json:"years"` + Months int `json:"month"` } // 输出审批记录值 @@ -66,6 +69,7 @@ type OutPutFlowLog struct { CurrentNode string `json:"currentnode"` //当前节点"` CurrentNodeMan string `json:"currentnodeman"` //当前节点操作人"` CreationDate string `json:"creationdate"` //创建日期"` + OccurrenceTime string `json:"occurrencetime"` //发生时间"` } // 输出工作流内容 diff --git a/api/version1/flowchart/myworkflow.go b/api/version1/flowchart/myworkflow.go index e83977f..13d8e18 100644 --- a/api/version1/flowchart/myworkflow.go +++ b/api/version1/flowchart/myworkflow.go @@ -72,6 +72,26 @@ func (a *ApiMethod) GetApprovalRecord(c *gin.Context) { gormDb = gormDb.Where("`ep_setup_department` IN ? OR `ep_accept_department` IN ?", userIdentity.OrgList, userIdentity.OrgList) default: } + + if receivedValue.OrgId != "" { + gormDb = gormDb.Where("ep_accept_department = ? OR ep_setup_department = ?", receivedValue.OrgId, receivedValue.OrgId) + } + + if receivedValue.Years != 0 { + if receivedValue.Months != 0 { + timeDay := fmt.Sprintf("%v-%v-01", receivedValue.Years, receivedValue.Months) + if receivedValue.Months <= 9 { + timeDay = fmt.Sprintf("%v-0%v-01", receivedValue.Years, receivedValue.Months) + } + startTime, endTime := publicmethod.GetAppointMonthStarAndEndTimeEs(timeDay) + gormDb = gormDb.Where("ep_happen_time BETWEEN ? AND ?", startTime, endTime) + } else { + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", receivedValue.Years)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", receivedValue.Years)) + gormDb = gormDb.Where("ep_happen_time BETWEEN ? AND ?", startTime, endTime) + } + } + fmt.Printf("userIdentity------------>%v\n", userIdentity) var total int64 totalErr := gormDb.Count(&total).Error @@ -107,13 +127,14 @@ func (a *ApiMethod) GetApprovalRecord(c *gin.Context) { sendCont.DetailedTarget = v.DetailedTarget //指标细则"` sendCont.AcceptDepartment = strconv.FormatInt(v.AcceptDepartment, 10) //接受考核部门"` sendCont.HappenTime = v.HappenTime //发生时间"` - sendCont.FlowKey = strconv.FormatInt(v.FlowKey, 10) //工作流识别符"` - sendCont.FlowVid = strconv.FormatInt(v.FlowVid, 10) //当前工作流版本号"` - sendCont.EpOld = v.EpOld //1:旧流程;2:新流程"` - sendCont.Creater = strconv.FormatInt(v.Creater, 10) //流程创始人"` - sendCont.TargetTitle = v.TargetTitle //指标名称"` - sendCont.BylawsTitle = v.BylawsTitle //细则名称"` - sendCont.Clique = strconv.FormatInt(v.Clique, 10) //公司"` + sendCont.OccurrenceTime = publicmethod.UnixTimeToDay(v.HappenTime, 14) + sendCont.FlowKey = strconv.FormatInt(v.FlowKey, 10) //工作流识别符"` + sendCont.FlowVid = strconv.FormatInt(v.FlowVid, 10) //当前工作流版本号"` + sendCont.EpOld = v.EpOld //1:旧流程;2:新流程"` + sendCont.Creater = strconv.FormatInt(v.Creater, 10) //流程创始人"` + sendCont.TargetTitle = v.TargetTitle //指标名称"` + sendCont.BylawsTitle = v.BylawsTitle //细则名称"` + sendCont.Clique = strconv.FormatInt(v.Clique, 10) //公司"` var accOrgCont modelshr.AdministrativeOrganization accOrgCont.GetCont(map[string]interface{}{"`id`": v.AcceptDepartment}, "`name`") sendCont.DepartmentName = accOrgCont.Name diff --git a/api/version1/postseting/postpc/scheme.go b/api/version1/postseting/postpc/scheme.go index c389fab..4427db0 100644 --- a/api/version1/postseting/postpc/scheme.go +++ b/api/version1/postseting/postpc/scheme.go @@ -26,7 +26,7 @@ func (a *ApiMethod) GetSchemeList(c *gin.Context) { receivedValue.PageSize = 20 } var schemeList []modelskpi.PositionPlanVersio - gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.PositionPlanVersio{}).Where("`state` BETWEEN ? AND ?", 1, 2) + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.PositionPlanVersio{}) if receivedValue.VersionNumber != "" { gormDb = gormDb.Where("`key` LIKE ?", "%"+receivedValue.VersionNumber+"%") } @@ -40,10 +40,10 @@ func (a *ApiMethod) GetSchemeList(c *gin.Context) { if receivedValue.OrgId != "" { gormDb = gormDb.Where("`orgid` = ?", receivedValue.OrgId) } - if receivedValue.PostId != "" { - gormDb = gormDb.Where("`position` = ?", receivedValue.PostId) + if len(receivedValue.PostId) > 0 { + gormDb = gormDb.Where("`position` IN ?", receivedValue.PostId) } - if receivedValue.Year != 0 { + if receivedValue.Year != "" { gormDb = gormDb.Where("`years` = ?", receivedValue.Year) } if receivedValue.State != 0 { @@ -52,7 +52,7 @@ func (a *ApiMethod) GetSchemeList(c *gin.Context) { gormDb = gormDb.Where("`state` BETWEEN ? AND ?", 1, 2) } gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize) - err := gormDb.Order("`state` ASC").Order("`version` ASC").Order("`id` DESC").Find(&schemeList).Error + err := gormDb.Order("`orgid` ASC").Order("`position` ASC").Order("`state` ASC").Order("`years` ASC").Order("`version` ASC").Order("`id` DESC").Find(&schemeList).Error var total int64 totalErr := gormDb.Count(&total).Error if totalErr != nil { @@ -90,7 +90,7 @@ func (a *ApiMethod) GetSchemeList(c *gin.Context) { var postContInfo modelshr.Position postContInfo.GetCont(map[string]interface{}{"`id`": schemeList[i].Position}, "`name`") sendDataCont.PostName = postContInfo.Name //`归属岗位"` - + sendDataCont.TimeStr = publicmethod.UnixTimeToDay(schemeList[i].AddTime, 1) sendData = append(sendData, sendDataCont) } publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(sendData)), sendData, c) @@ -1183,6 +1183,7 @@ func (a *ApiMethod) EditSchemeStateOfDel(c *gin.Context) { publicmethod.Result(1, err, c, "未知系统参数!") return } + where := map[string]interface{}{"`id`": receivedValue.Id} var oldSystemCont modelskpi.PositionPlanVersio err = oldSystemCont.GetCont(where) @@ -1194,13 +1195,15 @@ func (a *ApiMethod) EditSchemeStateOfDel(c *gin.Context) { saveData := publicmethod.MapOut[string]() saveData["`state`"] = receivedValue.State saveData["`eitetime`"] = time.Now().Unix() - err = oldSystemCont.EiteCont(where, saveData) + var editPostPlan modelskpi.PositionPlanVersio + err = editPostPlan.EiteCont(where, saveData) } else { // if receivedValue.IsTrue != 1 { saveData := publicmethod.MapOut[string]() saveData["`state`"] = receivedValue.State saveData["`eitetime`"] = time.Now().Unix() - err = oldSystemCont.EiteCont(where, saveData) + var editPostPlan modelskpi.PositionPlanVersio + err = editPostPlan.EiteCont(where, saveData) // } else { // err = overall.CONSTANT_DB_System_Permission.Where(where).Delete(&oldSystemCont).Error // } @@ -1226,12 +1229,13 @@ func editSchemeOther(schemeCont modelskpi.PositionPlanVersio, state int) { saveData["`eitetime`"] = time.Now().Unix() overall.CONSTANT_DB_KPI.Model(&modelskpi.QualitativeEvaluationScheme{}).Where("`company_id` = ? AND `department_id` = ? AND `org_id` = ? AND `post_id` = ? AND `version_number` <> ?", schemeCont.Group, schemeCont.Department, schemeCont.OrgId, schemeCont.Position, schemeCont.Key).Updates(saveData) // 将本岗位下其他方案禁用 - var oldSystemCont modelskpi.PositionPlanVersio + // var oldSystemCont modelskpi.PositionPlanVersio saveDataOther := publicmethod.MapOut[string]() saveDataOther["`state`"] = 2 saveDataOther["`eitetime`"] = time.Now().Unix() - where := map[string]interface{}{"`id`": schemeCont.Id} - oldSystemCont.EiteCont(where, saveDataOther) + // where := map[string]interface{}{"`id`": schemeCont.Id} + // oldSystemCont.EiteCont(where, saveDataOther) + overall.CONSTANT_DB_KPI.Model(&modelskpi.PositionPlanVersio{}).Where("`position` = ? AND `state` = 1 AND `id` <> ?", schemeCont.Position, schemeCont.Id).Updates(saveDataOther) //开启本岗位方案详情 var qesCont modelskpi.QualitativeEvaluationScheme qesCont.EiteCont(map[string]interface{}{"`version_number`": schemeCont.Key}, map[string]interface{}{"`state": 1}) @@ -1282,3 +1286,106 @@ func xieChengWeight(class, orgid, postid, dimensionIdInt64, target, hierarchy, q dimWeight.Quote = quote //1:不是引用;2:引用部门"` dimWeight.WriteTargetWeight() } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-04-20 14:04:52 +@ 功能: 获取岗位指标(添加方案时使用) +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) HavePostTarget(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 + } + var postCont modelshr.Position + err = postCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id}, "administrative_organization") + if err != nil { + publicmethod.Result(1, err, c, "未知岗位!请先选择岗位!") + return + } + var targetId []int64 + err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("target_id").Where("`level` = 2 AND `state` = 1 AND `post_id` = ?", receivedValue.Id).Find(&targetId).Error + if err != nil && len(targetId) < 1 { + publicmethod.Result(105, err, c) + return + } + var postTargetListCont []modelskpi.PostTarget + err = overall.CONSTANT_DB_KPI.Where("`id` IN ?", targetId).Find(&postTargetListCont).Error + if err != nil && len(postTargetListCont) < 1 { + publicmethod.Result(105, err, c) + return + } + + var postPlanScheme postScheme + postPlanScheme.OrgId = strconv.FormatInt(postCont.AdministrativeOrganization, 10) + postPlanScheme.PostId = receivedValue.Id + var dutyClassList []PostSchemeDiem + var dutyId []int64 + var tarList []PostSchemeTar + for _, v := range postTargetListCont { + if !publicmethod.IsInTrue[int64](v.Dimension, dutyId) { + dutyId = append(dutyId, v.Dimension) + var dutyCont modelskpi.DutyClass + errs := dutyCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "`title`", `sort`) + if errs == nil { + var dyCont PostSchemeDiem + dyCont.Id = strconv.FormatInt(v.Dimension, 10) + dyCont.Name = dutyCont.Title + dyCont.Sort = dutyCont.Sort + dutyClassList = append(dutyClassList, dyCont) + } + } + var tarCont PostSchemeTar + tarCont.Id = strconv.FormatInt(v.Id, 10) + tarCont.Name = v.Title + tarCont.Content = "" //说明 + tarCont.Score = 0 //分数 + tarCont.State = 1 //状态:1:启用;2:禁用;3:观察 + tarCont.Type = v.Type //1、定性指标;2、定量指标 + tarCont.Dimension = strconv.FormatInt(v.Dimension, 10) + tarList = append(tarList, tarCont) + } + //根据维度序号排序 + sort.Slice(dutyClassList, func(i, j int) bool { + return dutyClassList[i].Sort < dutyClassList[j].Sort + }) + for _, dv := range dutyClassList { + var dyInfo schemeStructure + dyInfo.Id = dv.Id + dyInfo.Name = dv.Name + dyInfo.Sort = dv.Sort + dyInfo.Score = 0 + for _, tv := range tarList { + if tv.Dimension == dv.Id { + var trInfo schemeTargetStructure + trInfo.Id = tv.Id + trInfo.Name = tv.Name + trInfo.Content = tv.Content //说明 + trInfo.Score = tv.Score //分数 + trInfo.State = tv.State //状态:1:启用;2:禁用;3:观察 + trInfo.Type = tv.Type //1、定性指标;2、定量指标 + dyInfo.Child = append(dyInfo.Child, trInfo) + } + } + postPlanScheme.PostChild = append(postPlanScheme.PostChild, dyInfo) + } + publicmethod.Result(0, postPlanScheme, c) +} diff --git a/api/version1/postseting/postpc/type.go b/api/version1/postseting/postpc/type.go index 9742d66..638e7b1 100644 --- a/api/version1/postseting/postpc/type.go +++ b/api/version1/postseting/postpc/type.go @@ -131,13 +131,13 @@ type schemeDetailedStructure struct { // 岗位考核方案列表 type postSchemeList struct { publicmethod.PagesTurn - VersionNumber string `json:"versionnumber"` //版本号 - CompanyId string `json:"companyid"` //归属公司"` - DepartmentId string `json:"departmentid"` //归属部门"` - OrgId string `json:"orgid"` //归属行政组织"` - PostId string `json:"postid"` //`归属岗位"` - Year int `json:"year"` //`年度"` - State int `json:"state"` //`状态(1:启用;2:禁用;3:删除)"` + VersionNumber string `json:"versionnumber"` //版本号 + CompanyId string `json:"companyid"` //归属公司"` + DepartmentId string `json:"departmentid"` //归属部门"` + OrgId string `json:"orgid"` //归属行政组织"` + PostId []string `json:"postid"` //`归属岗位"` + Year string `json:"year"` //`年度"` + State int `json:"state"` //`状态(1:启用;2:禁用;3:删除)"` } // 输出岗位考核方案列表 @@ -148,6 +148,7 @@ type sendPostSchemeList struct { DepartmentName string `json:"departmentname"` //归属部门"` OrgName string `json:"orgname"` //归属行政组织"` PostName string `json:"postname"` //`归属岗位"` + TimeStr string `json:"timestr"` //`时间"` } // 输出考核方案详细内容 @@ -462,3 +463,20 @@ type NewEditPostTargetCont struct { publicmethod.PublicId NewAddPostTargetInfo } + +// 岗位方案指标列表 +type PostSchemeDiem struct { + publicmethod.PublicId //id + publicmethod.PublicName //名称 + Sort int `json:"sort"` //排序 +} + +type PostSchemeTar struct { + publicmethod.PublicId //id + publicmethod.PublicName //名称 + Content string `json:"content"` //说明 + Score float64 `json:"score"` //分数 + State int `json:"state"` //状态:1:启用;2:禁用;3:观察 + Type int `json:"type"` //1、定性指标;2、定量指标 + Dimension string `json:"dimension"` +} diff --git a/apirouter/v1/postseting/pc.go b/apirouter/v1/postseting/pc.go index ff99082..db55cae 100644 --- a/apirouter/v1/postseting/pc.go +++ b/apirouter/v1/postseting/pc.go @@ -20,6 +20,8 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("get_post_scheme", methodBinding.GetPostScheme) //获取岗位方案内容列表 apiRouter.POST("get_copy_sheme_infor", methodBinding.GetCopyShemeInfor) //获取复制岗位考核方案 + apiRouter.POST("have_post_target", methodBinding.HavePostTarget) //获取岗位指标(添加方案时使用) + apiRouter.POST("set_evaluation_objectives", methodBinding.SetEvaluationObjectives) //提交岗位定量目标设定 apiRouter.POST("post_config_list", methodBinding.PostConfigList) //岗位定量考核目标列表