缓存时间设短
This commit is contained in:
parent
01fa4d4181
commit
e08ffe580e
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.0.5 on 2022-03-16 00:58
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ability', '0023_auto_20210728_0902'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='ability',
|
||||
name='cma_ok',
|
||||
field=models.BooleanField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='ability',
|
||||
name='cnas_ok',
|
||||
field=models.BooleanField(blank=True, null=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -19,6 +19,8 @@ class Ability(BaseModel):
|
|||
xzfw = models.TextField('限制范围',null=True,blank=True)
|
||||
bz = models.TextField('备注',null=True,blank=True)
|
||||
cma = models.TextField('CMA中心',null=True,blank=True)
|
||||
cma_ok = models.BooleanField(null=True, blank=True)
|
||||
cnas_ok = models.BooleanField(null=True, blank=True)
|
||||
cnas = models.TextField('CNAS中心',null=True,blank=True)
|
||||
cma_o = models.TextField('中心',null=True,blank=True)
|
||||
cma_oplace = models.TextField('地点',null=True,blank=True)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.db.models import base
|
||||
from django.urls import path, include
|
||||
from rest_framework import routers
|
||||
from .views import AbilityContentViewSet, AbilityRecordViewSet, CMAViewSet, CNASViewSet, CorrectViewSet, QualificationViewSet,InspectionViewSet,QualificationotherViewSet, QueryRecordListViewSet, correct_ability, merge_cma, merge_cnas
|
||||
from .views import AbilityContentViewSet, AbilityRecordViewSet, CMAViewSet, CNASViewSet, CorrectViewSet, QualificationViewSet,InspectionViewSet,QualificationotherViewSet, QueryRecordListViewSet, correct_ability, correct_cma, merge_cma, merge_cnas
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register('cma', CMAViewSet, basename="cma")
|
||||
|
|
@ -16,6 +16,6 @@ router.register('record', AbilityRecordViewSet, basename="abilityrecord")
|
|||
urlpatterns = [
|
||||
path('merge/cma/', merge_cma),
|
||||
path('merge/cnas/', merge_cnas),
|
||||
# path('correct/', correct_ability),
|
||||
path('correct_cma/', correct_cma),
|
||||
path('', include(router.urls))
|
||||
]
|
||||
|
|
@ -586,7 +586,7 @@ def import_cma(filename, path):
|
|||
wb = load_workbook(path)
|
||||
sheet = wb.worksheets[0]
|
||||
datalist = []
|
||||
sszx = filename.replace('.xlsx','').replace('副本14检验检测能力申请表-','')
|
||||
sszx = filename.replace('.xlsx','').replace('14检验检测能力申请表-','')
|
||||
i = 4
|
||||
while sheet['b'+str(i)].value:
|
||||
data = {}
|
||||
|
|
@ -846,9 +846,10 @@ def import_correct(path):
|
|||
from django.db.models.functions import Cast
|
||||
def merge_cnas(request):
|
||||
for i in CNAS.objects.all():
|
||||
objs = Ability.objects.filter(lbmc=i.lbmc,xmmc=i.xmmc, bzbh=i.bzbh, bztk=i.bztk)
|
||||
objs = Ability.objects.filter(lbmc=i.lbmc,xmmc=i.xmmc, bzbh=i.bzbh, bztk=i.bztk, bzmc=i.bzmc)
|
||||
if objs.exists():
|
||||
obj = objs[0]
|
||||
obj.cnas_ok = True
|
||||
if obj.cnas:
|
||||
obj.cnas = obj.cnas + ',' + i.sszx
|
||||
obj.save()
|
||||
|
|
@ -856,15 +857,29 @@ def merge_cnas(request):
|
|||
obj.cnas = i.sszx
|
||||
obj.save()
|
||||
print('已修改--'+obj.xmmc+ '-' + obj.cnas)
|
||||
else:
|
||||
obj = Ability()
|
||||
obj.lbmc = i.lbmc
|
||||
obj.xmmc = i.xmmc
|
||||
obj.bzmc = i.bzmc
|
||||
obj.bzbh = i.bzbh
|
||||
obj.bztk = i.bztk
|
||||
obj.cnas = i.sszx
|
||||
obj.cnas_ok = True
|
||||
obj.save()
|
||||
print('已添加--'+obj.xmmc+obj.bzmc)
|
||||
return Response({})
|
||||
|
||||
|
||||
def merge_cma(request):
|
||||
for i in CMA.objects.filter(type='center'):
|
||||
bztk = i.bzbh.split(' ')[-1]
|
||||
bzbh = i.bzbh.rstrip(bztk).strip()
|
||||
xmxh = i.xmxh.strip()
|
||||
if len(bzbh)<8:
|
||||
bzbh = i.bzbh
|
||||
bztk = ''
|
||||
objs = Ability.objects.filter(lbmc=i.lbmc, xmmc=i.xmmc, bzbh = bzbh, bztk=bztk)
|
||||
objs = Ability.objects.filter(lbmc=i.lbmc, xmmc=i.xmmc, bzbh = bzbh, bztk=bztk, xmxh=xmxh, bzmc = i.bzmc)
|
||||
if objs.exists():
|
||||
obj = objs[0]
|
||||
obj.cma = obj.cma + ',' + i.sszx
|
||||
|
|
@ -884,9 +899,10 @@ def merge_cma(request):
|
|||
obj.xzfw = i.xzfw
|
||||
obj.bz = i.bz
|
||||
obj.cma = i.sszx
|
||||
obj.cma_ok = True
|
||||
obj.save()
|
||||
print('已添加--'+obj.xmmc+obj.bzmc)
|
||||
|
||||
return Response({})
|
||||
def correct_ability(request):
|
||||
zxdict = {
|
||||
"测试中心":"B",
|
||||
|
|
@ -938,3 +954,10 @@ def correct_ability(request):
|
|||
i.cma_oplace = i.cma_oplace.replace(key, placedict[key])
|
||||
i.save()
|
||||
print('已修改' + i.cma)
|
||||
|
||||
|
||||
def correct_cma(request):
|
||||
for i in CMA.objects.all():
|
||||
i.sszx = i.sszx.replace('14检验检测能力申请表-','')
|
||||
i.save()
|
||||
return Response()
|
||||
|
|
@ -50,12 +50,12 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
|||
return TaksDetailSerializer
|
||||
return TaskListSerializer
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
instance.delete()
|
||||
TaskDept.objects.filter(task=instance).delete()
|
||||
Record.objects.filter(task=instance).delete()
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
# def destroy(self, request, *args, **kwargs):
|
||||
# instance = self.get_object()
|
||||
# instance.delete()
|
||||
# TaskDept.objects.filter(task=instance).delete()
|
||||
# Record.objects.filter(task=instance).delete()
|
||||
# return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
@action(methods=['post'], detail=True, perms_map = {'post':'task_init'})
|
||||
def init(self, request, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ def get_permission_list(user):
|
|||
perms = perms | i.perms.all()
|
||||
perms_list = perms.values_list('method', flat=True)
|
||||
perms_list = list(set(perms_list))
|
||||
cache.set(user.username + '__perms', perms_list, 60*60*24)
|
||||
cache.set(user.username + '__perms', perms_list, 60*60)
|
||||
return perms_list
|
||||
|
||||
def has_permission(action, user):
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
from .settings import *
|
||||
DEBUG = True
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'cma',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'zctest1234',
|
||||
'HOST': '47.95.0.242',
|
||||
'PORT': '5432',
|
||||
}
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.postgresql',
|
||||
# 'NAME': 'cma',
|
||||
# 'USER': 'cma',
|
||||
# 'PASSWORD': 'cma123',
|
||||
# 'HOST': '172.16.80.102',
|
||||
# 'PORT': '5432',
|
||||
# }
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.postgresql',
|
||||
# 'NAME': 'cma',
|
||||
# 'USER': 'postgres',
|
||||
# 'PASSWORD': 'zctest1234',
|
||||
# 'HOST': '47.95.0.242',
|
||||
# 'PORT': '5432',
|
||||
# }
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'cma',
|
||||
'USER': 'cma',
|
||||
'PASSWORD': 'cma123',
|
||||
'HOST': '172.16.80.102',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue