fix: 导入时使用get('')结构,并先删除文件夹
This commit is contained in:
parent
2dfaa6a273
commit
fae6fbde88
|
@ -3,8 +3,8 @@ ENV = 'development'
|
|||
|
||||
# base api
|
||||
#VUE_APP_BASE_API = 'http://10.0.11.127:8000/api'
|
||||
#VUE_APP_BASE_API = 'http://127.0.0.1:2222/api'
|
||||
VUE_APP_BASE_API = 'https://testsearch.ctc.ac.cn/api'
|
||||
VUE_APP_BASE_API = 'http://127.0.0.1:2222/api'
|
||||
# VUE_APP_BASE_API = 'https://testsearch.ctc.ac.cn/api'
|
||||
|
||||
#VUE_APP_BASE_API = 'http://47.95.0.242:9101/api'
|
||||
|
||||
|
|
|
@ -219,6 +219,9 @@ class CMAViewSet(RecordMixin, ModelViewSet):
|
|||
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
|
||||
elif fullpath.endswith('.zip'):
|
||||
fulldir = fullpath.replace('.zip','')
|
||||
if os.path.exists(fulldir):
|
||||
import shutil
|
||||
shutil.rmtree(fulldir) # 先删除该文件夹
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
CMA.objects.filter(type='center').delete()
|
||||
|
@ -255,6 +258,9 @@ class CMAViewSet(RecordMixin, ModelViewSet):
|
|||
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
|
||||
elif fullpath.endswith('.zip'):
|
||||
fulldir = fullpath.replace('.zip','')
|
||||
if os.path.exists(fulldir):
|
||||
import shutil
|
||||
shutil.rmtree(fulldir) # 先删除该文件夹
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
# CMA.objects.filter(type='sub').delete()
|
||||
|
@ -416,6 +422,9 @@ class InspectionViewSet(RecordMixin, ModelViewSet):
|
|||
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
|
||||
elif fullpath.endswith('.zip'):
|
||||
fulldir = fullpath.replace('.zip','')
|
||||
if os.path.exists(fulldir):
|
||||
import shutil
|
||||
shutil.rmtree(fulldir) # 先删除该文件夹
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
# CMA.objects.filter(type='sub').delete()
|
||||
|
@ -481,6 +490,9 @@ class CNASViewSet(RecordMixin, ModelViewSet):
|
|||
import_cnas(f, os.path.join(root,f))
|
||||
elif fullpath.endswith('.zip'):
|
||||
fulldir = fullpath.replace('.zip','')
|
||||
if os.path.exists(fulldir):
|
||||
import shutil
|
||||
shutil.rmtree(fulldir) # 先删除该文件夹
|
||||
os.mkdir(fulldir)
|
||||
os.chdir(fulldir)
|
||||
CNAS.objects.all().delete()
|
||||
|
@ -651,7 +663,7 @@ def import_cma2(filename, path):
|
|||
data['lbxh'] = sheet['c'+str(i)].value
|
||||
defaultv['lbxh'] = data['lbxh']
|
||||
else:
|
||||
data['lbxh'] = defaultv['lbxh']
|
||||
data['lbxh'] = defaultv.get('lbxh', '')
|
||||
if sheet['d'+str(i)].value:
|
||||
data['lbmc'] = sheet['d'+str(i)].value
|
||||
defaultv['lbmc'] = data['lbmc']
|
||||
|
@ -661,7 +673,7 @@ def import_cma2(filename, path):
|
|||
data['xmxh'] = sheet['e'+str(i)].value
|
||||
defaultv['xmxh'] = data['xmxh']
|
||||
else:
|
||||
data['xmxh'] = defaultv.get('xmxh', None)
|
||||
data['xmxh'] = defaultv.get('xmxh', '')
|
||||
if sheet['f'+str(i)].value:
|
||||
data['xmmc'] = sheet['f'+str(i)].value
|
||||
defaultv['xmmc'] = data['xmmc']
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue