Алерты
This commit is contained in:
1 parent
1ba8607f40
commit
da0d0b4dcb
8 files changed
+121
-173
No files matched your search
@@ -15,8 +15,8 @@ class PlanCalendarAdmin(admin.ModelAdmin):
|
||||
fields = ('name', 'start_work_period', 'end_work_period')
|
||||
|
||||
class BasePositionAmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'order')
|
||||
list_editable = ('order',)
|
||||
list_display = ('id', 'name', 'order')
|
||||
list_editable = ('order', 'name')
|
||||
|
||||
# admin.site.register(GeneralVacation, GeneralVacationAdmin),
|
||||
admin.site.register(PlanCalendar, PlanCalendarAdmin)
|
||||
|
||||
+38
-100
@@ -23,10 +23,9 @@ class roundExcel():
|
||||
self.df['tabel'] = self.df['login'].str.split('-', expand = True)[1]+self.df['login'].str.split('-', expand = True)[2]
|
||||
file_path = 'media/DailyRoundUp.xlsx'
|
||||
thins = Side(border_style="thin")
|
||||
print(len(self.df), "-------------------------------")
|
||||
ws = self.wb.active
|
||||
filters = ws.auto_filter
|
||||
filters.ref = "A6:L15"
|
||||
filters.ref = "A6:N15"
|
||||
ws.title = "Список"
|
||||
ws['B2'] = 'Список сотрудников'
|
||||
ws['B3'] = 'МИ ФНС России по ЦОД № 2'
|
||||
@@ -45,11 +44,12 @@ class roundExcel():
|
||||
ws['G6'] = 'Отпуск'
|
||||
ws['I6'] = 'Болен'
|
||||
ws['K6'] = 'Удаленка'
|
||||
ws['M6'] = 'Командировка'
|
||||
|
||||
|
||||
|
||||
|
||||
heads =['G6', 'I6', 'K6']
|
||||
heads =['G6', 'I6', 'K6', 'M6']
|
||||
for x in heads:
|
||||
|
||||
ws[x].fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
@@ -62,7 +62,7 @@ class roundExcel():
|
||||
|
||||
numb = 1
|
||||
|
||||
column_widths = [29, 53, 96, 96, 112, 28, 222, 29, 148, 28, 145, 33]
|
||||
column_widths = [29, 53, 96, 96, 112, 28, 222, 29, 148, 28, 145, 33, 148, 28]
|
||||
for i, width in enumerate(column_widths):
|
||||
column_letter = oxl.utils.get_column_letter(i+1)
|
||||
ws.column_dimensions[column_letter].width = self.convert_width(width)
|
||||
@@ -96,7 +96,7 @@ class roundExcel():
|
||||
|
||||
|
||||
|
||||
zap = [7, 9, 11]
|
||||
zap = [7, 9, 11, 13]
|
||||
for x in range(len(l)):
|
||||
k=k+1
|
||||
|
||||
@@ -107,9 +107,7 @@ class roundExcel():
|
||||
ws.cell(row = k, column = 3).value = l.iloc[x]['familyname']
|
||||
ws.cell(row = k, column = 4).value = l.iloc[x]['name']
|
||||
ws.cell(row = k, column = 5).value = l.iloc[x]['parentname']
|
||||
ws.cell(row = k, column = 6).value = '=If(OR(H'+str(k)+'=1, J'+str(k)+'=1, L'+str(k)+'=1,),"",1)'
|
||||
# '=If(H'+str(k)+'=1,IF(J'+str(k)+',IF(L'+str(k)+',"",1)))'
|
||||
|
||||
ws.cell(row = k, column = 6).value = '=If(OR(H'+str(k)+'=1, J'+str(k)+'=1, L'+str(k)+'=1, N'+str(k)+'=1),"",1)'
|
||||
|
||||
for h in zap:
|
||||
ws.cell(row = k, column = h).border = Border(top=thins, bottom=thins, left=thins, right=thins)
|
||||
@@ -126,46 +124,25 @@ class roundExcel():
|
||||
|
||||
k=k+1
|
||||
|
||||
ws.cell(row = k+1, column=6).value = len(self.df)
|
||||
# "=SUM(F6:F"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=6).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=6).font = Font(name='Times New Roman', size=13, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=7).value = "ВСЕГО отпуск="
|
||||
ws.cell(row = k+1, column=7).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=7).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=8).value = "=SUM(H6:H"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=8).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=8).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=9).value = "Всего больных="
|
||||
ws.cell(row = k+1, column=9).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=9).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=10).value = "=SUM(J6:J"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=10).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=10).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=11).value = "Всего удаленка="
|
||||
ws.cell(row = k+1, column=11).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=11).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
ws.cell(row = k+1, column=12).value = "=SUM(L6:L"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=12).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=12).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
# ws.cell(row = k+3, column=5).value = "ИТОГО"
|
||||
# ws.cell(row = k+3, column=5).font = Font(name='Times New Roman', size=14, bold=True)
|
||||
|
||||
# ws.cell(row = k+3, column=7).value = "факт работающих"
|
||||
# ws.cell(row = k+3, column=7).font = Font(name='Times New Roman', size=14, bold=True)
|
||||
col=6
|
||||
ws.cell(row = k+1, column=col).value = len(self.df)
|
||||
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=13, bold=True)
|
||||
|
||||
|
||||
# ws.cell(row = k+3, column=8).value = f"=F{k+1}-H{k+1}-J{k+1}-L{k+1}"
|
||||
# ws.cell(row = k+3, column=8).font = Font(name='Times New Roman', size=14, bold=True)
|
||||
|
||||
|
||||
col+=1
|
||||
ws.cell(row = k+1, column=col).value = "ВСЕГО отпуск="
|
||||
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
col+=1
|
||||
ws.cell(row = k+1, column=col).value = "=SUM(H6:H"+str(k-1)+")"
|
||||
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
val = ["Всего больных=", "=SUM(J6:J"+str(k-1)+")", "Всего удаленка=", "=SUM(L6:L"+str(k-1)+")", "Всего в командировке=", "=SUM(N6:N"+str(k-1)+")"]
|
||||
for x in val:
|
||||
col+=1
|
||||
self.resultpos(ws, x, k, col)
|
||||
|
||||
self.wb.save(file_path)
|
||||
return file_path
|
||||
@@ -177,57 +154,16 @@ class roundExcel():
|
||||
PIXELS_PER_CHAR = 7
|
||||
return (width) / PIXELS_PER_CHAR
|
||||
|
||||
def resultpos(self, ws, value, k, col):
|
||||
# Строка 88 подведение итогов
|
||||
ws.cell(row = k+1, column=col).value = value
|
||||
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
|
||||
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=10, bold=True)
|
||||
|
||||
def excelvacation(self):
|
||||
|
||||
print('helooooooooooooooooooooooooooooooooooooo')
|
||||
# def excroundread(self):
|
||||
# file = request.data['dailyfiles']
|
||||
# ed = pd.read_excel(file)
|
||||
# df = pd.DataFrame(ed)
|
||||
|
||||
# datas = df.columns[8].split(" ")[1]
|
||||
|
||||
|
||||
# df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
|
||||
# df=df.iloc[6:]
|
||||
# df= df[df.b.notna()]
|
||||
# df= df[df.a.notna()]
|
||||
# df['b']=df['b'].str[-3:]
|
||||
# df=df[['b', 'f', 'h', 'j','l']]
|
||||
|
||||
# df['b'] = df['b'].astype(int)
|
||||
|
||||
# types = ['f', 'h', 'j','l']
|
||||
# for n in types:
|
||||
# df[n] = df[n].fillna(0)
|
||||
# df[n] = df[n].astype(int)
|
||||
|
||||
# df3 = pd.merge(df, dfuser, left_on= 'b', right_on="id")
|
||||
# df3=df3[['login', 'f', 'h', 'j','l']]
|
||||
|
||||
|
||||
|
||||
# for ind in df3.index:
|
||||
# keys = ''
|
||||
# if df3['h'][ind] == 1:
|
||||
# keys = 4 # В отпуске
|
||||
# elif df3['j'][ind] == 1:
|
||||
# keys = 5 # Болен
|
||||
# elif df3['l'][ind] == 1:
|
||||
# keys = 2 # Удаленка
|
||||
# elif df3['f'][ind] == 1:
|
||||
# keys = 1 # На работе
|
||||
# else:
|
||||
# keys = 6
|
||||
# base=BasePosition.objects.get(pk=keys)
|
||||
# DailyRoundUp.objects.update_or_create(todaysDate=datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'),
|
||||
# user=df3['login'][ind], defaults={'position':base})
|
||||
|
||||
# pos = DailyRoundUp.objects.values('position__name', 'position').filter(position=6,todaysDate=date.today()).annotate(Count('user'))
|
||||
|
||||
|
||||
|
||||
# mess = "Файл загружен"
|
||||
|
||||
class loadExcel():
|
||||
def __init__(self, us, files):
|
||||
@@ -241,22 +177,22 @@ class loadExcel():
|
||||
df = pd.DataFrame(ed)
|
||||
datas = df.columns[8].split(" ")[1]
|
||||
|
||||
df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
|
||||
df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"]
|
||||
df=df.iloc[6:]
|
||||
df= df[df.b.notna()]
|
||||
df= df[df.a.notna()]
|
||||
df['b']=df['b'].str[-3:]
|
||||
df=df[['b', 'f', 'h', 'j','l']]
|
||||
df=df[['b', 'f', 'h', 'j','l', 'n']]
|
||||
|
||||
df['b'] = df['b'].astype(int)
|
||||
|
||||
types = ['f', 'h', 'j','l']
|
||||
types = ['f', 'h', 'j','l', 'n']
|
||||
for n in types:
|
||||
df[n] = df[n].fillna(0)
|
||||
df[n] = df[n].astype(int)
|
||||
|
||||
df3 = pd.merge(df, self.dfuser, left_on= 'b', right_on="id")
|
||||
df3=df3[['login', 'f', 'h', 'j','l']]
|
||||
df3=df3[['login', 'f', 'h', 'j','l','n']]
|
||||
|
||||
for ind in df3.index:
|
||||
|
||||
@@ -265,10 +201,12 @@ class loadExcel():
|
||||
keys = 4 # В отпуске
|
||||
elif df3['j'][ind] == 1:
|
||||
keys = 5 # Болен
|
||||
elif df3['l'][ind] == 1:
|
||||
keys = 2 # Удаленка
|
||||
elif df3['f'][ind] == 1:
|
||||
keys = 1 # На работе
|
||||
elif df3['l'][ind] == 1:
|
||||
keys = 2 # Удаленка
|
||||
elif df3['n'][ind] == 1:
|
||||
keys = 3 # Командировка
|
||||
else:
|
||||
keys = 6
|
||||
base=BasePosition.objects.get(pk=keys)
|
||||
|
||||
@@ -63,17 +63,16 @@ class DailyRoundUpAPIView(APIView):
|
||||
|
||||
|
||||
def post(self, request):
|
||||
print('----------ssssssssssssssssssssssssssssss-------------------------')
|
||||
user = DictEmployee.objects.filter(deleted=0).values('login', 'id', 'fio')
|
||||
print(user, '----------ddsfsdfds-------------------------')
|
||||
re = loadExcel(user, request.data['dailyfiles'])
|
||||
pos=''
|
||||
mess = 'Файл не найден'
|
||||
|
||||
try:
|
||||
getattr(re, request.GET.get("excel"))()
|
||||
|
||||
mess = 'Файл загружен'
|
||||
except Exception as e:
|
||||
print(e, '-----------------------------')
|
||||
mess = 'Файл не найден'
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user