|
@@ -138,22 +138,22 @@ def check(obj: any, rules) -> any:
|
|
|
field_qa = {}
|
|
|
for field in rules: # 获取检查字段
|
|
|
qa = {}
|
|
|
- # 字段检查
|
|
|
+ # 字段不存在检查
|
|
|
if field not in obj and field in nofield_checker.errors_tables:
|
|
|
func = nofield_checker.errors_tables[field]
|
|
|
# 开始执行函数
|
|
|
if func(obj, catch_content):
|
|
|
qa["0000"] = f"{field}:不存在!!"
|
|
|
- field_qa["%s_qa" % field] = qa
|
|
|
- continue
|
|
|
- # 字段存在,判断类型是否正确如值为null的,并把英文括号转换为中文括号
|
|
|
- # 类型检查
|
|
|
- func_type = fieldtype_checker.errors_tables[field]
|
|
|
- value = func_type(obj.get(field))
|
|
|
- if value is True:
|
|
|
- qa["0001"] = f"{field}:类型不正确、空值"
|
|
|
- field_qa["%s_qa" % field] = qa
|
|
|
+ field_qa["%s_qa" % field] = qa
|
|
|
continue
|
|
|
+ # 字段存在检查,判断字段值的类型是否正确,判断类型是否正确如值为null的,并把英文括号转换为中文括号
|
|
|
+ if field in obj and field in fieldtype_checker.errors_tables:
|
|
|
+ func_type = fieldtype_checker.errors_tables[field]
|
|
|
+ value = func_type(obj.get(field))
|
|
|
+ if value is True:
|
|
|
+ qa["0001"] = f"{field}:类型不正确、空值"
|
|
|
+ field_qa["%s_qa" % field] = qa
|
|
|
+ continue
|
|
|
if field not in check_chain:
|
|
|
continue
|
|
|
checker = check_chain[field]["checker"] # 获取检测器
|
|
@@ -196,9 +196,9 @@ if __name__ == '__main__':
|
|
|
"site" : "湖南省政府采购电子卖场",
|
|
|
"title" : "二连浩特",
|
|
|
"dataging" : int(0),
|
|
|
- "bidopentime":int(1798739414),
|
|
|
- "publishtime" : int(1698739410),
|
|
|
- "subtype" : "招标",
|
|
|
+ # "bidopentime":int(1798739414),
|
|
|
+ # "publishtime" : int(1698739410),
|
|
|
+ # "subtype" : "招标",
|
|
|
"purchasinglist" : [
|
|
|
{
|
|
|
"score" : 0.8275,
|
|
@@ -443,17 +443,23 @@ if __name__ == '__main__':
|
|
|
# }
|
|
|
# })
|
|
|
result = check(row, rules={
|
|
|
- "buyer": {
|
|
|
- "0103": {
|
|
|
- "name": "包含叠词,异常词汇,特殊词汇",
|
|
|
- "parent_name": "名称错误",
|
|
|
- "parent_code": "01"
|
|
|
+ "toptype": {
|
|
|
},
|
|
|
- "0104": {
|
|
|
- "name": "名称不完整",
|
|
|
- "parent_name": "名称错误",
|
|
|
- "parent_code": "01"
|
|
|
+ "subtype": {
|
|
|
+ },
|
|
|
+ "bidopentime": {
|
|
|
+ "0201": {
|
|
|
+ "name": "发布时间 > 开标时间",
|
|
|
+ "parent_name": "数据范围类型",
|
|
|
+ "parent_code": "02"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "publishtime": {
|
|
|
+ "0201": {
|
|
|
+ "name": "发布时间 > 开标时间 ",
|
|
|
+ "parent_name": "数据范围类型",
|
|
|
+ "parent_code": "02"
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
})
|
|
|
print(result)
|