diff --git a/alibabacloud_sample/dataservice.py b/alibabacloud_sample/dataservice.py index 9e2e050..866070f 100644 --- a/alibabacloud_sample/dataservice.py +++ b/alibabacloud_sample/dataservice.py @@ -38,7 +38,7 @@ class DataService: purchaserBankAccountInfo, purchaserContactInfo, purchaserName, purchaserTaxNumber, recipient, remarks, reviewer, sellerBankAccountInfo, sellerContactInfo, sellerName, sellerTaxNumber, - specialTag, title, totalAmount, totalAmountInWords,file_path,verify_time,cyjgxx, + specialTag, title, totalAmount, totalAmountInWords,file_path,verify_time, verify_time,verify_status,desc,desc_files,status from invoice """ @@ -124,14 +124,15 @@ class DataService: invoice_id = cursor.lastrowid return invoice_id # 更新发票状态 - def update_invoice_status(self, invoice_id: int, verify_status: str): + def update_invoice_status(self, invoice_id: int, verify_status: str,inspectionAmount :str ): conn = DBService().get_conn() cursor = conn.cursor() cursor.execute( "UPDATE invoice SET verify_time = ?," "verify_status = ?" + "inspectionAmount = ?" "WHERE id = ?", - (datetime.now().strftime("%Y-%m-%d %H:%M:%S"), verify_status, invoice_id)) + (datetime.now().strftime("%Y-%m-%d %H:%M:%S"), verify_status,inspectionAmount, invoice_id)) conn.commit() def update_invoice_desc(self, invoice_id: int|str, desc: str, desc_file: str,status: str): conn = DBService().get_conn() @@ -145,20 +146,20 @@ class DataService: (desc, desc_file,status, invoice_id)) conn.commit() # 查询验证记录 - def get_verify_log(self, file_path: str) -> dict[Any, Any]: + def get_verify_log(self, file_path: str) -> dict[Any, Any]|None: conn = DBService().get_conn() cursor = conn.cursor() cursor.execute(""" - select inspectionAmount,cyjgxx,verify_time,file_path from verify_log where file_path = ? order verify_time desc limit 1 + select inspectionAmount,cyjgxx,verify_time,file_path from verify_log where file_path = ? order by verify_time desc limit 1 """ , (file_path,)) rows = cursor.fetchall() - data = {} if len(rows) > 0: - + data = {} for i in range(len(rows[0])): data[cursor.description[i][0]] = rows[0][i] - return data + return data + return None # 插入验证记录 def insert_verify_log(self, inspection_amount: str, cyjgxx: str, file_path: str): conn = DBService().get_conn() @@ -196,18 +197,18 @@ class DataService: purchaserBankAccountInfo, purchaserContactInfo, purchaserName, purchaserTaxNumber, recipient, remarks, reviewer, sellerBankAccountInfo, sellerContactInfo, sellerName, sellerTaxNumber, - specialTag, title, totalAmount, totalAmountInWords,file_path,verify_time,verify_status,desc,desc_files,status + specialTag, title, totalAmount, totalAmountInWords,file_path,verify_time,verify_status,inspectionAmount,desc,desc_files,status from invoice where """ if time_out != 'all': sql += " date('now', '-"+time_out+" day') >= date(verify_time) and verify_status == 'success' " else: - sql += " verify_status = " + verify_status + sql += " verify_status = '" + verify_status+"'" if start_date is not None: sql += " and verify_time >= '" + start_date.strftime("%Y-%m-%d") + "'" if end_date is not None: sql += " and verify_time <= '" + end_date.strftime("%Y-%m-%d") + "'" - if value != '': + if value is not None and value != '': sql += " and ( " sql += "file_path like '%" + value + "%' or " sql += "checkCode like '%" + value + "%' or " @@ -242,43 +243,13 @@ class DataService: sql += "desc_files like '%" + value + "%' " sql += ")" sql += " order by verify_time desc" + print(sql) cursor.execute(sql) rows = cursor.fetchall() - data = [] + datas = [] for row in rows: - data.append({ - 'checkCode': row[0], - 'drawer': row[1], - 'formType': row[2], - 'invoiceAmountPreTax': row[3], - 'invoiceCode': row[4], - 'invoiceDate': row[5], - 'invoiceNumber': row[6], - 'invoiceTax': row[7], - 'invoiceType': row[8], - 'machineCode': row[9], - 'passwordArea': row[10], - 'printedInvoiceCode': row[11], - 'printedInvoiceNumber': row[12], - 'purchaserBankAccountInfo': row[13], - 'purchaserContactInfo': row[14], - 'purchaserName': row[15], - 'purchaserTaxNumber': row[16], - 'recipient': row[17], - 'remarks': row[18], - 'reviewer': row[19], - 'sellerBankAccountInfo': row[20], - 'sellerContactInfo': row[21], - 'sellerName': row[22], - 'sellerTaxNumber': row[23], - 'specialTag': row[24], - 'title': row[25], - 'totalAmount': row[26], - 'totalAmountInWords': row[27], - 'file_path': row[28], - 'verify_time': row[29], - 'verify_status': row[30], - 'desc': row[31], - 'desc_files': row[32] - }) - return data \ No newline at end of file + data = {} + for i in range(len(row)): + data[cursor.description[i][0]] = row[i] + datas.append(data) + return datas \ No newline at end of file diff --git a/alibabacloud_sample/dbservice.py b/alibabacloud_sample/dbservice.py index 67fc093..ec78d8a 100644 --- a/alibabacloud_sample/dbservice.py +++ b/alibabacloud_sample/dbservice.py @@ -117,6 +117,7 @@ class DBService: file_path TEXT, -- 文件哈希 verify_time TEXT, -- 验证时间 verify_status TEXT, -- 验证结果 + inspectionAmount TEXT, -- 验证次数 desc TEXT, -- 备注 desc_files TEXT, -- 备注附件 status TEXT, -- 是否报销(yes,no) diff --git a/alibabacloud_sample/main.py b/alibabacloud_sample/main.py index a4926cf..79a198a 100644 --- a/alibabacloud_sample/main.py +++ b/alibabacloud_sample/main.py @@ -65,8 +65,8 @@ def reverify(): # 发票列表 @app.route('/listInvoice',methods=['POST']) def list_invoice(): - value = request.form.get('value') - verify_status = request.form.get('verifyStatus') + value = request.json.get('value') + verify_status = request.json.get('verify_status') return dataservice.get_invoice_list(value=value,verify_status=verify_status) @app.route('/listInvoiceTimeOut',methods=['POST']) def list_invoice_time_out(): diff --git a/alibabacloud_sample/service.py b/alibabacloud_sample/service.py index 1a0f8a7..108f9dd 100644 --- a/alibabacloud_sample/service.py +++ b/alibabacloud_sample/service.py @@ -71,8 +71,8 @@ class Service: # 复验 if not reverify: data1 = dataservice.get_verify_log(file_path=file_path) - print(data) - if data1 is not None and data1.get('inspectionAmount') > 0: + print(data1) + if data1 is not None and int(data1.get('inspectionAmount')) > 0: return data1 client = Service.create_client() type = Service.typeDict.get(data.get('invoiceType')) @@ -96,13 +96,17 @@ class Service: try: resp = client.verify_vatinvoice_with_options(verify_vatinvoice_request, runtime) ConsoleClient.log(UtilClient.to_jsonstring(resp)) - resdata = json.loads(UtilClient.to_jsonstring(resp.body.data)).get('data') + respjson = json.loads(UtilClient.to_jsonstring(resp.body.data)) + code = respjson.get('code') + if code != '001': + return {'cyjgxx': respjson.get('msg'), 'inspectionAmount': -1,'status': 'fail'} + resdata = respjson.get('data') if resdata is None: resdata = {'cyjgxx': "未查询到发票信息", 'inspectionAmount': -1,'status': 'fail'} else: resdata.update({'status': 'success'}) dataservice.insert_verify_log(resdata.get('inspectionAmount'), resdata.get('cyjgxx'), file_path) - dataservice.update_invoice_status(data.get('id'), resdata.get('status')) + dataservice.update_invoice_status(data.get('id'), resdata.get('status'), resdata.get('inspectionAmount')) return resdata except Exception as error: # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 diff --git a/alibabacloud_sample/verify.db b/alibabacloud_sample/verify.db index 91be796..aea8c57 100644 Binary files a/alibabacloud_sample/verify.db and b/alibabacloud_sample/verify.db differ diff --git a/webapp/vite-project/src/components/check/Check.vue b/webapp/vite-project/src/components/check/Check.vue index 039e3e4..72c0a55 100644 --- a/webapp/vite-project/src/components/check/Check.vue +++ b/webapp/vite-project/src/components/check/Check.vue @@ -107,7 +107,7 @@ const emit= defineEmits(['update:formState']) const fileType = ref('img') onMounted(() => { - alert(props.filePath) + // alert(props.filePath) if(props.filePath){ fileType.value = props.filePath.split('.').pop() ==='pdf'?'pdf':'img' request.get('/recognize?filePath='+encodeURIComponent(props.filePath)).then((res) => { diff --git a/webapp/vite-project/src/components/check/index.vue b/webapp/vite-project/src/components/check/index.vue index 8567d0b..4a7220f 100644 --- a/webapp/vite-project/src/components/check/index.vue +++ b/webapp/vite-project/src/components/check/index.vue @@ -7,7 +7,7 @@ import { // SmileOutlined, } from '@ant-design/icons-vue' import type {StepProps} from "ant-design-vue" -import Check from './Check.vue' +import Check from './Check.vue' import upload from './upload.vue' import Report from "./report.vue" // 步骤 diff --git a/webapp/vite-project/src/components/check/upload.vue b/webapp/vite-project/src/components/check/upload.vue index 3f1fabb..6aaa55b 100644 --- a/webapp/vite-project/src/components/check/upload.vue +++ b/webapp/vite-project/src/components/check/upload.vue @@ -35,7 +35,8 @@ const handleUpload = (options: any) => { if (xhr.status === 200 || xhr.status === 201) { console.log(xhr.responseText); onSuccess(xhr.responseText, file); - emit('update:filePath', xhr.responseText) + let res = JSON.parse(xhr.responseText) + emit('update:filePath', res.file_path) } else { onError(new Error(`Upload failed with status ${xhr.status}`)); } diff --git a/webapp/vite-project/src/pages/manage.vue b/webapp/vite-project/src/pages/manage.vue index e90ac03..7fc656c 100644 --- a/webapp/vite-project/src/pages/manage.vue +++ b/webapp/vite-project/src/pages/manage.vue @@ -1,10 +1,10 @@ diff --git a/webapp/vite-project/src/utils/baseurl.ts b/webapp/vite-project/src/utils/baseurl.ts index ce5a87f..c01d42a 100644 --- a/webapp/vite-project/src/utils/baseurl.ts +++ b/webapp/vite-project/src/utils/baseurl.ts @@ -1,2 +1,2 @@ -export const baseURL = "http://192.168.1.100:5555" +export const baseURL = "http://127.0.0.1:5555" // export const baseURL = "http://101.200.148.149:8555" \ No newline at end of file