NoField.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. "s_winner": self.check_winner,
  19. "owner":self.check_owner,
  20. "budget": self.check_budget,
  21. "bidamount": self.check_bidamount,
  22. "area":self.check_region,
  23. "city":self.check_city,
  24. "district": self.check_district,
  25. "projectcode": self.check_projectcode,
  26. "toptype":self.check_toptype,
  27. "subtype":self.check_subtype,
  28. "publishtime":self.check_publishtime,
  29. "multipackage":self.check_subpackage,
  30. "purchasinglist":self.check_purchasinglist,
  31. "detail":self.check_detail,
  32. "href":self.check_href,
  33. "est_purchase_time":self.check_est_purchase_time
  34. }
  35. def check_bidamount(self,obj,catch_content: CatchContentObject) -> bool:
  36. """
  37. 中标金额为空检测
  38. :param obj:代表一个item
  39. :return:返回true 代表异常
  40. """
  41. subtype = obj.get("subtype", "")
  42. if subtype in ["中标", "成交","合同","验收"]:
  43. bidamount = obj.get("bidamount")
  44. if not bidamount:
  45. return True
  46. return False
  47. def check_owner(self,obj, catch_content: CatchContentObject) -> bool:
  48. """
  49. 业主单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空
  50. :param obj:代表一个item
  51. :return:返回true 代表异常
  52. """
  53. subtype = obj.get("subtype", "")
  54. if subtype in ["拟建"]:
  55. owner = obj.get("owner")
  56. if not owner:
  57. return True
  58. return False
  59. def check_winner(self,obj, catch_content: CatchContentObject) -> bool:
  60. """
  61. 中标单位名称为空检测,除中标类型的标讯,其他类型标讯不检查这个字段是否为空
  62. :param obj:代表一个item
  63. :return:返回true 代表异常
  64. """
  65. subtype = obj.get("subtype", "")
  66. if subtype in ["中标", "成交", "合同", "验收"]:
  67. winner = obj.get("s_winner")
  68. if not winner:
  69. return True
  70. return False
  71. def check_buyer(self,obj,catch_content: CatchContentObject) -> bool:
  72. """
  73. 采购单位名称是否为空检测
  74. :param buyer:采购单位,多个逗号分割
  75. :param obj:代表一个item
  76. :return:返回true 代表异常
  77. """
  78. subtype = obj.get("subtype", "")
  79. if subtype not in ["拟建"]:
  80. budget = obj.get("buyer")
  81. if not budget:
  82. return True
  83. return False
  84. def check_budget(self,obj, catch_content: CatchContentObject) -> bool:
  85. """
  86. 预算为空检测
  87. :param obj:代表一个item
  88. :return:返回true 代表异常
  89. """
  90. subtype = obj.get("subtype", "")
  91. if subtype in ["招标", "邀标", "询价", "竞谈","单一","竞价","变更"]:
  92. budget = obj.get("budget")
  93. if not budget:
  94. return True
  95. return False
  96. def check_region(self,obj, catch_content: CatchContentObject) -> bool:
  97. """
  98. 省份为空检测
  99. :param obj:代表一个item
  100. :return:返回true 代表异常
  101. """
  102. area = obj.get("area")
  103. if not area:
  104. return True
  105. return False
  106. def check_city(self,obj, catch_content: CatchContentObject) -> bool:
  107. """
  108. 城市为空检测
  109. :param obj:代表一个item
  110. :return:返回true 代表异常
  111. """
  112. city = obj.get("city")
  113. if not city:
  114. return True
  115. return False
  116. def check_district(self,obj, catch_content: CatchContentObject) -> bool:
  117. """
  118. 区县为空检测
  119. :param obj:代表一个item
  120. :return:返回true 代表异常
  121. """
  122. district = obj.get("district")
  123. if not district:
  124. return True
  125. return False
  126. def check_title(self,obj, catch_content: CatchContentObject) -> bool:
  127. """
  128. :param obj:代表一个item
  129. :return:返回true 代表异常
  130. """
  131. title = obj.get("title")
  132. if not title :
  133. return True
  134. return False
  135. def check_projectname(self,obj, catch_content: CatchContentObject) -> bool:
  136. """
  137. :param obj:代表一个item
  138. :return:返回true 代表异常
  139. """
  140. projectname = obj.get("projectname")
  141. if not projectname :
  142. return True
  143. return False
  144. def check_projectcode(self,obj, catch_content: CatchContentObject) -> bool:
  145. """
  146. 项目编号为空检测
  147. :param obj:代表一个item
  148. :return:返回true 代表异常
  149. """
  150. toptype = obj.get("toptype", "")
  151. if toptype not in ["拟建","采购意向"]:
  152. projectcode = obj.get("projectcode")
  153. if not projectcode:
  154. return True
  155. return False
  156. def check_subpackage(self,obj, catch_content: CatchContentObject) -> bool:
  157. """
  158. 公司名称检测
  159. :param obj:代表一个item
  160. :return:返回true 代表异常
  161. """
  162. pass
  163. # 处理正文
  164. # 检查因素
  165. # 是否返回 0000
  166. def check_purchasinglist(self,obj, catch_content: CatchContentObject) -> bool:
  167. if not obj.get("purchasinglist"):
  168. return True
  169. return False
  170. def check_toptype(self,obj, catch_content: CatchContentObject) -> bool:
  171. """
  172. 公告一级分类检测
  173. :param obj:代表一个item
  174. :return:返回true 代表异常
  175. """
  176. if not obj.get("toptype"):
  177. return True
  178. return False
  179. def check_subtype(self,obj, catch_content: CatchContentObject) -> bool:
  180. """
  181. 公告二级分类检测
  182. :param obj:代表一个item
  183. :return:返回true 代表异常
  184. """
  185. if not obj.get("subtype"):
  186. return True
  187. return False
  188. def check_publishtime(self,obj, catch_content: CatchContentObject) -> bool:
  189. if not obj.get("publishtime"):
  190. return True
  191. return False
  192. def check_detail(self,obj, catch_content: CatchContentObject) -> bool:
  193. if not obj.get("detail"):
  194. return True
  195. return False
  196. def check_href(self,obj, catch_content: CatchContentObject) -> bool:
  197. if not obj.get("href"):
  198. return True
  199. return False
  200. def check_est_purchase_time(self, obj, catch_content: CatchContentObject) -> bool:
  201. """
  202. 预计采购时间为空检测
  203. :param obj:代表一个item
  204. :return:返回true 代表异常
  205. """
  206. if obj.get("toptype") == "预告":
  207. if not obj.get("est_purchase_time"):
  208. return True
  209. return False
  210. return False
  211. def check_docstarttime(self, obj, catch_content: CatchContentObject) -> bool:
  212. """
  213. 招标文件获取开始时间为空检测
  214. :param obj:代表一个item
  215. :return:返回true 代表异常
  216. """
  217. if obj.get("toptype") == "招标":
  218. if not obj.get("docstarttime"):
  219. return True
  220. return False
  221. return False
  222. def check_docendtime(self, obj, catch_content: CatchContentObject) -> bool:
  223. """
  224. 招标文件获取截止时间为空检测
  225. :param obj:代表一个item
  226. :return:返回true 代表异常
  227. """
  228. if obj.get("toptype") == "招标":
  229. if not obj.get("docendtime"):
  230. return True
  231. return False
  232. return False
  233. def check_bidstarttime(self, obj, catch_content: CatchContentObject) -> bool:
  234. """
  235. 投标文件递交开始时间为空检测
  236. :param obj:代表一个item
  237. :return:返回true 代表异常
  238. """
  239. if obj.get("toptype") == "招标":
  240. if not obj.get("bidstarttime"):
  241. return True
  242. return False
  243. return False
  244. def check_bidendtime(self, obj, catch_content: CatchContentObject) -> bool:
  245. """
  246. 投标截止日期为空检测
  247. :param obj:代表一个item
  248. :return:返回true 代表异常
  249. """
  250. if obj.get("toptype") == "招标":
  251. if not obj.get("bidendtime"):
  252. return True
  253. return False
  254. return False
  255. def check_bidopentime(self, obj, catch_content: CatchContentObject) -> bool:
  256. """
  257. 开标日期为空检测
  258. :param obj:代表一个item
  259. :return:返回true 代表异常
  260. """
  261. if obj.get("toptype") != "结果" and obj.get("toptype") != "预告":
  262. if not obj.get("bidopentime"):
  263. return True
  264. return False
  265. return False
  266. def check_bidway(self, obj, catch_content: CatchContentObject) -> bool:
  267. """
  268. 投标方式为空检测
  269. :param obj:代表一个item
  270. :return:返回true 代表异常
  271. """
  272. toptype = obj.get("toptype")
  273. subtype = obj.get("subtype", "")
  274. if toptype == "招标" or subtype in ["合同", "验收"]:
  275. if not obj.get("bidway"):
  276. return True
  277. return False
  278. return False
  279. def check_buyerperson(self, obj, catch_content: CatchContentObject) -> bool:
  280. """
  281. 采购单位联系人为空检测
  282. :param obj:代表一个item
  283. :return:返回true 代表异常
  284. """
  285. toptype = obj.get("toptype")
  286. subtype = obj.get("subtype", "")
  287. if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
  288. if not obj.get("buyerperson"):
  289. return True
  290. return False
  291. return False
  292. def check_buyertel(self, obj, catch_content: CatchContentObject) -> bool:
  293. """
  294. 采购单位联系电话为空检测
  295. :param obj:代表一个item
  296. :return:返回true 代表异常
  297. """
  298. toptype = obj.get("toptype")
  299. subtype = obj.get("subtype", "")
  300. if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
  301. if not obj.get("buyertel"):
  302. return True
  303. return False
  304. return False
  305. def check_agency(self, obj, catch_content: CatchContentObject) -> bool:
  306. """
  307. 招标代理机构空检测
  308. :param obj:代表一个item
  309. :return:返回true 代表异常
  310. """
  311. toptype = obj.get("toptype")
  312. subtype = obj.get("subtype", "")
  313. if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
  314. if not obj.get("agency"):
  315. return True
  316. return False
  317. return False
  318. def check_agencyperson(self, obj, catch_content: CatchContentObject) -> bool:
  319. """
  320. 招标代理机构联系人为空检测
  321. :param obj:代表一个item
  322. :return:返回true 代表异常
  323. """
  324. toptype = obj.get("toptype")
  325. subtype = obj.get("subtype", "")
  326. if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
  327. if not obj.get("agencyperson"):
  328. return True
  329. return False
  330. return False
  331. def check_agencytel(self, obj, catch_content: CatchContentObject) -> bool:
  332. """
  333. 招标代理机构联系电话为空检测
  334. :param obj:代表一个item
  335. :return:返回true 代表异常
  336. """
  337. toptype = obj.get("toptype")
  338. subtype = obj.get("subtype", "")
  339. if toptype =="招标" or subtype in ["中标", "成交", "合同", "验收"]:
  340. if not obj.get("agencytel"):
  341. return True
  342. return False
  343. return False
  344. def check_winnerperson(self, obj, catch_content: CatchContentObject) -> bool:
  345. """
  346. 中标单位联系人为空检测
  347. :param obj:代表一个item
  348. :return:返回true 代表异常
  349. """
  350. subtype = obj.get("subtype", "")
  351. if subtype in ["中标", "成交", "合同", "验收"]:
  352. if not obj.get("winnerperson"):
  353. return True
  354. return False
  355. return False
  356. def check_winnertel(self, obj, catch_content: CatchContentObject) -> bool:
  357. """
  358. 中标单位联系电话为空检测
  359. :param obj:代表一个item
  360. :return:返回true 代表异常
  361. """
  362. subtype = obj.get("subtype", "")
  363. if subtype in ["中标", "成交", "合同", "验收"]:
  364. if not obj.get("winnertel"):
  365. return True
  366. return False
  367. return False
  368. def check_entname(self, obj, catch_content: CatchContentObject) -> bool:
  369. """
  370. 候选人名称为空检测
  371. :param obj:代表一个item
  372. :return:返回true 代表异常
  373. """
  374. subtype = obj.get("subtype", "")
  375. if subtype in ["中标", "成交"]:
  376. if "winnerorder" not in obj:
  377. return True # 如果没有winnerorder字段,视为无entname
  378. for item in obj["winnerorder"]:
  379. if "entname" in item:
  380. return False # 只要有一个entname存在,就返回False
  381. return True # 所有条目都没有entname,返回True
  382. return False
  383. def check_sort(self, obj, catch_content: CatchContentObject) -> bool:
  384. """
  385. 候选人名次为空检测
  386. :param obj:代表一个item
  387. :return:返回true 代表异常
  388. """
  389. subtype = obj.get("subtype", "")
  390. if subtype in ["中标", "成交"]:
  391. if "winnerorder" not in obj:
  392. return True # 如果没有winnerorder字段,视为无entname
  393. for item in obj["winnerorder"]:
  394. if "sort" in item or "sortstr" in item:
  395. return False # 只要有一个entname存在,就返回False
  396. return True # 所有条目都没有entname,返回True
  397. return False
  398. def check_price(self, obj, catch_content: CatchContentObject) -> bool:
  399. """
  400. 投标报价为空检测
  401. :param obj:代表一个item
  402. :return:返回true 代表异常
  403. """
  404. subtype = obj.get("subtype", "")
  405. if subtype in ["中标", "成交"]:
  406. if "winnerorder" not in obj:
  407. return True # 如果没有winnerorder字段,视为无entname
  408. for item in obj["winnerorder"]:
  409. if "price" in item :
  410. return False # 只要有一个entname存在,就返回False
  411. return True # 所有条目都没有entname,返回True
  412. return False