init 5153-5234
Showing
4 changed files
with
95 additions
and
3 deletions
... | @@ -5,5 +5,7 @@ from . import views | ... | @@ -5,5 +5,7 @@ from . import views |
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'query/employee', views.EmployeeView.as_view()), |
8 | path(r'query/greenBookHistoryFile', views.SearchGBHistoryFileView.as_view()), | ||
9 | path(r'query/greenBookHistoryFile', views.DownloadGBHistoryFileView.as_view()), | ||
8 | path(r'contract/v1', views.SEContractView.as_view()), | 10 | path(r'contract/v1', views.SEContractView.as_view()), |
9 | ] | 11 | ] | ... | ... |
... | @@ -1130,4 +1130,28 @@ class DealerMapping(models.Model): | ... | @@ -1130,4 +1130,28 @@ class DealerMapping(models.Model): |
1130 | 1130 | ||
1131 | class Meta: | 1131 | class Meta: |
1132 | managed = False | 1132 | managed = False |
1133 | db_table = 'dealer_mapping' | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1133 | db_table = 'dealer_mapping' | ||
1134 | |||
1135 | class HILGreenBookHistoryFile(models.Model): | ||
1136 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
1137 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
1138 | download_finish = models.BooleanField(default=True, verbose_name="是否下载完成") | ||
1139 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
1140 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
1141 | |||
1142 | class Meta: | ||
1143 | managed = False | ||
1144 | db_table = 'hil_gb_history_file' | ||
1145 | |||
1146 | |||
1147 | class AFCGreenBookHistoryFile(models.Model): | ||
1148 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
1149 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
1150 | download_finish = models.BooleanField(default=True, verbose_name="是否下载完成") | ||
1151 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
1152 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
1153 | |||
1154 | class Meta: | ||
1155 | managed = False | ||
1156 | db_table = 'afc_gb_history_file' | ||
1157 | situ_db_label = 'afc' | ... | ... |
... | @@ -163,3 +163,20 @@ class ECM(GenericView): | ... | @@ -163,3 +163,20 @@ class ECM(GenericView): |
163 | response.status_code, response.headers, response.text)) | 163 | response.status_code, response.headers, response.text)) |
164 | if 'ns12:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}): | 164 | if 'ns12:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}): |
165 | raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers)) | 165 | raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers)) |
166 | |||
167 | def search_doc_info_list(self, filePath, business_type): | ||
168 | args = { | ||
169 | "username": self.username, | ||
170 | "password": self.pwd, | ||
171 | "docbase": self.doc_base_map.get(business_type), | ||
172 | "documentType": "green_book", | ||
173 | "dql":"select r_object_id, object_name,b_application_no, r_object_type,b_customer_name,r_content_size, owner_name, b_input_date, r_modify_date, b_location from green_book where b_location = '"+ filePath +"' order by r_modify_date desc" | ||
174 | } | ||
175 | header_info = self.get_headers() | ||
176 | self.running_log.info("{0} search header_info:{1}".format(self.log_base, header_info)) | ||
177 | self.running_log.info("{0} search args_info:{1}".format(self.log_base, args)) | ||
178 | response = requests.post(self.search_url, headers=header_info, json=args, verify=False) | ||
179 | if response.status_code != 200: | ||
180 | raise ECMException('ECM search failed with code: {0}'.format(response.status_code)) | ||
181 | self.running_log.info("{0} search response.json():{1}".format(self.log_base, response.json())) | ||
182 | return response.json() | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -53,7 +53,9 @@ from .models import ( | ... | @@ -53,7 +53,9 @@ from .models import ( |
53 | AFCOCRResult, | 53 | AFCOCRResult, |
54 | AFCSEOCRResult, | 54 | AFCSEOCRResult, |
55 | HILCmsStatusInfo, | 55 | HILCmsStatusInfo, |
56 | AFCCmsStatusInfo | 56 | AFCCmsStatusInfo, |
57 | HILGreenBookHistoryFile, | ||
58 | AFCGreenBookHistoryFile | ||
57 | ) | 59 | ) |
58 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam | 60 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam |
59 | from .mixins import DocHandler, MPOSHandler, PreSEHandler | 61 | from .mixins import DocHandler, MPOSHandler, PreSEHandler |
... | @@ -61,7 +63,7 @@ from . import consts | ... | @@ -61,7 +63,7 @@ from . import consts |
61 | from apps.account.authentication import OAuth2AuthenticationWithUser | 63 | from apps.account.authentication import OAuth2AuthenticationWithUser |
62 | from celery_compare.tasks import compare, fsm_compare | 64 | from celery_compare.tasks import compare, fsm_compare |
63 | from prese.compare import get_empty_result | 65 | from prese.compare import get_empty_result |
64 | 66 | from apps.doc.ocr.ecm import ECM | |
65 | import time | 67 | import time |
66 | 68 | ||
67 | 69 | ||
... | @@ -1876,4 +1878,51 @@ class EmployeeView(GenericView): | ... | @@ -1876,4 +1878,51 @@ class EmployeeView(GenericView): |
1876 | self.running_log.info('[query Employee] [application_id={0}] [income_keywords={1}]'.format(application_id, income_keywords)) | 1878 | self.running_log.info('[query Employee] [application_id={0}] [income_keywords={1}]'.format(application_id, income_keywords)) |
1877 | if income_keywords is not None and len(income_keywords) > 0: | 1879 | if income_keywords is not None and len(income_keywords) > 0: |
1878 | return response.ok(data=True) | 1880 | return response.ok(data=True) |
1881 | return response.ok(data=False) | ||
1882 | |||
1883 | class SearchGBHistoryFileView(GenericView): | ||
1884 | permission_classes = [IsAuthenticated] | ||
1885 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
1886 | |||
1887 | @use_args(employee_args, location='data') | ||
1888 | def post(self, request, args): | ||
1889 | |||
1890 | filePath = args.get('filePath') | ||
1891 | business_type = args.get('business_type') | ||
1892 | |||
1893 | gb_history_file_class = HILGreenBookHistoryFile if business_type in consts.HIL_SET else AFCGreenBookHistoryFile | ||
1894 | ecm = ECM() | ||
1895 | response_json = ecm.search_doc_info_list(filePath, business_type) | ||
1896 | data_objects = response_json['Envelope']['Body']['executeResponse']['return']['dataPackage']['DataObjects'] | ||
1897 | for data_object in data_objects: | ||
1898 | object_id = data_object['Identity']['ObjectId']['@id'] | ||
1899 | properties_dict = {} | ||
1900 | properties = data_object['Properties']['Properties'] | ||
1901 | for prop in properties: | ||
1902 | name = prop['@name'] | ||
1903 | value = prop.get('Value', 'null') # 如果Value为空,则输出null | ||
1904 | properties_dict[name] = value | ||
1905 | self.running_log.info('[SearchGBHistoryFileView] [properties_dict={0}] '.format(properties_dict)) | ||
1906 | gb_history_file_class.objects.create( | ||
1907 | application_id=properties_dict['b_application_no'], | ||
1908 | download_finish=False | ||
1909 | ) | ||
1910 | return response.ok(data=False) | ||
1911 | |||
1912 | class DownloadGBHistoryFileView(GenericView): | ||
1913 | permission_classes = [IsAuthenticated] | ||
1914 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
1915 | |||
1916 | @use_args(employee_args, location='data') | ||
1917 | def post(self, request, args): | ||
1918 | |||
1919 | filePath = args.get('filePath') | ||
1920 | business_type = args.get('business_type') | ||
1921 | ecm = ECM() | ||
1922 | ecm.download(filePath, business_type) | ||
1923 | gb_history_file_class = HILGreenBookHistoryFile if business_type in consts.HIL_SET else AFCGreenBookHistoryFile | ||
1924 | gb_history_file_class.objects.create( | ||
1925 | application_id=gb_history_file_class.application_id, | ||
1926 | download_finish=False | ||
1927 | ) | ||
1879 | return response.ok(data=False) | 1928 | return response.ok(data=False) |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment