def add_brand(brand_name): brand_vo = MBrand.get_brand_by_name(brand_name) if brand_vo is None: brand_id = MPkGenerator.get_pk('brand') brand_vo = { 'brand_id': brand_id, 'brand_name': brand_name, 'brand_pics': 0 } MBrand.insert(brand_vo) return brand_vo['brand_id']
def add_model(brand_id, model_name): model_vo = MModel.get_model_by_name(model_name) if model_vo is None: model_id = MPkGenerator.get_pk('model') model_vo = { 'model_id': model_id, 'brand_id': brand_id, 'model_name': model_name, 'model_num': 0 } MModel.insert(model_vo) return model_vo['model_id']
def create_delta_ds(worker_id): ''' 在t_delta_ds表中生成新记录 ''' delta_ds_id = MPkGenerator.get_pk('delta_ds') delta_ds_vo = { 'delta_ds_id': delta_ds_id, 'worker_id': worker_id, 'state': 0 } MDeltaDs.insert(delta_ds_vo) return delta_ds_id
def add_bmy(brand_id, model_id, bmy_name): bmy_vo = MBmy.get_bmy_by_name(bmy_name) if bmy_vo is None: bmy_id = MPkGenerator.get_pk('bmy') bmy_vo = { 'brand_id': brand_id, 'model_id': model_id, 'bmy_id': bmy_id, 'bmy_name': bmy_name, 'bmy_pics': 0 } MBmy.insert(bmy_vo) return bmy_vo['bmy_id']
def add_delta_ds_detl(delta_ds_id, data_source_id, image_full_path, bmy_id): delta_ds_detl_id = MPkGenerator.get_pk('delta_ds_detl') delta_ds_detl_vo = { 'delta_ds_detl_id': delta_ds_detl_id, 'delta_ds_id': delta_ds_id, 'data_source_id': data_source_id, 'image_full_path': image_full_path, 'bmy_id': bmy_id, 'state': 4, 'last_date': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) } MDeltaDsDetl.insert(delta_ds_detl_vo) return delta_ds_detl_id
def add_data_source_sample(vehicle_image_id, bmy_id, sample_type): rec = MDataSource.get_data_source_by_vid(vehicle_image_id, bmy_id) if rec is None: data_source_id = MPkGenerator.get_pk('data_source') data_source_vo = { 'data_source_id': data_source_id, 'vehicle_image_id': vehicle_image_id, 'bmy_id': bmy_id, 'state': 0, 'type': sample_type } MDataSource.insert(data_source_vo) else: data_source_id = rec['data_source_id'] return data_source_id
def add_vehicle_image(image_file): ''' 将图片文件保存到t_vehicle_image表中 参数:image_file 全路径图片文件名 返回值:vehicle_image_id ''' arrs0 = image_file.split('/') filename = arrs0[-1] rec = CVehicleImage.get_vehicle_image_vo(filename) if rec is None: vehicle_image_id = MPkGenerator.get_pk('vehicle_image') vehicle_image_vo = { 'vehicle_image_id': vehicle_image_id, 'filename': filename, 'full_path': image_file } MVehicleImage.insert(vehicle_image_vo) else: vehicle_image_id = rec['vehicle_image_id'] return vehicle_image_id
def set_bmy_example_vehicle_image_id(bmy_id, vehicle_image_id): bmy_example_id = MPkGenerator.get_pk('bmy_example') MBmyExample.set_bmy_example_vehicle_image_id(bmy_example_id, bmy_id, vehicle_image_id)