NoField.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # coding:utf-8
  2. from tables import CatchContentObject, fsc
  3. from util.sensitive_word import AcAutomation
  4. from docs.config import amount_config
  5. from docs.config import budget_config
  6. from docs.config import DEBUG
  7. from docs.config import abnormal_config
  8. import csv
  9. class NoFieldChecker(object):
  10. """
  11. 无字段或空值检查
  12. """
  13. def __init__(self):
  14. self.errors_tables = {
  15. "title": self.check_title,
  16. "projectname": self.check_projectname,
  17. "buyer":self.check_buyer,
  18. "winner": self.check_winner,
  19. "owner":self.check_owner,
  20. "budget": self.check_budget,
  21. "bidamount": self.check_bidamount,
  22. "area":self.check_region,
  23. "projectcode": self.check_projectcode,
  24. "toptype":self.check_toptype,
  25. "subtype":self.check_subtype,
  26. "publishtime":self.check_publishtime,
  27. "multipackage":self.check_subpackage,
  28. "purchasinglist":self.check_purchasinglist
  29. }
  30. def check_bidamount(self,obj,catch_content: CatchContentObject) -> bool:
  31. """
  32. 中标金额为空检测
  33. :param obj:代表一个item
  34. :return:返回true 代表异常
  35. """
  36. subtype = obj.get("subtype", "")
  37. if subtype in ["中标", "成交","合同","验收"]:
  38. bidamount = obj.get("bidamount")
  39. if not bidamount:
  40. return True
  41. return False
  42. def check_owner(self,obj, catch_content: CatchContentObject) -> bool:
  43. """
  44. 业主单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空
  45. :param obj:代表一个item
  46. :return:返回true 代表异常
  47. """
  48. subtype = obj.get("subtype", "")
  49. if subtype in ["拟建"]:
  50. owner = obj.get("owner")
  51. if not owner:
  52. return True
  53. return False
  54. def check_winner(self,obj, catch_content: CatchContentObject) -> bool:
  55. """
  56. 中标单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空
  57. :param obj:代表一个item
  58. :return:返回true 代表异常
  59. """
  60. subtype = obj.get("subtype", "")
  61. if subtype in ["中标", "成交", "合同", "验收"]:
  62. winner = obj.get("winner")
  63. if not winner:
  64. return True
  65. return False
  66. def check_buyer(self,obj,catch_content: CatchContentObject) -> bool:
  67. """
  68. 采购单位名称是否为空检测
  69. :param buyer:采购单位,多个逗号分割
  70. :param obj:代表一个item
  71. :return:返回true 代表异常
  72. """
  73. subtype = obj.get("subtype", "")
  74. if subtype not in ["拟建"]:
  75. budget = obj.get("buyer")
  76. if not budget:
  77. return True
  78. return False
  79. def check_budget(self,obj, catch_content: CatchContentObject) -> bool:
  80. """
  81. 预算为空检测
  82. :param obj:代表一个item
  83. :return:返回true 代表异常
  84. """
  85. subtype = obj.get("subtype", "")
  86. if subtype in ["招标", "邀标", "询价", "竞谈","单一","竞价","变更"]:
  87. budget = obj.get("budget")
  88. if not budget:
  89. return True
  90. return False
  91. def check_region(self,obj, catch_content: CatchContentObject) -> bool:
  92. """
  93. 区域为空检测
  94. :param obj:代表一个item
  95. :return:返回true 代表异常
  96. """
  97. area = obj.get("area")
  98. if not area:
  99. return True
  100. return False
  101. def check_title(self,obj, catch_content: CatchContentObject) -> bool:
  102. """
  103. :param obj:代表一个item
  104. :return:返回true 代表异常
  105. """
  106. title = obj.get("title")
  107. if not title :
  108. return True
  109. return False
  110. def check_projectname(self,obj, catch_content: CatchContentObject) -> bool:
  111. """
  112. :param obj:代表一个item
  113. :return:返回true 代表异常
  114. """
  115. projectname = obj.get("projectname")
  116. if not projectname :
  117. return True
  118. return False
  119. def check_projectcode(self,obj, catch_content: CatchContentObject) -> bool:
  120. """
  121. 项目编号为空检测
  122. :param obj:代表一个item
  123. :return:返回true 代表异常
  124. """
  125. toptype = obj.get("toptype", "")
  126. if toptype not in ["拟建","采购意向"]:
  127. projectcode = obj.get("projectcode")
  128. if not projectcode:
  129. return True
  130. return False
  131. def check_subpackage(self,obj, catch_content: CatchContentObject) -> bool:
  132. """
  133. 公司名称检测
  134. :param obj:代表一个item
  135. :return:返回true 代表异常
  136. """
  137. pass
  138. # 处理正文
  139. # 检查因素
  140. # 是否返回 0000
  141. def check_purchasinglist(self,obj, catch_content: CatchContentObject) -> bool:
  142. if not obj.get("purchasinglist"):
  143. return True
  144. return False
  145. def check_toptype(self,obj, catch_content: CatchContentObject) -> bool:
  146. """
  147. 公告一级分类检测
  148. :param obj:代表一个item
  149. :return:返回true 代表异常
  150. """
  151. if not obj.get("toptype"):
  152. return True
  153. return False
  154. def check_subtype(self,obj, catch_content: CatchContentObject) -> bool:
  155. """
  156. 公告二级分类检测
  157. :param obj:代表一个item
  158. :return:返回true 代表异常
  159. """
  160. if not obj.get("subtype"):
  161. return True
  162. return False
  163. def check_publishtime(self,obj, catch_content: CatchContentObject) -> bool:
  164. if not obj.get("publishtime"):
  165. return True
  166. return False