package quantification
import (
"fmt"
"strconv"
"time"
"gin_server_admin/commonus"
"gin_server_admin/global"
"gin_server_admin/model/assessmentmodel"
)
//行政维度统计计算
/ *
@ taskId ( 执行中的考核方案ID弃用 ) 指标ID
@ dataAry 接收的界定参数
* /
func OrgDimensionStatistics ( taskId string , dataAry natureParameter ) ( outputData GraphicStatistics , outErr bool ) {
//当同时查询多个指标时启用 获取指标名称
outErr = true
var normName string = ""
norm := 1 //1:定性考核;2:定量考核
// if len(dataAry.TargetId) > 1 {
//当同时查询多个指标时启用 获取指标名称
// var qualEvalCont assessmentmodel.QualitativeEvaluation
// qualEvaWhe := commonus.MapOut()
// qualEvaWhe["qe_id"] = taskId
// qualEvalCont.GetCont(qualEvaWhe, "qe_target", "qe_type")
// taskCont, taskErr := commonus.GetTargetIn
taskIdInt , _ := strconv . ParseInt ( taskId , 10 , 64 )
taskCont , taskErr := commonus . GetTargetInfo ( taskIdInt )
if taskErr == true {
normName = taskCont . Title
outErr = taskErr
norm = taskCont . Type
} else {
// outErr = error.Error("此考核项目没有数据!")
outErr = taskErr
return
}
// }
//获取时间参数
timeFrame := EstimatedTime ( dataAry )
//获取组织架构参数
// orgAry, orgList := getGroupOrgList(dataAry.Org)
//获取组织架构参数
// var orgAry []orgModelsAry
var orgList [ ] orgModels
if len ( dataAry . Org ) > 0 {
_ , orgList = getGroupOrgList ( dataAry . Org )
} else {
_ , orgList = getGroupOrgList ( GetTargerDepartment ( taskCont . Dimension , taskIdInt ) )
}
//统计方式
statisticalMethod := 3
if len ( dataAry . AccMethod ) == 1 {
if commonus . IsItTrueInt ( 1 , dataAry . AccMethod ) == true {
statisticalMethod = 1
} else {
statisticalMethod = 2
}
}
for _ , v := range orgList {
//获取此指标跟查询部门相关的考核方案ID
var taskIdAry [ ] int64
global . GVA_DB_Performanceappraisal . Model ( & assessmentmodel . QualitativeEvaluation { } ) . Select ( "qe_id" ) . Where ( "qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation IN ?" , taskCont . Dimension , taskIdInt , v . SunOrg ) . Find ( & taskIdAry )
orgvSunOrg := "("
for tiai , tiav := range v . SunOrg {
if tiai != 0 {
orgvSunOrg = fmt . Sprintf ( "%v,%v" , orgvSunOrg , tiav )
} else {
orgvSunOrg = fmt . Sprintf ( "%v%v" , orgvSunOrg , tiav )
}
}
orgvSunOrg = fmt . Sprintf ( "%v)" , orgvSunOrg )
//组合考核方案ID
taskIdStrWher := "("
for tiai , tiav := range taskIdAry {
if tiai != 0 {
taskIdStrWher = fmt . Sprintf ( "%v,%v" , taskIdStrWher , tiav )
} else {
taskIdStrWher = fmt . Sprintf ( "%v%v" , taskIdStrWher , tiav )
}
}
taskIdStrWher = fmt . Sprintf ( "%v)" , taskIdStrWher )
if commonus . IsItTrueString ( v . Name , outputData . XLine ) == false {
outputData . XLine = append ( outputData . XLine , v . Name )
for _ , tv := range timeFrame { //在部门维度下进行时间跨度计算
switch tv . Class {
case 1 : //半年
//组合月
monthStr := "("
for twi , twv := range tv . Where {
if twi != 0 {
monthStr = fmt . Sprintf ( "%v,%v" , monthStr , twv )
} else {
monthStr = fmt . Sprintf ( "%v%v" , monthStr , twv )
}
}
monthStr = fmt . Sprintf ( "%v)" , monthStr )
if len ( dataAry . Year ) > 0 {
for _ , dayv := range dataAry . Year {
var sumScore float64
var averageScore float64
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department IN %v" , taskIdStrWher , dayv , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
//定量考核
wherStr := fmt . Sprintf ( "fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department IN %v" , taskIdStrWher , dayv , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
} else {
var sumScore float64
var averageScore float64
yearVal := commonus . ComputingTime ( time . Now ( ) . Unix ( ) , 1 )
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department IN %v" , taskIdStrWher , yearVal , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
wherStr := fmt . Sprintf ( "fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department IN %v" , taskIdStrWher , yearVal , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
case 2 : //季度
for _ , dayv := range dataAry . Year {
var sumScore float64
var averageScore float64
if len ( taskIdAry ) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_quarter` = %v AND sf_duty_department IN %v" , taskIdStrWher , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
wherStr := fmt . Sprintf ( "fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_quarter` = %v AND fl_duty_department IN %v" , taskIdStrWher , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v第%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v第%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v第%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v第%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
case 3 : //月
for _ , dayv := range dataAry . Year {
var sumScore float64
var averageScore float64
if len ( taskIdAry ) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_evaluation_plan IN %v AND `sf_year` = %v AND `sf_month` = %v AND sf_duty_department IN %v" , taskIdStrWher , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
//定量考核
wherStr := fmt . Sprintf ( "fld_evaluation_id IN %v AND `fl_year` = %v AND `fl_month` = %v AND fl_duty_department IN %v" , taskIdStrWher , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v年%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v年%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v年%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v年%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
default : //全年
var sumScore float64
var averageScore float64
if len ( taskIdAry ) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_evaluation_plan IN %v AND `sf_year` = %v AND sf_duty_department IN %v" , taskIdStrWher , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
//定量考核
wherStr := fmt . Sprintf ( "fld_evaluation_id IN %v AND `fl_year` = %v AND fl_duty_department IN %v" , taskIdStrWher , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
}
}
}
outErr = true
// fmt.Printf("orgAry====>%v\n", orgAry)
// jn, je := json.Marshal(orgList)
// fmt.Printf("orgList-====>%v-====>%v\n", string(jn), je)
// fmt.Printf("timeFrame-====>%v\n", timeFrame)
// tjn, tje := json.Marshal(timeFrame)
// fmt.Printf("timeFrameJson-====>%v-====>%v\n", string(tjn), tje)
// fmt.Printf("normName-====>%v\n", normName)
// fmt.Printf("statisticalMethod-====>%v\n", statisticalMethod)
return
}
func OrgDimensionStatisticsNew ( taskId string , dataAry natureParameter ) ( outputData GraphicStatistics , outErr bool ) {
//当同时查询多个指标时启用 获取指标名称
outErr = true
var normName string = ""
norm := 1 //1:定性考核;2:定量考核
// if len(dataAry.TargetId) > 1 {
//当同时查询多个指标时启用 获取指标名称
// var qualEvalCont assessmentmodel.QualitativeEvaluation
// qualEvaWhe := commonus.MapOut()
// qualEvaWhe["qe_id"] = taskId
// qualEvalCont.GetCont(qualEvaWhe, "qe_target", "qe_type")
// taskCont, taskErr := commonus.GetTargetIn
taskIdInt , _ := strconv . ParseInt ( taskId , 10 , 64 )
taskCont , taskErr := commonus . GetTargetInfo ( taskIdInt )
if taskErr == true {
normName = taskCont . Title
outErr = taskErr
norm = taskCont . Type
} else {
// outErr = error.Error("此考核项目没有数据!")
outErr = taskErr
return
}
// }
//获取时间参数
timeFrame := EstimatedTime ( dataAry )
//获取组织架构参数
// orgAry, orgList := getGroupOrgList(dataAry.Org)
//获取组织架构参数
// var orgAry []orgModelsAry
var orgList [ ] orgModels
if len ( dataAry . Org ) > 0 {
_ , orgList = getGroupOrgList ( dataAry . Org )
} else {
_ , orgList = getGroupOrgList ( GetTargerDepartment ( taskCont . Dimension , taskIdInt ) )
}
//统计方式
statisticalMethod := 3
if len ( dataAry . AccMethod ) == 1 {
if commonus . IsItTrueInt ( 1 , dataAry . AccMethod ) == true {
statisticalMethod = 1
} else {
statisticalMethod = 2
}
}
for _ , v := range orgList {
//获取此指标跟查询部门相关的考核方案ID
// var taskIdAry []int64
// global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.QualitativeEvaluation{}).Select("qe_id").Where("qe_state = 1 AND qe_dimension = ? AND qe_target = ? AND qe_accept_evaluation IN ?", taskCont.Dimension, taskIdInt, v.SunOrg).Find(&taskIdAry)
orgvSunOrg := "("
for tiai , tiav := range v . SunOrg {
if tiai != 0 {
orgvSunOrg = fmt . Sprintf ( "%v,%v" , orgvSunOrg , tiav )
} else {
orgvSunOrg = fmt . Sprintf ( "%v%v" , orgvSunOrg , tiav )
}
}
orgvSunOrg = fmt . Sprintf ( "%v)" , orgvSunOrg )
// //组合考核方案ID
// taskIdStrWher := "("
// for tiai, tiav := range taskIdAry {
// if tiai != 0 {
// taskIdStrWher = fmt.Sprintf("%v,%v", taskIdStrWher, tiav)
// } else {
// taskIdStrWher = fmt.Sprintf("%v%v", taskIdStrWher, tiav)
// }
// }
// taskIdStrWher = fmt.Sprintf("%v)", taskIdStrWher)
if commonus . IsItTrueString ( v . Name , outputData . XLine ) == false {
outputData . XLine = append ( outputData . XLine , v . Name )
for _ , tv := range timeFrame { //在部门维度下进行时间跨度计算
switch tv . Class {
case 1 : //半年
//组合月
monthStr := "("
for twi , twv := range tv . Where {
if twi != 0 {
monthStr = fmt . Sprintf ( "%v,%v" , monthStr , twv )
} else {
monthStr = fmt . Sprintf ( "%v%v" , monthStr , twv )
}
}
monthStr = fmt . Sprintf ( "%v)" , monthStr )
if len ( dataAry . Year ) > 0 {
for _ , dayv := range dataAry . Year {
var sumScore float64
var averageScore float64
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_target_id = %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department IN %v" , taskIdInt , dayv , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
//定量考核
wherStr := fmt . Sprintf ( "fld_target_id = %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department IN %v" , taskIdInt , dayv , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
} else {
var sumScore float64
var averageScore float64
yearVal := commonus . ComputingTime ( time . Now ( ) . Unix ( ) , 1 )
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_target_id = %v AND `sf_year` = %v AND `sf_month` IN %v AND sf_duty_department IN %v" , taskIdInt , yearVal , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
wherStr := fmt . Sprintf ( "fld_target_id = %v AND `fl_year` = %v AND `fl_month` IN %v AND fl_duty_department IN %v" , taskIdInt , yearVal , monthStr , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
case 2 : //季度
for _ , dayv := range dataAry . Year {
var sumScore float64
var averageScore float64
// if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_target_id = %v AND `sf_year` = %v AND `sf_quarter` = %v AND sf_duty_department IN %v" , taskIdInt , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
wherStr := fmt . Sprintf ( "fld_target_id = %v AND `fl_year` = %v AND `fl_quarter` = %v AND fl_duty_department IN %v" , taskIdInt , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
// }
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v第%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v第%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v第%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v第%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
case 3 : //月
for _ , dayv := range dataAry . Year {
var sumScore float64
var averageScore float64
// if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_target_id = %v AND `sf_year` = %v AND `sf_month` = %v AND sf_duty_department IN %v" , taskIdInt , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
//定量考核
wherStr := fmt . Sprintf ( "fld_target_id = %v AND `fl_year` = %v AND `fl_month` = %v AND fl_duty_department IN %v" , taskIdInt , dayv , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
// }
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v年%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v年%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v年%v %v" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v年%v %v平均值" , dayv , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
default : //全年
var sumScore float64
var averageScore float64
// if len(taskIdAry) > 0 {
if norm == 1 {
//定性考核
wherStr := fmt . Sprintf ( "sf_target_id = %v AND `sf_year` = %v AND sf_duty_department IN %v" , taskIdInt , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSumNature ( wherStr , 1 )
} else {
//定量考核
//定量考核
wherStr := fmt . Sprintf ( "fld_target_id = %v AND `fl_year` = %v AND fl_duty_department IN %v" , taskIdInt , tv . YearName , orgvSunOrg )
sumScore , averageScore = AverageOfSum ( wherStr )
}
// }
//判断计算总值还是平均值
switch statisticalMethod {
case 1 :
// sumScore, _ := AverageOfSum(wherStr)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
case 2 :
// _, averageScore := AverageOfSum(wherStr, 1)
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
default :
//合计与平均
// sumScore, averageScore := AverageOfSum(wherStr, 1)
normNameTotal := fmt . Sprintf ( "%v %v" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameTotal , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameTotal )
var seriesInfo series
seriesInfo . Name = normNameTotal
seriesInfo . Data = append ( seriesInfo . Data , sumScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfo )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameTotal {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , sumScore )
}
}
}
normNameAverage := fmt . Sprintf ( "%v %v平均值" , tv . XLine , normName )
if commonus . IsItTrueString ( normNameAverage , outputData . Cylindrical ) == false {
outputData . Cylindrical = append ( outputData . Cylindrical , normNameAverage )
var seriesInfoAverage series
seriesInfoAverage . Name = normNameAverage
seriesInfoAverage . Data = append ( seriesInfoAverage . Data , averageScore )
outputData . CylindricalData = append ( outputData . CylindricalData , seriesInfoAverage )
} else {
for cdi , cdv := range outputData . CylindricalData {
if cdv . Name == normNameAverage {
outputData . CylindricalData [ cdi ] . Data = append ( outputData . CylindricalData [ cdi ] . Data , averageScore )
}
}
}
}
}
}
}
}
outErr = true
// fmt.Printf("orgAry====>%v\n", orgAry)
// jn, je := json.Marshal(orgList)
// fmt.Printf("orgList-====>%v-====>%v\n", string(jn), je)
// fmt.Printf("timeFrame-====>%v\n", timeFrame)
// tjn, tje := json.Marshal(timeFrame)
// fmt.Printf("timeFrameJson-====>%v-====>%v\n", string(tjn), tje)
// fmt.Printf("normName-====>%v\n", normName)
// fmt.Printf("statisticalMethod-====>%v\n", statisticalMethod)
return
}