diff --git a/api/version1/departmentseting/departmentpc/dingliang.go b/api/version1/departmentseting/departmentpc/dingliang.go index 8f49b95..efa1238 100644 --- a/api/version1/departmentseting/departmentpc/dingliang.go +++ b/api/version1/departmentseting/departmentpc/dingliang.go @@ -77,198 +77,203 @@ func (a *ApiMethod) GetQuantitativeTasks(c *gin.Context) { publicmethod.Result(1, qualEvaList, c, "您没有要参加的考核项目!") return } + var idInAry []int64 var sendListCont []TargetContOutCont for _, vsss := range qualEvaList { var v modelskpi.QualitativeEvaluation v.GetCont(map[string]interface{}{"`qe_accept_evaluation`": vsss.AcceptEvaluation, "`qe_target`": vsss.Target, "`qe_state`": 1}) - var sendCont TargetContOutCont - sendCont.Id = strconv.FormatInt(v.Id, 10) - sendCont.Type = v.Type - sendCont.Group = strconv.FormatInt(v.Group, 10) - //公司 - var groupCont modelshr.AdministrativeOrganization - groupCont.GetCont(map[string]interface{}{"`id`": v.Group}, "`name`") - sendCont.GroupNAme = groupCont.Name - //部门 - var departCont modelshr.AdministrativeOrganization - departCont.GetCont(map[string]interface{}{"`id`": v.AcceptEvaluation}, "`name`") - sendCont.DepartmentName = departCont.Name - sendCont.DepartmentId = strconv.FormatInt(v.AcceptEvaluation, 10) - sendCont.PlanVersionNumber = v.QualEvalId //执行方案版本号 - //维度相关信息 - sendCont.Dimension = strconv.FormatInt(v.Dimension, 10) - var dimeCont modelskpi.DutyClass - dimeCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "`title`") - sendCont.DimensionName = dimeCont.Title - //指标信息 - sendCont.Target = strconv.FormatInt(v.Target, 10) - var targetCont modelskpi.EvaluationTarget - targetCont.GetCont(map[string]interface{}{"`et_id`": v.Target}, "`et_title`", "`et_scoring_method`") - sendCont.TargetName = targetCont.Title - //子栏目 - sendCont.ScoringMethod = int64(targetCont.ScoringMethod) - if v.TargetSun != 0 { - sendCont.TargetSun = strconv.FormatInt(v.TargetSun, 10) - var sunTargetCont modelskpi.QualitativeTarget - sunTargetCont.GetCont(map[string]interface{}{"`q_id`": v.Target}, "`q_title`") - sendCont.TargetSunName = sunTargetCont.Title - } - //指标细则 - if v.DetailedTarget != 0 { - sendCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10) - var detailedTargetCont modelskpi.DetailedTarget - detailedTargetCont.GetCont(map[string]interface{}{"`dt_id`": v.Target}, "`dt_title`", "`dt_content`") - sendCont.DetailedTargetName = detailedTargetCont.Title - sendCont.Content = detailedTargetCont.Content - } - sendCont.Unit = v.Unit - sendCont.ReferenceScore = v.ReferenceScore - sendCont.Cycles = v.Cycles - sendCont.CycleAttres = v.CycleAttres - sendCont.State = v.State - userAry := strings.Split(v.Operator, ",") - sendCont.UserList = userAry - for _, u_v := range userAry { - var repoCont modelshr.PersonArchives - repoErr := repoCont.GetCont(map[string]interface{}{"`key`": u_v}, "`number`", "`name`") - if repoErr == nil { - var userCont QualEvalArrt - userCont.Id = u_v - userCont.Name = repoCont.Name - sendCont.UserListAry = append(sendCont.UserListAry, userCont) + + if !publicmethod.IsInTrue[int64](v.Id, idInAry) { + idInAry = append(idInAry, v.Id) + var sendCont TargetContOutCont + sendCont.Id = strconv.FormatInt(v.Id, 10) + sendCont.Type = v.Type + sendCont.Group = strconv.FormatInt(v.Group, 10) + //公司 + var groupCont modelshr.AdministrativeOrganization + groupCont.GetCont(map[string]interface{}{"`id`": v.Group}, "`name`") + sendCont.GroupNAme = groupCont.Name + //部门 + var departCont modelshr.AdministrativeOrganization + departCont.GetCont(map[string]interface{}{"`id`": v.AcceptEvaluation}, "`name`") + sendCont.DepartmentName = departCont.Name + sendCont.DepartmentId = strconv.FormatInt(v.AcceptEvaluation, 10) + sendCont.PlanVersionNumber = v.QualEvalId //执行方案版本号 + //维度相关信息 + sendCont.Dimension = strconv.FormatInt(v.Dimension, 10) + var dimeCont modelskpi.DutyClass + dimeCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "`title`") + sendCont.DimensionName = dimeCont.Title + //指标信息 + sendCont.Target = strconv.FormatInt(v.Target, 10) + var targetCont modelskpi.EvaluationTarget + targetCont.GetCont(map[string]interface{}{"`et_id`": v.Target}, "`et_title`", "`et_scoring_method`") + sendCont.TargetName = targetCont.Title + //子栏目 + sendCont.ScoringMethod = int64(targetCont.ScoringMethod) + if v.TargetSun != 0 { + sendCont.TargetSun = strconv.FormatInt(v.TargetSun, 10) + var sunTargetCont modelskpi.QualitativeTarget + sunTargetCont.GetCont(map[string]interface{}{"`q_id`": v.Target}, "`q_title`") + sendCont.TargetSunName = sunTargetCont.Title } - } - fmt.Printf("版本号吗!--->%v\n", v.QualEvalId) - sendCont.DimensionWeight, sendCont.TargetWeight = getPlanVersionWeghit(v.QualEvalId, strconv.FormatInt(v.Dimension, 10), strconv.FormatInt(v.Target, 10)) - //获取目标设定 - quanTitWhere := publicmethod.MapOut[string]() - // quanTitWhere["company_id"] = v.Group - quanTitWhere["departmentid"] = v.AcceptEvaluation - // quanTitWhere["dimension"] = v.Dimension - quanTitWhere["target"] = v.Target - if v.DetailedTarget != 0 { - quanTitWhere["targetconfig"] = v.DetailedTarget - } - quanTitWhere["year"] = publicmethod.UnixTimeToDay(time.Now().Unix(), 16) - quanTitWhere["timecopy"] = AllZreoConfig(v.Cycles) - //目标值设定 - var quanTitCont modelskpi.QuantitativeConfig - quanTitCont.GetCont(quanTitWhere) - //全奖值、零奖值、封顶值 - sendCont.ZeroPrize = strconv.FormatFloat(float64(quanTitCont.Zeroprize)/100, 'f', -1, 64) - sendCont.AllPrize = strconv.FormatFloat(float64(quanTitCont.Allprize)/100, 'f', -1, 64) - sendCont.CappingVal = quanTitCont.CappingVal / 100 - //获取实际值 - shiJiZhi := publicmethod.MapOut[string]() - shiJiZhi["fl_evaluation_user"] = myLoginCont.Key - shiJiZhi["fl_evaluation_department"] = myLoginCont.MainDeparment - shiJiZhi["fl_evaluation_group"] = myLoginCont.Company - shiJiZhi["fl_duty_department"] = v.AcceptEvaluation - - operationTime := time.Now().Unix() - if receivedValue.Time != "" { - strTime := fmt.Sprintf("%v-01 00:00:00", receivedValue.Time) - stringToTime, strToTimeErr := publicmethod.DateToTimeStamp(strTime) - if strToTimeErr == true { - operationTime = stringToTime - } else { - strTime = fmt.Sprintf("%v 00:00:00", receivedValue.Time) - stringToTime, strToTimeErr = publicmethod.DateToTimeStamp(strTime) + //指标细则 + if v.DetailedTarget != 0 { + sendCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10) + var detailedTargetCont modelskpi.DetailedTarget + detailedTargetCont.GetCont(map[string]interface{}{"`dt_id`": v.Target}, "`dt_title`", "`dt_content`") + sendCont.DetailedTargetName = detailedTargetCont.Title + sendCont.Content = detailedTargetCont.Content + } + sendCont.Unit = v.Unit + sendCont.ReferenceScore = v.ReferenceScore + sendCont.Cycles = v.Cycles + sendCont.CycleAttres = v.CycleAttres + sendCont.State = v.State + userAry := strings.Split(v.Operator, ",") + sendCont.UserList = userAry + for _, u_v := range userAry { + var repoCont modelshr.PersonArchives + repoErr := repoCont.GetCont(map[string]interface{}{"`key`": u_v}, "`number`", "`name`") + if repoErr == nil { + var userCont QualEvalArrt + userCont.Id = u_v + userCont.Name = repoCont.Name + sendCont.UserListAry = append(sendCont.UserListAry, userCont) + } + } + fmt.Printf("版本号吗!--->%v\n", v.QualEvalId) + sendCont.DimensionWeight, sendCont.TargetWeight = getPlanVersionWeghit(v.QualEvalId, strconv.FormatInt(v.Dimension, 10), strconv.FormatInt(v.Target, 10)) + //获取目标设定 + quanTitWhere := publicmethod.MapOut[string]() + // quanTitWhere["company_id"] = v.Group + quanTitWhere["departmentid"] = v.AcceptEvaluation + // quanTitWhere["dimension"] = v.Dimension + quanTitWhere["target"] = v.Target + if v.DetailedTarget != 0 { + quanTitWhere["targetconfig"] = v.DetailedTarget + } + quanTitWhere["year"] = publicmethod.UnixTimeToDay(time.Now().Unix(), 16) + quanTitWhere["timecopy"] = AllZreoConfig(v.Cycles) + //目标值设定 + var quanTitCont modelskpi.QuantitativeConfig + quanTitCont.GetCont(quanTitWhere) + //全奖值、零奖值、封顶值 + sendCont.ZeroPrize = strconv.FormatFloat(float64(quanTitCont.Zeroprize)/100, 'f', -1, 64) + sendCont.AllPrize = strconv.FormatFloat(float64(quanTitCont.Allprize)/100, 'f', -1, 64) + sendCont.CappingVal = quanTitCont.CappingVal / 100 + //获取实际值 + shiJiZhi := publicmethod.MapOut[string]() + shiJiZhi["fl_evaluation_user"] = myLoginCont.Key + shiJiZhi["fl_evaluation_department"] = myLoginCont.MainDeparment + shiJiZhi["fl_evaluation_group"] = myLoginCont.Company + shiJiZhi["fl_duty_department"] = v.AcceptEvaluation + + operationTime := time.Now().Unix() + if receivedValue.Time != "" { + strTime := fmt.Sprintf("%v-01 00:00:00", receivedValue.Time) + stringToTime, strToTimeErr := publicmethod.DateToTimeStamp(strTime) if strToTimeErr == true { operationTime = stringToTime + } else { + strTime = fmt.Sprintf("%v 00:00:00", receivedValue.Time) + stringToTime, strToTimeErr = publicmethod.DateToTimeStamp(strTime) + if strToTimeErr == true { + operationTime = stringToTime + } } } - } - years := publicmethod.ComputingTime(operationTime, 1) - quarter := publicmethod.ComputingTime(operationTime, 2) - months := publicmethod.ComputingTime(operationTime, 3) - switch v.Cycles { - case 1: - shiJiZhi["fl_year"] = years - shiJiZhi["fl_quarter"] = quarter - shiJiZhi["fl_month"] = months - shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) - shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) - case 2: - shiJiZhi["fl_year"] = years - shiJiZhi["fl_quarter"] = quarter - shiJiZhi["fl_month"] = months - shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) - shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) - case 3: - shiJiZhi["fl_year"] = years - shiJiZhi["fl_quarter"] = quarter - shiJiZhi["fl_month"] = months - shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) - case 4: - shiJiZhi["fl_year"] = years - shiJiZhi["fl_quarter"] = quarter - shiJiZhi["fl_month"] = months - case 5: - shiJiZhi["fl_year"] = years - shiJiZhi["fl_quarter"] = quarter - case 6: - shiJiZhi["fl_year"] = years - default: - shiJiZhi["fl_year"] = years - shiJiZhi["fl_quarter"] = quarter - shiJiZhi["fl_month"] = months - shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) - shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) - } - sendCont.ReferTo = JudgeDingLiangIsTrue(v.Id, v.AcceptEvaluation, years, quarter, months, v.Cycles) - actualValue, shouDongScore := GetTimeIntervalDuty(shiJiZhi, v.Id) //实际值 - sendCont.Actual = strconv.FormatFloat(actualValue/100, 'f', -1, 64) - // chuShuVal := actualValue - quanTitCont.Zeroprize - // beiChuShuVal := quanTitCont.Allprize - quanTitCont.Zeroprize - // if beiChuShuVal > 0 { - // sendCont.ReachScore = chuShuVal / beiChuShuVal - // } else { - // sendCont.ReachScore = 0 - // } - var actual float64 - actual, sendCont.ReachScore = postweb.GetAchieAndActual(actualValue, float64(sendCont.TargetWeight), quanTitCont.Zeroprize, quanTitCont.Allprize, quanTitCont.CappingVal) - if targetCont.ScoringMethod != 1 { - sendCont.ReachScore = publicmethod.DecimalEs(shouDongScore/100, 2) - } - // fmt.Printf("All--->score:%v------>weight:%v------>zeroprize:%v------>allprize:%v------>cappingval:%v------>achievement:%v------>actual:%v\n", actualValue, sendCont.TargetWeight, quanTitCont.Zeroprize, quanTitCont.Allprize, quanTitCont.CappingVal, sendCont.ReachScore, actual) - if quanTitCont.Zeroprize == 0 && quanTitCont.Allprize == 0 { - sendCont.Reach = "未设置目标值" - } else { - dividend := quanTitCont.Allprize - quanTitCont.Zeroprize //被除数 - if dividend == 0 { + years := publicmethod.ComputingTime(operationTime, 1) + quarter := publicmethod.ComputingTime(operationTime, 2) + months := publicmethod.ComputingTime(operationTime, 3) + switch v.Cycles { + case 1: + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months + shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) + shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) + case 2: + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months + shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) + shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) + case 3: + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months + shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) + case 4: + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months + case 5: + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + case 6: + shiJiZhi["fl_year"] = years + default: + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months + shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) + shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) + } + sendCont.ReferTo = JudgeDingLiangIsTrue(v.Id, v.AcceptEvaluation, years, quarter, months, v.Cycles) + actualValue, shouDongScore := GetTimeIntervalDuty(shiJiZhi, v.Id) //实际值 + sendCont.Actual = strconv.FormatFloat(actualValue/100, 'f', -1, 64) + // chuShuVal := actualValue - quanTitCont.Zeroprize + // beiChuShuVal := quanTitCont.Allprize - quanTitCont.Zeroprize + // if beiChuShuVal > 0 { + // sendCont.ReachScore = chuShuVal / beiChuShuVal + // } else { + // sendCont.ReachScore = 0 + // } + var actual float64 + actual, sendCont.ReachScore = postweb.GetAchieAndActual(actualValue, float64(sendCont.TargetWeight), quanTitCont.Zeroprize, quanTitCont.Allprize, quanTitCont.CappingVal) + if targetCont.ScoringMethod != 1 { + sendCont.ReachScore = publicmethod.DecimalEs(shouDongScore/100, 2) + } + // fmt.Printf("All--->score:%v------>weight:%v------>zeroprize:%v------>allprize:%v------>cappingval:%v------>achievement:%v------>actual:%v\n", actualValue, sendCont.TargetWeight, quanTitCont.Zeroprize, quanTitCont.Allprize, quanTitCont.CappingVal, sendCont.ReachScore, actual) + if quanTitCont.Zeroprize == 0 && quanTitCont.Allprize == 0 { sendCont.Reach = "未设置目标值" } else { - // sendCont.Reach = fmt.Sprintf("(实际值-零奖值)/(全奖值-零奖值)") - actual = publicmethod.DecimalEs(actual*100, 2) - sendCont.Reach = fmt.Sprintf("%v%v", actual, "%") - if actualValue == 0 { - sendCont.Reach = "100%" + dividend := quanTitCont.Allprize - quanTitCont.Zeroprize //被除数 + if dividend == 0 { + sendCont.Reach = "未设置目标值" + } else { + // sendCont.Reach = fmt.Sprintf("(实际值-零奖值)/(全奖值-零奖值)") + actual = publicmethod.DecimalEs(actual*100, 2) + sendCont.Reach = fmt.Sprintf("%v%v", actual, "%") + if actualValue == 0 { + sendCont.Reach = "100%" + } } } + sendCont.Reason = "" + sendCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10) + + // switch v.Cycles { + // case 5: + // banNian := []int64{3, 6, 9, 12} + // if publicmethod.IsInTrue[int64](months, banNian) { + // sendListCont = append(sendListCont, sendCont) + // } + // case 6: + // if months == 12 { + // sendListCont = append(sendListCont, sendCont) + // } + // case 7: + // banNian := []int64{6, 12} + // if publicmethod.IsInTrue[int64](months, banNian) { + // sendListCont = append(sendListCont, sendCont) + // } + // default: + // sendListCont = append(sendListCont, sendCont) + // } + sendListCont = append(sendListCont, sendCont) } - sendCont.Reason = "" - sendCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10) - - // switch v.Cycles { - // case 5: - // banNian := []int64{3, 6, 9, 12} - // if publicmethod.IsInTrue[int64](months, banNian) { - // sendListCont = append(sendListCont, sendCont) - // } - // case 6: - // if months == 12 { - // sendListCont = append(sendListCont, sendCont) - // } - // case 7: - // banNian := []int64{6, 12} - // if publicmethod.IsInTrue[int64](months, banNian) { - // sendListCont = append(sendListCont, sendCont) - // } - // default: - // sendListCont = append(sendListCont, sendCont) - // } - sendListCont = append(sendListCont, sendCont) } publicmethod.Result(0, sendListCont, c) } diff --git a/api/workflow/workflowengine/flowhandle.go b/api/workflow/workflowengine/flowhandle.go index 66d16e4..05cb9f9 100644 --- a/api/workflow/workflowengine/flowhandle.go +++ b/api/workflow/workflowengine/flowhandle.go @@ -93,7 +93,15 @@ func (a *ApiMethod) GetAllParentNode(c *gin.Context) { } var outCont outAllNodeCont outCont.SeekFromNodeCont(receivedValue.Id, receivedValue.AllCont) - sendCont.AllCont = outCont.AllCont + var daoXun []NodePublicStruct + contLen := len(outCont.AllCont) + if contLen > 0 { + for i := contLen - 1; i >= 0; i-- { + daoXun = append(daoXun, outCont.AllCont[i]) + } + } + + sendCont.AllCont = daoXun sendCont.Total = len(outCont.AllCont) publicmethod.Result(0, sendCont, c) }