Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import sys
|
|
| 7 |
import re
|
| 8 |
from io import StringIO
|
| 9 |
|
| 10 |
-
def process_file(file_path, voucher_number):
|
| 11 |
# ์ํ ๋ฉ์์ง์ ๊ฒฐ๊ณผ๋ฅผ ํจ๊ป ๋ฐํํ๊ธฐ ์ํ ๋ณ์ ์ด๊ธฐํ
|
| 12 |
status_message = ""
|
| 13 |
output_file_path = None
|
|
@@ -15,8 +15,15 @@ def process_file(file_path, voucher_number):
|
|
| 15 |
# ๋ก๊ทธ๋ฅผ ์บก์ฒํ๊ธฐ ์ํ StringIO ๊ฐ์ฒด
|
| 16 |
log_capture = StringIO()
|
| 17 |
|
|
|
|
| 18 |
if file_path is None:
|
| 19 |
return None, "ํ์ผ์ ์
๋ก๋ํด์ฃผ์ธ์."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
try:
|
| 22 |
# ํ์ค ์ถ๋ ฅ์ ์บก์ฒ
|
|
@@ -36,8 +43,8 @@ def process_file(file_path, voucher_number):
|
|
| 36 |
# ์ด๋ฏธ CSV ํ์ผ์ด๋ฉด ๊ทธ๋๋ก ์ฌ์ฉ
|
| 37 |
input_path = file_path
|
| 38 |
|
| 39 |
-
# ๋ฉ์ธ ์ ์ฒ๋ฆฌ ํจ์ ํธ์ถ (
|
| 40 |
-
output_path = main.process_rental_company_with_voucher(input_path, voucher_number)
|
| 41 |
output_file_path = output_path
|
| 42 |
|
| 43 |
# ์ฑ๊ณต ๋ฉ์์ง ์์ฑ
|
|
@@ -108,7 +115,7 @@ def process_file(file_path, voucher_number):
|
|
| 108 |
|
| 109 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
| 110 |
with gr.Blocks() as demo:
|
| 111 |
-
gr.Markdown("# ERP ์๋ ์ ํ ๋ณํ๊ธฐ\n\n์
๋ก๋ํ ํ์ผ๊ณผ
|
| 112 |
|
| 113 |
with gr.Row():
|
| 114 |
file_input = gr.File(
|
|
@@ -116,10 +123,17 @@ with gr.Blocks() as demo:
|
|
| 116 |
file_types=[".csv", ".xlsx"],
|
| 117 |
type="filepath"
|
| 118 |
)
|
|
|
|
|
|
|
| 119 |
voucher_input = gr.Textbox(
|
| 120 |
-
label="์ ํ๋ฒํธ ์
๋ ฅ",
|
| 121 |
placeholder="์: 20250427001"
|
| 122 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
with gr.Row():
|
| 125 |
submit_btn = gr.Button("์ ์ถ", variant="primary")
|
|
@@ -137,14 +151,14 @@ with gr.Blocks() as demo:
|
|
| 137 |
# ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
| 138 |
submit_btn.click(
|
| 139 |
fn=process_file,
|
| 140 |
-
inputs=[file_input, voucher_input],
|
| 141 |
outputs=[output_file, status_output]
|
| 142 |
)
|
| 143 |
|
| 144 |
clear_btn.click(
|
| 145 |
-
fn=lambda: (None, "", ""),
|
| 146 |
inputs=[],
|
| 147 |
-
outputs=[file_input, voucher_input, status_output]
|
| 148 |
)
|
| 149 |
|
| 150 |
# ์์ ๋ฉ์์ง ํ์
|
|
|
|
| 7 |
import re
|
| 8 |
from io import StringIO
|
| 9 |
|
| 10 |
+
def process_file(file_path, voucher_number, employee_number):
|
| 11 |
# ์ํ ๋ฉ์์ง์ ๊ฒฐ๊ณผ๋ฅผ ํจ๊ป ๋ฐํํ๊ธฐ ์ํ ๋ณ์ ์ด๊ธฐํ
|
| 12 |
status_message = ""
|
| 13 |
output_file_path = None
|
|
|
|
| 15 |
# ๋ก๊ทธ๋ฅผ ์บก์ฒํ๊ธฐ ์ํ StringIO ๊ฐ์ฒด
|
| 16 |
log_capture = StringIO()
|
| 17 |
|
| 18 |
+
# ์
๋ ฅ๊ฐ ๊ฒ์ฆ
|
| 19 |
if file_path is None:
|
| 20 |
return None, "ํ์ผ์ ์
๋ก๋ํด์ฃผ์ธ์."
|
| 21 |
+
|
| 22 |
+
if not voucher_number or not voucher_number.strip():
|
| 23 |
+
return None, "์ ํ๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."
|
| 24 |
+
|
| 25 |
+
if not employee_number or not employee_number.strip():
|
| 26 |
+
return None, "์ฌ์๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์. ์ฌ์๋ฒํธ๋ ํ์ ์
๋ ฅ๊ฐ์
๋๋ค."
|
| 27 |
|
| 28 |
try:
|
| 29 |
# ํ์ค ์ถ๋ ฅ์ ์บก์ฒ
|
|
|
|
| 43 |
# ์ด๋ฏธ CSV ํ์ผ์ด๋ฉด ๊ทธ๋๋ก ์ฌ์ฉ
|
| 44 |
input_path = file_path
|
| 45 |
|
| 46 |
+
# ๋ฉ์ธ ์ ์ฒ๋ฆฌ ํจ์ ํธ์ถ (์ ํ๋ฒํธ์ ์ฌ์๋ฒํธ ๋๊ฒจ์ฃผ๊ธฐ)
|
| 47 |
+
output_path = main.process_rental_company_with_voucher(input_path, voucher_number, employee_number)
|
| 48 |
output_file_path = output_path
|
| 49 |
|
| 50 |
# ์ฑ๊ณต ๋ฉ์์ง ์์ฑ
|
|
|
|
| 115 |
|
| 116 |
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
| 117 |
with gr.Blocks() as demo:
|
| 118 |
+
gr.Markdown("# ERP ์๋ ์ ํ ๋ณํ๊ธฐ\n\n์
๋ก๋ํ ํ์ผ๊ณผ ์ ํ๋ฒํธ, ์ฌ์๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์.")
|
| 119 |
|
| 120 |
with gr.Row():
|
| 121 |
file_input = gr.File(
|
|
|
|
| 123 |
file_types=[".csv", ".xlsx"],
|
| 124 |
type="filepath"
|
| 125 |
)
|
| 126 |
+
|
| 127 |
+
with gr.Row():
|
| 128 |
voucher_input = gr.Textbox(
|
| 129 |
+
label="์ ํ๋ฒํธ ์
๋ ฅ (ํ์)",
|
| 130 |
placeholder="์: 20250427001"
|
| 131 |
)
|
| 132 |
+
|
| 133 |
+
employee_input = gr.Textbox(
|
| 134 |
+
label="์ฌ์๋ฒํธ ์
๋ ฅ (ํ์)",
|
| 135 |
+
placeholder="์: 00616"
|
| 136 |
+
)
|
| 137 |
|
| 138 |
with gr.Row():
|
| 139 |
submit_btn = gr.Button("์ ์ถ", variant="primary")
|
|
|
|
| 151 |
# ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
| 152 |
submit_btn.click(
|
| 153 |
fn=process_file,
|
| 154 |
+
inputs=[file_input, voucher_input, employee_input],
|
| 155 |
outputs=[output_file, status_output]
|
| 156 |
)
|
| 157 |
|
| 158 |
clear_btn.click(
|
| 159 |
+
fn=lambda: (None, "", "", ""),
|
| 160 |
inputs=[],
|
| 161 |
+
outputs=[file_input, voucher_input, employee_input, status_output]
|
| 162 |
)
|
| 163 |
|
| 164 |
# ์์ ๋ฉ์์ง ํ์
|