feat: wpm/sflog 增加 enstat 数据
This commit is contained in:
parent
bc44d0335a
commit
07c996964d
|
@ -31,6 +31,7 @@ from apps.wpm.services import mlog_submit_validate, generate_new_batch
|
|||
from apps.wf.models import State
|
||||
from apps.wpmw.models import Wpr
|
||||
from apps.qm.models import QctMat, Ftest
|
||||
from apps.enm.models import EnStat
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
@ -58,7 +59,7 @@ class StLogViewSet(CustomModelViewSet):
|
|||
return super().destroy(request, *args, **kwargs)
|
||||
|
||||
|
||||
class SfLogViewSet(UpdateModelMixin, ListModelMixin, DestroyModelMixin, CustomGenericViewSet):
|
||||
class SfLogViewSet(UpdateModelMixin, CustomListModelMixin, DestroyModelMixin, CustomGenericViewSet):
|
||||
"""
|
||||
list:值班记录
|
||||
|
||||
|
@ -72,6 +73,16 @@ class SfLogViewSet(UpdateModelMixin, ListModelMixin, DestroyModelMixin, CustomGe
|
|||
search_fields = ['note']
|
||||
ordering = ['-start_time']
|
||||
|
||||
def add_info_for_list(self, data):
|
||||
sflogs = [i['id'] for i in data]
|
||||
sflogs_dict = EnStat.objects.filter(sflog_id__in=sflogs).values('sflog_id', 'total_production','qua_data','production_hour','elec_consume_unit','run_rate','production_cost_unit')
|
||||
# 创建索引
|
||||
sflogs_dict = {x['sflog_id']: x for x in sflogs_dict}
|
||||
for item in data:
|
||||
if item['id'] in sflogs_dict:
|
||||
item.update({"enstat_info": sflogs_dict[item['id']]})
|
||||
return data
|
||||
|
||||
@action(methods=['get'], detail=True, perms_map={'get': '*'})
|
||||
def init_test(self, request, pk=None):
|
||||
"""
|
||||
|
@ -96,8 +107,8 @@ class SfLogViewSet(UpdateModelMixin, ListModelMixin, DestroyModelMixin, CustomGe
|
|||
'material__sort', 'material__create_time', 'testitem__sort', 'testitem__create_time')
|
||||
sr = QuaStatSerializer(instance=qs, many=True)
|
||||
return Response(sr.data)
|
||||
|
||||
|
||||
|
||||
|
||||
class SfLogExpViewSet(ListModelMixin, UpdateModelMixin, CustomGenericViewSet):
|
||||
"""
|
||||
list:异常值班处理
|
||||
|
|
Loading…
Reference in New Issue