Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
shilixia 2022-02-28 09:09:28 +08:00
commit 07992d9a14
16 changed files with 74 additions and 33 deletions

View File

@ -19,7 +19,11 @@
@expand-change="handlerExpand"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<el-table-column label="任务编号" prop="name" min-width="140" show-overflow-tooltip>
<el-table-column label="任务编号" min-width="140" show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.name">{{scope.row.name}}</span>
<span v-else></span>
</template>
</el-table-column>
<el-table-column label="产品名称" prop="productName" min-width="120" show-overflow-tooltip>
</el-table-column>

View File

@ -827,7 +827,7 @@
Math.round(end / this.currentDaySize.value) *
this.currentDaySize.value -this.currentDaySize.value;
this.currentProjectMsg = {
name: this.computedList[index].name,
name: this.computedList[index].name?this.computedList[index].name:'',
allTime: (end - start) / this.currentDaySize.value + 1,
per: this.computedList[index].per,
per1: this.computedList[index].per1,

View File

@ -243,7 +243,7 @@
that.img = new Image();
that.img.crossOrigin = 'anonymous';
let value = imag[0].field_value?imag[0].field_value:imag[0].draw_template;
that.img = 'http://47.95.0.242:2222'+value;
that.img = 'http://49.232.14.174:2222'+value;
setTimeout(function(){
that.canvasInit();
},500);

View File

@ -327,8 +327,8 @@
});
that.img = new Image();
that.img.crossOrigin = '';
that.img = 'http://47.95.0.242:2222'+imag[0].field_value;
that.originImg = 'http://47.95.0.242:2222'+imag[0].origin_value;
that.img = 'http://49.232.14.174:2222'+imag[0].field_value;
that.originImg = 'http://49.232.14.174:2222'+imag[0].origin_value;
listJudge.forEach(item => {
let obj = new Object();
obj = item;

View File

@ -106,7 +106,7 @@
<el-col v-for="item in fieldList" :key="item.id" :span="24">
<div class="items" v-if="item.field_type==='draw'" style="height: 400px">
<span class="itemLabel">{{item.field_name}}</span>
<img style="width: 45%;vertical-align: text-top;" :src="'http://47.95.0.242:2222'+item.field_value"/>
<img style="width: 45%;vertical-align: text-top;" :src="'http://49.232.14.174:2222'+item.field_value"/>
</div>
</el-col>
</el-row>

View File

@ -145,7 +145,7 @@
<el-col v-for="item in fieldList" :key="item.id" :span="24">
<div class="items" v-if="item.field_type==='draw'" style="height: 400px">
<span class="itemLabel">{{item.field_name}}</span>
<img style="width: 45%;vertical-align: text-top;" :src="'http://47.95.0.242:2222'+item.field_value"/>
<img style="width: 45%;vertical-align: text-top;" :src="'http://49.232.14.174:2222'+item.field_value"/>
</div>
</el-col>
</el-row>

View File

@ -79,7 +79,7 @@
<el-col v-for="item in fieldList" :key="item.id" :span="24">
<div class="items" v-if="item.field_type==='draw'" style="height: 400px">
<span class="itemLabel">{{item.field_name}}</span>
<img style="width: 45%;vertical-align: text-top;" :src="'http://47.95.0.242:2222'+item.field_value"/>
<img style="width: 45%;vertical-align: text-top;" :src="'http://49.232.14.174:2222'+item.field_value"/>
</div>
</el-col>
</el-row>

View File

@ -186,10 +186,10 @@
<el-col v-for="item in fieldList" :key="item.id" :span="24">
<div class="items" v-if="item.field_type==='draw'" style="height: 400px">
<span class="itemLabel">{{item.field_name}}</span>
<img style="width: 45%;vertical-align: text-top;" :src="'http://47.95.0.242:2222'+item.field_value"/>
<img style="width: 45%;vertical-align: text-top;" :src="'http://49.232.14.174:2222'+item.field_value"/>
</div>
</el-col>
<el-col :span="12" v-if="achieve">
<el-col :span="12">
<div class="items">
<span class="itemLabel">检验结果</span>
<span v-if="is_testok">检验合格</span>

View File

@ -651,7 +651,7 @@
<el-col v-for="item in fieldList" :key="item.id" :span="24">
<div class="items" v-if="item.field_type==='draw'" style="height: 400px">
<span class="itemLabel">{{item.field_name}}</span>
<img style="width: 45%;vertical-align: text-top;" :src="'http://47.95.0.242:2222'+item.field_value"/>
<img style="width: 45%;vertical-align: text-top;" :src="'http://49.232.14.174:2222'+item.field_value"/>
</div>
</el-col>
</el-row>

View File

@ -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

View File

@ -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()
completed = backup_database()
if completed.returncode == 0:
return Response()
else:
raise APIException(completed.stdout)

View File

@ -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
@ -12,7 +14,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

View File

@ -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'),
),
]

View File

@ -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):
"""

View File

@ -37,6 +37,7 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
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

View File

@ -8,6 +8,7 @@ def get_permission_list(user):
"""
获取权限列表,可用redis存取
"""
perms_list = ['visitor']
if user.is_superuser:
perms_list = ['admin']
else:
@ -43,7 +44,7 @@ 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'):
@ -57,8 +58,6 @@ class RbacPermission(BasePermission):
if perms_map[key] in perms or perms_map[key] == '*':
return True
return False
else:
return False
def has_object_permission(self, request, view, obj):
"""