duizhaopin
13507605001 2 years ago
parent fd5c27d409
commit 2e7d691e24

1
.gitignore vendored

@ -29,6 +29,7 @@ MANIFEST
.vscode/*
runserver_log/
img
local_conf.conf
# PyInstaller
# Usually these files are written by a python script from a template

@ -4,17 +4,36 @@ import json
import uuid
import sys
import os
import threading
# 获取分辨率索引
url = "http://localhost:6543/GetAllDisplayInfo"
param={
"dev_idx":"0",
}
#res = requests.get(url = url)
#print(json.loads(res.text))
#print(json.loads(res.text)['data'])
# print(json.loads(res.text)['code']=='0')
import inspect
import ctypes
# 关闭线程
def _async_raise(tid, exctype):
"""raises the exception, performs cleanup if needed"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stop_thread(thread):
_async_raise(thread.ident, SystemExit)
class GaoPaiYi():
# path = "/home/yanyi/Project/MainManage/img" # 默认存储地址
@ -24,46 +43,112 @@ class GaoPaiYi():
os.makedirs(path)
def __init__(self):
pass
def openCamera(self):
try:
url = 'http://127.0.0.1:6543/video=stream&camidx=0'
param={}
header ={'Content-Type':'application/json;charset=utf-8'}
res = requests.get(url = url,data=json.dumps(param),headers=header,timeout=10)
print(json.loads(res.text))
print(json.loads(res.text)['filepath'])
print('打开相机:::',json.loads(res.text)['code'])
except Exception as e:
print(e)
return {'code': -1, 'msg': e}
# win 版本
def getPic(self):
try:
# if path:
# self.path = path
#print('----------预览视频-------------------------')
# 打開視頻
url = "http://localhost:6543/StartPreview?dev_idx=0&res_id=0&pixfmt=pixfmt"
res = requests.get(url = url)
# print(json.loads(res.text))
#print(json.loads(res.text)['data'])
# print(json.loads(res.text)['code']=='0')
if json.loads(res.text)['returnCode']!=0:
return {'code':-1,'msg':"打开视频失败"}
p = threading.Thread(target=self.openCamera)
p.start()
time.sleep(2)
# 摄像头拍照
url = 'http://127.0.0.1:6543/video=grabimage'
# url = 'https://restapi.getui.com/v2/h8m8bkLRUG6C313Xw8sNV8/auth'
param = {
"filepath": f"{self.path}\\{str(uuid.uuid1())}.jpg",
"rotate": "90", #// 图像旋转角度90的整数倍默认"0"
"deskew": "0", #// 纠偏主头有效参数0:不纠偏1:纠偏
"deskewval":"0", #// 纠偏像素值正常给0正数时多裁负数时少裁
"camidx": "0", #// 摄像头索引参数0:主头1:副头
"ColorMode": "0", #// 色彩模式图片保存本地时调用。0彩色 1灰色 2黑白 3白纸印章 4去背景色(普通文件) 5:去背景色(身份证)
"quality": "0", #// 图片质量,图片保存本地调用
#print('----------拍照-------------------------',__file__)
# 打開視頻
url = "http://localhost:6543/getPic?savepath="+self.path+"&quality=80"
res = requests.get(url = url)
#print(json.loads(res.text)['data']["path"])
#print(json.loads(res.text)['returnCode']==0) /home/yanyi/Project/MainManage/img/2022-9-9 15-36-35.jpg
if json.loads(res.text)['returnCode']==0:
res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['data']["path"].split("/")[-1]}
# 。0:默认质量1:高质量2:较高质量3:中质量4:较低质量5:低质量
"bAutoAdjust":"1", #// 是否自动摆正: 0不摆正 1摆正
"bIsPrint1to1":"", #// 是否1:1打印
"watermark": {
"pos": "", #// 水印在图像中的位置0:左上1:右上2:左下3:右下4:中间
"content": "", #// 水印内容必须utf-8编码当水印内容为空将当前时间作为水印
"transparency": "", #// 透明度0~255,0:完全透明255:不透明
"fontsize": "", #// 字体大小默认32
"font": "", #// 字体
"color": "" # // 水印颜色colorname
}
}
header ={'Content-Type':'application/json;charset=utf-8'}
res = requests.post(url = url,data=json.dumps(param),headers=header)
print(json.loads(res.text).get('filepath'))
if json.loads(res.text)['code'] == "0":
res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['filepath'].split("\\")[-1]}
else:
res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['returnCode']}
#print('----------关闭视频-------------------------')
url = "http://localhost:6543/StopPreview?dev_idx=0"
res = requests.get(url = url)
res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['code']}
print(res_data)
# 关闭摄像头
url = 'http://127.0.0.1:6543/video=close'
param = {"camidx":"0"}
header = {'Content-Type': 'application/json;charset=utf-8'}
res = requests.post(url=url, data=json.dumps(param), headers=header,timeout=10)
print('关闭摄像头:::::::',json.loads(res.text)['code'])
stop_thread(thread=p)
return res_data
except Exception as e:
print('报错信息: ' + e + ' ,File: ' + __file__ + ', Line ' + str(sys._getframe().f_lineno))
return {'code':-1,'msg':e}
# # linux 版本
# def getPic(self):
# try:
# # if path:
# # self.path = path
# #print('----------预览视频-------------------------')
# # 打開視頻
# url = "http://localhost:6543/StartPreview?dev_idx=0&res_id=0&pixfmt=pixfmt"
# res = requests.get(url = url)
# # print(json.loads(res.text))
# #print(json.loads(res.text)['data'])
# # print(json.loads(res.text)['code']=='0')
# if json.loads(res.text)['returnCode']!=0:
# return {'code':-1,'msg':"打开视频失败"}
# time.sleep(2)
# #print('----------拍照-------------------------',__file__)
# # 打開視頻
# url = "http://localhost:6543/getPic?savepath="+self.path+"&quality=80"
# res = requests.get(url = url)
# #print(json.loads(res.text)['data']["path"])
# #print(json.loads(res.text)['returnCode']==0) /home/yanyi/Project/MainManage/img/2022-9-9 15-36-35.jpg
# if json.loads(res.text)['returnCode']==0:
# res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['data']["path"].split("/")[-1]}
# else:
# res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['returnCode']}
# #print('----------关闭视频-------------------------')
# url = "http://localhost:6543/StopPreview?dev_idx=0"
# res = requests.get(url = url)
# return res_data
# except Exception as e :
# print('报错信息: ' + e + ' ,File: ' + __file__ + ', Line ' + str(sys._getframe().f_lineno))
# return {'code':-1,'msg':e}
if __name__ =="__main__":
obj = GaoPaiYi()
obj.getPic()
path= '/tmp'
# pic_url = GaoPaiYi().getPic(path)
# print(pic_url)

@ -100,14 +100,14 @@ class CreateBarcode:
<body>
<div style="display:flex; align-content: center;width:100%">
<p style="font-size:6px; width: 100%;">
<span style="font-size:8px;display:flex;text-align:center !important;justify-content:center;width: 100%;">华润三九制药</span> <br />
<span style="font-size:8px;width: 100%;">华润三九制药</span> <br />
试剂名称: {} <br />
级别: {} <br />
批号: {} <br />
编号: {} <br />
货位号: {} <br />
</p>
<img src="{}">
</p>
</div>
</body>
""".format(
@ -125,8 +125,8 @@ class CreateBarcode:
printer.setPaperSize(QSizeF(30.0,18.0),QPrinter.Millimeter)
# printer.setPaperSize(QSizeF(30.0,50.0),QPrinter.Millimeter)
# 设置纸张到条码的边距 左上下右
# printer.setPageMargins(6, 2, 0, 0, QPrinter.Millimeter)
printer.setPageMargins(20, 20, 0, 0, QPrinter.Millimeter)
printer.setPageMargins(6, 3, 0, 0, QPrinter.Millimeter)
# printer.setPageMargins(20, 20, 0, 0, QPrinter.Millimeter)
document.setPageSize(QSizeF(printer.pageRect().size()))
#document.setPageSize(QSizeF(50.0,30.0))
@ -134,7 +134,7 @@ class CreateBarcode:
print('正在打印中。。。。')
document.print_(printer)
print('打印完成。。')
# os.remove(file_name)
os.remove(kwargs.get("file_path"))
if __name__ == '__main__':

@ -9,7 +9,7 @@ from flask import jsonify, request, g, send_from_directory
from flask import Blueprint
from db_logic.client import BllClient
from db_logic.dangerous import BllDangerous
from sqlalchemy import and_
from db_logic.medicament import BllMedicament
from db_logic.medicament_record import BllMedicamentRecord
@ -370,7 +370,8 @@ def save_drug_img_info():
# 根据条码查询试剂信息
drug_info = BllMedicament().findEntity(
EntityMedicament.medicament_id == medicament_id)
if not drug_info:
return jsonify(Utils.false_return(msg="试剂信息有误"))
obj = EntityMedicamentRelationImage(
name=drug_info.name,
variety_id=variety_id,
@ -416,8 +417,6 @@ def use_gaopaiyi():
return jsonify(data)
# 获取药剂图片列表
@drug_router.route("/get_medicament_image", methods=["GET", "POST"])
# @token_auth.login_required
def get_medicament_image():
@ -426,7 +425,7 @@ def get_medicament_image():
medicament_id = request.values.get("medicament_id")
data_list = BllMedicamentRelationImage().findList(
EntityMedicamentRelationImage.variety_id == variety_id).all()
EntityMedicamentRelationImage.medicament_id == medicament_id).all()
# data_list = Utils.resultAlchemyData(data_list)
data = Utils.true_return(msg='获取成功', data=data_list)
return jsonify(data)
@ -462,3 +461,22 @@ def get_stay_putin_list():
data = BllMedicament().get_drug_type_list(status=int(status), client_id=client_id, page_param=page_param, user=g.current_user)
data_list = Utils.msyql_table_model(data)
return jsonify(Utils.true_return(data={"data_list":data_list, "total_count": page_param.totalRecords}))
# 更改试剂状态
@drug_router.route("/update_drug_status", methods=["POST"])
@token_auth.login_required
def update_drug_status():
bar_code = request.values.get("bar_code")
status = request.values.get("status")
bar_code, new_code = Utils.get_bar_code_reverse(bar_code=bar_code)
obj = BllMedicament().findEntity(
and_(
EntityMedicament.bar_code == bar_code,
EntityMedicament.bar_code == new_code
)
)
if not obj:
return jsonify(Utils.false_return(msg="试剂信息有误"))
obj.status = status
BllMedicament().update(obj)
return jsonify(Utils.true_return(msg="修改成功"))

@ -162,7 +162,7 @@ def bind_tmp_input_db():
BllClient().findEntity(EntityClient.client_id==drug_entity.client_id),
user_info
)
return jsonify(Utils.true_return(msg="药剂入库成功"))
return jsonify(Utils.true_return(msg="药剂入库成功", data=Utils.to_dict(drug_entity)))
except Exception as error:
return jsonify(Utils.false_return(msg="数据异常,入库失败: %s" % error))

@ -24,7 +24,7 @@ monitor_router = Blueprint('monitor', __name__)
def get_day_monitor():
client_id = request.values.get("client_id")
# TODO 添加房间筛选
client_place = request.values.get("client_place")
client_place = request.values.get("place")
start_time = request.values.get("start_time")
end_time = request.values.get("end_time")
page = request.values.get("page", 1)
@ -62,7 +62,7 @@ def get_day_monitor():
def get_day_monitor_info():
client_id = request.values.get("client_id")
# TODO 添加房间筛选
client_place = request.values.get("client_place")
client_place = request.values.get("place")
start_time = request.values.get("start_time")
end_time = request.values.get("end_time")
page = request.values.get("page", 1)

@ -67,7 +67,7 @@ def get_stock_data_info():
page = int(request.values.get('page', 1))
page_size = int(request.values.get('page_size', 15))
# TODO 添加房间筛选
client_place = request.values.get("client_place")
client_place = request.values.get("palce")
client_id = request.values.get("client_id")
page_param = PageParam(page, page_size)
@ -117,7 +117,7 @@ def drun_input_info():
customer_id = None
client_id = request.values.get("client_id")
# TODO 添加房间筛选
client_place = request.values.get("client_place")
client_place = request.values.get("place")
# 分页处理
page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10))
@ -328,7 +328,7 @@ def drug_log_type_info():
page_param = PageParam(page, page_size)
# TODO 添加房间筛选
client_place = request.values.get("client_place")
client_place = request.values.get("place")
client_id = request.values.get("client_id")
# 报表数据

@ -137,6 +137,7 @@ def solve_apply():
# user_id = request.values.get("user_id")
user_id = g.current_user.user_id
# user_id_pt = request.values.get("user_id_pt")
t = request.values.get("t")
obj = BllUserApply().findEntity(EntityUserApply.id == apply_id)
if obj.is_solve == 1:
return jsonify(Utils.false_return(msg="已受理,无需重复受理"))
@ -147,8 +148,9 @@ def solve_apply():
if user_id == obj.solve_user_id:
return jsonify(Utils.false_return(msg="不能位同一人审批"))
obj.solve_user_id_pt=user_id
obj.is_solve == 1
BllUserTemporaryAuth().create_temporary_auth(user_ids=[obj.user_id, obj.user_id_pt], auth_type=2)
obj.is_solve = 1
obj.time_hour=t
BllUserTemporaryAuth().create_temporary_auth(user_ids=[obj.user_id, obj.user_id_pt], auth_type=2, t=t)
obj.solve_date = Utils.get_str_datetime()
# obj.solve_user_id = user_id
# obj.solve_user_id_pt = user_id_pt

@ -20,13 +20,15 @@ class BllUserTemporaryAuth(Repository):
def __init__(self, entityType=EntityUserTemporaryAuth):
super().__init__(entityType)
def create_temporary_auth(self, user_ids, auth_type):
def create_temporary_auth(self, user_ids, auth_type, t=None):
# try:
# client_code = BllClient().findEntity(EntityClient.client_id == client_id).client_code
# except:
# client_code = ''
if not t:
t = 8
for user_id in user_ids:
end_date = str(datetime.datetime.now() + datetime.timedelta(minutes=10))[:-7]
end_date = str(datetime.datetime.now() + datetime.timedelta(hours=int(t)))[:-7]
obj = self.entityType()
obj.user_id=user_id
obj.create_date = Utils.get_str_datetime()

@ -93,6 +93,7 @@ class EntityUserApply(Base):
solve_user_id_pt = Column(String(50), comment="受理人")
func_type = Column(Integer, comment="类型")
use_doc = Column(Text, comment="类型")
time_hour = Column(String(50), comment="时间小时")
# drug_name = Column(String(50), comment="试剂名称")

Loading…
Cancel
Save