补充存表
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import socket
|
||||
|
||||
from paddleocr import PaddleOCR
|
||||
|
||||
# 主机名
|
||||
HOSTNAME = socket.gethostname()
|
||||
|
||||
"""
|
||||
项目配置
|
||||
"""
|
||||
|
||||
@@ -8,7 +8,7 @@ from sqlalchemy import update, and_
|
||||
|
||||
from db import MysqlSession
|
||||
from db.mysql import ZxPhrec, ZxPhhd
|
||||
from photo_mask import OCR, PHHD_BATCH_SIZE, SLEEP_MINUTES, NAME_KEYS, ID_CARD_NUM_KEYS, SIMILAR_CHAR
|
||||
from photo_mask import OCR, PHHD_BATCH_SIZE, SLEEP_MINUTES, NAME_KEYS, ID_CARD_NUM_KEYS, SIMILAR_CHAR, HOSTNAME
|
||||
from ucloud import BUCKET, ufile
|
||||
from util import image_util, util
|
||||
|
||||
@@ -216,7 +216,7 @@ def mask_photo(img_url, name, id_card_num, color=(255, 255, 255)):
|
||||
|
||||
def photo_mask(pk_phhd, name, id_card_num):
|
||||
session = MysqlSession()
|
||||
phrecs = session.query(ZxPhrec.cfjaddress).filter(and_(
|
||||
phrecs = session.query(ZxPhrec.pk_phrec, ZxPhrec.cfjaddress).filter(and_(
|
||||
ZxPhrec.pk_phhd == pk_phhd,
|
||||
ZxPhrec.cRectype.in_(["3", "4"])
|
||||
)).all()
|
||||
@@ -236,6 +236,13 @@ def photo_mask(pk_phhd, name, id_card_num):
|
||||
cv2.imwrite(temp_file.name, image)
|
||||
try:
|
||||
ufile.upload_file(phrec.cfjaddress, temp_file.name)
|
||||
session = MysqlSession()
|
||||
update_flag = (update(ZxPhrec).where(ZxPhrec.pk_phrec == phrec.pk_phrec).values(
|
||||
paint_user=HOSTNAME,
|
||||
paint_date=util.get_default_datetime()))
|
||||
session.execute(update_flag)
|
||||
session.commit()
|
||||
session.close()
|
||||
except Exception as e:
|
||||
logging.error("上传图片出错", exc_info=e)
|
||||
finally:
|
||||
@@ -266,6 +273,7 @@ def main():
|
||||
session = MysqlSession()
|
||||
update_flag = (update(ZxPhhd).where(ZxPhhd.pk_phhd == pk_phhd).values(
|
||||
paint_flag="8",
|
||||
paint_user=HOSTNAME,
|
||||
paint_date=util.get_default_datetime()))
|
||||
session.execute(update_flag)
|
||||
session.commit()
|
||||
|
||||
@@ -19,7 +19,6 @@ from ucloud import ufile
|
||||
from util import image_util, util
|
||||
from util.data_util import handle_date, handle_decimal, parse_department, handle_name, \
|
||||
handle_insurance_type, handle_original_data, handle_hospital, handle_department, handle_id, handle_age, parse_money
|
||||
from util.util import get_default_datetime
|
||||
|
||||
|
||||
# 合并信息抽取结果
|
||||
@@ -86,7 +85,7 @@ def information_extraction(ie, phrecs):
|
||||
rotated_img = image_util.rotate(split_result["img"], int(angles[1]))
|
||||
ie_results.append({"result": ie_temp_image(ie, OCR, rotated_img), "angle": angles[1]})
|
||||
|
||||
now = get_default_datetime()
|
||||
now = util.get_default_datetime()
|
||||
for ie_result in ie_results:
|
||||
result_json = json.dumps(ie_result["result"], ensure_ascii=False)
|
||||
if len(result_json) > 5000:
|
||||
@@ -142,7 +141,7 @@ def save_or_update_ie(table, pk_phhd, data):
|
||||
obj = table(**data)
|
||||
session = MysqlSession()
|
||||
db_data = session.query(table).filter_by(pk_phhd=pk_phhd).one_or_none()
|
||||
now = get_default_datetime()
|
||||
now = util.get_default_datetime()
|
||||
if db_data:
|
||||
# 更新
|
||||
db_data.update_time = now
|
||||
@@ -282,7 +281,7 @@ def main():
|
||||
.distinct().limit(PHHD_BATCH_SIZE).all())
|
||||
# 将状态改为正在识别中
|
||||
pk_phhd_values = [phhd.pk_phhd for phhd in phhds]
|
||||
update_flag = (update(ZxPhhd).where(ZxPhhd.pk_phhd.in_(pk_phhd_values)).values(exsuccess_flag=2))
|
||||
update_flag = (update(ZxPhhd).where(ZxPhhd.pk_phhd.in_(pk_phhd_values)).values(exsuccess_flag="2"))
|
||||
session.execute(update_flag)
|
||||
session.commit()
|
||||
session.close()
|
||||
@@ -294,7 +293,10 @@ def main():
|
||||
|
||||
# 识别完成更新标识
|
||||
session = MysqlSession()
|
||||
update_flag = (update(ZxPhhd).where(ZxPhhd.pk_phhd == pk_phhd).values(exsuccess_flag=8))
|
||||
update_flag = (update(ZxPhhd).where(ZxPhhd.pk_phhd == pk_phhd).values(
|
||||
exsuccess_flag="8",
|
||||
ref_id1=HOSTNAME,
|
||||
check_time=util.get_default_datetime()))
|
||||
session.execute(update_flag)
|
||||
session.commit()
|
||||
session.close()
|
||||
|
||||
Reference in New Issue
Block a user