def get_case_lawyer_schema_before(): sql = 'select `id`,`lawyer_id`,`json_batch_count`,`createdate`,`updatedate`,`page_json`,`index`,`status` from case_lawyer_schema_before where `status`=00 order by `createdate` asc LIMIT 1' row = db_helper.fetch_one(sql) after_sql = 'update case_lawyer_schema_before set `status`=%s where `id`=%s' db_helper.update(after_sql, ('10', row.get('id'))) logging.info(row) return row
def update_fail_case_lawyer_schema(doc_id): try: sql = '''UPDATE case_lawyer_schema SET beautiful_html_status={} where json_data_id=%s'''.format( BEAUTIFUL_HTML_STATUS_09) db_helper.update(sql, (doc_id, )) except Exception as e: logging.error(e)
def insert_case_lawyer_schema(lawyer_id, page_json): global remark remark = True # 通过cursor创建游标 page_data = json.loads(page_json) template_sql = '''INSERT INTO `case_lawyer_schema` (`id`, `lawyer_id`, `json_batch_count`, `json_data_context`, `json_data_type`, `json_data_date`, `json_data_name`, `json_data_id`, `json_data_level`, `json_data_number`, `json_data_court` ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)''' json_batch_count = -1 global run_eval run_eval = None run_eval_key = None for it in page_data: if it.get("RunEval") is not None: run_eval = it.get("RunEval") run_eval_key = unzip_helper(run_eval, browser) if it.get("Count") is not None: json_batch_count = int(it.get("Count")) continue id = str(uuid.uuid1()) json_data_context = it.get("裁判要旨段原文") json_data_type = it.get("案件类型") json_data_date = it.get("裁判日期") json_data_name = it.get("案件名称") _json_data_id = doc_id_helper(it.get("文书ID"), run_eval_key, browser) logging.info(_json_data_id) json_data_id = _json_data_id json_data_level = it.get("审判程序") json_data_number = it.get("案号") json_data_court = it.get("法院名称") try: db_helper.insert( template_sql, (id, lawyer_id, json_batch_count, json_data_context, json_data_type, json_data_date, json_data_name, json_data_id, json_data_level, json_data_number, json_data_court)) except IntegrityError: remark = False logging.exception("发生了错误 IntegrityError") db_helper.update( 'update case_lawyer set repeatcont=repeatcont+1 where id=%s', (lawyer_id, )) except Exception: logging.exception("发生了错误") return remark
def update_case_lawyer_schema(doc_id, case_type, html_view, html_source_js): try: sql = '''UPDATE case_lawyer_schema SET beautiful_html_status=%s,beautiful_html_view=%s,beautiful_case_type=%s,beautiful_html_source_js=%s where json_data_id=%s''' db_helper.update(sql, ( BEAUTIFUL_HTML_STATUS_10, html_view, case_type, html_source_js, doc_id, )) except Exception as e: logging.error(e)
def update_lawyercase(detail={}): match = False lawyer_id = detail.get("lawyer_id") caseType = detail.get("beautiful_case_type") content = detail.get("beautiful_html_view") sourceId = detail.get("json_data_id") sql = '''SELECT `id`,lawyer_id,sourceFrom from lawyerCase where lawyer_id=%s and sourceId=%s limit 1''' row = db_helper.fetch_one(sql, ( lawyer_id, sourceId, )) if row is None: return match match = True row = db_helper.update( '''UPDATE lawyerCase SET sourceFrom=%s,caseType=%s,content=%s where lawyer_id=%s and sourceId=%s''', ( SOURCEFROM, caseType, content, lawyer_id, sourceId, )) logging.info("已经更新" + str(row) + str(detail)) return match
def update_pending_doc(doc_id, case_type): template_sql = ''' UPDATE lawyerCase SET caseType=%s,pending='10' WHERE `id`=%s ''' return db_helper.update(template_sql, ( case_type, doc_id, ))
def update_case_lawyer_schema_on_detail_sucess(detail={}): if detail is None: return id = detail.get("id") try: sql = '''UPDATE case_lawyer_schema SET sync_status=%s where `id`=%s''' row = db_helper.update(sql, ( SYNC_STATUS_20, id, )) logging.info(str(row)) except Exception as e: logging.exception("error.")
def update_case_lawyer_process(process, lawyer_id): template_sql = '''update `case_lawyer` set `process`= %s where `id`= %s''' db_helper.update(template_sql, (process, lawyer_id))
def update_case_lawyer_on_fail(lawyer_id): template_sql = '''update `case_lawyer` set fail=fail+1 where `id`= %s''' db_helper.update(template_sql, (lawyer_id, )) update_case_lawyer_process(0, lawyer_id)
def update_case_lawyer_on_sucess(lawyer_id, index): template_sql = '''update `case_lawyer` set `pageindex`=%s where `id`= %s''' db_helper.update(template_sql, ( index, lawyer_id, ))
def update_case_lawyer(lawyer_id, casenum): template_sql = '''update `case_lawyer` set `casenum`= %s,deal=TRUE where `id`= %s''' db_helper.update(template_sql, (casenum, lawyer_id)) update_case_lawyer_process(0, lawyer_id)