Запись в бд
This commit is contained in:
1 parent
39ca09ce84
commit
b437bfa7b0
2 files changed
+27
-11
No files matched your search
BIN
Binary file not shown.
+27
-11
@@ -232,7 +232,7 @@ class DailyRoundUpAPIView(APIView):
|
||||
|
||||
datas = df.columns[8].split(" ")[1]
|
||||
|
||||
base=BasePosition.objects.get(pk=1)
|
||||
|
||||
|
||||
# DailyRoundUp.objects.update_or_create(todaysDate=datetime.datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'), defaults={'user':self.request.user, 'position':base})
|
||||
df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
|
||||
@@ -240,21 +240,37 @@ class DailyRoundUpAPIView(APIView):
|
||||
df= df[df.b.notna()]
|
||||
df= df[df.a.notna()]
|
||||
df['b']=df['b'].str[-3:]
|
||||
df=df[['b', 'f', 'h', 'j']]
|
||||
df=df[['b', 'f', 'h', 'j','l']]
|
||||
|
||||
df['b'] = df['b'].astype(int)
|
||||
|
||||
# df_right_merge = pd.merge(df, dfuser, how='left', left_on="")
|
||||
print(df.dtypes)
|
||||
print(dfuser.dtypes)
|
||||
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']]
|
||||
# print(df3)
|
||||
df3=df3[['login', 'f', 'h', 'j','l']]
|
||||
|
||||
|
||||
# base=BasePosition.objects.get(pk=keys)
|
||||
|
||||
for ind in df3.index:
|
||||
DailyRoundUp.objects.update_or_create(todaysDate=datetime.datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'), user=df3['login'][ind], defaults={'position':base})
|
||||
# defaults={'user': df3['login'][ind], 'position':base})
|
||||
print(self.request.user, df3['login'][ind])
|
||||
# print(df3['login'][ind], df3['f'][ind], df3['h'][ind], df3['j'][ind])
|
||||
keys = ''
|
||||
if df3['h'][ind] == 1:
|
||||
keys = 4 # В отпуске
|
||||
elif df3['j'][ind] == 1:
|
||||
keys = 5 # Болен
|
||||
elif df3['l'][ind] == 1:
|
||||
keys = 2 # Удаленка
|
||||
else:
|
||||
keys = 6
|
||||
base=BasePosition.objects.get(pk=keys)
|
||||
DailyRoundUp.objects.update_or_create(todaysDate=datetime.datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'),
|
||||
user=df3['login'][ind], defaults={'position':base})
|
||||
|
||||
print(base)
|
||||
|
||||
|
||||
|
||||
return Response('')
|
||||
Reference in new issue
Block a user