Compare commits

...

4 Commits

@ -0,0 +1,190 @@
# from crypt import methods
# 将对应图片的base64编码解析为图片
from audioop import add
import base64
import os
from unicodedata import name
import time
from flask import Flask,request
from codecs import ignore_errors
from pickle import TRUE
import turtle
from xmlrpc.client import boolean
import numpy as np
from asyncore import write
import xlrd
import pandas as pd
import openpyxl
from xlrd import Book
import datetime
import time
import time
from flask import Flask,request
from encodings import utf_8
import pymssql
import json
import base64
import jpype
# 出校申请请求的类def decode_base64(base64_data,i):
# print(type(base64_data))
#print(base64_data)
# 如果想要在浏览器上访问base64格式图片需要在前面加上data:image/jpeg;base64,
class in_school:
def __init__(self,type='',sno='',name='',phone='',time='',door='',city='',area='',address='',health_code='',Tour_code='',NAT='',Pass=''):
self.type=''
self.sno=''
self.name=''
self.phone=''
self.time=''
self.door=''
self.city=''
self.area=''
self.address=''
self.health_code=''
self.Tour_code=''
self.NAT=''
self.Pass=''
def in_school1(p,json_data):
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')
cur = Conn.cursor()
sql = "Select [sno] from Form where sno= '{}'".format(json_data['sno'])
cur.execute(sql)
requests = cur.fetchall()
if(len (requests)!=0):
return '2'
sql = "Select state from [user] where username= '{}'".format(json_data['sno'])
cur.execute(sql)
requests = cur.fetchall()
for row in requests:
if(row[0]==json_data['type']):
return '3'
cur.close()
Conn.close()
#将请求得到的数据转换为json格式
l1 = len(json_data['test'])
'''for i in range(l1):
decode_base64(json_data['test'][i],i) #调用base64编码转换图片的函数得到相应图片并存到目录中'''
#查找user表如果state是在校 就return 2
a = in_school()
a.type='入校'
a.sno=json_data['sno']
a.name = json_data['name']
a.phone = json_data['phone']
a.time = json_data['time']
a.door = json_data['door']
a.city =json_data['city']
a.area =json_data['area']
a.address = json_data['address']
a.health_code = json_data['test'][0]
a.Tour_code = json_data['test'][1]
a.NAT = json_data['test'][2]
f=a.shengpi1(json_data['area'],json_data['time'],json_data['test'][2],json_data['test'][1],json_data['test'][0])
a.Pass = str(f)
return a
def shengpi1(p,a,b,c,d,e):#a:xx区 b时间 c健康码 d行程码 e核酸
year,month,day=b.split('-',2)
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')#xxx是防疫表现在先不填
cur = Conn.cursor()
sql = "Select [area] from height"
cur.execute(sql)
now=str(time.strftime("%d"))#调用本地时间
x=0
if '' not in a:
a=a+''
# wb1=openpyxl.load_workbook('D:\\fanyi.xlsx')
#ws1=wb1['Sheet1']
#num_rows1 = ws1.max_row # 总行数
#num_cols1 = ws1.max_column
row = cur.fetchone()
while row:
if(a==row[0]):
return 3 # ---调用防疫区数据库将a和防疫区数据库的值进行一一比较如果找到返回不通过
row = cur.fetchone()
#-----
a2=1
if(day!=now):
return 3 #2----将本地时间和b进行比较如果异常将数据库中对应用户的通过情况改成不通过。
#2----
#jarpath =r"D:\tupian\OCR_baidu.jar" # jar包地址
#jvmPath = jpype.getDefaultJVMPath()
#jpype.startJVM(jvmPath, "-ea", "-Djava.class.path=%s" % (jarpath))
java1 = jpype.JClass("HealthCode")
java2 = jpype.JClass("TripCode")
java3 = jpype.JClass("CovidTestRep")
j1 = java1()
j2 = java2()
j3 = java3()
a2=1
path="D:/tupian//12.jpg"
with open(path,'wb') as file:
img = base64.b64decode(c)
file.write(img)
str1 = str(j1.Judge(r"D:\tupian\12.jpg")) #Hst, Hname, Hdata 对应健康码颜色姓名日期3---- 将c传给ocr让ocr把颜色传回来对应给参数进行比较如果异常将数据库中对应用户的通过情况改成不通过。
Hst, Hname, Hdata = str1.split(',')
year1,month1,day1=Hdata.split('-')
#if(year1!=year or month!= month1 or day!=day1):
#return 3
print(Hst)
#if(Hst!='S绿'):
#return 3
path="D:/tupian//13.jpg"
with open(path,'wb') as file:
img = base64.b64decode(d)
file.write(img)
str2 = str(j2.Judge(r"D:\tupian\13.jpg"))
Tst, Ttel, Tdata, Tdis = str2.split(',')#Tst, Ttel, Tdata, Tdis 对应行程码颜色电话日期去过的地方4--- 将d传给ocr让ocr把地点颜色传回来 查看行程码是否是正常,如果异常,将数据库中对应用户的通过情况改成不通过。
year2,month2,day2=Tdata.split('.')
#if(year2!=year or month!= month2 or day!=day2):
#return 3
if(Tdis!='天津市'):
return 3
#4---
path="D://tupian/11.jpg"
with open(path,'wb') as file:
img = base64.b64decode(e)
file.write(img)
str3 = str(j3.Judge(r"D:\tupian\11.jpg"))
Cst, Cname, Cdata = str3.split(',')#Cst, Cname, Cdata 对应 核酸结果 姓名 核酸日期5--- 将e传给ocr让ocr把状态传回来 查看核酸是否是正常,如果异常,将数据库中对应用户的通过情况改成不通过。
year3,month3,day3=Cdata.split('-')
#if(year3!=year or month!= month3 or day-day3<=14):
#return 3
if(Cst!='阴性'):
return 3
return 2
# 路由交换数据
# def change(self):
# app= Flask(__name__)
# @app.route('/',methods=['GET','POST'])#开启app.route进到根目录里面
# def hello_world():
# json_data = request.json #将请求得到的数据转换为json格式
# l1 = len(json_data['test'])
# for i in range(l1):
# decode_base64(json_data['test'][i],i) #调用base64编码转换图片的函数得到相应图片并存到目录中
# self.name = json_data['name']
# self.sno = json_data['sno']
# self.phone = json_data['phone']
# self.time = json_data['time']
# self.door = json_data['door']
# self.city =json_data['city']
# self.area =json_data['area']
# self.address = json_data['address']
# return '1' #如果一切正常则返回1
# app.run(host='127.0.0.1',port=2022)
# if __name__=='__main__':
# a = in_school1()
# a.change()
# print(a.name)
# print(a.sno)
# print(a.)

