update
This commit is contained in:
80
cmd/main.go
80
cmd/main.go
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
prompt2 "wasm-go/internal/prompt"
|
||||
|
||||
"wasm-go/internal/api"
|
||||
"wasm-go/internal/excel"
|
||||
@@ -73,13 +74,7 @@ func main() {
|
||||
|
||||
fmt.Println("\n✅ 所有工作表已转换为Markdown格式!")
|
||||
|
||||
// 读取quarterly1.txt的prompt
|
||||
promptBytes, err := os.ReadFile("./quarterly1.txt")
|
||||
if err != nil {
|
||||
fmt.Printf("❌ 读取quarterly1.txt失败: %v\n", err)
|
||||
return
|
||||
}
|
||||
prompt := string(promptBytes)
|
||||
prompt := prompt2.Quarterly1Prompt
|
||||
|
||||
// 合并prompt和markdown表格
|
||||
finalPrompt := fmt.Sprintf("%s\n\n%s", prompt, allMarkdownTables.String())
|
||||
@@ -117,7 +112,7 @@ func main() {
|
||||
|
||||
// 创建税务健康服务客户端
|
||||
// 注意:这里需要替换为实际的用户ID和私钥
|
||||
taxHealthService := api.NewTaxHealthService("1560142251348287489", "")
|
||||
taxHealthService := api.NewTaxHealthService("1554047490758508546", "00d502fcac7a2b0e227751cd6d8b0c725c55f71adcaccc6a50c4d63c73db6c8add")
|
||||
|
||||
// 将解析的JSON解析为map结构
|
||||
var companyData map[string]interface{}
|
||||
@@ -125,13 +120,14 @@ func main() {
|
||||
fmt.Printf("❌ 解析JSON数据失败: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 构建税务评估请求
|
||||
request := api.TaxEvalRequest{
|
||||
ReqNo: fmt.Sprintf("REQ%v", time.Now().Unix()), // 使用时间戳生成请求号
|
||||
Detail: api.TaxEvalDetail{
|
||||
CompanyName: "企业名称", // 可以从数据中提取公司名称
|
||||
CompanyName: "郑州惠兴", // 可以从数据中提取公司名称
|
||||
Data: companyData,
|
||||
Period: "Q1",
|
||||
Year: "2024",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -145,6 +141,70 @@ func main() {
|
||||
fmt.Println("\n========== 税务健康API反馈结果 ==========")
|
||||
fmt.Printf("API响应: %+v\n", taxResponse)
|
||||
fmt.Println("======================================")
|
||||
|
||||
// 检查是否成功获取订单号
|
||||
if taxResponse.Code != 200 || taxResponse.Data.OrderNo == "" {
|
||||
fmt.Printf("❌ 税务健康API调用失败或未返回订单号: %+v\n", taxResponse)
|
||||
return
|
||||
}
|
||||
|
||||
orderNo := taxResponse.Data.OrderNo
|
||||
fmt.Printf("\n🔄 获取到订单号: %s,开始轮询查询结果...\n", orderNo)
|
||||
|
||||
// 轮询查询结果,最多等待5分钟(60次 * 5秒)
|
||||
maxAttempts := 60
|
||||
attempt := 0
|
||||
|
||||
for attempt < maxAttempts {
|
||||
// 查询税务评估结果
|
||||
queryResponse, err := taxHealthService.QueryTaxEvalResult(orderNo)
|
||||
if err != nil {
|
||||
fmt.Printf("❌ 查询税务评估结果失败: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\n========== 查询结果响应 ==========\n")
|
||||
fmt.Printf("状态码: %d\n", queryResponse.Code)
|
||||
fmt.Printf("消息: %s\n", queryResponse.Message)
|
||||
fmt.Printf("订单状态: %d\n", queryResponse.Data.Status)
|
||||
fmt.Printf("================================\n")
|
||||
|
||||
// 根据状态码判断处理结果
|
||||
switch queryResponse.Data.Status {
|
||||
case 99: // 执行成功
|
||||
fmt.Println("\n✅ 税务评估已完成!")
|
||||
fmt.Printf("结果文件地址: %v\n", queryResponse.Data.Detail.Files)
|
||||
|
||||
// 如果有错误信息也显示
|
||||
if queryResponse.Data.Detail.Error != "" {
|
||||
fmt.Printf("警告信息: %s\n", queryResponse.Data.Detail.Error)
|
||||
}
|
||||
|
||||
// 这里可以进一步处理结果文件,比如下载文件
|
||||
for _, fileURL := range queryResponse.Data.Detail.Files {
|
||||
fmt.Printf("文件URL: %s\n", fileURL)
|
||||
// TODO: 实现文件下载逻辑
|
||||
}
|
||||
|
||||
return // 完成任务,退出程序
|
||||
case 0: // 正在执行
|
||||
fmt.Printf("⏳ 任务仍在处理中... (%d/%d)\n", attempt+1, maxAttempts)
|
||||
time.Sleep(5 * time.Second) // 等待5秒后再次查询
|
||||
attempt++
|
||||
case -1: // 无效订单
|
||||
fmt.Printf("❌ 订单无效: %s\n", queryResponse.Data.Detail.Error)
|
||||
return
|
||||
case 98: // 执行失败
|
||||
fmt.Printf("❌ 任务执行失败: %s\n", queryResponse.Data.Detail.Error)
|
||||
return
|
||||
default:
|
||||
fmt.Printf("⚠️ 未知状态码: %d\n", queryResponse.Data.Status)
|
||||
time.Sleep(5 * time.Second)
|
||||
attempt++
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("\n⏰ 查询超时,建议稍后手动查询结果")
|
||||
}
|
||||
|
||||
// extractJSONFromResponse 从LLM响应中提取JSON内容
|
||||
|
||||
Reference in New Issue
Block a user