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

This commit is contained in:
shilixia 2022-02-25 10:12:14 +08:00
commit a0595d4c22
11 changed files with 78 additions and 46 deletions

View File

@ -2,6 +2,6 @@
ENV = 'production' ENV = 'production'
# base api # base api
VUE_APP_BASE_API = 'http://47.95.0.242:2222/api' VUE_APP_BASE_API = 'http://49.232.14.174:2222/api'
#VUE_APP_BASE_API = 'http://127.0.0.1:8000/api' #VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'

View File

@ -17,36 +17,34 @@ class HRMService:
f.write(base64_data) f.write(base64_data)
try: try:
unknown_picture = face_recognition.load_image_file(filepath) unknown_picture = face_recognition.load_image_file(filepath)
unknown_face_encoding = face_recognition.face_encodings(unknown_picture)[0] unknown_face_encoding = face_recognition.face_encodings(unknown_picture, num_jitters=2)[0]
os.remove(filepath) os.remove(filepath)
except: except:
os.remove(filepath) os.remove(filepath)
return None, '人脸识别失败' return None, '识别失败,请调整位置'
# 匹配人脸库 # 匹配人脸库
face_datas = cache.get('face_datas') face_datas = cache.get('face_datas')
face_users = cache.get('face_users')
if face_datas is None: if face_datas is None:
update_all_user_facedata_cache() update_all_user_facedata_cache()
try: face_datas = cache.get('face_datas')
results = face_recognition.compare_faces(face_datas, face_users = cache.get('face_users')
unknown_face_encoding, tolerance=0.5) results = face_recognition.compare_faces(face_datas,
except: unknown_face_encoding, tolerance=0.45)
return None, '人脸匹配失败'
for index, value in enumerate(results): for index, value in enumerate(results):
if value: if value:
# 识别成功 # 识别成功
user = User.objects.get(id=face_users[index]) user = User.objects.get(id=face_users[index])
return user, '' return user, ''
return None, '人脸匹配失败' return None, '人脸未匹配,请调整位置'
@classmethod @classmethod
def get_facedata_from_img(cls, img_path): def get_facedata_from_img(cls, img_path):
try: try:
photo_path = settings.BASE_DIR + img_path photo_path = settings.BASE_DIR + img_path
picture_of_me = face_recognition.load_image_file(photo_path) picture_of_me = face_recognition.load_image_file(photo_path)
my_face_encoding = face_recognition.face_encodings(picture_of_me)[0] my_face_encoding = face_recognition.face_encodings(picture_of_me, num_jitters=2)[0]
face_data_list = my_face_encoding.tolist() face_data_list = my_face_encoding.tolist()
return face_data_list, '' return face_data_list, ''
except: except:
return None, '人脸识别失败' return None, '人脸数据获取失败请重新上传图片'

View File

@ -183,6 +183,7 @@ class FaceLogin(CreateAPIView):
return Response({ return Response({
'refresh': str(refresh), 'refresh': str(refresh),
'access': str(refresh.access_token), 'access': str(refresh.access_token),
'username':user.username 'username':user.username,
'name':user.name
}) })
return Response(msg, status=status.HTTP_400_BAD_REQUEST) return Response(msg, status=status.HTTP_400_BAD_REQUEST)

View File

@ -55,23 +55,18 @@ class InmService:
for i in FIFOItem.objects.filter(fifo=instance): for i in FIFOItem.objects.filter(fifo=instance):
material = i.material material = i.material
warehouse = i.warehouse warehouse = i.warehouse
o1 = Inventory.objects.get(material=material, warehouse=warehouse) mb = MaterialBatch.objects.get(material=material, warehouse=warehouse, batch=i.batch)
temp_count = o1.count - i.count temp_count = mb.count - i.count
if temp_count < 0:
raise ValidationError('仓库库存不足,操作失败')
o1.count = temp_count
o1.save()
print(i.batch)
o2 = MaterialBatch.objects.get(material=material, warehouse=warehouse, batch=i.batch)
temp_count = o2.count - i.count
if temp_count < 0: if temp_count < 0:
raise ValidationError('批次库存不足,操作失败') raise ValidationError('批次库存不足,操作失败')
o2.count = temp_count mb.count = temp_count
o2.save() mb.save()
temp_count = material.count - i.count
if temp_count < 0: iv = Inventory.objects.get(material=material, warehouse=warehouse)
raise ValidationError('物料库存不足,操作失败') iv.count = MaterialBatch.objects.filter(material=material, warehouse=warehouse).count()
material.count = temp_count iv.save()
material.count = MaterialBatch.objects.filter(material=material).count()
material.save() material.save()
# 删除IProduct # 删除IProduct

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-02-25 01:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sam', '0014_auto_20220222_1530'),
]
operations = [
migrations.AddField(
model_name='sale',
name='ship_pic',
field=models.CharField(blank=True, max_length=200, null=True, verbose_name='物流图片'),
),
]

View File

@ -93,6 +93,7 @@ class Sale(CommonADModel):
receiver_phone = models.CharField('收货人联系电话', null=True, blank=True, max_length=20) receiver_phone = models.CharField('收货人联系电话', null=True, blank=True, max_length=20)
receiver_address = models.CharField('收获地址', null=True, blank=True, max_length=200) receiver_address = models.CharField('收获地址', null=True, blank=True, max_length=200)
remark = 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)
class SaleProduct(BaseModel): class SaleProduct(BaseModel):
""" """

View File

