NoField.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. "budget": self.check_budget,
  20. "bidamount": self.check_bidamount,
  21. "area":self.check_region,
  22. "projectcode": self.check_projectcode,
  23. "toptype":self.check_toptype,
  24. "subtype":self.check_subtype,
  25. "publishtime":self.check_publishtime,
  26. "multipackage":self.check_subpackage,
  27. "purchasinglist":self.check_purchasinglist
  28. }
  29. def check_bidamount(self,obj,catch_content: CatchContentObject) -> bool:
  30. """
  31. 中标金额为空检测
  32. :param obj:代表一个item
  33. :return:返回true 代表异常
  34. """
  35. subtype = obj.get("subtype", "")
  36. if subtype in ["中标", "成交","合同","验收"]:
  37. bidamount = obj.get("bidamount")
  38. if not bidamount:
  39. return True
  40. return False
  41. def check_winner(self,obj, catch_content: CatchContentObject) -> bool:
  42. """
  43. 中标单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空
  44. :param obj:代表一个item
  45. :return:返回true 代表异常
  46. """
  47. subtype = obj.get("subtype", "")
  48. if subtype in ["中标", "成交", "合同", "验收"]:
  49. winner = obj.get("winner")
  50. if not winner:
  51. return True
  52. return False
  53. def check_buyer(self,obj,catch_content: CatchContentObject) -> bool:
  54. """
  55. 采购单位名称是否为空检测
  56. :param buyer:采购单位,多个逗号分割
  57. :param obj:代表一个item
  58. :return:返回true 代表异常
  59. """
  60. buyer = obj.get("buyer")
  61. if not buyer :
  62. return True
  63. return False
  64. def check_budget(self,obj, catch_content: CatchContentObject) -> bool:
  65. """
  66. 预算为空检测
  67. :param obj:代表一个item
  68. :return:返回true 代表异常
  69. """
  70. subtype = obj.get("subtype", "")
  71. if subtype in ["招标", "邀标", "询价", "竞谈","单一","竞价","变更"]:
  72. budget = obj.get("budget")
  73. if not budget:
  74. return True
  75. return False
  76. def check_region(self,obj, catch_content: CatchContentObject) -> bool:
  77. """
  78. 区域为空检测
  79. :param obj:代表一个item
  80. :return:返回true 代表异常
  81. """
  82. area = obj.get("area")
  83. if not area:
  84. return True
  85. return False
  86. def check_title(self,obj, catch_content: CatchContentObject) -> bool:
  87. """
  88. :param obj:代表一个item
  89. :return:返回true 代表异常
  90. """
  91. title = obj.get("title")
  92. if not title :
  93. return True
  94. return False
  95. def check_projectname(self,obj, catch_content: CatchContentObject) -> bool:
  96. """
  97. :param obj:代表一个item
  98. :return:返回true 代表异常
  99. """
  100. projectname = obj.get("projectname")
  101. if not projectname :
  102. return True
  103. return False
  104. def check_projectcode(self,obj, catch_content: CatchContentObject) -> bool:
  105. """
  106. 项目编号为空检测
  107. :param obj:代表一个item
  108. :return:返回true 代表异常
  109. """
  110. toptype = obj.get("toptype", "")
  111. if toptype not in ["拟建","采购意向"]:
  112. projectcode = obj.get("projectcode")
  113. if not projectcode:
  114. return True
  115. return False
  116. def check_subpackage(self,obj, catch_content: CatchContentObject) -> bool:
  117. """
  118. 公司名称检测
  119. :param obj:代表一个item
  120. :return:返回true 代表异常
  121. """
  122. pass
  123. # 处理正文
  124. # 检查因素
  125. # 是否返回 0000
  126. def check_purchasinglist(self,obj, catch_content: CatchContentObject) -> bool:
  127. if not obj.get("purchasinglist"):
  128. return True
  129. return False
  130. def check_toptype(self,obj, catch_content: CatchContentObject) -> bool:
  131. """
  132. 公告一级分类检测
  133. :param obj:代表一个item
  134. :return:返回true 代表异常
  135. """
  136. if not obj.get("toptype"):
  137. return True
  138. return False
  139. def check_subtype(self,obj, catch_content: CatchContentObject) -> bool:
  140. """
  141. 公告二级分类检测
  142. :param obj:代表一个item
  143. :return:返回true 代表异常
  144. """
  145. if not obj.get("subtype"):
  146. return True
  147. return False
  148. def check_publishtime(self,obj, catch_content: CatchContentObject) -> bool:
  149. if not obj.get("publishtime"):
  150. return True
  151. return False