应用集成平台服务端
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.
 
 
 

579 lines
22 KiB

package customChartesing
import (
"appPlatform/overall/publicmethod"
"fmt"
"strconv"
)
/*
*
@ 作者: 秦东
@ 时间: 2025-09-22 15:56:52
@ 功能: 以时间线为主的子表数据处理
1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值
当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数;
# masterFiled 主表维度字段
# masterVal 主表相关数据
# val 子表所有数据
# x ,y 子表维度于度量
# chartType 图表类型
# types 时间类型
*/
func (b *BarDataInfo) SunDayVal(masterFiled string, masterVal interface{}, x, y []SunTableSetup, chartType, types string, timeAry []string) {
var dataMastKey []string
if valMapAry, isOk := masterVal.([]map[string]interface{}); isOk {
for _, v := range valMapAry {
if mastKey, isok := v["masters_key"]; isok {
key := publicmethod.TypeToInterface(mastKey)
if !publicmethod.IsInTrue[string](key, dataMastKey) {
dataMastKey = append(dataMastKey, key)
}
}
}
}
if len(dataMastKey) > 0 {
var SunTabelName []string //子表名称
var weiduDataMap []EveryOneSunTableData //子表数据
for _, v := range x {
if !publicmethod.IsInTrue[string](v.TableKey, SunTabelName) {
SunTabelName = append(SunTabelName, v.TableKey)
weiduDataMap = append(weiduDataMap, SunTableDataList(v, dataMastKey))
}
}
if len(weiduDataMap) > 0 { //存在子表数据
for _, v := range weiduDataMap {
for _, lv := range v.List { //每个子表数据
for _, yv := range y { //子表度量字段
var seriesInfo SeriesList //输出单元
titleStr := fmt.Sprintf("%v:%v-%v", lv.Title, lv.Label, yv.Title)
seriesInfo.Name = titleStr
seriesInfo.Types = chartType
if !publicmethod.IsInTrue[string](titleStr, b.Legend.Data) {
b.Legend.Data = append(b.Legend.Data, titleStr)
}
switch yv.Method { //结算类型
case 2:
seriesInfo.SunSumDataNewAverage(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
case 3:
seriesInfo.SunSumDataNewjs(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
case 4:
seriesInfo.SunSumDataNewQcjs(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
case 5:
seriesInfo.SunSumDataNewMax(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
case 6:
seriesInfo.SunSumDataNewMin(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
default:
// seriesInfo.SunSumData(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
seriesInfo.SunSumDataNew(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry)
}
b.Series = append(b.Series, seriesInfo)
}
}
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 09:13:23
@ 功能: 求最小值
*/
func (s *SeriesList) SunSumDataNewMin(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) {
var monthAry []interface{}
for _, v := range timeAry {
switch types {
case "year":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format))
case "month":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v))
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16))
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17))
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime.AllTime, sunListDate, xField, yField, format))
case "day":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format))
case "hour":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format))
case "minute":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format))
default:
}
}
s.Data = monthAry
}
/*
*AA
@ 作者: 秦东
@ 时间: 2025-09-23 09:14:05
@ 功能: 计算最大着
*/
func (s *SeriesList) QuSumDataNewMin(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) {
if yVal, isOk := val.([]interface{}); isOk {
var sumVal float64
for i, mv := range yVal {
if mapVal, isOk := mv.(map[string]interface{}); isOk {
if yzVal, isOk := mapVal[yField]; isOk {
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64)
if err == nil {
if i == 0 {
sumVal = minVal
} else {
if sumVal >= minVal {
sumVal = minVal
}
}
}
}
}
}
jieguo = publicmethod.DataChuli(sumVal, format)
} else {
jieguo = 0
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 08:57:58
@ 功能: 求最大值
*/
func (s *SeriesList) SunSumDataNewMax(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) {
var monthAry []interface{}
for _, v := range timeAry {
switch types {
case "year":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format))
case "month":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v))
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16))
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17))
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime.AllTime, sunListDate, xField, yField, format))
case "day":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format))
case "hour":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format))
case "minute":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format))
default:
}
}
s.Data = monthAry
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 09:14:05
@ 功能: 计算最大着
*/
func (s *SeriesList) QuSumDataNewMax(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) {
if yVal, isOk := val.([]interface{}); isOk {
var sumVal float64
for i, mv := range yVal {
if mapVal, isOk := mv.(map[string]interface{}); isOk {
if yzVal, isOk := mapVal[yField]; isOk {
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64)
if err == nil {
if i == 0 {
sumVal = minVal
} else {
if sumVal <= minVal {
sumVal = minVal
}
}
}
}
}
}
jieguo = publicmethod.DataChuli(sumVal, format)
} else {
jieguo = 0
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 09:03:55
@ 功能: 去重计数
*/
func (s *SeriesList) SunSumDataNewQcjs(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) {
var monthAry []interface{}
for _, v := range timeAry {
switch types {
case "year":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format))
case "month":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v))
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16))
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17))
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime.AllTime, sunListDate, xField, yField, format))
case "day":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format))
case "hour":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format))
case "minute":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format))
default:
}
}
s.Data = monthAry
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 08:04:59
@ 功能:计数
*/
func (s *SeriesList) QuSumDataNewQcjs(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) {
if yVal, isOk := val.([]interface{}); isOk {
var valAry []float64
for _, mv := range yVal {
if mapVal, isOk := mv.(map[string]interface{}); isOk {
if yzVal, isOk := mapVal[yField]; isOk {
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64)
if err == nil {
if !publicmethod.IsInTrue[float64](minVal, valAry) {
valAry = append(valAry, minVal)
}
}
}
}
}
jieguo = len(valAry)
// jieguo = publicmethod.DataChuli(sumVal, format)
} else {
jieguo = 0
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 09:03:55
@ 功能: 计数
*/
func (s *SeriesList) SunSumDataNewjs(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) {
var monthAry []interface{}
for _, v := range timeAry {
switch types {
case "year":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format))
case "month":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v))
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16))
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17))
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime.AllTime, sunListDate, xField, yField, format))
case "day":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format))
case "hour":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format))
case "minute":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format))
default:
}
}
s.Data = monthAry
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 08:04:59
@ 功能:计数
*/
func (s *SeriesList) QuSumDataNewjs(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) {
if yVal, isOk := val.([]interface{}); isOk {
var valAry []float64
for _, mv := range yVal {
if mapVal, isOk := mv.(map[string]interface{}); isOk {
if yzVal, isOk := mapVal[yField]; isOk {
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64)
if err == nil {
valAry = append(valAry, minVal)
}
}
}
}
jieguo = len(valAry)
// jieguo = publicmethod.DataChuli(sumVal, format)
} else {
jieguo = 0
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 08:58:06
@ 功能: 求平均值
*/
func (s *SeriesList) SunSumDataNewAverage(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) {
var monthAry []interface{}
for _, v := range timeAry {
switch types {
case "year":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format))
case "month":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v))
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16))
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17))
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime.AllTime, sunListDate, xField, yField, format))
case "day":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format))
case "hour":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format))
case "minute":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format))
default:
}
}
s.Data = monthAry
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 08:04:59
@ 功能:平均值
*/
func (s *SeriesList) QuSumDataNewpj(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) {
if yVal, isOk := val.([]interface{}); isOk {
var sumVal float64
jibuqi := len(yVal)
for _, mv := range yVal {
if mapVal, isOk := mv.(map[string]interface{}); isOk {
if yzVal, isOk := mapVal[yField]; isOk {
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64)
if err == nil {
sumVal = sumVal + minVal
}
}
}
}
if jibuqi > 0 {
avgVal := sumVal / float64(jibuqi)
jieguo = publicmethod.DataChuli(avgVal, format)
} else {
jieguo = 0
}
// jieguo = publicmethod.DataChuli(sumVal, format)
} else {
jieguo = 0
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 08:57:58
@ 功能: 求和
*/
func (s *SeriesList) SunSumDataNew(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) {
var monthAry []interface{}
for _, v := range timeAry {
switch types {
case "year":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format))
case "month":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v))
yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16))
monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17))
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime.AllTime, sunListDate, xField, yField, format))
case "day":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format))
case "hour":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format))
case "minute":
startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v))
endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v))
sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal)
monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format))
default:
}
}
s.Data = monthAry
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-23 08:04:59
@ 功能:
*/
func (s *SeriesList) QuSumDataNew(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) {
if yVal, isOk := val.([]interface{}); isOk {
var sumVal float64
for _, mv := range yVal {
if mapVal, isOk := mv.(map[string]interface{}); isOk {
if yzVal, isOk := mapVal[yField]; isOk {
minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64)
if err == nil {
sumVal = sumVal + minVal
}
}
}
}
jieguo = publicmethod.DataChuli(sumVal, format)
} else {
jieguo = 0
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-09-22 16:55:06
@ 功能: 获取当前时间段内的主数据,然后推导出当此时间段中的子数据
*/
func MasterToSunData(startTime, endTime int64, masterFiled string, masterVal, sunVal interface{}) interface{} {
var dataMastKey []string
if mVal, isOk := masterVal.([]map[string]interface{}); isOk {
for _, mv := range mVal {
if xVal, isOk := mv[masterFiled]; isOk {
pageTime, _ := publicmethod.StringToInt64(xVal)
var begTime int64
var eldTime int64
if publicmethod.GetIntLength(pageTime) >= 13 {
if publicmethod.GetIntLength(startTime) < 13 {
begTime = startTime * 1000
}
if publicmethod.GetIntLength(endTime) < 13 {
eldTime = endTime * 1000
}
} else {
begTime = startTime
eldTime = endTime
}
if begTime <= pageTime && pageTime <= eldTime {
if mastKey, isok := mv["masters_key"]; isok {
key := publicmethod.TypeToInterface(mastKey)
if !publicmethod.IsInTrue[string](key, dataMastKey) {
dataMastKey = append(dataMastKey, key)
}
}
}
}
}
}
var sunListData []interface{}
if sVal, isOk := sunVal.([]map[string]interface{}); isOk {
for _, mv := range sVal {
if mastKey, isok := mv["masters_key"]; isok {
key := publicmethod.TypeToInterface(mastKey)
if publicmethod.IsInTrue[string](key, dataMastKey) {
sunListData = append(sunListData, mv)
}
}
}
}
return sunListData
}