|
|
|
|
package examtestpage
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"reflect"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"gin_server_admin/commonus"
|
|
|
|
|
"gin_server_admin/global"
|
|
|
|
|
"gin_server_admin/model/common/response"
|
|
|
|
|
"gin_server_admin/model/location"
|
|
|
|
|
"gin_server_admin/model/locationing"
|
|
|
|
|
"gin_server_admin/model/wechat"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 健康上报列表
|
|
|
|
|
func (h *HealthReportStat) PostReportAnswerListLimit(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
|
|
|
|
|
}
|
|
|
|
|
// if reportAnswer.Date == "" {
|
|
|
|
|
// response.Result(103, err, "请输入要查询的日期!", c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
tadayTime := commonus.GetYesterDay()
|
|
|
|
|
if reportAnswer.Date != "" {
|
|
|
|
|
tadayTime = reportAnswer.Date
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if reportAnswer.PageSize == 0 {
|
|
|
|
|
reportAnswer.PageSize = 100
|
|
|
|
|
}
|
|
|
|
|
if reportAnswer.Page <= 0 {
|
|
|
|
|
reportAnswer.Page = 1
|
|
|
|
|
}
|
|
|
|
|
// tadayTime := reportAnswer.Date
|
|
|
|
|
//判断日期是否已经统计
|
|
|
|
|
calCulTime := commonus.DateToTimeStamp(tadayTime + " 12:00:00")
|
|
|
|
|
psge := (reportAnswer.Page - 1) * reportAnswer.PageSize
|
|
|
|
|
var reportInfo locationing.ReportAddress
|
|
|
|
|
errInfo := global.GVA_DB_HealthReport.Where("calcultime = ?", calCulTime).Limit(reportAnswer.PageSize).Offset(psge).First(&reportInfo).Error
|
|
|
|
|
var reportInfoAry []locationing.ReportAddress
|
|
|
|
|
|
|
|
|
|
if errInfo == nil { //当前日期存在,查询数据库
|
|
|
|
|
listErr := global.GVA_DB_HealthReport.Where("calcultime = ?", calCulTime).Limit(reportAnswer.PageSize).Offset(psge).Find(&reportInfoAry).Error
|
|
|
|
|
if listErr != nil {
|
|
|
|
|
response.Result(104, reportInfoAry, "数据获取失败!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var normalData []locationing.ReportAddress //正常数据
|
|
|
|
|
var abnormalData []locationing.ReportAddress //异常数据
|
|
|
|
|
for _, v := range reportInfoAry {
|
|
|
|
|
if v.IsDbnormal == 1 {
|
|
|
|
|
normalData = append(normalData, v)
|
|
|
|
|
} else {
|
|
|
|
|
abnormalData = append(abnormalData, v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
returnData["allData"] = reportInfoAry
|
|
|
|
|
returnData["allData_quantity"] = len(reportInfoAry)
|
|
|
|
|
returnData["normalData"] = normalData
|
|
|
|
|
returnData["normalData_quantity"] = len(normalData)
|
|
|
|
|
returnData["abnormalData"] = abnormalData
|
|
|
|
|
returnData["abnormalData_quantity"] = len(abnormalData)
|
|
|
|
|
response.Result(0, returnData, "查询成功!", c)
|
|
|
|
|
return
|
|
|
|
|
} else { //当前日期不存在,获取数据写入数据库
|
|
|
|
|
var legalAreaList []locationing.LegalArea
|
|
|
|
|
addressListErr := global.GVA_DB_HealthReport.Where("la_state = ?", 1).Find(&legalAreaList).Error
|
|
|
|
|
if addressListErr != nil {
|
|
|
|
|
response.Result(105, legalAreaList, "未设置围栏地址!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
weChatPage := reportAnswer.Page - 1
|
|
|
|
|
if weChatPage < 0 {
|
|
|
|
|
weChatPage = 0
|
|
|
|
|
}
|
|
|
|
|
_, reportAnswerInfoList, _, _ := commonus.GetUserWriteAnswer(reportAnswer.JobId, tadayTime, weChatPage, int64(reportAnswer.PageSize))
|
|
|
|
|
var writeInfo []locationing.ReportAddress
|
|
|
|
|
var normalInfo []locationing.ReportAddress
|
|
|
|
|
var abnormalInfo []locationing.ReportAddress
|
|
|
|
|
for _, v := range reportAnswerInfoList.Answers {
|
|
|
|
|
for _, v_sun := range v.ReportValues {
|
|
|
|
|
// fmt.Printf("v_sun.Text ===========>%v\n", v_sun.Text)
|
|
|
|
|
if v_sun.Text != "" {
|
|
|
|
|
|
|
|
|
|
countSplit := strings.Split(v_sun.Text, "省")
|
|
|
|
|
if len(countSplit) >= 2 {
|
|
|
|
|
var writeInfoUser locationing.ReportAddress
|
|
|
|
|
|
|
|
|
|
writeInfoUser.WechatId = v.Userid
|
|
|
|
|
writeInfoUser.Userid = v.Userid
|
|
|
|
|
writeInfoUser.AddTime = time.Now().Unix()
|
|
|
|
|
writeInfoUser.Address = v_sun.Text
|
|
|
|
|
writeInfoUser.CalCulTime = calCulTime
|
|
|
|
|
writeInfoUser.Address = v_sun.Text
|
|
|
|
|
|
|
|
|
|
writeInfoUser.Province = countSplit[0] + "省"
|
|
|
|
|
countSplitSun := strings.Split(countSplit[1], "市")
|
|
|
|
|
if len(countSplitSun) > 2 {
|
|
|
|
|
writeInfoUser.City = countSplitSun[0] + "市"
|
|
|
|
|
writeInfoUser.County = countSplitSun[1] + "市"
|
|
|
|
|
} else {
|
|
|
|
|
writeInfoUser.City = countSplitSun[0] + "市"
|
|
|
|
|
if len(countSplitSun) == 2 {
|
|
|
|
|
countSplitSunes := strings.Split(countSplitSun[1], "县")
|
|
|
|
|
if len(countSplitSun) > 1 {
|
|
|
|
|
writeInfoUser.County = countSplitSunes[0] + "县"
|
|
|
|
|
}
|
|
|
|
|
countSplitSunesi := strings.Split(countSplitSun[1], "区")
|
|
|
|
|
if len(countSplitSunesi) > 1 {
|
|
|
|
|
writeInfoUser.County = countSplitSunes[0] + "区"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abnormalIsTrue := false
|
|
|
|
|
for _, expVal := range legalAreaList {
|
|
|
|
|
if expVal.ProvinceName == writeInfoUser.Province {
|
|
|
|
|
if expVal.CityName == writeInfoUser.City {
|
|
|
|
|
abnormalIsTrue = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if abnormalIsTrue == true {
|
|
|
|
|
writeInfoUser.IsDbnormal = 1
|
|
|
|
|
// fmt.Printf("报警1=====>%v", abnormalIsTrue)
|
|
|
|
|
// normalInfoUser = writeInfoUser
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
writeInfoUser.IsDbnormal = 2
|
|
|
|
|
// abnormalInfoUser = writeInfoUser
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("报警2=====>%v", abnormalIsTrue)
|
|
|
|
|
}
|
|
|
|
|
writeInfo = append(writeInfo, writeInfoUser)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if reflect.DeepEqual(writeInfo, []locationing.ReportAddress{}) {
|
|
|
|
|
response.Result(106, writeInfo, "没有要处理的数据!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
errDb := global.GVA_DB_HealthReport.Create(&writeInfo).Error
|
|
|
|
|
if errDb != nil {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
for _, val := range writeInfo {
|
|
|
|
|
if val.IsDbnormal == 1 {
|
|
|
|
|
var normalInfoUser locationing.ReportAddress
|
|
|
|
|
|
|
|
|
|
normalInfoUser.Id = val.Id
|
|
|
|
|
normalInfoUser.WechatId = val.WechatId
|
|
|
|
|
normalInfoUser.Province = val.Province
|
|
|
|
|
normalInfoUser.City = val.City
|
|
|
|
|
normalInfoUser.County = val.County
|
|
|
|
|
normalInfoUser.Userid = val.Userid
|
|
|
|
|
normalInfoUser.AddTime = val.AddTime
|
|
|
|
|
normalInfoUser.CalCulTime = val.CalCulTime
|
|
|
|
|
normalInfoUser.Address = val.Address
|
|
|
|
|
normalInfoUser.IsDbnormal = val.IsDbnormal
|
|
|
|
|
normalInfoUser.UserName = val.UserName
|
|
|
|
|
normalInfoUser.UserTel = val.UserTel
|
|
|
|
|
|
|
|
|
|
normalInfo = append(normalInfo, normalInfoUser)
|
|
|
|
|
} else {
|
|
|
|
|
var abnormalInfoUser locationing.ReportAddress
|
|
|
|
|
|
|
|
|
|
abnormalInfoUser.Id = val.Id
|
|
|
|
|
abnormalInfoUser.WechatId = val.WechatId
|
|
|
|
|
abnormalInfoUser.Province = val.Province
|
|
|
|
|
abnormalInfoUser.City = val.City
|
|
|
|
|
abnormalInfoUser.County = val.County
|
|
|
|
|
abnormalInfoUser.Userid = val.Userid
|
|
|
|
|
abnormalInfoUser.AddTime = val.AddTime
|
|
|
|
|
abnormalInfoUser.CalCulTime = val.CalCulTime
|
|
|
|
|
abnormalInfoUser.Address = val.Address
|
|
|
|
|
abnormalInfoUser.IsDbnormal = val.IsDbnormal
|
|
|
|
|
abnormalInfoUser.UserName = val.UserName
|
|
|
|
|
abnormalInfoUser.UserTel = val.UserTel
|
|
|
|
|
abnormalInfo = append(abnormalInfo, abnormalInfoUser)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
returnData["allData"] = writeInfo
|
|
|
|
|
returnData["allData_quantity"] = len(writeInfo)
|
|
|
|
|
returnData["normalData"] = normalInfo
|
|
|
|
|
returnData["normalData_quantity"] = len(normalInfo)
|
|
|
|
|
returnData["abnormalData"] = abnormalInfo
|
|
|
|
|
returnData["abnormalData_quantity"] = len(abnormalInfo)
|
|
|
|
|
response.Result(0, returnData, "查询成功!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 向相关人员发送信息
|
|
|
|
|
func (h *HealthReportStat) SendRelevantPersonnelMsg(c *gin.Context) {
|
|
|
|
|
tadayTime := commonus.GetYesterDay() //获取昨日信息
|
|
|
|
|
calCulTime := commonus.DateToTimeStamp(tadayTime + " 12:00:00")
|
|
|
|
|
var reportInfoAry []locationing.ReportAddress //统计表模型
|
|
|
|
|
listErr := global.GVA_DB_HealthReport.Where("calcultime = ? and isabnormal = 2", calCulTime).Find(&reportInfoAry).Error
|
|
|
|
|
if listErr != nil {
|
|
|
|
|
response.Result(106, reportInfoAry, "没有异常人员信息数据!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
//判断报警人是不是为空
|
|
|
|
|
if len(reportInfoAry) > 0 {
|
|
|
|
|
var readBaoJinf []map[string]interface{}
|
|
|
|
|
for _, v := range reportInfoAry {
|
|
|
|
|
callPolice := commonus.MapOut()
|
|
|
|
|
callPolice["id"] = v.Id
|
|
|
|
|
callPolice["userid"] = v.WechatId
|
|
|
|
|
callPolice["province"] = v.Province
|
|
|
|
|
callPolice["city"] = v.City
|
|
|
|
|
callPolice["county"] = v.County
|
|
|
|
|
callPolice["userid"] = v.Userid
|
|
|
|
|
callPolice["addtime"] = v.AddTime
|
|
|
|
|
callPolice["calcultime"] = v.CalCulTime
|
|
|
|
|
callPolice["address"] = v.Address
|
|
|
|
|
callPolice["isabnormal"] = v.IsDbnormal
|
|
|
|
|
callPolice["user_name"] = v.UserName
|
|
|
|
|
callPolice["user_tel"] = v.UserTel
|
|
|
|
|
readBaoJinf = append(readBaoJinf, callPolice)
|
|
|
|
|
}
|
|
|
|
|
//给相关人员发送信息
|
|
|
|
|
sendMsg := sendMessAgeAlarm(calCulTime, readBaoJinf)
|
|
|
|
|
response.Result(0, sendMsg, "获取成功", c)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("没有异常人员!")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 返回结构体
|
|
|
|
|
type ReportStructExce struct {
|
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Department string `json:"department"`
|
|
|
|
|
DepartmentId int64 `json:"departmentid"`
|
|
|
|
|
JobNumber string `json:"jobnumber"`
|
|
|
|
|
TravelCodeIsTrue int `json:"travelcodeistrue"`
|
|
|
|
|
IsAbnormal int `json:"isabnormal"`
|
|
|
|
|
Date string `json:"date"`
|
|
|
|
|
AbnormalCont string `json:"abnormalcont"`
|
|
|
|
|
Group string `json:"group"`
|
|
|
|
|
GroupId int64 `json:"groupid"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上报统计
|
|
|
|
|
func (h *HealthReportStat) ReportStatistics(c *gin.Context) {
|
|
|
|
|
var reportStatistics commonus.ReportStatisticsStruct
|
|
|
|
|
err := c.ShouldBindJSON(&reportStatistics)
|
|
|
|
|
if err != nil {
|
|
|
|
|
// response.Result(101, reportStatistics, "参数错误!", c)
|
|
|
|
|
// return
|
|
|
|
|
}
|
|
|
|
|
if reportStatistics.Page == 0 {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if reportStatistics.PageSize == 0 {
|
|
|
|
|
reportStatistics.PageSize = 20
|
|
|
|
|
}
|
|
|
|
|
if reportStatistics.Page <= 0 {
|
|
|
|
|
reportStatistics.Page = 1
|
|
|
|
|
}
|
|
|
|
|
psge := (reportStatistics.Page - 1) * reportStatistics.PageSize
|
|
|
|
|
var reportInfoAry []locationing.ReportAddress
|
|
|
|
|
listStruct := global.GVA_DB_HealthReport
|
|
|
|
|
|
|
|
|
|
listStructCount := global.GVA_DB_HealthReport.Model(&reportInfoAry)
|
|
|
|
|
// whereMap := commonus.MapOut()
|
|
|
|
|
if reportStatistics.Name != "" {
|
|
|
|
|
// whereMap[""]
|
|
|
|
|
listStruct = listStruct.Where("user_name LIKE ?", "%"+reportStatistics.Name+"%")
|
|
|
|
|
listStructCount = listStructCount.Where("user_name LIKE ?", "%"+reportStatistics.Name+"%")
|
|
|
|
|
}
|
|
|
|
|
if reportStatistics.IsTrue != 0 {
|
|
|
|
|
listStruct = listStruct.Where("isabnormal = ?", reportStatistics.IsTrue)
|
|
|
|
|
listStructCount = listStructCount.Where("isabnormal = ?", reportStatistics.IsTrue)
|
|
|
|
|
}
|
|
|
|
|
if reportStatistics.Time != "" {
|
|
|
|
|
calCulTime := commonus.DateToTimeStamp(reportStatistics.Time + " 12:00:00")
|
|
|
|
|
listStruct = listStruct.Where("calcultime = ?", calCulTime)
|
|
|
|
|
listStructCount = listStructCount.Where("calcultime = ?", calCulTime)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if reportStatistics.GroupId != 0 {
|
|
|
|
|
listStruct = listStruct.Where("group_id = ?", reportStatistics.GroupId)
|
|
|
|
|
listStructCount = listStructCount.Where("group_id = ?", reportStatistics.GroupId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listStruct = listStruct.Order("addtime desc").Limit(reportStatistics.PageSize).Offset(psge).Find(&reportInfoAry)
|
|
|
|
|
var count int64
|
|
|
|
|
listStructCount = listStructCount.Count(&count)
|
|
|
|
|
|
|
|
|
|
if listStruct.Error != nil {
|
|
|
|
|
response.Result(100, reportInfoAry, "查询失败", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var reportStructExceAry []ReportStructExce
|
|
|
|
|
for _, v := range reportInfoAry {
|
|
|
|
|
isTrue, myDepartment := commonus.GetGroupInfo(v.MainDepartment)
|
|
|
|
|
var reportStructExceCont ReportStructExce
|
|
|
|
|
reportStructExceCont.Id = v.Id
|
|
|
|
|
reportStructExceCont.Name = v.UserName
|
|
|
|
|
reportStructExceCont.Date = commonus.TimeStampToDate(v.CalCulTime, 6)
|
|
|
|
|
if isTrue == true {
|
|
|
|
|
// reportStructExceCont.AbnormalCont = fmt.Sprintf("%s", myDepartment["name"])
|
|
|
|
|
reportStructExceCont.Department = fmt.Sprintf("%s", myDepartment.Name)
|
|
|
|
|
} else {
|
|
|
|
|
reportStructExceCont.Department = ""
|
|
|
|
|
}
|
|
|
|
|
reportStructExceCont.DepartmentId = v.MainDepartment
|
|
|
|
|
isTrueNum, myInfo := commonus.GetMainDataBaseUserInfo(v.WechatId)
|
|
|
|
|
if isTrueNum == true {
|
|
|
|
|
// reportStructExceCont.AbnormalCont = fmt.Sprintf("%s", myDepartment["name"])
|
|
|
|
|
reportStructExceCont.JobNumber = fmt.Sprintf("%s", myInfo.Number)
|
|
|
|
|
} else {
|
|
|
|
|
reportStructExceCont.JobNumber = ""
|
|
|
|
|
}
|
|
|
|
|
if v.IsDbnormal != 1 {
|
|
|
|
|
reportStructExceCont.AbnormalCont = v.Address
|
|
|
|
|
}
|
|
|
|
|
// util
|
|
|
|
|
// // util
|
|
|
|
|
// rainMap := commonus.MapOut()
|
|
|
|
|
// errdd := json.Unmarshal([]byte(myDepartment.Group), &rainMap)
|
|
|
|
|
var arrAy []int64
|
|
|
|
|
errdd := json.Unmarshal([]byte(myDepartment.Group), &arrAy)
|
|
|
|
|
if errdd == nil {
|
|
|
|
|
if len(arrAy) >= 2 {
|
|
|
|
|
if arrAy[0] == 1 {
|
|
|
|
|
reportStructExceCont.GroupId = arrAy[1]
|
|
|
|
|
isTrues, myDepartments := commonus.GetGroupInfo(arrAy[1])
|
|
|
|
|
if isTrues == true {
|
|
|
|
|
reportStructExceCont.Group = fmt.Sprintf("%s", myDepartments.Name)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
reportStructExceCont.GroupId = arrAy[0]
|
|
|
|
|
isTrues, myDepartments := commonus.GetGroupInfo(arrAy[0])
|
|
|
|
|
if isTrues == true {
|
|
|
|
|
reportStructExceCont.Group = fmt.Sprintf("%s", myDepartments.Name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
reportStructExceCont.IsAbnormal = v.IsDbnormal
|
|
|
|
|
// fmt.Printf("%v--------->%v##################3%v\n", len(arrAy), myDepartment.Group, errdd)
|
|
|
|
|
|
|
|
|
|
// reportStructExceCont.GroupId = myDepartment.Group
|
|
|
|
|
reportStructExceAry = append(reportStructExceAry, reportStructExceCont)
|
|
|
|
|
}
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
|
|
|
|
|
returnData["count"] = len(reportStructExceAry)
|
|
|
|
|
returnData["total"] = count
|
|
|
|
|
returnData["page"] = reportStatistics.Page
|
|
|
|
|
returnData["pageSize"] = reportStatistics.PageSize
|
|
|
|
|
returnData["list"] = reportStructExceAry
|
|
|
|
|
response.Result(0, returnData, "查询成功!", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 未上报人员
|
|
|
|
|
func (h *HealthReportStat) NotReportedPeople(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
|
|
|
|
|
// }
|
|
|
|
|
//获取企业微信员工列表
|
|
|
|
|
weChatList, weChatTrue := commonus.GetMemberList()
|
|
|
|
|
if weChatTrue != true {
|
|
|
|
|
response.Result(103, weChatTrue, "未能获取到企业微信员工数据!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
tadayTime := commonus.GetYesterDay()
|
|
|
|
|
if reportAnswer.Date != "" {
|
|
|
|
|
tadayTime = reportAnswer.Date
|
|
|
|
|
}
|
|
|
|
|
//判断日期是否已经统计
|
|
|
|
|
calCulTime := commonus.DateToTimeStamp(tadayTime + " 12:00:00")
|
|
|
|
|
//获取已上报人员
|
|
|
|
|
var reportInfoAry []locationing.ReportAddress
|
|
|
|
|
reportErr := global.GVA_DB_HealthReport.Where("calcultime = ?", calCulTime).Find(&reportInfoAry).Error
|
|
|
|
|
if reportErr != nil {
|
|
|
|
|
response.Result(104, reportErr, fmt.Sprintf("(%s)还没有上报数据", tadayTime), c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(reportInfoAry) <= 0 {
|
|
|
|
|
response.Result(104, reportErr, fmt.Sprintf("(%s)还没有上报数据", tadayTime), c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var notReportMan []wechat.WechatUsers
|
|
|
|
|
var yesReportMan []wechat.WechatUsers
|
|
|
|
|
for _, weChat_v := range weChatList {
|
|
|
|
|
isPost := true
|
|
|
|
|
for _, report_v := range reportInfoAry {
|
|
|
|
|
if weChat_v.Userid == report_v.Userid {
|
|
|
|
|
isPost = false
|
|
|
|
|
yesReportMan = append(yesReportMan, weChat_v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isPost == true {
|
|
|
|
|
notReportMan = append(notReportMan, weChat_v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
|
|
|
|
|
returnData["notReportMan_len"] = len(notReportMan)
|
|
|
|
|
// returnData["notReportMan"] = notReportMan
|
|
|
|
|
returnData["weChatList_len"] = len(weChatList)
|
|
|
|
|
// returnData["weChatList"] = weChatList
|
|
|
|
|
returnData["yesReportMan_len"] = len(yesReportMan)
|
|
|
|
|
// returnData["yesReportMan"] = yesReportMan
|
|
|
|
|
response.Result(0, returnData, "未上报人员列表!", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取全国风险地区列表(企鹅接口 https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5)
|
|
|
|
|
func (h *HealthReportStat) NationalRiskArea(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
jsondata, isyes := commonus.GetNationalRiskArea()
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
|
|
|
|
|
returnData["isyes"] = isyes
|
|
|
|
|
returnData["jsondata"] = jsondata
|
|
|
|
|
returnData["jsondata_len"] = len(jsondata)
|
|
|
|
|
|
|
|
|
|
response.Result(0, returnData, "全国风险地区列表!", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 测试写入异常人员
|
|
|
|
|
func (h *HealthReportStat) TestMan(c *gin.Context) {
|
|
|
|
|
var reportAnswer location.AbnormalPeople
|
|
|
|
|
c.ShouldBindJSON(&reportAnswer)
|
|
|
|
|
commonus.WriteInMan(reportAnswer.WechatId, "2021-12-04", 1)
|
|
|
|
|
returnData := commonus.MapOut()
|
|
|
|
|
returnData["isyes"] = reportAnswer
|
|
|
|
|
response.Result(0, returnData, "全国风险地区列表!", c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 向相关人员发送信息
|
|
|
|
|
func (h *HealthReportStat) SendRelevantPersonnelTodayMsg(c *gin.Context) {
|
|
|
|
|
tadayTime := commonus.GetToDay() //获取昨日信息
|
|
|
|
|
calCulTime := commonus.DateToTimeStamp(tadayTime + " 09:00:00")
|
|
|
|
|
var reportInfoAry []locationing.ReportAddress //统计表模型
|
|
|
|
|
listErr := global.GVA_DB_HealthReport.Where("calcultime = ? and isabnormal = 2", calCulTime).Find(&reportInfoAry).Error
|
|
|
|
|
if listErr != nil {
|
|
|
|
|
response.Result(106, reportInfoAry, "没有异常人员信息数据!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
//判断报警人是不是为空
|
|
|
|
|
if len(reportInfoAry) > 0 {
|
|
|
|
|
var readBaoJinf []map[string]interface{}
|
|
|
|
|
for _, v := range reportInfoAry {
|
|
|
|
|
callPolice := commonus.MapOut()
|
|
|
|
|
callPolice["id"] = v.Id
|
|
|
|
|
callPolice["userid"] = v.WechatId
|
|
|
|
|
callPolice["province"] = v.Province
|
|
|
|
|
callPolice["city"] = v.City
|
|
|
|
|
callPolice["county"] = v.County
|
|
|
|
|
callPolice["userid"] = v.Userid
|
|
|
|
|
callPolice["addtime"] = v.AddTime
|
|
|
|
|
callPolice["calcultime"] = v.CalCulTime
|
|
|
|
|
callPolice["address"] = v.Address
|
|
|
|
|
callPolice["isabnormal"] = v.IsDbnormal
|
|
|
|
|
callPolice["user_name"] = v.UserName
|
|
|
|
|
callPolice["user_tel"] = v.UserTel
|
|
|
|
|
readBaoJinf = append(readBaoJinf, callPolice)
|
|
|
|
|
}
|
|
|
|
|
//给相关人员发送信息
|
|
|
|
|
sendMsg := sendMessAgeAlarm(calCulTime, readBaoJinf)
|
|
|
|
|
sendMsgMap := commonus.MapOut()
|
|
|
|
|
sendMsgMap["list"] = sendMsg
|
|
|
|
|
fmt.Printf("sendMessAgeAlarm ====> %v\n", sendMsgMap)
|
|
|
|
|
response.Result(0, sendMsgMap, "获取成功", c)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("没有异常人员!")
|
|
|
|
|
response.Result(0, "", "获取成功", c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询
|
|
|
|
|
func (h *HealthReportStat) QueryHealthReport(c *gin.Context) {
|
|
|
|
|
var requestData QueryHealthReportType
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.PageSize == 0 {
|
|
|
|
|
requestData.PageSize = 20
|
|
|
|
|
}
|
|
|
|
|
if requestData.Page <= 0 {
|
|
|
|
|
requestData.Page = 1
|
|
|
|
|
}
|
|
|
|
|
var startTime int64
|
|
|
|
|
var endTime int64
|
|
|
|
|
startTime = 0
|
|
|
|
|
endTime = 0
|
|
|
|
|
if requestData.StartTime != "" {
|
|
|
|
|
startTimeStr := requestData.StartTime + " 00:00:00"
|
|
|
|
|
startTime, _ = commonus.DateToTimeStampEs(startTimeStr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.EndTime != "" {
|
|
|
|
|
endTimeStr := requestData.StartTime + " 23:59:59"
|
|
|
|
|
endTime, _ = commonus.DateToTimeStampEs(endTimeStr)
|
|
|
|
|
} else {
|
|
|
|
|
endTime = time.Now().Unix()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
offSetPage := commonus.CalculatePages(requestData.Page, requestData.PageSize)
|
|
|
|
|
|
|
|
|
|
gormDb := global.GVA_DB_HealthReport.Model(&locationing.ReportAddress{})
|
|
|
|
|
|
|
|
|
|
if startTime != 0 && endTime != 0 {
|
|
|
|
|
gormDb = gormDb.Where("`calcultime` BETWEEN ? AND ?", startTime, endTime)
|
|
|
|
|
} else if startTime != 0 && endTime == 0 {
|
|
|
|
|
gormDb = gormDb.Where("`calcultime` >= ?", startTime)
|
|
|
|
|
} else if startTime == 0 && endTime != 0 {
|
|
|
|
|
gormDb = gormDb.Where("`calcultime` <= ?", endTime)
|
|
|
|
|
}
|
|
|
|
|
gormDb = gormDb.Where("(`city` LIKE ? OR `city` LIKE ?)", "%济南%", "%聊城%")
|
|
|
|
|
|
|
|
|
|
var total int64
|
|
|
|
|
totalErr := gormDb.Count(&total).Error
|
|
|
|
|
if totalErr != nil {
|
|
|
|
|
total = 0
|
|
|
|
|
}
|
|
|
|
|
var reportAdd []locationing.ReportAddress
|
|
|
|
|
assessListerr := gormDb.Limit(requestData.PageSize).Offset(offSetPage).Order("id desc").Find(&reportAdd).Error
|
|
|
|
|
if assessListerr != nil {
|
|
|
|
|
response.Result(102, assessListerr, "数据获取失败!", c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
countSum := len(reportAdd)
|
|
|
|
|
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, reportAdd)
|
|
|
|
|
response.Result(0, printData, "查询成功!", c)
|
|
|
|
|
}
|