| | |
| | | "ruleModelEngine/db" |
| | | "ruleModelEngine/task" |
| | | "strconv" |
| | | "time" |
| | | ) |
| | | |
| | | // |
| | |
| | | cameraIds = append(cameraIds, deviceInfo.DeviceCode) |
| | | } |
| | | } |
| | | |
| | | if len(cameraIds) == 0 { |
| | | logger.Info("不存在商住楼设备:", cameraIds) |
| | | return |
| | |
| | | } |
| | | fmt.Println("ruleInfo: ", ruleInfo) |
| | | communityIDs, err := db.GetCommunityIDs() |
| | | //fmt.Println("communityIDs:", communityIDs) |
| | | fmt.Println("communityIDs:", communityIDs) |
| | | if err != nil { |
| | | logger.Error("GetCommunityIDs Error", err) |
| | | } |
| | |
| | | //fmt.Println(labeManage) |
| | | for _, communityID := range communityIDs { |
| | | executeEnteringButNotLeaving(communityID) |
| | | |
| | | //万全社区 |
| | | //if communityID != "50010101010000001001" { |
| | | // continue |
| | | //} |
| | | fmt.Println("communityID: ", communityID) |
| | | //continue |
| | | now := time.Now() |
| | | timeThresholdDay := now.AddDate(0, 0, -config.Api.TimeThreshold) |
| | | timeThresholdDayZeroTime := time.Date(timeThresholdDay.Year(), timeThresholdDay.Month(), timeThresholdDay.Day(), 0, 0, 0, 0, timeThresholdDay.Location()).Unix() |
| | | fmt.Println("比对时间戳:", timeThresholdDayZeroTime) |
| | | //查询社区内人员档案,方便数据更新 |
| | | personStatusList, err := db.QueryPersonStatusWithPagination(communityID, 30) |
| | | personStatusList, err := db.QueryPersonStatusWithPagination(communityID, timeThresholdDayZeroTime) |
| | | if err != nil { |
| | | logger.Error("QueryPersonStatusWithPagination err: ", err) |
| | | } |
| | | // |
| | | |
| | | documentNumberIDS := make([]string, 0) |
| | | for _, personStatus := range personStatusList { |
| | |
| | | documentNumberIDS = append(documentNumberIDS, personStatus.DocumentNumber) |
| | | //业务逻辑 |
| | | } |
| | | //fmt.Println("len(documentNumberIDS)", len(documentNumberIDS)) |
| | | fmt.Println("社区档案总条数:", len(documentNumberIDS)) |
| | | captureInfos := make([]db.CaptureInfo, 0) |
| | | batchSize := config.Elastic.BatchSize |
| | | //fmt.Println(batchSize) |
| | |
| | | } |
| | | batch := documentNumberIDS[i:end] |
| | | //fmt.Println("batch: ", batch) |
| | | batchCaptureInfos, err := db.Query1MDataByCommunityId(communityID, batch, 30) |
| | | batchCaptureInfos, err := db.QueryByTimeThresholdDataByCommunityId(communityID, batch, config.Api.TimeThreshold) |
| | | if err != nil { |
| | | logger.Error("Query1MDataByCommunityId Error", err) |
| | | } |
| | |
| | | fmt.Println("共计有档案数据条数为:", len(captureInfos)) |
| | | //补全分析所需数据 |
| | | for i := range captureInfos { |
| | | |
| | | captureDays, overnightCount := data.CalculateCaptureDays(captureInfos[i].CaptureDetail) |
| | | captureInfos[i].CaptureDays = captureDays |
| | | captureInfos[i].OvernightStays = overnightCount |
| | |
| | | } |
| | | //fmt.Println("residentCount: ", residentCount) |
| | | //fmt.Println("captureInfosQ: ", captureInfos) |
| | | |
| | | for _, identity := range labeManage { |
| | | switch identity.Name { |
| | | case "服务人员": |
| | | identity, attribute := CreateLinearModel(captureInfos, communityID, 2.68, identity.ValidDays, identity.Id) |
| | | |
| | | errIdentity := db.UpdateDBPersonLabel(identity) |
| | | if errIdentity != nil { |
| | | logger.Error("UpdateDBPersonLabel Error", errIdentity) |
| | | } |
| | | |
| | | captureInfos = attribute |
| | | |
| | | } |
| | | } |
| | | |
| | | identity := CreateProcessModel(captureInfos, 30, communityID, labeManage) |
| | | errIdentity := db.UpdateDBPersonLabel(identity) |
| | | if errIdentity != nil { |
| | | logger.Error("UpdateDBPersonLabel Error", errIdentity) |
| | | } |
| | | |
| | | //continue |
| | | |
| | | postCaptureInfos := data.ProcessData(captureInfos, personStatusList, ruleInfo, communityID) |
| | | /*for _, inf := range postCaptureInfos { |
| | | fmt.Println("inf: ", inf.DocumentNumber, inf.Status, inf.FrequentAddress, inf.LastAppearanceStatusTime) |
| | | }*/ |
| | | //fmt.Println("共更新档案数:", len(postCaptureInfos)) |
| | | for _, inf := range postCaptureInfos { |
| | | fmt.Println("---->pause prepare: capture ", inf.DocumentNumber, inf.Status, inf.FrequentAddress) |
| | | //return |
| | | //time.Sleep(time.Second * 10) |
| | | |
| | | //fmt.Println("inf: ", inf.DocumentNumber, inf.Status, inf.FrequentAddress, inf.LastAppearanceStatusTime) |
| | | } |
| | | fmt.Println("共更新档案数:", len(postCaptureInfos)) |
| | | //fmt.Println("----->captureInfos: ", len(captureInfos)) |
| | | //continue |
| | | UpdatePersonInfoErr := db.UpdatePersonInfo(postCaptureInfos, communityID) |