From 8286117e3435781401bc6d722095fa033c0704b2 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期四, 05 九月 2024 13:39:33 +0800
Subject: [PATCH] 补充地址计算规则

---
 rule/service.go |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/rule/service.go b/rule/service.go
index ebd6e0d..0b45822 100644
--- a/rule/service.go
+++ b/rule/service.go
@@ -2,7 +2,9 @@
 
 import (
 	"basic.com/valib/logger.git"
+	"encoding/csv"
 	"fmt"
+	"os"
 	"ruleModelEngine/cache"
 	"ruleModelEngine/config"
 	"ruleModelEngine/data"
@@ -30,6 +32,39 @@
 //	}
 //	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{"妗f缂栧彿", "鎶撴媿澶╂暟", "杩囧澶╂暟", "鍒嗙被", "甯哥敤鍦板潃"}
+	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) {
 	//杩涘嚭寮傚父甯冩帶浠诲姟锛屾殏鏃跺綊绫诲埌鏍囩璁$畻閮ㄥ垎
@@ -170,8 +205,13 @@
 			}
 			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)

--
Gitblit v1.8.0