You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.1 KiB
85 lines
3.1 KiB
|
4 years ago
|
package quantification
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
|
||
|
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
|
||
|
|
)
|
||
|
|
|
||
|
|
//维度计算
|
||
|
|
/*
|
||
|
|
@normName 标准名称
|
||
|
|
@wherStr 查询条件
|
||
|
|
@calculationMethod 计算方式 1:和;2:平均值;3:和与平均值
|
||
|
|
*/
|
||
|
|
func DimensionCalculation(normName, wherStr string, calculationMethod int, oldStatistics GraphicStatistics) (outputData GraphicStatistics) {
|
||
|
|
switch calculationMethod {
|
||
|
|
case 1: //计算
|
||
|
|
sumScore, _ := AverageOfSum(wherStr)
|
||
|
|
normNameTotal := fmt.Sprintf("%v总值", normName)
|
||
|
|
if commonus.IsItTrueString(normNameTotal, oldStatistics.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, oldStatistics.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:
|
||
|
|
//合计与平均
|
||
|
|
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)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return
|
||
|
|
}
|