36 changed files with 2207 additions and 148 deletions
@ -0,0 +1,4 @@ |
|||||
|
package statistics |
||||
|
|
||||
|
//统计
|
||||
|
type ApiGroup struct{} |
||||
@ -0,0 +1,33 @@ |
|||||
|
package statistics |
||||
|
|
||||
|
import ( |
||||
|
"strconv" |
||||
|
|
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//考核入口
|
||||
|
func (a *ApiGroup) Index(c *gin.Context) { |
||||
|
outPut := commonus.MapOut() |
||||
|
response.Result(0, outPut, "方案数据表格获取成功", c) |
||||
|
} |
||||
|
|
||||
|
//方案数据表格统计
|
||||
|
func (a *ApiGroup) PlanVersioStatistics(c *gin.Context) { |
||||
|
var requestData commonus.SetIds |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
response.Result(101, err, "参数错误!请重新提交!", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Id == 0 && requestData.OutId == "" { |
||||
|
response.Result(102, err, "参数错误!请重新提交!", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.OutId != "" && requestData.Id == 0 { |
||||
|
idInt, _ := strconv.ParseInt(requestData.OutId, 10, 64) |
||||
|
requestData.Id = idInt |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,13 @@ |
|||||
package statistics |
package statistics |
||||
|
|
||||
import "github.com/flipped-aurora/gin-vue-admin/server/api/statistics/nature" |
import ( |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/api/statistics/nature" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/api/statistics/quantification" |
||||
|
) |
||||
|
|
||||
type ApiGroup struct { |
type ApiGroup struct { |
||||
NatureApi nature.ApiGroup |
NatureApi nature.ApiGroup |
||||
|
QuantApi quantification.ApiGroup |
||||
} |
} |
||||
|
|
||||
var ApiGroupApp = new(ApiGroup) |
var ApiGroupApp = new(ApiGroup) |
||||
|
|||||
@ -0,0 +1,965 @@ |
|||||
|
package quantification |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/global" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/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) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
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 |
||||
|
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 |
||||
|
yearInt, _ := strconv.Atoi(dangQianYear) |
||||
|
timeFrameInfo.Where = append(timeFrameInfo.Where, yearInt) |
||||
|
timeFrame = append(timeFrame, timeFrameInfo) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
//时间维度统计计算
|
||||
|
/* |
||||
|
@taskId 执行中的考核方案ID |
||||
|
@dataAry 接收的界定参数 |
||||
|
*/ |
||||
|
func TimeDimensionStatistics(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 |
||||
|
} |
||||
|
|
||||
|
//行政维度统计计算
|
||||
|
/* |
||||
|
@taskId 执行中的考核方案ID |
||||
|
@dataAry 接收的界定参数 |
||||
|
*/ |
||||
|
func OrgDimensionStatistics(taskId string, dataAry natureParameter) (outputData GraphicStatistics, outErr bool) { |
||||
|
//获取时间参数
|
||||
|
// timeFrame := EstimatedTime(dataAry)
|
||||
|
orgAry, orgList := getGroupOrg(dataAry.Org) |
||||
|
fmt.Printf("orgAry====>%v\n", orgAry) |
||||
|
fmt.Printf("orgList-====>%v\n", orgList) |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,93 @@ |
|||||
|
package quantification |
||||
|
|
||||
|
import ( |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
type ApiGroup struct{} |
||||
|
|
||||
|
//入口
|
||||
|
func (a *ApiGroup) Index(c *gin.Context) { |
||||
|
outPut := commonus.MapOut() |
||||
|
response.Result(0, outPut, "手机量化考核入口", c) |
||||
|
} |
||||
|
|
||||
|
//获取指标ID
|
||||
|
type getTargetId[T any] struct { |
||||
|
TargetId []T `json:"targetid"` //指标
|
||||
|
} |
||||
|
|
||||
|
//定性考核查询参数
|
||||
|
type natureParameter struct { |
||||
|
TargetId []string `json:"targetid"` //指标
|
||||
|
Org []string `json:"org"` //行政组织
|
||||
|
Year []string `json:"year"` //年
|
||||
|
TimeAttribute TimeAttributeMap `json:"timeattribute"` //时间辅助
|
||||
|
AccMethod []int `json:"accmethod"` //核算方式 1:合计值;2:平均值
|
||||
|
AnalysisAngle int `json:"analysisangle"` //分析维度 1:行政组织;2:时间
|
||||
|
} |
||||
|
|
||||
|
//时间属性
|
||||
|
type TimeAttributeMap struct { |
||||
|
Class int `json:"class"` //0:全年;1:半年;2:季度;3:月度
|
||||
|
Time []int `json:"time"` //class->0(0),Time->1(1:上半年,2:下半年),class->2(1:第一季度,2:第二季度,3:第三季度,4:第四季度),class->3(1:1月....12:12月)
|
||||
|
} |
||||
|
|
||||
|
//组织架构
|
||||
|
type orgModels struct { |
||||
|
Id string `json:"id"` |
||||
|
Name string `json:"name"` |
||||
|
Level int64 `json:level` |
||||
|
} |
||||
|
type orgModelsAry struct { |
||||
|
orgModels |
||||
|
Child []orgModels `json:"child"` |
||||
|
} |
||||
|
|
||||
|
//查询指标数据流水
|
||||
|
type flowLogDataList struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:fld_id;type:bigint(20) unsigned;not null;comment:Id;index"` |
||||
|
EvaluationPlan int64 `json:"evaluationplan" gorm:"column:fld_evaluation_id;type:bigint(20) unsigned;default:0;not null;comment:考核方案项目ID"` |
||||
|
Key int64 `json:"key" gorm:"column:fld_flow_log;type:bigint(20) unsigned;default:0;not null;comment:识别标志"` |
||||
|
Score int64 `json:"score" gorm:"column:fld_score;type:bigint(20) unsigned;default:0;not null;comment:数据"` |
||||
|
|
||||
|
EvaluationPlanFlow string `json:"evaluationplanflow" gorm:"column:fl_evaluation_id;type:mediumtext unsigned;default:0;not null;comment:考核方案项目ID"` |
||||
|
KeyFlow int64 `json:"keyflow" gorm:"column:fl_key;type:bigint(20) unsigned;default:0;not null;comment:识别标志"` |
||||
|
Year int64 `json:"year" gorm:"column:fl_year;type:int(7) unsigned;default:0;not null;comment:年分"` |
||||
|
Quarter int64 `json:"quarter" gorm:"column:fl_quarter;type:int(2) unsigned;default:0;not null;comment:季度"` |
||||
|
Month int64 `json:"month" gorm:"column:fl_month;type:int(2) unsigned;default:0;not null;comment:月"` |
||||
|
Week int64 `json:"week" gorm:"column:fl_week;type:int(5) unsigned;default:0;not null;comment:周"` |
||||
|
ToDay int64 `json:"today" gorm:"column:fl_day;type:int(5) unsigned;default:0;not null;comment:天"` |
||||
|
DutyGroup int64 `json:"dutygroup" gorm:"column:fl_duty_group;type:bigint(20) unsigned;default:0;not null;comment:职责集团"` |
||||
|
DutyDepartment int64 `json:"dutydepartment" gorm:"column:fl_duty_department;type:bigint(20) unsigned;default:0;not null;comment:职责部门"` |
||||
|
} |
||||
|
|
||||
|
type OutGovCont struct { |
||||
|
hrsystem.AdministrativeOrganization |
||||
|
ClassName string `json:"classname" gorm:"column:classname;type:varchar(255) unsigned;default:'';not null;comment:行政组织分类名称"` |
||||
|
Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` |
||||
|
} |
||||
|
|
||||
|
//时间维度构造
|
||||
|
type TimeFrame struct { |
||||
|
XLine string `json:"xline"` |
||||
|
YearName string `json:"yearname"` |
||||
|
Class int `json:"class"` |
||||
|
Where []int `json:"where"` |
||||
|
} |
||||
|
|
||||
|
//时间维度输出构造
|
||||
|
type GraphicStatistics struct { |
||||
|
XLine []string `json:"xAxis"` //x轴维度
|
||||
|
Cylindrical []string `json:"legend"` //柱形体名称集合
|
||||
|
CylindricalData []series `json:"series"` //柱形体数值集合
|
||||
|
} |
||||
|
|
||||
|
//数值结构体
|
||||
|
type series struct { |
||||
|
Name string `json:"name"` //柱形体名称
|
||||
|
Data []float64 `json:"data"` //对应X轴点位数值
|
||||
|
} |
||||
@ -0,0 +1,405 @@ |
|||||
|
package quantification |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"strconv" |
||||
|
|
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/global" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//量化考核图标
|
||||
|
func (a *ApiGroup) GetQuantEChartOrgAndYear(c *gin.Context) { |
||||
|
isTrue, _ := commonus.ClientIdentity() |
||||
|
if isTrue != true { |
||||
|
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
||||
|
return |
||||
|
} |
||||
|
var requestData getTargetId[string] |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
response.Result(102, err, "数据获取失败!", c) |
||||
|
return |
||||
|
} |
||||
|
if len(requestData.TargetId) < 1 { |
||||
|
response.Result(102, err, "未获取到指标", c) |
||||
|
return |
||||
|
} |
||||
|
var accDepart []string |
||||
|
var yearTime []string |
||||
|
var orgMap []orgModelsAry |
||||
|
for _, v := range requestData.TargetId { |
||||
|
var flowLogList []assessmentmodel.FlowLog |
||||
|
floLogErr := global.GVA_DB_Performanceappraisal.Where("FIND_IN_SET(?,`fl_evaluation_id`)", v).Find(&flowLogList).Error |
||||
|
if floLogErr == nil { |
||||
|
for _, fv := range flowLogList { |
||||
|
fvDepartId := strconv.FormatInt(fv.DutyDepartment, 10) |
||||
|
if commonus.IsItTrueString(fvDepartId, accDepart) == false { |
||||
|
accDepart = append(accDepart, fvDepartId) |
||||
|
} |
||||
|
yearStr := strconv.FormatInt(int64(fv.Year), 10) |
||||
|
if commonus.IsItTrueString(yearStr, yearTime) == false { |
||||
|
yearTime = append(yearTime, yearStr) |
||||
|
} |
||||
|
//判断组织架构是否有数据
|
||||
|
if len(orgMap) > 0 { |
||||
|
for oi, ov := range orgMap { |
||||
|
//判断公司是否已经存在
|
||||
|
if ov.Id == strconv.FormatInt(fv.DutyGroup, 10) { |
||||
|
//判断是否有分厂数据
|
||||
|
if len(ov.Child) > 0 { |
||||
|
isYes := true |
||||
|
for _, dv := range ov.Child { |
||||
|
if dv.Id == strconv.FormatInt(fv.DutyDepartment, 10) { |
||||
|
isYes = false //该部门分厂已经存在
|
||||
|
} |
||||
|
} |
||||
|
if isYes == true { |
||||
|
//该部门分厂不存在是添加
|
||||
|
//写入部门
|
||||
|
whereDepart := commonus.MapOut() |
||||
|
whereDepart["id"] = fv.DutyDepartment |
||||
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name") |
||||
|
if orgDepartErr == nil { |
||||
|
var orgDepartMapCont orgModels |
||||
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10) |
||||
|
orgDepartMapCont.Name = orgDepartCont.Name |
||||
|
orgMap[oi].Child = append(orgMap[oi].Child, orgDepartMapCont) |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
//没有分厂数据,根据上级数据进行新增
|
||||
|
if fv.DutyDepartment != 0 { |
||||
|
//写入部门
|
||||
|
whereDepart := commonus.MapOut() |
||||
|
whereDepart["id"] = fv.DutyDepartment |
||||
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name") |
||||
|
if orgDepartErr == nil { |
||||
|
var orgDepartMapCont orgModels |
||||
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10) |
||||
|
orgDepartMapCont.Name = orgDepartCont.Name |
||||
|
orgMap[oi].Child = append(orgMap[oi].Child, orgDepartMapCont) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
if fv.DutyGroup != 0 { |
||||
|
//写入集团信息
|
||||
|
where := commonus.MapOut() |
||||
|
where["id"] = fv.DutyGroup |
||||
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name") |
||||
|
if orgGroupErr == nil { |
||||
|
var orgMapCont orgModelsAry |
||||
|
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10) |
||||
|
orgMapCont.Name = orgGroupCont.Name |
||||
|
|
||||
|
if fv.DutyDepartment != 0 { |
||||
|
//写入部门
|
||||
|
whereDepart := commonus.MapOut() |
||||
|
whereDepart["id"] = fv.DutyDepartment |
||||
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name") |
||||
|
if orgDepartErr == nil { |
||||
|
var orgDepartMapCont orgModels |
||||
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10) |
||||
|
orgDepartMapCont.Name = orgDepartCont.Name |
||||
|
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont) |
||||
|
} |
||||
|
} |
||||
|
orgMap = append(orgMap, orgMapCont) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
//没有数据的时候根据数值进行新增
|
||||
|
if fv.DutyGroup != 0 { |
||||
|
//写入集团信息
|
||||
|
where := commonus.MapOut() |
||||
|
where["id"] = fv.DutyGroup |
||||
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name") |
||||
|
if orgGroupErr == nil { |
||||
|
var orgMapCont orgModelsAry |
||||
|
orgMapCont.Id = strconv.FormatInt(fv.DutyGroup, 10) |
||||
|
orgMapCont.Name = orgGroupCont.Name |
||||
|
|
||||
|
if fv.DutyDepartment != 0 { |
||||
|
//写入部门
|
||||
|
whereDepart := commonus.MapOut() |
||||
|
whereDepart["id"] = fv.DutyDepartment |
||||
|
orgDepartCont, orgDepartErr := commonus.GetNewOrgCont(whereDepart, "name") |
||||
|
if orgDepartErr == nil { |
||||
|
var orgDepartMapCont orgModels |
||||
|
orgDepartMapCont.Id = strconv.FormatInt(fv.DutyDepartment, 10) |
||||
|
orgDepartMapCont.Name = orgDepartCont.Name |
||||
|
orgMapCont.Child = append(orgMapCont.Child, orgDepartMapCont) |
||||
|
} |
||||
|
} |
||||
|
orgMap = append(orgMap, orgMapCont) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
outMap := commonus.MapOut() |
||||
|
outMap["grouplist"] = orgMap |
||||
|
outMap["timelist"] = yearTime |
||||
|
response.Result(0, outMap, "数据获取失败!", c) |
||||
|
} |
||||
|
|
||||
|
//量化考核图标
|
||||
|
func (a *ApiGroup) QuantEChart(c *gin.Context) { |
||||
|
isTrue, _ := commonus.ClientIdentity() |
||||
|
if isTrue != true { |
||||
|
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
||||
|
return |
||||
|
} |
||||
|
var requestData natureParameter |
||||
|
c.ShouldBindJSON(&requestData) |
||||
|
// err := c.ShouldBindJSON(&requestData)
|
||||
|
// if err != nil {
|
||||
|
// response.Result(102, err, "数据获取失败!", c)
|
||||
|
// return
|
||||
|
// }
|
||||
|
if len(requestData.TargetId) < 1 { |
||||
|
response.Result(103, requestData, "未获取到指标", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.AnalysisAngle == 0 { |
||||
|
requestData.AnalysisAngle = 1 |
||||
|
} |
||||
|
outMap := commonus.MapOut() |
||||
|
var graphicStatistics GraphicStatistics |
||||
|
for _, v := range requestData.TargetId { |
||||
|
// var qualEvalCont assessmentmodel.QualitativeEvaluation
|
||||
|
// qualEvaWhe := commonus.MapOut()
|
||||
|
// qualEvaWhe["qe_id"] = v
|
||||
|
// qualEvalCont.GetCont(qualEvaWhe, "qe_target")
|
||||
|
// calculationEvaluation(qualEvalCont.Target, requestData)
|
||||
|
// calculationEvaluation(v, requestData)
|
||||
|
// kjs, kjddd := calculationEvaluation(v, requestData)
|
||||
|
// jsonStr, jsonEr := json.Marshal(kjs)
|
||||
|
// fmt.Printf("task------------>%v----->%v----->%v\n", string(jsonStr), jsonEr, kjddd)
|
||||
|
|
||||
|
// outMap["TimeDimension_"+v] = TimeDimension(v, requestData)
|
||||
|
if requestData.AnalysisAngle == 1 { |
||||
|
getStatistics, gstErr := OrgDimensionStatistics(v, requestData) |
||||
|
outMap["TimeDimension_"+v] = getStatistics |
||||
|
if gstErr == true { |
||||
|
} |
||||
|
} else { |
||||
|
//时间维度
|
||||
|
getStatistics, gstErr := TimeDimensionStatistics(v, requestData) |
||||
|
outMap["TimeDimension_"+v] = getStatistics |
||||
|
if gstErr == true { |
||||
|
for _, gsv := range getStatistics.XLine { |
||||
|
if commonus.IsItTrueString(gsv, graphicStatistics.XLine) == false { |
||||
|
graphicStatistics.XLine = append(graphicStatistics.XLine, gsv) |
||||
|
} |
||||
|
} |
||||
|
for _, cilv := range getStatistics.Cylindrical { |
||||
|
if commonus.IsItTrueString(cilv, graphicStatistics.Cylindrical) == false { |
||||
|
graphicStatistics.Cylindrical = append(graphicStatistics.Cylindrical, cilv) |
||||
|
for _, cdv := range getStatistics.CylindricalData { |
||||
|
if cdv.Name == cilv { |
||||
|
graphicStatistics.CylindricalData = append(graphicStatistics.CylindricalData, cdv) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
// getStatistics, gstErr := TimeDimensionStatistics(v, requestData)
|
||||
|
// fmt.Println(gstErr)
|
||||
|
|
||||
|
} |
||||
|
outMap["graphicStatistics"] = graphicStatistics |
||||
|
response.Result(0, graphicStatistics, "图形数据", c) |
||||
|
} |
||||
|
|
||||
|
//获取行政组织
|
||||
|
func getGroupOrg(orgAry []string) (orgMap []orgModelsAry, orgWherList []orgModels) { |
||||
|
|
||||
|
var govMap []OutGovCont |
||||
|
orgErr := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1 AND administrative_organization.id IN ?", orgAry).Find(&govMap).Error |
||||
|
if orgErr != nil { |
||||
|
return |
||||
|
} |
||||
|
// fmt.Printf("%v\n", govMap)
|
||||
|
|
||||
|
for _, v := range govMap { |
||||
|
|
||||
|
if len(orgMap) > 0 { |
||||
|
if v.Level > 2 { |
||||
|
groupId, groupIsTrue := commonus.GetNewHrOrg(v.Id) |
||||
|
if groupIsTrue == true { |
||||
|
newAdd := true |
||||
|
for gii, gvv := range orgMap { |
||||
|
if gvv.Id == strconv.FormatInt(groupId, 10) { |
||||
|
newAdd = false |
||||
|
for _, sgv := range orgMap[gii].Child { |
||||
|
if sgv.Id != strconv.FormatInt(v.Id, 10) { |
||||
|
var orgSun orgModels |
||||
|
orgSun.Id = strconv.FormatInt(v.Id, 10) |
||||
|
orgSun.Name = v.Name |
||||
|
orgSun.Level = v.Level |
||||
|
if v.Abbreviation != "" { |
||||
|
orgSun.Name = v.Abbreviation |
||||
|
} |
||||
|
orgMap[gii].Child = append(orgMap[gii].Child, orgSun) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if newAdd == true { |
||||
|
where := commonus.MapOut() |
||||
|
where["id"] = groupId |
||||
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name", "organization_type") |
||||
|
|
||||
|
if orgGroupErr == nil { |
||||
|
var groupInfo orgModelsAry |
||||
|
groupInfo.Id = strconv.FormatInt(groupId, 10) |
||||
|
groupInfo.Name = orgGroupCont.Name |
||||
|
if orgGroupCont.Abbreviation != "" { |
||||
|
groupInfo.Name = orgGroupCont.Abbreviation |
||||
|
} |
||||
|
var aotModel hrsystem.AdministrativeOrganizationType |
||||
|
where := commonus.MapOut() |
||||
|
where["id"] = orgGroupCont.OrganizationType |
||||
|
aotModel.GetCont(where, "level") |
||||
|
groupInfo.Level = aotModel.Level |
||||
|
var orgSun orgModels |
||||
|
orgSun.Id = strconv.FormatInt(v.Id, 10) |
||||
|
orgSun.Name = v.Name |
||||
|
if v.Abbreviation != "" { |
||||
|
orgSun.Name = v.Abbreviation |
||||
|
} |
||||
|
orgSun.Level = v.Level |
||||
|
groupInfo.Child = append(groupInfo.Child, orgSun) |
||||
|
orgMap = append(orgMap, groupInfo) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
for _, gv := range orgMap { |
||||
|
if gv.Id != strconv.FormatInt(v.Id, 10) { |
||||
|
var groupInfo orgModelsAry |
||||
|
groupInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
groupInfo.Name = v.Name |
||||
|
if v.Abbreviation != "" { |
||||
|
groupInfo.Name = v.Abbreviation |
||||
|
} |
||||
|
groupInfo.Level = v.Level |
||||
|
orgMap = append(orgMap, groupInfo) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
if v.Level > 2 { |
||||
|
groupId, groupIsTrue := commonus.GetNewHrOrg(v.Id) |
||||
|
if groupIsTrue == true { |
||||
|
where := commonus.MapOut() |
||||
|
where["id"] = groupId |
||||
|
orgGroupCont, orgGroupErr := commonus.GetNewOrgCont(where, "name", "abbreviation", "organization_type") |
||||
|
if orgGroupErr == nil { |
||||
|
var groupInfo orgModelsAry |
||||
|
groupInfo.Id = strconv.FormatInt(groupId, 10) |
||||
|
groupInfo.Name = orgGroupCont.Name |
||||
|
if orgGroupCont.Abbreviation != "" { |
||||
|
groupInfo.Name = orgGroupCont.Abbreviation |
||||
|
} |
||||
|
var aotModel hrsystem.AdministrativeOrganizationType |
||||
|
where := commonus.MapOut() |
||||
|
where["id"] = orgGroupCont.OrganizationType |
||||
|
aotModel.GetCont(where, "level") |
||||
|
groupInfo.Level = aotModel.Level |
||||
|
|
||||
|
var orgSun orgModels |
||||
|
orgSun.Id = strconv.FormatInt(v.Id, 10) |
||||
|
orgSun.Name = v.Name |
||||
|
if v.Abbreviation != "" { |
||||
|
orgSun.Name = v.Abbreviation |
||||
|
} |
||||
|
orgSun.Level = v.Level |
||||
|
groupInfo.Child = append(groupInfo.Child, orgSun) |
||||
|
orgMap = append(orgMap, groupInfo) |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
var groupInfo orgModelsAry |
||||
|
groupInfo.Id = strconv.FormatInt(v.Id, 10) |
||||
|
groupInfo.Name = v.Name |
||||
|
if v.Abbreviation != "" { |
||||
|
groupInfo.Name = v.Abbreviation |
||||
|
} |
||||
|
groupInfo.Level = v.Level |
||||
|
orgMap = append(orgMap, groupInfo) |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if len(orgMap) > 0 { |
||||
|
for _, ov := range orgMap { |
||||
|
|
||||
|
if len(orgWherList) > 0 { |
||||
|
isInGroup := true //界定是否写入
|
||||
|
for _, olv := range orgWherList { |
||||
|
if ov.Id == olv.Id { |
||||
|
isInGroup = false |
||||
|
} |
||||
|
} |
||||
|
if isInGroup == true { |
||||
|
var orgList orgModels |
||||
|
orgList.Id = ov.Id |
||||
|
orgList.Name = ov.Name |
||||
|
orgList.Level = ov.Level |
||||
|
orgWherList = append(orgWherList, orgList) |
||||
|
} |
||||
|
} else { |
||||
|
var orgList orgModels |
||||
|
orgList.Id = ov.Id |
||||
|
orgList.Name = ov.Name |
||||
|
orgList.Level = ov.Level |
||||
|
orgWherList = append(orgWherList, orgList) |
||||
|
} |
||||
|
//判断是否有下级菜单
|
||||
|
if len(ov.Child) > 0 { |
||||
|
for _, ocv := range ov.Child { |
||||
|
if len(orgWherList) > 0 { |
||||
|
isIn := true //界定是否写入
|
||||
|
for _, olv := range orgWherList { |
||||
|
if ocv.Id == olv.Id { |
||||
|
isIn = false |
||||
|
} |
||||
|
} |
||||
|
if isIn == true { |
||||
|
var orgList orgModels |
||||
|
orgList.Id = ocv.Id |
||||
|
orgList.Name = fmt.Sprintf("%v%v", ov.Name, ocv.Name) |
||||
|
orgList.Level = ocv.Level |
||||
|
orgWherList = append(orgWherList, orgList) |
||||
|
} |
||||
|
} else { |
||||
|
var orgList orgModels |
||||
|
orgList.Id = ocv.Id |
||||
|
orgList.Name = fmt.Sprintf("%v%v", ov.Name, ocv.Name) |
||||
|
orgList.Level = ocv.Level |
||||
|
orgWherList = append(orgWherList, orgList) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,84 @@ |
|||||
|
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 |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
package statisticsroute |
||||
|
|
||||
|
type StatisticsRoute struct{} |
||||
@ -0,0 +1,20 @@ |
|||||
|
package statisticsroute |
||||
|
|
||||
|
import ( |
||||
|
v2 "github.com/flipped-aurora/gin-vue-admin/server/api/index" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//统计
|
||||
|
func (s *StatisticsRoute) InitRouter(Router *gin.RouterGroup) { |
||||
|
shiyanCodeRouter := Router.Group("ststic") |
||||
|
var authorityApi = v2.ApiGroupApp.StatisticsApi |
||||
|
{ |
||||
|
shiyanCodeRouter.POST("", authorityApi.Index) // 入口
|
||||
|
shiyanCodeRouter.POST("/", authorityApi.Index) |
||||
|
shiyanCodeRouter.GET("", authorityApi.Index) |
||||
|
shiyanCodeRouter.GET("/", authorityApi.Index) |
||||
|
|
||||
|
shiyanCodeRouter.POST("getconfig", authorityApi.PlanVersioStatistics) //方案数据表格同居
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue