Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
21_22-J 31
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 31
21_22-J 31
Commits
d971a0d5
Commit
d971a0d5
authored
Jul 24, 2022
by
chalaka78
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
email notification part completed
parent
2e73ef9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
54 deletions
+137
-54
Data/MaintainData.csv
Data/MaintainData.csv
+21
-18
User/views.py
User/views.py
+89
-15
db.sqlite3
db.sqlite3
+0
-0
templates/Admin/NextMaintain.html
templates/Admin/NextMaintain.html
+27
-21
No files found.
Data/MaintainData.csv
View file @
d971a0d5
...
...
@@ -98,7 +98,7 @@ Date,Service,ServiceName,TakenTime,Price,Customer,VehicleType,VehicleMake,Vehicl
1/6/2019,1,Full Service,140,8500,98,Motor Car,LAND ROVER,RANGE ROVER,CAR-8888,30045,2015,,lalithfonseka@gmail.com
1/6/2013,1,Full Service,130,3500,99,Motor Car,MERCEDES BENZ,CLS350,CAA-1111,4035,2011,,sugaththilakarathne@gmail.com
1/6/2010,1,Full Service,70,2500,100,Dual Purpose Vehicle,MITSUBISHI,L200-DIAMOND,PD-4932,2239,2008,,maheshsamarakoon@gmail.com
6/2/201
8,1,Full Service,30,1750,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG -
6466,38010,2011,570,nbachalaka@gmail.com
6/2/201
4,1,Full Service,30,1750,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-
6466,38010,2011,570,nbachalaka@gmail.com
12/24/2012,2,Full Service,45,3750,1,Motor Car,TOYOTA,IST UA-NCP60,KA-5010,63644,2002,592,nbachalaka@gmail.com
2/8/2014,1,Full Service,60,3700,3,Dual Purpose Vehicle,TOYOTA,HIACE,254-0119,79100,1994,1100,sarathjay@gmail.com
9/20/2016,1,Full Service,60,3850,4,Motor Car,SUZUKI,DAA-MH44s WAGONR,CAR-1325,4094,2014,358,sankasilva@gmail.com
...
...
@@ -227,21 +227,22 @@ Date,Service,ServiceName,TakenTime,Price,Customer,VehicleType,VehicleMake,Vehicl
11/24/2009,1,Full Service,110,3100,113,Dual Purpose Vehicle,TOYOTA,KR-KDH200V HIACE,PF-2030,9997,2007,529,dilithmahanama@gmail.com
8/25/2020,1,Full Service,85,5200,114,Dual Purpose Vehicle,MAHINDRA,MAXXIMO,PR-3322,78153,2011,1129,sadunkumara@gmail.com
12/26/2019,1,Full Service,90,5500,115,Motor Car,M.G,MG ZS1.0T AT TL3,CBD-4525,28795,2018,745,anuramapa34@gmail.com
12/3/2018,1,Full Service,30,1750,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,41430,2011,570,nbachalaka@gmail.com
6/4/2019,1,Full Service,30,1800,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,44550,2011,520,nbachalaka@gmail.com
12/5/2019,1,Full Service,30,1850,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,48084,2011,589,nbachalaka@gmail.com
6/6/2020,1,Full Service,30,1900,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,51732,2011,608,nbachalaka@gmail.com
12/4/2020,1,Full Service,30,1950,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,55122,2011,565,nbachalaka@gmail.com
6/6/2021,1,Full Service,30,2000,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,58896,2011,629,nbachalaka@gmail.com
12/9/2021,1,Full Service,30,2050,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,62268,2011,562,nbachalaka@gmail.com
6/6/2022,1,Full Service,30,2100,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,66672,2011,722,nbachalaka@gmail.com
11/3/2022,1,Full Service,30,2150,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,70404,2011,622,nbachalaka@gmail.com
6/4/2019,1,Full Service,30,2200,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,41430,2011,570,nbachalaka@gmail.com
12/5/2019,1,Full Service,30,2250,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,44550,2011,520,nbachalaka@gmail.com
6/6/2020,1,Full Service,30,2300,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,48084,2011,589,nbachalaka@gmail.com
12/4/2020,1,Full Service,30,2350,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,51732,2011,608,nbachalaka@gmail.com
6/6/2021,1,Full Service,30,2400,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,55122,2011,565,nbachalaka@gmail.com
12/9/2021,1,Full Service,30,2450,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG - 6466,58896,2011,629,nbachalaka@gmail.com
12/3/2014,1,Full Service,30,1750,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,41430,2011,570,nbachalaka@gmail.com
6/4/2015,1,Full Service,30,1800,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,44550,2011,520,nbachalaka@gmail.com
12/5/2015,1,Full Service,30,1850,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,48084,2011,589,nbachalaka@gmail.com
6/6/2016,1,Full Service,30,1900,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,51732,2011,608,nbachalaka@gmail.com
12/4/2016,1,Full Service,30,1950,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,55122,2011,565,nbachalaka@gmail.com
6/6/2017,1,Full Service,30,2000,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,58896,2011,629,nbachalaka@gmail.com
12/9/2017,1,Full Service,30,2050,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,62268,2011,562,nbachalaka@gmail.com
6/6/2018,1,Full Service,30,2100,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,66672,2011,722,nbachalaka@gmail.com
11/3/2018,1,Full Service,30,2150,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,70404,2011,622,nbachalaka@gmail.com
6/4/2019,1,Full Service,30,2200,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,41430,2011,570,nbachalaka@gmail.com
12/5/2019,1,Full Service,30,2250,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,44550,2011,520,nbachalaka@gmail.com
6/6/2020,1,Full Service,30,2300,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,48084,2011,589,nbachalaka@gmail.com
12/4/2020,1,Full Service,30,2350,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,51732,2011,608,nbachalaka@gmail.com
6/6/2021,1,Full Service,30,2400,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,55122,2011,565,nbachalaka@gmail.com
12/9/2021,1,Full Service,30,2450,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,58896,2011,629,nbachalaka@gmail.com
5/8/2022,1,Full Service,30,2500,1,Motor Cycle,BAJAJ,DISCOVER 150-DIS,XG-6466,61786,2011,578,nbachalaka@gmail.com
10/20/2013,2,Full Service,45,3900,1,Motor Car,TOYOTA,IST UA-NCP60,KA-5010,70940,2002,608,nbachalaka@gmail.com
11/28/2014,2,Full Service,45,4150,1,Motor Car,TOYOTA,IST UA-NCP60,KA-5010,78116,2002,598,nbachalaka@gmail.com
8/18/2015,2,Full Service,45,4250,1,Motor Car,TOYOTA,IST UA-NCP60,KA-5010,86612,2002,708,nbachalaka@gmail.com
...
...
@@ -514,5 +515,7 @@ Date,Service,ServiceName,TakenTime,Price,Customer,VehicleType,VehicleMake,Vehicl
10/3/2018,1,Full Service,90,3640,79,Dual Purpose Vehicle,NISSAN,HOMY,254-0040,162349,1995,994,rukshansenevirathne@gmail.com
7/6/2019,1,Full Service,90,3800,79,Dual Purpose Vehicle,NISSAN,HOMY,254-0040,170080,1995,859,rukshansenevirathne@gmail.com
4/17/2020,1,Full Service,90,3950,79,Dual Purpose Vehicle,NISSAN,HOMY,254-0040,178693,1995,957,rukshansenevirathne@gmail.com
10/28/2020,1,Full Service,90,4200,79,Dual Purpose Vehicle,NISSAN,HOMY,254-0040,186925,1995,1029,rukshansenevirathne@gmail.com
7/7/2021,1,Full Service,90,4350,79,Dual Purpose Vehicle,NISSAN,HOMY,254-0040,194683,1995,862,rukshansenevirathne@gmail.com
6/3/2022,1,Full Service,60,4125,3,Dual Purpose Vehicle,TOYOTA,HIACE,254-0119,173252,1994,876,sarathjay@gmail.com
5/15/2022,1,Full Service,160,3100,500,Motor Car,HONDA,DAA-RU3 VEZEL,CAC-6566,1220,2014,200,jayasinghenbact@gmail.com
6/15/2022,1,Full Service,180,3200,500,Motor Car,HONDA,DAA-RU3 VEZEL,CAC-6566,1230,2014,210,jayasinghenbact@gmail.com
7/15/2022,1,Full Service,180,3250,500,Motor Car,HONDA,DAA-RU3 VEZEL,CAC-6566,1250,2014,210,jayasinghenbact@gmail.com
User/views.py
View file @
d971a0d5
...
...
@@ -847,9 +847,9 @@ def Customer_Frequency(request):
#Next Maintain Date
def
NextMaintain
(
request
):
if
request
.
method
==
'POST'
:
myForm
=
MyFormServices
(
request
.
POST
)
#myForm3 = MyForm3(request.POST or None)
#Next Service Date Prediction with logistic Regression
if
myForm
.
is_valid
():
...
...
@@ -857,7 +857,7 @@ def NextMaintain(request):
customerid
=
myForm
.
cleaned_data
[
'customerid'
]
checkValid
=
pd
.
read_csv
(
'Data/MaintainData.csv'
)
checkValid
=
checkValid
[(
checkValid
[
"Customer"
]
==
customerid
)]
print
(
"Validation
----------------------
"
)
print
(
"Validation
Done
"
)
checkValid
=
(
checkValid
.
shape
[
0
])
if
(
checkValid
>
0
):
...
...
@@ -873,7 +873,6 @@ def NextMaintain(request):
df
.
shape
dataset
=
df
.
head
()
# print(dataset)
# do same but attach it to the dataframe
df
[
'a'
]
=
pd
.
to_datetime
(
df
[
'Date'
])
.
diff
()
df
[
'a'
]
=
df
[
'a'
]
.
astype
(
str
)
.
str
.
replace
(
"days"
,
""
)
...
...
@@ -891,14 +890,15 @@ def NextMaintain(request):
print
(
Accuracy
)
MeterReading
=
df
[
'MeterReading'
]
.
mean
()
# print(MeterReading)
new_input
=
[[
28
,
200
,
MeterReading
]]
pred
=
logreg
.
predict
(
new_input
)
pred
=
int
(
pred
)
print
(
"--------------Customer will come after days---------------------"
)
# print(pred)
startdate
=
"10/31/2021"
print
(
"--------------Customer will come on---------------------"
)
# Get most recent date
start_date
=
pd
.
Timestamp
((
df
.
Date
)
.
iloc
[
-
1
])
startdate
=
start_date
.
strftime
(
'
%
Y,
%
d,
%
m'
)
enddate
=
pd
.
to_datetime
(
startdate
)
+
pd
.
DateOffset
(
days
=
pred
)
print
(
enddate
)
...
...
@@ -925,12 +925,11 @@ def NextMaintain(request):
df2
=
df2
[(
df2
[
"Service"
]
==
ServiceType
)]
df
=
df2
[(
df2
[
"VehicleNumber"
]
==
Vnumber
)]
# df.drop('Service','ServiceName','TakenTime','Customer','VehicleType','VehicleMake','VehicleModel','VehicleNumber','MeterReading','VehicleManufacturedYear','AvergeUsage','mailID', axis=1, inplace=True)
df
=
df
.
drop
(
columns
=
[
'Service'
,
'ServiceName'
,
'TakenTime'
,
'Customer'
,
'VehicleType'
,
'VehicleMake'
,
'VehicleModel'
,
'VehicleNumber'
,
'MeterReading'
,
'VehicleManufacturedYear'
,
'AvergeUsage'
,
'mailID'
,
])
df
.
head
()
#
#
Cleaning up the data
# Cleaning up the data
df
.
columns
=
[
"Date"
,
"Price"
]
rrr
=
df
.
head
()
...
...
@@ -940,10 +939,8 @@ def NextMaintain(request):
df
.
set_index
(
'Date'
,
inplace
=
True
)
df
.
head
()
df
.
describe
()
# df.plot()
# plt.show()
##Testing For Stationarity
#Testing For Stationarity
from
statsmodels.tsa.stattools
import
adfuller
test_result
=
adfuller
(
df
[
'Price'
])
...
...
@@ -1002,6 +999,85 @@ def NextMaintain(request):
else
:
form
=
MyFormServices
()
#excel sheet update
if
request
.
method
==
'POST'
and
'send'
in
request
.
POST
:
print
(
"Connect to mail"
)
warnings
.
filterwarnings
(
"ignore"
)
df
=
pd
.
read_csv
(
'Data/MaintainData.csv'
)
df
[
'a'
]
=
pd
.
to_datetime
(
df
[
'Date'
])
.
diff
()
df
[
'a'
]
=
df
[
'a'
]
.
astype
(
str
)
.
str
.
replace
(
"days"
,
""
)
df
[
'a'
]
=
df
[
'a'
]
.
astype
(
str
)
.
str
.
replace
(
"NaT"
,
"30"
)
X
=
df
[[
'TakenTime'
,
'Price'
,
'MeterReading'
]]
y
=
df
[
'a'
]
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
X
,
y
,
test_size
=
0.2
,
random_state
=
0
)
logreg
=
LogisticRegression
()
logreg
.
fit
(
X_train
,
y_train
)
Accuracy
=
logreg
.
score
(
X_test
,
y_test
)
MeterReading
=
df
[
'MeterReading'
]
.
mean
()
TakenTime
=
df
[
'TakenTime'
]
.
mean
()
Price
=
df
[
'Price'
]
.
mean
()
new_input
=
[[
TakenTime
,
Price
,
MeterReading
]]
pred
=
logreg
.
predict
(
X
)
# Assign predicted Dates to dataframe
se
=
pd
.
Series
(
pred
)
df
[
'new_col'
]
=
se
.
values
df
[
'Date'
]
=
pd
.
to_datetime
(
df
[
'Date'
])
df
[
'ComesON'
]
=
df
[
'Date'
]
+
pd
.
to_timedelta
(
df
[
'new_col'
]
.
astype
(
int
),
unit
=
'D'
)
# Get Today Date
from
datetime
import
date
today
=
date
.
today
()
print
(
"Today's Date"
)
print
(
today
)
# dd/mm/YY
d1
=
today
.
strftime
(
"
%
d/
%
m/
%
Y"
)
# 3 days before predicted date
enddate
=
pd
.
to_datetime
(
d1
)
-
pd
.
DateOffset
(
days
=+
3
)
# print(enddate.strftime("%d/%m/%Y"))
print
(
"Date to be"
)
print
(
enddate
)
finalDate
=
enddate
.
strftime
(
"
%
d/
%
m/
%
Y"
)
print
(
finalDate
)
df
=
df
[(
df
[
"ComesON"
]
==
finalDate
)]
print
(
df
)
PredictedComesON
=
df
[
"ComesON"
]
ServiceDate
=
pd
.
to_datetime
(
PredictedComesON
)
-
pd
.
DateOffset
(
days
=-
6
)
PredictedMails
=
df
[
"mailID"
]
.
tolist
()
PredictedComesON
=
ServiceDate
.
tolist
()
PredictedPrice
=
df
[
"Price"
]
.
tolist
()
MailLelemts
=
PredictedMails
+
PredictedComesON
+
PredictedPrice
print
(
MailLelemts
)
from
csv
import
writer
with
open
(
'mail/mail_list.csv'
,
'a'
,
newline
=
''
)
as
f_object
:
writer_object
=
writer
(
f_object
)
writer_object
.
writerow
(
MailLelemts
)
f_object
.
close
()
form
=
MyFormServices
()
Uploaded
=
"Email Excel Sheet Updated!"
return
render
(
request
,
'Admin/NextMaintain.html'
,
{
'form'
:
form
,
'Uploaded'
:
Uploaded
});
return
render
(
request
,
'Admin/NextMaintain.html'
,
{
'form'
:
form
});
...
...
@@ -1016,8 +1092,6 @@ def MaintainData(request):
return
render
(
request
,
'Admin/MaintainData.html'
,
context
);
def
AdminLogin
(
request
):
if
request
.
method
==
'POST'
:
myForm
=
MyForm2
(
request
.
POST
)
...
...
db.sqlite3
View file @
d971a0d5
No preview for this file type
templates/Admin/NextMaintain.html
View file @
d971a0d5
...
...
@@ -5,49 +5,47 @@
<head>
<!-- Font special for pages-->
<link
href=
"https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i"
rel=
"stylesheet"
>
<!-- Main CSS-->
<link
href=
"{% static "
css
/
main
.
css
"
%}"
rel=
"stylesheet"
media=
"all"
>
</head>
<div
class=
" >
<div class="
wrapper
wrapper
0
"
>
<div
style=
"margin-left: 0px;"
class=
"card card-5"
>
<br/><br/>
{% if messages %}
<div
class=
"alert alert-danger"
role=
"alert"
>
{% for message in messages %}
{% for message in messages %}
{% if message.tags %} {% endif %} {{ message }}
{% endfor %}
</div>
</div>
{% endif %}
<div
class=
"card-heading"
>
<h2
class=
"title"
style=
"color:#02111f"
>
NEXT
MAINTAIN DATE PREDICTION
</h2>
<h2
class=
"title"
style=
"color:#02111f"
>
NEXT
SERVICE DATE AND APPROXIMATE PRICE PREDICTION
</h2>
</div>
<div
class=
"card-body"
>
<div
class=
"card-body"
>
<form
action=
"/Admin/NextMaintain/"
method=
"post"
>
{% csrf_token %}
<table
class=
"table table-light"
>
{{form3.as_table}}
<table
class=
"table table-light"
>
{{form3.as_table}}
{{form.as_table}}
</table>
<input
type=
"submit"
value=
"PREDICT"
class=
"btn btn--radius-2 btn"
style=
"background:#02111f"
/>
</form>
<form
method=
"post"
>
{% csrf_token %}
<table
class=
"table table-light"
>
</table>
<input
type=
"submit"
value=
"
NEXT MAINTAIN DATE"
class=
"btn btn--radius-2 btn"
style=
"background:#02111f"
/>
<input
type=
"submit"
value=
"
SEND EMAIL"
name=
"send"
class=
"btn btn--radius-2 btn"
style=
"background:#02111f"
/>
</form>
<br>
{% if d %}
<center>
<div
class=
"alert alert-success"
>
Predicted Date: {{ d }}
...
...
@@ -55,9 +53,8 @@
Approximate Price: {{ forecastedPrice }}
</div>
</center>
</div>
</center>
{% endif %}
<br>
...
...
@@ -65,6 +62,15 @@
{% if Uploaded %}
<center>
<div
class=
"alert alert-success"
>
{{ Uploaded }}
</div>
</center>
{% endif %}
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment