利用python+sever酱实现排班信息微信自动推送提醒,方便广大朋友们知道自己的岗位班次
1、根据自己所在公司的轮班制度确认好员工的排班(本文以excel排班为例),如图:
2、编写排班相关代码:
#导入模块
import datetime
import xlrd
from xlrd import xldate_as_tuple
# 解析excel文件
def read_excel(filename, name, to_date):
# 打开文件
workbook = xlrd.open_workbook(filename)
# 获取所有sheet
# print(workbook.sheet_names())
sheetname = workbook.sheet_names()[0]
# 根据sheet索引或者名称获取sheet内容
ws = workbook.sheet_by_name(sheetname)
context = []
# 获取单元格内容
# j = 2 早班 3 正常班 4 正常班2 5 夜班 6 休息 7 巡检
for i in range(ws.nrows):
if ws.cell(i, 0).ctype == 3:
date = datetime.datetime(*xldate_as_tuple(ws.cell(i, 0).value, 0)).strftime('%m-%d')
#to_date = '3-24'
if date == to_date:
for j in range(ws.ncols):
if ws.cell(i, j).ctype == 3:
date = datetime.datetime(*xldate_as_tuple(ws.cell(i, 0).value, 0))
context.append("%s月%s日" % (date.strftime('%m'), date.strftime('%d')))
#print(date)
elif name in ws.cell(i, j).value:
if j == 2:
context.append("早班")
elif j == 3:
context.append("正常班")
elif j == 4:
context.append("正常班2")
elif j == 5:
if ws.cell(i, 7).value != '':
context.append("夜班,记得巡检")
else:
context.append("夜班")
elif j == 6:
text = "明天休息"
d = 1
if name in ws.cell(</