import requests import os import gradio as gr import openpyxl import string import re import shutil import time class presideOverBeantd: name: "" # 主持名称 income: 0 # 流水 frequency:0 #有效档数 # 派单厅 100档 wfrequency:0 #夜档数 # 派单厅 200档 ffrequency: 0#无效档 # 派单厅 <100档 money:0 #福利 dfl: 0 # 档福利 jl: 0 # 奖励 class presideOverBean: name:"" #主持名称 tiem:"" #主持档时 type:"" #主持类别(1为无任务) income:0 #流水 frequency:0 #有效档数 ffrequency:0 #无效档 money:0 #福利 dfl:0#档福利 jl:0#奖励 way:""#福利方法 def pdjl(income): jl = 0 if (10000 > income >= 5000): jl = 8 elif (20000 > income >= 10000): jl = 18 elif (40000 > income >= 20000): jl = 48 elif (60000 > income >= 40000): jl = 128 elif (100000 > income >= 60000): jl = 228 elif (income >= 100000): jl = 368 return jl def jyjl(income): jl = 0 if (20000 > income >= 10000): jl = 15 elif (30000 > income >= 20000): jl = 30 elif (50000 > income >= 30000): jl = 52 elif (80000 > income >= 50000): jl = 88 elif (120000 > income >= 80000): jl = 168 elif (180000 > income >= 120000): jl = 288 elif (250000 > income >= 180000): jl = 388 elif (350000 > income >= 250000): jl = 688 elif (350000 < income): jl = income * 0.0035 return jl def dsjl(income): jl = 0 if (10000 > income > 5000): jl = income * 0.0005 elif (20000 > income > 10000): jl = income * 0.001 elif (30000 > income > 20000): jl = income * 0.0015 elif (50000 > income > 30000): jl = income * 0.002 elif (70000 > income > 50000): jl = income * 0.0025 elif (income > 70000): jl = income * 0.003 return jl #派单 旧版 # def PDcalculate(ws,pbs,wb,file): # tdpds = {} # cd = ws.max_row # for index in range(cd): # if (ws["c" + str(index + 1)].value != "主持" and ws["c" + str(index + 1)].value != None): # # print(ws["b" + str(index + 1)].value, ws["c" + str(index + 1)].value, ws["g" + str(index + 1)].value) # zincome = ws["g" + str(index + 1)].value # if(zincome==None): # zincome=0 # zname = ws["c" + str(index + 1)].value.strip() # ztiem = ws["b" + str(index + 1)].value.strip() # # if (zincome >= 100): # # 判断是否替档 # if (pbs.get(zname+ztiem, 0) != 0): # # print("不是"+zname+ztiem) # pbs.get(zname+ztiem).frequency = pbs.get(zname+ztiem).frequency + 1 # pbs.get(zname+ztiem).income = pbs.get(zname+ztiem).income + zincome # else: # # print("是"+zname+ztiem) # # if (zname != ""): # # 判断是否第一次创建 # if (tdpds.get(zname+"替档", 0) != 0): # # 判断是否替夜档 # if (ztiem != "04:00-06:00" and ztiem != "06:00-08:00"): # tdpds.get(zname+"替档").frequency = tdpds.get(zname+"替档").frequency + 1 # else: # tdpds.get(zname+"替档").wfrequency = tdpds.get(zname+"替档").wfrequency + 1 # tdpds.get(zname+"替档").income = tdpds.get(zname+"替档").income + zincome # else: # pobtd = presideOverBeantd() # pobtd.name = zname # pobtd.income = zincome # pobtd.ffrequency = 0 # if (ztiem != "04:00-06:00" and ztiem != "06:00-08:00"): # pobtd.frequency = 1 # pobtd.wfrequency = 0 # else: # pobtd.frequency = 0 # pobtd.wfrequency = 1 # tdpds[zname+"替档"] = pobtd # else: # if (pbs.get(zname + ztiem, 0) != 0): # # print("不是"+zname+ztiem) # pbs.get(zname + ztiem).ffrequency = pbs.get(zname + ztiem).ffrequency + 1 # pbs.get(zname + ztiem).income = pbs.get(zname + ztiem).income + zincome # else: # # print("是"+zname+ztiem) # if (zname != ""): # # 判断是否第一次创建 # if (tdpds.get(zname + "替档", 0) != 0): # tdpds.get(zname + "替档").ffrequency = tdpds.get(zname + "替档").ffrequency + 1 # tdpds.get(zname + "替档").income = tdpds.get(zname + "替档").income + zincome # else: # pobtd = presideOverBeantd() # pobtd.name = zname # pobtd.income = zincome # pobtd.ffrequency = 1 # pobtd.frequency = 0 # pobtd.wfrequency = 0 # tdpds[zname + "替档"] = pobtd # # if '汇总' in wb.sheetnames: # print("工作表 '汇总' 已经存在,将不再创建。") # hzws = wb['汇总'] # # 清空工作表中的所有内容 # hzws.delete_rows(1, hzws.max_row) # else: # # 如果不存在名为'汇总'的工作表,则创建它 # hzws = wb.create_sheet(title='汇总') # print("创建了名为 '汇总' 的新工作表。") # # hzws["a1"] = "名称" # hzws["b1"] = "有效档时" # hzws["c1"] = "主持流水" # hzws["d1"] = "流水提成" # hzws["e1"] = "主持福利" # hzws["f1"] = "全部福利" # hzws["g1"] = "备注" # hzws["h1"] = "主持信息" # # flxhs = 1 # for k,xhz in pbs.items(): # flxhs += 1 # jl = 0 # if (xhz.tiem != "04:00-06:00" and xhz.tiem != "06:00-08:00"): # if (xhz.type == 0): # xhz.money = xhz.frequency * 10 # xhz.dfl = xhz.frequency * 10 # elif (xhz.type == "1"): # xhz.money = xhz.frequency * 8 # xhz.dfl = xhz.frequency * 8 # else: # if (xhz.type == 0): # xhz.money = xhz.frequency * 15 # xhz.dfl = xhz.frequency * 15 # elif (xhz.type == "1"): # xhz.money = xhz.frequency * 12 # xhz.dfl = xhz.frequency * 12 # if (xhz.type != "1"): # jl = pdjl(xhz.income) # xhz.money += jl # xhz.jl = jl # if (xhz.income < 5000): # xhz.money = xhz.money / 2 # elif (3 < xhz.frequency+xhz.ffrequency < 5): # xhz.money = xhz.money / 2 # elif (xhz.frequency+xhz.ffrequency <= 3): # xhz.money = 0 # # print(xhz.name, xhz.frequency, xhz.income, xhz.money) # hzws["a" + str(flxhs)] = xhz.name # hzws["b" + str(flxhs)] = "正常档"+str(xhz.frequency) + "无效档" + str(xhz.ffrequency) # hzws["c" + str(flxhs)] = xhz.income # hzws["d" + str(flxhs)] = jl # hzws["e" + str(flxhs)] = xhz.dfl # hzws["f" + str(flxhs)] = xhz.money if xhz.money < xhz.income * 0.01 else xhz.income * 0.01 # hzws["g" + str(flxhs)] = "无任务档" if xhz.type == "1" else "" # hzws["h" + str(flxhs)] = k # for k,xhz2 in tdpds.items(): # flxhs += 1 # jl = 0 # if (xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency <= 3): # xhz2.money = xhz2.frequency * 8 + xhz2.wfrequency * 12 # xhz2.dfl = xhz2.frequency * 8 + xhz2.wfrequency * 12 # else: # xhz2.money = xhz2.frequency * 10 + xhz2.wfrequency * 15 # xhz2.dfl = xhz2.frequency * 10 + xhz2.wfrequency * 15 # # print(xhz2.name, xhz2.frequency, xhz2.wfrequency) # jl = pdjl(xhz2.income) # xhz2.money+=jl # if (xhz2.income < 5000): # xhz2.money = xhz2.money / 2 # xhz2.jl = jl # if (xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency < 5): # xhz2.money = xhz2.money / 2 # # # print("提档", xhz2.name, xhz2.frequency + xhz2.wfrequency, xhz2.income, xhz2.money) # xunf = False # if (xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency <= 3): # for i in range(hzws.max_row): # if(hzws["a"+str(i+1)].value==xhz2.name): # xhz = pbs.get(hzws["h" + str(i + 1)].value) # print(xhz.name) # mo = 0 # zmo = pdjl(xhz.income + xhz2.income) # if(xhz.type!=1): # mo = xhz.dfl + xhz2.wfrequency*15 + xhz2.frequency*10 # else: # mo = xhz.dfl + xhz2.wfrequency*12 + xhz2.frequency*8 # zmo+=mo # if(xhz.income + xhz2.income>5000): # zmo=zmo/2 # print(xhz.name, zmo) # hzws["b" + str(i+1)] = hzws["b" + str(i+1)].value + "换档" + str(xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency) # hzws["e" + str(i+1)] = mo # hzws["c" + str(i+1)] = hzws["c" + str(i+1)].value + xhz2.income # hzws["f" + str(i+1)] = zmo if zmo < (xhz.income+xhz2.income) * 0.01 else (xhz.income + xhz2.income) * 0.01 # xunf = True # break # if(xunf): # continue # hzws["g" + str(flxhs)] = "替档" # hzws["a" + str(flxhs)] = xhz2.name # hzws["b" + str(flxhs)] = "日档" + str(xhz2.frequency) + "夜档" + str(xhz2.wfrequency) + "无效档" + str( # xhz2.ffrequency) # hzws["c" + str(flxhs)] = xhz2.income # hzws["d" + str(flxhs)] = jl # hzws["e" + str(flxhs)] = xhz2.dfl # hzws["f" + str(flxhs)] = xhz2.money # hzws["h" + str(flxhs)] = "日档:" + str(xhz2.frequency) + " | 夜档:" + str(xhz2.wfrequency) # else: # hzws["g" + str(flxhs)] = "" # hzws["a" + str(flxhs)] = xhz2.name # hzws["b" + str(flxhs)] = "日档" + str(xhz2.frequency) + "夜档" + str(xhz2.wfrequency) + "无效档" + str( # xhz2.ffrequency) # hzws["c" + str(flxhs)] = xhz2.income # hzws["d" + str(flxhs)] = jl # hzws["e" + str(flxhs)] = xhz2.dfl # hzws["f" + str(flxhs)] = xhz2.money if xhz2.money < xhz2.income * 0.01 else xhz2.income * 0.01 # hzws["h" + str(flxhs)] = "日档:" + str(xhz2.frequency) + " | 夜档:" + str(xhz2.wfrequency) # wb.save(file.name) # return file.name #派单 def PDcalculate(ws,pbs,wb,file): tdpds = {} cd = ws.max_row for index in range(cd): if (ws["c" + str(index + 1)].value != "主持" and ws["c" + str(index + 1)].value != None): # print(ws["b" + str(index + 1)].value, ws["c" + str(index + 1)].value, ws["g" + str(index + 1)].value) zincome = ws["g" + str(index + 1)].value if(zincome==None): zincome=0 zname = ws["c" + str(index + 1)].value.strip() ztiem = ws["b" + str(index + 1)].value.strip() if (pbs.get(zname + ztiem, 0) != 0): pbdx = pbs.get(zname + ztiem) if(pbdx.way == "5r"): pbdx.income = pbdx.income + zincome if(zincome >= 200): pbdx.frequency = 1+pbdx.frequency else: pbdx.ffrequency = 1 + pbdx.ffrequency else: pbdx.income = pbdx.income + zincome if (zincome >= 100): pbdx.frequency = 1 + pbdx.frequency else: pbdx.ffrequency = 1 + pbdx.ffrequency else: if (zname != ""): if (tdpds.get(zname + "替档", 0) != 0): tdpdx = tdpds.get(zname + "替档") tdpdx.income = zincome+tdpdx.income if (zincome >= 200): tdpdx.wfrequency = 1+tdpdx.wfrequency elif (zincome >= 100): tdpdx.frequency = 1+tdpdx.frequency elif (zincome < 100): tdpdx.ffrequency = 1+tdpdx.ffrequency else: tdpdx = presideOverBeantd() tdpdx.name = zname tdpdx.income = zincome if(zincome >= 200): tdpdx.frequency = 0 tdpdx.wfrequency = 1 tdpdx.ffrequency = 0 elif(zincome >= 100): tdpdx.frequency = 1 tdpdx.wfrequency = 0 tdpdx.ffrequency = 0 elif (zincome < 100): tdpdx.frequency = 0 tdpdx.wfrequency = 0 tdpdx.ffrequency = 1 tdpds[zname+"替档"] = tdpdx if '汇总' in wb.sheetnames: print("工作表 '汇总' 已经存在,将不再创建。") hzws = wb['汇总'] # 清空工作表中的所有内容 hzws.delete_rows(1, hzws.max_row) else: # 如果不存在名为'汇总'的工作表,则创建它 hzws = wb.create_sheet(title='汇总') print("创建了名为 '汇总' 的新工作表。") hzws["a1"] = "名称" hzws["b1"] = "档时详情" hzws["c1"] = "主持流水" hzws["d1"] = "福利" hzws["e1"] = "类别" namesz = [] for k,xhz in pbs.items(): for zk,zxhz in tdpds.items(): if(xhz.name == zxhz.name): xhz.income = zxhz.income + xhz.income if(xhz.way == "5r"): xhz.frequency = zxhz.wfrequency+xhz.frequency xhz.ffrequency = zxhz.frequency + zxhz.ffrequency+xhz.ffrequency else: xhz.frequency = zxhz.frequency + zxhz.wfrequency + xhz.frequency xhz.ffrequency = zxhz.ffrequency + xhz.ffrequency namesz.append(zk) for qcname in namesz: print("换挡=======》"+qcname) del tdpds[qcname] flxhs = 1 for k, xhz in pbs.items(): flxhs += 1 myinde = str(flxhs) if (xhz.way == "5r"): xhz.money = xhz.frequency * 5 elif(xhz.way == "10r"): xhz.money = xhz.frequency*10 if(3000<=xhz.income<6500): xhz.money = xhz.money/2 elif(xhz.income<3000): xhz.money = 0 elif(xhz.way == "15r"): xhz.money = xhz.frequency * 15 if (5000 <= xhz.income < 10000): xhz.money = xhz.money / 2 elif (xhz.income < 5000): xhz.money = 0 elif(xhz.way == "提成"): xhz.money = xhz.income * 0.008 if(3= 200): # 判断是否替档 if (pbs.get(zname + ztiem, 0) != 0): # print("不是"+zname+ztiem) pbs.get(zname + ztiem).frequency = pbs.get(zname + ztiem).frequency + 1 pbs.get(zname + ztiem).income = pbs.get(zname + ztiem).income + zincome else: # print("是"+zname+ztiem) if (zname != ""): # 判断是否第一次创建 if (tdpds.get(zname + "替档", 0) != 0): # 判断是否替夜档 if (ztiem != "04:00-06:00" and ztiem != "06:00-08:00"): tdpds.get(zname + "替档").frequency = tdpds.get(zname + "替档").frequency + 1 else: tdpds.get(zname + "替档").wfrequency = tdpds.get(zname + "替档").wfrequency + 1 tdpds.get(zname + "替档").income = tdpds.get(zname + "替档").income + zincome else: pobtd = presideOverBeantd() pobtd.name = zname pobtd.income = zincome pobtd.ffrequency = 0 if (ztiem != "04:00-06:00" and ztiem != "06:00-08:00"): pobtd.frequency = 1 pobtd.wfrequency = 0 else: pobtd.frequency = 0 pobtd.wfrequency = 1 tdpds[zname + "替档"] = pobtd else: if (pbs.get(zname + ztiem, 0) != 0): # print("不是"+zname+ztiem) pbs.get(zname + ztiem).ffrequency = pbs.get(zname + ztiem).ffrequency + 1 pbs.get(zname + ztiem).income = pbs.get(zname + ztiem).income + zincome else: # print("是"+zname+ztiem) if (zname != ""): # 判断是否第一次创建 if (tdpds.get(zname + "替档", 0) != 0): tdpds.get(zname + "替档").ffrequency = tdpds.get(zname + "替档").ffrequency + 1 tdpds.get(zname + "替档").income = tdpds.get(zname + "替档").income + zincome else: pobtd = presideOverBeantd() pobtd.name = zname pobtd.income = zincome pobtd.frequency = 0 pobtd.ffrequency = 1 pobtd.wfrequency = 0 tdpds[zname + "替档"] = pobtd if '汇总' in wb.sheetnames: print("工作表 '汇总' 已经存在,将不再创建。") hzws = wb['汇总'] # 清空工作表中的所有内容 hzws.delete_rows(1, hzws.max_row) else: # 如果不存在名为'汇总'的工作表,则创建它 hzws = wb.create_sheet(title='汇总') print("创建了名为 '汇总' 的新工作表。") hzws["a1"] = "名称" hzws["b1"] = "有效档时" hzws["c1"] = "主持流水" hzws["d1"] = "流水提成" hzws["e1"] = "主持福利" hzws["f1"] = "全部福利" hzws["g1"] = "备注" hzws["h1"] = "主持信息" flxhs = 1 for k, xhz in pbs.items(): flxhs += 1 jl = 0 if (xhz.tiem != "04:00-06:00" and xhz.tiem != "06:00-08:00"): if (xhz.type == 0): xhz.money = xhz.frequency * 20 xhz.dfl = xhz.frequency * 20 elif (xhz.type == "1"): xhz.money = xhz.frequency * 15 xhz.dfl = xhz.frequency * 15 else: if (xhz.type == 0): xhz.money = xhz.frequency * 25 xhz.dfl = xhz.frequency * 25 elif (xhz.type == "1"): xhz.money = xhz.frequency * 20 xhz.dfl = xhz.frequency * 20 if (xhz.type != "1"): jl = jyjl(xhz.income) xhz.money+=jl if (xhz.income < 3000): xhz.money = xhz.money / 2 if (3 < xhz.frequency+xhz.ffrequency < 5): xhz.money = xhz.money / 2 elif (xhz.frequency+xhz.ffrequency <= 3): xhz.money = 0 print(xhz.name, xhz.frequency, xhz.income, xhz.money) hzws["a" + str(flxhs)] = xhz.name hzws["b" + str(flxhs)] = "正常档"+str(xhz.frequency) + "无效档" + str(xhz.ffrequency) hzws["c" + str(flxhs)] = xhz.income hzws["d" + str(flxhs)] = jl hzws["e" + str(flxhs)] = xhz.dfl hzws["f" + str(flxhs)] = xhz.money if xhz.money < xhz.income * 0.01 else xhz.income * 0.01 hzws["g" + str(flxhs)] = "无任务档" if xhz.type == "1" else "" hzws["h" + str(flxhs)] = k for k,xhz2 in tdpds.items(): flxhs += 1 jl = 0 if (xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency <= 3): xhz2.money = xhz2.frequency * 15 + xhz2.wfrequency * 20 xhz2.dfl = xhz2.frequency * 15 + xhz2.wfrequency * 20 else: xhz2.money = xhz2.frequency * 20 + xhz2.wfrequency * 25 xhz2.dfl = xhz2.frequency * 20 + xhz2.wfrequency * 25 jl = jyjl(xhz2.income) xhz2.money += jl if (xhz2.income < 3000): xhz2.money = xhz2.money / 2 if (3 < xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency < 5): xhz2.money = xhz2.money / 2 xunf = False if (xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency <= 3): for i in range(hzws.max_row): if (hzws["a" + str(i + 1)].value == xhz2.name): xhz = pbs.get(hzws["h" + str(i + 1)].value) print(xhz.name) mo = 0 zmo = pdjl(xhz.income + xhz2.income) if (xhz.type != 1): mo = xhz.dfl + xhz2.frequency * 15 + xhz2.frequency * 20 else: mo = xhz.dfl + xhz.frequency * 20 + xhz2.wfrequency * 25 zmo += mo print(xhz.name, zmo) hzws["b" + str(i + 1)] = hzws["b" + str(i + 1)].value + "换档" + str( xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency) hzws["e" + str(i + 1)] = mo hzws["c" + str(i + 1)] = hzws["c" + str(i + 1)].value + xhz2.income hzws["f" + str(i + 1)] = zmo if zmo < (xhz.income + xhz2.income) * 0.01 else ( xhz.income + xhz2.income) * 0.01 xunf = True break if (xunf): continue hzws["g" + str(flxhs)] = "替档" hzws["a" + str(flxhs)] = xhz2.name hzws["b" + str(flxhs)] = "日档" + str(xhz2.frequency) + "夜档" + str(xhz2.wfrequency) + "无效档" + str( xhz2.ffrequency) hzws["c" + str(flxhs)] = xhz2.income hzws["d" + str(flxhs)] = jl hzws["e" + str(flxhs)] = xhz2.dfl hzws["f" + str(flxhs)] = xhz2.money hzws["h" + str(flxhs)] = "日档:" + str(xhz2.frequency) + " | 夜档:" + str(xhz2.wfrequency) else: hzws["g" + str(flxhs)] = "" hzws["a" + str(flxhs)] = xhz2.name hzws["b" + str(flxhs)] = "日档" + str(xhz2.frequency) + "夜档" + str(xhz2.wfrequency) + "无效档" + str( xhz2.ffrequency) hzws["c" + str(flxhs)] = xhz2.income hzws["d" + str(flxhs)] = jl hzws["e" + str(flxhs)] = xhz2.dfl hzws["f" + str(flxhs)] = xhz2.money if xhz2.money < xhz2.income * 0.01 else xhz2.income * 0.01 hzws["h" + str(flxhs)] = "日档:" + str(xhz2.frequency) + " | 夜档:" + str(xhz2.wfrequency) wb.save(file.name) return file.name #大神 def DScalculate(ws, pbs, wb, file): tdpds = {} shoug = {} cd = ws.max_row for index in range(cd): if (ws["c" + str(index + 1)].value != "主持" and ws["c" + str(index + 1)].value != None): print(ws["b" + str(index + 1)].value, ws["c" + str(index + 1)].value, ws["e" + str(index + 1)].value) zincome = ws["e" + str(index + 1)].value sgname = ws["g" + str(index + 1)].value sgz = ws["h" + str(index + 1)].value if(zincome==None): zincome=0 if(sgname!=None): if(sgz!=None): if(5000>sgz>=3000): shoug[sgname] = shoug.get(sgname,0) + sgz*0.001 elif(10000>sgz>=5000): shoug[sgname] = sgz * 0.0012 +shoug.get(sgname,0) elif (30000 > sgz >= 10000): shoug[sgname] = sgz * 0.0018+shoug.get(sgname,0) elif (50000 > sgz >= 30000): shoug[sgname] = sgz * 0.002+shoug.get(sgname,0) elif (100000 > sgz >= 50000): shoug[sgname] = sgz * 0.0025+shoug.get(sgname,0) elif (100000 < sgz): shoug[sgname] = sgz * 0.003+shoug.get(sgname,0) sgname = ws["i" + str(index + 1)].value sgz = ws["j" + str(index + 1)].value if (zincome == None): zincome = 0 if (sgname != None): if (sgz != None): if (5000 > sgz >= 3000): shoug[sgname] = sgz * 0.001+shoug.get(sgname,0) elif (10000 > sgz >= 5000): shoug[sgname] = sgz * 0.0012+shoug.get(sgname,0) elif (30000 > sgz >= 10000): shoug[sgname] = sgz * 0.0018+shoug.get(sgname,0) elif (50000 > sgz >= 30000): shoug[sgname] = sgz * 0.002+shoug.get(sgname,0) elif (100000 > sgz >= 50000): shoug[sgname] = sgz * 0.0025+shoug.get(sgname,0) elif (100000 < sgz): shoug[sgname] = sgz * 0.003+shoug.get(sgname,0) sgname = ws["k" + str(index + 1)].value sgz = ws["l" + str(index + 1)].value if (zincome == None): zincome = 0 if (sgname != None): if (sgz != None): if (5000 > sgz > 3000): shoug[sgname] = sgz * 0.001+shoug.get(sgname,0) elif (10000 > sgz >= 5000): shoug[sgname] = sgz * 0.0012+shoug.get(sgname,0) elif (30000 > sgz >= 10000): shoug[sgname] = sgz * 0.0018+shoug.get(sgname,0) elif (50000 > sgz >= 30000): shoug[sgname] = sgz * 0.002+shoug.get(sgname,0) elif (100000 > sgz >= 50000): shoug[sgname] = sgz * 0.0025+shoug.get(sgname,0) elif (100000 < sgz): shoug[sgname] = sgz * 0.003+shoug.get(sgname,0) zname = ws["c" + str(index + 1)].value.strip() ztiem = ws["b" + str(index + 1)].value.strip() if (zincome >= 100): # 判断是否替档 if (pbs.get(zname + ztiem, 0) != 0): # print("不是"+zname+ztiem) pbs.get(zname + ztiem).frequency = pbs.get(zname + ztiem).frequency + 1 pbs.get(zname + ztiem).income = pbs.get(zname + ztiem).income + zincome else: # print("是"+zname+ztiem) if (zname != ""): # 判断是否第一次创建 if (tdpds.get(zname + "替档", 0) != 0): # 判断是否替夜档 if (ztiem != "04:00-06:00" and ztiem != "06:00-08:00" and ztiem != "02:00-04:00"): tdpds.get(zname + "替档").frequency = tdpds.get(zname + "替档").frequency + 1 else: tdpds.get(zname + "替档").wfrequency = tdpds.get(zname + "替档").wfrequency + 1 tdpds.get(zname + "替档").income = tdpds.get(zname + "替档").income + zincome else: pobtd = presideOverBeantd() pobtd.name = zname pobtd.income = zincome pobtd.ffrequency = 0 if (ztiem != "04:00-06:00" and ztiem != "06:00-08:00" and ztiem != "02:00-04:00"): pobtd.frequency = 1 pobtd.wfrequency = 0 else: pobtd.frequency = 0 pobtd.wfrequency = 1 tdpds[zname + "替档"] = pobtd else: if (pbs.get(zname + ztiem, 0) != 0): # print("不是"+zname+ztiem) pbs.get(zname + ztiem).ffrequency = pbs.get(zname + ztiem).ffrequency + 1 pbs.get(zname + ztiem).income = pbs.get(zname + ztiem).income + zincome else: # print("是"+zname+ztiem) if (zname != ""): # 判断是否第一次创建 if (tdpds.get(zname + "替档", 0) != 0): tdpds.get(zname + "替档").ffrequency = tdpds.get(zname + "替档").ffrequency + 1 tdpds.get(zname + "替档").income = tdpds.get(zname + "替档").income + zincome else: pobtd = presideOverBeantd() pobtd.name = zname pobtd.income = zincome pobtd.frequency = 0 pobtd.ffrequency = 1 pobtd.wfrequency = 0 tdpds[zname + "替档"] = pobtd if '汇总' in wb.sheetnames: print("工作表 '汇总' 已经存在,将不再创建。") hzws = wb['汇总'] # 清空工作表中的所有内容 hzws.delete_rows(1, hzws.max_row) else: # 如果不存在名为'汇总'的工作表,则创建它 hzws = wb.create_sheet(title='汇总') print("创建了名为 '汇总' 的新工作表。") hzws["a1"] = "名称" hzws["b1"] = "有效档时" hzws["c1"] = "主持流水" hzws["d1"] = "流水提成" hzws["e1"] = "主持福利" hzws["f1"] = "全部福利" hzws["g1"] = "备注" hzws["h1"] = "主持信息" hzws["m1"] = "名称" hzws["n1"] = "收光福利" flxhs = 1 for k, xhz in pbs.items(): flxhs += 1 jl = 0 if (xhz.tiem != "04:00-06:00" and xhz.tiem != "06:00-08:00" and xhz.tiem != "02:00-04:00"): xhz.money = xhz.frequency * 10 xhz.dfl = xhz.frequency * 10 else: xhz.money = xhz.frequency * 15 xhz.dfl = xhz.frequency * 15 jl = dsjl(xhz.income) xhz.money += jl if(xhz.income<3000): xhz.money=xhz.money / 2 if (3 < xhz.frequency + xhz.ffrequency < 5): xhz.money = xhz.money / 2 elif (xhz.frequency + xhz.ffrequency <= 3): xhz.money = 0 print(xhz.name, xhz.frequency, xhz.income, xhz.money) hzws["a" + str(flxhs)] = xhz.name hzws["b" + str(flxhs)] ="正常档"+str(xhz.frequency) + "无效档" + str(xhz.ffrequency) hzws["c" + str(flxhs)] = xhz.income hzws["d" + str(flxhs)] = jl hzws["e" + str(flxhs)] = xhz.dfl hzws["f" + str(flxhs)] = xhz.money hzws["h" + str(flxhs)] = k for k, xhz2 in tdpds.items(): flxhs += 1 jl = 0 if (xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency <= 3): xhz2.money = xhz2.frequency * 10 + xhz2.wfrequency * 15 xhz2.dfl = xhz2.frequency * 10 + xhz2.wfrequency * 15 else: xhz2.money = xhz2.frequency * 10 + xhz2.wfrequency * 15 xhz2.dfl = xhz2.frequency * 10 + xhz2.wfrequency * 15 jl = dsjl(xhz2.income) xhz2.money += jl if (xhz2.income < 3000): xhz2.money = xhz2.money / 2 if (3 < xhz2.frequency+ xhz2.ffrequency < 5): xhz2.money = xhz2.money / 2 elif (xhz2.frequency+xhz2.ffrequency <= 3): xhz2.money = 0 xunf = False if (xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency <= 3): for i in range(hzws.max_row): if (hzws["a" + str(i + 1)].value == xhz2.name): xhz = pbs.get(hzws["h" + str(i + 1)].value) mo = 0 zmo = dsjl(xhz.income + xhz2.income) if (xhz.type != 1): mo = xhz.dfl + xhz2.wfrequency * 15 + xhz2.frequency * 10 else: mo = xhz.dfl + xhz2.wfrequency * 12 + xhz2.frequency * 8 zmo += mo print(xhz.name, zmo) hzws["b" + str(i + 1)] = hzws["b" + str(i + 1)].value + "换档" + str( xhz2.frequency + xhz2.wfrequency + xhz2.ffrequency) hzws["e" + str(i + 1)] = mo hzws["d" + str(i + 1)] = dsjl(xhz.income + xhz2.income) hzws["c" + str(i + 1)] = hzws["c" + str(i + 1)].value + xhz2.income hzws["f" + str(i + 1)] = zmo xunf = True break if (xunf): continue hzws["g" + str(flxhs)] = "替档" hzws["a" + str(flxhs)] = xhz2.name hzws["b" + str(flxhs)] = "日档" + str(xhz2.frequency) + "夜档" + str(xhz2.wfrequency) + "无效档" + str( xhz2.ffrequency) hzws["c" + str(flxhs)] = xhz2.income hzws["d" + str(flxhs)] = jl hzws["e" + str(flxhs)] = xhz2.dfl hzws["f" + str(flxhs)] = xhz2.money hzws["h" + str(flxhs)] = "日档:" + str(xhz2.frequency) + " | 夜档:" + str(xhz2.wfrequency) else: hzws["g" + str(flxhs)] = "" hzws["a" + str(flxhs)] = xhz2.name hzws["b" + str(flxhs)] = "日档" + str(xhz2.frequency) + "夜档" + str(xhz2.wfrequency) + "无效档" + str( xhz2.ffrequency) hzws["c" + str(flxhs)] = xhz2.income hzws["d" + str(flxhs)] = jl hzws["e" + str(flxhs)] = xhz2.dfl hzws["f" + str(flxhs)] = xhz2.money hzws["h" + str(flxhs)] = "日档:" + str(xhz2.frequency) + " | 夜档:" + str(xhz2.wfrequency) sgxhs = 1 for k,v in shoug.items(): sgxhs+=1 hzws["m" + str(sgxhs)] = k hzws["n" + str(sgxhs)] = v wb.save(file.name) print(file.name) return file.name def reverse(file,presid,type): wb = openpyxl.load_workbook(file.name) ws = wb.active pbs = {} wz="/tmp/gradio/" print(file.name) files = os.listdir(wz) print("文件信息") # 打印所有文件名 for xfile in files: print("--------------") print(xfile) if(os.path.isdir(wz+xfile)): ftime = time.strftime("%Y-%m-%d", time.localtime(os.stat(wz + xfile).st_ctime)) mtime = time.strftime("%Y-%m-%d", time.localtime(time.time())) print(time.strftime("%Y-%m-%d",time.localtime(os.stat(wz+xfile).st_ctime))) print(time.strftime("%Y-%m-%d",time.localtime(time.time()))) if(ftime!=mtime): shutil.rmtree(wz + xfile) print(ftime,xfile,"移除") for zc in presid.split("\n"): xx = zc.split("\t") pb = presideOverBean() pb.tiem = xx[0].strip() if(xx[1].strip()==""): continue xxx = xx[1].split("-") pb.name = xxx[0].strip() if(len(xxx)>1): pb.way = xxx[1].strip() else: pb.way = "无" pb.income=0 pb.frequency=0 pb.ffrequency = 0 pb.money=0 if(len(xx)>2): pb.type = xx[2].strip() else: pb.type = 0 pbs[pb.name+pb.tiem] = pb for itm in pbs.values(): print(itm.name,itm.tiem,itm.way) if(type=="派单"): print("====================派单") return PDcalculate(ws,pbs,wb,file) elif(type=="交友"): print("====================交友") return JYcalculate(ws,pbs,wb,file) elif (type == "大神"): print("====================大神") return DScalculate(ws,pbs,wb,file) demo = gr.Interface(reverse,inputs=[gr.File(label="打卡表"),gr.Text(label="主持排挡"),gr.Dropdown(["派单", "大神", "交友"], label="选择算法类别")],outputs= "file",) demo.launch()