|
|
@ -0,0 +1,341 @@ |
|
|
|
package models |
|
|
|
|
|
|
|
// 比较大小的接口
|
|
|
|
type ICompare interface { |
|
|
|
Compare(interface{}) int |
|
|
|
} |
|
|
|
|
|
|
|
// 年份的统计数据
|
|
|
|
type RecentYear struct { |
|
|
|
TimeDescr string `json:"timeDescr"` |
|
|
|
Year int `json:"year"` |
|
|
|
Type int `json:"type"` |
|
|
|
ASum int `json:"aSum"` |
|
|
|
BSum int `json:"bSum"` |
|
|
|
CSum int `json:"cSum"` |
|
|
|
DSum int `json:"dSum"` |
|
|
|
ESum int `json:"eSum"` |
|
|
|
Count int `json:"count"` |
|
|
|
SatisfactionPercent float64 `json:"satisfactionPercent"` |
|
|
|
} |
|
|
|
|
|
|
|
func (r RecentYear) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(RecentYear) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
if r.Year > data.Year { |
|
|
|
return 1 |
|
|
|
} |
|
|
|
if r.Year == data.Year { |
|
|
|
if r.Type > data.Type { |
|
|
|
return 1 |
|
|
|
} else { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
return -1 |
|
|
|
} |
|
|
|
|
|
|
|
// 年份 不同时间的统计数据
|
|
|
|
type TimeStatisticData struct { |
|
|
|
TimeDescr string `json:"timeDescr"` |
|
|
|
Year int `json:"year"` |
|
|
|
Type int `json:"type"` |
|
|
|
Count int `json:"count"` |
|
|
|
BreakingInPeriodASum int `json:"breakingInPeriodASum"` |
|
|
|
BreakingInPeriodBSum int `json:"breakingInPeriodBSum"` |
|
|
|
BreakingInPeriodCSum int `json:"breakingInPeriodCSum"` |
|
|
|
BreakingInPeriodDSum int `json:"breakingInPeriodDSum"` |
|
|
|
BreakingInPeriodESum int `json:"breakingInPeriodESum"` |
|
|
|
BreakingInPeriodCount int `json:"breakingInPeriodCount"` |
|
|
|
BreakingInPeriodPercent float64 `json:"breakingInPeriodPercent"` |
|
|
|
StablePeriodASum int `json:"stablePeriodASum"` |
|
|
|
StablePeriodBSum int `json:"stablePeriodBSum"` |
|
|
|
StablePeriodCSum int `json:"stablePeriodCSum"` |
|
|
|
StablePeriodDSum int `json:"stablePeriodDSum"` |
|
|
|
StablePeriodESum int `json:"stablePeriodESum"` |
|
|
|
StablePeriodCount int `json:"stablePeriodCount"` |
|
|
|
StablePeriodPercent float64 `json:"stablePeriodPercent"` |
|
|
|
AcquaintanceASum int `json:"acquaintanceASum"` |
|
|
|
AcquaintanceBSum int `json:"acquaintanceBSum"` |
|
|
|
AcquaintanceCSum int `json:"acquaintanceCSum"` |
|
|
|
AcquaintanceDSum int `json:"acquaintanceDSum"` |
|
|
|
AcquaintanceESum int `json:"acquaintanceESum"` |
|
|
|
AcquaintanceCount int `json:"acquaintanceCount"` |
|
|
|
AcquaintancePercent float64 `json:"acquaintancePercent"` |
|
|
|
} |
|
|
|
|
|
|
|
func (t TimeStatisticData) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(TimeStatisticData) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
if t.Year > data.Year { |
|
|
|
return 1 |
|
|
|
} |
|
|
|
if t.Year == data.Year { |
|
|
|
if t.Type > data.Type { |
|
|
|
return 1 |
|
|
|
} else { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
return -1 |
|
|
|
} |
|
|
|
|
|
|
|
// 年份 分模块统计数据
|
|
|
|
type YearStatisticData struct { |
|
|
|
TimeDescr string `json:"timeDescr"` |
|
|
|
Year int `json:"year"` |
|
|
|
Type string `json:"type"` |
|
|
|
CateData []SingleCateData `json:"cate"` |
|
|
|
CateMap map[string]SingleCateData `json:"cateMap"` |
|
|
|
} |
|
|
|
|
|
|
|
func (r YearStatisticData) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(YearStatisticData) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
if r.Year > data.Year { |
|
|
|
return 1 |
|
|
|
} |
|
|
|
if r.Year == data.Year { |
|
|
|
if r.Type > data.Type { |
|
|
|
return 1 |
|
|
|
} else { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
} |
|
|
|
return -1 |
|
|
|
} |
|
|
|
|
|
|
|
// 问题统计数据
|
|
|
|
type SubjectStaticData struct { |
|
|
|
CateId string `json:"subject_categoryid"` |
|
|
|
SubjectName string `json:"subject_name"` |
|
|
|
Pos int `json:"pos"` |
|
|
|
ASum int `json:"asum"` |
|
|
|
APercent float64 `json:"aper"` |
|
|
|
BSum int `json:"bsum"` |
|
|
|
BPercent float64 `json:"bper"` |
|
|
|
CSum int `json:"csum"` |
|
|
|
CPercent float64 `json:"cper"` |
|
|
|
DSum int `json:"dsum"` |
|
|
|
DPercent float64 `json:"dper"` |
|
|
|
ESum int `json:"esum"` |
|
|
|
EPercent float64 `json:"eper"` |
|
|
|
SatisfactionPercent float64 `json:"satisfaction_per"` |
|
|
|
Count int `json:"count"` |
|
|
|
} |
|
|
|
|
|
|
|
func (s SubjectStaticData) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(SubjectStaticData) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
if s.Pos > data.Pos { |
|
|
|
return 1 |
|
|
|
} else if s.Pos == data.Pos { |
|
|
|
return 0 |
|
|
|
} else { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 分类模块统计数据
|
|
|
|
type CateStatisticData struct { |
|
|
|
SubjectStaticDataLi []SubjectStaticData `json:"subjectStaticDataLi"` |
|
|
|
Count int `json:"count"` |
|
|
|
Cate string `json:"subject_categoryid"` |
|
|
|
ASum int `json:"aSum"` |
|
|
|
BSum int `json:"bSum"` |
|
|
|
CSum int `json:"cSum"` |
|
|
|
DSum int `json:"dSum"` |
|
|
|
ESum int `json:"eSum"` |
|
|
|
SatisfactionPercent float64 `json:"per_total"` |
|
|
|
} |
|
|
|
|
|
|
|
func (c CateStatisticData) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(CateStatisticData) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
if data.Cate == "整体满意度" { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
if c.Cate == "整体满意度" { |
|
|
|
return 1 |
|
|
|
} |
|
|
|
if c.Cate > data.Cate { |
|
|
|
return 1 |
|
|
|
} else if c.Cate == data.Cate { |
|
|
|
return 0 |
|
|
|
} else { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 楼栋统计数据
|
|
|
|
type BuildingStaticData struct { |
|
|
|
BuildingRooms int `json:"buildingRooms"` |
|
|
|
BuildingSamples int `json:"buildingSamples"` |
|
|
|
SampleBuildingPercent float64 `json:"sampleBuildingPercent"` |
|
|
|
SampleAllPercent float64 `json:"sampleAllPercent"` |
|
|
|
SatisfactionPercent float64 `json:"satisfactionPercent"` |
|
|
|
DifferencePercent float64 `json:"differencePercent"` |
|
|
|
ASum int `json:"aSum"` |
|
|
|
BSum int `json:"bSum"` |
|
|
|
CSum int `json:"cSum"` |
|
|
|
DSum int `json:"dSum"` |
|
|
|
ESum int `json:"eSum"` |
|
|
|
BuildingId string `json:"buildingId"` |
|
|
|
BuildingDescr string `json:"buildingDescr"` |
|
|
|
} |
|
|
|
|
|
|
|
func (b BuildingStaticData) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(BuildingStaticData) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
if b.BuildingId > data.BuildingId { |
|
|
|
return 1 |
|
|
|
} else if b.BuildingId == data.BuildingId { |
|
|
|
return 0 |
|
|
|
} else { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 单项模块数据统计
|
|
|
|
type SingleCateData struct { |
|
|
|
CateId string `json:"cateId"` |
|
|
|
BuildingDescr string `json:"buildingDescr"` |
|
|
|
ASum int `json:"aSum"` |
|
|
|
BSum int `json:"bSum"` |
|
|
|
CSum int `json:"cSum"` |
|
|
|
DSum int `json:"dSum"` |
|
|
|
ESum int `json:"eSum"` |
|
|
|
Count int `json:"count"` |
|
|
|
SatisfactionPercent float64 `json:"satisfactionPercent"` |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (s SingleCateData) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(SingleCateData) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
if data.CateId == "整体满意度" { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
if s.CateId == "整体满意度" { |
|
|
|
return 1 |
|
|
|
} |
|
|
|
if s.CateId > data.CateId { |
|
|
|
return 1 |
|
|
|
} else if s.CateId == data.CateId { |
|
|
|
return 0 |
|
|
|
} else { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 楼栋分类统计
|
|
|
|
type BuildingCate struct { |
|
|
|
BuildingDescr string `json:"buildingDescr"` |
|
|
|
Samples int `json:"samples"` |
|
|
|
CateData []SingleCateData `json:"cateData"` |
|
|
|
CateMap map[string]float64 `json:"cateMap"` |
|
|
|
} |
|
|
|
|
|
|
|
func (b BuildingCate) Compare(iData interface{}) int { |
|
|
|
data, ok := iData.(BuildingCate) |
|
|
|
if !ok { |
|
|
|
return -2 |
|
|
|
} |
|
|
|
satisfaction1, exist1 := b.CateMap["整体满意度"] |
|
|
|
satisfaction2, exist2 := data.CateMap["整体满意度"] |
|
|
|
if exist1 && exist2 { |
|
|
|
if satisfaction1 > satisfaction2 { |
|
|
|
return 1 |
|
|
|
} else if satisfaction1 == satisfaction2 { |
|
|
|
return 0 |
|
|
|
} else { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
} |
|
|
|
if b.BuildingDescr > data.BuildingDescr { |
|
|
|
return 1 |
|
|
|
} else if b.BuildingDescr == data.BuildingDescr { |
|
|
|
return 0 |
|
|
|
} else { |
|
|
|
return -1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
type BuildingData struct { |
|
|
|
BuildingStaticDataLi []BuildingStaticData `json:"buildingStaticDataLi"` |
|
|
|
ASum int `json:"aSum"` |
|
|
|
BSum int `json:"bSum"` |
|
|
|
CSum int `json:"cSum"` |
|
|
|
DSum int `json:"dSum"` |
|
|
|
ESum int `json:"eSum"` |
|
|
|
Count int `json:"count"` |
|
|
|
SatisfactionPercent float64 `json:"satisfactionPercent"` |
|
|
|
DifferencePercent float64 `json:"differencePercent"` |
|
|
|
Rooms int `json:"rooms"` |
|
|
|
SampleBuildingPercent float64 `json:"sampleBuildingPercent"` |
|
|
|
SampleAllPercent float64 `json:"sampleAllPercent"` |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type PicTotal struct { |
|
|
|
Row []string `json:"row"` |
|
|
|
ValueLi []float64 `json:"valueLi"` |
|
|
|
} |
|
|
|
|
|
|
|
type StatisticData struct { |
|
|
|
Total TotalStatisticData `json:"total"` |
|
|
|
PicTotal PicTotal `json:"picTotal"` |
|
|
|
RecentYears []RecentYear `json:"recentYears"` |
|
|
|
Time []TimeStatisticData `json:"time"` |
|
|
|
Cate []CateStatisticData `json:"cate"` |
|
|
|
Building BuildingData `json:"building"` |
|
|
|
BuildingCate []BuildingCate `json:"buildingCate"` |
|
|
|
YearCate []YearStatisticData `json:"yearCate"` |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type TotalStatisticData struct { |
|
|
|
ASum int `json:"aSum"` |
|
|
|
APercent float64 `json:"aPercent"` |
|
|
|
BSum int `json:"bSum"` |
|
|
|
BPercent float64 `json:"bPercent"` |
|
|
|
CSum int `json:"cSum"` |
|
|
|
CPercent float64 `json:"cPercent"` |
|
|
|
DSum int `json:"dSum"` |
|
|
|
DPercent float64 `json:"dPercent"` |
|
|
|
ESum int `json:"eSum"` |
|
|
|
EPercent float64 `json:"ePercent"` |
|
|
|
Count int `json:"count"` |
|
|
|
SatisfactionPercent float64 `json:"satisfactionPercent"` |
|
|
|
} |
|
|
|
|
|
|
|
func BubbleSort(list []ICompare) []ICompare { |
|
|
|
for i := 0; i < len(list); i++ { |
|
|
|
for j := 1; j < len(list)-i; j++ { |
|
|
|
result := list[j].Compare(list[j-1]) |
|
|
|
if result == -1 { |
|
|
|
//交换
|
|
|
|
list[j], list[j-1] = list[j-1], list[j] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return list |
|
|
|
} |