Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
aaa22fc4
Commit
aaa22fc4
authored
Apr 08, 2015
by
panos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Executables added for the WorkplanExtraction and the Interface
parent
c945e6ae
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
406 additions
and
0 deletions
+406
-0
dream/KnowledgeExtraction/PilotCases/CapacityStations/CapacityStationsInterface2.exe
...ilotCases/CapacityStations/CapacityStationsInterface2.exe
+0
-0
dream/KnowledgeExtraction/PilotCases/CapacityStations/CapacityStationsInterface2.py
...PilotCases/CapacityStations/CapacityStationsInterface2.py
+216
-0
dream/KnowledgeExtraction/PilotCases/CapacityStations/CapacityStationsInterface_exe.py
...otCases/CapacityStations/CapacityStationsInterface_exe.py
+15
-0
dream/KnowledgeExtraction/PilotCases/CapacityStations/WorkplanExtraction2.exe
...ction/PilotCases/CapacityStations/WorkplanExtraction2.exe
+0
-0
dream/KnowledgeExtraction/PilotCases/CapacityStations/WorkplanExtraction2.py
...action/PilotCases/CapacityStations/WorkplanExtraction2.py
+160
-0
dream/KnowledgeExtraction/PilotCases/CapacityStations/WorkplanExtraction_exe.py
...ion/PilotCases/CapacityStations/WorkplanExtraction_exe.py
+15
-0
No files found.
dream/KnowledgeExtraction/PilotCases/CapacityStations/CapacityStationsInterface2.exe
0 → 100644
View file @
aaa22fc4
File added
dream/KnowledgeExtraction/PilotCases/CapacityStations/CapacityStationsInterface2.py
0 → 100644
View file @
aaa22fc4
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 20 March 2015
@author: Panos
'''
import
Tkinter
as
tk
from
Tkinter
import
*
import
pyodbc
import
tkMessageBox
from
datetime
import
datetime
class
Demo1
(
Frame
):
def
__init__
(
self
):
tk
.
Frame
.
__init__
(
self
)
self
.
pack
()
self
.
master
.
title
(
"CapacityStations Interface"
)
if
not
self
.
checkInsertedProject
():
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'There is no new order inserted in the system, please insert one and try again'
)
label5
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
5
)
label5
.
pack
()
else
:
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'Please follow the instructions to update the system.'
)
label1
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label1
.
pack
()
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'1. Please select order'
)
label2
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label2
.
pack
()
self
.
OrderOption
=
StringVar
()
self
.
OrderOption
.
set
(
None
)
options
=
self
.
checkInsertedProject
()
self
.
ProjectDropDown
=
OptionMenu
(
self
,
self
.
OrderOption
,
*
options
).
pack
()
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'2. Please select the operation'
)
label4
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label4
.
pack
()
self
.
operationOption
=
StringVar
()
self
.
operationOption
.
set
(
None
)
options
=
[
'SMF'
,
'WELD'
,
'CNC'
,
'MCH'
,
'EEP'
,
'PPASB'
,
'PAINT'
,
'ASBTST'
]
self
.
operationDropDown
=
OptionMenu
(
self
,
self
.
operationOption
,
*
options
).
pack
()
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'3. Please click below only once, when you insert a WP_id.
\
n
If you have already clicked, please go to next step no 4'
)
label6
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label6
.
pack
()
self
.
checkBoxVal1
=
IntVar
()
checkBox1
=
Checkbutton
(
self
,
variable
=
self
.
checkBoxVal1
,
text
=
'Click to record the START DATE'
,
height
=
3
,
command
=
self
.
recordStartDate
)
checkBox1
.
pack
()
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'4. Please insert estimated capacity left, to be completed'
)
label6
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label6
.
pack
()
self
.
capleft
=
StringVar
(
None
)
self
.
capacity
=
Entry
(
self
,
textvariable
=
self
.
capleft
)
self
.
capacity
.
pack
()
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'5. Please insert any comments'
)
label2
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label2
.
pack
()
self
.
remark
=
StringVar
(
None
)
self
.
comments
=
Entry
(
self
,
textvariable
=
self
.
remark
)
self
.
comments
.
pack
()
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'6. Please click below only when the operation finished'
)
label6
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label6
.
pack
()
self
.
checkBoxVal2
=
IntVar
()
checkBox
=
Checkbutton
(
self
,
variable
=
self
.
checkBoxVal2
,
text
=
'Click to record the END DATE'
,
height
=
3
,
command
=
self
.
recordEndDate
)
checkBox
.
pack
()
self
.
labelText
=
StringVar
()
self
.
labelText
.
set
(
'7. Please update the system clicking the button below'
)
label6
=
Label
(
self
,
textvariable
=
self
.
labelText
,
height
=
2
)
label6
.
pack
()
self
.
button4
=
Button
(
self
,
text
=
'Update the system'
,
width
=
20
,
command
=
self
.
updateDatabase
)
self
.
button4
.
pack
()
def
recordStartDate
(
self
):
self
.
startdate
=
str
(
datetime
.
now
())
print
self
.
startdate
return
def
recordEndDate
(
self
):
self
.
endDate
=
str
(
datetime
.
now
())
print
self
.
endDate
return
def
checkInsertedProject
(
self
):
cnxn
=
pyodbc
.
connect
(
"Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=bal_database;UID=root;PASSWORD=Pitheos10;"
)
cursor
=
cnxn
.
cursor
()
a
=
cursor
.
execute
(
"""
select Order_id, ProjectName, Status
from orders
"""
)
availableProject
=
[]
for
j
in
range
(
a
.
rowcount
):
#get the next line
ind1
=
a
.
fetchone
()
#and create a dictionary order
if
ind1
.
Status
==
'in progress'
or
ind1
.
Status
==
'accepted'
:
availableProject
.
append
(
ind1
.
Order_id
)
return
availableProject
def
alreadyInsertedWP
(
self
):
cnxn
=
pyodbc
.
connect
(
"Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=bal_database;UID=root;PASSWORD=Pitheos10;"
)
cursor
=
cnxn
.
cursor
()
c
=
cursor
.
execute
(
"""
select WP_id, END_DATE
from production_status
"""
)
listb
=
[]
for
i
in
range
(
c
.
rowcount
):
ind
=
c
.
fetchone
()
if
ind
.
WP_id
:
listb
.
append
(
ind
.
WP_id
)
else
:
continue
return
def
updateDatabase
(
self
):
cnxn
=
pyodbc
.
connect
(
"Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=bal_database;UID=root;PASSWORD=Pitheos10;"
)
cursor
=
cnxn
.
cursor
()
if
self
.
checkBoxVal2
.
get
():
update_order
=
(
"INSERT INTO production_status(`status_id`, `WP_id`, `Operation_Name`, `START_DATE`, `Capacity_left`, `Remarks`,`END_DATE`) VALUES ( ?, ?, ?, ?, ?, ?, ?)"
)
cursor
.
execute
(
"SELECT @@IDENTITY AS ID"
)
order
=
self
.
OrderOption
.
get
()
a
=
cursor
.
execute
(
"""
select WP_id, Order_id
from sequence where Order_id=?
"""
,
order
)
for
j
in
range
(
a
.
rowcount
):
ind2
=
a
.
fetchone
()
lastWP
=
ind2
.
WP_id
b
=
cursor
.
execute
(
"""
select WP_id
from sequence where Operation_Name=? and Order_id=?
"""
,
self
.
operationOption
.
get
(),
order
)
ind4
=
b
.
fetchone
()
status2
=
'finished'
row
=
cursor
.
fetchone
()
WP
=
ind4
[
0
]
order_ref
=
row
.
ID
status1
=
'in progress'
cursor
.
execute
(
update_order
,
(
order_ref
,
WP
,
self
.
operationOption
.
get
(),
str
(
datetime
.
now
()),
self
.
capacity
.
get
(),
self
.
comments
.
get
(),
str
(
datetime
.
now
())
))
if
WP
==
lastWP
:
cursor
.
execute
(
"UPDATE orders SET `Status`=? WHERE Order_id=? "
,
status2
,
order
)
cursor
.
commit
()
self
.
close_window
()
else
:
update_order
=
(
"INSERT INTO production_status(`status_id`, `WP_id`, `Operation_Name`, `START_DATE`, `Capacity_left`, `Remarks`) VALUES ( ?, ?, ?, ?, ?, ?)"
)
cursor
.
execute
(
"SELECT @@IDENTITY AS ID"
)
order
=
self
.
OrderOption
.
get
()
a
=
cursor
.
execute
(
"""
select sequence.WP_id, sequence.Order_id, sequence.Operation_Name
from sequence where Order_id=? and Operation_Name=?
"""
,
order
,
self
.
operationOption
.
get
())
ind3
=
a
.
fetchone
()
WP
=
ind3
.
WP_id
row
=
cursor
.
fetchone
()
order_ref
=
row
.
ID
status1
=
'in progress'
cursor
.
execute
(
update_order
,
(
order_ref
,
WP
,
self
.
operationOption
.
get
(),
str
(
datetime
.
now
()),
self
.
capacity
.
get
(),
self
.
comments
.
get
()))
cursor
.
execute
(
"UPDATE orders SET `Status`=? WHERE Order_id=? "
,
status1
,
order
)
cursor
.
commit
()
self
.
close_window
()
return
def
close_window
(
self
):
self
.
destroy
()
def
main
():
Demo1
().
mainloop
()
if
__name__
==
'__main__'
:
main
()
\ No newline at end of file
dream/KnowledgeExtraction/PilotCases/CapacityStations/CapacityStationsInterface_exe.py
0 → 100644
View file @
aaa22fc4
'''
Created on 17 Jun 2014
@author: Panos
'''
from
distutils.core
import
setup
import
py2exe
setup
(
console
=
[
'C:
\
Eclipsewo
r
kspace
\
d
r
eamgui
\
d
r
eam
\
d
r
eam
\
K
n
owledgeExtraction
\
Pilo
t
Cases
\
C
a
pacityStations
\
C
a
pacityStationsInterface2.py'
],
options
=
{
"py2exe"
:
{
"includes"
:
[
"decimal"
]
}
}
)
\ No newline at end of file
dream/KnowledgeExtraction/PilotCases/CapacityStations/WorkplanExtraction2.exe
0 → 100644
View file @
aaa22fc4
File added
dream/KnowledgeExtraction/PilotCases/CapacityStations/WorkplanExtraction2.py
0 → 100644
View file @
aaa22fc4
'''
Created on 7 Apr 2015
@author: Panos
'''
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
import
xlrd
import
datetime
import
os
import
pyodbc
#Static variables that hold the column's number in Workplan (Excel document - template)
WPColumn
=
11
OrderColumn
=
0
ProjectColumn
=
2
FloorSpaceReq
=
5
DayColumn
=
0
#Method created to extract the required data from the spreadsheet
def
dataExtraction
(
File
):
# loop through all the sheets
for
sheet
in
xls_workbook
.
sheets
():
if
sheet
.
name
==
'Workplan'
:
orderId
=
sheet
.
cell
(
4
,
0
).
value
customer
=
sheet
.
cell
(
4
,
1
).
value
projectName
=
sheet
.
cell
(
4
,
2
).
value
orderDate
=
datetime
.
datetime
.
utcfromtimestamp
((
sheet
.
cell
(
4
,
3
).
value
-
25569
)
*
86400.0
)
dueDate
=
datetime
.
datetime
.
utcfromtimestamp
((
sheet
.
cell
(
4
,
4
).
value
-
25569
)
*
86400.0
)
floorSpace
=
sheet
.
cell
(
4
,
5
).
value
#create a dictionary called workplan with key the order id
workplan
[
orderId
]
=
{}
workplan
[
orderId
][
projectName
]
=
[]
workplan
[
orderId
][
projectName
].
insert
(
0
,
customer
)
workplan
[
orderId
][
projectName
].
insert
(
1
,
orderDate
)
workplan
[
orderId
][
projectName
].
insert
(
2
,
dueDate
)
workplan
[
orderId
][
projectName
].
insert
(
3
,
floorSpace
)
#loop in the rows of the spreadsheet
for
i
in
range
(
4
,
sheet
.
nrows
):
#check and continue the loop if there are WP_ids in column 11.
if
sheet
.
cell
(
i
,
11
).
value
:
wpId
=
sheet
.
cell
(
i
,
11
).
value
partId
=
sheet
.
cell
(
i
,
6
).
value
partType
=
sheet
.
cell
(
i
,
7
).
value
operation
=
sheet
.
cell
(
i
,
8
).
value
capacityRequired
=
sheet
.
cell
(
i
,
9
).
value
if
sheet
.
cell
(
i
,
10
).
value
:
earliestStart
=
datetime
.
datetime
.
utcfromtimestamp
((
sheet
.
cell
(
i
,
10
).
value
-
25569
)
*
86400.0
)
else
:
earliestStart
=
None
workplan
[
orderId
][
wpId
]
=
[]
workplan
[
orderId
][
wpId
].
insert
(
0
,
partId
)
workplan
[
orderId
][
wpId
].
insert
(
1
,
partType
)
workplan
[
orderId
][
wpId
].
insert
(
2
,
operation
)
workplan
[
orderId
][
wpId
].
insert
(
3
,
capacityRequired
)
workplan
[
orderId
][
wpId
].
insert
(
4
,
earliestStart
)
os
.
chdir
(
"C:
\
Use
r
s
\
P
a
nos
\
Docume
n
ts
\
DB_App
r
oach
\
C
a
pacityStations
\
Wo
r
kplans"
)
#create a list that hold the already inserted orders
alreadyInserted
=
[]
#use of the KE tool object to connect to database
cnxn
=
pyodbc
.
connect
(
"Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=bal_database;UID=root;PASSWORD=Pitheos10;"
)
cursor
=
cnxn
.
cursor
()
#loop that searches the files in the given directory
for
fileName
in
os
.
listdir
(
"."
):
print
fileName
#using the xlrd python library, we open the documents
xls_workbook
=
xlrd
.
open_workbook
(
fileName
)
#define Main the first sheet - sheet with the name 'Workplan'
Main
=
xls_workbook
.
sheet_by_name
(
'Workplan'
)
workplan
=
{}
#SQL query to extract data from orders table
check_order
=
cursor
.
execute
(
"""
select Order_id, ProjectName, Customer, Order_date, Due_date,FloorSpaceRequired,Status
from orders
"""
)
#check if rowcount is 0, if it is move on - otherwise go to the else part
if
check_order
.
rowcount
==
0
:
#call the method giving as argument the document
dataExtraction
(
fileName
)
for
i
in
range
(
4
,
Main
.
nrows
):
orderId
=
Main
.
cell
(
4
,
OrderColumn
).
value
projectName
=
Main
.
cell
(
4
,
ProjectColumn
).
value
#Another SQL query to input data this time in the database in orders table
add_order
=
(
"INSERT INTO orders(`id`, `Order_id`, `ProjectName`, `Customer`, `Order_date`, `Due_date`, `FloorSpaceRequired`, `Status`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
)
cursor
.
execute
(
"SELECT @@IDENTITY AS ID"
)
row
=
cursor
.
fetchone
()
order_ref
=
row
.
ID
status
=
'accepted'
#the following data inserted to the the database based on the structure of the query above
cursor
.
execute
(
add_order
,
(
order_ref
,
orderId
,
projectName
,
workplan
[
orderId
][
projectName
][
0
],
workplan
[
orderId
][
projectName
][
1
],
workplan
[
orderId
][
projectName
][
2
],
workplan
[
orderId
][
projectName
][
3
],
status
))
cursor
.
commit
()
#SQL query to input data in the database in sequence table
add_sequence
=
(
"INSERT INTO sequence(`seq_id`, `WP_id`, `Order_id`, `PartCode`, `PartName`, `Operation_Name`, `CapacityRequirement`, `EarliestStart`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) "
)
cursor
.
execute
(
"SELECT seq_id AS ID from sequence"
)
seq_ref
=
row
.
ID
#loop used to insert the required data based on the structure of the above query
for
i
in
range
(
4
,
Main
.
nrows
):
wpId
=
Main
.
cell
(
i
,
WPColumn
).
value
cursor
.
execute
(
add_sequence
,
(
seq_ref
,
wpId
,
orderId
,
workplan
[
orderId
][
wpId
][
0
],
workplan
[
orderId
][
wpId
][
1
],
workplan
[
orderId
][
wpId
][
2
],
workplan
[
orderId
][
wpId
][
3
],
workplan
[
orderId
][
wpId
][
4
]))
cursor
.
commit
()
seq_ref
+=
1
else
:
#follows the logic of the if part
check_order
=
cursor
.
execute
(
"""
select Order_id, ProjectName, Customer, Order_date, Due_date,FloorSpaceRequired
from orders
"""
)
for
j
in
range
(
check_order
.
rowcount
):
#get the next line
ind1
=
check_order
.
fetchone
()
dataExtraction
(
fileName
)
for
i
in
range
(
4
,
Main
.
nrows
):
orderId
=
Main
.
cell
(
4
,
OrderColumn
).
value
projectName
=
Main
.
cell
(
4
,
ProjectColumn
).
value
#check the existence of orderId
if
not
orderId
in
ind1
.
Order_id
:
add_order
=
(
"INSERT INTO orders(`id`, `Order_id`, `ProjectName`, `Customer`, `Order_date`, `Due_date`, `FloorSpaceRequired`, `Status`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
)
cursor
.
execute
(
"SELECT MAX(id)+1 AS ID from orders"
)
row
=
cursor
.
fetchone
()
order_ref
=
row
.
ID
status
=
'accepted'
cursor
.
execute
(
add_order
,
(
order_ref
,
orderId
,
projectName
,
workplan
[
orderId
][
projectName
][
0
],
workplan
[
orderId
][
projectName
][
1
],
workplan
[
orderId
][
projectName
][
2
],
workplan
[
orderId
][
projectName
][
3
],
status
))
cursor
.
commit
()
add_sequence
=
(
"INSERT INTO sequence(`seq_id`, `WP_id`, `Order_id`, `PartCode`, `PartName`, `Operation_Name`, `CapacityRequirement`, `EarliestStart`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) "
)
cursor
.
execute
(
"SELECT MAX(seq_id)+1 AS ID from sequence"
)
row
=
cursor
.
fetchone
()
seq_ref
=
row
.
ID
for
i
in
range
(
4
,
Main
.
nrows
):
wpId
=
Main
.
cell
(
i
,
WPColumn
).
value
cursor
.
execute
(
add_sequence
,
(
seq_ref
,
wpId
,
orderId
,
workplan
[
orderId
][
wpId
][
0
],
workplan
[
orderId
][
wpId
][
1
],
workplan
[
orderId
][
wpId
][
2
],
workplan
[
orderId
][
wpId
][
3
],
workplan
[
orderId
][
wpId
][
4
]))
cursor
.
commit
()
seq_ref
+=
1
else
:
continue
\ No newline at end of file
dream/KnowledgeExtraction/PilotCases/CapacityStations/WorkplanExtraction_exe.py
0 → 100644
View file @
aaa22fc4
'''
Created on 18 Jun 2014
@author: Panos
'''
from
distutils.core
import
setup
import
py2exe
setup
(
console
=
[
'C:
\
Eclipsewo
r
kspace
\
d
r
eamgui
\
d
r
eam
\
d
r
eam
\
K
n
owledgeExtraction
\
Pilo
t
Cases
\
C
a
pacityStations
\
Wo
r
kplanExtraction2.py'
],
options
=
{
"py2exe"
:
{
"includes"
:
[
"decimal"
]
}
}
)
\ No newline at end of file
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