merge
Showing
4 changed files
with
28 additions
and
4 deletions
| ... | @@ -4,5 +4,6 @@ from . import views | ... | @@ -4,5 +4,6 @@ from . import views |
| 4 | 4 | ||
| 5 | urlpatterns = [ | 5 | urlpatterns = [ |
| 6 | path(r'', views.DocView.as_view()), | 6 | path(r'', views.DocView.as_view()), |
| 7 | path(r'query/employee', views.EmployeeView.as_view()), | ||
| 7 | path(r'contract/v1', views.SEContractView.as_view()), | 8 | path(r'contract/v1', views.SEContractView.as_view()), |
| 8 | ] | 9 | ] | ... | ... |
| ... | @@ -1507,7 +1507,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1507,7 +1507,7 @@ class Command(BaseCommand, LoggerMixin): |
| 1507 | # AFC合同 | 1507 | # AFC合同 |
| 1508 | if classify_1_str == str(consts.CONTRACT_CLASSIFY): | 1508 | if classify_1_str == str(consts.CONTRACT_CLASSIFY): |
| 1509 | is_fsm = doc.is_ovp_fsm == 1 | 1509 | is_fsm = doc.is_ovp_fsm == 1 |
| 1510 | ocr_result = afc_predict(self,pdf_handler.pdf_info, is_fsm=is_fsm) | 1510 | ocr_result = afc_predict(pdf_handler.pdf_info, is_fsm=is_fsm) |
| 1511 | page_res = {} | 1511 | page_res = {} |
| 1512 | for page_num, page_info in ocr_result.get('page_info', {}).items(): | 1512 | for page_num, page_info in ocr_result.get('page_info', {}).items(): |
| 1513 | if isinstance(page_num, str) and page_num.startswith('page_'): | 1513 | if isinstance(page_num, str) and page_num.startswith('page_'): | ... | ... |
| ... | @@ -92,6 +92,10 @@ class CustomDecimal(fields.Decimal): | ... | @@ -92,6 +92,10 @@ class CustomDecimal(fields.Decimal): |
| 92 | def load_data(request, schema): | 92 | def load_data(request, schema): |
| 93 | return request.data | 93 | return request.data |
| 94 | 94 | ||
| 95 | employee_args = { | ||
| 96 | 'applicationId': fields.Str(required=True, validate=validate.Length(max=64)), | ||
| 97 | 'business_type': fields.Str(required=True, validate=validate.Length(max=64)), | ||
| 98 | } | ||
| 95 | 99 | ||
| 96 | go_args = { | 100 | go_args = { |
| 97 | 'image': fields.Raw(required=True), | 101 | 'image': fields.Raw(required=True), |
| ... | @@ -1890,3 +1894,24 @@ def notifyCmsPass(self, request): | ... | @@ -1890,3 +1894,24 @@ def notifyCmsPass(self, request): |
| 1890 | else: | 1894 | else: |
| 1891 | self.running_log.info('[pressure cms success] [response={0}]'.format(response)) | 1895 | self.running_log.info('[pressure cms success] [response={0}]'.format(response)) |
| 1892 | return True | 1896 | return True |
| 1897 | class EmployeeView(GenericView): | ||
| 1898 | permission_classes = [IsAuthenticated] | ||
| 1899 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
| 1900 | |||
| 1901 | @use_args(employee_args, location='data') | ||
| 1902 | def post(self, request, args): | ||
| 1903 | |||
| 1904 | application_id = args.get('application_id') | ||
| 1905 | business_type = args.get('business_type') | ||
| 1906 | |||
| 1907 | ocr_result_class = HILOCRResult if business_type in consts.HIL_SET else AFCOCRResult | ||
| 1908 | ocr_result_info = ocr_result_class.objects.filter(application_id=application_id).first() | ||
| 1909 | if not ocr_result_info: | ||
| 1910 | return response.ok(data=False) | ||
| 1911 | bss_ocr_str = ocr_result_info.bss_ocr | ||
| 1912 | bss_ocr = json.loads(bss_ocr_str) | ||
| 1913 | for one_bss in bss_ocr: | ||
| 1914 | income_keywords = one_bss['income_keywords'] | ||
| 1915 | if income_keywords is not None and len(income_keywords) > 0: | ||
| 1916 | return response.ok(data=True) | ||
| 1917 | return response.ok(data=False) | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -24,7 +24,7 @@ def extract_info(ocr_results): | ... | @@ -24,7 +24,7 @@ def extract_info(ocr_results): |
| 24 | return {'page_1': {'合同编号': contract_no}} | 24 | return {'page_1': {'合同编号': contract_no}} |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | def predict(self, pdf_info, is_qrs=False, is_fsm=False): | 27 | def predict(pdf_info, is_qrs=False, is_fsm=False): |
| 28 | pop_seceond_page_info = {} | 28 | pop_seceond_page_info = {} |
| 29 | if not is_fsm and not is_qrs and len(pdf_info) == 9: | 29 | if not is_fsm and not is_qrs and len(pdf_info) == 9: |
| 30 | pop_seceond_page_info = pdf_info.pop('1', {}) | 30 | pop_seceond_page_info = pdf_info.pop('1', {}) |
| ... | @@ -61,10 +61,8 @@ def predict(self, pdf_info, is_qrs=False, is_fsm=False): | ... | @@ -61,10 +61,8 @@ def predict(self, pdf_info, is_qrs=False, is_fsm=False): |
| 61 | else: | 61 | else: |
| 62 | # 输入是整个 PDF 中的信息 | 62 | # 输入是整个 PDF 中的信息 |
| 63 | if is_fsm: | 63 | if is_fsm: |
| 64 | self.online_log.info('afc_contract_is_fsm') | ||
| 65 | f = FSMFinder(pdf_info, ocr_results=ocr_results) | 64 | f = FSMFinder(pdf_info, ocr_results=ocr_results) |
| 66 | else: | 65 | else: |
| 67 | self.online_log.info('afc_contract_is_non_fsm') | ||
| 68 | f = Finder(pdf_info, ocr_results=ocr_results) | 66 | f = Finder(pdf_info, ocr_results=ocr_results) |
| 69 | results = f.get_info() | 67 | results = f.get_info() |
| 70 | return results | 68 | return results | ... | ... |
-
Please register or sign in to post a comment