123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- # 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,
- "s_winner": self.check_winner,
- "owner":self.check_owner,
- "budget": self.check_budget,
- "bidamount": self.check_bidamount,
- "area":self.check_region,
- "city":self.check_city,
- "district": self.check_district,
- "projectcode": self.check_projectcode,
- "toptype":self.check_toptype,
- "subtype":self.check_subtype,
- "publishtime":self.check_publishtime,
- "multipackage":self.check_subpackage,
- "purchasinglist":self.check_purchasinglist,
- "detail":self.check_detail,
- "href":self.check_href,
- "est_purchase_time":self.check_est_purchase_time,
- "docstarttime":self.check_docstarttime,
- "docendtime":self.check_docendtime,
- "bidstarttime":self.check_bidstarttime,
- "bidendtime":self.check_bidendtime,
- "bidopentime":self.check_bidopentime,
- "bidway":self.check_bidway,
- "buyerperson":self.check_buyerperson,
- "buyertel":self.check_buyertel,
- "agency":self.check_agency,
- "agencyperson":self.check_agencyperson,
- "agencytel":self.check_agencytel,
- "winnerperson":self.check_winnerperson,
- "winnertel":self.check_winnertel,
- "entname":self.check_entname,
- "sortstr":self.check_sort,
- "price":self.check_price,
- "winnerorder":self.check_winnerorder
- }
- 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 not bidamount:
- return True
- return False
- def check_owner(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 业主单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["拟建"]:
- owner = obj.get("owner")
- if not owner:
- 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("s_winner")
- if not winner:
- return True
- return False
- def check_buyer(self,obj,catch_content: CatchContentObject) -> bool:
- """
- 采购单位名称是否为空检测
- :param buyer:采购单位,多个逗号分割
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype not in ["拟建"]:
- budget = obj.get("buyer")
- if not budget:
- return True
- return False
- def check_budget(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 预算为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["招标", "邀标", "询价", "竞谈","单一","竞价","变更"]:
- budget = obj.get("budget")
- if not budget:
- return True
- return False
- def check_region(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 省份为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- area = obj.get("area")
- if not area:
- return True
- return False
- def check_city(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 城市为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- city = obj.get("city")
- if not city:
- return True
- return False
- def check_district(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 区县为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- district = obj.get("district")
- if not district:
- return True
- return False
- def check_title(self,obj, catch_content: CatchContentObject) -> bool:
- """
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- title = obj.get("title")
- if not title :
- return True
- return False
- def check_projectname(self,obj, catch_content: CatchContentObject) -> bool:
- """
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- projectname = obj.get("projectname")
- if not projectname :
- return True
- return False
- def check_projectcode(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 项目编号为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- toptype = obj.get("toptype", "")
- if toptype not in ["拟建","采购意向"]:
- projectcode = obj.get("projectcode")
- if not projectcode:
- return True
- return False
- def check_subpackage(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 公司名称检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- pass
- # 处理正文
- # 检查因素
- # 是否返回 0000
- def check_purchasinglist(self,obj, catch_content: CatchContentObject) -> bool:
- if not obj.get("purchasinglist"):
- return True
- return False
- def check_toptype(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 公告一级分类检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if not obj.get("toptype"):
- return True
- return False
- def check_subtype(self,obj, catch_content: CatchContentObject) -> bool:
- """
- 公告二级分类检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if not obj.get("subtype"):
- return True
- return False
- def check_publishtime(self,obj, catch_content: CatchContentObject) -> bool:
- if not obj.get("publishtime"):
- return True
- return False
- def check_detail(self,obj, catch_content: CatchContentObject) -> bool:
- if not obj.get("detail"):
- return True
- return False
- def check_href(self,obj, catch_content: CatchContentObject) -> bool:
- if not obj.get("href"):
- return True
- return False
- def check_est_purchase_time(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 预计采购时间为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if obj.get("toptype") == "预告":
- if not obj.get("est_purchase_time"):
- return True
- return False
- return False
- def check_docstarttime(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 招标文件获取开始时间为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if obj.get("toptype") == "招标":
- if not obj.get("docstarttime"):
- return True
- return False
- return False
- def check_docendtime(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 招标文件获取截止时间为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if obj.get("toptype") == "招标":
- if not obj.get("docendtime"):
- return True
- return False
- return False
- def check_bidstarttime(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 投标文件递交开始时间为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if obj.get("toptype") == "招标":
- if not obj.get("bidstarttime"):
- return True
- return False
- return False
- def check_bidendtime(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 投标截止日期为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if obj.get("toptype") == "招标":
- if not obj.get("bidendtime"):
- return True
- return False
- return False
- def check_bidopentime(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 开标日期为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- if obj.get("toptype") == "招标":
- if not obj.get("bidopentime"):
- return True
- return False
- return False
- def check_bidway(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 投标方式为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- toptype = obj.get("toptype")
- subtype = obj.get("subtype", "")
- if toptype == "招标" or subtype in ["合同", "验收"]:
- if not obj.get("bidway"):
- return True
- return False
- return False
- def check_buyerperson(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 采购单位联系人为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- toptype = obj.get("toptype")
- subtype = obj.get("subtype", "")
- if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
- if not obj.get("buyerperson"):
- return True
- return False
- return False
- def check_buyertel(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 采购单位联系电话为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- toptype = obj.get("toptype")
- subtype = obj.get("subtype", "")
- if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
- if not obj.get("buyertel"):
- return True
- return False
- return False
- def check_agency(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 招标代理机构空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- toptype = obj.get("toptype")
- subtype = obj.get("subtype", "")
- if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
- if not obj.get("agency"):
- return True
- return False
- return False
- def check_agencyperson(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 招标代理机构联系人为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- toptype = obj.get("toptype")
- subtype = obj.get("subtype", "")
- if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
- if not obj.get("agencyperson"):
- return True
- return False
- return False
- def check_agencytel(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 招标代理机构联系电话为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- toptype = obj.get("toptype")
- subtype = obj.get("subtype", "")
- if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
- if not obj.get("agencytel"):
- return True
- return False
- return False
- def check_winnerperson(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 中标单位联系人为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["中标", "成交", "合同", "验收"]:
- if not obj.get("winnerperson"):
- return True
- return False
- return False
- def check_winnertel(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 中标单位联系电话为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["中标", "成交", "合同", "验收"]:
- if not obj.get("winnertel"):
- return True
- return False
- return False
- def check_entname(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 候选人名称为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["中标", "成交"]:
- if "winnerorder" not in obj:
- return True # 如果没有winnerorder字段,视为无entname
- for item in obj["winnerorder"]:
- if "entname" in item:
- return False # 只要有一个entname存在,就返回False
- return True # 所有条目都没有entname,返回True
- return False
- def check_sort(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 候选人名次为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["中标", "成交"]:
- if "winnerorder" not in obj:
- return True # 如果没有winnerorder字段,视为无entname
- for item in obj["winnerorder"]:
- if "sort" in item or "sortstr" in item:
- return False # 只要有一个entname存在,就返回False
- return True # 所有条目都没有entname,返回True
- return False
- def check_price(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 投标报价为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["中标", "成交"]:
- if "winnerorder" not in obj:
- return True # 如果没有winnerorder字段,视为无entname
- for item in obj["winnerorder"]:
- if "price" in item :
- return False # 只要有一个entname存在,就返回False
- return True # 所有条目都没有entname,返回True
- return False
- def check_winnerorder(self, obj, catch_content: CatchContentObject) -> bool:
- """
- 候选人信息为空检测
- :param obj:代表一个item
- :return:返回true 代表异常
- """
- subtype = obj.get("subtype", "")
- if subtype in ["中标", "成交"]:
- if "winnerorder" not in obj:
- return True # 如果没有winnerorder字段,视为无
- return False
|