feat: 优化多个组件的高度设置,确保更好的用户体验;更新交易记录控制器以处理智能分类结果
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 28s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 28s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
This commit is contained in:
@@ -211,7 +211,7 @@ public class BudgetService(
|
|||||||
|
|
||||||
result.Limit = totalLimit;
|
result.Limit = totalLimit;
|
||||||
result.Current = totalCurrent;
|
result.Current = totalCurrent;
|
||||||
result.Rate = totalLimit > 0 ? (totalCurrent / totalLimit) * 100 : 0;
|
result.Rate = totalLimit > 0 ? totalCurrent / totalLimit * 100 : 0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,9 +119,14 @@ public class SmartHandleService(
|
|||||||
|
|
||||||
输出格式要求(强制):
|
输出格式要求(强制):
|
||||||
- 请使用 NDJSON(每行一个独立的 JSON 对象,末尾以换行符分隔),不要输出数组。
|
- 请使用 NDJSON(每行一个独立的 JSON 对象,末尾以换行符分隔),不要输出数组。
|
||||||
- 每行的JSON格式严格为:{"reason": "交易摘要", "type": 0, "classify": "分类名称"}
|
- 每行的JSON格式严格为:
|
||||||
|
{
|
||||||
|
"reason": "交易摘要",
|
||||||
|
"type": Number, // 交易类型,0=支出,1=收入,2=不计入收支
|
||||||
|
"classify": "分类名称"
|
||||||
|
}
|
||||||
- 不要输出任何解释性文字、编号、标点或多余的文本
|
- 不要输出任何解释性文字、编号、标点或多余的文本
|
||||||
- 如果无法判断分类,请将 "classify" 设为 "其他",并确保仍然输出 JSON 行
|
- 如果无法判断分类,请不要输出改行的JSON对象
|
||||||
|
|
||||||
只输出按行的JSON对象(NDJSON),不要有其他文字说明。
|
只输出按行的JSON对象(NDJSON),不要有其他文字说明。
|
||||||
""";
|
""";
|
||||||
@@ -151,7 +156,12 @@ public class SmartHandleService(
|
|||||||
{
|
{
|
||||||
if (sendedIds.Add(id))
|
if (sendedIds.Add(id))
|
||||||
{
|
{
|
||||||
var resultJson = JsonSerializer.Serialize(new { id, result.Classify, result.Type });
|
var resultJson = JsonSerializer.Serialize(new
|
||||||
|
{
|
||||||
|
id,
|
||||||
|
result.Classify,
|
||||||
|
result.Type
|
||||||
|
});
|
||||||
chunkAction(("data", resultJson));
|
chunkAction(("data", resultJson));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { showToast } from 'vant'
|
import { showToast } from 'vant'
|
||||||
|
import { useAuthStore } from '@/stores/auth'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账单导入相关 API
|
* 账单导入相关 API
|
||||||
@@ -21,7 +22,8 @@ export const uploadBillFile = (file, type) => {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data',
|
||||||
|
Authorization: `Bearer ${useAuthStore().token || ''}`
|
||||||
},
|
},
|
||||||
timeout: 60000 // 文件上传增加超时时间
|
timeout: 60000 // 文件上传增加超时时间
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<!-- 展开状态 -->
|
<!-- 展开状态 -->
|
||||||
<Transition v-else :name="transitionName">
|
<Transition v-else :name="transitionName">
|
||||||
<div :key="budget.period" class="budget-inner-card">
|
<div :key="budget.period" class="budget-inner-card">
|
||||||
<div class="card-header">
|
<div class="card-header" style="margin-bottom: 0;">
|
||||||
<div class="budget-info">
|
<div class="budget-info">
|
||||||
<slot name="tag">
|
<slot name="tag">
|
||||||
<van-tag
|
<van-tag
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
{{ budget.type === BudgetPeriodType.Year ? '年度' : '月度' }}
|
{{ budget.type === BudgetPeriodType.Year ? '年度' : '月度' }}
|
||||||
</van-tag>
|
</van-tag>
|
||||||
</slot>
|
</slot>
|
||||||
<h3 class="card-title">{{ budget.name }}</h3>
|
<h3 class="card-title" style="max-width: 120px;">{{ budget.name }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<slot name="actions">
|
<slot name="actions">
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="showBillListModal"
|
v-model="showBillListModal"
|
||||||
title="关联账单列表"
|
title="关联账单列表"
|
||||||
height="80%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<TransactionList
|
<TransactionList
|
||||||
:transactions="billList"
|
:transactions="billList"
|
||||||
@@ -452,7 +452,6 @@ const timePercentage = computed(() => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
max-width: 120px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-subtitle {
|
.card-subtitle {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="showAddBill"
|
v-model="showAddBill"
|
||||||
title="记一笔"
|
title="记一笔"
|
||||||
height="85%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<van-tabs v-model:active="activeTab" shrink>
|
<van-tabs v-model:active="activeTab" shrink>
|
||||||
<van-tab title="一句话录账" name="one">
|
<van-tab title="一句话录账" name="one">
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
v-model="showTransactionList"
|
v-model="showTransactionList"
|
||||||
:title="selectedGroup?.reason || '交易记录'"
|
:title="selectedGroup?.reason || '交易记录'"
|
||||||
:subtitle="groupTransactionsTotal ? `共 ${groupTransactionsTotal} 笔交易` : ''"
|
:subtitle="groupTransactionsTotal ? `共 ${groupTransactionsTotal} 笔交易` : ''"
|
||||||
height="85%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<template #header-actions>
|
<template #header-actions>
|
||||||
<van-button
|
<van-button
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
:type="buttonType"
|
:type="buttonType"
|
||||||
size="small"
|
size="small"
|
||||||
:loading="loading || saving"
|
:loading="loading || saving"
|
||||||
|
:loading-text="loadingText"
|
||||||
:disabled="loading || saving"
|
:disabled="loading || saving"
|
||||||
class="smart-classify-btn"
|
class="smart-classify-btn"
|
||||||
@click="handleClick"
|
@click="handleClick"
|
||||||
@@ -12,9 +13,6 @@
|
|||||||
<van-icon :name="buttonIcon" />
|
<van-icon :name="buttonIcon" />
|
||||||
<span style="margin-left: 4px;">{{ buttonText }}</span>
|
<span style="margin-left: 4px;">{{ buttonText }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
|
||||||
<span>{{ loadingText }}</span>
|
|
||||||
</template>
|
|
||||||
</van-button>
|
</van-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -39,6 +37,7 @@ const emit = defineEmits(['update', 'save', 'notifyDonedTransactionId'])
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
const classifiedResults = ref([])
|
const classifiedResults = ref([])
|
||||||
|
const lockClassifiedResults = ref(false)
|
||||||
const isAllCompleted = ref(false)
|
const isAllCompleted = ref(false)
|
||||||
let toastInstance = null
|
let toastInstance = null
|
||||||
|
|
||||||
@@ -47,7 +46,8 @@ const hasTransactions = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const hasClassifiedResults = computed(() => {
|
const hasClassifiedResults = computed(() => {
|
||||||
return isAllCompleted.value && classifiedResults.value.length > 0
|
// Show save state once we have any classified result, even if not all batches finished
|
||||||
|
return classifiedResults.value.length > 0 && lockClassifiedResults.value === false
|
||||||
})
|
})
|
||||||
|
|
||||||
// 按钮类型
|
// 按钮类型
|
||||||
@@ -92,6 +92,8 @@ const handleClick = () => {
|
|||||||
* 保存分类结果
|
* 保存分类结果
|
||||||
*/
|
*/
|
||||||
const handleSaveClassify = async () => {
|
const handleSaveClassify = async () => {
|
||||||
|
if (saving.value || loading.value) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
saving.value = true
|
saving.value = true
|
||||||
showToast({
|
showToast({
|
||||||
@@ -145,12 +147,23 @@ const handleSaveClassify = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理智能分类
|
|
||||||
*/
|
|
||||||
const handleSmartClassify = async () => {
|
const handleSmartClassify = async () => {
|
||||||
|
if (loading.value || saving.value) {
|
||||||
|
showToast('当前有任务正在进行,请稍后再试')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
|
||||||
if (!props.transactions || props.transactions.length === 0) {
|
if (!props.transactions || props.transactions.length === 0) {
|
||||||
showToast('没有可分类的交易记录')
|
showToast('没有可分类的交易记录')
|
||||||
|
loading.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lockClassifiedResults.value) {
|
||||||
|
showToast('当前有分类任务正在进行,请稍后再试')
|
||||||
|
loading.value = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,17 +171,12 @@ const handleSmartClassify = async () => {
|
|||||||
isAllCompleted.value = false
|
isAllCompleted.value = false
|
||||||
classifiedResults.value = []
|
classifiedResults.value = []
|
||||||
|
|
||||||
const batchSize = 30
|
const batchSize = 3
|
||||||
let processedCount = 0
|
let processedCount = 0
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
lockClassifiedResults.value = true
|
||||||
// 清除之前的Toast
|
// 等待父组件的 beforeClassify 事件处理完成(如果有返回 Promise)
|
||||||
if (toastInstance) {
|
|
||||||
closeToast()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 等待父组件的 beforeClassify 事件处理完成(如果有返回 Promise) TODO 没有生效
|
|
||||||
if (props.onBeforeClassify) {
|
if (props.onBeforeClassify) {
|
||||||
const shouldContinue = await props.onBeforeClassify()
|
const shouldContinue = await props.onBeforeClassify()
|
||||||
if (shouldContinue === false) {
|
if (shouldContinue === false) {
|
||||||
@@ -323,6 +331,7 @@ const handleSmartClassify = async () => {
|
|||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
lockClassifiedResults.value = false
|
||||||
// 确保Toast被清除
|
// 确保Toast被清除
|
||||||
if (toastInstance) {
|
if (toastInstance) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -342,6 +351,11 @@ const removeClassifiedTransaction = (transactionId) => {
|
|||||||
* 重置组件状态
|
* 重置组件状态
|
||||||
*/
|
*/
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
|
if(lockClassifiedResults.value) {
|
||||||
|
showToast('当前有分类任务正在进行,无法重置')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
isAllCompleted.value = false
|
isAllCompleted.value = false
|
||||||
classifiedResults.value = []
|
classifiedResults.value = []
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="visible"
|
v-model="visible"
|
||||||
title="交易详情"
|
title="交易详情"
|
||||||
height="85%"
|
height="75%"
|
||||||
:closeable="false"
|
:closeable="false"
|
||||||
>
|
>
|
||||||
<template #header-actions>
|
<template #header-actions>
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="showOffsetPopup"
|
v-model="showOffsetPopup"
|
||||||
title="选择抵账交易"
|
title="选择抵账交易"
|
||||||
height="70%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<van-list>
|
<van-list>
|
||||||
<van-cell
|
<van-cell
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表格样式优化 - 撑满宽度并支持独立横向和纵向滚动 */
|
/* 表格样式优化 - 确保表格独立滚动且列对齐 */
|
||||||
.rich-html-content table {
|
.rich-html-content table {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -62,55 +62,52 @@
|
|||||||
background: var(--van-background-2);
|
background: var(--van-background-2);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: none;
|
border: none;
|
||||||
overflow-x: auto;
|
overflow-x: auto; /* 仅表格内部横向滚动 */
|
||||||
overflow-y: auto;
|
|
||||||
max-height: 50vh;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: 35vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rich-html-content thead,
|
||||||
|
.rich-html-content tbody {
|
||||||
|
display: table;
|
||||||
|
width: 130%;
|
||||||
|
min-width: 400px; /* 确保窄屏下有足够宽度触发滚动 */
|
||||||
|
table-layout: fixed; /* 核心:强制列宽分配逻辑一致 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.rich-html-content tr {
|
||||||
|
display: table-row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-html-content th,
|
.rich-html-content th,
|
||||||
.rich-html-content td {
|
.rich-html-content td {
|
||||||
padding: 6px 8px;
|
display: table-cell;
|
||||||
|
padding: 8px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid var(--van-border-color-light);
|
border-bottom: 1px solid var(--van-border-color-light);
|
||||||
min-width: 70px; /* 防止内容过于拥挤 */
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
white-space: nowrap; /* 防止文字换行 */
|
white-space: nowrap;
|
||||||
flex: 1; /* 让单元格按比例撑满宽度 */
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表格行确保100%撑满 */
|
/* 针对第一列“名称”分配更多空间,其余平分 */
|
||||||
.rich-html-content tbody,
|
.rich-html-content th:first-child,
|
||||||
.rich-html-content thead {
|
|
||||||
display: table;
|
|
||||||
width: 100%;
|
|
||||||
table-layout: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 针对第一列预算项增加最小宽度 - 确保在滑动时有背景遮挡 */
|
|
||||||
.rich-html-content td:first-child {
|
.rich-html-content td:first-child {
|
||||||
min-width: 80px;
|
width: 30%;
|
||||||
position: sticky;
|
|
||||||
left: 0;
|
|
||||||
background: var(--van-background-2);
|
|
||||||
z-index: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-html-content th:first-child {
|
.rich-html-content th:not(:first-child),
|
||||||
min-width: 80px;
|
.rich-html-content td:not(:first-child) {
|
||||||
position: sticky;
|
width: 20%;
|
||||||
left: 0;
|
|
||||||
background: var(--van-gray-1);
|
|
||||||
z-index: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.rich-html-content th {
|
.rich-html-content th {
|
||||||
background: var(--van-gray-1);
|
background: var(--van-gray-1);
|
||||||
color: var(--van-text-color);
|
color: var(--van-text-color);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 12px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 业务特定样式:收入、支出、高亮 */
|
/* 业务特定样式:收入、支出、高亮 */
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
v-model="listVisible"
|
v-model="listVisible"
|
||||||
:title="selectedDateText"
|
:title="selectedDateText"
|
||||||
:subtitle="getBalance(dateTransactions)"
|
:subtitle="getBalance(dateTransactions)"
|
||||||
height="85%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<template #header-actions>
|
<template #header-actions>
|
||||||
<SmartClassifyButton
|
<SmartClassifyButton
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="showRecordsList"
|
v-model="showRecordsList"
|
||||||
title="交易记录列表"
|
title="交易记录列表"
|
||||||
height="80%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<div style="background: var(--van-background, #f7f8fa);">
|
<div style="background: var(--van-background, #f7f8fa);">
|
||||||
<!-- 批量操作按钮 -->
|
<!-- 批量操作按钮 -->
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="detailVisible"
|
v-model="detailVisible"
|
||||||
:title="currentEmail ? (currentEmail.Subject || currentEmail.subject || '(无主题)') : ''"
|
:title="currentEmail ? (currentEmail.Subject || currentEmail.subject || '(无主题)') : ''"
|
||||||
height="80%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<template #header-actions>
|
<template #header-actions>
|
||||||
<van-button
|
<van-button
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="transactionListVisible"
|
v-model="transactionListVisible"
|
||||||
title="关联账单列表"
|
title="关联账单列表"
|
||||||
height="70%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<TransactionList
|
<TransactionList
|
||||||
:transactions="transactionList"
|
:transactions="transactionList"
|
||||||
|
|||||||
@@ -41,8 +41,7 @@
|
|||||||
v-model="detailVisible"
|
v-model="detailVisible"
|
||||||
:title="currentMessage.title"
|
:title="currentMessage.title"
|
||||||
:subtitle="currentMessage.createTime"
|
:subtitle="currentMessage.createTime"
|
||||||
height="80%"
|
height="75%"
|
||||||
:closeable="true"
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="currentMessage.messageType === 2"
|
v-if="currentMessage.messageType === 2"
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
<PopupContainer
|
<PopupContainer
|
||||||
v-model="dialogVisible"
|
v-model="dialogVisible"
|
||||||
:title="isEdit ? '编辑周期账单' : '新增周期账单'"
|
:title="isEdit ? '编辑周期账单' : '新增周期账单'"
|
||||||
height="85%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<van-form>
|
<van-form>
|
||||||
<van-cell-group inset title="周期设置">
|
<van-cell-group inset title="周期设置">
|
||||||
|
|||||||
@@ -281,7 +281,7 @@
|
|||||||
v-model="billListVisible"
|
v-model="billListVisible"
|
||||||
:title="selectedCategoryTitle"
|
:title="selectedCategoryTitle"
|
||||||
:subtitle="categoryBillsTotal ? `共 ${categoryBillsTotal} 笔交易` : ''"
|
:subtitle="categoryBillsTotal ? `共 ${categoryBillsTotal} 笔交易` : ''"
|
||||||
height="85%"
|
height="75%"
|
||||||
>
|
>
|
||||||
<template #header-actions>
|
<template #header-actions>
|
||||||
<SmartClassifyButton
|
<SmartClassifyButton
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
namespace WebApi.Controllers;
|
namespace WebApi.Controllers;
|
||||||
|
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
using Repository;
|
using Repository;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@@ -452,12 +454,57 @@ public class TransactionRecordController(
|
|||||||
await smartHandleService.SmartClassifyAsync(request.TransactionIds.ToArray(), async (chunk) =>
|
await smartHandleService.SmartClassifyAsync(request.TransactionIds.ToArray(), async (chunk) =>
|
||||||
{
|
{
|
||||||
var (eventType, content) = chunk;
|
var (eventType, content) = chunk;
|
||||||
|
await TrySetUnconfirmedAsync(eventType, content);
|
||||||
await WriteEventAsync(eventType, content);
|
await WriteEventAsync(eventType, content);
|
||||||
});
|
});
|
||||||
|
|
||||||
await Response.Body.FlushAsync();
|
await Response.Body.FlushAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task TrySetUnconfirmedAsync(string eventType, string content)
|
||||||
|
{
|
||||||
|
if (eventType != "data")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var jsonObject = JsonSerializer.Deserialize<JsonObject>(content);
|
||||||
|
var id = jsonObject?["id"]?.GetValue<long>() ?? 0;
|
||||||
|
var classify = jsonObject?["Classify"]?.GetValue<string>() ?? string.Empty;
|
||||||
|
var typeValue = jsonObject?["Type"]?.GetValue<int>() ?? -1;
|
||||||
|
|
||||||
|
if(id == 0 || typeValue == -1 || string.IsNullOrEmpty(classify))
|
||||||
|
{
|
||||||
|
logger.LogWarning("解析智能分类结果时,发现无效数据,内容: {Content}", content);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var record = await transactionRepository.GetByIdAsync(id);
|
||||||
|
if (record == null)
|
||||||
|
{
|
||||||
|
logger.LogWarning("解析智能分类结果时,未找到对应的交易记录,ID: {Id}", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
record.UnconfirmedClassify = classify;
|
||||||
|
record.UnconfirmedType = (TransactionType)typeValue;
|
||||||
|
|
||||||
|
var success = await transactionRepository.UpdateAsync(record);
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
logger.LogWarning("解析智能分类结果时,更新交易记录失败,ID: {Id}", id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "解析智能分类结果失败,内容: {Content}", content);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量更新账单分类
|
/// 批量更新账单分类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user