@ -97,3 +97,6 @@ class SaleProductPackSerializer(serializers.ModelSerializer):
class SRemarkItemCreateSerializer(serializers.Serializer): class SRemarkItemCreateSerializer(serializers.Serializer):
remark = serializers.CharField(min_length=6) remark = serializers.CharField(min_length=6)
class SaleUpShipPicSerializer(serializers.Serializer):
path = serializers.CharField(min_length=4, max_length=200)

View File

@ -6,7 +6,7 @@ from apps.inm.models import FIFO, FIFOItem, FIFOItemProduct, IProduct, WareHouse
from apps.inm.services import InmService from apps.inm.services import InmService
from apps.mtm.models import Material, PackItem from apps.mtm.models import Material, PackItem
from apps.sam.models import Sale, SalePack, SaleProduct from apps.sam.models import Sale, SalePack, SaleProduct
from apps.sam.serializers_sale import SRemarkItemCreateSerializer, SaleCreateSerializer, SaleListSerializer, SaleProductCreateSerializer, SaleProductListSerializer, SaleProductPackDetailSerializer, SaleProductPackSerializer from apps.sam.serializers_sale import SRemarkItemCreateSerializer, SaleCreateSerializer, SaleListSerializer, SaleProductCreateSerializer, SaleProductListSerializer, SaleProductPackDetailSerializer, SaleProductPackSerializer, SaleUpShipPicSerializer
from rest_framework import exceptions from rest_framework import exceptions
from django.db import transaction from django.db import transaction
from rest_framework.decorators import action from rest_framework.decorators import action
@ -85,8 +85,6 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
fifo.sale = obj fifo.sale = obj
fifo.type = FIFO.FIFO_TYPE_SALE_OUT fifo.type = FIFO.FIFO_TYPE_SALE_OUT
fifo.is_audited = False fifo.is_audited = False
fifo.auditor = request.user
fifo.inout_date = timezone.now()
fifo.create_by = request.user fifo.create_by = request.user
fifo.number = 'CK' + ranstr(7) fifo.number = 'CK' + ranstr(7)
fifo.save() fifo.save()
@ -95,6 +93,20 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
obj.save() obj.save()
return Response() return Response()
@action(methods=['post'], detail=True, perms_map={'post':'sale_up_ship'}, serializer_class=SaleUpShipPicSerializer)
@transaction.atomic
def up_ship(self, request, pk=None):
"""
上传物流信息
"""
serializer = SaleUpShipPicSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
vdata = serializer.validated_data
obj = self.get_object()
obj.ship_pic = vdata['path']
obj.save()
return Response()

View File

@ -158,7 +158,7 @@ REST_FRAMEWORK = {
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
], ],
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
# 'rest_framework.permissions.IsAuthenticated', 'rest_framework.permissions.AllowAny',
'apps.system.permission.RbacPermission' 'apps.system.permission.RbacPermission'
], ],
'DEFAULT_RENDERER_CLASSES': [ 'DEFAULT_RENDERER_CLASSES': [

View File

@ -25,21 +25,25 @@ from rest_framework import routers
from rest_framework.documentation import include_docs_urls from rest_framework.documentation import include_docs_urls
from django.views.generic import TemplateView from django.views.generic import TemplateView
from utils.view import GenSignature, UpdateDevelop from utils.view import GenSignature, UpdateDevelop
import os
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register('', FileViewSet, basename="file") router.register('', FileViewSet, basename="file")
schema_view = get_schema_view( schema_dict = dict(
openapi.Info( info=openapi.Info(
title="航玻ERP API", title="航玻ERP API",
default_version='v1', default_version='v1',
contact=openapi.Contact(email="caoqianming@foxmail.com"), contact=openapi.Contact(email="caoqianming@foxmail.com"),
license=openapi.License(name="MIT License"), license=openapi.License(name="MIT License"),
), ),
public=True, public=True,
permission_classes=[], permission_classes=[],)
url="http://49.232.14.174:2222/"
) if os.getenv('DJANGO_SETTINGS_MODULE') != 'server.settings_dev':
schema_dict['url'] = "http://49.232.14.174:2222/"
schema_view = get_schema_view(**schema_dict)
urlpatterns = [ urlpatterns = [
path('api/admin/doc/', include('django.contrib.admindocs.urls')), path('api/admin/doc/', include('django.contrib.admindocs.urls')),

View File

@ -78,15 +78,15 @@ class UpdateDevelop(APIView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
import os import os
# 更新后端 # 更新后端
os.chdir('/home/hberp') os.chdir('/home/lighthouse/hberp')
ret = os.popen('git pull https://caoqianming%40foxmail.com:9093qqww@e.coding.net/ctcdevteam/hberp/hberp.git develop') ret = os.popen('sudo git pull && sudo service supervisor reload')
# 奇怪的处理 # 奇怪的处理
os.chdir('/home/hberp/hb_server/vuedist') # os.chdir('/home/hberp/hb_server/vuedist')
os.popen('cp index.html indexbak') # os.popen('cp index.html indexbak')
time.sleep(1000) # time.sleep(1000)
os.popen('rm -rf index.html') # os.popen('rm -rf index.html')
time.sleep(1000) # time.sleep(1000)
os.popen('mv -f indexbak index.html') # os.popen('mv -f indexbak index.html')
# 打包前端 # 打包前端
# os.chdir('/home/hberp/hb_client') # os.chdir('/home/hberp/hb_client')
# os.system('npm run build:prod') # os.system('npm run build:prod')