publishtime.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. 中标时间字段检查
  3. """
  4. import time
  5. class PublishtimeChecker(object):
  6. """
  7. 开标时间字段检查
  8. """
  9. def __init__(self):
  10. self.errors_tables = {
  11. "0201": {
  12. "name": "发布时间 > 开标时间",
  13. "parent_name": "数据范围类型",
  14. "parent_code": "02",
  15. "checkFn": self.check0201
  16. },
  17. "0202": {
  18. "name": "发布时间 > 当前时间",
  19. "parent_name": "数据范围类型",
  20. "parent_code": "02",
  21. "checkFn": self.check0202
  22. }
  23. }
  24. def check0201(self, subtype:str,bidopentime: int,publishtime:int ) -> bool:
  25. """
  26. return true 代表返回异常
  27. """
  28. if subtype in ["招标", "邀标", "询价", "竞谈","单一","竞价","变更"]:
  29. if bidopentime and publishtime:
  30. if bidopentime < publishtime :
  31. return True
  32. else:
  33. return False
  34. else:
  35. # 两者中有一方为空不判断
  36. return False
  37. else:
  38. return False
  39. def check0202(self, publishtime:int ) -> bool:
  40. current_timestamp = int(time.time())
  41. if publishtime > current_timestamp:
  42. return True
  43. else:
  44. return False