package quantification
import (
"fmt"
"strconv"
"time"
"gin_server_admin/commonus"
"gin_server_admin/global"
"gin_server_admin/model/assessmentmodel"
)
// 获取总值
func AuxiliaryCalculationSum ( where interface { } ) ( sumScore float64 ) {
gormDb := global . GVA_DB_Performanceappraisal . Model ( & assessmentmodel . FlowLogData { } ) . Joins ( "left join flow_log as fl on fl.fl_key = flow_log_data.fld_flow_log" ) . Where ( where )
gormDb . Pluck ( "COALESCE(SUM(fld_score), 0) as rescore" , & sumScore )
return
}
// 获取总数
func AuxiliaryCalculationCount ( where interface { } ) ( sumScore float64 ) {
gormDb := global . GVA_DB_Performanceappraisal . Model ( & assessmentmodel . FlowLogData { } ) . Joins ( "left join flow_log as fl on fl.fl_key = flow_log_data.fld_flow_log" ) . Where ( where )
gormDb . Pluck ( "COALESCE(COUNT(fld_id), 0) as countid" , & sumScore ) //获取总数
return
}
// 计算总值和平均值
func AverageOfSum ( where interface { } , class ... int ) ( sumScore float64 , averageScore float64 ) {
sumScore = AuxiliaryCalculationSum ( where ) / 100
if len ( class ) > 0 {
countPage := AuxiliaryCalculationCount ( where )
if countPage > 0 {
averageScore = sumScore / countPage
}
}
if sumScore != 0 {
sumScore = commonus . Decimal ( sumScore )
}
if averageScore != 0 {
averageScore = commonus . Decimal ( averageScore )
}
return
}
//时间推算
/ *
@ dataAry 接收的界定参数
* /
func EstimatedTime ( dataAry natureParameter ) ( timeFrame [ ] TimeFrame ) {
if len ( dataAry . Year ) > 0 {
switch dataAry . TimeAttribute . Class {
case 1 : //半年
// for _, yearV := range dataAry.Year {
// if len(dataAry.TimeAttribute.Time) > 0 {
// for _, banYearVal := range dataAry.TimeAttribute.Time {
// if banYearVal == 1 {
// var timeFrameInfo TimeFrame
// timeFrameInfo.XLine = fmt.Sprintf("%v上半年", yearV)
// timeFrameInfo.Class = 1
// timeFrameInfo.YearName = yearV
// timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6}
// timeFrame = append(timeFrame, timeFrameInfo)
// }
// if banYearVal == 2 {
// var timeFrameInfo TimeFrame
// timeFrameInfo.XLine = fmt.Sprintf("%v下半年", yearV)
// timeFrameInfo.Class = 1
// timeFrameInfo.YearName = yearV
// timeFrameInfo.Where = []int{7, 8, 9, 10, 11, 12}
// timeFrame = append(timeFrame, timeFrameInfo)
// }
// }
// } else {
// var timeFrameInfo TimeFrame
// timeFrameInfo.XLine = fmt.Sprintf("%v上半年", yearV)
// timeFrameInfo.Class = 1
// timeFrameInfo.YearName = yearV
// timeFrameInfo.Where = []int{1, 2, 3, 4, 5, 6}
// timeFrame = append(timeFrame, timeFrameInfo)
// var timeFrameInfoXia TimeFrame
// timeFrameInfoXia.XLine = fmt.Sprintf("%v下半年", yearV)
// timeFrameInfoXia.Class = 1
// timeFrameInfoXia.YearName = yearV
// timeFrameInfoXia.Where = []int{7, 8, 9, 10, 11, 12}
// timeFrame = append(timeFrame, timeFrameInfoXia)
// }
// }
if len ( dataAry . TimeAttribute . Time ) > 0 {
for _ , banYearVal := range dataAry . TimeAttribute . Time {
if banYearVal == 1 {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "上半年" )
timeFrameInfo . Class = 1
timeFrameInfo . YearName = "1"
timeFrameInfo . Where = [ ] int { 1 , 2 , 3 , 4 , 5 , 6 }
timeFrame = append ( timeFrame , timeFrameInfo )
}
if banYearVal == 2 {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "下半年" )
timeFrameInfo . Class = 1
timeFrameInfo . YearName = "2"
timeFrameInfo . Where = [ ] int { 7 , 8 , 9 , 10 , 11 , 12 }
timeFrame = append ( timeFrame , timeFrameInfo )
}
}
} else {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "上半年" )
timeFrameInfo . Class = 1
timeFrameInfo . YearName = "1"
timeFrameInfo . Where = [ ] int { 1 , 2 , 3 , 4 , 5 , 6 }
timeFrame = append ( timeFrame , timeFrameInfo )
var timeFrameInfoXia TimeFrame
timeFrameInfoXia . XLine = fmt . Sprintf ( "下半年" )
timeFrameInfoXia . Class = 1
timeFrameInfoXia . YearName = "2"
timeFrameInfoXia . Where = [ ] int { 7 , 8 , 9 , 10 , 11 , 12 }
timeFrame = append ( timeFrame , timeFrameInfoXia )
}
case 2 :
if len ( dataAry . TimeAttribute . Time ) > 0 && len ( dataAry . TimeAttribute . Time ) < 5 {
for _ , quarV := range dataAry . TimeAttribute . Time {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "%v季度" , quarV )
timeFrameInfo . Class = 2
timeFrameInfo . YearName = fmt . Sprintf ( "%v" , quarV )
timeFrameInfo . Where = append ( timeFrameInfo . Where , quarV )
timeFrame = append ( timeFrame , timeFrameInfo )
}
} else {
for i := 1 ; i < 5 ; i ++ {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "%v季度" , i )
timeFrameInfo . Class = 2
timeFrameInfo . YearName = fmt . Sprintf ( "%v" , i )
timeFrameInfo . Where = append ( timeFrameInfo . Where , i )
timeFrame = append ( timeFrame , timeFrameInfo )
}
}
case 3 :
if len ( dataAry . TimeAttribute . Time ) > 0 {
for _ , monthV := range dataAry . TimeAttribute . Time {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "%v月" , monthV )
timeFrameInfo . Class = 3
timeFrameInfo . YearName = fmt . Sprintf ( "%v" , monthV )
timeFrameInfo . Where = append ( timeFrameInfo . Where , monthV )
timeFrame = append ( timeFrame , timeFrameInfo )
}
} else {
for i := 1 ; i < 13 ; i ++ {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "%v月" , i )
timeFrameInfo . Class = 3
timeFrameInfo . YearName = fmt . Sprintf ( "%v" , i )
timeFrameInfo . Where = append ( timeFrameInfo . Where , i )
timeFrame = append ( timeFrame , timeFrameInfo )
}
}
default :
for _ , yv := range dataAry . Year {
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "%v年" , yv )
timeFrameInfo . Class = 0
timeFrameInfo . YearName = yv
yearInt , _ := strconv . Atoi ( yv )
timeFrameInfo . Where = append ( timeFrameInfo . Where , yearInt )
timeFrame = append ( timeFrame , timeFrameInfo )
}
}
} else {
dangQianTime := time . Now ( ) . Unix ( )
dangQianYear := commonus . TimeStampToDate ( dangQianTime , 11 )
var timeFrameInfo TimeFrame
timeFrameInfo . XLine = fmt . Sprintf ( "%v年" , dangQianYear )
timeFrameInfo . Class = 0
timeFrameInfo . YearName = dangQianYear
yearInt , _ := strconv . Atoi ( dangQianYear )
timeFrameInfo . Where = append ( timeFrameInfo . Where , yearInt )
timeFrame = append ( timeFrame , timeFrameInfo )
}
return
}
//时间维度统计计算
/ *
@ taskId 执行中的考核方案ID
@ dataAry 接收的界定参数
* /
func TimeStatistics ( taskId string , dataAry natureParameter ) ( outputData GraphicStatistics , outErr bool ) {
outErr = true
var normName string = ""
if len ( dataAry . TargetId ) > 1 {
//当同时查询多个指标时启用 获取指标名称
var qualEvalCont assessmentmodel . QualitativeEvaluation
qualEvaWhe := commonus . MapOut ( )
qualEvaWhe [ "qe_id" ] = taskId
qualEvalCont . GetCont ( qualEvaWhe , "qe_target" )
taskCont , taskErr := commonus . GetTargetInfo ( qualEvalCont . Target )
if taskErr == true {
normName = taskCont . Title
outErr = taskErr
} else {
// outErr = error.Error("此考核项目没有数据!")
outErr = taskErr
return
}
}
//以时间维度,获取X坐标轴
timeFrame := EstimatedTime ( dataAry )
//统计方式
statisticalMethod := 3
if len ( dataAry . AccMethod ) == 1 {
if commonus . IsItTrueInt ( 1 , dataAry . AccMethod ) == true {
statisticalMethod = 1
} else {
statisticalMethod = 2
}
}
// fmt.Printf("timeFrame--------->%v\n", timeFrame)
// return
//根据时间维度进行统计
for _ , tfv := range timeFrame {
switch tfv . Class {
case 1 :
// fmt.Sprintf("KKKKK--------->%v\n", tfv.XLine)
if commonus . IsItTrueString ( tfv . XLine , outputData . XLine ) == false {
outputData . XLine = append ( outputData . XLine , tfv . XLine )
}
monthStr := "("
for twi , twv := range tfv . Where {
if twi != 0 {
monthStr = fmt . Sprintf ( "%v,%v" , monthStr , twv )
} else {
monthStr = fmt . Sprintf ( "%v%v" , monthStr , twv )
}
}
monthStr = fmt . Sprintf ( "%v)" , monthStr )
wherStr := fmt . Sprintf ( "fld_evaluation_id = %v AND `fl_year` = %v AND `fl_month` IN %v" , taskId , tfv . YearName , monthStr )
if len ( dataAry . Org ) > 0 {
//存在组织结构
_ , orgList := getGroupOrg ( dataAry . Org )
if len ( orgList ) > 0 {
for _ , orgv := range orgList {
if orgv . Level <= 2 {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_group` = %v" , wherStr , orgv . Id )
} else {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_department` = %v" , wherStr , orgv . Id )
}
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v %v总值" , orgv . Name , 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平均值" , orgv . Name , 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总值" , orgv . Name , 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平均值" , orgv . Name , 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 {
//不存在行政组织
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v总值" , 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平均值" , 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总值" , 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平均值" , 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 )
}
}
}
}
}
if len ( dataAry . AccMethod ) > 0 {
if commonus . IsItTrueInt ( 1 , dataAry . AccMethod ) == true && commonus . IsItTrueInt ( 2 , dataAry . AccMethod ) == true {
//合计与平均
sumScore , averageScore := AverageOfSum ( wherStr , 1 )
normNameTotal := fmt . Sprintf ( "%v总值" , 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平均值" , 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 if commonus . IsItTrueInt ( 1 , dataAry . AccMethod ) == true {
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v总值" , 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 )
}
}
}
} else if commonus . IsItTrueInt ( 2 , dataAry . AccMethod ) == true {
_ , averageScore := AverageOfSum ( wherStr , 1 )
normNameAverage := fmt . Sprintf ( "%v平均值" , 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 {
//合计与平均
sumScore , averageScore := AverageOfSum ( wherStr , 1 )
normNameTotal := fmt . Sprintf ( "%v总值" , 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平均值" , 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 :
//季度
if commonus . IsItTrueString ( tfv . XLine , outputData . XLine ) == false {
outputData . XLine = append ( outputData . XLine , tfv . XLine )
}
for _ , yearVal := range dataAry . Year {
wherStr := fmt . Sprintf ( "fld_evaluation_id = %v AND `fl_year` = %v AND `fl_quarter` = %v" , taskId , yearVal , tfv . YearName )
// fmt.Printf("%v季度\n", yearVal)
if len ( dataAry . Org ) > 0 {
//存在组织结构
_ , orgList := getGroupOrg ( dataAry . Org )
if len ( orgList ) > 0 {
for _ , orgv := range orgList {
if orgv . Level <= 2 {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_group` = %v" , wherStr , orgv . Id )
} else {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_department` = %v" , wherStr , orgv . Id )
}
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v %v总值" , orgv . Name , 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平均值" , orgv . Name , 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总值" , orgv . Name , 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平均值" , orgv . Name , 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 {
//不存在行政组织
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v总值" , 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平均值" , 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总值" , 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平均值" , 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 :
//月
if commonus . IsItTrueString ( tfv . XLine , outputData . XLine ) == false {
outputData . XLine = append ( outputData . XLine , tfv . XLine )
}
for _ , yearVal := range dataAry . Year {
wherStr := fmt . Sprintf ( "fld_evaluation_id = %v AND `fl_year` = %v AND `fl_month` = %v" , taskId , yearVal , tfv . YearName )
if len ( dataAry . Org ) > 0 {
//存在组织结构
_ , orgList := getGroupOrg ( dataAry . Org )
if len ( orgList ) > 0 {
for _ , orgv := range orgList {
if orgv . Level <= 2 {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_group` = %v" , wherStr , orgv . Id )
} else {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_department` = %v" , wherStr , orgv . Id )
}
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v %v总值" , orgv . Name , 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平均值" , orgv . Name , 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总值" , orgv . Name , 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平均值" , orgv . Name , 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 {
//不存在行政组织
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v总值" , 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平均值" , 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总值" , 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平均值" , 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 :
//全年
if commonus . IsItTrueString ( tfv . XLine , outputData . XLine ) == false {
outputData . XLine = append ( outputData . XLine , tfv . XLine )
}
for _ , tfwv := range tfv . Where {
wherStr := fmt . Sprintf ( "fld_evaluation_id = %v AND `fl_year` = %v" , taskId , tfwv )
if len ( dataAry . Org ) > 0 {
//存在组织结构
_ , orgList := getGroupOrg ( dataAry . Org )
if len ( orgList ) > 0 {
for _ , orgv := range orgList {
if orgv . Level <= 2 {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_group` = %v" , wherStr , orgv . Id )
} else {
wherStr = fmt . Sprintf ( "%v AND `fl_duty_department` = %v" , wherStr , orgv . Id )
}
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v %v总值" , orgv . Name , 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平均值" , orgv . Name , 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总值" , orgv . Name , 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平均值" , orgv . Name , 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 {
//不存在行政组织
switch statisticalMethod {
case 1 :
//合计
sumScore , _ := AverageOfSum ( wherStr )
normNameTotal := fmt . Sprintf ( "%v总值" , 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平均值" , 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总值" , 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平均值" , 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 )
}
}
}
}
}
}
}
}
// fmt.Println(normName)
return
}