diff --git a/gin_server_admin/api/v1/examtestpage/healthreportstat.go b/gin_server_admin/api/v1/examtestpage/healthreportstat.go index b13a0c4..9fe580d 100644 --- a/gin_server_admin/api/v1/examtestpage/healthreportstat.go +++ b/gin_server_admin/api/v1/examtestpage/healthreportstat.go @@ -203,6 +203,7 @@ func (h *HealthReportStat) PostReportAnswerListAll(c *gin.Context) { // fmt.Printf("时间是=》%v\n", reportAnswer.Date) } //判断日期是否已经统计 + sendCalCulTime := tadayTime + " 12:00:00" calCulTime := commonus.DateToTimeStamp(tadayTime + " 12:00:00") var reportInfo locationing.ReportAddress errInfo := global.GVA_DB_HealthReport.Where("calcultime = ?", calCulTime).First(&reportInfo).Error @@ -235,7 +236,7 @@ func (h *HealthReportStat) PostReportAnswerListAll(c *gin.Context) { nationalRiskLevel, riskIsTrue := commonus.GetNationalRiskArea() for i := 0; i < dateExcept; i++ { myStatisWg.Add(1) - go dataStruct.getUserAnswerList(reportAnswer.JobId, tadayTime, i, 100, legalAreaList, nationalRiskLevel, riskIsTrue) + go dataStruct.getUserAnswerList(reportAnswer.JobId, tadayTime, sendCalCulTime, i, 100, legalAreaList, nationalRiskLevel, riskIsTrue) } myStatisWg.Wait() @@ -331,7 +332,7 @@ func sendMessAgeAlarm(calCulTime int64, alarmUser []map[string]interface{}) { sendImgMsg.News.Articles = sendContAry sendImgMsg.DuplicateCheckInterval = 1800 callbakcMsg, isTrueCall, callBackCont := sendImgMsg.SendImgMessage() - fmt.Printf("发送信息返回:%v-----------%v----------->%v\n", callbakcMsg, isTrueCall, callBackCont) + fmt.Printf("发送信息返回:%v-----------%v----------->%v\n", string(callbakcMsg), isTrueCall, callBackCont) } else { fmt.Println("没有要通知的人") } @@ -343,10 +344,11 @@ func sendMessAgeAlarm(calCulTime int64, alarmUser []map[string]interface{}) { } //获取上报地址异常的数据人员信息 -func (d *dataLockStatistics) getUserAnswerList(jobid, tadayTime string, page int, pageSize int64, legalAreaList []locationing.LegalArea, regionalRiskLevel []commonus.RegionalRiskLevel, isRiskYes bool) { +func (d *dataLockStatistics) getUserAnswerList(jobid, tadayTime, calCulTime string, page int, pageSize int64, legalAreaList []locationing.LegalArea, regionalRiskLevel []commonus.RegionalRiskLevel, isRiskYes bool) { d.mutext.Lock() defer d.mutext.Unlock() - calCulTime := tadayTime + " 12:00:00" + // calCulTime := tadayTime + // calCulTime := tadayTime + " 12:00:00" // fmt.Printf("page ------------> %v\n", page) // timeStamp := commonus.DateToTimeStamp(calCulTime) // var judgeWriteInfoUser locationing.ReportAddress @@ -652,3 +654,78 @@ func (h *HealthReportStat) LookNoticeUser(c *gin.Context) { } response.Result(0, reportAnswerSet, "获取成功!", c) } + +func (h *HealthReportStat) PostReportAnswerListTodayAll(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.GetToDay() + if reportAnswer.Date != "" { + tadayTime = reportAnswer.Date + // fmt.Printf("时间是=》%v\n", reportAnswer.Date) + } + //判断日期是否已经统计 + sendCalCulTime := tadayTime + " 09:00:00" + calCulTime := commonus.DateToTimeStamp(sendCalCulTime) + + var reportInfo locationing.ReportAddress + errInfo := global.GVA_DB_HealthReport.Where("calcultime = ?", calCulTime).First(&reportInfo).Error + if errInfo == nil { + response.Result(102, tadayTime, "该日期已经统计", c) + return + } + //获取围栏地址 + var legalAreaList []locationing.LegalArea + addressListErr := global.GVA_DB_HealthReport.Where("la_state = ?", 1).Find(&legalAreaList).Error + + if addressListErr != nil { + fmt.Printf("未设置围栏地址:%v\n", addressListErr) + } + // return + strucr, isTrue, _, msg := commonus.GetReportJobInfo(reportAnswer.JobId, tadayTime) + //strucr.JobInfo.FinishCnt + if isTrue != true { + response.Result(103, err, msg, c) + return + } + dateExcept := strucr.JobInfo.FinishCnt / 100 + dateSurplus := strucr.JobInfo.FinishCnt % 100 + if dateSurplus > 0 { + dateExcept = dateExcept + 1 + } + // fmt.Printf("%v****************%v-------->%v\n", strucr.JobInfo.FinishCnt, dateExcept, dateSurplus) + var dataStruct dataLockStatistics + //获取全国风险等级 + nationalRiskLevel, riskIsTrue := commonus.GetNationalRiskArea() + for i := 0; i < dateExcept; i++ { + myStatisWg.Add(1) + go dataStruct.getUserAnswerList(reportAnswer.JobId, tadayTime, sendCalCulTime, i, 100, legalAreaList, nationalRiskLevel, riskIsTrue) + } + myStatisWg.Wait() + + returData := commonus.MapOut() + readDataMap, readBaoJinf := dataStruct.readMyDayData() + + returData["alenda"] = len(readDataMap) + returData["alendalist"] = readDataMap + + returData["baojing"] = len(readBaoJinf) + returData["baojinglist"] = readBaoJinf + + //计算未上报人员 + // CalculationNotReport(tadayTime, calCulTime, readDataMap) + //判断报警人是不是超员 + if len(readBaoJinf) > 0 { + //给相关人员发送信息 + // sendMessAgeAlarm(calCulTime, readBaoJinf) + } + + response.Result(0, returData, msg, c) +} diff --git a/gin_server_admin/api/v1/examtestpage/healthreportstathand.go b/gin_server_admin/api/v1/examtestpage/healthreportstathand.go index 7b693c4..ca29d39 100644 --- a/gin_server_admin/api/v1/examtestpage/healthreportstathand.go +++ b/gin_server_admin/api/v1/examtestpage/healthreportstathand.go @@ -458,3 +458,40 @@ func (h *HealthReportStat) TestMan(c *gin.Context) { 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) + } + //给相关人员发送信息 + sendMessAgeAlarm(calCulTime, readBaoJinf) + + } else { + fmt.Println("没有异常人员!") + } +} diff --git a/gin_server_admin/main.go b/gin_server_admin/main.go index 3729efd..0b95886 100644 --- a/gin_server_admin/main.go +++ b/gin_server_admin/main.go @@ -83,6 +83,8 @@ func main() { if global.GVA_DB_Performanceappraisal != nil { fmt.Printf("%v==>数据库mysqlApprovalProcess初始化成功\n", global.GVA_DB_Performanceappraisal) } + + // fmt.Printf("WEiXin------>%v===>%v----->%v----->%v\n", global.GVA_CONFIG.WorkWechatId, global.GVA_CONFIG.WorkWechatSchool, global.GVA_CONFIG.WorkWechatMailList, global.GVA_CONFIG.WorkHealthReport) // fmt.Printf("jkskd => %v===>%v----->%v\n", global.GVA_CONFIG.MyConfig.AppKey, global.GVA_CONFIG.MyConfig.Visit, global.GVA_CONFIG) // fmt.Printf("%v===>%v----->%v\n", global.GVA_CONFIG.WorkWechatIds, global.GVA_CONFIG.WorkWechatSchools, global.GVA_CONFIG.WorkWechatMailLists)MysqlHealthReportDate core.RunWindowsServer() diff --git a/gin_server_admin/router/examtestpage/healthreporthandle.go b/gin_server_admin/router/examtestpage/healthreporthandle.go index f563c2a..1e90b77 100644 --- a/gin_server_admin/router/examtestpage/healthreporthandle.go +++ b/gin_server_admin/router/examtestpage/healthreporthandle.go @@ -36,6 +36,9 @@ func (g *GroupHandleRouter) InitHealthReporRouter(Router *gin.RouterGroup) (R gi groupCodeRouter.POST("/testman", authorityApi.TestMan) //测试 + groupCodeRouter.POST("/postreportanswerlisttodayall", authorityApi.PostReportAnswerListTodayAll) //获取当日9点之前全部上报人员 + groupCodeRouter.GET("/postreportanswerlisttodayall", authorityApi.PostReportAnswerListTodayAll) //获取当日9点之前全部上报人员 + groupCodeRouter.POST("/sendrelevantpersonneltodaymsg", authorityApi.SendRelevantPersonnelTodayMsg) //向相关人员发送信息当日9点 } return groupCodeRouter }