| | |
| | | |
| | | // 遍历Resident结构体切片 |
| | | for _, resident := range residents { |
| | | //fmt.Println("gogogogo!!!!!!!!!!!!!!!!!!!!!!!!!!!") |
| | | // 将字符串类型的时间转换为time.Time类型,并只保留年月日 |
| | | lastAppearanceTime := time.Unix(resident.LastAppearanceTime, 0) |
| | | lastAppearanceDate := time.Date(lastAppearanceTime.Year(), lastAppearanceTime.Month(), lastAppearanceTime.Day(), 0, 0, 0, 0, lastAppearanceTime.Location()) |
| | | //lastAppearanceTime, err := time.Parse("2006-01-02", resident.LastAppearanceTime) |
| | | datePart := strings.Split(resident.CreateAt, "T")[0] |
| | | createdAt, err := time.Parse("2006-01-02", datePart) |
| | | createdAt, err := time.Parse("2006-01-02", resident.CreateAt) |
| | | if err != nil { |
| | | fmt.Println(err) |
| | | // 处理时间解析错误 |
| | | // 可以选择跳过该条数据或者记录日志 |
| | | continue |
| | | } |
| | | |
| | | // 计算LastAppearanceTime和CreateAt距离当前日期的天数 |
| | | daysSinceLastAppearance := currentDate.Sub(lastAppearanceDate).Hours() / 24 |
| | | daysSinceCreateAt := currentDate.Sub(createdAt).Hours() / 24 |
| | |
| | | moveInout = append(moveInout, db.MoveInout{ |
| | | DocumentNumber: resident.DocumentNumber, |
| | | CommunityID: resident.CommunityId, |
| | | MoveInDate: createdAt, // 存储年月日 |
| | | MoveOutDate: &lastAppearanceDate, // 存储年月日 |
| | | MoveInDate: createdAt.Format("2006-01-02"), // 存储年月日 |
| | | MoveOutDate: lastAppearanceDate.Format("2006-01-02"), // 存储年月日 |
| | | MoveType: moveType, |
| | | Status: status, |
| | | }) |
| | |
| | | // return true, nil |
| | | //} |
| | | |
| | | func CreateLinearModel(personInfos []db.CaptureInfo, communityID string, threshold float64, validDays int, labelId int) ([]db.Identity, []db.CaptureInfo) { |
| | | func CreateLinearModel(personInfos []db.CaptureInfo, communityID string, threshold float64, validDays int, labelId string) ([]db.Identity, []db.CaptureInfo) { |
| | | identity := make([]db.Identity, 0) |
| | | captureInfo := make([]db.CaptureInfo, 0) |
| | | for _, info := range personInfos { |
| | |
| | | //fmt.Println(addrDataArray) |
| | | //fmt.Println("threshold: ", threshold) |
| | | //fmt.Println("stdDev: ", stdDev) |
| | | info.Status = "fieldworker" |
| | | //info.Status = "fieldworker" |
| | | info.Status = "visitor" |
| | | captureInfo = append(captureInfo, info) |
| | | identity = append(identity, db.Identity{ |
| | | CommunityID: communityID, |
| | |
| | | identity = append(identity, db.Identity{ |
| | | CommunityID: communityID, |
| | | DocumentNumber: info.DocumentNumber, |
| | | LabelId: labelManage[lIndex].Id, |
| | | LabelId: labelManage[lIndex].ID, |
| | | ExpireTime: GetCurrentDateAddDaysTimestamp(labelManage[lIndex].ValidDays)}) |
| | | } else if info.Age >= 23 && info.Age <= 60 { |
| | | lIndex := labelIndexMap["上班族"] |
| | | identity = append(identity, db.Identity{ |
| | | CommunityID: communityID, |
| | | DocumentNumber: info.DocumentNumber, |
| | | LabelId: labelManage[lIndex].Id, |
| | | LabelId: labelManage[lIndex].ID, |
| | | ExpireTime: GetCurrentDateAddDaysTimestamp(labelManage[lIndex].ValidDays)}) |
| | | } else if info.Age > 60 { |
| | | lIndex := labelIndexMap["离退休人员"] |
| | | identity = append(identity, db.Identity{ |
| | | CommunityID: communityID, |
| | | DocumentNumber: info.DocumentNumber, |
| | | LabelId: labelManage[lIndex].Id, |
| | | LabelId: labelManage[lIndex].ID, |
| | | ExpireTime: GetCurrentDateAddDaysTimestamp(labelManage[lIndex].ValidDays)}) |
| | | } |
| | | //fmt.Println("上班族", info.DocumentNumber, info.Age, countMaxRows, colS, colE) |
| | |
| | | identity = append(identity, db.Identity{ |
| | | CommunityID: communityID, |
| | | DocumentNumber: info.DocumentNumber, |
| | | LabelId: labelManage[lIndex].Id, |
| | | LabelId: labelManage[lIndex].ID, |
| | | ExpireTime: GetCurrentDateAddDaysTimestamp(labelManage[lIndex].ValidDays)}) |
| | | } else if info.Age >= 23 && info.Age <= 60 { |
| | | lIndex := labelIndexMap["上班族"] |
| | | identity = append(identity, db.Identity{ |
| | | CommunityID: communityID, |
| | | DocumentNumber: info.DocumentNumber, |
| | | LabelId: labelManage[lIndex].Id, |
| | | LabelId: labelManage[lIndex].ID, |
| | | ExpireTime: GetCurrentDateAddDaysTimestamp(labelManage[lIndex].ValidDays)}) |
| | | } else if info.Age > 60 { |
| | | lIndex := labelIndexMap["离退休人员"] |
| | | identity = append(identity, db.Identity{ |
| | | CommunityID: communityID, |
| | | DocumentNumber: info.DocumentNumber, |
| | | LabelId: labelManage[lIndex].Id, |
| | | LabelId: labelManage[lIndex].ID, |
| | | ExpireTime: GetCurrentDateAddDaysTimestamp(labelManage[lIndex].ValidDays)}) |
| | | } |
| | | //fmt.Println("上班族", info.DocumentNumber, info.Age, countMaxRows, colS, colE) |