| | |
| | | |
| | | import ( |
| | | "basic.com/valib/logger.git" |
| | | "encoding/csv" |
| | | "fmt" |
| | | "os" |
| | | "ruleModelEngine/cache" |
| | | "ruleModelEngine/config" |
| | | "ruleModelEngine/data" |
| | |
| | | // return true |
| | | //} |
| | | |
| | | func writeCSV(filename string, data []db.CaptureInfo) error { |
| | | file, err := os.Create(filename) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | defer file.Close() |
| | | |
| | | writer := csv.NewWriter(file) |
| | | defer writer.Flush() |
| | | |
| | | // Write header |
| | | header := []string{"档案编号", "抓拍天数", "过夜天数", "分类", "常用地址"} |
| | | if err := writer.Write(header); err != nil { |
| | | return err |
| | | } |
| | | |
| | | // Write data |
| | | for _, info := range data { |
| | | record := []string{ |
| | | info.DocumentNumber, |
| | | strconv.Itoa(info.CaptureDays), |
| | | strconv.Itoa(info.OvernightStays), |
| | | info.Status, |
| | | info.FrequentAddress, |
| | | } |
| | | if err := writer.Write(record); err != nil { |
| | | return err |
| | | } |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func executeEnteringButNotLeaving(communityId string) { |
| | | //进出异常布控任务,暂时归类到标签计算部分 |
| | | //fmt.Println("进出异常开始入口!!!!!!") |
| | |
| | | |
| | | cameraIds := make([]string, 0) |
| | | for _, deviceInfo := range cache.Device { |
| | | if deviceInfo.AreaID == communityId && deviceInfo.BuildingType == db.BuildingTypeMixedUse { |
| | | if deviceInfo.CommunityID == communityId && deviceInfo.BuildingType == db.BuildingTypeMixedUse { |
| | | cameraIds = append(cameraIds, deviceInfo.DeviceCode) |
| | | } |
| | | } |
| | |
| | | logger.Error("GetAllData Error", err) |
| | | } |
| | | fmt.Println("ruleInfo: ", ruleInfo) |
| | | statusNo := make(map[string]int) |
| | | statusNo["stranger"] = db.StatusStranger |
| | | statusNo["visitor"] = db.StatusVisitor |
| | | statusNo["resident"] = db.StatusResident |
| | | communityIDs, err := db.GetCommunityIDs() |
| | | fmt.Println("communityIDs:", communityIDs) |
| | | if err != nil { |
| | | logger.Error("GetCommunityIDs Error", err) |
| | | } |
| | | labeManage, err := db.GetLabelManageIdentity(2) |
| | | labeManage, err := db.GeIdentityLabels() |
| | | if err != nil { |
| | | logger.Error("GetDBPersonStatusData Error", err) |
| | | } |
| | |
| | | //业务逻辑 |
| | | } |
| | | fmt.Println("社区档案总条数:", len(documentNumberIDS)) |
| | | |
| | | captureInfos := make([]db.CaptureInfo, 0) |
| | | batchSize := config.Elastic.BatchSize |
| | | //fmt.Println(batchSize) |
| | |
| | | } |
| | | captureInfos[i].Age = age |
| | | captureInfos[i].FrequentAddress = data.GetFrequentAddress(captureInfos[i].CaptureDetail) |
| | | |
| | | //fmt.Println("CaptureDetail: ", captureInfos[i].DocumentNumber, captureInfos[i].CaptureDays, captureInfos[i].CaptureDetail) |
| | | } |
| | | //err1 := writeCSV("report.csv", captureInfos) |
| | | //if err != nil { |
| | | // fmt.Println(err1) |
| | | //} |
| | | //continue |
| | | //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) |
| | | identity, attribute := CreateLinearModel(captureInfos, communityID, 2.68, identity.ValidDays, identity.ID) |
| | | |
| | | errIdentity := db.UpdateDBPersonLabel(identity) |
| | | if errIdentity != nil { |
| | |
| | | |
| | | //continue |
| | | |
| | | postCaptureInfos := data.ProcessData(captureInfos, personStatusList, ruleInfo, communityID) |
| | | postCaptureInfos := data.ProcessData(captureInfos, personStatusList, ruleInfo, statusNo, communityID) |
| | | for _, inf := range postCaptureInfos { |
| | | fmt.Println("---->pause prepare: capture ", inf.DocumentNumber, inf.Status, inf.FrequentAddress) |
| | | //return |