report fix
Showing
6 changed files
with
64 additions
and
24 deletions
| ... | @@ -20,7 +20,7 @@ from common.tools.pdf_to_img import PDFHandler | ... | @@ -20,7 +20,7 @@ from common.tools.pdf_to_img import PDFHandler |
| 20 | from apps.doc import consts | 20 | from apps.doc import consts |
| 21 | from apps.doc.exceptions import OCR1Exception, OCR2Exception, LTGTException | 21 | from apps.doc.exceptions import OCR1Exception, OCR2Exception, LTGTException |
| 22 | from apps.doc.ocr.wb import BSWorkbook | 22 | from apps.doc.ocr.wb import BSWorkbook |
| 23 | from apps.doc.models import OfflineReport | 23 | from apps.doc.models import OfflineReport, AFCOfflineReport |
| 24 | from apps.doc.named_enum import OfflineFailureReason | 24 | from apps.doc.named_enum import OfflineFailureReason |
| 25 | 25 | ||
| 26 | 26 | ||
| ... | @@ -447,7 +447,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -447,7 +447,8 @@ class Command(BaseCommand, LoggerMixin): |
| 447 | finally: | 447 | finally: |
| 448 | end_time = time.time() | 448 | end_time = time.time() |
| 449 | try: | 449 | try: |
| 450 | OfflineReport.objects.create( | 450 | report_table = OfflineReport if input_dir.find(consts.HIL_PREFIX) != -1 else AFCOfflineReport |
| 451 | report_table.objects.create( | ||
| 451 | input_folder=input_dir, | 452 | input_folder=input_dir, |
| 452 | doc_type=consts.DDA_CLASSIFY, | 453 | doc_type=consts.DDA_CLASSIFY, |
| 453 | file_name=name, | 454 | file_name=name, | ... | ... |
| ... | @@ -21,7 +21,7 @@ from common.electronic_afc_contract.afc_contract_ocr import predict as afc_predi | ... | @@ -21,7 +21,7 @@ from common.electronic_afc_contract.afc_contract_ocr import predict as afc_predi |
| 21 | from apps.doc import consts | 21 | from apps.doc import consts |
| 22 | from apps.doc.exceptions import OCR1Exception, OCR2Exception, LTGTException | 22 | from apps.doc.exceptions import OCR1Exception, OCR2Exception, LTGTException |
| 23 | from apps.doc.ocr.wb import BSWorkbook | 23 | from apps.doc.ocr.wb import BSWorkbook |
| 24 | from apps.doc.models import OfflineReport | 24 | from apps.doc.models import OfflineReport, AFCOfflineReport |
| 25 | from apps.doc.named_enum import OfflineFailureReason | 25 | from apps.doc.named_enum import OfflineFailureReason |
| 26 | 26 | ||
| 27 | 27 | ||
| ... | @@ -769,7 +769,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -769,7 +769,8 @@ class Command(BaseCommand, LoggerMixin): |
| 769 | finally: | 769 | finally: |
| 770 | end_time = time.time() | 770 | end_time = time.time() |
| 771 | try: | 771 | try: |
| 772 | OfflineReport.objects.create( | 772 | report_table = OfflineReport if input_dir.find(consts.HIL_PREFIX) != -1 else AFCOfflineReport |
| 773 | report_table.objects.create( | ||
| 773 | input_folder=input_dir, | 774 | input_folder=input_dir, |
| 774 | doc_type=classify, | 775 | doc_type=classify, |
| 775 | file_name=name, | 776 | file_name=name, | ... | ... |
| ... | @@ -18,7 +18,7 @@ from common.tools.pdf_to_img import PDFHandler | ... | @@ -18,7 +18,7 @@ from common.tools.pdf_to_img import PDFHandler |
| 18 | from apps.doc import consts | 18 | from apps.doc import consts |
| 19 | from apps.doc.exceptions import OCR1Exception, OCR4Exception | 19 | from apps.doc.exceptions import OCR1Exception, OCR4Exception |
| 20 | from apps.doc.ocr.wb import BSWorkbook | 20 | from apps.doc.ocr.wb import BSWorkbook |
| 21 | from apps.doc.models import OfflineReport | 21 | from apps.doc.models import OfflineReport, AFCOfflineReport |
| 22 | from apps.doc.named_enum import OfflineFailureReason | 22 | from apps.doc.named_enum import OfflineFailureReason |
| 23 | 23 | ||
| 24 | 24 | ||
| ... | @@ -385,7 +385,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -385,7 +385,8 @@ class Command(BaseCommand, LoggerMixin): |
| 385 | finally: | 385 | finally: |
| 386 | end_time = time.time() | 386 | end_time = time.time() |
| 387 | try: | 387 | try: |
| 388 | OfflineReport.objects.create( | 388 | report_table = OfflineReport if input_dir.find(consts.HIL_PREFIX) != -1 else AFCOfflineReport |
| 389 | report_table.objects.create( | ||
| 389 | input_folder=input_dir, | 390 | input_folder=input_dir, |
| 390 | doc_type=classify, | 391 | doc_type=classify, |
| 391 | file_name=name, | 392 | file_name=name, | ... | ... |
| ... | @@ -21,7 +21,7 @@ from common.tools.pdf_to_img import PDFHandler | ... | @@ -21,7 +21,7 @@ from common.tools.pdf_to_img import PDFHandler |
| 21 | from apps.doc import consts | 21 | from apps.doc import consts |
| 22 | from apps.doc.exceptions import OCR1Exception, OCR4Exception | 22 | from apps.doc.exceptions import OCR1Exception, OCR4Exception |
| 23 | from apps.doc.ocr.wb import BSWorkbook, PatternFill | 23 | from apps.doc.ocr.wb import BSWorkbook, PatternFill |
| 24 | from apps.doc.models import OfflineReport | 24 | from apps.doc.models import OfflineReport, AFCOfflineReport |
| 25 | from apps.doc.named_enum import OfflineFailureReason | 25 | from apps.doc.named_enum import OfflineFailureReason |
| 26 | 26 | ||
| 27 | 27 | ||
| ... | @@ -632,7 +632,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -632,7 +632,8 @@ class Command(BaseCommand, LoggerMixin): |
| 632 | finally: | 632 | finally: |
| 633 | end_time = time.time() | 633 | end_time = time.time() |
| 634 | try: | 634 | try: |
| 635 | OfflineReport.objects.create( | 635 | report_table = OfflineReport if input_dir.find(consts.HIL_PREFIX) != -1 else AFCOfflineReport |
| 636 | report_table.objects.create( | ||
| 636 | input_folder=input_dir, | 637 | input_folder=input_dir, |
| 637 | doc_type=consts.FOLDER_WSC_CLASSIFY, | 638 | doc_type=consts.FOLDER_WSC_CLASSIFY, |
| 638 | file_name=name, | 639 | file_name=name, | ... | ... |
| ... | @@ -923,6 +923,7 @@ class MposReport(models.Model): | ... | @@ -923,6 +923,7 @@ class MposReport(models.Model): |
| 923 | image_count = models.SmallIntegerField(default=0, verbose_name="图片数目") | 923 | image_count = models.SmallIntegerField(default=0, verbose_name="图片数目") |
| 924 | # status = models.SmallIntegerField(default=, verbose_name="请求状态") | 924 | # status = models.SmallIntegerField(default=, verbose_name="请求状态") |
| 925 | status = models.BooleanField(default=True, verbose_name="是否成功") | 925 | status = models.BooleanField(default=True, verbose_name="是否成功") |
| 926 | source = models.SmallIntegerField(default=0, verbose_name="来源") # 默认0,代表MPOS | ||
| 926 | 927 | ||
| 927 | duration = models.IntegerField(null=True, verbose_name='处理时长') | 928 | duration = models.IntegerField(null=True, verbose_name='处理时长') |
| 928 | 929 | ||
| ... | @@ -950,20 +951,20 @@ class OfflineReport(models.Model): | ... | @@ -950,20 +951,20 @@ class OfflineReport(models.Model): |
| 950 | db_table = 'offline_report' | 951 | db_table = 'offline_report' |
| 951 | 952 | ||
| 952 | 953 | ||
| 953 | # class AFCOfflineReport(models.Model): | 954 | class AFCOfflineReport(models.Model): |
| 954 | # id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | 955 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 |
| 955 | # | 956 | |
| 956 | # input_folder = models.CharField(max_length=512, verbose_name="文件夹路径") | 957 | input_folder = models.CharField(max_length=512, verbose_name="文件夹路径") |
| 957 | # doc_type = models.SmallIntegerField(default=0, verbose_name="文件类型") | 958 | doc_type = models.SmallIntegerField(default=0, verbose_name="文件类型") |
| 958 | # file_name = models.CharField(max_length=1024, verbose_name="文件名") | 959 | file_name = models.CharField(max_length=1024, verbose_name="文件名") |
| 959 | # status = models.BooleanField(default=True, verbose_name="是否成功") | 960 | status = models.BooleanField(default=True, verbose_name="是否成功") |
| 960 | # failure_reason = models.SmallIntegerField(default=0, verbose_name="失败原因") | 961 | failure_reason = models.SmallIntegerField(default=0, verbose_name="失败原因") |
| 961 | # duration = models.IntegerField(verbose_name='处理时长') | 962 | duration = models.IntegerField(verbose_name='处理时长') |
| 962 | # | 963 | |
| 963 | # create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 964 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| 964 | # | 965 | |
| 965 | # class Meta: | 966 | class Meta: |
| 966 | # managed = False | 967 | managed = False |
| 967 | # db_table = 'afc_offline_report' | 968 | db_table = 'afc_offline_report' |
| 968 | # situ_db_label = 'afc' | 969 | situ_db_label = 'afc' |
| 969 | 970 | ... | ... |
src/common/tools/mssql_script20.py
0 → 100644
| 1 | import pyodbc | ||
| 2 | |||
| 3 | hil_sql = """ | ||
| 4 | ALTER TABLE mpos_report ADD source tinyint default 0 not null; | ||
| 5 | """ | ||
| 6 | |||
| 7 | afc_sql = """ | ||
| 8 | create table afc_offline_report | ||
| 9 | ( | ||
| 10 | id bigint identity primary key, | ||
| 11 | input_folder nvarchar(512) not null, | ||
| 12 | doc_type tinyint default 0 not null, | ||
| 13 | file_name nvarchar(1024) not null, | ||
| 14 | status bit default 1 not null, | ||
| 15 | failure_reason tinyint default 0 not null, | ||
| 16 | duration smallint not null, | ||
| 17 | create_time datetime not null | ||
| 18 | ); | ||
| 19 | """ | ||
| 20 | |||
| 21 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
| 22 | |||
| 23 | hil_cursor = hil_cnxn.cursor() | ||
| 24 | hil_cursor.execute(hil_sql) | ||
| 25 | |||
| 26 | hil_cursor.close() | ||
| 27 | hil_cnxn.close() | ||
| 28 | |||
| 29 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
| 30 | |||
| 31 | afc_cursor = afc_cnxn.cursor() | ||
| 32 | afc_cursor.execute(afc_sql) | ||
| 33 | |||
| 34 | afc_cursor.close() | ||
| 35 | afc_cnxn.close() |
-
Please register or sign in to post a comment