feat: 益选 OCR 订单处理系统初始提交
- 智能供应商识别(蓉城易购/烟草/杨碧月/通用) - 百度 OCR 表格识别集成 - 规则引擎(列映射/数据清洗/单位转换/规格推断) - 条码映射管理与云端同步(Gitea REST API) - 云端同步支持:条码映射、供应商配置、商品资料、采购模板 - 拖拽一键处理(图片→OCR→Excel→合并) - 191 个单元测试 - 移除无用的模板管理功能 - 清理 IDE 产物目录 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,273 @@
|
||||
{
|
||||
"6920584471055": {
|
||||
"map_to": "6920584471017",
|
||||
"description": "条码映射:6920584471055 -> 6920584471017"
|
||||
},
|
||||
"6925861571159": {
|
||||
"map_to": "69021824",
|
||||
"description": "条码映射:6925861571159 -> 69021824"
|
||||
},
|
||||
"6923644268923": {
|
||||
"map_to": "6923644268480",
|
||||
"description": "条码映射:6923644268923 -> 6923644268480"
|
||||
},
|
||||
"6925861571466": {
|
||||
"map_to": "6925861571459",
|
||||
"description": "条码映射:6925861571466 -> 6925861571459"
|
||||
},
|
||||
"6907992508344": {
|
||||
"map_to": "6907992508191",
|
||||
"description": "条码映射:6907992508344 -> 6907992508191"
|
||||
},
|
||||
"6903979000979": {
|
||||
"map_to": "6903979000962",
|
||||
"description": "条码映射:6903979000979 -> 6903979000962"
|
||||
},
|
||||
"6923644283582": {
|
||||
"map_to": "6923644283575",
|
||||
"description": "条码映射:6923644283582 -> 6923644283575"
|
||||
},
|
||||
"6923644268930": {
|
||||
"map_to": "6923644268497",
|
||||
"description": "条码映射:6923644268930 -> 6923644268497"
|
||||
},
|
||||
"6923644268916": {
|
||||
"map_to": "6923644268503",
|
||||
"description": "条码映射:6923644268916 -> 6923644268503"
|
||||
},
|
||||
"6923644268909": {
|
||||
"map_to": "6923644268510",
|
||||
"description": "条码映射:6923644268909 -> 6923644268510"
|
||||
},
|
||||
"6923644299804": {
|
||||
"map_to": "6923644299774",
|
||||
"description": "条码映射:6923644299804 -> 6923644299774"
|
||||
},
|
||||
"6923644266318": {
|
||||
"map_to": "6923644266066",
|
||||
"description": "条码映射:6923644266318 -> 6923644266066"
|
||||
},
|
||||
"6923644210151": {
|
||||
"map_to": "6923644223458",
|
||||
"description": "条码映射:6923644210151 -> 6923644223458"
|
||||
},
|
||||
"6907992501819": {
|
||||
"map_to": "6907992500133",
|
||||
"description": "条码映射:6907992501819 -> 6907992500133"
|
||||
},
|
||||
"6907992502052": {
|
||||
"map_to": "6907992100272",
|
||||
"description": "条码映射:6907992502052 -> 6907992100272"
|
||||
},
|
||||
"6907992507385": {
|
||||
"map_to": "6907992507095",
|
||||
"description": "条码映射:6907992507385 -> 6907992507095"
|
||||
},
|
||||
"6973726149671": {
|
||||
"map_to": "6973726149657",
|
||||
"description": "条码映射:6973726149671 -> 6973726149657"
|
||||
},
|
||||
"6977426410574": {
|
||||
"map_to": "6977426410567",
|
||||
"description": "条码映射:6977426410574 -> 6977426410567"
|
||||
},
|
||||
"6973726149688": {
|
||||
"map_to": "6973726149664",
|
||||
"description": "条码映射:6973726149688 -> 6973726149664"
|
||||
},
|
||||
"6935205322012": {
|
||||
"map_to": "6935205320018",
|
||||
"description": "条码映射:6935205322012 -> 6935205320018"
|
||||
},
|
||||
"6943497411024": {
|
||||
"map_to": "6943497411017",
|
||||
"description": "条码映射:6943497411024 -> 6943497411017"
|
||||
},
|
||||
"6921734968821": {
|
||||
"map_to": "6921734968814",
|
||||
"description": "条码映射:6921734968821 -> 6921734968814"
|
||||
},
|
||||
"6921734968258": {
|
||||
"map_to": "6921734968241",
|
||||
"description": "条码映射:6921734968258 -> 6921734968241"
|
||||
},
|
||||
"6921734968180": {
|
||||
"map_to": "6921734968173",
|
||||
"description": "条码映射:6921734968180 -> 6921734968173"
|
||||
},
|
||||
"6921734908735": {
|
||||
"map_to": "6935205372772",
|
||||
"description": "条码映射:6921734908735 -> 6935205372772"
|
||||
},
|
||||
"6923644248222": {
|
||||
"map_to": "6923644248208",
|
||||
"description": "条码映射:6923644248222 -> 6923644248208"
|
||||
},
|
||||
"6902083881122": {
|
||||
"map_to": "6902083881085",
|
||||
"description": "条码映射:6902083881122 -> 6902083881085"
|
||||
},
|
||||
"6907992501857": {
|
||||
"map_to": "6907992500010",
|
||||
"description": "条码映射:6907992501857 -> 6907992500010"
|
||||
},
|
||||
"6902083891015": {
|
||||
"map_to": "6902083890636",
|
||||
"description": "条码映射:6902083891015 -> 6902083890636"
|
||||
},
|
||||
"6923450605240": {
|
||||
"map_to": "6923450605226",
|
||||
"description": "条码映射:6923450605240 -> 6923450605226"
|
||||
},
|
||||
"6923450605196": {
|
||||
"map_to": "6923450614624",
|
||||
"description": "条码映射:6923450605196 -> 6923450614624"
|
||||
},
|
||||
"6923450665213": {
|
||||
"map_to": "6923450665206",
|
||||
"description": "条码映射:6923450665213 -> 6923450665206"
|
||||
},
|
||||
"6923450666821": {
|
||||
"map_to": "6923450666838",
|
||||
"description": "条码映射:6923450666821 -> 6923450666838"
|
||||
},
|
||||
"6923450661505": {
|
||||
"map_to": "6923450661499",
|
||||
"description": "条码映射:6923450661505 -> 6923450661499"
|
||||
},
|
||||
"6923450676103": {
|
||||
"map_to": "6923450676097",
|
||||
"description": "条码映射:6923450676103 -> 6923450676097"
|
||||
},
|
||||
"6923450614631": {
|
||||
"map_to": "6923450614624",
|
||||
"description": "条码映射:6923450614631 -> 6923450614624"
|
||||
},
|
||||
"6901424334174": {
|
||||
"map_to": "6973730760015",
|
||||
"description": "条码映射:6901424334174 -> 6973730760015"
|
||||
},
|
||||
"6958620703716": {
|
||||
"map_to": "6958620703907",
|
||||
"description": "条码映射:6958620703716 -> 6958620703907"
|
||||
},
|
||||
"6937003706322": {
|
||||
"map_to": "6937003703833",
|
||||
"description": "条码映射:6937003706322 -> 6937003703833"
|
||||
},
|
||||
"6950783203494": {
|
||||
"map_to": "6950873203494",
|
||||
"description": "条码映射:6950783203494 -> 6950873203494"
|
||||
},
|
||||
"6907992501871": {
|
||||
"map_to": "6907992500010",
|
||||
"description": "条码映射:6907992501871 -> 6907992500010"
|
||||
},
|
||||
"6907992501864": {
|
||||
"map_to": "6907992100012",
|
||||
"description": "条码映射:6907992501864 -> 6907992100012"
|
||||
},
|
||||
"6923644264192": {
|
||||
"map_to": "6923644264116",
|
||||
"description": "条码映射:6923644264192 -> 6923644264116"
|
||||
},
|
||||
"6923450667316": {
|
||||
"map_to": "69042386",
|
||||
"description": "条码映射:6923450667316 -> 69042386"
|
||||
},
|
||||
"6923450653012": {
|
||||
"map_to": "69021343",
|
||||
"description": "条码映射:6923450653012 -> 69021343"
|
||||
},
|
||||
"6923644295844": {
|
||||
"map_to": "6923644285036",
|
||||
"description": "条码映射:6923644295844 -> 6923644285036"
|
||||
},
|
||||
"6907992513157": {
|
||||
"map_to": "6907992513195",
|
||||
"description": "条码映射:6907992513157 -> 6907992513195"
|
||||
},
|
||||
"6902083893842": {
|
||||
"map_to": "6902083907150",
|
||||
"description": "条码映射:6902083893842 -> 6902083907150"
|
||||
},
|
||||
"6902083904685": {
|
||||
"map_to": "6902083905217",
|
||||
"description": "条码映射:6902083904685 -> 6902083905217"
|
||||
},
|
||||
"6917878036849": {
|
||||
"map_to": "6917878036847",
|
||||
"description": "条码映射:6917878036849 -> 6917878036847"
|
||||
},
|
||||
"6903979000078": {
|
||||
"map_to": "6903979000061",
|
||||
"description": "条码映射:6903979000078 -> 6903979000061"
|
||||
},
|
||||
"6937003706353": {
|
||||
"map_to": "6937003706360",
|
||||
"description": "条码映射:6937003706353 -> 6937003706360"
|
||||
},
|
||||
"6923644242961": {
|
||||
"map_to": "6907992100043",
|
||||
"description": "条码映射:6923644242961 -> 6907992100043"
|
||||
},
|
||||
"6923644258382": {
|
||||
"map_to": "6923644252823",
|
||||
"description": "条码映射:6923644258382 -> 6923644252823"
|
||||
},
|
||||
"6923450657430": {
|
||||
"map_to": "69029110",
|
||||
"description": "条码映射:6923450657430 -> 69029110"
|
||||
},
|
||||
"6923450660232": {
|
||||
"map_to": "6923450690123",
|
||||
"description": "条码映射:6923450660232 -> 6923450690123"
|
||||
},
|
||||
"6923450657614": {
|
||||
"map_to": "6923450657607",
|
||||
"description": "条码映射:6923450657614 -> 6923450657607"
|
||||
},
|
||||
"6972556000022": {
|
||||
"map_to": "6977826050028",
|
||||
"description": "条码映射:6972556000022 -> 6977826050028"
|
||||
},
|
||||
"6949352266280": {
|
||||
"map_to": "6949352266273",
|
||||
"description": "条码映射:6949352266280 -> 6949352266273"
|
||||
},
|
||||
"6925019900087": {
|
||||
"multiplier": 10,
|
||||
"target_unit": "瓶",
|
||||
"description": "特殊处理:数量*10,单位转换为瓶"
|
||||
},
|
||||
"6921168593804": {
|
||||
"multiplier": 30,
|
||||
"target_unit": "瓶",
|
||||
"description": "NFC产品特殊处理:每箱30瓶"
|
||||
},
|
||||
"6901826888138": {
|
||||
"multiplier": 30,
|
||||
"target_unit": "瓶",
|
||||
"fixed_price": 3.7333333333333334,
|
||||
"specification": "1*30",
|
||||
"description": "特殊处理: 规格1*30,数量*30,单价=112/30"
|
||||
},
|
||||
"6958620703907": {
|
||||
"multiplier": 14,
|
||||
"target_unit": "个",
|
||||
"specification": "1*14",
|
||||
"description": "友臣肉松,1盒14个"
|
||||
},
|
||||
"6921734933485": {
|
||||
"multiplier": 12,
|
||||
"target_unit": "支",
|
||||
"specification": "1*12",
|
||||
"description": "得力铅笔"
|
||||
},
|
||||
"6901826888244": {
|
||||
"multiplier": 30,
|
||||
"target_unit": "对",
|
||||
"specification": "1*30",
|
||||
"description": "南孚电池"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
[API]
|
||||
api_key =
|
||||
secret_key =
|
||||
timeout = 30
|
||||
max_retries = 3
|
||||
retry_delay = 2
|
||||
api_url = https://aip.baidubce.com/rest/2.0/ocr/v1/table
|
||||
token_url = https://aip.baidubce.com/oauth/2.0/token
|
||||
form_ocr_url = https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/get_request_result
|
||||
|
||||
[Paths]
|
||||
input_folder = data/input
|
||||
output_folder = data/output
|
||||
temp_folder = data/temp
|
||||
template_folder = templates
|
||||
template_file = 银豹-采购单模板.xls
|
||||
processed_record = data/processed_files.json
|
||||
data_dir = data
|
||||
product_db = data/product_cache.db
|
||||
|
||||
[Performance]
|
||||
max_workers = 4
|
||||
batch_size = 5
|
||||
skip_existing = true
|
||||
|
||||
[File]
|
||||
allowed_extensions = .jpg,.jpeg,.png,.bmp
|
||||
excel_extension = .xlsx
|
||||
max_file_size_mb = 4
|
||||
|
||||
[Templates]
|
||||
purchase_order = 银豹-采购单模板.xls
|
||||
item_data = 商品资料.xlsx
|
||||
|
||||
[Gitea]
|
||||
base_url = https://gitea.94kan.cn
|
||||
owner = houhuan
|
||||
repo = yixuan-sync-data
|
||||
token =
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
{
|
||||
"suppliers": [
|
||||
{
|
||||
"name": "蓉城易购",
|
||||
"description": "蓉城易购供应商订单处理",
|
||||
"filename_patterns": [
|
||||
"*蓉城*",
|
||||
"*rongcheng*",
|
||||
"*易*"
|
||||
],
|
||||
"content_indicators": [
|
||||
"蓉城易购",
|
||||
"商品编码",
|
||||
"订货数量"
|
||||
],
|
||||
"column_mapping": {
|
||||
"商品条码(小条码)": "barcode",
|
||||
"商品名称": "name",
|
||||
"规格": "specification",
|
||||
"订购数量(小单位)": "quantity",
|
||||
"单位": "unit",
|
||||
"单价(小单位)": "unit_price",
|
||||
"优惠后金额(小单位)": "total_price",
|
||||
"备注": "category",
|
||||
"行号": "supplier"
|
||||
},
|
||||
"cleaning_rules": [
|
||||
{
|
||||
"type": "remove_rows",
|
||||
"condition": "订货数量 == 0 or 订货数量.isna()"
|
||||
},
|
||||
{
|
||||
"type": "fill_na",
|
||||
"columns": [
|
||||
"unit_price"
|
||||
],
|
||||
"value": 0
|
||||
}
|
||||
],
|
||||
"calculations": [
|
||||
{
|
||||
"type": "multiply",
|
||||
"source_column": "quantity",
|
||||
"target_column": "quantity",
|
||||
"factor": 1
|
||||
}
|
||||
],
|
||||
"output_suffix": "_蓉城易购_银豹采购单",
|
||||
"header_row": 2,
|
||||
"rules": [
|
||||
{
|
||||
"type": "split_quantity_unit",
|
||||
"source": "订购数量(小单位)"
|
||||
},
|
||||
{
|
||||
"type": "extract_spec_from_name",
|
||||
"source": "商品名称"
|
||||
},
|
||||
{
|
||||
"type": "normalize_unit",
|
||||
"target": "unit",
|
||||
"map": {
|
||||
"箱": "件",
|
||||
"提": "件",
|
||||
"盒": "件"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "compute_quantity_from_total"
|
||||
},
|
||||
{
|
||||
"type": "mark_gift"
|
||||
},
|
||||
{
|
||||
"type": "fill_missing",
|
||||
"fills": {
|
||||
"unit": "瓶"
|
||||
}
|
||||
}
|
||||
],
|
||||
"output_templates": [
|
||||
"templates/银豹-采购单模板.xls"
|
||||
],
|
||||
"current_template_index": 0
|
||||
},
|
||||
{
|
||||
"name": "通用食品供应商",
|
||||
"description": "通用食品类供应商订单",
|
||||
"filename_patterns": [
|
||||
"*食品*",
|
||||
"*配送*",
|
||||
"*供货*"
|
||||
],
|
||||
"content_indicators": [
|
||||
"产品条码",
|
||||
"订购量",
|
||||
"进货价"
|
||||
],
|
||||
"column_mapping": {
|
||||
"产品条码": "barcode",
|
||||
"产品名称": "name",
|
||||
"订购量": "quantity",
|
||||
"进货价": "unit_price"
|
||||
},
|
||||
"cleaning_rules": [
|
||||
{
|
||||
"type": "convert_type",
|
||||
"columns": [
|
||||
"unit_price"
|
||||
],
|
||||
"target_type": "float"
|
||||
},
|
||||
{
|
||||
"type": "fill_na",
|
||||
"columns": [
|
||||
"barcode",
|
||||
"name",
|
||||
"quantity"
|
||||
],
|
||||
"value": 0
|
||||
}
|
||||
],
|
||||
"output_suffix": "_食品供应商_银豹采购单",
|
||||
"rules": [
|
||||
{
|
||||
"type": "split_quantity_unit",
|
||||
"source": "订购量"
|
||||
},
|
||||
{
|
||||
"type": "extract_spec_from_name",
|
||||
"source": "产品名称"
|
||||
},
|
||||
{
|
||||
"type": "normalize_unit",
|
||||
"target": "unit",
|
||||
"map": {
|
||||
"箱": "件",
|
||||
"提": "件",
|
||||
"盒": "件"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "compute_quantity_from_total"
|
||||
},
|
||||
{
|
||||
"type": "mark_gift"
|
||||
},
|
||||
{
|
||||
"type": "fill_missing",
|
||||
"fills": {
|
||||
"unit": "瓶"
|
||||
}
|
||||
}
|
||||
],
|
||||
"output_templates": [
|
||||
"templates/银豹-采购单模板.xls"
|
||||
],
|
||||
"current_template_index": 0
|
||||
},
|
||||
{
|
||||
"name": "农夫山泉",
|
||||
"description": "",
|
||||
"filename_patterns": [],
|
||||
"content_indicators": [],
|
||||
"column_mapping": {
|
||||
"条形码": "barcode",
|
||||
"商品名称": "name",
|
||||
"销售价": "unit_price",
|
||||
"订单金额": "total_price",
|
||||
"Unnamed: 0": "supplier",
|
||||
"备注": "brand"
|
||||
},
|
||||
"header_row": 0,
|
||||
"rules": [
|
||||
{
|
||||
"type": "split_quantity_unit",
|
||||
"source": "订单数量"
|
||||
},
|
||||
{
|
||||
"type": "extract_spec_from_name",
|
||||
"source": "name"
|
||||
},
|
||||
{
|
||||
"type": "normalize_unit",
|
||||
"target": "unit",
|
||||
"map": {
|
||||
"箱": "件",
|
||||
"提": "件",
|
||||
"盒": "件"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "compute_quantity_from_total"
|
||||
},
|
||||
{
|
||||
"type": "mark_gift"
|
||||
},
|
||||
{
|
||||
"type": "fill_missing",
|
||||
"fills": {
|
||||
"unit": "瓶"
|
||||
}
|
||||
}
|
||||
],
|
||||
"dictionary": {
|
||||
"ignore_words": [
|
||||
"白膜",
|
||||
"彩膜",
|
||||
"赠品"
|
||||
],
|
||||
"unit_synonyms": {
|
||||
"箱": "件",
|
||||
"提": "件",
|
||||
"盒": "件",
|
||||
"瓶": "瓶"
|
||||
},
|
||||
"pack_multipliers": {
|
||||
"件": 24,
|
||||
"箱": 24,
|
||||
"提": 12,
|
||||
"盒": 10
|
||||
},
|
||||
"name_patterns": [
|
||||
"(\\d+(?:\\.\\d+)?)(ml|mL|ML|l|L|升|毫升)[*×xX](\\d+)",
|
||||
"(\\d+)[*×xX](\\d+)瓶",
|
||||
"(\\d{2,3}).*?(\\d{1,3})"
|
||||
],
|
||||
"default_unit": "瓶",
|
||||
"default_package_quantity": 1
|
||||
},
|
||||
"output_templates": [
|
||||
"templates/银豹-采购单模板.xls"
|
||||
],
|
||||
"current_template_index": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user