diff --git a/hb_client/src/components/faceLogin/review.vue b/hb_client/src/components/faceLogin/review.vue index c791bdd..d466c30 100644 --- a/hb_client/src/components/faceLogin/review.vue +++ b/hb_client/src/components/faceLogin/review.vue @@ -131,7 +131,7 @@ faceLogin(imgData).then((res) => { if (res.code >= 200) { if(res.data.access){ - let item= {name:res.data.username,token:res.data.access}; + let item= {name:res.data.name,token:res.data.access}; that.$emit('func',item); that.$message.success("身份认证成功!"); this.closeCamera(); diff --git a/hb_client/src/views/mtm/materialdo.vue b/hb_client/src/views/mtm/materialdo.vue index 306988d..6a63650 100644 --- a/hb_client/src/views/mtm/materialdo.vue +++ b/hb_client/src/views/mtm/materialdo.vue @@ -101,6 +101,7 @@ v-model="recordform.form" style="width: 100%" clearable + filterable placeholder="请选择" > { + getsubplanList(this.listQuery).then((response) => { if (response.data) { this.subPlanList = response.data.results; this.count = response.data.count; diff --git a/hb_server/apps/develop/tasks.py b/hb_server/apps/develop/tasks.py index f4e566d..a7345dc 100644 --- a/hb_server/apps/develop/tasks.py +++ b/hb_server/apps/develop/tasks.py @@ -1,7 +1,8 @@ from __future__ import absolute_import, unicode_literals from rest_framework.response import Response from celery import shared_task - +import os +import subprocess @shared_task @@ -9,15 +10,13 @@ def backup_database(): """ 备份数据库 """ - import os ret = os.popen('sudo pg_dump -U postgres -d hberp -f /home/lighthouse/hberp_backup.sql') return Response() @shared_task def reload_server(): - import os # 更新后端 os.chdir('/home/lighthouse/hberp') - ret = os.popen('sudo git pull && sudo service supervisor reload') + ret = subprocess.run('sudo git pull && sudo service supervisor reload') return Response(ret.read()) diff --git a/hb_server/apps/inm/serializers.py b/hb_server/apps/inm/serializers.py index 1b14ae3..d033aaa 100644 --- a/hb_server/apps/inm/serializers.py +++ b/hb_server/apps/inm/serializers.py @@ -192,6 +192,8 @@ class FIFOInPurSerializer(serializers.ModelSerializer): def create(self, validated_data): pu_order = validated_data['pu_order'] + if not pu_order.is_audited: + raise ValidationError('该采购订单未审核') validated_data['vendor'] = pu_order.vendor validated_data['number'] = 'RK' + ranstr(7) validated_data['type'] = FIFO.FIFO_TYPE_PUR_IN diff --git a/hb_server/apps/inm/services.py b/hb_server/apps/inm/services.py index aac1d34..8be61b7 100644 --- a/hb_server/apps/inm/services.py +++ b/hb_server/apps/inm/services.py @@ -17,15 +17,19 @@ class InmService: for i in FIFOItem.objects.filter(fifo=instance): material = i.material warehouse = i.warehouse - o1, _ = Inventory.objects.get_or_create(material=material, warehouse=warehouse, \ - defaults={'material':material, 'warehouse':warehouse, 'count':0}) - o1.count = o1.count + i.count - o1.save() + o2, _ = MaterialBatch.objects.get_or_create(material=material, warehouse=warehouse, batch=i.batch,\ defaults={'material':material, 'warehouse':warehouse, 'count':0, 'batch':i.batch}) o2.count = o2.count + i.count o2.save() - material.count = material.count + i.count + + iv, _= Inventory.objects.get_or_create(material=material, warehouse=warehouse, \ + defaults={'material':material, 'warehouse':warehouse, 'count':0}) + iv.count = MaterialBatch.objects.filter(material=material, + warehouse=warehouse).aggregate(total=Sum('count')).get('total', 0) + iv.save() + + material.count = MaterialBatch.objects.filter(material=material).aggregate(total=Sum('count')).get('total', 0) material.save() # 创建IProduct @@ -63,10 +67,12 @@ class InmService: mb.save() iv = Inventory.objects.get(material=material, warehouse=warehouse) - iv.count = MaterialBatch.objects.filter(material=material, warehouse=warehouse).count() + iv.count = MaterialBatch.objects.filter(material=material, + warehouse=warehouse).aggregate(total=Sum('count')).get('total', 0) iv.save() - material.count = MaterialBatch.objects.filter(material=material).count() + material.count = MaterialBatch.objects.filter(material= + material).aggregate(total=Sum('count')).get('total', 0) material.save() # 删除IProduct diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 04c7f9f..00410a0 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -352,6 +352,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): serializer = ScrapSerializer(data=request.data) serializer.is_valid(raise_exception=True) vdata = serializer.validated_data + if obj.ticket is not None: + raise exceptions.APIException('该产品存在进行工单') if obj.act_state == WProduct.WPR_ACT_STATE_NOTOK: pass elif obj.step.process.id == 1 and \