39cc8176 by 冯轩

init 5153-5234

1 parent 6349bed3
......@@ -5,5 +5,7 @@ from . import views
urlpatterns = [
path(r'', views.DocView.as_view()),
path(r'query/employee', views.EmployeeView.as_view()),
path(r'query/greenBookHistoryFile', views.SearchGBHistoryFileView.as_view()),
path(r'query/greenBookHistoryFile', views.DownloadGBHistoryFileView.as_view()),
path(r'contract/v1', views.SEContractView.as_view()),
]
......
......@@ -1131,3 +1131,27 @@ class DealerMapping(models.Model):
class Meta:
managed = False
db_table = 'dealer_mapping'
class HILGreenBookHistoryFile(models.Model):
id = models.AutoField(primary_key=True, verbose_name="id") # 主键
application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
download_finish = models.BooleanField(default=True, verbose_name="是否下载完成")
update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
class Meta:
managed = False
db_table = 'hil_gb_history_file'
class AFCGreenBookHistoryFile(models.Model):
id = models.AutoField(primary_key=True, verbose_name="id") # 主键
application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引
download_finish = models.BooleanField(default=True, verbose_name="是否下载完成")
update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
class Meta:
managed = False
db_table = 'afc_gb_history_file'
situ_db_label = 'afc'
......
......@@ -163,3 +163,20 @@ class ECM(GenericView):
response.status_code, response.headers, response.text))
if 'ns12:createResponse' not in response.json().get('S:Envelope', {}).get('S:Body', {}):
raise ECMException('ECM upload failed: {0} , with headers: {1}'.format(response.json(), response.headers))
def search_doc_info_list(self, filePath, business_type):
args = {
"username": self.username,
"password": self.pwd,
"docbase": self.doc_base_map.get(business_type),
"documentType": "green_book",
"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"
}
header_info = self.get_headers()
self.running_log.info("{0} search header_info:{1}".format(self.log_base, header_info))
self.running_log.info("{0} search args_info:{1}".format(self.log_base, args))
response = requests.post(self.search_url, headers=header_info, json=args, verify=False)
if response.status_code != 200:
raise ECMException('ECM search failed with code: {0}'.format(response.status_code))
self.running_log.info("{0} search response.json():{1}".format(self.log_base, response.json()))
return response.json()
\ No newline at end of file
......
......@@ -53,7 +53,9 @@ from .models import (
AFCOCRResult,
AFCSEOCRResult,
HILCmsStatusInfo,
AFCCmsStatusInfo
AFCCmsStatusInfo,
HILGreenBookHistoryFile,
AFCGreenBookHistoryFile
)
from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam
from .mixins import DocHandler, MPOSHandler, PreSEHandler
......@@ -61,7 +63,7 @@ from . import consts
from apps.account.authentication import OAuth2AuthenticationWithUser
from celery_compare.tasks import compare, fsm_compare
from prese.compare import get_empty_result
from apps.doc.ocr.ecm import ECM
import time
......@@ -1877,3 +1879,50 @@ class EmployeeView(GenericView):
if income_keywords is not None and len(income_keywords) > 0:
return response.ok(data=True)
return response.ok(data=False)
class SearchGBHistoryFileView(GenericView):
permission_classes = [IsAuthenticated]
authentication_classes = [OAuth2AuthenticationWithUser]
@use_args(employee_args, location='data')
def post(self, request, args):
filePath = args.get('filePath')
business_type = args.get('business_type')
gb_history_file_class = HILGreenBookHistoryFile if business_type in consts.HIL_SET else AFCGreenBookHistoryFile
ecm = ECM()
response_json = ecm.search_doc_info_list(filePath, business_type)
data_objects = response_json['Envelope']['Body']['executeResponse']['return']['dataPackage']['DataObjects']
for data_object in data_objects:
object_id = data_object['Identity']['ObjectId']['@id']
properties_dict = {}
properties = data_object['Properties']['Properties']
for prop in properties:
name = prop['@name']
value = prop.get('Value', 'null') # 如果Value为空,则输出null
properties_dict[name] = value
self.running_log.info('[SearchGBHistoryFileView] [properties_dict={0}] '.format(properties_dict))
gb_history_file_class.objects.create(
application_id=properties_dict['b_application_no'],
download_finish=False
)
return response.ok(data=False)
class DownloadGBHistoryFileView(GenericView):
permission_classes = [IsAuthenticated]
authentication_classes = [OAuth2AuthenticationWithUser]
@use_args(employee_args, location='data')
def post(self, request, args):
filePath = args.get('filePath')
business_type = args.get('business_type')
ecm = ECM()
ecm.download(filePath, business_type)
gb_history_file_class = HILGreenBookHistoryFile if business_type in consts.HIL_SET else AFCGreenBookHistoryFile
gb_history_file_class.objects.create(
application_id=gb_history_file_class.application_id,
download_finish=False
)
return response.ok(data=False)
\ 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!