NoField.py 16 KB

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