From a350e0085ff65965b0143465ebb35d05caa6eaf7 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 28 Feb 2022 22:06:31 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/develop/tasks.py | 6 ++---- hb_server/git.sh | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 hb_server/git.sh diff --git a/hb_server/apps/develop/tasks.py b/hb_server/apps/develop/tasks.py index c167aad..3a5ea27 100644 --- a/hb_server/apps/develop/tasks.py +++ b/hb_server/apps/develop/tasks.py @@ -12,15 +12,13 @@ def backup_database(): """ import datetime name = datetime.datetime.now().strftime('%Y%m%d%H%M%S') - command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > - /home/lighthouse/backup/hberp_{}.sql'''.format(name) + command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > /home/lighthouse/backup/hberp_{}.sql'''.format(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/git.sh' completed = subprocess.run(command, shell=True, capture_output=True, text=True) return completed diff --git a/hb_server/git.sh b/hb_server/git.sh new file mode 100644 index 0000000..d7cbef4 --- /dev/null +++ b/hb_server/git.sh @@ -0,0 +1,7 @@ +#!/bin/bash +cd /home/lighthouse/hberp +sudo git pull +cd /home/lighthouse/hberp/hb_client +npm run build:prod +rsync -avu /home/lighthouse/hberp/hb_client/dist/ /home/lighthouse/hberp/hb_server/vuedist/ +sudo service supervisor reload \ No newline at end of file From 9f56e30c80ffffb9c87a295812f9406bbf59761b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 28 Feb 2022 22:11:42 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/develop/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/develop/tasks.py b/hb_server/apps/develop/tasks.py index 3a5ea27..5b7351f 100644 --- a/hb_server/apps/develop/tasks.py +++ b/hb_server/apps/develop/tasks.py @@ -12,7 +12,7 @@ def backup_database(): """ import datetime name = datetime.datetime.now().strftime('%Y%m%d%H%M%S') - command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > /home/lighthouse/backup/hberp_{}.sql'''.format(name) + command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > /home/lighthouse/backup/database/hberp_{}.sql'''.format(name) completed = subprocess.run(command, shell=True, capture_output=True, text=True) return completed From a486848639c0c75f2b9043e3417b4d5e6d45e53b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 28 Feb 2022 22:23:32 +0800 Subject: [PATCH 03/16] =?UTF-8?q?coding=20git=20push=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/develop/views.py | 6 ++++-- hb_server/server/urls.py | 3 +-- hb_server/utils/view.py | 27 --------------------------- 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/hb_server/apps/develop/views.py b/hb_server/apps/develop/views.py index bdd9b07..0ece46c 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,10 @@ class UpdateFIFONumber(APIView): i.save() return Response() + + class ReloadServer(APIView): - permission_classes = [IsAdminUser] + permission_classes = [AllowAny] def post(self, request): """ 拉取代码并重启服务 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()) From 49666dcd49e20c61ae113a835df2f9e527611c82 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 28 Feb 2022 22:28:26 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9reload=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/develop/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hb_server/apps/develop/views.py b/hb_server/apps/develop/views.py index 0ece46c..ec43e41 100644 --- a/hb_server/apps/develop/views.py +++ b/hb_server/apps/develop/views.py @@ -124,7 +124,8 @@ class UpdateFIFONumber(APIView): class ReloadServer(APIView): - permission_classes = [AllowAny] + authentication_classes = [] + permission_classes = [] def post(self, request): """ 拉取代码并重启服务 From 4388459247da30da00650280f03a792e432fd983 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 1 Mar 2022 08:53:13 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E5=88=9B=E5=BB=BAsh=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/.gitignore | 1 + hb_server/apps/develop/tasks.py | 12 +++++++++--- hb_server/cbeat_start.sh | 4 ---- hb_server/cworker_start.sh | 4 ---- hb_server/git.sh | 7 ------- hb_server/gunicorn_start.sh | 4 ---- 6 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 hb_server/cbeat_start.sh delete mode 100644 hb_server/cworker_start.sh delete mode 100644 hb_server/git.sh delete mode 100644 hb_server/gunicorn_start.sh diff --git a/hb_server/.gitignore b/hb_server/.gitignore index df1c6b0..f5f2ce9 100644 --- a/hb_server/.gitignore +++ b/hb_server/.gitignore @@ -4,6 +4,7 @@ venv/ __pycache__/ *.pyc +sh/* media/* static/* vuedist/* diff --git a/hb_server/apps/develop/tasks.py b/hb_server/apps/develop/tasks.py index 5b7351f..398ad36 100644 --- a/hb_server/apps/develop/tasks.py +++ b/hb_server/apps/develop/tasks.py @@ -4,6 +4,7 @@ from rest_framework.response import Response from celery import shared_task import os import subprocess +from server.settings_pro import DATABASES, BACKUP_DATABASE_PATH @shared_task def backup_database(): @@ -12,13 +13,18 @@ def backup_database(): """ import datetime name = datetime.datetime.now().strftime('%Y%m%d%H%M%S') - command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > /home/lighthouse/backup/database/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(): - command = 'bash /home/lighthouse/hberp/hb_server/git.sh' + command = 'bash /home/lighthouse/hberp/hb_server/sh/git.sh' completed = subprocess.run(command, shell=True, capture_output=True, text=True) return completed @@ -30,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/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/git.sh b/hb_server/git.sh deleted file mode 100644 index d7cbef4..0000000 --- a/hb_server/git.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -cd /home/lighthouse/hberp -sudo git pull -cd /home/lighthouse/hberp/hb_client -npm run build:prod -rsync -avu /home/lighthouse/hberp/hb_client/dist/ /home/lighthouse/hberp/hb_server/vuedist/ -sudo service supervisor reload \ No newline at end of file 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 From 164c1c58471f7e124e35d5d14596b5db7add822b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 1 Mar 2022 09:29:36 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E5=A4=8D=E6=A3=80=E4=B8=8D=E5=90=88?= =?UTF-8?q?=E6=A0=BC=E8=BF=94=E5=9B=9E=E5=88=B0=E6=93=8D=E4=BD=9C=E5=87=86?= =?UTF-8?q?=E5=A4=87=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/signals.py | 2 ++ hb_server/apps/wpm/views.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hb_server/apps/wpm/signals.py b/hb_server/apps/wpm/signals.py index 04455d7..67ba2d2 100644 --- a/hb_server/apps/wpm/signals.py +++ b/hb_server/apps/wpm/signals.py @@ -71,6 +71,8 @@ def handleTicket(sender, instance, created, **kwargs): elif decision in [WProduct.NG_ACCEPT, WProduct.NG_PERMIT]: wp.act_state = WProduct.WPR_ACT_STATE_OK + if wp.test_wproduct.filter(is_submited=True).order_by('-id').last().type == TestRecord.TEST_PROCESS_RE: + 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..9e53ef9 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -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,7 +660,7 @@ 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: # 不是冷加工 + if omis.exists() and processId !=1: # 不是冷加工 raise exceptions.APIException('请选择消耗物料') # 检查自定义表单填写 From c25bc213afcb363dbe12956eb99cf8b07a3486f7 Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Tue, 1 Mar 2022 09:31:39 +0800 Subject: [PATCH 07/16] tijiao --- hb_client/src/views/em/equipment.vue | 6 +- hb_client/src/views/em/monitoring.vue | 11 +++- hb_client/src/views/em/record.vue | 11 +++- hb_client/src/views/inm/fifo.vue | 20 ++++++- hb_client/src/views/inm/fifodetail.vue | 42 ++++++++++--- hb_client/src/views/inm/materialbatch.vue | 3 + hb_client/src/views/mtm/productprocess.vue | 2 +- hb_client/src/views/wpm/need.vue | 38 +++++++----- hb_client/src/views/wpm/operation.vue | 2 +- hb_client/src/views/wpm/operationdo.vue | 69 ++++++++++++---------- hb_client/src/views/wpm/worktask.vue | 1 + 11 files changed, 144 insertions(+), 61 deletions(-) diff --git a/hb_client/src/views/em/equipment.vue b/hb_client/src/views/em/equipment.vue index 7b616e6..1ed7500 100644 --- a/hb_client/src/views/em/equipment.vue +++ b/hb_client/src/views/em/equipment.vue @@ -65,13 +65,13 @@