NoField.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. "multipackage":self.check_subpackage,
  24. "purchasinglist":self.check_purchasinglist
  25. }
  26. def check_bidamount(self,obj,catch_content: CatchContentObject) -> bool:
  27. """
  28. 中标金额为空检测
  29. :param obj:代表一个item
  30. :return:返回true 代表异常
  31. """
  32. subtype = obj.get("subtype", "")
  33. if subtype in ["中标", "成交","合同","验收"]:
  34. bidamount = obj.get("bidamount", "")
  35. if bidamount:
  36. return False
  37. return True
  38. return False
  39. def check_winner(self,obj, catch_content: CatchContentObject) -> bool:
  40. """
  41. 中标单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空
  42. :param obj:代表一个item
  43. :return:返回true 代表异常
  44. """
  45. subtype = obj.get("subtype", "")
  46. if subtype in ["中标", "成交", "合同", "验收"]:
  47. winner = obj.get("winner", "")
  48. if winner:
  49. return False
  50. return True
  51. return False
  52. def check_buyer(self,obj,catch_content: CatchContentObject) -> bool:
  53. """
  54. 采购单位名称是否为空检测
  55. :param buyer:采购单位,多个逗号分割
  56. :param obj:代表一个item
  57. :return:返回true 代表异常
  58. """
  59. buyer = obj.get("buyer", "")
  60. if buyer :
  61. return False
  62. return True
  63. def check_budget(self,obj, catch_content: CatchContentObject) -> bool:
  64. """
  65. 预算为空检测
  66. :param obj:代表一个item
  67. :return:返回true 代表异常
  68. """
  69. subtype = obj.get("subtype", "")
  70. if subtype not in ["中标", "成交", "合同", "验收"]:
  71. budget = obj.get("budget", "")
  72. if budget:
  73. return False
  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. pass
  83. # 处理正文
  84. # 检查因素
  85. # 是否返回 0000
  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 title :
  93. return False
  94. return True
  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 projectname :
  102. return False
  103. return True
  104. def check_projectcode(self,obj, catch_content: CatchContentObject) -> bool:
  105. """
  106. 项目编号为空检测
  107. :param obj:代表一个item
  108. :return:返回true 代表异常
  109. """
  110. projectcode = obj.get("projectcode", "")
  111. if projectcode:
  112. return False
  113. return True
  114. def check_subpackage(self,obj, catch_content: CatchContentObject) -> bool:
  115. """
  116. 公司名称检测
  117. :param obj:代表一个item
  118. :return:返回true 代表异常
  119. """
  120. pass
  121. # 处理正文
  122. # 检查因素
  123. # 是否返回 0000
  124. def check_purchasinglist(self,obj, catch_content: CatchContentObject) -> bool:
  125. if not obj.get("purchasinglist"):
  126. return True
  127. return False