NoField.py 4.0 KB

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