duizhaopin
13507605001 2 years ago
parent fd5c27d409
commit 2e7d691e24

1
.gitignore vendored

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

@ -4,17 +4,36 @@ import json
import uuid import uuid
import sys import sys
import os import os
import threading
# 获取分辨率索引 # 获取分辨率索引
url = "http://localhost:6543/GetAllDisplayInfo" url = "http://localhost:6543/GetAllDisplayInfo"
param={ param={
"dev_idx":"0", "dev_idx":"0",
} }
#res = requests.get(url = url) #res = requests.get(url = url)
#print(json.loads(res.text)) #print(json.loads(res.text))
#print(json.loads(res.text)['data']) #print(json.loads(res.text)['data'])
# print(json.loads(res.text)['code']=='0') # 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(): class GaoPaiYi():
# path = "/home/yanyi/Project/MainManage/img" # 默认存储地址 # path = "/home/yanyi/Project/MainManage/img" # 默认存储地址
@ -24,46 +43,112 @@ class GaoPaiYi():
os.makedirs(path) os.makedirs(path)
def __init__(self): def __init__(self):
pass 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): def getPic(self):
try: try:
# if path: p = threading.Thread(target=self.openCamera)
# self.path = path p.start()
#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) 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__) # 。0:默认质量1:高质量2:较高质量3:中质量4:较低质量5:低质量
# 打開視頻 "bAutoAdjust":"1", #// 是否自动摆正: 0不摆正 1摆正
url = "http://localhost:6543/getPic?savepath="+self.path+"&quality=80" "bIsPrint1to1":"", #// 是否1:1打印
res = requests.get(url = url) "watermark": {
"pos": "", #// 水印在图像中的位置0:左上1:右上2:左下3:右下4:中间
#print(json.loads(res.text)['data']["path"]) "content": "", #// 水印内容必须utf-8编码当水印内容为空将当前时间作为水印
#print(json.loads(res.text)['returnCode']==0) /home/yanyi/Project/MainManage/img/2022-9-9 15-36-35.jpg "transparency": "", #// 透明度0~255,0:完全透明255:不透明
if json.loads(res.text)['returnCode']==0: "fontsize": "", #// 字体大小默认32
res_data = {'code':0,'msg':"图片保存成功","path":json.loads(res.text)['data']["path"].split("/")[-1]} "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: else:
res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['returnCode']} res_data= {'code':-1, 'msg':"图片保存失败", "path":json.loads(res.text)['code']}
print(res_data)
#print('----------关闭视频-------------------------') # 关闭摄像头
url = "http://localhost:6543/StopPreview?dev_idx=0" url = 'http://127.0.0.1:6543/video=close'
res = requests.get(url = url) 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 return res_data
except Exception as e : except Exception as e:
print('报错信息: ' + e + ' ,File: ' + __file__ + ', Line ' + str(sys._getframe().f_lineno)) print('报错信息: ' + e + ' ,File: ' + __file__ + ', Line ' + str(sys._getframe().f_lineno))
return {'code':-1,'msg':e} 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__": if __name__ =="__main__":
obj = GaoPaiYi()
obj.getPic()
path= '/tmp' path= '/tmp'
# pic_url = GaoPaiYi().getPic(path) # pic_url = GaoPaiYi().getPic(path)
# print(pic_url) # print(pic_url)

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

@ -9,7 +9,7 @@ from flask import jsonify, request, g, send_from_directory
from flask import Blueprint from flask import Blueprint
from db_logic.client import BllClient from db_logic.client import BllClient
from db_logic.dangerous import BllDangerous from db_logic.dangerous import BllDangerous
from sqlalchemy import and_
from db_logic.medicament import BllMedicament from db_logic.medicament import BllMedicament
from db_logic.medicament_record import BllMedicamentRecord from db_logic.medicament_record import BllMedicamentRecord
@ -370,7 +370,8 @@ def save_drug_img_info():
# 根据条码查询试剂信息 # 根据条码查询试剂信息
drug_info = BllMedicament().findEntity( drug_info = BllMedicament().findEntity(
EntityMedicament.medicament_id == medicament_id) EntityMedicament.medicament_id == medicament_id)
if not drug_info:
return jsonify(Utils.false_return(msg="试剂信息有误"))
obj = EntityMedicamentRelationImage( obj = EntityMedicamentRelationImage(
name=drug_info.name, name=drug_info.name,
variety_id=variety_id, variety_id=variety_id,
@ -416,8 +417,6 @@ def use_gaopaiyi():
return jsonify(data) return jsonify(data)
# 获取药剂图片列表 # 获取药剂图片列表
@drug_router.route("/get_medicament_image", methods=["GET", "POST"]) @drug_router.route("/get_medicament_image", methods=["GET", "POST"])
# @token_auth.login_required # @token_auth.login_required
def get_medicament_image(): def get_medicament_image():
@ -426,7 +425,7 @@ def get_medicament_image():
medicament_id = request.values.get("medicament_id") medicament_id = request.values.get("medicament_id")
data_list = BllMedicamentRelationImage().findList( data_list = BllMedicamentRelationImage().findList(
EntityMedicamentRelationImage.variety_id == variety_id).all() EntityMedicamentRelationImage.medicament_id == medicament_id).all()
# data_list = Utils.resultAlchemyData(data_list) # data_list = Utils.resultAlchemyData(data_list)
data = Utils.true_return(msg='获取成功', data=data_list) data = Utils.true_return(msg='获取成功', data=data_list)
return jsonify(data) return jsonify(data)
@ -461,4 +460,23 @@ 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 = 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) data_list = Utils.msyql_table_model(data)
return jsonify(Utils.true_return(data={"data_list":data_list, "total_count": page_param.totalRecords})) 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), BllClient().findEntity(EntityClient.client_id==drug_entity.client_id),
user_info user_info
) )
return jsonify(Utils.true_return(msg="药剂入库成功")) return jsonify(Utils.true_return(msg="药剂入库成功", data=Utils.to_dict(drug_entity)))
except Exception as error: except Exception as error:
return jsonify(Utils.false_return(msg="数据异常,入库失败: %s" % error)) return jsonify(Utils.false_return(msg="数据异常,入库失败: %s" % error))

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

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

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

@ -20,13 +20,15 @@ class BllUserTemporaryAuth(Repository):
def __init__(self, entityType=EntityUserTemporaryAuth): def __init__(self, entityType=EntityUserTemporaryAuth):
super().__init__(entityType) super().__init__(entityType)
def create_temporary_auth(self, user_ids, auth_type): def create_temporary_auth(self, user_ids, auth_type, t=None):
# try: # try:
# client_code = BllClient().findEntity(EntityClient.client_id == client_id).client_code # client_code = BllClient().findEntity(EntityClient.client_id == client_id).client_code
# except: # except:
# client_code = '' # client_code = ''
if not t:
t = 8
for user_id in user_ids: 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 = self.entityType()
obj.user_id=user_id obj.user_id=user_id
obj.create_date = Utils.get_str_datetime() obj.create_date = Utils.get_str_datetime()

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

Loading…
Cancel
Save