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.
153 lines
4.3 KiB
153 lines
4.3 KiB
package examtestpage
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"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"
|
|
)
|
|
|
|
//健康上报
|
|
type HealthReportStat struct{}
|
|
|
|
func (h *HealthReportStat) HealthList(c *gin.Context) {
|
|
var healthReport commonus.GetHealthReport
|
|
err := c.ShouldBindJSON(&healthReport)
|
|
tadayTime := commonus.GetYesterDay()
|
|
if err == nil {
|
|
if healthReport.Date != "" {
|
|
tadayTime = healthReport.Date
|
|
}
|
|
}
|
|
// fmt.Printf("%v===>%v\n", tadayTime, healthReport)
|
|
pv, uv, isTrue, msg := commonus.GetHealthReportStat(tadayTime)
|
|
if isTrue != true {
|
|
response.Result(101, tadayTime, msg, c)
|
|
return
|
|
}
|
|
type outStruct struct {
|
|
Pv int64 `json:"pv"` //应用使用次数
|
|
Uv int64 `json:"uv"` //应用使用成员数
|
|
}
|
|
var healthReportInfo outStruct
|
|
healthReportInfo.Pv = pv
|
|
healthReportInfo.Uv = uv
|
|
// fmt.Printf("%v===>%v===>%v===>%v===>%v\n", tadayTime, pv, uv, isTrue, msg)
|
|
response.Result(200, healthReportInfo, msg, c)
|
|
}
|
|
|
|
//获取企业当前正在运行的上报任务ID列表
|
|
func (h *HealthReportStat) RunHealthList(c *gin.Context) {
|
|
var healthReport commonus.GetHealthReportRun
|
|
err := c.ShouldBindJSON(&healthReport)
|
|
var page int
|
|
var pageSize int64
|
|
page = 0
|
|
pageSize = 100
|
|
if err == nil {
|
|
if healthReport.Offset != 0 {
|
|
page = healthReport.Offset
|
|
}
|
|
if healthReport.Limit != 0 {
|
|
pageSize = healthReport.Limit
|
|
}
|
|
}
|
|
jobMap, isTrue, msg := commonus.GetRunHealthReportJobids(page, pageSize)
|
|
if isTrue != true {
|
|
response.Result(102, isTrue, msg, c)
|
|
return
|
|
}
|
|
// fmt.Printf("%v\n", jobMap)
|
|
response.Result(200, jobMap, msg, c)
|
|
}
|
|
|
|
//获取健康上报任务详情
|
|
func (h *HealthReportStat) PostReportJobInfo(c *gin.Context) {
|
|
var healthReportJob commonus.GetReportJobInfoDate
|
|
err := c.ShouldBindJSON(&healthReportJob)
|
|
if err != nil {
|
|
response.Result(101, healthReportJob, "参数错误!", c)
|
|
return
|
|
}
|
|
if healthReportJob.JobId == "" {
|
|
response.Result(102, err, "参数错误!", c)
|
|
return
|
|
}
|
|
tadayTime := commonus.GetYesterDay()
|
|
if healthReportJob.Date != "" {
|
|
tadayTime = healthReportJob.Date
|
|
}
|
|
strucr, _, _, msg := commonus.GetReportJobInfo(healthReportJob.JobId, tadayTime)
|
|
response.Result(200, strucr, msg, c)
|
|
}
|
|
|
|
//获取用户填写答案列表
|
|
func (h *HealthReportStat) PostReportAnswerList(c *gin.Context) {
|
|
var reportAnswer commonus.ReportAnswerStruct
|
|
err := c.ShouldBindJSON(&reportAnswer)
|
|
if err != nil {
|
|
response.Result(101, reportAnswer, "参数错误!", c)
|
|
return
|
|
}
|
|
if reportAnswer.JobId == "" {
|
|
response.Result(102, err, "参数错误!", c)
|
|
return
|
|
}
|
|
tadayTime := commonus.GetYesterDay()
|
|
if reportAnswer.Date != "" {
|
|
tadayTime = reportAnswer.Date
|
|
}
|
|
var page int
|
|
var pageSize int64
|
|
page = 0
|
|
pageSize = 100
|
|
if reportAnswer.Offset != 0 {
|
|
page = reportAnswer.Offset
|
|
}
|
|
if reportAnswer.Limit != 0 {
|
|
pageSize = reportAnswer.Limit
|
|
}
|
|
_, reportAnswerInfoList, _, msg := commonus.GetUserWriteAnswer(reportAnswer.JobId, tadayTime, page, pageSize)
|
|
// var reportAnswerJson commonus.ReportAnswerResult
|
|
// err = json.Unmarshal(reportByte, &reportAnswerJson)
|
|
var AdmDivStruct []commonus.AdministrativeDivision
|
|
for _, v := range reportAnswerInfoList.Answers {
|
|
for _, v_sun := range v.ReportValues {
|
|
if v_sun.Text != "" {
|
|
var AdmDiv commonus.AdministrativeDivision
|
|
|
|
countSplit := strings.Split(v_sun.Text, "省")
|
|
if len(countSplit) >= 2 {
|
|
AdmDiv.Userid = v.Userid
|
|
AdmDiv.Province = countSplit[0] + "省"
|
|
countSplitSun := strings.Split(countSplit[1], "市")
|
|
if len(countSplitSun) > 2 {
|
|
AdmDiv.City = countSplitSun[0] + "市"
|
|
AdmDiv.County = countSplitSun[1] + "市"
|
|
} else {
|
|
AdmDiv.City = countSplitSun[0] + "市"
|
|
if len(countSplitSun) == 2 {
|
|
countSplitSunes := strings.Split(countSplitSun[1], "县")
|
|
if len(countSplitSun) > 1 {
|
|
AdmDiv.County = countSplitSunes[0] + "县"
|
|
}
|
|
countSplitSunesi := strings.Split(countSplitSun[1], "区")
|
|
if len(countSplitSunesi) > 1 {
|
|
AdmDiv.County = countSplitSunesi[0] + "区"
|
|
}
|
|
|
|
fmt.Printf("%v切割地址%v-------------%v\n", v.Userid, countSplitSunes, len(countSplitSunes))
|
|
}
|
|
|
|
}
|
|
AdmDivStruct = append(AdmDivStruct, AdmDiv)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
response.Result(200, reportAnswerInfoList, msg, c)
|
|
}
|
|
|