NoField.py 17 KB

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