NoField.py 19 KB

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