1 Star 0 Fork 7

孙权/xgc

forked from goodfeng/xgc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
callback.py 2.76 KB
一键复制 编辑 原始数据 按行查看 历史
goodfeng 提交于 2022-10-10 14:24 . init
# -*- coding: utf-8 -
from db.models import Department
from logic.department import DepartmentLG
from logic.covip import ClistLG
from util.time import getToday
from datasource.eggs.covip.locationInfo import LocationInfo
def creatDepartmentID(c):
alpha = [str(i) for i in range(0,10)] + [chr(i) for i in range(65,91)]
w1 = c//len(alpha)
w2 = c%len(alpha)
return alpha[w1]+alpha[w2]
def creatPasw(i):
return 'hnjm'+str(i)[-8:]
if __name__ == '__main__':
sdate = getToday()
t = LocationInfo(sdate)
did = DepartmentLG().getDepartmentByName('国际教育学院').id
DepartmentLG().clear(did)
ClistLG().clear(did)
departlen = Department.objects.filter(id__lte='0Y').count()
dicts =[]
depts = []
admins ={}
dclasses ={}
for rec in t.getRecs():
name = rec['name'].strip().replace('\n','').replace('\t','')
dname = rec['department'].strip().replace('\n','').replace('\t','')
try:
department = DepartmentLG().getDepartmentByName(dname).id
except Exception as e:
print('-3')
dclass = rec['dclass']
if dclass not in depts:
depts.append(dclass)
i = depts.index(dclass)
dclass = creatDepartmentID(departlen+i)
dclasses[dclass]=department
eid = rec['eid']
pasw = creatPasw(eid)
mobile = str(rec['mobile']).strip()
isadmin = rec['isadmin']
if isadmin=='是':
role = '1'
admins[dclass]=name
else:
role = '0'
acovip = ClistLG().create(name,department,dclass, name, mobile, pasw, role)
dicts.append(acovip)
tdicts=[]
c=0
for t in depts:
c+=1
dname = t
dtype = '2'
dorder =c
dclass = creatDepartmentID(c+departlen-1)
print(dname,dclass)
try:
DepartmentLG().getDepartmentByName(dname)
print('-3')
except Exception as e:
print(dname,e)
adept = DepartmentLG().create(dclass,dname, dtype, dorder, dclasses[dclass])
tdicts.append(adept)
for t in tdicts:
print(t.__dict__)
DepartmentLG().bulk_create(tdicts)
ndicts=[]
for acovip in dicts:
if acovip.dclass in admins:
acovip.admin = admins[acovip.dclass]
else:
acovip.admin = acovip.name
ndicts.append(acovip)
ClistLG().bulk_create(ndicts)
print('1')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sun-quan317/xgc.git
git@gitee.com:sun-quan317/xgc.git
sun-quan317
xgc
xgc
master

搜索帮助