@ -0,0 +1,172 @@
from audioop import add
import base64
import os
import json
from unicodedata import name
from codecs import ignore_errors
from pickle import TRUE
import turtle
from xmlrpc.client import boolean
import numpy as np
from asyncore import write
import xlrd
import pandas as pd
import openpyxl
from xlrd import Book
import datetime
import time
from flask import Flask,request
from encodings import utf_8
import pymssql
import json
import base64
from out_school import out_school
from in_school import in_school
import time
from flask import Flask,request
from shengpi import approval
from admin_log import admin_log
from user_log import user_log
from view import view
from scan_the_code import scan_the_code
import jpype
app= Flask(__name__)
@app.route('/',methods=['GET','POST'])
def hello():
return '2'
@app.route('/uesr',methods=['GET','POST'])
def log():
a= request.json
user=user_log()
a1=user.user_log1(a)
return a1
@app.route('/admin',methods=['GET','POST'])
def log1():
a= request.json
admin=admin_log()
a1=admin.admin_log1(a)
#a='{"a":{"test":1},"b":2,"c":3,"d":4,"e":5}'
return a1
@app.route('/in_school',methods=['GET','POST'])#开启app.route进到根目录里面
def in_school1():
json_data = request.json
a=in_school()
b=a.in_school1(json_data)
if(b=='2' or b == '3'):
print(b)
return b
to_mssql(b)
# print(a.sno)
return '1'
@app.route('/out_school',methods=['GET','POST'])#开启app.route进到根目录里面
def out_school1():
json_data = request.json #将请求得到的数据转换为json格式
a=out_school()
b=a.out_school1(json_data)
if(b=='2' or b == '3'):
return b
to_mssql(b)
return '1'
def a():
password = request.values.get("password")
print(password)
@app.route('/shengpi',methods=['GET','POST'])
def Userdisplay(): #收到request返回所有没有通过申请的用户名字的列表
a=approval()
data=a.list()
data=json.dumps(data,ensure_ascii=False)
return data
@app.route('/info',methods=['GET','POST'])
def Userdisplay1(): #收到学号返回该用户信息
a=approval()
b=a.list2()
a=json.dumps(b,ensure_ascii=False)
data=json.loads(a)
# print(data)
return data
def to_mssql(a):
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')
if Conn:
print ("连接成功")
else:
print("失败")
# print(a.type,a.sno,a.name,a.phone,a.time,a.door,a.city,a.area,a.address,a.health_code,a.Tour_code,a.NAT,a.Pass)
# print(type(a.NAT))
cur = Conn.cursor()
print(a.Pass)
insert = "insert into Form([type] ,[sno] ,[name] ,[phone] ,[time] ,[door] ,[city] ,[area] ,[address] ,[health_code] ,[Tour_code] ,[NAT] ,[Pass]) values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s') ; COMMIT"%(
a.type,a.sno,a.name,a.phone,a.time,a.door,a.city,a.area,a.address,a.health_code,a.Tour_code,a.NAT,a.Pass
)
cur.execute(insert)
print("qqqqq")
cur.close()
Conn.close()
@app.route('/access',methods=['GET','POST'])#开启app.route进到根目录里面
def access():
# return '1'
a= request.json
a1=approval()
a1.shengpi2(a)
return '1'
@app.route('/state',methods=['GET','POST'])
def State():
a = request.json
num = a['sno']
print(num)
Conn = pymssql.connect(server="LAPTOP-FLH9FTB4",#本地服务器
user="sa",password="as2799094948",
database="software_project",
charset="utf8")
cur = Conn.cursor()
Query = 'Select [Pass] from Form where [sno] = %s'%num
cur.execute(Query)
p = cur.fetchall()
if(len(p)==0):
print('您还没有提交表单或您的申请已被管理员驳回')
return '您还没有提交表单或您的申请已被管理员驳回'
if p[0][0] == '1':
print('您的申请表待审核')
return '您的申请表待审核'
elif p[0][0] == '2':
print('您的申请表已通过审核')
return '您的申请表已通过审核'
elif p[0][0] == '3':
print('您的申请表自动审批未通过,等待管理员审批')
return '您的申请表自动审批未通过,等待管理员审批'
else:
print('error')
return 'error'
# 查看疫情信息
@app.route('/look_info',methods=['GET','POST'])
def look():
json_data = request.json
a=view()
b=a.view1(json_data)
return b
@app.route('/scan_the_code',methods=['GET','POST'])#开启app.route进到根目录里面
def scan():
data = request.json
a=scan_the_code()
b=a.scan_the_code1(data)
return b
if __name__ == "__main__":
jarpath =r"D:\tupian\OCR_baidu.jar"
jvmPath = jpype.getDefaultJVMPath()
jpype.startJVM(jvmPath, "-ea", "-Djava.class.path=%s" % (jarpath))
app.run(host='127.0.0.1',port=2020)
jpype.shutdownJVM ()

