From b1d7efd8c4ab9c4bf56f62e636a358a5182c09bf Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期六, 28 九月 2024 23:43:58 +0800
Subject: [PATCH] fix db colummn

---
 rule/engine.go |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/rule/engine.go b/rule/engine.go
index 8d3322f..95fdafd 100644
--- a/rule/engine.go
+++ b/rule/engine.go
@@ -17,19 +17,17 @@
 
 	// 閬嶅巻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)
 			// 澶勭悊鏃堕棿瑙f瀽閿欒
 			// 鍙互閫夋嫨璺宠繃璇ユ潯鏁版嵁鎴栬�呰褰曟棩蹇�
 			continue
 		}
+
 		// 璁$畻LastAppearanceTime鍜孋reateAt璺濈褰撳墠鏃ユ湡鐨勫ぉ鏁�
 		daysSinceLastAppearance := currentDate.Sub(lastAppearanceDate).Hours() / 24
 		daysSinceCreateAt := currentDate.Sub(createdAt).Hours() / 24
@@ -63,8 +61,8 @@
 		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,
 		})
@@ -84,7 +82,7 @@
 //	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 {
@@ -203,21 +201,21 @@
 				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)
@@ -230,21 +228,21 @@
 					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)

--
Gitblit v1.8.0