Browse Source

改了一个bug

pull/5/head
娄文智 3 years ago
parent
commit
1f916a3f85
1 changed files with 37 additions and 29 deletions
  1. +37
    -29
      web/models/c_surveysheet_result.go

+ 37
- 29
web/models/c_surveysheet_result.go View File

@ -534,7 +534,7 @@ type CourtJoinResult struct {
} }
// 满意度统计 // 满意度统计
func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string) (result StatisticData, err error) {
func (c *CSurveysheetResult) Statistic(selectType string, year string, unit string) (result StatisticData, err error) {
engine := db.MasterEngine() engine := db.MasterEngine()
engine.ShowSQL(true) engine.ShowSQL(true)
query := engine.Table("c_surveysheet_resultlst").Join("LEFT", "c_surveysheet_result", "c_surveysheet_resultlst.cid = c_surveysheet_result.cid and c_surveysheet_resultlst.surveynr = c_surveysheet_result.surveynr") query := engine.Table("c_surveysheet_resultlst").Join("LEFT", "c_surveysheet_result", "c_surveysheet_resultlst.cid = c_surveysheet_result.cid and c_surveysheet_resultlst.surveynr = c_surveysheet_result.surveynr")
@ -554,23 +554,23 @@ func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string
return result, err return result, err
} }
yearstr := date.Year() yearstr := date.Year()
if utils.ValueToInt(year,0) != yearstr{
if utils.ValueToInt(year, 0) != yearstr {
continue continue
} }
month := int(date.Month()) month := int(date.Month())
if unit == "top"{
if month >6{
if unit == "top" {
if month > 6 {
continue continue
} }
}else if unit == "bottom"{
if month <= 6{
} else if unit == "bottom" {
if month <= 6 {
continue continue
} }
}else {
} else {
} }
cate := joinResult.CSurveysheetSubjectlst.SubjectCategoryid cate := joinResult.CSurveysheetSubjectlst.SubjectCategoryid
if cate == "整体满意程度" || cate == ""{
if cate == "整体满意程度" || cate == "" {
continue continue
} }
cateMap[cate] = append(cateMap[cate], joinResult) cateMap[cate] = append(cateMap[cate], joinResult)
@ -649,7 +649,7 @@ func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string
return result, err return result, err
} }
yearstr := date.Year() yearstr := date.Year()
if utils.ValueToInt(year,0) != yearstr{
if utils.ValueToInt(year, 0) != yearstr {
continue continue
} }
month := int(date.Month()) month := int(date.Month())
@ -660,16 +660,16 @@ func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string
innerTimeType = "年中" innerTimeType = "年中"
} }
if unit == "top"{
if unit == "top" {
innerTimeType = "年末" innerTimeType = "年末"
if month >6{
if month > 6 {
continue continue
} }
}else if unit == "bottom"{
if month <= 6{
} else if unit == "bottom" {
if month <= 6 {
continue continue
} }
}else {
} else {
} }
if joinResult.CSurveysheetSubjectlst.SubjectCategoryid == "" { if joinResult.CSurveysheetSubjectlst.SubjectCategoryid == "" {
@ -886,19 +886,19 @@ func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string
return result, err return result, err
} }
yearstr := date.Year() yearstr := date.Year()
if utils.ValueToInt(year,0) != yearstr{
if utils.ValueToInt(year, 0) != yearstr {
continue continue
} }
month := int(date.Month()) month := int(date.Month())
if unit == "top"{
if month >6{
if unit == "top" {
if month > 6 {
continue continue
} }
}else if unit == "bottom"{
if month <= 6{
} else if unit == "bottom" {
if month <= 6 {
continue continue
} }
}else {
} else {
} }
buildingDescr := joinResult.Buildingtab.Descr buildingDescr := joinResult.Buildingtab.Descr
@ -1083,7 +1083,11 @@ func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string
if selectType == "ratio" { if selectType == "ratio" {
// 处理整体满意度的表格 // 处理整体满意度的表格
result.Total.SatisfactionPercent = utils.Decimal(float64(result.Total.ASum+result.Total.BSum)/float64(result.Total.Count), 3)
if result.Total.Count > 0 {
result.Total.SatisfactionPercent = utils.Decimal(float64(result.Total.ASum+result.Total.BSum)/float64(result.Total.Count), 3)
} else {
result.Total.SatisfactionPercent = 0
}
// 处理饼图数据 // 处理饼图数据
result.PicTotal.Row = []string{"非常满意", "满意", "一般", "不满意", "非常不满意"} result.PicTotal.Row = []string{"非常满意", "满意", "一般", "不满意", "非常不满意"}
result.PicTotal.ValueLi = []float64{totalData.APercent, totalData.BPercent, totalData.CPercent, totalData.DPercent, totalData.EPercent} result.PicTotal.ValueLi = []float64{totalData.APercent, totalData.BPercent, totalData.CPercent, totalData.DPercent, totalData.EPercent}
@ -1121,7 +1125,7 @@ func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string
if subjectData.Count == 0 { if subjectData.Count == 0 {
subjectData.SatisfactionPercent = 0 subjectData.SatisfactionPercent = 0
} else { } else {
subjectData.SatisfactionPercent = utils.Decimal(subjectData.APercent + subjectData.BPercent, 3)
subjectData.SatisfactionPercent = utils.Decimal(subjectData.APercent+subjectData.BPercent, 3)
} }
data.SubjectStaticDataLi[innerIndex] = subjectData data.SubjectStaticDataLi[innerIndex] = subjectData
} }
@ -1189,7 +1193,11 @@ func (c *CSurveysheetResult) Statistic(selectType string,year string,unit string
*三分比例法:3分比例法统计的是选择非常满意满意一般的人数占比,此三项加和作为分母 *三分比例法:3分比例法统计的是选择非常满意满意一般的人数占比,此三项加和作为分母
**************/ **************/
// 处理整体满意度的表格 // 处理整体满意度的表格
result.Total.SatisfactionPercent = result.Total.APercent + result.Total.BPercent + result.Total.CPercent
if result.Total.Count > 0 {
result.Total.SatisfactionPercent = utils.Decimal(float64(result.Total.ASum+result.Total.BSum+result.Total.CSum)/float64(result.Total.Count), 3)
} else {
result.Total.SatisfactionPercent = 0
}
// 处理饼图数据 // 处理饼图数据
result.PicTotal.Row = []string{"非常满意", "满意", "一般", "不满意", "非常不满意"} result.PicTotal.Row = []string{"非常满意", "满意", "一般", "不满意", "非常不满意"}
result.PicTotal.ValueLi = []float64{totalData.APercent, totalData.BPercent, totalData.CPercent, totalData.DPercent, totalData.EPercent} result.PicTotal.ValueLi = []float64{totalData.APercent, totalData.BPercent, totalData.CPercent, totalData.DPercent, totalData.EPercent}
@ -1471,19 +1479,19 @@ func (c *CSurveysheetResult) AllStatistic(selectType string, cids []string, year
return result, err return result, err
} }
yearstr := date.Year() yearstr := date.Year()
if utils.ValueToInt(year,0) != yearstr{
if utils.ValueToInt(year, 0) != yearstr {
continue continue
} }
month := int(date.Month()) month := int(date.Month())
if unit == "top"{
if month >6{
if unit == "top" {
if month > 6 {
continue continue
} }
}else if unit == "bottom"{
if month <= 6{
} else if unit == "bottom" {
if month <= 6 {
continue continue
} }
}else {
} else {
} }


Loading…
Cancel
Save