@ -0,0 +1,149 @@
from codecs import ignore_errors
from pickle import TRUE
import turtle
from xmlrpc.client import boolean
import numpy as np
from asyncore import write
import xlrd
import pandas as pd
import openpyxl
from xlrd import Book
import datetime
import time
import time
from flask import Flask,request
from encodings import utf_8
import pymssql
import json
import base64
import jpype
class out_school:
def __init__(self,type='',sno='',name='',phone='',time='',door='',city='',area='',address='',health_code='',Tour_code='',NAT='',Pass=''):
self.type=''
self.sno=''
self.name=''
self.phone=''
self.time=''
self.door=''
self.city=''
self.area=''
self.address=''
self.health_code=''
self.Tour_code=''
self.NAT=''
self.Pass=''
def out_school1(p,json_data):
l1 = len(json_data['test'])
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')
cur = Conn.cursor()
sql = "Select [sno] from Form where sno= '{}'".format(json_data['sno'])
cur.execute(sql)
requests = cur.fetchall()
if(len (requests)!=0):
return '2'
sql = "Select state from [user] where username= '{}'".format(json_data['sno'])
cur.execute(sql)
requests = cur.fetchall()
for row in requests:
print(type(json_data['type']))
if(row[0]==json_data['type']):
return '3'
cur.close()
Conn.close()
'''for i in range(l1):
decode_base64(json_data['test'][i],i+3) #调用base64编码转换图片的函数得到相应图片并存到目录中'''
#查找user表如果state是出校 就return 2
a = out_school()
a.type = '出校'
a.sno = json_data['sno']
a.name = json_data['name']
a.phone = json_data['phone']
a.time = json_data['time']
a.door = json_data['door']
a.city =json_data['city']
a.area =json_data['area']
a.address = json_data['address']
a.health_code = json_data['test'][0]
a.Tour_code = json_data['test'][1]
a.NAT = json_data['test'][2]
f=a.shengpi1(json_data['area'],json_data['time'],json_data['test'][1],json_data['test'][2],json_data['test'][0])
a.Pass=f
return a
def shengpi1(p,a,b,c,d,e):#a:xx区 b时间 c健康码 d行程码 e核酸
year,month,day=b.split('-',2)
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')#xxx是防疫表现在先不填
cur = Conn.cursor()
sql = "Select [area] from height"
cur.execute(sql)
now=str(time.strftime("%d"))#调用本地时间
x=0
if '' not in a:
a=a+''
row = cur.fetchone()
while row:
if(a==row[0]):
return 3 # ---调用防疫区数据库将a和防疫区数据库的值进行一一比较如果找到返回不通过
row = cur.fetchone()
#-----
sql = "Select [area] from middle"
cur.execute(sql)
row = cur.fetchone()
while row:
if(a==row[0]):
return 3 # ---调用防疫区数据库将a和防疫区数据库的值进行一一比较如果找到返回不通过
row = cur.fetchone()
a2=1
if(day!=now):
return 3 #2----将本地时间和b进行比较如果异常将数据库中对应用户的通过情况改成不通过。
#2----
#jarpath =r"D:\tupian\OCR_baidu.jar" # jar包地址
#jvmPath = jpype.getDefaultJVMPath()
#jpype.startJVM(jvmPath, "-ea", "-Djava.class.path=%s" % (jarpath))
java1 = jpype.JClass("HealthCode")
java2 = jpype.JClass("TripCode")
java3 = jpype.JClass("CovidTestRep")
j1 = java1()
j2 = java2()
j3 = java3()
a2=1
path="D:/tupian//12.jpg"
with open(path,'wb') as file:
img = base64.b64decode(c)
file.write(img)
str1 = str(j1.Judge(r"D:\tupian\12.jpg")) #Hst, Hname, Hdata 对应健康码颜色姓名日期3---- 将c传给ocr让ocr把颜色传回来对应给参数进行比较如果异常将数据库中对应用户的通过情况改成不通过。
Hst, Hname, Hdata = str1.split(',')
year1,month1,day1=Hdata.split('-')
#if(year1!=year or month!= month1 or day!=day1):
#return 3
if(Hst!='S绿'):
return 3
path="D:/tupian//13.jpg"
with open(path,'wb') as file:
img = base64.b64decode(d)
file.write(img)
str2 = str(j2.Judge(r"D:\tupian\13.jpg"))
Tst, Ttel, Tdata, Tdis = str2.split(',')#Tst, Ttel, Tdata, Tdis 对应行程码颜色电话日期去过的地方4--- 将d传给ocr让ocr把地点颜色传回来 查看行程码是否是正常,如果异常,将数据库中对应用户的通过情况改成不通过。
year2,month2,day2=Tdata.split('.')
#if(year2!=year or month!= month2 or day!=day2):
#return 3
if(Tdis!='天津市'):
return 3
#4---
path="D://tupian/11.jpg"
with open(path,'wb') as file:
img = base64.b64decode(e)
file.write(img)
str3 = str(j3.Judge(r"D:\tupian\11.jpg"))
Cst, Cname, Cdata = str3.split(',')#Cst, Cname, Cdata 对应 核酸结果 姓名 核酸日期5--- 将e传给ocr让ocr把状态传回来 查看核酸是否是正常,如果异常,将数据库中对应用户的通过情况改成不通过。
year3,month3,day3=Cdata.split('-')
#if(year3!=year or month!= month3 or day-day3<=14):
#return 3
if(Cst!='阴性'):
return 3
return 2

