补充存表

This commit is contained in:
2024-08-08 16:14:11 +08:00
parent 2b6ba7b71e
commit a8d40eba22
3 changed files with 22 additions and 7 deletions

View File

@@ -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()