|
|
|
@ -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.)
|