From 88019113de507c451fc93592a95a16c92c254892 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Feb 2022 16:13:07 +0800 Subject: [PATCH 1/7] =?UTF-8?q?update=20inm=20=E5=85=B6=E4=BB=96=E5=85=A5?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/inm/services.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hb_server/apps/inm/services.py b/hb_server/apps/inm/services.py index 8be61b7..42e08ae 100644 --- a/hb_server/apps/inm/services.py +++ b/hb_server/apps/inm/services.py @@ -12,7 +12,8 @@ class InmService: """ 更新库存(正反) """ - if instance.type in [FIFO.FIFO_TYPE_PUR_IN, FIFO.FIFO_TYPE_DO_IN]: # 采购入库, 生产入库 + if instance.type in [FIFO.FIFO_TYPE_PUR_IN, + FIFO.FIFO_TYPE_DO_IN, FIFO.FIFO_TYPE_OTHER_IN]: # 采购入库, 生产入库, 其他入库 # 更新相关表 for i in FIFOItem.objects.filter(fifo=instance): material = i.material From e44a3d7e4b76e7649701b423d95c83fffbac3770 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Feb 2022 17:00:35 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/system/permission.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hb_server/apps/system/permission.py b/hb_server/apps/system/permission.py index bcb94ac..7b218d3 100644 --- a/hb_server/apps/system/permission.py +++ b/hb_server/apps/system/permission.py @@ -8,6 +8,7 @@ def get_permission_list(user): """ 获取权限列表,可用redis存取 """ + perms_list = ['visitor'] if user.is_superuser: perms_list = ['admin'] else: @@ -43,21 +44,19 @@ class RbacPermission(BasePermission): perms = cache.get(request.user.username + '__perms') if not perms: perms = get_permission_list(request.user) - if perms: - if 'admin' in perms: - return True - elif not hasattr(view, 'perms_map'): - return True - else: - perms_map = view.perms_map - _method = request._request.method.lower() - if perms_map: - for key in perms_map: - if key == _method or key == '*': - if perms_map[key] in perms or perms_map[key] == '*': - return True - return False + + if 'admin' in perms: + return True + elif not hasattr(view, 'perms_map'): + return True else: + perms_map = view.perms_map + _method = request._request.method.lower() + if perms_map: + for key in perms_map: + if key == _method or key == '*': + if perms_map[key] in perms or perms_map[key] == '*': + return True return False def has_object_permission(self, request, view, obj): From e38141b866492a281f8eeb233db6285e031ee553 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Feb 2022 20:59:06 +0800 Subject: [PATCH 3/7] =?UTF-8?q?log=20=E6=B5=8B=E8=AF=95=20inm=20=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E5=85=A5=E5=BA=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/inm/services.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hb_server/apps/inm/services.py b/hb_server/apps/inm/services.py index 42e08ae..aa8ffe1 100644 --- a/hb_server/apps/inm/services.py +++ b/hb_server/apps/inm/services.py @@ -5,6 +5,8 @@ from apps.mtm.models import Material from apps.sam.models import SalePack, SaleProduct from django.db.models import Count from django.db.models.aggregates import Sum +import logging +logger = logging.getLogger('log') class InmService: @classmethod @@ -16,6 +18,7 @@ class InmService: FIFO.FIFO_TYPE_DO_IN, FIFO.FIFO_TYPE_OTHER_IN]: # 采购入库, 生产入库, 其他入库 # 更新相关表 for i in FIFOItem.objects.filter(fifo=instance): + logger.info(i) material = i.material warehouse = i.warehouse From 2fbbe745640bfbbde963b2635dba507cf21dd9ed Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Feb 2022 21:01:06 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=B5=8B=E8=AF=95log=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/inm/services.py | 1 - 1 file changed, 1 deletion(-) diff --git a/hb_server/apps/inm/services.py b/hb_server/apps/inm/services.py index aa8ffe1..8ee155d 100644 --- a/hb_server/apps/inm/services.py +++ b/hb_server/apps/inm/services.py @@ -18,7 +18,6 @@ class InmService: FIFO.FIFO_TYPE_DO_IN, FIFO.FIFO_TYPE_OTHER_IN]: # 采购入库, 生产入库, 其他入库 # 更新相关表 for i in FIFOItem.objects.filter(fifo=instance): - logger.info(i) material = i.material warehouse = i.warehouse From b3f14a8f6f0badd52fa82d0e84d5955a42d59a8c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sat, 26 Feb 2022 12:16:02 +0800 Subject: [PATCH 5/7] develop reload backup --- hb_server/apps/develop/tasks.py | 9 +++++---- hb_server/apps/develop/views.py | 13 +++++++++++-- .../sam/migrations/0016_sale_iproducts.py | 19 +++++++++++++++++++ hb_server/apps/sam/models.py | 1 + hb_server/apps/sam/views_sale.py | 7 ++++++- 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 hb_server/apps/sam/migrations/0016_sale_iproducts.py diff --git a/hb_server/apps/develop/tasks.py b/hb_server/apps/develop/tasks.py index a7345dc..eb46aa2 100644 --- a/hb_server/apps/develop/tasks.py +++ b/hb_server/apps/develop/tasks.py @@ -10,14 +10,15 @@ def backup_database(): """ 备份数据库 """ - ret = os.popen('sudo pg_dump -U postgres -d hberp -f /home/lighthouse/hberp_backup.sql') - return Response() + completed = subprocess.run('sudo pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > /home/lighthouse/hberp_backup.sql', + shell=True, capture_output=True, text=True) + return completed @shared_task def reload_server(): os.chdir('/home/lighthouse/hberp') - ret = subprocess.run('sudo git pull && sudo service supervisor reload') - return Response(ret.read()) + completed = subprocess.run('sudo git pull && sudo service supervisor reload', 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 0cad10c..90b29ca 100644 --- a/hb_server/apps/develop/views.py +++ b/hb_server/apps/develop/views.py @@ -13,6 +13,7 @@ from apps.wf.models import Ticket from apps.wpm.models import Operation, OperationMaterial, WProduct, WproductFlow from apps.wpm.services import WpmService from apps.em.tasks import update_equip_state_by_next_check_date +from rest_framework.exceptions import APIException # Create your views here. class CleanDataView(APIView): @@ -123,10 +124,18 @@ class UpdateFIFONumber(APIView): class ReloadServer(APIView): permission_classes = [IsAdminUser] def post(self, request): - reload_server() + completed = reload_server() + if completed.returncode == 0: + return Response() + else: + raise APIException(completed.stdout) class BackupDatabase(APIView): permission_classes = [IsAdminUser] def post(self, request): - backup_database() \ No newline at end of file + completed = backup_database() + if completed.returncode == 0: + return Response() + else: + raise APIException(completed.stdout) \ No newline at end of file diff --git a/hb_server/apps/sam/migrations/0016_sale_iproducts.py b/hb_server/apps/sam/migrations/0016_sale_iproducts.py new file mode 100644 index 0000000..00c6f8d --- /dev/null +++ b/hb_server/apps/sam/migrations/0016_sale_iproducts.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.9 on 2022-02-26 00:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('inm', '0032_auto_20220222_0941'), + ('sam', '0015_sale_ship_pic'), + ] + + operations = [ + migrations.AddField( + model_name='sale', + name='iproducts', + field=models.ManyToManyField(through='sam.SaleProduct', to='inm.IProduct'), + ), + ] diff --git a/hb_server/apps/sam/models.py b/hb_server/apps/sam/models.py index ba9a809..12ef0a8 100644 --- a/hb_server/apps/sam/models.py +++ b/hb_server/apps/sam/models.py @@ -94,6 +94,7 @@ class Sale(CommonADModel): receiver_address = models.CharField('收获地址', null=True, blank=True, max_length=200) remark = models.CharField('备注', null=True, blank=True, max_length=200) ship_pic = models.CharField('物流图片', max_length=200, null=True, blank=True) + iproducts = models.ManyToManyField('inm.iproduct', through='sam.saleproduct') class SaleProduct(BaseModel): """ diff --git a/hb_server/apps/sam/views_sale.py b/hb_server/apps/sam/views_sale.py index ed18874..1889abc 100644 --- a/hb_server/apps/sam/views_sale.py +++ b/hb_server/apps/sam/views_sale.py @@ -36,7 +36,8 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C elif self.action == 'retrieve': return SaleListSerializer return super().get_serializer_class() - + + @transaction.atomic def destroy(self, request, *args, **kwargs): obj = self.get_object() if obj.is_audited: @@ -161,6 +162,8 @@ class SaleProductViewSet(ListModelMixin, DestroyModelMixin, CreateModelMixin, Ge }) return Response(SaleProductPackDetailSerializer(instance=obj).data) elif request.method == 'POST': + if obj.sale.is_audited: + raise exceptions.APIException('该销售记录已审核,不可装箱') serializer = SaleProductPackSerializer(data=request.data) serializer.is_valid(raise_exception=True) vdata = serializer.validated_data @@ -180,6 +183,8 @@ class SaleProductViewSet(ListModelMixin, DestroyModelMixin, CreateModelMixin, Ge 不装箱备注 """ obj = self.get_object() + if obj.sale.is_audited: + raise exceptions.APIException('该销售记录已审核,不可填写备注') serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) vdata = serializer.validated_data From d4730020a1c3564aa6743df7190f9f84f39f8c76 Mon Sep 17 00:00:00 2001 From: shilixia <2309368887@qq.com> Date: Mon, 28 Feb 2022 09:09:21 +0800 Subject: [PATCH 6/7] tijiao --- hb_client/src/views/pm/management.vue | 2 +- hb_client/src/views/pm/resources.vue | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hb_client/src/views/pm/management.vue b/hb_client/src/views/pm/management.vue index 5a2df27..caa5cb6 100644 --- a/hb_client/src/views/pm/management.vue +++ b/hb_client/src/views/pm/management.vue @@ -46,7 +46,7 @@ - -