NoField.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 not bidamount:
  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 not winner:
  48. return True
  49. return False
  50. def check_buyer(self,obj,catch_content: CatchContentObject) -> bool:
  51. """
  52. 采购单位名称是否为空检测
  53. :param buyer:采购单位,多个逗号分割
  54. :param obj:代表一个item
  55. :return:返回true 代表异常
  56. """
  57. buyer = obj.get("buyer")
  58. if not buyer :
  59. return True
  60. return False
  61. def check_budget(self,obj, catch_content: CatchContentObject) -> bool:
  62. """
  63. 预算为空检测
  64. :param obj:代表一个item
  65. :return:返回true 代表异常
  66. """
  67. subtype = obj.get("subtype", "")
  68. if subtype not in ["中标", "成交", "合同", "验收"]:
  69. budget = obj.get("budget")
  70. if not budget:
  71. return True
  72. return False
  73. def check_region(self,obj, catch_content: CatchContentObject) -> bool:
  74. """
  75. 区域为空检测
  76. :param obj:代表一个item
  77. :return:返回true 代表异常
  78. """
  79. area = obj.get("area")
  80. if not area:
  81. return True
  82. return False
  83. def check_title(self,obj, catch_content: CatchContentObject) -> bool:
  84. """
  85. :param obj:代表一个item
  86. :return:返回true 代表异常
  87. """
  88. title = obj.get("title")
  89. if not title :
  90. return True
  91. return False
  92. def check_projectname(self,obj, catch_content: CatchContentObject) -> bool:
  93. """
  94. :param obj:代表一个item
  95. :return:返回true 代表异常
  96. """
  97. projectname = obj.get("projectname")
  98. if not projectname :
  99. return True
  100. return False
  101. def check_projectcode(self,obj, catch_content: CatchContentObject) -> bool:
  102. """
  103. 项目编号为空检测
  104. :param obj:代表一个item
  105. :return:返回true 代表异常
  106. """
  107. projectcode = obj.get("projectcode")
  108. if not projectcode:
  109. return True
  110. return False
  111. def check_subpackage(self,obj, catch_content: CatchContentObject) -> bool:
  112. """
  113. 公司名称检测
  114. :param obj:代表一个item
  115. :return:返回true 代表异常
  116. """
  117. pass
  118. # 处理正文
  119. # 检查因素
  120. # 是否返回 0000
  121. def check_purchasinglist(self,obj, catch_content: CatchContentObject) -> bool:
  122. if not obj.get("purchasinglist"):
  123. return True
  124. return False