领用申请完善;待领用、待归还、待入库接口

duizhaopin
13507605001 2 years ago
parent a46d412924
commit ba1a3d3c12

@ -333,6 +333,9 @@ class DrugRecordType(object):
#归还操作
Return = 3
# 登记操作
Register = 4
#药剂状态类型

@ -125,7 +125,7 @@ def drug_return():
user_id = user_info.user_id
user_id_pt = user_id
BllUserTemporaryAuth().create_temporary_auth(user_ids=[user_id, user_id_pt], client_id=drug_info.client_id)
BllUserTemporaryAuth().create_temporary_auth(user_ids=[user_id, user_id_pt], auth_type=3)
BllMedicament().drugReturn(drug_info, BllClient().findEntity(drug_info.client_id), user_info)
@ -447,5 +447,16 @@ def del_medicament_image():
return jsonify(data)
# 待入库试剂信息and 待归还试剂信息
@drug_router.route("/stay_putin_return_list", methods=["POST"])
@token_auth.login_required
def get_stay_putin_list():
client_id = request.values.get("client_id")
page = request.values.get("page")
page_size = request.values.get("page_size")
status = request.values.get("status")
page_param = PageParam(int(page), int(page_size))
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}))

@ -151,7 +151,7 @@ def bind_tmp_input_db():
# obj.create_drug_lobel_code(**new_dict)
# user_id = user_info.user_id
# user_id_pt = request.values.get("user_id_pt", '34306da6-0f11-11ed-ba01-009027e3906b')
# BllUserTemporaryAuth().create_temporary_auth(user_ids=[user_id, user_id_pt], client_id=client_id)
# BllUserTemporaryAuth().create_temporary_auth(user_ids=[user_id, user_id_pt], auth_type=1)
obj = CreateBarcode()
obj.create_drug_lobel_code(**new_dict)
BllMedicament().drugPutIn(

@ -14,227 +14,6 @@ from apps.report.utils_base import download_file
report_router = Blueprint("report", __name__)
"""
# # 获取报表统计页面展示
# # @report_router.route('/report_home', methods=["GET", "POST"])
# # def report_home_info():
# # # 试剂使用统计
# # data_list = BllMedicamentRecord().get_drug_record_count()
# # return jsonify(Utils.true_return(data=data_list))
# # # 消耗统计
# # @report_router.route("/drug_stock_use_classify", methods=["GET", "POST"])
# # def get_drug_stock_use_classify():
# # data_list, total_number = BllMedicament().get_drug_stock_use_classify()
# # return jsonify(Utils.true_return(data={"total_count":total_number, "data":data_list}))
# # # 试剂用量消耗
# # @report_router.route("/drug_use_classify", methods=["GET", "POST"])
# # def get_drug_use_classify():
# # data_list = BllMedicamentRecord().report_home_drug_useing_classify()
# # return jsonify(Utils.true_return(data=data_list))
# # # 用户试剂消耗
# # @report_router.route("/drug_user_use_info", methods=["GET", "POST"])
# # def get_drug_user_use_number():
# # data_list = BllMedicamentRecord().report_home_user_use_info()
# # return jsonify(Utils.true_return(data=data_list))
# # 报表统计主页
# @report_router.route("/report_home", methods=["GET", "POST"])
# @token_auth.login_required
# def report_home_show():
# resp_data = {
# "drug_use_type_data": "",
# "use_avg_info":{},
# "drug_stock_expend": {"count_number":0, "data":""},
# "drug_use_expend":"",
# "user_use_expend": ""
# }
# try:
# obj_data = BllMedicamentRecord()
# # 试剂使用统计
# drug_use_type_data, avg_use_dic = obj_data.get_drug_record_count()
# # 消耗统计部分
# drug_stock_expend, num_all = BllMedicament().get_drug_stock_use_classify()
# # 试剂用量消耗
# drug_use_expend = obj_data.report_home_drug_useing_classify()
# # 用户试剂消耗
# user_use_expend = obj_data.report_home_user_use_info()
# resp_data["drug_use_type_data"] = drug_use_type_data
# resp_data["use_avg_info"] = avg_use_dic
# resp_data["drug_stock_expend"] = {
# "count_number": num_all,
# "data": drug_stock_expend
# }
# resp_data["drug_use_expend"] = drug_use_expend
# resp_data["user_use_expend"] = user_use_expend
# return jsonify(Utils.true_return(data=resp_data))
# except Exception as error:
# return jsonify(Utils.except_return(msg=f"error:{error}", data=resp_data))
# # 库存信息总览
# @report_router.route("/stock_data_info", methods=["GET", "POST"])
# @token_auth.login_required
# def get_stock_data_info():
# name = request.values.get("name", None)
# page = int(request.values.get('page', 1))
# page_size = int(request.values.get('page_size', 15))
# page_param = PageParam(page, page_size)
# data_list = BllMedicament().get_stock_all_info(
# name=name,
# page_param=page_param)
# data_list = Utils.msyql_table_model(data_list)
# if data_list:
# return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data_list}))
# else:
# return jsonify(Utils.false_return(msg="无效数据"))
# # 入库信息查询and 试剂信息查询
# @report_router.route("/drug_details_info", methods=["GET", "POST"])
# @token_auth.login_required
# def drun_input_info():
# # 获取参数
# seach_word = request.values.get('seach_word')
# manufacturer = request.values.get("manufacturer")
# start_time = request.values.get("start_time")
# end_time = request.values.get("end_time")
# # 客户id
# customer_id = None
# client_id = request.values.get("client_id")
# # 分页处理
# page = int(request.values.get("page", 1))
# page_size = int(request.values.get("page_size", 10))
# page_param = PageParam(page, page_size)
# # 获取数据
# data = BllMedicament().getAllDrugList(
# search_word=seach_word,
# manufacturer=manufacturer,
# start_time=start_time,
# end_time=end_time,
# page_param=page_param,
# customer_id=customer_id,
# client_id=client_id
# )
# # 数据处理列表keyvalue格式
# data_list = Utils.msyql_table_model(data)
# return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data_list}))
# # 库存消耗
# # 试剂名称、纯度、cas码 查询rms_medicament 分组后获取
# @report_router.route("/stock_loss_info", methods=["GET", "POST"])
# @token_auth.login_required
# def stock_loss_info():
# # 获取参数
# seach_word = request.values.get('seach_word')
# start_time = request.values.get('start_time')
# end_time = request.values.get('end_time')
# page = int(request.values.get("page", 1))
# page_size = int(request.values.get("page_size", 10))
# page_param = PageParam(page, page_size)
# # 获取数据结果
# data = BllMedicamentRecord().durg_stock_loss(
# seach_word=seach_word,
# start_time=start_time,
# end_time=end_time,
# page_param=page_param)
# return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# # 试剂用量消耗
# @report_router.route("/drug_use_expend", methods=["GET", "POST"])
# @token_auth.login_required
# def get_drug_use_expend():
# # 参数获取
# seach_word = request.values.get('seach_word')
# start_time = request.values.get('start_time')
# end_time = request.values.get('end_time')
# page = int(request.values.get("page", 1))
# page_size = int(request.values.get("page_size", 10))
# page_param = PageParam(page, page_size)
# # 获取数据
# data = BllMedicamentRecord().durg_useing_info(
# seach_word=seach_word,
# start_time=start_time,
# end_time=end_time,
# page_param=page_param)
# return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# # 人员用量消耗
# @report_router.route("/drug_user_use_expend", methods=["GET", "POST"])
# @token_auth.login_required
# def get_drug_user_use_expend():
# # 参数获取
# seach_user = request.values.get('seach_user')
# start_time = request.values.get('start_time')
# end_time = request.values.get('end_time')
# page = int(request.values.get("page", 1))
# page_size = int(request.values.get("page_size", 10))
# page_param = PageParam(page, page_size)
# # 获取数据
# data = BllMedicamentRecord().user_use_info(
# seach_user=seach_user,
# start_time=start_time,
# end_time=end_time,
# page_param=page_param)
# return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# # 使用频率
# @report_router.route("/use_frequency", methods=["GET", "POST"])
# @token_auth.login_required
# def drug_use_frequency():
# seach_word = request.values.get('seach_word')
# client_id = request.values.get("client_id")
# start_time = request.values.get('start_time')
# end_time = request.values.get('end_time')
# page = int(request.values.get("page", 1))
# page_size = int(request.values.get("page_size", 10))
# page_param = PageParam(page, page_size)
# data = BllMedicamentRecord().use_frequency(
# seach_word=seach_word,
# start_time=start_time,
# end_time=end_time,
# client_id=client_id,
# page_param=page_param)
# return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data}))
# # 入库、领用、归还记录
# @report_router.route("/drug_log_type_info", methods=["GET", "POST"])
# @token_auth.login_required
# def drug_log_type_info():
# page = int(request.values.get("page", 1))
# page_size = int(request.values.get("page_size", 10))
# statue_type = request.values.get("status")
# record_type = request.values.get("record_type")
# put_in_user_name = request.values.get("user_name")
# name = request.values.get("name")
# start_time = request.values.get("start_time")
# end_time = request.values.get("end_time")
# page_param = PageParam(page, page_size)
# data_list = BllMedicament().drug_show_type_info(
# record_type=record_type, put_in_user_name=put_in_user_name, statue_type=statue_type,
# name=name,
# start_time=start_time, end_time=end_time,
# page_param=page_param
# )
# data_list = Utils.msyql_table_model(data_list)
# return jsonify(Utils.true_return(data={"total_count": page_param.totalRecords, "data": data_list}))
"""
# 报表统计主页
@report_router.route("/report_home", methods=["GET", "POST"])
@token_auth.login_required

@ -8,13 +8,14 @@ sys.path.append('.')
import json
from flask import Blueprint, request, jsonify, g
from sqlalchemy import and_, or_
from db_logic.user_temporary_auth import BllUserTemporaryAuth
from db_logic.user_apply import BllUserApply
from db_logic.medicament import BllMedicament
from db_logic.client import BllClient
from db_logic.user import BllUser
from models.client_models import EntityClient
from models.medicament_models import EntityMedicament
from models.power_models import EntityUserApply, EntityUserTemporaryAuth
from Common.Utils import Utils, PageParam
from Common.auth import token_auth
@ -40,40 +41,69 @@ def get_use_drug_list():
def user_apply_log():
user_id = request.values.get("user_id")
user_id_pt = request.values.get("user_id_pt")
drug_name = request.values.get("drug_name")
drug_num = request.values.get("drug_num")
client_id = request.values.get("client_id")
func_type = request.values.get("func_type")
use_doc = request.values.get("use_doc")
try:
client_code = BllClient().findEntity(EntityClient.client_id==client_id).client_code
except:
client_code = ''
use_content = request.values.get("use_content")
# drug_name = request.values.get("drug_name")
# drug_num = request.values.get("drug_num")
# client_id = request.values.get("client_id")
# try:
# client_code = BllClient().findEntity(EntityClient.client_id==client_id).client_code
# except:
# client_code = ''
if not use_content:
return jsonify(Utils.false_return(msg='内容为空,无需提交'))
obj = EntityUserApply(
user_id = user_id,
user_id_pt = user_id_pt,
drug_name = drug_name,
drug_num = drug_num,
# drug_name = drug_name,
# drug_num = drug_num,
create_date = Utils.get_str_datetime(),
is_solve = 0,
client_id = client_id,
use_content = use_content,
# client_id = client_id,
func_type=func_type,
client_code=client_code,
# client_code=client_code,
use_doc=use_doc
)
BllUserApply().insert(obj)
return jsonify(Utils.true_return())
# 修改个人申请
@temporary_bp.route("/update_itself_apply", methods=["POST"])
@token_auth.login_required
def update_itself_apply():
apply_id = request.values.get("id")
# func_type = request.values.get("func_type")
use_content = request.values.get("use_content")
if not use_content:
return jsonify(Utils.false_return(msg='内容为空,无需提交'))
user = g.current_user
user_apply_obj = BllUserApply().findEntity(
and_(
EntityUserApply.id == apply_id,
EntityUserApply.user_id == user.user_id
)
)
if not user_apply_obj:
return jsonify(Utils.false_return(msg="只能修改自己的申请!"))
user_apply_obj.use_content=use_content
BllUserApply().update(user_apply_obj)
return jsonify(Utils.true_return())
# 展示
@temporary_bp.route("/get_list", methods=["POST"])
# @token_auth.login_required
@token_auth.login_required
def get_info_list():
client_id = request.values.get("client_id")
# client_id = request.values.get("client_id")
func_type = request.values.get("func_type")
page = request.values.get("page")
page_size = request.values.get("page_size")
user = g.current_user
page_param = PageParam(int(page), int(page_size))
data = BllUserApply().get_list_info(client_id=client_id, func_type=func_type, page_param=page_param)
data = BllUserApply().get_list_info(func_type=func_type, page_param=page_param, user=user)
user_list = BllUser().findList()
user_dict = {}
for i in user_list:
@ -103,15 +133,75 @@ def del_user_apply():
@token_auth.login_required
def solve_apply():
apply_id =request.values.get("id")
user_id = request.values.get("user_id")
user_id_pt = request.values.get("user_id_pt")
# user_id = request.values.get("user_id")
user_id = g.current_user.user_id
# user_id_pt = request.values.get("user_id_pt")
obj = BllUserApply().findEntity(EntityUserApply.id == apply_id)
if obj.is_solve == 1:
return jsonify(Utils.false_return(msg="已受理,无需重复受理"))
obj.is_solve = 1
# obj.is_solve = 1
if not obj.solve_user_id:
obj.solve_user_id = user_id
else:
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.solve_date = Utils.get_str_datetime()
obj.solve_user_id = user_id
obj.solve_user_id_pt = user_id_pt
BllUserTemporaryAuth().create_temporary_auth(user_ids=[obj.user_id, obj.user_pt], client_id=obj.client_id)
# obj.solve_user_id = user_id
# obj.solve_user_id_pt = user_id_pt
# BllUserTemporaryAuth().create_temporary_auth(user_ids=[obj.user_id, obj.user_pt], auth_type=2)
BllUserApply().update(obj)
return jsonify(Utils.true_return())
# 展示待登记列表
@temporary_bp.route("/register_drug_list", methods=["GET", "POST"])
def get_register_drug():
data = BllMedicament().execute(f"select * from rms_medicament where status=4").fetchall()
data_list = Utils.msyql_table_model(data)
return jsonify(Utils.true_return(data=data_list))
# 登记接口
@temporary_bp.route("/set_register", methods=["POST"])
@token_auth.login_required
def set_register():
bar_code = request.values.get("bar_code")
bar_code, new_code = Utils.get_bar_code_reverse(bar_code)
obj = BllMedicament().findEntity(
or_(
EntityMedicament.bar_code == bar_code,
EntityMedicament.bar_code == new_code
)
)
if not obj:
return jsonify(Utils.false_return())
# drug_id = request.values.get("medicament_id")
remain = request.values.get("remain")
# obj = BllMedicament().findEntity(EntityMedicament.medicament_id==drug_id)
if obj:
setattr(obj, "remain", remain)
setattr(obj, "status", 2)
BllMedicament().update(obj)
# 登记
BllUserApply().update_use_content(client_id=obj.client_id, user=g.current_user, drug_info=obj)
BllMedicament().drugRegister(
entityDrug=obj,
entityClient= BllClient().findEntity(EntityClient.client_id==obj.client_id),
entityUser=g.current_user
)
return jsonify(Utils.true_return())
else:
return jsonify(Utils.false_return())
# 获取待领用试剂列表
@temporary_bp.route("/get_stay_use_list", methods=["GET", "POST"])
@token_auth.login_required
def get_stay_use_list():
client_id = request.values.get("client_id")
data_list = BllUserApply().get_stay_use_list(client_id=client_id, user=g.current_user)
return jsonify(Utils.true_return(data=data_list))

@ -59,6 +59,7 @@ def get_user_info_list():
page_param = PageParam(page, page_size)
data_list = BllUser().get_seach_user_list(
user_id = g.current_user.user_id,
user_code=user_code,
real_name=real_name,
role_name=role_name,

@ -326,10 +326,39 @@ class BllMedicament(Repository):
self.commitTrans()
# 药剂登记
def drugRegister(self, entityDrug, entityClient=EntityClient(), entityUser=EntityUser()):
#创建事务
self.beginTrans()
entityDrug.remark30 = '0'
self.session.merge(entityDrug)
drug = BllMedicament().findEntity(entityDrug.medicament_id)
lastRemain = float(drug.remain)
entityDrugRecord = EntityMedicamentRecord(
customer_id=entityClient.customer_id,
client_id=entityClient.client_id,
client_code=entityClient.client_code,
variety_id=entityDrug.variety_id,
medicament_id=entityDrug.medicament_id,
price=entityDrug.price,
use_quantity=float(lastRemain) - float(entityDrug.remain if entityDrug.remain else 0),
record_type=DrugRecordType.Register,
record_remain=float(entityDrug.remain),
is_empty=1 if(entityDrug.status == DrugStatus.Empty) else 0,
create_date=Utils.get_str_datetime(),
create_user_id=entityUser.user_id,
create_user_name=entityUser.real_name,
)
self.session.add(entityDrugRecord)
self.commitTrans()
# 获取领用和归还页面列表
def drug_use_return(self, status, func_type, page_param):
sql_all = f"""
select * from rms_medicament where status={status} and func_type='{func_type}' order by by_user_date desc
select * from rms_medicament where status={status} and func_type='{func_type}' and status != 3 order by by_user_date desc
"""
try:
count_number = len(self.execute(sql_all).fetchall())
@ -530,13 +559,30 @@ class BllMedicament(Repository):
# 可领用试剂列表
def use_drug_info_list(self, client_id, page_param):
sql_all = f"""
select
filter_base = ""
if client_id:
filter_base += f"client_id='{client_id}'"
if filter_base:
filter_base = f" and {filter_base}"
"""
select
`name`, speci, purity, count(*) drug_num, manufacturer, distributor
from
rms_medicament WHERE `status`=1 and client_id='{client_id}'
rms_medicament WHERE `status`=1 {filter_base}
GROUP BY
`name`, speci, purity
`name`, speci, purity, client_id
"""
sql_all = f"""
select a.*,b.client_name from (
select
`name`, speci, purity, count(*) drug_num, manufacturer, distributor,client_id,medicament_id
from
rms_medicament WHERE `status`=1 {filter_base}
GROUP BY
`name`, speci, purity, client_id
) a LEFT JOIN (
select * from rms_client
) b on a.client_id = b.client_id
"""
try:
count_number = self.execute(f"select count(*) num from ({sql_all}) a").fetchone().num
@ -547,6 +593,36 @@ class BllMedicament(Repository):
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(sql_all).fetchall()
# 获取待入库and待归还试剂数据
def get_drug_type_list(self, status, client_id, page_param, user):
filter_base = ""
if status:
filter_base += f" status={status} "
if filter_base:
filter_base += " and "
if status == 5:
filter_base += f" put_in_user_id='{user.user_id}'"
else:
filter_base += f" by_user_id='{user.user_id}'"
if client_id:
if filter_base:
filter_base += " and "
filter_base += f" client_id='{client_id}' "
if filter_base:
filter_base = f" where {filter_base}"
sql_all = f"""
select * from rms_medicament {filter_base}
"""
try:
count_number = self.execute(f"select count(*) num from rms_medicament {filter_base} ").fetchone().num
except Exception:
count_number = 0
if page_param:
page_param.totalRecords = count_number
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(sql_all).fetchall()
def inster_log_shiji(self):
import random
name_list = ["", "硫酸", "氧化钠"]

@ -136,7 +136,7 @@ class BllMedicamentRecord(Repository):
# select COUNT(record_id) count_number, record_type from rms_medicament_record GROUP BY record_type
sql_all = f"""
select count(record_id) count_number, record_type from (
select record_id,medicament_id, record_type from rms_medicament_record
select record_id,medicament_id, record_type from rms_medicament_record where record_type != 4
) as a LEFT JOIN
rms_medicament as b on a.medicament_id=b.medicament_id where func_type='{func_type}'
GROUP BY record_type

@ -78,7 +78,7 @@ class BllUser(Repository):
return self.findEntity(payload.get('user_id'))
# 用户管理
def get_seach_user_list(self, user_code, real_name, role_name, is_enabled, page_param):
def get_seach_user_list(self, user_code, real_name, role_name, is_enabled, page_param, user_id):
filter_base = ""
if user_code:
filter_base += f" user_code like '%{user_code}%'"
@ -94,8 +94,12 @@ class BllUser(Repository):
if filter_base:
filter_base += " and "
filter_base += f" is_enabled={is_enabled}"
if filter_base:
filter_base += " and "
filter_base += f" user_id != '{user_id}' "
if filter_base:
filter_base = f" where {filter_base}"
sql_all = f"""
select * from rms_user {filter_base} order by create_date desc
"""

@ -6,7 +6,7 @@
import sys
sys.path.append('.')
import json
from db_logic.db_base import Repository
from models.power_models import EntityUserApply
from Common.Utils import Utils
@ -16,24 +16,32 @@ class BllUserApply(Repository):
def __init__(self, entityType=EntityUserApply):
super().__init__(entityType)
def get_list_info(self, client_id, func_type, page_param):
def get_list_info(self, func_type, page_param, user):
fileter_base = ""
if client_id:
fileter_base += f" client_id='{client_id}'"
# if client_id:
# fileter_base += f" client_id='{client_id}'"
if func_type:
if fileter_base:
fileter_base += " and "
fileter_base += f" func_type={func_type}"
if user.role_name == "普通用户":
if fileter_base:
fileter_base += " and "
fileter_base += f" user_id = '{user.user_id}'"
if fileter_base:
fileter_base = f" where {fileter_base}"
sql_all = f"""
"""
select a.*, b.client_name from (
select * from rms_user_apply {fileter_base}
) a LEFT JOIN (
select * from rms_client
) b on a.client_id=b.client_id
order by a.create_date desc
"""
sql_all = f"""
select * from rms_user_apply {fileter_base} order by is_solve asc, create_date desc
"""
try:
count_number = self.execute(f"select count(*) num from rms_user_apply {fileter_base} order by create_date desc").fetchone().num
@ -43,3 +51,56 @@ class BllUserApply(Repository):
page_param.totalRecords = count_number
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
return self.execute(sql_all).fetchall()
def update_use_content(self, client_id, user, drug_info):
sql_all = f"""
select * from rms_user_apply
where
user_id='{user.user_id}' and
is_solve=1 and
solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
"""
data = self.execute(sql_all).fetchall()
break_bool = True
for d in data:
if not break_bool:
break
use_content = json.loads(d.use_content)
for j in range(len(use_content)):
con_info = use_content[j]
if con_info["client_id"] == client_id:
if con_info["name"] == drug_info.name and con_info["purity"] == drug_info.purity and con_info["speci"] == drug_info.speci:
if not con_info.get("use_num"):
con_info["use_num"] = 0
if int(con_info["use_num"]) < int(con_info["num"]):
con_info["use_num"] += 1
break_bool = False
obj = self.findEntity(self.entityType.id == d.id)
obj.use_content = json.dumps(use_content)
self.update(obj)
def get_stay_use_list(self, client_id, user):
sql_all = f"""
select * from rms_user_apply
where
user_id='{user.user_id}' and
is_solve=1 and
solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
"""
data = self.execute(sql_all).fetchall()
data_list = []
for i in data:
use_content = json.loads(i.use_content)
for j_index in range(len(use_content)):
j = use_content[j_index]
if j["client_id"] != client_id:
continue
if j.get("use_num") != 0:
n = int(j.get("num")) - int(j.get("use_num"))
if n > 0:
j["stay_use_num"] = n
data_list.append(j)
return data_list

@ -20,29 +20,39 @@ class BllUserTemporaryAuth(Repository):
def __init__(self, entityType=EntityUserTemporaryAuth):
super().__init__(entityType)
def create_temporary_auth(self, user_ids, client_id):
try:
client_code = BllClient().findEntity(EntityClient.client_id == client_id).client_code
except:
client_code = ''
def create_temporary_auth(self, user_ids, auth_type):
# try:
# client_code = BllClient().findEntity(EntityClient.client_id == client_id).client_code
# except:
# client_code = ''
for user_id in user_ids:
obj = self.findEntity(
and_(
self.entityType.user_id == user_id, client_id== client_id
)
)
end_date = str(datetime.datetime.now() + datetime.timedelta(minutes=10))[:-7]
if obj:
obj.create_date = Utils.get_str_datetime()
obj.end_date = end_date
obj.client_id = client_id
obj.client_code = client_code
self.update(obj)
else:
obj = self.entityType()
obj.user_id=user_id
obj.create_date = Utils.get_str_datetime()
obj.end_date = end_date
obj.client_id = client_id
obj.client_code = client_code
self.insert(obj)
obj = self.entityType()
obj.user_id=user_id
obj.create_date = Utils.get_str_datetime()
obj.end_date = end_date
obj.tp = auth_type
# obj.client_id = client_id
# obj.client_code = client_code
self.insert(obj)
# obj = self.findEntity(
# and_(
# self.entityType.user_id == user_id, client_id== client_id
# )
# )
# end_date = str(datetime.datetime.now() + datetime.timedelta(minutes=10))[:-7]
# if obj:
# obj.create_date = Utils.get_str_datetime()
# obj.end_date = end_date
# obj.client_id = client_id
# obj.client_code = client_code
# self.update(obj)
# else:
# obj = self.entityType()
# obj.user_id=user_id
# obj.create_date = Utils.get_str_datetime()
# obj.end_date = end_date
# obj.client_id = client_id
# obj.client_code = client_code
# self.insert(obj)

@ -28,5 +28,31 @@ def picture_shoot(image_name='img.png', image_path=r'C:/local_project/imgs') ->
break
cap.release()
cv2.destroyAllWindows()
if __name__ == '__main__':
picture_shoot()
# if __name__ == '__main__':
# picture_shoot()
import json
data_list = [
{"id": 1, "use_content": json.dumps([{"name":"氨水","num":1,"client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","purity":"25~28%","speci":"500"}])},
{"id": 2, "use_content": json.dumps([{"name":"双氧水","num":1,"client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","purity":"25~28%","speci":"500"}])},
{"id": 4, "use_content": json.dumps([{"name":"硫酸水","num":1,"client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","purity":"25~28%","speci":"500"}])},
]
drug_list = []
update_id = ''
client_id = '1c39cb24-07f8-11ed-abd4-f47b094925e1'
drug_info = {"name": "双氧水"}
for d in data_list:
if update_id:
break
use_content = json.loads(d["use_content"])
for j in range(len(use_content)):
# for j in use_content:
j_info = use_content[j]
if j_info["client_id"] == client_id and j_info["name"] == drug_info["name"] and j_info["purity"] == "25~28%" and j_info["speci"] == "500":
if not j_info.get("use_num"):
j_info["use_num"] = 0
if int(j_info["use_num"]) == int(j_info["num"]):
continue
else:
j_info["use_num"] += 1
update_id = d["id"]
print(use_content)

@ -70,6 +70,7 @@ class EntityUserTemporaryAuth(Base):
user_id = Column(String(50), comment="用户id")
create_date = Column(String(50), comment="创建时间")
end_date = Column(String(50), comment="权限结束时间")
tp = Column(Integer, comment="类型") # 类型说明1入库类型权限2申请通过类型权限3归还时临时权限
is_add = Column(Integer, comment="是否同步", default=0)
client_id = Column(String(50), comment="柜子id")
client_code = Column(String(50), comment="柜子code")
@ -84,21 +85,23 @@ class EntityUserApply(Base):
id = Column(String(50), primary_key=True, comment="id", default=get_uuid)
user_id = Column(String(50), comment="用户id")
user_id_pt = Column(String(50), comment="陪同用户id")
drug_name = Column(String(50), comment="试剂名称")
drug_num = Column(Integer, comment="试剂数量", default=0)
create_date = Column(String(50), comment="申请时间")
use_num = Column(Integer, comment="领用数量", default=0)
user_close = Column(Integer, comment="是否取消", default=0)
use_content = Column(Text, comment="领用详情")
is_solve = Column(Integer, comment="是否处理", default=0)
solve_date = Column(String(50), comment="受理时间")
solve_user_id = Column(String(50), comment="受理人")
solve_user_id_pt = Column(String(50), comment="受理人")
client_id = Column(String(50), comment="柜子id")
client_code = Column(String(50), comment="柜子code")
func_type = Column(Integer, comment="类型")
use_doc = Column(Text, comment="类型")
# drug_name = Column(String(50), comment="试剂名称")
# drug_num = Column(Integer, comment="试剂数量", default=0)
# use_num = Column(Integer, comment="领用数量", default=0)
# user_close = Column(Integer, comment="是否取消", default=0)
# client_id = Column(String(50), comment="柜子id")
# client_code = Column(String(50), comment="柜子code")
# if __name__ == '__main__':
# from sqlalchemy import create_engine
# from config.SystemConfig import SystemConfig

Loading…
Cancel
Save