69521081 by 冯轩

Merge branch 'CHINARPA-4562'

2 parents b331bf72 29aedd0a
...@@ -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 ]
......
...@@ -90,6 +90,10 @@ class CustomDecimal(fields.Decimal): ...@@ -90,6 +90,10 @@ class CustomDecimal(fields.Decimal):
90 def load_data(request, schema): 90 def load_data(request, schema):
91 return request.data 91 return request.data
92 92
93 employee_args = {
94 'application_id': fields.Str(required=True, validate=validate.Length(max=64)),
95 'business_type': fields.Str(required=True, validate=validate.Length(max=64)),
96 }
93 97
94 go_args = { 98 go_args = {
95 'image': fields.Raw(required=True), 99 'image': fields.Raw(required=True),
...@@ -1845,3 +1849,29 @@ class GoView(GenericView): ...@@ -1845,3 +1849,29 @@ class GoView(GenericView):
1845 return response.ok(data=result) 1849 return response.ok(data=result)
1846 else: 1850 else:
1847 return response.error_msg(msg='识别错误') 1851 return response.error_msg(msg='识别错误')
1852
1853 class EmployeeView(GenericView):
1854 permission_classes = [IsAuthenticated]
1855 authentication_classes = [OAuth2AuthenticationWithUser]
1856
1857 @use_args(employee_args, location='data')
1858 def post(self, request, args):
1859
1860 application_id = args.get('application_id')
1861 business_type = args.get('business_type')
1862
1863 ocr_result_class = HILOCRResult if business_type in consts.HIL_SET else AFCOCRResult
1864 ocr_result_info = ocr_result_class.objects.filter(application_id=application_id).first()
1865 self.running_log.info('[query Employee] [application_id={0}] [business_type={1}] [ocr_result_info exist={2}]'.format(application_id, business_type, ocr_result_info is not None))
1866 if not ocr_result_info:
1867 self.running_log.info('[query Employee] [application_id={0}] ocr_result none'.format(application_id))
1868 return response.ok(data=False)
1869 bss_ocr_str = ocr_result_info.bss_ocr
1870 bss_ocr = json.loads(bss_ocr_str)
1871 self.running_log.info('[query Employee] [application_id={0}] [bss_ocr={1}]'.format(application_id, bss_ocr))
1872 for one_bss in bss_ocr:
1873 income_keywords = one_bss.get('income_keywords')
1874 self.running_log.info('[query Employee] [application_id={0}] [income_keywords={1}]'.format(application_id, income_keywords))
1875 if income_keywords is not None and len(income_keywords) > 0:
1876 return response.ok(data=True)
1877 return response.ok(data=False)
...\ No newline at end of file ...\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!