32 KiB
32 KiB
In [1]:
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["place"]
place_id = 250226
place_code = "16"
dw_name = "山东东营陈庄镇"
dw_jc = "山东东营陈庄镇"
myquery = { "id": place_id }
num = mycol.count_documents(myquery)
if num>0:
print(num)
else:
mydict = { "id":place_id,"name": dw_name, "code": place_code }
x = mycol.insert_one(mydict) In [2]:
import openpyxl
import os,sys,shutil
import json
import math
import glob
import random
from pathlib import Path
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
place_id = 250226
place_code = "16"
dw_name = "山东东营陈庄镇"
dw_jc = "山东东营陈庄镇"
fi_path = '/home/songyi/python/mycrm/flask/pdf/files'
fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')
code_list = []
for i in range(10): # 0~9
code_list.append(str(i))
list1 = []
mycol = mydb["pdf"]
query1 = { "place_id": place_id }
list2 = []
mydoc = mycol.find(query1,{ "code": 1, "_id": 0 })
for x in mydoc:
list2.append(x['code'])
i = 0
while i < len(fls):
code = random.sample(code_list,4) #随机取3位数
code_num = ''.join(code)
if place_code+code_num not in list1 and place_code+code_num not in list2:
list1.append(place_code+code_num)
i +=1
i = 0
list2= []
for fn in fls:
dict2 = {}
fi_name =Path(fn).stem.split('-')[0]
#fi_name =Path(fn).stem
code = int(fi_name)
dxm = list1[i]
dict2 = {'place_id':place_id,'code':dxm,'fn':Path(fn).name}
list2.append(dict2)
i +=1
x = mycol.insert_many(list2)
print(len(list2),'ok') 116 ok
In [3]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
import time
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["pdf"]
dw_jc = "山东东营陈庄镇测试者"
filename = 'data/陈庄检测人员.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
#place_id = 571315
myquery = { "place_id": place_id}
for x in mycol.find(myquery,{ "_id": 0, "place_id": 0}):
code = int(x['fn'].split('-')[0])
if str(code) in dict1.keys() and 'phone' in dict1[str(code)].keys():
dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code'],'name':x['fn']}
else:
print(code,'no phone')
#print(dict2)
i=1
#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}
for k, v in dict2.items():
phone = '+86'+v['phone']
yzm = v['code']
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1875765"
req.TemplateParamSet = [dw_jc,yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
#resp = client.SendSms(req)
#dict3 = json.loads(resp.to_json_string(indent=2))
#print(v['phone'],dict3['SendStatusSet'][0]["Message"])
print(i,v['phone'],v['name'], v['code'])
i+=1
except TencentCloudSDKException as err:
print(v['phone'],err)1 17354672396 0108-徐中华.pdf 160486 2 13563358955 0103-薄友梅.pdf 163176 3 13561096259 0095-王天成.pdf 162197 4 13371558516 0047-刘芳.pdf 160524 5 14768999777 0112-杨国良.pdf 168926 6 17754600886 0094-崔明波.pdf 167621 7 18562083357 0053-梁文硕.pdf 162163 8 15550539133 0097-李燕.pdf 166914 9 18254652100 0074-王鲁笑.pdf 160615 10 13625462769 0005-李卫忠.pdf 167935 11 15266065108 0044-纪荣平.pdf 166395 12 17754684486 0063-孙霞.pdf 165102 13 15318307578 0018-冯海华.pdf 163802 14 13561011787 0033-石振波.pdf 168039 15 13561006241 0041-薛真.pdf 167614 16 15965466216 0111-李培荣.pdf 167615 17 18562961538 0093-李乐.pdf 168561 18 13465269869 0015-王翠霞.pdf 163169 19 17754629112 0054-孟玲.pdf 162869 20 18554626567 0122-刘建云.pdf 161832 21 15318391717 0080-李小青.pdf 166590 22 17754629138 0067-牟艳红.pdf 166379 23 17754629077 0062-胡振云.pdf 162831 24 17754651259 0124-王学晴.pdf 169650 25 15254633988 0009-张伟花.pdf 164287 26 18562007818 0083-蔻艳.pdf 167918 27 18654691866 0001-陈彤彤.pdf 166271 28 18954628871 0100-张玉荣.pdf 167910 29 19854689029 0082-陈希珍.pdf 164523 30 15154681871 0010-王兰玉.pdf 167460 31 13780756776 0023-张仕荣.pdf 164763 32 15154622086 0077-孙义芬.pdf 164789 33 13455721686 0036-陈光梅.pdf 162051 34 13475465246 0064-李铭悦.pdf 164913 35 13181857658 0116-韩书贞.pdf 165482 36 13562298356 0084-胡冰叶.pdf 165170 37 18562961552 0101-王乃玲.pdf 161429 38 13371528169 0042-刘志芳.pdf 167682 39 17754629165 0048-徐雪花.pdf 165471 40 13256477708 0117-崔树红.pdf 161758 41 13356619896 0114-陈延红.pdf 167963 42 13287371168 0038-王守美.pdf 166920 43 15715468750 0006-韩小荣.pdf 168734 44 15154619169 0079-刘桂.pdf 164271 45 17754629082 0070-王芳.pdf 168370 46 15306476627 0055-张韶岩.pdf 166984 47 13705467605 0126-巴月华.pdf 160364 48 17754629057 0065-商孟加.pdf 161934 49 19963763561 0123-陈建正.pdf 160236 50 13325059838 0025-崔志猛.pdf 162853 51 15318328975 0040-王元.pdf 163259 52 13205471255 0029-张秀奎.pdf 165897 53 13361503856 0102-宋珊珊.pdf 167024 54 18954680512 0059-孟祥菊.pdf 162648 55 13465275185 0060-张春先.pdf 169518 56 13361522787 0069-王明杰.pdf 165038 57 13054610918 0057-郭立凯.pdf 168106 58 18506466571 0091-赵培芬.pdf 166937 59 13181854171 0107-董强.pdf 168902 60 13210388535 0071-刘俊志.pdf 161024 61 13306475903 0072-王芹.pdf 163160 62 15965465758 0043-郭振芹.pdf 165241 63 13355460615 0035-李跃粉.pdf 165670 64 18266665051 0052-王一涵.pdf 162679 65 13054600511 0125-季书奎.pdf 164526 66 15314325556 0045-张绪民.pdf 163645 67 13963355696 0118-王兴业.pdf 163275 68 13081417578 0028-李召兰.pdf 168653 69 15965466030 0086-陈春华.pdf 165723 70 15254639986 0014-陈召云.pdf 164920 71 13792069959 0016-崔士叶.pdf 163204 72 13905465022 0075-孙丽.pdf 165792 73 17754629228 0088-陈奎霞.pdf 164810 74 15154623768 0017-崔业常.pdf 166814 75 15965466216 0032-李培荣.pdf 164150 76 13864785309 0115-杨建军.pdf 162097 77 15990986892 0104-林燕燕.pdf 169407 78 18764586870 0056-曹志捷.pdf 168719 79 15315038808 0119-韩永强.pdf 165184 80 18562961530 0106-张玉军.pdf 169036 81 13054673678 0039-王新娥.pdf 167120 82 13706470006 0024-毕玉江.pdf 165769 83 13954696798 0008-陈振玉.pdf 163164 84 18766719018 0092-程艳娟.pdf 162109 85 17754629160 0090-徐妮.pdf 162709 86 15954759855 0019-陈新英.pdf 162859 87 13375461776 0022-盖新茂.pdf 164270 88 15954671399 0121-韩秀娥.pdf 168275 89 18954680397 0046-尚玉兰.pdf 161083 90 13561016489 0020-王乐花.pdf 164631 91 18860673506 0012-崔桂灵.pdf 163906 92 15665876948 0051-薄尊敏.pdf 165219 93 17754629197 0096-吴松.pdf 167890 94 18865467781 0098-徐雪梅.pdf 167148 95 17754629133 0068-李艳红.pdf 161483 96 17754600676 0066-吴根林.pdf 166370 97 13561086165 0004-李伟军.pdf 164165 98 15605469730 0089-曹莹莹.pdf 164137 99 17754629176 0050-徐凤霞.pdf 161527 100 13220505818 0026-霍卫华.pdf 160537 101 15154655057 0085-左连亮.pdf 168761 102 15275640625 0120-石东初.pdf 164391 103 13562257108 0081-李英霞.pdf 165483 104 15318382108 0087-刘肖丽.pdf 160973 105 13625462769 0109-李卫忠.pdf 167350 106 17754600760 0061-胡菲菲.pdf 169176 107 13006548466 0037-李振琴.pdf 162870 108 18954676358 0058-赵凯.pdf 167032 109 15552779321 0105-刘胜彩.pdf 163867 110 13563395385 0027-王振泉.pdf 164018 111 19854689027 0078-张卫卫.pdf 164520 112 17754629226 0049-蔡立庆.pdf 169251 113 13406089611 0076-王宪芳.pdf 168925 114 17754665865 0073-韩霞.pdf 161576 115 13963351053 0099-韩英.pdf 160826 116 17754629175 0034-段德引.pdf 162306
In [4]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
import time
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["pdf"]
dw_jc = "山东东营陈庄镇测试者"
filename = 'data/陈庄检测人员.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
place_id = 250226
myquery = { "place_id": place_id }
for x in mycol.find(myquery,{ "_id": 0, "place_id": 0}):
code = int(x['fn'].split('-')[0])
if str(code) in dict1.keys() and 'phone' in dict1[str(code)].keys():
dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code'],'name':x['fn']}
else:
print('no phone')
#print(dict2)
#dw_jc = "北体体质康健班测试者"
#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}
for k, v in dict2.items():
phone = '+86'+v['phone']
yzm = v['code']
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1875765"
req.TemplateParamSet = [dw_jc,yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
resp = client.SendSms(req)
dict3 = json.loads(resp.to_json_string(indent=2))
print(v['phone'], v['code'],dict3['SendStatusSet'][0]["Message"])
time.sleep(5)
except TencentCloudSDKException as err:
print(v['phone'],err)17354672396 160486 send success 13563358955 163176 send success 13561096259 162197 send success 13371558516 160524 send success 14768999777 168926 send success 17754600886 167621 send success 18562083357 162163 send success 15550539133 166914 send success 18254652100 160615 send success 13625462769 167935 send success 15266065108 166395 send success 17754684486 165102 send success 15318307578 163802 send success 13561011787 168039 send success 13561006241 167614 send success 15965466216 167615 send success 18562961538 168561 send success 13465269869 163169 send success 17754629112 162869 send success 18554626567 161832 send success 15318391717 166590 send success 17754629138 166379 send success 17754629077 162831 send success 17754651259 169650 send success 15254633988 164287 send success 18562007818 167918 send success 18654691866 166271 send success 18954628871 167910 send success 19854689029 164523 send success 15154681871 167460 send success 13780756776 164763 send success 15154622086 164789 send success 13455721686 162051 send success 13475465246 164913 send success 13181857658 165482 send success 13562298356 165170 send success 18562961552 161429 send success 13371528169 167682 send success 17754629165 165471 send success 13256477708 161758 send success 13356619896 167963 send success 13287371168 166920 send success 15715468750 168734 send success 15154619169 164271 send success 17754629082 168370 send success 15306476627 166984 send success 13705467605 160364 send success 17754629057 161934 send success 19963763561 160236 send success 13325059838 162853 send success 15318328975 163259 send success 13205471255 165897 send success 13361503856 167024 send success 18954680512 162648 send success 13465275185 169518 send success 13361522787 165038 send success 13054610918 168106 send success 18506466571 166937 send success 13181854171 168902 send success 13210388535 161024 send success 13306475903 163160 send success 15965465758 165241 send success 13355460615 165670 send success 18266665051 162679 send success 13054600511 164526 send success 15314325556 163645 send success 13963355696 163275 send success 13081417578 168653 send success 15965466030 165723 send success 15254639986 164920 send success 13792069959 163204 send success 13905465022 165792 send success 17754629228 164810 send success 15154623768 166814 send success 15965466216 164150 send success 13864785309 162097 send success 15990986892 169407 send success 18764586870 168719 send success 15315038808 165184 send success 18562961530 169036 send success 13054673678 167120 send success 13706470006 165769 send success 13954696798 163164 send success 18766719018 162109 send success 17754629160 162709 send success 15954759855 162859 send success 13375461776 164270 send success 15954671399 168275 send success 18954680397 161083 send success 13561016489 164631 send success 18860673506 163906 send success 15665876948 165219 send success 17754629197 167890 send success 18865467781 167148 send success 17754629133 161483 send success 17754600676 166370 send success 13561086165 164165 send success 15605469730 164137 send success 17754629176 161527 send success 13220505818 160537 send success 15154655057 168761 send success 15275640625 164391 send success 13562257108 165483 send success 15318382108 160973 send success 13625462769 167350 send success 17754600760 169176 send success 13006548466 162870 send success 18954676358 167032 send success 15552779321 163867 send success 13563395385 164018 send success 19854689027 164520 send success 17754629226 169251 send success 13406089611 168925 send success 17754665865 161576 send success 13963351053 160826 send success 17754629175 162306 send success
In [ ]:
dict1 = json.loads(resp.to_json_string(indent=2))
print(dict1['SendStatusSet'][0]["Message"])In [5]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["pdf"]
dw_jc = "北体体质康健班学员"
filename = 'data/北体体质康健班202412.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
place_id = 141002
myquery = { "place_id": place_id }
for x in mycol.find(myquery,{ "_id": 0, "place_id": 0}):
code = int(x['fn'].split('-')[0])
if str(code) in dict1.keys() and 'phone' in dict1[str(code)].keys():
dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code'],'name':x['fn']}
else:
print('no phone')
phone = '+86'+'13793180751'
yzm = '155673'
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1875765"
req.TemplateParamSet = [dw_jc,yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
resp = client.SendSms(req)
dict3 = json.loads(resp.to_json_string(indent=2))
print(phone,dict3['SendStatusSet'][0]["Message"])
except TencentCloudSDKException as err:
print(v['phone'],err)+8613793180751 send success
In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["pdf"]
filename = 'data/中安联合.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
place_id = 624770
myquery = { "place_id": place_id,"code":"051067" }
for x in mycol.find(myquery,{ "_id": 0, "place_id": 0}):
code = int(x['fn'].split('-')[0])
if str(code) in dict1.keys():
dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code']}
else:
print('no phone')
print(dict2)In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendStatusStatisticsRequest()
req.SmsSdkAppId = "1400140089"
# 拉取最大条数,最多100条
req.Limit = 100
# 偏移量 注:目前固定设置为0
req.Offset = 0
# 开始时间,yyyymmddhh 需要拉取的起始时间,精确到小时
req.BeginTime = "2023112700"
# 结束时间,yyyymmddhh 需要拉取的截止时间,精确到小时
# 注:EndTime 必须大于 BeginTime
req.EndTime = "2023112723"
# 通过client对象调用SendStatusStatistics方法发起请求。注意请求方法名与请求对象是对应的。
# 返回的resp是一个SendStatusStatisticsResponse类的实例,与请求对象对应。
resp = client.SendStatusStatistics(req)
# 输出json格式的字符串回包
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print(err)
In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.PullSmsSendStatusRequest()
req.SmsSdkAppId = "1400140089"
req.Limit = 100
resp = client.PullSmsSendStatus(req)
# 输出json格式的字符串回包
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print(err)
In [ ]:
In [ ]: