Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
shijing 2022-02-17 14:32:25 +08:00
commit e2493b0eee
8 changed files with 49 additions and 14 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-02-16 07:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mtm', '0045_usedstep_need_test'),
]
operations = [
migrations.AlterField(
model_name='recordform',
name='type',
field=models.IntegerField(choices=[(10, '生产记录表'), (20, '工序检查表'), (30, '入厂检查表'), (40, '成品检查表'), (50, '首件检查表')], default=1, verbose_name='表格类型'),
),
]

View File

@ -107,11 +107,17 @@ class RecordForm(CommonAModel):
"""
记录表格
"""
RF_TYPE_DO = 1
RF_TYPE_TEST = 2
RF_TYPE_DO = 10
RF_TYPE_TEST = 20
RF_TYPE_TEST_IN = 30
RF_TYPE_TEST_GOOD = 40
RF_TYPE_TEST_FIRST = 50
type_choices=(
(RF_TYPE_DO, '生产记录模板'),
(RF_TYPE_TEST, '检验记录模板')
(RF_TYPE_DO, '生产记录表'),
(RF_TYPE_TEST, '工序检查表'),
(RF_TYPE_TEST_IN, '入厂检查表'),
(RF_TYPE_TEST_GOOD, '成品检查表'),
(RF_TYPE_TEST_FIRST, '首件检查表'),
)
name = models.CharField('表格名称', max_length=100)
type = models.IntegerField('表格类型', choices=type_choices, default=1)

View File

@ -190,6 +190,7 @@ class RecordFormCreateSerializer(serializers.ModelSerializer):
model = RecordForm
fields = ['name', 'type', 'step', 'material', 'number', 'enabled']
class RecordFormUpdateSerializer(serializers.ModelSerializer):
class Meta:
model = RecordForm

View File

@ -7,7 +7,7 @@ import django.utils.timezone as timezone
from django.db.models.query import QuerySet
from utils.model import SoftModel, BaseModel
from apps.mtm.models import Material, Process, SubProduction, SubprodctionMaterial
from apps.mtm.models import Material, Process, RecordFormField, SubProduction, SubprodctionMaterial
from apps.sam.models import Order
class ProductionPlan(CommonAModel):
@ -91,6 +91,16 @@ class SubProductionPlan(CommonAModel):
verbose_name = '子生产计划'
verbose_name_plural = verbose_name
class FirstItem(BaseModel):
"""
首件确认表记录条目
"""
form_field = models.ForeignKey(RecordFormField, verbose_name='关联自定义表格字段', on_delete=models.CASCADE)
field_value = models.JSONField('录入值', null=True, blank=True)
is_hidden = models.BooleanField('是否隐藏', default=False)
is_testok = models.BooleanField('是否合格', null=True, blank=True)
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联的子计划', on_delete=models.CASCADE, related_name='item_test_record')
class SubProductionProgress(BaseModel):
"""
子计划生产进度统计表/物料消耗
@ -104,3 +114,4 @@ class SubProductionProgress(BaseModel):
count_real = models.PositiveIntegerField('实际消耗/产出数', default=0)
count_ok = models.PositiveIntegerField('合格数量', default=0)
count_notok = models.PositiveIntegerField('不合格数量', default=0)

View File

@ -9,15 +9,11 @@ class CustomBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
if username is None:
username = kwargs.get(UserModel.USERNAME_FIELD)
if username is None or password is None:
return
try:
user = UserModel._default_manager.get(
Q(username=username) | Q(phone=username) | Q(email=username))
except UserModel.DoesNotExist:
# Run the default password hasher once to reduce the timing
# difference between an existing and a nonexistent user (#20760).
UserModel().set_password(password)
return None
else:
if user.check_password(password) and self.user_can_authenticate(user):
return user

View File

@ -35,7 +35,10 @@ class RbacPermission(BasePermission):
:return:
"""
if not request.user:
perms = ['visitor'] # 如果没有经过认证,视为游客
if request.META.get('HTTP_AUTHORIZATION', None) == 'big_screen':
perms = ['visitor']
else:
return False
else:
perms = cache.get(request.user.username + '__perms')
if not perms:

View File

@ -158,7 +158,7 @@ REST_FRAMEWORK = {
'rest_framework.authentication.SessionAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
# 'rest_framework.permissions.IsAuthenticated',
'apps.system.permission.RbacPermission'
],
'DEFAULT_RENDERER_CLASSES': [

View File

@ -48,9 +48,9 @@ class FitJSONRenderer(JSONRenderer):
response_body = BaseResponse()
response = renderer_context.get("response")
status_code = response.status_code # Http状态异常码
print(status_code)
if status_code >= 400: # 如果http响应异常
if isinstance(data, dict) and 'code' in data: # 如果自定义了异常码
if isinstance(data, dict) \
and 'code' in data and 'msg' in data: # 如果自定义了异常码
response_body = data
else:
response_body.data = data # data里是详细异常信息