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.
611 lines
19 KiB
611 lines
19 KiB
package customChartesing
|
|
|
|
import (
|
|
"appPlatform/api/version1/customerform"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/models/modelssystempermission"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"fmt"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-07-21 09:50:02
|
|
@ 功能: 饼图
|
|
*/
|
|
func (c *ChartInfo) pieChart(val interface{}, untis []customerform.MasterStruct, chartType string) (snedMap interface{}) {
|
|
for _, v := range c.XAxis {
|
|
// fmt.Printf("\n\nc.X ===1==> %v =====> %v\n\n", v.Type, v)
|
|
switch v.Type {
|
|
case 3:
|
|
snedMap = c.PieTimeDataAnaly(v, c.YAxis, val, chartType)
|
|
default:
|
|
snedMap = c.PieDataAnaly(v, c.YAxis, val, chartType, untis)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (c *ChartInfo) PieTimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, chartType string) (charData SendPicInfo) {
|
|
tayTime := time.Now().Unix()
|
|
searchTime := c.JieXiSearchTime()
|
|
switch x.TimeType {
|
|
case "year":
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 16)
|
|
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", yearVal))
|
|
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", yearVal))
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime = endTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pickName := fmt.Sprintf("%v年", yearVal)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
case "month":
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 16)
|
|
yearValInt, _ := strconv.Atoi(yearVal)
|
|
var timeList []string
|
|
tayTime := int(time.Now().Month())
|
|
for i := 1; i <= tayTime; i++ {
|
|
createTime := fmt.Sprintf("%v-%v-01 00:00:00", yearVal, i)
|
|
if i < 10 {
|
|
createTime = fmt.Sprintf("%v-0%v-01 00:00:00", yearVal, i)
|
|
}
|
|
startTime := publicmethod.DateToTimeStampOld(createTime)
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, i)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime.AllTime = endTime.AllTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime.AllTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pickName := fmt.Sprintf("%v年%v月", yearVal, i)
|
|
timeList = append(timeList, pickName)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
}
|
|
case "day":
|
|
// fmt.Printf("饼图处理====>%v\n\n", searchTime)
|
|
if len(searchTime) <= 0 {
|
|
yearVal := int(time.Now().Year())
|
|
tayTime := int(time.Now().Month())
|
|
dayTime := int(time.Now().Day())
|
|
var timeList []string
|
|
for i := 1; i <= tayTime; i++ {
|
|
for j := 1; j <= dayTime; j++ {
|
|
pickName := fmt.Sprintf("%v年%v月%v日", yearVal, i, j)
|
|
createTime := fmt.Sprintf("%v-%v-%v 00:00:00", yearVal, i, j)
|
|
if i < 10 {
|
|
if j < 10 {
|
|
createTime = fmt.Sprintf("%v-0%v-0%v 00:00:00", yearVal, i, j)
|
|
} else {
|
|
createTime = fmt.Sprintf("%v-0%v-%v 00:00:00", yearVal, i, j)
|
|
}
|
|
} else {
|
|
if j < 10 {
|
|
createTime = fmt.Sprintf("%v-%v-0%v 00:00:00", yearVal, i, j)
|
|
} else {
|
|
createTime = fmt.Sprintf("%v-%v-%v 00:00:00", yearVal, i, j)
|
|
}
|
|
}
|
|
tayTime := publicmethod.DateToTimeStampOld(createTime)
|
|
startTime, endTime := publicmethod.TimeUnixDayStartAndEnd(tayTime)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime = endTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
timeList = append(timeList, pickName)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
}
|
|
}
|
|
} else {
|
|
// var timeList []string
|
|
for _, v := range searchTime {
|
|
createTime := fmt.Sprintf("%v 00:00:00", v)
|
|
// fmt.Printf("时间智慧--->%v\n\n", createTime)
|
|
tayTime := publicmethod.DateToTimeStampOld(createTime)
|
|
startTime, endTime := publicmethod.TimeUnixDayStartAndEnd(tayTime)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
// if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
// startTime = startTime * 1000
|
|
// endTime = endTime * 1000
|
|
// }
|
|
|
|
var begTime int64
|
|
var eldTime int64
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
begTime = startTime * 1000
|
|
eldTime = endTime * 1000
|
|
} else {
|
|
begTime = startTime
|
|
eldTime = endTime
|
|
}
|
|
|
|
// fmt.Printf("时间炼狱:%v-----------%v-----%v\n\n", publicmethod.UnixTimeToDay(begTime/1000, 1), publicmethod.UnixTimeToDay(pageTime/1000, 1), publicmethod.UnixTimeToDay(eldTime/1000, 1))
|
|
if begTime <= pageTime && pageTime <= eldTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// dfhjk, _ := json.Marshal(newVal)
|
|
// fmt.Printf("时间炼狱:%v-----1------%v\n\n", v, string(dfhjk))
|
|
charData.picMasterDataAnaly(x.Field, x.Field, v, newVal)
|
|
charData.AggregateCalculatingPic(v, newVal, y)
|
|
|
|
}
|
|
}
|
|
|
|
case "hour":
|
|
tayTime := time.Now().Unix()
|
|
ymdhVal := publicmethod.UnixTimeToDay(tayTime, 14)
|
|
var timeList []string
|
|
for i := 0; i <= 23; i++ {
|
|
createTime := fmt.Sprintf("%v %v:00:00", ymdhVal, i)
|
|
if i < 10 {
|
|
createTime = fmt.Sprintf("%v 0%v:00:00", ymdhVal, i)
|
|
}
|
|
tayTime := publicmethod.DateToTimeStampOld(createTime)
|
|
startTime, endTime := publicmethod.TimeUnixDayStartAndEnd(tayTime)
|
|
pickName := fmt.Sprintf("%v %v", ymdhVal, i)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime = endTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
timeList = append(timeList, pickName)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
}
|
|
case "minute":
|
|
tayTime := time.Now().Unix()
|
|
ymdhVal := publicmethod.UnixTimeToDay(tayTime, 13)
|
|
var timeList []string
|
|
for i := 0; i <= 60; i++ {
|
|
createTime := fmt.Sprintf("%v %v:00", ymdhVal, i)
|
|
if i < 10 {
|
|
createTime = fmt.Sprintf("%v 0%v:00", ymdhVal, i)
|
|
}
|
|
tayTime := publicmethod.DateToTimeStampOld(createTime)
|
|
startTime, endTime := publicmethod.TimeUnixDayStartAndEnd(tayTime)
|
|
pickName := fmt.Sprintf("%v :%v", ymdhVal, i)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime = endTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
timeList = append(timeList, pickName)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
}
|
|
case "second":
|
|
tayTime := time.Now().Unix()
|
|
ymdhVal := publicmethod.UnixTimeToDay(tayTime, 12)
|
|
var timeList []string
|
|
for i := 0; i <= 60; i++ {
|
|
createTime := fmt.Sprintf("%v %v", ymdhVal, i)
|
|
if i < 10 {
|
|
createTime = fmt.Sprintf("%v 0%v", ymdhVal, i)
|
|
}
|
|
tayTime := publicmethod.DateToTimeStampOld(createTime)
|
|
startTime, endTime := publicmethod.TimeUnixDayStartAndEnd(tayTime)
|
|
pickName := fmt.Sprintf("%v :%v", ymdhVal, i)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime = endTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
timeList = append(timeList, pickName)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
}
|
|
case "ymdhms":
|
|
tayTime := time.Now().Unix()
|
|
ymdhVal := publicmethod.UnixTimeToDay(tayTime, 12)
|
|
var timeList []string
|
|
for i := 0; i <= 60; i++ {
|
|
createTime := fmt.Sprintf("%v %v", ymdhVal, i)
|
|
if i < 10 {
|
|
createTime = fmt.Sprintf("%v 0%v", ymdhVal, i)
|
|
}
|
|
tayTime := publicmethod.DateToTimeStampOld(createTime)
|
|
startTime, endTime := publicmethod.TimeUnixDayStartAndEnd(tayTime)
|
|
pickName := fmt.Sprintf("%v :%v", ymdhVal, i)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime = endTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
timeList = append(timeList, pickName)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
}
|
|
default:
|
|
yearVal := publicmethod.UnixTimeToDay(tayTime, 16)
|
|
yearValInt, _ := strconv.Atoi(yearVal)
|
|
var timeList []string
|
|
tayTime := int(time.Now().Month())
|
|
for i := 1; i <= tayTime; i++ {
|
|
createTime := fmt.Sprintf("%v-%v-01 00:00:00", yearVal, i)
|
|
if i < 10 {
|
|
createTime = fmt.Sprintf("%v-0%v-01 00:00:00", yearVal, i)
|
|
}
|
|
startTime := publicmethod.DateToTimeStampOld(createTime)
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, i)
|
|
var newVal []map[string]interface{}
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
pageTime, _ := publicmethod.StringToInt64(xVal)
|
|
if publicmethod.GetIntLength(pageTime) >= 13 {
|
|
startTime = startTime * 1000
|
|
endTime.AllTime = endTime.AllTime * 1000
|
|
}
|
|
if startTime <= pageTime && pageTime <= endTime.AllTime {
|
|
newVal = append(newVal, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pickName := fmt.Sprintf("%v年%v月", yearVal, i)
|
|
timeList = append(timeList, pickName)
|
|
charData.picMasterDataAnaly(x.Field, x.Field, pickName, newVal)
|
|
charData.AggregateCalculatingPic(pickName, newVal, y)
|
|
}
|
|
}
|
|
for i, v := range charData.MasterData {
|
|
for _, ov := range charData.OtherData {
|
|
if v.Name == ov.FathreName {
|
|
charData.MasterData[i].Value = ov.Toolval
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (c *ChartInfo) PieDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, chartType string, untis []customerform.MasterStruct) (charData SendPicInfo) {
|
|
|
|
var timeList []string //根据维度分组
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[x.Field]; isOk {
|
|
// fmt.Printf("人员--->%v\n\n", xVal)
|
|
pageTime := publicmethod.TypeToInterface(xVal)
|
|
if !publicmethod.IsInTrue[string](pageTime, timeList) {
|
|
timeList = append(timeList, pageTime)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// fmt.Printf("人员--2->%v\n\n", timeList)
|
|
for _, v := range timeList {
|
|
pickName := DimensionToChinaName(x.Field, v, untis)
|
|
charData.picMasterDataAnaly(x.Field, v, pickName, val)
|
|
charData.AggregateCalculatingPic(pickName, val, y)
|
|
// fmt.Printf("人员--pickName->%v\n\n", pickName)
|
|
}
|
|
return
|
|
}
|
|
|
|
// 处理主数据
|
|
func (s *SendPicInfo) picMasterDataAnaly(xField, keyName string, fathreName, val interface{}) {
|
|
// fmt.Printf("处理主数据----->%v-----------%v\n\n\n", keyName, fathreName)
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
jsq := 0
|
|
var masterInfo PicChartInfo
|
|
masterInfo.Name = publicmethod.TypeToInterface(fathreName)
|
|
for _, mv := range yVal {
|
|
if xVal, isOk := mv[xField]; isOk {
|
|
// fmt.Printf("处理主数据--2323--->%v-----------%v\n\n\n", xVal, fathreName)
|
|
xValStr := publicmethod.TypeToInterface(xVal)
|
|
if xValStr == keyName {
|
|
jsq++
|
|
}
|
|
}
|
|
}
|
|
masterInfo.Value = jsq
|
|
s.MasterData = append(s.MasterData, masterInfo)
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-07-18 08:45:24
|
|
@ 功能:饼形 聚合计算
|
|
|
|
#fathreName
|
|
# y Y轴设定
|
|
# val 查询到的值
|
|
#chartType 图标类型
|
|
1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值
|
|
当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数;
|
|
*/
|
|
func (s *SendPicInfo) AggregateCalculatingPic(fathreName, val interface{}, y []YAxisInfo) {
|
|
for _, v := range y {
|
|
var pickInfo OtherDataInfo
|
|
pickInfo.FathreName = publicmethod.TypeToInterface(fathreName)
|
|
pickInfo.ToolName = v.OldTitle
|
|
switch v.Method {
|
|
case 2:
|
|
pickInfo.AverageValuees(v.Field, val, v.Format)
|
|
case 3:
|
|
pickInfo.StatisticalQuantityes(v.Field, val, v.Format)
|
|
case 4:
|
|
pickInfo.RemoveDuplicateCountss(v.Field, val, v.Format)
|
|
case 5:
|
|
pickInfo.maxDataes(v.Field, val, v.Format)
|
|
case 6:
|
|
pickInfo.minDataes(v.Field, val, v.Format)
|
|
default:
|
|
pickInfo.sumDataes(v.Field, val, v.Format)
|
|
}
|
|
s.OtherData = append(s.OtherData, pickInfo)
|
|
}
|
|
}
|
|
|
|
// 平均值
|
|
func (o *OtherDataInfo) AverageValuees(yField string, val interface{}, format int) {
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
var sumVal float64
|
|
jibuqi := 1
|
|
for _, mv := range yVal {
|
|
if vVal, isOk := mv[yField]; isOk {
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(vVal), 64)
|
|
if err == nil {
|
|
sumVal = sumVal + minVal
|
|
jibuqi++
|
|
}
|
|
}
|
|
}
|
|
if jibuqi > 0 {
|
|
sumValAvg := sumVal / float64(jibuqi)
|
|
jieguo := publicmethod.DataChuli(sumValAvg, format)
|
|
o.Toolval = jieguo
|
|
} else {
|
|
o.Toolval = 0
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
// 去重计数
|
|
func (o *OtherDataInfo) StatisticalQuantityes(yField string, val interface{}, format int) {
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
var sumVal []float64
|
|
for _, mv := range yVal {
|
|
if vVal, isOk := mv[yField]; isOk {
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(vVal), 64)
|
|
if err == nil {
|
|
sumVal = append(sumVal, minVal)
|
|
}
|
|
}
|
|
}
|
|
// jieguo := publicmethod.DataChuli(sumVal, format)
|
|
o.Toolval = len(sumVal)
|
|
}
|
|
}
|
|
|
|
// 去重计数
|
|
func (o *OtherDataInfo) RemoveDuplicateCountss(yField string, val interface{}, format int) {
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
var sumVal []float64
|
|
for _, mv := range yVal {
|
|
if vVal, isOk := mv[yField]; isOk {
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(vVal), 64)
|
|
if err == nil {
|
|
if !publicmethod.IsInTrue[float64](minVal, sumVal) {
|
|
sumVal = append(sumVal, minVal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// jieguo := publicmethod.DataChuli(sumVal, format)
|
|
o.Toolval = len(sumVal)
|
|
}
|
|
}
|
|
|
|
// 求最大值
|
|
func (o *OtherDataInfo) maxDataes(yField string, val interface{}, format int) {
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
var sumVal float64 = 1
|
|
for _, mv := range yVal {
|
|
if vVal, isOk := mv[yField]; isOk {
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(vVal), 64)
|
|
if err == nil {
|
|
if sumVal <= minVal {
|
|
sumVal = minVal
|
|
}
|
|
}
|
|
}
|
|
}
|
|
jieguo := publicmethod.DataChuli(sumVal, format)
|
|
o.Toolval = jieguo
|
|
}
|
|
}
|
|
|
|
// 求最小值
|
|
func (o *OtherDataInfo) minDataes(yField string, val interface{}, format int) {
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
var sumVal float64 = 1
|
|
for _, mv := range yVal {
|
|
if vVal, isOk := mv[yField]; isOk {
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(vVal), 64)
|
|
if err == nil {
|
|
if sumVal >= minVal {
|
|
sumVal = minVal
|
|
}
|
|
}
|
|
}
|
|
}
|
|
jieguo := publicmethod.DataChuli(sumVal, format)
|
|
o.Toolval = jieguo
|
|
}
|
|
}
|
|
|
|
// 求和
|
|
func (o *OtherDataInfo) sumDataes(yField string, val interface{}, format int) {
|
|
if yVal, isOk := val.([]map[string]interface{}); isOk {
|
|
var sumVal float64
|
|
for _, mv := range yVal {
|
|
if vVal, isOk := mv[yField]; isOk {
|
|
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(vVal), 64)
|
|
// fmt.Printf("字段---》%v----%v\n\n", yField, minVal)
|
|
if err == nil {
|
|
sumVal = sumVal + minVal
|
|
}
|
|
}
|
|
}
|
|
jieguo := publicmethod.DataChuli(sumVal, format)
|
|
o.Toolval = jieguo
|
|
}
|
|
}
|
|
|
|
// 判断维度是否要换成中文
|
|
func DimensionToChinaName(xField string, timeList string, untis []customerform.MasterStruct) (names interface{}) {
|
|
for _, v := range untis {
|
|
if v.Name == xField {
|
|
// fmt.Printf("姓名转换---->%v\n\n", v.Type)
|
|
switch v.Type {
|
|
case "pickrole":
|
|
var nameVal string
|
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`name`").Where("`id` = ?", timeList).First(&nameVal)
|
|
names = nameVal
|
|
case "pickpost":
|
|
var nameVal string
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`name`").Where("`id` = ?", timeList).First(&nameVal)
|
|
names = nameVal
|
|
case "deptOrg":
|
|
var nameVal string
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`name`").Where("`id` = ?", timeList).First(&nameVal)
|
|
names = nameVal
|
|
case "orgCentent":
|
|
var nameVal string
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`name`").Where("`id` = ?", timeList).First(&nameVal)
|
|
names = nameVal
|
|
case "owner":
|
|
var nameVal string
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`name`").Where("`key` = ?", timeList).First(&nameVal)
|
|
names = nameVal
|
|
case "founder":
|
|
var nameVal string
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`name`").Where("`key` = ?", timeList).First(&nameVal)
|
|
names = nameVal
|
|
case "expand-user":
|
|
var nameVal string
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`name`").Where("`key` = ?", timeList).First(&nameVal)
|
|
names = nameVal
|
|
case "checkbox":
|
|
if len(v.Options) > 0 {
|
|
|
|
for _, ov := range v.Options {
|
|
if timeList == ov.Value {
|
|
names = ov.Label
|
|
}
|
|
}
|
|
|
|
} else {
|
|
names = timeList
|
|
}
|
|
case "radio":
|
|
if len(v.Options) > 0 {
|
|
for _, ov := range v.Options {
|
|
if timeList == ov.Value {
|
|
names = ov.Label
|
|
}
|
|
}
|
|
} else {
|
|
names = timeList
|
|
}
|
|
default:
|
|
names = timeList
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|