ifms_go/test/trace_test.go
2025-06-10 17:50:46 +08:00

46 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package test
import (
"context"
"fmt"
"ifms/internal/mods/trace/dal"
"ifms/internal/mods/trace/schema"
"ifms/internal/wirex"
"testing"
"time"
)
func TestPlan(t *testing.T) {
db, _, err := wirex.InitDB(context.Background())
if err != nil {
fmt.Println(err)
return
}
plan := dal.BreedingPlan{DB: db}
param := schema.BreedingPlanForm{BreedingVariety: "test", FishSource: "test", FishStage: "test"}
list, err := plan.QueryList(context.Background(), param)
if err != nil {
t.Fatal(err)
}
fmt.Println(len(list))
}
func TestBatchNum(t *testing.T) {
var todayList []dal.BreedingPlan
i := len(todayList)
// 获取当前时间
now := time.Now()
// 格式化年份为两位数(例如 2025 -> 25
year := now.Year() % 100
yearStr := fmt.Sprintf("%02d", year)
// 格式化日期为 "0406" 的格式
dateStr := now.Format("0102")
// 格式化序号为两位数
sequenceStr := fmt.Sprintf("%02d", i+1)
// 拼接最终的字符串
fmt.Println(fmt.Sprintf("%s年%s%s%s批", yearStr, "鲈鱼", dateStr, sequenceStr))
}