@ -0,0 +1,113 @@
from codecs import ignore_errors
from pickle import TRUE
import turtle
from xmlrpc.client import boolean
import numpy as np
from asyncore import write
import xlrd
import pandas as pd
import openpyxl
from xlrd import Book
import datetime
import time
import time
from flask import Flask,request
from encodings import utf_8
import pymssql
import json
import base64
import jpype
class approval:
def shengpi2(p,a):#a:xx区 b时间 c健康码 d行程码 e核酸
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')
cur = Conn.cursor()
sql = "Select [type] ,[sno] ,[name] ,[phone] ,[time] ,[door] ,[city] ,[area] ,[address] ,[health_code] ,[Tour_code] ,[NAT] ,[Pass] from Form"
cur.execute(sql)
row = cur.fetchone()
sno=a['data']
sno1,sno=sno.split('')
print(sno)
print(a['condition'])
while row:
if(row[1]==sno):
if(a['condition'] == '通过'):
change = "update Form set [Pass] = '2' where [sno] = '%s';COMMIT"%row[1]
elif a['condition'] == '不通过':
change = "delete From Form where [sno] = '%s';COMMIT"%row[1]
cur.execute(change)
break
#把row找到的这个值的通过情况改为xxx
row = cur.fetchone()
cur.close()
Conn.close()
def list(p):
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')
cur = Conn.cursor()
sql = "Select [type] ,[sno] ,[name] ,[phone] ,[time] ,[door] ,[city] ,[area] ,[address] ,[health_code] ,[Tour_code] ,[NAT] ,[Pass] from Form"
cur.execute(sql)
row = cur.fetchone()
data={
'test1':[],
}
while row:
# #row[1].encode('big5hkscs')
# print(row[1].encode('latin1').decode('gbk'))
if(row[12]=='3'):
data['test1'].append(row[2])#将每一行的名字进行对code的编码和在code的基础上进行gbk解码
row = cur.fetchone()
cur.close()
Conn.close()
return data
def list2(p):
Conn = pymssql.connect('LAPTOP-FLH9FTB4',"sa","as2799094948","software_project",charset='utf8')
cur = Conn.cursor()
sql = "Select [type] ,[sno] ,[name] ,[phone] ,[time] ,[door] ,[city] ,[area] ,[address] ,[health_code] ,[Tour_code] ,[NAT] ,[Pass] from Form"
cur.execute(sql)
row = cur.fetchone()
b={
'test1':[],
'text':'2',
'image':[]
}
number=0
while row:
if(row[12]=='3'):
b['image'].append([])
b['image'][number].append(row[9])
b['image'][number].append(row[10])
b['image'][number].append(row[11])
b['test1'].append([])
b['test1'][number].append('申请表类型:{}'.format(row[0]))
b['test1'][number].append('姓名:{}'.format(row[2]))
b['test1'][number].append('学号:{}'.format(row[1]))
b['test1'][number].append('联系电话:{}'.format(row[3]))
b['test1'][number].append('时间:{}'.format(row[4]))
b['test1'][number].append('校门:{}'.format(row[5]))
b['test1'][number].append('省市:{}'.format(row[6]))
b['test1'][number].append('区:{}'.format(row[7]))
b['test1'][number].append('详细地址:{}'.format(row[8]))
# b['test1'][number].append('健康码:{}'.format(row[9]))
# b['test1'][number].append('行程码:{}'.format(row[10]))
# b['test1'][number].append('核酸:{}'.format(row[11]))
b['test1'][number].append('通过情况:不通过')
number=number+1
row = cur.fetchone()
cur.close()
Conn.close()
return b
'''a1=shengpi()
path="D://tupian/11.jpg"
with open(path,'rb') as file:
a=file.read()
img = base64.b64encode(a)
path="D://tupian/12.jpg"
with open(path,'rb') as file:
a=file.read()
img1 = base64.b64encode(a)
path="D://tupian/13.jpg"
with open(path,'rb') as file:
a=file.read()
img2 = base64.b64encode(a)
print(a1.shengpi1(str('爱华'),'2022-11-12',img1,img2,img))'''

