def cmpare_hbc(self): maxid = self.get_cltxmaxid()['maxid'] if maxid <= self.id_flag: # 没有新的数据 返回1 time.sleep(1) return 1 carinfo = self.get_cltxs() if carinfo['total_count'] == 0: if self.id_flag + self.step < maxid: self.id_flag += self.step else: self.id_flag = maxid self.myini.set_hbc(self.id_flag) time.sleep(1) #print 'id_flag: %s' % self.id_flag return 0 elif carinfo['total_count'] < self.step: time.sleep(1) # 黄标车检测 list # hbc_list = [] for i in carinfo['items']: # 判断车牌是否需要黄标车查询 f_hphm = helper.fix_hphm(i['hphm'], i['hpys_code']) if f_hphm['hpzl'] != '00': # 是否在黄标车集合里面 if (f_hphm['hphm'], f_hphm['hpzl']) in self.hzhbc_set: jgsj = arrow.get(i['jgsj']) #print u'黄表车: %s, 号牌颜色: %s' % (i['hphm'], i['hpys']) hbc_img = self.check_hbc_img_by_hphm(jgsj.format('YYYY-MM-DD'), i['hphm']) imgpath = '' if hbc_img['total_count'] == 0: try: #path = u'd://videoandimage/'+u'%s年%s月%s日'%(i['jgsj'][:4], i['jgsj'][5:7], i['jgsj'][8:10])+u'/'+u'违章图片目录' path = u'%s/%s/违章图片目录' % (self.img_file, jgsj.format('YYYY年MM月DD日')) #name = u'机号'+self.floder2[i['kkdd_id']]+u'车道A'+str(i['cdbh'])+jgsj.format('YYYY年MM月DD日HH时mm分ss秒')+u'R454DOK3'+u'T'+f_hphm['cpzl']+u'C'+self.hpys5[i['hpys_code']]+u'P'+i['hphm']+u'驶向'+self.fxbh3.get(i['fxbh_code'],u'无')+u'违章黄标车违反禁令标志' name = u'机号%s车道A%s%sR454DOK3T%sC%sP%s驶向%s违章黄标车违反禁令标志' % (self.floder2[i['kkdd_id']], i['cdbh'], jgsj.format('YYYY年MM月DD日HH时mm分ss秒'), f_hphm['cpzl'], self.hpys5[i['hpys_code']], i['hphm'], self.fxbh3.get(i['fxbh_code'], u'无')) imgpath = self.get_img_by_url(i['imgurl'], path, name) except Exception as e: logger.error('url: %s' % i['imgurl']) logger.error(e) imgpath = '' data = { 'jgsj': i['jgsj'], 'hphm': i['hphm'], 'kkdd_id': i['kkdd_id'], 'hpys_code': i['hpys_code'], 'fxbh_code': i['fxbh_code'], 'cdbh': i['cdbh'], 'imgurl': i['imgurl'], 'imgpath': imgpath } self.add_hbc(data)
def cmpare_hbc(self, i): """根据车辆信息比对黄标车""" # 判断车牌是否需要黄标车查询 f_hphm = helper.fix_hphm(i['hphm'], i['hpys_code']) if f_hphm['hpzl'] == '00': return # 是否在黄标车集合里面 if not self.check_hbc(f_hphm['hphm'], f_hphm['hpzl']): return jgsj = arrow.get(i['jgsj']) # print u'黄表车: %s, 号牌颜色: %s' % (i['hphm'], i['hpys']) hbc_img = self.check_hbc_img_by_hphm(jgsj.format('YYYY-MM-DD'), i['hphm']) imgpath = '' if hbc_img['total_count'] == 0: try: path = u'%s/%s/违章图片目录' % (self.hbc_img_path, jgsj.format(u'YYYY年MM月DD日')) # 图片名称 name = u'机号%s车道A%s%sR454DOK3T%sC%sP%s驶向%s违章黄标车违反禁令标志' % ( self.jh_dict[i['kkdd_id']], i['cdbh'], jgsj.format(u'YYYY年MM月DD日HH时mm分ss秒'), f_hphm['cpzl'], self.hpys_dict[i['hpys_code']], i['hphm'], self.fxbh_dict.get(i['fxbh_code'], u'其他')) # 水印内容 text = u'违法时间:%s 违法地点:%s%s\n违法代码:13441 违法行为:违章黄标车 设备编号:%s\n防伪码:%s' % ( i['jgsj'], self.city_name, i['kkdd'], self.sbdh_dict[i['kkdd_id']], helper.get_sign()) # 违章路标图片 wz_img = self.hbc_img_dict.get((i['kkdd_id'], i['fxbh_code']), None) ## if wz_img is not None: ## wz_img = u'hbc_img/'+wz_img imgpath = img_builder.get_img_by_url(i['imgurl'], path, name, text, wz_img) except Exception as e: logger.error('url: %s' % i['imgurl']) logger.error(e) imgpath = '' data = { 'jgsj': i['jgsj'], 'hphm': i['hphm'], 'kkdd_id': i['kkdd_id'], 'hpys_code': i['hpys_code'], 'fxbh_code': i['fxbh_code'], 'cdbh': i['cdbh'], 'imgurl': i['imgurl'], 'imgpath': imgpath } # 添加黄标车信息到数据库 self.add_hbc(data)
def cmpare_hbc(self, i): """根据车辆信息比对黄标车""" # 判断车牌是否需要黄标车查询 f_hphm = helper.fix_hphm(i['hphm'], i['hpys_code']) if f_hphm['hpzl'] == '00': return # 是否在黄标车集合里面 if not self.check_hbc(f_hphm['hphm'], f_hphm['hpzl']): return jgsj = arrow.get(i['jgsj']) # print u'黄表车: %s, 号牌颜色: %s' % (i['hphm'], i['hpys']) hbc_img = self.check_hbc_img_by_hphm( jgsj.format('YYYY-MM-DD'), i['hphm']) imgpath = '' if hbc_img['total_count'] == 0: try: path = u'%s/%s/违章图片目录' % ( self.hbc_img_path, jgsj.format(u'YYYY年MM月DD日')) # 图片名称 name = u'机号%s车道A%s%sR454DOK3T%sC%sP%s驶向%s违章黄标车违反禁令标志' % ( self.jh_dict[i['kkdd_id']], i['cdbh'], jgsj.format(u'YYYY年MM月DD日HH时mm分ss秒'), f_hphm['cpzl'], self.hpys_dict[i['hpys_code']], i['hphm'], self.fxbh_dict.get(i['fxbh_code'], u'其他')) # 水印内容 text = u'违法时间:%s 违法地点:%s%s\n违法代码:13441 违法行为:违章黄标车 设备编号:%s\n防伪码:%s' % ( i['jgsj'], self.city_name, i['kkdd'], self.sbdh_dict[i['kkdd_id']], helper.get_sign()) # 违章路标图片 wz_img = self.hbc_img_dict.get((i['kkdd_id'], i['fxbh_code']), None) ## if wz_img is not None: ## wz_img = u'hbc_img/'+wz_img imgpath = img_builder.get_img_by_url( i['imgurl'], path, name, text, wz_img) except Exception as e: logger.error('url: %s' % i['imgurl']) logger.error(e) imgpath = '' data = { 'jgsj': i['jgsj'], 'hphm': i['hphm'], 'kkdd_id': i['kkdd_id'], 'hpys_code': i['hpys_code'], 'fxbh_code': i['fxbh_code'], 'cdbh': i['cdbh'], 'imgurl': i['imgurl'], 'imgpath': imgpath } # 添加黄标车信息到数据库 self.add_hbc(data)