merge
Showing
4 changed files
with
118 additions
and
2 deletions
... | @@ -5,6 +5,8 @@ from . import views | ... | @@ -5,6 +5,8 @@ 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'invoice/downloadExcel', views.InvoiceExcelView.as_view()), | 10 | path(r'invoice/downloadExcel', views.InvoiceExcelView.as_view()), |
9 | path(r'invoice/queryInfo', views.InvoiceQueryInfoView.as_view()), | 11 | path(r'invoice/queryInfo', views.InvoiceQueryInfoView.as_view()), |
10 | path(r'contract/v1', views.SEContractView.as_view()), | 12 | path(r'contract/v1', views.SEContractView.as_view()), | ... | ... |
... | @@ -1130,4 +1130,46 @@ class DealerMapping(models.Model): | ... | @@ -1130,4 +1130,46 @@ 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 | object_id = models.CharField(max_length=64, verbose_name="文件唯一ID") | ||
1138 | object_name = models.CharField(max_length=255, verbose_name="文件名称") | ||
1139 | application_no = models.CharField(max_length=64, verbose_name="申请号") | ||
1140 | object_type = models.CharField(max_length=64, verbose_name="文件类型") | ||
1141 | customer_name = models.CharField(max_length=64, verbose_name="customer_name") | ||
1142 | content_size = models.CharField(max_length=64, verbose_name="文件大小") | ||
1143 | owner_name = models.CharField(max_length=64, verbose_name="owner_name") | ||
1144 | input_date = models.DateTimeField(verbose_name="上传时间") | ||
1145 | modify_date = models.DateTimeField(verbose_name="修改时间") | ||
1146 | location = models.CharField(max_length=255, verbose_name="文件位置") | ||
1147 | download_finish = models.BooleanField(default=True, verbose_name="是否下载完成") | ||
1148 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
1149 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
1150 | |||
1151 | class Meta: | ||
1152 | managed = False | ||
1153 | db_table = 'hil_gb_history_file' | ||
1154 | |||
1155 | |||
1156 | class AFCGreenBookHistoryFile(models.Model): | ||
1157 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
1158 | object_id = models.CharField(max_length=64, verbose_name="文件唯一ID") | ||
1159 | object_name = models.CharField(max_length=255, verbose_name="文件名称") | ||
1160 | application_no = models.CharField(max_length=64, verbose_name="申请号") | ||
1161 | object_type = models.CharField(max_length=64, verbose_name="文件类型") | ||
1162 | customer_name = models.CharField(max_length=64, verbose_name="customer_name") | ||
1163 | content_size = models.CharField(max_length=64, verbose_name="文件大小") | ||
1164 | owner_name = models.CharField(max_length=64, verbose_name="owner_name") | ||
1165 | input_date = models.DateTimeField(verbose_name="上传时间") | ||
1166 | modify_date = models.DateTimeField(verbose_name="修改时间") | ||
1167 | location = models.CharField(max_length=255, verbose_name="文件位置") | ||
1168 | download_finish = models.BooleanField(default=True, verbose_name="是否下载完成") | ||
1169 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
1170 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
1171 | |||
1172 | class Meta: | ||
1173 | managed = False | ||
1174 | db_table = 'afc_gb_history_file' | ||
1175 | situ_db_label = 'afc' | ... | ... |
... | @@ -168,3 +168,20 @@ class ECM(GenericView): | ... | @@ -168,3 +168,20 @@ class ECM(GenericView): |
168 | response.status_code, response.headers, response.text)) | 168 | response.status_code, response.headers, response.text)) |
169 | if 'ns12:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}): | 169 | if 'ns12:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}): |
170 | raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers)) | 170 | raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers)) |
171 | |||
172 | def search_doc_info_list(self, filePath, business_type): | ||
173 | args = { | ||
174 | "username": self.username, | ||
175 | "password": self.pwd, | ||
176 | "docbase": self.doc_base_map.get(business_type), | ||
177 | "documentType": "green_book", | ||
178 | "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 +"'" | ||
179 | } | ||
180 | header_info = self.get_headers() | ||
181 | self.running_log.info("{0} search header_info:{1}".format(self.log_base, header_info)) | ||
182 | self.running_log.info("{0} search args_info:{1}".format(self.log_base, args)) | ||
183 | response = requests.post(self.search_url, headers=header_info, json=args, verify=False) | ||
184 | if response.status_code != 200: | ||
185 | raise ECMException('ECM search failed with code: {0}'.format(response.status_code)) | ||
186 | self.running_log.info("{0} search response.json():{1}".format(self.log_base, response.json())) | ||
187 | return response.json() | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -55,6 +55,8 @@ from .models import ( | ... | @@ -55,6 +55,8 @@ from .models import ( |
55 | AFCSEOCRResult, | 55 | AFCSEOCRResult, |
56 | HILCmsStatusInfo, | 56 | HILCmsStatusInfo, |
57 | AFCCmsStatusInfo, | 57 | AFCCmsStatusInfo, |
58 | HILGreenBookHistoryFile, | ||
59 | AFCGreenBookHistoryFile, | ||
58 | Configs | 60 | Configs |
59 | ) | 61 | ) |
60 | from common.exceptions import (NoPermissionException) | 62 | from common.exceptions import (NoPermissionException) |
... | @@ -64,7 +66,7 @@ from . import consts | ... | @@ -64,7 +66,7 @@ from . import consts |
64 | from apps.account.authentication import OAuth2AuthenticationWithUser | 66 | from apps.account.authentication import OAuth2AuthenticationWithUser |
65 | from celery_compare.tasks import compare, fsm_compare | 67 | from celery_compare.tasks import compare, fsm_compare |
66 | from prese.compare import get_empty_result | 68 | from prese.compare import get_empty_result |
67 | 69 | from apps.doc.ocr.ecm import ECM | |
68 | import time | 70 | import time |
69 | from django.http import HttpResponse | 71 | from django.http import HttpResponse |
70 | from django.utils.encoding import escape_uri_path | 72 | from django.utils.encoding import escape_uri_path |
... | @@ -2066,4 +2068,57 @@ class EmployeeView(GenericView): | ... | @@ -2066,4 +2068,57 @@ class EmployeeView(GenericView): |
2066 | self.running_log.info('[query Employee] [application_id={0}] [income_keywords={1}]'.format(application_id, income_keywords)) | 2068 | self.running_log.info('[query Employee] [application_id={0}] [income_keywords={1}]'.format(application_id, income_keywords)) |
2067 | if income_keywords is not None and len(income_keywords) > 0: | 2069 | if income_keywords is not None and len(income_keywords) > 0: |
2068 | return response.ok(data=True) | 2070 | return response.ok(data=True) |
2071 | return response.ok(data=False) | ||
2072 | |||
2073 | class SearchGBHistoryFileView(GenericView): | ||
2074 | permission_classes = [IsAuthenticated] | ||
2075 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
2076 | |||
2077 | @use_args(employee_args, location='data') | ||
2078 | def post(self, request, args): | ||
2079 | |||
2080 | filePath = args.get('filePath') | ||
2081 | business_type = args.get('business_type') | ||
2082 | |||
2083 | gb_history_file_class = HILGreenBookHistoryFile if business_type in consts.HIL_SET else AFCGreenBookHistoryFile | ||
2084 | ecm = ECM() | ||
2085 | response_json = ecm.search_doc_info_list(filePath, business_type) | ||
2086 | data_objects = response_json['Envelope']['Body']['executeResponse']['return']['dataPackage']['DataObjects'] | ||
2087 | for data_object in data_objects: | ||
2088 | object_id = data_object['Identity']['ObjectId']['@id'] | ||
2089 | properties_dict = {} | ||
2090 | properties = data_object['Properties']['Properties'] | ||
2091 | for prop in properties: | ||
2092 | name = prop['@name'] | ||
2093 | value = prop.get('Value', 'null') # 如果Value为空,则输出null | ||
2094 | properties_dict[name] = value | ||
2095 | self.running_log.info('[SearchGBHistoryFileView] [properties_dict={0}] '.format(properties_dict)) | ||
2096 | gb_history_file_class.objects.create( | ||
2097 | object_id=object_id, | ||
2098 | object_name=properties_dict.get('object_name', ''), | ||
2099 | application_no=properties_dict.get('b_application_no', ''), | ||
2100 | object_type=properties_dict.get('r_object_type', ''), | ||
2101 | customer_name=properties_dict.get('b_customer_name', ''), | ||
2102 | content_size=properties_dict.get('r_content_size', ''), | ||
2103 | owner_name=properties_dict.get('owner_name', ''), | ||
2104 | #input_date=properties_dict.get('b_input_date', ''), | ||
2105 | #modify_date=properties_dict.get('r_modify_date', ''), | ||
2106 | location=properties_dict.get('b_location', ''), | ||
2107 | download_finish=False | ||
2108 | ) | ||
2109 | return response.ok(data=False) | ||
2110 | |||
2111 | class DownloadGBHistoryFileView(GenericView): | ||
2112 | permission_classes = [IsAuthenticated] | ||
2113 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
2114 | |||
2115 | @use_args(employee_args, location='data') | ||
2116 | def post(self, request, args): | ||
2117 | |||
2118 | business_type = args.get('business_type') | ||
2119 | object_id = args.get('object_id') | ||
2120 | save_path = args.get('save_path') | ||
2121 | ecm = ECM() | ||
2122 | ecm.download(save_path, object_id, 'green_book', business_type) | ||
2123 | self.running_log.info('[DownloadGBHistoryFileView] [args={0}] '.format(args)) | ||
2069 | return response.ok(data=False) | 2124 | 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