@ -0,0 +1,96 @@
from audioop import add
import base64
import os
import json
from unicodedata import name
from codecs import ignore_errors
from pickle import TRUE
import turtle
from xmlrpc.client import boolean
import numpy as np
from asyncore import write
import xlrd
import pandas as pd
import openpyxl
from xlrd import Book
import datetime
import time
from flask import Flask,request
from encodings import utf_8
import pymssql
import json
import base64
from out_school import out_school
from in_school import in_school
import time
class view():
def view1(p,json_data):
print(type(json_data['name']))
area=json_data['name']
data={
'height':[],
'middle':[],
'low':[]
}
conn =pymssql.connect(
server="LAPTOP-FLH9FTB4",#本地服务器
user="sa",password="as2799094948",
database="software_project",
charset="utf8"
#这里设置全局的GBK如果设置的是UTF—8需要将数据库默认的GBK转化成UTF-8
)
if conn:
print('连接数据库成功!')#测试是否连接上
#高风险地区
cursor =conn.cursor() #使用cursor()方法获取操作游标
if area=='全部':sql_select="SELECT location FROM height order by location"
else:sql_select="SELECT location FROM height where area ='{}' order by location".format(area)
# sql_select="SELECT location FROM height where location like '{}%'".format(area) #数据库查询语句
cursor.execute(sql_select) #执行语句
results =cursor.fetchall() #获取所有记录列表
if len(results)==0:
print('该地区暂无高风险区域')
data['height'].append('该地区暂无高风险区域')
else:
print('共查询到{}条信息'.format(len(results)))
data['height'].append('共查询到{}条信息'.format(len(results)))
for result in results:
print(result[0])
data['height'].append(result[0])
#中风险地区
cursor =conn.cursor() #使用cursor()方法获取操作游标
if area=='全部':sql_select="SELECT location FROM middle order by location"
else:sql_select="SELECT location FROM middle where area ='{}' order by location".format(area)
cursor.execute(sql_select) #执行语句
results =cursor.fetchall() #获取所有记录列表
if len(results)==0:
print('该地区暂无中风险区域')
data['middle'].append('该地区暂无中风险区域')
else:
print('共查询到{}条信息'.format(len(results)))
data['middle'].append('共查询到{}条信息'.format(len(results)))
for result in results:
print(result[0])
data['middle'].append(result[0])
#低风险地区
cursor =conn.cursor() #使用cursor()方法获取操作游标
if area=='全部':sql_select="SELECT location FROM low order by location"
else:sql_select="SELECT location FROM low where area ='{}' order by location".format(area)
cursor.execute(sql_select) #执行语句
results =cursor.fetchall() #获取所有记录列表
if len(results)==0:
print('该地区暂无低风险区域')
data['low'].append('该地区暂无低风险区域')
else:
print('共查询到{}条信息'.format(len(results)))
data['low'].append('共查询到{}条信息'.format(len(results)))
for result in results:
print(result[0])
data['low'].append(result[0])
conn.commit()
cursor.close()
conn.close()
b=json.dumps(data,ensure_ascii=False)
return b
Loading…
Cancel
Save