# coding:utf-8 from tables import CatchContentObject, fsc from util.sensitive_word import AcAutomation from docs.config import amount_config from docs.config import budget_config from docs.config import DEBUG from docs.config import abnormal_config import csv class NoFieldChecker(object): """ 无字段或空值检查 """ def __init__(self): self.errors_tables = { "title": self.check_title, "projectname": self.check_projectname, "buyer":self.check_buyer, "winner": self.check_winner, "budget": self.check_budget, "bidamount": self.check_bidamount, "area":self.check_region, "projectcode": self.check_projectcode, "multipackage":self.check_subpackage, } def check_bidamount(self,obj,catch_content: CatchContentObject) -> bool: """ 中标金额为空检测 :param obj:代表一个item :return:返回true 代表异常 """ subtype = obj.get("subtype", "") if subtype in ["中标", "成交","合同","验收"]: bidamount = obj.get("bidamount", "") if bidamount: return False return True return False def check_winner(self,obj, catch_content: CatchContentObject) -> bool: """ 中标单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空 :param obj:代表一个item :return:返回true 代表异常 """ subtype = obj.get("subtype", "") if subtype in ["中标", "成交", "合同", "验收"]: winner = obj.get("winner", "") if winner: return False return True return False def check_buyer(self,obj,catch_content: CatchContentObject) -> bool: """ 采购单位名称是否为空检测 :param buyer:采购单位,多个逗号分割 :param obj:代表一个item :return:返回true 代表异常 """ buyer = obj.get("buyer", "") if buyer : return False return True def check_budget(self,obj, catch_content: CatchContentObject) -> bool: """ 预算为空检测 :param obj:代表一个item :return:返回true 代表异常 """ subtype = obj.get("subtype", "") if subtype not in ["中标", "成交", "合同", "验收"]: budget = obj.get("budget", "") if budget: return False return True return False def check_region(self,obj, catch_content: CatchContentObject) -> bool: """ 区域为空检测 :param obj:代表一个item :return:返回true 代表异常 """ pass # 处理正文 # 检查因素 # 是否返回 0000 def check_title(self,obj, catch_content: CatchContentObject) -> bool: """ :param obj:代表一个item :return:返回true 代表异常 """ title = obj.get("title", "") if title : return False return True def check_projectname(self,obj, catch_content: CatchContentObject) -> bool: """ :param obj:代表一个item :return:返回true 代表异常 """ projectname = obj.get("projectname", "") if projectname : return False return True def check_projectcode(self,obj, catch_content: CatchContentObject) -> bool: """ 项目编号为空检测 :param obj:代表一个item :return:返回true 代表异常 """ projectcode = obj.get("projectcode", "") if projectcode: return False return True def check_subpackage(self,obj, catch_content: CatchContentObject) -> bool: """ 公司名称检测 :param obj:代表一个item :return:返回true 代表异常 """ pass # 处理正文 # 检查因素 # 是否返回 0000