编辑
@@ -812,35 +816,41 @@ export default {
handleClick(tab) {
console.log(tab.name);
var str = tab.label.substr(tab.label.length - 1, 1);
- if (str == "x") {
- const xhr = new XMLHttpRequest();
+ // if (str == "x") {
+ // const xhr = new XMLHttpRequest();
- xhr.open("get", tab.name, true);
+ // xhr.open("get", tab.name, true);
- xhr.responseType = "arraybuffer";
+ // xhr.responseType = "arraybuffer";
- xhr.onload = () => {
- if (xhr.status == 200) {
- mammoth
- .convertToHtml({ arrayBuffer: new Uint8Array(xhr.response) })
- .then((resultObject) => {
- this.$nextTick(() => {
- this.wordText = resultObject.value;
- });
- });
- }
- };
- xhr.send();
- var filediv = document.getElementById("file");
- filediv.innerHTML =
- '
- /home/lighthouse/backup/hberp_{}.sql'''.format(name)
+ command = 'pg_dump "user={} password={} dbname={}" > {}/hberp_{}.sql'.format(
+ DATABASES['default']['USER'],
+ DATABASES['default']['PASSWORD'],
+ DATABASES['default']['NAME'],
+ BACKUP_DATABASE_PATH,
+ name)
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed
@shared_task
def reload_server():
- os.chdir('/home/lighthouse/hberp')
- command = 'sudo git pull && sudo service supervisor reload'
+ command = 'bash /home/lighthouse/hberp/hb_server/sh/git.sh'
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed
@@ -32,7 +36,7 @@ def reload_server_only():
@shared_task
def backup_media():
- command = 'rsync -avu /home/lighthouse/hberp/hb_server/media/ /home/lighthouse/backup/media/'
+ command = 'bash /home/lighthouse/hberp/hb_server/sh/backup_media.sh'
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed
diff --git a/hb_server/apps/develop/views.py b/hb_server/apps/develop/views.py
index bdd9b07..ec43e41 100644
--- a/hb_server/apps/develop/views.py
+++ b/hb_server/apps/develop/views.py
@@ -2,7 +2,7 @@ from django.db import transaction
from django.shortcuts import render
from rest_framework.decorators import permission_classes
from rest_framework.views import APIView
-from rest_framework.permissions import IsAdminUser
+from rest_framework.permissions import IsAdminUser, AllowAny
from rest_framework.response import Response
from apps.develop.tasks import backup_database, backup_media, reload_server, reload_server_only
from apps.inm.models import FIFO, FIFOItem, Inventory, MaterialBatch
@@ -121,8 +121,11 @@ class UpdateFIFONumber(APIView):
i.save()
return Response()
+
+
class ReloadServer(APIView):
- permission_classes = [IsAdminUser]
+ authentication_classes = []
+ permission_classes = []
def post(self, request):
"""
拉取代码并重启服务
diff --git a/hb_server/apps/pm/views.py b/hb_server/apps/pm/views.py
index cb02d67..4257e9f 100644
--- a/hb_server/apps/pm/views.py
+++ b/hb_server/apps/pm/views.py
@@ -98,7 +98,7 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
for index, i in enumerate(subps):
steps = Step.objects.filter(usedstep__subproduction=i, usedstep__subproduction__is_deleted=False,
usedstep__is_deleted=False, is_deleted=False
- ).values('id', 'number', 'name', 'usedstep__remark', need_test=F('usedstep__need_test'))
+ ).order_by('number').values('id', 'number', 'name', 'usedstep__remark', need_test=F('usedstep__need_test'))
instance = SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i,
start_date=production_plan.start_date, end_date=production_plan.end_date,
workshop=i.process.workshop, process=i.process, create_by=request.user,
diff --git a/hb_server/apps/system/views.py b/hb_server/apps/system/views.py
index 3664054..3677e66 100644
--- a/hb_server/apps/system/views.py
+++ b/hb_server/apps/system/views.py
@@ -200,9 +200,9 @@ class PermissionViewSet(ModelViewSet):
queryset = Permission.objects.all()
serializer_class = PermissionSerializer
pagination_class = None
- search_fields = ['name']
- ordering_fields = ['sort']
- ordering = ['pk']
+ search_fields = ['name', 'method']
+ ordering_fields = ['sort', 'id', 'method']
+ ordering = ['sort']
class OrganizationViewSet(ModelViewSet):
diff --git a/hb_server/apps/wpm/serializers.py b/hb_server/apps/wpm/serializers.py
index b5c702f..61ae4b5 100644
--- a/hb_server/apps/wpm/serializers.py
+++ b/hb_server/apps/wpm/serializers.py
@@ -64,6 +64,8 @@ class PickSerializer(serializers.Serializer):
fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_OUT,
inout_date=timezone.now(), create_by=self.context['request'].user,
number = 'CK' + ranstr(7))
+ if len(picks)<=0:
+ raise exceptions.APIException('没有领料项目')
for i in picks:
isLowLevel = False
# 更新出库详情
@@ -116,8 +118,9 @@ class PickSerializer(serializers.Serializer):
subproduction_plan=sp)
sp.is_picked=True
sp.state = SubProductionPlan.SUBPLAN_STATE_WORKING #生产中
- sp.state_date_real = timezone.now() #实际开工日期
- sp.save()
+ if sp.start_date_real is None:
+ sp.start_date_real = timezone.now()#实际开工日期
+ sp.save()
# 创建领料记录
pick = Pick()
pick.subproduction_plan = sp
diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py
index acf5cf0..f836273 100644
--- a/hb_server/apps/wpm/services.py
+++ b/hb_server/apps/wpm/services.py
@@ -76,8 +76,9 @@ class WpmService(object):
if wt.step.process == test.step.process:
wproduct.ng_sign = None
ticket = wt.ticket
- ticket_data = wt.ticket_data
+ ticket_data = ticket.ticket_data
ticket_data['retest_result'] = 1
+ ticket.ticket_data = ticket_data
ticket.update_by = user
ticket.save()
# 创建处理日志
diff --git a/hb_server/apps/wpm/signals.py b/hb_server/apps/wpm/signals.py
index 04455d7..874859a 100644
--- a/hb_server/apps/wpm/signals.py
+++ b/hb_server/apps/wpm/signals.py
@@ -71,6 +71,10 @@ def handleTicket(sender, instance, created, **kwargs):
elif decision in [WProduct.NG_ACCEPT, WProduct.NG_PERMIT]:
wp.act_state = WProduct.WPR_ACT_STATE_OK
+ # 获取最后一次检验
+ test= wp.test_wproduct.filter(is_submited=True).order_by('-id').last()
+ if test.type == TestRecord.TEST_PROCESS_RE or test.is_midtesting:
+ wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT
wp.ng_sign = decision
wt.save()
wp.ticket = None # 解除当前工单
diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py
index 00410a0..59a4086 100644
--- a/hb_server/apps/wpm/views.py
+++ b/hb_server/apps/wpm/views.py
@@ -163,7 +163,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
'to_order').prefetch_related('wp_child')
serializer_class = WProductListSerializer
filterset_class = WProductFilterSet
- search_fields = ['number']
+ search_fields = ['number', 'material__name', 'subproduction_plan__number']
ordering_fields = ['id']
ordering = ['id']
@@ -315,7 +315,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
remark = vdata.get('remark', '')
fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_IN,
is_audited=True, auditor=request.user, inout_date=timezone.now(),
- create_by=request.user, remark=remark)
+ create_by=request.user, remark=remark, number='RK'+ranstr(7))
# 创建入库明细
fifoitem = FIFOItem()
fifoitem.warehouse = warehouse
@@ -331,6 +331,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
ip = {}
ip['fifoitem'] = fifoitem
ip['wproduct'] = i
+ if i.number is None:
+ raise exceptions.APIException('缺少编号')
ip['number'] = i.number
ip['material'] = material
ips.append(FIFOItemProduct(**ip))
@@ -658,8 +660,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
if set(list(sps_omi_l)) != set(list(sps_omo_l)):
raise exceptions.APIException('消耗与产出不一致')
else:
- if not omis.exists() and processId !=1: # 不是冷加工
- raise exceptions.APIException('请选择消耗物料')
+ pass
+ # if omis.exists() and processId !=1: # 不是冷加工
+ # raise exceptions.APIException('请选择消耗物料')
# 检查自定义表单填写
if OperationRecord.objects.filter(operation=op, is_filled=False).exists():
@@ -710,6 +713,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT
if needTest:
wp.act_state = WProduct.WPR_ACT_STATE_TOTEST
+ if wp.test:# 如果有正在进行的工序中检验
+ wp.test.is_submited = False
+ wp.test.save()
wp.operation = None
wp.update_by = request.user
diff --git a/hb_server/cbeat_start.sh b/hb_server/cbeat_start.sh
deleted file mode 100644
index cd68f13..0000000
--- a/hb_server/cbeat_start.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd /home/lighthouse/hberp/hb_server
-source venv/bin/activate
-exec celery -A server beat -l info
diff --git a/hb_server/cworker_start.sh b/hb_server/cworker_start.sh
deleted file mode 100644
index bad19e2..0000000
--- a/hb_server/cworker_start.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd /home/lighthouse/hberp/hb_server
-source venv/bin/activate
-exec celery -A server worker -l info
diff --git a/hb_server/gunicorn_start.sh b/hb_server/gunicorn_start.sh
deleted file mode 100644
index b842dc0..0000000
--- a/hb_server/gunicorn_start.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd /home/lighthouse/hberp/hb_server
-source venv/bin/activate
-exec gunicorn -w 5 -b 0.0.0.0:2223 server.wsgi
diff --git a/hb_server/server/urls.py b/hb_server/server/urls.py
index 0ed07c3..50bc49f 100644
--- a/hb_server/server/urls.py
+++ b/hb_server/server/urls.py
@@ -24,7 +24,7 @@ from drf_yasg.views import get_schema_view
from rest_framework import routers
from rest_framework.documentation import include_docs_urls
from django.views.generic import TemplateView
-from utils.view import GenSignature, UpdateDevelop
+from utils.view import GenSignature
import os
router = routers.DefaultRouter()
router.register('', FileViewSet, basename="file")
@@ -75,7 +75,6 @@ urlpatterns = [
# 工具
path('api/utils/signature/', GenSignature.as_view()),
- path('api/utils/develop/', UpdateDevelop.as_view()),
# 前端页面入口
path('',TemplateView.as_view(template_name="index.html"))
diff --git a/hb_server/utils/view.py b/hb_server/utils/view.py
index be860d6..3d489a3 100644
--- a/hb_server/utils/view.py
+++ b/hb_server/utils/view.py
@@ -65,30 +65,3 @@ class GenSignature(APIView):
except:
return Response('签名照处理失败,请重新上传',
status=status.HTTP_400_BAD_REQUEST)
-
-
-import time
-class UpdateDevelop(APIView):
- """
- 更新开发服务器
- """
- authentication_classes = ()
- permission_classes = ()
-
- def post(self, request, *args, **kwargs):
- import os
- # 更新后端
- os.chdir('/home/lighthouse/hberp')
- ret = os.popen('sudo git pull && sudo service supervisor reload')
- # 奇怪的处理
- # os.chdir('/home/hberp/hb_server/vuedist')
- # os.popen('cp index.html indexbak')
- # time.sleep(1000)
- # os.popen('rm -rf index.html')
- # time.sleep(1000)
- # os.popen('mv -f indexbak index.html')
- # 打包前端
- # os.chdir('/home/hberp/hb_client')
- # os.system('npm run build:prod')
- # os.system('\cp -rf /home/hberp/hb_client/dist/* /home/hberp/hb_server/vuedist')
- return Response(ret.read())