赞
踩
近来河南商丘地区疫情较为严重,全面开展核酸检测工作,据猜测,考虑到设备、以及老人小孩没有智能手机,无法进行核酸检测信息填报,本社区采用了人工信息的填报(即,所有信息采用手写的方式)。这导致后期信息上报到系统出现困难,其过程步骤过于繁琐。开发了这个程序,方便了核酸检测信息的录入,节省了大量时间(只收集姓名、身份证号、手机号即可,省去了地区、性别等)。
注:由于同一地区,而省去了地区的选择。
def check_id_data(id): #核验身份证号是否合理 var=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2] var_id=['1','0','x','9','8','7','6','5','4','3','2'] id = str(id) sum = 0 if int(id[16])%2==0: gender="女" same=int(int(id[16])/2) else: gender="男" same=int((int(id[16])+1)/2) for i in range(0,17): sum += int(id[i])*var[i] sum %= 11 CheckBit = str(id[17]); if "X"==CheckBit: CheckBit = "x" if (var_id[sum])==CheckBit: print("身份证号规则核验通过,校验码是:",var_id[sum]) print("出生于:",id[6:10],"年",id[10:12],"月",id[12:14],"日","性别:",gender,"\n当地同性别同生日排名:",same) return sum else: print("出生于:",id[6:10],"年",id[10:12],"月",id[12:14],"日","性别:",gender,"\n当地同性别同生日排名:",same) print("但身份证号规则核验失败,校验码应为",var_id[sum],",当前校验码是:",id[17]) return -1
def InformationReporting(name, id, phone): id = str(id) char = id[16] gender_num = int(char) if gender_num%2 == 1: gender = '男' else: gender = '女' url = "http://36.133.44.216:9100/hsxxdj-service/p/core/yidd/addPerson?name=" + name + "&idcard=" + id + "&linkPhone=" + phone + "&currAddr=虞城县/城关镇/虞城县北街居委会/某某村&sex=" + gender + "&cardType=身份证" req = requests.get(url) result = req.json(); print(result) result = str(result) if result[12:16] == "True": return True else: return False
url = "http://36.133.44.216:9100/hsxxdj-service/p/core/yidd/addPerson?name=" + name + "&idcard=" + id + "&linkPhone=" + phone + "&currAddr=虞城县/城关镇/虞城县北街居委会/某某村&sex=" + gender + "&cardType=身份证"
上述查看源之后,将其对应的值修改即可
请将下面代码中的地址,替换至上报系统对应地址。(此地址不代表任何含义,使用的全是第一个选项)
虞城县/城关镇/虞城县北街居委会/某某村
def GenerateQRCode(name, id):
qr=qrcode.QRCode(version = 2,error_correction = qrcode.constants.ERROR_CORRECT_L,box_size=10,border=10,)
strInput = '{"idcard":"' + id + '","name":"' + name +'"}'
print('本码:'+strInput)
bs=str(base64.b64encode(strInput.encode('utf-8')),"utf-8")
print('转码:'+bs)
qr.add_data(bs)
qr.make(fit=True)
img = qr.make_image()
img.show()
(不同地区的二维码生成信息可能不一致,仅供参考)
通过其他程序扫描得知,它是一段base64的数据,通过解码得到了一串json数据(关于idcard和name),所以通过生成姓名和身份证号的json数据,进行base64编码,即可得到对应二维码
import sys import qrcode import base64 import datetime import os import sys import requests,json def InformationReporting(name, id, phone): id = str(id) char = id[16] gender_num = int(char) if gender_num%2 == 1: gender = '男' else: gender = '女' url = "http://36.133.44.216:9100/hsxxdj-service/p/core/yidd/addPerson?name=" + name + "&idcard=" + id + "&linkPhone=" + phone + "&currAddr=虞城县/城关镇/虞城县北街居委会/某某村&sex=" + gender + "&cardType=身份证" req = requests.get(url) result = req.json(); print(result) result = str(result) if result[12:16] == "True": return True else: return False def GenerateQRCode(name, id): qr=qrcode.QRCode(version = 2,error_correction = qrcode.constants.ERROR_CORRECT_L,box_size=10,border=10,) strInput = '{"idcard":"' + id + '","name":"' + name +'"}' print('本码:'+strInput) bs=str(base64.b64encode(strInput.encode('utf-8')),"utf-8") print('转码:'+bs) qr.add_data(bs) qr.make(fit=True) img = qr.make_image() img.show() #path = 'E:/Aurora/Desktop/核酸/1/' + str_1 + '.jpg' #img.save(path) def check_id_length(id): #核验身份证号长度是否合理 if len(str(id)) != 18: print("只支持18位身份证号查询") return False else: return True def check_id_data(id): #核验身份证号是否合理 var=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2] var_id=['1','0','x','9','8','7','6','5','4','3','2'] id = str(id) sum = 0 if int(id[16])%2==0: gender="女" same=int(int(id[16])/2) else: gender="男" same=int((int(id[16])+1)/2) for i in range(0,17): sum += int(id[i])*var[i] sum %= 11 CheckBit = str(id[17]); if "X"==CheckBit: CheckBit = "x" if (var_id[sum])==CheckBit: print("身份证号规则核验通过,校验码是:",var_id[sum]) print("出生于:",id[6:10],"年",id[10:12],"月",id[12:14],"日","性别:",gender,"\n当地同性别同生日排名:",same) return sum else: print("出生于:",id[6:10],"年",id[10:12],"月",id[12:14],"日","性别:",gender,"\n当地同性别同生日排名:",same) print("但身份证号规则核验失败,校验码应为",var_id[sum],",当前校验码是:",id[17]) return -1 def main(name, id, phone): if check_id_length(id) == False: return False if check_id_data(id) == -1: return False if InformationReporting(name, id, phone): GenerateQRCode(name, id) name = str(sys.argv[1]) id = str(sys.argv[2]) phone = str(sys.argv[3]) main(name, id, phone)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。